/// <reference types="react" />
export * from "./constants";
import { Text } from "./elements/types";
export interface FormElementProps<TValue = undefined> extends FormElementSettableProps<TValue> {
    /** The description of the element. */
    description?: Text;
    /** The enabled state of the element. */
    enabled: boolean;
    /** The error state of the element. */
    error?: Text;
    /** The title of the element. */
    title?: string;
    /**
     * A callback function to raise an event. The `custom` event accepts any
     * value as the eventValue. Use the Get Form Event Data to access the event
     * data in a sub-workflow of the Display Form activity.
     * @param eventName The name of the event to raise. Currently only `custom`
     * is permitted.
     * @param eventValue The value of the event.
     */
    raiseEvent: (eventName: "custom", eventValue: any) => void;
    /**
     * Set a property on the element.
     * @param property The name of the property to set.
     * @param value The new value to set.
     */
    setProperty: <K extends keyof Omit<this, keyof FormElementProps<TValue>> | keyof FormElementSettableProps<TValue>>(property: K, value: this[K]) => void;
    /**
     * Sets the `value` property of the element. Equivalent to calling
     * `setProperty("value", value)`.
     *
     * Setting the value will raise the `change` event on the element.
     *
     * @param value The new value to set.
     */
    setValue: (value: this["value"]) => void;
}
export interface FormElementSettableProps<TValue = undefined> {
    /** The value of the element. */
    value: TValue;
}
declare type SettablePropsFromProps<TProps extends FormElementProps> = Omit<TProps, keyof FormElementProps> & FormElementSettableProps<TProps["value"]>;
declare type Unionize<T> = T[keyof T];
export declare type PropertyChangeEvent<TSettableProps, TSetProperty> = Unionize<{
    [K in keyof Required<TSettableProps>]: {
        properties: Readonly<TSettableProps>;
        property: K;
        setProperty: TSetProperty;
    };
}>;
export interface FormElementRegistration<TProps extends FormElementProps<any> = FormElementProps, TSettableProps extends SettablePropsFromProps<TProps> = SettablePropsFromProps<TProps>> {
    /** The React component definition of the form element. */
    component: React.ComponentType<TProps>;
    /** The unique identifier of the element. */
    id: string;
    /**
     * Generate the initial properties of the form element. This will be assigned to
     * the element properties before first render.
     */
    getInitialProperties?: () => Partial<TSettableProps>;
    /**
     * This function will be invoked prior to updating a property of the element
     * state. It will be invoked even if the element isn't currently visible.
     *
     * @returns Either a new value, an error message, or nothing.
     */
    onPropertyChange?: (event: PropertyChangeEvent<TSettableProps, TProps["setProperty"]>) => void;
}
