import * as i0 from '@angular/core'; import { TemplateRef, ElementRef, QueryList, OnInit, DoCheck, AfterViewInit, OnDestroy, EventEmitter, ChangeDetectorRef, DestroyRef, InjectionToken } from '@angular/core'; import { BooleanInput } from '@angular/cdk/coercion'; import { ControlValueAccessor, NgControl, ControlContainer, NgForm } from '@angular/forms'; import { Nullable, HasElementRef } from '@fundamental-ngx/cdk/utils'; import { Subject, Observable, Subscription } from 'rxjs'; interface BaseCVA extends ControlValueAccessor { ngControl: NgControl | null; } declare const formStates: readonly ["success", "error", "warning", "default", "information"]; type FormStates = (typeof formStates)[number]; interface FormFieldErrorContext { label: string; $implicit: T; } interface FormError { detectChanges$: Subject; fdpFormFieldErrorAs: T; type: FormStates; error: string; _headingTemplateRef: TemplateRef>; _descriptionTemplateRef: TemplateRef> | null; templateRef: TemplateRef>; registerHeading: (heading: FormErrorHeading) => void; registerDescription: (description: FormErrorDescription) => void; } interface FormErrorHeading { fdpFormFieldErrorHeadingAs: T; fdpFormFieldErrorHeadingType?: FormStates; templateRef: TemplateRef>; } interface FormErrorDescription { fdpFormFieldErrorDescriptionAs: T; templateRef: TemplateRef>; } interface FormFieldErrorDirectiveContext { directive: FormError; error: any; } interface FormFieldAdvancedStateMessage { template: Nullable>; hasErrors: boolean; } /** * FormField base class. * * This class is used to create form field components. * */ declare abstract class FormField { /** * Register underlying form control */ registerFormFieldControl: (control: FormFieldControl) => void; /** * Unregister underlying form control */ unregisterFormFieldControl: (control: FormFieldControl) => void; /** * Set default columns layout */ setDefaultColumnLayout: () => void; /** Gets field error priority state. */ getPriorityState: () => FormStates; /** Groups errors. */ groupErrors: () => void; /** Sets error directives from parent container */ setErrorDirectives: (directives: QueryList) => void; } interface FormFieldControl { /** * Each input control has always a value. Need to make sure we keep a convention for * input fields */ value: T | null; /** * Need to have a way to set placeholder to the input */ placeholder: string; /** * Need to have a way to set Mandatory to the input field */ required: boolean; /** * Sets id from FF to Input */ id: string; /** * This should be coming from Parent. */ editable: boolean; /** * The height of the extra content at the bottom of the form control, * which should not affect the alignment of form control and it's label */ extraContentHeightPx?: number; /** * * Form Field listen for all the changes happening inside the input */ stateChanges: Observable; /** * Each input should inject its own ngControl and we should retrieve it */ ngControl: NgControl | null; /** Whether the control is disabled. */ disabled: boolean; /** * Keeps track if the form element is in focus */ focused: boolean; /** Whether control has errors */ controlInvalid: boolean; /** Corresponding element reference. */ elementRef: ElementRef; /** Form field instance. */ formField: Nullable; /** Method for focusing on the element */ focus(event?: MouseEvent): void; /** * Handles even when we click on parent container which is the FormField Wrapping this * control */ onContainerClick(event: MouseEvent): void; } declare class CvaDirective implements HasElementRef, BaseCVA, FormFieldControl, OnInit, DoCheck, AfterViewInit, OnDestroy, ControlValueAccessor { /** Input placeholder */ placeholder: string; /** Input type */ type: string; /** * The state of the form control - applies css classes. * Can be 'success', 'error', 'warning', 'default', 'information'. * * @default 'default' */ set state(state: Nullable); get state(): FormStates; /** Holds the message with respect to state */ stateMessage: Nullable; /** Whether the input is disabled */ set disabled(value: boolean); get disabled(): boolean; /** * readOnly Value to Mark component read only */ readonly: boolean; /** Binds to control aria-labelledBy attribute */ ariaLabelledBy: Nullable; /** Sets control aria-label attribute value */ ariaLabel: Nullable; /** * Tell the component if we are in editing mode. */ set editable(value: BooleanInput); get editable(): boolean; /** * Name of the control. */ name: string; /** * Emits when change detection is needed. */ detectChanges: EventEmitter; /** * Emits when mark for changes detection is needed. */ markForCheck: EventEmitter; /** * Reference to internal Input element */ protected _elementRef: ElementRef; /** @hidden */ value: T; /** set when input field is mandatory form field */ required: boolean; /** * See @FormFieldControl */ focused: boolean; /** Whether control has errors */ get controlInvalid(): boolean; /** * See @FormFieldControl */ readonly stateChanges: Subject; /** @hidden */ readonly formField: FormField | null; /** * NgControl instance. */ readonly ngControl: NgControl | null; /** * Form container instance. Usually ngForm or FormGroup directives. */ readonly controlContainer: ControlContainer | null; /** * Separate NgForm instance. For cases when formGroup is used with the form itself. */ readonly ngForm: NgForm | null; /** @hidden */ readonly normalizedState$: i0.Signal<"success" | "error" | "warning" | "default" | "information">; /** @hidden */ protected _subscriptions: Subscription; /** * A private property to hold the ElementRef which might be null */ private _elementRefOrNull; /** * Element reference. */ get elementRef(): ElementRef; /** @hidden */ private _defaultId; /** ID for the Element */ id: string; /** @hidden */ private _disabled; /** @hidden */ private _editable; /** * @hidden */ private readonly _controlInvalid$; /** @hidden */ private readonly _parentControl; /** * @hidden * The state of the form control - applies css classes. * Can be `success`, `error`, `warning`, `information` or 'default' */ private readonly _state$; /** @hidden */ constructor(); /** @hidden */ onChange: (value: any) => void; /** @hidden */ onTouched: () => void; /** @hidden */ ngOnInit(): void; /** * Re-validate and emit event to parent container on every CD cycle as they are some errors * that we can't subscribe to. */ ngDoCheck(): void; /** @hidden */ ngAfterViewInit(): void; /** @hidden */ registerOnChange(fn: (_: any) => void): void; /** @hidden */ registerOnTouched(fn: () => void): void; /** @hidden */ ngOnDestroy(): void; /** @hidden */ setDisabledState(isDisabled: BooleanInput): void; /** * Method for setting the value * @param value */ writeValue(value: T): void; /** * * Keeps track of element focus */ _onFocusChanged(isFocused: boolean): void; /** * Handles even when we click on parent container which is the FormField Wrapping this * control */ onContainerClick(event: MouseEvent): void; /** * In most of the cases when working with input element directly you should be just find to assign * variable to this element * * ``` * * ``` * * and this default behavior used. For other cases implement focus. * */ focus(event?: MouseEvent): void; /** * Need re-validates errors on every CD iteration to make sure we are also * covering non-control errors, errors that happens outside of this control */ updateErrorState(): void; /** * Used to change the value of a control. * @param value the value to be applied * @param emitOnChange whether to emit "onChange" event. * Should be "false", if the change is made programmatically (internally) by the control, "true" otherwise */ setValue(value: T, emitOnChange?: boolean): void; /** @hidden */ private _markForCheck; static ɵfac: i0.ɵɵFactoryDeclaration, never>; static ɵdir: i0.ɵɵDirectiveDeclaration, "[fdkCva]", never, { "placeholder": { "alias": "placeholder"; "required": false; }; "type": { "alias": "type"; "required": false; }; "state": { "alias": "state"; "required": false; }; "stateMessage": { "alias": "stateMessage"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "readonly": { "alias": "readonly"; "required": false; }; "ariaLabelledBy": { "alias": "ariaLabelledBy"; "required": false; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; }; "editable": { "alias": "editable"; "required": false; }; "name": { "alias": "name"; "required": false; }; "id": { "alias": "id"; "required": false; }; }, { "detectChanges": "detectChanges"; "markForCheck": "markForCheck"; }, never, never, true, never>; } /** * @deprecated * Use direct imports of components and directives. */ declare class FormsModule { static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } /** * Base ControlValueAccessor control class. * Used in conjunction with CvaDirective. * * This class performs generic change detection based on `CvaDirective` outputs. */ declare class CvaControl { /** * Control value accessor directive instance. */ cvaDirective: CvaDirective | null; /** * Change detector instance. */ protected _changeDetector: ChangeDetectorRef; /** @Hidden */ protected _destroyRef: DestroyRef; /** @hidden */ listenToChanges(): void; static ɵfac: i0.ɵɵFactoryDeclaration, never>; static ɵprov: i0.ɵɵInjectableDeclaration>; } /** Checks if the given state is a valid control state. */ declare function isValidControlState(value: any): value is FormStates; /** * Common interface for dropdown-based controls that have single selected value. */ interface SingleDropdownValueControl { tabOutStrategy: 'close' | 'closeAndSelect'; } /** * Interface SelectItem is used to deal with complex object in order to be able to format * custom label that is shown in the options. * * Used in various controls: Select, RadioGroup, CheckboxGroup, Combobox */ interface SelectItem { /** * Item text shown in the popup */ label: string; /** * References to the object instance */ value: T; disabled?: boolean; icon?: string; /** * Trigger values is a text for selected item */ triggerValue?: string; isGroup?: boolean; secondaryText?: string; children?: SelectItem[]; } interface OptionItem { /** Item text */ label: string; /** * References to the object instance */ value: T; id?: string; isGroup?: boolean; secondaryText?: string; children?: OptionItem[]; } interface SelectableOptionItem extends OptionItem { selected?: boolean; children?: SelectableOptionItem[]; } /** @hidden */ declare function isSelectableItem(item: SelectItem | any): item is SelectItem; /** @hidden */ declare function isSelectItem(item: SelectItem | any): item is SelectItem; declare const isOptionItem: typeof isSelectItem; declare const isSelectableOptionItem: typeof isSelectableItem; declare const FD_FORM_FIELD_CONTROL: InjectionToken>; declare const FD_FORM_FIELD: InjectionToken; export { CvaControl, CvaDirective, FD_FORM_FIELD, FD_FORM_FIELD_CONTROL, FormField, FormsModule, formStates, isOptionItem, isSelectItem, isSelectableItem, isSelectableOptionItem, isValidControlState }; export type { BaseCVA, FormError, FormErrorDescription, FormErrorHeading, FormFieldAdvancedStateMessage, FormFieldControl, FormFieldErrorContext, FormFieldErrorDirectiveContext, FormStates, OptionItem, SelectItem, SelectableOptionItem, SingleDropdownValueControl };