import { MXValueComponent, AXComponent } from '@acorex/cdk/common';
import { AXLabelComponent } from '@acorex/components/label';
import * as i0 from '@angular/core';
import { forwardRef, HostListener, ContentChildren, ViewEncapsulation, ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
import * as i1 from '@angular/forms';
import { FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
import { CommonModule } from '@angular/common';

/**
 * The Button is a component which detects user interaction and triggers a corresponding event
 *
 * @category
 */
class AXRadioComponent extends MXValueComponent {
    /** @ignore */
    ngAfterViewChecked() {
        this._labels?.forEach((c) => {
            c.for = this;
        });
    }
    /** @ignore */
    _handleClick(e) {
        e.stopPropagation();
        if (this.readonly || this.disabled) {
            e.preventDefault();
            return false;
        }
        return true;
    }
    /** @ignore */
    _handleModelChange(value) {
        this.commitValue(value, true);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: AXRadioComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.16", type: AXRadioComponent, isStandalone: true, selector: "ax-radio", inputs: { disabled: "disabled", tabIndex: "tabIndex", readonly: "readonly", value: "value", name: "name", id: "id" }, outputs: { onBlur: "onBlur", onFocus: "onFocus", valueChange: "valueChange", onValueChanged: "onValueChanged" }, host: { listeners: { "click": "_handleClick($event)" } }, providers: [
            {
                provide: NG_VALUE_ACCESSOR,
                useExisting: forwardRef(() => AXRadioComponent),
                multi: true,
            },
            { provide: AXComponent, useExisting: AXRadioComponent },
        ], queries: [{ propertyName: "_labels", predicate: AXLabelComponent }], usesInheritance: true, ngImport: i0, template: "<div class=\"ax-radio-label\" [class.ax-state-readonly]=\"readonly\" [class.ax-state-disabled]=\"disabled\">\n  <div class=\"ax-radio-start-side\">\n    <input\n      [id]=\"id\"\n      class=\"ax-radio\"\n      type=\"radio\"\n      [ngModel]=\"value\"\n      [checked]=\"value\"\n      [disabled]=\"disabled\"\n      [readonly]=\"readonly\"\n      [tabindex]=\"tabIndex\"\n      (ngModelChange)=\"_handleModelChange($event)\"\n      (focus)=\"emitOnFocusEvent($event)\"\n      (blur)=\"emitOnBlurEvent($event)\"\n    />\n  </div>\n  <div class=\"ax-radio-end-side\">\n    <ng-content select=\"ax-label\"></ng-content>\n    <ng-content select=\"ax-form-hint\"></ng-content>\n    <span class=\"ax-error-container\"></span>\n  </div>\n</div>\n<ng-content select=\"ax-validation-rule\"></ng-content>\n", styles: [".ax-radio-label{display:flex;width:fit-content;-webkit-user-select:none;user-select:none;align-items:flex-start;font-size:.875rem;line-height:1.25rem}.ax-radio-label.ax-state-readonly{opacity:.75}.ax-radio-label .ax-radio-start-side{display:flex;height:1.25rem;align-items:center}.ax-radio-label .ax-radio-end-side{margin-inline-start:.75rem}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.RadioControlValueAccessor, selector: "input[type=radio][formControlName],input[type=radio][formControl],input[type=radio][ngModel]", inputs: ["name", "formControlName", "value"] }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: AXRadioComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ax-radio', inputs: ['disabled', 'tabIndex', 'readonly', 'value', 'name', 'id'], outputs: ['onBlur', 'onFocus', 'valueChange', 'onValueChanged'], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, providers: [
                        {
                            provide: NG_VALUE_ACCESSOR,
                            useExisting: forwardRef(() => AXRadioComponent),
                            multi: true,
                        },
                        { provide: AXComponent, useExisting: AXRadioComponent },
                    ], imports: [FormsModule], template: "<div class=\"ax-radio-label\" [class.ax-state-readonly]=\"readonly\" [class.ax-state-disabled]=\"disabled\">\n  <div class=\"ax-radio-start-side\">\n    <input\n      [id]=\"id\"\n      class=\"ax-radio\"\n      type=\"radio\"\n      [ngModel]=\"value\"\n      [checked]=\"value\"\n      [disabled]=\"disabled\"\n      [readonly]=\"readonly\"\n      [tabindex]=\"tabIndex\"\n      (ngModelChange)=\"_handleModelChange($event)\"\n      (focus)=\"emitOnFocusEvent($event)\"\n      (blur)=\"emitOnBlurEvent($event)\"\n    />\n  </div>\n  <div class=\"ax-radio-end-side\">\n    <ng-content select=\"ax-label\"></ng-content>\n    <ng-content select=\"ax-form-hint\"></ng-content>\n    <span class=\"ax-error-container\"></span>\n  </div>\n</div>\n<ng-content select=\"ax-validation-rule\"></ng-content>\n", styles: [".ax-radio-label{display:flex;width:fit-content;-webkit-user-select:none;user-select:none;align-items:flex-start;font-size:.875rem;line-height:1.25rem}.ax-radio-label.ax-state-readonly{opacity:.75}.ax-radio-label .ax-radio-start-side{display:flex;height:1.25rem;align-items:center}.ax-radio-label .ax-radio-end-side{margin-inline-start:.75rem}\n"] }]
        }], propDecorators: { _labels: [{
                type: ContentChildren,
                args: [AXLabelComponent]
            }], _handleClick: [{
                type: HostListener,
                args: ['click', ['$event']]
            }] } });

const COMPONENT = [AXRadioComponent];
const MODULES = [CommonModule, FormsModule];
class AXRadioModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: AXRadioModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.16", ngImport: i0, type: AXRadioModule, imports: [CommonModule, FormsModule, AXRadioComponent], exports: [AXRadioComponent] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: AXRadioModule, imports: [MODULES, COMPONENT] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: AXRadioModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [...MODULES, ...COMPONENT],
                    exports: [...COMPONENT],
                    providers: [],
                }]
        }] });

/**
 * Generated bundle index. Do not edit.
 */

export { AXRadioComponent, AXRadioModule };
//# sourceMappingURL=acorex-components-radio.mjs.map
