import { Component, Input, ViewChild, inject } from "@angular/core";
import { FormGroup } from "@angular/forms";
import { Calendar } from "primeng/calendar";
import { first } from "rxjs/operators";
import { LocaleService } from "@seniorsistemas/angular-components/locale";
import * as i0 from "@angular/core";
import * as i1 from "@angular/forms";
import * as i2 from "primeng/datepicker";
export class InlineEditCalendarComponent {
    localeService = inject(LocaleService);
    field;
    formGroup = new FormGroup({});
    calendar = null;
    tempValue = '';
    calendarLocaleOptions = null;
    ngOnInit() {
        this._getLocaleOptions();
        if (this.formGroup && this.field) {
            this.tempValue = this.formGroup.get(this.field.name)?.value || '';
        }
    }
    saveValue() {
        if (this.formGroup && this.field) {
            this.formGroup.get(this.field.name)?.setValue(this.tempValue);
        }
    }
    getValueAsText() {
        return this.calendar?.el.nativeElement.querySelector('input').value ?? '';
    }
    _getLocaleOptions() {
        this.localeService.get().pipe(first()).subscribe((locale) => {
            this.calendarLocaleOptions = locale.calendar;
        });
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: InlineEditCalendarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.14", type: InlineEditCalendarComponent, selector: "ng-component", inputs: { field: "field", formGroup: "formGroup" }, viewQueries: [{ propertyName: "calendar", first: true, predicate: Calendar, descendants: true }], ngImport: i0, template: "<!-- Este componente utilizava a diretiva: sCalendarMask, verificar se ainda \u00E9 necess\u00E1rio -->\n<p-datepicker\n    #calendar\n    [inputId]=\"field.name\"\n    [name]=\"field.name\"\n    [showIcon]=\"true\"\n    [selectionMode]=\"field.selectionMode\"\n    [rangeSeparator]=\"field.rangeSeparator ? field.rangeSeparator : calendar.rangeSeparator\"\n    [showSeconds]=\"field.showSeconds\"\n    [showOnFocus]=\"field.showOnFocus\"\n    icon=\"fa fa-calendar\"\n    [minDate]=\"field.minDate\"\n    [maxDate]=\"field.maxDate\"\n    [dateFormat]=\"calendarLocaleOptions?.dateFormat ?? calendar.dateFormat\"\n    [hourFormat]=\"calendarLocaleOptions?.hourFormat ?? calendar.hourFormat\"\n    [defaultDate]=\"field.defaultDate ? field.defaultDate : calendar.defaultDate\"\n    [view]=\"field.view ? field.view : calendar.view\"\n    [placeholder]=\"field.placeholder\"\n    inputStyleClass=\"mousetrap\"\n    [appendTo]=\"field.appendTo\"\n    (onBlur)=\"field.onBlur ? field.onBlur($event) : null\"\n    (onFocus)=\"field.onFocus ? field.onFocus($event) : null\"\n    (onSelect)=\"field.onSelect ? field.onSelect($event) : null\"\n    (onClose)=\"field.onClose ? field.onClose($event) : null\"\n    (onTodayClick)=\"field.onTodayClick ? field.onTodayClick($event) : null\"\n    (onClearClick)=\"field.onClearClick ? field.onClearClick($event) : null\"\n    (onMonthChange)=\"field.onMonthChange ? field.onMonthChange($event) : null\"\n    (onYearChange)=\"field.onYearChange ? field.onYearChange($event) : null\"\n    [showTransitionOptions]=\"'0ms'\"\n    [hideTransitionOptions]=\"'0ms'\"\n    [(ngModel)]=\"tempValue\">\n</p-datepicker>\n", styles: [""], dependencies: [{ 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"] }, { kind: "component", type: i2.DatePicker, selector: "p-datePicker, p-datepicker, p-date-picker", inputs: ["iconDisplay", "style", "styleClass", "inputStyle", "inputId", "name", "inputStyleClass", "placeholder", "ariaLabelledBy", "ariaLabel", "iconAriaLabel", "disabled", "dateFormat", "multipleSeparator", "rangeSeparator", "inline", "showOtherMonths", "selectOtherMonths", "showIcon", "fluid", "icon", "appendTo", "readonlyInput", "shortYearCutoff", "monthNavigator", "yearNavigator", "hourFormat", "timeOnly", "stepHour", "stepMinute", "stepSecond", "showSeconds", "required", "showOnFocus", "showWeek", "startWeekFromFirstDayOfYear", "showClear", "dataType", "selectionMode", "maxDateCount", "showButtonBar", "todayButtonStyleClass", "clearButtonStyleClass", "autofocus", "autoZIndex", "baseZIndex", "panelStyleClass", "panelStyle", "keepInvalid", "hideOnDateTimeSelect", "touchUI", "timeSeparator", "focusTrap", "showTransitionOptions", "hideTransitionOptions", "tabindex", "variant", "size", "minDate", "maxDate", "disabledDates", "disabledDays", "yearRange", "showTime", "responsiveOptions", "numberOfMonths", "firstDayOfWeek", "locale", "view", "defaultDate"], outputs: ["onFocus", "onBlur", "onClose", "onSelect", "onClear", "onInput", "onTodayClick", "onClearClick", "onMonthChange", "onYearChange", "onClickOutside", "onShow"] }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: InlineEditCalendarComponent, decorators: [{
            type: Component,
            args: [{ template: "<!-- Este componente utilizava a diretiva: sCalendarMask, verificar se ainda \u00E9 necess\u00E1rio -->\n<p-datepicker\n    #calendar\n    [inputId]=\"field.name\"\n    [name]=\"field.name\"\n    [showIcon]=\"true\"\n    [selectionMode]=\"field.selectionMode\"\n    [rangeSeparator]=\"field.rangeSeparator ? field.rangeSeparator : calendar.rangeSeparator\"\n    [showSeconds]=\"field.showSeconds\"\n    [showOnFocus]=\"field.showOnFocus\"\n    icon=\"fa fa-calendar\"\n    [minDate]=\"field.minDate\"\n    [maxDate]=\"field.maxDate\"\n    [dateFormat]=\"calendarLocaleOptions?.dateFormat ?? calendar.dateFormat\"\n    [hourFormat]=\"calendarLocaleOptions?.hourFormat ?? calendar.hourFormat\"\n    [defaultDate]=\"field.defaultDate ? field.defaultDate : calendar.defaultDate\"\n    [view]=\"field.view ? field.view : calendar.view\"\n    [placeholder]=\"field.placeholder\"\n    inputStyleClass=\"mousetrap\"\n    [appendTo]=\"field.appendTo\"\n    (onBlur)=\"field.onBlur ? field.onBlur($event) : null\"\n    (onFocus)=\"field.onFocus ? field.onFocus($event) : null\"\n    (onSelect)=\"field.onSelect ? field.onSelect($event) : null\"\n    (onClose)=\"field.onClose ? field.onClose($event) : null\"\n    (onTodayClick)=\"field.onTodayClick ? field.onTodayClick($event) : null\"\n    (onClearClick)=\"field.onClearClick ? field.onClearClick($event) : null\"\n    (onMonthChange)=\"field.onMonthChange ? field.onMonthChange($event) : null\"\n    (onYearChange)=\"field.onYearChange ? field.onYearChange($event) : null\"\n    [showTransitionOptions]=\"'0ms'\"\n    [hideTransitionOptions]=\"'0ms'\"\n    [(ngModel)]=\"tempValue\">\n</p-datepicker>\n" }]
        }], propDecorators: { field: [{
                type: Input,
                args: [{ required: true }]
            }], formGroup: [{
                type: Input
            }], calendar: [{
                type: ViewChild,
                args: [Calendar]
            }] } });
//# sourceMappingURL=data:application/json;base64, 