var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { Input, Directive } from '@angular/core';
import { CaseField } from '../../../domain/definition';
import { FormGroup } from '@angular/forms';
var AbstractFormFieldComponent = /** @class */ (function () {
    function AbstractFormFieldComponent() {
    }
    AbstractFormFieldComponent.prototype.defaultControlRegister = function () {
        var _this = this;
        return function (control) {
            if (!_this.formGroup) {
                return null;
            }
            if (_this.formGroup.controls[_this.caseField.id]) {
                return _this.formGroup.get(_this.caseField.id);
            }
            _this.addValidators(_this.caseField, control);
            _this.formGroup.addControl(_this.caseField.id, control);
            return control;
        };
    };
    AbstractFormFieldComponent.prototype.addValidators = function (caseField, control) {
        // No validators by default, override this method to add validators to the form control
    };
    __decorate([
        Input(),
        __metadata("design:type", CaseField)
    ], AbstractFormFieldComponent.prototype, "caseField", void 0);
    __decorate([
        Input(),
        __metadata("design:type", FormGroup)
    ], AbstractFormFieldComponent.prototype, "formGroup", void 0);
    __decorate([
        Input(),
        __metadata("design:type", Function)
    ], AbstractFormFieldComponent.prototype, "registerControl", void 0);
    AbstractFormFieldComponent = __decorate([
        Directive()
    ], AbstractFormFieldComponent);
    return AbstractFormFieldComponent;
}());
export { AbstractFormFieldComponent };
//# sourceMappingURL=abstract-form-field.component.js.map