@coolon/angular-ui-powerups 0.0.61 → 0.0.62

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 (40) hide show
  1. package/bundles/coolon-angular-ui-powerups.umd.js +419 -117
  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/coolon-angular-ui-powerups.js +2 -2
  7. package/esm2015/index.js +2 -2
  8. package/esm2015/lib/interaction/activity.js +11 -1
  9. package/esm2015/lib/interaction/components/activity-container/activity-container.component.js +49 -1
  10. package/esm2015/lib/interaction/components/activity-outlet/activity-outlet.component.js +7 -56
  11. package/esm2015/lib/interaction/guards/close-interaction.guard.js +62 -0
  12. package/esm2015/lib/interaction/index.js +3 -2
  13. package/esm2015/lib/interaction/interaction-context.js +25 -5
  14. package/esm2015/lib/interaction/services/dialog-interaction.service.js +93 -4
  15. package/esm2015/lib/place/guards/leave-place.guard.js +128 -20
  16. package/esm2015/public_api.js +2 -2
  17. package/esm5/coolon-angular-ui-powerups.js +2 -2
  18. package/esm5/index.js +2 -2
  19. package/esm5/lib/interaction/activity.js +11 -1
  20. package/esm5/lib/interaction/components/activity-container/activity-container.component.js +67 -1
  21. package/esm5/lib/interaction/components/activity-outlet/activity-outlet.component.js +11 -78
  22. package/esm5/lib/interaction/guards/close-interaction.guard.js +66 -0
  23. package/esm5/lib/interaction/index.js +3 -2
  24. package/esm5/lib/interaction/interaction-context.js +33 -6
  25. package/esm5/lib/interaction/services/dialog-interaction.service.js +109 -4
  26. package/esm5/lib/place/guards/leave-place.guard.js +131 -20
  27. package/esm5/public_api.js +2 -2
  28. package/fesm2015/coolon-angular-ui-powerups.js +355 -82
  29. package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
  30. package/fesm5/coolon-angular-ui-powerups.js +406 -105
  31. package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
  32. package/lib/interaction/activity.d.ts +2 -0
  33. package/lib/interaction/components/activity-container/activity-container.component.d.ts +10 -1
  34. package/lib/interaction/components/activity-outlet/activity-outlet.component.d.ts +2 -9
  35. package/lib/interaction/guards/close-interaction.guard.d.ts +12 -0
  36. package/lib/interaction/index.d.ts +1 -0
  37. package/lib/interaction/interaction-context.d.ts +17 -4
  38. package/lib/interaction/services/dialog-interaction.service.d.ts +14 -2
  39. package/lib/place/guards/leave-place.guard.d.ts +7 -1
  40. package/package.json +1 -1
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core'), require('@angular/forms'), require('@angular/material'), require('@angular/material/tabs'), require('@angular/platform-browser/animations'), require('@coolon/pectin'), require('@angular/cdk/portal'), require('@coolon/typescript-utilities'), require('@angular/material/dialog'), require('@angular/material/icon'), require('@angular/material/list'), require('@angular/material/tooltip'), require('@angular/router'), require('@typescript-plus/fast-memoize-decorator/dist/src'), require('@typescript-plus/fast-memoize-decorator'), require('reflect-metadata'), require('lodash'), require('@angular/animations'), require('resize-observer-polyfill')) :
3
- typeof define === 'function' && define.amd ? define('@coolon/angular-ui-powerups', ['exports', '@angular/common', '@angular/core', '@angular/forms', '@angular/material', '@angular/material/tabs', '@angular/platform-browser/animations', '@coolon/pectin', '@angular/cdk/portal', '@coolon/typescript-utilities', '@angular/material/dialog', '@angular/material/icon', '@angular/material/list', '@angular/material/tooltip', '@angular/router', '@typescript-plus/fast-memoize-decorator/dist/src', '@typescript-plus/fast-memoize-decorator', 'reflect-metadata', 'lodash', '@angular/animations', 'resize-observer-polyfill'], factory) :
4
- (global = global || self, factory((global.coolon = global.coolon || {}, global.coolon['angular-ui-powerups'] = {}), global.ng.common, global.ng.core, global.ng.forms, global.ng.material, global.ng.material.tabs, global.ng.platformBrowser.animations, global.pectin, global.ng.cdk.portal, global.typescriptUtilities, global.ng.material.dialog, global.ng.material.icon, global.ng.material.list, global.ng.material.tooltip, global.ng.router, global.src, global.fastMemoizeDecorator, null, global.___default, global.ng.animations, global.ResizeObserver));
5
- }(this, function (exports, common, core, forms, material, tabs, animations, pectin, portal, typescriptUtilities, dialog, icon, list, tooltip, router, src, fastMemoizeDecorator, reflectMetadata, ___default, animations$1, ResizeObserver) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core'), require('@angular/forms'), require('@angular/material'), require('@angular/material/tabs'), require('@angular/platform-browser/animations'), require('@coolon/pectin'), require('@angular/cdk/portal'), require('@coolon/typescript-utilities'), require('@angular/material/dialog'), require('@angular/router'), require('@angular/material/icon'), require('@angular/material/list'), require('@angular/material/tooltip'), require('@typescript-plus/fast-memoize-decorator/dist/src'), require('@typescript-plus/fast-memoize-decorator'), require('reflect-metadata'), require('lodash'), require('@angular/animations'), require('resize-observer-polyfill')) :
3
+ typeof define === 'function' && define.amd ? define('@coolon/angular-ui-powerups', ['exports', '@angular/common', '@angular/core', '@angular/forms', '@angular/material', '@angular/material/tabs', '@angular/platform-browser/animations', '@coolon/pectin', '@angular/cdk/portal', '@coolon/typescript-utilities', '@angular/material/dialog', '@angular/router', '@angular/material/icon', '@angular/material/list', '@angular/material/tooltip', '@typescript-plus/fast-memoize-decorator/dist/src', '@typescript-plus/fast-memoize-decorator', 'reflect-metadata', 'lodash', '@angular/animations', 'resize-observer-polyfill'], factory) :
4
+ (global = global || self, factory((global.coolon = global.coolon || {}, global.coolon['angular-ui-powerups'] = {}), global.ng.common, global.ng.core, global.ng.forms, global.ng.material, global.ng.material.tabs, global.ng.platformBrowser.animations, global.pectin, global.ng.cdk.portal, global.typescriptUtilities, global.ng.material.dialog, global.ng.router, global.ng.material.icon, global.ng.material.list, global.ng.material.tooltip, global.src, global.fastMemoizeDecorator, null, global.___default, global.ng.animations, global.ResizeObserver));
5
+ }(this, function (exports, common, core, forms, material, tabs, animations, pectin, portal, typescriptUtilities, dialog, router, icon, list, tooltip, src, fastMemoizeDecorator, reflectMetadata, ___default, animations$1, ResizeObserver) { 'use strict';
6
6
 
7
7
  var ___default__default = 'default' in ___default ? ___default['default'] : ___default;
8
8
  ResizeObserver = ResizeObserver && ResizeObserver.hasOwnProperty('default') ? ResizeObserver['default'] : ResizeObserver;
@@ -980,20 +980,46 @@
980
980
  * @fileoverview added by tsickle
981
981
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
982
982
  */
983
- /** @type {?} */
984
- var INTERACTION_CONTEXT = new core.InjectionToken('InteractionContext');
985
983
  /**
986
984
  * @abstract
987
985
  */
988
986
  var /**
989
987
  * @abstract
990
988
  */
991
- InteractionContext = /** @class */ (function () {
989
+ InteractionContext = /** @class */ (function (_super) {
990
+ __extends(InteractionContext, _super);
992
991
  function InteractionContext() {
992
+ return _super.call(this) || this;
993
993
  }
994
+ /**
995
+ * Returns true if an activity is currently running.
996
+ */
997
+ /**
998
+ * Returns true if an activity is currently running.
999
+ * @return {?}
1000
+ */
1001
+ InteractionContext.prototype.isActive = /**
1002
+ * Returns true if an activity is currently running.
1003
+ * @return {?}
1004
+ */
1005
+ function () {
1006
+ return this.activityList.length > 0;
1007
+ };
994
1008
  return InteractionContext;
995
- }());
1009
+ }(pectin.GarbageCollector));
996
1010
  if (false) {
1011
+ /**
1012
+ * Returns the activity that is currently active.
1013
+ * This model is only updated in the next tick after the view has been updated.
1014
+ * @type {?}
1015
+ */
1016
+ InteractionContext.prototype.currentActivity;
1017
+ /**
1018
+ * Returns the current list of activities that are in progress.
1019
+ * This model is only updated in the next tick after the view has been updated.
1020
+ * @type {?}
1021
+ */
1022
+ InteractionContext.prototype.activityList;
997
1023
  /**
998
1024
  * @abstract
999
1025
  * @template D, R, E
@@ -1045,6 +1071,16 @@
1045
1071
  * @return {?}
1046
1072
  */
1047
1073
  Activity.prototype.initialise = function (activityContext) { };
1074
+ /**
1075
+ * @param {?} result
1076
+ * @return {?}
1077
+ */
1078
+ Activity.prototype.done = function (result) { };
1079
+ /**
1080
+ * @param {?} e
1081
+ * @return {?}
1082
+ */
1083
+ Activity.prototype.cancel = function (e) { };
1048
1084
  }
1049
1085
 
1050
1086
  /**
@@ -1059,7 +1095,7 @@
1059
1095
  * <activity-view [activityClass]="...", [activityData]="..." (done)=".." (cancel)="..."></activity-view>
1060
1096
  * @template D, R, E
1061
1097
  */
1062
- exports.ɵv = /** @class */ (function () {
1098
+ var ActivityOutletComponent = /** @class */ (function () {
1063
1099
  function ActivityOutletComponent(componentFactoryResolver, viewContainerRef, injector) {
1064
1100
  this.componentFactoryResolver = componentFactoryResolver;
1065
1101
  this.viewContainerRef = viewContainerRef;
@@ -1111,6 +1147,16 @@
1111
1147
  this.activityComponentRef = this.viewContainerRef.createComponent(componentFactory, 0, injector);
1112
1148
  this.activityComponentRef.instance.initialise(activityContext);
1113
1149
  };
1150
+ Object.defineProperty(ActivityOutletComponent.prototype, "component", {
1151
+ get: /**
1152
+ * @return {?}
1153
+ */
1154
+ function () {
1155
+ return this.activityComponentRef.instance;
1156
+ },
1157
+ enumerable: true,
1158
+ configurable: true
1159
+ });
1114
1160
  /**
1115
1161
  * @param {?} alert
1116
1162
  * @return {?}
@@ -1197,105 +1243,29 @@
1197
1243
  }());
1198
1244
  if (false) {
1199
1245
  /** @type {?} */
1200
- exports.ɵv.prototype.interactionContext;
1246
+ ActivityOutletComponent.prototype.interactionContext;
1201
1247
  /**
1202
1248
  * @type {?}
1203
1249
  * @private
1204
1250
  */
1205
- exports.ɵv.prototype.activityComponentRef;
1251
+ ActivityOutletComponent.prototype.activityComponentRef;
1206
1252
  /**
1207
1253
  * @type {?}
1208
1254
  * @private
1209
1255
  */
1210
- exports.ɵv.prototype.componentFactoryResolver;
1256
+ ActivityOutletComponent.prototype.componentFactoryResolver;
1211
1257
  /**
1212
1258
  * @type {?}
1213
1259
  * @private
1214
1260
  */
1215
- exports.ɵv.prototype.viewContainerRef;
1261
+ ActivityOutletComponent.prototype.viewContainerRef;
1216
1262
  /**
1217
1263
  * @type {?}
1218
1264
  * @private
1219
1265
  */
1220
- exports.ɵv.prototype.injector;
1266
+ ActivityOutletComponent.prototype.injector;
1221
1267
  /* Skipping unhandled member: ;*/
1222
1268
  }
1223
- (function (ActivityOutletComponent) {
1224
- /**
1225
- * @template D, R, E
1226
- */
1227
- var /**
1228
- * @template D, R, E
1229
- */
1230
- OutletInteractionContext = /** @class */ (function () {
1231
- function OutletInteractionContext(context) {
1232
- this.context = context;
1233
- }
1234
- /**
1235
- * @param {?} alert
1236
- * @return {?}
1237
- */
1238
- OutletInteractionContext.prototype.alert = /**
1239
- * @param {?} alert
1240
- * @return {?}
1241
- */
1242
- function (alert) {
1243
- return pectin.lang.notImplemented();
1244
- };
1245
- /**
1246
- * @param {?} confirm
1247
- * @return {?}
1248
- */
1249
- OutletInteractionContext.prototype.confirm = /**
1250
- * @param {?} confirm
1251
- * @return {?}
1252
- */
1253
- function (confirm) {
1254
- return pectin.lang.notImplemented();
1255
- };
1256
- /**
1257
- * @template D1, R1, E1
1258
- * @param {?} confirm
1259
- * @param {?} activityType
1260
- * @param {?=} data
1261
- * @return {?}
1262
- */
1263
- OutletInteractionContext.prototype.confirmThen = /**
1264
- * @template D1, R1, E1
1265
- * @param {?} confirm
1266
- * @param {?} activityType
1267
- * @param {?=} data
1268
- * @return {?}
1269
- */
1270
- function (confirm, activityType, data) {
1271
- return pectin.lang.notImplemented();
1272
- };
1273
- /**
1274
- * @template D1, R1, E1
1275
- * @param {?} activityType
1276
- * @param {?=} data
1277
- * @return {?}
1278
- */
1279
- OutletInteractionContext.prototype.startActivity = /**
1280
- * @template D1, R1, E1
1281
- * @param {?} activityType
1282
- * @param {?=} data
1283
- * @return {?}
1284
- */
1285
- function (activityType, data) {
1286
- return pectin.lang.notImplemented();
1287
- };
1288
- return OutletInteractionContext;
1289
- }());
1290
- ActivityOutletComponent.OutletInteractionContext = OutletInteractionContext;
1291
- if (false) {
1292
- /**
1293
- * @type {?}
1294
- * @private
1295
- */
1296
- OutletInteractionContext.prototype.context;
1297
- }
1298
- })(exports.ɵv || (exports.ɵv = {}));
1299
1269
 
1300
1270
  /**
1301
1271
  * @fileoverview added by tsickle
@@ -1600,8 +1570,28 @@
1600
1570
  _this.activityOutletTabs = new pectin.MutableListModel();
1601
1571
  _this.obsoleteTabs = [];
1602
1572
  _this.finished = false;
1573
+ _this._activityList = new pectin.MutableListModel();
1603
1574
  return _this;
1604
1575
  }
1576
+ /**
1577
+ * @return {?}
1578
+ */
1579
+ ActivityContainerComponent.prototype.isActive = /**
1580
+ * @return {?}
1581
+ */
1582
+ function () {
1583
+ return this.parentInteractionContext.isActive();
1584
+ };
1585
+ Object.defineProperty(ActivityContainerComponent.prototype, "activityList", {
1586
+ get: /**
1587
+ * @return {?}
1588
+ */
1589
+ function () {
1590
+ return this._activityList.readonly;
1591
+ },
1592
+ enumerable: true,
1593
+ configurable: true
1594
+ });
1605
1595
  /**
1606
1596
  * @return {?}
1607
1597
  */
@@ -1619,11 +1609,50 @@
1619
1609
  function () {
1620
1610
  var _this = this;
1621
1611
  var observe = pectin.Dsl.disposeWith(this).observe;
1612
+ this._activityList.value = this.outlets.toArray().map((/**
1613
+ * @param {?} c
1614
+ * @return {?}
1615
+ */
1616
+ function (c) { return c.component; }));
1617
+ observe.valuesFrom(this.outlets.changes).subscribe((/**
1618
+ * @param {?} change
1619
+ * @return {?}
1620
+ */
1621
+ function (change) {
1622
+ _this.safelyUpdateActivityList(change.map((/**
1623
+ * @param {?} c
1624
+ * @return {?}
1625
+ */
1626
+ function (c) { return c.component; })));
1627
+ }));
1622
1628
  observe.valuesFrom(this.tabs.animationDone).subscribe((/**
1623
1629
  * @return {?}
1624
1630
  */
1625
1631
  function () { return _this.onAnimationFinished(); }));
1626
1632
  };
1633
+ /**
1634
+ * Update in the next tick to avoid changing state in the current change detection cycle.
1635
+ * @param activities
1636
+ */
1637
+ /**
1638
+ * Update in the next tick to avoid changing state in the current change detection cycle.
1639
+ * @private
1640
+ * @param {?} activities
1641
+ * @return {?}
1642
+ */
1643
+ ActivityContainerComponent.prototype.safelyUpdateActivityList = /**
1644
+ * Update in the next tick to avoid changing state in the current change detection cycle.
1645
+ * @private
1646
+ * @param {?} activities
1647
+ * @return {?}
1648
+ */
1649
+ function (activities) {
1650
+ var _this = this;
1651
+ setTimeout((/**
1652
+ * @return {?}
1653
+ */
1654
+ function () { return _this._activityList.value = activities; }));
1655
+ };
1627
1656
  /**
1628
1657
  * @template D, R, E
1629
1658
  * @param {?} initialContext
@@ -1808,7 +1837,7 @@
1808
1837
  parentInteractionContext: [{ type: core.Input }],
1809
1838
  initialActivityOutletContext: [{ type: core.Input }],
1810
1839
  tabs: [{ type: core.ViewChild, args: ['tabs', { static: true },] }],
1811
- outlets: [{ type: core.ViewChildren, args: [exports.ɵv,] }]
1840
+ outlets: [{ type: core.ViewChildren, args: [ActivityOutletComponent,] }]
1812
1841
  };
1813
1842
  return ActivityContainerComponent;
1814
1843
  }(DisposableComponent));
@@ -1818,6 +1847,8 @@
1818
1847
  /** @type {?} */
1819
1848
  exports.ɵu.prototype.initialActivityOutletContext;
1820
1849
  /** @type {?} */
1850
+ exports.ɵu.prototype.currentActivity;
1851
+ /** @type {?} */
1821
1852
  exports.ɵu.prototype.tabs;
1822
1853
  /** @type {?} */
1823
1854
  exports.ɵu.prototype.outlets;
@@ -1833,6 +1864,11 @@
1833
1864
  * @private
1834
1865
  */
1835
1866
  exports.ɵu.prototype.finished;
1867
+ /**
1868
+ * @type {?}
1869
+ * @private
1870
+ */
1871
+ exports.ɵu.prototype._activityList;
1836
1872
  }
1837
1873
  (function (ActivityContainerComponent) {
1838
1874
  /**
@@ -1861,14 +1897,60 @@
1861
1897
  var DIALOG_INTERACTION_SERVICE_DEFAULTS = new core.InjectionToken('DIALOG_INTERACTION_SERVICE_DEFAULTS');
1862
1898
  var DialogInteractionService = /** @class */ (function (_super) {
1863
1899
  __extends(DialogInteractionService, _super);
1864
- function DialogInteractionService(dialogService, dialogServiceDefaults, matDialogDefaultConfig) {
1900
+ function DialogInteractionService(dialogService, router, dialogServiceDefaults, matDialogDefaultConfig) {
1865
1901
  var _this = _super.call(this) || this;
1866
1902
  _this.dialogService = dialogService;
1903
+ _this.router = router;
1867
1904
  _this.dialogServiceDefaults = dialogServiceDefaults;
1868
1905
  _this.matDialogDefaultConfig = matDialogDefaultConfig;
1906
+ _this._activityList = new pectin.DelegatingListModel();
1907
+ _this._active = false;
1869
1908
  typescriptUtilities.assert.notNil(dialogService);
1909
+ var _a = pectin.Dsl.disposeWith(_this), chain = _a.chain, observe = _a.observe;
1910
+ _this.currentActivity = chain(_this.activityList).last();
1870
1911
  return _this;
1912
+ // observe.valuesFrom(this.router.events)
1913
+ // .tap((event:RouterEvent) => {
1914
+ // const nav = router.getCurrentNavigation();
1915
+ // console.log({
1916
+ // previousUrl: nav.previousNavigation && nav.previousNavigation.finalUrl,
1917
+ // initialUrl: nav.initialUrl,
1918
+ // finalUrl: nav.finalUrl,
1919
+ // });
1920
+ //
1921
+ // })
1922
+ // .filter(event => event instanceof NavigationStart)
1923
+ // .subscribe((event: NavigationStart) => {
1924
+ // console.log(event.navigationTrigger);
1925
+ // if (event.navigationTrigger === 'popstate' && this.isActive()) {
1926
+ // const prev = router.getCurrentNavigation().previousNavigation.finalUrl;
1927
+ // // this.router.navigateByUrl(prev.toString(), {
1928
+ // // replaceUrl: true,
1929
+ // // skipLocationChange: false
1930
+ // // });
1931
+ // // this.cancelActivity();
1932
+ // }
1933
+ // });
1871
1934
  }
1935
+ /**
1936
+ * @return {?}
1937
+ */
1938
+ DialogInteractionService.prototype.cancelActivity = /**
1939
+ * @return {?}
1940
+ */
1941
+ function () {
1942
+ this.currentActivity.value.cancel(null);
1943
+ };
1944
+ Object.defineProperty(DialogInteractionService.prototype, "activityList", {
1945
+ get: /**
1946
+ * @return {?}
1947
+ */
1948
+ function () {
1949
+ return this._activityList.readonly;
1950
+ },
1951
+ enumerable: true,
1952
+ configurable: true
1953
+ });
1872
1954
  /**
1873
1955
  * @template D, R, E
1874
1956
  * @param {?} activityType
@@ -1903,8 +1985,18 @@
1903
1985
  function (activityType, data, disableClose) {
1904
1986
  var _this = this;
1905
1987
  if (disableClose === void 0) { disableClose = true; }
1988
+ if (this.isActive()) {
1989
+ pectin.lang.illegalState("Activity already in progress: " + this.activityList.value.map((/**
1990
+ * @param {?} a
1991
+ * @return {?}
1992
+ */
1993
+ function (a) { return a.constructor.name; })).join(', '));
1994
+ }
1995
+ this._active = true;
1906
1996
  /** @type {?} */
1907
- var config = __assign({ autoFocus: false, hasBackdrop: true }, this.matDialogDefaultConfig, this.dialogServiceDefaults, {
1997
+ var self = this;
1998
+ /** @type {?} */
1999
+ var config = __assign({ autoFocus: false, hasBackdrop: true, closeOnNavigation: false }, this.matDialogDefaultConfig, this.dialogServiceDefaults, {
1908
2000
  data: data,
1909
2001
  disableClose: disableClose,
1910
2002
  panelClass: 'dialog-interaction-service'
@@ -1920,6 +2012,7 @@
1920
2012
  /** @type {?} */
1921
2013
  var activityContainer = matDialogRef.componentInstance;
1922
2014
  activityContainer.parentInteractionContext = _this;
2015
+ self.safelyUpdateActivityListDelegate(activityContainer.activityList);
1923
2016
  activityContainer.initialise({
1924
2017
  activityClass: activityType,
1925
2018
  activityData: data,
@@ -1943,8 +2036,35 @@
1943
2036
  }
1944
2037
  });
1945
2038
  matDialogRef.updateSize();
2039
+ })).finally((/**
2040
+ * @return {?}
2041
+ */
2042
+ function () {
2043
+ self.safelyUpdateActivityListDelegate(null);
2044
+ self._active = false;
1946
2045
  }));
1947
2046
  };
2047
+ /**
2048
+ * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
2049
+ * @param delegate
2050
+ */
2051
+ /**
2052
+ * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
2053
+ * @param {?} delegate
2054
+ * @return {?}
2055
+ */
2056
+ DialogInteractionService.prototype.safelyUpdateActivityListDelegate = /**
2057
+ * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
2058
+ * @param {?} delegate
2059
+ * @return {?}
2060
+ */
2061
+ function (delegate) {
2062
+ var _this = this;
2063
+ setTimeout((/**
2064
+ * @return {?}
2065
+ */
2066
+ function () { return _this._activityList.setDelegate(delegate); }));
2067
+ };
1948
2068
  /**
1949
2069
  * @param {?} alert
1950
2070
  * @return {?}
@@ -1996,18 +2116,36 @@
1996
2116
  /** @nocollapse */
1997
2117
  DialogInteractionService.ctorParameters = function () { return [
1998
2118
  { type: material.MatDialog },
2119
+ { type: router.Router },
1999
2120
  { type: dialog.MatDialogConfig, decorators: [{ type: core.Optional }, { type: core.Inject, args: [DIALOG_INTERACTION_SERVICE_DEFAULTS,] }] },
2000
2121
  { type: dialog.MatDialogConfig, decorators: [{ type: core.Optional }, { type: core.Inject, args: [dialog.MAT_DIALOG_DEFAULT_OPTIONS,] }] }
2001
2122
  ]; };
2002
- /** @nocollapse */ DialogInteractionService.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function DialogInteractionService_Factory() { return new DialogInteractionService(core.ɵɵinject(dialog.MatDialog), core.ɵɵinject(DIALOG_INTERACTION_SERVICE_DEFAULTS, 8), core.ɵɵinject(dialog.MAT_DIALOG_DEFAULT_OPTIONS, 8)); }, token: DialogInteractionService, providedIn: "root" });
2123
+ /** @nocollapse */ DialogInteractionService.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function DialogInteractionService_Factory() { return new DialogInteractionService(core.ɵɵinject(dialog.MatDialog), core.ɵɵinject(router.Router), core.ɵɵinject(DIALOG_INTERACTION_SERVICE_DEFAULTS, 8), core.ɵɵinject(dialog.MAT_DIALOG_DEFAULT_OPTIONS, 8)); }, token: DialogInteractionService, providedIn: "root" });
2003
2124
  return DialogInteractionService;
