import { ErrorTranslator } from '@jsonforms/core';
import { FASTElement } from '@microsoft/fast-element';
import { FoundationElement } from '@microsoft/fast-foundation';
import { JsonFormsState } from '@jsonforms/core';
import { JSONSchema7 } from 'json-schema';
import { Logger } from '@genesislcap/foundation-utils';
import { OwnPropsOfControl } from '@jsonforms/core';
import { RankedTester } from '@jsonforms/core';
import { StatePropsOfControl } from '@jsonforms/core';
import { UISchemaElement } from '@jsonforms/core';
import { ViewTemplate } from '@microsoft/fast-element';

declare class DispatchRenderer extends FASTElement {
    jsonforms: any;
    jsonformsChanged(): void;
    props: any;
    propsChanged(): void;
    touched: any;
    submitted: boolean;
    submittedChanged(): void;
    dispatch: any;
    control: any;
    renderer: any;
    createRenderer: () => void;
    onBlur(): void;
    get determinedRenderer(): unknown;
    disconnectedCallback(): void;
}

/**
 * Foundation form component for automatically generated forms based on json schema
 * obtained from the api, supplied initial data or supplied JSON schema.
 * Allowing customisable form elements using UI schema and set of custom renderers
 * @beta
 */
export declare class Form extends FoundationElement {
    /**
     * Name of the backend resource which will provide metadata
     * used to generate form and later used for submitting data
     * @public
     */
    resourceName: string;
    private resourceNameChanged;
    private removeDataProperties;
    /**
     * UI schema used to define configuration of the layout and elements in the form
     * Check {@link UiSchemaElement} for possible options
     *
     * @remarks
     * If not provided will be autogenerated based on json schema or initial data
     *
     * @example
     * Here's a simple example:
     * ```
     * const sampleUISchema = {
     *   type: 'VerticalLayout',
     *   elements: [
     *     {
     *       type: 'Control',
     *       scope: '#/properties/QUANTITY',
     *       label: 'Quantity',
     *     },
     *     {
     *       type: 'Control',
     *       scope: '#/properties/INSTRUMENT_ID',
     *       options: {
     *         allOptionsResourceName: 'INSTRUMENT',
     *         valueField: 'INSTRUMENT_ID',
     *         labelField: 'INSTRUMENT_ID',
     *       },
     *       label: 'Instrument',
     *     },
     *     {
     *       type: 'Control',
     *       scope: '#/properties/SIDE',
     *       label: 'Side',
     *     },
     *   ],
     * };
     * ```
     * @public
     */
    uischema: UISchemaElement;
    /**
     * Allows to provide set of renderers used by the form. If not provided it will default to text-field inputs
     * @public
     */
    renderers: RendererEntry[];
    /**
     * Alternatively to providing {@link Form.resourceName} you can hardcode the JSON schema on the client.
     * @public
     * @remarks
     * Use this when you want to avoid fetching metadata from the server but
     * be aware that it could get out of sync if metadata changes on the server
     */
    jsonSchema: JSONSchema7;
    private errors;
    private connect;
    /**
     * Initial data for the form
     * @public
     */
    data: {};
    /**
     * @internal
     */
    submitting: boolean;
    /**
     * @internal
     */
    submitted: boolean;
    /**
     * @internal
     */
    submissionErrors: string;
    readonly: boolean;
    /**
     * @internal
     */
    _submit(): Promise<void>;
    /**
     * @internal
     */
    onChange(event: CustomEvent): void;
    disconnectedCallback(): void;
}

export declare const genesisErrorTranslator: ErrorTranslator;

export declare const logger: Logger;

/**
 * Ensures the value of the current field (the one the validator is on) matches the one of the target field.
 * @param target any other field
 * @returns a validator function that will be run by the smart form during the client-side validation stage
 */
export declare const mustMatch: (target: string) => (data: any, path: any, label: any) => {
    instancePath: string;
    message: string;
    schemaPath: string;
    keyword: string;
    params: {};
}[];

export declare type RendererEntry = {
    renderer: ViewTemplate<DispatchRenderer, any>;
    tester: RankedTester;
    mapper: (state: JsonFormsState, ownProps: OwnPropsOfControl) => StatePropsOfControl;
};

export declare type UiSchema = {
    type: UiSchemaElementType;
    elements: UiSchemaElement[];
};

export declare type UiSchemaElement = {
    type: UiSchemaElementType;
    scope: string;
    label?: string;
    options?: UiSchemaElementOptions;
};

export declare type UiSchemaElementOptions = {
    allOptionsResourceName?: string;
    valueField?: string;
    labelField?: string;
    textarea?: boolean;
    data?: any[];
    i18n?: {
        [key: string]: any;
    };
};

export declare type UiSchemaElementType = 'Control' | 'VerticalLayout' | any;

export { }
