import { ClientConnection } from 'message-event-channel'; import { CDv2Response } from './interfaces/cd2-response'; import { HandlerContainer } from './handler-container'; import { IModel, ModelChangeDispose, ModelChangeHandler } from './interfaces/form-handler'; import { DeliveryRequestConfig } from './request-config'; export declare const KEY = "visualization-sdk:dc-form"; export declare enum FORM_EVENTS { GET = "visualization-sdk:form:get", CHANGE = "visualization-sdk:form:change", SAVED = "visualization-sdk:form:saved", CHANGED_CONFIG = "visualization-sdk:form:changed-config", SAVED_CONFIG = "visualization-sdk:form:saved-config" } export interface OnChangeHandler { model: IModel; handlerId: string; } /** * Form class allows you to watch for changes within the content form, it is not enabled for other contexts such as SnapshotBrowser or Edition page ect. */ export declare class Form { connection: ClientConnection; /** @internal */ changeHandlerContainer: HandlerContainer>; /** @internal */ savedHandlerContainer: HandlerContainer>; constructor(connection: ClientConnection); /** * Get the current model state of all the fields in the form in Delivery Format. * * @param config - Config for how the model should be returned e.g CDv2 or CDv1 * * ### Example * ```typescript * try { * const value = await visualization.form.get(); * * console.log(value) * } catch (e) { * // In a context where there is no form model * } * ``` */ get(config?: Partial): Promise; /** * Sets up a listener for when the form saves * * @param cb - callback function to be called when form has saved * @param config - Config for how the model should be returned e.g CDv2 or CDv1 * * @returns a dispose function which removes the listener * * ### Example * * ```typescript * const dispose = visualization.form.saved((model) => { * // handle form saved * }) * ``` */ saved(cb: ModelChangeHandler, config?: Partial): ModelChangeDispose; /** * Sets up a listener for when the form changes * * @param cb - callback function to be called when form has changed * @param config - Config for how the model should be returned e.g CDv2 or CDv1 * * @returns a dispose function which removes the listener * * ### Example * * ```typescript * const dispose = visualization.form.changed((model) => { * // handle form change * }) * ``` */ changed(cb: ModelChangeHandler, config?: Partial): ModelChangeDispose; }