@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 { __decorate, __metadata, __awaiter } 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';
@@ -697,15 +696,10 @@ if (false) {
697
696
  /** @type {?} */
698
697
  Activity.prototype.busy;
699
698
  /**
700
- * @param {?} callback
701
- * @return {?}
702
- */
703
- Activity.prototype.onDone = function (callback) { };
704
- /**
705
- * @param {?} callback
699
+ * @param {?} activityContext
706
700
  * @return {?}
707
701
  */
708
- Activity.prototype.onCancel = function (callback) { };
702
+ Activity.prototype.initialise = function (activityContext) { };
709
703
  }
710
704
 
711
705
  /**
@@ -764,8 +758,7 @@ class ActivityOutletComponent {
764
758
  const componentFactory = this.componentFactoryResolver.resolveComponentFactory(activityContext.activityClass);
765
759
  this.viewContainerRef.clear();
766
760
  this.activityComponentRef = this.viewContainerRef.createComponent(componentFactory, 0, injector);
767
- this.activityComponentRef.instance.onDone(activityContext.onDone);
768
- this.activityComponentRef.instance.onCancel(activityContext.onCancel);
761
+ this.activityComponentRef.instance.initialise(activityContext);
769
762
  }
770
763
  /**
771
764
  * @param {?} alert
@@ -816,6 +809,12 @@ ActivityOutletComponent.propDecorators = {
816
809
  interactionContext: [{ type: Input }],
817
810
  activityContext: [{ type: Input }]
818
811
  };
812
+ __decorate([
813
+ Trace(),
814
+ __metadata("design:type", Function),
815
+ __metadata("design:paramtypes", [Object]),
816
+ __metadata("design:returntype", void 0)
817
+ ], ActivityOutletComponent.prototype, "loadActivity", null);
819
818
  if (false) {
820
819
  /** @type {?} */
821
820
  ActivityOutletComponent.prototype.interactionContext;
