import { CommonModule } from '@angular/common';
import { Component, forwardRef, input } from '@angular/core';
import { FormControl, NG_VALUE_ACCESSOR, ReactiveFormsModule } from '@angular/forms';
import { MatNativeDateModule } from '@angular/material/core';
import { MatDatepickerModule } from '@angular/material/datepicker';
import { MatInputModule } from '@angular/material/input';
import { OcapCoreModule } from '@metad/ocap-angular/core';
import * as i0 from "@angular/core";
import * as i1 from "@angular/forms";
import * as i2 from "@angular/material/datepicker";
import * as i3 from "@angular/material/input";
export class NgmDatepickerComponent {
    constructor() {
        this.label = input('');
        this.date = new FormControl(new Date());
        /**
         * Invoked when the model has been changed
         */
        this.onChange = (_) => { };
        /**
         * Invoked when the model has been touched
         */
        this.onTouched = () => { };
    }
    writeValue(obj) {
        this.date.setValue(obj);
    }
    registerOnChange(fn) {
        this.onChange = fn;
    }
    registerOnTouched(fn) {
        this.onTouched = fn;
    }
    setDisabledState(isDisabled) {
        isDisabled ? this.date.disable() : this.date.enable();
    }
    onDateChange(event) {
        this.onChange(event.value);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NgmDatepickerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.12", type: NgmDatepickerComponent, isStandalone: true, selector: "ngm-datepicker", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
            {
                provide: NG_VALUE_ACCESSOR,
                useExisting: forwardRef(() => NgmDatepickerComponent),
                multi: true
            }
        ], ngImport: i0, template: "@if (label()) {\n    <label>{{label()}}</label>\n}\n\n<div class=\"group-date relative flex items-center\">\n    <input matInput class=\"ngm-input-element w-full\"\n        [matDatepicker]=\"picker\" [formControl]=\"date\"\n        (dateChange)=\"onDateChange($event)\">\n    <mat-datepicker #picker></mat-datepicker>\n    <div class=\"absolute right-0 h-full flex items-center opacity-50 group-hover/date:opacity-100\">\n        <mat-datepicker-toggle [for]=\"picker\" />\n        <ng-content select=\"[ngmSuffix]\"></ng-content>\n    </div>\n</div>", styles: [":host{position:relative;display:flex;flex-direction:column;align-items:stretch}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { 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.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "ngmodule", type: MatDatepickerModule }, { kind: "component", type: i2.MatDatepicker, selector: "mat-datepicker", exportAs: ["matDatepicker"] }, { kind: "directive", type: i2.MatDatepickerInput, selector: "input[matDatepicker]", inputs: ["matDatepicker", "min", "max", "matDatepickerFilter"], exportAs: ["matDatepickerInput"] }, { kind: "component", type: i2.MatDatepickerToggle, selector: "mat-datepicker-toggle", inputs: ["for", "tabIndex", "aria-label", "disabled", "disableRipple"], exportAs: ["matDatepickerToggle"] }, { 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: MatNativeDateModule }, { kind: "ngmodule", type: OcapCoreModule }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NgmDatepickerComponent, decorators: [{
            type: Component,
            args: [{ standalone: true, imports: [
                        CommonModule,
                        ReactiveFormsModule,
                        MatDatepickerModule,
                        MatInputModule,
                        MatNativeDateModule,
                        OcapCoreModule,
                    ], selector: 'ngm-datepicker', providers: [
                        {
                            provide: NG_VALUE_ACCESSOR,
                            useExisting: forwardRef(() => NgmDatepickerComponent),
                            multi: true
                        }
                    ], template: "@if (label()) {\n    <label>{{label()}}</label>\n}\n\n<div class=\"group-date relative flex items-center\">\n    <input matInput class=\"ngm-input-element w-full\"\n        [matDatepicker]=\"picker\" [formControl]=\"date\"\n        (dateChange)=\"onDateChange($event)\">\n    <mat-datepicker #picker></mat-datepicker>\n    <div class=\"absolute right-0 h-full flex items-center opacity-50 group-hover/date:opacity-100\">\n        <mat-datepicker-toggle [for]=\"picker\" />\n        <ng-content select=\"[ngmSuffix]\"></ng-content>\n    </div>\n</div>", styles: [":host{position:relative;display:flex;flex-direction:column;align-items:stretch}\n"] }]
        }] });
//# sourceMappingURL=data:application/json;base64, 