@ricsam/react-spreadsheets 0.0.7 → 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.
- package/README.md +86 -4
- package/dist/cjs/lib.cjs +411 -62
- package/dist/cjs/lib.cjs.map +5 -5
- package/dist/cjs/package.json +1 -1
- package/dist/mjs/lib.mjs +412 -63
- package/dist/mjs/lib.mjs.map +5 -5
- package/dist/mjs/package.json +1 -1
- package/dist/styles.css +36 -0
- package/dist/types/lib.d.ts +3 -1
- package/dist/types/spreadsheet/spreadsheet.d.ts +18 -1
- package/dist/types/workbook/workbook-selection-manager.d.ts +23 -3
- package/package.json +3 -3
package/dist/mjs/package.json
CHANGED
package/dist/styles.css
CHANGED
|
@@ -150,6 +150,7 @@
|
|
|
150
150
|
--_rsp-accent-contrast: var(--rsp-accent-contrast, #ffffff);
|
|
151
151
|
--_rsp-selection-bg: var(--rsp-selection-bg, var(--rsp-light, #e8f2fe) var(--rsp-dark, #17304f));
|
|
152
152
|
--_rsp-selection-range-bg: var(--rsp-selection-range-bg, var(--rsp-light, #f1f7fe) var(--rsp-dark, #14263d));
|
|
153
|
+
--_rsp-reference-accent: var(--rsp-reference-accent, var(--rsp-light, #f97316) var(--rsp-dark, #fb923c));
|
|
153
154
|
--_rsp-hover-bg: var(--rsp-hover-bg, var(--rsp-light, #f5f7fa) var(--rsp-dark, #1c2436));
|
|
154
155
|
--_rsp-focus-ring: var(--rsp-focus-ring, var(--rsp-light, rgba(33, 150, 243, 0.22)) var(--rsp-dark, rgba(88, 166, 255, 0.28)));
|
|
155
156
|
|
|
@@ -276,6 +277,41 @@
|
|
|
276
277
|
z-index: 2;
|
|
277
278
|
}
|
|
278
279
|
|
|
280
|
+
/* Formula references are not primary selections. They live in one independent
|
|
281
|
+
overlay so table fills, conditional styles and the selected-cell perimeter
|
|
282
|
+
remain untouched. Four animated gradients create Excel-like marching ants. */
|
|
283
|
+
.rsp-reference-selection {
|
|
284
|
+
position: absolute;
|
|
285
|
+
z-index: 4;
|
|
286
|
+
pointer-events: none;
|
|
287
|
+
background-image:
|
|
288
|
+
linear-gradient(90deg, var(--_rsp-reference-accent) 50%, transparent 50%),
|
|
289
|
+
linear-gradient(90deg, var(--_rsp-reference-accent) 50%, transparent 50%),
|
|
290
|
+
linear-gradient(0deg, var(--_rsp-reference-accent) 50%, transparent 50%),
|
|
291
|
+
linear-gradient(0deg, var(--_rsp-reference-accent) 50%, transparent 50%);
|
|
292
|
+
background-position: 0 0, 0 100%, 0 0, 100% 0;
|
|
293
|
+
background-repeat: repeat-x, repeat-x, repeat-y, repeat-y;
|
|
294
|
+
background-size: 8px 2px, 8px 2px, 2px 8px, 2px 8px;
|
|
295
|
+
filter: drop-shadow(0 0 1px var(--_rsp-bg));
|
|
296
|
+
animation: rsp-reference-marching-ants 480ms linear infinite;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
.rsp-reference-selection-selecting {
|
|
300
|
+
opacity: 0.9;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
@keyframes rsp-reference-marching-ants {
|
|
304
|
+
to {
|
|
305
|
+
background-position: 8px 0, -8px 100%, 0 -8px, 100% 8px;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
@media (prefers-reduced-motion: reduce) {
|
|
310
|
+
.rsp-reference-selection {
|
|
311
|
+
animation: none;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
279
315
|
/* The editor surface must win over the selection tint above (equal specificity
|
|
280
316
|
would otherwise leave the selected-cell background showing through), and over
|
|
281
317
|
a consumer background so the text being typed stays legible. */
|
package/dist/types/lib.d.ts
CHANGED
|
@@ -8,8 +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 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
|
+
export type { SelectionNavigationModel } from "@ricsam/selection-manager";
|
|
12
13
|
export { FormulaSheet, FormulaWorkbook, WorkbookClipboardManager, WorkbookSelectionManager, } from "./workbook/workbook";
|
|
14
|
+
export type { WorkbookRangeFocusOptions } from "./workbook/workbook-selection-manager";
|
|
13
15
|
export { coerceCellInput, getCellDisplayText, getCellDisplayValue, } from "./workbook/cell-data-type";
|
|
14
16
|
export { normalizeBorderSides, hasAnyBorderSide, type BorderSides, type NormalizedBorderSides, } from "./workbook/border-sides";
|
|
15
17
|
export { onCellEditError, queueCellEditError, type CellEditErrorListener, } from "./workbook/cell-edit-error";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Format, SelectionManager, type SelectionManagerState } 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';
|
|
@@ -39,6 +39,10 @@ export interface SpreadsheetProps {
|
|
|
39
39
|
cellData?: Map<string, SerializedCellValue>;
|
|
40
40
|
onCellDataChange?: (data: Map<string, SerializedCellValue>) => void;
|
|
41
41
|
onCellDataChangeError?: (error: unknown) => void;
|
|
42
|
+
/** Finite number of rows. Omit for an unbounded sheet. */
|
|
43
|
+
rowCount?: number;
|
|
44
|
+
/** Finite number of columns. Omit for an unbounded sheet. */
|
|
45
|
+
columnCount?: number;
|
|
42
46
|
columnWidths?: SpreadsheetColumnWidths;
|
|
43
47
|
onColumnWidthsChange?: (columnWidths: SpreadsheetColumnWidths) => void;
|
|
44
48
|
rowHeights?: SpreadsheetRowHeights;
|
|
@@ -62,6 +66,8 @@ export interface SpreadsheetProps {
|
|
|
62
66
|
onStateChange?: (state: SelectionManagerState) => void;
|
|
63
67
|
effects?: (selectionManager: SelectionManager) => (() => void) | void;
|
|
64
68
|
formats?: Format[];
|
|
69
|
+
/** Data- and table-aware keyboard navigation hooks. */
|
|
70
|
+
navigation?: SelectionNavigationModel;
|
|
65
71
|
};
|
|
66
72
|
components?: Record<string, SpreadsheetComponent>;
|
|
67
73
|
overlayChildren?: SpreadsheetChild[];
|
|
@@ -79,9 +85,20 @@ export interface SpreadsheetProps {
|
|
|
79
85
|
/** Whether the parent component is selected (used to gate overlay selection) */
|
|
80
86
|
parentSelected?: boolean;
|
|
81
87
|
}
|
|
88
|
+
export type SpreadsheetScrollAlignment = 'nearest' | 'start' | 'end';
|
|
89
|
+
export interface SpreadsheetScrollToCellOptions {
|
|
90
|
+
align?: SpreadsheetScrollAlignment;
|
|
91
|
+
}
|
|
92
|
+
export interface SpreadsheetScrollToRangeOptions {
|
|
93
|
+
align?: SpreadsheetScrollAlignment;
|
|
94
|
+
}
|
|
82
95
|
export interface SpreadsheetRef {
|
|
83
96
|
focus: () => void;
|
|
84
97
|
blur: () => void;
|
|
98
|
+
/** Reveal a zero-based cell without changing the selection. */
|
|
99
|
+
scrollToCell: (cell: SMCell, options?: SpreadsheetScrollToCellOptions) => void;
|
|
100
|
+
/** Reveal a zero-based range without changing the selection. */
|
|
101
|
+
scrollToRange: (range: SMArea, options?: SpreadsheetScrollToRangeOptions) => void;
|
|
85
102
|
}
|
|
86
103
|
export declare const Spreadsheet: React.ForwardRefExoticComponent<SpreadsheetProps & {
|
|
87
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
|
|
63
|
-
*
|
|
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.
|
|
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.
|
|
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.
|
|
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",
|