@coolon/angular-ui-powerups 0.0.58 → 0.0.60

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.
Files changed (31) hide show
  1. package/bundles/coolon-angular-ui-powerups.umd.js +121 -127
  2. package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -1
  3. package/bundles/coolon-angular-ui-powerups.umd.min.js +1 -1
  4. package/bundles/coolon-angular-ui-powerups.umd.min.js.map +1 -1
  5. package/coolon-angular-ui-powerups.metadata.json +1 -1
  6. package/esm2015/lib/interaction/abstract-activity.js +18 -70
  7. package/esm2015/lib/interaction/activity.js +3 -8
  8. package/esm2015/lib/interaction/components/activity-container/activity-container.component.js +82 -26
  9. package/esm2015/lib/interaction/components/activity-outlet/activity-outlet.component.js +10 -4
  10. package/esm2015/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.js +2 -2
  11. package/esm2015/lib/interaction/interaction-context.js +1 -1
  12. package/esm2015/lib/interaction/services/dialog-interaction.service.js +6 -6
  13. package/esm5/lib/interaction/abstract-activity.js +20 -89
  14. package/esm5/lib/interaction/activity.js +3 -8
  15. package/esm5/lib/interaction/components/activity-container/activity-container.component.js +87 -27
  16. package/esm5/lib/interaction/components/activity-outlet/activity-outlet.component.js +10 -4
  17. package/esm5/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.js +2 -2
  18. package/esm5/lib/interaction/interaction-context.js +1 -1
  19. package/esm5/lib/interaction/services/dialog-interaction.service.js +5 -5
  20. package/fesm2015/coolon-angular-ui-powerups.js +112 -110
  21. package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
  22. package/fesm5/coolon-angular-ui-powerups.js +119 -126
  23. package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
  24. package/lib/interaction/abstract-activity.d.ts +5 -8
  25. package/lib/interaction/activity.d.ts +2 -2
  26. package/lib/interaction/components/activity-container/activity-container.component.d.ts +5 -4
  27. package/lib/interaction/components/activity-outlet/activity-outlet.component.d.ts +2 -2
  28. package/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.d.ts +1 -1
  29. package/lib/interaction/interaction-context.d.ts +1 -1
  30. package/lib/interaction/services/dialog-interaction.service.d.ts +3 -3
  31. package/package.json +1 -1
