From f0a77abaece496d3b6158809abd423ee78a9b7b8 Mon Sep 17 00:00:00 2001 From: KHOUBZA Younes Date: Sat, 9 Jan 2021 08:17:47 +0100 Subject: [PATCH] addoptions to flasher libraries builders --- src/Noty/Prime/.phpstorm.meta.php | 13 +- src/Noty/Prime/NotyBuilder.php | 81 +- .../DependencyInjection/Configuration.php | 2 +- src/Notyf/Prime/.phpstorm.meta.php | 4 + src/Notyf/Prime/NotyfBuilder.php | 59 + src/Pnotify/Prime/.phpstorm.meta.php | 12 + src/Pnotify/Prime/PnotifyBuilder.php | 426 ++++++ src/Prime/.phpstorm.meta.php | 11 +- .../Resources/public/flasher-sweet-alert.js | 8 +- src/SweetAlert/Prime/.phpstorm.meta.php | 9 + src/SweetAlert/Prime/SweetAlertBuilder.php | 1152 +++++++++++++++++ .../DependencyInjection/Configuration.php | 19 +- .../Resources/public/flasher-sweet-alert.js | 8 +- src/Symfony/Resources/assets/package.json | 14 + .../Resources/views/tailwindcss.html.twig | 16 +- .../Resources/views/tailwindcss_bg.html.twig | 10 +- .../Resources/views/tailwindcss_r.html.twig | 53 + src/Toastr/Prime/.phpstorm.meta.php | 10 +- src/Toastr/Prime/ToastrBuilder.php | 36 +- 19 files changed, 1879 insertions(+), 64 deletions(-) create mode 100644 src/Symfony/Resources/assets/package.json create mode 100644 src/Symfony/Resources/views/tailwindcss_r.html.twig diff --git a/src/Noty/Prime/.phpstorm.meta.php b/src/Noty/Prime/.phpstorm.meta.php index 400d7b42..48437bdf 100644 --- a/src/Noty/Prime/.phpstorm.meta.php +++ b/src/Noty/Prime/.phpstorm.meta.php @@ -2,8 +2,11 @@ namespace PHPSTORM_META; -use Flasher\Noty\Prime\NotyBuilder; - -expectedArguments(NotyBuilder::showMethod(), 1, ['fadeIn', 'slideDown', 'show']); -expectedArguments(NotyBuilder::showEasing(), 1, ['swing', 'linear']); -expectedArguments(NotyBuilder::positionClass(), 1, ['toast-top-right', 'toast-top-center', 'toast-bottom-center', 'toast-top-full-width', 'toast-bottom-full-width', 'toast-top-left', 'toast-bottom-right', 'toast-bottom-left']); +expectedArguments(\Flasher\Noty\Prime\NotyBuilder::layout(), 0, 'top', 'topLeft', 'topCenter', 'topRight', 'center', 'centerLeft', 'centerRight', 'bottom', 'bottomLeft', 'bottomCenter', 'bottomRight'); +expectedArguments(\Flasher\Noty\Prime\NotyBuilder::theme(), 0, 'relax', 'mint', 'metroui'); +expectedArguments(\Flasher\Noty\Prime\NotyBuilder::timeout(), 0, false, 1000, 3000, 3500, 5000); +expectedArguments(\Flasher\Noty\Prime\NotyBuilder::closeWith(), 0, 'click', 'button', array('click', 'button')); +expectedArguments(\Flasher\Noty\Prime\NotyBuilder::animation(), 0, 'open', 'close'); +expectedArguments(\Flasher\Noty\Prime\NotyBuilder::sounds(), 0, 'sources', 'volume', 'conditions'); +expectedArguments(\Flasher\Noty\Prime\NotyBuilder::docTitle(), 0, 'conditions'); +expectedArguments(\Flasher\Noty\Prime\NotyBuilder::queue(), 0, 'global'); diff --git a/src/Noty/Prime/NotyBuilder.php b/src/Noty/Prime/NotyBuilder.php index 1385a71a..4ee8a8fa 100644 --- a/src/Noty/Prime/NotyBuilder.php +++ b/src/Noty/Prime/NotyBuilder.php @@ -7,6 +7,8 @@ use Flasher\Prime\Notification\NotificationBuilder; final class NotyBuilder extends NotificationBuilder { /** + * This string can contain HTML too. But be careful and don't pass user inputs to this parameter. + * * @param string $text * * @return NotyBuilder @@ -28,6 +30,9 @@ final class NotyBuilder extends NotificationBuilder } /** + * top, topLeft, topCenter, topRight, center, centerLeft, centerRight, bottom, bottomLeft, bottomCenter, + * bottomRight - ClassName generator uses this value → noty_layout__${layout} + * * @param string $layout * * @return $this @@ -40,6 +45,8 @@ final class NotyBuilder extends NotificationBuilder } /** + * relax, mint, metroui - ClassName generator uses this value → noty_theme__${theme} + * * @param string $theme * * @return $this @@ -52,6 +59,8 @@ final class NotyBuilder extends NotificationBuilder } /** + * false, 1000, 3000, 3500, etc. Delay for closing event in milliseconds (ms). Set 'false' for sticky notifications. + * * @param int|bool $timeout * * @return $this @@ -64,6 +73,8 @@ final class NotyBuilder extends NotificationBuilder } /** + * true, false - Displays a progress bar if timeout is not false. + * * @param bool $progressBar * * @return $this @@ -76,18 +87,23 @@ final class NotyBuilder extends NotificationBuilder } /** - * @param array $closeWith + * click, button + * + * @param string|array $closeWith * * @return $this */ public function closeWith($closeWith) { - $this->option('closeWith', $closeWith); + $this->option('closeWith', (array) $closeWith); return $this; } /** + * If string, assumed to be CSS class name. If null, no animation at all. If function, runs the function. (v3.0.1+) + * You can use animate.css class names or your custom css animations as well. + * * @param string $animation * @param string $effect * @@ -113,6 +129,19 @@ final class NotyBuilder extends NotificationBuilder return $this; } + /** + * @param string $option + * @param mixed $docTitle + * + * @return $this + */ + public function docTitle($option, $docTitle) + { + $this->option('docTitle'.$option, $docTitle); + + return $this; + } + /** * @param bool $modal * @@ -126,6 +155,22 @@ final class NotyBuilder extends NotificationBuilder } /** + * You can use this id with querySelectors. Generated automatically if false. + * + * @param bool|string $id + * + * @return $this + */ + public function id($id) + { + $this->option('id', $id); + + return $this; + } + + /** + * DOM insert method depends on this parameter. If false uses append, if true uses prepend. + * * @param bool $force * * @return $this @@ -138,6 +183,20 @@ final class NotyBuilder extends NotificationBuilder } /** + * @param string $queue + * + * @return $this + */ + public function queue($queue) + { + $this->option('queue', $queue); + + return $this; + } + + /** + * If true closes all visible notifications and shows itself. If string(queueName) closes all visible notification on this queue and shows itself. + * * @param string|bool $killer * * @return $this @@ -150,6 +209,8 @@ final class NotyBuilder extends NotificationBuilder } /** + * Custom container selector string. Like '.my-custom-container'. Layout parameter will be ignored. + * * @param string|bool $container * * @return $this @@ -162,6 +223,8 @@ final class NotyBuilder extends NotificationBuilder } /** + * An array of Noty.button, for creating confirmation dialogs. + * * @param array $buttons * * @return $this @@ -172,4 +235,18 @@ final class NotyBuilder extends NotificationBuilder return $this; } + + /** + * If true Noty uses PageVisibility API to handle timeout. To ensure that users do not miss their notifications. + * + * @param bool $visibilityControl + * + * @return $this + */ + public function visibilityControl($visibilityControl) + { + $this->option('visibilityControl', $visibilityControl); + + return $this; + } } diff --git a/src/Noty/Symfony/DependencyInjection/Configuration.php b/src/Noty/Symfony/DependencyInjection/Configuration.php index e70fabfc..a2edaca4 100644 --- a/src/Noty/Symfony/DependencyInjection/Configuration.php +++ b/src/Noty/Symfony/DependencyInjection/Configuration.php @@ -42,7 +42,7 @@ final class Configuration implements ConfigurationInterface ->defaultValue(array( 'layout' => 'topRight', 'theme' => 'mint', - 'timeout' => false, + 'timeout' => 5000, 'progressBar' => true, 'animation.open' => 'noty_effects_open', 'animation.close' => 'noty_effects_close', diff --git a/src/Notyf/Prime/.phpstorm.meta.php b/src/Notyf/Prime/.phpstorm.meta.php index 55dcbfa4..796f22fc 100644 --- a/src/Notyf/Prime/.phpstorm.meta.php +++ b/src/Notyf/Prime/.phpstorm.meta.php @@ -1,3 +1,7 @@ option('duration', $duration); + + return $this; + } + + /** + * Whether to show the notification with a ripple effect + * + * @param bool $ripple + * + * @return $this + */ + public function ripple($ripple) + { + $this->option('ripple', $ripple); + + return $this; + } + + /** + * Viewport location where notifications are rendered + * + * @param string $position + * @param string $value + * + * @return $this + */ + public function position($position, $value) + { + $option = $this->getEnvelope()->getOption('position', array()); + $option[$position] = $value; + + $this->option('position', $option); + + return $this; + } + + /** + * Whether to allow users to dismiss the notification with a button + * + * @param bool $dismissible + * + * @return $this + */ + public function dismissible($dismissible) + { + $this->option('dismissible', $dismissible); + + return $this; + } } diff --git a/src/Pnotify/Prime/.phpstorm.meta.php b/src/Pnotify/Prime/.phpstorm.meta.php index 55dcbfa4..10ea20ed 100644 --- a/src/Pnotify/Prime/.phpstorm.meta.php +++ b/src/Pnotify/Prime/.phpstorm.meta.php @@ -1,3 +1,15 @@ type('notice', $message, $options); + } + + /** + * The notice's title. + * + * @param bool|string $title + * + * @return $this + */ + public function title($title) + { + $this->option('title', addslashes($title)); + + return $this; + } + + /** + * Whether to escape the content of the title. (Not allow HTML.) + * + * @param bool $titleEscape + * + * @return $this + */ + public function titleEscape($titleEscape = true) + { + $this->option('title_escape', $titleEscape); + + return $this; + } + + /** + * The notice's text. + * + * @param string $text + * + * @return $this + */ + public function text($text) + { + $this->option('text', addslashes($text)); + + return $this; + } + + /** + * @inheritDoc + */ + public function message($message) + { + parent::message($message); + + return $this->text($message); + } + + /** + * Whether to escape the content of the text. (Not allow HTML.) + * + * @param bool $textEscape + * + * @return $this + */ + public function textEscape($textEscape = true) + { + $this->option('text_escape', $textEscape); + + return $this; + } + + /** + * What styling classes to use. (Can be either "brighttheme", "bootstrap3", "fontawesome", or a custom style + * object. See the source in the end of pnotify.js for the properties in a style object.) + * + * @param string $styling + * + * @return $this + */ + public function styling($styling) + { + $this->option('styling', $styling); + + return $this; + } + + /** + * Additional classes to be added to the notice. (For custom styling.) + * + * @param string $addClass + * + * @return $this + */ + public function addClass($addClass) + { + $this->option('addclass', $addClass); + + return $this; + } + + /** + * Class to be added to the notice for corner styling. + * + * @param string $cornerClass + * + * @return $this + */ + public function cornerClass($cornerClass) + { + $this->option('cornerclass', $cornerClass); + + return $this; + } + + /** + * Display the notice when it is created. Turn this off to add notifications to the history without displaying them. + * + * @param bool $autoDisplay + * + * @return $this + */ + public function autoDisplay($autoDisplay = true) + { + $this->option('auto_display', $autoDisplay); + + return $this; + } + + /** + * Width of the notice. + * + * @param int $width + * + * @return $this + */ + public function width($width) + { + $this->option('width', $width); + + return $this; + } + + /** + * Minimum height of the notice. It will expand to fit content. + * + * @param string $minHeight + * + * @return $this + */ + public function minHeight($minHeight) + { + $this->option('minHeight', $minHeight); + + return $this; + } + + /** + * Set icon to true to use the default icon for the selected style/type, false for no icon, or a string for your + * own icon class. + * + * @param bool $icon + * + * @return $this + */ + public function icon($icon = true) + { + $this->option('icon', $icon); + + return $this; + } + + /** + * The animation to use when displaying and hiding the notice. "none" and "fade" are supported through CSS. Others + * are supported through the Animate module and Animate.css. + * + * @param string $animation + * + * @return $this + */ + public function animation($animation) + { + $this->option('animation', $animation); + + return $this; + } + + /** + * Speed at which the notice animates in and out. "slow", "normal", or "fast". Respectively, 400ms, 250ms, 100ms. + * + * @param string $animateSpeed + * + * @return $this + */ + public function animateSpeed($animateSpeed) + { + $this->option('animate_speed', $animateSpeed); + + return $this; + } + + /** + * Display a drop shadow. + * + * @param bool $shadow + * + * @return $this + */ + public function shadow($shadow = true) + { + $this->option('shadow', $shadow); + + return $this; + } + + /** + * After a delay, remove the notice. + * + * @param bool $hide + * + * @return $this + */ + public function hide($hide = true) + { + $this->option('hide', $hide); + + return $this; + } + + /** + * Delay in milliseconds before the notice is removed. + * + * @param int $timer + * + * @return $this + */ + public function timer($timer) + { + $this->option('delay', $timer); + + return $this; + } + + /** + * Reset the hide timer if the mouse moves over the notice. + * + * @param bool $mouseReset + * + * @return $this + */ + public function mouseReset($mouseReset = true) + { + $this->option('mouse_reset', $mouseReset); + + return $this; + } + + /** + * Remove the notice's elements from the DOM after it is removed. + * + * @param bool $remove + * + * @return $this + */ + public function remove($remove = true) + { + $this->option('remove', $remove); + + return $this; + } + + /** + * Change new lines to br tags. + * + * @param bool $insertBrs + * + * @return $this + */ + public function insertBrs($insertBrs = true) + { + $this->option('insert_brs', $insertBrs); + + return $this; + } + + /** + * Whether to remove the notice from the global array when it is closed. + * + * @param bool $destroy + * + * @return $this + */ + public function destroy($destroy = true) + { + $this->option('destroy', $destroy); + + return $this; + } + + /** + * Desktop Module + * + * @param string $desktop + * @param mixed $value + * + * @return $this + */ + public function desktop($desktop, $value) + { + $option = $this->getEnvelope()->getOption('desktop', array()); + $option[$desktop] = $value; + + $this->option('desktop', $option); + + return $this; + } + + /** + * Buttons Module + * + * @param string $buttons + * @param mixed $value + * + * @return $this + */ + public function buttons($buttons, $value) + { + $option = $this->getEnvelope()->getOption('buttons', array()); + $option[$buttons] = $value; + + $this->option('buttons', $option); + + return $this; + } + + /** + * NonBlock Module + * + * @param string $nonblock + * @param mixed $value + * + * @return $this + */ + public function nonblock($nonblock, $value) + { + $option = $this->getEnvelope()->getOption('nonblock', array()); + $option[$nonblock] = $value; + + $this->option('nonblock', $option); + + return $this; + } + + /** + * Mobile Module + * + * @param string $mobile + * @param mixed $value + * + * @return $this + */ + public function mobile($mobile, $value) + { + $option = $this->getEnvelope()->getOption('mobile', array()); + $option[$mobile] = $value; + + $this->option('mobile', $option); + + return $this; + } + + /** + * Animate Module + * + * @param string $animate + * @param mixed $value + * + * @return $this + */ + public function animate($animate, $value) + { + $option = $this->getEnvelope()->getOption('animate', array()); + $option[$animate] = $value; + + $this->option('animate', $option); + + return $this; + } + + /** + * Confirm Module + * + * @param string $confirm + * @param mixed $value + * + * @return $this + */ + public function confirm($confirm, $value) + { + $option = $this->getEnvelope()->getOption('confirm', array()); + $option[$confirm] = $value; + + $this->option('confirm', $option); + + return $this; + } + + /** + * History Module + * + * @param string $history + * @param mixed $value + * + * @return $this + */ + public function history($history, $value) + { + $option = $this->getEnvelope()->getOption('history', array()); + $option[$history] = $value; + + $this->option('history', $option); + + return $this; + } } diff --git a/src/Prime/.phpstorm.meta.php b/src/Prime/.phpstorm.meta.php index d9b2b73d..1bc13539 100644 --- a/src/Prime/.phpstorm.meta.php +++ b/src/Prime/.phpstorm.meta.php @@ -2,15 +2,12 @@ namespace PHPSTORM_META; -use Flasher\Prime\Notification\NotificationBuilderInterface; -use Flasher\Prime\Notification\NotificationInterface; - registerArgumentsSet('notificationTypes', NotificationInterface::TYPE_SUCCESS, NotificationInterface::TYPE_ERROR, NotificationInterface::TYPE_WARNING, NotificationInterface::TYPE_INFO); override(Envelope::get(0), type(0)); -expectedArguments(NotificationBuilderInterface::type(), 1, argumentsSet('notificationTypes')); -expectedArguments(NotificationBuilderInterface::addFlash(), 1, argumentsSet('notificationTypes')); -expectedArguments(NotificationInterface::setType(), 1, argumentsSet('notificationTypes')); +expectedArguments(\Flasher\Prime\Notification\NotificationBuilderInterface::type(), 0, argumentsSet('notificationTypes')); +expectedArguments(\Flasher\Prime\Notification\NotificationBuilderInterface::addFlash(), 0, argumentsSet('notificationTypes')); +expectedArguments(\Flasher\Prime\Notification\NotificationInterface::setType(), 0, argumentsSet('notificationTypes')); -expectedReturnValues(NotificationInterface::getType(), argumentsSet('notificationTypes')); +expectedReturnValues(\Flasher\Prime\Notification\NotificationInterface::getType(), argumentsSet('notificationTypes')); diff --git a/src/SweetAlert/Laravel/Resources/public/flasher-sweet-alert.js b/src/SweetAlert/Laravel/Resources/public/flasher-sweet-alert.js index 74ac20f4..547ce7a6 100644 --- a/src/SweetAlert/Laravel/Resources/public/flasher-sweet-alert.js +++ b/src/SweetAlert/Laravel/Resources/public/flasher-sweet-alert.js @@ -5,14 +5,8 @@ PHPFlasher.addFactory('sweet_alert', (function () { exports.render = function (data) { var notification = data.notification; - var options = { - title: ' ', - text: notification.message, - icon: notification.type, - ...notification.options - } - window.SwalToast.fire(options); + window.SwalToast.fire(notification.options); }; exports.renderOptions = function (options) { diff --git a/src/SweetAlert/Prime/.phpstorm.meta.php b/src/SweetAlert/Prime/.phpstorm.meta.php index 55dcbfa4..374b214b 100644 --- a/src/SweetAlert/Prime/.phpstorm.meta.php +++ b/src/SweetAlert/Prime/.phpstorm.meta.php @@ -1,3 +1,12 @@ icon($type); + + return parent::type($type, $message, $options); + } + + /** + * Display a question typed alert message + * + * @param string $message + * @param array $options + * + * @return SweetAlertBuilder + */ + public function question($message = null, array $options = array()) + { + return $this->type('question', $message, $options); + } + + /** + * The title of the popup, as HTML. + * + * @param string $title + * + * @return $this + */ + public function title($title) + { + $this->option('title', addslashes($title)); + + return $this; + } + + /** + * The title of the popup, as text. Useful to avoid HTML injection. + * + * @param string $titleText + * + * @return $this + */ + public function titleText($titleText) + { + $this->option('titleText', addslashes($titleText)); + + return $this; + } + + /** + * A HTML description for the popup. + * + * [Security] SweetAlert2 does NOT sanitize this parameter. It is the developer's responsibility to escape any user + * input when using the html option, so XSS attacks would be prevented. + * + * @param string $html + * + * @return $this + */ + public function html($html) + { + $this->option('html', $html); + + return $this; + } + + /** + * A description for the popup. If "text" and "html" parameters are provided in the same time, "text" will be used. + * + * @param string $text + * + * @return $this + */ + public function text($text) + { + $this->option('text', addslashes($text)); + + return $this; + } + + /** + * @inheritDoc + */ + public function message($message) + { + parent::message($message); + + return $this->text($message); + } + + /** + * The icon of the popup. SweetAlert2 comes with 5 built-in icon which will show a corresponding icon animation: + * warning, error, success, info, and question. It can either be put in the array under the key "icon" or passed as + * the third parameter of the function. + * + * @param string $icon + * + * @return $this + */ + public function icon($icon) + { + $this->option('icon', $icon); + + return $this; + } + + /** + * Use this to change the color of the icon. + * + * @param string $iconColor + * + * @return $this + */ + public function iconColor($iconColor) + { + $this->option('iconColor', $iconColor); + + return $this; + } + + /** + * The custom HTML content for an icon. + * + * @param string $iconHtml + * + * @return $this + */ + public function iconHtml($iconHtml) + { + $this->option('iconHtml', $iconHtml); + + return $this; + } + + /** + * CSS classes for animations when showing a popup (fade in) + * + * @param string $showClass + * @param string $value + * + * @return $this + */ + public function showClass($showClass, $value) + { + $option = $this->getEnvelope()->getOption('showClass', array()); + $option[$showClass] = $value; + + $this->option('showClass', $option); + + return $this; + } + + /** + * CSS classes for animations when hiding a popup (fade out) + * + * @param string $hideClass + * @param string $value + * + * @return $this + */ + public function hideClass($hideClass, $value) + { + $option = $this->getEnvelope()->getOption('hideClass', array()); + $option[$hideClass] = $value; + + $this->option('hideClass', $option); + + return $this; + } + + /** + * The footer of the popup. Can be either plain text or HTML. + * + * @param string $footer + * + * @return $this + */ + public function footer($footer) + { + $this->option('footer', $footer); + + return $this; + } + + /** + * Whether or not SweetAlert2 should show a full screen click-to-dismiss backdrop. Can be either a boolean or a + * string which will be assigned to the CSS background property. + * + * @param string|bool $backdrop + * + * @return $this + */ + public function backdrop($backdrop = true) + { + $this->option('backdrop', $backdrop); + + return $this; + } + + /** + * Whether or not an alert should be treated as a toast notification. This option is normally coupled with the + * position parameter and a timer. Toasts are NEVER autofocused. + * + * @param bool $toast + * @param string $position + * @param bool $showConfirmButton + * + * @return $this + */ + public function toast($toast = true, $position = 'top-end', $showConfirmButton = false) + { + $this->option('toast', $toast); + $this->position($position); + $this->showConfirmButton($showConfirmButton); + + if (null === $this->getEnvelope()->getOption('title')) { + $this->title(' '); + } + + return $this; + } + + /** + * The container element for adding popup into. + * + * @param string $target + * + * @return $this + */ + public function target($target) + { + $this->option('target', $target); + + return $this; + } + + /** + * Input field type, can be text, email, password, number, tel, range, textarea, select, radio, checkbox, file and + * url. + * + * @param string $input + * + * @return $this + */ + public function input($input) + { + $this->option('input', $input); + + return $this; + } + + /** + * Popup window width, including paddings (box-sizing: border-box). Can be in px or %. The default width is 32rem. + * + * @param string $width + * + * @return $this + */ + public function width($width) + { + $this->option('width', $width); + + return $this; + } + + /** + * Popup window padding. The default padding is 1.25rem. + * + * @param string $padding + * + * @return $this + */ + public function padding($padding) + { + $this->option('padding', $padding); + + return $this; + } + + /** + * Popup window background (CSS background property). The default background is '#fff'. + * + * @param string $background + * + * @return $this + */ + public function background($background) + { + $this->option('background', $background); + + return $this; + } + + /** + * Popup window position, can be 'top', 'top-start', 'top-end', 'center', 'center-start', 'center-end', 'bottom', + * 'bottom-start', or 'bottom-end'. + * + * @param string $position + * + * @return $this + */ + public function position($position) + { + $this->option('position', $position); + + return $this; + } + + /** + * Paired with window position, sets the direction the popup should grow in, can be set to 'row', 'column', + * 'fullscreen', or false. + * + * @param bool|string $grow + * + * @return $this + */ + public function grow($grow) + { + $this->option('grow', $grow); + + return $this; + } + + /** + * A custom CSS class for the popup + * + * @param string $customClass + * @param string $value + * + * @return $this + */ + public function customClass($customClass, $value) + { + $option = $this->getEnvelope()->getOption('customClass', array()); + $option[$customClass] = $value; + + $this->option('customClass', $option); + + return $this; + } + + /** + * Auto close timer of the popup. Set in ms (milliseconds). + * + * @param int $timer + * + * @return $this + */ + public function timer($timer) + { + $this->option('timer', $timer); + + return $this; + } + + /** + * If set to true, the timer will have a progress bar at the bottom of a popup. Mostly, this feature is useful with + * toasts. + * + * @param bool $timerProgressBar + * + * @return $this + */ + public function timerProgressBar($timerProgressBar = true) + { + $this->option('timerProgressBar', $timerProgressBar); + + return $this; + } + + /** + * 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. + * + * @param bool $heightAuto + * + * @return $this + */ + public function heightAuto($heightAuto = true) + { + $this->option('heightAuto', $heightAuto); + + return $this; + } + + /** + * If set to false, the user can't dismiss the popup by clicking outside it. + * You can also pass a custom function returning a boolean value, e.g. if you want to disable outside clicks for + * the loading state of a popup. + * + * @param bool|string $allowOutsideClick + * + * @return $this + */ + public function allowOutsideClick($allowOutsideClick = true) + { + $this->option('allowOutsideClick', $allowOutsideClick); + + return $this; + } + + /** + * If set to false, the user can't dismiss the popup by pressing the Esc key. You can also pass a custom function + * returning a boolean value, e.g. if you want to disable the Esc key for the loading state of a popup. + * + * @param bool|string $allowEscapeKey + * + * @return $this + */ + public function allowEscapeKey($allowEscapeKey = true) + { + $this->option('allowEscapeKey', $allowEscapeKey); + + return $this; + } + + /** + * If set to false, the user can't confirm the popup by pressing the Enter or Space keys, unless they manually + * focus the confirm button. You can also pass a custom function returning a boolean value. + * + * @param bool|string $allowEnterKey + * + * @return $this + */ + public function allowEnterKey($allowEnterKey = true) + { + $this->option('allowEnterKey', $allowEnterKey); + + return $this; + } + + /** + * If set to false, SweetAlert2 will allow keydown events propagation to the document. + * + * @param bool $stopKeydownPropagation + * + * @return $this + */ + public function stopKeydownPropagation($stopKeydownPropagation = true) + { + $this->option('stopKeydownPropagation', $stopKeydownPropagation); + + return $this; + } + + /** + * Useful for those who are using SweetAlert2 along with Bootstrap modals. By default keydownListenerCapture is + * false which means when a user hits Esc, both SweetAlert2 and Bootstrap modals will be closed. Set + * keydownListenerCapture to true to fix that behavior. + * + * @param bool $keydownListenerCapture + * + * @return $this + */ + public function keydownListenerCapture($keydownListenerCapture = true) + { + $this->option('keydownListenerCapture', $keydownListenerCapture); + + return $this; + } + + /** + * If set to false, a "Confirm"-button will not be shown. + * + * @param bool $showConfirmButton + * @param string $confirmButtonText + * @param string $confirmButtonColor + * @param string $confirmButtonAriaLabel + * + * @return $this + */ + public function showConfirmButton($showConfirmButton = true, $confirmButtonText = null, $confirmButtonColor = null, $confirmButtonAriaLabel = null) + { + $this->option('showConfirmButton', $showConfirmButton); + + if (null !== $confirmButtonText) { + $this->confirmButtonText($confirmButtonText); + } + + if (null !== $confirmButtonColor) { + $this->confirmButtonColor($confirmButtonColor); + } + + if (null !== $confirmButtonAriaLabel) { + $this->confirmButtonAriaLabel($confirmButtonAriaLabel); + } + + return $this; + } + + /** + * If set to true, a "Deny"-button will be shown. It can be useful when you want a popup with 3 buttons. + * + * @param bool $showDenyButton + * @param string $denyButtonText + * @param string $denyButtonColor + * @param string $denyButtonAriaLabel + * + * @return $this + */ + public function showDenyButton($showDenyButton = true, $denyButtonText = null, $denyButtonColor = null, $denyButtonAriaLabel = null) + { + $this->option('showDenyButton', $showDenyButton); + + if (null !== $denyButtonText) { + $this->denyButtonText($denyButtonText); + } + + if (null !== $denyButtonColor) { + $this->denyButtonColor($denyButtonColor); + } + + if (null !== $denyButtonAriaLabel) { + $this->denyButtonAriaLabel($denyButtonAriaLabel); + } + + return $this; + } + + /** + * If set to true, a "Cancel"-button will be shown, which the user can click on to dismiss the modal. + * + * @param bool $showCancelButton + * @param string $cancelButtonText + * @param string $cancelButtonColor + * @param string $cancelButtonAriaLabel + * + * @return $this + */ + public function showCancelButton($showCancelButton = true, $cancelButtonText = null, $cancelButtonColor = null, $cancelButtonAriaLabel = null) + { + $this->option('showCancelButton', $showCancelButton); + + if (null !== $cancelButtonText) { + $this->cancelButtonText($cancelButtonText); + } + + if (null !== $cancelButtonColor) { + $this->cancelButtonColor($cancelButtonColor); + } + + if (null !== $cancelButtonAriaLabel) { + $this->cancelButtonAriaLabel($cancelButtonAriaLabel); + } + + return $this; + } + + /** + * Use this to change the text on the "Confirm"-button. + * + * @param string $confirmButtonText + * @param string $confirmButtonColor + * @param string $confirmButtonAriaLabel + * + * @return $this + */ + public function confirmButtonText($confirmButtonText, $confirmButtonColor = null, $confirmButtonAriaLabel = null) + { + $this->option('confirmButtonText', $confirmButtonText); + + if (null !== $confirmButtonColor) { + $this->confirmButtonColor($confirmButtonColor); + } + + if (null !== $confirmButtonAriaLabel) { + $this->confirmButtonAriaLabel($confirmButtonAriaLabel); + } + + return $this; + } + + /** + * Use this to change the text on the "Deny"-button. + * + * @param string $denyButtonText + * @param string $denyButtonColor + * @param string $denyButtonAriaLabel + * + * @return $this + */ + public function denyButtonText($denyButtonText, $denyButtonColor = null, $denyButtonAriaLabel = null) + { + $this->option('denyButtonText', $denyButtonText); + + if (null !== $denyButtonColor) { + $this->denyButtonColor($denyButtonColor); + } + + if (null !== $denyButtonAriaLabel) { + $this->denyButtonAriaLabel($denyButtonAriaLabel); + } + + return $this; + } + + /** + * Use this to change the text on the "Cancel"-button. + * + * @param string $cancelButtonText + * @param string $cancelButtonColor + * @param string $cancelButtonAriaLabel + * + * @return $this + */ + public function cancelButtonText($cancelButtonText, $cancelButtonColor = null, $cancelButtonAriaLabel = null) + { + $this->option('cancelButtonText', $cancelButtonText); + + if (null !== $cancelButtonColor) { + $this->cancelButtonColor($cancelButtonColor); + } + + if (null !== $cancelButtonAriaLabel) { + $this->cancelButtonAriaLabel($cancelButtonAriaLabel); + } + + return $this; + } + + /** + * Use this to change the background color of the "Confirm"-button. The default color is #3085d6 + * + * @param string $confirmButtonColor + * + * @return $this + */ + public function confirmButtonColor($confirmButtonColor) + { + $this->option('confirmButtonColor', $confirmButtonColor); + + return $this; + } + + /** + * Use this to change the background color of the "Deny"-button. The default color is #dd6b55 + * + * @param string $denyButtonColor + * + * @return $this + */ + public function denyButtonColor($denyButtonColor) + { + $this->option('denyButtonColor', $denyButtonColor); + + return $this; + } + + /** + * Use this to change the background color of the "Cancel"-button. The default color is #aaa + * + * @param string $cancelButtonColor + * + * @return $this + */ + public function cancelButtonColor($cancelButtonColor) + { + $this->option('cancelButtonColor', $cancelButtonColor); + + return $this; + } + + /** + * Use this to change the aria-label for the "Confirm"-button. + * + * @param string $confirmButtonAriaLabel + * + * @return $this + */ + public function confirmButtonAriaLabel($confirmButtonAriaLabel) + { + $this->option('confirmButtonAriaLabel', $confirmButtonAriaLabel); + + return $this; + } + + /** + * Use this to change the aria-label for the "Deny"-button. + * + * @param string $denyButtonAriaLabel + * + * @return $this + */ + public function denyButtonAriaLabel($denyButtonAriaLabel) + { + $this->option('denyButtonAriaLabel', $denyButtonAriaLabel); + + return $this; + } + + /** + * Use this to change the aria-label for the "Cancel"-button. + * + * @param string $cancelButtonAriaLabel + * + * @return $this + */ + public function cancelButtonAriaLabel($cancelButtonAriaLabel) + { + $this->option('cancelButtonAriaLabel', $cancelButtonAriaLabel); + + return $this; + } + + /** + * Apply default styling to buttons. If you want to use your own classes (e.g. Bootstrap classes) set this + * parameter to false. + * + * @param bool $buttonsStyling + * + * @return $this + */ + public function buttonsStyling($buttonsStyling = true) + { + $this->option('buttonsStyling', $buttonsStyling); + + return $this; + } + + /** + * Set to true if you want to invert default buttons positions ("Confirm"-button on the right side). + * + * @param bool $reverseButtons + * + * @return $this + */ + public function reverseButtons($reverseButtons = true) + { + $this->option('reverseButtons', $reverseButtons); + + return $this; + } + + /** + * Set to false if you want to focus the first element in tab order instead of "Confirm"-button by default. + * + * @param bool $focusConfirm + * + * @return $this + */ + public function focusConfirm($focusConfirm = true) + { + $this->option('focusConfirm', $focusConfirm); + + return $this; + } + + /** + * Set to true if you want to focus the "Deny"-button by default. + * + * @param bool $focusDeny + * + * @return $this + */ + public function focusDeny($focusDeny = true) + { + $this->option('focusDeny', $focusDeny); + + return $this; + } + + /** + * Set to true if you want to focus the "Cancel"-button by default. + * + * @param bool $focusCancel + * + * @return $this + */ + public function focusCancel($focusCancel = true) + { + $this->option('focusCancel', $focusCancel); + + return $this; + } + + /** + * Set to true to show close button in top right corner of the popup. + * + * @param bool $showCloseButton + * + * @return $this + */ + public function showCloseButton($showCloseButton = true) + { + $this->option('showCloseButton', $showCloseButton); + + return $this; + } + + /** + * Use this to change the content of the close button. + * + * @param string $closeButtonHtml + * + * @return $this + */ + public function closeButtonHtml($closeButtonHtml) + { + $this->option('closeButtonHtml', $closeButtonHtml); + + return $this; + } + + /** + * Use this to change the aria-label for the close button. + * + * @param string $closeButtonAriaLabel + * + * @return $this + */ + public function closeButtonAriaLabel($closeButtonAriaLabel) + { + $this->option('closeButtonAriaLabel', $closeButtonAriaLabel); + + return $this; + } + + /** + * Use this to change the HTML content of the loader. + * + * @param string $loaderHtml + * + * @return $this + */ + public function loaderHtml($loaderHtml) + { + $this->option('loaderHtml', $loaderHtml); + + return $this; + } + + /** + * Set to true to disable buttons and show that something is loading. Use it in combination with the preConfirm + * parameter. + * + * @param bool $showLoaderOnConfirm + * + * @return $this + */ + public function showLoaderOnConfirm($showLoaderOnConfirm = true) + { + $this->option('showLoaderOnConfirm', $showLoaderOnConfirm); + + return $this; + } + + /** + * Set to false to disable body padding adjustment when the page scrollbar gets hidden while the popup is shown + * + * @param bool $scrollbarPadding + * + * @return $this + */ + public function scrollbarPadding($scrollbarPadding = true) + { + $this->option('scrollbarPadding', $scrollbarPadding); + + return $this; + } + + /** + * Function to execute before confirming, may be async (Promise-returning) or sync. + * Returned (or resolved) value can be: + * - false to prevent a popup from closing + * - anything else to pass that value as the result.value of Swal.fire() + * - undefined to keep the default result.value + * + * @param bool|string $preConfirm + * + * @return $this + */ + public function preConfirm($preConfirm) + { + $this->option('preConfirm', $preConfirm); + + return $this; + } + + /** + * Function to execute before denying, may be async (Promise-returning) or sync. + * Returned (or resolved) value can be: + * - false to prevent a popup from closing + * - anything else to pass that value as the result.value of Swal.fire() + * - undefined to keep the default result.value + * + * @param string $preDeny + * + * @return $this + */ + public function preDeny($preDeny) + { + $this->option('preDeny', $preDeny); + + return $this; + } + + /** + * If you want to return the input value as result.value when denying the popup, set to true. Otherwise, the + * denying will set result.value to false. + * + * @param bool $returnInputValueOnDeny + * + * @return $this + */ + public function returnInputValueOnDeny($returnInputValueOnDeny = true) + { + $this->option('returnInputValueOnDeny', $returnInputValueOnDeny); + + return $this; + } + + /** + * Add a customized icon for the popup. Should contain a string with the path or URL to the image. + * + * @param string $imageUrl + * @param int $imageWidth + * @param int $imageHeight + * @param string $imageAlt + * + * @return $this + */ + public function imageUrl($imageUrl, $imageWidth = null, $imageHeight = null, $imageAlt = null) + { + $this->option('imageUrl', $imageUrl); + + if (null !== $imageWidth) { + $this->imageWidth($imageWidth); + } + + if (null !== $imageHeight) { + $this->imageHeight($imageHeight); + } + + if (null !== $imageAlt) { + $this->imageAlt($imageAlt); + } + + return $this; + } + + /** + * If imageUrl is set, you can specify imageWidth to describes image width in px. + * + * @param int $imageWidth + * + * @return $this + */ + public function imageWidth($imageWidth) + { + $this->option('imageWidth', $imageWidth); + + return $this; + } + + /** + * Custom int height in px. + * + * @param string $imageHeight + * + * @return $this + */ + public function imageHeight($imageHeight) + { + $this->option('imageHeight', $imageHeight); + + return $this; + } + + /** + * An alternative text for the custom image icon. + * + * @param string $imageAlt + * + * @return $this + */ + public function imageAlt($imageAlt) + { + $this->option('imageAlt', $imageAlt); + + return $this; + } + + /** + * @param string $title + * @param string $text + * @param string $imageUrl + * @param int $imageWidth + * @param int $imageHeight + * @param string $imageAlt + * + * @return $this + */ + public function image($title, $text, $imageUrl, $imageWidth = 400, $imageHeight = 200, $imageAlt = null) + { + $this->title($title); + $this->text($text); + $this->imageUrl($imageUrl); + $this->imageWidth($imageWidth); + $this->imageHeight($imageHeight); + + if (null !== $imageAlt) { + $this->imageAlt($imageAlt); + } else { + $this->imageAlt($title); + } + + return $this; + } + + /** + * Shortcut to add and flush an image + * + * @param string $title + * @param string $text + * @param string $imageUrl + * @param int $imageWidth + * @param int $imageHeight + * @param string $imageAlt + * + * @return \Flasher\Prime\Envelope + */ + public function addImage($title, $text, $imageUrl, $imageWidth = 400, $imageHeight = 200, $imageAlt = null) + { + $this->image($title, $text, $imageUrl, $imageWidth, $imageHeight, $imageAlt); + + return $this->flash(); + } + + /** + * Input field label. + * + * @param string $inputLabel + * + * @return $this + */ + public function inputLabel($inputLabel) + { + $this->option('inputLabel', $inputLabel); + + return $this; + } + + /** + * Input field placeholder. + * + * @param string $inputPlaceholder + * + * @return $this + */ + public function inputPlaceholder($inputPlaceholder) + { + $this->option('inputPlaceholder', $inputPlaceholder); + + return $this; + } + + /** + * Input field initial value. + * - If the input type is select, inputValue will represent the selected the key. Finally, you + * can also provide a Promise that resolves with one of those types. + * + * @param string $inputOptions + * + * @return $this + */ + public function inputOptions($inputOptions) + { + $this->option('inputOptions', $inputOptions); + + return $this; + } + + /** + * Automatically remove whitespaces from both ends of a result string. Set this parameter to false to disable + * auto-trimming. + * + * @param bool $inputAutoTrim + * + * @return $this + */ + public function inputAutoTrim($inputAutoTrim = true) + { + $this->option('inputAutoTrim', $inputAutoTrim); + + return $this; + } + + /** + * HTML input attributes (e.g. min, max, autocomplete, accept), that are added to the input field. Object keys will + * represent attributes names, object values will represent attributes values. + * + * @param string $inputAttributes + * + * @return $this + */ + public function inputAttributes($inputAttributes) + { + $this->option('inputAttributes', $inputAttributes); + + return $this; + } + + /** + * Validator for input field, may be async (Promise-returning) or sync. + * Returned (or resolved) value can be: + * - a falsy value (undefined, null, false) for indicating success + * - a string value (error message) for indicating failure + * + * @param string $inputValidator + * + * @return $this + */ + public function inputValidator($inputValidator) + { + $this->option('inputValidator', $inputValidator); + + return $this; + } + + /** + * A custom validation message for default validators (email, url). + * + * @param string $validationMessage + * + * @return $this + */ + public function validationMessage($validationMessage) + { + $this->option('validationMessage', $validationMessage); + + return $this; + } } diff --git a/src/SweetAlert/Symfony/DependencyInjection/Configuration.php b/src/SweetAlert/Symfony/DependencyInjection/Configuration.php index 2fd0b380..b3831cac 100644 --- a/src/SweetAlert/Symfony/DependencyInjection/Configuration.php +++ b/src/SweetAlert/Symfony/DependencyInjection/Configuration.php @@ -35,7 +35,6 @@ final class Configuration implements ConfigurationInterface ->arrayNode('styles') ->prototype('scalar')->end() ->defaultValue(array( - 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css', 'https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/10.10.2/sweetalert2.min.css', )) ->end() @@ -43,22 +42,8 @@ final class Configuration implements ConfigurationInterface ->ignoreExtraKeys(false) ->prototype('variable')->end() ->defaultValue(array( - 'timer' => 5000, - 'padding' => '1.25rem', - 'showConfirmButton' => false, - 'showCloseButton' => false, - 'toast' => true, - 'position' => 'top-end', - 'timerProgressBar' => true, - 'animation' => true, - 'showClass' => array( - 'popup' => 'animate__animated animate__fadeInDown', - ), - 'hideClass' => array( - 'popup' => 'animate__animated animate__fadeOutUp', - ), - 'backdrop' => true, - 'grow' => true, + 'timer' => 50000, + 'timerProgressBar' => true, )) ->end() ->end() diff --git a/src/SweetAlert/Symfony/Resources/public/flasher-sweet-alert.js b/src/SweetAlert/Symfony/Resources/public/flasher-sweet-alert.js index 74ac20f4..547ce7a6 100644 --- a/src/SweetAlert/Symfony/Resources/public/flasher-sweet-alert.js +++ b/src/SweetAlert/Symfony/Resources/public/flasher-sweet-alert.js @@ -5,14 +5,8 @@ PHPFlasher.addFactory('sweet_alert', (function () { exports.render = function (data) { var notification = data.notification; - var options = { - title: ' ', - text: notification.message, - icon: notification.type, - ...notification.options - } - window.SwalToast.fire(options); + window.SwalToast.fire(notification.options); }; exports.renderOptions = function (options) { diff --git a/src/Symfony/Resources/assets/package.json b/src/Symfony/Resources/assets/package.json new file mode 100644 index 00000000..28e16b6c --- /dev/null +++ b/src/Symfony/Resources/assets/package.json @@ -0,0 +1,14 @@ +{ + "name": "@php-flasher/flasher", + "description": "Flasher factory adapter for the PHP Flasher library", + "license": "MIT", + "version": "0.1.0", + "scripts": { + "build": "babel src -d dist", + "lint": "eslint src test" + }, + "devDependencies": { + "@babel/core": "^7.12", + "@babel/preset-env": "^7.12" + } +} diff --git a/src/Symfony/Resources/views/tailwindcss.html.twig b/src/Symfony/Resources/views/tailwindcss.html.twig index ab57a3f7..3074b174 100644 --- a/src/Symfony/Resources/views/tailwindcss.html.twig +++ b/src/Symfony/Resources/views/tailwindcss.html.twig @@ -1,36 +1,40 @@ {% if 'success' == envelope.type %} {% set title = 'Success' %} {% set text_color = 'text-green-600' %} + {% set ring_color = 'ring-green-300' %} {% set background_color = 'bg-green-600' %} {% set progress_background_color = 'bg-green-100' %} {% set border_color = 'border-green-600' %} - {% set icon = '' %} + {% set icon = '' %} {% elseif 'error' == envelope.type %} {% set title = 'Error' %} {% set text_color = 'text-red-600' %} + {% set ring_color = 'ring-red-300' %} {% set background_color = 'bg-red-600' %} {% set progress_background_color = 'bg-red-100' %} {% set border_color = 'border-red-600' %} - {% set icon = '' %} + {% set icon = '' %} {% elseif 'warning' == envelope.type %} {% set title = 'Warning' %} {% set text_color = 'text-yellow-600' %} + {% set ring_color = 'ring-yellow-300' %} {% set background_color = 'bg-yellow-600' %} {% set progress_background_color = 'bg-yellow-100' %} {% set border_color = 'border-yellow-600' %} - {% set icon = '' %} + {% set icon = '' %} {% else %} {% set title = 'Info' %} {% set text_color = 'text-blue-600' %} + {% set ring_color = 'ring-blue-300' %} {% set background_color = 'bg-blue-600' %} {% set progress_background_color = 'bg-blue-100' %} {% set border_color = 'border-blue-600' %} - {% set icon = '' %} + {% set icon = '' %} {% endif %} -
+
-
+
{{ icon | raw }}
diff --git a/src/Symfony/Resources/views/tailwindcss_bg.html.twig b/src/Symfony/Resources/views/tailwindcss_bg.html.twig index 6dc98f6f..702e4d87 100644 --- a/src/Symfony/Resources/views/tailwindcss_bg.html.twig +++ b/src/Symfony/Resources/views/tailwindcss_bg.html.twig @@ -4,33 +4,33 @@ {% set background_color = 'bg-green-50' %} {% set progress_background_color = 'bg-green-200' %} {% set border_color = 'border-green-600' %} - {% set icon = '' %} + {% set icon = '' %} {% elseif 'error' == envelope.type %} {% set title = 'Error' %} {% set text_color = 'text-red-700' %} {% set background_color = 'bg-red-50' %} {% set progress_background_color = 'bg-red-200' %} {% set border_color = 'border-red-600' %} - {% set icon = '' %} + {% set icon = '' %} {% elseif 'warning' == envelope.type %} {% set title = 'Warning' %} {% set text_color = 'text-yellow-700' %} {% set background_color = 'bg-yellow-50' %} {% set progress_background_color = 'bg-yellow-200' %} {% set border_color = 'border-yellow-600' %} - {% set icon = '' %} + {% set icon = '' %} {% else %} {% set title = 'Info' %} {% set text_color = 'text-blue-700' %} {% set background_color = 'bg-blue-50' %} {% set progress_background_color = 'bg-blue-200' %} {% set border_color = 'border-blue-600' %} - {% set icon = '' %} + {% set icon = '' %} {% endif %}
-
+
{{ icon | raw }}
diff --git a/src/Symfony/Resources/views/tailwindcss_r.html.twig b/src/Symfony/Resources/views/tailwindcss_r.html.twig new file mode 100644 index 00000000..4227a282 --- /dev/null +++ b/src/Symfony/Resources/views/tailwindcss_r.html.twig @@ -0,0 +1,53 @@ +{% if 'success' == envelope.type %} + {% set title = 'Success' %} + {% set text_color = 'text-green-600' %} + {% set ring_color = 'ring-green-300' %} + {% set background_color = 'bg-green-600' %} + {% set progress_background_color = 'bg-green-100' %} + {% set border_color = 'border-green-600' %} + {% set icon = '' %} +{% elseif 'error' == envelope.type %} + {% set title = 'Error' %} + {% set text_color = 'text-red-600' %} + {% set ring_color = 'ring-red-300' %} + {% set background_color = 'bg-red-600' %} + {% set progress_background_color = 'bg-red-100' %} + {% set border_color = 'border-red-600' %} + {% set icon = '' %} +{% elseif 'warning' == envelope.type %} + {% set title = 'Warning' %} + {% set text_color = 'text-yellow-600' %} + {% set ring_color = 'ring-yellow-300' %} + {% set background_color = 'bg-yellow-600' %} + {% set progress_background_color = 'bg-yellow-100' %} + {% set border_color = 'border-yellow-600' %} + {% set icon = '' %} +{% else %} + {% set title = 'Info' %} + {% set text_color = 'text-blue-600' %} + {% set ring_color = 'ring-blue-300' %} + {% set background_color = 'bg-blue-600' %} + {% set progress_background_color = 'bg-blue-100' %} + {% set border_color = 'border-blue-600' %} + {% set icon = '' %} +{% endif %} + + +
+
+
+ {{ icon | raw }} +
+
+

+ {{ title | trans }} +

+

+ {{ envelope.message }} +

+
+
+
+ +
+
diff --git a/src/Toastr/Prime/.phpstorm.meta.php b/src/Toastr/Prime/.phpstorm.meta.php index 0e38b52c..7a54c0b0 100644 --- a/src/Toastr/Prime/.phpstorm.meta.php +++ b/src/Toastr/Prime/.phpstorm.meta.php @@ -2,8 +2,8 @@ namespace PHPSTORM_META; -use Flasher\Toastr\Prime\ToastrBuilder; - -expectedArguments(ToastrBuilder::showMethod(), 1, ['fadeIn', 'slideDown', 'show']); -expectedArguments(ToastrBuilder::showEasing(), 1, ['swing', 'linear']); -expectedArguments(ToastrBuilder::positionClass(), 1, ['toast-top-right', 'toast-top-center', 'toast-bottom-center', 'toast-top-full-width', 'toast-bottom-full-width', 'toast-top-left', 'toast-bottom-right', 'toast-bottom-left']); +expectedArguments(\Flasher\Toastr\Prime\ToastrBuilder::showMethod(), 0, 'fadeIn', 'fadeOut', 'slideDown', 'show'); +expectedArguments(\Flasher\Toastr\Prime\ToastrBuilder::hideMethod(), 0, 'fadeIn', 'fadeOut', 'slideDown', 'show'); +expectedArguments(\Flasher\Toastr\Prime\ToastrBuilder::showEasing(), 0, 'swing', 'linear'); +expectedArguments(\Flasher\Toastr\Prime\ToastrBuilder::hideEasing(), 0, 'swing', 'linear'); +expectedArguments(\Flasher\Toastr\Prime\ToastrBuilder::positionClass(), 0, 'toast-top-right', 'toast-top-center', 'toast-bottom-center', 'toast-top-full-width', 'toast-bottom-full-width', 'toast-top-left', 'toast-bottom-right', 'toast-bottom-left'); diff --git a/src/Toastr/Prime/ToastrBuilder.php b/src/Toastr/Prime/ToastrBuilder.php index 5eb035b7..b02e1fad 100644 --- a/src/Toastr/Prime/ToastrBuilder.php +++ b/src/Toastr/Prime/ToastrBuilder.php @@ -20,6 +20,8 @@ final class ToastrBuilder extends NotificationBuilder } /** + * enable a close button + * * @param bool $closeButton * * @return $this @@ -68,6 +70,8 @@ final class ToastrBuilder extends NotificationBuilder } /** + * override the close button's HTML. + * * @param string $closeHtml * * @return $this @@ -128,6 +132,8 @@ final class ToastrBuilder extends NotificationBuilder } /** + * In case you want to escape HTML characters in title and message + * * @param bool $escapeHtml * * @return $this @@ -140,6 +146,8 @@ final class ToastrBuilder extends NotificationBuilder } /** + * How long the toast will display after a user hovers over it + * * @param int $extendedTimeOut * * @return $this @@ -212,6 +220,8 @@ final class ToastrBuilder extends NotificationBuilder } /** + * Show newest toast at bottom (top is default) + * * @param bool $newestOnTop * * @return $this @@ -260,6 +270,8 @@ final class ToastrBuilder extends NotificationBuilder } /** + * Rather than having identical toasts stack, set the preventDuplicates property to true. Duplicates are matched to the previous toast based on their message content. + * * @param bool $preventDuplicates * * @return $this @@ -272,6 +284,8 @@ final class ToastrBuilder extends NotificationBuilder } /** + * Visually indicate how long before a toast expires. + * * @param bool $progressBar * * @return $this @@ -296,6 +310,8 @@ final class ToastrBuilder extends NotificationBuilder } /** + * Flip the toastr to be displayed properly for right-to-left languages. + * * @param bool $rtl * * @return $this @@ -368,14 +384,21 @@ final class ToastrBuilder extends NotificationBuilder } /** - * @param int $timeOut + * How long the toast will display without user interaction + * + * @param int $timeOut + * @param int $extendedTimeOut * * @return $this */ - public function timeOut($timeOut) + public function timeOut($timeOut, $extendedTimeOut = null) { $this->option('timeOut', $timeOut); + if (null !== $extendedTimeOut) { + $this->extendedTimeOut($extendedTimeOut); + } + return $this; } @@ -402,4 +425,13 @@ final class ToastrBuilder extends NotificationBuilder return $this; } + + /** + * Prevent from Auto Hiding + */ + public function persistent() + { + $this->timeOut(0); + $this->extendedTimeOut(0); + } }