mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-20 19:39:54 +00:00
63 lines
1.4 KiB
TypeScript
63 lines
1.4 KiB
TypeScript
import { Observable, Subject } from 'rxjs'
|
|
import { ViewRef } from '@angular/core'
|
|
|
|
export abstract class BaseTabComponent {
|
|
private static lastTabID = 0
|
|
id: number
|
|
title: string
|
|
customTitle: string
|
|
hasActivity = false
|
|
hasFocus = false
|
|
hostView: ViewRef
|
|
protected titleChange = new Subject<string>()
|
|
protected focused = new Subject<void>()
|
|
protected blurred = new Subject<void>()
|
|
|
|
get focused$ (): Observable<void> { return this.focused }
|
|
get blurred$ (): Observable<void> { return this.blurred }
|
|
get titleChange$ (): Observable<string> { return this.titleChange }
|
|
|
|
constructor () {
|
|
this.id = BaseTabComponent.lastTabID++
|
|
this.focused$.subscribe(() => {
|
|
this.hasFocus = true
|
|
})
|
|
this.blurred$.subscribe(() => {
|
|
this.hasFocus = false
|
|
})
|
|
}
|
|
|
|
setTitle (title: string) {
|
|
this.title = title
|
|
if (!this.customTitle) {
|
|
this.titleChange.next(title)
|
|
}
|
|
}
|
|
|
|
displayActivity (): void {
|
|
this.hasActivity = true
|
|
}
|
|
|
|
getRecoveryToken (): any {
|
|
return null
|
|
}
|
|
|
|
async canClose (): Promise<boolean> {
|
|
return true
|
|
}
|
|
|
|
emitFocused () {
|
|
this.focused.next()
|
|
}
|
|
|
|
emitBlurred () {
|
|
this.blurred.next()
|
|
}
|
|
|
|
destroy (): void {
|
|
this.focused.complete()
|
|
this.blurred.complete()
|
|
this.titleChange.complete()
|
|
}
|
|
}
|