import { RevDataServer, RevRectangle, RevSchemaField } from '../../common'; import { RevBehavioredColumnSettings } from '../settings'; import { RevCellPossiblyPaintable } from './cell-possibly-paintable'; import { RevViewCell } from './view-cell'; /** @public */ export interface RevCellEditor< BCS extends RevBehavioredColumnSettings, SF extends RevSchemaField > extends RevCellPossiblyPaintable { // Common properties, methods and events /** Indicates if editor can only display data */ readonly: boolean; /** Get latest data from data server */ pullCellValueEventer?: RevCellEditor.PullCellValueEventer; /** Save data to data server. Optional. If not supplied then editor is read only */ pushCellValueEventer?: RevCellEditor.PushCellValueEventer; /** Editor can optionally use this eventer to notify Grid that it has completed */ cellClosedEventer?: RevCellEditor.CellClosedEventer; /** Emits key down events generated by editor */ keyDownEventer?: RevCellEditor.KeyDownEventer; /** Provide the initial data to the editor. This is done after all events have been subscribed to - so editor can start running */ tryOpenCell(viewCell: RevViewCell, openingKeyDownEvent: KeyboardEvent | undefined, openingClickEvent: MouseEvent | undefined): boolean; /** Close the editor - returns data that was in editor or undefined if cancel specified */ closeCell(field: SF, dataServerRowIndex: number, cancel: boolean): void; /** Server data value has changed since being provided to editor or pulled by editor */ invalidateValue?(): void; /** See if the editor wants the key down event. If fromEditor is true, then this editor generated the event in the first place */ processGridKeyDownEvent(event: KeyboardEvent, fromEditor: boolean, field: SF, dataServerRowIndex: number): boolean; /** See if the editor wants the mouse down event. If fromEditor is true, then this editor generated the event in the first place */ processGridClickEvent?(event: MouseEvent, viewCell: RevViewCell): boolean; /** See if the editor wants the mouse move event. If fromEditor is true, then this editor generated the event in the first place */ processGridPointerMoveEvent?(event: PointerEvent, viewCell: RevViewCell): RevCellEditor.MouseActionPossible | undefined; // HTML Element methods and events /** Implement if editor paints itself (eg a HTML Input element). If bounds is undefined, then editor is hidden */ setBounds?(bounds: RevRectangle | undefined): void; /** Implement if editor can be focused. */ focus?(): void; } /** @public */ export namespace RevCellEditor { export type PullCellValueEventer = (this: void) => RevDataServer.ViewValue; export type PushCellValueEventer = (this: void, value: RevDataServer.ViewValue) => void; // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents export type CellClosedEventer = (this: void, value: RevDataServer.ViewValue | undefined) => void; export type KeyDownEventer = (this: void, event: KeyboardEvent) => void; export interface MouseActionPossible { cursorName: string | undefined; titleText: string | undefined; } }