-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
71aef5f
commit 4ad86a2
Showing
17 changed files
with
77 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './attribute-transform'; | ||
export * from './control-value-accessor-mixin'; | ||
export * from './router-link-support-mixin'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { inject } from '@angular/core'; | ||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; | ||
import { NavigationEnd, Router, RouterLink } from '@angular/router'; | ||
import { AbstractConstructor } from '@sbb-esta/lyne-elements/core/mixins.js'; | ||
|
||
/** | ||
* Patches the behavior of the Angular RouterLink. | ||
* With this patch the RouterLink recognizes the web component links | ||
* as native links and processes them correctly. | ||
* TODO: Check whether there is support of Angular for that case: | ||
* - https://github.com/angular/angular/pull/59567 | ||
* - https://github.com/angular/angular/issues/28345 | ||
*/ | ||
export const SbbRouterLinkSupportMixin = <T extends AbstractConstructor>( | ||
superclass: T, | ||
): AbstractConstructor & T => { | ||
abstract class SbbRouterLink extends superclass { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
constructor(...args: any[]) { | ||
super(...args); | ||
|
||
const routerLink = inject(RouterLink, { optional: true }) as unknown as { | ||
isAnchorElement: boolean; | ||
updateHref: () => void; | ||
setTabIndexIfNotOnNativeEl: (newTabIndex: string | null) => void; | ||
}; | ||
|
||
if (!routerLink) { | ||
return; | ||
} | ||
|
||
routerLink.setTabIndexIfNotOnNativeEl(null); | ||
routerLink.isAnchorElement = true; | ||
|
||
inject(Router) | ||
.events.pipe(takeUntilDestroyed()) | ||
.subscribe((s) => { | ||
if (s instanceof NavigationEnd) { | ||
routerLink.updateHref(); | ||
} | ||
}); | ||
} | ||
} | ||
return SbbRouterLink as unknown as AbstractConstructor & T; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
@import '@sbb-esta/lyne-elements/standard-theme.css'; | ||
|
||
/* You can add global styles to this file, and also import other style files */ |