/* Copyright CloudLinux Zug GmbH 2010-2017 All Rights Reserved
 *
 * Licensed under CLOUD LINUX LICENSE AGREEMENT
 * http://cloudlinux.com/docs/LICENSE.TXT
 */

import { Component, Input, Output, ElementRef, EventEmitter } from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { InputAccessor } from '../input-accessor';
import { TypeOfButtons, TypeOfButtonSize } from '../../types';

@Component({
    selector: 'ui-button',
    template: require('./ui-button.html'),
    styles: [
        require('./ui-button.less')
    ],
    providers: [
        {provide: NG_VALUE_ACCESSOR, useExisting: UiButton, multi: true}
    ],
})



export class UiButton extends InputAccessor {

    @Input() icon: string;
    @Input() style: TypeOfButtons = 'primary';
    @Input() size: TypeOfButtonSize = 'large';
    @Input() customClass: string;

    @Output() clickAction = new EventEmitter();

    /**
     * Convert text to upper case or not
     * @type {boolean}
     */
    @Input() upper: boolean = true;

    /**
     * Indicate multi action of button with dropdown list
     * @type {boolean}
     */
    @Input() multi: boolean = false;

    /**
     * It's used if multi=true
     */
    @Input() listOfActions;

    constructor(public elementRef: ElementRef) {
        super();
    }

    public prepareValueHook() {}

    private clicked(event) {
        this.clickAction.emit(event);
    }
}
