coreui-angular-ex
Version:
CoreUI Components Library for Angular
65 lines (53 loc) • 1.63 kB
text/typescript
import { booleanAttribute, Directive, ElementRef, HostBinding, Input } from '@angular/core';
import { Colors } from '../coreui.types';
export class ListGroupItemDirective {
constructor(
private hostElement: ElementRef
) { }
/**
* Toggle the active state for the component.
* @type boolean
*/
active?: boolean;
/**
* Sets the color context of the component to one of CoreUI’s themed colors.
* @type Colors
*/
color?: Colors;
/**
* Set disabled attr for the host element. [docs]
* @type boolean
*/
disabled: string | boolean = false;
get isDisabled(): boolean | null {
return <boolean>this.disabled || null;
}
get attrDisabled() {
return this.disabled ? '' : null;
};
get getTabindex(): string | null {
return this.disabled ? '-1' : null;
}
get ariaCurrent(): boolean {
return !!this.active;
}
get hostClasses(): any {
const host: HTMLElement = this.hostElement.nativeElement;
return {
'list-group-item': true,
'list-group-item-action': host.nodeName === 'A' || host.nodeName === 'BUTTON',
active: !!this.active,
disabled: this.isDisabled,
[`list-group-item-${this.color}`]: !!this.color
};
}
}