{"version":3,"file":"ng-forge-dynamic-forms-primeng-lazy-datepicker.mjs","mappings":";;;;;;;;;;;AA8CmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CE;;AACA;;AACA;;AAEnB;AACE;AACA;;gBAQiB;AACjB;AACA;AAAU;AACV;AACA;;;IAIF;AACE;;;;AAGE;;;IAKJ;QAEE;;;;AAGE;;;;AAMF;;;AAKA;;;;AA9FS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAlCF;AACT;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BC;;AAEF;;;ACSa;;;;;;;;AAMH;;AAEU;;;;AAIf;;AAEF;;;;AAdiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAVlB;;;;AAlCS","names":[],"ignoreList":[],"sources":["../../../../packages/dynamic-forms-primeng/src/lib/fields/datepicker/prime-datepicker-control.component.ts","../../../../packages/dynamic-forms-primeng/src/lib/fields/datepicker/prime-datepicker.component.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, computed, ElementRef, inject, input, model } from '@angular/core';\nimport { FormsModule } from '@angular/forms';\nimport { FormValueControl } from '@angular/forms/signals';\nimport { NgForgeField, setupMetaTracking, InputMeta } from '@ng-forge/dynamic-forms/integration';\nimport { DatePicker } from 'primeng/datepicker';\n\n/**\n * PrimeNG DatePicker wrapper implementing FormValueControl. Value is stored\n * as an ISO date string. Rendered inside `df-prime-datepicker` — picks up\n * meta + aria from the ambient parent NgForgeField (selector: `'input'`).\n */\n@Component({\n  selector: 'df-prime-datepicker-control',\n  imports: [DatePicker, FormsModule],\n  template: `\n    <p-datepicker\n      [inputId]=\"inputId()\"\n      [ngModel]=\"dateValue()\"\n      (ngModelChange)=\"onModelChange($event)\"\n      (onSelect)=\"onSelect($event)\"\n      (onClear)=\"onClear()\"\n      [placeholder]=\"placeholder()\"\n      [disabled]=\"disabled()\"\n      [readonlyInput]=\"readonly()\"\n      [invalid]=\"ariaInvalid()\"\n      [dateFormat]=\"dateFormat()\"\n      [inline]=\"inline()\"\n      [showIcon]=\"showIcon()\"\n      [showButtonBar]=\"showButtonBar()\"\n      [selectionMode]=\"selectionMode()\"\n      [touchUI]=\"touchUI()\"\n      [view]=\"view()\"\n      [minDate]=\"minDate()\"\n      [maxDate]=\"maxDate()\"\n      [defaultDate]=\"defaultDate()\"\n      [styleClass]=\"styleClass()\"\n      [attr.tabindex]=\"tabIndex()\"\n      [attr.aria-invalid]=\"ariaInvalid()\"\n      [attr.aria-required]=\"ariaRequired()\"\n      [attr.aria-describedby]=\"ariaDescribedBy()\"\n      (onBlur)=\"onBlur()\"\n    />\n  `,\n  changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class PrimeDatepickerControlComponent implements FormValueControl<string | null> {\n  private readonly elementRef = inject(ElementRef<HTMLElement>);\n  private readonly parentField = inject(NgForgeField, { optional: true });\n\n  // ─────────────────────────────────────────────────────────────────────────────\n  // FormValueControl implementation\n  // ─────────────────────────────────────────────────────────────────────────────\n\n  /** The value of the datepicker as ISO string - required by FormValueControl */\n  readonly value = model<string | null>(null);\n\n  /** Tracks whether the field has been touched - used by FormField directive */\n  readonly touched = model<boolean>(false);\n\n  /** Whether the field is disabled */\n  readonly disabled = input<boolean>(false);\n\n  /** Whether the field is readonly */\n  readonly readonly = input<boolean>(false);\n\n  /** Whether the field is invalid (from FormField directive) */\n  readonly invalid = input<boolean>(false);\n\n  /** Whether the field is required (from FormField directive) */\n  readonly required = input<boolean>(false);\n\n  // ─────────────────────────────────────────────────────────────────────────────\n  // PrimeNG DatePicker-specific props\n  // ─────────────────────────────────────────────────────────────────────────────\n\n  readonly inputId = input<string>('');\n  readonly placeholder = input<string>('');\n  readonly dateFormat = input<string>('mm/dd/yy');\n  readonly inline = input<boolean>(false);\n  readonly showIcon = input<boolean>(true);\n  readonly showButtonBar = input<boolean>(false);\n  readonly selectionMode = input<'single' | 'multiple' | 'range'>('single');\n  readonly touchUI = input<boolean>(false);\n  readonly view = input<'date' | 'month' | 'year'>('date');\n  readonly minDate = input<Date | null>(null);\n  readonly maxDate = input<Date | null>(null);\n  readonly defaultDate = input<Date | null>(null);\n  readonly styleClass = input<string>('');\n  readonly tabIndex = input<number | undefined>(undefined);\n\n  // Meta + aria read from the ambient parent NgForgeField.\n  protected readonly meta = computed<InputMeta | undefined>(() => this.parentField?.meta() as InputMeta | undefined);\n  protected readonly ariaInvalid = computed<boolean>(() => this.parentField?.ariaInvalid() ?? false);\n  protected readonly ariaRequired = computed<true | null>(() => this.parentField?.ariaRequired() ?? null);\n  protected readonly ariaDescribedBy = computed<string | null>(() => this.parentField?.ariaDescribedBy() ?? null);\n\n  constructor() {\n    this.parentField?.markClaimed();\n    setupMetaTracking(this.elementRef, this.meta, { selector: 'input' });\n  }\n\n  // ─────────────────────────────────────────────────────────────────────────────\n  // Date conversion\n  // ─────────────────────────────────────────────────────────────────────────────\n\n  /** Converts the string value to Date for PrimeNG's ngModel */\n  protected readonly dateValue = computed(() => {\n    const val = this.value();\n    if (!val) return null;\n    const date = new Date(val);\n    return isNaN(date.getTime()) ? null : date;\n  });\n\n  /** Handles ngModel changes (from typing or calendar selection) */\n  onModelChange(date: Date | null): void {\n    if (date instanceof Date && !isNaN(date.getTime())) {\n      this.value.set(date.toISOString());\n    } else {\n      this.value.set(null);\n    }\n  }\n\n  /** Handles date selection from DatePicker calendar - converts Date to ISO string */\n  onSelect(event: Date): void {\n    // onSelect is redundant with onModelChange but kept for explicit calendar selection handling\n    if (event instanceof Date && !isNaN(event.getTime())) {\n      this.value.set(event.toISOString());\n    } else {\n      this.value.set(null);\n    }\n  }\n\n  /** Handles clear action from DatePicker */\n  onClear(): void {\n    this.value.set(null);\n  }\n\n  /** Marks the field as touched when datepicker loses focus */\n  onBlur(): void {\n    this.touched.set(true);\n    this.parentField?.field()().markAsTouched();\n  }\n}\n","import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';\nimport { FormField } from '@angular/forms/signals';\nimport { DynamicTextPipe } from '@ng-forge/dynamic-forms/integration';\nimport { injectNgForgeField, NgForgeFieldHost } from '@ng-forge/dynamic-forms/integration';\nimport { PrimeDatepickerProps } from './prime-datepicker.type';\nimport { AsyncPipe } from '@angular/common';\nimport { PrimeDatepickerControlComponent } from './prime-datepicker-control.component';\n\n@Component({\n  selector: 'df-prime-datepicker',\n  imports: [PrimeDatepickerControlComponent, FormField, DynamicTextPipe, AsyncPipe],\n  styleUrl: '../../styles/_form-field.scss',\n  hostDirectives: [NgForgeFieldHost],\n  template: `\n    <div class=\"df-prime-field\">\n      @if (ngf.label()) {\n        <label [for]=\"ngf.key() + '-datepicker'\" class=\"df-prime-label\">{{ ngf.label() | dynamicText | async }}</label>\n      }\n\n      <df-prime-datepicker-control\n        [formField]=\"ngf.field()\"\n        [inputId]=\"ngf.key() + '-datepicker'\"\n        [placeholder]=\"(ngf.placeholder() | dynamicText | async) ?? ''\"\n        [tabIndex]=\"ngf.tabIndex()\"\n        [dateFormat]=\"props()?.dateFormat || 'mm/dd/yy'\"\n        [inline]=\"props()?.inline ?? false\"\n        [showIcon]=\"props()?.showIcon ?? true\"\n        [showButtonBar]=\"props()?.showButtonBar ?? false\"\n        [selectionMode]=\"props()?.selectionMode || 'single'\"\n        [touchUI]=\"props()?.touchUI ?? false\"\n        [view]=\"props()?.view || 'date'\"\n        [minDate]=\"minDate()\"\n        [maxDate]=\"maxDate()\"\n        [defaultDate]=\"startAt()\"\n        [styleClass]=\"datepickerClasses()\"\n      />\n\n      @if (ngf.errorsToDisplay()[0]; as error) {\n        <small class=\"p-error\" [id]=\"ngf.errorId()\" role=\"alert\">{{ error.message }}</small>\n      } @else if (props()?.hint; as hint) {\n        <small class=\"df-prime-hint\" [id]=\"ngf.hintId()\">{{ hint | dynamicText | async }}</small>\n      }\n    </div>\n  `,\n  changeDetection: ChangeDetectionStrategy.OnPush,\n  styles: [\n    `\n      :host([hidden]) {\n        display: none !important;\n      }\n    `,\n  ],\n})\nexport default class PrimeDatepickerFieldComponent {\n  protected readonly ngf = injectNgForgeField<string>();\n\n  readonly minDate = input<Date | null>(null);\n  readonly maxDate = input<Date | null>(null);\n  readonly startAt = input<Date | null>(null);\n  readonly props = input<PrimeDatepickerProps>();\n\n  protected readonly datepickerClasses = computed(() => {\n    const classes: string[] = [];\n    const styleClass = this.props()?.styleClass;\n    if (styleClass) {\n      classes.push(styleClass);\n    }\n    return classes.join(' ');\n  });\n}\n"]}