@pixerate/editor 0.22.0 → 0.23.0
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 +80 -2
- package/THIRD_PARTY_NOTICES.md +88 -0
- package/dist/agent/index.cjs +83 -108
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +69 -211
- package/dist/agent/index.d.ts +69 -211
- package/dist/agent/index.js +76 -101
- package/dist/agent/index.js.map +1 -1
- package/dist/arrangeShortcuts-B8O3f8-P.d.cts +184 -0
- package/dist/arrangeShortcuts-sLlD2rSX.d.ts +184 -0
- package/dist/canvas/index.cjs +879 -83
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +291 -186
- package/dist/canvas/index.d.ts +291 -186
- package/dist/canvas/index.js +865 -69
- package/dist/canvas/index.js.map +1 -1
- package/dist/chunk-26BVFKHU.cjs +453 -0
- package/dist/chunk-26BVFKHU.cjs.map +1 -0
- package/dist/chunk-2H7ZHPEJ.js +762 -0
- package/dist/chunk-2H7ZHPEJ.js.map +1 -0
- package/dist/chunk-7DWMJCAT.js +453 -0
- package/dist/chunk-7DWMJCAT.js.map +1 -0
- package/dist/chunk-ARRTP33I.js +101 -0
- package/dist/chunk-ARRTP33I.js.map +1 -0
- package/dist/chunk-CPOKFNBG.cjs +101 -0
- package/dist/chunk-CPOKFNBG.cjs.map +1 -0
- package/dist/chunk-G2I4QJOT.cjs +762 -0
- package/dist/chunk-G2I4QJOT.cjs.map +1 -0
- package/dist/{chunk-RU52I7QO.js → chunk-K3R5NG2D.js} +147 -42
- package/dist/chunk-K3R5NG2D.js.map +1 -0
- package/dist/{chunk-DENSCKFC.js → chunk-QBJ22YZR.js} +423 -30
- package/dist/chunk-QBJ22YZR.js.map +1 -0
- package/dist/{chunk-SAZRENEZ.cjs → chunk-RIKBJLS2.cjs} +424 -31
- package/dist/chunk-RIKBJLS2.cjs.map +1 -0
- package/dist/{chunk-6M3BCTBD.cjs → chunk-XDMXXC4Z.cjs} +230 -125
- package/dist/chunk-XDMXXC4Z.cjs.map +1 -0
- package/dist/commands/index.cjs +860 -0
- package/dist/commands/index.cjs.map +1 -0
- package/dist/commands/index.d.cts +592 -0
- package/dist/commands/index.d.ts +592 -0
- package/dist/commands/index.js +860 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/{controller-B7GIybc4.d.cts → controller-pePCJLT1.d.cts} +78 -5
- package/dist/{controller-B7GIybc4.d.ts → controller-pePCJLT1.d.ts} +78 -5
- package/dist/history/index.cjs +12 -2
- package/dist/history/index.cjs.map +1 -1
- package/dist/history/index.d.cts +211 -7
- package/dist/history/index.d.ts +211 -7
- package/dist/history/index.js +13 -3
- package/dist/image-editor/index.cjs +418 -13
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +154 -3
- package/dist/image-editor/index.d.ts +154 -3
- package/dist/image-editor/index.js +417 -12
- package/dist/image-editor/index.js.map +1 -1
- package/dist/index.cjs +34 -76
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -42
- package/dist/index.d.ts +5 -42
- package/dist/index.js +27 -69
- package/dist/index.js.map +1 -1
- package/dist/registry-D5-R90p0.d.cts +209 -0
- package/dist/registry-D5-R90p0.d.ts +209 -0
- package/dist/spreadsheet/index.cjs +19 -3
- package/dist/spreadsheet/index.cjs.map +1 -1
- package/dist/spreadsheet/index.d.cts +67 -9
- package/dist/spreadsheet/index.d.ts +67 -9
- package/dist/spreadsheet/index.js +18 -2
- package/dist/{types-CJ4U-HHI.d.cts → types-DX4Mh4SL.d.cts} +1 -1
- package/dist/{types-CJ4U-HHI.d.ts → types-DX4Mh4SL.d.ts} +1 -1
- package/dist/types-GT5a5YAX.d.cts +86 -0
- package/dist/types-GT5a5YAX.d.ts +86 -0
- package/package.json +8 -2
- package/dist/chunk-2TWGLC5K.cjs +0 -262
- package/dist/chunk-2TWGLC5K.cjs.map +0 -1
- package/dist/chunk-6M3BCTBD.cjs.map +0 -1
- package/dist/chunk-DENSCKFC.js.map +0 -1
- package/dist/chunk-KAADNAPF.js +0 -262
- package/dist/chunk-KAADNAPF.js.map +0 -1
- package/dist/chunk-RU52I7QO.js.map +0 -1
- package/dist/chunk-SAZRENEZ.cjs.map +0 -1
- package/dist/types-BZgcDsC5.d.cts +0 -42
- package/dist/types-BZgcDsC5.d.ts +0 -42
|
@@ -12,7 +12,13 @@
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
var _chunkRIKBJLS2cjs = require('./chunk-RIKBJLS2.cjs');
|
|
16
22
|
|
|
17
23
|
// src/spreadsheet/formula/dependency-graph.ts
|
|
18
24
|
var columnDependencyKey = (col) => `${col.toUpperCase()}:`;
|
|
@@ -23,22 +29,22 @@ function extractCellDependencies(node) {
|
|
|
23
29
|
deps.push({ col: curr.col, row: curr.row });
|
|
24
30
|
} else if (curr.type === "SpillRef") {
|
|
25
31
|
deps.push({ col: curr.col, row: curr.row });
|
|
26
|
-
} else if (curr.type === "Range" && curr.endRow >=
|
|
27
|
-
const startC =
|
|
28
|
-
const endC =
|
|
32
|
+
} else if (curr.type === "Range" && curr.endRow >= _chunkRIKBJLS2cjs.WHOLE_COLUMN_END_ROW) {
|
|
33
|
+
const startC = _chunkRIKBJLS2cjs.colNameToIndex.call(void 0, curr.startCol);
|
|
34
|
+
const endC = _chunkRIKBJLS2cjs.colNameToIndex.call(void 0, curr.endCol);
|
|
29
35
|
for (let c = Math.min(startC, endC); c <= Math.max(startC, endC); c++) {
|
|
30
|
-
deps.push({ col:
|
|
36
|
+
deps.push({ col: _chunkRIKBJLS2cjs.indexToColName.call(void 0, c), row: 0 });
|
|
31
37
|
}
|
|
32
38
|
} else if (curr.type === "Range") {
|
|
33
|
-
const startC =
|
|
34
|
-
const endC =
|
|
39
|
+
const startC = _chunkRIKBJLS2cjs.colNameToIndex.call(void 0, curr.startCol);
|
|
40
|
+
const endC = _chunkRIKBJLS2cjs.colNameToIndex.call(void 0, curr.endCol);
|
|
35
41
|
const minC = Math.min(startC, endC);
|
|
36
42
|
const maxC = Math.max(startC, endC);
|
|
37
43
|
const minR = Math.min(curr.startRow, curr.endRow);
|
|
38
44
|
const maxR = Math.max(curr.startRow, curr.endRow);
|
|
39
45
|
for (let c = minC; c <= maxC; c++) {
|
|
40
46
|
for (let r = minR; r <= maxR; r++) {
|
|
41
|
-
deps.push({ col:
|
|
47
|
+
deps.push({ col: _chunkRIKBJLS2cjs.indexToColName.call(void 0, c), row: r });
|
|
42
48
|
}
|
|
43
49
|
}
|
|
44
50
|
} else if (curr.type === "BinaryOp") {
|
|
@@ -77,7 +83,7 @@ var DependencyGraph = (_class = class {constructor() { _class.prototype.__init.c
|
|
|
77
83
|
return;
|
|
78
84
|
}
|
|
79
85
|
try {
|
|
80
|
-
const ast =
|
|
86
|
+
const ast = _chunkRIKBJLS2cjs.parseFormula.call(void 0, formulaStr);
|
|
81
87
|
const deps = extractCellDependencies(ast);
|
|
82
88
|
const newDeps = /* @__PURE__ */ new Set();
|
|
83
89
|
for (const d of deps) {
|
|
@@ -323,19 +329,19 @@ function parsePart(text) {
|
|
|
323
329
|
if (cell) {
|
|
324
330
|
return {
|
|
325
331
|
colAbs: cell[1],
|
|
326
|
-
col:
|
|
332
|
+
col: _chunkRIKBJLS2cjs.colNameToIndex.call(void 0, cell[2]),
|
|
327
333
|
rowAbs: cell[3],
|
|
328
334
|
row: parseInt(cell[4], 10) - 1
|
|
329
335
|
};
|
|
330
336
|
}
|
|
331
337
|
const column = COLUMN_PART.exec(text);
|
|
332
338
|
if (column) {
|
|
333
|
-
return { colAbs: column[1], col:
|
|
339
|
+
return { colAbs: column[1], col: _chunkRIKBJLS2cjs.colNameToIndex.call(void 0, column[2]), rowAbs: "", row: null };
|
|
334
340
|
}
|
|
335
341
|
return null;
|
|
336
342
|
}
|
|
337
343
|
function formatPart(part) {
|
|
338
|
-
const col = `${part.colAbs}${
|
|
344
|
+
const col = `${part.colAbs}${_chunkRIKBJLS2cjs.indexToColName.call(void 0, part.col)}`;
|
|
339
345
|
return part.row === null ? col : `${col}${part.rowAbs}${part.row + 1}`;
|
|
340
346
|
}
|
|
341
347
|
function shiftCoordinate(value, change) {
|
|
@@ -382,7 +388,7 @@ function mapFormulaReferences(formula, rewrite) {
|
|
|
382
388
|
if (!formula.startsWith("=")) return formula;
|
|
383
389
|
let tokens;
|
|
384
390
|
try {
|
|
385
|
-
tokens =
|
|
391
|
+
tokens = _chunkRIKBJLS2cjs.tokenizeFormula.call(void 0, formula);
|
|
386
392
|
} catch (e2) {
|
|
387
393
|
return formula;
|
|
388
394
|
}
|
|
@@ -520,7 +526,7 @@ function innermostCall(stack) {
|
|
|
520
526
|
}
|
|
521
527
|
var toSuggestion = (def) => ({
|
|
522
528
|
name: def.name,
|
|
523
|
-
signature:
|
|
529
|
+
signature: _chunkRIKBJLS2cjs.getFormulaSignature.call(void 0, def),
|
|
524
530
|
description: def.description,
|
|
525
531
|
category: def.category
|
|
526
532
|
});
|
|
@@ -529,20 +535,20 @@ function getFormulaHints(input, caret = input.length, options = {}) {
|
|
|
529
535
|
let suggestions = [];
|
|
530
536
|
if (context.prefix) {
|
|
531
537
|
const query = context.prefix.text.toUpperCase();
|
|
532
|
-
suggestions =
|
|
538
|
+
suggestions = _chunkRIKBJLS2cjs.searchFormulaFunctions.call(void 0, query, { limit: void 0 }).filter((def) => def.name.startsWith(query)).slice(0, _nullishCoalesce(options.limit, () => ( 8))).map(toSuggestion);
|
|
533
539
|
const followedByParen = input.slice(context.prefix.end).trimStart().startsWith("(");
|
|
534
540
|
if (followedByParen || suggestions.length === 1 && suggestions[0].name === query) suggestions = [];
|
|
535
541
|
}
|
|
536
542
|
let activeCall = null;
|
|
537
543
|
if (context.call) {
|
|
538
|
-
const def =
|
|
544
|
+
const def = _chunkRIKBJLS2cjs.getFormulaFunction.call(void 0, context.call.name);
|
|
539
545
|
if (def) {
|
|
540
|
-
const specIndex =
|
|
546
|
+
const specIndex = _chunkRIKBJLS2cjs.getFormulaArgumentSpecIndex.call(void 0, def, context.call.argIndex);
|
|
541
547
|
activeCall = {
|
|
542
548
|
name: def.name,
|
|
543
|
-
signature:
|
|
549
|
+
signature: _chunkRIKBJLS2cjs.getFormulaSignature.call(void 0, def),
|
|
544
550
|
description: def.description,
|
|
545
|
-
parts:
|
|
551
|
+
parts: _chunkRIKBJLS2cjs.getFormulaSignatureParts.call(void 0, def, context.call.argIndex),
|
|
546
552
|
argIndex: context.call.argIndex,
|
|
547
553
|
argument: specIndex >= 0 ? def.args[specIndex] : null
|
|
548
554
|
};
|
|
@@ -678,28 +684,41 @@ function compareCellValues(a, b, direction = "asc") {
|
|
|
678
684
|
const aBlank = isBlankValue(a);
|
|
679
685
|
const bBlank = isBlankValue(b);
|
|
680
686
|
if (aBlank || bBlank) return aBlank === bBlank ? 0 : aBlank ? 1 : -1;
|
|
681
|
-
const aNum = toNumber(a);
|
|
682
|
-
const bNum = toNumber(b);
|
|
683
687
|
let result;
|
|
684
|
-
if (
|
|
685
|
-
|
|
686
|
-
else
|
|
687
|
-
|
|
688
|
+
if (isPlainText(a) && isPlainText(b) && !(_chunkRIKBJLS2cjs.parseIsoDate.call(void 0, a) && _chunkRIKBJLS2cjs.parseIsoDate.call(void 0, b))) {
|
|
689
|
+
result = compareText(a, b);
|
|
690
|
+
} else {
|
|
691
|
+
result = _chunkRIKBJLS2cjs.sortCompareValues.call(void 0, a, b);
|
|
692
|
+
}
|
|
688
693
|
if (result === 0) return 0;
|
|
689
694
|
return direction === "desc" ? -Math.sign(result) : Math.sign(result);
|
|
690
695
|
}
|
|
696
|
+
var isPlainText = (value) => typeof value === "string" && !_chunkRIKBJLS2cjs.isFormulaError.call(void 0, value);
|
|
697
|
+
function filterValue(value) {
|
|
698
|
+
if (isBlankValue(value) || _chunkRIKBJLS2cjs.isFormulaError.call(void 0, value)) return null;
|
|
699
|
+
if (typeof value === "number") return Number.isFinite(value) ? { value, kind: "number" } : null;
|
|
700
|
+
if (typeof value === "boolean") return { value, kind: "boolean" };
|
|
701
|
+
const num = _chunkRIKBJLS2cjs.numericValue.call(void 0, value);
|
|
702
|
+
if (num !== null) return { value: num, kind: "number" };
|
|
703
|
+
const text = String(value);
|
|
704
|
+
return { value: text, kind: _chunkRIKBJLS2cjs.parseIsoDate.call(void 0, text) ? "number" : "text" };
|
|
705
|
+
}
|
|
706
|
+
function filterOperand(operand) {
|
|
707
|
+
if (typeof operand !== "string") return filterValue(operand);
|
|
708
|
+
if (operand.trim() === "") return null;
|
|
709
|
+
const parsed = _chunkRIKBJLS2cjs.parseCellInput.call(void 0, operand.trim());
|
|
710
|
+
if (parsed.type === "number" || parsed.type === "date" || parsed.type === "boolean") return filterValue(parsed.value);
|
|
711
|
+
return { value: operand, kind: "text" };
|
|
712
|
+
}
|
|
691
713
|
function compareForFilter(value, operand) {
|
|
692
|
-
|
|
693
|
-
const
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
if (a !== null || b !== null) return null;
|
|
697
|
-
return compareText(String(value), String(operand));
|
|
714
|
+
const a = filterValue(value);
|
|
715
|
+
const b = filterOperand(operand);
|
|
716
|
+
if (!a || !b || a.kind !== b.kind) return null;
|
|
717
|
+
return _chunkRIKBJLS2cjs.compareValues.call(void 0, a.value, b.value);
|
|
698
718
|
}
|
|
699
719
|
function looselyEquals(value, operand) {
|
|
700
|
-
const
|
|
701
|
-
|
|
702
|
-
if (a !== null && b !== null) return a === b;
|
|
720
|
+
const c = compareForFilter(value, operand);
|
|
721
|
+
if (c !== null) return c === 0;
|
|
703
722
|
return String(_nullishCoalesce(value, () => ( ""))).trim().toLowerCase() === String(_nullishCoalesce(operand, () => ( ""))).trim().toLowerCase();
|
|
704
723
|
}
|
|
705
724
|
function matchesFilterRule(value, rule) {
|
|
@@ -774,7 +793,8 @@ function classifyFillValue(raw) {
|
|
|
774
793
|
if (raw.trim() === "") return { kind: "blank" };
|
|
775
794
|
const num = toNumber(raw);
|
|
776
795
|
if (num !== null) return { kind: "number", value: num };
|
|
777
|
-
const
|
|
796
|
+
const typed = _chunkRIKBJLS2cjs.parseCellInput.call(void 0, raw);
|
|
797
|
+
const date = ISO_DATE_PATTERN.exec(typed.type === "date" ? String(typed.value) : raw.trim());
|
|
778
798
|
if (date) {
|
|
779
799
|
const [year, month, day] = [Number(date[1]), Number(date[2]), Number(date[3])];
|
|
780
800
|
const time = Date.UTC(year, month - 1, day);
|
|
@@ -1071,11 +1091,16 @@ function parseHtmlTable(html) {
|
|
|
1071
1091
|
return rows.length > 0 ? rows : null;
|
|
1072
1092
|
}
|
|
1073
1093
|
function createSpreadsheetClipboardData(cells, origin) {
|
|
1074
|
-
const
|
|
1075
|
-
const payload = {
|
|
1094
|
+
const texts = cells.map((row) => row.map((cell) => _nullishCoalesce(cell.text, () => ( displayText(cell.value)))));
|
|
1095
|
+
const payload = {
|
|
1096
|
+
type: "pixerate-spreadsheet",
|
|
1097
|
+
version: 1,
|
|
1098
|
+
origin,
|
|
1099
|
+
cells: cells.map((row) => row.map(({ raw, value }) => ({ raw, value })))
|
|
1100
|
+
};
|
|
1076
1101
|
return {
|
|
1077
|
-
"text/plain": serializeTsv(
|
|
1078
|
-
"text/html": serializeHtmlTable(
|
|
1102
|
+
"text/plain": serializeTsv(texts),
|
|
1103
|
+
"text/html": serializeHtmlTable(texts),
|
|
1079
1104
|
[SPREADSHEET_CLIPBOARD_MIME]: JSON.stringify(payload)
|
|
1080
1105
|
};
|
|
1081
1106
|
}
|
|
@@ -1289,6 +1314,7 @@ function buildSpreadsheetView(doc, getValue) {
|
|
|
1289
1314
|
|
|
1290
1315
|
// src/spreadsheet/controller.ts
|
|
1291
1316
|
var nextIdSequence = 0;
|
|
1317
|
+
var DEFAULT_MAX_HISTORY_BYTES = 64 * 1024 * 1024;
|
|
1292
1318
|
var MAX_SPILL_PASSES = 25;
|
|
1293
1319
|
var spillCellId = (rowId, colId) => `${rowId}\0${colId}`;
|
|
1294
1320
|
var SpreadsheetController = (_class3 = class {
|
|
@@ -1308,6 +1334,7 @@ var SpreadsheetController = (_class3 = class {
|
|
|
1308
1334
|
__init13() {this.undoStack = []}
|
|
1309
1335
|
__init14() {this.redoStack = []}
|
|
1310
1336
|
__init15() {this.isApplyingHistory = false}
|
|
1337
|
+
|
|
1311
1338
|
// Set while importing TSV: history and recalculation are done once at the end.
|
|
1312
1339
|
__init16() {this.batching = false}
|
|
1313
1340
|
__init17() {this.pendingCommits = []}
|
|
@@ -1349,13 +1376,14 @@ var SpreadsheetController = (_class3 = class {
|
|
|
1349
1376
|
..._optionalChain([options, 'access', _72 => _72.document, 'optionalAccess', _73 => _73.table]) ? { table: options.document.table } : {}
|
|
1350
1377
|
};
|
|
1351
1378
|
this.primaryDataSourceId = options.primaryDataSourceId;
|
|
1379
|
+
this.maxHistoryBytes = Math.max(0, _nullishCoalesce(options.maxHistoryBytes, () => ( DEFAULT_MAX_HISTORY_BYTES)));
|
|
1352
1380
|
this.onDocumentChange = options.onDocumentChange;
|
|
1353
1381
|
this.onSelectionChange = options.onSelectionChange;
|
|
1354
1382
|
this.onCellCommit = options.onCellCommit;
|
|
1355
1383
|
if (options.dataSources) {
|
|
1356
1384
|
options.dataSources.forEach((ds) => this.binder.register(ds));
|
|
1357
1385
|
}
|
|
1358
|
-
this.evaluator = new (0,
|
|
1386
|
+
this.evaluator = new (0, _chunkRIKBJLS2cjs.FormulaEvaluator)({
|
|
1359
1387
|
resolveCell: (colStr, rowNum) => this.resolveCellByCoord(colStr, rowNum),
|
|
1360
1388
|
resolveRange: (sCol, sRow, eCol, eRow) => this.resolveRangeByCoords(sCol, sRow, eCol, eRow),
|
|
1361
1389
|
resolveProperty: (prop) => this.resolveCurrentRowProperty(prop),
|
|
@@ -1363,6 +1391,7 @@ var SpreadsheetController = (_class3 = class {
|
|
|
1363
1391
|
getFormulaCell: () => this.evaluatingCell
|
|
1364
1392
|
});
|
|
1365
1393
|
this.syncWithDataSource();
|
|
1394
|
+
this.rederiveTypedValues();
|
|
1366
1395
|
this.recalculateAll();
|
|
1367
1396
|
}
|
|
1368
1397
|
loadDocument(document) {
|
|
@@ -1374,9 +1403,63 @@ var SpreadsheetController = (_class3 = class {
|
|
|
1374
1403
|
this.undoStack = [];
|
|
1375
1404
|
this.redoStack = [];
|
|
1376
1405
|
this.syncWithDataSource();
|
|
1406
|
+
this.rederiveTypedValues();
|
|
1377
1407
|
this.recalculateAll();
|
|
1378
1408
|
this.notifyChange();
|
|
1379
1409
|
}
|
|
1410
|
+
/**
|
|
1411
|
+
* Re-parses the value of every stored typed (non-formula) cell from its
|
|
1412
|
+
* `raw` input, so documents saved before typed input was parsed (whose
|
|
1413
|
+
* values are text such as `"120"`) compare and sort as numbers. Cells of
|
|
1414
|
+
* bound columns in record rows keep their value: it belongs to the data
|
|
1415
|
+
* source.
|
|
1416
|
+
*/
|
|
1417
|
+
rederiveTypedValues() {
|
|
1418
|
+
for (const row of this.document.rows) {
|
|
1419
|
+
const cells = this.document.cells[row.id];
|
|
1420
|
+
if (!cells) continue;
|
|
1421
|
+
for (const col of this.document.columns) {
|
|
1422
|
+
const cell = cells[col.id];
|
|
1423
|
+
if (!cell || typeof cell.raw !== "string" || cell.raw.startsWith("=")) continue;
|
|
1424
|
+
if (col.type === "bound" && col.binding && row.recordId) continue;
|
|
1425
|
+
const typed = this.typedCell(cell.raw, cell.format);
|
|
1426
|
+
cell.value = typed.value;
|
|
1427
|
+
if (typed.numberFormat) cell.numberFormat = typed.numberFormat;
|
|
1428
|
+
else delete cell.numberFormat;
|
|
1429
|
+
if (typed.format) cell.format = typed.format;
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
/**
|
|
1434
|
+
* Value of typed (non-formula) input: a number, boolean, ISO date, error
|
|
1435
|
+
* or text (see `parseCellInput`), its automatic number format, and the
|
|
1436
|
+
* `CellFormat` to use: the automatic one (currency, percentage, date,
|
|
1437
|
+
* number) when `format` is unset or `text` (the default of new columns).
|
|
1438
|
+
*/
|
|
1439
|
+
typedCell(raw, format) {
|
|
1440
|
+
const parsed = _chunkRIKBJLS2cjs.parseCellInput.call(void 0, raw);
|
|
1441
|
+
return {
|
|
1442
|
+
value: parsed.value,
|
|
1443
|
+
...parsed.numberFormat ? { numberFormat: parsed.numberFormat } : {},
|
|
1444
|
+
format: parsed.cellFormat && (!format || format === "text") ? parsed.cellFormat : format
|
|
1445
|
+
};
|
|
1446
|
+
}
|
|
1447
|
+
/**
|
|
1448
|
+
* Typed input for a bound field, coerced by the field's declared type:
|
|
1449
|
+
* number, boolean and date fields get a number, boolean or ISO date when
|
|
1450
|
+
* the input parses as one; string and enum fields (and unknown fields)
|
|
1451
|
+
* keep the text exactly as typed.
|
|
1452
|
+
*/
|
|
1453
|
+
boundInputValue(dataSourceId, field, raw) {
|
|
1454
|
+
if (raw.startsWith("=")) return raw;
|
|
1455
|
+
const type = _optionalChain([this, 'access', _74 => _74.binder, 'access', _75 => _75.getDataSource, 'call', _76 => _76(dataSourceId), 'optionalAccess', _77 => _77.getFields, 'call', _78 => _78(), 'access', _79 => _79.find, 'call', _80 => _80((f) => f.key === field), 'optionalAccess', _81 => _81.type]);
|
|
1456
|
+
if (type !== "number" && type !== "boolean" && type !== "date") return raw;
|
|
1457
|
+
const parsed = _chunkRIKBJLS2cjs.parseCellInput.call(void 0, raw);
|
|
1458
|
+
if (type === "number" && parsed.type === "number") return parsed.value;
|
|
1459
|
+
if (type === "boolean" && parsed.type === "boolean") return parsed.value;
|
|
1460
|
+
if (type === "date" && parsed.type === "date") return parsed.value;
|
|
1461
|
+
return raw;
|
|
1462
|
+
}
|
|
1380
1463
|
registerDataSource(ds) {
|
|
1381
1464
|
this.binder.register(ds);
|
|
1382
1465
|
this.syncWithDataSource();
|
|
@@ -1397,7 +1480,7 @@ var SpreadsheetController = (_class3 = class {
|
|
|
1397
1480
|
r.index = idx;
|
|
1398
1481
|
});
|
|
1399
1482
|
this.document.columns.forEach((c, idx) => {
|
|
1400
|
-
c.key =
|
|
1483
|
+
c.key = _chunkRIKBJLS2cjs.indexToColName.call(void 0, idx);
|
|
1401
1484
|
});
|
|
1402
1485
|
}
|
|
1403
1486
|
getColumn(colIdOrKey) {
|
|
@@ -1412,7 +1495,7 @@ var SpreadsheetController = (_class3 = class {
|
|
|
1412
1495
|
return this.document.rows.find((r) => r.id === rowIdOrIndex);
|
|
1413
1496
|
}
|
|
1414
1497
|
getCell(rowId, colId) {
|
|
1415
|
-
const existing = _optionalChain([this, 'access',
|
|
1498
|
+
const existing = _optionalChain([this, 'access', _82 => _82.document, 'access', _83 => _83.cells, 'access', _84 => _84[rowId], 'optionalAccess', _85 => _85[colId]]);
|
|
1416
1499
|
if (existing && existing.raw !== "") return existing;
|
|
1417
1500
|
if (this.spillCells.size > 0) {
|
|
1418
1501
|
const spilled = this.spillCells.get(spillCellId(rowId, colId));
|
|
@@ -1444,7 +1527,7 @@ var SpreadsheetController = (_class3 = class {
|
|
|
1444
1527
|
format: col.format
|
|
1445
1528
|
};
|
|
1446
1529
|
}
|
|
1447
|
-
return { raw: "", value: "", format: _optionalChain([col, 'optionalAccess',
|
|
1530
|
+
return { raw: "", value: "", format: _optionalChain([col, 'optionalAccess', _86 => _86.format]) };
|
|
1448
1531
|
}
|
|
1449
1532
|
setCellValue(rowId, colId, raw) {
|
|
1450
1533
|
this.recordSnapshot();
|
|
@@ -1453,21 +1536,20 @@ var SpreadsheetController = (_class3 = class {
|
|
|
1453
1536
|
}
|
|
1454
1537
|
const col = this.document.columns.find((c) => c.id === colId);
|
|
1455
1538
|
const row = this.document.rows.find((r) => r.id === rowId);
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1539
|
+
const isFormula = raw.startsWith("=");
|
|
1540
|
+
let cell;
|
|
1541
|
+
if (_optionalChain([col, 'optionalAccess', _87 => _87.type]) === "bound" && col.binding && _optionalChain([row, 'optionalAccess', _88 => _88.recordId])) {
|
|
1542
|
+
const value = this.boundInputValue(col.binding.dataSource, col.binding.field, raw);
|
|
1543
|
+
this.binder.commitBoundValue(col.binding.dataSource, row.recordId, col.binding.field, value);
|
|
1544
|
+
cell = { raw, value, format: col.format };
|
|
1545
|
+
} else if (isFormula) {
|
|
1546
|
+
cell = { raw, value: raw, format: _optionalChain([col, 'optionalAccess', _89 => _89.format]) };
|
|
1547
|
+
} else {
|
|
1548
|
+
cell = { raw, ...this.typedCell(raw, _optionalChain([col, 'optionalAccess', _90 => _90.format])) };
|
|
1463
1549
|
}
|
|
1464
1550
|
const cellKey = this.getCellKey(rowId, colId);
|
|
1465
|
-
this.depGraph.setCellFormula(cellKey,
|
|
1466
|
-
this.document.cells[rowId][colId] =
|
|
1467
|
-
raw,
|
|
1468
|
-
value: raw,
|
|
1469
|
-
format: _optionalChain([col, 'optionalAccess', _81 => _81.format])
|
|
1470
|
-
};
|
|
1551
|
+
this.depGraph.setCellFormula(cellKey, isFormula ? raw : null);
|
|
1552
|
+
this.document.cells[rowId][colId] = cell;
|
|
1471
1553
|
this.document.updatedAt = Date.now();
|
|
1472
1554
|
if (this.batching) {
|
|
1473
1555
|
this.pendingCommits.push([rowId, colId, raw]);
|
|
@@ -1475,8 +1557,8 @@ var SpreadsheetController = (_class3 = class {
|
|
|
1475
1557
|
}
|
|
1476
1558
|
this.recalculateCell(rowId, colId);
|
|
1477
1559
|
this.notifyChange();
|
|
1478
|
-
const evaluatedVal = _optionalChain([this, 'access',
|
|
1479
|
-
_optionalChain([this, 'access',
|
|
1560
|
+
const evaluatedVal = _optionalChain([this, 'access', _91 => _91.document, 'access', _92 => _92.cells, 'access', _93 => _93[rowId], 'access', _94 => _94[colId], 'optionalAccess', _95 => _95.value]);
|
|
1561
|
+
_optionalChain([this, 'access', _96 => _96.onCellCommit, 'optionalCall', _97 => _97(rowId, colId, raw, evaluatedVal)]);
|
|
1480
1562
|
}
|
|
1481
1563
|
getCellKey(rowId, colId) {
|
|
1482
1564
|
const row = this.document.rows.find((r) => r.id === rowId);
|
|
@@ -1527,7 +1609,7 @@ var SpreadsheetController = (_class3 = class {
|
|
|
1527
1609
|
const formulaKeys = [];
|
|
1528
1610
|
for (const row of this.document.rows) {
|
|
1529
1611
|
for (const col of this.document.columns) {
|
|
1530
|
-
const cell = _nullishCoalesce(_optionalChain([this, 'access',
|
|
1612
|
+
const cell = _nullishCoalesce(_optionalChain([this, 'access', _98 => _98.document, 'access', _99 => _99.cells, 'access', _100 => _100[row.id], 'optionalAccess', _101 => _101[col.id]]), () => ( this.getDerivedCell(row, col)));
|
|
1531
1613
|
if (cell.raw.startsWith("=")) {
|
|
1532
1614
|
const cellKey = `${col.key}${row.index + 1}`.toUpperCase();
|
|
1533
1615
|
this.depGraph.setCellFormula(cellKey, cell.raw);
|
|
@@ -1625,7 +1707,7 @@ var SpreadsheetController = (_class3 = class {
|
|
|
1625
1707
|
placeSpill(anchor, row, col, array) {
|
|
1626
1708
|
const { rows, cols } = array;
|
|
1627
1709
|
const area = { startRow: row, startCol: col, endRow: row + rows - 1, endCol: col + cols - 1 };
|
|
1628
|
-
const label = `${
|
|
1710
|
+
const label = `${_chunkRIKBJLS2cjs.indexToColName.call(void 0, area.startCol)}${area.startRow + 1}:${_chunkRIKBJLS2cjs.indexToColName.call(void 0, area.endCol)}${area.endRow + 1}`;
|
|
1629
1711
|
let reason = null;
|
|
1630
1712
|
const blockers = [];
|
|
1631
1713
|
if (area.endRow >= this.document.rows.length || area.endCol >= this.document.columns.length) {
|
|
@@ -1639,7 +1721,7 @@ var SpreadsheetController = (_class3 = class {
|
|
|
1639
1721
|
if (r === row && c === col) continue;
|
|
1640
1722
|
const rowObj = this.document.rows[r];
|
|
1641
1723
|
const key = `${column.key}${r + 1}`.toUpperCase();
|
|
1642
|
-
const stored = _optionalChain([this, 'access',
|
|
1724
|
+
const stored = _optionalChain([this, 'access', _102 => _102.document, 'access', _103 => _103.cells, 'access', _104 => _104[rowObj.id], 'optionalAccess', _105 => _105[column.id]]);
|
|
1643
1725
|
const raw = stored ? stored.raw : this.getDerivedCell(rowObj, column).raw;
|
|
1644
1726
|
const owner = this.spilledBy.get(key);
|
|
1645
1727
|
if (raw !== "") {
|
|
@@ -1667,14 +1749,14 @@ var SpreadsheetController = (_class3 = class {
|
|
|
1667
1749
|
const key = `${column.key}${row + r + 1}`.toUpperCase();
|
|
1668
1750
|
const value = _nullishCoalesce(array.values[c * rows + r], () => ( ""));
|
|
1669
1751
|
const display = { raw: "", value, format: column.format, spillAnchor: anchor };
|
|
1670
|
-
if (
|
|
1752
|
+
if (_chunkRIKBJLS2cjs.isFormulaError.call(void 0, value)) {
|
|
1671
1753
|
display.error = value;
|
|
1672
|
-
display.errorMessage =
|
|
1754
|
+
display.errorMessage = _chunkRIKBJLS2cjs.describeFormulaError.call(void 0, value);
|
|
1673
1755
|
}
|
|
1674
1756
|
this.spillCells.set(spillCellId(rowObj.id, column.id), display);
|
|
1675
1757
|
if (this.spilledBy.get(key) !== anchor) {
|
|
1676
1758
|
this.spilledBy.set(key, anchor);
|
|
1677
|
-
_optionalChain([this, 'access',
|
|
1759
|
+
_optionalChain([this, 'access', _106 => _106.spillChanges, 'optionalAccess', _107 => _107.add, 'call', _108 => _108(key)]);
|
|
1678
1760
|
}
|
|
1679
1761
|
cells.push({ key, rowId: rowObj.id, colId: column.id });
|
|
1680
1762
|
}
|
|
@@ -1703,13 +1785,13 @@ var SpreadsheetController = (_class3 = class {
|
|
|
1703
1785
|
if (this.spilledBy.get(cell.key) !== anchor) return;
|
|
1704
1786
|
this.spilledBy.delete(cell.key);
|
|
1705
1787
|
this.spillCells.delete(spillCellId(cell.rowId, cell.colId));
|
|
1706
|
-
_optionalChain([this, 'access',
|
|
1788
|
+
_optionalChain([this, 'access', _109 => _109.spillChanges, 'optionalAccess', _110 => _110.add, 'call', _111 => _111(cell.key)]);
|
|
1707
1789
|
}
|
|
1708
1790
|
resolveSpillByCoord(colStr, rowNum) {
|
|
1709
1791
|
const record = this.spills.get(`${colStr}${rowNum}`.toUpperCase());
|
|
1710
1792
|
if (record) return { rows: record.rows, cols: record.cols, values: record.values };
|
|
1711
1793
|
const value = this.resolveCellByCoord(colStr, rowNum);
|
|
1712
|
-
return
|
|
1794
|
+
return _chunkRIKBJLS2cjs.isFormulaError.call(void 0, value) ? value : "#REF!";
|
|
1713
1795
|
}
|
|
1714
1796
|
toSpill(record) {
|
|
1715
1797
|
const row = this.document.rows[record.row];
|
|
@@ -1732,7 +1814,7 @@ var SpreadsheetController = (_class3 = class {
|
|
|
1732
1814
|
*/
|
|
1733
1815
|
getSpillAt(row, col) {
|
|
1734
1816
|
if (this.spills.size === 0) return null;
|
|
1735
|
-
const key = `${
|
|
1817
|
+
const key = `${_chunkRIKBJLS2cjs.indexToColName.call(void 0, col)}${row + 1}`;
|
|
1736
1818
|
const record = _nullishCoalesce(this.spills.get(key), () => ( this.spills.get(_nullishCoalesce(this.spilledBy.get(key), () => ( "")))));
|
|
1737
1819
|
return record ? this.toSpill(record) : null;
|
|
1738
1820
|
}
|
|
@@ -1760,15 +1842,15 @@ var SpreadsheetController = (_class3 = class {
|
|
|
1760
1842
|
return _nullishCoalesce(this.getCell(row.id, col.id).value, () => ( ""));
|
|
1761
1843
|
}
|
|
1762
1844
|
resolveRangeByCoords(sCol, sRow, eCol, eRow) {
|
|
1763
|
-
const startC =
|
|
1764
|
-
const endC =
|
|
1845
|
+
const startC = _chunkRIKBJLS2cjs.colNameToIndex.call(void 0, sCol);
|
|
1846
|
+
const endC = _chunkRIKBJLS2cjs.colNameToIndex.call(void 0, eCol);
|
|
1765
1847
|
const minC = Math.min(startC, endC);
|
|
1766
1848
|
const maxC = Math.max(startC, endC);
|
|
1767
1849
|
const minR = Math.min(sRow, eRow);
|
|
1768
|
-
const maxR = Math.min(Math.max(sRow, eRow),
|
|
1850
|
+
const maxR = Math.min(Math.max(sRow, eRow), _chunkRIKBJLS2cjs.WHOLE_COLUMN_END_ROW, this.document.rows.length);
|
|
1769
1851
|
const results = [];
|
|
1770
1852
|
for (let c = minC; c <= maxC; c++) {
|
|
1771
|
-
const colName =
|
|
1853
|
+
const colName = _chunkRIKBJLS2cjs.indexToColName.call(void 0, c);
|
|
1772
1854
|
const col = this.document.columns.find((colDef) => colDef.key.toUpperCase() === colName);
|
|
1773
1855
|
if (!col) continue;
|
|
1774
1856
|
for (let r = minR; r <= maxR; r++) {
|
|
@@ -1780,7 +1862,7 @@ var SpreadsheetController = (_class3 = class {
|
|
|
1780
1862
|
return results;
|
|
1781
1863
|
}
|
|
1782
1864
|
resolveCurrentRowProperty(prop) {
|
|
1783
|
-
const rowIndex = _nullishCoalesce(this.evaluatingRowIndex, () => ( _optionalChain([this, 'access',
|
|
1865
|
+
const rowIndex = _nullishCoalesce(this.evaluatingRowIndex, () => ( _optionalChain([this, 'access', _112 => _112.activeCell, 'optionalAccess', _113 => _113.row])));
|
|
1784
1866
|
if (rowIndex === void 0 || rowIndex === null) return 0;
|
|
1785
1867
|
const row = this.document.rows[rowIndex];
|
|
1786
1868
|
if (!row || !row.recordId || !this.primaryDataSourceId) return 0;
|
|
@@ -1798,8 +1880,8 @@ var SpreadsheetController = (_class3 = class {
|
|
|
1798
1880
|
this.activeCell = {
|
|
1799
1881
|
row: activeRow,
|
|
1800
1882
|
col: activeCol,
|
|
1801
|
-
rowId: _optionalChain([rowObj, 'optionalAccess',
|
|
1802
|
-
colId: _optionalChain([colObj, 'optionalAccess',
|
|
1883
|
+
rowId: _optionalChain([rowObj, 'optionalAccess', _114 => _114.id]),
|
|
1884
|
+
colId: _optionalChain([colObj, 'optionalAccess', _115 => _115.id])
|
|
1803
1885
|
};
|
|
1804
1886
|
if (extendSelection && this.selectedRange) {
|
|
1805
1887
|
this.selectedRange = this.expandRangeToMerges({
|
|
@@ -1818,16 +1900,16 @@ var SpreadsheetController = (_class3 = class {
|
|
|
1818
1900
|
endCol: clampedCol
|
|
1819
1901
|
};
|
|
1820
1902
|
}
|
|
1821
|
-
_optionalChain([this, 'access',
|
|
1903
|
+
_optionalChain([this, 'access', _116 => _116.onSelectionChange, 'optionalCall', _117 => _117(this.activeCell, this.selectedRange)]);
|
|
1822
1904
|
}
|
|
1823
1905
|
selectRange(range) {
|
|
1824
1906
|
this.selectedRange = range;
|
|
1825
|
-
_optionalChain([this, 'access',
|
|
1907
|
+
_optionalChain([this, 'access', _118 => _118.onSelectionChange, 'optionalCall', _119 => _119(this.activeCell, this.selectedRange)]);
|
|
1826
1908
|
}
|
|
1827
1909
|
startEditing(row, col, initialValue) {
|
|
1828
|
-
this.selectCell(_nullishCoalesce(_nullishCoalesce(row, () => ( _optionalChain([this, 'access',
|
|
1829
|
-
const targetRow = _nullishCoalesce(_optionalChain([this, 'access',
|
|
1830
|
-
const targetCol = _nullishCoalesce(_optionalChain([this, 'access',
|
|
1910
|
+
this.selectCell(_nullishCoalesce(_nullishCoalesce(row, () => ( _optionalChain([this, 'access', _120 => _120.activeCell, 'optionalAccess', _121 => _121.row]))), () => ( 0)), _nullishCoalesce(_nullishCoalesce(col, () => ( _optionalChain([this, 'access', _122 => _122.activeCell, 'optionalAccess', _123 => _123.col]))), () => ( 0)));
|
|
1911
|
+
const targetRow = _nullishCoalesce(_optionalChain([this, 'access', _124 => _124.activeCell, 'optionalAccess', _125 => _125.row]), () => ( 0));
|
|
1912
|
+
const targetCol = _nullishCoalesce(_optionalChain([this, 'access', _126 => _126.activeCell, 'optionalAccess', _127 => _127.col]), () => ( 0));
|
|
1831
1913
|
const rowObj = this.document.rows[targetRow];
|
|
1832
1914
|
const colObj = this.document.columns[targetCol];
|
|
1833
1915
|
if (!rowObj || !colObj) return;
|
|
@@ -1881,17 +1963,17 @@ var SpreadsheetController = (_class3 = class {
|
|
|
1881
1963
|
// --- Grid Structure Mutations ---
|
|
1882
1964
|
insertColumn(index, config) {
|
|
1883
1965
|
this.recordSnapshot();
|
|
1884
|
-
const newId = _optionalChain([config, 'optionalAccess',
|
|
1966
|
+
const newId = _optionalChain([config, 'optionalAccess', _128 => _128.id]) || this.generateId("col");
|
|
1885
1967
|
const newCol = {
|
|
1886
1968
|
id: newId,
|
|
1887
|
-
key:
|
|
1888
|
-
title: _optionalChain([config, 'optionalAccess',
|
|
1889
|
-
width: _optionalChain([config, 'optionalAccess',
|
|
1890
|
-
type: _optionalChain([config, 'optionalAccess',
|
|
1891
|
-
binding: _optionalChain([config, 'optionalAccess',
|
|
1892
|
-
formula: _optionalChain([config, 'optionalAccess',
|
|
1893
|
-
format: _optionalChain([config, 'optionalAccess',
|
|
1894
|
-
readOnly: _optionalChain([config, 'optionalAccess',
|
|
1969
|
+
key: _chunkRIKBJLS2cjs.indexToColName.call(void 0, index),
|
|
1970
|
+
title: _optionalChain([config, 'optionalAccess', _129 => _129.title]) || _chunkRIKBJLS2cjs.indexToColName.call(void 0, index),
|
|
1971
|
+
width: _optionalChain([config, 'optionalAccess', _130 => _130.width]) || 130,
|
|
1972
|
+
type: _optionalChain([config, 'optionalAccess', _131 => _131.type]) || "freeform",
|
|
1973
|
+
binding: _optionalChain([config, 'optionalAccess', _132 => _132.binding]),
|
|
1974
|
+
formula: _optionalChain([config, 'optionalAccess', _133 => _133.formula]),
|
|
1975
|
+
format: _optionalChain([config, 'optionalAccess', _134 => _134.format]) || "text",
|
|
1976
|
+
readOnly: _optionalChain([config, 'optionalAccess', _135 => _135.readOnly])
|
|
1895
1977
|
};
|
|
1896
1978
|
this.shiftReferences({ axis: "col", index, type: "insert" });
|
|
1897
1979
|
this.adjustTableForStructuralChange({ axis: "col", index, type: "insert" });
|
|
@@ -1916,13 +1998,13 @@ var SpreadsheetController = (_class3 = class {
|
|
|
1916
1998
|
}
|
|
1917
1999
|
insertRow(index, config) {
|
|
1918
2000
|
this.recordSnapshot();
|
|
1919
|
-
const newId = _optionalChain([config, 'optionalAccess',
|
|
2001
|
+
const newId = _optionalChain([config, 'optionalAccess', _136 => _136.id]) || this.generateId("row");
|
|
1920
2002
|
const newRow = {
|
|
1921
2003
|
id: newId,
|
|
1922
2004
|
index,
|
|
1923
|
-
height: _optionalChain([config, 'optionalAccess',
|
|
1924
|
-
recordId: _optionalChain([config, 'optionalAccess',
|
|
1925
|
-
type: _optionalChain([config, 'optionalAccess',
|
|
2005
|
+
height: _optionalChain([config, 'optionalAccess', _137 => _137.height]) || 32,
|
|
2006
|
+
recordId: _optionalChain([config, 'optionalAccess', _138 => _138.recordId]),
|
|
2007
|
+
type: _optionalChain([config, 'optionalAccess', _139 => _139.type]) || "freeform"
|
|
1926
2008
|
};
|
|
1927
2009
|
this.shiftReferences({ axis: "row", index, type: "insert" });
|
|
1928
2010
|
this.adjustTableForStructuralChange({ axis: "row", index, type: "insert" });
|
|
@@ -1953,14 +2035,14 @@ var SpreadsheetController = (_class3 = class {
|
|
|
1953
2035
|
shiftReferences(change) {
|
|
1954
2036
|
for (const rowCells of Object.values(this.document.cells)) {
|
|
1955
2037
|
for (const cell of Object.values(rowCells)) {
|
|
1956
|
-
if (_optionalChain([cell, 'access',
|
|
2038
|
+
if (_optionalChain([cell, 'access', _140 => _140.raw, 'optionalAccess', _141 => _141.startsWith, 'call', _142 => _142("=")])) {
|
|
1957
2039
|
cell.raw = shiftFormulaReferences(cell.raw, change);
|
|
1958
2040
|
}
|
|
1959
2041
|
}
|
|
1960
2042
|
}
|
|
1961
2043
|
if (change.axis === "col") {
|
|
1962
2044
|
for (const col of this.document.columns) {
|
|
1963
|
-
if (_optionalChain([col, 'access',
|
|
2045
|
+
if (_optionalChain([col, 'access', _143 => _143.formula, 'optionalAccess', _144 => _144.startsWith, 'call', _145 => _145("=")])) {
|
|
1964
2046
|
col.formula = shiftFormulaReferences(col.formula, change);
|
|
1965
2047
|
}
|
|
1966
2048
|
}
|
|
@@ -1983,7 +2065,7 @@ var SpreadsheetController = (_class3 = class {
|
|
|
1983
2065
|
let maxLen = (col.title || "").length + (col.key ? col.key.length + 3 : 0);
|
|
1984
2066
|
for (const row of this.document.rows) {
|
|
1985
2067
|
const cell = this.getCell(row.id, col.id);
|
|
1986
|
-
const valStr =
|
|
2068
|
+
const valStr = _chunkRIKBJLS2cjs.formatCellDisplay.call(void 0, cell);
|
|
1987
2069
|
if (valStr.length > maxLen) {
|
|
1988
2070
|
maxLen = valStr.length;
|
|
1989
2071
|
}
|
|
@@ -2007,8 +2089,7 @@ var SpreadsheetController = (_class3 = class {
|
|
|
2007
2089
|
) : this.document.columns;
|
|
2008
2090
|
return rows.map(
|
|
2009
2091
|
(row) => columns.map((col) => {
|
|
2010
|
-
|
|
2011
|
-
return String(_nullishCoalesce(cell.value, () => ( ""))).replace(/\t/g, " ");
|
|
2092
|
+
return _chunkRIKBJLS2cjs.formatCellDisplay.call(void 0, this.getCell(row.id, col.id)).replace(/\t/g, " ");
|
|
2012
2093
|
}).join(" ")
|
|
2013
2094
|
).join("\n");
|
|
2014
2095
|
}
|
|
@@ -2028,7 +2109,7 @@ var SpreadsheetController = (_class3 = class {
|
|
|
2028
2109
|
this.document.rows.push({ id: this.generateId("row"), index, height: 32, type: "freeform" });
|
|
2029
2110
|
}
|
|
2030
2111
|
while (colIndex >= this.document.columns.length) {
|
|
2031
|
-
const key =
|
|
2112
|
+
const key = _chunkRIKBJLS2cjs.indexToColName.call(void 0, this.document.columns.length);
|
|
2032
2113
|
this.document.columns.push({
|
|
2033
2114
|
id: this.generateId("col"),
|
|
2034
2115
|
key,
|
|
@@ -2075,7 +2156,7 @@ var SpreadsheetController = (_class3 = class {
|
|
|
2075
2156
|
const commits = this.pendingCommits;
|
|
2076
2157
|
this.pendingCommits = [];
|
|
2077
2158
|
for (const [rowId, colId, raw] of commits) {
|
|
2078
|
-
_optionalChain([this, 'access',
|
|
2159
|
+
_optionalChain([this, 'access', _146 => _146.onCellCommit, 'optionalCall', _147 => _147(rowId, colId, raw, _optionalChain([this, 'access', _148 => _148.document, 'access', _149 => _149.cells, 'access', _150 => _150[rowId], 'optionalAccess', _151 => _151[colId], 'optionalAccess', _152 => _152.value]))]);
|
|
2079
2160
|
}
|
|
2080
2161
|
}
|
|
2081
2162
|
// --- CSV ---
|
|
@@ -2085,7 +2166,7 @@ var SpreadsheetController = (_class3 = class {
|
|
|
2085
2166
|
*/
|
|
2086
2167
|
exportToCsv(options = {}) {
|
|
2087
2168
|
const matrix = this.readMatrix(_nullishCoalesce(options.range, () => ( null))).map(
|
|
2088
|
-
(row) => row.map((cell) => options.formulas ? cell.raw :
|
|
2169
|
+
(row) => row.map((cell) => options.formulas ? cell.raw : _chunkRIKBJLS2cjs.formatCellDisplay.call(void 0, cell))
|
|
2089
2170
|
);
|
|
2090
2171
|
return serializeCsv(matrix, {
|
|
2091
2172
|
delimiter: options.delimiter,
|
|
@@ -2126,10 +2207,11 @@ var SpreadsheetController = (_class3 = class {
|
|
|
2126
2207
|
const cells = this.readMatrix(r).map(
|
|
2127
2208
|
(row) => row.map((cell) => {
|
|
2128
2209
|
const value = cell.error || cell.value;
|
|
2210
|
+
const text = _chunkRIKBJLS2cjs.formatCellDisplay.call(void 0, cell);
|
|
2129
2211
|
if (cell.spillAnchor && !this.spillAnchorInRange(cell.spillAnchor, r)) {
|
|
2130
|
-
return { raw:
|
|
2212
|
+
return { raw: text, value, text };
|
|
2131
2213
|
}
|
|
2132
|
-
return { raw: cell.raw, value };
|
|
2214
|
+
return { raw: cell.raw, value, text };
|
|
2133
2215
|
})
|
|
2134
2216
|
);
|
|
2135
2217
|
return createSpreadsheetClipboardData(cells, { row: r.startRow, col: r.startCol });
|
|
@@ -2163,7 +2245,7 @@ var SpreadsheetController = (_class3 = class {
|
|
|
2163
2245
|
const r = normalizeRange(this.selectedRange);
|
|
2164
2246
|
return { row: r.startRow, col: r.startCol };
|
|
2165
2247
|
}
|
|
2166
|
-
return { row: _nullishCoalesce(_optionalChain([this, 'access',
|
|
2248
|
+
return { row: _nullishCoalesce(_optionalChain([this, 'access', _153 => _153.activeCell, 'optionalAccess', _154 => _154.row]), () => ( 0)), col: _nullishCoalesce(_optionalChain([this, 'access', _155 => _155.activeCell, 'optionalAccess', _156 => _156.col]), () => ( 0)) };
|
|
2167
2249
|
}
|
|
2168
2250
|
// --- Table operations: shared helpers ---
|
|
2169
2251
|
/** The table settings object, created on first use. */
|
|
@@ -2197,7 +2279,7 @@ var SpreadsheetController = (_class3 = class {
|
|
|
2197
2279
|
remapAllFormulas(moveCell) {
|
|
2198
2280
|
for (const rowCells of Object.values(this.document.cells)) {
|
|
2199
2281
|
for (const cell of Object.values(rowCells)) {
|
|
2200
|
-
if (_optionalChain([cell, 'access',
|
|
2282
|
+
if (_optionalChain([cell, 'access', _157 => _157.raw, 'optionalAccess', _158 => _158.startsWith, 'call', _159 => _159("=")])) {
|
|
2201
2283
|
cell.raw = remapFormulaReferences(cell.raw, moveCell);
|
|
2202
2284
|
}
|
|
2203
2285
|
}
|
|
@@ -2209,8 +2291,8 @@ var SpreadsheetController = (_class3 = class {
|
|
|
2209
2291
|
* merges reduced to a single cell are dropped.
|
|
2210
2292
|
*/
|
|
2211
2293
|
adjustTableForStructuralChange(change) {
|
|
2212
|
-
const merges = _optionalChain([this, 'access',
|
|
2213
|
-
if (!_optionalChain([merges, 'optionalAccess',
|
|
2294
|
+
const merges = _optionalChain([this, 'access', _160 => _160.document, 'access', _161 => _161.table, 'optionalAccess', _162 => _162.merges]);
|
|
2295
|
+
if (!_optionalChain([merges, 'optionalAccess', _163 => _163.length])) return;
|
|
2214
2296
|
const startKey = change.axis === "row" ? "startRow" : "startCol";
|
|
2215
2297
|
const endKey = change.axis === "row" ? "endRow" : "endCol";
|
|
2216
2298
|
const next = [];
|
|
@@ -2241,8 +2323,8 @@ var SpreadsheetController = (_class3 = class {
|
|
|
2241
2323
|
const colCount = this.document.columns.length;
|
|
2242
2324
|
const body = this.getBodyRowBounds();
|
|
2243
2325
|
const range = options.range ? normalizeRange(options.range) : null;
|
|
2244
|
-
const startRow = Math.max(_nullishCoalesce(_optionalChain([range, 'optionalAccess',
|
|
2245
|
-
const endRow = Math.min(_nullishCoalesce(_optionalChain([range, 'optionalAccess',
|
|
2326
|
+
const startRow = Math.max(_nullishCoalesce(_optionalChain([range, 'optionalAccess', _164 => _164.startRow]), () => ( body.start)), body.start);
|
|
2327
|
+
const endRow = Math.min(_nullishCoalesce(_optionalChain([range, 'optionalAccess', _165 => _165.endRow]), () => ( body.end)), body.end);
|
|
2246
2328
|
const startCol = range ? Math.max(0, range.startCol) : 0;
|
|
2247
2329
|
const endCol = range ? Math.min(colCount - 1, range.endCol) : colCount - 1;
|
|
2248
2330
|
if (endRow - startRow < 1 || startCol > endCol) return false;
|
|
@@ -2252,7 +2334,7 @@ var SpreadsheetController = (_class3 = class {
|
|
|
2252
2334
|
}));
|
|
2253
2335
|
if (keyCols.length === 0 || keyCols.some((k) => k.index < startCol || k.index > endCol)) return false;
|
|
2254
2336
|
const area = { startRow, startCol, endRow, endCol };
|
|
2255
|
-
if ((_nullishCoalesce(_optionalChain([this, 'access',
|
|
2337
|
+
if ((_nullishCoalesce(_optionalChain([this, 'access', _166 => _166.document, 'access', _167 => _167.table, 'optionalAccess', _168 => _168.merges]), () => ( []))).some((m) => rangesIntersect(m, area))) return false;
|
|
2256
2338
|
if (this.intersectsSpill(area)) return false;
|
|
2257
2339
|
const sourceRows = [];
|
|
2258
2340
|
for (let r = startRow; r <= endRow; r++) sourceRows.push(r);
|
|
@@ -2280,7 +2362,7 @@ var SpreadsheetController = (_class3 = class {
|
|
|
2280
2362
|
const colIds = this.document.columns.slice(startCol, endCol + 1).map((c) => c.id);
|
|
2281
2363
|
const snapshot = sorted.map((oldRow) => {
|
|
2282
2364
|
const rowId = this.document.rows[oldRow].id;
|
|
2283
|
-
return colIds.map((colId) => _optionalChain([this, 'access',
|
|
2365
|
+
return colIds.map((colId) => _optionalChain([this, 'access', _169 => _169.document, 'access', _170 => _170.cells, 'access', _171 => _171[rowId], 'optionalAccess', _172 => _172[colId]]));
|
|
2284
2366
|
});
|
|
2285
2367
|
snapshot.forEach((cells, i) => {
|
|
2286
2368
|
const rowId = this.document.rows[startRow + i].id;
|
|
@@ -2296,7 +2378,7 @@ var SpreadsheetController = (_class3 = class {
|
|
|
2296
2378
|
}
|
|
2297
2379
|
// --- Filters ---
|
|
2298
2380
|
getFilterState() {
|
|
2299
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
|
2381
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _173 => _173.document, 'access', _174 => _174.table, 'optionalAccess', _175 => _175.filter]), () => ( { enabled: false, rules: [] }));
|
|
2300
2382
|
}
|
|
2301
2383
|
/** Replaces all filter rules (and turns filters on when there are any). */
|
|
2302
2384
|
setFilterRules(rules) {
|
|
@@ -2373,7 +2455,7 @@ var SpreadsheetController = (_class3 = class {
|
|
|
2373
2455
|
}
|
|
2374
2456
|
setTableCount(key, count, max) {
|
|
2375
2457
|
const value = Math.max(0, Math.min(Math.floor(count), max));
|
|
2376
|
-
if ((_nullishCoalesce(_optionalChain([this, 'access',
|
|
2458
|
+
if ((_nullishCoalesce(_optionalChain([this, 'access', _176 => _176.document, 'access', _177 => _177.table, 'optionalAccess', _178 => _178[key]]), () => ( 0))) === value) return;
|
|
2377
2459
|
this.applyTableChange(() => {
|
|
2378
2460
|
this.table[key] = value;
|
|
2379
2461
|
});
|
|
@@ -2414,7 +2496,7 @@ var SpreadsheetController = (_class3 = class {
|
|
|
2414
2496
|
}
|
|
2415
2497
|
// --- Merged cells ---
|
|
2416
2498
|
getMerges() {
|
|
2417
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
|
2499
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _179 => _179.document, 'access', _180 => _180.table, 'optionalAccess', _181 => _181.merges]), () => ( []));
|
|
2418
2500
|
}
|
|
2419
2501
|
/** The merge containing (row, col), or null. */
|
|
2420
2502
|
getMergeAt(row, col) {
|
|
@@ -2467,7 +2549,7 @@ var SpreadsheetController = (_class3 = class {
|
|
|
2467
2549
|
const rowId = this.document.rows[row].id;
|
|
2468
2550
|
for (let col = r.startCol; col <= r.endCol; col++) {
|
|
2469
2551
|
if (row === r.startRow && col === r.startCol) continue;
|
|
2470
|
-
_optionalChainDelete([this, 'access',
|
|
2552
|
+
_optionalChainDelete([this, 'access', _182 => _182.document, 'access', _183 => _183.cells, 'access', _184 => _184[rowId], 'optionalAccess', _185 => _185[this.document.columns[col].id]]);
|
|
2471
2553
|
}
|
|
2472
2554
|
}
|
|
2473
2555
|
this.table.merges = [...merges.filter((m) => !rangeContainsRange(r, m)), r];
|
|
@@ -2553,14 +2635,14 @@ var SpreadsheetController = (_class3 = class {
|
|
|
2553
2635
|
});
|
|
2554
2636
|
}
|
|
2555
2637
|
ungroupRows() {
|
|
2556
|
-
if (!_optionalChain([this, 'access',
|
|
2638
|
+
if (!_optionalChain([this, 'access', _186 => _186.document, 'access', _187 => _187.table, 'optionalAccess', _188 => _188.grouping])) return;
|
|
2557
2639
|
this.applyTableChange(() => {
|
|
2558
2640
|
delete this.table.grouping;
|
|
2559
2641
|
});
|
|
2560
2642
|
}
|
|
2561
2643
|
/** Sets (or with `null`, removes) the group summary for a column. */
|
|
2562
2644
|
setGroupSummary(colId, aggregate) {
|
|
2563
|
-
const grouping = _optionalChain([this, 'access',
|
|
2645
|
+
const grouping = _optionalChain([this, 'access', _189 => _189.document, 'access', _190 => _190.table, 'optionalAccess', _191 => _191.grouping]);
|
|
2564
2646
|
if (!grouping) return;
|
|
2565
2647
|
this.applyTableChange(() => {
|
|
2566
2648
|
const others = grouping.summaries.filter((s) => s.colId !== colId);
|
|
@@ -2571,7 +2653,7 @@ var SpreadsheetController = (_class3 = class {
|
|
|
2571
2653
|
});
|
|
2572
2654
|
}
|
|
2573
2655
|
setGroupCollapsed(key, collapsed) {
|
|
2574
|
-
const grouping = _optionalChain([this, 'access',
|
|
2656
|
+
const grouping = _optionalChain([this, 'access', _192 => _192.document, 'access', _193 => _193.table, 'optionalAccess', _194 => _194.grouping]);
|
|
2575
2657
|
if (!grouping || grouping.collapsed.includes(key) === collapsed) return;
|
|
2576
2658
|
this.applyTableChange(() => {
|
|
2577
2659
|
this.table.grouping = {
|
|
@@ -2581,7 +2663,7 @@ var SpreadsheetController = (_class3 = class {
|
|
|
2581
2663
|
});
|
|
2582
2664
|
}
|
|
2583
2665
|
toggleGroupCollapsed(key) {
|
|
2584
|
-
const grouping = _optionalChain([this, 'access',
|
|
2666
|
+
const grouping = _optionalChain([this, 'access', _195 => _195.document, 'access', _196 => _196.table, 'optionalAccess', _197 => _197.grouping]);
|
|
2585
2667
|
if (!grouping) return;
|
|
2586
2668
|
this.setGroupCollapsed(key, !grouping.collapsed.includes(key));
|
|
2587
2669
|
}
|
|
@@ -2619,9 +2701,9 @@ var SpreadsheetController = (_class3 = class {
|
|
|
2619
2701
|
moved.push({
|
|
2620
2702
|
row: s.startRow + (c - s.startCol),
|
|
2621
2703
|
col: s.startCol + (r - s.startRow),
|
|
2622
|
-
cell: _optionalChain([this, 'access',
|
|
2704
|
+
cell: _optionalChain([this, 'access', _198 => _198.document, 'access', _199 => _199.cells, 'access', _200 => _200[rowId(r)], 'optionalAccess', _201 => _201[colId(c)]])
|
|
2623
2705
|
});
|
|
2624
|
-
_optionalChainDelete([this, 'access',
|
|
2706
|
+
_optionalChainDelete([this, 'access', _202 => _202.document, 'access', _203 => _203.cells, 'access', _204 => _204[rowId(r)], 'optionalAccess', _205 => _205[colId(c)]]);
|
|
2625
2707
|
}
|
|
2626
2708
|
}
|
|
2627
2709
|
for (const { row, col, cell } of moved) {
|
|
@@ -2648,6 +2730,28 @@ var SpreadsheetController = (_class3 = class {
|
|
|
2648
2730
|
this.undoStack.push(JSON.stringify(this.document));
|
|
2649
2731
|
if (this.undoStack.length > 50) this.undoStack.shift();
|
|
2650
2732
|
this.redoStack = [];
|
|
2733
|
+
this.trimHistory();
|
|
2734
|
+
}
|
|
2735
|
+
/** Drops the oldest snapshots beyond `maxHistoryBytes`, always keeping the newest. */
|
|
2736
|
+
trimHistory() {
|
|
2737
|
+
if (this.maxHistoryBytes <= 0 || this.undoStack.length <= 1) return;
|
|
2738
|
+
let total = 0;
|
|
2739
|
+
for (const s of this.undoStack) total += s.length * 2;
|
|
2740
|
+
for (const s of this.redoStack) total += s.length * 2;
|
|
2741
|
+
while (total > this.maxHistoryBytes && this.undoStack.length > 1) {
|
|
2742
|
+
total -= this.undoStack.shift().length * 2;
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2745
|
+
/** Approximate bytes held by the undo/redo snapshots (UTF-16 size). */
|
|
2746
|
+
getHistoryByteSize() {
|
|
2747
|
+
let total = 0;
|
|
2748
|
+
for (const s of this.undoStack) total += s.length * 2;
|
|
2749
|
+
for (const s of this.redoStack) total += s.length * 2;
|
|
2750
|
+
return total;
|
|
2751
|
+
}
|
|
2752
|
+
/** Number of undo / redo snapshots currently held. */
|
|
2753
|
+
getHistoryDepth() {
|
|
2754
|
+
return { undo: this.undoStack.length, redo: this.redoStack.length };
|
|
2651
2755
|
}
|
|
2652
2756
|
undo() {
|
|
2653
2757
|
if (this.undoStack.length === 0) return;
|
|
@@ -2674,7 +2778,7 @@ var SpreadsheetController = (_class3 = class {
|
|
|
2674
2778
|
}
|
|
2675
2779
|
}
|
|
2676
2780
|
notifyChange() {
|
|
2677
|
-
_optionalChain([this, 'access',
|
|
2781
|
+
_optionalChain([this, 'access', _206 => _206.onDocumentChange, 'optionalCall', _207 => _207(this.document)]);
|
|
2678
2782
|
}
|
|
2679
2783
|
}, _class3);
|
|
2680
2784
|
function stepInOrder(order, from, delta) {
|
|
@@ -2710,8 +2814,9 @@ function getSpreadsheetMenuItems(controller, cell) {
|
|
|
2710
2814
|
const row = doc.rows[cell.row];
|
|
2711
2815
|
if (!column || !row) return [];
|
|
2712
2816
|
const selection = controller.selectedRange && rangeContains(controller.selectedRange, cell.row, cell.col) ? normalizeRange(controller.selectedRange) : { startRow: cell.row, startCol: cell.col, endRow: cell.row, endCol: cell.col };
|
|
2713
|
-
const colName =
|
|
2714
|
-
const
|
|
2817
|
+
const colName = _chunkRIKBJLS2cjs.indexToColName.call(void 0, cell.col);
|
|
2818
|
+
const cellData = controller.getCell(row.id, column.id);
|
|
2819
|
+
const value = cellData.value;
|
|
2715
2820
|
const table = _nullishCoalesce(doc.table, () => ( {}));
|
|
2716
2821
|
const filter = controller.getFilterState();
|
|
2717
2822
|
const grouping = table.grouping;
|
|
@@ -2733,7 +2838,7 @@ function getSpreadsheetMenuItems(controller, cell) {
|
|
|
2733
2838
|
},
|
|
2734
2839
|
{
|
|
2735
2840
|
id: "filter-equals",
|
|
2736
|
-
label: `Show only rows where ${colName} = ${quote(
|
|
2841
|
+
label: `Show only rows where ${colName} = ${quote(_chunkRIKBJLS2cjs.formatCellDisplay.call(void 0, cellData))}`,
|
|
2737
2842
|
separatorBefore: true,
|
|
2738
2843
|
run: () => controller.addFilterRule({ colId: column.id, operator: "equals", value: String(_nullishCoalesce(value, () => ( ""))) })
|
|
2739
2844
|
},
|
|
@@ -2992,4 +3097,4 @@ async function importFileIntoSpreadsheet(controller, input, options) {
|
|
|
2992
3097
|
|
|
2993
3098
|
|
|
2994
3099
|
exports.columnDependencyKey = columnDependencyKey; exports.extractCellDependencies = extractCellDependencies; exports.DependencyGraph = DependencyGraph; exports.shiftFormulaReferences = shiftFormulaReferences; exports.mapFormulaReferences = mapFormulaReferences; exports.offsetFormulaReferences = offsetFormulaReferences; exports.remapFormulaReferences = remapFormulaReferences; exports.getFormulaCaretContext = getFormulaCaretContext; exports.getFormulaHints = getFormulaHints; exports.applyFormulaSuggestion = applyFormulaSuggestion; exports.DataSourceBinder = DataSourceBinder; exports.normalizeRange = normalizeRange; exports.rangeContains = rangeContains; exports.rangesIntersect = rangesIntersect; exports.rangeContainsRange = rangeContainsRange; exports.isSingleCellRange = isSingleCellRange; exports.isBlankValue = isBlankValue; exports.toNumber = toNumber; exports.compareCellValues = compareCellValues; exports.matchesFilterRule = matchesFilterRule; exports.aggregateValues = aggregateValues; exports.roundFloat = roundFloat; exports.fillSeries = fillSeries; exports.computeFillTarget = computeFillTarget; exports.getFillDirection = getFillDirection; exports.parseCsv = parseCsv; exports.escapeCsvField = escapeCsvField; exports.serializeCsv = serializeCsv; exports.parseTsv = parseTsv; exports.serializeTsv = serializeTsv; exports.SPREADSHEET_CLIPBOARD_MIME = SPREADSHEET_CLIPBOARD_MIME; exports.serializeHtmlTable = serializeHtmlTable; exports.parseHtmlTable = parseHtmlTable; exports.createSpreadsheetClipboardData = createSpreadsheetClipboardData; exports.readSpreadsheetClipboard = readSpreadsheetClipboard; exports.rebaseClipboardRows = rebaseClipboardRows; exports.DEFAULT_ROW_HEIGHT = DEFAULT_ROW_HEIGHT; exports.DEFAULT_COLUMN_WIDTH = DEFAULT_COLUMN_WIDTH; exports.getTableSections = getTableSections; exports.getRowSection = getRowSection; exports.rowPassesFilters = rowPassesFilters; exports.computeRowGroups = computeRowGroups; exports.buildSpreadsheetView = buildSpreadsheetView; exports.SpreadsheetController = SpreadsheetController; exports.clampMenuPosition = clampMenuPosition; exports.getSpreadsheetMenuItems = getSpreadsheetMenuItems; exports.SPREADSHEET_TABLE_ACTIONS = SPREADSHEET_TABLE_ACTIONS; exports.bindSpreadsheetTableActions = bindSpreadsheetTableActions; exports.csvImportAdapter = csvImportAdapter; exports.tsvImportAdapter = tsvImportAdapter; exports.SPREADSHEET_IMPORT_ADAPTERS = SPREADSHEET_IMPORT_ADAPTERS; exports.registerSpreadsheetImportAdapters = registerSpreadsheetImportAdapters; exports.importFileIntoSpreadsheet = importFileIntoSpreadsheet;
|
|
2995
|
-
//# sourceMappingURL=chunk-
|
|
3100
|
+
//# sourceMappingURL=chunk-XDMXXC4Z.cjs.map
|