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