@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.
- package/bundles/coolon-angular-ui-powerups.umd.js +123 -71
- 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/interaction/services/interaction.service.js +10 -1
- package/esm2015/lib/place/guards/navigation-state.js +33 -8
- 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/interaction/services/interaction.service.js +24 -1
- package/esm5/lib/place/guards/navigation-state.js +39 -19
- 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 +98 -49
- package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
- package/fesm5/coolon-angular-ui-powerups.js +124 -72
- package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
- package/lib/interaction/services/interaction.service.d.ts +9 -0
- 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';
|
|
@@ -2257,10 +2257,33 @@ var InteractionService = /** @class */ (function () {
|
|
|
2257
2257
|
return this.modelInteractionActive.value;
|
|
2258
2258
|
};
|
|
2259
2259
|
/**
|
|
2260
|
+
* @deprecated use #createModalInteractionContextDisposedWith instead.
|
|
2261
|
+
* @param disposable
|
|
2262
|
+
*/
|
|
2263
|
+
/**
|
|
2264
|
+
* @deprecated use #createModalInteractionContextDisposedWith instead.
|
|
2260
2265
|
* @param {?} disposable
|
|
2261
2266
|
* @return {?}
|
|
2262
2267
|
*/
|
|
2263
2268
|
InteractionService.prototype.createModalInteractionContextFor = /**
|
|
2269
|
+
* @deprecated use #createModalInteractionContextDisposedWith instead.
|
|
2270
|
+
* @param {?} disposable
|
|
2271
|
+
* @return {?}
|
|
2272
|
+
*/
|
|
2273
|
+
function (disposable) {
|
|
2274
|
+
return this.createModalInteractionContextDisposedWith(disposable);
|
|
2275
|
+
};
|
|
2276
|
+
/**
|
|
2277
|
+
* Creates a new model interaction context that will be disposed along with the component.
|
|
2278
|
+
* @param disposable
|
|
2279
|
+
*/
|
|
2280
|
+
/**
|
|
2281
|
+
* Creates a new model interaction context that will be disposed along with the component.
|
|
2282
|
+
* @param {?} disposable
|
|
2283
|
+
* @return {?}
|
|
2284
|
+
*/
|
|
2285
|
+
InteractionService.prototype.createModalInteractionContextDisposedWith = /**
|
|
2286
|
+
* Creates a new model interaction context that will be disposed along with the component.
|
|
2264
2287
|
* @param {?} disposable
|
|
2265
2288
|
* @return {?}
|
|
2266
2289
|
*/
|
|
@@ -3647,7 +3670,7 @@ var PlaceComponentDeactivationHandler = /** @class */ (function () {
|
|
|
3647
3670
|
// we always return true if we accepted promise from a previous cycle of the current
|
|
3648
3671
|
// navigation session.
|
|
3649
3672
|
if (!this.canDeactivatePromise) {
|
|
3650
|
-
console.log(
|
|
3673
|
+
// console.log(`creating deactivate promise for -> ${this.component.constructor.name}`);
|
|
3651
3674
|
this.canDeactivatePromise = this.canDeactivateComponent(currentUrl, nextState);
|
|
3652
3675
|
}
|
|
3653
3676
|
return [2 /*return*/, this.canDeactivatePromise];
|
|
@@ -3676,7 +3699,6 @@ var PlaceComponentDeactivationHandler = /** @class */ (function () {
|
|
|
3676
3699
|
return __generator(this, function (_a) {
|
|
3677
3700
|
switch (_a.label) {
|
|
3678
3701
|
case 0:
|
|
3679
|
-
console.log(this.navigationState.toString());
|
|
3680
3702
|
if (!this.navigationState.isPopState) return [3 /*break*/, 5];
|
|
3681
3703
|
if (!(this.isPrimaryComponent && this.interactionService.isModalActive())) return [3 /*break*/, 3];
|
|
3682
3704
|
routeIds = this.placeRouter.getActiveInteractionIdsFromUrl(nextState.url);
|
|
@@ -4402,11 +4424,15 @@ if (false) {
|
|
|
4402
4424
|
navigationTransition.storeVisit(visit);
|
|
4403
4425
|
return navigationTransition;
|
|
4404
4426
|
};
|
|
4427
|
+
// @Trace()
|
|
4428
|
+
// @Trace()
|
|
4405
4429
|
/**
|
|
4406
4430
|
* @param {?} event
|
|
4407
4431
|
* @return {?}
|
|
4408
4432
|
*/
|
|
4409
|
-
IdleDuringInteraction.prototype.onRouterStarted =
|
|
4433
|
+
IdleDuringInteraction.prototype.onRouterStarted =
|
|
4434
|
+
// @Trace()
|
|
4435
|
+
/**
|
|
4410
4436
|
* @param {?} event
|
|
4411
4437
|
* @return {?}
|
|
4412
4438
|
*/
|
|
@@ -4424,12 +4450,6 @@ if (false) {
|
|
|
4424
4450
|
function (event) {
|
|
4425
4451
|
return new InteractionPopStateTransition(this.context, event.url);
|
|
4426
4452
|
};
|
|
4427
|
-
__decorate([
|
|
4428
|
-
Trace(),
|
|
4429
|
-
__metadata("design:type", Function),
|
|
4430
|
-
__metadata("design:paramtypes", [NavigationStart]),
|
|
4431
|
-
__metadata("design:returntype", NavigationState)
|
|
4432
|
-
], IdleDuringInteraction.prototype, "onRouterStarted", null);
|
|
4433
4453
|
__decorate([
|
|
4434
4454
|
Trace(),
|
|
4435
4455
|
__metadata("design:type", Function),
|
|
@@ -4474,11 +4494,7 @@ if (false) {
|
|
|
4474
4494
|
* This state exists to handle all events while any kind of navigation is in progress. That way all other states can
|
|
4475
4495
|
* happily ignore interaction contexts.
|
|
4476
4496
|
*/
|
|
4477
|
-
var /**
|
|
4478
|
-
* This state exists to handle all events while any kind of navigation is in progress. That way all other states can
|
|
4479
|
-
* happily ignore interaction contexts.
|
|
4480
|
-
*/
|
|
4481
|
-
InteractionTransition = /** @class */ (function (_super) {
|
|
4497
|
+
var InteractionTransition = /** @class */ (function (_super) {
|
|
4482
4498
|
__extends(InteractionTransition, _super);
|
|
4483
4499
|
function InteractionTransition() {
|
|
4484
4500
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
@@ -4532,6 +4548,24 @@ if (false) {
|
|
|
4532
4548
|
return new Idle(this.context);
|
|
4533
4549
|
}
|
|
4534
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);
|
|
4535
4569
|
return InteractionTransition;
|
|
4536
4570
|
}(AbstractInteractionTransition));
|
|
4537
4571
|
NavigationState.InteractionTransition = InteractionTransition;
|
|
@@ -4543,11 +4577,7 @@ if (false) {
|
|
|
4543
4577
|
* This state exists to handle all events while any kind of navigation is in progress. That way all other states can
|
|
4544
4578
|
* happily ignore interaction contexts.
|
|
4545
4579
|
*/
|
|
4546
|
-
var /**
|
|
4547
|
-
* This state exists to handle all events while any kind of navigation is in progress. That way all other states can
|
|
4548
|
-
* happily ignore interaction contexts.
|
|
4549
|
-
*/
|
|
4550
|
-
InteractionPopStateTransition = /** @class */ (function (_super) {
|
|
4580
|
+
var InteractionPopStateTransition = /** @class */ (function (_super) {
|
|
4551
4581
|
__extends(InteractionPopStateTransition, _super);
|
|
4552
4582
|
function InteractionPopStateTransition() {
|
|
4553
4583
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
@@ -4589,6 +4619,18 @@ if (false) {
|
|
|
4589
4619
|
return new Idle(this.context);
|
|
4590
4620
|
}
|
|
4591
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);
|
|
4592
4634
|
return InteractionPopStateTransition;
|
|
4593
4635
|
}(AbstractInteractionTransition));
|
|
4594
4636
|
NavigationState.InteractionPopStateTransition = InteractionPopStateTransition;
|
|
@@ -4837,10 +4879,9 @@ if (false) {
|
|
|
4837
4879
|
*/
|
|
4838
4880
|
var UrlSnapshot = /** @class */ (function () {
|
|
4839
4881
|
// TODO: Update this accept a url Parser so it can be immutable and generate new trees on mutation using toString() are parseUrl.
|
|
4840
|
-
function UrlSnapshot(urlSerializer, url
|
|
4882
|
+
function UrlSnapshot(urlSerializer, url) {
|
|
4841
4883
|
this.urlSerializer = urlSerializer;
|
|
4842
4884
|
this.url = url;
|
|
4843
|
-
this.options = options;
|
|
4844
4885
|
this.urlTree = urlSerializer.parse(url);
|
|
4845
4886
|
}
|
|
4846
4887
|
/**
|
|
@@ -4868,7 +4909,7 @@ var UrlSnapshot = /** @class */ (function () {
|
|
|
4868
4909
|
// do not use the return value, it's the items that were removed!
|
|
4869
4910
|
segments.splice.apply(segments, __spread([replaceAt, visitSegments.length], visitSegments));
|
|
4870
4911
|
urlTree.root.children.primary.segments = segments;
|
|
4871
|
-
return new UrlSnapshot(this.urlSerializer, urlTree.toString()
|
|
4912
|
+
return new UrlSnapshot(this.urlSerializer, urlTree.toString());
|
|
4872
4913
|
};
|
|
4873
4914
|
/**
|
|
4874
4915
|
* @private
|
|
@@ -4973,7 +5014,7 @@ var UrlSnapshot = /** @class */ (function () {
|
|
|
4973
5014
|
/** @type {?} */
|
|
4974
5015
|
var urlTree = this.urlSerializer.parse(this.url);
|
|
4975
5016
|
urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM] = UrlSnapshot.createPathIdFor(ids);
|
|
4976
|
-
return new UrlSnapshot(this.urlSerializer, urlTree.toString()
|
|
5017
|
+
return new UrlSnapshot(this.urlSerializer, urlTree.toString());
|
|
4977
5018
|
}
|
|
4978
5019
|
};
|
|
4979
5020
|
// @Trace()
|
|
@@ -4992,27 +5033,7 @@ var UrlSnapshot = /** @class */ (function () {
|
|
|
4992
5033
|
if (urlTree.queryParams && urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM]) {
|
|
4993
5034
|
urlTree.queryParams = {}; //[UrlSnapshot.INTERACTION_ROUTER_OUTLET]
|
|
4994
5035
|
}
|
|
4995
|
-
return new UrlSnapshot(this.urlSerializer, urlTree.toString()
|
|
4996
|
-
};
|
|
4997
|
-
/**
|
|
4998
|
-
* @param {?} options
|
|
4999
|
-
* @return {?}
|
|
5000
|
-
*/
|
|
5001
|
-
UrlSnapshot.prototype.withOptions = /**
|
|
5002
|
-
* @param {?} options
|
|
5003
|
-
* @return {?}
|
|
5004
|
-
*/
|
|
5005
|
-
function (options) {
|
|
5006
|
-
return new UrlSnapshot(this.urlSerializer, this.url, options);
|
|
5007
|
-
};
|
|
5008
|
-
/**
|
|
5009
|
-
* @return {?}
|
|
5010
|
-
*/
|
|
5011
|
-
UrlSnapshot.prototype.getNavigationExtras = /**
|
|
5012
|
-
* @return {?}
|
|
5013
|
-
*/
|
|
5014
|
-
function () {
|
|
5015
|
-
return this.options;
|
|
5036
|
+
return new UrlSnapshot(this.urlSerializer, urlTree.toString());
|
|
5016
5037
|
};
|
|
5017
5038
|
return UrlSnapshot;
|
|
5018
5039
|
}());
|
|
@@ -5023,11 +5044,6 @@ if (false) {
|
|
|
5023
5044
|
UrlSnapshot.prototype.urlSerializer;
|
|
5024
5045
|
/** @type {?} */
|
|
5025
5046
|
UrlSnapshot.prototype.url;
|
|
5026
|
-
/**
|
|
5027
|
-
* @type {?}
|
|
5028
|
-
* @private
|
|
5029
|
-
*/
|
|
5030
|
-
UrlSnapshot.prototype.options;
|
|
5031
5047
|
}
|
|
5032
5048
|
(function (UrlSnapshot) {
|
|
5033
5049
|
UrlSnapshot.INTERACTION_QUERY_PARAM = 'aup-interactions';
|
|
@@ -5150,7 +5166,7 @@ var PlaceRouter = /** @class */ (function (_super) {
|
|
|
5150
5166
|
* @return {?}
|
|
5151
5167
|
*/
|
|
5152
5168
|
function (ids, previous) {
|
|
5153
|
-
_this.syncInteractionIdsWithRouter();
|
|
5169
|
+
_this.syncInteractionIdsWithRouter(ids, previous);
|
|
5154
5170
|
}), { unless: _this.navigationInProgress }); // TODO: I think the exclusive interaction prevents interactions starting while it's active so we might not need this.
|
|
5155
5171
|
// TODO: I think the exclusive interaction prevents interactions starting while it's active so we might not need this.
|
|
5156
5172
|
/** @type {?} */
|
|
@@ -5441,7 +5457,7 @@ var PlaceRouter = /** @class */ (function (_super) {
|
|
|
5441
5457
|
* @return {?}
|
|
5442
5458
|
*/
|
|
5443
5459
|
function (url) {
|
|
5444
|
-
return new UrlSnapshot(this.urlSerializer, url
|
|
5460
|
+
return new UrlSnapshot(this.urlSerializer, url);
|
|
5445
5461
|
};
|
|
5446
5462
|
/**
|
|
5447
5463
|
* @param {?} url
|
|
@@ -5523,47 +5539,77 @@ var PlaceRouter = /** @class */ (function (_super) {
|
|
|
5523
5539
|
function (url) {
|
|
5524
5540
|
return this.getActiveInteractionIdsFromUrl(url).length > 0;
|
|
5525
5541
|
};
|
|
5526
|
-
// @Trace()
|
|
5527
|
-
// @Trace()
|
|
5528
5542
|
/**
|
|
5529
5543
|
* @param {?} urlSnapshot
|
|
5544
|
+
* @param {?=} navigationExtras
|
|
5530
5545
|
* @return {?}
|
|
5531
5546
|
*/
|
|
5532
|
-
PlaceRouter.prototype.navigateByUrl =
|
|
5533
|
-
// @Trace()
|
|
5534
|
-
/**
|
|
5547
|
+
PlaceRouter.prototype.navigateByUrl = /**
|
|
5535
5548
|
* @param {?} urlSnapshot
|
|
5549
|
+
* @param {?=} navigationExtras
|
|
5536
5550
|
* @return {?}
|
|
5537
5551
|
*/
|
|
5538
|
-
function (urlSnapshot) {
|
|
5539
|
-
this.router.navigateByUrl(urlSnapshot.urlTree,
|
|
5552
|
+
function (urlSnapshot, navigationExtras) {
|
|
5553
|
+
return this.router.navigateByUrl(urlSnapshot.urlTree, navigationExtras);
|
|
5540
5554
|
};
|
|
5541
|
-
//
|
|
5542
|
-
//
|
|
5555
|
+
// TODO: Should this be moved to the navigation states?
|
|
5556
|
+
// TODO: Should this be moved to the navigation states?
|
|
5543
5557
|
/**
|
|
5558
|
+
* @param {?} currentIds
|
|
5559
|
+
* @param {?} previous
|
|
5544
5560
|
* @return {?}
|
|
5545
5561
|
*/
|
|
5546
5562
|
PlaceRouter.prototype.syncInteractionIdsWithRouter =
|
|
5547
|
-
//
|
|
5563
|
+
// TODO: Should this be moved to the navigation states?
|
|
5548
5564
|
/**
|
|
5565
|
+
* @param {?} currentIds
|
|
5566
|
+
* @param {?} previous
|
|
5549
5567
|
* @return {?}
|
|
5550
5568
|
*/
|
|
5551
|
-
function () {
|
|
5569
|
+
function (currentIds, previous) {
|
|
5570
|
+
var _this = this;
|
|
5552
5571
|
assert.isFalsey(this.navigationInProgress.value); // Updating interaction routes during an existing navigation breaks all the things.
|
|
5553
|
-
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
5572
|
+
console.log({
|
|
5573
|
+
startingActivity: currentIds.length > previous.length,
|
|
5574
|
+
wasBackButton: this.navigationState.isPopState
|
|
5575
|
+
});
|
|
5576
|
+
if (___default.isEqual(currentIds, previous)) {
|
|
5557
5577
|
console.log('activity ids were the same, skipping');
|
|
5558
5578
|
}
|
|
5559
5579
|
else {
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
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
|
+
});
|
|
5563
5592
|
}
|
|
5564
5593
|
else {
|
|
5565
|
-
|
|
5566
|
-
this.
|
|
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
|
+
}
|
|
5567
5613
|
}
|
|
5568
5614
|
}
|
|
5569
5615
|
};
|
|
@@ -5581,6 +5627,12 @@ var PlaceRouter = /** @class */ (function (_super) {
|
|
|
5581
5627
|
{ type: InteractionService }
|
|
5582
5628
|
]; };
|
|
5583
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);
|
|
5584
5636
|
return PlaceRouter;
|
|
5585
5637
|
}(GarbageCollector));
|
|
5586
5638
|
if (false) {
|