import { ChangeDetectionStrategy, ChangeDetectorRef, Component } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ReactiveFormsModule } from '@angular/forms';
import { FormModelBuilder } from '@anglr/common/forms';
import { FirstUppercaseLocalizeSAPipe } from '@anglr/common';
import { TitledDialogService } from '@anglr/common/material';
import { LayoutEditorMetadataExtractor, PropertiesControlBase } from '@anglr/dynamic/layout-editor';
import { RadioOptionModel } from '../../../metadata/radio.model';
import * as i0 from "@angular/core";
import * as i1 from "@anglr/dynamic/layout-editor";
import * as i2 from "@anglr/common/material";
import * as i3 from "@anglr/common/forms";
import * as i4 from "@angular/common";
import * as i5 from "@angular/forms";
/**
 * Component used for displaying material tab group properties control
 */
export class RadioPropertiesControlSAComponent extends PropertiesControlBase {
    //######################### protected properties #########################
    /**
     * Options control
     */
    get optionsControl() {
        return this.form?.controls.options;
    }
    /**
     * Options control form groups
     */
    get optionsControls() {
        return this.optionsControl?.controls;
    }
    //######################### constructor #########################
    constructor(changeDetector, metadataExtractor, dialog, formModelBuilder) {
        super(changeDetector, metadataExtractor);
        this.dialog = dialog;
        this.formModelBuilder = formModelBuilder;
    }
    //######################### protected methods - template bindings #########################
    /**
     * Adds new tab to tab group
     */
    async addOption() {
        this.optionsControl?.push(this.formModelBuilder.build(new RadioOptionModel()));
    }
    /**
     * Removes tab on specified index in form array
     * @param index Tab index to remove
     */
    removeOption(index) {
        this.optionsControl?.removeAt(index);
    }
}
RadioPropertiesControlSAComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: RadioPropertiesControlSAComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i1.LayoutEditorMetadataExtractor }, { token: i2.TitledDialogService }, { token: i3.FormModelBuilder }], target: i0.ɵɵFactoryTarget.Component });
RadioPropertiesControlSAComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.4", type: RadioPropertiesControlSAComponent, isStandalone: true, selector: "radio-properties-control", usesInheritance: true, ngImport: i0, template: "<div class=\"properties-form-group\">\n    <label class=\"properties-control-label\">{{'options'|firstUppercaseLocalize}}</label>\n    <div>\n        <div class=\"dynamic-flex-row\" *ngFor=\"let tabControl of optionsControls; let i = index\" [formGroup]=\"tabControl\">\n            <div class=\"dynamic-flex-1\">\n                <input class=\"properties-form-control dynamic-flex-1\" type=\"text\" [placeholder]=\"'code'|firstUppercaseLocalize\" formControlName=\"code\">\n                <textarea class=\"properties-form-control dynamic-flex-1\" type=\"text\" [placeholder]=\"'text'|firstUppercaseLocalize\" formControlName=\"text\"></textarea>\n            </div>\n            <button type=\"button\" class=\"dynamic-btn-icon dynamic-margin-horizontal-extra-small\" (click)=\"$event.preventDefault(); $event.stopPropagation(); removeOption(i)\">\n                <span class=\"fas fa-times\"></span>\n            </button>\n        </div>\n        \n        <button type=\"button\" class=\"dynamic-btn dynamic-btn-primary dynamic-margin-vertical-small\" (click)=\"addOption()\">\n            <span>{{'add option'|firstUppercaseLocalize}}</span>\n        </button>\n    </div>\n</div>\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i5.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: i5.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i5.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i5.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i5.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "pipe", type: FirstUppercaseLocalizeSAPipe, name: "firstUppercaseLocalize" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: RadioPropertiesControlSAComponent, decorators: [{
            type: Component,
            args: [{ selector: 'radio-properties-control', standalone: true, imports: [
                        CommonModule,
                        ReactiveFormsModule,
                        FirstUppercaseLocalizeSAPipe,
                    ], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"properties-form-group\">\n    <label class=\"properties-control-label\">{{'options'|firstUppercaseLocalize}}</label>\n    <div>\n        <div class=\"dynamic-flex-row\" *ngFor=\"let tabControl of optionsControls; let i = index\" [formGroup]=\"tabControl\">\n            <div class=\"dynamic-flex-1\">\n                <input class=\"properties-form-control dynamic-flex-1\" type=\"text\" [placeholder]=\"'code'|firstUppercaseLocalize\" formControlName=\"code\">\n                <textarea class=\"properties-form-control dynamic-flex-1\" type=\"text\" [placeholder]=\"'text'|firstUppercaseLocalize\" formControlName=\"text\"></textarea>\n            </div>\n            <button type=\"button\" class=\"dynamic-btn-icon dynamic-margin-horizontal-extra-small\" (click)=\"$event.preventDefault(); $event.stopPropagation(); removeOption(i)\">\n                <span class=\"fas fa-times\"></span>\n            </button>\n        </div>\n        \n        <button type=\"button\" class=\"dynamic-btn dynamic-btn-primary dynamic-margin-vertical-small\" (click)=\"addOption()\">\n            <span>{{'add option'|firstUppercaseLocalize}}</span>\n        </button>\n    </div>\n</div>\n" }]
        }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: i1.LayoutEditorMetadataExtractor }, { type: i2.TitledDialogService }, { type: i3.FormModelBuilder }] });
//# sourceMappingURL=radioPropertiesControl.component.js.map