@coolon/angular-ui-powerups 0.0.83 → 0.0.85

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, assert, UnaryCommand, lang, Dsl, Logger, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel, DelegatingValueModel, MutableStream, MutableListModel, DelegatingListModel, StoreInValueModel, Binding, MutableValueModel, Trace, Guard as Guard$1, Command, OptionsHelper, ValueHolder } from '@coolon/pectin';
8
8
  import { __decorate, __metadata, __awaiter } from 'tslib';
9
9
  import { PortalModule } from '@angular/cdk/portal';
10
- import { Router, RouterModule, UrlSegment, NavigationStart, NavigationEnd, NavigationError, RouterOutlet, ActivatedRouteSnapshot, RouterStateSnapshot, UrlSerializer } from '@angular/router';
10
+ import { Router, RouterModule, UrlSegment, NavigationStart, NavigationEnd, NavigationError, ActivatedRouteSnapshot, RouterStateSnapshot, UrlSerializer } from '@angular/router';
11
11
  import ___default, { last, isNil, isEqual } from 'lodash';
12
12
  import { assert as assert$1, Opts, Klass } from '@coolon/typescript-utilities';
13
13
  import { MatDialogConfig, MAT_DIALOG_DEFAULT_OPTIONS, MatDialog as MatDialog$1 } from '@angular/material/dialog';
@@ -3242,7 +3242,6 @@ class PlaceRouter extends GarbageCollector {
3242
3242
  [def.getFormattedRouteId(visit), def.getFormattedRouteParameters(visit)] :
3243
3243
  [def.getFormattedRouteParameters(visit)];
3244
3244
  }
3245
- // @Trace()
3246
3245
  /**
3247
3246
  * @private
3248
3247
  * @param {?} event
@@ -3260,7 +3259,6 @@ class PlaceRouter extends GarbageCollector {
3260
3259
  }
3261
3260
  this.firstRoute = false;
3262
3261
  }
3263
- // @Trace()
3264
3262
  /**
3265
3263
  * @private
3266
3264
  * @return {?}
@@ -3312,6 +3310,18 @@ __decorate([
3312
3310
  __metadata("design:paramtypes", [Visit, Object]),
3313
3311
  __metadata("design:returntype", Promise)
3314
3312
  ], PlaceRouter.prototype, "navigate", null);
3313
+ __decorate([
3314
+ Trace(),
3315
+ __metadata("design:type", Function),
3316
+ __metadata("design:paramtypes", [NavigationStart]),
3317
+ __metadata("design:returntype", void 0)
3318
+ ], PlaceRouter.prototype, "onAngularRouterStarted", null);
3319
+ __decorate([
3320
+ Trace(),
3321
+ __metadata("design:type", Function),
3322
+ __metadata("design:paramtypes", []),
3323
+ __metadata("design:returntype", void 0)
3324
+ ], PlaceRouter.prototype, "onAngularRouterFinished", null);
3315
3325
  if (false) {
3316
3326
  /**
3317
3327
  * @type {?}
@@ -3436,13 +3446,16 @@ class PlaceOutletComponent extends DisposableComponent {
3436
3446
  this.placeChanged = new EventEmitter();
3437
3447
  this._activePlace = new MutableValueModel();
3438
3448
  this._activePlaceVisitModel = new DelegatingValueModel();
3439
- this._inOutletUpdate = new Guard$1();
3449
+ this._inOutletActivation = new Guard$1();
3450
+ this._inOutletDeactivation = new Guard$1();
3451
+ this._inRouteVisitUpdate = new Guard$1();
3440
3452
  this._activatedRouteModel = new MutableValueModel();
3441
3453
  this._placeDefinition = new MutableValueModel();
3442
- this.isOnInitialPlace = true;
3454
+ this.initialPlaceIndex = null;
3443
3455
  const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);
3444
3456
  this.parentOutletModel = new MutableValueModel(parentOutlet);
3445
3457
  this._activePlaceVisitModel.setDelegate(new MutableValueModel());
3458
+ this._inOutletUpdate = valueOf.any(this._inOutletDeactivation, this._inOutletActivation).areTruthy();
3446
3459
  /** @type {?} */
3447
3460
  const defaultPlaceAnimationOrder = chain(this.parentOutletModel)
3448
3461
  .pullValueModel((/**
@@ -3461,37 +3474,31 @@ class PlaceOutletComponent extends DisposableComponent {
3461
3474
  p => (/** @type {?} */ (p.constructor))));
3462
3475
  this.placeAnimationOrder = chain(this.customPlaceAnimationOrderModel)
