Skip to content

Commit

Permalink
BREAKING CHANGE: @toverux/ngx-sweetalert2 -> @sweetalert2/ngx-sweetal…
Browse files Browse the repository at this point in the history
…ert2

BREAKING CHANGE: @toverux/ngx-sweetalert2 -> @sweetalert2/ngx-sweetalert2
  • Loading branch information
Limon Monte committed Mar 23, 2019
1 parent 241d76c commit ff5f39b
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 33 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
</p>

<p align="center">
<a href="https://www.npmjs.com/package/@toverux/ngsweetalert2"><img alt="npm version" src="https://img.shields.io/npm/v/@toverux/ngx-sweetalert2.svg?style=flat-square"></a>
<a href="LICENSE"><img alt="license" src="https://img.shields.io/github/license/toverux/ngx-sweetalert2.svg?style=flat-square"></a>
<img alt="npm total downloads" src="https://img.shields.io/npm/dt/@toverux/ngx-sweetalert2.svg?style=flat-square">
<img alt="npm legacy total downloads" src="https://img.shields.io/npm/dt/@toverux/ngsweetalert2.svg?style=flat-square&label=downloads%20(legacy)">
<a href="https://www.npmjs.com/package/@sweetalert2/ngx-sweetalert2"><img alt="npm version" src="https://img.shields.io/npm/v/@sweetalert2/ngx-sweetalert2.svg?style=flat-square"></a>
<a href="LICENSE"><img alt="license" src="https://img.shields.io/github/license/sweetalert2/ngx-sweetalert2.svg?style=flat-square"></a>
<img alt="npm total downloads" src="https://img.shields.io/npm/dt/@sweetalert2/ngx-sweetalert2.svg?style=flat-square">
<img alt="npm legacy total downloads" src="https://img.shields.io/npm/dt/@sweetalert2/ngsweetalert2.svg?style=flat-square&label=downloads%20(legacy)">
</p>

<br>
Expand All @@ -39,15 +39,15 @@ This is not a regular API wrapper for SweetAlert (which already works very well
1) Install _ngx-sweetalert2_ and _sweetalert2_ via the npm registry:

```bash
npm install --save sweetalert2@^7.15.1 @toverux/ngx-sweetalert2
npm install --save sweetalert2 @sweetalert2/ngx-sweetalert2
```

:arrow_double_up: Always upgrade SweetAlert2 when you upgrade ngx-sweetalert2. The latter is statically linked with SweetAlert2's type definitions.

2) Import the module:

```typescript
import { SweetAlert2Module } from '@toverux/ngx-sweetalert2';
import { SweetAlert2Module } from '@sweetalert2/ngx-sweetalert2';

@NgModule({
//=> Basic usage
Expand Down Expand Up @@ -198,7 +198,7 @@ The other cool thing about using a structural directive is that the modal's cont
You just have to change the _target_ of the partial view (_`content`_ is the default target). First, inject this service in your component:

```typescript
import { SwalPartialTargets } from '@toverux/ngx-sweetalert2';
import { SwalPartialTargets } from '@sweetalert2/ngx-sweetalert2';

