import { __decorate } from "tslib";
import { mixinLoad, mixinDisabled } from '@bravobit/bb-foundation';
import { ChangeDetectionStrategy, Component, ElementRef, Input, ViewEncapsulation } from '@angular/core';
class BbButtonBase {
    constructor(_elementRef) {
        this._elementRef = _elementRef;
    }
}
const BbButtonMixinBase = mixinDisabled(mixinLoad(BbButtonBase));
let BbButton = class BbButton extends BbButtonMixinBase {
    constructor(_elementRef) {
        super(_elementRef);
    }
    get nativeElement() {
        return this._elementRef.nativeElement;
    }
    focus() {
        this.nativeElement && this.nativeElement.focus();
    }
};
BbButton.ctorParameters = () => [
    { type: ElementRef }
];
BbButton = __decorate([
    Component({
        selector: 'button[bb-button]',
        template: "<bb-spinner [class.visible]=\"loading\"\n            class=\"bb-button-spinner small\">\n</bb-spinner>\n\n<ng-content></ng-content>\n",
        exportAs: 'bbButton',
        host: {
            'class': 'bb-button',
            '[class.loading]': 'loading',
            '[attr.disabled]': 'disabled || loading || null'
        },
        inputs: ['disabled', 'loading'],
        encapsulation: ViewEncapsulation.None,
        changeDetection: ChangeDetectionStrategy.OnPush,
        styles: [".bb-button{height:38px;padding:0 8px;cursor:pointer;font-size:16px;font-weight:500;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;position:relative;font-style:normal;border-radius:4px;text-align:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;text-decoration:none;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;background-color:#fff;color:#2d3c4d!important;border:1px solid #d4d8e1;-webkit-transition-duration:.2s;transition-duration:.2s;box-shadow:0 6px 6px -6px rgba(0,0,0,.1);-webkit-transition-timing-function:cubic-bezier(0,0,.2,1);transition-timing-function:cubic-bezier(0,0,.2,1);-webkit-transition-property:padding-left,background-color,box-shadow;transition-property:padding-left,background-color,box-shadow}.bb-button:hover{background-color:#fcfcfb}.bb-button:active,.bb-button:focus{box-shadow:0 6px 6px -6px rgba(0,0,0,.1),0 0 0 3px rgba(220,224,233,.5)}.bb-button.full{width:100%}.bb-button.full.loading{padding-left:42px}.bb-button.primary{border-color:#2f2b85;color:#fff!important;background-color:#5b53ff}.bb-button.primary:hover{background-color:#564ee6}.bb-button.primary:active,.bb-button.primary:focus{box-shadow:0 6px 6px -6px rgba(0,0,0,.1),0 0 0 3px rgba(91,83,255,.5)}.bb-button.destructive{border-color:#8f2020;color:#fff!important;background-color:#d32f2f}.bb-button.destructive:hover{background-color:#c32929}.bb-button.destructive:active,.bb-button.destructive:focus{box-shadow:0 6px 6px -6px rgba(0,0,0,.1),0 0 0 3px rgba(211,47,47,.5)}.bb-button.loading,.bb-button.loading:active,.bb-button.loading:focus,.bb-button.loading:hover,.bb-button:disabled,.bb-button:disabled:active,.bb-button:disabled:focus,.bb-button:disabled:hover,.bb-button[disabled],.bb-button[disabled]:active,.bb-button[disabled]:focus,.bb-button[disabled]:hover{opacity:.4;cursor:default;box-shadow:none}.bb-button-spinner{width:0;opacity:0;overflow:hidden;visibility:hidden;padding:0!important;-webkit-transition:width .2s cubic-bezier(0,0,.2,1),opacity .1s cubic-bezier(0,0,.2,1);transition:width .2s cubic-bezier(0,0,.2,1),opacity .1s cubic-bezier(0,0,.2,1)}.bb-button-spinner.visible{opacity:1;width:20px;margin-right:8px;visibility:visible}.bb-button.loading.full>.bb-button-spinner{left:8px;margin-right:0;position:absolute}"]
    })
], BbButton);
export { BbButton };
let BbAnchor = class BbAnchor extends BbButton {
    constructor(_elementRef) {
        super(_elementRef);
    }
    stopDisabledEvents(event) {
        // If the button is not disabled (and not loading) let all events pass.
        if (!this.disabled && !this.loading) {
            return;
        }
        // If the button is disabled and/or loading stop
        // the event from bubbling up.
        event.preventDefault();
        event.stopImmediatePropagation();
    }
};
BbAnchor.ctorParameters = () => [
    { type: ElementRef }
];
__decorate([
    Input()
], BbAnchor.prototype, "tabIndex", void 0);
BbAnchor = __decorate([
    Component({
        selector: 'a[bb-button]',
        template: "<bb-spinner [class.visible]=\"loading\"\n            class=\"bb-button-spinner small\">\n</bb-spinner>\n\n<ng-content></ng-content>\n",
        exportAs: 'bbButton, bbAnchor',
        host: {
            'class': 'bb-button',
            '[attr.tabindex]': '(disabled || loading) ? -1 : (tabIndex || 0)',
            '[attr.disabled]': 'disabled || loading || null',
            '[attr.aria-disabled]': '(disabled || loading).toString()',
            '(click)': 'stopDisabledEvents($event)'
        },
        inputs: ['disabled', 'loading'],
        encapsulation: ViewEncapsulation.None,
        changeDetection: ChangeDetectionStrategy.OnPush,
        styles: [".bb-button{height:38px;padding:0 8px;cursor:pointer;font-size:16px;font-weight:500;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;position:relative;font-style:normal;border-radius:4px;text-align:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;text-decoration:none;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;background-color:#fff;color:#2d3c4d!important;border:1px solid #d4d8e1;-webkit-transition-duration:.2s;transition-duration:.2s;box-shadow:0 6px 6px -6px rgba(0,0,0,.1);-webkit-transition-timing-function:cubic-bezier(0,0,.2,1);transition-timing-function:cubic-bezier(0,0,.2,1);-webkit-transition-property:padding-left,background-color,box-shadow;transition-property:padding-left,background-color,box-shadow}.bb-button:hover{background-color:#fcfcfb}.bb-button:active,.bb-button:focus{box-shadow:0 6px 6px -6px rgba(0,0,0,.1),0 0 0 3px rgba(220,224,233,.5)}.bb-button.full{width:100%}.bb-button.full.loading{padding-left:42px}.bb-button.primary{border-color:#2f2b85;color:#fff!important;background-color:#5b53ff}.bb-button.primary:hover{background-color:#564ee6}.bb-button.primary:active,.bb-button.primary:focus{box-shadow:0 6px 6px -6px rgba(0,0,0,.1),0 0 0 3px rgba(91,83,255,.5)}.bb-button.destructive{border-color:#8f2020;color:#fff!important;background-color:#d32f2f}.bb-button.destructive:hover{background-color:#c32929}.bb-button.destructive:active,.bb-button.destructive:focus{box-shadow:0 6px 6px -6px rgba(0,0,0,.1),0 0 0 3px rgba(211,47,47,.5)}.bb-button.loading,.bb-button.loading:active,.bb-button.loading:focus,.bb-button.loading:hover,.bb-button:disabled,.bb-button:disabled:active,.bb-button:disabled:focus,.bb-button:disabled:hover,.bb-button[disabled],.bb-button[disabled]:active,.bb-button[disabled]:focus,.bb-button[disabled]:hover{opacity:.4;cursor:default;box-shadow:none}.bb-button-spinner{width:0;opacity:0;overflow:hidden;visibility:hidden;padding:0!important;-webkit-transition:width .2s cubic-bezier(0,0,.2,1),opacity .1s cubic-bezier(0,0,.2,1);transition:width .2s cubic-bezier(0,0,.2,1),opacity .1s cubic-bezier(0,0,.2,1)}.bb-button-spinner.visible{opacity:1;width:20px;margin-right:8px;visibility:visible}.bb-button.loading.full>.bb-button-spinner{left:8px;margin-right:0;position:absolute}"]
    })
], BbAnchor);
export { BbAnchor };
//# sourceMappingURL=data:application/json;base64, 