/// <reference types="jquery" />
import { EventEmitter, InitModelOf, LifecycleEventMap, LifecycleModel, ObjectWithType, Session, SomeRequired, Status, Widget } from '../index';
/**
 * Abstract base class for validation lifecycles as used for forms.
 * A subclass must set the properties, in order to display messages:
 * - emptyMandatoryElementsTextKey
 * - invalidElementsErrorTextKey
 * - invalidElementsWarningTextKey
 * - saveChangesQuestionTextKey
 */
export declare abstract class Lifecycle<TValidationResult extends {
    errorStatus?: Status;
}> extends EventEmitter implements LifecycleModel, ObjectWithType {
    model: LifecycleModel;
    initModel: SomeRequired<this['model'], 'widget'>;
    eventMap: LifecycleEventMap<TValidationResult>;
    self: Lifecycle<any>;
    objectType: string;
    widget: Widget;
    emptyMandatoryElementsTextKey: string;
    emptyMandatoryElementsText: string;
    invalidElementsErrorTextKey: string;
    invalidElementsErrorText: string;
    invalidElementsWarningTextKey: string;
    invalidElementsWarningText: string;
    saveChangesQuestionTextKey: string;
    askIfNeedSave: boolean;
    askIfNeedSaveText: string;
    handlers: Record<string, () => JQuery.Promise<void>>;
    constructor();
    init(model: InitModelOf<this>): void;
    load(): JQuery.Promise<void>;
    protected _load(): JQuery.Promise<void>;
    protected _defaultLoad(): JQuery.Promise<void>;
    ok(): JQuery.Promise<void>;
    cancel(): JQuery.Promise<void>;
    protected _showYesNoCancelMessageBox(message: string, yesAction: () => JQuery.Promise<void>, noAction: () => JQuery.Promise<void>): JQuery.Promise<void>;
    reset(): JQuery.Promise<void>;
    close(): JQuery.Promise<void>;
    protected _close(): JQuery.Promise<void>;
    save(): JQuery.Promise<void>;
    protected _reset(): void;
    protected _save(): JQuery.Promise<void>;
    protected _defaultSave(): JQuery.Promise<void>;
    markAsSaved(): void;
    /**
     * Override this function to check if any data has changed and saving is required.
     */
    saveNeeded(): boolean;
    setAskIfNeedSave(askIfNeedSave: boolean): void;
    protected _validateAndHandle(): JQuery.Promise<Status>;
    protected _handleInvalid(status: Status): JQuery.Promise<Status>;
    /**
     * @returns a promise resolved with the validation result as {@link Status}.
     */
    validate(): JQuery.Promise<Status>;
    protected _validate(): JQuery.Promise<Status>;
    /**
     * Validates all elements (i.e. form-fields) covered by the lifecycle and checks for missing or invalid elements.
     */
    protected _validateElements(): Status;
    protected _revealInvalidElement(invalidElement: TValidationResult): void;
    /**
     * Validates the widget (i.e. form) associated with this lifecycle. This function is only called when there are
     * no missing or invalid elements. It is used to implement an overall-validate logic which has nothing to do
     * with a specific element or field. For instance, you could validate if an internal member variable of a Lifecycle
     * or Form is set.
     */
    protected _validateWidget(): Status | JQuery.Promise<Status>;
    /**
     * Override this function to check for invalid elements on the parent which prevent saving of the parent (e.g. check if all mandatory elements contain a value).
     */
    protected invalidElements(): {
        missingElements: TValidationResult[];
        invalidElements: TValidationResult[];
    };
    /**
     * Creates an HTML message used to display missing and invalid fields in a message box.
     */
    protected _createInvalidElementsMessageHtml(missing: TValidationResult[], invalid: TValidationResult[]): string;
    /**
     * Override this function to retrieve the text of an invalid element
     */
    protected _invalidElementText(element: TValidationResult): string;
    protected _invalidElementErrorText(element: TValidationResult): string;
    protected _invalidElementWarningText(element: TValidationResult): string;
    /**
     * Override this function to retrieve the text of a missing mandatory element
     */
    protected _missingElementText(element: TValidationResult): string;
    session(): Session;
    /**
     * Register a handler function for save actions.
     * All handler functions must return a Status. In case of an error a Status object with severity error must be returned.
     * Note: in contrast to events, handlers can control the flow of the lifecycle. They also have a return value where events have none.
     *   Only one handler can be registered for each type.
     */
    handle(type: 'load' | 'save', func: () => JQuery.Promise<void>): void;
}
//# sourceMappingURL=Lifecycle.d.ts.map