design-angular-kit 1.0.0-8 → 1.0.0-9
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/esm2020/lib/abstracts/abstract-form-component.mjs +11 -3
- package/esm2020/lib/components/core/notifications/notifications.component.mjs +55 -11
- package/esm2020/lib/interfaces/core.mjs +1 -1
- package/esm2020/lib/services/notifications/notifications.service.mjs +24 -26
- package/fesm2015/design-angular-kit.mjs +82 -33
- package/fesm2015/design-angular-kit.mjs.map +1 -1
- package/fesm2020/design-angular-kit.mjs +82 -33
- package/fesm2020/design-angular-kit.mjs.map +1 -1
- package/lib/abstracts/abstract-form-component.d.ts +5 -1
- package/lib/components/core/notifications/notifications.component.d.ts +21 -7
- package/lib/interfaces/core.d.ts +24 -1
- package/lib/services/notifications/notifications.service.d.ts +17 -17
- package/package.json +1 -1
|
@@ -79,6 +79,12 @@ class AbstractFormComponent extends AbstractComponent {
|
|
|
79
79
|
this.control = new FormControl();
|
|
80
80
|
this._ngControl && (this._ngControl.valueAccessor = this);
|
|
81
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Set the disabled state
|
|
84
|
+
*/
|
|
85
|
+
set disabled(isDisabled) {
|
|
86
|
+
this.setDisabledState(isTrueBooleanInput(isDisabled));
|
|
87
|
+
}
|
|
82
88
|
/**
|
|
83
89
|
* Check if field is invalid (Validation failed)
|
|
84
90
|
*/
|
|
@@ -200,7 +206,7 @@ class AbstractFormComponent extends AbstractComponent {
|
|
|
200
206
|
}
|
|
201
207
|
}
|
|
202
208
|
AbstractFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: AbstractFormComponent, deps: [{ token: i2.NgControl, optional: true, self: true }, { token: i1.TranslateService }, { token: i0.Renderer2 }, { token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
203
|
-
AbstractFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.4", type: AbstractFormComponent, selector: "ng-component", inputs: { label: "label", validationMode: "validationMode" }, usesInheritance: true, ngImport: i0, template: '', isInline: true });
|
|
209
|
+
AbstractFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.4", type: AbstractFormComponent, selector: "ng-component", inputs: { label: "label", validationMode: "validationMode", disabled: "disabled" }, usesInheritance: true, ngImport: i0, template: '', isInline: true });
|
|
204
210
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: AbstractFormComponent, decorators: [{
|
|
205
211
|
type: Component,
|
|
206
212
|
args: [{ template: '' }]
|
|
@@ -212,6 +218,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImpor
|
|
|
212
218
|
type: Input
|
|
213
219
|
}], validationMode: [{
|
|
214
220
|
type: Input
|
|
221
|
+
}], disabled: [{
|
|
222
|
+
type: Input
|
|
215
223
|
}] } });
|
|
216
224
|
|
|
217
225
|
class CollapseComponent extends AbstractComponent {
|
|
@@ -1203,17 +1211,17 @@ class NotificationsService {
|
|
|
1203
1211
|
* Create new Standard notification
|
|
1204
1212
|
* @param title notification title
|
|
1205
1213
|
* @param message notification message
|
|
1206
|
-
* @param
|
|
1207
|
-
* @param duration notification duration (
|
|
1214
|
+
* @param dismissible notification dismissible
|
|
1215
|
+
* @param duration notification duration (milliseconds)
|
|
1208
1216
|
* @param position notification position
|
|
1209
1217
|
*/
|
|
1210
|
-
standard(title, message,
|
|
1218
|
+
standard(title, message, dismissible, duration, position) {
|
|
1211
1219
|
this.addNotification({
|
|
1212
1220
|
type: NotificationType.Standard,
|
|
1213
1221
|
message,
|
|
1214
1222
|
title,
|
|
1215
1223
|
duration,
|
|
1216
|
-
|
|
1224
|
+
dismissible,
|
|
1217
1225
|
position
|
|
1218
1226
|
});
|
|
1219
1227
|
}
|
|
@@ -1221,17 +1229,17 @@ class NotificationsService {
|
|
|
1221
1229
|
* Create new Success notification
|
|
1222
1230
|
* @param title notification title
|
|
1223
1231
|
* @param message notification message
|
|
1224
|
-
* @param
|
|
1225
|
-
* @param duration notification duration (
|
|
1232
|
+
* @param dismissible notification dismissible
|
|
1233
|
+
* @param duration notification duration (milliseconds)
|
|
1226
1234
|
* @param position notification position
|
|
1227
1235
|
*/
|
|
1228
|
-
success(title, message,
|
|
1236
|
+
success(title, message, dismissible, duration, position) {
|
|
1229
1237
|
this.addNotification({
|
|
1230
1238
|
type: NotificationType.Success,
|
|
1231
1239
|
message,
|
|
1232
1240
|
title,
|
|
1233
1241
|
duration,
|
|
1234
|
-
|
|
1242
|
+
dismissible,
|
|
1235
1243
|
position
|
|
1236
1244
|
});
|
|
1237
1245
|
}
|
|
@@ -1239,17 +1247,17 @@ class NotificationsService {
|
|
|
1239
1247
|
* Create new Error notification
|
|
1240
1248
|
* @param title notification title
|
|
1241
1249
|
* @param message notification message
|
|
1242
|
-
* @param
|
|
1243
|
-
* @param duration notification duration (
|
|
1250
|
+
* @param dismissible notification dismissible
|
|
1251
|
+
* @param duration notification duration (milliseconds)
|
|
1244
1252
|
* @param position notification position
|
|
1245
1253
|
*/
|
|
1246
|
-
error(title, message,
|
|
1254
|
+
error(title, message, dismissible, duration, position) {
|
|
1247
1255
|
this.addNotification({
|
|
1248
1256
|
type: NotificationType.Error,
|
|
1249
1257
|
message,
|
|
1250
1258
|
title,
|
|
1251
1259
|
duration,
|
|
1252
|
-
|
|
1260
|
+
dismissible,
|
|
1253
1261
|
position
|
|
1254
1262
|
});
|
|
1255
1263
|
}
|
|
@@ -1257,17 +1265,17 @@ class NotificationsService {
|
|
|
1257
1265
|
* Create new Warning notification
|
|
1258
1266
|
* @param title notification title
|
|
1259
1267
|
* @param message notification message
|
|
1260
|
-
* @param
|
|
1261
|
-
* @param duration notification duration (
|
|
1268
|
+
* @param dismissible notification dismissible
|
|
1269
|
+
* @param duration notification duration (milliseconds)
|
|
1262
1270
|
* @param position notification position
|
|
1263
1271
|
*/
|
|
1264
|
-
warning(title, message,
|
|
1272
|
+
warning(title, message, dismissible, duration, position) {
|
|
1265
1273
|
this.addNotification({
|
|
1266
1274
|
type: NotificationType.Warning,
|
|
1267
1275
|
message,
|
|
1268
1276
|
title,
|
|
1269
1277
|
duration,
|
|
1270
|
-
|
|
1278
|
+
dismissible,
|
|
1271
1279
|
position
|
|
1272
1280
|
});
|
|
1273
1281
|
}
|
|
@@ -1275,17 +1283,17 @@ class NotificationsService {
|
|
|
1275
1283
|
* Create new Info notification
|
|
1276
1284
|
* @param title notification title
|
|
1277
1285
|
* @param message notification message
|
|
1278
|
-
* @param
|
|
1279
|
-
* @param duration notification duration (
|
|
1286
|
+
* @param dismissible notification dismissible
|
|
1287
|
+
* @param duration notification duration (milliseconds)
|
|
1280
1288
|
* @param position notification position
|
|
1281
1289
|
*/
|
|
1282
|
-
info(title, message,
|
|
1290
|
+
info(title, message, dismissible, duration, position) {
|
|
1283
1291
|
this.addNotification({
|
|
1284
1292
|
type: NotificationType.Info,
|
|
1285
1293
|
message,
|
|
1286
1294
|
title,
|
|
1287
1295
|
duration,
|
|
1288
|
-
|
|
1296
|
+
dismissible,
|
|
1289
1297
|
position
|
|
1290
1298
|
});
|
|
1291
1299
|
}
|
|
@@ -1294,19 +1302,24 @@ NotificationsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", ver
|
|
|
1294
1302
|
NotificationsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: NotificationsService, providedIn: 'root' });
|
|
1295
1303
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: NotificationsService, decorators: [{
|
|
1296
1304
|
type: Injectable,
|
|
1297
|
-
args: [{
|
|
1298
|
-
providedIn: 'root'
|
|
1299
|
-
}]
|
|
1305
|
+
args: [{ providedIn: 'root' }]
|
|
1300
1306
|
}] });
|
|
1301
1307
|
|
|
1302
1308
|
class NotificationsComponent {
|
|
1303
|
-
constructor(_notificationService) {
|
|
1309
|
+
constructor(_changeDetectorRef, _notificationService) {
|
|
1310
|
+
this._changeDetectorRef = _changeDetectorRef;
|
|
1304
1311
|
this._notificationService = _notificationService;
|
|
1305
1312
|
/**
|
|
1306
|
-
* Default notifications duration
|
|
1313
|
+
* Default notifications duration (milliseconds)
|
|
1307
1314
|
* @default 8000
|
|
1308
1315
|
*/
|
|
1309
1316
|
this.duration = 8000;
|
|
1317
|
+
/**
|
|
1318
|
+
* Default notifications is dismissible
|
|
1319
|
+
* @default true
|
|
1320
|
+
*/
|
|
1321
|
+
this.dismissible = true;
|
|
1322
|
+
this.notificationCount = 0;
|
|
1310
1323
|
this.notifications = [];
|
|
1311
1324
|
this.subscription = this._notificationService.onNotification().subscribe(notification => {
|
|
1312
1325
|
if (!notification.duration) {
|
|
@@ -1315,11 +1328,18 @@ class NotificationsComponent {
|
|
|
1315
1328
|
if (!notification.position && this.position) {
|
|
1316
1329
|
notification.position = this.position; // Add position if not is set
|
|
1317
1330
|
}
|
|
1331
|
+
if (notification.dismissible === undefined && isTrueBooleanInput(this.dismissible)) {
|
|
1332
|
+
notification.dismissible = true; // Add dismissible if not is set
|
|
1333
|
+
}
|
|
1334
|
+
if (!notification.icon) {
|
|
1335
|
+
notification.icon = this.getNotificationIcon(notification);
|
|
1336
|
+
}
|
|
1318
1337
|
const newNotification = {
|
|
1319
1338
|
...notification,
|
|
1320
|
-
id: `${notification.type}-${this.
|
|
1339
|
+
id: `${notification.type}-${this.notificationCount++}-notification`
|
|
1321
1340
|
};
|
|
1322
|
-
|
|
1341
|
+
this.notifications.push(newNotification);
|
|
1342
|
+
this._changeDetectorRef.detectChanges();
|
|
1323
1343
|
setTimeout(() => {
|
|
1324
1344
|
// Show the notification
|
|
1325
1345
|
new Notification(document.getElementById(newNotification.id), {
|
|
@@ -1327,7 +1347,14 @@ class NotificationsComponent {
|
|
|
1327
1347
|
}).show();
|
|
1328
1348
|
// Clear notification after the duration
|
|
1329
1349
|
setTimeout(() => {
|
|
1330
|
-
|
|
1350
|
+
const index = this.notifications.findIndex(n => n.id === newNotification.id);
|
|
1351
|
+
if (index > -1) {
|
|
1352
|
+
this.notifications.splice(index, 1);
|
|
1353
|
+
if (!this.notifications.length) {
|
|
1354
|
+
this.notificationCount = 0;
|
|
1355
|
+
}
|
|
1356
|
+
this._changeDetectorRef.detectChanges();
|
|
1357
|
+
}
|
|
1331
1358
|
}, notification.duration);
|
|
1332
1359
|
}, 200);
|
|
1333
1360
|
});
|
|
@@ -1345,16 +1372,38 @@ class NotificationsComponent {
|
|
|
1345
1372
|
hideNotification(id) {
|
|
1346
1373
|
Notification.getInstance(document.getElementById(id))?.hide();
|
|
1347
1374
|
}
|
|
1375
|
+
/**
|
|
1376
|
+
* Retrieve the icon name by notification type
|
|
1377
|
+
* @param notification the notification
|
|
1378
|
+
* @protected
|
|
1379
|
+
*/
|
|
1380
|
+
getNotificationIcon(notification) {
|
|
1381
|
+
switch (notification.type) {
|
|
1382
|
+
case NotificationType.Success:
|
|
1383
|
+
return 'check-circle';
|
|
1384
|
+
case NotificationType.Error:
|
|
1385
|
+
return 'close-circle';
|
|
1386
|
+
case NotificationType.Warning:
|
|
1387
|
+
return 'error';
|
|
1388
|
+
case NotificationType.Info:
|
|
1389
|
+
return 'info-circle';
|
|
1390
|
+
case NotificationType.Standard:
|
|
1391
|
+
default:
|
|
1392
|
+
return undefined;
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1348
1395
|
}
|
|
1349
|
-
NotificationsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: NotificationsComponent, deps: [{ token: NotificationsService }], target: i0.ɵɵFactoryTarget.Component });
|
|
1350
|
-
NotificationsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.4", type: NotificationsComponent, selector: "it-notifications", inputs: { duration: "duration", position: "position" }, ngImport: i0, template: "<div *ngFor=\"let notification of notifications
|
|
1396
|
+
NotificationsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: NotificationsComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: NotificationsService }], target: i0.ɵɵFactoryTarget.Component });
|
|
1397
|
+
NotificationsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.4", type: NotificationsComponent, selector: "it-notifications", inputs: { duration: "duration", position: "position", dismissible: "dismissible" }, ngImport: i0, template: "<div *ngFor=\"let notification of notifications\"\n [id]=\"notification.id\"\n class=\"notification {{notification.position}} {{notification.type}}\"\n [class.with-icon]=\"!!notification.icon\"\n [class.dismissable]=\"notification.dismissible\"\n role=\"alert\" [attr.aria-labelledby]=\"notification.id+'-title'\">\n\n <h2 [id]=\"notification.id+'-title'\" class=\"h5\">\n <it-icon *ngIf=\"!!notification.icon\" [name]=\"notification.icon\"></it-icon>\n <ng-container>{{notification.title}}</ng-container>\n </h2>\n <p *ngIf=\"notification.message\">{{notification.message}}</p>\n\n <button *ngIf=\"notification.dismissible\" type=\"button\" class=\"btn notification-close\"\n (click)=\"hideNotification(notification.id)\">\n <it-icon name=\"close\"></it-icon>\n <span class=\"visually-hidden\">{{'it.core.close-notification'|translate:{ title: notification.title } }}</span>\n </button>\n</div>\n", styles: [".notification{z-index:10000}\n"], dependencies: [{ kind: "directive", type: i1$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: IconComponent, selector: "it-icon[name]", inputs: ["name", "size", "color", "padded", "class"] }, { kind: "pipe", type: i1.TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1351
1398
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: NotificationsComponent, decorators: [{
|
|
1352
1399
|
type: Component,
|
|
1353
|
-
args: [{ selector: 'it-notifications', template: "<div *ngFor=\"let notification of notifications
|
|
1354
|
-
}], ctorParameters: function () { return [{ type: NotificationsService }]; }, propDecorators: { duration: [{
|
|
1400
|
+
args: [{ selector: 'it-notifications', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div *ngFor=\"let notification of notifications\"\n [id]=\"notification.id\"\n class=\"notification {{notification.position}} {{notification.type}}\"\n [class.with-icon]=\"!!notification.icon\"\n [class.dismissable]=\"notification.dismissible\"\n role=\"alert\" [attr.aria-labelledby]=\"notification.id+'-title'\">\n\n <h2 [id]=\"notification.id+'-title'\" class=\"h5\">\n <it-icon *ngIf=\"!!notification.icon\" [name]=\"notification.icon\"></it-icon>\n <ng-container>{{notification.title}}</ng-container>\n </h2>\n <p *ngIf=\"notification.message\">{{notification.message}}</p>\n\n <button *ngIf=\"notification.dismissible\" type=\"button\" class=\"btn notification-close\"\n (click)=\"hideNotification(notification.id)\">\n <it-icon name=\"close\"></it-icon>\n <span class=\"visually-hidden\">{{'it.core.close-notification'|translate:{ title: notification.title } }}</span>\n </button>\n</div>\n", styles: [".notification{z-index:10000}\n"] }]
|
|
1401
|
+
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: NotificationsService }]; }, propDecorators: { duration: [{
|
|
1355
1402
|
type: Input
|
|
1356
1403
|
}], position: [{
|
|
1357
1404
|
type: Input
|
|
1405
|
+
}], dismissible: [{
|
|
1406
|
+
type: Input
|
|
1358
1407
|
}] } });
|
|
1359
1408
|
|
|
1360
1409
|
class PaginationComponent {
|