UNPKG

smart-webcomponents

Version:

Web Components & Custom Elements for Professional Web Applications

82 lines (65 loc) 2.44 kB
import { TabItemsGroup } 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 { TabItemsGroup } from './../index'; @Directive({ exportAs: 'smart-tab-items-group', selector: 'smart-tab-items-group, [smart-tab-items-group]' }) export class TabItemsGroupComponent extends BaseElement implements OnInit, AfterViewInit, OnDestroy, OnChanges { constructor(ref: ElementRef<TabItemsGroup>) { super(ref); this.nativeElement = ref.nativeElement as TabItemsGroup; } private eventHandlers: any[] = []; public declare nativeElement: TabItemsGroup; /** @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 = <TabItemsGroup>document.createElement('smart-tab-items-group'); for (let propertyName in properties) { this.nativeElement[propertyName] = properties[propertyName]; } return this.nativeElement; } /** @description */ @Input() get label(): string { return this.nativeElement ? this.nativeElement.label : undefined; } set label(value: string) { this.nativeElement ? this.nativeElement.label = value : undefined; } /** @description */ @Input() get labelSize(): number { return this.nativeElement ? this.nativeElement.labelSize : undefined; } set labelSize(value: number) { this.nativeElement ? this.nativeElement.labelSize = 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; } } } } }