@coolon/angular-ui-powerups 0.0.38 → 0.0.41

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.
Files changed (30) hide show
  1. package/bundles/coolon-angular-ui-powerups.umd.js +180 -63
  2. package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -1
  3. package/bundles/coolon-angular-ui-powerups.umd.min.js +1 -1
  4. package/bundles/coolon-angular-ui-powerups.umd.min.js.map +1 -1
  5. package/coolon-angular-ui-powerups.metadata.json +1 -1
  6. package/esm2015/lib/angular-ui-powerups.module.js +3 -1
  7. package/esm2015/lib/place/components/abstract-place-navigation.component.js +4 -4
  8. package/esm2015/lib/place/components/list-place-nav/list-place-nav.component.js +2 -2
  9. package/esm2015/lib/place/components/place-outlet/place-outlet.component.js +110 -16
  10. package/esm2015/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.js +2 -2
  11. package/esm2015/lib/place/guards/leave-place.guard.js +12 -4
  12. package/esm2015/lib/place/guards/place-route.guard.js +2 -2
  13. package/esm2015/lib/place/place-component.js +3 -8
  14. package/esm2015/lib/place/place.service.js +6 -28
  15. package/esm5/lib/angular-ui-powerups.module.js +3 -1
  16. package/esm5/lib/place/components/abstract-place-navigation.component.js +4 -4
  17. package/esm5/lib/place/components/list-place-nav/list-place-nav.component.js +2 -2
  18. package/esm5/lib/place/components/place-outlet/place-outlet.component.js +141 -20
  19. package/esm5/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.js +2 -2
  20. package/esm5/lib/place/guards/leave-place.guard.js +11 -3
  21. package/esm5/lib/place/guards/place-route.guard.js +2 -2
  22. package/esm5/lib/place/place-component.js +7 -9
  23. package/esm5/lib/place/place.service.js +22 -32
  24. package/fesm2015/coolon-angular-ui-powerups.js +129 -53
  25. package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
  26. package/fesm5/coolon-angular-ui-powerups.js +178 -61
  27. package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
  28. package/lib/place/components/abstract-place-navigation.component.d.ts +1 -1
  29. package/lib/place/components/place-outlet/place-outlet.component.d.ts +16 -8
  30. package/package.json +1 -1
