@sheetxl/grid-react 0.7.22 → 0.7.23-beta.2

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 (172) 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 -1497
  8. package/types/src/cell/CellLayer.d.ts +70 -0
  9. package/types/src/cell/CellLayer.d.ts.map +1 -0
  10. package/types/src/cell/CellRenderer.d.ts +42 -0
  11. package/types/src/cell/CellRenderer.d.ts.map +1 -0
  12. package/types/src/cell/DefaultCellRenderer.d.ts +6 -0
  13. package/types/src/cell/DefaultCellRenderer.d.ts.map +1 -0
  14. package/types/src/cell/GridlineLayer.d.ts +38 -0
  15. package/types/src/cell/GridlineLayer.d.ts.map +1 -0
  16. package/types/src/cell/Types.d.ts +12 -0
  17. package/types/src/cell/Types.d.ts.map +1 -0
  18. package/types/src/cell/_CellModel.d.ts +82 -0
  19. package/types/src/cell/_CellModel.d.ts.map +1 -0
  20. package/types/src/cell/index.d.ts +6 -0
  21. package/types/src/cell/index.d.ts.map +1 -0
  22. package/types/src/editor/DefaultEditable.d.ts +121 -0
  23. package/types/src/editor/DefaultEditable.d.ts.map +1 -0
  24. package/types/src/editor/EditSession.d.ts +182 -0
  25. package/types/src/editor/EditSession.d.ts.map +1 -0
  26. package/types/src/editor/EditState.d.ts +61 -0
  27. package/types/src/editor/EditState.d.ts.map +1 -0
  28. package/types/src/editor/EditorDiv.d.ts +65 -0
  29. package/types/src/editor/EditorDiv.d.ts.map +1 -0
  30. package/types/src/editor/EditorInput.d.ts +88 -0
  31. package/types/src/editor/EditorInput.d.ts.map +1 -0
  32. package/types/src/editor/EditorLayer.d.ts +69 -0
  33. package/types/src/editor/EditorLayer.d.ts.map +1 -0
  34. package/types/src/editor/EditorPlacement.d.ts +38 -0
  35. package/types/src/editor/EditorPlacement.d.ts.map +1 -0
  36. package/types/src/editor/index.d.ts +10 -0
  37. package/types/src/editor/index.d.ts.map +1 -0
  38. package/types/src/editor/useEditorKeymap.d.ts +74 -0
  39. package/types/src/editor/useEditorKeymap.d.ts.map +1 -0
  40. package/types/src/grid/Grid.d.ts +16 -0
  41. package/types/src/grid/Grid.d.ts.map +1 -0
  42. package/types/src/grid/IGrid.d.ts +93 -0
  43. package/types/src/grid/IGrid.d.ts.map +1 -0
  44. package/types/src/grid/index.d.ts +3 -0
  45. package/types/src/grid/index.d.ts.map +1 -0
  46. package/types/src/header/HeaderDividerAnchor.d.ts +120 -0
  47. package/types/src/header/HeaderDividerAnchor.d.ts.map +1 -0
  48. package/types/src/header/index.d.ts +3 -0
  49. package/types/src/header/index.d.ts.map +1 -0
  50. package/types/src/header/useHeaderSelectionPointer.d.ts +122 -0
  51. package/types/src/header/useHeaderSelectionPointer.d.ts.map +1 -0
  52. package/types/src/index.d.ts +13 -0
  53. package/types/src/index.d.ts.map +1 -0
  54. package/types/src/layer/HoverTipLayer.d.ts +74 -0
  55. package/types/src/layer/HoverTipLayer.d.ts.map +1 -0
  56. package/types/src/layer/Layer.d.ts +92 -0
  57. package/types/src/layer/Layer.d.ts.map +1 -0
  58. package/types/src/layer/LayerTypes.d.ts +47 -0
  59. package/types/src/layer/LayerTypes.d.ts.map +1 -0
  60. package/types/src/layer/RangePrompt.d.ts +42 -0
  61. package/types/src/layer/RangePrompt.d.ts.map +1 -0
  62. package/types/src/layer/Stage.d.ts +147 -0
  63. package/types/src/layer/Stage.d.ts.map +1 -0
  64. package/types/src/layer/StickyAnchor.d.ts +83 -0
  65. package/types/src/layer/StickyAnchor.d.ts.map +1 -0
  66. package/types/src/layer/StickyFloat.d.ts +65 -0
  67. package/types/src/layer/StickyFloat.d.ts.map +1 -0
  68. package/types/src/layer/VirtualDiv.d.ts +59 -0
  69. package/types/src/layer/VirtualDiv.d.ts.map +1 -0
  70. package/types/src/layer/_Utils.d.ts +37 -0
  71. package/types/src/layer/_Utils.d.ts.map +1 -0
  72. package/types/src/layer/index.d.ts +11 -0
  73. package/types/src/layer/index.d.ts.map +1 -0
  74. package/types/src/layer/useGridAnchor.d.ts +157 -0
  75. package/types/src/layer/useGridAnchor.d.ts.map +1 -0
  76. package/types/src/layer/useHoverIntent.d.ts +49 -0
  77. package/types/src/layer/useHoverIntent.d.ts.map +1 -0
  78. package/types/src/layer/useLayerResponder.d.ts +29 -0
  79. package/types/src/layer/useLayerResponder.d.ts.map +1 -0
  80. package/types/src/layer/usePlacement.d.ts +18 -0
  81. package/types/src/layer/usePlacement.d.ts.map +1 -0
  82. package/types/src/layer/useRangeHover.d.ts +35 -0
  83. package/types/src/layer/useRangeHover.d.ts.map +1 -0
  84. package/types/src/list/CheckboxList.d.ts +63 -0
  85. package/types/src/list/CheckboxList.d.ts.map +1 -0
  86. package/types/src/list/List.d.ts +55 -0
  87. package/types/src/list/List.d.ts.map +1 -0
  88. package/types/src/list/index.d.ts +3 -0
  89. package/types/src/list/index.d.ts.map +1 -0
  90. package/types/src/metrics/Types.d.ts +23 -0
  91. package/types/src/metrics/Types.d.ts.map +1 -0
  92. package/types/src/metrics/index.d.ts +3 -0
  93. package/types/src/metrics/index.d.ts.map +1 -0
  94. package/types/src/metrics/useGridMetrics.d.ts +67 -0
  95. package/types/src/metrics/useGridMetrics.d.ts.map +1 -0
  96. package/types/src/range/DragHandle.d.ts +129 -0
  97. package/types/src/range/DragHandle.d.ts.map +1 -0
  98. package/types/src/range/Draggable.d.ts +86 -0
  99. package/types/src/range/Draggable.d.ts.map +1 -0
  100. package/types/src/range/FillHandle.d.ts +54 -0
  101. package/types/src/range/FillHandle.d.ts.map +1 -0
  102. package/types/src/range/RangeRect.d.ts +36 -0
  103. package/types/src/range/RangeRect.d.ts.map +1 -0
  104. package/types/src/range/RangeResizer.d.ts +68 -0
  105. package/types/src/range/RangeResizer.d.ts.map +1 -0
  106. package/types/src/range/RangeStyle.d.ts +8 -0
  107. package/types/src/range/RangeStyle.d.ts.map +1 -0
  108. package/types/src/range/index.d.ts +13 -0
  109. package/types/src/range/index.d.ts.map +1 -0
  110. package/types/src/selection/DefaultSelection.d.ts +59 -0
  111. package/types/src/selection/DefaultSelection.d.ts.map +1 -0
  112. package/types/src/selection/ICellAnchor.d.ts +21 -0
  113. package/types/src/selection/ICellAnchor.d.ts.map +1 -0
  114. package/types/src/selection/ISelection.d.ts +65 -0
  115. package/types/src/selection/ISelection.d.ts.map +1 -0
  116. package/types/src/selection/RangesPickerLayer.d.ts +128 -0
  117. package/types/src/selection/RangesPickerLayer.d.ts.map +1 -0
  118. package/types/src/selection/SelectionLayer.d.ts +179 -0
  119. package/types/src/selection/SelectionLayer.d.ts.map +1 -0
  120. package/types/src/selection/SelectionStyle.d.ts +28 -0
  121. package/types/src/selection/SelectionStyle.d.ts.map +1 -0
  122. package/types/src/selection/SelectionTouchGrips.d.ts +29 -0
  123. package/types/src/selection/SelectionTouchGrips.d.ts.map +1 -0
  124. package/types/src/selection/SelectionUtils.d.ts +2 -0
  125. package/types/src/selection/SelectionUtils.d.ts.map +1 -0
  126. package/types/src/selection/Types.d.ts +67 -0
  127. package/types/src/selection/Types.d.ts.map +1 -0
  128. package/types/src/selection/_SelectionNavigation.d.ts +6 -0
  129. package/types/src/selection/_SelectionNavigation.d.ts.map +1 -0
  130. package/types/src/selection/_SelectionUtils.d.ts +7 -0
  131. package/types/src/selection/_SelectionUtils.d.ts.map +1 -0
  132. package/types/src/selection/index.d.ts +12 -0
  133. package/types/src/selection/index.d.ts.map +1 -0
  134. package/types/src/selection/useDragCells.d.ts +218 -0
  135. package/types/src/selection/useDragCells.d.ts.map +1 -0
  136. package/types/src/selection/useSelectionPointer.d.ts +70 -0
  137. package/types/src/selection/useSelectionPointer.d.ts.map +1 -0
  138. package/types/src/surface/GridPane.d.ts +85 -0
  139. package/types/src/surface/GridPane.d.ts.map +1 -0
  140. package/types/src/surface/GridPaneProvider.d.ts +37 -0
  141. package/types/src/surface/GridPaneProvider.d.ts.map +1 -0
  142. package/types/src/surface/GridSurface.d.ts +11 -0
  143. package/types/src/surface/GridSurface.d.ts.map +1 -0
  144. package/types/src/surface/IGridPane.d.ts +288 -0
  145. package/types/src/surface/IGridPane.d.ts.map +1 -0
  146. package/types/src/surface/IGridSurface.d.ts +141 -0
  147. package/types/src/surface/IGridSurface.d.ts.map +1 -0
  148. package/types/src/surface/SurfaceStateProvider.d.ts +50 -0
  149. package/types/src/surface/SurfaceStateProvider.d.ts.map +1 -0
  150. package/types/src/surface/_GridUtils.d.ts +37 -0
  151. package/types/src/surface/_GridUtils.d.ts.map +1 -0
  152. package/types/src/surface/index.d.ts +7 -0
  153. package/types/src/surface/index.d.ts.map +1 -0
  154. package/types/src/surface/useGridPane.d.ts +31 -0
  155. package/types/src/surface/useGridPane.d.ts.map +1 -0
  156. package/types/src/surface/useSurfaceState.d.ts +22 -0
  157. package/types/src/surface/useSurfaceState.d.ts.map +1 -0
  158. package/types/src/svg/LineSVG.d.ts +13 -0
  159. package/types/src/svg/LineSVG.d.ts.map +1 -0
  160. package/types/src/svg/RectangleSVG.d.ts +114 -0
  161. package/types/src/svg/RectangleSVG.d.ts.map +1 -0
  162. package/types/src/svg/ShapeBounds.d.ts +15 -0
  163. package/types/src/svg/ShapeBounds.d.ts.map +1 -0
  164. package/types/src/svg/Types.d.ts +37 -0
  165. package/types/src/svg/Types.d.ts.map +1 -0
  166. package/types/src/svg/index.d.ts +9 -0
  167. package/types/src/svg/index.d.ts.map +1 -0
  168. package/types/src/theme/GridTheme.d.ts +56 -0
  169. package/types/src/theme/GridTheme.d.ts.map +1 -0
  170. package/types/src/theme/index.d.ts +2 -0
  171. package/types/src/theme/index.d.ts.map +1 -0
  172. package/node/assets/style.css +0 -1
