@coolon/angular-ui-powerups 0.0.69 → 0.0.71

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.
@@ -1,5 +1,5 @@
1
1
  import { DOCUMENT, Location, CommonModule } from '@angular/common';
2
- import { EventEmitter, Input, Output, HostListener, Component, Directive, ElementRef, Inject, NgZone, InjectionToken, Injector, ComponentFactoryResolver, ViewContainerRef, ViewChild, ViewChildren, Injectable, Optional, ɵɵdefineInjectable, ɵɵinject, NgModule, HostBinding, INJECTOR } from '@angular/core';
2
+ import { EventEmitter, Input, Output, HostListener, Component, Directive, ElementRef, Inject, NgZone, InjectionToken, Injector, ComponentFactoryResolver, ViewContainerRef, ViewChild, ViewChildren, Injectable, Optional, ɵɵdefineInjectable, ɵɵinject, NgModule, HostBinding, SkipSelf, INJECTOR } from '@angular/core';
3
3
  import { FormsModule } from '@angular/forms';
4
4
  import { MatDialog, MatButtonModule, MatDialogModule, MatTabsModule, MatProgressSpinnerModule, MatInputModule, MatFormFieldModule, MatSelectModule } from '@angular/material';
5
5
  import { MatTabsModule as MatTabsModule$1 } from '@angular/material/tabs';
@@ -7,7 +7,7 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
7
7
  import { __decorate, __metadata, __awaiter } from 'tslib';
8
8
  import { GarbageCollector, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel, assert, UnaryCommand, lang, Dsl, Logger, DelegatingValueModel, MutableStream, MutableListModel, DelegatingListModel, StoreInValueModel, Binding, MutableValueModel, Trace, Guard as Guard$1, OptionsHelper, ValueHolder } from '@coolon/pectin';
9
9
  import { PortalModule } from '@angular/cdk/portal';
