]>
Commit | Line | Data |
---|---|---|
6af662a5 | 1 | import { ListKeyManagerOption } from '@angular/cdk/a11y' |
67ed6552 C |
2 | import { Component, Input, OnInit } from '@angular/core' |
3 | import { RouterLink } from '@angular/router' | |
6af662a5 | 4 | |
5fb2e288 | 5 | export type SuggestionPayload = { |
6af662a5 | 6 | text: string |
5fb2e288 C |
7 | type: SuggestionPayloadType |
8 | routerLink?: RouterLink | |
9 | default: boolean | |
6af662a5 RK |
10 | } |
11 | ||
5fb2e288 C |
12 | export type SuggestionPayloadType = 'search-instance' | 'search-index' |
13 | ||
6af662a5 RK |
14 | @Component({ |
15 | selector: 'my-suggestion', | |
16 | templateUrl: './suggestion.component.html', | |
5fb2e288 | 17 | styleUrls: [ './suggestion.component.scss' ] |
6af662a5 RK |
18 | }) |
19 | export class SuggestionComponent implements OnInit, ListKeyManagerOption { | |
5fb2e288 | 20 | @Input() result: SuggestionPayload |
6af662a5 | 21 | @Input() highlight: string |
6af662a5 | 22 | |
6af662a5 RK |
23 | disabled = false |
24 | active = false | |
25 | ||
6af662a5 RK |
26 | getLabel () { |
27 | return this.result.text | |
28 | } | |
29 | ||
30 | ngOnInit () { | |
52cc0d54 | 31 | if (this.result.default) this.active = true |
6af662a5 | 32 | } |
6af662a5 | 33 | } |