import { __decorate, __extends } from "tslib";
import Vue from 'vue';
import Component from 'vue-class-component';
import { Emit, Prop } from 'vue-property-decorator';
import { Enums } from '../../utils/enums/enums';
import { BUTTON_NAME } from '../component-names';
import { MIcon } from '../icon/icon';
import { MSpinner } from '../spinner/spinner';
import WithRender from './button.html?style=./button.scss';
export var MButtonType;
(function (MButtonType) {
    MButtonType["Button"] = "button";
    MButtonType["Submit"] = "submit";
    MButtonType["Reset"] = "reset";
})(MButtonType || (MButtonType = {}));
export var MButtonSkin;
(function (MButtonSkin) {
    MButtonSkin["Primary"] = "primary";
    MButtonSkin["Secondary"] = "secondary";
    MButtonSkin["Tertiary"] = "tertiary";
})(MButtonSkin || (MButtonSkin = {}));
export var MButtonIconPosition;
(function (MButtonIconPosition) {
    MButtonIconPosition["Left"] = "left";
    MButtonIconPosition["Right"] = "right";
})(MButtonIconPosition || (MButtonIconPosition = {}));
var MButton = /** @class */ (function (_super) {
    __extends(MButton, _super);
    function MButton() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    MButton.prototype.onClick = function (event) { };
    MButton.prototype.onMousedown = function (event) { };
    MButton.prototype.onTouchstart = function (event) { };
    MButton.prototype.onTouchend = function (event) { };
    MButton.prototype.onFocus = function (event) { };
    MButton.prototype.onBlur = function (event) { };
    Object.defineProperty(MButton.prototype, "isSkinPrimary", {
        get: function () {
            return this.skin === MButtonSkin.Primary;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MButton.prototype, "isSkinSecondary", {
        get: function () {
            return this.skin === MButtonSkin.Secondary;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MButton.prototype, "isSkinTertiary", {
        get: function () {
            return this.skin === MButtonSkin.Tertiary;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MButton.prototype, "isWaiting", {
        get: function () {
            return !this.disabled ? this.waiting : false;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MButton.prototype, "hasIcone", {
        get: function () {
            return Boolean(this.iconName);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MButton.prototype, "hasIconLeft", {
        get: function () {
            return this.iconPosition === MButtonIconPosition.Left && this.hasIcone && !this.waiting;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MButton.prototype, "hasIconRight", {
        get: function () {
            return this.iconPosition === MButtonIconPosition.Right && this.hasIcone && !this.waiting;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MButton.prototype, "hasWaitingIconLeft", {
        get: function () {
            return this.iconPosition === MButtonIconPosition.Left && this.waiting;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MButton.prototype, "hasWaitingIconRight", {
        get: function () {
            return this.iconPosition === MButtonIconPosition.Right && this.waiting;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MButton.prototype, "hasPrecision", {
        get: function () {
            return !!this.precision || !!this.$slots.precision;
        },
        enumerable: false,
        configurable: true
    });
    __decorate([
        Prop({
            default: MButtonType.Button,
            validator: function (value) { return Enums.toValueArray(MButtonType).includes(value); }
        })
    ], MButton.prototype, "type", void 0);
    __decorate([
        Prop({
            default: MButtonSkin.Primary,
            validator: function (value) { return Enums.toValueArray(MButtonSkin).includes(value); }
        })
    ], MButton.prototype, "skin", void 0);
    __decorate([
        Prop()
    ], MButton.prototype, "precision", void 0);
    __decorate([
        Prop({ default: false })
    ], MButton.prototype, "disabled", void 0);
    __decorate([
        Prop({ default: false })
    ], MButton.prototype, "waiting", void 0);
    __decorate([
        Prop({ default: false })
    ], MButton.prototype, "fullSize", void 0);
    __decorate([
        Prop()
    ], MButton.prototype, "iconName", void 0);
    __decorate([
        Prop({
            default: MButtonIconPosition.Left,
            validator: function (value) { return Enums.toValueArray(MButtonIconPosition).includes(value); }
        })
    ], MButton.prototype, "iconPosition", void 0);
    __decorate([
        Prop({ default: '12px' })
    ], MButton.prototype, "iconSize", void 0);
    __decorate([
        Emit('click')
    ], MButton.prototype, "onClick", null);
    __decorate([
        Emit('mousedown')
    ], MButton.prototype, "onMousedown", null);
    __decorate([
        Emit('touchstart')
    ], MButton.prototype, "onTouchstart", null);
    __decorate([
        Emit('touchend')
    ], MButton.prototype, "onTouchend", null);
    __decorate([
        Emit('focus')
    ], MButton.prototype, "onFocus", null);
    __decorate([
        Emit('blur')
    ], MButton.prototype, "onBlur", null);
    MButton = __decorate([
        WithRender,
        Component({
            components: {
                MSpinner: MSpinner,
                MIcon: MIcon
            }
        })
    ], MButton);
    return MButton;
}(Vue));
export { MButton };
var ButtonPlugin = {
    install: function (v, options) {
        v.prototype.$log.debug(BUTTON_NAME, 'plugin.install');
        v.component(BUTTON_NAME, MButton);
    }
};
export default ButtonPlugin;
//# sourceMappingURL=button.js.map