{"version":3,"file":"ng-forge-dynamic-forms-primeng-lazy-select.mjs","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAuGqB;;AACA;;AACA;;gBAOA;AACjB;AACA;;;IAIF;;;IAKA;;;;AAOE;;;;AAnES;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAHV;;;;AA9CQ;AACT;AACA;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CC;;AAEF;;;ACfa;;;;AAIH;;AAEU;;AAEA;;;;AAIf;;QAGF;;;;AAfiB;;;;;;;;;;;;;;;;;;;;;;;AAVlB;;;;AA3BS","names":[],"ignoreList":[],"sources":["../../../../packages/dynamic-forms-primeng/src/lib/fields/select/prime-select-control.component.ts","../../../../packages/dynamic-forms-primeng/src/lib/fields/select/prime-select.component.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, computed, inject, input, model } from '@angular/core';\nimport { FormsModule } from '@angular/forms';\nimport { FormValueControl } from '@angular/forms/signals';\nimport { FieldOption, ValueType } from '@ng-forge/dynamic-forms';\nimport { NgForgeField, NgForgeHostControl } from '@ng-forge/dynamic-forms/integration';\nimport { Select, SelectChangeEvent } from 'primeng/select';\nimport { MultiSelect, MultiSelectChangeEvent } from 'primeng/multiselect';\n\n/**\n * PrimeNG Select/MultiSelect wrapper implementing FormValueControl. Rendered\n * inside `df-prime-select` — `NgForgeHostControl` claims the ambient parent\n * NgForgeField for meta + aria. Standalone use lands `aria-invalid=\"false\"`\n * with no `aria-required` / `aria-describedby`.\n */\n@Component({\n  selector: 'df-prime-select-control',\n  imports: [Select, MultiSelect, FormsModule],\n  hostDirectives: [NgForgeHostControl],\n  template: `\n    @if (multiple()) {\n      <p-multiSelect\n        [inputId]=\"inputId()\"\n        [ngModel]=\"multiValue()\"\n        (onChange)=\"onMultiSelectChange($event)\"\n        [options]=\"options()\"\n        optionLabel=\"label\"\n        optionValue=\"value\"\n        [placeholder]=\"placeholder()\"\n        [disabled]=\"disabled()\"\n        [invalid]=\"ariaInvalid()\"\n        [filter]=\"filter()\"\n        [showClear]=\"showClear()\"\n        [styleClass]=\"styleClass()\"\n        [attr.aria-invalid]=\"ariaInvalid()\"\n        [attr.aria-required]=\"ariaRequired()\"\n        [attr.aria-describedby]=\"ariaDescribedBy()\"\n        (onBlur)=\"onBlur()\"\n        (onHide)=\"onBlur()\"\n      />\n    } @else {\n      <p-select\n        [inputId]=\"inputId()\"\n        [ngModel]=\"value()\"\n        (onChange)=\"onSelectChange($event)\"\n        [options]=\"options()\"\n        optionLabel=\"label\"\n        optionValue=\"value\"\n        [placeholder]=\"placeholder()\"\n        [disabled]=\"disabled()\"\n        [invalid]=\"ariaInvalid()\"\n        [filter]=\"filter()\"\n        [showClear]=\"showClear()\"\n        [styleClass]=\"styleClass()\"\n        [attr.aria-invalid]=\"ariaInvalid()\"\n        [attr.aria-required]=\"ariaRequired()\"\n        [attr.aria-describedby]=\"ariaDescribedBy()\"\n        (onBlur)=\"onBlur()\"\n        (onHide)=\"onBlur()\"\n      />\n    }\n  `,\n  changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class PrimeSelectControlComponent implements FormValueControl<ValueType> {\n  // Ambient parent NgForgeField — feeds aria fallback for inner <p-select> bindings.\n  private readonly parentField = inject(NgForgeField, { optional: true });\n\n  // ─────────────────────────────────────────────────────────────────────────────\n  // FormValueControl implementation\n  // ─────────────────────────────────────────────────────────────────────────────\n\n  /** The value of the select - required by FormValueControl */\n  readonly value = model<ValueType>(undefined as unknown as ValueType);\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 Select-specific props\n  // ─────────────────────────────────────────────────────────────────────────────\n\n  readonly inputId = input<string>('');\n  readonly placeholder = input<string>('');\n  readonly options = input<FieldOption<ValueType>[]>([]);\n  readonly multiple = input<boolean>(false);\n  readonly filter = input<boolean>(false);\n  readonly showClear = input<boolean>(false);\n  readonly styleClass = input<string>('');\n\n  // Aria signals read from the ambient parent NgForgeField. Standalone use\n  // (no parent) lands `false` / `null`.\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  // ─────────────────────────────────────────────────────────────────────────────\n  // Multi-select value handling\n  // ─────────────────────────────────────────────────────────────────────────────\n\n  /** Computed to cast value as array for multi-select */\n  protected readonly multiValue = computed(() => {\n    const val = this.value();\n    return Array.isArray(val) ? val : [];\n  });\n\n  /** Handles single select change event */\n  onSelectChange(event: SelectChangeEvent): void {\n    this.value.set(event.value);\n  }\n\n  /** Handles multi select change event */\n  onMultiSelectChange(event: MultiSelectChangeEvent): void {\n    // Store as array for multi-select - cast to ValueType since that's what the field expects\n    this.value.set(event.value as unknown as ValueType);\n  }\n\n  /** Marks the field as touched when select 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 { FieldOption, ValueType } from '@ng-forge/dynamic-forms';\nimport { DynamicTextPipe } from '@ng-forge/dynamic-forms/integration';\nimport { injectNgForgeField, NgForgeFieldHost } from '@ng-forge/dynamic-forms/integration';\nimport { AsyncPipe } from '@angular/common';\nimport { PrimeSelectProps } from './prime-select.type';\nimport { PrimeSelectControlComponent } from './prime-select-control.component';\n\n@Component({\n  selector: 'df-prime-select',\n  imports: [FormField, PrimeSelectControlComponent, DynamicTextPipe, AsyncPipe],\n  styleUrl: '../../styles/_form-field.scss',\n  hostDirectives: [NgForgeFieldHost],\n  template: `\n    <div class=\"df-prime-field\">\n      @if (ngf.label(); as label) {\n        <label [for]=\"ngf.key() + '-select'\" class=\"df-prime-label\">{{ label | dynamicText | async }}</label>\n      }\n\n      <df-prime-select-control\n        [formField]=\"ngf.field()\"\n        [inputId]=\"ngf.key() + '-select'\"\n        [options]=\"options()\"\n        [placeholder]=\"(ngf.placeholder() | dynamicText | async) ?? ''\"\n        [multiple]=\"isMultiple()\"\n        [filter]=\"props()?.filter ?? false\"\n        [showClear]=\"props()?.showClear ?? false\"\n        [styleClass]=\"selectClasses()\"\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 PrimeSelectFieldComponent {\n  protected readonly ngf = injectNgForgeField<ValueType>();\n\n  readonly options = input<FieldOption<ValueType>[]>([]);\n  readonly props = input<PrimeSelectProps>();\n\n  protected readonly isMultiple = computed(() => this.props()?.multiple ?? false);\n\n  protected readonly selectClasses = computed(() => {\n    const classes: string[] = [];\n    const styleClass = this.props()?.styleClass;\n    if (styleClass) {\n      classes.push(styleClass);\n    }\n    // Note: p-invalid is handled by [invalid] input binding, not manual class\n    return classes.join(' ');\n  });\n}\n"]}