UNPKG

ng2-simple-forms

Version:

A simple(ish) module for creating accessible, reactive forms.

92 lines (91 loc) 2.75 kB
import { EventEmitter, OnInit } from '@angular/core'; import { FormControl, FormGroup } from '@angular/forms'; import { ComponentValue, FormElement, LabelConfig } from '../../../simple-forms.types'; export declare class ElementBaseComponent implements OnInit { formGroup: FormGroup; elementData: FormElement; changeEmitter: EventEmitter<ComponentValue>; isFocussed: boolean; labelConfig: LabelConfig; elementWrapperClass: string; elementGroupLabelClass: string; elementLabelClass: string; elementInputClass: string; elementFieldsetClass: string; elementLegendClass: string; elementOptionLabelClass: string; constructor(); ngOnInit(): void; initElement(): void; getId(): string; setElementStyles(): void; /** * Emit a ComponentValue when this element value changes * (Used when an element is rendered as single element without a FormGroup) */ emit(): void; /** * Get the relevent data about this element * (Used for accessibility directive) */ getElementData(option?: { display: string; value: any; }): { elementData: FormElement; formGroup: FormGroup; option: { display: string; value: any; }; }; /** * Get this elements LabelConfig as an object to pass to LabelComponent */ getLabelConfig(): LabelConfig; /** * Get the default FormGroup for this element * (If part of a form, use forms Formgroup, else, create a FormGroup for JUST this element) */ getFormGroup(): void; /** * Create a single element FormGroup from this element */ toOwnFormgroup(): any; /** * Has the current element got focus? * (Used to apply 'has-focus' class to surrounding DOM elements (label, etc) */ hasFocus(): boolean; /** * Check if element has config options */ hasConfig(): boolean; /** * Get a custom marker for required fields. If none supplied * in config, return * */ getRequiredMarker(): string; /** * Toggle focus of element input, and activate validation listener */ toggleFocus(hasFocus: boolean): void; /** * Subscribe to the elements value changes to activate validation * on change, rather than on lose focus */ activateValidationListener(): void; /** * Simple accessor for getting the FormControl by inputId */ getElement(): FormControl; /** * Convert string to camelCase inputId * @TODO - Remove from here and move to utils */ toInputId(str: string): string; valid(): boolean; invalid(): boolean; touched(): boolean; hasValue(): boolean; }