/* eslint-disable @angular-eslint/no-output-on-prefix */
import { Component, EventEmitter, Input, Output, ViewEncapsulation } from '@angular/core';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import * as i0 from "@angular/core";
import * as i1 from "@seniorsistemas/angular-components/button";
import * as i2 from "@angular/common";
import * as i3 from "@angular/forms";
import * as i4 from "@seniorsistemas/angular-components/tooltip";
import * as i5 from "@seniorsistemas/angular-components/radio-button";
import * as i6 from "../../../components/field-label/field-label.component";
export class RadioButtonFieldComponent {
    field;
    formControl;
    onClick = new EventEmitter();
    onFocus = new EventEmitter();
    _ngUnsubscribe = new Subject();
    ngOnInit() {
        this.onFocus.pipe(takeUntil(this._ngUnsubscribe)).subscribe((event) => {
            if (this.field.onFocus)
                this.field.onFocus(event);
        });
        this.onClick.pipe(takeUntil(this._ngUnsubscribe)).subscribe((event) => {
            if (this.field.onClick)
                this.field.onClick(event);
        });
    }
    ngOnDestroy() {
        this._ngUnsubscribe.next();
        this._ngUnsubscribe.complete();
    }
    onClear() {
        this.formControl.reset();
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: RadioButtonFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: RadioButtonFieldComponent, selector: "ng-component", inputs: { field: "field", formControl: "formControl" }, outputs: { onClick: "onClick", onFocus: "onFocus" }, ngImport: i0, template: "<s-field-label [field]=\"field\"></s-field-label>\n\n@if (field.verticalAlignment) {\n    <div class=\"ui-g\">\n        @for (option of field.options; let i = $index; track i) {\n            <div class=\"ui-g-12\">\n                <ng-container\n                    [ngTemplateOutlet]=\"radioButton\"\n                    [ngTemplateOutletContext]=\"{ option: option, index: i }\"\n                >\n                </ng-container>\n            </div>\n        }\n        @if (field.showClear && field.required && !field.required() && !formControl.disabled) {\n            <s-button\n                [label]=\"field.clearLabel || 'Clear selection'\"\n                (clicked)=\"onClear()\"\n                priority=\"link\"\n            >\n            </s-button>\n        }\n    </div>\n} @else {\n    <div class=\"ui-g horizontal-radio-buttons-container\">\n        @for (option of field.options; let i = $index; track i) {\n            <ng-container\n                [ngTemplateOutlet]=\"radioButton\"\n                [ngTemplateOutletContext]=\"{ option: option, index: i }\"\n            >\n            </ng-container>\n        }\n    </div>\n    @if (field.showClear && field.required && !field.required() && !formControl.disabled) {\n        <s-button\n            class=\"horizontal-clear-option\"\n            [label]=\"field.clearLabel || 'Clear selection'\"\n            (clicked)=\"onClear()\"\n            priority=\"link\"\n        >\n        </s-button>\n    }\n}\n\n<ng-template\n    #radioButton\n    let-option=\"option\"\n    let-i=\"index\"\n>\n    @let inputId = (field.id || field.name) + '-' + i;\n    <s-radiobutton\n        class=\"radio-button-item\"\n        [name]=\"field.name\"\n        [value]=\"option.value\"\n        [formControl]=\"formControl\"\n        [inputId]=\"inputId\"\n        [sTooltip]=\"field.tooltip\"\n        [label]=\"option.label\"\n        (focusedInput)=\"onFocus.next($event)\"\n        (inputFocusLost)=\"field.onBlur ? field.onBlur($event) : null\"\n    />\n</ng-template>\n", styles: ["s-button.horizontal-clear-option button{width:min-content!important}.horizontal-radio-buttons-container{gap:20px 40px;.radio-button-item{margin:0}}\n"], dependencies: [{ kind: "component", type: i1.ButtonComponent, selector: "s-button", inputs: ["id", "label", "tooltip", "tooltipPosition", "iconClass", "rightIconClass", "caret", "styleClass", "baseZIndex", "disabled", "auxiliary", "type", "priority", "menuOptions", "size", "slide", "animation", "badge", "iconColor"], outputs: ["clicked"] }, { kind: "directive", type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i4.TooltipDirective, selector: "[sTooltip]", inputs: ["sTooltip", "tooltipPosition", "showDelay", "displayTime", "tooltipEvent", "escape", "visible", "mobileBehavior", "focusedInputRef", "checkTruncatedText"] }, { kind: "component", type: i5.RadioButtonComponent, selector: "s-radiobutton", inputs: ["buttonDisabled", "label", "name", "value", "inputId"], outputs: ["buttonDisabledChange", "valueChange", "focusedInput", "inputFocusLost"] }, { kind: "component", type: i6.FieldLabelComponent, selector: "s-field-label", inputs: ["field", "fieldContainerRef"] }], encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: RadioButtonFieldComponent, decorators: [{
            type: Component,
            args: [{ encapsulation: ViewEncapsulation.None, template: "<s-field-label [field]=\"field\"></s-field-label>\n\n@if (field.verticalAlignment) {\n    <div class=\"ui-g\">\n        @for (option of field.options; let i = $index; track i) {\n            <div class=\"ui-g-12\">\n                <ng-container\n                    [ngTemplateOutlet]=\"radioButton\"\n                    [ngTemplateOutletContext]=\"{ option: option, index: i }\"\n                >\n                </ng-container>\n            </div>\n        }\n        @if (field.showClear && field.required && !field.required() && !formControl.disabled) {\n            <s-button\n                [label]=\"field.clearLabel || 'Clear selection'\"\n                (clicked)=\"onClear()\"\n                priority=\"link\"\n            >\n            </s-button>\n        }\n    </div>\n} @else {\n    <div class=\"ui-g horizontal-radio-buttons-container\">\n        @for (option of field.options; let i = $index; track i) {\n            <ng-container\n                [ngTemplateOutlet]=\"radioButton\"\n                [ngTemplateOutletContext]=\"{ option: option, index: i }\"\n            >\n            </ng-container>\n        }\n    </div>\n    @if (field.showClear && field.required && !field.required() && !formControl.disabled) {\n        <s-button\n            class=\"horizontal-clear-option\"\n            [label]=\"field.clearLabel || 'Clear selection'\"\n            (clicked)=\"onClear()\"\n            priority=\"link\"\n        >\n        </s-button>\n    }\n}\n\n<ng-template\n    #radioButton\n    let-option=\"option\"\n    let-i=\"index\"\n>\n    @let inputId = (field.id || field.name) + '-' + i;\n    <s-radiobutton\n        class=\"radio-button-item\"\n        [name]=\"field.name\"\n        [value]=\"option.value\"\n        [formControl]=\"formControl\"\n        [inputId]=\"inputId\"\n        [sTooltip]=\"field.tooltip\"\n        [label]=\"option.label\"\n        (focusedInput)=\"onFocus.next($event)\"\n        (inputFocusLost)=\"field.onBlur ? field.onBlur($event) : null\"\n    />\n</ng-template>\n", styles: ["s-button.horizontal-clear-option button{width:min-content!important}.horizontal-radio-buttons-container{gap:20px 40px;.radio-button-item{margin:0}}\n"] }]
        }], propDecorators: { field: [{
                type: Input,
                args: [{ required: true }]
            }], formControl: [{
                type: Input,
                args: [{ required: true }]
            }], onClick: [{
                type: Output
            }], onFocus: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64, 