@kermodes/grid 0.0.0-stage → 0.3.13-dev.68.g32b767a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/ColumnHeaderGroup.d.ts +8 -0
  2. package/dist/ContextMenu.d.ts +15 -0
  3. package/dist/EventHandlerResult.d.ts +16 -0
  4. package/dist/FilterBar.d.ts +32 -0
  5. package/dist/Grid.d.ts +458 -0
  6. package/dist/GridAxisRange.d.ts +9 -0
  7. package/dist/GridMetricCalculator.d.ts +509 -0
  8. package/dist/GridMetrics.d.ts +125 -0
  9. package/dist/GridModel.d.ts +96 -0
  10. package/dist/GridMouseHandler.d.ts +29 -0
  11. package/dist/GridRange.d.ts +268 -0
  12. package/dist/GridRenderer.d.ts +159 -0
  13. package/dist/GridRendererTypes.d.ts +25 -0
  14. package/dist/GridSelectionUtils.d.ts +97 -0
  15. package/dist/GridStyles.d.ts +2 -0
  16. package/dist/GridTheme.d.ts +96 -0
  17. package/dist/GridUtils.d.ts +457 -0
  18. package/dist/KeyHandler.d.ts +33 -0
  19. package/dist/RangedSelection.d.ts +118 -0
  20. package/dist/Selection.d.ts +218 -0
  21. package/dist/TableViewer.d.ts +16 -0
  22. package/dist/TableViewerGrid.d.ts +16 -0
  23. package/dist/TextCellRenderer.d.ts +8 -0
  24. package/dist/ThemeContext.d.ts +5 -0
  25. package/dist/ValuePopover.d.ts +23 -0
  26. package/dist/ViewportGridModel.d.ts +92 -0
  27. package/dist/cellValue.d.ts +11 -0
  28. package/dist/copy.d.ts +29 -0
  29. package/dist/cover.d.ts +16 -0
  30. package/dist/errors/AssertionError.d.ts +4 -0
  31. package/dist/errors/assertIsDefined.d.ts +2 -0
  32. package/dist/errors/index.d.ts +2 -0
  33. package/dist/fastMemoize.d.ts +50 -0
  34. package/dist/index.d.ts +32 -0
  35. package/dist/index.js +7909 -0
  36. package/dist/key-handlers/SelectionKeyHandler.d.ts +11 -0
  37. package/dist/key-handlers/index.d.ts +1 -0
  38. package/dist/menuItems.d.ts +53 -0
  39. package/dist/mouse-handlers/GridColumnMoveMouseHandler.d.ts +50 -0
  40. package/dist/mouse-handlers/GridColumnSeparatorMouseHandler.d.ts +27 -0
  41. package/dist/mouse-handlers/GridHorizontalScrollBarMouseHandler.d.ts +24 -0
  42. package/dist/mouse-handlers/GridScrollBarCornerMouseHandler.d.ts +14 -0
  43. package/dist/mouse-handlers/GridSelectionMouseHandler.d.ts +19 -0
  44. package/dist/mouse-handlers/GridSeparatorMouseHandler.d.ts +61 -0
  45. package/dist/mouse-handlers/GridVerticalScrollBarMouseHandler.d.ts +24 -0
  46. package/dist/mouse-handlers/index.d.ts +8 -0
  47. package/dist/sorting.d.ts +19 -0
  48. package/dist/utils.d.ts +15 -0
  49. package/package.json +28 -3
  50. package/README.md +0 -3
