@sheetxl/grid-react 0.7.21 → 0.7.23-beta.1
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.
- package/README.md +502 -2
- package/browser/cjs/index.cjs +3 -12
- package/browser/esm/index.mjs +5797 -1867
- package/licenses/dependencies.txt +143 -41
- package/node/esm/index.mjs +4951 -1861
- package/package.json +7 -6
- package/types/index.d.ts +2 -1497
- package/types/src/cell/CellLayer.d.ts +70 -0
- package/types/src/cell/CellLayer.d.ts.map +1 -0
- package/types/src/cell/CellRenderer.d.ts +42 -0
- package/types/src/cell/CellRenderer.d.ts.map +1 -0
- package/types/src/cell/DefaultCellRenderer.d.ts +6 -0
- package/types/src/cell/DefaultCellRenderer.d.ts.map +1 -0
- package/types/src/cell/GridlineLayer.d.ts +38 -0
- package/types/src/cell/GridlineLayer.d.ts.map +1 -0
- package/types/src/cell/Types.d.ts +12 -0
- package/types/src/cell/Types.d.ts.map +1 -0
- package/types/src/cell/_CellModel.d.ts +82 -0
- package/types/src/cell/_CellModel.d.ts.map +1 -0
- package/types/src/cell/index.d.ts +6 -0
- package/types/src/cell/index.d.ts.map +1 -0
- package/types/src/editor/DefaultEditable.d.ts +121 -0
- package/types/src/editor/DefaultEditable.d.ts.map +1 -0
- package/types/src/editor/EditSession.d.ts +182 -0
- package/types/src/editor/EditSession.d.ts.map +1 -0
- package/types/src/editor/EditState.d.ts +61 -0
- package/types/src/editor/EditState.d.ts.map +1 -0
- package/types/src/editor/EditorDiv.d.ts +65 -0
- package/types/src/editor/EditorDiv.d.ts.map +1 -0
- package/types/src/editor/EditorInput.d.ts +88 -0
- package/types/src/editor/EditorInput.d.ts.map +1 -0
- package/types/src/editor/EditorLayer.d.ts +69 -0
- package/types/src/editor/EditorLayer.d.ts.map +1 -0
- package/types/src/editor/EditorPlacement.d.ts +38 -0
- package/types/src/editor/EditorPlacement.d.ts.map +1 -0
- package/types/src/editor/index.d.ts +10 -0
- package/types/src/editor/index.d.ts.map +1 -0
- package/types/src/editor/useEditorKeymap.d.ts +74 -0
- package/types/src/editor/useEditorKeymap.d.ts.map +1 -0
- package/types/src/grid/Grid.d.ts +16 -0
- package/types/src/grid/Grid.d.ts.map +1 -0
- package/types/src/grid/IGrid.d.ts +93 -0
- package/types/src/grid/IGrid.d.ts.map +1 -0
- package/types/src/grid/index.d.ts +3 -0
- package/types/src/grid/index.d.ts.map +1 -0
- package/types/src/header/HeaderDividerAnchor.d.ts +120 -0
- package/types/src/header/HeaderDividerAnchor.d.ts.map +1 -0
- package/types/src/header/index.d.ts +3 -0
- package/types/src/header/index.d.ts.map +1 -0
- package/types/src/header/useHeaderSelectionPointer.d.ts +122 -0
- package/types/src/header/useHeaderSelectionPointer.d.ts.map +1 -0
- package/types/src/index.d.ts +13 -0
- package/types/src/index.d.ts.map +1 -0
- package/types/src/layer/HoverTipLayer.d.ts +74 -0
- package/types/src/layer/HoverTipLayer.d.ts.map +1 -0
- package/types/src/layer/Layer.d.ts +92 -0
- package/types/src/layer/Layer.d.ts.map +1 -0
- package/types/src/layer/LayerTypes.d.ts +47 -0
- package/types/src/layer/LayerTypes.d.ts.map +1 -0
- package/types/src/layer/RangePrompt.d.ts +42 -0
- package/types/src/layer/RangePrompt.d.ts.map +1 -0
- package/types/src/layer/Stage.d.ts +147 -0
- package/types/src/layer/Stage.d.ts.map +1 -0
- package/types/src/layer/StickyAnchor.d.ts +83 -0
- package/types/src/layer/StickyAnchor.d.ts.map +1 -0
- package/types/src/layer/StickyFloat.d.ts +65 -0
- package/types/src/layer/StickyFloat.d.ts.map +1 -0
- package/types/src/layer/VirtualDiv.d.ts +59 -0
- package/types/src/layer/VirtualDiv.d.ts.map +1 -0
- package/types/src/layer/_Utils.d.ts +37 -0
- package/types/src/layer/_Utils.d.ts.map +1 -0
- package/types/src/layer/index.d.ts +11 -0
- package/types/src/layer/index.d.ts.map +1 -0
- package/types/src/layer/useGridAnchor.d.ts +157 -0
- package/types/src/layer/useGridAnchor.d.ts.map +1 -0
- package/types/src/layer/useHoverIntent.d.ts +49 -0
- package/types/src/layer/useHoverIntent.d.ts.map +1 -0
- package/types/src/layer/useLayerResponder.d.ts +29 -0
- package/types/src/layer/useLayerResponder.d.ts.map +1 -0
- package/types/src/layer/usePlacement.d.ts +18 -0
- package/types/src/layer/usePlacement.d.ts.map +1 -0
- package/types/src/layer/useRangeHover.d.ts +35 -0
- package/types/src/layer/useRangeHover.d.ts.map +1 -0
- package/types/src/list/CheckboxList.d.ts +63 -0
- package/types/src/list/CheckboxList.d.ts.map +1 -0
- package/types/src/list/List.d.ts +55 -0
- package/types/src/list/List.d.ts.map +1 -0
- package/types/src/list/index.d.ts +3 -0
- package/types/src/list/index.d.ts.map +1 -0
- package/types/src/metrics/Types.d.ts +23 -0
- package/types/src/metrics/Types.d.ts.map +1 -0
- package/types/src/metrics/index.d.ts +3 -0
- package/types/src/metrics/index.d.ts.map +1 -0
- package/types/src/metrics/useGridMetrics.d.ts +67 -0
- package/types/src/metrics/useGridMetrics.d.ts.map +1 -0
- package/types/src/range/DragHandle.d.ts +129 -0
- package/types/src/range/DragHandle.d.ts.map +1 -0
- package/types/src/range/Draggable.d.ts +86 -0
- package/types/src/range/Draggable.d.ts.map +1 -0
- package/types/src/range/FillHandle.d.ts +54 -0
- package/types/src/range/FillHandle.d.ts.map +1 -0
- package/types/src/range/RangeRect.d.ts +36 -0
- package/types/src/range/RangeRect.d.ts.map +1 -0
- package/types/src/range/RangeResizer.d.ts +68 -0
- package/types/src/range/RangeResizer.d.ts.map +1 -0
- package/types/src/range/RangeStyle.d.ts +8 -0
- package/types/src/range/RangeStyle.d.ts.map +1 -0
- package/types/src/range/index.d.ts +13 -0
- package/types/src/range/index.d.ts.map +1 -0
- package/types/src/selection/DefaultSelection.d.ts +59 -0
- package/types/src/selection/DefaultSelection.d.ts.map +1 -0
- package/types/src/selection/ICellAnchor.d.ts +21 -0
- package/types/src/selection/ICellAnchor.d.ts.map +1 -0
- package/types/src/selection/ISelection.d.ts +65 -0
- package/types/src/selection/ISelection.d.ts.map +1 -0
- package/types/src/selection/RangesPickerLayer.d.ts +128 -0
- package/types/src/selection/RangesPickerLayer.d.ts.map +1 -0
- package/types/src/selection/SelectionLayer.d.ts +179 -0
- package/types/src/selection/SelectionLayer.d.ts.map +1 -0
- package/types/src/selection/SelectionStyle.d.ts +28 -0
- package/types/src/selection/SelectionStyle.d.ts.map +1 -0
- package/types/src/selection/SelectionTouchGrips.d.ts +29 -0
- package/types/src/selection/SelectionTouchGrips.d.ts.map +1 -0
- package/types/src/selection/SelectionUtils.d.ts +2 -0
- package/types/src/selection/SelectionUtils.d.ts.map +1 -0
- package/types/src/selection/Types.d.ts +67 -0
- package/types/src/selection/Types.d.ts.map +1 -0
- package/types/src/selection/_SelectionNavigation.d.ts +6 -0
- package/types/src/selection/_SelectionNavigation.d.ts.map +1 -0
- package/types/src/selection/_SelectionUtils.d.ts +7 -0
- package/types/src/selection/_SelectionUtils.d.ts.map +1 -0
- package/types/src/selection/index.d.ts +12 -0
- package/types/src/selection/index.d.ts.map +1 -0
- package/types/src/selection/useDragCells.d.ts +218 -0
- package/types/src/selection/useDragCells.d.ts.map +1 -0
- package/types/src/selection/useSelectionPointer.d.ts +70 -0
- package/types/src/selection/useSelectionPointer.d.ts.map +1 -0
- package/types/src/surface/GridPane.d.ts +85 -0
- package/types/src/surface/GridPane.d.ts.map +1 -0
- package/types/src/surface/GridPaneProvider.d.ts +37 -0
- package/types/src/surface/GridPaneProvider.d.ts.map +1 -0
- package/types/src/surface/GridSurface.d.ts +11 -0
- package/types/src/surface/GridSurface.d.ts.map +1 -0
- package/types/src/surface/IGridPane.d.ts +288 -0
- package/types/src/surface/IGridPane.d.ts.map +1 -0
- package/types/src/surface/IGridSurface.d.ts +141 -0
- package/types/src/surface/IGridSurface.d.ts.map +1 -0
- package/types/src/surface/SurfaceStateProvider.d.ts +50 -0
- package/types/src/surface/SurfaceStateProvider.d.ts.map +1 -0
- package/types/src/surface/_GridUtils.d.ts +37 -0
- package/types/src/surface/_GridUtils.d.ts.map +1 -0
- package/types/src/surface/index.d.ts +7 -0
- package/types/src/surface/index.d.ts.map +1 -0
- package/types/src/surface/useGridPane.d.ts +31 -0
- package/types/src/surface/useGridPane.d.ts.map +1 -0
- package/types/src/surface/useSurfaceState.d.ts +22 -0
- package/types/src/surface/useSurfaceState.d.ts.map +1 -0
- package/types/src/svg/LineSVG.d.ts +13 -0
- package/types/src/svg/LineSVG.d.ts.map +1 -0
- package/types/src/svg/RectangleSVG.d.ts +114 -0
- package/types/src/svg/RectangleSVG.d.ts.map +1 -0
- package/types/src/svg/ShapeBounds.d.ts +15 -0
- package/types/src/svg/ShapeBounds.d.ts.map +1 -0
- package/types/src/svg/Types.d.ts +37 -0
- package/types/src/svg/Types.d.ts.map +1 -0
- package/types/src/svg/index.d.ts +9 -0
- package/types/src/svg/index.d.ts.map +1 -0
- package/types/src/theme/GridTheme.d.ts +56 -0
- package/types/src/theme/GridTheme.d.ts.map +1 -0
- package/types/src/theme/index.d.ts +2 -0
- package/types/src/theme/index.d.ts.map +1 -0
- package/node/assets/style.css +0 -1
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { RangeCoords } from '@sheetxl/utils';
|
|
2
|
+
import { ISelection } from './ISelection';
|
|
3
|
+
/**
|
|
4
|
+
* Options for {@link useSelectionPointer}.
|
|
5
|
+
*/
|
|
6
|
+
export interface SelectionPointerOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Allow Ctrl/Cmd-dragging over an already-selected area to remove it.
|
|
9
|
+
*
|
|
10
|
+
* @defaultValue true
|
|
11
|
+
*/
|
|
12
|
+
allowDeselect?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Allow Ctrl/Cmd to append (and, with {@link SelectionPointerOptions.allowDeselect}, remove)
|
|
15
|
+
* additional ranges. When `false` the selection is held to a **single range** (the modifier is
|
|
16
|
+
* treated as a plain replace) — for single-rectangle range pickers like precedents / chart data
|
|
17
|
+
* ranges, where multi-range selection is meaningless.
|
|
18
|
+
*
|
|
19
|
+
* @defaultValue true
|
|
20
|
+
*/
|
|
21
|
+
allowMulti?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Fired when a selection pointer interaction **ends** (pointer-up after a click or drag on the grid).
|
|
24
|
+
* A consumer uses it for "act on the range the user just selected" — e.g. the format painter applies
|
|
25
|
+
* the copied format to the just-selected destination. Command-free; view-side only.
|
|
26
|
+
*/
|
|
27
|
+
onSelectionEnd?: (e: React.PointerEvent) => void;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Handlers + transient drag state produced by {@link useSelectionPointer}, to spread onto an
|
|
31
|
+
* a `Layer` tap.
|
|
32
|
+
*/
|
|
33
|
+
export interface SelectionPointerResult {
|
|
34
|
+
onPointerDown: (e: React.PointerEvent) => void;
|
|
35
|
+
onPointerMove: (e: React.PointerEvent) => void;
|
|
36
|
+
onPointerUp: (e: React.PointerEvent) => void;
|
|
37
|
+
/**
|
|
38
|
+
* The rubber-band rectangle to render while a Ctrl/Cmd remove-drag is in progress, else `null`.
|
|
39
|
+
* The layer renders this; the actual removal is applied to the model on pointer-up.
|
|
40
|
+
*/
|
|
41
|
+
removePreview: RangeCoords | null;
|
|
42
|
+
/**
|
|
43
|
+
* What the in-flight pointer drag is doing — `'extend'` (a drag-select growing the active range),
|
|
44
|
+
* `'remove'` (Ctrl/Cmd remove-drag), or `null` (no drag). Flips only on down / up (not per move), so a
|
|
45
|
+
* layer can show a transient tip (e.g. live R×C) without re-rendering on every pointer move.
|
|
46
|
+
*/
|
|
47
|
+
dragMode: 'extend' | 'remove' | null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The body selection pointer controller. Translates raw pointer gestures into {@link ISelection} intents
|
|
51
|
+
* and **holds no range math itself** — every mutation is a model call (`setSelection` / `modify` /
|
|
52
|
+
* `append` / `deselect`). The drag *mechanics* (pointer capture, per-cell de-dup, held-still auto-scroll)
|
|
53
|
+
* live in the shared {@link useDragCells} engine; this hook is just the body's policy adapter over it,
|
|
54
|
+
* plus the remove-drag rubber-band (the one piece of React state a drag renders).
|
|
55
|
+
*
|
|
56
|
+
* @remarks
|
|
57
|
+
* View-coupled by nature: {@link useDragCells} reads the pane for hit-testing and drives directional
|
|
58
|
+
* auto-scroll, so it lives in grid-react, not the sdk. It is the single mouse path (touch will fold into
|
|
59
|
+
* the same handlers later).
|
|
60
|
+
*
|
|
61
|
+
* Gestures:
|
|
62
|
+
* - **Click + drag** → new selection at the cell, drag extends it.
|
|
63
|
+
* - **Shift + click/drag** → extend the active range from the existing anchor.
|
|
64
|
+
* - **Ctrl/Cmd + click/drag on empty** → append a new range, drag extends it.
|
|
65
|
+
* - **Ctrl/Cmd + click/drag on selected** → remove-drag (rubber-band), applied on release.
|
|
66
|
+
*
|
|
67
|
+
* The Stage element is pointer-captured for the drag so move / up keep firing past the viewport edge.
|
|
68
|
+
*/
|
|
69
|
+
export declare const useSelectionPointer: (selection: ISelection, options?: SelectionPointerOptions) => SelectionPointerResult;
|
|
70
|
+
//# sourceMappingURL=useSelectionPointer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSelectionPointer.d.ts","sourceRoot":"","sources":["../../../../src/selection/useSelectionPointer.ts"],"names":[],"mappings":"AAEA,OAAO,EAA+B,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAI/E,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/C;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,YAAY,KAAK,IAAI,CAAC;CAClD;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,aAAa,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,YAAY,KAAK,IAAI,CAAC;IAC/C,aAAa,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,YAAY,KAAK,IAAI,CAAC;IAC/C,WAAW,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,YAAY,KAAK,IAAI,CAAC;IAC7C;;;OAGG;IACH,aAAa,EAAE,WAAW,GAAG,IAAI,CAAC;IAClC;;;;OAIG;IACH,QAAQ,EAAE,QAAQ,GAAG,QAAQ,GAAG,IAAI,CAAC;CACtC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,mBAAmB,GAC9B,WAAW,UAAU,EACrB,UAAU,uBAAuB,KAChC,sBAuHF,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { AnchorLocation, CellCoords, RangeCoords, OrientationFlags, TopLeft, Point, Rectangle } from '@sheetxl/utils';
|
|
3
|
+
import { IViewport } from '@sheetxl/utils-react';
|
|
4
|
+
import { IGridMetrics } from '../metrics';
|
|
5
|
+
import { IGridPane } from './IGridPane';
|
|
6
|
+
import { IStageElement } from '../layer/Stage';
|
|
7
|
+
/**
|
|
8
|
+
* Per-axis dimensions for a single pane (one entry for the scrolling pane, one for the frozen pane).
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* The structural fields (minCoord/maxCoord/minBounds/maxBounds/maxVirtualBounds/freezeOffset) are
|
|
12
|
+
* scroll-independent; minIndex/maxIndex/metrics/visibleIndices/scrollOffset vary with scroll and are
|
|
13
|
+
* read live per-frame.
|
|
14
|
+
*/
|
|
15
|
+
export interface GridPaneDimensions {
|
|
16
|
+
minIndex: number;
|
|
17
|
+
maxIndex: number;
|
|
18
|
+
minCoord: number;
|
|
19
|
+
maxCoord: number;
|
|
20
|
+
visibleIndices: (from?: number, to?: number) => readonly number[];
|
|
21
|
+
minBounds: number;
|
|
22
|
+
maxBounds: number;
|
|
23
|
+
metrics: IGridMetrics;
|
|
24
|
+
maxVirtualBounds: number;
|
|
25
|
+
scrollOffset: number;
|
|
26
|
+
freezeOffset: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Static description of a pane: where it sits in the freeze grid, its scroll orientation, its insets,
|
|
30
|
+
* and the {@link Stage} element/ref that backs it. Stable across scroll.
|
|
31
|
+
*/
|
|
32
|
+
export interface GridPaneDef {
|
|
33
|
+
anchor: AnchorLocation;
|
|
34
|
+
columnIndex: number;
|
|
35
|
+
rowIndex: number;
|
|
36
|
+
elemStage: React.ReactNode;
|
|
37
|
+
refStage: IStageElement | null;
|
|
38
|
+
scrollOrientation: OrientationFlags;
|
|
39
|
+
insets: Rectangle;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Everything {@link createGridPane} needs from the surrounding `GridSurface` to build an
|
|
43
|
+
* {@link IGridPane}.
|
|
44
|
+
*
|
|
45
|
+
* @remarks
|
|
46
|
+
* Most fields are values/factories computed before pane creation. A few (`getSurfacePointFromPointer`,
|
|
47
|
+
* `scrollTo`, `scrollCellCoordsIntoView`, `getAllPanes`) are defined *after* the panes in the surface
|
|
48
|
+
* render and must be passed as call-time wrappers (they are only invoked later, never during pane
|
|
49
|
+
* creation).
|
|
50
|
+
*/
|
|
51
|
+
export interface GridPaneDeps {
|
|
52
|
+
/** Structural row dimensions (scroll-0 snapshot). */
|
|
53
|
+
rowDims: readonly GridPaneDimensions[];
|
|
54
|
+
/** Structural column dimensions (scroll-0 snapshot). */
|
|
55
|
+
columnDims: readonly GridPaneDimensions[];
|
|
56
|
+
/** Live row dimensions for a given scrollTop. */
|
|
57
|
+
computeRowDims: (scrollTop: number) => readonly GridPaneDimensions[];
|
|
58
|
+
/** Live column dimensions for a given scrollLeft. */
|
|
59
|
+
computeColumnDims: (scrollLeft: number) => readonly GridPaneDimensions[];
|
|
60
|
+
viewport: IViewport;
|
|
61
|
+
zoom: number;
|
|
62
|
+
containerWidth: number;
|
|
63
|
+
containerHeight: number;
|
|
64
|
+
getRangeFromCell: (coords: CellCoords) => RangeCoords;
|
|
65
|
+
invalidate: () => void;
|
|
66
|
+
/** The full grid range, shared by all panes. */
|
|
67
|
+
totalRange: RangeCoords;
|
|
68
|
+
getSurfacePointFromPointer: (clientX: number, clientY: number) => Point | null;
|
|
69
|
+
scrollTo: (options?: ScrollToOptions | number[]) => void;
|
|
70
|
+
scrollCellCoordsIntoView: (coords: Partial<CellCoords>, options?: globalThis.ScrollIntoViewOptions | boolean, anchor?: AnchorLocation) => Promise<Partial<TopLeft>>;
|
|
71
|
+
getAllPanes: () => Readonly<Partial<Record<AnchorLocation, IGridPane>>>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Build the {@link IGridPane} handle for a single {@link GridPaneDef}.
|
|
75
|
+
*
|
|
76
|
+
* @returns The pane, or `null` for a degenerate (empty) freeze pane.
|
|
77
|
+
*
|
|
78
|
+
* @remarks
|
|
79
|
+
* Pure factory — no hooks, no JSX. The pane OBJECT is stable across scroll; its volatile geometry is
|
|
80
|
+
* recomputed live per-frame via `getFrame()` (memoized on the viewport snapshot).
|
|
81
|
+
*/
|
|
82
|
+
export declare const createGridPane: (def: GridPaneDef, deps: GridPaneDeps) => IGridPane | null;
|
|
83
|
+
export declare const createTranslatedMetrics: (base: IGridMetrics, scrollPoint: Partial<TopLeft>, point?: Partial<Point>) => IGridMetrics;
|
|
84
|
+
export declare const EmptyPanes: readonly GridPaneDimensions[];
|
|
85
|
+
//# sourceMappingURL=GridPane.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GridPane.d.ts","sourceRoot":"","sources":["../../../../src/surface/GridPane.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EACQ,cAAc,EAC3B,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,KAAK,gBAAgB,EAAE,KAAK,OAAO,EACtE,KAAK,KAAK,EAAE,KAAK,SAAS,EAC3B,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default as React } from 'react';
|
|
2
|
+
import { ViewportStore } from '@sheetxl/utils-react';
|
|
3
|
+
import { IGridPane } from './IGridPane';
|
|
4
|
+
/**
|
|
5
|
+
* Context for providing IGridPane to descendant components.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* The value is a `{ pane }` wrapper (not the bare pane) so the provider can hand descendants a NEW
|
|
9
|
+
* identity on each scroll — the pane object itself is stable across scroll, but layers
|
|
10
|
+
* must still re-render to re-read its scroll-dependent geometry. The wrapper changes identity when
|
|
11
|
+
* the pane changes (structural) OR the viewport scrolls.
|
|
12
|
+
*/
|
|
13
|
+
export declare const GridPaneContext: React.Context<{
|
|
14
|
+
pane: IGridPane;
|
|
15
|
+
} | null>;
|
|
16
|
+
export interface PaneProviderProps {
|
|
17
|
+
pane: IGridPane;
|
|
18
|
+
/**
|
|
19
|
+
* The scroll store. When provided, the provider subscribes and re-renders its consumers on every
|
|
20
|
+
* scroll (the panes are stable, so this is what makes layers re-read live geometry). Optional so a
|
|
21
|
+
* standalone `GridPaneProvider` (e.g. in a test) still works — it just won't track scroll.
|
|
22
|
+
*/
|
|
23
|
+
viewport?: ViewportStore;
|
|
24
|
+
children: React.ReactNode;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Provider component that makes IGridPane available to all descendant layers
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* <GridPaneProvider pane={pane} viewport={viewport}>
|
|
32
|
+
* <Layer x={100} y={100} width={200} height={100} />
|
|
33
|
+
* </GridPaneProvider>
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare const GridPaneProvider: React.FC<PaneProviderProps>;
|
|
37
|
+
//# sourceMappingURL=GridPaneProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GridPaneProvider.d.ts","sourceRoot":"","sources":["../../../../src/surface/GridPaneProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAqC,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE7F,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe;UAAyB,SAAS;SAAgB,CAAC;AAE/E,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,SAAS,CAAC;IAChB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAWxD,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { GridSurfaceProps, IGridSurface } from './IGridSurface';
|
|
3
|
+
/**
|
|
4
|
+
* GridSurface for rendering layers into virtual panels using
|
|
5
|
+
* IGridMetrics.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* * To support scrolling, wrap it in a `ScrollPane` and pass both the same {@link IViewport}.
|
|
9
|
+
*/
|
|
10
|
+
export declare const GridSurface: React.NamedExoticComponent<Omit<GridSurfaceProps, "ref"> & React.RefAttributes<IGridSurface>>;
|
|
11
|
+
//# sourceMappingURL=GridSurface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GridSurface.d.ts","sourceRoot":"","sources":["../../../../src/surface/GridSurface.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAsC/B,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,YAAY,EAA+B,MAAM,gBAAgB,CAAC;AAMvG;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,+FAg7BrB,CAAC"}
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { CellCoords, RangeCoords, OrientationFlags, TopLeft, Point, Rectangle, Bounds, Size, AnchorLocation, RemoveListener } from '@sheetxl/utils';
|
|
3
|
+
import { IGridMetrics } from '../metrics';
|
|
4
|
+
/**
|
|
5
|
+
* Describes a virtualize handle to a view section of a grid.
|
|
6
|
+
*/
|
|
7
|
+
export interface IGridPane {
|
|
8
|
+
/**
|
|
9
|
+
* Sets focus to the view.
|
|
10
|
+
*/
|
|
11
|
+
focus(options?: FocusOptions): void;
|
|
12
|
+
/**
|
|
13
|
+
* Set pointer capture to the view.
|
|
14
|
+
*/
|
|
15
|
+
setPointerCapture(pointerId: number): void;
|
|
16
|
+
/**
|
|
17
|
+
* Release pointer capture from the view.
|
|
18
|
+
*/
|
|
19
|
+
releasePointerCapture(pointerId: number): void;
|
|
20
|
+
/**
|
|
21
|
+
* The anchor for the view.
|
|
22
|
+
*/
|
|
23
|
+
getAnchor(): AnchorLocation;
|
|
24
|
+
/**
|
|
25
|
+
* Allow for dimensions to be determined for various cells.
|
|
26
|
+
* The `IGridMetrics` is inclusive of the zoom.
|
|
27
|
+
*/
|
|
28
|
+
getMetrics(): IGridMetrics;
|
|
29
|
+
/**
|
|
30
|
+
* The LIVE visible range of THIS pane — exactly the cells on screen right now. Changes as the pane
|
|
31
|
+
* scrolls. Same span as {@link getVisibleRows} / {@link getVisibleColumns}.
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* One of three range concepts, from narrowest to widest:
|
|
35
|
+
* - {@link getVisibleRange} — this pane, on screen now (scroll-dependent).
|
|
36
|
+
* - {@link getPaneRange} — this pane's full structural coverage (scroll-independent).
|
|
37
|
+
* - {@link getTotalRange} — the whole grid, all panes.
|
|
38
|
+
*/
|
|
39
|
+
getVisibleRange(): Readonly<RangeCoords>;
|
|
40
|
+
/**
|
|
41
|
+
* The visible (non-hidden) rows as {@link SpanSize} tracks (index + geometry), in order — so a
|
|
42
|
+
* caller iterates position + width in one pass; the array position is the visible ordinal.
|
|
43
|
+
*
|
|
44
|
+
* @param from Optional start index — overrides the viewport with a FRESH scan of exactly `[from, to]`
|
|
45
|
+
* (e.g. an overscan buffer, which extends past the viewport). Hidden runs are still skipped; the
|
|
46
|
+
* range is NOT clamped to the viewport. Caller keeps it within the grid.
|
|
47
|
+
* @param to Optional (inclusive) end index. Both `from` and `to` must be supplied to override.
|
|
48
|
+
*/
|
|
49
|
+
getVisibleRows(from?: number, to?: number): readonly SpanSize[];
|
|
50
|
+
/**
|
|
51
|
+
* The visible (non-hidden) columns as {@link SpanSize} tracks (index + geometry), in order.
|
|
52
|
+
*
|
|
53
|
+
* @param from Optional start index — overrides the viewport with a custom range (see {@link getVisibleRows}).
|
|
54
|
+
* @param to Optional (inclusive) end index.
|
|
55
|
+
*/
|
|
56
|
+
getVisibleColumns(from?: number, to?: number): readonly SpanSize[];
|
|
57
|
+
/**
|
|
58
|
+
* The geometry of ONE column by index (random access), or `null` for an out-of-grid index. Backed by
|
|
59
|
+
* the metrics cache — window-independent, so it also resolves off-viewport (overscan) tracks. Prefer
|
|
60
|
+
* {@link getVisibleColumns} when iterating; use this for the odd lookup (e.g. a merge boundary).
|
|
61
|
+
*/
|
|
62
|
+
getColumnSize(index: number): SpanSize | null;
|
|
63
|
+
/**
|
|
64
|
+
* The geometry of ONE row by index (random access), or `null` for an out-of-grid index. See
|
|
65
|
+
* {@link getColumnSize}.
|
|
66
|
+
*/
|
|
67
|
+
getRowSize(index: number): SpanSize | null;
|
|
68
|
+
/**
|
|
69
|
+
* Clip a rectangle against the viewport, culling to `null` when it falls fully outside — the
|
|
70
|
+
* clip/cull primitive. Pair with {@link getBoundsFromRange} for the common "range → visible bounds"
|
|
71
|
+
* path: `toClipBounds(getBoundsFromRange(range), insets)`.
|
|
72
|
+
*
|
|
73
|
+
* @param bounds The (view-relative) rect to clip. Defaults to the full pane bounds.
|
|
74
|
+
* @param insets Slack in view pixels. A negative inset extends OUTSIDE the viewport, so elements
|
|
75
|
+
* that visually 'flow' off the edge (e.g. a selection with an outward-growing border) are not
|
|
76
|
+
* culled while still partly visible.
|
|
77
|
+
*
|
|
78
|
+
* @remarks
|
|
79
|
+
* Returns `null` when nothing survives the clip (the rect is entirely off-screen).
|
|
80
|
+
*/
|
|
81
|
+
toClipBounds(bounds?: Bounds, insets?: number | Bounds): Bounds | null;
|
|
82
|
+
/**
|
|
83
|
+
* ABSOLUTE → VIEW: map a rect from scroll-independent content space into this pane's view space
|
|
84
|
+
* (subtract the pane's scroll offset, then apply zoom). The inverse of {@link toAbsoluteBounds}.
|
|
85
|
+
*
|
|
86
|
+
* @remarks
|
|
87
|
+
* A distinct axis from {@link getBoundsFromRange} / {@link toClipBounds}, which already live in view
|
|
88
|
+
* space. This pair exists for content anchored in ABSOLUTE space — a floating movable (image / chart
|
|
89
|
+
* / shape) whose position must survive scroll & zoom. Use this to render such a movable at its current
|
|
90
|
+
* on-screen spot; use {@link toAbsoluteBounds} to persist a drag result back to the model. Cells never
|
|
91
|
+
* need it (they are range-derived, hence already view-space).
|
|
92
|
+
*/
|
|
93
|
+
toPaneBounds(bounds: Bounds): Bounds;
|
|
94
|
+
/**
|
|
95
|
+
* VIEW → ABSOLUTE: map a rect from this pane's view space back into scroll-independent content space
|
|
96
|
+
* (undo zoom, then add the pane's scroll offset). The inverse of {@link toPaneBounds}.
|
|
97
|
+
*
|
|
98
|
+
* @remarks
|
|
99
|
+
* See {@link toPaneBounds}. Used to store a movable's live (view-space) drag/resize result as
|
|
100
|
+
* scroll-independent model bounds, so it stays anchored as the grid scrolls or zooms.
|
|
101
|
+
*/
|
|
102
|
+
toAbsoluteBounds(bounds: Bounds): Bounds;
|
|
103
|
+
/**
|
|
104
|
+
* Additional inside padding.
|
|
105
|
+
*/
|
|
106
|
+
getInsets(): Rectangle;
|
|
107
|
+
/**
|
|
108
|
+
* Returns the cell as a range.
|
|
109
|
+
*
|
|
110
|
+
* @remarks
|
|
111
|
+
* If this cell spans this will return a range later than 1.
|
|
112
|
+
* Note - This may return ranges for Cells if if they are not the top left.
|
|
113
|
+
*/
|
|
114
|
+
getRangeFromCell(coords: CellCoords): RangeCoords;
|
|
115
|
+
/**
|
|
116
|
+
* The view-relative bounds of a range — the raw geometry primitive (never clipped, never `null`).
|
|
117
|
+
*
|
|
118
|
+
* @param range The range to measure. Defaults to the visible cell range.
|
|
119
|
+
* @param adjustment Optional per-edge pixel offset of the returned rect (each edge moves
|
|
120
|
+
* independently — this is NOT an inset, which would shrink symmetrically).
|
|
121
|
+
*
|
|
122
|
+
* @remarks
|
|
123
|
+
* Bounds are relative to the view (they move with scroll), NOT absolute. This resolves ANY
|
|
124
|
+
* range, including one entirely off-screen (e.g. an overscan/buffer cell), so callers that must
|
|
125
|
+
* place off-viewport content use it directly. For "geometry only if visible" (clipped to the pane,
|
|
126
|
+
* culled to `null` when off-screen) compose with {@link toClipBounds}:
|
|
127
|
+
* `toClipBounds(getBoundsFromRange(range), insets)`.
|
|
128
|
+
*/
|
|
129
|
+
getBoundsFromRange(range?: RangeCoords, adjustment?: Partial<Rectangle>): Bounds;
|
|
130
|
+
/**
|
|
131
|
+
* Scroll the cell coords into view.
|
|
132
|
+
* If the coord does not have an index it will only scroll in a single direction.
|
|
133
|
+
*/
|
|
134
|
+
scrollCellCoordsIntoView(coords: Partial<CellCoords>, options?: globalThis.ScrollIntoViewOptions | boolean): Promise<Partial<TopLeft>>;
|
|
135
|
+
/**
|
|
136
|
+
* Scroll to the specified top/left.
|
|
137
|
+
* @param options
|
|
138
|
+
*/
|
|
139
|
+
scrollTo(options?: ScrollToOptions): void;
|
|
140
|
+
/**
|
|
141
|
+
* Indicate the allowable scroll directions.
|
|
142
|
+
*/
|
|
143
|
+
getScrollOrientation(): OrientationFlags;
|
|
144
|
+
/**
|
|
145
|
+
* Returns the current scroll top/left for the view.
|
|
146
|
+
*/
|
|
147
|
+
getScrollTopLeft(): TopLeft;
|
|
148
|
+
/**
|
|
149
|
+
* The pane's scroll baseline at the viewport TARGET — {@link getScrollTopLeft} plus any in-flight
|
|
150
|
+
* scroll (an animated glide, or an applied-but-not-yet-ticked instant target). Frame-invariant math
|
|
151
|
+
* (chaining PageDowns under key repeat, paging during a glide) must baseline here: the rendered
|
|
152
|
+
* position can lag the authoritative target by a frame or a whole animation.
|
|
153
|
+
*/
|
|
154
|
+
getScrollTarget?(): TopLeft;
|
|
155
|
+
/**
|
|
156
|
+
* The frozen region's pixel offset for this pane (`{ left, top }`, view px). Like
|
|
157
|
+
* {@link getScrollTopLeft}, this is a pixel `TopLeft` — NOT a cell count. `{ left: 0, top: 0 }` when
|
|
158
|
+
* nothing is frozen on that axis.
|
|
159
|
+
*
|
|
160
|
+
* @remarks
|
|
161
|
+
* For the freeze STRUCTURE use {@link getAllPanes} — the `Top` / `Left` / `TopLeft` entries exist only
|
|
162
|
+
* when frozen — and each frozen pane's {@link getPaneRange} is exactly its frozen cell band, so
|
|
163
|
+
* `getPaneRange().colEnd + 1` / `.rowEnd + 1` gives the frozen column / row COUNT. The configured
|
|
164
|
+
* freeze count as a model value lives on `ISheetView.getFreezePanes().coords`.
|
|
165
|
+
*/
|
|
166
|
+
getFreezeTopLeft(): TopLeft;
|
|
167
|
+
/**
|
|
168
|
+
* Useful for internal rendering.
|
|
169
|
+
*
|
|
170
|
+
* @remarks
|
|
171
|
+
* The cell layout will account for zoom factors already.
|
|
172
|
+
*/
|
|
173
|
+
getZoom(): number;
|
|
174
|
+
/**
|
|
175
|
+
* Returns the range for the entire GridSurface.
|
|
176
|
+
*/
|
|
177
|
+
getTotalRange(): Readonly<RangeCoords>;
|
|
178
|
+
/**
|
|
179
|
+
* The size of the surface for all grid panes.
|
|
180
|
+
*/
|
|
181
|
+
getSurfaceSize(): Size;
|
|
182
|
+
/**
|
|
183
|
+
* Returns the total size of all rendered values in pixels.
|
|
184
|
+
*/
|
|
185
|
+
getTotalSize(): Size;
|
|
186
|
+
/**
|
|
187
|
+
* The STRUCTURAL range of THIS pane — the full band of cells the pane is responsible for, scroll-
|
|
188
|
+
* independent (most of it is usually off-screen). The center/scrolling pane spans
|
|
189
|
+
* `[freezeLeft..columnCount-1] × [freezeTop..rowCount-1]`; a frozen pane spans its frozen band.
|
|
190
|
+
*
|
|
191
|
+
* @remarks
|
|
192
|
+
* NOT the visible range — see {@link getVisibleRange} for the on-screen cells, and
|
|
193
|
+
* {@link getTotalRange} for the whole grid across all panes.
|
|
194
|
+
*/
|
|
195
|
+
getPaneRange(): RangeCoords;
|
|
196
|
+
/**
|
|
197
|
+
* The STRUCTURAL pixel rectangle of THIS pane within the surface — scroll-independent (a frozen-left
|
|
198
|
+
* pane sits at `x: 0`; the center pane starts at the freeze width). The pixel-space analog of
|
|
199
|
+
* {@link getPaneRange}.
|
|
200
|
+
*
|
|
201
|
+
* @remarks
|
|
202
|
+
* NOT view-relative and NOT clipped — it is the pane's own box on the surface. For a range's
|
|
203
|
+
* geometry use {@link getBoundsFromRange}; for the whole-surface / content sizes see
|
|
204
|
+
* {@link getSurfaceSize} / {@link getTotalSize}.
|
|
205
|
+
*/
|
|
206
|
+
getPaneBounds(): Bounds;
|
|
207
|
+
/**
|
|
208
|
+
* Convert a CLIENT coordinate (browser-viewport pixels, e.g. a pointer event's `clientX`/`clientY`)
|
|
209
|
+
* into a point in this pane's view space — the same space {@link getBoundsFromRange} returns — so the
|
|
210
|
+
* result can be hit-tested directly against a range's bounds.
|
|
211
|
+
*
|
|
212
|
+
* @param clientX Client x, as from `PointerEvent.clientX`.
|
|
213
|
+
* @param clientY Client y, as from `PointerEvent.clientY`.
|
|
214
|
+
*
|
|
215
|
+
* @remarks
|
|
216
|
+
* The usual use is turning a DOM pointer event into grid space to find what is under the pointer
|
|
217
|
+
* (context menus, tooltips, hover). Passing `(0, 0)` is a useful special case: it yields the offset
|
|
218
|
+
* between client space and this pane's view space, so a view-space rect can be mapped back to
|
|
219
|
+
* on-screen (client) coordinates.
|
|
220
|
+
*/
|
|
221
|
+
getPanePointFromPointer(clientX: number, clientY: number): Point | null;
|
|
222
|
+
/**
|
|
223
|
+
* Returns the coords at the offset.
|
|
224
|
+
*
|
|
225
|
+
* @param x The x offset relative to the view
|
|
226
|
+
* @param y The y offset relative to the view
|
|
227
|
+
* @param actualCell Don't return the topLeft of a merge. Default value `false`.
|
|
228
|
+
*/
|
|
229
|
+
getCellFromPointer(x: number, y: number, actualCell?: boolean): CellCoords | null;
|
|
230
|
+
/**
|
|
231
|
+
* Hit-test a client (absolute) point to the pane under it.
|
|
232
|
+
*
|
|
233
|
+
* @remarks
|
|
234
|
+
* May return a DIFFERENT pane than this one (e.g. a frozen pane the pointer is over), or `null`
|
|
235
|
+
* when the point is outside every pane (off the surface). Frozen panes do not overlap the center,
|
|
236
|
+
* so a point in the scroll region resolves to the center pane and a point in a frozen gutter to
|
|
237
|
+
* that frozen pane.
|
|
238
|
+
*/
|
|
239
|
+
getPaneFromPointer(clientX: number, clientY: number): IGridPane | null;
|
|
240
|
+
/**
|
|
241
|
+
* Invalidate the current view.
|
|
242
|
+
*/
|
|
243
|
+
invalidate(): void;
|
|
244
|
+
/**
|
|
245
|
+
* All grid panes currently mounted, keyed by {@link AnchorLocation}.
|
|
246
|
+
* Callable from ANY pane, so a single pane handle can reach its siblings.
|
|
247
|
+
*
|
|
248
|
+
* @remarks
|
|
249
|
+
* The `Center` (scrolling) pane is always present; the `Top` / `Left` / `TopLeft` panes exist only
|
|
250
|
+
* when the grid has frozen rows and/or columns. Use it to reach the scrolling pane
|
|
251
|
+
* (`getAllPanes()[AnchorLocation.Center]`), to walk every pane (e.g. hit-test across the freeze
|
|
252
|
+
* split), or to detect whether the grid is frozen (more than one entry).
|
|
253
|
+
*/
|
|
254
|
+
getAllPanes(): Readonly<Partial<Record<AnchorLocation, IGridPane>>>;
|
|
255
|
+
/**
|
|
256
|
+
* Add a listener for a single event type to the pane's event dispatch (e.g. a custom header
|
|
257
|
+
* renderer listening for `pointermove` hover). Returns a remover — hold it and call it on
|
|
258
|
+
* teardown; no other bookkeeping needed.
|
|
259
|
+
*
|
|
260
|
+
* @param type The native event type (`'pointermove'`, `'keydown'`, …).
|
|
261
|
+
* @param listener Receives the React synthetic event.
|
|
262
|
+
* @param listenerPane Optional variant that also receives the pane the event dispatched on.
|
|
263
|
+
*
|
|
264
|
+
* @remarks
|
|
265
|
+
* The listener joins the pane's z-ordered dispatch walk as an element-less responder (it has no
|
|
266
|
+
* layer membership). Registering while the pane's element is unmounted returns a no-op remover.
|
|
267
|
+
*/
|
|
268
|
+
addReactEventListener(type: string, listener: (event: React.SyntheticEvent) => void, listenerPane?: (event: React.SyntheticEvent, pane: IGridPane) => void): RemoveListener;
|
|
269
|
+
/**
|
|
270
|
+
* Contains the div element for the pane — the pane's focusable surface (event root).
|
|
271
|
+
*/
|
|
272
|
+
getElement(): HTMLElement | null;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* The geometry of a single row/column track: its index, its leading-edge pixel `offset` (VIEW-relative
|
|
276
|
+
* — moves with scroll) and its pixel `size` (0 for a hidden track). The visible-ordinal is the position
|
|
277
|
+
* in {@link IGridPane.getVisibleColumns}/{@link IGridPane.getVisibleRows}; it is deliberately NOT stored
|
|
278
|
+
* here (an ordinal is only meaningful relative to a specific visible enumeration — see useBorders).
|
|
279
|
+
*/
|
|
280
|
+
export interface SpanSize {
|
|
281
|
+
/** The row/column index this span describes. */
|
|
282
|
+
index: number;
|
|
283
|
+
/** Leading-edge pixel offset, view-relative. */
|
|
284
|
+
offset: number;
|
|
285
|
+
/** Pixel extent; 0 for a hidden track. */
|
|
286
|
+
size: number;
|
|
287
|
+
}
|
|
288
|
+
//# sourceMappingURL=IGridPane.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IGridPane.d.ts","sourceRoot":"","sources":["../../../../src/surface/IGridPane.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EACL,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,KAAK,gBAAgB,E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C,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,CAAC;IAClF;;;;;;;;OAQG;IACH,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IACvE;;OAEG;IACH,UAAU,IAAI,IAAI,CAAC;IACnB;;;;;;;;;OASG;IACH,WAAW,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACpE;;;;;;;;;;;;OAYG;IACH,qBAAqB,CACnB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,KAAK,IAAI,EAC/C,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,EAAE,IAAI,EAAE,SAAS,KAAK,IAAI,GACpE,cAAc,CAAC;IAElB;;OAEG;IACH,UAAU,IAAI,WAAW,GAAG,IAAI,CAAC;CAClC;AAGD;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACvB,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,MAAM,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { CellCoords, RangeCoords, TopLeft, FixedEdge, AnchorLocation } from '@sheetxl/utils';
|
|
2
|
+
import { IViewport } from '@sheetxl/utils-react';
|
|
3
|
+
import { IGridMetrics } from '../metrics';
|
|
4
|
+
import { LayerNode } from '../layer';
|
|
5
|
+
import { LineSVGProps } from '../svg';
|
|
6
|
+
import { IGridPane } from './IGridPane';
|
|
7
|
+
export interface GridSurfaceProps extends React.HTMLAttributes<HTMLDivElement>, React.RefAttributes<IGridSurface> {
|
|
8
|
+
/**
|
|
9
|
+
* Number of columns in the grid.
|
|
10
|
+
*/
|
|
11
|
+
columnCount: number;
|
|
12
|
+
/**
|
|
13
|
+
* Number of rows in the grid.
|
|
14
|
+
*/
|
|
15
|
+
rowCount: number;
|
|
16
|
+
/**
|
|
17
|
+
* The metric for calculating cell positions. The surface is metrics-only; the size-convenience
|
|
18
|
+
* (`getRowHeight` / `getColumnWidth`) lives on {@link Grid}.
|
|
19
|
+
*/
|
|
20
|
+
metrics?: IGridMetrics | null;
|
|
21
|
+
/**
|
|
22
|
+
* The scroll viewport — a single {@link IViewport} object (position + zoom + bounds + sizes +
|
|
23
|
+
* ticker). Pass the SAME instance to a wrapping `ScrollPane` and they stay in sync through it.
|
|
24
|
+
*
|
|
25
|
+
* @remarks
|
|
26
|
+
* Use a `Viewport` for a normal grid. For per-axis sharing — a sheet header that follows
|
|
27
|
+
* the main grid, or split peers sharing one axis — pass an `AxisViewport` composed from the relevant
|
|
28
|
+
* controllers. When omitted, GridSurface creates and owns its own (standalone, non-scrolling without
|
|
29
|
+
* a wrapper). A passed-in viewport's lifecycle (dispose) belongs to the caller.
|
|
30
|
+
*/
|
|
31
|
+
viewport?: IViewport;
|
|
32
|
+
/**
|
|
33
|
+
* Returns the cell as a range. If this cell is merged this will be reflected.
|
|
34
|
+
*
|
|
35
|
+
* @remarks
|
|
36
|
+
* Slightly more sophisticated than rowSpan and colSpan because it allows for queries that are not on the top/left.
|
|
37
|
+
*/
|
|
38
|
+
getRangeFromCell?: (coords: CellCoords) => RangeCoords;
|
|
39
|
+
/**
|
|
40
|
+
* Will skip rendering for this row and the adjacent rows in the given direction.
|
|
41
|
+
*/
|
|
42
|
+
hiddenRowsAt?: (rowIndex: number, forward?: boolean) => number;
|
|
43
|
+
/**
|
|
44
|
+
* Will skip rendering for this columns and the adjacent columns in the given direction.
|
|
45
|
+
*/
|
|
46
|
+
hiddenColumnsAt?: (colIndex: number, forward?: boolean) => number;
|
|
47
|
+
/**
|
|
48
|
+
* Number of frozen left columns, or a {@link FixedEdge} whose `offset` is the frozen-region scroll
|
|
49
|
+
* in zoom-independent (base) px (scaled to screen px internally by the current zoom).
|
|
50
|
+
*/
|
|
51
|
+
freezeLeft?: number | FixedEdge;
|
|
52
|
+
/**
|
|
53
|
+
* Number of frozen top rows, or a {@link FixedEdge} whose `offset` is the frozen-region scroll in
|
|
54
|
+
* zoom-independent (base) px (scaled to screen px internally by the current zoom).
|
|
55
|
+
*/
|
|
56
|
+
freezeTop?: number | FixedEdge;
|
|
57
|
+
/**
|
|
58
|
+
* Allow for customization of freezeLeftDivider
|
|
59
|
+
*/
|
|
60
|
+
propsFreezeLeft?: Partial<LineSVGProps>;
|
|
61
|
+
/**
|
|
62
|
+
* Allow for customization of freezeTopDivider
|
|
63
|
+
*/
|
|
64
|
+
propsFreezeTop?: Partial<LineSVGProps>;
|
|
65
|
+
/**
|
|
66
|
+
* Call only once when the renders for the first time.
|
|
67
|
+
*/
|
|
68
|
+
onFirstRender?: (grid: IGridSurface) => void;
|
|
69
|
+
/**
|
|
70
|
+
* The layers, as children, bottom → top. Each layer is an ordinary React node that reads its pane
|
|
71
|
+
* from context ({@link useGridPane}), so the children are just JSX rendered once per pane
|
|
72
|
+
* (`<GridSurface><Layer>…</Layer></GridSurface>`). A layer with a `zIndex` sorts within the stack.
|
|
73
|
+
* For the rare layer that must be BUILT from the pane, call
|
|
74
|
+
* {@link useGridPane} from a small wrapper component.
|
|
75
|
+
*/
|
|
76
|
+
children?: LayerNode;
|
|
77
|
+
/**
|
|
78
|
+
* Wraps each pane's layers (inside its `GridPaneProvider`), once per pane. The default is the
|
|
79
|
+
* identity (children pass through). The seam for **per-pane** context that must sit *outside*
|
|
80
|
+
* the layers yet *inside* the pane — e.g. a consumer injecting a per-pane feature context (such
|
|
81
|
+
* as a command scope) so layers can contribute to it. Kept a render callback so `grid-react`
|
|
82
|
+
* stays free of any command/feature import: the pane is passed in, the consumer supplies the
|
|
83
|
+
* wrapper.
|
|
84
|
+
*
|
|
85
|
+
* @param pane The pane whose layers are being wrapped (one call per pane; up to 4 with freeze).
|
|
86
|
+
* @param children The pane's layers (already normalized + provider-wrapped).
|
|
87
|
+
*/
|
|
88
|
+
wrapPane?: (pane: IGridPane, children: React.ReactNode) => React.ReactNode;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The imperative API of a {@link GridSurface}, exposed on its {@link IGridSurface} handle.
|
|
92
|
+
*/
|
|
93
|
+
export interface IGridSurfaceAttributes {
|
|
94
|
+
/**
|
|
95
|
+
* Invalidate and re-render the grid, dropping cached pane/cell output.
|
|
96
|
+
*
|
|
97
|
+
* @remarks
|
|
98
|
+
* Use after a change the surface cannot observe through its props. {@link IGrid} widens this to
|
|
99
|
+
* accept a cell or range to invalidate only a subset.
|
|
100
|
+
*/
|
|
101
|
+
invalidate: () => void;
|
|
102
|
+
/**
|
|
103
|
+
* Scroll a cell into view.
|
|
104
|
+
*
|
|
105
|
+
* @remarks
|
|
106
|
+
* When `coords` omits an index it scrolls only along the axis that is provided.
|
|
107
|
+
*
|
|
108
|
+
* @returns The clamped scroll position that was applied.
|
|
109
|
+
*/
|
|
110
|
+
scrollCellCoordsIntoView: (coords: Partial<CellCoords>, options?: globalThis.ScrollIntoViewOptions | boolean) => Promise<Partial<TopLeft>>;
|
|
111
|
+
/**
|
|
112
|
+
* Returns the pane at the given client coordinates. A point over a frozen pane returns that frozen
|
|
113
|
+
* pane; otherwise the center (scrolling) pane is returned.
|
|
114
|
+
*/
|
|
115
|
+
getPaneFromClient: (x: number, y: number) => IGridPane;
|
|
116
|
+
/**
|
|
117
|
+
* Returns the pane that owns the given cell.
|
|
118
|
+
*
|
|
119
|
+
* @remarks
|
|
120
|
+
* Prefers the last-focused pane and falls back to the center pane. Used to support goto/navigation.
|
|
121
|
+
*/
|
|
122
|
+
getPaneFromCell: (coords: CellCoords) => IGridPane;
|
|
123
|
+
/**
|
|
124
|
+
* Returns the pane at the given anchor location, or `null` when that pane is not present in the
|
|
125
|
+
* current freeze layout. With **no argument**, returns the pane focus would land on — the
|
|
126
|
+
* last-focused pane, else the center (primary scrolling) pane — the pane analog of
|
|
127
|
+
* {@link IGridSurfaceAttributes.focus} (`focusLastPane`), so a consumer can name "the grid's
|
|
128
|
+
* active pane" without knowing the freeze geometry.
|
|
129
|
+
*/
|
|
130
|
+
getPane: (anchor?: AnchorLocation) => IGridPane | null;
|
|
131
|
+
/**
|
|
132
|
+
* Registers a callback fired the next time the pane layout changes. Fires at most once.
|
|
133
|
+
*/
|
|
134
|
+
onPaneChangeOnce: (callback: () => void) => void;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Type returned via ref property
|
|
138
|
+
*/
|
|
139
|
+
export interface IGridSurface extends HTMLDivElement, IGridSurfaceAttributes {
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=IGridSurface.d.ts.map
|