@coolon/angular-ui-powerups 0.0.105 → 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 { GarbageCollector, DelegatingValueModel, assert, UnaryCommand, lang, Dsl, Logger, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel, DelegatingListModel, Deferred, MutableStream, MutableValueModel, MutableListModel, Binding, Trace, Guard, StoreInValueModel, Command, OptionsHelper, ValueHolder } from '@coolon/pectin';
8
8
  import { __decorate, __metadata, __awaiter } from 'tslib';
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';
@@ -1829,10 +1829,19 @@ class InteractionService {
1829
1829
  return this.modelInteractionActive.value;
1830
1830
  }
1831
1831
  /**
1832
+ * @deprecated use #createModalInteractionContextDisposedWith instead.
1832
1833
  * @param {?} disposable
1833
1834
  * @return {?}
1834
1835
  */
1835
1836
  createModalInteractionContextFor(disposable) {
1837
+ return this.createModalInteractionContextDisposedWith(disposable);
1838
+ }
1839
+ /**
1840
+ * Creates a new model interaction context that will be disposed along with the component.
1841
+ * @param {?} disposable
1842
+ * @return {?}
1843
+ */
1844
+ createModalInteractionContextDisposedWith(disposable) {
1836
1845
  /** @type {?} */
1837
1846
  const context = this.modelInteractionContextFactory.createInteractionContext();
1838
1847
  disposable.registerDisposable(new InteractionService.Monitor('modal', context, this._activeModalInteractionContextModel, this.exclusiveContext));
@@ -2954,7 +2963,7 @@ class PlaceComponentDeactivationHandler {
2954
2963
  // we always return true if we accepted promise from a previous cycle of the current
2955
2964
  // navigation session.
2956
2965
  if (!this.canDeactivatePromise) {
2957
- console.log(`creating deactivate promise for -> ${this.component.constructor.name}`);
2966
+ // console.log(`creating deactivate promise for -> ${this.component.constructor.name}`);
2958
2967
  this.canDeactivatePromise = this.canDeactivateComponent(currentUrl, nextState);
2959
2968
  }
2960
2969
  return this.canDeactivatePromise;
@@ -2969,7 +2978,7 @@ class PlaceComponentDeactivationHandler {
2969
2978
  */
2970
2979
  canDeactivateComponent(currentUrl, nextState) {
2971
2980
  return __awaiter(this, void 0, void 0, function* () {
2972
- console.log(this.navigationState.toString());
2981
+ // console.log(this.navigationState.toString());
2973
2982
  // Automatically cancel any active activities if the navigation session was triggered by the back button.
2974
2983
  // If we handled more than just the pop state then it leads to the UI ignoring clicks and just cancelling things which is deeply disconcerting.
2975
2984
  if (this.navigationState.isPopState) {
@@ -3525,6 +3534,7 @@ if (false) {
3525
3534
  navigationTransition.storeVisit(visit);
3526
3535
  return navigationTransition;
3527
3536
  }
3537
+ // @Trace()
3528
3538
  /**
3529
3539
  * @param {?} event
3530
3540
  * @return {?}
@@ -3540,12 +3550,6 @@ if (false) {
3540
3550
  return new InteractionPopStateTransition(this.context, event.url);
3541
3551
  }
3542
3552
  }
3543
- __decorate([
3544
- Trace(),
3545
- __metadata("design:type", Function),
3546
- __metadata("design:paramtypes", [NavigationStart]),
3547
- __metadata("design:returntype", NavigationState)
3548
- ], IdleDuringInteraction.prototype, "onRouterStarted", null);
3549
3553
  __decorate([
3550
3554
  Trace(),
3551
3555
  __metadata("design:type", Function),
@@ -3627,6 +3631,24 @@ if (false) {
3627
3631
  }
3628
3632
  }
3629
3633
  }
3634
+ __decorate([
3635
+ Trace(),
3636
+ __metadata("design:type", Function),
3637
+ __metadata("design:paramtypes", [NavigationCancel]),
3638
+ __metadata("design:returntype", NavigationState)
3639
+ ], InteractionTransition.prototype, "onRouterCancelled", null);
3640
+ __decorate([
3641
+ Trace(),
3642
+ __metadata("design:type", Function),
3643
+ __metadata("design:paramtypes", [NavigationError]),
3644
+ __metadata("design:returntype", NavigationState)
3645
+ ], InteractionTransition.prototype, "onRouterError", null);
3646
+ __decorate([
3647
+ Trace(),
3648
+ __metadata("design:type", Function),
3649
+ __metadata("design:paramtypes", [NavigationEnd]),
3650
+ __metadata("design:returntype", NavigationState)
3651
+ ], InteractionTransition.prototype, "onRouterEnd", null);
3630
3652
  NavigationState.InteractionTransition = InteractionTransition;
3631
3653
  if (false) {
3632
3654
  /** @type {?} */
@@ -3669,6 +3691,18 @@ if (false) {
3669
3691
  }
3670
3692
  }
3671
3693
  }
3694
+ __decorate([
3695
+ Trace(),
3696
+ __metadata("design:type", Function),
3697
+ __metadata("design:paramtypes", [NavigationCancel]),
3698
+ __metadata("design:returntype", NavigationState)
3699
+ ], InteractionPopStateTransition.prototype, "onRouterCancelled", null);
3700
+ __decorate([
3701
+ Trace(),
3702
+ __metadata("design:type", Function),
3703
+ __metadata("design:paramtypes", [NavigationEnd]),
3704
+ __metadata("design:returntype", NavigationState)
3705
+ ], InteractionPopStateTransition.prototype, "onRouterEnd", null);
3672
3706
  NavigationState.InteractionPopStateTransition = InteractionPopStateTransition;
3673
3707
  if (false) {
3674
3708
  /** @type {?} */
@@ -3860,12 +3894,10 @@ class UrlSnapshot {
3860
3894
  /**
3861
3895
  * @param {?} urlSerializer
3862
3896
  * @param {?} url
3863
- * @param {?} options
3864
3897
  */
3865
- constructor(urlSerializer, url, options) {
3898
+ constructor(urlSerializer, url) {
3866
3899
  this.urlSerializer = urlSerializer;
3867
3900
  this.url = url;
3868
- this.options = options;
3869
3901
  this.urlTree = urlSerializer.parse(url);
3870
3902
  }
3871
3903
  /**
@@ -3889,7 +3921,7 @@ class UrlSnapshot {
3889
3921
  // do not use the return value, it's the items that were removed!
3890
3922
  segments.splice(replaceAt, visitSegments.length, ...visitSegments);
3891
3923
  urlTree.root.children.primary.segments = segments;
3892
- return new UrlSnapshot(this.urlSerializer, urlTree.toString(), this.options);
3924
+ return new UrlSnapshot(this.urlSerializer, urlTree.toString());
3893
3925
  }
3894
3926
  /**
3895
3927
  * @private
@@ -3962,7 +3994,7 @@ class UrlSnapshot {
3962
3994
  /** @type {?} */
3963
3995
  const urlTree = this.urlSerializer.parse(this.url);
3964
3996
  urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM] = UrlSnapshot.createPathIdFor(ids);
3965
- return new UrlSnapshot(this.urlSerializer, urlTree.toString(), this.options);
3997
+ return new UrlSnapshot(this.urlSerializer, urlTree.toString());
3966
3998
  }
3967
3999
  }
3968
4000
  // @Trace()
@@ -3975,20 +4007,7 @@ class UrlSnapshot {
3975
4007
  if (urlTree.queryParams && urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM]) {
3976
4008
  urlTree.queryParams = {}; //[UrlSnapshot.INTERACTION_ROUTER_OUTLET]
3977
4009
  }
3978
- return new UrlSnapshot(this.urlSerializer, urlTree.toString(), this.options);
3979
- }
3980
- /**
3981
- * @param {?} options
3982
- * @return {?}
3983
- */
3984
- withOptions(options) {
3985
- return new UrlSnapshot(this.urlSerializer, this.url, options);
3986
- }
3987
- /**
3988
- * @return {?}
3989
- */
3990
- getNavigationExtras() {
3991
- return this.options;
4010
+ return new UrlSnapshot(this.urlSerializer, urlTree.toString());
3992
4011
  }
3993
4012
  }
3994
4013
  if (false) {
@@ -3998,11 +4017,6 @@ if (false) {
3998
4017
  UrlSnapshot.prototype.urlSerializer;
3999
4018
  /** @type {?} */
4000
4019
  UrlSnapshot.prototype.url;
4001
- /**
4002
- * @type {?}
4003
- * @private
4004
- */
4005
- UrlSnapshot.prototype.options;
4006
4020
  }
4007
4021
  (function (UrlSnapshot) {
4008
4022
  UrlSnapshot.INTERACTION_QUERY_PARAM = 'aup-interactions';
@@ -4131,7 +4145,7 @@ class PlaceRouter extends GarbageCollector {
4131
4145
  * @return {?}
4132
4146
  */
4133
4147
  (ids, previous) => {
4134
- this.syncInteractionIdsWithRouter();
4148
+ this.syncInteractionIdsWithRouter(ids, previous);
4135
4149
  }), { unless: this.navigationInProgress }); // TODO: I think the exclusive interaction prevents interactions starting while it's active so we might not need this.
4136
4150
  // TODO: I think the exclusive interaction prevents interactions starting while it's active so we might not need this.
4137
4151
  /** @type {?} */
@@ -4332,7 +4346,7 @@ class PlaceRouter extends GarbageCollector {
4332
4346
  * @return {?}
4333
4347
  */
4334
4348
  parseUrl(url) {
4335
- return new UrlSnapshot(this.urlSerializer, url, {});
4349
+ return new UrlSnapshot(this.urlSerializer, url);
4336
4350
  }
4337
4351
  /**
4338
4352
  * @param {?} url
@@ -4384,34 +4398,63 @@ class PlaceRouter extends GarbageCollector {
4384
4398
  hasActiveInteractionIds(url) {
4385
4399
  return this.getActiveInteractionIdsFromUrl(url).length > 0;
4386
4400
  }
4387
- // @Trace()
4388
4401
  /**
4389
4402
  * @param {?} urlSnapshot
4403
+ * @param {?=} navigationExtras
4390
4404
  * @return {?}
4391
4405
  */
4392
- navigateByUrl(urlSnapshot) {
4393
- this.router.navigateByUrl(urlSnapshot.urlTree, urlSnapshot.getNavigationExtras());
4406
+ navigateByUrl(urlSnapshot, navigationExtras) {
4407
+ return this.router.navigateByUrl(urlSnapshot.urlTree, navigationExtras);
4394
4408
  }
4395
- // @Trace()
4409
+ // TODO: Should this be moved to the navigation states?
4396
4410
  /**
4411
+ * @param {?} currentIds
4412
+ * @param {?} previous
4397
4413
  * @return {?}
4398
4414
  */
4399
- syncInteractionIdsWithRouter() {
4415
+ syncInteractionIdsWithRouter(currentIds, previous) {
4400
4416
  assert.isFalsey(this.navigationInProgress.value); // Updating interaction routes during an existing navigation breaks all the things.
4401
- // Updating interaction routes during an existing navigation breaks all the things.
4402
- /** @type {?} */
4403
- const currentIds = this.interactionService.activeInteractionContextIds.value;
4404
- if (___default.isEqual(currentIds, this.getActiveInteractionIdsFromUrl(this.getCurrentRouterUrl()))) {
4417
+ console.log({
4418
+ startingActivity: currentIds.length > previous.length,
4419
+ wasBackButton: this.navigationState.isPopState
4420
+ });
4421
+ if (___default.isEqual(currentIds, previous)) {
4405
4422
  console.log('activity ids were the same, skipping');
4406
4423
  }
4407
4424
  else {
4408
- if (currentIds.length < 1) {
4409
- // no more interactions to remove from history.
4410
- this.navigateByUrl(this.getCurrentRouteSnapshot().removeInteractionIds());
4425
+ // OMG, this is nuts.
4426
+ /** @type {?} */
4427
+ const addingActivity = currentIds.length > previous.length;
4428
+ /** @type {?} */
4429
+ const isFirstActivity = addingActivity && previous.length < 1;
4430
+ /** @type {?} */
4431
+ const removingLastActivity = currentIds.length < 1;
4432
+ if (addingActivity) { // we're starting a new activity, push the change to the history and update the url
4433
+ console.log('adding activity');
4434
+ this.navigateByUrl(this.getCurrentRouteSnapshot().updateInteractionIds(currentIds), {
4435
+ replaceUrl: !isFirstActivity // we don't let the history pile up
4436
+ });
4411
4437
  }
4412
4438
  else {
4413
- // todo was or is...
4414
- this.navigateByUrl(this.getCurrentRouteSnapshot().updateInteractionIds(currentIds));
4439
+ /** @type {?} */
4440
+ const urlSnapshot = this.getCurrentRouteSnapshot().updateInteractionIds(currentIds);
4441
+ if (removingLastActivity) {
4442
+ this.navigateByUrl(urlSnapshot, {
4443
+ replaceUrl: true
4444
+ }).then((/**
4445
+ * @return {?}
4446
+ */
4447
+ () => {
4448
+ // for some reason we need to pop the last history off the stack when leaving the
4449
+ // active activity state.
4450
+ this.angularLocation.back();
4451
+ }));
4452
+ }
4453
+ else {
4454
+ this.navigateByUrl(urlSnapshot, {
4455
+ replaceUrl: true
4456
+ });
4457
+ }
4415
4458
  }
4416
4459
  }
4417
4460
  }
@@ -4430,6 +4473,12 @@ PlaceRouter.ctorParameters = () => [
4430
4473
  { type: InteractionService }
4431
4474
  ];
4432
4475
  /** @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" });
4476
+ __decorate([
4477
+ Trace(),
4478
+ __metadata("design:type", Function),
4479
+ __metadata("design:paramtypes", [UrlSnapshot, Object]),
4480
+ __metadata("design:returntype", Promise)
4481
+ ], PlaceRouter.prototype, "navigateByUrl", null);
4433
4482
  if (false) {
4434
4483
  /**
4435
4484
  * @type {?}