import { __decorate, __metadata } from "tslib";
import { ChangeDetectionStrategy, Component, Injector, TemplateRef, ViewChild } from '@angular/core';
import { ReactiveFormsModule, Validators } from '@angular/forms';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { MatTooltipModule } from '@angular/material/tooltip';
import { OMatErrorDirective } from '../../../../../directives/o-mat-error.directive';
import { OTranslatePipe } from '../../../../../pipes/o-translate.pipe';
import { NumberInputConverter } from '../../../../../decorators/input-converter';
import { Util } from '../../../../../util/util';
import { OTableCellEditorIntegerComponent } from '../integer/o-table-cell-editor-integer.component';
import * as i0 from "@angular/core";
import * as i1 from "@angular/forms";
import * as i2 from "@angular/material/form-field";
import * as i3 from "@angular/material/input";
import * as i4 from "@angular/material/tooltip";
export class OTableCellEditorRealComponent extends OTableCellEditorIntegerComponent {
    constructor(injector) {
        super(injector);
        this.injector = injector;
        this.step = 0.01;
    }
    getCellData() {
        const cellData = super.getCellData();
        const floatValue = parseFloat(cellData?.toString());
        return isNaN(floatValue) ? undefined : floatValue;
    }
    resolveValidators() {
        const validators = super.resolveValidators();
        if (Util.isDefined(this.min)) {
            validators.push(Validators.min(this.min));
        }
        if (Util.isDefined(this.max)) {
            validators.push(Validators.max(this.max));
        }
        return validators;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: OTableCellEditorRealComponent, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: OTableCellEditorRealComponent, isStandalone: true, selector: "o-table-cell-editor-real", viewQueries: [{ propertyName: "templateref", first: true, predicate: ["templateref"], descendants: true, read: TemplateRef, static: true }], usesInheritance: true, ngImport: i0, template: "<ng-template #templateref let-cellvalue=\"cellvalue\" let-rowvalue=\"rowvalue\">\n  <div class=\"o-table-cell-editor-real o-table-cell-editor\" [formGroup]=\"formGroup\"\n    [matTooltip]=\"tooltip\"\n    [matTooltipClass]=\"tooltipClass\"\n    [matTooltipPosition]=\"tooltipPosition\"\n    [matTooltipShowDelay]=\"tooltipShowDelay\"\n    [matTooltipHideDelay]=\"tooltipHideDelay\">\n    <mat-form-field cdkFocusInitial>\n\n      <input #input matInput type=\"number\" [placeholder]=\"getPlaceholder()\" [formControl]=\"formControl\"\n        [required]=\"orequired\" [min]=\"min\" [max]=\"max\" [step]=\"step\" [id]=\"cellEditorId\">\n\n        <mat-error *oMatError=\"hasError('required')\">\n          {{ 'FORM_VALIDATION.REQUIRED' | oTranslate }}\n        </mat-error>\n        <mat-error *oMatError=\"hasError('min')\">\n          {{ 'FORM_VALIDATION.MIN_VALUE' | oTranslate }}: {{ getErrorValue('min', 'min') }}\n        </mat-error>\n        <mat-error *oMatError=\"hasError('max')\">\n          {{ 'FORM_VALIDATION.MAX_VALUE' | oTranslate }}: {{ getErrorValue('max', 'max') }}\n        </mat-error>\n        @for (oError of getActiveOErrors(); track oError) {\n          <mat-error>\n            {{ getErrorText(oError) }}\n          </mat-error>\n        }\n      </mat-form-field>\n    </div>\n  </ng-template>\n", dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { 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.NumberValueAccessor, selector: "input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.MinValidator, selector: "input[type=number][min][formControlName],input[type=number][min][formControl],input[type=number][min][ngModel]", inputs: ["min"] }, { kind: "directive", type: i1.MaxValidator, selector: "input[type=number][max][formControlName],input[type=number][max][formControl],input[type=number][max][ngModel]", inputs: ["max"] }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "component", type: i2.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i2.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i3.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl],      input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "directive", type: i4.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "pipe", type: OTranslatePipe, name: "oTranslate" }, { kind: "directive", type: OMatErrorDirective, selector: "[oMatError]", inputs: ["oMatError"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
__decorate([
    NumberInputConverter(),
    __metadata("design:type", Number)
], OTableCellEditorRealComponent.prototype, "min", void 0);
__decorate([
    NumberInputConverter(),
    __metadata("design:type", Number)
], OTableCellEditorRealComponent.prototype, "max", void 0);
__decorate([
    NumberInputConverter(),
    __metadata("design:type", Number)
], OTableCellEditorRealComponent.prototype, "step", void 0);
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: OTableCellEditorRealComponent, decorators: [{
            type: Component,
            args: [{ standalone: true, imports: [ReactiveFormsModule, MatFormFieldModule, MatInputModule, MatTooltipModule, OTranslatePipe, OMatErrorDirective], selector: 'o-table-cell-editor-real', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-template #templateref let-cellvalue=\"cellvalue\" let-rowvalue=\"rowvalue\">\n  <div class=\"o-table-cell-editor-real o-table-cell-editor\" [formGroup]=\"formGroup\"\n    [matTooltip]=\"tooltip\"\n    [matTooltipClass]=\"tooltipClass\"\n    [matTooltipPosition]=\"tooltipPosition\"\n    [matTooltipShowDelay]=\"tooltipShowDelay\"\n    [matTooltipHideDelay]=\"tooltipHideDelay\">\n    <mat-form-field cdkFocusInitial>\n\n      <input #input matInput type=\"number\" [placeholder]=\"getPlaceholder()\" [formControl]=\"formControl\"\n        [required]=\"orequired\" [min]=\"min\" [max]=\"max\" [step]=\"step\" [id]=\"cellEditorId\">\n\n        <mat-error *oMatError=\"hasError('required')\">\n          {{ 'FORM_VALIDATION.REQUIRED' | oTranslate }}\n        </mat-error>\n        <mat-error *oMatError=\"hasError('min')\">\n          {{ 'FORM_VALIDATION.MIN_VALUE' | oTranslate }}: {{ getErrorValue('min', 'min') }}\n        </mat-error>\n        <mat-error *oMatError=\"hasError('max')\">\n          {{ 'FORM_VALIDATION.MAX_VALUE' | oTranslate }}: {{ getErrorValue('max', 'max') }}\n        </mat-error>\n        @for (oError of getActiveOErrors(); track oError) {\n          <mat-error>\n            {{ getErrorText(oError) }}\n          </mat-error>\n        }\n      </mat-form-field>\n    </div>\n  </ng-template>\n" }]
        }], ctorParameters: () => [{ type: i0.Injector }], propDecorators: { templateref: [{
                type: ViewChild,
                args: ['templateref', { read: TemplateRef, static: true }]
            }], min: [], max: [], step: [] } });
//# sourceMappingURL=data:application/json;base64, 