import type { FormComponent } from "./FormComponent"; import type * as defs from "./FormDefinition"; import type { FormatOptions } from "./numberFormatter"; import type { ExternalEvent } from "../execution/ExternalEvent"; import type { ComponentType, ReactNode } from "react"; /** * Exposes various features to components that require features of the environment. * @product This is intended for internal use only within VertiGIS Studio products. */ export interface FormPresenterHost { /** Indicates if the form is enabled or not. */ enabled: boolean; /** The form to render. */ form: defs.Form; /** References all elements. */ refs: Record; /** Coerces a number from a value. */ coerceNumber(value: string, locale?: string): number; /** * Derives the current locale set by the host application (or default if undefined) will be returned. */ deriveLocale(): string; /** * Shows a dialog in the context of the running application. * @param children A function that produces the children for the dialog. * @param DialogComponent The type of component to use as the dialog. */ displayDialog(children: (closeDialog: () => void) => ReactNode, DialogComponent: ComponentType): Promise; /** Disposes the form. */ dispose(): void; /** * Passes on an external event (from the host application) to the form's event queue. * @param event An event received from the host application. */ enqueueExternalEvent(event: ExternalEvent): void; /** Find the element. */ find(name: string | { name: string; } | undefined): defs.Element | undefined; /** Formats a value into a string. */ formatNumber(value: number, options?: FormatOptions): string; /** * Returns `true` if the element has a `type` of `"Section"` and at least one visible child with `error` equal to `true`. * @param element */ hasInvalidChild(element: defs.Element): boolean; /** Posts an event. */ post(type: "changed" | "cancel" | "clicked" | "custom" | "dragged" | "suggest", event?: defs.Event): void; /** Renders the focus. */ renderFocus(target: Node, name?: string): boolean; /** Renders a component's state. */ renderState(name: string, type: "geometry", state?: defs.GeometryState[]): boolean; /** Renders a component's state. */ renderState(name: string, type: string, state?: object): boolean; /** Renders form text to display text. */ renderText(text: defs.Text | undefined): string; /** Renders a component's visual. */ renderVisual(component: object): any; /** * Translates the supplied value. * @param content The string or {@link defs.StatusRef} to be translated. * @returns A translated version of the text. */ translateText(content: string | defs.StatusRef | undefined): string | undefined; /** * Translates the supplied value. * @param content The {@link defs.MarkdownRef} to be translated. */ translateText(content: defs.MarkdownRef | undefined): defs.MarkdownRef | undefined; /** * Translates the supplied value. * @param content The {@link defs.Text} to be translated. */ translateText(content: defs.Text | undefined): string | defs.MarkdownRef | undefined; /** * Collapses all neighbouring mutually exclusive sections except the one specified. * @param expandedSection The name of the section to be expanded. All others in the group will be collapsed. */ updateMutuallyExclusiveSections(expandedSection: string): void; }