import { FormGroup } from '@angular/forms'; import { Observable } from 'rxjs'; import { GeneralFieldConfigInterface } from './general-field-config.interface'; import { GeneralFormFieldValidatorInterface } from './general-form-field-validator.interface'; import { GeneralODataServiceInterface } from './general-odata-service.interface'; import { GridColumnFilterInterface } from './grid-column-filter.interface'; import { GridColumnInterface } from './grid-column.interface'; import { TextboxCurrencyConfigInterface } from './textbox-currency-config.interface'; import { ConceptualColorType, SizeType } from '../types'; export type FieldDepency = { setup: (currentValues: T, previousValues: T) => P; dependencies: (keyof T)[]; }; export type ConfigDepency = { setup: (currentValues: T, previousValues: T, config: P) => P | undefined; dependencies: (keyof T)[]; }; type HiddenFieldType = { type: 'hiddenField'; }; type LabelType = { type: 'label'; color?: ConceptualColorType; }; type PropType = { type: 'prop'; ref: keyof T; }; type TextboxType = { type: 'textbox'; maxlength?: number; inputType?: 'currency' | 'number' | 'tel' | 'time' | 'email' | 'password' | 'url' | 'text' | (string & {}); mask?: string; currencyConfig?: TextboxCurrencyConfigInterface; direction?: 'ltr' | 'rtl'; dynamicConfig?: ConfigDepency, 'dynamicConfig'>>; minYear?: number; maxYear?: number; }; type TextareaType = { type: 'textarea'; maxlength?: number; size?: SizeType; direction?: 'ltr' | 'rtl'; dynamicConfig?: ConfigDepency, 'dynamicConfig'>>; }; type SelectType = { type: 'select'; selectConfig?: SelectConfigInterface; dynamicConfig?: ConfigDepency, 'dynamicConfig'>>; options?: any[]; }; type CheckboxType = { type: 'checkbox'; checkBoxConfig?: CheckBoxConfigInterface; dynamicConfig?: ConfigDepency, 'dynamicConfig'>>; beforeChangeCallback?: (next: boolean) => boolean | Promise; }; type RadioType = { type: 'radio'; dynamicConfig?: ConfigDepency, 'dynamicConfig'>>; }; type IdentitySelectorType = { type: 'identity-selector'; identitySelectorConfig: IndentiySelectorConfigInterface; dynamicConfig?: ConfigDepency, 'dynamicConfig'>>; beforeChangeCallback?: (selectedItem: any, previousSelectedItem?: any) => boolean | Promise; }; type TreeSelectType = { type: 'tree'; treeConfig?: TreeConfigInterface; dynamicConfig?: ConfigDepency, 'dynamicConfig'>>; }; interface SelectConfigInterface { multiple?: boolean; oDataService?: GeneralODataServiceInterface; oDataEntity?: string; bindValue?: string; bindLabel?: string; isLoaded?: boolean; isLoading?: boolean; oDataServer?: string; oDataTable?: string; oDataHttpHeaders?: { [key: string]: string; }; allowClear?: boolean; } interface TreeConfigInterface { multiple?: boolean; bindValue?: string; bindLabel?: string; bindItems?: string; data: any[]; allowClear?: boolean; } interface IndentiySelectorConfigInterface { valueData?: any; valueDataBinding?: (currentValues: T) => Object; inputField: string; secondInputField?: string; resultField: string; displayField?: string; gridFields?: GridColumnInterface[]; oDataService?: GeneralODataServiceInterface; oDataServer?: string; oDataTable?: string; oDataEntity?: string; hasCrudOrigin?: boolean; oDataHttpHeaders?: { [key: string]: string; }; oDataFilters?: GridColumnFilterInterface[]; allowClear?: boolean; } interface CheckBoxConfigInterface { bindNumberValue: boolean; } export type FormFieldConfig = { id?: string; autoFocus?: boolean; placeholder?: string; validators?: GeneralFormFieldValidatorInterface[]; columnWidth?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12; columnWidthInside?: 2 | 3 | 4 | 6 | 8 | 12 | 24; order?: number; binding?: string; label?: string; fieldsetSectionSlug?: string; labelType?: 'side' | 'float'; hint?: { message: string; color?: ConceptualColorType; }; defaultValue?: P; value?: P; value$?: Observable

; conditionalValue?: (userTouchedField: boolean) => FieldDepency | undefined; /** * Determines whether the field is hidden. * * - If `true`, the field is hidden. * - If a function, it takes the form's current values as an argument and returns a boolean indicating whether the field should be hidden. * * @param values - The current form values, optionally passed to the function when `hidden` is a function. * @returns `true` if the field should be hidden, `false` otherwise. */ hidden?: boolean | ((values?: any) => boolean); hidden2?: FieldDepency; /** * Determines whether the field is disabled. Use `readonly` if you need to include this field in data * * - If `true`, the field is disabled. * - If a function, it takes the form's current values as an argument and returns a boolean indicating whether the field should be disabled. * * @param values - The current form values, optionally passed to the function when `disabled` is a function. * @returns `true` if the field should be disabled, `false` otherwise. */ disabled?: boolean | ((values?: any) => boolean); disabled2?: FieldDepency; /** * Determines whether the field is readonly. Use `disabled` if you need to exclude this field from data * * - If `true`, the field is readonly. * - If a function, it takes the form's current values as an argument and returns a boolean indicating whether the field should be readonly. * * @param values - The current form values, optionally passed to the function when `readonly` is a function. * @returns `true` if the field should be readonly, `false` otherwise. */ readonly?: boolean | ((values?: any) => boolean); readonly2?: FieldDepency; onChange?: (changedValue: any, formGroup?: FormGroup, fieldConfig?: GeneralFieldConfigInterface) => void; }; export type IdentitySelectorFormFieldConfig = FormFieldConfig & IdentitySelectorType; export type SelectFormFieldConfig = FormFieldConfig & SelectType; export type CheckboxFormFieldConfig = FormFieldConfig & CheckboxType; export type TreeSelectFormFieldConfig = FormFieldConfig & TreeSelectType; export type HiddenFieldFormFieldConfig = FormFieldConfig & HiddenFieldType; export type LabelFormFieldConfig = FormFieldConfig & LabelType; export type TextboxFormFieldConfig = FormFieldConfig & TextboxType; export type TextareaFormFieldConfig = FormFieldConfig & TextareaType; export type RadioFormFieldConfig = FormFieldConfig & RadioType; export type PropFormFieldConfig = FormFieldConfig & PropType; export type GeneralFormFieldConfigInterface = IdentitySelectorFormFieldConfig | SelectFormFieldConfig | CheckboxFormFieldConfig | TreeSelectFormFieldConfig | HiddenFieldFormFieldConfig | LabelFormFieldConfig | TextboxFormFieldConfig | TextareaFormFieldConfig | RadioFormFieldConfig | PropFormFieldConfig; export {};