@ricsam/react-spreadsheets 0.0.8 → 0.0.9

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.
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@ricsam/react-spreadsheets",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "type": "module"
5
5
  }
@@ -8,9 +8,10 @@
8
8
  * Remember to import the stylesheet once in your app:
9
9
  * import "@ricsam/react-spreadsheets/styles.css";
10
10
  */
11
- export { Spreadsheet, type SpreadsheetProps, type SpreadsheetRef, type SpreadsheetScrollAlignment, type SpreadsheetScrollToCellOptions, type SpreadsheetChild, type SpreadsheetChildInitial, type SpreadsheetChildState, type SpreadsheetComponent, } from "./spreadsheet/spreadsheet";
11
+ export { Spreadsheet, type SpreadsheetProps, type SpreadsheetRef, type SpreadsheetScrollAlignment, type SpreadsheetScrollToCellOptions, type SpreadsheetScrollToRangeOptions, type SpreadsheetChild, type SpreadsheetChildInitial, type SpreadsheetChildState, type SpreadsheetComponent, } from "./spreadsheet/spreadsheet";
12
12
  export type { SelectionNavigationModel } from "@ricsam/selection-manager";
13
13
  export { FormulaSheet, FormulaWorkbook, WorkbookClipboardManager, WorkbookSelectionManager, } from "./workbook/workbook";
14
+ export type { WorkbookRangeFocusOptions } from "./workbook/workbook-selection-manager";
14
15
  export { coerceCellInput, getCellDisplayText, getCellDisplayValue, } from "./workbook/cell-data-type";
15
16
  export { normalizeBorderSides, hasAnyBorderSide, type BorderSides, type NormalizedBorderSides, } from "./workbook/border-sides";
16
17
  export { onCellEditError, queueCellEditError, type CellEditErrorListener, } from "./workbook/cell-edit-error";
@@ -1,4 +1,4 @@
1
- import { type Format, SelectionManager, type SelectionNavigationModel, type SelectionManagerState, type SMCell } from '@ricsam/selection-manager';
1
+ import { type Format, SelectionManager, type SelectionNavigationModel, type SelectionManagerState, type SMArea, type SMCell } from '@ricsam/selection-manager';
2
2
  import React, { type ReactNode } from 'react';
3
3
  import type { CellRenderContext, SerializedCellValue, SpreadsheetColumnWidths, SpreadsheetRowHeights } from '../types';
4
4
  import { type CellSnapAnchor } from './snapping';
@@ -89,11 +89,16 @@ export type SpreadsheetScrollAlignment = 'nearest' | 'start' | 'end';
89
89
  export interface SpreadsheetScrollToCellOptions {
90
90
  align?: SpreadsheetScrollAlignment;
91
91
  }
92
+ export interface SpreadsheetScrollToRangeOptions {
93
+ align?: SpreadsheetScrollAlignment;
94
+ }
92
95
  export interface SpreadsheetRef {
93
96
  focus: () => void;
94
97
  blur: () => void;
95
98
  /** Reveal a zero-based cell without changing the selection. */
96
99
  scrollToCell: (cell: SMCell, options?: SpreadsheetScrollToCellOptions) => void;
100
+ /** Reveal a zero-based range without changing the selection. */
101
+ scrollToRange: (range: SMArea, options?: SpreadsheetScrollToRangeOptions) => void;
97
102
  }
98
103
  export declare const Spreadsheet: React.ForwardRefExoticComponent<SpreadsheetProps & {
99
104
  disableClipboard?: boolean;
@@ -1,15 +1,25 @@
1
1
  import type { RangeAddress } from '@ricsam/formula-engine';
2
- import type { SelectionManager } from '@ricsam/selection-manager';
2
+ import type { SelectionManager, ViewportAlignment } from '@ricsam/selection-manager';
3
3
  interface ManagerContext {
4
4
  workbookName: string;
5
5
  sheetName: string;
6
6
  }
7
+ export interface WorkbookRangeFocusOptions {
8
+ /** How the target range should be positioned in the spreadsheet viewport. */
9
+ align?: ViewportAlignment;
10
+ }
7
11
  export declare class WorkbookSelectionManager {
8
12
  private managers;
9
13
  private lastFocusedManager;
10
14
  private listeners;
11
15
  private cleanupFunctions;
16
+ private pendingRangeFocus;
12
17
  private smAreaToSpreadsheetRange;
18
+ private spreadsheetRangeToSmArea;
19
+ private cloneRangeAddress;
20
+ private matchesContext;
21
+ private applyRangeFocus;
22
+ private applyPendingRangeFocusOnMount;
13
23
  /**
14
24
  * Register a SelectionManager with its workbook/sheet context
15
25
  * Returns a cleanup function to unregister
@@ -59,10 +69,20 @@ export declare class WorkbookSelectionManager {
59
69
  * Finds the matching SelectionManager, sets its selection to the given cell,
60
70
  * and focuses it.
61
71
  *
62
- * @returns true if the cell was successfully focused, false if no matching
63
- * manager was found (e.g. the sheet is not currently rendered).
72
+ * @returns true when focused immediately, false when queued until the target
73
+ * sheet mounts.
64
74
  */
65
75
  focusCell(workbookName: string, sheetName: string, row: number, col: number): boolean;
76
+ /**
77
+ * Focus, select and reveal a range in its workbook/sheet.
78
+ *
79
+ * If the sheet is not mounted yet, the latest request is queued and applied
80
+ * when that sheet registers. This lets controlled workbooks switch their
81
+ * active sheet before the target grid exists.
82
+ *
83
+ * @returns true when applied immediately, false when queued for a future mount.
84
+ */
85
+ focusRange(address: RangeAddress, options?: WorkbookRangeFocusOptions): boolean;
66
86
  /**
67
87
  * Notify all listeners of selection change
68
88
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ricsam/react-spreadsheets",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "Headless-friendly React spreadsheet and workbook components: infinite virtualized grid, zoom, resizing, clipboard, fill handles and formula-engine bindings.",
5
5
  "type": "module",
6
6
  "module": "./dist/mjs/lib.mjs",
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "peerDependencies": {
45
45
  "@ricsam/formula-engine": ">=0.2.0",
46
- "@ricsam/selection-manager": ">=0.0.29",
46
+ "@ricsam/selection-manager": ">=0.0.31",
47
47
  "react": "^18 || ^19",
48
48
  "react-dom": "^18 || ^19"
49
49
  },
@@ -55,7 +55,7 @@
55
55
  "devDependencies": {
56
56
  "@happy-dom/global-registrator": "^18.0.1",
57
57
  "@ricsam/formula-engine": "^0.2.15",
58
- "@ricsam/selection-manager": "^0.0.29",
58
+ "@ricsam/selection-manager": "^0.0.31",
59
59
  "@testing-library/react": "^16.3.0",
60
60
  "@types/bun": "latest",
61
61
  "@types/react": "^19",