@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 { __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,
|
|
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(
|
|
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;
|
|
@@ -4661,10 +4680,14 @@ if (false) {
|
|
|
4661
4680
|
*/
|
|
4662
4681
|
function (event) {
|
|
4663
4682
|
// Depending on the state of the router and what was done we get a different
|
|
4664
|
-
// sequence of events.
|
|
4665
|
-
// with the locationChangeTriggerUrl as the final event.
|
|
4666
|
-
//
|
|
4667
|
-
|
|
4683
|
+
// sequence of events.
|
|
4684
|
+
// If the navigation change was triggered by clicking a link we'll get a cancel with the locationChangeTriggerUrl as the final event.
|
|
4685
|
+
// 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.
|
|
4686
|
+
if (this.gotPopStateWithLeavingUrl && this.interactionService.isActive()) {
|
|
4687
|
+
/** @type {?} */
|
|
4688
|
+
var interactionIds = this.interactionService.activeInteractionContextIds.value;
|
|
4689
|
+
this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
|
|
4690
|
+
}
|
|
4668
4691
|
return this.gotPopStateWithLeavingUrl || this.locationChangeTriggerUrl === event.url ? this.createIdleState() : this.ignore(event);
|
|
4669
4692
|
};
|
|
4670
4693
|
/**
|
|
@@ -4860,10 +4883,9 @@ if (false) {
|
|
|
4860
4883
|
*/
|
|
4861
4884
|
var UrlSnapshot = /** @class */ (function () {
|
|
4862
4885
|
// 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
|
|
4886
|
+
function UrlSnapshot(urlSerializer, url) {
|
|
4864
4887
|
this.urlSerializer = urlSerializer;
|
|
4865
4888
|
this.url = url;
|
|
4866
|
-
this.options = options;
|
|
4867
4889
|
this.urlTree = urlSerializer.parse(url);
|
|
4868
4890
|
}
|
|
4869
4891
|
/**
|
|
@@ -4891,7 +4913,7 @@ var UrlSnapshot = /** @class */ (function () {
|
|
|
4891
4913
|
// do not use the return value, it's the items that were removed!
|
|
4892
4914
|
segments.splice.apply(segments, __spread([replaceAt, visitSegments.length], visitSegments));
|
|
4893
4915
|
urlTree.root.children.primary.segments = segments;
|
|
4894
|
-
return new UrlSnapshot(this.urlSerializer, urlTree.toString()
|
|
4916
|
+
return new UrlSnapshot(this.urlSerializer, urlTree.toString());
|
|
4895
4917
|
};
|
|
4896
4918
|
/**
|
|
4897
4919
|
* @private
|
|
@@ -4996,7 +5018,7 @@ var UrlSnapshot = /** @class */ (function () {
|
|
|
4996
5018
|
/** @type {?} */
|
|
4997
5019
|
var urlTree = this.urlSerializer.parse(this.url);
|
|
4998
5020
|
urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM] = UrlSnapshot.createPathIdFor(ids);
|
|
4999
|
-
return new UrlSnapshot(this.urlSerializer, urlTree.toString()
|
|
5021
|
+
return new UrlSnapshot(this.urlSerializer, urlTree.toString());
|
|
5000
5022
|
}
|
|
5001
5023
|
};
|
|
5002
5024
|
// @Trace()
|
|
@@ -5015,27 +5037,7 @@ var UrlSnapshot = /** @class */ (function () {
|
|
|
5015
5037
|
if (urlTree.queryParams && urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM]) {
|
|
5016
5038
|
urlTree.queryParams = {}; //[UrlSnapshot.INTERACTION_ROUTER_OUTLET]
|
|
5017
5039
|
}
|
|
5018
|
-
return new UrlSnapshot(this.urlSerializer, urlTree.toString()
|
|
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;
|
|
5040
|
+
return new UrlSnapshot(this.urlSerializer, urlTree.toString());
|
|
5039
5041
|
};
|
|
5040
5042
|
return UrlSnapshot;
|
|
5041
5043
|
}());
|
|
@@ -5046,11 +5048,6 @@ if (false) {
|
|
|
5046
5048
|
UrlSnapshot.prototype.urlSerializer;
|
|
5047
5049
|
/** @type {?} */
|
|
5048
5050
|
UrlSnapshot.prototype.url;
|
|
5049
|
-
/**
|
|
5050
|
-
* @type {?}
|
|
5051
|
-
* @private
|
|
5052
|
-
*/
|
|
5053
|
-
UrlSnapshot.prototype.options;
|
|
5054
5051
|
}
|
|
5055
5052
|
(function (UrlSnapshot) {
|
|
5056
5053
|
UrlSnapshot.INTERACTION_QUERY_PARAM = 'aup-interactions';
|
|
@@ -5173,7 +5170,7 @@ var PlaceRouter = /** @class */ (function (_super) {
|
|
|
5173
5170
|
* @return {?}
|
|
5174
5171
|
*/
|
|
5175
5172
|
function (ids, previous) {
|
|
5176
|
-
_this.syncInteractionIdsWithRouter();
|
|
5173
|
+
_this.syncInteractionIdsWithRouter(ids, previous);
|
|
5177
5174
|
}), { unless: _this.navigationInProgress }); // TODO: I think the exclusive interaction prevents interactions starting while it's active so we might not need this.
|
|
5178
5175
|
// TODO: I think the exclusive interaction prevents interactions starting while it's active so we might not need this.
|
|
5179
5176
|
/** @type {?} */
|
|
@@ -5464,7 +5461,7 @@ var PlaceRouter = /** @class */ (function (_super) {
|
|
|
5464
5461
|
* @return {?}
|
|
5465
5462
|
*/
|
|
5466
5463
|
function (url) {
|
|
5467
|
-
return new UrlSnapshot(this.urlSerializer, url
|
|
5464
|
+
return new UrlSnapshot(this.urlSerializer, url);
|
|
5468
5465
|
};
|
|
5469
5466
|
/**
|
|
5470
5467
|
* @param {?} url
|
|
@@ -5546,47 +5543,77 @@ var PlaceRouter = /** @class */ (function (_super) {
|
|
|
5546
5543
|
function (url) {
|
|
5547
5544
|
return this.getActiveInteractionIdsFromUrl(url).length > 0;
|
|
5548
5545
|
};
|
|
5549
|
-
// @Trace()
|
|
5550
|
-
// @Trace()
|
|
5551
5546
|
/**
|
|
5552
5547
|
* @param {?} urlSnapshot
|
|
5548
|
+
* @param {?=} navigationExtras
|
|
5553
5549
|
* @return {?}
|
|
5554
5550
|
*/
|
|
5555
|
-
PlaceRouter.prototype.navigateByUrl =
|
|
5556
|
-
// @Trace()
|
|
5557
|
-
/**
|
|
5551
|
+
PlaceRouter.prototype.navigateByUrl = /**
|
|
5558
5552
|
* @param {?} urlSnapshot
|
|
5553
|
+
* @param {?=} navigationExtras
|
|
5559
5554
|
* @return {?}
|
|
5560
5555
|
*/
|
|
5561
|
-
function (urlSnapshot) {
|
|
5562
|
-
this.router.navigateByUrl(urlSnapshot.urlTree,
|
|
5556
|
+
function (urlSnapshot, navigationExtras) {
|
|
5557
|
+
return this.router.navigateByUrl(urlSnapshot.urlTree, navigationExtras);
|
|
5563
5558
|
};
|
|
5564
|
-
//
|
|
5565
|
-
//
|
|
5559
|
+
// TODO: Should this be moved to the navigation states?
|
|
5560
|
+
// TODO: Should this be moved to the navigation states?
|
|
5566
5561
|
/**
|
|
5562
|
+
* @param {?} currentIds
|
|
5563
|
+
* @param {?} previous
|
|
5567
5564
|
* @return {?}
|
|
5568
5565
|
*/
|
|
5569
5566
|
PlaceRouter.prototype.syncInteractionIdsWithRouter =
|
|
5570
|
-
//
|
|
5567
|
+
// TODO: Should this be moved to the navigation states?
|
|
5571
5568
|
/**
|
|
5569
|
+
* @param {?} currentIds
|
|
5570
|
+
* @param {?} previous
|
|
5572
5571
|
* @return {?}
|
|
5573
5572
|
*/
|
|
5574
|
-
function () {
|
|
5573
|
+
function (currentIds, previous) {
|
|
5574
|
+
var _this = this;
|
|
5575
5575
|
assert.isFalsey(this.navigationInProgress.value); // Updating interaction routes during an existing navigation breaks all the things.
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
|
|
5576
|
+
console.log({
|
|
5577
|
+
startingActivity: currentIds.length > previous.length,
|
|
5578
|
+
wasBackButton: this.navigationState.isPopState
|
|
5579
|
+
});
|
|
5580
|
+
if (___default.isEqual(currentIds, previous)) {
|
|
5580
5581
|
console.log('activity ids were the same, skipping');
|
|
5581
5582
|
}
|
|
5582
5583
|
else {
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
|
|
5584
|
+
// OMG, this is nuts.
|
|
5585
|
+
/** @type {?} */
|
|
5586
|
+
var addingActivity = currentIds.length > previous.length;
|
|
5587
|
+
/** @type {?} */
|
|
5588
|
+
var isFirstActivity = addingActivity && previous.length < 1;
|
|
5589
|
+
/** @type {?} */
|
|
5590
|
+
var removingLastActivity = currentIds.length < 1;
|
|
5591
|
+
if (addingActivity) { // we're starting a new activity, push the change to the history and update the url
|
|
5592
|
+
console.log('adding activity');
|
|
5593
|
+
this.navigateByUrl(this.getCurrentRouteSnapshot().updateInteractionIds(currentIds), {
|
|
5594
|
+
replaceUrl: !isFirstActivity // we don't let the history pile up
|
|
5595
|
+
});
|
|
5586
5596
|
}
|
|
5587
5597
|
else {
|
|
5588
|
-
|
|
5589
|
-
this.
|
|
5598
|
+
/** @type {?} */
|
|
5599
|
+
var urlSnapshot = this.getCurrentRouteSnapshot().updateInteractionIds(currentIds);
|
|
5600
|
+
if (removingLastActivity) {
|
|
5601
|
+
this.navigateByUrl(urlSnapshot, {
|
|
5602
|
+
replaceUrl: true
|
|
5603
|
+
}).then((/**
|
|
5604
|
+
* @return {?}
|
|
5605
|
+
*/
|
|
5606
|
+
function () {
|
|
5607
|
+
// for some reason we need to pop the last history off the stack when leaving the
|
|
5608
|
+
// active activity state.
|
|
5609
|
+
_this.angularLocation.back();
|
|
5610
|
+
}));
|
|
5611
|
+
}
|
|
5612
|
+
else {
|
|
5613
|
+
this.navigateByUrl(urlSnapshot, {
|
|
5614
|
+
replaceUrl: true
|
|
5615
|
+
});
|
|
5616
|
+
}
|
|
5590
5617
|
}
|
|
5591
5618
|
}
|
|
5592
5619
|
};
|
|
@@ -5604,6 +5631,12 @@ var PlaceRouter = /** @class */ (function (_super) {
|
|
|
5604
5631
|
{ type: InteractionService }
|
|
5605
5632
|
]; };
|
|
5606
5633
|
/** @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" });
|
|
5634
|
+
__decorate([
|
|
5635
|
+
Trace(),
|
|
5636
|
+
__metadata("design:type", Function),
|
|
5637
|
+
__metadata("design:paramtypes", [UrlSnapshot, Object]),
|
|
5638
|
+
__metadata("design:returntype", Promise)
|
|
5639
|
+
], PlaceRouter.prototype, "navigateByUrl", null);
|
|
5607
5640
|
return PlaceRouter;
|
|
5608
5641
|
}(GarbageCollector));
|
|
5609
5642
|
if (false) {
|