@coolon/angular-ui-powerups 0.0.106 → 0.0.107

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.
@@ -7,7 +7,7 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
7
7
  import { __extends, __decorate, __metadata, __awaiter, __generator, __assign, __spread } from 'tslib';
8
8
  import { DelegatingValueModel, assert, UnaryCommand, lang, Dsl, GarbageCollector, Logger, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel, DelegatingListModel, Deferred, MutableStream, MutableValueModel, MutableListModel, Binding, Trace, Guard, StoreInValueModel, Command, OptionsHelper, ValueHolder } from '@coolon/pectin';
9
9
  import { PortalModule } from '@angular/cdk/portal';
10
- import { RouterModule, NavigationStart, NavigationCancel, UrlSegment, NavigationEnd, NavigationError, Router, UrlSerializer } from '@angular/router';
10
+ import { RouterModule, NavigationStart, NavigationCancel, NavigationError, NavigationEnd, UrlSegment, Router, UrlSerializer } from '@angular/router';
11
11
  import { assert as assert$1, Opts, Klass } from '@coolon/typescript-utilities';
12
12
  import { MatIconModule } from '@angular/material/icon';
13
13
  import { MatListModule } from '@angular/material/list';
@@ -3670,7 +3670,7 @@ var PlaceComponentDeactivationHandler = /** @class */ (function () {
3670
3670
  // we always return true if we accepted promise from a previous cycle of the current
3671
3671
  // navigation session.
3672
3672
  if (!this.canDeactivatePromise) {
3673
- console.log("creating deactivate promise for -> " + this.component.constructor.name);
3673
+ // console.log(`creating deactivate promise for -> ${this.component.constructor.name}`);
3674
3674
  this.canDeactivatePromise = this.canDeactivateComponent(currentUrl, nextState);
3675
3675
  }
3676
3676
  return [2 /*return*/, this.canDeactivatePromise];
@@ -3699,7 +3699,6 @@ var PlaceComponentDeactivationHandler = /** @class */ (function () {
3699
3699
  return __generator(this, function (_a) {
3700
3700
  switch (_a.label) {
3701
3701
  case 0:
3702
- console.log(this.navigationState.toString());
3703
3702
  if (!this.navigationState.isPopState) return [3 /*break*/, 5];
3704
3703
  if (!(this.isPrimaryComponent && this.interactionService.isModalActive())) return [3 /*break*/, 3];
3705
3704
  routeIds = this.placeRouter.getActiveInteractionIdsFromUrl(nextState.url);
@@ -4425,11 +4424,15 @@ if (false) {
4425
4424
  navigationTransition.storeVisit(visit);
4426
4425
  return navigationTransition;
4427
4426
  };
4427
+ // @Trace()
4428
+ // @Trace()
4428
4429
  /**
4429
4430
  * @param {?} event
4430
4431
  * @return {?}
4431
4432
  */
4432
- IdleDuringInteraction.prototype.onRouterStarted = /**
4433
+ IdleDuringInteraction.prototype.onRouterStarted =
4434
+ // @Trace()
4435
+ /**
4433
4436
  * @param {?} event
4434
4437
  * @return {?}
4435
4438
  */
@@ -4447,12 +4450,6 @@ if (false) {
4447
4450
  function (event) {
4448
4451
  return new InteractionPopStateTransition(this.context, event.url);
4449
4452
  };
4450
- __decorate([
4451
- Trace(),
4452
- __metadata("design:type", Function),
4453
- __metadata("design:paramtypes", [NavigationStart]),
4454
- __metadata("design:returntype", NavigationState)
4455
- ], IdleDuringInteraction.prototype, "onRouterStarted", null);
4456
4453
  __decorate([
4457
4454
  Trace(),
4458
4455
  __metadata("design:type", Function),
@@ -4497,11 +4494,7 @@ if (false) {
4497
4494
  * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4498
4495
  * happily ignore interaction contexts.
4499
4496
  */
4500
- var /**
4501
- * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4502
- * happily ignore interaction contexts.
4503
- */
4504
- InteractionTransition = /** @class */ (function (_super) {
4497
+ var InteractionTransition = /** @class */ (function (_super) {
4505
4498
  __extends(InteractionTransition, _super);
4506
4499
  function InteractionTransition() {
4507
4500
  var _this = _super !== null && _super.apply(this, arguments) || this;
@@ -4555,6 +4548,24 @@ if (false) {
4555
4548
  return new Idle(this.context);
4556
4549
  }
4557
4550
  };
4551
+ __decorate([
4552
+ Trace(),
4553
+ __metadata("design:type", Function),
4554
+ __metadata("design:paramtypes", [NavigationCancel]),
4555
+ __metadata("design:returntype", NavigationState)
4556
+ ], InteractionTransition.prototype, "onRouterCancelled", null);
4557
+ __decorate([
4558
+ Trace(),
4559
+ __metadata("design:type", Function),
4560
+ __metadata("design:paramtypes", [NavigationError]),
4561
+ __metadata("design:returntype", NavigationState)
4562
+ ], InteractionTransition.prototype, "onRouterError", null);
4563
+ __decorate([
4564
+ Trace(),
4565
+ __metadata("design:type", Function),
4566
+ __metadata("design:paramtypes", [NavigationEnd]),
4567
+ __metadata("design:returntype", NavigationState)
4568
+ ], InteractionTransition.prototype, "onRouterEnd", null);
4558
4569
  return InteractionTransition;
4559
4570
  }(AbstractInteractionTransition));
4560
4571
  NavigationState.InteractionTransition = InteractionTransition;
@@ -4566,11 +4577,7 @@ if (false) {
4566
4577
  * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4567
4578
  * happily ignore interaction contexts.
4568
4579
  */
4569
- var /**
4570
- * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4571
- * happily ignore interaction contexts.
4572
- */
4573
- InteractionPopStateTransition = /** @class */ (function (_super) {
4580
+ var InteractionPopStateTransition = /** @class */ (function (_super) {
4574
4581
  __extends(InteractionPopStateTransition, _super);
4575
4582
  function InteractionPopStateTransition() {
4576
4583
  var _this = _super !== null && _super.apply(this, arguments) || this;
@@ -4612,6 +4619,18 @@ if (false) {
4612
4619
  return new Idle(this.context);
4613
4620
  }
4614
4621
  };
4622
+ __decorate([
4623
+ Trace(),
4624
+ __metadata("design:type", Function),
4625
+ __metadata("design:paramtypes", [NavigationCancel]),
4626
+ __metadata("design:returntype", NavigationState)
4627
+ ], InteractionPopStateTransition.prototype, "onRouterCancelled", null);
4628
+ __decorate([
4629
+ Trace(),
4630
+ __metadata("design:type", Function),
4631
+ __metadata("design:paramtypes", [NavigationEnd]),
4632
+ __metadata("design:returntype", NavigationState)
4633
+ ], InteractionPopStateTransition.prototype, "onRouterEnd", null);
4615
4634
  return InteractionPopStateTransition;
4616
4635
  }(AbstractInteractionTransition));
4617
4636
  NavigationState.InteractionPopStateTransition = InteractionPopStateTransition;
@@ -4860,10 +4879,9 @@ if (false) {
4860
4879
  */
4861
4880
  var UrlSnapshot = /** @class */ (function () {
4862
4881
  // TODO: Update this accept a url Parser so it can be immutable and generate new trees on mutation using toString() are parseUrl.
4863
- function UrlSnapshot(urlSerializer, url, options) {
4882
+ function UrlSnapshot(urlSerializer, url) {
4864
4883
  this.urlSerializer = urlSerializer;
4865
4884
  this.url = url;
4866
- this.options = options;
4867
4885
  this.urlTree = urlSerializer.parse(url);
4868
4886
  }
4869
4887
  /**
@@ -4891,7 +4909,7 @@ var UrlSnapshot = /** @class */ (function () {
4891
4909
  // do not use the return value, it's the items that were removed!
4892
4910
  segments.splice.apply(segments, __spread([replaceAt, visitSegments.length], visitSegments));
4893
4911
  urlTree.root.children.primary.segments = segments;
4894
- return new UrlSnapshot(this.urlSerializer, urlTree.toString(), this.options);
4912
+ return new UrlSnapshot(this.urlSerializer, urlTree.toString());
4895
4913
  };
4896
4914
  /**
4897
4915
  * @private
@@ -4996,7 +5014,7 @@ var UrlSnapshot = /** @class */ (function () {
4996
5014
  /** @type {?} */
4997
5015
  var urlTree = this.urlSerializer.parse(this.url);
4998
5016
  urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM] = UrlSnapshot.createPathIdFor(ids);
4999
- return new UrlSnapshot(this.urlSerializer, urlTree.toString(), this.options);
5017
+ return new UrlSnapshot(this.urlSerializer, urlTree.toString());
5000
5018
  }
5001
5019
  };
5002
5020
  // @Trace()
@@ -5015,27 +5033,7 @@ var UrlSnapshot = /** @class */ (function () {
5015
5033
  if (urlTree.queryParams && urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM]) {
5016
5034
  urlTree.queryParams = {}; //[UrlSnapshot.INTERACTION_ROUTER_OUTLET]
5017
5035
  }
5018
- return new UrlSnapshot(this.urlSerializer, urlTree.toString(), this.options);
5019
- };
5020
- /**
5021
- * @param {?} options
5022
- * @return {?}
5023
- */
5024
- UrlSnapshot.prototype.withOptions = /**
5025
- * @param {?} options
5026
- * @return {?}
5027
- */
5028
- function (options) {
5029
- return new UrlSnapshot(this.urlSerializer, this.url, options);
5030
- };
5031
- /**
5032
- * @return {?}
5033
- */
5034
- UrlSnapshot.prototype.getNavigationExtras = /**
5035
- * @return {?}
5036
- */
5037
- function () {
5038
- return this.options;
5036
+ return new UrlSnapshot(this.urlSerializer, urlTree.toString());
5039
5037
  };
5040
5038
  return UrlSnapshot;
5041
5039
  }());
@@ -5046,11 +5044,6 @@ if (false) {
5046
5044
  UrlSnapshot.prototype.urlSerializer;
5047
5045
  /** @type {?} */
5048
5046
  UrlSnapshot.prototype.url;
5049
- /**
5050
- * @type {?}
5051
- * @private
5052
- */
5053
- UrlSnapshot.prototype.options;
5054
5047
  }
5055
5048
  (function (UrlSnapshot) {
5056
5049
  UrlSnapshot.INTERACTION_QUERY_PARAM = 'aup-interactions';
@@ -5173,7 +5166,7 @@ var PlaceRouter = /** @class */ (function (_super) {
5173
5166
  * @return {?}
5174
5167
  */
5175
5168
  function (ids, previous) {
5176
- _this.syncInteractionIdsWithRouter();
5169
+ _this.syncInteractionIdsWithRouter(ids, previous);
5177
5170
  }), { unless: _this.navigationInProgress }); // TODO: I think the exclusive interaction prevents interactions starting while it's active so we might not need this.
5178
5171
  // TODO: I think the exclusive interaction prevents interactions starting while it's active so we might not need this.
5179
5172
  /** @type {?} */
@@ -5464,7 +5457,7 @@ var PlaceRouter = /** @class */ (function (_super) {
5464
5457
  * @return {?}
5465
5458
  */
5466
5459
  function (url) {
5467
- return new UrlSnapshot(this.urlSerializer, url, {});
5460
+ return new UrlSnapshot(this.urlSerializer, url);
5468
5461
  };
5469
5462
  /**
5470
5463
  * @param {?} url
@@ -5546,47 +5539,77 @@ var PlaceRouter = /** @class */ (function (_super) {
5546
5539
  function (url) {
5547
5540
  return this.getActiveInteractionIdsFromUrl(url).length > 0;
5548
5541
  };
5549
- // @Trace()
5550
- // @Trace()
5551
5542
  /**
5552
5543
  * @param {?} urlSnapshot
5544
+ * @param {?=} navigationExtras
5553
5545
  * @return {?}
5554
5546
  */
5555
- PlaceRouter.prototype.navigateByUrl =
5556
- // @Trace()
5557
- /**
5547
+ PlaceRouter.prototype.navigateByUrl = /**
5558
5548
  * @param {?} urlSnapshot
5549
+ * @param {?=} navigationExtras
5559
5550
  * @return {?}
5560
5551
  */
5561
- function (urlSnapshot) {
5562
- this.router.navigateByUrl(urlSnapshot.urlTree, urlSnapshot.getNavigationExtras());
5552
+ function (urlSnapshot, navigationExtras) {
5553
+ return this.router.navigateByUrl(urlSnapshot.urlTree, navigationExtras);
5563
5554
  };
5564
- // @Trace()
5565
- // @Trace()
5555
+ // TODO: Should this be moved to the navigation states?
5556
+ // TODO: Should this be moved to the navigation states?
5566
5557
  /**
5558
+ * @param {?} currentIds
5559
+ * @param {?} previous
5567
5560
  * @return {?}
5568
5561
  */
5569
5562
  PlaceRouter.prototype.syncInteractionIdsWithRouter =
5570
- // @Trace()
5563
+ // TODO: Should this be moved to the navigation states?
5571
5564
  /**
5565
+ * @param {?} currentIds
5566
+ * @param {?} previous
5572
5567
  * @return {?}
5573
5568
  */
5574
- function () {
5569
+ function (currentIds, previous) {
5570
+ var _this = this;
5575
5571
  assert.isFalsey(this.navigationInProgress.value); // Updating interaction routes during an existing navigation breaks all the things.
5576
- // Updating interaction routes during an existing navigation breaks all the things.
5577
- /** @type {?} */
5578
- var currentIds = this.interactionService.activeInteractionContextIds.value;
5579
- if (___default.isEqual(currentIds, this.getActiveInteractionIdsFromUrl(this.getCurrentRouterUrl()))) {
5572
+ console.log({
5573
+ startingActivity: currentIds.length > previous.length,
5574
+ wasBackButton: this.navigationState.isPopState
5575
+ });
5576
+ if (___default.isEqual(currentIds, previous)) {
5580
5577
  console.log('activity ids were the same, skipping');
5581
5578
  }
5582
5579
  else {
5583
- if (currentIds.length < 1) {
5584
- // no more interactions to remove from history.
5585
- this.navigateByUrl(this.getCurrentRouteSnapshot().removeInteractionIds());
5580
+ // OMG, this is nuts.
5581
+ /** @type {?} */
5582
+ var addingActivity = currentIds.length > previous.length;
5583
+ /** @type {?} */
5584
+ var isFirstActivity = addingActivity && previous.length < 1;
5585
+ /** @type {?} */
5586
+ var removingLastActivity = currentIds.length < 1;
5587
+ if (addingActivity) { // we're starting a new activity, push the change to the history and update the url
5588
+ console.log('adding activity');
5589
+ this.navigateByUrl(this.getCurrentRouteSnapshot().updateInteractionIds(currentIds), {
5590
+ replaceUrl: !isFirstActivity // we don't let the history pile up
5591
+ });
5586
5592
  }
5587
5593
  else {
5588
- // todo was or is...
5589
- this.navigateByUrl(this.getCurrentRouteSnapshot().updateInteractionIds(currentIds));
5594
+ /** @type {?} */
5595
+ var urlSnapshot = this.getCurrentRouteSnapshot().updateInteractionIds(currentIds);
5596
+ if (removingLastActivity) {
5597
+ this.navigateByUrl(urlSnapshot, {
5598
+ replaceUrl: true
5599
+ }).then((/**
5600
+ * @return {?}
5601
+ */
5602
+ function () {
5603
+ // for some reason we need to pop the last history off the stack when leaving the
5604
+ // active activity state.
5605
+ _this.angularLocation.back();
5606
+ }));
5607
+ }
5608
+ else {
5609
+ this.navigateByUrl(urlSnapshot, {
5610
+ replaceUrl: true
5611
+ });
5612
+ }
5590
5613
  }
5591
5614
  }
5592
5615
  };
@@ -5604,6 +5627,12 @@ var PlaceRouter = /** @class */ (function (_super) {
5604
5627
  { type: InteractionService }
5605
5628
  ]; };
5606
5629
  /** @nocollapse */ PlaceRouter.ngInjectableDef = ɵɵdefineInjectable({ factory: function PlaceRouter_Factory() { return new PlaceRouter(ɵɵinject(Router), ɵɵinject(UrlSerializer), ɵɵinject(Location), ɵɵinject(PlaceHistory), ɵɵinject(InteractionService)); }, token: PlaceRouter, providedIn: "root" });
5630
+ __decorate([
5631
+ Trace(),
5632
+ __metadata("design:type", Function),
5633
+ __metadata("design:paramtypes", [UrlSnapshot, Object]),
5634
+ __metadata("design:returntype", Promise)
5635
+ ], PlaceRouter.prototype, "navigateByUrl", null);
5607
5636
  return PlaceRouter;
5608
5637
  }(GarbageCollector));
5609
5638
  if (false) {