@coolon/angular-ui-powerups 0.0.106 → 0.0.108
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.
- package/bundles/coolon-angular-ui-powerups.umd.js +108 -75
- package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -1
- package/bundles/coolon-angular-ui-powerups.umd.min.js +1 -1
- package/bundles/coolon-angular-ui-powerups.umd.min.js.map +1 -1
- package/coolon-angular-ui-powerups.metadata.json +1 -1
- package/esm2015/lib/place/guards/navigation-state.js +41 -12
- package/esm2015/lib/place/guards/place-component-deactivation-handler.js +3 -3
- package/esm2015/lib/place/place-router.js +53 -18
- package/esm2015/lib/place/url-snapshot.js +5 -25
- package/esm5/lib/place/guards/navigation-state.js +47 -23
- package/esm5/lib/place/guards/place-component-deactivation-handler.js +2 -3
- package/esm5/lib/place/place-router.js +60 -24
- package/esm5/lib/place/url-snapshot.js +5 -31
- package/fesm2015/coolon-angular-ui-powerups.js +97 -53
- package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
- package/fesm5/coolon-angular-ui-powerups.js +109 -76
- package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
- package/lib/place/place-router.d.ts +3 -3
- package/lib/place/url-snapshot.d.ts +2 -5
- package/package.json +1 -1
|
@@ -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,
|
|
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';
|
|
@@ -2963,7 +2963,7 @@ class PlaceComponentDeactivationHandler {
|
|
|
2963
2963
|
// we always return true if we accepted promise from a previous cycle of the current
|
|
2964
2964
|
// navigation session.
|
|
2965
2965
|
if (!this.canDeactivatePromise) {
|
|
2966
|
-
console.log(`creating deactivate promise for -> ${this.component.constructor.name}`);
|
|
2966
|
+
// console.log(`creating deactivate promise for -> ${this.component.constructor.name}`);
|
|
2967
2967
|
this.canDeactivatePromise = this.canDeactivateComponent(currentUrl, nextState);
|
|
2968
2968
|
}
|
|
2969
2969
|
return this.canDeactivatePromise;
|
|
@@ -2978,7 +2978,7 @@ class PlaceComponentDeactivationHandler {
|
|
|
2978
2978
|
*/
|
|
2979
2979
|
canDeactivateComponent(currentUrl, nextState) {
|
|
2980
2980
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2981
|
-
console.log(this.navigationState.toString());
|
|
2981
|
+
// console.log(this.navigationState.toString());
|
|
2982
2982
|
// Automatically cancel any active activities if the navigation session was triggered by the back button.
|
|
2983
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.
|
|
2984
2984
|
if (this.navigationState.isPopState) {
|
|
@@ -3534,6 +3534,7 @@ if (false) {
|
|
|
3534
3534
|
navigationTransition.storeVisit(visit);
|
|
3535
3535
|
return navigationTransition;
|
|
3536
3536
|
}
|
|
3537
|
+
// @Trace()
|
|
3537
3538
|
/**
|
|
3538
3539
|
* @param {?} event
|
|
3539
3540
|
* @return {?}
|
|
@@ -3549,12 +3550,6 @@ if (false) {
|
|
|
3549
3550
|
return new InteractionPopStateTransition(this.context, event.url);
|
|
3550
3551
|
}
|
|
3551
3552
|
}
|
|
3552
|
-
__decorate([
|
|
3553
|
-
Trace(),
|
|
3554
|
-
__metadata("design:type", Function),
|
|
3555
|
-
__metadata("design:paramtypes", [NavigationStart]),
|
|
3556
|
-
__metadata("design:returntype", NavigationState)
|
|
3557
|
-
], IdleDuringInteraction.prototype, "onRouterStarted", null);
|
|
3558
3553
|
__decorate([
|
|
3559
3554
|
Trace(),
|
|
3560
3555
|
__metadata("design:type", Function),
|
|
@@ -3636,6 +3631,24 @@ if (false) {
|
|
|
3636
3631
|
}
|
|
3637
3632
|
}
|
|
3638
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);
|
|
3639
3652
|
NavigationState.InteractionTransition = InteractionTransition;
|
|
3640
3653
|
if (false) {
|
|
3641
3654
|
/** @type {?} */
|
|
@@ -3678,6 +3691,18 @@ if (false) {
|
|
|
3678
3691
|
}
|
|
3679
3692
|
}
|
|
3680
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);
|
|
3681
3706
|
NavigationState.InteractionPopStateTransition = InteractionPopStateTransition;
|
|
3682
3707
|
if (false) {
|
|
3683
3708
|
/** @type {?} */
|
|
@@ -3717,10 +3742,14 @@ if (false) {
|
|
|
3717
3742
|
*/
|
|
3718
3743
|
onRouterCancelled(event) {
|
|
3719
3744
|
// Depending on the state of the router and what was done we get a different
|
|
3720
|
-
// sequence of events.
|
|
3721
|
-
// with the locationChangeTriggerUrl as the final event.
|
|
3722
|
-
//
|
|
3723
|
-
|
|
3745
|
+
// sequence of events.
|
|
3746
|
+
// If the navigation change was triggered by clicking a link we'll get a cancel with the locationChangeTriggerUrl as the final event.
|
|
3747
|
+
// If the navigation change was triggered with a pop state then we'll get an onPopState with the locationChangeTriggerUrl but no cancel event with it.
|
|
3748
|
+
if (this.gotPopStateWithLeavingUrl && this.interactionService.isActive()) {
|
|
3749
|
+
/** @type {?} */
|
|
3750
|
+
const interactionIds = this.interactionService.activeInteractionContextIds.value;
|
|
3751
|
+
this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
|
|
3752
|
+
}
|
|
3724
3753
|
return this.gotPopStateWithLeavingUrl || this.locationChangeTriggerUrl === event.url ? this.createIdleState() : this.ignore(event);
|
|
3725
3754
|
}
|
|
3726
3755
|
/**
|
|
@@ -3869,12 +3898,10 @@ class UrlSnapshot {
|
|
|
3869
3898
|
/**
|
|
3870
3899
|
* @param {?} urlSerializer
|
|
3871
3900
|
* @param {?} url
|
|
3872
|
-
* @param {?} options
|
|
3873
3901
|
*/
|
|
3874
|
-
constructor(urlSerializer, url
|
|
3902
|
+
constructor(urlSerializer, url) {
|
|
3875
3903
|
this.urlSerializer = urlSerializer;
|
|
3876
3904
|
this.url = url;
|
|
3877
|
-
this.options = options;
|
|
3878
3905
|
this.urlTree = urlSerializer.parse(url);
|
|
3879
3906
|
}
|
|
3880
3907
|
/**
|
|
@@ -3898,7 +3925,7 @@ class UrlSnapshot {
|
|
|
3898
3925
|
// do not use the return value, it's the items that were removed!
|
|
3899
3926
|
segments.splice(replaceAt, visitSegments.length, ...visitSegments);
|
|
3900
3927
|
urlTree.root.children.primary.segments = segments;
|
|
3901
|
-
return new UrlSnapshot(this.urlSerializer, urlTree.toString()
|
|
3928
|
+
return new UrlSnapshot(this.urlSerializer, urlTree.toString());
|
|
3902
3929
|
}
|
|
3903
3930
|
/**
|
|
3904
3931
|
* @private
|
|
@@ -3971,7 +3998,7 @@ class UrlSnapshot {
|
|
|
3971
3998
|
/** @type {?} */
|
|
3972
3999
|
const urlTree = this.urlSerializer.parse(this.url);
|
|
3973
4000
|
urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM] = UrlSnapshot.createPathIdFor(ids);
|
|
3974
|
-
return new UrlSnapshot(this.urlSerializer, urlTree.toString()
|
|
4001
|
+
return new UrlSnapshot(this.urlSerializer, urlTree.toString());
|
|
3975
4002
|
}
|
|
3976
4003
|
}
|
|
3977
4004
|
// @Trace()
|
|
@@ -3984,20 +4011,7 @@ class UrlSnapshot {
|
|
|
3984
4011
|
if (urlTree.queryParams && urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM]) {
|
|
3985
4012
|
urlTree.queryParams = {}; //[UrlSnapshot.INTERACTION_ROUTER_OUTLET]
|
|
3986
4013
|
}
|
|
3987
|
-
return new UrlSnapshot(this.urlSerializer, urlTree.toString()
|
|
3988
|
-
}
|
|
3989
|
-
/**
|
|
3990
|
-
* @param {?} options
|
|
3991
|
-
* @return {?}
|
|
3992
|
-
*/
|
|
3993
|
-
withOptions(options) {
|
|
3994
|
-
return new UrlSnapshot(this.urlSerializer, this.url, options);
|
|
3995
|
-
}
|
|
3996
|
-
/**
|
|
3997
|
-
* @return {?}
|
|
3998
|
-
*/
|
|
3999
|
-
getNavigationExtras() {
|
|
4000
|
-
return this.options;
|
|
4014
|
+
return new UrlSnapshot(this.urlSerializer, urlTree.toString());
|
|
4001
4015
|
}
|
|
4002
4016
|
}
|
|
4003
4017
|
if (false) {
|
|
@@ -4007,11 +4021,6 @@ if (false) {
|
|
|
4007
4021
|
UrlSnapshot.prototype.urlSerializer;
|
|
4008
4022
|
/** @type {?} */
|
|
4009
4023
|
UrlSnapshot.prototype.url;
|
|
4010
|
-
/**
|
|
4011
|
-
* @type {?}
|
|
4012
|
-
* @private
|
|
4013
|
-
*/
|
|
4014
|
-
UrlSnapshot.prototype.options;
|
|
4015
4024
|
}
|
|
4016
4025
|
(function (UrlSnapshot) {
|
|
4017
4026
|
UrlSnapshot.INTERACTION_QUERY_PARAM = 'aup-interactions';
|
|
@@ -4140,7 +4149,7 @@ class PlaceRouter extends GarbageCollector {
|
|
|
4140
4149
|
* @return {?}
|
|
4141
4150
|
*/
|
|
4142
4151
|
(ids, previous) => {
|
|
4143
|
-
this.syncInteractionIdsWithRouter();
|
|
4152
|
+
this.syncInteractionIdsWithRouter(ids, previous);
|
|
4144
4153
|
}), { unless: this.navigationInProgress }); // TODO: I think the exclusive interaction prevents interactions starting while it's active so we might not need this.
|
|
4145
4154
|
// TODO: I think the exclusive interaction prevents interactions starting while it's active so we might not need this.
|
|
4146
4155
|
/** @type {?} */
|
|
@@ -4341,7 +4350,7 @@ class PlaceRouter extends GarbageCollector {
|
|
|
4341
4350
|
* @return {?}
|
|
4342
4351
|
*/
|
|
4343
4352
|
parseUrl(url) {
|
|
4344
|
-
return new UrlSnapshot(this.urlSerializer, url
|
|
4353
|
+
return new UrlSnapshot(this.urlSerializer, url);
|
|
4345
4354
|
}
|
|
4346
4355
|
/**
|
|
4347
4356
|
* @param {?} url
|
|
@@ -4393,34 +4402,63 @@ class PlaceRouter extends GarbageCollector {
|
|
|
4393
4402
|
hasActiveInteractionIds(url) {
|
|
4394
4403
|
return this.getActiveInteractionIdsFromUrl(url).length > 0;
|
|
4395
4404
|
}
|
|
4396
|
-
// @Trace()
|
|
4397
4405
|
/**
|
|
4398
4406
|
* @param {?} urlSnapshot
|
|
4407
|
+
* @param {?=} navigationExtras
|
|
4399
4408
|
* @return {?}
|
|
4400
4409
|
*/
|
|
4401
|
-
navigateByUrl(urlSnapshot) {
|
|
4402
|
-
this.router.navigateByUrl(urlSnapshot.urlTree,
|
|
4410
|
+
navigateByUrl(urlSnapshot, navigationExtras) {
|
|
4411
|
+
return this.router.navigateByUrl(urlSnapshot.urlTree, navigationExtras);
|
|
4403
4412
|
}
|
|
4404
|
-
//
|
|
4413
|
+
// TODO: Should this be moved to the navigation states?
|
|
4405
4414
|
/**
|
|
4415
|
+
* @param {?} currentIds
|
|
4416
|
+
* @param {?} previous
|
|
4406
4417
|
* @return {?}
|
|
4407
4418
|
*/
|
|
4408
|
-
syncInteractionIdsWithRouter() {
|
|
4419
|
+
syncInteractionIdsWithRouter(currentIds, previous) {
|
|
4409
4420
|
assert.isFalsey(this.navigationInProgress.value); // Updating interaction routes during an existing navigation breaks all the things.
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4421
|
+
console.log({
|
|
4422
|
+
startingActivity: currentIds.length > previous.length,
|
|
4423
|
+
wasBackButton: this.navigationState.isPopState
|
|
4424
|
+
});
|
|
4425
|
+
if (___default.isEqual(currentIds, previous)) {
|
|
4414
4426
|
console.log('activity ids were the same, skipping');
|
|
4415
4427
|
}
|
|
4416
4428
|
else {
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4429
|
+
// OMG, this is nuts.
|
|
4430
|
+
/** @type {?} */
|
|
4431
|
+
const addingActivity = currentIds.length > previous.length;
|
|
4432
|
+
/** @type {?} */
|
|
4433
|
+
const isFirstActivity = addingActivity && previous.length < 1;
|
|
4434
|
+
/** @type {?} */
|
|
4435
|
+
const removingLastActivity = currentIds.length < 1;
|
|
4436
|
+
if (addingActivity) { // we're starting a new activity, push the change to the history and update the url
|
|
4437
|
+
console.log('adding activity');
|
|
4438
|
+
this.navigateByUrl(this.getCurrentRouteSnapshot().updateInteractionIds(currentIds), {
|
|
4439
|
+
replaceUrl: !isFirstActivity // we don't let the history pile up
|
|
4440
|
+
});
|
|
4420
4441
|
}
|
|
4421
4442
|
else {
|
|
4422
|
-
|
|
4423
|
-
this.
|
|
4443
|
+
/** @type {?} */
|
|
4444
|
+
const urlSnapshot = this.getCurrentRouteSnapshot().updateInteractionIds(currentIds);
|
|
4445
|
+
if (removingLastActivity) {
|
|
4446
|
+
this.navigateByUrl(urlSnapshot, {
|
|
4447
|
+
replaceUrl: true
|
|
4448
|
+
}).then((/**
|
|
4449
|
+
* @return {?}
|
|
4450
|
+
*/
|
|
4451
|
+
() => {
|
|
4452
|
+
// for some reason we need to pop the last history off the stack when leaving the
|
|
4453
|
+
// active activity state.
|
|
4454
|
+
this.angularLocation.back();
|
|
4455
|
+
}));
|
|
4456
|
+
}
|
|
4457
|
+
else {
|
|
4458
|
+
this.navigateByUrl(urlSnapshot, {
|
|
4459
|
+
replaceUrl: true
|
|
4460
|
+
});
|
|
4461
|
+
}
|
|
4424
4462
|
}
|
|
4425
4463
|
}
|
|
4426
4464
|
}
|
|
@@ -4439,6 +4477,12 @@ PlaceRouter.ctorParameters = () => [
|
|
|
4439
4477
|
{ type: InteractionService }
|
|
4440
4478
|
];
|
|
4441
4479
|
/** @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" });
|
|
4480
|
+
__decorate([
|
|
4481
|
+
Trace(),
|
|
4482
|
+
__metadata("design:type", Function),
|
|
4483
|
+
__metadata("design:paramtypes", [UrlSnapshot, Object]),
|
|
4484
|
+
__metadata("design:returntype", Promise)
|
|
4485
|
+
], PlaceRouter.prototype, "navigateByUrl", null);
|
|
4442
4486
|
if (false) {
|
|
4443
4487
|
/**
|
|
4444
4488
|
* @type {?}
|