@@ -0,0 +1,70 @@
1
+ import { default as React } from 'react';
2
+ import { CellCoords } from '@sheetxl/utils';
3
+ import { LayerProps } from '../layer';
4
+ import { CellRendererProps } from './CellRenderer';
5
+ import { CellModelOptions } from './_CellModel';
6
+ /**
7
+ * Props for {@link CellTileDiv} — the tiled cell content WITHOUT a layer: everything the tiling
8
+ * engine needs, none of the z-slot concerns.
9
+ */
10
+ export interface CellTileDivProps extends CellModelOptions {
11
+ /** Class for the tiling-origin box (devtools identification). */
12
+ className?: string;
13
+ /** Style merged UNDER the scroll-carry transform (which must win). */
14
+ style?: React.CSSProperties;
15
+ /**
16
+ * Render one cell. Called a lot — keep it cheap. Mirrors `GridSurface.renderCells`.
17
+ */
18
+ renderCell: (props: CellRendererProps) => React.ReactNode;
19
+ /**
20
+ * Opaque cache-bust token. The per-cell render cache survives scrolling (cells keep their
21
+ * absolute position), but must be dropped when cell CONTENT or geometry changes. Pass a value
22
+ * whose identity changes on invalidate / metrics change (and NOT on scroll); a new identity
23
+ * drops the cache. `renderCell` identity is always also treated as a bust.
24
+ */
25
+ cacheToken?: unknown;
26
+ /**
27
+ * Visually suppress the cell at these SHEET-absolute coordinates — WITHOUT invalidating anything.
28
+ *
29
+ * @remarks
30
+ * Transient per-coordinate state (a cell hidden under an open editor / a custom single-cell
31
+ * overlay) must not live inside the tile snapshots, or every change would rebuild tiles. This is
32
+ * the live channel: one scoped CSS rule targeting the cell's `data-rc` stamp (see
33
+ * `CellRendererProps`), so cached, rebuilt, and scrolled-back-in tiles all honor it for free.
34
+ * `visibility: hidden` (not `opacity`) so the suppressed cell — including any text overflowing
35
+ * its bounds, and a hyperlink that opted back into pointer-events — is neither visible nor
36
+ * hit-testable. Distinct from `hiddenCellAt`, which is a structural scan-time skip.
37
+ */
38
+ suppressCell?: CellCoords | null;
39
+ }
40
+ /**
41
+ * {@link CellLayer} is the cells' **layer**: a {@link Layer} (its z-slot; tap props forward to it)
42
+ * hosting one {@link CellTileDiv}. Use it directly as a grid child when the cells are the layer's
43
+ * ONLY content; a composite layer that hosts more than the tiles (an overlay peer of the cells)
44
+ * renders its own `Layer` with a `CellTileDiv` inside instead. `className` merges onto the layer's
45
+ * boundary div and `style` merges under the scroll transform (which must win).
46
+ */
47
+ export interface CellLayerProps extends Omit<LayerProps, 'children'>, CellTileDivProps {
48
+ }
49
+ /**
50
+ * The tiled cell content — a full-view scroll-carry {@link VirtualDiv} of immutable tile
51
+ * snapshots, plus the live per-coordinate suppression rule. NOT a layer: it is hosted inside one
52
+ * (see {@link CellLayer} for the direct-use wrapper), so a composite layer can stack overlay
53
+ * content beside the tiles within its single z-slot.
54
+ *
55
+ * @remarks
56
+ * Tiles (segment containers) are positioned in ABSOLUTE content space (`tileIndex * SEGMENT_SIZE`),
57
+ * so a tile is a pure function of its tile coordinate — an immutable snapshot. A single outer
58
+ * `<div>` translates the whole content by `-origin` to carry the scroll. The tile tree is
59
+ * `useMemo`'d on the visible RANGE (+ content token), NOT the pixel scroll: within a range, every
60
+ * cell's absolute position is invariant (`origin + bounds.x` is constant as scroll shifts both
61
+ * terms oppositely), so a sub-tile scroll reuses the exact same tile tree and only re-renders the
62
+ * one outer element. Net on-screen position is identical to the classic path (`= bounds.x`).
63
+ */
64
+ export declare const CellTileDiv: React.MemoExoticComponent<(props: CellTileDivProps) => React.JSX.Element>;
65
+ /**
66
+ * CellLayer — the thin direct-use wrapper: one {@link Layer} (its z-slot; tap props forward)
67
+ * hosting one {@link CellTileDiv}. See {@link CellTileDiv} for the tiling model.
68
+ */
69
+ export declare const CellLayer: React.MemoExoticComponent<(props: CellLayerProps) => React.JSX.Element>;
70
+ //# sourceMappingURL=CellLayer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CellLayer.d.ts","sourceRoot":"","sources":["../../../../src/cell/CellLayer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EAAE,KAAK,UAAU,EAAoB,MAAM,gBAAgB,CAAC;AAGnE,OAAO,EAAqB,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAE9D,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAgC,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAInF;;;GAGG;AACH,MAAM,WAAW,gBAAiB,SAAQ,gBAAgB;IACxD,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sEAAsE;IACtE,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B;;OAEG;IACH,UAAU,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,KAAK,CAAC,SAAS,CAAC;IAC1D;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;;;;;;OAWG;IACH,YAAY,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;CAClC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,EAAE,gBAAgB;CAAG;AAEzF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW,oCAAgB,gBAAgB,uBAmPtD,CAAC;AAGH;;;GAGG;AACH,eAAO,MAAM,SAAS,oCAAgB,cAAc,uBAqBlD,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { Bounds, CellCoords, RangeCoords } from '@sheetxl/utils';
2
+ import { IGridPane } from '../surface';
3
+ export interface CellRendererProps<T = any> extends React.HTMLAttributes<HTMLElement>, React.Attributes {
4
+ /**
5
+ * A value to render.
6
+ */
7
+ value: T;
8
+ /**
9
+ * The view that is rendering a collection of cells.
10
+ */
11
+ pane: IGridPane;
12
+ /**
13
+ * The range bounds relative to the current viewport and zoom.
14
+ */
15
+ bounds: Bounds;
16
+ /**
17
+ * The cell coords that is being rendered.
18
+ */
19
+ cell: CellCoords;
20
+ /**
21
+ * The RangeCoords that is being rendered.
22
+ *
23
+ * @defaultValue A range representing the coords
24
+ *
25
+ * @remarks
26
+ * For most cells this is the same as the coords. This will only be different for spanning cells.
27
+ */
28
+ range?: RangeCoords;
29
+ /**
30
+ * Absolute cell-coordinate stamp (`"rowIndex:colIndex"`), provided by the layer.
31
+ *
32
+ * @remarks
33
+ * A renderer that spreads its rest props onto its root element carries this automatically; a
34
+ * custom renderer must place it on its root itself. It is the hook the layer's live suppression
35
+ * rule targets (see `CellLayerProps.suppressCell`) — per-coordinate CSS over immutable cached
36
+ * tiles, so transient state (an open editor) never invalidates the tile cache. Coordinates are
37
+ * SHEET-absolute (never tile- or pane-relative): a cell rendered in more than one pane (a merge
38
+ * spanning a freeze line) matches the one selector in every instance.
39
+ */
40
+ 'data-rc'?: string;
41
+ }
42
+ //# sourceMappingURL=CellRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CellRenderer.d.ts","sourceRoot":"","sources":["../../../../src/cell/CellRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEhF,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,WAAW,iBAAiB,CAAC,CAAC,GAAC,GAAG,CAAE,SAAQ,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,UAAU;IACnG;;OAEG;IACH,KAAK,EAAE,CAAC,CAAC;IACT;;OAEG;IACH,IAAI,EAAE,SAAS,CAAC;IAChB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,IAAI,EAAE,UAAU,CAAC;IACjB;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB;;;;;;;;;;OAUG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
@@ -0,0 +1,6 @@
1
+ import { CellRendererProps } from './CellRenderer';
2
+ /**
3
+ * Default cell component capable of rendering a value.
4
+ */
5
+ export declare const DefaultCellRenderer: import('react').MemoExoticComponent<(props: CellRendererProps) => import("react").JSX.Element>;
6
+ //# sourceMappingURL=DefaultCellRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultCellRenderer.d.ts","sourceRoot":"","sources":["../../../../src/cell/DefaultCellRenderer.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGxD;;GAEG;AACH,eAAO,MAAM,mBAAmB,8CAAgB,iBAAiB,iCAoB/D,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { default as React } from 'react';
2
+ import { OrientationFlags } from '@sheetxl/utils';
3
+ import { LayerProps } from '../layer';
4
+ import { CellModelOptions } from './_CellModel';
5
+ /**
6
+ * {@link GridlineLayer} is the gridlines' **layer**: a {@link Layer} (its z-slot; tap props forward
7
+ * to it) hosting its two axis `<svg>`s inside one full-view, pointer-transparent {@link VirtualDiv}
8
+ * (a decoration host). Use it directly as a grid child. `className`/`style` apply to the host box.
9
+ */
10
+ export interface GridlineLayerProps extends Omit<LayerProps, 'children'>, CellModelOptions {
11
+ /** Class for the host box (devtools identification). */
12
+ className?: string;
13
+ /** Style for the host box. */
14
+ style?: React.CSSProperties;
15
+ /**
16
+ * Show grid lines. `true` shows both; an {@link OrientationFlags} partial toggles each axis.
17
+ *
18
+ * @defaultValue true
19
+ */
20
+ showGridLines?: boolean | Partial<OrientationFlags>;
21
+ /**
22
+ * Grid line color. Overridden per-axis by {@link GridlineLayerProps.propsRows} /
23
+ * {@link GridlineLayerProps.propsColumns}.
24
+ */
25
+ gridLineColor?: string;
26
+ /** Per-`<path>` props for the horizontal (row) lines. */
27
+ propsRows?: React.SVGProps<SVGPathElement>;
28
+ /** Per-`<path>` props for the vertical (column) lines. */
29
+ propsColumns?: React.SVGProps<SVGPathElement>;
30
+ }
31
+ /**
32
+ * A **layer** (pane-aware): paints the gridlines for its pane, broken around merged cells, inside a
33
+ * single full-pane {@link Layer} host box. Sources the merge spans from the merges-only
34
+ * {@link getMergedRanges} pass — index-space, memoized on the visible RANGE (not pixel scroll), so
35
+ * ordinary scroll frames re-render this layer without re-scanning a single cell.
36
+ */
37
+ export declare const GridlineLayer: React.MemoExoticComponent<(props: GridlineLayerProps) => React.JSX.Element | null>;
38
+ //# sourceMappingURL=GridlineLayer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GridlineLayer.d.ts","sourceRoot":"","sources":["../../../../src/cell/GridlineLayer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EAAgC,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIrF,OAAO,EAAqB,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAE9D,OAAO,EAAmB,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAItE;;;;GAIG;AACH,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,EAAE,gBAAgB;IACxF,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8BAA8B;IAC9B,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACpD;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yDAAyD;IACzD,SAAS,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;IAC3C,0DAA0D;IAC1D,YAAY,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;CAC/C;AA+MD;;;;;GAKG;AACH,eAAO,MAAM,aAAa,oCAAgB,kBAAkB,8BA+E1D,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { CellCoords, RangeCoords, Bounds } from '@sheetxl/utils';
2
+ /**
3
+ * A single cell resolved for rendering: its anchor coords, the range it occupies (a 1x1 range for
4
+ * a normal cell, larger for a merge), the pane-relative bounds, and an optional pre-resolved value.
5
+ */
6
+ export interface VisibleCell {
7
+ cell: CellCoords;
8
+ range?: RangeCoords;
9
+ bounds?: Bounds;
10
+ value?: any;
11
+ }
12
+ //# sourceMappingURL=Types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Types.d.ts","sourceRoot":"","sources":["../../../../src/cell/Types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,KAAK,MAAM,EAC/C,MAAM,gBAAgB,CAAC;AAExB;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,GAAG,CAAC;CACb"}
@@ -0,0 +1,82 @@
1
+ import { CellCoords, RangeCoords } from '@sheetxl/utils';
2
+ import { IGridPane } from '../surface';
3
+ import { VisibleCell } from './Types';
4
+ /**
5
+ * The "what is visible right now" pass for a single pane.
6
+ *
7
+ * @remarks
8
+ * {@link CellLayer} renders `cells`. {@link GridlineLayer} needs only the spans — it consumes the
9
+ * dedicated merges-only {@link getMergedRanges} pass (same source semantics, no cell allocation)
10
+ * rather than this full model.
11
+ */
12
+ export interface CellModel {
13
+ /** Visible cells (merge-deduped: only the anchor of a merge appears). */
14
+ cells: VisibleCell[];
15
+ /** Merged ranges spanning more than one ROW — horizontal gridlines break around these. */
16
+ rangesH: RangeCoords[];
17
+ /** Merged ranges spanning more than one COLUMN — vertical gridlines break around these. */
18
+ rangesV: RangeCoords[];
19
+ }
20
+ export interface CellModelOptions {
21
+ /**
22
+ * Optimization hook: return exactly the cells worth rendering for this pane. When omitted, every
23
+ * visible cell is iterated and {@link CellModelOptions.hiddenCellAt} is consulted.
24
+ *
25
+ * @param range Overrides the visible range (the buffered/tiled CellLayer passes a window that
26
+ * extends past the visible edge). When omitted, the implementation uses the pane's visible range.
27
+ */
28
+ getVisibleCells?: (pane: IGridPane, range?: RangeCoords) => (VisibleCell | CellCoords)[];
29
+ /**
30
+ * Skip a cell that has nothing to render. Ignored for merged cells (a merge is always considered)
31
+ * and ignored entirely when {@link CellModelOptions.getVisibleCells} is provided.
32
+ */
33
+ hiddenCellAt?: (coords: CellCoords) => boolean;
34
+ /**
35
+ * Render cells for this range instead of just the visible range — an overscan buffer so scrolling
36
+ * within it needs no recompute. Cells outside the visible range get their geometry from
37
+ * `getBoundsFromRange` (they are not in the visible offset maps). Used by the tiled CellLayer.
38
+ */
39
+ bufferRange?: RangeCoords;
40
+ /**
41
+ * Content-version token (cache-key only; ignored by {@link computeCellModel}). A new identity busts
42
+ * the {@link getCellModel} memo so a content edit recomputes the model immediately — without it the
43
+ * model cache (keyed on scroll + callback identity) would return the pre-edit cells for a frame,
44
+ * since an in-place value edit changes neither the scroll key nor the callback identities. Pass the
45
+ * same token CellLayer uses to drop its tile cache so both invalidate in lockstep.
46
+ */
47
+ cacheToken?: unknown;
48
+ }
49
+ /**
50
+ * Compute the visible cells + merge spans for a pane. Pure; no React. This is the ENUMERATION half
51
+ * of cell rendering — the tile bucketing / element rendering half lives in {@link CellLayer}.
52
+ */
53
+ export declare const computeCellModel: (pane: IGridPane, options?: CellModelOptions) => CellModel;
54
+ export declare const getCellModel: (pane: IGridPane, options?: CellModelOptions) => CellModel;
55
+ /**
56
+ * The merge/extrusion spans of the visible window — the subset of {@link CellModel} that
57
+ * {@link GridlineLayer} consumes. Index-space only ({@link RangeCoords}), so unlike the full model it
58
+ * is invariant under sub-cell PIXEL scroll.
59
+ */
60
+ export interface MergedRanges {
61
+ /** Spans covering more than one ROW — horizontal gridlines break around these. */
62
+ rangesH: RangeCoords[];
63
+ /** Spans covering more than one COLUMN — vertical gridlines break around these. */
64
+ rangesV: RangeCoords[];
65
+ }
66
+ /**
67
+ * Merges-only sibling of {@link computeCellModel}: collect just the spanned ranges (merges +
68
+ * extrusions) intersecting the pane's visible window. No cell array, no bounds resolution, no
69
+ * per-cell allocation — the full model allocates ~a-thousand `VisibleCell`s just to throw them away
70
+ * when the caller (gridlines) only breaks lines around spans.
71
+ *
72
+ * @remarks
73
+ * `hiddenCellAt` is deliberately not consulted: it is documented as ignored for merged cells, and a
74
+ * single (non-spanned) cell contributes nothing here — so it cannot affect this output.
75
+ */
76
+ export declare const computeMergedRanges: (pane: IGridPane, options?: CellModelOptions) => MergedRanges;
77
+ export declare const getMergedRanges: (pane: IGridPane, options?: CellModelOptions) => MergedRanges;
78
+ /**
79
+ * Create a stringified cell identifier.
80
+ */
81
+ export declare const cellIdentifier: (rowIndex: number, colIndex: number) => string;
82
+ //# sourceMappingURL=_CellModel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_CellModel.d.ts","sourceRoot":"","sources":["../../../../src/cell/_CellModel.ts"],"names":[],"mappings":"AAAA,OAAO,EACO,KAAK,UAAU,EAAE,KAAK,WAAW,EAC9C,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;;;;GAOG;AACH,MAAM,WAAW,SAAS;IACxB,yEAAyE;IACzE,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,0FAA0F;IAC1F,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,2FAA2F;IAC3F,OAAO,EAAE,WAAW,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,gBAAgB;IAC/B;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,WAAW,KAAK,CAAC,WAAW,GAAG,UAAU,CAAC,EAAE,CAAC;IACzF;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,CAAC;IAC/C;;;;OAIG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAOD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,SAAS,EAAE,UAAS,gBAAqB,KAAG,SA2IlF,CAAC;AAgCF,eAAO,MAAM,YAAY,GAAI,MAAM,SAAS,EAAE,UAAS,gBAAqB,KAAG,SA+B9E,CAAC;AAGF;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,kFAAkF;IAClF,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,mFAAmF;IACnF,OAAO,EAAE,WAAW,EAAE,CAAC;CACxB;AAID;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,SAAS,EAAE,UAAS,gBAAqB,KAAG,YAyCrF,CAAC;AAsBF,eAAO,MAAM,eAAe,GAAI,MAAM,SAAS,EAAE,UAAS,gBAAqB,KAAG,YAiBjF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,UAAU,MAAM,EAAE,UAAU,MAAM,KAAG,MAAmC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from './Types';
2
+ export * from './CellRenderer';
3
+ export * from './DefaultCellRenderer';
4
+ export * from './CellLayer';
5
+ export * from './GridlineLayer';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cell/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AAExB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,121 @@
1
+ import { CellCoords } from '@sheetxl/utils';
2
+ import { ICellAnchor } from '../selection';
3
+ import { EditCommitArgs } from './EditState';
4
+ import { EditSession, StartEditOptions, EditModel } from './EditSession';
5
+ /**
6
+ * How to edit a cell — supplied by whoever builds the editable. Returns the {@link EditModel} bits
7
+ * (`clean` + `commit`) for the cell, or `null` if the cell is not editable. The editable wraps these
8
+ * in an {@link EditSession}; the author never constructs one.
9
+ *
10
+ * @remarks
11
+ * An implementation detail of {@link DefaultEditable}, not part of the layer-facing contract. Collapses
12
+ * the former `getClean` + `canEdit` + `commit` (`null` ⇒ "not editable"). A story closes over a values
13
+ * map; the real app reads an `ISheet` (and returns `null` for a protected cell).
14
+ *
15
+ * @typeParam C - clean type. @typeParam D - dirty type. @typeParam A - commit args.
16
+ */
17
+ export type CreateEdit<C, D = string, A = EditCommitArgs> = (coords: CellCoords) => EditModel<C, D, A> | null;
18
+ /**
19
+ * The thing a grid edits **through** — owns the active-cell anchor and the **single** current edit,
20
+ * and is the one place an edit is started/committed/cancelled. The parallel of {@link ICellAnchor}:
21
+ * where the selection owns the current coords, the editable owns the current {@link EditSession}.
22
+ *
23
+ * @remarks
24
+ * The layer-facing contract. {@link EditorLayer} and the formula bar share one instance and drive it
25
+ * (`startEdit`/`commit`/`cancel`); an app-side bridge can publish {@link getSession} onto the edit-mode
26
+ * bus on each `subscribe` notification. It does **not** vend sessions — there is only
27
+ * ever one active edit, held here. {@link DefaultEditable} is the default implementation; the real app
28
+ * supplies its own (or reuses it with an `ISheet`-backed {@link CreateEdit}).
29
+ *
30
+ * @typeParam C - clean type. @typeParam D - dirty type. @typeParam A - commit args.
31
+ */
32
+ export interface IEditable<C, D = string, A = EditCommitArgs> {
33
+ /**
34
+ * The active-cell anchor, as {@link ICellAnchor}. The editor reads it (`getCoords`/`subscribe`) to
35
+ * follow the active cell and detect click-away; it cannot move it (navigation is the selection's
36
+ * job — the anchor read view is intentionally setter-less).
37
+ */
38
+ getAnchor(): ICellAnchor;
39
+ /** The current edit session, or `null` when idle. */
40
+ getSession(): EditSession<C, D, A> | null;
41
+ /** Subscribe to session changes (start/stop only). Returns an unsubscribe. */
42
+ subscribe(listener: () => void): () => void;
43
+ /** Begin an edit on `coords`. Returns `false` (and does nothing) if the cell is not editable. */
44
+ startEdit(coords: CellCoords, options?: StartEditOptions<D>): boolean;
45
+ /** Commit the current edit. On success clears the session; returns whether it succeeded. */
46
+ commit(args?: A): boolean;
47
+ /** Cancel the current edit (revert + clear the session). */
48
+ cancel(): void;
49
+ /**
50
+ * Tear the editable down: unsubscribe from the anchor (the click-away watch) and cancel any live
51
+ * session. Call when the owning view/sheet goes away so a per-view/per-sheet editable doesn't keep
52
+ * observing (and mutating through) a dead anchor.
53
+ */
54
+ dispose(): void;
55
+ }
56
+ /**
57
+ * The edit-mode bus payload published (as `EditMode.args`) while a cell edit is active: the live
58
+ * {@link IEditable} handle. Lives here, next to {@link IEditable}, so the publisher and every bus
59
+ * reader share one type instead of casting `args` loosely. The bus key for this mode is `'edit'`;
60
+ * the fine-grained enter/edit state is read from `editable.getSession()`, not the key.
61
+ */
62
+ export interface EditModeEditArgs<C = any, D = any, A = any> {
63
+ editable: IEditable<C, D, A>;
64
+ }
65
+ /**
66
+ * Options for {@link DefaultEditable}.
67
+ */
68
+ export interface DefaultEditableOptions {
69
+ /**
70
+ * The click-away **pre-commit gate** fallback: when the anchor moves off the edited cell and the
71
+ * commit FAILS (vetoed / rejected value), the session must not stay open on cell A while the
72
+ * selection sits on cell B. Supply this to pull the anchor **back to the edited cell** (Excel-style
73
+ * — an invalid entry keeps you in the cell); the owner — who holds the writable selection the
74
+ * anchor reads — performs the move. When omitted, the editable **cancels** the failed edit instead
75
+ * (the typed value is discarded, but session and selection stay in sync).
76
+ */
77
+ revertAnchor?: (coords: CellCoords) => void;
78
+ }
79
+ /**
80
+ * The default {@link IEditable}: holds the {@link ICellAnchor} anchor and the single current edit, and
81
+ * mints that edit (when started) via a {@link CreateEdit} callback.
82
+ *
83
+ * @remarks
84
+ * One per workbook, passed by reference to every `EditorLayer` and the formula bar. Its `subscribe`
85
+ * fires **only** on a current-edit change (start/stop) — anchor changes are observed directly on the
86
+ * anchor; the edit's per-keystroke *value* updates live on the {@link EditSession}'s own `subscribe`.
87
+ *
88
+ * It owns the **click-away** rule: it watches the anchor and commits the current edit when the active
89
+ * cell moves off the edited cell — so the layer never has to. (When Point mode lands, this is where an
90
+ * anchor move would instead route a reference into the edit rather than commit.)
91
+ *
92
+ * Methods are plain (unbound) — consumers read it via `useBoundSyncExternalStore` (or its optional
93
+ * variant), which calls `subscribe`/the snapshot selector on the instance, so no per-method binding
94
+ * is needed.
95
+ */
96
+ export declare class DefaultEditable<C, D = string, A = EditCommitArgs> implements IEditable<C, D, A> {
97
+ private readonly anchor;
98
+ private readonly createEdit;
99
+ private readonly revertAnchor?;
100
+ private readonly unsubscribeAnchor;
101
+ private current;
102
+ private readonly listeners;
103
+ constructor(anchor: ICellAnchor, createEdit: CreateEdit<C, D, A>, options?: DefaultEditableOptions);
104
+ private onAnchorChange;
105
+ /** @inheritdoc IEditable.getAnchor */
106
+ getAnchor(): ICellAnchor;
107
+ /** @inheritdoc IEditable.subscribe */
108
+ subscribe(listener: () => void): () => void;
109
+ /** @inheritdoc IEditable.getSession */
110
+ getSession(): EditSession<C, D, A> | null;
111
+ /** @inheritdoc IEditable.startEdit */
112
+ startEdit(coords: CellCoords, options?: StartEditOptions<D>): boolean;
113
+ /** @inheritdoc IEditable.commit */
114
+ commit(args?: A): boolean;
115
+ /** @inheritdoc IEditable.cancel */
116
+ cancel(): void;
117
+ /** @inheritdoc IEditable.dispose */
118
+ dispose(): void;
119
+ private notify;
120
+ }
121
+ //# sourceMappingURL=DefaultEditable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultEditable.d.ts","sourceRoot":"","sources":["../../../../src/editor/DefaultEditable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE7D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AAEnF;;;;;;;;;;;GA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,CAAC,GAAG,cAAc,CAAE,YAAW,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAC3F,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;IACrC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAsB;IACjD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAA+B;IAC7D,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAa;IAC/C,OAAO,CAAC,OAAO,CAAqC;IACpD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAyB;gBAEvC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,sBAAsB;IASlG,OAAO,CAAC,cAAc;IActB,sCAAsC;IACtC,SAAS,IAAI,WAAW;IAIxB,sCAAsC;IACtC,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAK3C,uCAAuC;IACvC,UAAU,IAAI,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI;IAIzC,sCAAsC;IACtC,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,GAAE,gBAAgB,CAAC,CAAC,CAAM,GAAG,OAAO;IAQzE,mCAAmC;IACnC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,OAAO;IAUzB,mCAAmC;IACnC,MAAM,IAAI,IAAI;IAOd,oCAAoC;IACpC,OAAO,IAAI,IAAI;IAMf,OAAO,CAAC,MAAM;CAGf"}
@@ -0,0 +1,182 @@
1
+ import { CellCoords } from '@sheetxl/utils';
2
+ import { ICellAnchor } from '../selection';
3
+ import { EditState, EditorMode, EditorTextSelection, EditCommitArgs } from './EditState';
4
+ /**
5
+ * The imperative handle a caret-owning **input** exposes for **caret-dependent** operations — the input
6
+ * analog of the selection's `SelectionNavigation`. These act on *this input's* caret/selection, so they
7
+ * live on the view, not on any shared value: two inputs on the same cell (the inline editor + the formula
8
+ * bar) share the value but each has its own caret.
9
+ *
10
+ * @remarks
11
+ * Deliberately broader than "cell editor": not every range input is one (the formula bar is not). A
12
+ * cell editor registers on the {@link EditSession} it participates in
13
+ * ({@link EditSession.registerEditor}), reached via {@link EditSession.getActiveEditor}.
14
+ *
15
+ * Kept **spreadsheet-agnostic** — grid-react knows text inputs, not references. Reference-specific caret
16
+ * ops (F4 `$`-cycling, insert a picked reference) live on a `@sheetxl/react` subtype that extends this.
17
+ */
18
+ export interface IInputHandle {
19
+ /** Insert `text` at the caret (replacing any selection); the caret ends up after it. */
20
+ insertText(text: string): void;
21
+ /** Select all of the input's text. */
22
+ selectAll(): void;
23
+ /**
24
+ * Place this input's caret / selection. The host-facing counterpart of the read-side caret ops: caret
25
+ * position is a **view** concern (each input owns its own), so a host that needs one parked somewhere —
26
+ * e.g. after the reference just picked — asks the input rather than the edit carrying a caret of its own.
27
+ */
28
+ setSelection(selection: EditorTextSelection): void;
29
+ /** Focus this input (used by `toggleEditorFocus` to move the edit between inputs). */
30
+ focus(): void;
31
+ }
32
+ /**
33
+ * The model-specific bits {@link CreateEdit} supplies for a cell: the captured clean value and how to
34
+ * write the dirty value back. Everything else (coords/dirty/mode/lifecycle) is the library's machinery.
35
+ *
36
+ * @typeParam C - clean type. @typeParam D - dirty type. @typeParam A - commit args.
37
+ */
38
+ export interface EditModel<C, D = string, A = EditCommitArgs> {
39
+ /** The clean value, captured now (edit start). */
40
+ clean: C;
41
+ /** Write the dirty value to the model. Return `false`, or throw, to reject (keeps the edit open). */
42
+ commit(dirty: D, args?: A): boolean | void;
43
+ }
44
+ /**
45
+ * What the {@link EditSession} constructor takes: the {@link EditModel} bits plus the cell. The owning
46
+ * {@link DefaultEditable} assembles this (model bits from `createEdit` + the coords it was asked to
47
+ * edit) — a `createEdit` author supplies only the {@link EditModel}.
48
+ */
49
+ export interface EditSessionInit<C, D = string, A = EditCommitArgs> extends EditModel<C, D, A> {
50
+ /** The cell being edited. */
51
+ coords: CellCoords;
52
+ }
53
+ /**
54
+ * Options applied when an edit begins (`DefaultEditable.startEdit` → the `EditSession` constructor).
55
+ *
56
+ * @typeParam D - The dirty (working) value type.
57
+ */
58
+ export interface StartEditOptions<D = string> {
59
+ /** @defaultValue `'enter'` */
60
+ mode?: EditorMode;
61
+ /** Seed dirty value (the "first keystroke, by value"). `undefined` keeps the clean value. */
62
+ dirty?: D;
63
+ /** Initial selection to apply on focus. */
64
+ initialSelection?: EditorTextSelection | null;
65
+ /** @defaultValue `true` */
66
+ autoFocus?: boolean;
67
+ }
68
+ /**
69
+ * Passed to each beforeCommit consumer ({@link EditSession.addCommitListener}). Call {@link veto} to
70
+ * reject the commit (the edit stays open and the leave-key does not navigate).
71
+ */
72
+ export interface CommitContext<D = string, A = EditCommitArgs> {
73
+ readonly coords: CellCoords;
74
+ /**
75
+ * The working value being committed, or `undefined` for a **no-op** commit (nothing typed — the
76
+ * model is not written, but listeners still run and may veto, e.g. to hold the session open).
77
+ */
78
+ readonly dirty: D | undefined;
79
+ readonly args?: A;
80
+ veto(): void;
81
+ }
82
+ /**
83
+ * A single edit — created per edit by a model's `getEdit`, discarded on commit/cancel. It carries the
84
+ * captured clean + the model's write, and owns the working state + commit lifecycle.
85
+ *
86
+ * @remarks
87
+ * Consumers read it via {@link getState} / {@link subscribe} and drive its value via {@link setDirty} /
88
+ * {@link setMode} / {@link addCommitListener}. The owning {@link DefaultEditable} constructs it and
89
+ * drives its `@internal` {@link commit} / {@link cancel} (you call `editable.commit/cancel`, not these).
90
+ * Methods are plain (unbound) — consumers read it via `useOptionalBoundSyncExternalStore`, which calls
91
+ * `subscribe`/the snapshot selector on the instance, so no per-method binding is needed.
92
+ *
93
+ * Implements {@link ICellAnchor} as a **fixed-cell** anchor: `getCoords` returns the edited cell
94
+ * (which never moves for the life of the session) and `subscribe` observes its edit state. Lets a
95
+ * session be read uniformly as "a thing located at a cell".
96
+ */
97
+ export declare class EditSession<C, D = string, A = EditCommitArgs> implements ICellAnchor {
98
+ private readonly commitFn;
99
+ private state;
100
+ private readonly listeners;
101
+ private readonly commitListeners;
102
+ private readonly cancelListeners;
103
+ private readonly editors;
104
+ private activeEditor;
105
+ private activeEditorId;
106
+ private auxState;
107
+ /**
108
+ * Built by {@link DefaultEditable.startEdit}: the model bits + coords ({@link EditSessionInit}) plus
109
+ * the open-time {@link StartEditOptions} (mode, seeded keystroke, focus). A fresh focus token is
110
+ * stamped per session — each edit is a new session, so the input re-focuses.
111
+ */
112
+ constructor(init: EditSessionInit<C, D, A>, options?: StartEditOptions<D>);
113
+ getState(): EditState<C, D>;
114
+ /** @inheritdoc ICellAnchor.getCoords */
115
+ getCoords(): CellCoords;
116
+ subscribe(listener: () => void): (() => void);
117
+ /**
118
+ * Register an editor participating in this edit (inline editor, formula bar…). Returns an unregister
119
+ * (call on unmount). Both editors of the same cell reach the SAME session via the shared editable, so
120
+ * both register here — which is how `toggleEditorFocus` enumerates them and a caret command finds the
121
+ * focused one.
122
+ */
123
+ registerEditor(handle: IInputHandle): () => void;
124
+ /** Mark the focused editor (the caret owner) on focus, or `null` on blur. */
125
+ setActiveEditor(handle: IInputHandle | null): void;
126
+ /** The focused editor's handle (the caret owner), or `null`. Caret commands target this. */
127
+ getActiveEditor(): IInputHandle | null;
128
+ /**
129
+ * Park the LOGICAL id of the editor taking focus. Called by the **host** (the editor layer / formula bar),
130
+ * which is what owns editor identity — an input is a physical mount and stays identity-free.
131
+ *
132
+ * @remarks
133
+ * Deliberately *not* derived from {@link IInputHandle}: a handle dies with its mount, and the whole point
134
+ * of this id is to outlive a host that hides or unmounts (switching sheets mid-edit) so the same host can
135
+ * recognize itself on the way back. Never cleared on unmount — a host parks an id on FOCUS only. `null`
136
+ * explicitly UN-parks (focus landed on a host with no id — no host may later reclaim focus as "the
137
+ * active editor"); the session itself is discarded on commit/cancel, so it can't go stale across edits.
138
+ */
139
+ setActiveEditorId(id: string | null): void;
140
+ /**
141
+ * The parked id ({@link setActiveEditorId}) of the editor that last held focus — durable across a host
142
+ * unmount/remount, unlike {@link getActiveEditor}. A host reads it to decide whether it *was* the active
143
+ * editor and may reclaim focus (so it never steals from the formula bar / a 3rd-party editor). `null`
144
+ * until some host has parked one.
145
+ */
146
+ getActiveEditorId(): string | null;
147
+ /** All editors participating in this edit — for `toggleEditorFocus` to cycle focus. */
148
+ getEditors(): IInputHandle[];
149
+ /**
150
+ * An opaque, **app-defined** value the active editor publishes and peer views observe (through the
151
+ * session's normal `subscribe`). grid-react does not interpret it — the SDK-aware `@sheetxl/react`
152
+ * layer defines the shape (e.g. a formula's reference ranges for the pane picker). Cast on read.
153
+ * Held OFF {@link EditState} so publishing it doesn't re-render the value/mode subscribers (their
154
+ * `getState()` snapshot is unchanged); only `getAuxState` readers re-render.
155
+ */
156
+ getAuxState<T = unknown>(): T | null;
157
+ /**
158
+ * Publish the {@link getAuxState} value (the active editor calls this on value/caret change; `null`
159
+ * when it has nothing to show). Referential guard only — the caller owns value-equality and should
160
+ * pass a stable reference for unchanged content, so a caret move that changes nothing doesn't churn.
161
+ */
162
+ setAuxState(next: unknown): void;
163
+ setDirty(dirty: D): void;
164
+ setMode(mode: EditorMode): void;
165
+ /**
166
+ * @internal Driven by {@link DefaultEditable.commit}. Runs **every** beforeCommit consumer (a
167
+ * `veto()` or throw rejects — a throw is also logged, never silently swallowed), then the model's
168
+ * write. Returns whether it succeeded. A no-op (nothing typed) skips only the model write — the
169
+ * listeners still run (and may veto), so a consumer observing "commit happened" is never skipped.
170
+ * Does NOT clear the owning editable's session — `editable.commit` does that on success.
171
+ */
172
+ commit(args?: A): boolean;
173
+ /** @internal Driven by {@link DefaultEditable.cancel}. Notifies cancel observers; the editable clears the session. */
174
+ cancel(): void;
175
+ /** Register a beforeCommit consumer (validation, peers, …). Many may register; any may veto. */
176
+ addCommitListener(fn: (ctx: CommitContext<D, A>) => void): (() => void);
177
+ /** Observe a cancel. */
178
+ addCancelListener(fn: () => void): (() => void);
179
+ private emit;
180
+ private notify;
181
+ }
182
+ //# sourceMappingURL=EditSession.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditSession.d.ts","sourceRoot":"","sources":["../../../../src/editor/EditSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,KAAK,mBAAmB,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7G;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,YAAY;IAC3B,wFAAwF;IACxF,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,sCAAsC;IACtC,SAAS,IAAI,IAAI,CAAC;IAClB;;;;OAIG;IACH,YAAY,CAAC,SAAS,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACnD,sFAAsF;IACtF,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;;;;GAKG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,GAAG,cAAc;IAC1D,kDAAkD;IAClD,KAAK,EAAE,CAAC,CAAC;IACT,qGAAqG;IACrG,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,OAAO,GAAG,IAAI,CAAC;CAC5C;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,GAAG,cAAc,CAAE,SAAQ,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAC5F,6BAA6B;IAC7B,MAAM,EAAE,UAAU,CAAC;CACpB;AAGD;;;;GAIG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,MAAM;IAC1C,8BAA8B;IAC9B,IAAI,CAAC,EAAE,U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