@coolon/angular-ui-powerups 16.1.0-alpha.308 → 16.1.0-alpha.309

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.
@@ -5,6 +5,7 @@ import { DisposableComponent } from '../../components/disposable-component';
5
5
  import { PlaceComponent } from '../place-component';
6
6
  import type { PlaceDefinition } from '../place-definition';
7
7
  import { PlaceRouter } from '../place-router';
8
+ import { PlaceScope } from '../place-scope';
8
9
  import { PlaceOutletComponent } from './place-outlet/place-outlet.component';
9
10
  import * as i0 from "@angular/core";
10
11
  interface MenuItem {
@@ -33,6 +34,7 @@ export declare class AbstractPlaceNavigationComponent extends DisposableComponen
33
34
  private activePlaceDefinition;
34
35
  private placeFaces;
35
36
  readonly trackByPlaceDef: TrackByFunction<MenuItem>;
37
+ protected readonly placeScope: PlaceScope;
36
38
  private authorisedPlaces$;
37
39
  constructor(placeRouter: PlaceRouter);
38
40
  protected handlePlaceOutLetChanged(outlet: PlaceOutletComponent): void;
@@ -0,0 +1,9 @@
1
+ import * as i0 from "@angular/core";
2
+ /**
3
+ * Shown by the place outlet in place of a page that has left the {@link PlaceScope} while open.
4
+ * Replace it with AUP_OUT_OF_SCOPE_PLACE_NOTICE_COMPONENT.
5
+ */
6
+ export declare class OutOfScopeNoticeComponent {
7
+ static ɵfac: i0.ɵɵFactoryDeclaration<OutOfScopeNoticeComponent, never>;
8
+ static ɵcmp: i0.ɵɵComponentDeclaration<OutOfScopeNoticeComponent, "aup-out-of-scope-notice", never, {}, {}, never, never, false, never>;
9
+ }
@@ -7,12 +7,16 @@ import type { PlaceComponent } from '../../place-component';
7
7
  import { type PlaceConfig } from '../../place-config';
8
8
  import type { PlaceDefinition } from '../../place-definition';
9
9
  import { PlaceRouter } from '../../place-router';
10
+ import { PlaceScope } from '../../place-scope';
10
11
  import * as i0 from "@angular/core";
11
12
  export declare const AUP_UNAUTHORISED_PLACE_NOTICE_COMPONENT: InjectionToken<Constructable<any>>;
13
+ /** Replaces {@link OutOfScopeNoticeComponent}; see {@link PlaceScope.Options.whenOutOfScope}. */
14
+ export declare const AUP_OUT_OF_SCOPE_PLACE_NOTICE_COMPONENT: InjectionToken<Constructable<any>>;
12
15
  export declare class PlaceOutletComponent extends DisposableComponent {
13
16
  private readonly router;
14
17
  private readonly placeRouter;
15
18
  readonly placeConfig: PlaceConfig;
19
+ private readonly placeScope;
16
20
  accessor animate$: ValueModel<boolean>;
17
21
  accessor animate: boolean;
18
22
  accessor customPlaceAnimationOrder$: ListModel<Constructable<PlaceComponent>>;
@@ -36,7 +40,13 @@ export declare class PlaceOutletComponent extends DisposableComponent {
36
40
  readonly animationEnabled: BooleanValueModelChain;
37
41
  readonly authorised: ValueModelChain<boolean>;
38
42
  readonly notAuthorisedNoticePortal: ComponentPortal<any>;
39
- constructor(router: Router, placeRouter: PlaceRouter, placeConfig: PlaceConfig, unauthorisedPlaceNotice: Constructable<any>, parentOutlet: PlaceOutletComponent);
43
+ /** Whether the active place is in the {@link PlaceScope}; true until there is one. */
44
+ readonly inScope: ValueModelChain<boolean>;
45
+ readonly outOfScopeNoticePortal: ComponentPortal<any>;
46
+ constructor(router: Router, placeRouter: PlaceRouter, placeConfig: PlaceConfig, unauthorisedPlaceNotice: Constructable<any>, outOfScopePlaceNotice: Constructable<any>, placeScope: PlaceScope, parentOutlet: PlaceOutletComponent);
47
+ /** In `notice` mode; an unauthorised place shows the unauthorised notice instead. */
48
+ get showOutOfScopeNotice(): boolean;
49
+ private redirectOutOfScopePlace;
40
50
  getAnimationOrder(): number;
41
51
  get animationDuration(): string;
42
52
  get isAuthorised(): boolean;
@@ -52,6 +62,6 @@ export declare class PlaceOutletComponent extends DisposableComponent {
52
62
  private notifyComponentVisitSegmentChanged;
53
63
  animationStarted(): void;
54
64
  animationDone(): void;
55
- static ɵfac: i0.ɵɵFactoryDeclaration<PlaceOutletComponent, [null, null, { optional: true; }, { optional: true; }, { optional: true; skipSelf: true; }]>;
65
+ static ɵfac: i0.ɵɵFactoryDeclaration<PlaceOutletComponent, [null, null, { optional: true; }, { optional: true; }, { optional: true; }, null, { optional: true; skipSelf: true; }]>;
56
66
  static ɵcmp: i0.ɵɵComponentDeclaration<PlaceOutletComponent, "aup-place-outlet", never, { "animate$": { "alias": "animate$"; "required": false; }; "animate": { "alias": "animate"; "required": false; }; "customPlaceAnimationOrder$": { "alias": "placeAnimationOrderModel"; "required": false; }; "customPlaceAnimationOrder": { "alias": "placeAnimationOrder"; "required": false; }; }, { "placeChanged": "placeChanged"; }, never, never, false, never>;
57
67
  }
@@ -13,7 +13,8 @@ import * as i0 from "@angular/core";
13
13
  * - at least two of its children are authorised: one child isn't a choice, so a parent with one
14
14
  * authorised child is a single entry that navigates to it.
15
15
  * Anything else is a leaf that navigates to its place. A `redirectToFirstChild` parent with no
16
- * authorised child is dropped, as it has nowhere to land. Only two levels are shown; deeper places
16
+ * authorised child is dropped, as it has nowhere to land. Places outside the {@link PlaceScope} are
17
+ * left out at both levels, so a parent with no child in scope goes too. Only two levels are shown; deeper places
17
18
  * stay as tabs in their pages.
18
19
  *
19
20
  * The rail collapses to an icon strip from the Menu row, and expands over the content when the
@@ -10,6 +10,7 @@ export * from "./place-definition";
10
10
  export * from "./place-history";
11
11
  export * from "./place-metadata";
12
12
  export * from "./place-router";
13
+ export * from "./place-scope";
13
14
  export * from "./place.decorator";
14
15
  export * from "./place.module";
15
16
  export * from "./url-service";
@@ -19,6 +20,7 @@ export * from "./visit";
19
20
  export * from "./components/abstract-place-navigation.component";
20
21
  export * from "./components/list-place-nav/list-place-nav.component";
21
22
  export * from "./components/not-authorised-notice/not-authorised-notice.component";
23
+ export * from "./components/out-of-scope-notice/out-of-scope-notice.component";
22
24
  export * from "./components/place-outlet/place-outlet.component";
23
25
  export * from "./components/place-outlet/route-animations";
24
26
  export * from "./components/side-place-navigation/side-place-navigation.component";
@@ -5,6 +5,7 @@ import type { PlaceAuthService } from "../place-auth-service";
5
5
  import { PlaceComponent } from '../place-component';
6
6
  import { PlaceHistory } from '../place-history';
7
7
  import { PlaceRouter } from '../place-router';
8
+ import { PlaceScope } from '../place-scope';
8
9
  import { UrlService } from '../url-service';
9
10
  import { UrlSnapshot } from '../url-snapshot';
10
11
  import * as i0 from "@angular/core";
@@ -15,7 +16,8 @@ export declare class PlaceGuard {
15
16
  private readonly placeHistory;
16
17
  private readonly interactionService;
17
18
  private readonly injector;
18
- constructor(router: Router, urlService: UrlService, placeRouter: PlaceRouter, placeHistory: PlaceHistory, interactionService: InteractionService, injector: Injector);
19
+ private readonly placeScope;
20
+ constructor(router: Router, urlService: UrlService, placeRouter: PlaceRouter, placeHistory: PlaceHistory, interactionService: InteractionService, injector: Injector, placeScope: PlaceScope);
19
21
  get authService(): PlaceAuthService;
20
22
  canActivate(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean | UrlTree>;
21
23
  /**
@@ -34,6 +36,7 @@ export declare class PlaceGuard {
34
36
  * 1. the place's own pick, when it declares {@link PlaceDefinition.redirectChild};
35
37
  * 2. the last active child, when `rememberLastChild` is enabled (the default);
36
38
  * 3. the first authorised child in declaration order (the legacy behaviour).
39
+ * A child outside the {@link PlaceScope} is never valid, the picked and the remembered ones included.
37
40
  *
38
41
  * Authorisation is read AFTER awaiting each candidate child's authorisation-readiness (its
39
42
  * `enablePlace` postpone conditions). Without this, a child whose enablement is still settling —
@@ -43,6 +46,7 @@ export declare class PlaceGuard {
43
46
  */
44
47
  private selectRedirectChild;
45
48
  private findBestAuthenticatedAlternative;
49
+ private scopeHome;
46
50
  /**
47
51
  * A visit to the alternative place, carrying its ancestors' RESOLVED route parameters.
48
52
  *
@@ -22,6 +22,7 @@ export declare class PlaceComponent extends LoadableComponent {
22
22
  readonly placeId: string;
23
23
  canDeactivate?(interactionContext: InteractionContext): boolean | Promise<boolean>;
24
24
  protected readonly placeRouter: PlaceRouter;
25
+ private readonly placeScope;
25
26
  private readonly activatedRoute;
26
27
  constructor();
27
28
  initialiseVisit(visit: VisitSegment, notifyVisitChanged: (current: VisitSegment, previous: VisitSegment, metadata?: Transaction.MetaData) => void): void;
@@ -0,0 +1,86 @@
1
+ import { Constructable, ValueModel } from '@coolon/pectin';
2
+ import type { PlaceComponent } from './place-component';
3
+ import type { PlaceDefinition } from './place-definition';
4
+ import { Visit } from './visit';
5
+ import * as i0 from "@angular/core";
6
+ /**
7
+ * Which places the current shell can show. A scope is about layout, not access: an out-of-scope
8
+ * place is never reported as unauthorised, so the app's authorisation-failure hook (which may sign
9
+ * the user out) never sees it. See docs/PlaceScopeDesign.md.
10
+ *
11
+ * The default scope includes every place. An app sets a narrower one when it switches shells:
12
+ *
13
+ * @example
14
+ * placeScope.set({
15
+ * includes: [DevicesComponent, JoiningComponent, LoginComponent, BootstrapComponent],
16
+ * home: () => DevicesComponent,
17
+ * whenOutOfScope: 'redirect'
18
+ * });
19
+ * // and back again
20
+ * placeScope.reset();
21
+ *
22
+ * The app names places; the rest follows from the tree:
23
+ * - naming a place includes everything below it, unless it is named with {@link PlaceScope.only};
24
+ * - a place is in scope when it is named or any place below it is, so the ancestors of an
25
+ * in-scope place are reachable (their guards run first);
26
+ * - a `redirectToFirstChild` parent is in scope only when one of its children is, even when it is
27
+ * named with `only`: it has no page of its own, so it needs somewhere to land.
28
+ *
29
+ * Places are named by their component class, so a typo or a removed place fails to compile. When the
30
+ * lazy place graph lands (LazyPlaceGraphDesign.md §5.1), a `PlaceRef` names a place without
31
+ * importing its component, and {@link PlaceScope.Target} widens to accept one.
32
+ */
33
+ export declare class PlaceScope {
34
+ private options;
35
+ private included;
36
+ private readonly revision$;
37
+ /** Changes whenever the app sets a scope: anything derived from {@link includes} depends on it. */
38
+ readonly dependsOn$: ValueModel<number>;
39
+ set(options: PlaceScope.Options): void;
40
+ /** Back to the default scope, which includes every place. */
41
+ reset(): void;
42
+ includes(definition: PlaceDefinition): boolean;
43
+ /** Whether every place a visit passes through is in scope. */
44
+ includesVisit(visit: Visit): boolean;
45
+ /** Where an out-of-scope link lands instead. Undefined only for the default scope. */
46
+ home(): Visit | undefined;
47
+ /** See {@link PlaceScope.Options.whenOutOfScope}. */
48
+ get whenOutOfScope(): PlaceScope.OutOfScopeBehaviour;
49
+ private change;
50
+ private names;
51
+ static ɵfac: i0.ɵɵFactoryDeclaration<PlaceScope, never>;
52
+ static ɵprov: i0.ɵɵInjectableDeclaration<PlaceScope>;
53
+ }
54
+ export declare namespace PlaceScope {
55
+ type OutOfScopeBehaviour = 'notice' | 'redirect';
56
+ /** A place and everything below it, or, through {@link only}, the place alone. */
57
+ type Target = Constructable<PlaceComponent> | Only;
58
+ interface Only {
59
+ readonly only: Constructable<PlaceComponent>;
60
+ }
61
+ interface Options {
62
+ /** The places the scope names. */
63
+ includes: readonly Target[];
64
+ /**
65
+ * Where to send a link to an out-of-scope place. Read when needed, so it can depend on state.
66
+ * It must itself be in scope.
67
+ */
68
+ home(): Visit | Constructable<PlaceComponent>;
69
+ /**
70
+ * What the outlet does when the scope changes while an out-of-scope place is open (a tablet
71
+ * resized into the phone layout). Guards don't re-run on such a change, so without this the
72
+ * place would stay up in a shell that can't show it.
73
+ * - `notice` (default): shows the out-of-scope notice in place of the page, as the outlet does
74
+ * for a place whose authorisation is lost. Nothing navigates, so nothing unsaved is put at
75
+ * risk, and widening the scope again brings the page straight back.
76
+ * - `redirect`: navigates to {@link home}, as a link to the place would have.
77
+ */
78
+ whenOutOfScope?: OutOfScopeBehaviour;
79
+ }
80
+ /**
81
+ * Names a place without the places below it. A place's tabs are places too, so prefer naming the
82
+ * place itself; use this for a parent that has a page of its own and children the shell can't show.
83
+ */
84
+ function only(place: Constructable<PlaceComponent>): Only;
85
+ function isOnly(target: Target): target is Only;
86
+ }
@@ -5,20 +5,21 @@ import * as i3 from "./components/list-place-nav/list-place-nav.component";
5
5
  import * as i4 from "./components/side-place-navigation/side-place-navigation.component";
6
6
  import * as i5 from "./components/abstract-place-navigation.component";
7
7
  import * as i6 from "./components/not-authorised-notice/not-authorised-notice.component";
8
- import * as i7 from "@angular/common";
9
- import * as i8 from "@angular/platform-browser/animations";
10
- import * as i9 from "@angular/material/progress-spinner";
11
- import * as i10 from "@angular/router";
12
- import * as i11 from "@angular/material/tabs";
13
- import * as i12 from "@angular/material/list";
14
- import * as i13 from "@angular/material/tooltip";
15
- import * as i14 from "@angular/material/icon";
16
- import * as i15 from "../directives/directives.module";
17
- import * as i16 from "../components/components.module";
18
- import * as i17 from "@angular/cdk/portal";
19
- import * as i18 from "@angular/material/card";
8
+ import * as i7 from "./components/out-of-scope-notice/out-of-scope-notice.component";
9
+ import * as i8 from "@angular/common";
10
+ import * as i9 from "@angular/platform-browser/animations";
11
+ import * as i10 from "@angular/material/progress-spinner";
12
+ import * as i11 from "@angular/router";
13
+ import * as i12 from "@angular/material/tabs";
14
+ import * as i13 from "@angular/material/list";
15
+ import * as i14 from "@angular/material/tooltip";
16
+ import * as i15 from "@angular/material/icon";
17
+ import * as i16 from "../directives/directives.module";
18
+ import * as i17 from "../components/components.module";
19
+ import * as i18 from "@angular/cdk/portal";
20
+ import * as i19 from "@angular/material/card";
20
21
  export declare class PlaceModule {
21
22
  static ɵfac: i0.ɵɵFactoryDeclaration<PlaceModule, never>;
22
- static ɵmod: i0.ɵɵNgModuleDeclaration<PlaceModule, [typeof i1.PlaceOutletComponent, typeof i2.TabbedPlaceNavigationComponent, typeof i3.ListPlaceNavComponent, typeof i4.SidePlaceNavigationComponent, typeof i5.AbstractPlaceNavigationComponent, typeof i6.NotAuthorisedNoticeComponent], [typeof i7.CommonModule, typeof i8.BrowserAnimationsModule, typeof i9.MatProgressSpinnerModule, typeof i10.RouterModule, typeof i11.MatTabsModule, typeof i12.MatListModule, typeof i13.MatTooltipModule, typeof i14.MatIconModule, typeof i15.DirectivesModule, typeof i16.ComponentsModule, typeof i17.PortalModule, typeof i18.MatCardModule], [typeof i1.PlaceOutletComponent, typeof i2.TabbedPlaceNavigationComponent, typeof i3.ListPlaceNavComponent, typeof i4.SidePlaceNavigationComponent, typeof i5.AbstractPlaceNavigationComponent]>;
23
+ static ɵmod: i0.ɵɵNgModuleDeclaration<PlaceModule, [typeof i1.PlaceOutletComponent, typeof i2.TabbedPlaceNavigationComponent, typeof i3.ListPlaceNavComponent, typeof i4.SidePlaceNavigationComponent, typeof i5.AbstractPlaceNavigationComponent, typeof i6.NotAuthorisedNoticeComponent, typeof i7.OutOfScopeNoticeComponent], [typeof i8.CommonModule, typeof i9.BrowserAnimationsModule, typeof i10.MatProgressSpinnerModule, typeof i11.RouterModule, typeof i12.MatTabsModule, typeof i13.MatListModule, typeof i14.MatTooltipModule, typeof i15.MatIconModule, typeof i16.DirectivesModule, typeof i17.ComponentsModule, typeof i18.PortalModule, typeof i19.MatCardModule], [typeof i1.PlaceOutletComponent, typeof i2.TabbedPlaceNavigationComponent, typeof i3.ListPlaceNavComponent, typeof i4.SidePlaceNavigationComponent, typeof i5.AbstractPlaceNavigationComponent]>;
23
24
  static ɵinj: i0.ɵɵInjectorDeclaration<PlaceModule>;
24
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coolon/angular-ui-powerups",
3
- "version": "16.1.0-alpha.308",
3
+ "version": "16.1.0-alpha.309",
4
4
  "peerDependencies": {
5
5
  "@angular/animations": "^16.2.9",
6
6
  "@angular/common": "^16.2.9",