export class MyComponent {
public constructor(public readonly swalTargets: SwalPartialTargets) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"karma-jasmine-html-reporter": "^1.1.0",
"ng-packagr": "^4.3.1",
"semantic-release": "^15.4.1",
"sweetalert2": "^7.8.0",
"sweetalert2": "^8.5.0",
"travis-deploy-once": "^5.0.0",
"ts-node": "^7.0.1",
"tsickle": "^0.33.0",
Expand Down
4 changes: 2 additions & 2 deletions src/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@toverux/ngx-sweetalert2",
"name": "@sweetalert2/ngx-sweetalert2",
"version": "0.0.0-semantic-released",
"description": "SweetAlert2 integration for Angular 4+",
"repository": "[email protected]:sweetalert2/ngx-sweetalert2.git",
Expand All @@ -9,7 +9,7 @@
"@angular/core": "^5.0.0 || ^6.0.0 || ^7.0.0",
"@angular/common": "^5.0.0 || ^6.0.0 || ^7.0.0",
"rxjs": "^6.1.0",
"sweetalert2": "^7.15.1"
"sweetalert2": "^8.5.0"
},
"ngPackage": {
"$schema": "./node_modules/ng-packagr/ng-package.schema.json",
Expand Down
21 changes: 8 additions & 13 deletions src/swal-partial-targets.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
import swal from 'sweetalert2';
import Swal from 'sweetalert2';

/**
* Represents an object of targets for <swal> partials (use with *swalPartial directive).
* We must use thunks to access the swal.* functions listed below, because they get created after the first modal is
* We must use thunks to access the Swal.* functions listed below, because they get created after the first modal is
* shown, so this object lets us reference those functions safely and in a statically-typed manner.
*/
export class SwalPartialTargets {
public readonly title = () => swal.getTitle();
public readonly title = () => Swal.getTitle();

public readonly content = () => swal.getContent();
public readonly content = () => Swal.getContent();

/**
* @deprecated Will be removed in the next major version, please use {@link SwalPartialTargets#actions} instead.
*/
public readonly buttonsWrapper = () => swal.getButtonsWrapper();
public readonly actions = () => Swal.getActions();

public readonly actions = () => swal.getActions();
public readonly confirmButton = () => Swal.getConfirmButton();

public readonly confirmButton = () => swal.getConfirmButton();
public readonly cancelButton = () => Swal.getCancelButton();

public readonly cancelButton = () => swal.getCancelButton();

public readonly footer = () => swal.getFooter();
public readonly footer = () => Swal.getFooter();
}
8 changes: 4 additions & 4 deletions src/swal.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
ChangeDetectionStrategy, Component, EventEmitter, Inject, Input, OnChanges, OnDestroy, Output, SimpleChanges
} from '@angular/core';
import swal, { SweetAlertOptions } from 'sweetalert2';
import Swal, { SweetAlertOptions } from 'sweetalert2';
import { SwalDefaults } from './di';
import * as events from './swal-events';

Expand Down Expand Up @@ -148,7 +148,7 @@ export class SwalComponent implements OnChanges, OnDestroy {
return options;
}

public nativeSwal = swal;
public nativeSwal = Swal;

private isCurrentlyShown = false;

Expand All @@ -170,7 +170,7 @@ export class SwalComponent implements OnChanges, OnDestroy {

public ngOnDestroy(): void {
if (this.isCurrentlyShown) {
swal.close();
Swal.close();
}
}

Expand Down Expand Up @@ -206,7 +206,7 @@ export class SwalComponent implements OnChanges, OnDestroy {
};

//=> Show the Swal!
const promise = swal(options);
const promise = Swal.fire(options);

//=> Handle (confirm) and (cancel) @Outputs
// tslint:disable-next-line:no-string-literal
Expand Down
4 changes: 2 additions & 2 deletions src/swal.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
ComponentFactoryResolver, ComponentRef, Directive, EventEmitter, HostListener, Input, OnDestroy, OnInit, Output,
ViewContainerRef
} from '@angular/core';
import swal, { SweetAlertArrayOptions, SweetAlertOptions } from 'sweetalert2';
import Swal, { SweetAlertArrayOptions, SweetAlertOptions } from 'sweetalert2';
import { SwalComponent } from './swal.component';

/**
Expand Down Expand Up @@ -33,7 +33,7 @@ export class SwalDirective implements OnInit, OnDestroy {
if (options instanceof SwalComponent) {
this.swalInstance = options;
} else if (Array.isArray(options)) {
this.swalOptions = swal.argsToParams(options);
this.swalOptions = Swal.argsToParams(options);
} else {
this.swalOptions = options;
}
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9083,10 +9083,10 @@ supports-color@^5.1.0, supports-color@^5.3.0, supports-color@^5.4.0, supports-co
dependencies:
has-flag "^3.0.0"

sweetalert2@^7.8.0:
version "7.28.7"
resolved "https://registry.yarnpkg.com/sweetalert2/-/sweetalert2-7.28.7.tgz#69a138f1e47b091fb0c310c47feeb123fcea14ca"
integrity sha512-gl+/201OeRJbGbor7GBM5pP6f8VUkAM1qxusNCQ9VmTMFtFHVUUntPctcNbGWh2r0vlsexO40u7ry5KIvQ5IGA==
sweetalert2@^8.5.0:
version "8.5.0"
resolved "https://registry.yarnpkg.com/sweetalert2/-/sweetalert2-8.5.0.tgz#453ee0b3dd4ab5b8d89b1588c48ea90d74b16d63"
integrity sha512-cvGitYfnutaRIWuLJ+p+eLXieJyodWpB9F8AtD6Y5uNWN5OcQD1dDwN7VPDo4U7y4ni3rgK9gDYmkz9RCf4PSA==

[email protected], symbol-observable@^1.2.0:
version "1.2.0"
Expand Down

0 comments on commit ff5f39b

Please sign in to comment.