import { EventEmitter, OnChanges, OnInit, OnDestroy, SimpleChanges, ChangeDetectorRef } from '@angular/core'; import { FormBuilder, FormGroup } from '@angular/forms'; import { getValueFromPath } from '../../../../dynamic-component.service'; import { HttpClient } from '@angular/common/http'; import * as i0 from "@angular/core"; export interface FormFieldConfig { key: string; type: 'text' | 'number' | 'textarea' | 'html-editor' | 'checkbox' | 'radio' | 'select' | 'select2' | 'multi-select' | 'time' | 'file'; label?: string; placeholder?: string; defaultValue?: any; required?: boolean; disabled?: boolean; readonly?: boolean; /** * If true, the control will be disabled automatically when an initial value * (from formData or defaultValue) is present. */ disabledOnValue?: boolean; validators?: any[]; errorMessages?: { [key: string]: string; }; options?: any[]; /** * If present, options will be loaded from this API (external call). * labelKey/valueKey allow mapping of API results. */ optionsApi?: { url: string; path?: string; labelKey?: string; valueKey?: string; childrenKey?: string; headers?: import('@angular/common/http').HttpHeaders | { [header: string]: string | string[]; }; displayLabelTransform?: (option: any, originalLabel: string) => string; }; /** * If true, renders as a multi-select dropdown (array value). * Only applies to 'multi-select' type fields. */ multiSelect?: boolean; displayValue?: boolean; /** * For Strapi integration - if true, this field is a linked field * and should be transformed to only include IDs on form submission */ isLinkedField?: boolean; rows?: number | null; width?: string; containerClass?: string; labelClass?: string; inputClass?: string; helpText?: string; onChange?: (value: any) => void; accept?: string; multiple?: boolean; showGallery?: boolean; gridSpan?: number; labelPosition?: 'top' | 'left'; preview?: { key: string; filesize?: string; deletable?: boolean; baseUrl?: string; }; } export interface FormRowConfig { fields: FormFieldConfig[]; class?: string; layout?: 'flex' | 'grid'; gridCols?: number; } export interface FormSectionConfig { title?: string; description?: string; rows: FormRowConfig[]; class?: string; } export interface ButtonConfig { label: string; icon?: string; class?: string; severity?: 'primary' | 'secondary' | 'success' | 'info' | 'danger' | 'warn' | 'help' | 'contrast'; outlined?: boolean; disabled?: boolean; onClick?: (formValue?: any) => void; } export interface FormConfig { uid?: string | number; sections: FormSectionConfig[]; class?: string; key?: string; title?: string; /** * If true, the form is configured for Strapi integration * and will transform linked fields to only include IDs on submission */ isStrapiForm?: boolean; submitButton?: { label: string; icon?: string; class?: string; position?: 'left' | 'center' | 'right'; severity?: 'primary' | 'secondary' | 'success' | 'info' | 'danger' | 'warn' | 'help' | 'contrast'; outlined?: boolean; disabled?: boolean; }; resetButton?: { label: string; icon?: string; class?: string; severity?: 'secondary' | 'primary' | 'success' | 'info' | 'danger' | 'warn' | 'help' | 'contrast'; outlined?: boolean; disabled?: boolean; }; customButtons?: ButtonConfig[]; } /** * Dynamic Form Component * * A flexible, configuration-driven form component that generates complex forms * using UNIVERSAL form components. */ export declare class DynamicFormComponent implements OnInit, OnChanges, OnDestroy { private http; private fb; private cdr; /** * Cache for API-loaded options to prevent repeated fetching. */ private apiOptionsCache; private keyMapping; private reverseKeyMapping; constructor(http: HttpClient, fb: FormBuilder, cdr: ChangeDetectorRef); /** * Convert a key with dots to a safe FormGroup key * e.g., "e_warehouse.categories" -> "e_warehouse__DOT__categories" */ private getSafeKey; /** * Get the original key from a safe key */ private getOriginalKey; /** * Transform form data from safe keys back to original keys */ private transformFormData; /** * Transform input data from original keys to safe keys for form initialization */ private transformInputData; /** * Public method for template to get safe key for a field */ getSafeKeyForTemplate(field: FormFieldConfig): string; /** * Handles PrimeNG file upload event for a specific field. * Updates uploadedFiles map for the field. */ /** * Handles file input changes from both native input and PrimeNG p-fileUpload. * Updates uploadedFiles and fileInputs for the field. */ handleFileInputChange(files: File[], fieldKey: string): void; getValueFromPath: typeof getValueFromPath; isArray(value: any): boolean; /** * PrimeNG p-fileUpload event handler */ onUpload(files: File[], fieldKey: string): void; /** * Native input[type=file] event handler */ onFileChange(fieldKey: string, event: Event): void; uploadedFiles: { [key: string]: any[]; }; fileInputs: { [key: string]: File[]; }; private fileObjectUrls; config: FormConfig; class: string; formData: any; /** @type {EventEmitter} */ formSubmit: EventEmitter; removeFile(fieldKey: string, index: number): void; getImageUrls(fieldKey: string): string[]; isGalleryField(fieldKey: string): boolean; private cleanupObjectUrls; ngOnDestroy(): void; /** @type {EventEmitter} */ formReset: EventEmitter; /** @type {EventEmitter<{key: string, value: any}>} */ fieldChange: EventEmitter; /** @type {EventEmitter<{buttonId: string, formValue: any}>} */ buttonClick: EventEmitter; form: FormGroup; formReady: boolean; ngOnInit(): void; ngOnChanges(changes: SimpleChanges): void; /** * Loads options for fields with optionsApiUrl, then builds the form. * Ensures all async option loads are completed before rendering. */ private loadApiOptionsAndBuildForm; private buildForm; onSubmit(): void; onReset(): void; onCustomButtonClick(button: ButtonConfig): void; onFieldChange(key: string, event: any): void; private findField; private markAllAsTouched; hasError(key: string): boolean; getErrorMessage(field: FormFieldConfig): string; getControlClass(key: string, inputClass?: string): string; returnFormatedInitialValues(key: string): any; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; }