2020-05-29 14:16:24 +00:00
|
|
|
import { Input, Component, Output, EventEmitter, OnInit, ChangeDetectionStrategy, OnChanges } from '@angular/core'
|
2020-01-25 15:32:06 +00:00
|
|
|
import { RouterLink } from '@angular/router'
|
|
|
|
import { ListKeyManagerOption } from '@angular/cdk/a11y'
|
|
|
|
|
2020-05-29 14:16:24 +00:00
|
|
|
export type SuggestionPayload = {
|
2020-01-25 15:32:06 +00:00
|
|
|
text: string
|
2020-05-29 14:16:24 +00:00
|
|
|
type: SuggestionPayloadType
|
|
|
|
routerLink?: RouterLink
|
|
|
|
default: boolean
|
2020-01-25 15:32:06 +00:00
|
|
|
}
|
|
|
|
|
2020-05-29 14:16:24 +00:00
|
|
|
export type SuggestionPayloadType = 'search-instance' | 'search-index'
|
|
|
|
|
2020-01-25 15:32:06 +00:00
|
|
|
@Component({
|
|
|
|
selector: 'my-suggestion',
|
|
|
|
templateUrl: './suggestion.component.html',
|
2020-05-29 14:16:24 +00:00
|
|
|
styleUrls: [ './suggestion.component.scss' ]
|
2020-01-25 15:32:06 +00:00
|
|
|
})
|
|
|
|
export class SuggestionComponent implements OnInit, ListKeyManagerOption {
|
2020-05-29 14:16:24 +00:00
|
|
|
@Input() result: SuggestionPayload
|
2020-01-25 15:32:06 +00:00
|
|
|
@Input() highlight: string
|
|
|
|
|
|
|
|
disabled = false
|
|
|
|
active = false
|
|
|
|
|
|
|
|
getLabel () {
|
|
|
|
return this.result.text
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit () {
|
2020-02-03 13:04:42 +00:00
|
|
|
if (this.result.default) this.active = true
|
2020-01-25 15:32:06 +00:00
|
|
|
}
|
|
|
|
}
|