@@ -896,56 +895,29 @@ if (false) {
896
895
  class AbstractActivity extends DisposableComponent {
897
896
  constructor() {
898
897
  super(...arguments);
899
- this._doneListeners = new EventListenerList();
900
- this._cancelListeners = new EventListenerList();
901
- this._finishListeners = new EventListenerList();
902
898
  this._busyModel = new DelegatingValueModel().withDefault(false);
903
899
  }
904
900
  /**
905
- * @param {?} callback
906
- * @return {?}
907
- */
908
- onDone(callback) {
909
- this._doneListeners.add(callback);
910
- }
911
- /**
912
- * @param {?} callback
901
+ * @param {?} activityContext
913
902
  * @return {?}
914
903
  */
915
- onCancel(callback) {
916
- this._cancelListeners.add(callback);
904
+ initialise(activityContext) {
905
+ assert$1.isNil(this.activityContext);
906
+ this.activityContext = activityContext;
917
907
  }
918
908
  /**
919
909
  * @param {?=} result
920
910
  * @return {?}
921
911
  */
922
912
  done(result) {
923
- return this._doneListeners
924
- .fireAndWait((/**
925
- * @param {?} l
926
- * @return {?}
927
- */
928
- l => l(result)))
929
- .finally((/**
930
- * @return {?}
931
- */
932
- () => this.finalizeAndDispose()));
913
+ return this.activityContext.onDone(result);
933
914
  }
934
915
  /**
935
916
  * @param {?=} error
936
917
  * @return {?}
937
918
  */
938
919
  cancel(error) {
939
- return this._cancelListeners
940
- .fireAndWait((/**
941
- * @param {?} l
942
- * @return {?}
943
- */
944
- l => l(error)))
945
- .finally((/**
946
- * @return {?}
947
- */
948
- () => this.finalizeAndDispose()));
920
+ this.activityContext.onCancel(error);
949
921
  }
950
922
  // @Trace()
951
923
  /**
@@ -953,29 +925,6 @@ class AbstractActivity extends DisposableComponent {
953
925
  */
954
926
  onActivityReady() {
955
927
  }
956
- /**
957
- * @private
958
- * @return {?}
959
- */
960
- finalizeAndDispose() {
961
- // this._activeModel.value = false;
962
- this._finishListeners.fire((/**
963
- * @param {?} l
964
- * @return {?}
965
- */
966
- l => l()));
967
- // this._interactionContext = null;
968
- // this._initialized = false;
969
- [
970
- this._finishListeners,
971
- this._doneListeners,
972
- this._cancelListeners
973
- ].forEach((/**
974
- * @param {?} l
975
- * @return {?}
976
- */
977
- l => l.dispose()));
978
- }
979
928
  /**
980
929
  * @return {?}
981
930
  */
@@ -996,27 +945,23 @@ class AbstractActivity extends DisposableComponent {
996
945
  return this._busyModel.value;
997
946
  }
998
947
  }
948
+ __decorate([
949
+ Trace(),
950
+ __metadata("design:type", Function),
951
+ __metadata("design:paramtypes", [Object]),
952
+ __metadata("design:returntype", void 0)
953
+ ], AbstractActivity.prototype, "initialise", null);
999
954
  if (false) {
1000
955
  /**
1001
956
  * @type {?}
1002
957
  * @private
1003
958
  */
1004
- AbstractActivity.prototype._doneListeners;
1005
- /**
1006
- * @type {?}
1007
- * @private
1008
- */
1009
- AbstractActivity.prototype._cancelListeners;
1010
- /**
1011
- * @type {?}
1012
- * @private
1013
- */
1014
- AbstractActivity.prototype._finishListeners;
959
+ AbstractActivity.prototype._busyModel;
1015
960
  /**
1016
961
  * @type {?}
1017
962
  * @private
1018
963
  */
1019
- AbstractActivity.prototype._busyModel;
964
+ AbstractActivity.prototype.activityContext;
1020
965
  }
1021
966
 
1022
967
  /**
@@ -1081,7 +1026,7 @@ class ConfirmationDialogComponent extends AbstractActivity {
1081
1026
  ConfirmationDialogComponent.decorators = [
1082
1027
  { type: Component, args: [{
1083
1028
  selector: 'angular-ui-powerups-confirmation-dialog',
1084
- 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",
1029
+ 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",
1085
1030
  styles: [":host{display:block;padding:var(--angular-ui-powerups-default-padding)}.mat-dialog-actions{justify-content:flex-end}"]
1086
1031
  }] }
1087
1032
  ];
@@ -1103,8 +1048,7 @@ class ActivityContainerComponent extends DisposableComponent {
1103
1048
  super();
1104
1049
  this.activityOutletTabs = new MutableListModel();
1105
1050
  this.obsoleteTabs = [];
1106
- const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);
1107
- this.lastActivityTab = chain(this.activityOutletTabs).last().otherwise(this.initialActivityOutlet);
1051
+ this.finished = false;
1108
1052
  }
1109
1053
  /**
1110
1054
  * @return {?}
@@ -1123,11 +1067,33 @@ class ActivityContainerComponent extends DisposableComponent {
1123
1067
  }
1124
1068
  /**
1125
1069
  * @template D, R, E
1126
- * @param {?} options
1070
+ * @param {?} initialContext
1127
1071
  * @return {?}
1128
1072
  */
1129
- initialise(options) {
1130
- this.initialActivityOutlet = Object.assign({}, options, { interactionContext: this });
1073
+ initialise(initialContext) {
1074
+ /** @type {?} */
1075
+ const self = this;
1076
+ this.initialActivityOutletContext = {
1077
+ activityClass: initialContext.activityClass,
1078
+ activityData: initialContext.activityData,
1079
+ onDone: (/**
1080
+ * @param {?} result
1081
+ * @return {?}
1082
+ */
1083
+ function (result) {
1084
+ self.finished = true;
1085
+ return initialContext.onDone(result);
1086
+ }),
1087
+ onCancel: (/**
1088
+ * @param {?} error
1089
+ * @return {?}
1090
+ */
1091
+ function (error) {
1092
+ self.finished = true;
1093
+ return initialContext.onCancel(error);
1094
+ }),
1095
+ interactionContext: this
1096
+ };
1131
1097
  }
1132
1098
  /**
1133
1099
  * @template D, R, E
@@ -1137,23 +1103,49 @@ class ActivityContainerComponent extends DisposableComponent {
1137
1103
  */
1138
1104
  startActivity(activityType, data) {
1139
1105
  /** @type {?} */
1140
- const deferred = Deferred.defer();
1141
- /** @type {?} */
1142
- const context = {
1143
- interactionContext: this,
1144
- activityClass: activityType,
1145
- activityData: data,
1146
- onDone: deferred.resolve,
1147
- onCancel: deferred.reject
1148
- };
1149
- this.activityOutletTabs.push(context);
1150
- this.tabs.selectedIndex = this.activityOutletTabs.length;
1151
- return deferred.promise.finally((/**
1106
+ const self = this;
1107
+ return new Promise((/**
1108
+ * @param {?} resolve
1109
+ * @param {?} reject
1152
1110
  * @return {?}
1153
1111
  */
1154
- () => {
1155
- this.obsoleteTabs.push(context);
1156
- this.tabs.selectedIndex = this.activityOutletTabs.length - 1;
1112
+ (resolve, reject) => {
1113
+ /** @type {?} */
1114
+ const context = {
1115
+ interactionContext: self,
1116
+ activityClass: activityType,
1117
+ activityData: data,
1118
+ onDone: (/**
1119
+ * @param {?} result
1120
+ * @return {?}
1121
+ */
1122
+ function (result) {
1123
+ self.obsoleteTabs.push(context);
1124
+ // animating on the next tick gives chained done's a chance to
1125
+ // finished before we start an animations
1126
+ resolve(result);
1127
+ setTimeout((/**
1128
+ * @return {?}
1129
+ */
1130
+ () => self.animateTabs()));
1131
+ }),
1132
+ onCancel: (/**
1133
+ * @param {?} error
1134
+ * @return {?}
1135
+ */
1136
+ function (error) {
1137
+ self.obsoleteTabs.push(context);
1138
+ // finished before we start an animations
1139
+ reject(error);
1140
+ // animating on the next tick gives chained done's a chance to complete before we animate
1141
+ setTimeout((/**
1142
+ * @return {?}
1143
+ */
1144
+ () => self.animateTabs()));
1145
+ })
1146
+ };
1147
+ self.activityOutletTabs.push(context);
1148
+ self.tabs.selectedIndex = this.activityOutletTabs.length;
1157
1149
  }));
1158
1150
  }
1159
1151
  /**
@@ -1182,13 +1174,23 @@ class ActivityContainerComponent extends DisposableComponent {
1182
1174
  tab => {
1183
1175
  return !this.obsoleteTabs.includes(tab);
1184
1176
  }));
1177
+ this.obsoleteTabs = [];
1185
1178
  this.outlets.toArray()[this.tabs.selectedIndex].notifyReady();
1186
1179
  }
1180
+ /**
1181
+ * @private
1182
+ * @return {?}
1183
+ */
1184
+ animateTabs() {
1185
+ if (!this.finished) {
1186
+ this.tabs.selectedIndex = this.activityOutletTabs.length - this.obsoleteTabs.length;
1187
+ }
1188
+ }
1187
1189
  }
1188
1190
  ActivityContainerComponent.decorators = [
1189
1191
  { type: Component, args: [{
1190
1192
  selector: 'angular-ui-powerups-activity-container',
1191
- 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",
1193
+ 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",
1192
1194
  styles: [":host{display:block}"]
1193
1195
  }] }
1194
1196
  ];
@@ -1196,7 +1198,7 @@ ActivityContainerComponent.decorators = [
1196
1198
  ActivityContainerComponent.ctorParameters = () => [];
1197
1199
  ActivityContainerComponent.propDecorators = {
1198
1200
  parentInteractionContext: [{ type: Input }],
1199
- initialActivityOutlet: [{ type: Input }],
1201
+ initialActivityOutletContext: [{ type: Input }],
1200
1202
  tabs: [{ type: ViewChild, args: ['tabs', { static: true },] }],
1201
1203
  outlets: [{ type: ViewChildren, args: [ActivityOutletComponent,] }]
1202
1204
  };
@@ -1204,7 +1206,7 @@ if (false) {
1204
1206
  /** @type {?} */
1205
1207
  ActivityContainerComponent.prototype.parentInteractionContext;
1206
1208
  /** @type {?} */
1207
- ActivityContainerComponent.prototype.initialActivityOutlet;
1209
+ ActivityContainerComponent.prototype.initialActivityOutletContext;
1208
1210
  /** @type {?} */
1209
1211
  ActivityContainerComponent.prototype.tabs;
1210
1212
  /** @type {?} */
@@ -1220,7 +1222,7 @@ if (false) {
1220
1222
  * @type {?}
1221
1223
  * @private
1222
1224
  */
1223
- ActivityContainerComponent.prototype.lastActivityTab;
1225
+ ActivityContainerComponent.prototype.finished;
1224
1226
  }
1225
1227
  (function (ActivityContainerComponent) {
1226
1228
  /**
@@ -1250,13 +1252,13 @@ const DIALOG_INTERACTION_SERVICE_DEFAULTS = new InjectionToken('DIALOG_INTERACTI
1250
1252
  class DialogInteractionService extends InteractionContext {
1251
1253
  /**
1252
1254
  * @param {?} dialogService
1253
- * @param {?} dialogDefaults
1255
+ * @param {?} dialogServiceDefaults
1254
1256
  * @param {?} matDialogDefaultConfig
1255
1257
  */
1256
- constructor(dialogService, dialogDefaults, matDialogDefaultConfig) {
1258
+ constructor(dialogService, dialogServiceDefaults, matDialogDefaultConfig) {
1257
1259
  super();
1258
1260
  this.dialogService = dialogService;
1259
- this.dialogDefaults = dialogDefaults;
1261
+ this.dialogServiceDefaults = dialogServiceDefaults;
1260
1262
  this.matDialogDefaultConfig = matDialogDefaultConfig;
1261
1263
  assert$1.notNil(dialogService);
1262
1264
  }
@@ -1279,7 +1281,7 @@ class DialogInteractionService extends InteractionContext {
1279
1281
  */
1280
1282
  _startActivity(activityType, data, disableClose = true) {
1281
1283
  /** @type {?} */
1282
- const config = Object.assign({ autoFocus: false }, this.matDialogDefaultConfig, this.dialogDefaults, {
1284
+ const config = Object.assign({ autoFocus: false, hasBackdrop: true }, this.matDialogDefaultConfig, this.dialogServiceDefaults, {
1283
1285
  data,
1284
1286
  disableClose,
1285
1287
  panelClass: 'dialog-interaction-service'
@@ -1354,7 +1356,7 @@ if (false) {
1354
1356
  */
1355
1357
  DialogInteractionService.prototype.dialogService;
1356
1358
  /** @type {?} */
1357
- DialogInteractionService.prototype.dialogDefaults;
1359
+ DialogInteractionService.prototype.dialogServiceDefaults;
1358
1360
  /** @type {?} */
1359
1361
  DialogInteractionService.prototype.matDialogDefaultConfig;
1360
1362
  }