forked from CenterForOpenScience/angular-osf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch-input.component.ts
More file actions
34 lines (27 loc) · 1.02 KB
/
Copy pathsearch-input.component.ts
File metadata and controls
34 lines (27 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { TranslatePipe } from '@ngx-translate/core';
import { Button } from 'primeng/button';
import { InputText } from 'primeng/inputtext';
import { ChangeDetectionStrategy, Component, input, output } from '@angular/core';
import { FormControl, ReactiveFormsModule } from '@angular/forms';
import { IconComponent } from '../icon/icon.component';
@Component({
selector: 'osf-search-input',
imports: [InputText, Button, ReactiveFormsModule, IconComponent, TranslatePipe],
templateUrl: './search-input.component.html',
styleUrl: './search-input.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class SearchInputComponent {
control = input<FormControl>(new FormControl<string>(''));
placeholder = input<string>('');
showHelpIcon = input(false);
triggerSearch = output<string>();
helpClicked = output<void>();
enterClicked() {
const searchValue = this.control().value;
if (!searchValue || !searchValue?.trim()?.length) {
return;
}
this.triggerSearch.emit(searchValue);
}
}