import { Component, OnInit, OnDestroy, Input, Output, EventEmitter } from '@angular/core';
import { SessionService, LayoutService } from '@pepperi/lib';

export enum GROUP_BUTTONS_VIEW_TYPE {
    Regular,
    Dropdown,
    Split,
}

@Component({
    selector: 'pepperi-group-buttons',
    templateUrl: './group-buttons.component.html',
    styleUrls: ['./group-buttons.component.scss'],
})
export class GroupButtonsComponent implements OnInit, OnDestroy {
    GROUP_BUTTONS_VIEW_TYPE = GROUP_BUTTONS_VIEW_TYPE;

    @Input() viewType: GROUP_BUTTONS_VIEW_TYPE = GROUP_BUTTONS_VIEW_TYPE.Regular;
    @Input() buttons: any;
    @Input() buttonsClass: string;
    @Input() buttonsDisabled: string;

    @Output() buttonClick: EventEmitter<any> = new EventEmitter<any>();

    constructor(public layoutService: LayoutService, public sessionService: SessionService) { }

    ngOnInit(): void { }

    ngOnDestroy() {
        if (this.buttonClick) this.buttonClick.unsubscribe();
    }

    onButtonClicked(button) {
        this.buttonClick.emit(button);
    }
}
