@craftsjs/alert 5.1.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +160 -145
- package/_craftsjs-alert.theme.scss +414 -414
- package/esm2022/lib/alert.module.mjs +69 -0
- package/esm2022/lib/alert.providers.mjs +14 -0
- package/esm2022/lib/components/dialog-alert/components/alert-info/alert-info.component.mjs +13 -0
- package/esm2022/lib/components/dialog-alert/components/alert-success/alert-success.component.mjs +13 -0
- package/esm2022/lib/components/dialog-alert/components/buttons/alert-cancel-button/alert-cancel-button.component.mjs +20 -0
- package/esm2022/lib/components/dialog-alert/components/buttons/alert-ok-button/alert-ok-button.component.mjs +20 -0
- package/{esm2020 → esm2022}/lib/components/dialog-alert/components/components.mjs +1 -1
- package/esm2022/lib/components/dialog-alert/components/error/error.component.mjs +13 -0
- package/esm2022/lib/components/dialog-alert/components/warning/warning.component.mjs +13 -0
- package/esm2022/lib/components/dialog-alert/dialog-alert.component.mjs +78 -0
- package/{esm2020 → esm2022}/lib/models/alert-enum.model.mjs +1 -1
- package/esm2022/lib/models/alert.model.mjs +2 -0
- package/{esm2020 → esm2022}/lib/services/alert.service.mjs +5 -5
- package/{esm2020 → esm2022}/public-api.mjs +2 -1
- package/fesm2022/craftsjs-alert.mjs +313 -0
- package/fesm2022/craftsjs-alert.mjs.map +1 -0
- package/lib/alert.module.d.ts +12 -13
- package/lib/alert.providers.d.ts +6 -0
- package/lib/components/dialog-alert/components/alert-info/alert-info.component.d.ts +1 -1
- package/lib/components/dialog-alert/components/alert-success/alert-success.component.d.ts +1 -1
- package/lib/components/dialog-alert/components/buttons/alert-cancel-button/alert-cancel-button.component.d.ts +1 -1
- package/lib/components/dialog-alert/components/buttons/alert-ok-button/alert-ok-button.component.d.ts +1 -1
- package/lib/components/dialog-alert/components/error/error.component.d.ts +1 -1
- package/lib/components/dialog-alert/components/warning/warning.component.d.ts +1 -1
- package/lib/components/dialog-alert/dialog-alert.component.d.ts +1 -1
- package/package.json +12 -17
- package/public-api.d.ts +1 -0
- package/esm2020/lib/alert.module.mjs +0 -67
- package/esm2020/lib/components/dialog-alert/components/alert-info/alert-info.component.mjs +0 -13
- package/esm2020/lib/components/dialog-alert/components/alert-success/alert-success.component.mjs +0 -13
- package/esm2020/lib/components/dialog-alert/components/buttons/alert-cancel-button/alert-cancel-button.component.mjs +0 -18
- package/esm2020/lib/components/dialog-alert/components/buttons/alert-ok-button/alert-ok-button.component.mjs +0 -18
- package/esm2020/lib/components/dialog-alert/components/error/error.component.mjs +0 -13
- package/esm2020/lib/components/dialog-alert/components/warning/warning.component.mjs +0 -13
- package/esm2020/lib/components/dialog-alert/dialog-alert.component.mjs +0 -74
- package/esm2020/lib/models/alert.model.mjs +0 -2
- package/fesm2015/craftsjs-alert.mjs +0 -299
- package/fesm2015/craftsjs-alert.mjs.map +0 -1
- package/fesm2020/craftsjs-alert.mjs +0 -297
- package/fesm2020/craftsjs-alert.mjs.map +0 -1
- /package/{esm2020 → esm2022}/craftsjs-alert.mjs +0 -0
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020 Craftsjs
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Craftsjs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,145 +1,160 @@
|
|
|
1
|
-
# craftsjs alert
|
|
2
|
-
|
|
3
|
-
craftsjs alert is a library for angular
|
|
4
|
-
|
|
5
|
-
[See demo](http://craftsjs.com/admin/components/modals-alerts)
|
|
6
|
-
|
|
7
|
-
[Example code](https://stackblitz.com/edit/angular-alert-craftsjs)
|
|
8
|
-
|
|
9
|
-
## Getting Started
|
|
10
|
-
To get started, let's install the package through npm:
|
|
11
|
-
|
|
12
|
-
Choose the version corresponding to your Angular version:
|
|
13
|
-
|
|
14
|
-
| Angular | @craftsjs/alert |
|
|
15
|
-
| ------- | --------------- |
|
|
16
|
-
|
|
|
17
|
-
|
|
|
18
|
-
|
|
|
19
|
-
|
|
|
20
|
-
|
|
|
21
|
-
|
|
22
|
-
```
|
|
23
|
-
npm i @craftsjs/alert --S
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
@angular/cdk
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
this._alertService.
|
|
90
|
-
// this._alertService.
|
|
91
|
-
// this._alertService.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
@import '~@
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
$craftsjs-app-
|
|
124
|
-
$craftsjs-app-
|
|
125
|
-
$craftsjs-app-
|
|
126
|
-
$craftsjs-
|
|
127
|
-
|
|
128
|
-
color-
|
|
129
|
-
color-
|
|
130
|
-
color-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
@include
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
```
|
|
1
|
+
# craftsjs alert
|
|
2
|
+
|
|
3
|
+
craftsjs alert is a library for angular
|
|
4
|
+
|
|
5
|
+
[See demo](http://craftsjs.com/admin/components/modals-alerts)
|
|
6
|
+
|
|
7
|
+
[Example code](https://stackblitz.com/edit/angular-alert-craftsjs)
|
|
8
|
+
|
|
9
|
+
## Getting Started
|
|
10
|
+
To get started, let's install the package through npm:
|
|
11
|
+
|
|
12
|
+
Choose the version corresponding to your Angular version:
|
|
13
|
+
|
|
14
|
+
| Angular | @craftsjs/alert |
|
|
15
|
+
| ------- | --------------- |
|
|
16
|
+
| 18 | 6.x |
|
|
17
|
+
| 15 | 5.x |
|
|
18
|
+
| 13 | 4.x |
|
|
19
|
+
| 12 | 3.x |
|
|
20
|
+
| 11 | 2.x |
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
npm i @craftsjs/alert --S
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Compatibility
|
|
27
|
+
|
|
28
|
+
Current version: 6.1.0 (Compatible with Angular v18)
|
|
29
|
+
|
|
30
|
+
Install peer dependencies
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
npm i @craftsjs/core @ngx-translate/core @angular/material @angular/cdk @angular/animations --S
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Configuration (i18n optional)
|
|
37
|
+
|
|
38
|
+
- If you want translations, configure `@ngx-translate/core` in your app. Example (standalone):
|
|
39
|
+
|
|
40
|
+
The library is configured as follows:
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
// main.ts
|
|
44
|
+
import { bootstrapApplication, importProvidersFrom } from '@angular/platform-browser';
|
|
45
|
+
import { provideAnimations } from '@angular/platform-browser/animations';
|
|
46
|
+
import { provideCraftsjsAlert } from '@craftsjs/alert';
|
|
47
|
+
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
|
|
48
|
+
import { HttpClient, HttpClientModule } from '@angular/common/http';
|
|
49
|
+
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
|
|
50
|
+
import { AppComponent } from './app/app.component';
|
|
51
|
+
|
|
52
|
+
export function createTranslateLoader(http: HttpClient) {
|
|
53
|
+
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
bootstrapApplication(AppComponent, {
|
|
57
|
+
providers: [
|
|
58
|
+
provideAnimations(),
|
|
59
|
+
provideCraftsjsAlert(),
|
|
60
|
+
importProvidersFrom(
|
|
61
|
+
HttpClientModule,
|
|
62
|
+
TranslateModule.forRoot({
|
|
63
|
+
loader: { provide: TranslateLoader, useFactory: createTranslateLoader, deps: [HttpClient] }
|
|
64
|
+
})
|
|
65
|
+
)
|
|
66
|
+
]
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## How to use (standalone service)
|
|
71
|
+
|
|
72
|
+
- Inject `AlertService` anywhere and call the helpers. The dialog component is standalone and provided by the service.
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
import { Component } from '@angular/core';
|
|
76
|
+
import { AlertService } from '@craftsjs/alert';
|
|
77
|
+
|
|
78
|
+
@Component({
|
|
79
|
+
selector: 'app-alert-demo',
|
|
80
|
+
standalone: true,
|
|
81
|
+
template: `<button type="button" mat-raised-button color="primary" (click)="openDialog()">Alert warning</button>`
|
|
82
|
+
})
|
|
83
|
+
export class AlertDemoComponent {
|
|
84
|
+
constructor(private _alertService: AlertService) {}
|
|
85
|
+
|
|
86
|
+
openDialog() {
|
|
87
|
+
this._alertService.showSimple('Alert', 'Simple alert');
|
|
88
|
+
// this._alertService.showSuccess('Success', 'Saved successfully');
|
|
89
|
+
// this._alertService.showWarning('Warn', 'Warning');
|
|
90
|
+
// this._alertService.showInfo('Info', 'Information');
|
|
91
|
+
// this._alertService.showError('Error', 'Error');
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
// Confirmation example
|
|
98
|
+
const dialog = this._alertService.showConfirmation('Confirmation', 'Are you sure delete alert?');
|
|
99
|
+
dialog.beforeClose().subscribe((result) => {
|
|
100
|
+
if (!result) { return; }
|
|
101
|
+
switch (result.result) {
|
|
102
|
+
case 'ok':
|
|
103
|
+
console.log('ok');
|
|
104
|
+
break;
|
|
105
|
+
case 'cancel':
|
|
106
|
+
console.log('cancel');
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
```html
|
|
113
|
+
<button type="button" mat-raised-button color="primary" (click)="openDialog()">Alert warning</button>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
- Finally, it is important to import the styles to the application
|
|
117
|
+
|
|
118
|
+
```scss
|
|
119
|
+
@import '~@craftsjs/alert/craftsjs-alert.theme';
|
|
120
|
+
@import '~@angular/material/theming';
|
|
121
|
+
|
|
122
|
+
$craftsjs-app-primary: mat-palette($mat-teal, 800);
|
|
123
|
+
$craftsjs-app-accent: mat-palette($mat-pink, 800, A100, 100);
|
|
124
|
+
$craftsjs-app-warn: mat-palette($mat-red);
|
|
125
|
+
$craftsjs-app-theme: mat-light-theme($craftsjs-app-primary, $craftsjs-app-accent, $craftsjs-app-warn);
|
|
126
|
+
$craftsjs-theme-variables: (
|
|
127
|
+
color-info: #20a9d2,
|
|
128
|
+
color-success: #5cb85c,
|
|
129
|
+
color-danger: #d43934,
|
|
130
|
+
color-warning: #e09d3d
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
@include mat-core();
|
|
134
|
+
body.theme-default{
|
|
135
|
+
@include angular-material-theme($craftsjs-app-theme);
|
|
136
|
+
@include alert($craftsjs-theme-variables);
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
- Don't forget to put the theme-default class in the html body
|
|
141
|
+
and ensure Angular Material animations are provided (e.g., `provideAnimations()` in main.ts).
|
|
142
|
+
|
|
143
|
+
## NgModule (compatibility)
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
|
147
|
+
import { AlertModule } from '@craftsjs/alert';
|
|
148
|
+
|
|
149
|
+
@NgModule({
|
|
150
|
+
imports: [
|
|
151
|
+
BrowserAnimationsModule,
|
|
152
|
+
AlertModule.forRoot()
|
|
153
|
+
]
|
|
154
|
+
})
|
|
155
|
+
export class AppModule {}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
```html
|
|
159
|
+
<body class="theme-default"></body>
|
|
160
|
+
```
|