3463
3476
  .otherwise(defaultPlaceAnimationOrder)
3464
- .indexOf(activatePlaceType)
3465
- .map((/**
3466
- * @param {?} order
3477
+ .reduce((/**
3478
+ * @param {?} placesInOrder
3467
3479
  * @return {?}
3468
3480
  */
3469
- order => {
3470
- // we get -1 on the first load which triggers an animation to the first page, so alway pin it to 0
3471
- // if we're animating.
3472
- return this.isOnInitialPlace ? 0 :
3473
- this.animate ? Math.max(order, 0) : 0;
3474
- }));
3481
+ (placesInOrder) => {
3482
+ /** @type {?} */
3483
+ let placeIndex = 0;
3484
+ if (activatePlaceType.value) {
3485
+ placeIndex = placesInOrder.indexOf(activatePlaceType.value);
3486
+ if (isNil(this.initialPlaceIndex)) {
3487
+ this.initialPlaceIndex = placeIndex;
3488
+ }
3489
+ }
3490
+ return isNil(this.initialPlaceIndex) ? 0 : placeIndex - this.initialPlaceIndex;
3491
+ }), { dependsOn: activatePlaceType });
3475
3492
  // Push incoming changes into the component
3476
- /** @type {?} */
3477
- const routeVisit = chain(this._activePlace).pluck('placeDefinition').findIn(placeRouter.activeVisitIndex);
3478
- /** @type {?} */
3479
- const inRouteVisitUpdate = new Guard$1();
3480
- when.valueOf(routeVisit).changes((/**
3481
- * @param {?} visit
3493
+ this.routerVisit = chain(this._activePlace).pluck('placeDefinition').findIn(placeRouter.activeVisitIndex);
3494
+ // Our router visit will change when our active is nullified during deactivation, which will push a null visit
3495
+ // the the deactivated component, which will nuke it's view before the animations have finished.
3496
+ // The visit will alway updated after the router session is finsised (when the new visits are registered) so
3497
+ // we can safely ignore it during outlet changes as these always happen before the router session ends.
3498
+ when.valueOf(this.routerVisit).changes((/**
3482
3499
  * @return {?}
3483
3500
  */
3484
- (visit) => {
3485
- console.log("### Route visit changed");
3486
- if (visit) { // can be null while the place and index sync up
3487
- inRouteVisitUpdate.whileTrue((/**
3488
- * @return {?}
3489
- */
3490
- () => {
3491
- this._activePlaceVisitModel.value = visit;
3492
- }));
3493
- }
3494
- }));
3501
+ () => this.pushRouteChangesToVisit()), { unless: this._inOutletUpdate });
3495
3502
  // Handle component based changes