@@ -0,0 +1,8 @@
1
+ import { type MoveOperation } from './GridMetrics';
2
+ import { type BoundedAxisRange } from './GridAxisRange';
3
+ export interface IColumnHeaderGroup {
4
+ name: string;
5
+ depth: number;
6
+ color?: string;
7
+ getVisibleRange: (movedColumns: readonly MoveOperation[]) => BoundedAxisRange;
8
+ }
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { type MenuAction, type MenuItem } from './menuItems';
3
+ export type ContextMenuProps = {
4
+ x: number;
5
+ y: number;
6
+ sections: MenuItem[][];
7
+ onPick: (action: MenuAction) => void;
8
+ onClose: () => void;
9
+ };
10
+ /**
11
+ * A right-click menu over the grid. Escape, a click elsewhere, or scrolling
12
+ * closes it; arrow keys move between items.
13
+ */
14
+ export declare function ContextMenu({ x, y, sections, onPick, onClose, }: ContextMenuProps): React.ReactElement;
15
+ export default ContextMenu;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * An options object can be returned as the result to control
3
+ * if event.stopPropagation() and event.preventDefault() should be called
4
+ */
5
+ export type EventHandlerResultOptions = {
6
+ stopPropagation?: boolean;
7
+ preventDefault?: boolean;
8
+ };
9
+ /**
10
+ * Result from the event handler for an event.
11
+ * Return one of the following:
12
+ * - `false` if the event was not consumed and should be passed to other registered grid event handlers
13
+ * - `true` to stop the event from being passed along to other registered grid event handlers, as well as call event.stopPropagation() and event.preventDefault()
14
+ * - An `EventHandlerResultOptions` object to stop the event from being passed along to other registered grid event handlers, and decide whether to call event.stopPropagation() and/or event.preventDefault()
15
+ */
16
+ export type EventHandlerResult = boolean | EventHandlerResultOptions;
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ import type GridMetrics from './GridMetrics';
3
+ import { type DraggingColumn } from './mouse-handlers/GridColumnMoveMouseHandler';
4
+ import { type ViewportColumn } from '@kermodes/client';
5
+ /** Height of the quick filter bar under the column headers */
6
+ export declare const FILTER_BAR_HEIGHT = 26;
7
+ export declare const FILTER_SYNTAX: string;
8
+ export declare function filterPlaceholder(type: string): string;
9
+ /** Where one column's filter input sits, from the grid's metrics */
10
+ export type FilterCell = {
11
+ column: ViewportColumn;
12
+ left: number;
13
+ width: number;
14
+ };
15
+ /**
16
+ * The filter inputs' positions for the columns on screen, in display order. Columns being
17
+ * dragged sit where the drag draws them, under the pointer, not at the slot they hold.
18
+ */
19
+ export declare function filterCells(metrics: Pick<GridMetrics, 'columnsForRender' | 'allColumnXs' | 'allColumnWidths' | 'modelColumns' | 'gridX'>, columns: readonly ViewportColumn[], dragging?: DraggingColumn | null): FilterCell[];
20
+ type FilterBarProps = {
21
+ cells: readonly FilterCell[];
22
+ top: number;
23
+ filters: Readonly<Record<string, string>>;
24
+ errors: Readonly<Record<string, string>>;
25
+ onChange: (column: string, text: string) => void;
26
+ };
27
+ /**
28
+ * One text input per column under the headers, like Deephaven's quick filter bar. Each fills
29
+ * its column's cell of the band the renderer draws (`drawFilterBar`), short of the divider.
30
+ */
31
+ export declare function FilterBar({ cells, top, filters, errors, onChange, }: FilterBarProps): React.ReactElement;
32
+ export {};
package/dist/Grid.d.ts ADDED
@@ -0,0 +1,458 @@
1
+ import React, { PureComponent, type ReactNode, type RefObject } from 'react';
2
+ import GridMetricCalculator, { type GridMetricState } from './GridMetricCalculator';
3
+ import type GridModel from './GridModel';
4
+ import { type GridMouseEvent, type GridMouseHandlerFunctionName } from './GridMouseHandler';
5
+ import type GridMouseHandler from './GridMouseHandler';
6
+ import { type GridTheme as GridThemeType } from './GridTheme';
7
+ import GridRange, { type GridRangeIndex, SELECTION_DIRECTION } from './GridRange';
8
+ import GridRenderer from './GridRenderer';
9
+ import { type GridPoint } from './GridUtils';
10
+ import { type GridSeparator } from './mouse-handlers';
11
+ import { type DraggingColumn } from './mouse-handlers/GridColumnMoveMouseHandler';
12
+ import { type GridKeyHandlerFunctionName, type GridKeyboardEvent } from './KeyHandler';
13
+ import type KeyHandler from './KeyHandler';
14
+ import { type Coordinate, type ModelIndex, type MoveOperation, type VisibleIndex } from './GridMetrics';
15
+ import type GridMetrics from './GridMetrics';
16
+ import ThemeContext from './ThemeContext';
17
+ import { type GestureMode, type GetModel, type Selection } from './Selection';
18
+ import { type GridRenderState } from './GridRendererTypes';
19
+ export type GridProps = typeof Grid.defaultProps & {
20
+ children?: ReactNode;
21
+ canvasOptions?: CanvasRenderingContext2DSettings;
22
+ isStickyBottom?: boolean;
23
+ isStickyRight?: boolean;
24
+ isStuckToBottom?: boolean;
25
+ isStuckToRight?: boolean;
26
+ metricCalculator?: GridMetricCalculator;
27
+ model: GridModel;
28
+ keyHandlers?: readonly KeyHandler[];
29
+ mouseHandlers?: readonly GridMouseHandler[];
30
+ createEmptySelection?: (getModel: GetModel) => Selection;
31
+ movedColumns?: readonly MoveOperation[];
32
+ movedRows?: readonly MoveOperation[];
33
+ onError?: (e: Error) => void;
34
+ onSelectionChange?: (selection: Selection) => void;
35
+ onViewChanged?: (metrics: GridMetrics) => void;
36
+ renderer?: GridRenderer;
37
+ filterBarHeight?: number;
38
+ stateOverride?: Record<string, unknown>;
39
+ theme?: Partial<GridThemeType>;
40
+ };
41
+ export type GridState = {
42
+ top: VisibleIndex;
43
+ left: VisibleIndex;
44
+ topOffset: number;
45
+ leftOffset: number;
46
+ draggingColumn: DraggingColumn | null;
47
+ draggingColumnSeparator: GridSeparator | null;
48
+ isDraggingHorizontalScrollBar: boolean;
49
+ isDraggingVerticalScrollBar: boolean;
50
+ isDragging: boolean;
51
+ mouseX: number | null;
52
+ mouseY: number | null;
53
+ movedColumns: readonly MoveOperation[];
54
+ movedRows: readonly MoveOperation[];
55
+ selection: Selection;
56
+ lastSelection: Selection;
57
+ gestureMode: GestureMode | null;
58
+ cursor: string | null;
59
+ isStuckToBottom: boolean;
60
+ isStuckToRight: boolean;
61
+ /**
62
+ * Errors thrown during a render animation frame.
63
+ * These are not caught by the grid panel,
64
+ * so we need to throw them in componentDidUpdate
65
+ */
66
+ renderError?: unknown;
67
+ /** What revision the grid is drawing. Automatically increments when a forceUpdate is called. */
68
+ updateRevision: number;
69
+ };
70
+ /** Selection-related slice of `GridState`. Returned by gesture entry points. */
71
+ export type GridSelectionState = Pick<GridState, 'selection' | 'lastSelection'>;
72
+ /**
73
+ * High performance, extendible, themeable grid component.
74
+ * Architectured to be fast and handle billions of rows/columns by default.
75
+ * The base model does not provide support for sorting, filtering, etc.
76
+ * To get that functionality, extend GridModel/GridRenderer, and add onClick/onContextMenu handlers to implement your own sort.
77
+ *
78
+ * Extend GridModel with your own data model to provide the data for the grid.
79
+ * Extend GridTheme to change the appearance if the grid. See GridTheme for all the settable values.
80
+ * Extend GridMetricCalculator to provide different metrics for the grid, such as column sizing, header sizing, etc.
81
+ * Extend GridRenderer to have complete control over the rendering process. Can override just one method such as drawColumnHeader, or override the whole drawCanvas process.
82
+ *
83
+ * Add an onViewChanged callback to page in/out data as user moves around the grid
84
+ * Can also add onClick and onContextMenu handlers to add custom functionality and menus.
85
+ */
86
+ declare class Grid extends PureComponent<GridProps, GridState> {
87
+ static contextType: React.Context<Partial<GridThemeType>>;
88
+ context: React.ContextType<typeof ThemeContext>;
89
+ static defaultProps: {
90
+ canvasOptions: CanvasRenderingContext2DSettings;
91
+ isStickyBottom: boolean;
92
+ isStickyRight: boolean;
93
+ isStuckToBottom: boolean;
94
+ isStuckToRight: boolean;
95
+ keyHandlers: readonly KeyHandler[];
96
+ mouseHandlers: readonly GridMouseHandler[];
97
+ movedColumns: readonly MoveOperation[];
98
+ movedRows: readonly MoveOperation[];
99
+ filterBarHeight: number;
100
+ onError: () => void;
101
+ onSelectionChange: (_selection: Selection) => void;
102
+ onViewChanged: (metrics: GridMetrics) => void;
103
+ stateOverride: Record<string, unknown>;
104
+ theme: Partial<GridThemeType>;
105
+ createEmptySelection: (getModel: GetModel) => Selection;
106
+ };
107
+ static pixelsPerLine: number;
108
+ static dragTimeout: number;
109
+ static getTheme: import("memoize-one").MemoizedFn<(contextTheme: Partial<GridThemeType>, userTheme: Partial<GridThemeType>) => {
110
+ allowColumnResize: boolean;
111
+ allowRowResize: boolean;
112
+ autoSelectRow: boolean;
113
+ autoSelectColumn: boolean;
114
+ autoSizeColumns: boolean;
115
+ autoSizeRows: boolean;
116
+ backgroundColor: import("./GridTheme").GridColor;
117
+ textColor: import("./GridTheme").GridColor;
118
+ positiveNumberColor: import("./GridTheme").GridColor;
119
+ negativeNumberColor: import("./GridTheme").GridColor;
120
+ zeroNumberColor: import("./GridTheme").GridColor;
121
+ dateColor: import("./GridTheme").GridColor;
122
+ nullBackgroundColor: import("./GridTheme").NullableGridColor;
123
+ cellHorizontalPadding: number;
124
+ headerHorizontalPadding: number;
125
+ font: import("./GridTheme").GridFont;
126
+ gridColumnColor: import("./GridTheme").NullableGridColor;
127
+ gridRowColor: import("./GridTheme").NullableGridColor;
128
+ headerBackgroundColor: import("./GridTheme").GridColor;
129
+ headerSeparatorColor: import("./GridTheme").GridColor;
130
+ headerSeparatorHoverColor: import("./GridTheme").GridColor;
131
+ headerSeparatorHandleSize: number;
132
+ headerHiddenSeparatorSize: number;
133
+ headerHiddenSeparatorHoverColor: import("./GridTheme").GridColor;
134
+ headerColor: import("./GridTheme").GridColor;
135
+ headerFont: import("./GridTheme").GridFont;
136
+ columnHoverBackgroundColor: import("./GridTheme").NullableGridColor;
137
+ rowHoverBackgroundColor: import("./GridTheme").NullableGridColor;
138
+ selectedRowHoverBackgroundColor: import("./GridTheme").NullableGridColor;
139
+ cursorRowBackgroundColor: import("./GridTheme").NullableGridColor;
140
+ rowBackgroundColors: import("./GridTheme").GridColorWay;
141
+ minScrollHandleSize: number;
142
+ scrollBarBackgroundColor: import("./GridTheme").GridColor;
143
+ scrollBarHoverBackgroundColor: import("./GridTheme").GridColor;
144
+ scrollBarCasingColor: import("./GridTheme").GridColor;
145
+ scrollBarCornerColor: import("./GridTheme").GridColor;
146
+ scrollBarColor: import("./GridTheme").GridColor;
147
+ scrollBarHoverColor: import("./GridTheme").GridColor;
148
+ scrollBarActiveColor: import("./GridTheme").GridColor;
149
+ scrollBarSize: number;
150
+ scrollBarHoverSize: number;
151
+ scrollBarCasingWidth: number;
152
+ scrollSnapToColumn: boolean;
153
+ scrollSnapToRow: boolean;
154
+ scrollBarSelectionTick: boolean;
155
+ scrollBarSelectionTickColor: import("./GridTheme").NullableGridColor;
156
+ scrollBarActiveSelectionTickColor: import("./GridTheme").NullableGridColor;
157
+ activeCellSelectionBorderWidth: number;
158
+ selectionColor: import("./GridTheme").GridColor;
159
+ selectionOutlineColor: import("./GridTheme").GridColor;
160
+ selectionOutlineCasingColor: import("./GridTheme").GridColor;
161
+ reorderOffset: number;
162
+ shadowBlur: number;
163
+ shadowColor: import("./GridTheme").GridColor;
164
+ flashColor: import("./GridTheme").GridColor;
165
+ errorColor: import("./GridTheme").GridColor;
166
+ rowHeight: number;
167
+ columnWidth: number;
168
+ minColumnWidth: number;
169
+ maxColumnWidth: number;
170
+ columnHeaderHeight: number;
171
+ rowHeaderWidth: number;
172
+ rowFooterWidth: number;
173
+ headerResizeSnapThreshold: number;
174
+ headerResizeHiddenSnapThreshold: number;
175
+ floatingGridColumnColor: import("./GridTheme").NullableGridColor;
176
+ floatingGridRowColor: import("./GridTheme").NullableGridColor;
177
+ floatingRowBackgroundColors: import("./GridTheme").GridColorWay;
178
+ floatingDividerOuterColor: import("./GridTheme").GridColor;
179
+ floatingDividerInnerColor: import("./GridTheme").GridColor;
180
+ }>;
181
+ /**
182
+ * On some devices there may be different scaling required for high DPI. Get the scale required for the canvas.
183
+ * @param context The canvas context
184
+ * @returns The scale to use
185
+ */
186
+ static getScale(context: CanvasRenderingContext2D): number;
187
+ /**
188
+ * Get the floored layout size of an element, unaffected by CSS transforms.
189
+ * clientWidth/clientHeight round fractional sizes, which can make the canvas
190
+ * overflow its wrapper by a pixel, so read the fractional size from the
191
+ * computed style when available.
192
+ * @param element The element to get the size of
193
+ * @returns The floored layout width and height of the element
194
+ */
195
+ static getFlooredLayoutSize(element: HTMLElement): {
196
+ width: number;
197
+ height: number;
198
+ };
199
+ /**
200
+ * Get the class name from the cursor provided
201
+ * @param cursor The grid cursor to use
202
+ * @returns Class name with the grid-cursor prefix or null if no cursor provided
203
+ */
204
+ static getCursorClassName(cursor: string | null): string | null;
205
+ renderer: GridRenderer;
206
+ metricCalculator: GridMetricCalculator;
207
+ canvas: HTMLCanvasElement | null;
208
+ canvasContext: CanvasRenderingContext2D | null;
209
+ canvasWrapper: RefObject<HTMLDivElement | null>;
210
+ resizeObserver: ResizeObserver;
211
+ animationFrame: number | null;
212
+ prevMetrics: GridMetrics | null;
213
+ metrics: GridMetrics | null;
214
+ private renderState;
215
+ documentCursor: string | null;
216
+ hasAddedBlockEvents: boolean;
217
+ dragTimer: ReturnType<typeof setTimeout> | null;
218
+ keyHandlers: readonly KeyHandler[];
219
+ mouseHandlers: readonly GridMouseHandler[];
220
+ constructor(props: GridProps);
221
+ componentDidMount(): void;
222
+ componentDidUpdate(prevProps: GridProps, prevState: GridState): void;
223
+ componentWillUnmount(): void;
224
+ getTheme(): GridThemeType;
225
+ getGridPointFromEvent(event: GridMouseEvent): GridPoint;
226
+ getGridPointFromXY(x: Coordinate, y: Coordinate): GridPoint;
227
+ getMetricState(state?: Readonly<GridState>): GridMetricState;
228
+ getCachedKeyHandlers: import("memoize-one").MemoizedFn<(keyHandlers: readonly KeyHandler[]) => KeyHandler[]>;
229
+ getKeyHandlers(): readonly KeyHandler[];
230
+ getCachedMouseHandlers: import("memoize-one").MemoizedFn<(mouseHandlers: readonly GridMouseHandler[]) => readonly GridMouseHandler[]>;
231
+ getMouseHandlers(): readonly GridMouseHandler[];
232
+ /**
233
+ * Translate from the provided visible index to the model index
234
+ * @param columnIndex The column index to get the model for
235
+ * @returns The model index
236
+ */
237
+ getModelColumn(columnIndex: VisibleIndex): ModelIndex;
238
+ /**
239
+ * Translate from the provided visible index to the model index
240
+ * @param rowIndex The row index to get the model for
241
+ * @returns The model index
242
+ */
243
+ getModelRow(rowIndex: VisibleIndex): ModelIndex;
244
+ getStickyScrollPosition(isStickyBottom: boolean, isStickyRight: boolean): {
245
+ top: VisibleIndex;
246
+ left: VisibleIndex;
247
+ };
248
+ /**
249
+ * Allows the selected ranges to be set programatically
250
+ * Will update the cursor and selection start/end based on the new ranges
251
+ * @param gridRanges The new selected ranges to set
252
+ */
253
+ setSelectedRanges(gridRanges: readonly GridRange[]): void;
254
+ initContext(): void;
255
+ requestUpdateCanvas(): void;
256
+ /**
257
+ * Updates the canvas, metrics, and render state, then draws the canvas.
258
+ */
259
+ updateCanvas(): void;
260
+ private updateCanvasScale;
261
+ updateScrollBounds(): void;
262
+ /**
263
+ * Compares the current metrics with the previous metrics to see if we need to scroll when it is stuck to the bottom or the right
264
+ */
265
+ needToUpdateScroll(): boolean;
266
+ updateMetrics(state?: Readonly<GridState>): GridMetrics;
267
+ /**
268
+ * Check if the selection state has changed, and call the onSelectionChange callback if it has
269
+ * @param prevState The previous grid state
270
+ */
271
+ checkSelectionChange(prevState: GridState): void;
272
+ /**
273
+ * Validate the current selection, and reset if it is invalid
274
+ * @returns True if the selection is valid, false if the selection was invalid and has been reset
275
+ */
276
+ validateSelection(): boolean;
277
+ /**
278
+ * Clears all selected ranges
279
+ */
280
+ clearSelectedRanges(): void;
281
+ /** Clears all but the last selected range */
282
+ trimSelectedRanges(): void;
283
+ /** Sets the selection directly, bypassing mouse/keyboard gesture state. */
284
+ setSelection(selection: Selection): void;
285
+ /** Gets the current selection */
286
+ getSelection(): Selection;
287
+ /**
288
+ * Queries the current grid model.
289
+ * @returns The current GridModel instance.
290
+ */
291
+ getModel(): GridModel;
292
+ /**
293
+ * Extend + commit a gesture at `cursor` and return the resulting partial
294
+ * state. Shared by mouse click-and-release and keyboard commits.
295
+ *
296
+ * @param selection Pre-gesture selection to fold against. Cursor landing
297
+ * reads its extended (pre-commit) form so `KeyedSelection`'s overlay is
298
+ * still available.
299
+ * @param cursor Gesture target cell.
300
+ * @param mode Modifier-derived gesture mode.
301
+ * @param opts.moveCursor Snap the cursor to `cursor` (default true).
302
+ * Pass false for keyboard extend / maximize / add so the cursor stays put.
303
+ * @param opts.allowDeselect Whether committing on top of the same
304
+ * single-row / single-cell selection should deselect (mouse affordance,
305
+ * default true). Keyboard callers pass false so arrowing onto an
306
+ * already-selected cell just moves the cursor.
307
+ * @param opts.settle Whether the commit should finalize (deselect check,
308
+ * hole-punch, consolidation). Mouse-down passes false so a drag can grow
309
+ * the last range before mouse-up finalizes.
310
+ */
311
+ private applyGestureAt;
312
+ /**
313
+ * Start a mouse-driven selection gesture at `cursor` with the given
314
+ * modifier-derived `mode`. Extends the selection per `mode` semantics
315
+ * and commits immediately so a click without drag settles the state.
316
+ */
317
+ handleMouseSelectStart(cursor: {
318
+ row: GridRangeIndex;
319
+ column: GridRangeIndex;
320
+ }, mode: GestureMode): void;
321
+ /**
322
+ * Extend the current mouse selection gesture to `cursor`. Transient
323
+ * overlay only; the settled commit runs on `handleMouseSelectEnd`.
324
+ */
325
+ handleMouseSelectDrag(cursor: {
326
+ row: GridRangeIndex;
327
+ column: GridRangeIndex;
328
+ }): void;
329
+ /** Settle the current mouse selection gesture. Called on mouse-up. */
330
+ handleMouseSelectEnd(): void;
331
+ /**
332
+ * Apply a keyboard-driven selection gesture at `cursor` with `mode`, then
333
+ * optionally scroll the viewport to bring the cursor into view. Shared
334
+ * entry point for arrow keys, Home/End, and page-key movements.
335
+ *
336
+ * Only `replace` moves the cursor to `cursor`; extend/maximize/add
337
+ * preserve the existing cursor and update `selectionEnd` only. This
338
+ * matches long-standing Shift+Arrow semantics where the cursor stays put
339
+ * as the selection grows.
340
+ */
341
+ handleKeySelectAt(cursor: {
342
+ row: GridRangeIndex;
343
+ column: GridRangeIndex;
344
+ }, mode: GestureMode, opts?: {
345
+ keepCursorInView?: boolean;
346
+ }): void;
347
+ /**
348
+ * Advance the cursor in `direction` through the current selection. Used
349
+ * by Tab/Enter — cycles within the selected ranges when there are
350
+ * multiple, wraps at grid edges when there is only a single cell.
351
+ * When the resulting cursor falls outside the current selection (e.g.
352
+ * from an initial empty state), installs a fresh single-cell selection.
353
+ */
354
+ handleKeyAdvanceCursor(direction: SELECTION_DIRECTION): void;
355
+ /**
356
+ * Page-move gesture. `direction` is +1 (page-down) or -1 (page-up). Reads
357
+ * viewport metrics to compute the target cell, applies the gesture without
358
+ * auto-scrolling, then pins the viewport top so the cursor lands where it
359
+ * was on screen before.
360
+ */
361
+ private handleKeyPage;
362
+ handleKeyPageUp(mode: GestureMode): void;
363
+ handleKeyPageDown(mode: GestureMode): void;
364
+ /**
365
+ * Move the cursor to a cell without touching the selection.
366
+ */
367
+ handleKeyMoveCursor(column: VisibleIndex, row: VisibleIndex): void;
368
+ setFocusRow(focusedRow: number): void;
369
+ /**
370
+ * Set the selection to the entire grid
371
+ */
372
+ selectAll(): void;
373
+ /**
374
+ * Moves the view to make the specified cell visible
375
+ *
376
+ * @param column The column index to bring into view
377
+ * @param row The row index to bring into view
378
+ */
379
+ moveViewToCell(column: GridRangeIndex, row: GridRangeIndex): void;
380
+ /**
381
+ * Checks the `top` and `left` properties that are set and updates the isStuckToBottom/Right properties
382
+ * Should be called when user interaction occurs
383
+ * @param viewState New state properties to set.
384
+ * @param forceUpdate Whether to force an update.
385
+ */
386
+ setViewState(viewState: Partial<GridState>, forceUpdate?: boolean): void;
387
+ /**
388
+ * Check if a given cell is within the current selection
389
+ * @param row Row to check
390
+ * @param column Column to check
391
+ * @returns True if the cell is in the current selection, false otherwise
392
+ */
393
+ isSelected(row: VisibleIndex, column: VisibleIndex): boolean;
394
+ addDocumentCursor(cursor?: string | null): void;
395
+ removeDocumentCursor(): void;
396
+ startDragTimer(event: React.MouseEvent): void;
397
+ stopDragTimer(): void;
398
+ /**
399
+ * Draw the grid with the metrics provided
400
+ * When scrolling you've have to re-draw the whole canvas. As a consequence, all these drawing methods
401
+ * must be very quick.
402
+ */
403
+ private drawCanvas;
404
+ /**
405
+ * Set focus to this grid element
406
+ */
407
+ focus(): void;
408
+ /**
409
+ * Check if this grid is currently focused
410
+ * @returns True if the active element is this grid
411
+ */
412
+ isFocused(): boolean;
413
+ /**
414
+ * Handle a mouse click event. Pass the event to the registered mouse handlers until one handles it.
415
+ * Focuses the grid after the click.
416
+ * @param event The mouse event
417
+ */
418
+ handleClick(event: React.MouseEvent): void;
419
+ /**
420
+ * Handle a mouse context menu event. Pass the event to the registered mouse handlers until one handles it.
421
+ * @param event The mouse event triggering the context menu
422
+ */
423
+ handleContextMenu(event: React.MouseEvent): void;
424
+ /**
425
+ * Notify all of the keyboard handlers for this grid of a keyboard event.
426
+ * @param functionName The name of the function in the keyboard handler to call
427
+ * @param event The keyboard event to notify
428
+ */
429
+ notifyKeyboardHandlers(functionName: GridKeyHandlerFunctionName, event: GridKeyboardEvent): void;
430
+ handleKeyDown(event: GridKeyboardEvent): void;
431
+ handleKeyUp(event: GridKeyboardEvent): void;
432
+ /** Shows `cursor` over the canvas, eg. when a modifier key changes under a still pointer */
433
+ setCursor(cursor: string | null): void;
434
+ /**
435
+ * Notify all of the mouse handlers for this grid of a mouse event.
436
+ * @param functionName The name of the function in the mouse handler to call
437
+ * @param event The mouse event to notify
438
+ * @param updateCoordinates Whether to update the mouse coordinates
439
+ * @param addCursorToDocument Whether to add a cursor overlay or not (for dragging)
440
+ */
441
+ notifyMouseHandlers(functionName: GridMouseHandlerFunctionName, event: GridMouseEvent, updateCoordinates?: boolean, addCursorToDocument?: boolean): void;
442
+ handleMouseDown(event: React.MouseEvent): void;
443
+ handleDoubleClick(event: React.MouseEvent): void;
444
+ handleMouseMove(event: React.MouseEvent): void;
445
+ handleMouseLeave(event: React.MouseEvent): void;
446
+ handleMouseDrag(event: MouseEvent): void;
447
+ handleMouseUp(event: MouseEvent): void;
448
+ handleResize(): void;
449
+ forceUpdate(callback?: (() => void) | undefined): void;
450
+ handleWheel(event: WheelEvent): void;
451
+ /**
452
+ * Gets the render state
453
+ * @returns The render state
454
+ */
455
+ updateRenderState(): GridRenderState;
456
+ render(): ReactNode;
457
+ }
458
+ export default Grid;
@@ -0,0 +1,9 @@
1
+ import type { GridRangeIndex } from './GridRange';
2
+ import type { VisibleIndex } from './GridMetrics';
3
+ export type Range<T> = [start: T, end: T];
4
+ export type AxisRange = Range<GridRangeIndex>;
5
+ export type BoundedAxisRange = Range<VisibleIndex>;
6
+ export declare function isAxisRange(range: unknown): range is AxisRange;
7
+ export declare function assertAxisRange(range: unknown): asserts range is AxisRange;
8
+ export declare function isBoundedAxisRange(range: unknown): range is BoundedAxisRange;
9
+ export declare function assertBoundedAxisRange(range: unknown): asserts range is BoundedAxisRange;