import { InjectionToken } from '@angular/core'; import { ValidationErrors } from '@angular/forms'; import { AnnotatableNumberMap } from '@mtna/annotations-ui'; import { ConditionalItem, FormItemImpl } from '../../../models/form/index'; import { FormItemComponent } from '../../form-item/index'; /** Registry of custom error messages for a specific form item. A custom error can also * be a function returning a string. The FormItem object is passed to any ValidationErrors * that are functions, so item specific information can be provided. * @example { * max: `This field's value must be less.`, * min: (item: FormItemImpl) => instanceofWholeNumberItem(item) * ? `This field's value must be greater than ${item.minValue}.` * : `This field's value must be greater.` * } */ export declare type CustomErrors = { [id: string]: ValidationErrors; }; /** List of default error messages to display */ export declare const DEFAULT_ERROR_MESSAGES: ValidationErrors; export declare const WEB_FORM_CUSTOM_ERRORS: InjectionToken; export declare class MtnaWfUIService { /** Map of annotation counts for each annotatable item */ private annotations; /** Map of components in the MtnaForm */ private components; /** Map of item.disabled values that have changed */ private disabledState; /** Map of toggler ID's for components that have multiple togglers */ private multipleEnablers; private errors; constructor(errors?: any); getDisabledStates(): { [x: string]: boolean; }; /** * Returns an error message matching the error id * @param errorId Id of the error, to find the associated error message * @param item FormItem to pass to ValidationErrors that are functions. For instance, * this is useful for 'min' & 'max' value limits to display more helpful messages */ getError(errorId: string, item?: FormItemImpl): any; getItemSummary(id: string): { item: ConditionalItem; parentIds: string[]; }; /** * Toggles a FormItem's visiblity and enable/disable state * * @param enabledItemIds array of component IDs for enabled items. * @param disabledItemIds array of component IDs for disabled items. * @param enabled Whether the enabledItemIds are enabled. * @param callerId instanceId of the item invoking this function * @param reset Whether to reset the multiple enabler map of the toggled item */ toggleFormItems(enabledItemIds: Array, disabledItemIds: Array, enabled: boolean, callerId: string, reset?: boolean): void; /** * Sets the initial map of annotation counts, and/or pushes the new count onto the component observable stream * @param map AnnotatableNumberMap of counts mapped to their annotatableIds */ registerAnnotations(map: AnnotatableNumberMap): void; /** * Maps a component to its items instanceId. * @param component component calling this method, i.e. 'this' */ registerSelf(component: FormItemComponent): void; /** * Generates map of all IDs currently influencing an item. * @param toggledItem item being toggled */ private _registerCurrentEnablers; /** * Resets the map of components. This should be called by the form when * it is destroyed. */ resetComponentMap(): void; /** * Determines if an influencer is currently toggling the specified toggledItemId. * @param influencer Item to check whether it's currently influencing the toggledItemId * @param toggledId InstanceId of the item being toggled * @returns Whether the influencer is currently toggling the toggled item */ private _isCurrentlyToggling; /** * Handles component visibility for a FormItem with multiple enablers in its condition * @param component FormItemComponent being toggled * @param enabled Whether the component is being enabled * @param callerId ID of the caller toggling this component */ private _handleMultipleEnablers; /** * Enables or disables the control on a FormItemComponent * @param component FormItemComponent to enable or disable its control * @param enabled whether to enable the control */ private _toggleControlState; /** * Toggles both the component visiblity and the control's enable/disable status * @param component FormItemComponent to show or hide and enable or disable * @param enabled whether to show the component and whether to enable the component */ private _toggleDisabledStateAndControl; /** * Enables controls individually using recursion. * FormGroups should only exist for items with 'items' arrays, or * if the component is a BaseParentItemControl * @param comp FormItemComponent */ private _enableIndividualControls; /** * Determines if a component is disabled. Prioritizes the disabledState value, * if it exists, otherwise returns the item's previous disabled value * @param item item to check for its disabled state */ private _isDisabled; }