@ricsam/formula-engine 0.0.12 → 0.0.14
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/dist/cjs/core/autofill-utils.cjs +95 -3
- package/dist/cjs/core/autofill-utils.cjs.map +3 -3
- package/dist/cjs/core/engine.cjs +76 -5
- package/dist/cjs/core/engine.cjs.map +3 -3
- package/dist/cjs/core/managers/copy-manager.cjs +291 -10
- package/dist/cjs/core/managers/copy-manager.cjs.map +3 -3
- package/dist/cjs/core/types.cjs.map +1 -1
- package/dist/cjs/package.json +1 -1
- package/dist/mjs/core/autofill-utils.mjs +95 -3
- package/dist/mjs/core/autofill-utils.mjs.map +3 -3
- package/dist/mjs/core/engine.mjs +76 -5
- package/dist/mjs/core/engine.mjs.map +3 -3
- package/dist/mjs/core/managers/copy-manager.mjs +292 -11
- package/dist/mjs/core/managers/copy-manager.mjs.map +3 -3
- package/dist/mjs/core/types.mjs.map +1 -1
- package/dist/mjs/package.json +1 -1
- package/dist/types/core/autofill-utils.d.ts +12 -2
- package/dist/types/core/engine.d.ts +72 -5
- package/dist/types/core/managers/copy-manager.d.ts +39 -2
- package/dist/types/core/types.d.ts +13 -1
- package/package.json +1 -1
|
@@ -152,9 +152,75 @@ export declare class FormulaEngine {
|
|
|
152
152
|
*/
|
|
153
153
|
clearCellStyles(range: RangeAddress): void;
|
|
154
154
|
/**
|
|
155
|
-
*
|
|
155
|
+
* Paste cells from source to target
|
|
156
156
|
*/
|
|
157
|
-
|
|
157
|
+
pasteCells(source: CellAddress[], target: CellAddress, options: CopyCellsOptions): void;
|
|
158
|
+
/**
|
|
159
|
+
* Fill one or more areas with a seed range's content/style
|
|
160
|
+
* Uses column-first strategy: fills down, then replicates right
|
|
161
|
+
* Formulas are adjusted based on each target cell's offset from the seed
|
|
162
|
+
*
|
|
163
|
+
* @param seedRange - The range to use as a template/pattern
|
|
164
|
+
* @param targetRanges - One or more range addresses to fill
|
|
165
|
+
* @param options - Copy options (target: 'all'|'content'|'style', type: 'value'|'formula', cut: boolean)
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* // Fill F6:J10 with A1:B2 seed (2x2 pattern fills 5x5 area)
|
|
169
|
+
* engine.fillAreas(
|
|
170
|
+
* {
|
|
171
|
+
* workbookName,
|
|
172
|
+
* sheetName,
|
|
173
|
+
* range: {
|
|
174
|
+
* start: { col: 0, row: 0 },
|
|
175
|
+
* end: { col: { type: "number", value: 1 }, row: { type: "number", value: 1 } }
|
|
176
|
+
* }
|
|
177
|
+
* },
|
|
178
|
+
* [{
|
|
179
|
+
* workbookName,
|
|
180
|
+
* sheetName,
|
|
181
|
+
* range: {
|
|
182
|
+
* start: { col: 5, row: 5 },
|
|
183
|
+
* end: { col: { type: "number", value: 9 }, row: { type: "number", value: 9 } }
|
|
184
|
+
* }
|
|
185
|
+
* }],
|
|
186
|
+
* { cut: false, type: "formula", target: "all" }
|
|
187
|
+
* );
|
|
188
|
+
*/
|
|
189
|
+
fillAreas(seedRange: RangeAddress, targetRanges: RangeAddress[], options: CopyCellsOptions): void;
|
|
190
|
+
/**
|
|
191
|
+
* Smart paste that automatically determines whether to paste or fill
|
|
192
|
+
* Handles multiple selection areas - each area is independently pasted or filled
|
|
193
|
+
* - If area is larger than source, uses fillAreas() to fill the area
|
|
194
|
+
* - If area is same size or smaller, uses pasteCells() for normal paste
|
|
195
|
+
*
|
|
196
|
+
* @param sourceCells - The copied cells
|
|
197
|
+
* @param pasteSelection - One or more selection areas where user is pasting
|
|
198
|
+
* @param options - Copy options
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* // Copy A1, paste into two areas B1:C2 and E5:F6 - both get filled
|
|
202
|
+
* engine.smartPaste(
|
|
203
|
+
* [{ workbookName, sheetName, colIndex: 0, rowIndex: 0 }],
|
|
204
|
+
* {
|
|
205
|
+
* workbookName,
|
|
206
|
+
* sheetName,
|
|
207
|
+
* areas: [
|
|
208
|
+
* { start: { col: 1, row: 0 }, end: { col: { type: "number", value: 2 }, row: { type: "number", value: 1 } } },
|
|
209
|
+
* { start: { col: 4, row: 4 }, end: { col: { type: "number", value: 5 }, row: { type: "number", value: 5 } } }
|
|
210
|
+
* ]
|
|
211
|
+
* },
|
|
212
|
+
* { cut: false, type: "formula", target: "all" }
|
|
213
|
+
* );
|
|
214
|
+
*/
|
|
215
|
+
smartPaste(sourceCells: CellAddress[], pasteSelection: {
|
|
216
|
+
workbookName: string;
|
|
217
|
+
sheetName: string;
|
|
218
|
+
areas: SpreadsheetRange[];
|
|
219
|
+
}, options: CopyCellsOptions): void;
|
|
220
|
+
/**
|
|
221
|
+
* Get bounds (min/max row/col) from an array of cell addresses
|
|
222
|
+
*/
|
|
223
|
+
private getBoundsFromCells;
|
|
158
224
|
addSheet(opts: {
|
|
159
225
|
workbookName: string;
|
|
160
226
|
sheetName: string;
|
|
@@ -203,7 +269,8 @@ export declare class FormulaEngine {
|
|
|
203
269
|
*/
|
|
204
270
|
reevaluate(): void;
|
|
205
271
|
/**
|
|
206
|
-
* Auto-fills
|
|
272
|
+
* Auto-fills one or more ranges based on the seedRange and the direction.
|
|
273
|
+
* Supports pattern detection and style copying.
|
|
207
274
|
*/
|
|
208
275
|
autoFill(opts: {
|
|
209
276
|
sheetName: string;
|
|
@@ -214,9 +281,9 @@ export declare class FormulaEngine {
|
|
|
214
281
|
*/
|
|
215
282
|
seedRange: SpreadsheetRange,
|
|
216
283
|
/**
|
|
217
|
-
* the new cells populated by the drag, excluding the seed
|
|
284
|
+
* One or more ranges to fill (the new cells populated by the drag, excluding the seed)
|
|
218
285
|
*/
|
|
219
|
-
|
|
286
|
+
fillRanges: SpreadsheetRange[],
|
|
220
287
|
/**
|
|
221
288
|
* The direction of the fill.
|
|
222
289
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* CopyManager - Manages cell copy/paste operations
|
|
3
3
|
*/
|
|
4
|
-
import type { CellAddress, CopyCellsOptions } from "../types";
|
|
4
|
+
import type { CellAddress, CopyCellsOptions, RangeAddress } from "../types";
|
|
5
5
|
import type { WorkbookManager } from "./workbook-manager";
|
|
6
6
|
import type { EvaluationManager } from "./evaluation-manager";
|
|
7
7
|
import type { StyleManager } from "./style-manager";
|
|
@@ -11,7 +11,7 @@ export declare class CopyManager {
|
|
|
11
11
|
private styleManager;
|
|
12
12
|
constructor(workbookManager: WorkbookManager, evaluationManager: EvaluationManager, styleManager: StyleManager);
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* Paste cells from source to target
|
|
15
15
|
*/
|
|
16
16
|
copyCells(source: CellAddress[], target: CellAddress, options: CopyCellsOptions): void;
|
|
17
17
|
/**
|
|
@@ -43,4 +43,41 @@ export declare class CopyManager {
|
|
|
43
43
|
* Clear source cells (for cut operation)
|
|
44
44
|
*/
|
|
45
45
|
private clearSourceCells;
|
|
46
|
+
/**
|
|
47
|
+
* Fill one or more areas with a seed range's content/style
|
|
48
|
+
* Uses column-first strategy: fills down, then replicates right
|
|
49
|
+
* Formulas are adjusted based on each target cell's offset from the seed
|
|
50
|
+
*/
|
|
51
|
+
fillAreas(seedRange: RangeAddress, targetRanges: RangeAddress[], options: CopyCellsOptions): void;
|
|
52
|
+
/**
|
|
53
|
+
* Fill a target range with a seed range using column-first strategy
|
|
54
|
+
* Step 1: Fill down - extend seed pattern vertically to match target height
|
|
55
|
+
* Step 2: Replicate right - copy filled columns horizontally
|
|
56
|
+
*/
|
|
57
|
+
private fillRangeWithSeed;
|
|
58
|
+
/**
|
|
59
|
+
* Get the width of a range (number of columns)
|
|
60
|
+
*/
|
|
61
|
+
private getRangeWidth;
|
|
62
|
+
/**
|
|
63
|
+
* Get the height of a range (number of rows)
|
|
64
|
+
*/
|
|
65
|
+
private getRangeHeight;
|
|
66
|
+
/**
|
|
67
|
+
* Expand a RangeAddress into an array of CellAddress
|
|
68
|
+
* Handles finite ranges, row-bounded, and column-bounded ranges
|
|
69
|
+
*/
|
|
70
|
+
private expandRangeToCells;
|
|
71
|
+
/**
|
|
72
|
+
* Copy cell content with explicit row/column offset for fill operations
|
|
73
|
+
*/
|
|
74
|
+
private copyCellContentWithOffset;
|
|
75
|
+
/**
|
|
76
|
+
* Adjust formula references by a specific row/column offset
|
|
77
|
+
*/
|
|
78
|
+
private adjustFormulaWithOffset;
|
|
79
|
+
/**
|
|
80
|
+
* Copy formatting from one cell to another
|
|
81
|
+
*/
|
|
82
|
+
private copyCellFormatting;
|
|
46
83
|
}
|
|
@@ -318,6 +318,18 @@ export interface CellStyle {
|
|
|
318
318
|
}
|
|
319
319
|
export interface CopyCellsOptions {
|
|
320
320
|
cut: boolean;
|
|
321
|
+
/**
|
|
322
|
+
* all: Copy everything from the source to the target
|
|
323
|
+
* content: Copy only the content from the source to the target
|
|
324
|
+
* style: Copy only the style from the source to the target
|
|
325
|
+
*/
|
|
326
|
+
target: 'all' | 'content' | 'style';
|
|
327
|
+
/**
|
|
328
|
+
* The type of the content to copy
|
|
329
|
+
* value: Copy the value from the source to the target,
|
|
330
|
+
* e.g. if the cell has the formula =123 + 123 then the value is 246
|
|
331
|
+
* formula: Copy the formula from the source to the target,
|
|
332
|
+
* e.g. if the cell has the formula =123 + 123 then the formula is =123 + 123 is copied
|
|
333
|
+
*/
|
|
321
334
|
type: "value" | "formula";
|
|
322
|
-
formatting: boolean;
|
|
323
335
|
}
|