@sheetxl/grid-react 0.7.27 → 0.7.28-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.
Files changed (90) hide show
  1. package/README.md +502 -2
  2. package/browser/cjs/index.cjs +3 -12
  3. package/browser/esm/index.mjs +5797 -1867
  4. package/licenses/dependencies.txt +143 -41
  5. package/node/esm/index.mjs +4951 -1861
  6. package/package.json +7 -6
  7. package/types/index.d.ts +2 -1503
  8. package/types/src/cell/CellLayer.d.ts +70 -0
  9. package/types/src/cell/CellRenderer.d.ts +42 -0
  10. package/types/src/cell/DefaultCellRenderer.d.ts +6 -0
  11. package/types/src/cell/GridlineLayer.d.ts +38 -0
  12. package/types/src/cell/Types.d.ts +12 -0
  13. package/types/src/cell/_CellModel.d.ts +82 -0
  14. package/types/src/cell/index.d.ts +6 -0
  15. package/types/src/editor/DefaultEditable.d.ts +121 -0
  16. package/types/src/editor/EditSession.d.ts +182 -0
  17. package/types/src/editor/EditState.d.ts +61 -0
  18. package/types/src/editor/EditorDiv.d.ts +65 -0
  19. package/types/src/editor/EditorInput.d.ts +88 -0
  20. package/types/src/editor/EditorLayer.d.ts +69 -0
  21. package/types/src/editor/EditorPlacement.d.ts +38 -0
  22. package/types/src/editor/index.d.ts +10 -0
  23. package/types/src/editor/useEditorKeymap.d.ts +74 -0
  24. package/types/src/grid/Grid.d.ts +16 -0
  25. package/types/src/grid/IGrid.d.ts +93 -0
  26. package/types/src/grid/index.d.ts +3 -0
  27. package/types/src/header/HeaderDividerAnchor.d.ts +120 -0
  28. package/types/src/header/index.d.ts +3 -0
  29. package/types/src/header/useHeaderSelectionPointer.d.ts +122 -0
  30. package/types/src/index.d.ts +13 -0
  31. package/types/src/layer/HoverTipLayer.d.ts +74 -0
  32. package/types/src/layer/Layer.d.ts +92 -0
  33. package/types/src/layer/LayerTypes.d.ts +47 -0
  34. package/types/src/layer/RangePrompt.d.ts +42 -0
  35. package/types/src/layer/Stage.d.ts +147 -0
  36. package/types/src/layer/StickyAnchor.d.ts +83 -0
  37. package/types/src/layer/StickyFloat.d.ts +65 -0
  38. package/types/src/layer/VirtualDiv.d.ts +59 -0
  39. package/types/src/layer/_Utils.d.ts +37 -0
  40. package/types/src/layer/index.d.ts +11 -0
  41. package/types/src/layer/useGridAnchor.d.ts +157 -0
  42. package/types/src/layer/useHoverIntent.d.ts +49 -0
  43. package/types/src/layer/useLayerResponder.d.ts +29 -0
  44. package/types/src/layer/usePlacement.d.ts +18 -0
  45. package/types/src/layer/useRangeHover.d.ts +35 -0
  46. package/types/src/list/CheckboxList.d.ts +63 -0
  47. package/types/src/list/List.d.ts +55 -0
  48. package/types/src/list/index.d.ts +3 -0
  49. package/types/src/metrics/Types.d.ts +23 -0
  50. package/types/src/metrics/index.d.ts +3 -0
  51. package/types/src/metrics/useGridMetrics.d.ts +67 -0
  52. package/types/src/range/DragHandle.d.ts +129 -0
  53. package/types/src/range/Draggable.d.ts +86 -0
  54. package/types/src/range/FillHandle.d.ts +54 -0
  55. package/types/src/range/RangeRect.d.ts +36 -0
  56. package/types/src/range/RangeResizer.d.ts +68 -0
  57. package/types/src/range/RangeStyle.d.ts +8 -0
  58. package/types/src/range/index.d.ts +13 -0
  59. package/types/src/selection/DefaultSelection.d.ts +59 -0
  60. package/types/src/selection/ICellAnchor.d.ts +21 -0
  61. package/types/src/selection/ISelection.d.ts +65 -0
  62. package/types/src/selection/RangesPickerLayer.d.ts +128 -0
  63. package/types/src/selection/SelectionLayer.d.ts +179 -0
  64. package/types/src/selection/SelectionStyle.d.ts +28 -0
  65. package/types/src/selection/SelectionTouchGrips.d.ts +29 -0
  66. package/types/src/selection/SelectionUtils.d.ts +2 -0
  67. package/types/src/selection/Types.d.ts +67 -0
  68. package/types/src/selection/_SelectionNavigation.d.ts +6 -0
  69. package/types/src/selection/_SelectionUtils.d.ts +7 -0
  70. package/types/src/selection/index.d.ts +12 -0
  71. package/types/src/selection/useDragCells.d.ts +218 -0
  72. package/types/src/selection/useSelectionPointer.d.ts +70 -0
  73. package/types/src/surface/GridPane.d.ts +85 -0
  74. package/types/src/surface/GridPaneProvider.d.ts +37 -0
  75. package/types/src/surface/GridSurface.d.ts +11 -0
  76. package/types/src/surface/IGridPane.d.ts +288 -0
  77. package/types/src/surface/IGridSurface.d.ts +141 -0
  78. package/types/src/surface/SurfaceStateProvider.d.ts +50 -0
  79. package/types/src/surface/_GridUtils.d.ts +37 -0
  80. package/types/src/surface/index.d.ts +7 -0
  81. package/types/src/surface/useGridPane.d.ts +31 -0
  82. package/types/src/surface/useSurfaceState.d.ts +22 -0
  83. package/types/src/svg/LineSVG.d.ts +13 -0
  84. package/types/src/svg/RectangleSVG.d.ts +114 -0
  85. package/types/src/svg/ShapeBounds.d.ts +15 -0
  86. package/types/src/svg/Types.d.ts +37 -0
  87. package/types/src/svg/index.d.ts +9 -0
  88. package/types/src/theme/GridTheme.d.ts +56 -0
  89. package/types/src/theme/index.d.ts +2 -0
  90. package/node/assets/style.css +0 -1
