UNPKG

@ekisa-cdk/forms

Version:

🛠️ Easily build & integrate dynamic forms

38 lines (37 loc) 1.71 kB
import { RadioGroupItem, SelectBoxOption } from '../controls'; import { FormPlugin } from '../plugins'; import { FormControlType } from '../types/form-control-type.enum'; import { FormControls } from '../types/form-control.type'; declare type MappingSource = Array<Record<string, any>>; declare type ControlPublicKeys = 'key' | 'value' | 'label' | 'placeholder' | 'validators'; declare type FieldsetPublicKeys = 'legend' | 'cols' | 'children'; declare type TextAreaPublicKeys = 'cols' | 'rows'; declare type NumberBoxPublicKeys = 'min' | 'max'; declare type SelectBoxPublicKeys = 'options' | keyof SelectBoxOption; declare type RadioGroupPublicKeys = 'text' | 'items' | keyof RadioGroupItem; export declare type AutoMapperPluginConfig<ControlType> = { types: Record<FormControlType, ControlType>; keys: { controlTypePropertyName: string; fieldSet: Record<FieldsetPublicKeys, string>; control: Record<ControlPublicKeys, string>; textAreaOptions: Record<TextAreaPublicKeys, string>; numberBoxOptions: Record<NumberBoxPublicKeys, string>; selectBoxOptions: Record<SelectBoxPublicKeys, string>; radioGroupOptions: Record<RadioGroupPublicKeys, string>; validators: { propertyName: string; name: string; value?: string; }; }; }; export declare class AutoMapperPlugin<ControlType> implements FormPlugin<AutoMapperPluginConfig<ControlType>> { private _source; private _config; constructor(source: MappingSource, config: AutoMapperPluginConfig<ControlType>); run(): FormControls; private _mapFromSource; private _mapValidators; } export {};