import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, HostBinding, Input, Output, ViewChild, ElementRef, Renderer2, } from '@angular/core';
export class RRadioComponent {
    constructor(cd, renderer) {
        this.cd = cd;
        this.renderer = renderer;
        this._checked = false;
        this._disabled = false;
        this.status = 'basic';
        this.valueChange = new EventEmitter();
        this.blur = new EventEmitter();
    }
    get name() {
        return this._name;
    }
    set name(value) {
        if (this._name !== value) {
            this._name = value;
        }
    }
    get checked() {
        return this._checked;
    }
    set checked(value) {
        const boolValue = !!value;
        if (this._checked !== boolValue) {
            this._checked = boolValue;
        }
    }
    get value() {
        return this._value;
    }
    set value(value) {
        if (this._value !== value) {
            this._value = value;
        }
    }
    get disabled() {
        return this._disabled;
    }
    set disabled(disabled) {
        const boolValue = !!disabled;
        if (this._disabled !== boolValue) {
            this._disabled = boolValue;
        }
    }
    get isPrimary() {
        return this.status === 'primary';
    }
    get isSuccess() {
        return this.status === 'success';
    }
    get isWarning() {
        return this.status === 'warning';
    }
    get isDanger() {
        return this.status === 'danger';
    }
    get isInfo() {
        return this.status === 'info';
    }
    get isBasic() {
        return this.status === 'basic';
    }
    get isControl() {
        return this.status === 'control';
    }
    onChange(event) {
        event.stopPropagation();
        this.checked = true;
        this.valueChange.emit(this.value);
    }
    onClick(event) {
        event.stopPropagation();
    }
    /*
     * @docs-private
     * We use this method when setting radio inputs from radio group component.
     * Otherwise Angular won't detect changes in radio template as cached last rendered
     * value didn't updated.
     **/
    _markForCheck() {
        this.cd.markForCheck();
    }
    /*
     * @docs-private
     * Use this method when setting radio name from radio group component.
     * In case option 'name' isn't set on r-radio component we need to set name
     * right away, so it won't overlap with options without names from other radio
     * groups. Otherwise they all would have same name and will be considered as
     * options from one group so only the last option will stay selected.
     **/
    _setName(name) {
        this.name = name;
        if (this.input) {
            this.renderer.setProperty(this.input.nativeElement, 'name', name);
        }
    }
}
RRadioComponent.decorators = [
    { type: Component, args: [{
                selector: 'r-radio',
                template: `
    <label>
      <input
        #input
        type="radio"
        class="native-input visually-hidden"
        [name]="name"
        [value]="value"
        [checked]="checked"
        [disabled]="disabled"
        (change)="onChange($event)"
        (click)="onClick($event)">
      <span class="outer-circle"></span>
      <span class="inner-circle"></span>
      <span class="text">
        <ng-content></ng-content>
      </span>
    </label>
  `,
                changeDetection: ChangeDetectionStrategy.OnPush,
                styles: [":host{display:block;position:relative}:host label{display:inline-flex;margin:0;min-height:inherit;padding:.375rem 1.5rem .375rem 0;align-items:center}:host .inner-circle,:host .outer-circle{border-radius:50%;position:absolute;top:50%;left:0;transform:translateY(-50%)}:host .inner-circle{left:1px;transition:transform,background-color .15s ease;transform:translateY(-50%) scale(.6)}:host .text{padding-left:.5rem}"]
            },] }
];
RRadioComponent.ctorParameters = () => [
    { type: ChangeDetectorRef },
    { type: Renderer2 }
];
RRadioComponent.propDecorators = {
    name: [{ type: Input }],
    checked: [{ type: Input }],
    value: [{ type: Input }],
    disabled: [{ type: Input }],
    status: [{ type: Input }],
    valueChange: [{ type: Output }],
    blur: [{ type: Output }],
    input: [{ type: ViewChild, args: ['input', { read: ElementRef },] }],
    isPrimary: [{ type: HostBinding, args: ['class.status-primary',] }],
    isSuccess: [{ type: HostBinding, args: ['class.status-success',] }],
    isWarning: [{ type: HostBinding, args: ['class.status-warning',] }],
    isDanger: [{ type: HostBinding, args: ['class.status-danger',] }],
    isInfo: [{ type: HostBinding, args: ['class.status-info',] }],
    isBasic: [{ type: HostBinding, args: ['class.status-basic',] }],
    isControl: [{ type: HostBinding, args: ['class.status-control',] }]
};
//# sourceMappingURL=radio.component.js.map