2004
2125
  }(InteractionContext));
2005
2126
  if (false) {
2127
+ /** @type {?} */
2128
+ DialogInteractionService.prototype.currentActivity;
2129
+ /**
2130
+ * @type {?}
2131
+ * @private
2132
+ */
2133
+ DialogInteractionService.prototype._activityList;
2134
+ /**
2135
+ * @type {?}
2136
+ * @private
2137
+ */
2138
+ DialogInteractionService.prototype._active;
2006
2139
  /**
2007
2140
  * @type {?}
2008
2141
  * @private
2009
2142
  */
2010
2143
  DialogInteractionService.prototype.dialogService;
2144
+ /**
2145
+ * @type {?}
2146
+ * @private
2147
+ */
2148
+ DialogInteractionService.prototype.router;
2011
2149
  /** @type {?} */
2012
2150
  DialogInteractionService.prototype.dialogServiceDefaults;
2013
2151
  /** @type {?} */
@@ -2035,11 +2173,11 @@
2035
2173
  ConfirmationDialogComponent,
2036
2174
  exports.ɵba,
2037
2175
  AlertDialogComponent,
2038
- exports.ɵv
2176
+ ActivityOutletComponent
2039
2177
  ],
2040
2178
  exports: [
2041
2179
  exports.ɵu,
2042
- exports.ɵv,
2180
+ ActivityOutletComponent,
2043
2181
  ],
