UNPKG

smart-webcomponents

Version:

Web Components & Custom Elements for Professional Web Applications

100 lines (81 loc) 3.05 kB
import { RibbonTab } from './../index'; import { ElementRenderMode} from './../index'; import { Component, Directive, AfterViewInit, ElementRef, Input, OnInit, OnChanges, OnDestroy, SimpleChanges } from '@angular/core'; import { BaseElement, Smart } from './smart.element'; export { ElementRenderMode} from './../index'; export { Smart } from './smart.element'; export { RibbonTab } from './../index'; @Directive({ exportAs: 'smart-ribbon-tab', selector: 'smart-ribbon-tab, [smart-ribbon-tab]' }) export class RibbonTabComponent extends BaseElement implements OnInit, AfterViewInit, OnDestroy, OnChanges { constructor(ref: ElementRef<RibbonTab>) { super(ref); this.nativeElement = ref.nativeElement as RibbonTab; } private eventHandlers: any[] = []; public declare nativeElement: RibbonTab; /** @description Creates the component on demand. * @param properties An optional object of properties, which will be added to the template binded ones. */ public createComponent(properties = {}): any { this.nativeElement = <RibbonTab>document.createElement('smart-ribbon-tab'); for (let propertyName in properties) { this.nativeElement[propertyName] = properties[propertyName]; } return this.nativeElement; } /** @description Determines whether the tab item is disabled. */ @Input() get disabled(): boolean { return this.nativeElement ? this.nativeElement.disabled : undefined; } set disabled(value: boolean) { this.nativeElement ? this.nativeElement.disabled = value : undefined; } /** @description Determines the label of the tab item. */ @Input() get label(): string { return this.nativeElement ? this.nativeElement.label : undefined; } set label(value: string) { this.nativeElement ? this.nativeElement.label = value : undefined; } /** @description Determines whether the tab item is selected. */ @Input() get selected(): boolean { return this.nativeElement ? this.nativeElement.selected : undefined; } set selected(value: boolean) { this.nativeElement ? this.nativeElement.selected = value : undefined; } /** @description Determines the ribbon group of the tab item */ @Input() get ribbonGroups(): any { return this.nativeElement ? this.nativeElement.ribbonGroups : undefined; } set ribbonGroups(value: any) { this.nativeElement ? this.nativeElement.ribbonGroups = value : undefined; } get isRendered(): boolean { return this.nativeElement ? this.nativeElement.isRendered : false; } ngOnInit() { } ngAfterViewInit() { const that = this; that.onCreate.emit(that.nativeElement); this.nativeElement.classList.add('smart-angular'); if (this.nativeElement.whenRendered) this.nativeElement.whenRendered(() => { that.onReady.emit(that.nativeElement); }); } ngOnDestroy() { } ngOnChanges(changes: SimpleChanges) { if (this.nativeElement && this.nativeElement.isRendered) { for (const propName in changes) { if (changes.hasOwnProperty(propName)) { this.nativeElement[propName] = changes[propName].currentValue; } } } } }