3496
3503
  when.valueOf(this._activePlaceVisitModel).changes((/**
3497
3504
  * @param {?} next
@@ -3501,7 +3508,7 @@ class PlaceOutletComponent extends DisposableComponent {
3501
3508
  (next, previous) => {
3502
3509
  this.pushVisitChangesToRoute(next, previous);
3503
3510
  }), {
3504
- unless: valueOf.any(this._inOutletUpdate, inRouteVisitUpdate).areTruthy()
3511
+ unless: this.placeRouter.navigationSessionActive
3505
3512
  });
3506
3513
  chain(this._activePlace)
3507
3514
  .postponeWhile(placeRouter.navigationSessionActive)
@@ -3518,18 +3525,26 @@ class PlaceOutletComponent extends DisposableComponent {
3518
3525
  */
3519
3526
  ngOnInit() {
3520
3527
  }
3528
+ // @Trace()
3529
+ /**
3530
+ * @return {?}
3531
+ */
3532
+ getAnimationOrder() {
3533
+ return this.placeAnimationOrder.value;
3534
+ }
3521
3535
  /**
3522
3536
  * @return {?}
3523
3537
  */
3524
3538
  get animationDuration() {
3525
3539
  return this.placeConfig && this.placeConfig.animationDuration ? this.placeConfig.animationDuration : '500ms';
3526
3540
  }
3541
+ // @Trace()
3527
3542
  /**
3528
3543
  * @param {?} visit
3529
3544
  * @return {?}
3530
3545
  */
3531
3546
  navigate(visit) {
3532
- console.log({ activatedRoute: this._activatedRouteModel.value });
3547
+ // console.log({ activatedRoute: this._activatedRouteModel.value });
3533
3548
  this.placeRouter.navigate(visit, {
3534
3549
  relativeTo: this.parentOutlet ? this.parentOutlet.activatedRouteModel.value : null
3535
3550
  });
@@ -3540,6 +3555,28 @@ class PlaceOutletComponent extends DisposableComponent {
3540
3555
  get parentOutlet() {
3541
3556
  return this.parentOutletModel.value;
3542
3557
  }
3558
+ // @Trace()
3559
+ /**
3560
+ * @return {?}
3561
+ */
3562
+ pushRouteChangesToVisit() {
3563
+ /** @type {?} */
3564
+ const visit = this.routerVisit.value;
3565
+ console.log({
3566
+ visit,
3567
+ place: visit ? visit.placeDefinition.component : null,
3568
+ inOutletActivation: this._inOutletActivation.value,
3569
+ inRoutingSession: this.placeRouter.navigationSessionActive.value
3570
+ });
3571
+ if (visit) { // can be null while the place and index sync up
3572
+ this._inRouteVisitUpdate.whileTrue((/**
3573
+ * @return {?}
3574
+ */
3575
+ () => {
3576
+ this._activePlaceVisitModel.value = visit;
3577
+ }));
3578
+ }
3579
+ }
3543
3580
  /**
3544
3581
  * @param {?} next
3545
3582
  * @param {?} previous
@@ -3562,13 +3599,14 @@ class PlaceOutletComponent extends DisposableComponent {
3562
3599
  get activatedRouteModel() {
3563
3600
  return this._activatedRouteModel.readonly;
3564
3601
  }
3602
+ // @Trace()
3565
3603
  /**
3566
3604
  * @param {?} routerOutlet
3567
3605
  * @param {?} place
3568
3606
  * @return {?}
3569
3607
  */
3570
3608
  onOutletActivated(routerOutlet, place) {
3571
- this._inOutletUpdate.whileTrue((/**
3609
+ this._inOutletActivation.whileTrue((/**
3572
3610
  * @return {?}
3573
3611
  */
3574
3612
  () => {
@@ -3590,27 +3628,29 @@ class PlaceOutletComponent extends DisposableComponent {
3590
3628
  this.animationDone();
3591
3629
  }
3592
3630
  }
3631
+ // @Trace()
3593
3632
  /**
3594
3633
  * @return {?}
3595
3634
  */
3596
3635
  onOutletDeactivated() {
3597
- this._inOutletUpdate.whileTrue((/**
3636
+ this._inOutletDeactivation.whileTrue((/**
3598
3637
  * @return {?}
3599
3638
  */
3600
3639
  () => {
3601
- this._activePlaceVisitModel.setDelegate(null);
3602
- this.isOnInitialPlace = false;
3603
3640
  this._activePlace.value = null;
3604
3641
  this._activatedRouteModel.value = null;
3605
3642
  this._placeDefinition.value = null;
3643
+ this._activePlaceVisitModel.setDelegate(null);
3606
3644
  }));
3607
3645
  }
3646
+ // @Trace()
3608
3647
  /**
3609
3648
  * @return {?}
3610
3649
  */
3611
3650
  animationStarted() {
3612
3651
  console.log({ activePlace: this._activePlace.value });
3613
3652
  }
3653
+ // @Trace()
3614
3654
  /**
3615
3655
  * @return {?}
3616
3656
  */
@@ -3623,7 +3663,7 @@ class PlaceOutletComponent extends DisposableComponent {
3623
3663
  PlaceOutletComponent.decorators = [
3624
3664
  { type: Component, args: [{
3625
3665
  selector: 'aup-place-outlet',
3626
- template: "<div class=\"router-outlet-container\"\n [@routeAnimations]=\"{value: placeAnimationOrder.value, params:{duration: animationDuration}}\"\n (@routeAnimations.start)=\"animationStarted()\"\n (@routeAnimations.done)=\"animationDone()\"\n>\n <router-outlet #routerOutlet=\"outlet\"\n (activate)=\"onOutletActivated(routerOutlet, $event)\"\n (deactivate)=\"onOutletDeactivated()\">\n </router-outlet>\n</div>\n\n",
3666
+ template: "<div class=\"router-outlet-container\"\n [@routeAnimations]=\"{value: getAnimationOrder(), params:{duration: animationDuration}}\"\n (@routeAnimations.start)=\"animationStarted()\"\n (@routeAnimations.done)=\"animationDone()\"\n>\n <router-outlet #routerOutlet=\"outlet\"\n (activate)=\"onOutletActivated(routerOutlet, $event)\"\n (deactivate)=\"onOutletDeactivated()\">\n </router-outlet>\n</div>\n\n",
3627
3667
  animations: [LEFT_RIGHT_PLACE_ANIMATION],
3628
3668
  styles: [":host{display:flex;flex-direction:column;min-height:0;overflow-x:hidden}.router-outlet-container{flex:1;display:block;position:relative;min-height:0}router-outlet{display:none}"]
3629
3669
  }] }
@@ -3650,36 +3690,6 @@ __decorate([
3650
3690
  StoreInListModel('customPlaceAnimationOrderModel'),
3651
3691
  __metadata("design:type", Array)
3652
3692
  ], PlaceOutletComponent.prototype, "customPlaceAnimationOrder", void 0);
3653
- __decorate([
3654
- Trace(),
3655
- __metadata("design:type", Function),
3656
- __metadata("design:paramtypes", [Visit]),
3657
- __metadata("design:returntype", void 0)
3658
- ], PlaceOutletComponent.prototype, "navigate", null);
3659
- __decorate([
3660
- Trace(),
3661
- __metadata("design:type", Function),
3662
- __metadata("design:paramtypes", [RouterOutlet, PlaceComponent]),
3663
- __metadata("design:returntype", void 0)
3664
- ], PlaceOutletComponent.prototype, "onOutletActivated", null);
3665
- __decorate([
3666
- Trace(),
3667
- __metadata("design:type", Function),
3668
- __metadata("design:paramtypes", []),
3669
- __metadata("design:returntype", void 0)
3670
- ], PlaceOutletComponent.prototype, "onOutletDeactivated", null);
3671
- __decorate([
3672
- Trace(),
3673
- __metadata("design:type", Function),
3674
- __metadata("design:paramtypes", []),
3675
- __metadata("design:returntype", void 0)
3676
- ], PlaceOutletComponent.prototype, "animationStarted", null);
3677
- __decorate([
3678
- Trace(),
3679
- __metadata("design:type", Function),
3680
- __metadata("design:paramtypes", []),
3681
- __metadata("design:returntype", void 0)
3682
- ], PlaceOutletComponent.prototype, "animationDone", null);
3683
3693
  if (false) {
3684
3694
  /** @type {?} */
3685
3695
  PlaceOutletComponent.prototype.animate;
@@ -3701,11 +3711,26 @@ if (false) {
3701
3711
  * @private
3702
3712
  */
3703
3713
  PlaceOutletComponent.prototype._activePlaceVisitModel;
3714
+ /**
3715
+ * @type {?}
3716
+ * @private
3717
+ */
3718
+ PlaceOutletComponent.prototype._inOutletActivation;
3719
+ /**
3720
+ * @type {?}
3721
+ * @private
3722
+ */
3723
+ PlaceOutletComponent.prototype._inOutletDeactivation;
3704
3724
  /**
3705
3725
  * @type {?}
3706
3726
  * @private
3707
3727
  */
3708
3728
  PlaceOutletComponent.prototype._inOutletUpdate;
3729
+ /**
3730
+ * @type {?}
3731
+ * @private
3732
+ */
3733
+ PlaceOutletComponent.prototype._inRouteVisitUpdate;
3709
3734
  /**
3710
3735
  * @type {?}
3711
3736
  * @private
@@ -3727,7 +3752,12 @@ if (false) {
3727
3752
  * @type {?}
3728
3753
  * @private
3729
3754
  */
3730
- PlaceOutletComponent.prototype.isOnInitialPlace;
3755
+ PlaceOutletComponent.prototype.initialPlaceIndex;
3756
+ /**
3757
+ * @type {?}
3758
+ * @private
3759
+ */
3760
+ PlaceOutletComponent.prototype.routerVisit;
3731
3761
  /**
3732
3762
  * @type {?}
3733
3763
  * @private
@@ -3916,7 +3946,6 @@ TabbedPlaceNavigationComponent.ctorParameters = () => [];
3916
3946
  * @fileoverview added by tsickle
3917
3947
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3918
3948
  */
3919
- const ɵ0 = { animationDuration: "2000ms" };
3920
3949
  class PlaceModule {
3921
3950
  }
3922
3951
  PlaceModule.decorators = [
@@ -3948,7 +3977,7 @@ PlaceModule.decorators = [
3948
3977
  ListPlaceNavComponent
3949
3978
  ],
3950
3979
  providers: [
3951
- { provide: AUP_PLACE_CONFIG, useValue: ɵ0 }
3980
+ // {provide: AUP_PLACE_CONFIG, useValue: {animationDuration: "2000ms"}}
3952
3981
  ]
3953
3982
  },] }
3954
3983
  ];