2044
2182
  entryComponents: [
2045
2183
  exports.ɵu,
@@ -4488,6 +4626,65 @@
4488
4626
  ActivityOutletContext.prototype.onCancel;
4489
4627
  }
4490
4628
 
4629
+ /**
4630
+ * @fileoverview added by tsickle
4631
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4632
+ */
4633
+ var CloseInteractionGuard = /** @class */ (function () {
4634
+ function CloseInteractionGuard(router, injector, interactionContext) {
4635
+ this.router = router;
4636
+ this.injector = injector;
4637
+ this.interactionContext = interactionContext;
4638
+ }
4639
+ /**
4640
+ * @param {?} component
4641
+ * @param {?} currentRoute
4642
+ * @param {?} currentState
4643
+ * @param {?=} nextState
4644
+ * @return {?}
4645
+ */
4646
+ CloseInteractionGuard.prototype.canDeactivate = /**
4647
+ * @param {?} component
4648
+ * @param {?} currentRoute
4649
+ * @param {?} currentState
4650
+ * @param {?=} nextState
4651
+ * @return {?}
4652
+ */
4653
+ function (component, currentRoute, currentState, nextState) {
4654
+ return !this.interactionContext.isActive();
4655
+ };
4656
+ CloseInteractionGuard.decorators = [
4657
+ { type: core.Injectable, args: [{
4658
+ providedIn: 'root'
4659
+ },] }
4660
+ ];
4661
+ /** @nocollapse */
4662
+ CloseInteractionGuard.ctorParameters = function () { return [
4663
+ { type: router.Router },
4664
+ { type: core.Injector },
4665
+ { type: InteractionContext }
4666
+ ]; };
4667
+ /** @nocollapse */ CloseInteractionGuard.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function CloseInteractionGuard_Factory() { return new CloseInteractionGuard(core.ɵɵinject(router.Router), core.ɵɵinject(core.INJECTOR), core.ɵɵinject(InteractionContext)); }, token: CloseInteractionGuard, providedIn: "root" });
4668
+ return CloseInteractionGuard;
4669
+ }());
4670
+ if (false) {
4671
+ /**
4672
+ * @type {?}
4673
+ * @private
4674
+ */
4675
+ CloseInteractionGuard.prototype.router;
4676
+ /**
4677
+ * @type {?}
4678
+ * @private
4679
+ */
4680
+ CloseInteractionGuard.prototype.injector;
4681
+ /**
4682
+ * @type {?}
4683
+ * @private
4684
+ */
4685
+ CloseInteractionGuard.prototype.interactionContext;
4686
+ }
4687
+
4491
4688
  /**
4492
4689
  * @fileoverview added by tsickle
4493
4690
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -4589,9 +4786,33 @@
4589
4786
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4590
4787
  */
