import { Component, Input, OnInit, ChangeDetectionStrategy, Renderer2, ElementRef } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { LAYOUT_TYPE, CustomizationService } from '@pepperi/lib';

@Component({
    selector: 'pepperi-separator',
    templateUrl: './separator.component.html',
    styleUrls: ['./separator.component.scss'],
    changeDetection: ChangeDetectionStrategy.OnPush
})
export class PepperiSeparatorComponent implements OnInit {
    @Input() key: string = '';
    @Input() label: string = '';
    @Input() xAlignment: string = '0';

    controlType = 'separator';

    @Input() form: FormGroup = null;
    @Input() layoutType: LAYOUT_TYPE = LAYOUT_TYPE.PepperiForm;

    LAYOUT_TYPE = LAYOUT_TYPE;
    standAlone = false;

    constructor(
        public customizationService: CustomizationService,
        private renderer: Renderer2,
        public _eref: ElementRef) { }

    ngOnInit() {
        if (this.form === null) {
            this.standAlone = true;

            this.renderer.addClass(this._eref.nativeElement, CustomizationService.STAND_ALONE_FIELD_CLASS_NAME);
        }
    }
}
