@mintplayer/ng-bootstrap 21.23.0 → 21.24.0

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 +1 @@
1
- {"version":3,"file":"mintplayer-ng-bootstrap-navigation-lock.mjs","sources":["../../../../libs/mintplayer-ng-bootstrap/navigation-lock/src/guard/navigation-lock.guard.ts","../../../../libs/mintplayer-ng-bootstrap/navigation-lock/src/directive/navigation-lock.directive.ts","../../../../libs/mintplayer-ng-bootstrap/navigation-lock/mintplayer-ng-bootstrap-navigation-lock.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport { ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree } from '@angular/router';\nimport { BsHasNavigationLock } from '../interface/has-navigation-lock';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class BsNavigationLockGuard {\n canDeactivate(\n component: BsHasNavigationLock,\n currentRoute: ActivatedRouteSnapshot,\n currentState: RouterStateSnapshot,\n nextState?: RouterStateSnapshot): Promise<boolean | UrlTree> {\n if (component.navigationLock()) {\n return component.navigationLock().requestCanExit();\n } else {\n console.warn('When using <bs-navigation-lock>, you should implement BsHasNavigationLock and add \"readonly navigationLock = viewChild.required<BsNavigationLockDirective>(\\'navigationLock\\');\" to your page');\n return new Promise<boolean>(resolve => resolve(false));\n }\n }\n \n}\n","import { DestroyRef, Directive, inject, input } from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { ActivatedRoute, Router } from '@angular/router';\nimport { take, Observable } from 'rxjs';\n\n\n/**\n * Places a navigation lock on this page.\n *\n * Don't forget to add the following to your route:\n *\n * ```ts\n * canDeactivate: [BsNavigationLockGuard]\n * ```\n *\n * and implement the `BsHasNavigationLock` on the page:\n *\n * ```ts\n * ViewChild('navigationLock') navigationLock!: BsNavigationLockDirective;\n * ```\n *\n **/\n@Directive({\n selector: '[bsNavigationLock]',\n exportAs: 'bsNavigationLock',\n host: {\n '(window:beforeunload)': 'onBeforeUnload($event)',\n '(window:unload)': 'onUnload($event)',\n },\n})\nexport class BsNavigationLockDirective {\n private router = inject(Router);\n private route = inject(ActivatedRoute);\n private destroy = inject(DestroyRef);\n\n readonly canExit = input<boolean | (() => boolean) | Observable<boolean> | undefined>(undefined);\n readonly exitMessage = input<string | undefined>(undefined);\n\n requestCanExit() {\n const canExit = this.canExit();\n return new Promise<boolean>((resolve, reject) => {\n if (typeof canExit === 'undefined') {\n resolve(true);\n } else if (typeof canExit === 'boolean') {\n resolve(canExit);\n } else if (typeof canExit === 'function') {\n const result = canExit();\n resolve(result);\n } else {\n canExit.pipe(take(1), takeUntilDestroyed(this.destroy))\n .subscribe((result) => resolve(result));\n }\n });\n }\n\n async onBeforeUnload(ev: BeforeUnloadEvent): Promise<string | undefined> {\n const canExit = await this.requestCanExit();\n if (!canExit) {\n ev.preventDefault();\n ev.returnValue = false;\n return 'Are you sure?';\n } else {\n return undefined;\n }\n }\n\n onUnload(ev: Event) {\n\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;MAOa,qBAAqB,CAAA;AAChC,IAAA,aAAa,CACX,SAA8B,EAC9B,YAAoC,EACpC,YAAiC,EACjC,SAA+B,EAAA;AAC7B,QAAA,IAAI,SAAS,CAAC,cAAc,EAAE,EAAE;AAC9B,YAAA,OAAO,SAAS,CAAC,cAAc,EAAE,CAAC,cAAc,EAAE;QACpD;aAAO;AACL,YAAA,OAAO,CAAC,IAAI,CAAC,+LAA+L,CAAC;AAC7M,YAAA,OAAO,IAAI,OAAO,CAAU,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC;QACxD;IACJ;+GAZW,qBAAqB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAArB,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAA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BAAuB,EAAE,wBAAwB;AACjD,wBAAA,iBAAiB,EAAE,kBAAkB;AACtC,qBAAA;AACF,iBAAA;;;AC7BD;;AAEG;;;;"}
1
+ {"version":3,"file":"mintplayer-ng-bootstrap-navigation-lock.mjs","sources":["../../../../libs/mintplayer-ng-bootstrap/navigation-lock/src/service/navigation-lock.service.ts","../../../../libs/mintplayer-ng-bootstrap/navigation-lock/src/directive/navigation-lock.directive.ts","../../../../libs/mintplayer-ng-bootstrap/navigation-lock/src/guard/navigation-lock.guard.ts","../../../../libs/mintplayer-ng-bootstrap/navigation-lock/src/providers/navigation-lock.provider.ts","../../../../libs/mintplayer-ng-bootstrap/navigation-lock/mintplayer-ng-bootstrap-navigation-lock.ts"],"sourcesContent":["import { isPlatformBrowser } from '@angular/common';\nimport { DestroyRef, inject, Injectable, InjectionToken, isDevMode, PLATFORM_ID } from '@angular/core';\nimport { ROUTER_CONFIGURATION } from '@angular/router';\nimport { defaultIfEmpty, firstValueFrom, isObservable, Observable, take } from 'rxjs';\nimport { BsNavigationLockHandle } from './navigation-lock-handle';\n\n/** Confirm hook used by the directive's fallback path (canExit undefined + exitMessage set). */\nexport const BS_NAVIGATION_LOCK_CONFIRM = new InjectionToken<\n (message: string) => boolean | Promise<boolean>\n>('BS_NAVIGATION_LOCK_CONFIRM', {\n providedIn: 'root',\n factory: () => (message: string) =>\n typeof window === 'undefined' ? true : window.confirm(message),\n});\n\n@Injectable({ providedIn: 'root' })\nexport class BsNavigationLockService {\n private readonly platformId = inject(PLATFORM_ID);\n private readonly destroy = inject(DestroyRef);\n private readonly locks = new Set<BsNavigationLockHandle>();\n private pending: Promise<boolean> | null = null;\n\n constructor() {\n if (isDevMode()) {\n // canceledNavigationResolution is needed to restore the history stack\n // on popstate-cancel. Default 'replace' loses the popped entry. The\n // value is set via ROUTER_CONFIGURATION (typically through\n // withRouterConfig in provideRouter); read it directly from the token\n // since Router.options is private in the public type.\n const config = inject(ROUTER_CONFIGURATION, { optional: true });\n if (config?.canceledNavigationResolution !== 'computed') {\n console.warn(\n '[BsNavigationLockService] Router.canceledNavigationResolution is not \"computed\". ' +\n 'Pass withRouterConfig({ canceledNavigationResolution: \"computed\" }) to provideRouter ' +\n 'so popstate cancellations restore the history stack correctly.',\n );\n }\n }\n\n if (isPlatformBrowser(this.platformId)) {\n const handler = (ev: BeforeUnloadEvent) => this.onBeforeUnload(ev);\n window.addEventListener('beforeunload', handler);\n this.destroy.onDestroy(() => window.removeEventListener('beforeunload', handler));\n }\n }\n\n /** Internal — called by directive on init. */\n register(lock: BsNavigationLockHandle): void {\n this.locks.add(lock);\n }\n\n /** Internal — called by directive on destroy. */\n unregister(lock: BsNavigationLockHandle): void {\n this.locks.delete(lock);\n }\n\n /**\n * Programmatic check: ask every active lock if exit is OK.\n * Resolves true only when every lock allows exit. Short-circuits on first false.\n *\n * Re-entrant calls while a check is already in flight return the same Promise\n * — only the first `reason` is consulted. This dedups both router-driven\n * fires (e.g. `canMatch` running once) and programmatic call sites that\n * might invoke `requestExit` multiple times in the same tick.\n */\n requestExit(reason?: string): Promise<boolean> {\n if (this.pending) return this.pending;\n this.pending = this.doRequestExit(reason);\n return this.pending;\n }\n\n private async doRequestExit(reason?: string): Promise<boolean> {\n try {\n for (const lock of this.locks) {\n const ok = await this.normalise(lock.requestCanExit(reason));\n if (!ok) return false;\n }\n return true;\n } finally {\n this.pending = null;\n }\n }\n\n private onBeforeUnload(ev: BeforeUnloadEvent): void {\n // PRD §5.4 — sync-first, browser does NOT await async results.\n for (const lock of this.locks) {\n const result = lock.requestCanExit();\n if (typeof result === 'boolean') {\n if (!result) { ev.preventDefault(); ev.returnValue = ''; return; }\n continue;\n }\n // Promise / Observable — safe default: prompt the browser confirm.\n ev.preventDefault();\n ev.returnValue = '';\n return;\n }\n }\n\n private normalise(r: boolean | Promise<boolean> | Observable<boolean>): Promise<boolean> {\n if (typeof r === 'boolean') return Promise.resolve(r);\n if (isObservable(r)) return firstValueFrom(r.pipe(take(1), defaultIfEmpty(true)));\n return r;\n }\n}\n","import { DestroyRef, Directive, inject, input } from '@angular/core';\nimport { Observable } from 'rxjs';\nimport { BS_NAVIGATION_LOCK_CONFIRM, BsNavigationLockService } from '../service/navigation-lock.service';\nimport { BsNavigationLockHandle } from '../service/navigation-lock-handle';\n\n/**\n * Marks the host as a navigation-blocker. Drop `[bsNavigationLock]` on a real\n * element (typically the form). Set `[canExit]` to a boolean, function, or\n * Observable. The service consults every active lock on Router navigation\n * (via `bsNavigationLockGuard` registered at the root) and on `beforeunload`.\n *\n * Fallback: if `canExit` is not set but `exitMessage` is, the directive uses\n * the injected `BS_NAVIGATION_LOCK_CONFIRM` hook with that message.\n */\n@Directive({\n selector: '[bsNavigationLock]',\n exportAs: 'bsNavigationLock',\n})\nexport class BsNavigationLockDirective implements BsNavigationLockHandle {\n private readonly destroy = inject(DestroyRef);\n private readonly service = inject(BsNavigationLockService);\n private readonly confirmFn = inject(BS_NAVIGATION_LOCK_CONFIRM);\n\n readonly canExit = input<\n | boolean\n | ((reason?: string) => boolean | Promise<boolean> | Observable<boolean>)\n | Observable<boolean>\n | undefined\n >(undefined);\n readonly exitMessage = input<string | undefined>(undefined);\n\n constructor() {\n this.service.register(this);\n this.destroy.onDestroy(() => this.service.unregister(this));\n }\n\n requestCanExit(reason?: string): boolean | Promise<boolean> | Observable<boolean> {\n const canExit = this.canExit();\n if (canExit === undefined) {\n const msg = this.exitMessage();\n if (msg) return Promise.resolve(this.confirmFn(msg));\n return true;\n }\n if (typeof canExit === 'boolean') return canExit;\n if (typeof canExit === 'function') return canExit(reason);\n return canExit; // Observable<boolean>\n }\n}\n","import { inject } from '@angular/core';\nimport { CanMatchFn } from '@angular/router';\nimport { BsNavigationLockService } from '../service/navigation-lock.service';\n\n/**\n * Functional `canMatch` guard the consumer registers ONCE at the root route:\n *\n * ```ts\n * { path: '', canMatch: [bsNavigationLockGuard], children: [...] }\n * ```\n *\n * `canMatch` is the right Angular guard for \"should this navigation be allowed\n * to start\": it runs once per route-match attempt, regardless of how deeply\n * nested the destination is. (`canActivateChild` would fire once per descendant\n * activation — N prompts for an N-deep destination.)\n *\n * Note: when `canMatch` returns false the router treats the route as not\n * matching; if a sibling route or wildcard fallback matches the destination URL,\n * the user lands there instead of staying put. Most apps don't have a `**`\n * redirect that conflicts; if yours does, additionally guard the wildcard.\n *\n * Programmatic call sites that need a `reason` argument should call\n * `BsNavigationLockService.requestExit(reason)` directly.\n */\nexport const bsNavigationLockGuard: CanMatchFn = () => {\n return inject(BsNavigationLockService).requestExit();\n};\n","import { EnvironmentProviders, makeEnvironmentProviders } from '@angular/core';\nimport { provideRouter, RouterFeatures, Routes, withRouterConfig } from '@angular/router';\nimport { bsNavigationLockGuard } from '../guard/navigation-lock.guard';\nimport { BS_NAVIGATION_LOCK_CONFIRM } from '../service/navigation-lock.service';\n\nexport interface NavigationLockOptions {\n confirm?: (message: string) => boolean | Promise<boolean>;\n}\n\n/**\n * Optional provider. Without it, the service is still root-provided and\n * uses `window.confirm` as the default fallback confirm UI.\n */\nexport function provideNavigationLock(opts?: NavigationLockOptions): EnvironmentProviders {\n return makeEnvironmentProviders([\n ...(opts?.confirm\n ? [{ provide: BS_NAVIGATION_LOCK_CONFIRM, useValue: opts.confirm }]\n : []),\n ]);\n}\n\n/**\n * One-call router setup for navigation-lock. Wraps `routes` in a root\n * `{ path: '', canMatch: [bsNavigationLockGuard], children }` entry and\n * applies `canceledNavigationResolution: 'computed'` (required for\n * popstate-cancel to restore the history stack). Pass any additional router\n * features (`withPreloading`, `withInMemoryScrolling`, …) as extra arguments.\n *\n * If you also pass your own `withRouterConfig`, make sure it includes\n * `canceledNavigationResolution: 'computed'` — the dev-mode warning from\n * `BsNavigationLockService` will fire otherwise.\n */\nexport function provideNavigationLockRouter(\n routes: Routes,\n ...features: RouterFeatures[]\n): EnvironmentProviders {\n return provideRouter(\n [{ path: '', canMatch: [bsNavigationLockGuard], children: routes }],\n withRouterConfig({ canceledNavigationResolution: 'computed' }),\n ...features,\n );\n}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ACI,MAAM,qBAAqB,GAAe,MAAK;AACpD,IAAA,OAAO,MAAM,CAAC,uBAAuB,CAAC,CAAC,WAAW,EAAE;AACtD;;ACjBA;;;AAGG;AACG,SAAU,qBAAqB,CAAC,IAA4B,EAAA;AAChE,IAAA,OAAO,wBAAwB,CAAC;QAC9B,IAAI,IAAI,EAAE;AACR,cAAE,CAAC,EAAE,OAAO,EAAE,0BAA0B,EAAE,QAAQ,EAAE,IAAI,CAAC,OAAO,EAAE;cAChE,EAAE,CAAC;AACR,KAAA,CAAC;AACJ;AAEA;;;;;;;;;;AAUG;SACa,2BAA2B,CACzC,MAAc,EACd,GAAG,QAA0B,EAAA;AAE7B,IAAA,OAAO,aAAa,CAClB,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,qBAAqB,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,EACnE,gBAAgB,CAAC,EAAE,4BAA4B,EAAE,UAAU,EAAE,CAAC,EAC9D,GAAG,QAAQ,CACZ;AACH;;ACzCA;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mintplayer/ng-bootstrap",
3
3
  "private": false,
4
- "version": "21.23.0",
4
+ "version": "21.24.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/MintPlayer/mintplayer-ng-bootstrap",
@@ -107,6 +107,33 @@ declare class BsNavbarContentDirective implements AfterViewInit, OnDestroy {
107
107
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BsNavbarContentDirective, "[bsNavbarContent]", never, { "navbar": { "alias": "bsNavbarContent"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
108
108
  }
109
109
 
110
+ /**
111
+ * Marks a navbar dropdown trigger anchor. Replaces both `routerLink` and
112
+ * `routerLinkActive` on a trigger element: toggles the active CSS class when a
113
+ * sub-route under the bound URL is active, but does NOT navigate on click
114
+ * (which `routerLink` would do via its own host listener, even when other
115
+ * click handlers `preventDefault`).
116
+ *
117
+ * @example
118
+ * ```html
119
+ * <a bsNavbarTrigger="/overlays">Overlays</a>
120
+ * ```
121
+ *
122
+ * Items inside the dropdown panel still use real `[routerLink]`s for
123
+ * navigation. Use this directive only for the trigger anchor that opens the
124
+ * dropdown panel.
125
+ */
126
+ declare class BsNavbarTriggerDirective {
127
+ private router;
128
+ readonly bsNavbarTrigger: _angular_core.InputSignal<string | readonly string[]>;
129
+ private currentUrl;
130
+ private targetUrl;
131
+ readonly isActive: _angular_core.Signal<boolean>;
132
+ constructor();
133
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<BsNavbarTriggerDirective, never>;
134
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BsNavbarTriggerDirective, "[bsNavbarTrigger]", never, { "bsNavbarTrigger": { "alias": "bsNavbarTrigger"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
135
+ }
136
+
110
137
  declare class BsExpandButtonDirective {
111
138
  constructor();
112
139
  static ngTemplateContextGuard(dir: BsExpandButtonDirective, ctx: any): ctx is BsExpandButtonContext;
@@ -135,4 +162,4 @@ declare class NavLinkDirective {
135
162
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NavLinkDirective, "bs-navbar-item > li > a", never, {}, {}, never, never, true, never>;
136
163
  }
137
164
 
138
- export { BsExpandButtonContext, BsExpandButtonDirective, BsNavbarBrandComponent, BsNavbarComponent, BsNavbarContentDirective, BsNavbarDropdownComponent, BsNavbarItemComponent, BsNavbarNavComponent, DropdownToggleDirective, NavLinkDirective };
165
+ export { BsExpandButtonContext, BsExpandButtonDirective, BsNavbarBrandComponent, BsNavbarComponent, BsNavbarContentDirective, BsNavbarDropdownComponent, BsNavbarItemComponent, BsNavbarNavComponent, BsNavbarTriggerDirective, DropdownToggleDirective, NavLinkDirective };
@@ -1,57 +1,117 @@
1
- import { ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree } from '@angular/router';
2
1
  import * as i0 from '@angular/core';
3
- import { Signal } from '@angular/core';
2
+ import { InjectionToken, EnvironmentProviders } from '@angular/core';
4
3
  import { Observable } from 'rxjs';
4
+ import { CanMatchFn, Routes, RouterFeatures } from '@angular/router';
5
5
 
6
6
  /**
7
- * Places a navigation lock on this page.
8
- *
9
- * Don't forget to add the following to your route:
10
- *
11
- * ```ts
12
- * canDeactivate: [BsNavigationLockGuard]
13
- * ```
14
- *
15
- * and implement the `BsHasNavigationLock` on the page:
16
- *
17
- * ```ts
18
- * ViewChild('navigationLock') navigationLock!: BsNavigationLockDirective;
19
- * ```
7
+ * Contract a navigation lock implements so the service can consult it.
8
+ * Implemented by `BsNavigationLockDirective`; consumers may also register
9
+ * arbitrary handles via `BsNavigationLockService.register(...)`.
10
+ */
11
+ interface BsNavigationLockHandle {
12
+ /**
13
+ * Returns whether this lock allows exit. May be sync, Promise, or Observable.
14
+ * `reason` is forwarded from `BsNavigationLockService.requestExit(reason)` for
15
+ * programmatic call sites (e.g. `'logout'`); the functional CanActivateChild
16
+ * guard passes `undefined`.
17
+ */
18
+ requestCanExit(reason?: string): boolean | Promise<boolean> | Observable<boolean>;
19
+ /** Optional message shown in the fallback confirm dialog when no `canExit` is set. */
20
+ exitMessage(): string | undefined;
21
+ }
22
+
23
+ /**
24
+ * Marks the host as a navigation-blocker. Drop `[bsNavigationLock]` on a real
25
+ * element (typically the form). Set `[canExit]` to a boolean, function, or
26
+ * Observable. The service consults every active lock on Router navigation
27
+ * (via `bsNavigationLockGuard` registered at the root) and on `beforeunload`.
20
28
  *
21
- **/
22
- declare class BsNavigationLockDirective {
23
- private router;
24
- private route;
25
- private destroy;
26
- readonly canExit: i0.InputSignal<boolean | Observable<boolean> | (() => boolean) | undefined>;
29
+ * Fallback: if `canExit` is not set but `exitMessage` is, the directive uses
30
+ * the injected `BS_NAVIGATION_LOCK_CONFIRM` hook with that message.
31
+ */
32
+ declare class BsNavigationLockDirective implements BsNavigationLockHandle {
33
+ private readonly destroy;
34
+ private readonly service;
35
+ private readonly confirmFn;
36
+ readonly canExit: i0.InputSignal<boolean | Observable<boolean> | ((reason?: string) => boolean | Promise<boolean> | Observable<boolean>) | undefined>;
27
37
  readonly exitMessage: i0.InputSignal<string | undefined>;
28
- requestCanExit(): Promise<boolean>;
29
- onBeforeUnload(ev: BeforeUnloadEvent): Promise<string | undefined>;
30
- onUnload(ev: Event): void;
38
+ constructor();
39
+ requestCanExit(reason?: string): boolean | Promise<boolean> | Observable<boolean>;
31
40
  static ɵfac: i0.ɵɵFactoryDeclaration<BsNavigationLockDirective, never>;
32
41
  static ɵdir: i0.ɵɵDirectiveDeclaration<BsNavigationLockDirective, "[bsNavigationLock]", ["bsNavigationLock"], { "canExit": { "alias": "canExit"; "required": false; "isSignal": true; }; "exitMessage": { "alias": "exitMessage"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
33
42
  }
34
43
 
35
44
  /**
36
- * Implement this interface on pages that use the `<... bsNavigationLock>` directive:
37
- *
38
- * @example
45
+ * Functional `canMatch` guard the consumer registers ONCE at the root route:
39
46
  *
40
47
  * ```ts
41
- * readonly navigationLock = viewChild.required<BsNavigationLockDirective>('navigationLock');
48
+ * { path: '', canMatch: [bsNavigationLockGuard], children: [...] }
42
49
  * ```
43
50
  *
44
- * Don't forget to add the `canDeactivate: [BsNavigationLockGuard]` guard to your page route.
51
+ * `canMatch` is the right Angular guard for "should this navigation be allowed
52
+ * to start": it runs once per route-match attempt, regardless of how deeply
53
+ * nested the destination is. (`canActivateChild` would fire once per descendant
54
+ * activation — N prompts for an N-deep destination.)
55
+ *
56
+ * Note: when `canMatch` returns false the router treats the route as not
57
+ * matching; if a sibling route or wildcard fallback matches the destination URL,
58
+ * the user lands there instead of staying put. Most apps don't have a `**`
59
+ * redirect that conflicts; if yours does, additionally guard the wildcard.
60
+ *
61
+ * Programmatic call sites that need a `reason` argument should call
62
+ * `BsNavigationLockService.requestExit(reason)` directly.
45
63
  */
46
- interface BsHasNavigationLock {
47
- navigationLock: Signal<BsNavigationLockDirective>;
64
+ declare const bsNavigationLockGuard: CanMatchFn;
65
+
66
+ /** Confirm hook used by the directive's fallback path (canExit undefined + exitMessage set). */
67
+ declare const BS_NAVIGATION_LOCK_CONFIRM: InjectionToken<(message: string) => boolean | Promise<boolean>>;
68
+ declare class BsNavigationLockService {
69
+ private readonly platformId;
70
+ private readonly destroy;
71
+ private readonly locks;
72
+ private pending;
73
+ constructor();
74
+ /** Internal — called by directive on init. */
75
+ register(lock: BsNavigationLockHandle): void;
76
+ /** Internal — called by directive on destroy. */
77
+ unregister(lock: BsNavigationLockHandle): void;
78
+ /**
79
+ * Programmatic check: ask every active lock if exit is OK.
80
+ * Resolves true only when every lock allows exit. Short-circuits on first false.
81
+ *
82
+ * Re-entrant calls while a check is already in flight return the same Promise
83
+ * — only the first `reason` is consulted. This dedups both router-driven
84
+ * fires (e.g. `canMatch` running once) and programmatic call sites that
85
+ * might invoke `requestExit` multiple times in the same tick.
86
+ */
87
+ requestExit(reason?: string): Promise<boolean>;
88
+ private doRequestExit;
89
+ private onBeforeUnload;
90
+ private normalise;
91
+ static ɵfac: i0.ɵɵFactoryDeclaration<BsNavigationLockService, never>;
92
+ static ɵprov: i0.ɵɵInjectableDeclaration<BsNavigationLockService>;
48
93
  }
49
94
 
50
- declare class BsNavigationLockGuard {
51
- canDeactivate(component: BsHasNavigationLock, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState?: RouterStateSnapshot): Promise<boolean | UrlTree>;
52
- static ɵfac: i0.ɵɵFactoryDeclaration<BsNavigationLockGuard, never>;
53
- static ɵprov: i0.ɵɵInjectableDeclaration<BsNavigationLockGuard>;
95
+ interface NavigationLockOptions {
96
+ confirm?: (message: string) => boolean | Promise<boolean>;
54
97
  }
98
+ /**
99
+ * Optional provider. Without it, the service is still root-provided and
100
+ * uses `window.confirm` as the default fallback confirm UI.
101
+ */
102
+ declare function provideNavigationLock(opts?: NavigationLockOptions): EnvironmentProviders;
103
+ /**
104
+ * One-call router setup for navigation-lock. Wraps `routes` in a root
105
+ * `{ path: '', canMatch: [bsNavigationLockGuard], children }` entry and
106
+ * applies `canceledNavigationResolution: 'computed'` (required for
107
+ * popstate-cancel to restore the history stack). Pass any additional router
108
+ * features (`withPreloading`, `withInMemoryScrolling`, …) as extra arguments.
109
+ *
110
+ * If you also pass your own `withRouterConfig`, make sure it includes
111
+ * `canceledNavigationResolution: 'computed'` — the dev-mode warning from
112
+ * `BsNavigationLockService` will fire otherwise.
113
+ */
114
+ declare function provideNavigationLockRouter(routes: Routes, ...features: RouterFeatures[]): EnvironmentProviders;
55
115
 
56
- export { BsNavigationLockDirective, BsNavigationLockGuard };
57
- export type { BsHasNavigationLock };
116
+ export { BS_NAVIGATION_LOCK_CONFIRM, BsNavigationLockDirective, BsNavigationLockService, bsNavigationLockGuard, provideNavigationLock, provideNavigationLockRouter };
117
+ export type { BsNavigationLockHandle, NavigationLockOptions };