import type { AltEditorLiteError } from './alt-editor-lite-error.js'; import type { AltEditorLite } from './alt-editor-lite.js'; import type { EditorOperationMode, EditorOperationTarget } from './editor-operation.js'; import type { BatchChanges, EditorValues } from './editor-values.js'; /** Names of the stable DOM events published by the editor. */ export type EditorEventName = 'alteditor-lite:open' | 'alteditor-lite:close' | 'alteditor-lite:submit' | 'alteditor-lite:success' | 'alteditor-lite:error' | 'alteditor-lite:refresh' | 'alteditor-lite:destroy'; /** Reason that an operation dialog was closed. */ export type EditorCloseReason = 'api' | 'cancel' | 'escape' | 'success' | 'unchanged' | 'redraw'; interface EditorEventDetailBase { readonly editor: AltEditorLite; } /** Detail published after an operation dialog or inline editor is fully open. */ export type EditorOpenEventDetail = EditorEventDetailBase & ({ readonly type: 'open'; readonly operation: 'create'; readonly mode: 'dialog'; } | { readonly type: 'open'; readonly operation: 'edit'; readonly mode: 'dialog' | 'inline'; readonly target: Readonly; } | { readonly type: 'open'; readonly operation: 'batchEdit'; readonly mode: 'dialog'; readonly originals: readonly Readonly[]; readonly targets: readonly Readonly[]; } | { readonly type: 'open'; readonly operation: 'remove'; readonly mode: 'dialog'; }); /** Create detail published after validation and collection, before persistence. */ export interface EditorCreateSubmitEventDetail { readonly type: 'submit'; readonly editor: AltEditorLite; readonly operation: 'create'; readonly values: Readonly>; readonly mode: EditorOperationMode; readonly target?: Readonly; } /** Edit detail published after target validation, before persistence. */ export interface EditorEditSubmitEventDetail { readonly type: 'submit'; readonly editor: AltEditorLite; readonly operation: 'edit'; readonly values: Readonly>; readonly original: Readonly; readonly mode: 'dialog' | 'inline'; readonly target: Readonly; } /** Batch Edit detail published after validation, before persistence. */ export interface EditorBatchEditSubmitEventDetail { readonly type: 'submit'; readonly editor: AltEditorLite; readonly operation: 'batchEdit'; readonly changes: Readonly>; readonly originals: readonly Readonly[]; readonly mode: 'dialog'; readonly targets: readonly Readonly[]; } /** Remove detail published after snapshot validation, before persistence. */ export interface EditorRemoveSubmitEventDetail { readonly type: 'submit'; readonly editor: AltEditorLite; readonly operation: 'remove'; readonly rows: readonly Readonly[]; readonly mode: EditorOperationMode; readonly target?: Readonly; } /** Concrete detail union for the three dialog submission operations. */ export type EditorSubmitEventDetail = EditorCreateSubmitEventDetail | EditorEditSubmitEventDetail | EditorBatchEditSubmitEventDetail | EditorRemoveSubmitEventDetail; /** Detail published after the Host applies a created record. */ export interface EditorCreateSuccessEventDetail { readonly type: 'success'; readonly editor: AltEditorLite; readonly operation: 'create'; readonly values: Readonly>; readonly row: Readonly; readonly mode: EditorOperationMode; readonly target?: Readonly; } /** Detail published after the Host applies an updated record. */ export interface EditorEditSuccessEventDetail { readonly type: 'success'; readonly editor: AltEditorLite; readonly operation: 'edit'; readonly original: Readonly; readonly values: Readonly>; readonly row: Readonly; readonly mode: 'dialog' | 'inline'; readonly target: Readonly; } /** Detail published after the Host applies a batch of canonical rows. */ export interface EditorBatchEditSuccessEventDetail { readonly type: 'success'; readonly editor: AltEditorLite; readonly operation: 'batchEdit'; readonly changes: Readonly>; readonly originals: readonly Readonly[]; readonly rows: readonly Readonly[]; readonly mode: 'dialog'; readonly targets: readonly Readonly[]; } /** Detail published after the Host removes all captured records. */ export interface EditorRemoveSuccessEventDetail { readonly type: 'success'; readonly editor: AltEditorLite; readonly operation: 'remove'; readonly rows: readonly Readonly[]; readonly mode: EditorOperationMode; readonly target?: Readonly; } /** Detail published after a Host refresh completes successfully. */ export interface EditorRefreshSuccessEventDetail { readonly type: 'success'; readonly editor: AltEditorLite; readonly operation: 'refresh'; readonly mode: EditorOperationMode; readonly target?: Readonly; } /** Concrete detail union for every successful operation. */ export type EditorSuccessEventDetail = EditorCreateSuccessEventDetail | EditorEditSuccessEventDetail | EditorBatchEditSuccessEventDetail | EditorRemoveSuccessEventDetail | EditorRefreshSuccessEventDetail; /** Detail published after an error is visible without a Host mutation. */ export type EditorErrorEventDetail = EditorEventDetailBase & { readonly type: 'error'; readonly error: AltEditorLiteError; } & ({ readonly operation: 'create'; readonly mode: 'dialog'; } | { readonly operation: 'edit'; readonly mode: 'dialog' | 'inline'; readonly target: Readonly; } | { readonly operation: 'batchEdit'; readonly mode: 'dialog'; readonly targets: readonly Readonly[]; } | { readonly operation: 'remove'; readonly mode: 'dialog'; } | { readonly operation: 'refresh'; readonly mode: 'api'; } | { readonly operation: 'refresh'; readonly mode: 'inline'; readonly target: Readonly; }); /** Detail published after dialog cleanup and focus restoration. */ export type EditorCloseEventDetail = EditorEventDetailBase & { readonly type: 'close'; readonly reason: EditorCloseReason; } & ({ readonly operation: 'create'; readonly mode: 'dialog'; } | { readonly operation: 'edit'; readonly mode: 'dialog' | 'inline'; readonly target: Readonly; } | { readonly operation: 'batchEdit'; readonly mode: 'dialog'; readonly targets: readonly Readonly[]; } | { readonly operation: 'remove'; readonly mode: 'dialog'; }); /** Detail published at the start and completion of a Refresh operation. */ export interface EditorRefreshEventDetail { readonly type: 'refresh'; readonly editor: AltEditorLite; readonly operation: 'refresh'; readonly phase: 'start' | 'complete'; readonly mode: EditorOperationMode; readonly target?: Readonly; } /** Detail published once after all owned resources are destroyed. */ export interface EditorDestroyEventDetail { readonly type: 'destroy'; readonly editor: AltEditorLite; readonly mode: EditorOperationMode; readonly target?: Readonly; } /** * Name-to-detail mapping for every stable editor event. */ export interface EditorEventDetailMap { readonly 'alteditor-lite:open': EditorOpenEventDetail; readonly 'alteditor-lite:close': EditorCloseEventDetail; readonly 'alteditor-lite:submit': EditorSubmitEventDetail; readonly 'alteditor-lite:success': EditorSuccessEventDetail; readonly 'alteditor-lite:error': EditorErrorEventDetail; readonly 'alteditor-lite:refresh': EditorRefreshEventDetail; readonly 'alteditor-lite:destroy': EditorDestroyEventDetail; } /** * Dispatches a non-bubbling, observation-only editor event. * * @param eventTarget - Host event destination that owns consumer listeners. * @param eventName - Stable event name. * @param detail - Concrete event detail for that name. */ export declare function dispatchEditorEvent>(eventTarget: EventTarget, eventName: TEventName, detail: EditorEventDetailMap[TEventName]): void; export {};