10
- import { Router, RouterModule, NavigationStart, NavigationEnd, NavigationError, ActivatedRoute, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
10
+ import { Router, RouterModule, NavigationStart, NavigationEnd, NavigationError, ActivatedRoute, RouterOutlet, ActivatedRouteSnapshot, RouterStateSnapshot } 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';
@@ -2616,79 +2616,6 @@ if (false) {
2616
2616
  ListPlaceNavComponent.prototype.expanded;
2617
2617
  }
2618
2618
 
2619
- /**
2620
- * @fileoverview added by tsickle
2621
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2622
- */
2623
- class PlaceHistory {
2624
- /**
2625
- * @param {?} router
2626
- */
2627
- constructor(router) {
2628
- this.router = router;
2629
- this._history = new Map();
2630
- }
2631
- // @Trace()
2632
- /**
2633
- * @param {?} state
2634
- * @return {?}
2635
- */
2636
- add(state) {
2637
- /** @type {?} */
2638
- const history = this.getHistory(state.placeDefinition);
2639
- /** @type {?} */
2640
- const previousState = ___default.last(history);
2641
- if (!previousState || state.hasChangedFrom(previousState)) {
2642
- history.unshift(state); // LIFO
2643
- this.setHistory(state.placeDefinition, history.slice(0, 3)); // limit our history to 4 visits
2644
- }
2645
- }
2646
- /**
2647
- * @param {?} placeDef
2648
- * @return {?}
2649
- */
2650
- getHistory(placeDef) {
2651
- /** @type {?} */
2652
- let history = this._history.get(placeDef);
2653
- if (!history) {
2654
- history = [];
2655
- this.setHistory(placeDef, history);
2656
- }
2657
- return history;
2658
- }
2659
- /**
2660
- * @private
2661
- * @param {?} placeDef
2662
- * @param {?} history
2663
- * @return {?}
2664
- */
2665
- setHistory(placeDef, history) {
2666
- this._history.set(placeDef, history);
2667
- }
2668
- }
2669
- PlaceHistory.decorators = [
2670
- { type: Injectable, args: [{
2671
- providedIn: 'root'
2672
- },] }
2673
- ];
2674
- /** @nocollapse */
2675
- PlaceHistory.ctorParameters = () => [
2676
- { type: Router }
2677
- ];
2678
- /** @nocollapse */ PlaceHistory.ngInjectableDef = ɵɵdefineInjectable({ factory: function PlaceHistory_Factory() { return new PlaceHistory(ɵɵinject(Router)); }, token: PlaceHistory, providedIn: "root" });
2679
- if (false) {
2680
- /**
2681
- * @type {?}
2682
- * @private
2683
- */
2684
- PlaceHistory.prototype._history;
2685
- /**
2686
- * @type {?}
2687
- * @private
2688
- */
2689
- PlaceHistory.prototype.router;
2690
- }
2691
-
2692
2619
  /**
2693
2620
  * @fileoverview added by tsickle
2694
2621
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -2836,6 +2763,79 @@ if (false) {
2836
2763
  NavigationSession.createExternal = createExternal;
2837
2764
  })(NavigationSession || (NavigationSession = {}));
2838
2765
 
2766
+ /**
2767
+ * @fileoverview added by tsickle
2768
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2769
+ */
2770
+ class PlaceHistory {
2771
+ /**
2772
+ * @param {?} router
2773
+ */
2774
+ constructor(router) {
2775
+ this.router = router;
2776
+ this._history = new Map();
2777
+ }
2778
+ // @Trace()
2779
+ /**
2780
+ * @param {?} state
2781
+ * @return {?}
2782
+ */
2783
+ add(state) {
2784
+ /** @type {?} */
2785
+ const history = this.getHistory(state.placeDefinition);
2786
+ /** @type {?} */
2787
+ const previousState = ___default.last(history);
2788
+ if (!previousState || state.hasChangedFrom(previousState)) {
2789
+ history.unshift(state); // LIFO
2790
+ this.setHistory(state.placeDefinition, history.slice(0, 3)); // limit our history to 4 visits
2791
+ }
2792
+ }
2793
+ /**
2794
+ * @param {?} placeDef
2795
+ * @return {?}
2796
+ */
2797
+ getHistory(placeDef) {
2798
+ /** @type {?} */
2799
+ let history = this._history.get(placeDef);
2800
+ if (!history) {
2801
+ history = [];
2802
+ this.setHistory(placeDef, history);
2803
+ }
2804
+ return history;
2805
+ }
2806
+ /**
2807
+ * @private
2808
+ * @param {?} placeDef
2809
+ * @param {?} history
2810
+ * @return {?}
2811
+ */
2812
+ setHistory(placeDef, history) {
2813
+ this._history.set(placeDef, history);
2814
+ }
2815
+ }
2816
+ PlaceHistory.decorators = [
2817
+ { type: Injectable, args: [{
2818
+ providedIn: 'root'
2819
+ },] }
2820
+ ];
2821
+ /** @nocollapse */
2822
+ PlaceHistory.ctorParameters = () => [
2823
+ { type: Router }
2824
+ ];
2825
+ /** @nocollapse */ PlaceHistory.ngInjectableDef = ɵɵdefineInjectable({ factory: function PlaceHistory_Factory() { return new PlaceHistory(ɵɵinject(Router)); }, token: PlaceHistory, providedIn: "root" });
2826
+ if (false) {
2827
+ /**
2828
+ * @type {?}
2829
+ * @private
2830
+ */
2831
+ PlaceHistory.prototype._history;
2832
+ /**
2833
+ * @type {?}
2834
+ * @private
2835
+ */
2836
+ PlaceHistory.prototype.router;
2837
+ }
2838
+
2839
2839
  /**
2840
2840
  * @fileoverview added by tsickle
2841
2841
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -3034,12 +3034,25 @@ class PlaceRouter extends GarbageCollector {
3034
3034
  /**
3035
3035
  * placeRouter.navigate(placeDestinations.somePlace.createVisit(routeId, ...visitParams));
3036
3036
  * @param {?} visit
3037
+ * @param {?=} options
3037
3038
  * @return {?}
3038
3039
  */
3039
- // @Trace()
3040
- navigate(visit) {
3040
+ navigate(visit, options) {
3041
3041
  return __awaiter(this, void 0, void 0, function* () {
3042
- this.doNavigation(visit);
3042
+ this.doNavigation(visit, (/**
3043
+ * @param {?} router
3044
+ * @return {?}
3045
+ */
3046
+ (router) => __awaiter(this, void 0, void 0, function* () {
3047
+ /** @type {?} */
3048
+ const commands = [
3049
+ visit.placeDefinition.path,
3050
+ ...this.createRouteParameters(visit)
3051
+ ];
3052
+ yield this.router.navigate(commands, {
3053
+ relativeTo: options ? options.relativeTo : null
3054
+ });
3055
+ })));
3043
3056
  });
3044
3057
  }
3045
3058
  /**
@@ -3063,13 +3076,11 @@ class PlaceRouter extends GarbageCollector {
3063
3076
  /** @type {?} */
3064
3077
  const relativePath = !!previous.placeDefinition.hasRouteId() ? '..' : '.';
3065
3078
  /** @type {?} */
3066
- const def = next.placeDefinition;
3067
- /** @type {?} */
3068
- const params = next.hasRouteId() ?
3069
- [def.getFormattedRouteId(next), def.getFormattedRouteParameters(next)] :
3070
- [def.getFormattedRouteParameters(next)];
3071
- /** @type {?} */
3072
- const commands = [relativePath].concat(params, this.getChildPath(activatedRoute.snapshot));
3079
+ const commands = [
3080
+ relativePath,
3081
+ ...this.createRouteParameters(next),
3082
+ ...this.extractChildPath(activatedRoute.snapshot)
3083
+ ];
3073
3084
  console.log('### Redirect', commands);
3074
3085
  return router.navigate(commands, {
3075
3086
  relativeTo: activatedRoute
@@ -3080,29 +3091,14 @@ class PlaceRouter extends GarbageCollector {
3080
3091
  }
3081
3092
  /**
3082
3093
  * @param {?} visit
3083
- * @param {?=} customNavigation
3094
+ * @param {?} customNavigation
3084
3095
  * @return {?}
3085
3096
  */
3086
3097
  doNavigation(visit, customNavigation) {
3087
3098
  return __awaiter(this, void 0, void 0, function* () {
3088
3099
  this._navigationSessionModel.value = NavigationSession.createInternal(visit);
3089
3100
  try {
3090
- if (customNavigation) {
3091
- yield customNavigation(this.router);
3092
- }
3093
- else {
3094
- /** @type {?} */
3095
- const def = visit.placeDefinition;
3096
- // @see https://coolon.atlassian.net/browse/AUP-41
3097
- /** @type {?} */
3098
- const parameterCommands = visit.hasRouteId() ?
3099
- [def.getFormattedRouteId(visit), def.getFormattedRouteParameters(visit)] :
3100
- [def.getFormattedRouteParameters(visit)];
3101
- /** @type {?} */
3102
- const commands = [def.path].concat(parameterCommands);
3103
- console.log('_doNavigation', visit, commands);
3104
- yield this.router.navigate(commands);
3105
- }
3101
+ yield customNavigation(this.router);
3106
3102
  }
3107
3103
  finally {
3108
3104
  if (this.navigationSession && !this.router.getCurrentNavigation()) {
@@ -3111,6 +3107,18 @@ class PlaceRouter extends GarbageCollector {
3111
3107
  }
3112
3108
  });
3113
3109
  }
3110
+ /**
3111
+ * @private
3112
+ * @param {?} visit
3113
+ * @return {?}
3114
+ */
3115
+ createRouteParameters(visit) {
3116
+ /** @type {?} */
3117
+ const def = visit.placeDefinition;
3118
+ return visit.hasRouteId() ?
3119
+ [def.getFormattedRouteId(visit), def.getFormattedRouteParameters(visit)] :
3120
+ [def.getFormattedRouteParameters(visit)];
3121
+ }
3114
3122
  // @Trace()
3115
3123
  /**
3116
3124
  * @private
@@ -3155,7 +3163,7 @@ class PlaceRouter extends GarbageCollector {
3155
3163
  * @param {?} activatedRoute
3156
3164
  * @return {?}
3157
3165
  */
3158
- getChildPath(activatedRoute) {
3166
+ extractChildPath(activatedRoute) {
3159
3167
  return ___default.flatten(activatedRoute.children.map((/**
3160
3168
  * @param {?} child
3161
3169
  * @return {?}
@@ -3175,6 +3183,12 @@ PlaceRouter.ctorParameters = () => [
3175
3183
  { type: PlaceHistory }
3176
3184
  ];
3177
3185
  /** @nocollapse */ PlaceRouter.ngInjectableDef = ɵɵdefineInjectable({ factory: function PlaceRouter_Factory() { return new PlaceRouter(ɵɵinject(Router), ɵɵinject(Location), ɵɵinject(PlaceHistory)); }, token: PlaceRouter, providedIn: "root" });
3186
+ __decorate([
3187
+ Trace(),
3188
+ __metadata("design:type", Function),
3189
+ __metadata("design:paramtypes", [Visit, Object]),
3190
+ __metadata("design:returntype", Promise)
3191
+ ], PlaceRouter.prototype, "navigate", null);
3178
3192
  __decorate([
3179
3193
  Trace(),
3180
3194
  __metadata("design:type", Function),
@@ -3290,13 +3304,13 @@ class PlaceOutletComponent extends DisposableComponent {
3290
3304
  /**
3291
3305
  * @param {?} router
3292
3306
  * @param {?} placeRouter
3293
- * @param {?} placeHistory
3307
+ * @param {?} parentOutlet
3294
3308
  */
3295
- constructor(router, placeRouter, placeHistory) {
3309
+ constructor(router, placeRouter, parentOutlet) {
3296
3310
  super();
3297
3311
  this.router = router;
3298
3312
  this.placeRouter = placeRouter;
3299
- this.placeHistory = placeHistory;
3313
+ this.parentOutlet = parentOutlet;
3300
3314
  this.animate = true;
3301
3315
  this.placeChanged = new EventEmitter();
3302
3316
  this._activePlace = new MutableValueModel();
@@ -3353,6 +3367,16 @@ class PlaceOutletComponent extends DisposableComponent {
3353
3367
  */
3354
3368
  ngOnInit() {
3355
3369
  }
3370
+ /**
3371
+ * @param {?} visit
3372
+ * @return {?}
3373
+ */
3374
+ navigate(visit) {
3375
+ console.log({ activatedRoute: this._activatedRouteModel.value });
3376
+ this.placeRouter.navigate(visit, {
3377
+ relativeTo: this.parentOutlet ? this.parentOutlet.activatedRouteModel.value : null
3378
+ });
3379
+ }
3356
3380
  /**
3357
3381
  * @param {?} next
3358
3382
  * @param {?} previous
@@ -3369,6 +3393,12 @@ class PlaceOutletComponent extends DisposableComponent {
3369
3393
  get activePlaceModel() {
3370
3394
  return this._activePlace.readonly;
3371
3395
  }
3396
+ /**
3397
+ * @return {?}
3398
+ */
3399
+ get activatedRouteModel() {
3400
+ return this._activatedRouteModel.readonly;
3401
+ }
3372
3402
  /**
3373
3403
  * @param {?} routerOutlet
3374
3404
  * @param {?} place
@@ -3424,13 +3454,6 @@ class PlaceOutletComponent extends DisposableComponent {
3424
3454
  this._activePlace.value.onPlaceReady();
3425
3455
  }
3426
3456
  }
3427
- /**
3428
- * @param {?} placeDestination
3429
- * @return {?}
3430
- */
3431
- activate(placeDestination) {
3432
- // this.router.
3433
- }
3434
3457
  }
3435
3458
  PlaceOutletComponent.decorators = [
3436
3459
  { type: Component, args: [{
@@ -3444,13 +3467,31 @@ PlaceOutletComponent.decorators = [
3444
3467
  PlaceOutletComponent.ctorParameters = () => [
3445
3468
  { type: Router },
3446
3469
  { type: PlaceRouter },
3447
- { type: PlaceHistory }
3470
+ { type: PlaceOutletComponent, decorators: [{ type: SkipSelf }, { type: Optional }] }
3448
3471
  ];
3449
3472
  PlaceOutletComponent.propDecorators = {
3450
3473
  animate: [{ type: Input }],
3451
3474
  placeChanged: [{ type: Output }],
3452
3475
  routerOut: [{ type: ViewChild, args: ['routeOutlet', { static: true },] }]
3453
3476
  };
3477
+ __decorate([
3478
+ Trace(),
3479
+ __metadata("design:type", Function),
3480
+ __metadata("design:paramtypes", [Visit]),
3481
+ __metadata("design:returntype", void 0)
3482
+ ], PlaceOutletComponent.prototype, "navigate", null);
3483
+ __decorate([
3484
+ Trace(),
3485
+ __metadata("design:type", Function),
3486
+ __metadata("design:paramtypes", [RouterOutlet, PlaceComponent]),
3487
+ __metadata("design:returntype", void 0)
3488
+ ], PlaceOutletComponent.prototype, "onOutletActivated", null);
3489
+ __decorate([
3490
+ Trace(),
3491
+ __metadata("design:type", Function),
3492
+ __metadata("design:paramtypes", [RouterOutlet, Object]),
3493
+ __metadata("design:returntype", void 0)
3494
+ ], PlaceOutletComponent.prototype, "onOutletDeactivated", null);
3454
3495
  if (false) {
3455
3496
  /** @type {?} */
3456
3497
  PlaceOutletComponent.prototype.animate;
@@ -3493,11 +3534,8 @@ if (false) {
3493
3534
  * @private
3494
3535
  */
3495
3536
  PlaceOutletComponent.prototype.placeRouter;
3496
- /**
3497
- * @type {?}
3498
- * @private
3499
- */
3500
- PlaceOutletComponent.prototype.placeHistory;
3537
+ /** @type {?} */
3538
+ PlaceOutletComponent.prototype.parentOutlet;
3501
3539
  }
3502
3540
 
3503
3541
  /**
@@ -4232,6 +4270,8 @@ function RouteId(type, options) {
4232
4270
  * @return {?}
4233
4271
  */
4234
4272
  function VisitParameter(options) {
4273
+ /** @type {?} */
4274
+ const opts = Opts.get(options);
4235
4275
  return (/**
4236
4276
  * @param {?} prototype
4237
4277
  * @param {?} propertyKey
@@ -4239,7 +4279,7 @@ function VisitParameter(options) {
4239
4279
  */
4240
4280
  (prototype, propertyKey) => {
4241
4281
  /** @type {?} */
4242
- const param = new ParameterDefinition.ValueParameter(propertyKey.toString(), options, options.storeInUrl);
4282
+ const param = new ParameterDefinition.ValueParameter(propertyKey.toString(), options, opts.getOptional("storeInUrl", null));
4243
4283
  Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
4244
4284
  UseDelegate()(prototype, propertyKey);
4245
4285
  });
@@ -4250,6 +4290,8 @@ function VisitParameter(options) {
4250
4290
  * @return {?}
4251
4291
  */
4252
4292
  function VisitParameterList(options) {
4293
+ /** @type {?} */
4294
+ const opts = Opts.get(options);
4253
4295
  return (/**
4254
4296
  * @param {?} prototype
4255
4297
  * @param {?} propertyKey
@@ -4257,7 +4299,7 @@ function VisitParameterList(options) {
4257
4299
  */
4258
4300
  (prototype, propertyKey) => {
4259
4301
  /** @type {?} */
4260
- const param = new ParameterDefinition.ArrayParameter(propertyKey.toString(), options, options.storeInUrl);
4302
+ const param = new ParameterDefinition.ArrayParameter(propertyKey.toString(), options, opts.getOptional("storeInUrl", null));
4261
4303
  Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
4262
4304
  UseDelegate()(prototype, propertyKey);
4263
4305
  });
@@ -4609,16 +4651,16 @@ class PlaceRouteGuard {
4609
4651
  /** @type {?} */
4610
4652
  const sanitiser = new VisitSanitiser(activatedRoute, this.router, this.placeHistory, this.injector);
4611
4653
  /** @type {?} */
4612
- const updatedVisit = yield sanitiser.sanitise(initialVisit.mergeRouteParameters(parsedParams));
4654
+ const sanitisedVisit = yield sanitiser.sanitise(initialVisit.mergeRouteParameters(parsedParams));
4613
4655
  // Save the visit with any updated parameters. We need to save it so we remember any non route parameters
4614
- this.placeRouter.navigationSession.storeVisit(updatedVisit);
4615
- if (initialVisit.hasRoutingChangedFrom(updatedVisit)) {
4656
+ this.placeRouter.navigationSession.storeVisit(sanitisedVisit);
4657
+ if (initialVisit.hasRoutingChangedFrom(sanitisedVisit)) {
4616
4658
  /** @type {?} */
4617
- const parameterCommands = updatedVisit.hasRouteId() ?
4618
- [placeDefinition.getFormattedRouteId(updatedVisit), placeDefinition.getFormattedRouteParameters(updatedVisit)] :
4619
- [placeDefinition.getFormattedRouteParameters(updatedVisit)];
4659
+ const parameterCommands = sanitisedVisit.hasRouteId() ?
4660
+ [placeDefinition.getFormattedRouteId(sanitisedVisit), placeDefinition.getFormattedRouteParameters(sanitisedVisit)] :
4661
+ [placeDefinition.getFormattedRouteParameters(sanitisedVisit)];
4620
4662
  /** @type {?} */
4621
- const commands = [(activatedRoute.url[0].path)].concat(parameterCommands, this.placeRouter.getChildPath(activatedRoute));
4663
+ const commands = [(activatedRoute.url[0].path)].concat(parameterCommands, this.placeRouter.extractChildPath(activatedRoute));
4622
4664
  console.log('##### Redirect', commands);
4623
4665
  return this.router.createUrlTree(commands, {
4624
4666
  replaceUrl: true,