-
Notifications
You must be signed in to change notification settings - Fork 478
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: some stuff * chore: fix tests * chore: fix tests
- Loading branch information
Showing
27 changed files
with
106 additions
and
160 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,15 @@ | ||
import {Directive, EventEmitter, HostListener, Output} from '@angular/core'; | ||
import {tuiAssertIsHTMLElement} from '@taiga-ui/cdk/classes'; | ||
import {shouldCall} from '@tinkoff/ng-event-plugins'; | ||
import {Directive, Inject} from '@angular/core'; | ||
import {Observable} from 'rxjs'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
export function movedOut({currentTarget, relatedTarget}: MouseEvent): boolean { | ||
tuiAssertIsHTMLElement(currentTarget); | ||
tuiAssertIsHTMLElement(relatedTarget); | ||
|
||
return !currentTarget.contains(relatedTarget); | ||
} | ||
import {TuiHoveredService} from './hovered.service'; | ||
|
||
@Directive({ | ||
selector: '[tuiHoveredChange]', | ||
outputs: ['tuiHoveredChange'], | ||
providers: [TuiHoveredService], | ||
}) | ||
export class TuiHoveredDirective { | ||
@Output() | ||
readonly tuiHoveredChange = new EventEmitter<boolean>(); | ||
|
||
@HostListener('mouseenter') | ||
onHover(): void { | ||
this.tuiHoveredChange.emit(true); | ||
} | ||
|
||
@shouldCall(movedOut) | ||
@HostListener('mouseout.init', ['$event']) | ||
@HostListener('mouseout.silent', ['$event']) | ||
onOut(_: MouseEvent): void { | ||
this.tuiHoveredChange.emit(false); | ||
} | ||
constructor( | ||
@Inject(TuiHoveredService) readonly tuiHoveredChange: Observable<boolean>, | ||
) {} | ||
} |
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,32 @@ | ||
import {ElementRef, Inject, Injectable, NgZone} from '@angular/core'; | ||
import {tuiAssertIsElement} from '@taiga-ui/cdk/classes'; | ||
import {tuiTypedFromEvent, tuiZoneOptimized} from '@taiga-ui/cdk/observables'; | ||
import {merge, Observable} from 'rxjs'; | ||
import {distinctUntilChanged, filter, mapTo} from 'rxjs/operators'; | ||
|
||
function movedOut({currentTarget, relatedTarget}: MouseEvent): boolean { | ||
tuiAssertIsElement(currentTarget); | ||
tuiAssertIsElement(relatedTarget); | ||
|
||
return !currentTarget.contains(relatedTarget); | ||
} | ||
|
||
@Injectable() | ||
export class TuiHoveredService extends Observable<boolean> { | ||
private readonly stream$ = merge( | ||
tuiTypedFromEvent(this.elementRef.nativeElement, 'mouseenter').pipe(mapTo(true)), | ||
tuiTypedFromEvent(this.elementRef.nativeElement, 'mouseleave').pipe(mapTo(false)), | ||
// Hello, Safari | ||
tuiTypedFromEvent(this.elementRef.nativeElement, 'mouseout').pipe( | ||
filter(movedOut), | ||
mapTo(false), | ||
), | ||
).pipe(distinctUntilChanged(), tuiZoneOptimized(this.ngZone)); | ||
|
||
constructor( | ||
@Inject(ElementRef) private readonly elementRef: ElementRef<Element>, | ||
@Inject(NgZone) private readonly ngZone: NgZone, | ||
) { | ||
super(subscriber => this.stream$.subscribe(subscriber)); | ||
} | ||
} |
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 './hovered.directive'; | ||
export * from './hovered.module'; | ||
export * from './hovered.service'; |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
:host { | ||
position: fixed; | ||
bottom: 0; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 0; | ||
|
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export const DESCRIBED_BY = '_described-by'; |
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
Oops, something went wrong.