import * as React from "react"; import { IArrayProp, IObjectProp, PropType } from "./propertyPathBuilder"; export declare type ValidationModes = "none" | "icon" | "below" | "both"; export declare namespace DataValidationMessage { function spread(message: string): { ["data-validation-message"]: string; }; function set(props: any, message: string): void; function get(props: any): string; } export declare namespace DataValidationMode { function spread(mode: ValidationModes): { ["data-validation-mode"]: ValidationModes; }; function set(props: any, mode: ValidationModes): void; function get(props: any): ValidationModes; } export interface IFormValidationResult { /** The attribute (dataPath) of the invalid entry */ attribute: string; /** The validation message */ message: string; } /** * Form Binder Core interface * The defintion of a form binder */ export interface IFormBinder { /** The path used to bind to the data object */ dataPath: string; /** * Augment the component props that will be applied to the forms child element being bound */ setElementProperty(props: TComponentProps, dataBinder: IDataBinder, validationResults?: IFormValidationResult[]): void; /** * Add the value changed event handler, calling the supplied `notifyChanged` function when a change event has occurred */ handleValueChanged(props: TComponentProps, dataBinder: IDataBinder, notifyChanged: () => void): void; /** * Override the children for the element */ overrideChildren?(props: TComponentProps, dataBinder: IDataBinder): React.ReactNode; /** * An optional additional set of component props that allows consumers of your FormBinder to add, change or remove the properties that will be applied to the target element */ extender?(props: TComponentProps, dataBinder: IDataBinder, notifyChanged: () => void): void; } /** * The Form Data Binder Core interface * Wraps access to the data being bound to the form. * This provides the bridge between the data source and the form elements */ export interface IDataBinder { lastDataPathSet?: string; /** Gets a value for the key name (does NOT use dot notation) */ getKeyValue(dataName: (builder: PropType) => IObjectProp): X; getKeyValue(dataName: (builder: PropType) => IArrayProp): X[]; getKeyValue(keyName: TKey): T[TKey]; /** Sets a value for the key name (does NOT use dot notation) */ setKeyValue(dataName: (builder: PropType) => IObjectProp, value: X): void; setKeyValue(dataName: (builder: PropType) => IArrayProp, value: X[]): void; setKeyValue(keyName: TKey, value: T[TKey]): void; /** Gets a value for the data path (uses dot notation) */ getValue(dataPath: string): any; /** Sets a value for the data path (uses dot notation) */ setValue(dataPath: string, value: any): void; /** Gets the inner data as the native object */ toJson(): T; createChildBinder(dataName: (builder: PropType) => IObjectProp, autoSync?: boolean): IChildDataBinder; createChildBinder(dataName: (builder: PropType) => IArrayProp, autoSync?: boolean): IChildDataBinder; createChildBinder(keyName: TKey, autoSync?: boolean): IChildDataBinder; } export interface IChildDataBinder extends IDataBinder { sync(): void; } declare const FormBinderInjectorKey = "data-form-binder"; /** Used to inject properties onto React components to permit form binding */ export interface IFormBinderInjector { [FormBinderInjectorKey]: IFormBinder; } export declare function getFormBinderFromInjector(injector: IFormBinderInjector): IFormBinder; export declare function updateFormBinderInjector(target: IFormBinderInjector, formBinder: IFormBinder): IFormBinderInjector; export declare function getEventTargetAs(evt: React.FormEvent): T; export {};