@@ -0,0 +1,218 @@
1
+ import { CellCoords } from '@sheetxl/utils';
2
+ import { IGridPane } from '../surface';
3
+ /**
4
+ * Repeat interval (ms) for the held-still auto-scroll. While a drag is parked past the viewport edge no
5
+ * pointer-move events fire, so the engine re-applies the drag at the last pointer position on this
6
+ * cadence; each tick scrolls one cell, which shifts the cell under the (fixed) point, continuing the drag.
7
+ */
8
+ export declare const AUTO_SCROLL_INTERVAL_MS = 60;
9
+ /**
10
+ * How close (client px) the pointer must get to a pane edge — on the INSIDE of the viewport, or past it —
11
+ * to engage the auto-scroll. Edge detection is by pointer POSITION, not by the resolved cell, because a
12
+ * TOUCH drag can never resolve a cell past the last visible one: a finger is pinned to the physical grid
13
+ * edge and can't roam into the empty space beyond the content the way a mouse cursor can. This band is
14
+ * sized so a fingertip at the edge falls inside it.
15
+ */
16
+ export declare const EDGE_AUTO_SCROLL_MARGIN_PX = 24;
17
+ /**
18
+ * The default {@link DragCellsSession.edgeScroll} for a body / picker drag: step the pane's viewport ONE
19
+ * cell toward whichever edge(s) the pointer sits within {@link EDGE_AUTO_SCROLL_MARGIN_PX} of (or past),
20
+ * on both axes. Returns whether an edge is still scrollable — so the held-still auto-scroll keeps ticking.
21
+ *
22
+ * @remarks
23
+ * Position/direction-based rather than "scroll the dragged cell into view": the latter only advances when
24
+ * the resolved cell is off-screen (reachable by a mouse roaming past the content, never by a finger). A
25
+ * fixed one-cell step per tick advances the viewport regardless, and the engine then extends to the cell
26
+ * newly revealed under the pointer. The step routes through the CENTER pane (a frozen pane can't move its
27
+ * frozen axis).
28
+ *
29
+ * @param axes restricts which axes may scroll — a whole-row/column touch grip extends only one axis, so
30
+ * it passes e.g. `{ x: true, y: false }`. Omitted axes default to enabled (both).
31
+ */
32
+ export declare const edgeScrollPane: (pane: IGridPane, point: {
33
+ x: number;
34
+ y: number;
35
+ }, axes?: {
36
+ x?: boolean;
37
+ y?: boolean;
38
+ }) => boolean;
39
+ /**
40
+ * The in-flight gesture returned by {@link DragCellsOptions.onStart}. It carries the *policy* — how a
41
+ * given cell-drag mutates the model — while the engine owns the *mechanics* (pointer capture, `lastCell`
42
+ * de-dup, the held-still auto-scroll timer, and the public `dragMode` signal).
43
+ *
44
+ * @remarks
45
+ * `onStart` has already SEEDED the model for the down cell (and taken ownership of the down event —
46
+ * `stopPropagation` / `preventDefault` per its own policy); the session's callbacks then drive the drag:
47
+ * `drag` on each new cell, `edgeScroll` for the held-still edge auto-scroll, `end` on release, `cancel`
48
+ * on an OS-cancelled abort.
49
+ */
50
+ export interface DragCellsSession {
51
+ /**
52
+ * Apply the in-flight update for a newly-entered `cell` — called once per DISTINCT cell during the
53
+ * drag (the engine de-dups moves within the same cell). Not called for the down cell (already seeded).
54
+ * `e` is the triggering pointer event when the move came from a real pointer (read live modifiers off
55
+ * it — e.g. a move-drag's Ctrl=copy / Shift=insert); it is ABSENT on a held-still auto-scroll tick
56
+ * (no pointer event fires while the pointer is parked past the edge), so treat it as optional.
57
+ */
58
+ drag: (cell: CellCoords, e?: React.PointerEvent) => void;
59
+ /**
60
+ * The auto-scroll step: given the pointer's client `point`, scroll the viewport ONE cell toward any edge
61
+ * the pointer is at (see {@link edgeScrollPane}), and return whether an edge is still engaged so the
62
+ * held-still timer keeps ticking. Called every tick (not gated on a distinct cell) — the drag EXTEND is
63
+ * separate (the engine's per-cell `drag`), so the two concerns don't fight: this steps the viewport, and
64
+ * the engine then extends to the cell newly under the pointer.
65
+ *
66
+ * Position/direction-based on purpose — a cell-based "is the dragged cell off-screen?" test can't fire
67
+ * on TOUCH (a finger can't leave the content). The header supplies a single-axis, sheet-routed version
68
+ * (its controlled viewport can't scroll itself); a body / picker drag uses the default.
69
+ * @defaultValue {@link edgeScrollPane} of the engine's pane (both axes).
70
+ */
71
+ edgeScroll?: (point: {
72
+ x: number;
73
+ y: number;
74
+ }) => boolean;
75
+ /** Finalize on pointer-up (e.g. a remove-drag's `deselect`, an `onSelectionEnd`, a refocus). */
76
+ end?: (e: React.PointerEvent) => void;
77
+ /**
78
+ * Abort cleanup for a CANCELLED gesture — the OS/browser seized the pointer (`pointercancel`: a touch
79
+ * became a system pan/zoom, a pen left range, a window blurred), OR the user pressed **Escape**
80
+ * (Windows-style drag abort). The engine always runs the mechanical teardown (stop the auto-scroll
81
+ * timer, disarm the touch swallow, release capture); this hook is for the policy's own rollback —
82
+ * restore the pre-drag selection, clear a rubber-band / preview — WITHOUT committing, since a cancel is
83
+ * an abort, not a release. {@link DragCellsSession.end} never runs on a cancel. The event is absent on
84
+ * an Escape abort (no pointer event drives it).
85
+ */
86
+ cancel?: (e?: React.PointerEvent) => void;
87
+ /**
88
+ * Take pointer capture and track the drag. `false` = a click-only gesture (e.g. a header right-click
89
+ * that positions the selection for the context menu): no capture, moves are ignored, but {@link end}
90
+ * still runs on the next pointer-up. @defaultValue true
91
+ */
92
+ capture?: boolean;
93
+ /**
94
+ * `stopPropagation` the move / up events while this drag is in flight, so a layer below never also acts
95
+ * on them. The down event is owned by `onStart` itself. @defaultValue true
96
+ */
97
+ captureEvents?: boolean;
98
+ /**
99
+ * A public label for the gesture, surfaced as {@link DragCellsResult.dragMode} between down and up (a
100
+ * layer shows a transient tip — e.g. live R×C — off it). Flips only on start / end, not per move.
101
+ */
102
+ dragMode?: string;
103
+ }
104
+ /**
105
+ * Options for {@link useDragCells} / {@link createDragCells}.
106
+ */
107
+ export interface DragCellsOptions {
108
+ /**
109
+ * Begin a gesture at the `cell` under the pointer. SEED the model, take ownership of the down event
110
+ * (`stopPropagation` / `preventDefault` as the policy needs), and return a {@link DragCellsSession} to
111
+ * drive the drag — or `null` to not start one (a non-primary button, an intercepted right-click, …).
112
+ * The engine captures the pointer only for a returned session (unless {@link DragCellsSession.capture}
113
+ * is `false`).
114
+ */
115
+ onStart: (cell: CellCoords, e: React.PointerEvent) => DragCellsSession | null;
116
+ }
117
+ /** The spreadable handlers + the public `dragMode`, produced by {@link useDragCells}. */
118
+ export interface DragCellsResult {
119
+ onPointerDown: (e: React.PointerEvent) => void;
120
+ onPointerMove: (e: React.PointerEvent) => void;
121
+ onPointerUp: (e: React.PointerEvent) => void;
122
+ /**
123
+ * Abort the in-flight drag. Wire it onto the tap only if the host routes `pointercancel` — the engine
124
+ * ALSO listens natively on the captured element (a `pointercancel` fires there whether or not the host
125
+ * dispatches it), so this is a safe idempotent extra, not a requirement.
126
+ */
127
+ onPointerCancel: (e: React.PointerEvent) => void;
128
+ /**
129
+ * What the in-flight drag is doing — the active session's {@link DragCellsSession.dragMode}, or `null`
130
+ * between drags. Flips only on down / up so a layer can show a transient tip without re-rendering on
131
+ * every pointer move.
132
+ */
133
+ dragMode: string | null;
134
+ }
135
+ /** The headless controller behind {@link useDragCells}. */
136
+ export interface DragCellsController {
137
+ onPointerDown: (e: React.PointerEvent) => void;
138
+ onPointerMove: (e: React.PointerEvent) => void;
139
+ onPointerUp: (e: React.PointerEvent) => void;
140
+ /** Abort the in-flight drag (see {@link DragCellsResult.onPointerCancel}). */
141
+ onPointerCancel: (e: React.PointerEvent) => void;
142
+ /** Stop the auto-scroll timer + disarm touch. Call on unmount (the hook wires this). */
143
+ dispose: () => void;
144
+ }
145
+ /**
146
+ * The **shared cell-drag engine** — the axis-agnostic mechanics every pointer selection needs: pointer
147
+ * capture, per-cell de-dup, the held-still auto-scroll timer, and the public `dragMode` signal. It holds
148
+ * NO range math: an {@link DragCellsOptions.onStart} adapter supplies the policy as a
149
+ * {@link DragCellsSession}. Used by the body selection, the header selection, and the range picker's draw
150
+ * — each a thin adapter over this one engine (so all three get identical auto-scroll for free).
151
+ *
152
+ * @remarks
153
+ * This is the **tap driver**: the consumer spreads `onPointerDown` / `onPointerMove` / `onPointerUp`
154
+ * (and, if the host routes it, `onPointerCancel`) onto a Stage tap; the engine captures the pointer on
155
+ * that tap's element so move / up keep firing when the drag leaves the viewport. The handle / grip
156
+ * flavors, whose element repositions or unmounts mid-drag, use {@link createWindowDragCells} instead —
157
+ * same session, `window`-tracked.
158
+ *
159
+ * A plain (non-hook) factory so a headless controller (e.g. the header's `createHeaderSelectionPointer`,
160
+ * unit-tested with a fake pane) can build on it directly. The React hook is {@link useDragCells}.
161
+ * `onStart` is captured at creation; a caller that needs live values reads them through a ref inside its
162
+ * `onStart` closure (as the hook does).
163
+ *
164
+ * @param onDragModeChange Notified when the active session's `dragMode` changes (a hook turns this into
165
+ * React state); omit for a headless controller that doesn't surface it.
166
+ */
167
+ export declare const createDragCells: (pane: IGridPane, onStart: (cell: CellCoords, e: React.PointerEvent) => DragCellsSession | null, onDragModeChange?: (mode: string | null) => void) => DragCellsController;
168
+ /** The headless controller behind {@link useWindowDragCells}. */
169
+ export interface WindowDragCellsController {
170
+ /**
171
+ * Begin a `window`-driven gesture from a pointer-down on the source element. `cursorEl` is captured
172
+ * (pointer-capture) purely so the browser paints ITS cursor for the whole drag — the gesture tracks on
173
+ * `window` regardless, surviving the element repositioning / unmounting. Defaults to `e.currentTarget`.
174
+ */
175
+ start: (e: React.PointerEvent, cursorEl?: Element | null) => void;
176
+ /** Stop any in-flight gesture (drop the `window` listeners + timer + touch swallow). Call on unmount. */
177
+ dispose: () => void;
178
+ }
179
+ /**
180
+ * The **window-driven** cell-drag engine — same {@link DragCellsSession} policy and shared mechanics as
181
+ * {@link createDragCells}, but the gesture tracks on `window` listeners instead of a Stage tap's element
182
+ * capture. Use it when the element that starts the drag repositions or unmounts mid-gesture: a fill /
183
+ * resize handle culled under an edge auto-scroll, a move grip whose source range scrolls off in ghost
184
+ * mode. Element capture on such an element would silently drop the drag; `window` tracking is immune.
185
+ *
186
+ * @remarks
187
+ * The source element is still pointer-captured (for its CURSOR only — see {@link WindowDragCellsController.start});
188
+ * the actual move / up / cancel are `window` listeners, so a re-render or unmount of the handle never
189
+ * interrupts the gesture. Consumers supply `onStart` policy exactly as for the tap engine, and get the
190
+ * same held-still auto-scroll, touch arming, per-cell de-dup, and abort-on-cancel.
191
+ */
192
+ export declare function createWindowDragCells(pane: IGridPane, onStart: (cell: CellCoords, e: React.PointerEvent) => DragCellsSession | null, onDragModeChange?: (mode: string | null) => void,
193
+ /** Override cell resolution (a touch grip resolves against the pane the finger is over). */
194
+ resolveCell?: (clientX: number, clientY: number) => CellCoords | null): WindowDragCellsController;
195
+ /**
196
+ * The React hook over {@link createDragCells}: reads the pane from context, owns the `dragMode` state,
197
+ * and stops the auto-scroll timer on unmount. `onStart` is read live through a ref, so a consumer's
198
+ * closure over changing values (selection, options) needs no handler rebuild.
199
+ */
200
+ export declare const useDragCells: (onStart: (cell: CellCoords, e: React.PointerEvent) => DragCellsSession | null) => DragCellsResult;
201
+ /** Handlers + transient `dragMode` produced by {@link useWindowDragCells}. */
202
+ export interface WindowDragCellsResult {
203
+ /**
204
+ * Begin a window-driven gesture. Spread as the source element's `onPointerDown`. Pass a `cursorEl` (the
205
+ * element whose cursor should paint for the drag) when the pointer-down may be dispatched with a
206
+ * `currentTarget` other than that element (e.g. a grip below an interactive child).
207
+ */
208
+ start: (e: React.PointerEvent, cursorEl?: Element | null) => void;
209
+ /** The active session's `dragMode`, or `null` between drags (flips only on start / end). */
210
+ dragMode: string | null;
211
+ }
212
+ /**
213
+ * The React hook over {@link createWindowDragCells}: reads the pane from context, owns the `dragMode`
214
+ * state, and disposes the gesture on unmount. For handle / grip flavors (fill, resize, move, touch grips)
215
+ * whose element repositions or unmounts mid-drag. `onStart` is read live through a ref.
216
+ */
217
+ export declare const useWindowDragCells: (onStart: (cell: CellCoords, e: React.PointerEvent) => DragCellsSession | null) => WindowDragCellsResult;
218
+ //# sourceMappingURL=useDragCells.d.ts.map
@@ -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,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,37 @@
1
+ import { 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,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