@odoo/o-spreadsheet
Version:
A spreadsheet component
124 lines (123 loc) • 5.37 kB
TypeScript
import { Component } from "@odoo/owl";
import { Store } from "../../store_engine";
import { Client, DOMCoordinates, DOMDimension, GridClickModifiers, HeaderIndex, Pixel, Table } from "../../types/index";
import { SpreadsheetChildEnv } from "../../types/spreadsheet_env";
import { Autofill } from "../autofill/autofill";
import { ClientTag } from "../collaborative_client_tag/collaborative_client_tag";
import { ComposerSelection } from "../composer/composer/abstract_composer_store";
import { GridComposer } from "../composer/grid_composer/grid_composer";
import { GridOverlay } from "../grid_overlay/grid_overlay";
import { GridPopover } from "../grid_popover/grid_popover";
import { HeadersOverlay } from "../headers_overlay/headers_overlay";
import { ZoomedMouseEvent } from "../helpers/zoom";
import { Highlight } from "../highlight/highlight/highlight";
import { MenuPopover } from "../menu_popover/menu_popover";
import { Popover } from "../popover/popover";
import { HorizontalScrollBar, VerticalScrollBar } from "../scrollbar/";
import { Selection } from "../selection/selection";
import { SidePanelStore } from "../side_panel/side_panel/side_panel_store";
import { TableResizer } from "../tables/table_resizer/table_resizer";
import { DelayedHoveredCellStore } from "./delayed_hovered_cell_store";
/**
* The Grid component is the main part of the spreadsheet UI. It is responsible
* for displaying the actual grid, rendering it, managing events, ...
*
* The grid is rendered on a canvas. 3 sub components are (sometimes) displayed
* on top of the canvas:
* - a composer (to edit the cell content)
* - a horizontal resizer (to resize columns)
* - a vertical resizer (same, for rows)
*/
export type ContextMenuType = "ROW" | "COL" | "CELL" | "FILTER" | "GROUP_HEADERS" | "UNGROUP_HEADERS";
interface Props {
exposeFocus: (focus: () => void) => void;
getGridSize: () => DOMDimension;
}
export declare class Grid extends Component<Props, SpreadsheetChildEnv> {
static template: string;
static props: {
exposeFocus: FunctionConstructor;
getGridSize: FunctionConstructor;
};
static components: {
GridComposer: typeof GridComposer;
GridOverlay: typeof GridOverlay;
GridPopover: typeof GridPopover;
HeadersOverlay: typeof HeadersOverlay;
MenuPopover: typeof MenuPopover;
Autofill: typeof Autofill;
ClientTag: typeof ClientTag;
Highlight: typeof Highlight;
Popover: typeof Popover;
VerticalScrollBar: typeof VerticalScrollBar;
HorizontalScrollBar: typeof HorizontalScrollBar;
TableResizer: typeof TableResizer;
Selection: typeof Selection;
};
readonly HEADER_HEIGHT = 26;
readonly HEADER_WIDTH = 48;
private menuState;
private gridRef;
private highlightStore;
private cellPopovers;
private composerFocusStore;
private DOMFocusableElementStore;
private paintFormatStore;
private clientFocusStore;
dragNDropGrid: {
start: (initialPointerCoordinates: {
clientX: number;
clientY: number;
}, onPointerMove: (col: HeaderIndex, row: HeaderIndex, ev: MouseEvent) => void, onPointerUp: () => void, startScrollDirection?: import("../helpers/drag_and_drop_grid_hook").DnDDirection) => void;
};
onMouseWheel: (ev: WheelEvent) => void;
hoveredCell: Store<DelayedHoveredCellStore>;
sidePanel: Store<SidePanelStore>;
setup(): void;
get highlights(): import("../..").Highlight[];
get gridOverlayDimensions(): string;
onClosePopover(): void;
private keyDownMapping;
private focusComposerFromActiveCell;
private editOrMoveInSelection;
private moveInSelection;
private isSingleCellOrMergeSelection;
focusDefaultElement(): void;
get gridEl(): HTMLElement;
getAutofillPosition(): {
x: number;
y: number;
};
get isAutofillVisible(): boolean;
onGridResized(): void;
private moveCanvas;
private processSpaceKey;
getClientPositionKey(client: Client): string;
isCellHovered(col: HeaderIndex, row: HeaderIndex): boolean;
get focusedClients(): Set<string>;
private getGridRect;
onCellClicked(col: HeaderIndex, row: HeaderIndex, modifiers: GridClickModifiers, zoomedMouseEvent: ZoomedMouseEvent<PointerEvent>): void;
onCellDoubleClicked(col: HeaderIndex, row: HeaderIndex): void;
processArrows(ev: KeyboardEvent): void;
onKeydown(ev: KeyboardEvent): void;
onInputContextMenu(ev: MouseEvent): void;
onCellRightClicked(col: HeaderIndex, row: HeaderIndex, { x, y }: DOMCoordinates): void;
/**
* expects x and y coordinates in true pixels (not zoomed)
*/
toggleContextMenu(type: ContextMenuType, x: Pixel, y: Pixel): void;
copy(cut: boolean, ev: ClipboardEvent): Promise<void>;
paste(ev: ClipboardEvent): Promise<void>;
private clearFormatting;
private setHorizontalAlign;
closeMenu(): void;
private processHeaderGroupingKey;
private processHeaderGroupingEventOnHeaders;
private processHeaderGroupingEventOnWholeSheet;
private processHeaderGroupingEventOnGrid;
onComposerCellFocused(content?: string, selection?: ComposerSelection): void;
onComposerContentFocused(): void;
get staticTables(): Table[];
get displaySelectionHandler(): boolean;
}
export {};