Ngx Sweetalert2 Versions Save

Declarative, reactive, and template-driven SweetAlert2 integration for Angular

v12.3.0

3 months ago

12.3.0 (2024-02-16)

Features

v12.2.0

9 months ago

12.2.0 (2023-07-22)

Features

v12.1.0

1 year ago

12.1.0 (2022-12-09)

Features

v12.0.1

1 year ago

12.0.1 (2022-10-01)

Bug Fixes

  • require Angular >= 14 in peerDependencies (5b9b615)

v12.0.0

1 year ago

12.0.0 (2022-10-01)

  • BREAKING CHANGE: Angular 14 support (b78deca)

BREAKING CHANGES

  • Angular 14 support

v11.0.0

2 years ago

11.0.0 (2022-02-27)

Features

BREAKING CHANGES

  • If you application still uses View Engine, it won't be able to use ngx-sweetalert2. Otherwise please note that the library remains compatible with Angular 12 (Ivy-enabled). This change allows to speed up compilation preparation time on Ivy-enabled apps, and is now recommended by the Angular guidelines.

v10.0.0

3 years ago

10.0.0 (2021-05-15)

BREAKING CHANGES

  • The depracated animation param was removed, please use showClass and hideClass instead.
  showClass: { 
    popup: 'swal2-noanimation', 
    backdrop: 'swal2-noanimation' 
  },
  hideClass: { 
    popup: '', 
    backdrop: '' 
  }

v9.0.0

3 years ago

9.0.0 (2020-12-27)

:arrow_double_up: Required minimal SweetAlert2 version is now ^10.8.0.

:warning: BREAKING CHANGES: A few symbols (properties, methods...) were renamed, inducing breaking changes, so please take a look a the Migration guide section.

Check out our new wiki recipes to use ngx-sweetalert2 better!

What's new

🔟 SweetAlert version 10

Although version 8 could run SweetAlert2 v10, it did not expose new SweetAlert2 APIs concerning the new, optional, Deny button. Attention, version 9 is no longer compatible with SweetAlert2 v9 and prior.

Release notes for SweetAlert v10

✋ New Deny button support

A third button was added alongside the classic Confirm and Cancel ones: Deny. Useful in some UX scenarios, you can now use it with ngx-sweetalert2.

Here are the new @Input properties of SwalComponent (<swal>) controlling it:

  • [showDenyButton]: If set to true, the “Deny” button will be shown, which the user can click on to deny the popup.
  • [denyButtonText]: Use this to change the text on the “Confirm” button.
  • [denyButtonColor]: Use this to change the background color of the "Deny" button.
  • [denyButtonAriaLabel]: Use this to change the aria-label for the “Deny” button.
  • [focusDeny]: Set to true if you want to focus the “Deny” button by default.
  • [preDeny]: Function to execute before denying, may be async (Promise-returning) or sync.

A new @Output, (deny), was added too on both SwalComponent (<swal>) and SwalDirective ([swal]), so you know when the deny button was clicked. Here's an example using all three buttons' outputs, were the user is asked to either save a file, abandon changes (deny), or cancel (do nothing):

<button
  [swal]="{ title: 'Save file as...', input: 'text', showDenyButton: true, denyButtonText: 'Don\'t save', showCancelButton: true }"
  (confirm)="saveFile($event)"
  (deny)="handleDenial()"
  (dismiss)="handleDismiss($event)">

  Save
</button>

Also, a new SwalPortalDirective (*swalPortal) target was added for the deny button:

<ng-container *swalPortal="swalTargets.denyButton">...</ng-container>

:wrench: Added a few new @Inputs from SweetAlert2 v10 onwards

Added the following @Input properties to SwalComponent (<swal>):

  • [iconColor]: Use this to change the color of the icon.
  • [loaderHtml]: Use this to change the HTML content of the loader.
  • [inputLabel]: Input field label.
  • [returnInputValueOnDeny]: If you want to return the input value as result.value when denying the popup, set to true.

Migration guide

:red_circle: Rename SwalComponent and SwalDirective output (cancel) to (dismiss)

To match current SweetAlert2 terminology, we renamed the (cancel) @Output() to (dismiss) on both the component and the directive:

<button 
  [swal]="[...]"
-  (cancel)="handler()">
+  (dismiss)="handler()">
<swal 
-  (cancel)="handler()">
+  (dismiss)="handler()">

:red_circle: Rename SwalComponent method .dimiss() to .close()

To match current SweetAlert2 terminology, we renamed the SwalComponent (<swal>) .dimiss() method:

class MyComponent {
  @ViewChild('mySwal')
  public mySwal!: SwalComponent;

  public doSomething(): void {
-    this.mySwal.dismiss();
+    this.mySwal.close();
  }
}

:red_circle: Rename modal lifecycle hooks

SweetAlert2 v10 modal lifecycle hooks have been renamed for a much more coherent naming scheme, so we renamed our @Outputs too.

<swal
-  (beforeOpen)="handler()"
+  (willOpen)="handler()"

-  (open)="handler()"
+  (didOpen)="handler()"

-  (render)="handler()"
+  (didRender)="handler()"

-  (close)="handler()"
+  (willClose)="handler()"

-  (afterClose)="handler()"
+  (didClose)="handler()"

-  (destroy)="handler()">
+  (didDestroy)="handler()">
</swal>

:red_circle: Rename modal lifecycle event interfaces names

If you use modal lifecycle event interfaces in your modal lifecycle output handlers, you will again have to rename them to match the new naming scheme:

class MyComponent {
-  public myBeforeOpenHandler(event: BeforeOpenEvent): void {
+  public myWillOpenHandler(event: WillOpenEvent): void {
  }

-  public myOpenHandler(event: OpenEvent): void {
+  public myDidOpenHandler(event: DidOpenEvent): void {
  }

-  public myRenderHandler(event: RenderEvent): void {
+  public myDidRenderHandler(event: DidRenderEvent): void {
  }

-  public myCloseHandler(event: CloseEvent): void {
+  public myWillCloseHandler(event: WillCloseEvent): void {
  }
}

v8.1.1

3 years ago

8.1.1 (2020-06-18)

:arrow_double_up: Required minimal SweetAlert2 version is ^9.14.4.

Improvements (refactor)

  • ngx-sweetalert2 uses new types provided by sweetalert2 for better type safety (thanks @rafaelss95)

Bug Fixes

  • package: fix Angular version requirement (6f868d1)

v8.1.0

4 years ago

8.1.0 (2020-04-10)

Features

  • SwalComponent: allow user to pass native hooks as well (fixes #159) (72699d3)