import {Component, ElementRef, Input, ViewChild} from "@angular/core";
import {MobileDropdownComponent} from "../mobile-dropdown/mobile-dropdown.component";
declare var UIkit;
@Component({
selector: 'dropdown-filter',
template: `
`
})
export class DropdownFilterComponent {
@Input()
public name;
@Input()
public count: number = 0;
@Input()
public dropdownClass: string;
@Input()
public dropdownMinWidth: number;
@Input()
public overflow: boolean = true;
@Input()
public disabled = false;
@Input()
public isMobile: boolean = false;
@ViewChild("dropdownElement") dropdownElement: ElementRef;
@ViewChild("mobileDropdown") mobileDropdown: MobileDropdownComponent;
get isOpen() {
if(this.isMobile) {
return this.mobileDropdown?.opened;
} else {
return (typeof document !== 'undefined') && this.dropdownElement && UIkit.dropdown(this.dropdownElement.nativeElement).isActive();
}
}
closeDropdown() {
if(this.isMobile) {
this.mobileDropdown.close();
} else {
UIkit.dropdown(this.dropdownElement.nativeElement).hide();
}
}
}