import UseCase from '../UseCase/types'; /** * The change event is triggered when the `Element`'s value changes. * * The ready event is emitted when an EBT Element’s input field is * able to respond to user interactions like keypress, focus, etc. * * @docs https://docs.joinforage.app/reference/events */ export type ElementEventType = 'change' | 'ready'; export interface ValidationError { message: string; } export interface ElementEvent { /** * A constant string representing the type of event. */ type: ElementEventType; /** * A constant string representing the type of EBT Element that emitted the event. */ usecase: UseCase; /** * If the EBT element contains input that is potentially valid, * then the `complete` status for the change event is set to true. * * @docs https://docs.joinforage.app/reference/change#listen-for-complete */ complete: boolean; /** * A helpful validation error message that may be shown directly to end users. * It will be null when the input is valid. * * Listen for an error value on the change event object to display * input validation errors to the user. * * @docs https://docs.joinforage.app/reference/change#listen-for-error */ error: ValidationError | null; } export type ElementEventHandler = (e: ElementEvent) => void;