4591
4788
  var LeavePlaceGuard = /** @class */ (function () {
4592
- function LeavePlaceGuard(router, injector) {
4593
- this.router = router;
4789
+ function LeavePlaceGuard(router$1, injector, interactionContext, location) {
4790
+ this.router = router$1;
4594
4791
  this.injector = injector;
4792
+ this.interactionContext = interactionContext;
4793
+ this.location = location;
4794
+ // TODO: should probably replace this with a RouteTracker thingy.
4795
+ this._alreadyAccepted = [];
4796
+ console.log('***** Created new guard ******');
4797
+ /** @type {?} */
4798
+ var self = this;
4799
+ this.router.events.subscribe((/**
4800
+ * @param {?} event
4801
+ * @return {?}
4802
+ */
4803
+ function (event) {
4804
+ // NavigationStart -> .... -> NavigationCancel === redirect (so don't ask again)
4805
+ // NavigationStart -> .... -> NavigationEnd === navigated (so ask next time)
4806
+ // NavigationStart -> .... -> NavigationError === canceled (guard cancelled so ask next time)
4807
+ if (event instanceof router.NavigationEnd) {
4808
+ console.log("navigation ended");
4809
+ self._alreadyAccepted = [];
4810
+ }
4811
+ if (event instanceof router.NavigationError) {
4812
+ console.log("navigation errored");
4813
+ self._alreadyAccepted = [];
4814
+ }
4815
+ }));
4595
4816
  }
4596
4817
  /**
4597
4818
  * @param {?} component
@@ -4608,27 +4829,90 @@
4608
4829
  * @return {?}
4609
4830
  */
4610
4831
  function (component, currentRoute, currentState, nextState) {
4611
- // HACK: this will break with child routes...
4832
+ var _this = this;
4612
4833
  /** @type {?} */
4613
- var path = "/" + component.placeDefinition.path;
4614
- // let thisTree = this.router.parseUrl(currentState.url);
4615
- // let nextTree = this.router.parseUrl(nextState.url);
4616
- // console.log({
4617
- // placePath: path,
4618
- // currentRoute: currentRoute.toString(),
4619
- // currentStateUrl: currentState.url,
4620
- // nextStateUrl: nextState.url,
4621
- // currentStateUrlTree: thisTree.root.children[PRIMARY_OUTLET].segments,
4622
- // nextStateUrlTree: nextTree.root.children[PRIMARY_OUTLET].segments
4623
- // });
4624
- // nextState is the full path...
4625
- if (!nextState.url.startsWith(path)) {
4626
- return component.canDeactivate();
4834
+ var placeDefinitionPath = "/" + component.placeDefinition.path;
4835
+ console.log('canDeactivate', {
4836
+ staticPath: placeDefinitionPath,
4837
+ currentStateUrl: currentState.url,
4838
+ nextStateUrl: nextState.url,
4839
+ alreadyDeclined: this._alreadyAccepted
4840
+ });
4841
+ // Example of the above when navigating to a different child route.
4842
+ // canDeactivate {staticPath: "/hero-details",
4843
+ // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-details",
4844
+ // nextStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats"
4845
+ // }
4846
+ // Example clicking on router tab of the parent component (de-activates the parent due to route param changes)
4847
+ // canDeactivate {
4848
+ // staticPath: "/hero-stats",
4849
+ // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
4850
+ // nextStateUrl: "/route-parameters/"
4851
+ // }
4852
+ // canDeactivate {
4853
+ // staticPath: "/route-parameters",
4854
+ // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
4855
+ // nextStateUrl: "/route-parameters/"
4856
+ // }
4857
+ // logger.class.js:54 ParameterSnapshot.sanitise -> {idModel: -1, pv: undefined, pl: Array(0), dv: undefined, dl: Array(0), …}
4858
+ // parameter-snapshot.ts:20 {name: "idModel", mine: -1, theirs: null}
4859
+ // place-router.ts:28 redirect path (3) ["route-parameters", "-1", {…}]
4860
+ // canDeactivate {
4861
+ // staticPath: "/hero-stats",
4862
+ // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
4863
+ // nextStateUrl: "/route-parameters/-1"
4864
+ // }
4865
+ // canDeactivate {
4866
+ // staticPath: "/route-parameters",
4867
+ // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
4868
+ // nextStateUrl: "/route-parameters/-1"
4869
+ // }
4870
+ // logger.class.js:54 ParameterSnapshot.sanitise -> {idModel: -1, pv: undefined, pl: Array(0), dv: "A", dl: Array(3), …}
4871
+ // parameter-snapshot.ts:20 {name: "dv", mine: "A", theirs: undefined}
4872
+ // place-router.ts:28 redirect path (3) ["route-parameters", "-1", {…}]
4873
+ // canDeactivate {
4874
+ // staticPath: "/hero-stats",
4875
+ // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
4876
+ // nextStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c"
4877
+ // }
4878
+ // HACK: this will break with child routes...
4879
+ if (this.alreadyAccepted(component)) {
4880
+ return true;
4627
4881
  }
4628
4882
  else {
4883
+ if (!nextState.url.startsWith(placeDefinitionPath)) {
4884
+ /** @type {?} */
4885
+ var self_1 = this;
4886
+ return Promise.resolve(component.canDeactivate()).then((/**
4887
+ * @param {?} canLeave
4888
+ * @return {?}
4889
+ */
4890
+ function (canLeave) {
4891
+ if (!canLeave) {
4892
+ // Angular doesn't preserve the url when a guard cancels the back button.
4893
+ // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4894
+ _this.location.go(currentState.url);
4895
+ }
4896
+ else {
4897
+ self_1._alreadyAccepted.push(component);
4898
+ }
4899
+ return canLeave;
4900
+ }));
4901
+ }
4629
4902
  return true;
4630
4903
  }
4631
4904
  };
4905
+ /**
4906
+ * @param {?} placeComponent
4907
+ * @return {?}
4908
+ */
4909
+ LeavePlaceGuard.prototype.alreadyAccepted = /**
4910
+ * @param {?} placeComponent
4911
+ * @return {?}
4912
+ */
4913
+ function (placeComponent) {
4914
+ return this._alreadyAccepted.includes(placeComponent);
4915
+ };
4632
4916
  LeavePlaceGuard.decorators = [
4633
4917
  { type: core.Injectable, args: [{
4634
4918
  providedIn: 'root'
@@ -4637,12 +4921,25 @@
4637
4921
  /** @nocollapse */
4638
4922
  LeavePlaceGuard.ctorParameters = function () { return [
4639
4923
  { type: router.Router },
4640
- { type: core.Injector }
4924
+ { type: core.Injector },
4925
+ { type: InteractionContext },
4926
+ { type: common.Location }
4641
4927
  ]; };
4642
- /** @nocollapse */ LeavePlaceGuard.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function LeavePlaceGuard_Factory() { return new LeavePlaceGuard(core.ɵɵinject(router.Router), core.ɵɵinject(core.INJECTOR)); }, token: LeavePlaceGuard, providedIn: "root" });
4928
+ /** @nocollapse */ LeavePlaceGuard.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function LeavePlaceGuard_Factory() { return new LeavePlaceGuard(core.ɵɵinject(router.Router), core.ɵɵinject(core.INJECTOR), core.ɵɵinject(InteractionContext), core.ɵɵinject(common.Location)); }, token: LeavePlaceGuard, providedIn: "root" });
4929
+ __decorate([
4930
+ pectin.Trace(),
4931
+ __metadata("design:type", Function),
4932
+ __metadata("design:paramtypes", [exports.PlaceComponent]),
4933
+ __metadata("design:returntype", Boolean)
4934
+ ], LeavePlaceGuard.prototype, "alreadyAccepted", null);
4643
4935
  return LeavePlaceGuard;
4644
4936
  }());
4645
4937
  if (false) {
4938
+ /**
4939
+ * @type {?}
4940
+ * @private
4941
+ */
4942
+ LeavePlaceGuard.prototype._alreadyAccepted;
4646
4943
  /**
4647
4944
  * @type {?}
4648
4945
  * @private
@@ -4653,6 +4950,10 @@
4653
4950
  * @private
4654
4951
  */
4655
4952
  LeavePlaceGuard.prototype.injector;
4953
+ /** @type {?} */
4954
+ LeavePlaceGuard.prototype.interactionContext;
4955
+ /** @type {?} */
4956
+ LeavePlaceGuard.prototype.location;
4656
4957
  }
4657
4958
 
4658
4959
  /**
@@ -4946,10 +5247,11 @@
4946
5247
  exports.AbstractInputComponent = AbstractInputComponent;
4947
5248
  exports.AbstractPlaceNavigationComponent = AbstractPlaceNavigationComponent;
4948
5249
  exports.ActivityContainerComponent = exports.ɵu;
4949
- exports.ActivityOutletComponent = exports.ɵv;
5250
+ exports.ActivityOutletComponent = ActivityOutletComponent;
4950
5251
  exports.AlertDialogComponent = AlertDialogComponent;
4951
5252
  exports.AngularUiPowerupsModule = AngularUiPowerupsModule;
4952
5253
  exports.BusyOverlayComponent = BusyOverlayComponent;
5254
+ exports.CloseInteractionGuard = CloseInteractionGuard;
4953
5255
  exports.CommandDirective = CommandDirective;
4954
5256
  exports.ConfirmThenDialogComponent = exports.ɵba;
4955
5257
  exports.ConfirmationDialogComponent = ConfirmationDialogComponent;
@@ -4960,7 +5262,6 @@
4960
5262
  exports.DisposableComponent = DisposableComponent;
4961
5263
  exports.EmptyStateComponent = EmptyStateComponent;
4962
5264
  exports.FocusBindingDirective = FocusBindingDirective;
4963
- exports.INTERACTION_CONTEXT = INTERACTION_CONTEXT;
4964
5265
  exports.InteractionContext = InteractionContext;
4965
5266
  exports.InteractionModule = InteractionModule;
4966
5267
  exports.LEFT_RIGHT_PLACE_ANIMATION = LEFT_RIGHT_PLACE_ANIMATION;
@@ -5010,6 +5311,7 @@
5010
5311
  exports.ɵr = AbstractPlaceNavigationComponent;
5011
5312
  exports.ɵs = ListPlaceNavComponent;
5012
5313
  exports.ɵt = InteractionModule;
5314
+ exports.ɵv = ActivityOutletComponent;
5013
5315
  exports.ɵw = ConfirmationDialogComponent;
5014
5316
  exports.ɵx = AbstractActivity;
5015
5317
  exports.ɵy = ACTIVITY_DATA;