@@ -2,6 +2,7 @@ import { DOCUMENT, CommonModule } from '@angular/common';
2
2
  import { EventEmitter, Input, Output, HostListener, Component, Directive, ElementRef, Inject, NgZone, InjectionToken, Injector, ComponentFactoryResolver, ViewContainerRef, ViewChild, ViewChildren, Injectable, ɵɵdefineInjectable, ɵɵinject, NgModule, HostBinding, 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
+ import { MatTabsModule as MatTabsModule$1 } from '@angular/material/tabs';
5
6
  import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
6
7
  import { __decorate, __metadata, __awaiter } from 'tslib';
7
8
  import { GarbageCollector, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel, assert, UnaryCommand, lang, Dsl, Logger, EventListenerList, DelegatingValueModel, Trace, MutableListModel, StoreInValueModel, MutableValueModel, Binding, OptionsHelper, ValueHolder } from '@coolon/pectin';
@@ -11,9 +12,8 @@ import { assert as assert$1, Klass, Opts } from '@coolon/typescript-utilities';
11
12
  import { MatDialog as MatDialog$1 } from '@angular/material/dialog';
12
13
  import { MatIconModule } from '@angular/material/icon';
13
14
  import { MatListModule } from '@angular/material/list';
14
- import { MatTabsModule as MatTabsModule$1 } from '@angular/material/tabs';
15
15
  import { MatTooltipModule } from '@angular/material/tooltip';
16
- import { Router, RouterModule } from '@angular/router';
16
+ import { Router, ActivatedRoute, RouterOutlet, RouterModule, PRIMARY_OUTLET } from '@angular/router';
17
17
  import { Memoize } from '@typescript-plus/fast-memoize-decorator/dist/src';
18
18
  import { Memoize as Memoize$1 } from '@typescript-plus/fast-memoize-decorator';
19
19
  import { isNil, isEqual, isEmpty, isFunction } from 'lodash';
@@ -1922,6 +1922,7 @@ class PlaceComponent extends DisposableComponent {
1922
1922
  canDeactivate() {
1923
1923
  return true;
1924
1924
  }
1925
+ // @Trace()
1925
1926
  /**
1926
1927
  * @return {?}
1927
1928
  */
@@ -1933,12 +1934,6 @@ __decorate([
1933
1934
  __metadata("design:type", PlaceComponent.Definition),
1934
1935
  __metadata("design:paramtypes", [])
1935
1936
  ], PlaceComponent.prototype, "placeDefinition", null);
1936
- __decorate([
1937
- Trace(),
1938
- __metadata("design:type", Function),
1939
- __metadata("design:paramtypes", []),
1940
- __metadata("design:returntype", void 0)
1941
- ], PlaceComponent.prototype, "onPlaceReady", null);
1942
1937
  if (false) {
1943
1938
  /** @type {?} */
1944
1939
  PlaceComponent.prototype._incomingRouteChange;
@@ -2105,9 +2100,9 @@ class AbstractPlaceNavigationComponent extends DisposableComponent {
2105
2100
  * @param {?} placeDef
2106
2101
  * @return {?}
2107
2102
  */
2108
- getNavItem(placeDef) {
2103
+ getNav(placeDef) {
2109
2104
  /** @type {?} */
2110
- const navItem = (/** @type {?} */ (placeDef.getData('navItem')));
2105
+ const navItem = (/** @type {?} */ (placeDef.getData('nav')));
2111
2106
  return {
2112
2107
  title: (/**
2113
2108
  * @return {?}
@@ -2146,7 +2141,7 @@ __decorate([
2146
2141
  __metadata("design:type", Function),
2147
2142
  __metadata("design:paramtypes", [PlaceComponent.Definition]),
2148
2143
  __metadata("design:returntype", Object)
2149
- ], AbstractPlaceNavigationComponent.prototype, "getNavItem", null);
2144
+ ], AbstractPlaceNavigationComponent.prototype, "getNav", null);
2150
2145
  if (false) {
2151
2146
  /** @type {?} */
2152
2147
  AbstractPlaceNavigationComponent.prototype.places;
@@ -2187,7 +2182,7 @@ class ListPlaceNavComponent extends AbstractPlaceNavigationComponent {
2187
2182
  ListPlaceNavComponent.decorators = [
2188
2183
  { type: Component, args: [{
2189
2184
  selector: 'angular-ui-powerups-list-place-nav',
2190
- template: "<mat-nav-list class=\"app-menu\">\n <a mat-list-item *ngFor=\"let place of placeDefinitions.value\"\n [routerLink]='place.path'\n routerLinkActive #rla=\"routerLinkActive\"\n [matTooltip]=\"getNavItem(place).tooltip()\">\n <mat-icon *ngIf=\"getNavItem(place).icon()\">{{getNavItem(place).icon()}}</mat-icon>\n <span class=\"expanded-only\">{{getNavItem(place).title()}}</span>\n </a>\n</mat-nav-list>\n",
2185
+ template: "<mat-nav-list class=\"app-menu\">\n <a mat-list-item *ngFor=\"let place of placeDefinitions.value\"\n [routerLink]='place.path'\n routerLinkActive #rla=\"routerLinkActive\"\n [matTooltip]=\"getNav(place).tooltip()\">\n <mat-icon *ngIf=\"getNav(place).icon()\">{{getNav(place).icon()}}</mat-icon>\n <span class=\"expanded-only\">{{getNav(place).title()}}</span>\n </a>\n</mat-nav-list>\n",
2191
2186
  styles: [":host{display:flex;flex-direction:column;--expanded-width:235px;--nav-item-width:var(--nav-bar-height);width:var(--nav-item-width);transition:width 125ms linear}:host.expanded{width:var(--expanded-width);max-width:var(--expanded-width)}.expanded-only{max-width:0;overflow:hidden}.collapsed-only{max-width:100%;overflow:hidden}.header{display:flex;flex-direction:row;justify-content:flex-end;align-items:center;height:var(--nav-bar-height);border-bottom:var(--pinstripe-border);cursor:pointer}.header .menu{flex:1}.header button{color:inherit;width:var(--nav-item-width);height:var(--nav-bar-height)}mat-nav-list{flex:1;display:flex;flex-direction:column}.mat-list-item{width:var(--nav-item-width);height:var(--nav-bar-height);color:inherit}mat-icon{color:inherit}mat-icon.flip-horizontal{transform:scaleX(-1)}:host-context(.expanded) .expanded-only{max-width:100%}:host-context(.expanded) .collapsed-only{max-width:0}:host-context(.expanded) .mat-list-item mat-icon{margin-right:12px}:host-context(.expanded) .mat-list-item span{text-wrap:none;white-space:nowrap}a[ng-reflect-router-link=manage-instruments] mat-icon{transform:rotate(90deg)}.app-menu{padding-top:0}"]
2192
2187
  }] }
2193
2188
  ];
@@ -2222,6 +2217,7 @@ class PlaceService extends GarbageCollector {
2222
2217
  get activePlaces() {
2223
2218
  return this._activePlaces.readonly;
2224
2219
  }
2220
+ // @Trace()
2225
2221
  /**
2226
2222
  * @param {?} place
2227
2223
  * @return {?}
@@ -2229,6 +2225,7 @@ class PlaceService extends GarbageCollector {
2229
2225
  onActivate(place) {
2230
2226
  this._activePlaces.push(place);
2231
2227
  }
2228
+ // @Trace()
2232
2229
  /**
2233
2230
  * @param {?} place
2234
2231
  * @return {?}
@@ -2236,6 +2233,7 @@ class PlaceService extends GarbageCollector {
2236
2233
  onDeactivate(place) {
2237
2234
  this._activePlaces.remove(place);
2238
2235
  }
2236
+ // @Trace()
2239
2237
  /**
2240
2238
  * @param {?} params
2241
2239
  * @return {?}
@@ -2254,6 +2252,7 @@ class PlaceService extends GarbageCollector {
2254
2252
  });
2255
2253
  }
2256
2254
  }
2255
+ // @Trace()
2257
2256
  /**
2258
2257
  * @param {?} snapshot
2259
2258
  * @return {?}
@@ -2275,30 +2274,6 @@ PlaceService.ctorParameters = () => [
2275
2274
  { type: Injector }
2276
2275
  ];
2277
2276
  /** @nocollapse */ PlaceService.ngInjectableDef = ɵɵdefineInjectable({ factory: function PlaceService_Factory() { return new PlaceService(ɵɵinject(Router), ɵɵinject(INJECTOR)); }, token: PlaceService, providedIn: "root" });
2278
- __decorate([
2279
- Trace(),
2280
- __metadata("design:type", Function),
2281
- __metadata("design:paramtypes", [PlaceComponent]),
2282
- __metadata("design:returntype", void 0)
2283
- ], PlaceService.prototype, "onActivate", null);
2284
- __decorate([
2285
- Trace(),
2286
- __metadata("design:type", Function),
2287
- __metadata("design:paramtypes", [PlaceComponent]),
2288
- __metadata("design:returntype", void 0)
2289
- ], PlaceService.prototype, "onDeactivate", null);
2290
- __decorate([
2291
- Trace(),
2292
- __metadata("design:type", Function),
2293
- __metadata("design:paramtypes", [Object]),
2294
- __metadata("design:returntype", void 0)
2295
- ], PlaceService.prototype, "notifyRouteParametersChanged", null);
2296
- __decorate([
2297
- Trace(),
2298
- __metadata("design:type", Function),
2299
- __metadata("design:paramtypes", [ParameterSnapshot]),
2300
- __metadata("design:returntype", Promise)
2301
- ], PlaceService.prototype, "sanitise", null);
2302
2277
  if (false) {
2303
2278
  /**
2304
2279
  * @type {?}
@@ -2374,35 +2349,97 @@ const LEFT_RIGHT_PLACE_ANIMATION = leftRightPlaceAnimation("0.3s");
2374
2349
  * @fileoverview added by tsickle
2375
2350
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2376
2351
  */
2377
- class PlaceOutletComponent {
2352
+ class PlaceOutletComponent extends DisposableComponent {
2378
2353
  /**
2379
2354
  * @param {?} placeService
2355
+ * @param {?} activatedRoute
2380
2356
  */
2381
- constructor(placeService) {
2357
+ constructor(placeService, activatedRoute) {
2358
+ super();
2382
2359
  this.placeService = placeService;
2360
+ this.activatedRoute = activatedRoute;
2383
2361
  this.animate = true;
2362
+ this.outletUrlSegment = new MutableListModel();
2363
+ const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);
2364
+ this.myPath = observe.listsFrom(activatedRoute.url).last().map((/**
2365
+ * @param {?} s
2366
+ * @return {?}
2367
+ */
2368
+ s => s.toString())).reduce((/**
2369
+ * @param {?} bits
2370
+ * @return {?}
2371
+ */
2372
+ bits => bits.join(',')));
2373
+ console.log(`new outlet@(${this.myPath.value})`);
2374
+ this.outletChildPath = chain(this.outletUrlSegment).map((/**
2375
+ * @param {?} s
2376
+ * @return {?}
2377
+ */
2378
+ s => s.toString())).reduce((/**
2379
+ * @param {?} bits
2380
+ * @return {?}
2381
+ */
2382
+ bits => bits.join(",")));
2383
+ this.state = chain(this.myPath).map((/**
2384
+ * @param {?} path
2385
+ * @return {?}
2386
+ */
2387
+ path => {
2388
+ return `outlet@(${path}), child path->${this.outletChildPath.value}`;
2389
+ }), { dependsOn: this.outletChildPath });
2390
+ when.valueOf(this.state).changes((/**
2391
+ * @param {?} debug
2392
+ * @return {?}
2393
+ */
2394
+ debug => {
2395
+ console.log(`Outlet Changed -> ${debug}`);
2396
+ }));
2384
2397
  }
2385
2398
  /**
2386
2399
  * @return {?}
2387
2400
  */
2388
2401
  ngOnInit() {
2389
2402
  }
2403
+ /**
2404
+ * @return {?}
2405
+ */
2406
+ ngAfterViewInit() {
2407
+ // this.routerOutLetQuery.changes.subscribe(() => {
2408
+ // this.updateRouterOutlet(this.routerOutLetQuery.first);
2409
+ // });
2410
+ }
2411
+ /**
2412
+ * @return {?}
2413
+ */
2414
+ ngAfterViewChecked() {
2415
+ // console.log(`@AfterViewChecked: ${this.state.value}`);
2416
+ this.updateRouterOutlet(this.routerOutLetQuery.first);
2417
+ }
2418
+ // @Trace()
2419
+ // ngOnDestroy(): void {
2420
+ // console.log('outletSegments', this.outletUrlSegment.value);
2421
+ // console.log('mySegments', this.myPath.value);
2422
+ // super.ngOnDestroy();
2423
+ // }
2424
+ // @Trace()
2390
2425
  /**
2391
2426
  * @param {?} $event
2392
2427
  * @return {?}
2393
2428
  */
2394
- onActivate($event) {
2429
+ onOutletActivated($event) {
2430
+ // console.log(this.routerOutLet.activatedRoute.snapshot.url);
2395
2431
  this.currentPlace = $event;
2396
2432
  this.placeService.onActivate($event);
2397
2433
  if (!this.animate) {
2398
- this.notifyPlaceReady();
2434
+ // we're not animating so trigger any post animation callbacks now.
2435
+ this.animationDone();
2399
2436
  }
2400
2437
  }
2401
2438
  /**
2402
2439
  * @param {?} $event
2403
2440
  * @return {?}
2404
2441
  */
2405
- onDeactivate($event) {
2442
+ onOutletDeactivated($event) {
2406
2443
  this.currentPlace = null;
2407
2444
  this.placeService.onDeactivate($event);
2408
2445
  }
@@ -2417,49 +2454,79 @@ class PlaceOutletComponent {
2417
2454
  * @return {?}
2418
2455
  */
2419
2456
  animationDone() {
2420
- this.notifyPlaceReady();
2457
+ if (this.currentPlace) {
2458
+ this.currentPlace.onPlaceReady();
2459
+ }
2421
2460
  }
2461
+ // @Trace()
2422
2462
  /**
2423
2463
  * @private
2464
+ * @param {?} first
2424
2465
  * @return {?}
2425
2466
  */
2426
- notifyPlaceReady() {
2427
- if (this.currentPlace) {
2428
- this.currentPlace.onPlaceReady();
2467
+ updateRouterOutlet(first) {
2468
+ if (first.isActivated) {
2469
+ this.outletUrlSegment.value = first.activatedRoute.snapshot.url;
2429
2470
  }
2430
2471
  }
2431
2472
  }
2432
2473
  PlaceOutletComponent.decorators = [
2433
2474
  { type: Component, args: [{
2434
2475
  selector: 'angular-ui-powerups-place-outlet',
2435
- template: "<div class=\"router-outlet-container\"\n [@routeAnimations]=\"getPlaceOrder(routerOutlet)\"\n (@routeAnimations.done)=\"animationDone()\"\n>\n <router-outlet #routerOutlet=\"outlet\"\n (activate)=\"onActivate($event)\"\n (deactivate)=\"onDeactivate($event)\">\n </router-outlet>\n</div>\n\n",
2476
+ template: "<div class=\"router-outlet-container\"\n [@routeAnimations]=\"getPlaceOrder(routerOutlet)\"\n (@routeAnimations.done)=\"animationDone()\"\n>\n <router-outlet #routerOutlet=\"outlet\"\n (activate)=\"onOutletActivated($event)\"\n (deactivate)=\"onOutletDeactivated($event)\">\n </router-outlet>\n</div>\n\n",
2436
2477
  animations: [LEFT_RIGHT_PLACE_ANIMATION],
2437
2478
  styles: [":host{display:flex;flex-direction:column;min-height:0}.router-outlet-container{flex:1;display:block;position:relative;min-height:0}router-outlet{display:none}"]
2438
2479
  }] }
2439
2480
  ];
2440
2481
  /** @nocollapse */
2441
2482
  PlaceOutletComponent.ctorParameters = () => [
2442
- { type: PlaceService }
2483
+ { type: PlaceService },
2484
+ { type: ActivatedRoute }
2443
2485
  ];
2444
2486
  PlaceOutletComponent.propDecorators = {
2445
2487
  animate: [{ type: Input }],
2446
- routerOutLet: [{ type: ViewChild, args: ['routerOutlet', { static: false },] }]
2488
+ routerOutLetQuery: [{ type: ViewChildren, args: [RouterOutlet,] }]
2447
2489
  };
2448
2490
  if (false) {
2449
2491
  /** @type {?} */
2450
2492
  PlaceOutletComponent.prototype.animate;
2451
2493
  /** @type {?} */
2452
- PlaceOutletComponent.prototype.routerOutLet;
2494
+ PlaceOutletComponent.prototype.routerOutLetQuery;
2453
2495
  /**
2454
2496
  * @type {?}
2455
2497
  * @private
2456
2498
  */
2457
2499
  PlaceOutletComponent.prototype.currentPlace;
2500
+ /**
2501
+ * @type {?}
2502
+ * @private
2503
+ */
2504
+ PlaceOutletComponent.prototype.myPath;
2505
+ /**
2506
+ * @type {?}
2507
+ * @private
2508
+ */
2509
+ PlaceOutletComponent.prototype.outletUrlSegment;
2510
+ /**
2511
+ * @type {?}
2512
+ * @private
2513
+ */
2514
+ PlaceOutletComponent.prototype.outletChildPath;
2515
+ /**
2516
+ * @type {?}
2517
+ * @private
2518
+ */
2519
+ PlaceOutletComponent.prototype.state;
2458
2520
  /**
2459
2521
  * @type {?}
2460
2522
  * @private
2461
2523
  */
2462
2524
  PlaceOutletComponent.prototype.placeService;
2525
+ /**
2526
+ * @type {?}
2527
+ * @private
2528
+ */
2529
+ PlaceOutletComponent.prototype.activatedRoute;
2463
2530
  }
2464
2531
 
2465
2532
  /**
@@ -2474,7 +2541,7 @@ class TabbedPlaceNavigationComponent extends AbstractPlaceNavigationComponent {
2474
2541
  TabbedPlaceNavigationComponent.decorators = [
2475
2542
  { type: Component, args: [{
2476
2543
  selector: 'angular-ui-powerups-tabbed-place-navigation',
2477
- template: "<nav mat-tab-nav-bar>\n <a mat-tab-link *ngFor=\"let place of placeDefinitions.value\"\n [routerLink]='place.path'\n routerLinkActive #rla=\"routerLinkActive\"\n [active]=\"rla.isActive\"\n [matTooltip]=\"getNavItem(place).tooltip()\">\n <mat-icon *ngIf=\"getNavItem(place).icon()\">{{getNavItem(place).icon()}}</mat-icon>\n <span>{{getNavItem(place).title()}}</span>\n </a>\n</nav>\n",
2544
+ template: "<nav mat-tab-nav-bar>\n <a mat-tab-link *ngFor=\"let place of placeDefinitions.value\"\n [routerLink]='place.path'\n routerLinkActive #rla=\"routerLinkActive\"\n [active]=\"rla.isActive\"\n [matTooltip]=\"getNav(place).tooltip()\">\n <mat-icon *ngIf=\"getNav(place).icon()\">{{getNav(place).icon()}}</mat-icon>\n <span>{{getNav(place).title()}}</span>\n </a>\n</nav>\n",
2478
2545
  styles: [""]
2479
2546
  }] }
2480
2547
  ];
@@ -2543,6 +2610,7 @@ AngularUiPowerupsModule.decorators = [
2543
2610
  MatInputModule,
2544
2611
  MatFormFieldModule,
2545
2612
  MatSelectModule,
2613
+ MatTabsModule$1,
2546
2614
  PlaceModule,
2547
2615
  InteractionModule
2548
2616
  ],
@@ -3018,8 +3086,16 @@ class LeavePlaceGuard {
3018
3086
  canDeactivate(component, currentRoute, currentState, nextState) {
3019
3087
  // HACK: this will break with child routes...
3020
3088
  /** @type {?} */
3021
- let path = `/${component.placeDefinition.path}`;
3022
- console.log({ path: path, next: nextState.url });
3089
+ const path = `/${component.placeDefinition.path}`;
3090
+ console.log({
3091
+ placePath: path,
3092
+ currentRoute: currentRoute.toString(),
3093
+ currentStateUrl: currentState.url,
3094
+ nextStateUrl: nextState.url,
3095
+ currentStateUrlTree: this.router.parseUrl(currentState.url).root.children[PRIMARY_OUTLET].segments,
3096
+ nextStateUrlTree: this.router.parseUrl(nextState.url).root.children[PRIMARY_OUTLET].segments
3097
+ });
3098
+ // nextState is the full path...
3023
3099
  if (!nextState.url.startsWith(path)) {
3024
3100
  return component.canDeactivate();
3025
3101
  }
@@ -3076,7 +3152,7 @@ class PlaceRouteGuard {
3076
3152
  // Id snapshot are repesented by 2 url segments
3077
3153
  // ID => [{'/basePath', params}, {'id', params}]
3078
3154
  // NO ID => [{'/basePath', params}]
3079
- console.log({ urlSegments: route.url });
3155
+ // console.log({urlSegments: route.url});
3080
3156
  // const snapshot = ParameterSnapshot.create(PlaceComponent.getDefinition(route.component as Constructable<PlaceComponent>), route.paramMap);
3081
3157
  // return this.placeService.sanitise(snapshot).then(sanitised => {
3082
3158
  // if (sanitised.hasChanged(snapshot)) {