@@ -5,11 +5,10 @@ import { MatDialog, MatButtonModule, MatDialogModule, MatTabsModule, MatProgress
5
5
  import { MatTabsModule as MatTabsModule$1 } from '@angular/material/tabs';
6
6
  import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
7
7
  import { __extends, __decorate, __metadata, __assign, __awaiter, __generator } from 'tslib';
8
- import { GarbageCollector, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel, assert, UnaryCommand, lang, Dsl, Logger, EventListenerList, DelegatingValueModel, MutableListModel, StoreInValueModel, Binding, MutableValueModel, Guard, OptionsHelper, ValueHolder } from '@coolon/pectin';
8
+ import { GarbageCollector, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel, assert, UnaryCommand, lang, Dsl, Logger, Trace, DelegatingValueModel, MutableListModel, StoreInValueModel, Binding, MutableValueModel, Guard, OptionsHelper, ValueHolder } from '@coolon/pectin';
9
9
  import { PortalModule } from '@angular/cdk/portal';
10
- import { Deferred } from '@coolon/pectin/lib/promise/deferred.class';
11
- import { MatDialogConfig, MAT_DIALOG_DEFAULT_OPTIONS, MatDialog as MatDialog$1 } from '@angular/material/dialog';
12
10
  import { assert as assert$1, Klass, Opts } from '@coolon/typescript-utilities';
11
+ import { MatDialogConfig, MAT_DIALOG_DEFAULT_OPTIONS, MatDialog as MatDialog$1 } from '@angular/material/dialog';
13
12
  import { MatIconModule } from '@angular/material/icon';
14
13
  import { MatListModule } from '@angular/material/list';
15
14
  import { MatTooltipModule } from '@angular/material/tooltip';
@@ -848,15 +847,10 @@ if (false) {
848
847
  /** @type {?} */
849
848
  Activity.prototype.busy;
850
849
  /**
851
- * @param {?} callback
852
- * @return {?}
853
- */
854
- Activity.prototype.onDone = function (callback) { };
855
- /**
856
- * @param {?} callback
850
+ * @param {?} activityContext
857
851
  * @return {?}
858
852
  */
859
- Activity.prototype.onCancel = function (callback) { };
853
+ Activity.prototype.initialise = function (activityContext) { };
860
854
  }
861
855
 
862
856
  /**
@@ -921,8 +915,7 @@ var ActivityOutletComponent = /** @class */ (function () {
921
915
  var componentFactory = this.componentFactoryResolver.resolveComponentFactory(activityContext.activityClass);
922
916
  this.viewContainerRef.clear();
923
917
  this.activityComponentRef = this.viewContainerRef.createComponent(componentFactory, 0, injector);
924
- this.activityComponentRef.instance.onDone(activityContext.onDone);
925
- this.activityComponentRef.instance.onCancel(activityContext.onCancel);
918
+ this.activityComponentRef.instance.initialise(activityContext);
926
919
  };
927
920
  /**
928
921
  * @param {?} alert
@@ -989,6 +982,12 @@ var ActivityOutletComponent = /** @class */ (function () {
989
982
  interactionContext: [{ type: Input }],
990
983
  activityContext: [{ type: Input }]
991
984
  };
985
+ __decorate([
986
+ Trace(),
987
+ __metadata("design:type", Function),
988
+ __metadata("design:paramtypes", [Object]),
989
+ __metadata("design:returntype", void 0)
990
+ ], ActivityOutletComponent.prototype, "loadActivity", null);
992
991
  return ActivityOutletComponent;
993
992
  }());
994
993
  if (false) {
@@ -1083,40 +1082,24 @@ if (false) {
1083
1082
  /**
1084
1083
  * @template D, R, E
1085
1084
  */
1086
- var /**
1087
- * @template D, R, E
1088
- */
1089
- AbstractActivity = /** @class */ (function (_super) {
1085
+ var AbstractActivity = /** @class */ (function (_super) {
1090
1086
  __extends(AbstractActivity, _super);
1091
1087
  function AbstractActivity() {
1092
1088
  var _this = _super !== null && _super.apply(this, arguments) || this;
1093
- _this._doneListeners = new EventListenerList();
1094
- _this._cancelListeners = new EventListenerList();
1095
- _this._finishListeners = new EventListenerList();
1096
1089
  _this._busyModel = new DelegatingValueModel().withDefault(false);
1097
1090
  return _this;
1098
1091
  }
1099
1092
  /**
1100
- * @param {?} callback
1101
- * @return {?}
1102
- */
1103
- AbstractActivity.prototype.onDone = /**
1104
- * @param {?} callback
1105
- * @return {?}
1106
- */
1107
- function (callback) {
1108
- this._doneListeners.add(callback);
1109
- };
1110
- /**
1111
- * @param {?} callback
1093
+ * @param {?} activityContext
1112
1094
  * @return {?}
1113
1095
  */
1114
- AbstractActivity.prototype.onCancel = /**
1115
- * @param {?} callback
1096
+ AbstractActivity.prototype.initialise = /**
1097
+ * @param {?} activityContext
1116
1098
  * @return {?}
1117
1099
  */
1118
- function (callback) {
1119
- this._cancelListeners.add(callback);
1100
+ function (activityContext) {
1101
+ assert$1.isNil(this.activityContext);
1102
+ this.activityContext = activityContext;
1120
1103
  };
1121
1104
  /**
1122
1105
  * @param {?=} result
@@ -1127,17 +1110,7 @@ AbstractActivity = /** @class */ (function (_super) {
1127
1110
  * @return {?}
1128
1111
  */
1129
1112
  function (result) {
1130
- var _this = this;
1131
- return this._doneListeners
1132
- .fireAndWait((/**
1133
- * @param {?} l
1134
- * @return {?}
1135
- */
1136
- function (l) { return l(result); }))
1137
- .finally((/**
1138
- * @return {?}
1139
- */
1140
- function () { return _this.finalizeAndDispose(); }));
1113
+ return this.activityContext.onDone(result);
1141
1114
  };
1142
1115
  /**
1143
1116
  * @param {?=} error
@@ -1148,17 +1121,7 @@ AbstractActivity = /** @class */ (function (_super) {
1148
1121
  * @return {?}
1149
1122
  */
1150
1123
  function (error) {
1151
- var _this = this;
1152
- return this._cancelListeners
1153
- .fireAndWait((/**
1154
- * @param {?} l
1155
- * @return {?}
1156
- */
1157
- function (l) { return l(error); }))
1158
- .finally((/**
1159
- * @return {?}
1160
- */
1161
- function () { return _this.finalizeAndDispose(); }));
1124
+ this.activityContext.onCancel(error);
1162
1125
  };
1163
1126
  // @Trace()
1164
1127
  // @Trace()
@@ -1172,33 +1135,6 @@ AbstractActivity = /** @class */ (function (_super) {
1172
1135
  */
1173
1136
  function () {
1174
1137
  };
1175
- /**
1176
- * @private
1177
- * @return {?}
1178
- */
1179
- AbstractActivity.prototype.finalizeAndDispose = /**
1180
- * @private
1181
- * @return {?}
1182
- */
1183
- function () {
1184
- // this._activeModel.value = false;
1185
- this._finishListeners.fire((/**
1186
- * @param {?} l
1187
- * @return {?}
1188
- */
1189
- function (l) { return l(); }));
1190
- // this._interactionContext = null;
1191
- // this._initialized = false;
1192
- [
1193
- this._finishListeners,
1194
- this._doneListeners,
1195
- this._cancelListeners
1196
- ].forEach((/**
1197
- * @param {?} l
1198
- * @return {?}
1199
- */
1200
- function (l) { return l.dispose(); }));
1201
- };
1202
1138
  Object.defineProperty(AbstractActivity.prototype, "busy", {
1203
1139
  get: /**
1204
1140
  * @return {?}
@@ -1229,6 +1165,12 @@ AbstractActivity = /** @class */ (function (_super) {
1229
1165
  function () {
1230
1166
  return this._busyModel.value;
1231
1167
  };
1168
+ __decorate([
1169
+ Trace(),
1170
+ __metadata("design:type", Function),
1171
+ __metadata("design:paramtypes", [Object]),
1172
+ __metadata("design:returntype", void 0)
1173
+ ], AbstractActivity.prototype, "initialise", null);
1232
1174
  return AbstractActivity;
1233
1175
  }(DisposableComponent));
1234
1176
  if (false) {
@@ -1236,22 +1178,12 @@ if (false) {
1236
1178
  * @type {?}
1237
1179
  * @private
1238
1180
  */
1239
- AbstractActivity.prototype._doneListeners;
1240
- /**
1241
- * @type {?}
1242
- * @private
1243
- */
1244
- AbstractActivity.prototype._cancelListeners;
1245
- /**
1246
- * @type {?}
1247
- * @private
1248
- */
1249
- AbstractActivity.prototype._finishListeners;
1181
+ AbstractActivity.prototype._busyModel;
1250
1182
  /**
1251
1183
  * @type {?}
1252
1184
  * @private
1253
1185
  */
1254
- AbstractActivity.prototype._busyModel;
1186
+ AbstractActivity.prototype.activityContext;
1255
1187
  }
1256
1188
 
1257
1189
  /**
@@ -1323,7 +1255,7 @@ var ConfirmationDialogComponent = /** @class */ (function (_super) {
1323
1255
  ConfirmationDialogComponent.decorators = [
1324
1256
  { type: Component, args: [{
1325
1257
  selector: 'angular-ui-powerups-confirmation-dialog',
1326
- template: "<h3 matDialogTitle *ngIf=\"confirm.title\">{{confirm.title()}}</h3>\n<div matDialogContent>\n <p *ngFor=\"let line of confirm.content()\">{{line}}</p>\n</div>\n<p matDialogActions>\n <button mat-button (click)=\"cancel()\">{{confirm.cancel()}}</button>\n <button mat-raised-button [color]=\"isDestructive() ? 'warn' : 'primary'\"\n (click)=\"done(true)\">{{confirm.ok()}}</button>\n</p>\n\n",
1258
+ template: "<h3 matDialogTitle *ngIf=\"confirm.title\">{{confirm.title()}}</h3>\n<div matDialogContent>\n <p *ngFor=\"let line of confirm.content()\">{{line}}</p>\n</div>\n<p matDialogActions>\n <button mat-button (click)=\"cancel()\">{{confirm.cancel()}}</button>\n <button mat-raised-button [color]=\"isDestructive() ? 'warn' : 'primary'\"\n (click)=\"done()\">{{confirm.ok()}}</button>\n</p>\n\n",
1327
1259
  styles: [":host{display:block;padding:var(--angular-ui-powerups-default-padding)}.mat-dialog-actions{justify-content:flex-end}"]
1328
1260
  }] }
1329
1261
  ];
@@ -1348,8 +1280,7 @@ var ActivityContainerComponent = /** @class */ (function (_super) {
1348
1280
  var _this = _super.call(this) || this;
1349
1281
  _this.activityOutletTabs = new MutableListModel();
1350
1282
  _this.obsoleteTabs = [];
1351
- var _a = Dsl.disposeWith(_this), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
1352
- _this.lastActivityTab = chain(_this.activityOutletTabs).last().otherwise(_this.initialActivityOutlet);
1283
+ _this.finished = false;
1353
1284
  return _this;
1354
1285
  }
1355
1286
  /**
@@ -1376,16 +1307,38 @@ var ActivityContainerComponent = /** @class */ (function (_super) {
1376
1307
  };
1377
1308
  /**
1378
1309
  * @template D, R, E
1379
- * @param {?} options
1310
+ * @param {?} initialContext
1380
1311
  * @return {?}
1381
1312
  */
1382
1313
  ActivityContainerComponent.prototype.initialise = /**
1383
1314
  * @template D, R, E
1384
- * @param {?} options
1315
+ * @param {?} initialContext
1385
1316
  * @return {?}
1386
1317
  */
1387
- function (options) {
1388
- this.initialActivityOutlet = __assign({}, options, { interactionContext: this });
1318
+ function (initialContext) {
1319
+ /** @type {?} */
1320
+ var self = this;
1321
+ this.initialActivityOutletContext = {
1322
+ activityClass: initialContext.activityClass,
1323
+ activityData: initialContext.activityData,
1324
+ onDone: (/**
1325
+ * @param {?} result
1326
+ * @return {?}
1327
+ */
1328
+ function (result) {
1329
+ self.finished = true;
1330
+ return initialContext.onDone(result);
1331
+ }),
1332
+ onCancel: (/**
1333
+ * @param {?} error
1334
+ * @return {?}
1335
+ */
1336
+ function (error) {
1337
+ self.finished = true;
1338
+ return initialContext.onCancel(error);
1339
+ }),
1340
+ interactionContext: this
1341
+ };
1389
1342
  };
1390
1343
  /**
1391
1344
  * @template D, R, E
@@ -1402,23 +1355,49 @@ var ActivityContainerComponent = /** @class */ (function (_super) {
1402
1355
  function (activityType, data) {
1403
1356
  var _this = this;
1404
1357
  /** @type {?} */
1405
- var deferred = Deferred.defer();
1406
- /** @type {?} */
1407
- var context = {
1408
- interactionContext: this,
1409
- activityClass: activityType,
1410
- activityData: data,
1411
- onDone: deferred.resolve,
1412
- onCancel: deferred.reject
1413
- };
1414
- this.activityOutletTabs.push(context);
1415
- this.tabs.selectedIndex = this.activityOutletTabs.length;
1416
- return deferred.promise.finally((/**
1358
+ var self = this;
1359
+ return new Promise((/**
1360
+ * @param {?} resolve
1361
+ * @param {?} reject
1417
1362
  * @return {?}
1418
1363
  */
1419
- function () {
1420
- _this.obsoleteTabs.push(context);
1421
- _this.tabs.selectedIndex = _this.activityOutletTabs.length - 1;
1364
+ function (resolve, reject) {
1365
+ /** @type {?} */
1366
+ var context = {
1367
+ interactionContext: self,
1368
+ activityClass: activityType,
1369
+ activityData: data,
1370
+ onDone: (/**
1371
+ * @param {?} result
1372
+ * @return {?}
1373
+ */
1374
+ function (result) {
1375
+ self.obsoleteTabs.push(context);
1376
+ // animating on the next tick gives chained done's a chance to
1377
+ // finished before we start an animations
1378
+ resolve(result);
1379
+ setTimeout((/**
1380
+ * @return {?}
1381
+ */
1382
+ function () { return self.animateTabs(); }));
1383
+ }),
1384
+ onCancel: (/**
1385
+ * @param {?} error
1386
+ * @return {?}
1387
+ */
1388
+ function (error) {
1389
+ self.obsoleteTabs.push(context);
1390
+ // finished before we start an animations
1391
+ reject(error);
1392
+ // animating on the next tick gives chained done's a chance to complete before we animate
1393
+ setTimeout((/**
1394
+ * @return {?}
1395
+ */
1396
+ function () { return self.animateTabs(); }));
1397
+ })
1398
+ };
1399
+ self.activityOutletTabs.push(context);
1400
+ self.tabs.selectedIndex = _this.activityOutletTabs.length;
1422
1401
  }));
1423
1402
  };
1424
1403
  /**
@@ -1460,12 +1439,26 @@ var ActivityContainerComponent = /** @class */ (function (_super) {
1460
1439
  function (tab) {
1461
1440
  return !_this.obsoleteTabs.includes(tab);
1462
1441
  }));
1442
+ this.obsoleteTabs = [];
1463
1443
  this.outlets.toArray()[this.tabs.selectedIndex].notifyReady();
1464
1444
  };
1445
+ /**
1446
+ * @private
1447
+ * @return {?}
1448
+ */
1449
+ ActivityContainerComponent.prototype.animateTabs = /**
1450
+ * @private
1451
+ * @return {?}
1452
+ */
1453
+ function () {
1454
+ if (!this.finished) {
1455
+ this.tabs.selectedIndex = this.activityOutletTabs.length - this.obsoleteTabs.length;
1456
+ }
1457
+ };
1465
1458
  ActivityContainerComponent.decorators = [
1466
1459
  { type: Component, args: [{
1467
1460
  selector: 'angular-ui-powerups-activity-container',
1468
- template: "<mat-tab-group #tabs no-tab-header [dynamicHeight]=\"true\">\n <mat-tab>\n <angular-ui-powerups-activity-outlet [interactionContext]=\"this\"\n [activityContext]=\"initialActivityOutlet\"></angular-ui-powerups-activity-outlet>\n </mat-tab>\n <mat-tab *ngFor=\"let tab of activityOutletTabs.value\">\n <angular-ui-powerups-activity-outlet [interactionContext]=\"this\"\n [activityContext]=\"tab\"></angular-ui-powerups-activity-outlet>\n </mat-tab>\n</mat-tab-group>\n",
1461
+ template: "<mat-tab-group #tabs no-tab-header [dynamicHeight]=\"true\">\n <mat-tab>\n <angular-ui-powerups-activity-outlet [interactionContext]=\"this\"\n [activityContext]=\"initialActivityOutletContext\"></angular-ui-powerups-activity-outlet>\n </mat-tab>\n <mat-tab *ngFor=\"let tab of activityOutletTabs.value\">\n <angular-ui-powerups-activity-outlet [interactionContext]=\"this\"\n [activityContext]=\"tab\"></angular-ui-powerups-activity-outlet>\n </mat-tab>\n</mat-tab-group>\n",
1469
1462
  styles: [":host{display:block}"]
1470
1463
  }] }
1471
1464
  ];
@@ -1473,7 +1466,7 @@ var ActivityContainerComponent = /** @class */ (function (_super) {
1473
1466
  ActivityContainerComponent.ctorParameters = function () { return []; };
1474
1467
  ActivityContainerComponent.propDecorators = {
1475
1468
  parentInteractionContext: [{ type: Input }],
1476
- initialActivityOutlet: [{ type: Input }],
1469
+ initialActivityOutletContext: [{ type: Input }],
1477
1470
  tabs: [{ type: ViewChild, args: ['tabs', { static: true },] }],
1478
1471
  outlets: [{ type: ViewChildren, args: [ActivityOutletComponent,] }]
1479
1472
  };
@@ -1483,7 +1476,7 @@ if (false) {
1483
1476
  /** @type {?} */
1484
1477
  ActivityContainerComponent.prototype.parentInteractionContext;
1485
1478
  /** @type {?} */
1486
- ActivityContainerComponent.prototype.initialActivityOutlet;
1479
+ ActivityContainerComponent.prototype.initialActivityOutletContext;
1487
1480
  /** @type {?} */
1488
1481
  ActivityContainerComponent.prototype.tabs;
1489
1482
  /** @type {?} */
@@ -1499,7 +1492,7 @@ if (false) {
1499
1492
  * @type {?}
1500
1493
  * @private
1501
1494
  */
1502
- ActivityContainerComponent.prototype.lastActivityTab;
1495
+ ActivityContainerComponent.prototype.finished;
1503
1496
  }
1504
1497
  (function (ActivityContainerComponent) {
1505
1498
  /**
@@ -1528,10 +1521,10 @@ if (false) {
1528
1521
  var DIALOG_INTERACTION_SERVICE_DEFAULTS = new InjectionToken('DIALOG_INTERACTION_SERVICE_DEFAULTS');
1529
1522
  var DialogInteractionService = /** @class */ (function (_super) {
1530
1523
  __extends(DialogInteractionService, _super);
1531
- function DialogInteractionService(dialogService, dialogDefaults, matDialogDefaultConfig) {
1524
+ function DialogInteractionService(dialogService, dialogServiceDefaults, matDialogDefaultConfig) {
1532
1525
  var _this = _super.call(this) || this;
1533
1526
  _this.dialogService = dialogService;
1534
- _this.dialogDefaults = dialogDefaults;
1527
+ _this.dialogServiceDefaults = dialogServiceDefaults;
1535
1528
  _this.matDialogDefaultConfig = matDialogDefaultConfig;
1536
1529
  assert$1.notNil(dialogService);
1537
1530
  return _this;
@@ -1571,7 +1564,7 @@ var DialogInteractionService = /** @class */ (function (_super) {
1571
1564
  var _this = this;
1572
1565
  if (disableClose === void 0) { disableClose = true; }
1573
1566
  /** @type {?} */
1574
- var config = __assign({ autoFocus: false }, this.matDialogDefaultConfig, this.dialogDefaults, {
1567
+ var config = __assign({ autoFocus: false, hasBackdrop: true }, this.matDialogDefaultConfig, this.dialogServiceDefaults, {
1575
1568
  data: data,
1576
1569
  disableClose: disableClose,
1577
1570
  panelClass: 'dialog-interaction-service'
@@ -1655,7 +1648,7 @@ if (false) {
1655
1648
  */
1656
1649
  DialogInteractionService.prototype.dialogService;
1657
1650
  /** @type {?} */
1658
- DialogInteractionService.prototype.dialogDefaults;
1651
+ DialogInteractionService.prototype.dialogServiceDefaults;
1659
1652
  /** @type {?} */
1660
1653
  DialogInteractionService.prototype.matDialogDefaultConfig;
1661
1654
  }