@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/README.md
CHANGED
|
@@ -134,9 +134,90 @@ function ReferenceAwareSheet({ highlight }: { highlight?: Highlight }) {
|
|
|
134
134
|
|
|
135
135
|
Update `highlight` from the formula editor's caret/reference analysis. Clearing
|
|
136
136
|
it removes the decoration, while the selection manager continues to own mouse,
|
|
137
|
-
keyboard and edit selection state independently.
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
keyboard and edit selection state independently. The same `customCellStyle`
|
|
138
|
+
prop is forwarded to a `FormulaWorkbook`'s active sheet.
|
|
139
|
+
|
|
140
|
+
To focus and reveal the reference itself, share a `WorkbookSelectionManager`
|
|
141
|
+
with the formula sheets and pass the resolved `RangeAddress` to `focusRange`:
|
|
142
|
+
|
|
143
|
+
```tsx
|
|
144
|
+
const workbookSelection = new WorkbookSelectionManager();
|
|
145
|
+
|
|
146
|
+
workbookSelection.focusRange(referenceAddress, { align: "nearest" });
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
The call selects the complete target range, focuses its grid and asks the grid
|
|
150
|
+
to reveal it. It returns `true` when the target sheet is already mounted. If a
|
|
151
|
+
controlled `FormulaWorkbook` still needs to switch `activeSheet`, it returns
|
|
152
|
+
`false` and queues the latest request; mounting that sheet applies the focus and
|
|
153
|
+
reveal automatically.
|
|
154
|
+
|
|
155
|
+
For the range currently being inserted into a formula, use selection-manager's
|
|
156
|
+
reference-picking mode instead. It preserves the primary/editing selection and
|
|
157
|
+
the grid renders the picked range with an independent animated border:
|
|
158
|
+
|
|
159
|
+
```tsx
|
|
160
|
+
<Spreadsheet
|
|
161
|
+
rowCount={1_000}
|
|
162
|
+
columnCount={50}
|
|
163
|
+
selection={{
|
|
164
|
+
effects(manager) {
|
|
165
|
+
const stop = manager.listenToReferenceSelection((event) => {
|
|
166
|
+
if (event.phase === "start" || event.phase === "change") {
|
|
167
|
+
updateFormulaReference(event.range);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
manager.beginReferenceSelection({
|
|
172
|
+
editedRange: {
|
|
173
|
+
start: { row: 1, col: 3 },
|
|
174
|
+
end: {
|
|
175
|
+
row: { type: "number", value: 1 },
|
|
176
|
+
col: { type: "number", value: 3 },
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
return () => {
|
|
181
|
+
stop();
|
|
182
|
+
manager.endReferenceSelection();
|
|
183
|
+
};
|
|
184
|
+
},
|
|
185
|
+
}}
|
|
186
|
+
/>
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Data-aware keyboard navigation
|
|
190
|
+
|
|
191
|
+
`Cmd/Ctrl + Arrow` jumps through populated cells and reveals the destination;
|
|
192
|
+
adding Shift extends the primary selection. Plain `Spreadsheet` derives its
|
|
193
|
+
used range and jump targets from non-empty `cellData`. `FormulaSheet` also
|
|
194
|
+
supplies table bounds from the formula engine, so navigation inside a table
|
|
195
|
+
respects its data body.
|
|
196
|
+
|
|
197
|
+
Override any part of that behavior through `selection.navigation`:
|
|
198
|
+
|
|
199
|
+
```tsx
|
|
200
|
+
<Spreadsheet
|
|
201
|
+
rowCount={100_000}
|
|
202
|
+
columnCount={200}
|
|
203
|
+
selection={{
|
|
204
|
+
navigation: {
|
|
205
|
+
getUsedRange: () => model.usedRange,
|
|
206
|
+
getTableAt: (cell) => model.tableAt(cell),
|
|
207
|
+
resolveTarget: (request) => model.resolveJump(request),
|
|
208
|
+
},
|
|
209
|
+
}}
|
|
210
|
+
/>
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
The imperative `SpreadsheetRef.scrollToCell({ row, col }, { align })` reveals a
|
|
214
|
+
cell without changing selection. Alignment is `"nearest"` by default, with
|
|
215
|
+
`"start"` and `"end"` available for explicit positioning.
|
|
216
|
+
|
|
217
|
+
`SpreadsheetRef.scrollToRange(range, { align })` does the same for an `SMArea`.
|
|
218
|
+
Finite ranges may be supplied in either direction and are clamped to finite grid
|
|
219
|
+
bounds. An open-ended axis reaches the final row or column of a finite grid; on
|
|
220
|
+
an unbounded grid its finite start is used as the reveal anchor.
|
|
140
221
|
|
|
141
222
|
## Theming
|
|
142
223
|
|
|
@@ -227,11 +308,12 @@ Per-cell styling is done in JS:
|
|
|
227
308
|
| --- | --- |
|
|
228
309
|
| `cellData` | `Map<string, SerializedCellValue>` keyed by A1 reference. Omit for uncontrolled mode. |
|
|
229
310
|
| `onCellDataChange` | Called with the next map after an edit, paste or fill. |
|
|
311
|
+
| `rowCount` / `columnCount` | Finite grid dimensions. Omit either dimension for an unbounded axis. |
|
|
230
312
|
| `columnWidths` / `rowHeights` | Controlled sizing, keyed by column letter / 1-based row. |
|
|
231
313
|
| `customCellStyle` | Per-cell `CSSProperties`. |
|
|
232
314
|
| `customCellRenderer` | Per-cell React node. |
|
|
233
315
|
| `parseValue` | Coerce raw editor strings (e.g. text → number) before storing. |
|
|
234
|
-
| `selection` | Selection state,
|
|
316
|
+
| `selection` | Selection state, navigation model, and `effects(selectionManager)` for copy/paste/fill/reference hooks. |
|
|
235
317
|
| `components` + `overlayChildren` | Floating overlays anchored to the grid, optionally snapped to cell edges. |
|
|
236
318
|
|
|
237
319
|
## Development
|