@rowsncolumns/spreadsheet 10.10.4 → 10.10.5

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.
Files changed (108) hide show
  1. package/dist/cjs/api/error-checking.d.ts +39 -3
  2. package/dist/cjs/api/error-checking.d.ts.map +1 -1
  3. package/dist/cjs/api/error-checking.js +169 -13
  4. package/dist/cjs/api/excel-edit-value.d.ts +18 -0
  5. package/dist/cjs/api/excel-edit-value.d.ts.map +1 -0
  6. package/dist/cjs/api/excel-edit-value.js +98 -0
  7. package/dist/cjs/api/split-pane.d.ts +19 -0
  8. package/dist/cjs/api/split-pane.d.ts.map +1 -0
  9. package/dist/cjs/api/split-pane.js +70 -0
  10. package/dist/cjs/atoms/cell-input-context.atom.d.ts.map +1 -1
  11. package/dist/cjs/components/canvas-grid/index.d.ts.map +1 -1
  12. package/dist/cjs/components/canvas-grid/index.js +125 -68
  13. package/dist/cjs/components/canvas-grid/typings.d.ts +30 -0
  14. package/dist/cjs/components/canvas-grid/typings.d.ts.map +1 -1
  15. package/dist/cjs/components/error-check-smart-tag/index.d.ts +3 -2
  16. package/dist/cjs/components/error-check-smart-tag/index.d.ts.map +1 -1
  17. package/dist/cjs/components/error-check-smart-tag/index.js +4 -2
  18. package/dist/cjs/components/filter-box/filter-by-color.d.ts +1 -1
  19. package/dist/cjs/components/filter-box/filter-by-color.d.ts.map +1 -1
  20. package/dist/cjs/components/filter-box/filter-by-color.js +3 -6
  21. package/dist/cjs/components/filter-box/index.d.ts.map +1 -1
  22. package/dist/cjs/components/filter-box/index.js +1 -3
  23. package/dist/cjs/components/print-preview/page-block.d.ts +2 -0
  24. package/dist/cjs/components/print-preview/page-block.d.ts.map +1 -1
  25. package/dist/cjs/components/print-preview/page-block.js +131 -101
  26. package/dist/cjs/components/print-preview/page-break-preview.d.ts.map +1 -1
  27. package/dist/cjs/components/print-preview/page-break-preview.js +5 -3
  28. package/dist/cjs/components/print-preview/print-preview-dialog.d.ts +1 -1
  29. package/dist/cjs/components/print-preview/print-preview-dialog.d.ts.map +1 -1
  30. package/dist/cjs/components/print-preview/print-preview-dialog.js +38 -17
  31. package/dist/cjs/components/print-preview/settings.d.ts +22 -1
  32. package/dist/cjs/components/print-preview/settings.d.ts.map +1 -1
  33. package/dist/cjs/components/print-preview/settings.js +54 -1
  34. package/dist/cjs/components/print-preview/sheet-page-setup.d.ts +22 -1
  35. package/dist/cjs/components/print-preview/sheet-page-setup.d.ts.map +1 -1
  36. package/dist/cjs/components/print-preview/sheet-page-setup.js +59 -3
  37. package/dist/cjs/hooks/use-copy-paste-cut.d.ts.map +1 -1
  38. package/dist/cjs/hooks/use-copy-paste-cut.js +5 -2
  39. package/dist/cjs/hooks/use-editor-submit.d.ts +9 -1
  40. package/dist/cjs/hooks/use-editor-submit.d.ts.map +1 -1
  41. package/dist/cjs/hooks/use-editor-submit.js +39 -15
  42. package/dist/cjs/hooks/use-embeds-charts.d.ts.map +1 -1
  43. package/dist/cjs/hooks/use-embeds-charts.js +6 -4
  44. package/dist/cjs/hooks/use-selection-renderer.d.ts +3 -1
  45. package/dist/cjs/hooks/use-selection-renderer.d.ts.map +1 -1
  46. package/dist/cjs/hooks/use-selection-renderer.js +4 -3
  47. package/dist/cjs/index.d.ts +1 -0
  48. package/dist/cjs/index.d.ts.map +1 -1
  49. package/dist/cjs/index.js +1 -0
  50. package/dist/cjs/release-date.js +1 -1
  51. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  52. package/dist/cjs/types.d.ts +44 -2
  53. package/dist/cjs/types.d.ts.map +1 -1
  54. package/dist/esm/api/error-checking.d.ts +39 -3
  55. package/dist/esm/api/error-checking.d.ts.map +1 -1
  56. package/dist/esm/api/error-checking.js +128 -3
  57. package/dist/esm/api/excel-edit-value.d.ts +18 -0
  58. package/dist/esm/api/excel-edit-value.d.ts.map +1 -0
  59. package/dist/esm/api/excel-edit-value.js +90 -0
  60. package/dist/esm/api/split-pane.d.ts +19 -0
  61. package/dist/esm/api/split-pane.d.ts.map +1 -0
  62. package/dist/esm/api/split-pane.js +63 -0
  63. package/dist/esm/atoms/cell-input-context.atom.d.ts.map +1 -1
  64. package/dist/esm/components/canvas-grid/index.d.ts.map +1 -1
  65. package/dist/esm/components/canvas-grid/index.js +59 -5
  66. package/dist/esm/components/canvas-grid/typings.d.ts +30 -0
  67. package/dist/esm/components/canvas-grid/typings.d.ts.map +1 -1
  68. package/dist/esm/components/error-check-smart-tag/index.d.ts +3 -2
  69. package/dist/esm/components/error-check-smart-tag/index.d.ts.map +1 -1
  70. package/dist/esm/components/error-check-smart-tag/index.js +4 -2
  71. package/dist/esm/components/filter-box/filter-by-color.d.ts +1 -1
  72. package/dist/esm/components/filter-box/filter-by-color.d.ts.map +1 -1
  73. package/dist/esm/components/filter-box/filter-by-color.js +3 -6
  74. package/dist/esm/components/filter-box/index.d.ts.map +1 -1
  75. package/dist/esm/components/filter-box/index.js +1 -3
  76. package/dist/esm/components/print-preview/page-block.d.ts +2 -0
  77. package/dist/esm/components/print-preview/page-block.d.ts.map +1 -1
  78. package/dist/esm/components/print-preview/page-block.js +141 -110
  79. package/dist/esm/components/print-preview/page-break-preview.d.ts.map +1 -1
  80. package/dist/esm/components/print-preview/page-break-preview.js +6 -4
  81. package/dist/esm/components/print-preview/print-preview-dialog.d.ts +1 -1
  82. package/dist/esm/components/print-preview/print-preview-dialog.d.ts.map +1 -1
  83. package/dist/esm/components/print-preview/print-preview-dialog.js +40 -19
  84. package/dist/esm/components/print-preview/settings.d.ts +22 -1
  85. package/dist/esm/components/print-preview/settings.d.ts.map +1 -1
  86. package/dist/esm/components/print-preview/settings.js +50 -0
  87. package/dist/esm/components/print-preview/sheet-page-setup.d.ts +22 -1
  88. package/dist/esm/components/print-preview/sheet-page-setup.d.ts.map +1 -1
  89. package/dist/esm/components/print-preview/sheet-page-setup.js +51 -0
  90. package/dist/esm/hooks/use-copy-paste-cut.d.ts.map +1 -1
  91. package/dist/esm/hooks/use-copy-paste-cut.js +5 -2
  92. package/dist/esm/hooks/use-editor-submit.d.ts +9 -1
  93. package/dist/esm/hooks/use-editor-submit.d.ts.map +1 -1
  94. package/dist/esm/hooks/use-editor-submit.js +24 -1
  95. package/dist/esm/hooks/use-embeds-charts.d.ts.map +1 -1
  96. package/dist/esm/hooks/use-embeds-charts.js +7 -4
  97. package/dist/esm/hooks/use-selection-renderer.d.ts +3 -1
  98. package/dist/esm/hooks/use-selection-renderer.d.ts.map +1 -1
  99. package/dist/esm/hooks/use-selection-renderer.js +4 -3
  100. package/dist/esm/index.d.ts +1 -0
  101. package/dist/esm/index.d.ts.map +1 -1
  102. package/dist/esm/index.js +1 -0
  103. package/dist/esm/release-date.js +1 -1
  104. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  105. package/dist/esm/types.d.ts +44 -2
  106. package/dist/esm/types.d.ts.map +1 -1
  107. package/dist/spreadsheet.min.css +1 -1
  108. package/package.json +6 -6
@@ -6,13 +6,36 @@ import type { ErrorValue, ExtendedValue, IgnoredError } from "../types";
6
6
  *
7
7
  * - `evalError` — "Cells containing formulas that result in an error".
8
8
  * - `numberStoredAsText` — "Numbers formatted as text or preceded by an apostrophe".
9
+ * - `formulaRange` — "Formulas which omit cells in a region" (Formula Omits Adjacent Cells).
9
10
  */
10
- export type ErrorCheckKind = "evalError" | "numberStoredAsText";
11
+ export type ErrorCheckKind = "evalError" | "numberStoredAsText" | "formulaRange";
11
12
  /**
12
13
  * The number a "number stored as text" holds, or `undefined` when the text is not one. This is
13
14
  * the value Excel's Convert to Number writes back.
14
15
  */
15
16
  export declare const parseNumberStoredAsText: (text: string | null | undefined) => number | undefined;
17
+ /** A cell's position on its sheet (1-based, as the grid counts: A1 is row 1, column 1). */
18
+ type CellPosition = {
19
+ rowIndex: number;
20
+ columnIndex: number;
21
+ };
22
+ /** What "Update Formula to Include Cells" does to a formula that omits adjacent cells. */
23
+ export type OmittedAdjacentCells = {
24
+ /** The range the formula refers to now. */
25
+ range: GridRange;
26
+ /** The range that also takes in the adjacent numbers. */
27
+ expandedRange: GridRange;
28
+ /** The formula with its range widened to `expandedRange`. */
29
+ updatedFormula: string;
30
+ };
31
+ /**
32
+ * Excel's "Formulas which omit cells in a region" rule: a formula such as `=SUM(A3:A5)` whose
33
+ * one-column (or one-row) range stops next to more numbers in that column (row) — `A2` holds a
34
+ * number. The adjacent run of numbers on each end is what "Update Formula to Include Cells" adds;
35
+ * it never runs into the formula's own cell. `isNumber` says whether a cell holds a number typed as a
36
+ * value (not text, not a formula). `undefined` when the formula omits nothing.
37
+ */
38
+ export declare const findOmittedAdjacentCells: (formula: string | null | undefined, formulaCell: CellPosition, isNumber: (rowIndex: number, columnIndex: number) => boolean) => OmittedAdjacentCells | undefined;
16
39
  export type ErrorCheckInput = {
17
40
  /** What the user typed (`uev`): a formula, a number, a string, … */
18
41
  userEnteredValue: ExtendedValue | null | undefined;
@@ -23,15 +46,21 @@ export type ErrorCheckInput = {
23
46
  effectiveValue?: ExtendedValue | null;
24
47
  /** The cell's error, if its effective value is one. */
25
48
  errorValue: ErrorValue | null | undefined;
49
+ /**
50
+ * The cell's own position and a reader of its neighbours (does this cell hold a number typed as
51
+ * a value?). With both, a formula is also checked for omitting adjacent cells (`formulaRange`).
52
+ */
53
+ cell?: CellPosition;
54
+ isNumberAt?(rowIndex: number, columnIndex: number): boolean;
26
55
  };
27
56
  /**
28
57
  * Which error-checking rule (if any) flags this cell, before ignored errors are applied.
29
58
  * A typed error constant (`#N/A` entered as a value) is not flagged — only a formula's result.
30
59
  * A data-validation failure is not an error-checking rule (Excel only circles it on request).
31
60
  */
32
- export declare const getErrorCheckKind: ({ userEnteredValue, effectiveValue, errorValue, }: ErrorCheckInput) => ErrorCheckKind | undefined;
61
+ export declare const getErrorCheckKind: ({ userEnteredValue, effectiveValue, errorValue, cell, isNumberAt, }: ErrorCheckInput) => ErrorCheckKind | undefined;
33
62
  /** What the error-checking smart tag's menu can do. */
34
- export type ErrorCheckOption = "convertToNumber" | "help" | "ignore" | "editInFormulaBar" | "options";
63
+ export type ErrorCheckOption = "convertToNumber" | "updateFormulaToIncludeCells" | "help" | "ignore" | "editInFormulaBar" | "options";
35
64
  /** The menu's heading, as Excel words it. */
36
65
  export declare const getErrorCheckTitle: (kind: ErrorCheckKind, errorName?: string) => string;
37
66
  /** Excel's own help pages: hiding error values and error indicators, and the rule options. */
@@ -67,6 +96,12 @@ export type ErrorCheckActionContext = {
67
96
  maxRow: number;
68
97
  maxColumn: number;
69
98
  getIgnoredErrors?(sheetId: number): IgnoredError[] | null | undefined;
99
+ /** The active cell: the one whose formula "Update Formula to Include Cells" rewrites. */
100
+ activeCell?: CellPosition;
101
+ /** Does this cell hold a number typed as a value? (Formula Omits Adjacent Cells.) */
102
+ isNumberAt?(rowIndex: number, columnIndex: number): boolean;
103
+ /** Writes one cell's entry (a formula), as typing it would. */
104
+ onChange?(sheetId: number, cell: CellPosition, value: string): void;
70
105
  onChangeBatch?(sheetId: number, range: GridRange, values: number[][]): void;
71
106
  /** Records every write `action` makes as one undo step. */
72
107
  batchHistory?<R>(action: () => R): R;
@@ -85,4 +120,5 @@ export type ErrorCheckActionContext = {
85
120
  * sheet's `ignoredErrors` (persisted, xlsx `<ignoredErrors>`).
86
121
  */
87
122
  export declare const runErrorCheckOption: (option: ErrorCheckOption, context: ErrorCheckActionContext) => void;
123
+ export {};
88
124
  //# sourceMappingURL=error-checking.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"error-checking.d.ts","sourceRoot":"","sources":["../../../api/error-checking.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExE;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,oBAAoB,CAAC;AAShE;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAClC,MAAM,MAAM,GAA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M,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,GAAG,IAAI,CAAC;IAC5E,2DAA2D;IAC3D,YAAY,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IACrC,aAAa,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE;QAAE,aAAa,EAAE,YAAY,EAAE,CAAA;KAAE,GAAG,IAAI,CAAC;IAChF,8FAA8F;IAC9F,gBAAgB,IAAI,IAAI,CAAC;IACzB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,gBAAgB,EACxB,SAAS,uBAAuB,SA8DjC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runErrorCheckOption = exports.collectNumberStoredAsTextRuns = exports.appendIgnoredError = exports.isErrorIgnored = exports.getErrorHelpUrl = exports.ERROR_CHECKING_HELP_URL = exports.getErrorCheckTitle = exports.getErrorCheckKind = exports.parseNumberStoredAsText = void 0;
3
+ exports.runErrorCheckOption = exports.collectNumberStoredAsTextRuns = exports.appendIgnoredError = exports.isErrorIgnored = exports.getErrorHelpUrl = exports.ERROR_CHECKING_HELP_URL = exports.getErrorCheckTitle = exports.getErrorCheckKind = exports.findOmittedAdjacentCells = exports.parseNumberStoredAsText = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  /**
6
6
  * Text that Excel's "Number Stored as Text" rule flags: an optionally signed number, with optional
@@ -24,6 +24,145 @@ var parseNumberStoredAsText = function (text) {
24
24
  return isPercent ? value / 100 : value;
25
25
  };
26
26
  exports.parseNumberStoredAsText = parseNumberStoredAsText;
27
+ /**
28
+ * The functions Excel's "Formulas which omit cells in a region" rule looks at: the ones that sum
29
+ * up a block of numbers (`=SUM(A3:A5)` beside more numbers).
30
+ */
31
+ var REGION_FUNCTIONS = "SUM|AVERAGE|AVERAGEA|COUNT|COUNTA|MIN|MAX|MINA|MAXA|PRODUCT|MEDIAN|MODE|STDEV|STDEV\\.S|STDEV\\.P|STDEVA|STDEVP|VAR|VAR\\.S|VAR\\.P|VARA|VARP";
32
+ /** `FN( A1:A9 )` with a single same-sheet range argument; quoted text is skipped by the caller. */
33
+ var REGION_CALL = new RegExp("(?<![A-Za-z0-9_.!])(?:".concat(REGION_FUNCTIONS, ")\\(\\s*(\\$?)([A-Za-z]{1,3})(\\$?)(\\d+):(\\$?)([A-Za-z]{1,3})(\\$?)(\\d+)\\s*\\)"), "gi");
34
+ var columnNumber = function (letters) {
35
+ return letters
36
+ .toUpperCase()
37
+ .split("")
38
+ .reduce(function (total, letter) { return total * 26 + letter.charCodeAt(0) - 64; }, 0);
39
+ };
40
+ var columnLetters = function (column) {
41
+ var letters = "";
42
+ for (var n = column; n > 0; n = Math.floor((n - 1) / 26)) {
43
+ letters = String.fromCharCode(65 + ((n - 1) % 26)) + letters;
44
+ }
45
+ return letters;
46
+ };
47
+ var MAX_REFERENCE_CACHE = 5000;
48
+ var referenceCache = new Map();
49
+ /** The one-column / one-row ranges a formula hands to {@link REGION_FUNCTIONS}, in text order. */
50
+ var regionReferences = function (formula) {
51
+ var e_1, _a;
52
+ var cached = referenceCache.get(formula);
53
+ if (cached)
54
+ return cached;
55
+ // Blank out string literals so a quoted `"SUM(A1:A2)"` is not read as a call.
56
+ var text = formula.replace(/"(?:[^"]|"")*"/g, function (match) { return " ".repeat(match.length); });
57
+ var references = [];
58
+ try {
59
+ for (var _b = tslib_1.__values(text.matchAll(REGION_CALL)), _c = _b.next(); !_c.done; _c = _b.next()) {
60
+ var match = _c.value;
61
+ var _d = tslib_1.__read(match, 9), whole = _d[0], a1 = _d[1], c1 = _d[2], a2 = _d[3], r1 = _d[4], a3 = _d[5], c2 = _d[6], a4 = _d[7], r2 = _d[8];
62
+ var startColumn = columnNumber(c1);
63
+ var endColumn = columnNumber(c2);
64
+ var startRow = Number(r1);
65
+ var endRow = Number(r2);
66
+ if (startRow > endRow || startColumn > endColumn)
67
+ continue;
68
+ if (startRow !== endRow && startColumn !== endColumn)
69
+ continue;
70
+ var offset = match.index + whole.indexOf("(") + 1;
71
+ var start = text.indexOf("".concat(a1).concat(c1), offset);
72
+ references.push({
73
+ start: start,
74
+ end: start + "".concat(a1).concat(c1).concat(a2).concat(r1, ":").concat(a3).concat(c2).concat(a4).concat(r2).length,
75
+ range: {
76
+ startRowIndex: startRow,
77
+ endRowIndex: endRow,
78
+ startColumnIndex: startColumn,
79
+ endColumnIndex: endColumn,
80
+ },
81
+ absolute: [a1 === "$", a2 === "$", a3 === "$", a4 === "$"],
82
+ });
83
+ }
84
+ }
85
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
86
+ finally {
87
+ try {
88
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
89
+ }
90
+ finally { if (e_1) throw e_1.error; }
91
+ }
92
+ if (referenceCache.size >= MAX_REFERENCE_CACHE)
93
+ referenceCache.clear();
94
+ referenceCache.set(formula, references);
95
+ return references;
96
+ };
97
+ /**
98
+ * Excel's "Formulas which omit cells in a region" rule: a formula such as `=SUM(A3:A5)` whose
99
+ * one-column (or one-row) range stops next to more numbers in that column (row) — `A2` holds a
100
+ * number. The adjacent run of numbers on each end is what "Update Formula to Include Cells" adds;
101
+ * it never runs into the formula's own cell. `isNumber` says whether a cell holds a number typed as a
102
+ * value (not text, not a formula). `undefined` when the formula omits nothing.
103
+ */
104
+ var findOmittedAdjacentCells = function (formula, formulaCell, isNumber) {
105
+ var e_2, _a;
106
+ if (!formula)
107
+ return undefined;
108
+ var _loop_1 = function (reference) {
109
+ var range = reference.range;
110
+ var vertical = range.startColumnIndex === range.endColumnIndex;
111
+ var at = function (index) {
112
+ return vertical
113
+ ? { rowIndex: index, columnIndex: range.startColumnIndex }
114
+ : { rowIndex: range.startRowIndex, columnIndex: index };
115
+ };
116
+ var usable = function (index) {
117
+ if (index < 1)
118
+ return false;
119
+ var cell = at(index);
120
+ if (cell.rowIndex === formulaCell.rowIndex &&
121
+ cell.columnIndex === formulaCell.columnIndex) {
122
+ return false;
123
+ }
124
+ return isNumber(cell.rowIndex, cell.columnIndex);
125
+ };
126
+ var first = vertical ? range.startRowIndex : range.startColumnIndex;
127
+ var last = vertical ? range.endRowIndex : range.endColumnIndex;
128
+ var newFirst = first;
129
+ while (usable(newFirst - 1))
130
+ newFirst--;
131
+ var newLast = last;
132
+ // A range of one cell has no direction to grow along beyond its own.
133
+ while (first !== last && usable(newLast + 1))
134
+ newLast++;
135
+ if (newFirst === first && newLast === last)
136
+ return "continue";
137
+ var expandedRange = vertical
138
+ ? tslib_1.__assign(tslib_1.__assign({}, range), { startRowIndex: newFirst, endRowIndex: newLast }) : tslib_1.__assign(tslib_1.__assign({}, range), { startColumnIndex: newFirst, endColumnIndex: newLast });
139
+ var _d = tslib_1.__read(reference.absolute.map(function (flag) { return (flag ? "$" : ""); }), 4), c1 = _d[0], r1 = _d[1], c2 = _d[2], r2 = _d[3];
140
+ var text = "".concat(c1).concat(columnLetters(expandedRange.startColumnIndex)).concat(r1).concat(expandedRange.startRowIndex, ":") +
141
+ "".concat(c2).concat(columnLetters(expandedRange.endColumnIndex)).concat(r2).concat(expandedRange.endRowIndex);
142
+ return { value: {
143
+ range: range,
144
+ expandedRange: expandedRange,
145
+ updatedFormula: formula.slice(0, reference.start) + text + formula.slice(reference.end),
146
+ } };
147
+ };
148
+ try {
149
+ for (var _b = tslib_1.__values(regionReferences(formula)), _c = _b.next(); !_c.done; _c = _b.next()) {
150
+ var reference = _c.value;
151
+ var state_1 = _loop_1(reference);
152
+ if (typeof state_1 === "object")
153
+ return state_1.value;
154
+ }
155
+ }
156
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
157
+ finally {
158
+ try {
159
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
160
+ }
161
+ finally { if (e_2) throw e_2.error; }
162
+ }
163
+ return undefined;
164
+ };
165
+ exports.findOmittedAdjacentCells = findOmittedAdjacentCells;
27
166
  /**
28
167
  * The text a cell's value is, or `undefined` when its value is not text: `ev.sv` when the cell has
29
168
  * an effective value (a number typed into a Text-formatted cell, or after an apostrophe, is text
@@ -42,10 +181,15 @@ var getCellText = function (userEnteredValue, effectiveValue) {
42
181
  */
43
182
  var getErrorCheckKind = function (_a) {
44
183
  var _b;
45
- var userEnteredValue = _a.userEnteredValue, effectiveValue = _a.effectiveValue, errorValue = _a.errorValue;
184
+ var userEnteredValue = _a.userEnteredValue, effectiveValue = _a.effectiveValue, errorValue = _a.errorValue, cell = _a.cell, isNumberAt = _a.isNumberAt;
46
185
  var formula = (_b = userEnteredValue === null || userEnteredValue === void 0 ? void 0 : userEnteredValue.fv) !== null && _b !== void 0 ? _b : userEnteredValue === null || userEnteredValue === void 0 ? void 0 : userEnteredValue.formulaValue;
47
186
  if (formula) {
48
- return (errorValue === null || errorValue === void 0 ? void 0 : errorValue.type) === "Error" ? "evalError" : undefined;
187
+ if ((errorValue === null || errorValue === void 0 ? void 0 : errorValue.type) === "Error")
188
+ return "evalError";
189
+ if (cell && isNumberAt && (0, exports.findOmittedAdjacentCells)(formula, cell, isNumberAt)) {
190
+ return "formulaRange";
191
+ }
192
+ return undefined;
49
193
  }
50
194
  var text = getCellText(userEnteredValue, effectiveValue);
51
195
  if ((0, exports.parseNumberStoredAsText)(text) !== undefined)
@@ -68,7 +212,9 @@ var ERROR_TITLES = {
68
212
  var getErrorCheckTitle = function (kind, errorName) {
69
213
  return kind === "numberStoredAsText"
70
214
  ? "Number Stored as Text"
71
- : (errorName && ERROR_TITLES[errorName]) || "Error in Formula";
215
+ : kind === "formulaRange"
216
+ ? "Formula Omits Adjacent Cells"
217
+ : (errorName && ERROR_TITLES[errorName]) || "Error in Formula";
72
218
  };
73
219
  exports.getErrorCheckTitle = getErrorCheckTitle;
74
220
  /** Excel's own help pages: hiding error values and error indicators, and the rule options. */
@@ -114,7 +260,7 @@ exports.appendIgnoredError = appendIgnoredError;
114
260
  * only the used rows.
115
261
  */
116
262
  var collectNumberStoredAsTextRuns = function (ranges, getUserEnteredValue, maxRow, maxColumn, getEffectiveValue) {
117
- var e_1, _a;
263
+ var e_3, _a;
118
264
  var runs = [];
119
265
  var seen = new Set();
120
266
  try {
@@ -150,12 +296,12 @@ var collectNumberStoredAsTextRuns = function (ranges, getUserEnteredValue, maxRo
150
296
  }
151
297
  }
152
298
  }
153
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
299
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
154
300
  finally {
155
301
  try {
156
302
  if (ranges_1_1 && !ranges_1_1.done && (_a = ranges_1.return)) _a.call(ranges_1);
157
303
  }
158
- finally { if (e_1) throw e_1.error; }
304
+ finally { if (e_3) throw e_3.error; }
159
305
  }
160
306
  return runs;
161
307
  };
@@ -168,7 +314,7 @@ exports.collectNumberStoredAsTextRuns = collectNumberStoredAsTextRuns;
168
314
  * sheet's `ignoredErrors` (persisted, xlsx `<ignoredErrors>`).
169
315
  */
170
316
  var runErrorCheckOption = function (option, context) {
171
- var _a, _b;
317
+ var _a, _b, _c, _d;
172
318
  var sheetId = context.sheetId, kind = context.kind, ranges = context.ranges;
173
319
  switch (option) {
174
320
  case "convertToNumber": {
@@ -176,7 +322,7 @@ var runErrorCheckOption = function (option, context) {
176
322
  if (!runs_1.length)
177
323
  return;
178
324
  var write = function () {
179
- var e_2, _a;
325
+ var e_4, _a;
180
326
  var _b;
181
327
  try {
182
328
  for (var runs_2 = tslib_1.__values(runs_1), runs_2_1 = runs_2.next(); !runs_2_1.done; runs_2_1 = runs_2.next()) {
@@ -189,12 +335,12 @@ var runErrorCheckOption = function (option, context) {
189
335
  }, [run.values]);
190
336
  }
191
337
  }
192
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
338
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
193
339
  finally {
194
340
  try {
195
341
  if (runs_2_1 && !runs_2_1.done && (_a = runs_2.return)) _a.call(runs_2);
196
342
  }
197
- finally { if (e_2) throw e_2.error; }
343
+ finally { if (e_4) throw e_4.error; }
198
344
  }
199
345
  };
200
346
  if (context.batchHistory)
@@ -203,9 +349,19 @@ var runErrorCheckOption = function (option, context) {
203
349
  write();
204
350
  return;
205
351
  }
352
+ case "updateFormulaToIncludeCells": {
353
+ var cell = context.activeCell;
354
+ if (!cell || !context.isNumberAt)
355
+ return;
356
+ var uev = context.getUserEnteredValue(cell.rowIndex, cell.columnIndex);
357
+ var omitted = (0, exports.findOmittedAdjacentCells)((_a = uev === null || uev === void 0 ? void 0 : uev.fv) !== null && _a !== void 0 ? _a : uev === null || uev === void 0 ? void 0 : uev.formulaValue, cell, context.isNumberAt);
358
+ if (omitted)
359
+ (_b = context.onChange) === null || _b === void 0 ? void 0 : _b.call(context, sheetId, cell, omitted.updatedFormula);
360
+ return;
361
+ }
206
362
  case "ignore":
207
- (_a = context.onUpdateSheet) === null || _a === void 0 ? void 0 : _a.call(context, sheetId, {
208
- ignoredErrors: (0, exports.appendIgnoredError)((_b = context.getIgnoredErrors) === null || _b === void 0 ? void 0 : _b.call(context, sheetId), ranges, kind),
363
+ (_c = context.onUpdateSheet) === null || _c === void 0 ? void 0 : _c.call(context, sheetId, {
364
+ ignoredErrors: (0, exports.appendIgnoredError)((_d = context.getIgnoredErrors) === null || _d === void 0 ? void 0 : _d.call(context, sheetId), ranges, kind),
209
365
  });
210
366
  return;
211
367
  case "editInFormulaBar":
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The number format a date, time or percentage cell shows in Excel's formula bar and cell editor:
3
+ * not the cell's display (`2-Jan`, which drops the year), but the whole value in the person's short
4
+ * date and long time, so the entry can be read and edited back to the same value.
5
+ *
6
+ * - a date: the short date (`1/2/2026` in en-US),
7
+ * - a time of day: the long time (`3:00:00 PM`),
8
+ * - a date with a time: both (`1/2/2026 3:00:00 PM`),
9
+ * - a percentage: the number times 100 with `%` (`12.5%`).
10
+ *
11
+ * `undefined` for any other cell: it edits as its number.
12
+ */
13
+ export declare const excelEditValueOfNumber: (value: number, numberFormatType: string | null | undefined, locale?: string) => string | undefined;
14
+ /** The locale's short date as a number format (`m/d/yyyy` in en-US, `dd.mm.yyyy` in de-DE). */
15
+ export declare const shortDatePattern: (locale?: string) => string;
16
+ /** The locale's long time as a number format (`h:mm:ss AM/PM` in en-US, `h:mm:ss` in de-DE). */
17
+ export declare const longTimePattern: (locale?: string) => string;
18
+ //# sourceMappingURL=excel-edit-value.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"excel-edit-value.d.ts","sourceRoot":"","sources":["../../../api/excel-edit-value.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,GACjC,OAAO,MAAM,EACb,kBAAkB,MAAM,GAAG,IAAI,GAAG,SAAS,EAC3C,SAAS,MAAM,KACd,MAAM,GAAG,SA4BX,CAAC;AAIF,+FAA+F;AAC/F,eAAO,MAAM,gBAAgB,GAAI,eAAgB,KAAG,MA+BnD,CAAC;AAEF,gGAAgG;AAChG,eAAO,MAAM,eAAe,GAAI,eAAgB,KAAG,MAQlD,CAAC"}
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.longTimePattern = exports.shortDatePattern = exports.excelEditValueOfNumber = void 0;
4
+ var utils_1 = require("@rowsncolumns/utils");
5
+ /**
6
+ * The number format a date, time or percentage cell shows in Excel's formula bar and cell editor:
7
+ * not the cell's display (`2-Jan`, which drops the year), but the whole value in the person's short
8
+ * date and long time, so the entry can be read and edited back to the same value.
9
+ *
10
+ * - a date: the short date (`1/2/2026` in en-US),
11
+ * - a time of day: the long time (`3:00:00 PM`),
12
+ * - a date with a time: both (`1/2/2026 3:00:00 PM`),
13
+ * - a percentage: the number times 100 with `%` (`12.5%`).
14
+ *
15
+ * `undefined` for any other cell: it edits as its number.
16
+ */
17
+ var excelEditValueOfNumber = function (value, numberFormatType, locale) {
18
+ if (!Number.isFinite(value))
19
+ return undefined;
20
+ if (numberFormatType === "PERCENT") {
21
+ return "".concat(Number((value * 100).toPrecision(15)), "%");
22
+ }
23
+ if (numberFormatType !== "DATE" &&
24
+ numberFormatType !== "DATE_TIME" &&
25
+ numberFormatType !== "TIME") {
26
+ return undefined;
27
+ }
28
+ // Before Excel's day 0 a date has no spelling: it edits as its number, as in Excel.
29
+ if (value < 0)
30
+ return undefined;
31
+ var day = Math.floor(value);
32
+ var hasTime = value - day > 0 || numberFormatType === "TIME";
33
+ var pattern = day === 0 && numberFormatType !== "DATE"
34
+ ? (0, exports.longTimePattern)(locale)
35
+ : hasTime
36
+ ? "".concat((0, exports.shortDatePattern)(locale), " ").concat((0, exports.longTimePattern)(locale))
37
+ : (0, exports.shortDatePattern)(locale);
38
+ try {
39
+ var formatted = (0, utils_1.ssfFormat)(pattern, value, locale);
40
+ return typeof formatted === "string" && formatted !== "" ? formatted : undefined;
41
+ }
42
+ catch (_a) {
43
+ return undefined;
44
+ }
45
+ };
46
+ exports.excelEditValueOfNumber = excelEditValueOfNumber;
47
+ var shortDateCache = new Map();
48
+ /** The locale's short date as a number format (`m/d/yyyy` in en-US, `dd.mm.yyyy` in de-DE). */
49
+ var shortDatePattern = function (locale) {
50
+ if (locale === void 0) { locale = "en-US"; }
51
+ var cached = shortDateCache.get(locale);
52
+ if (cached)
53
+ return cached;
54
+ var pattern = "m/d/yyyy";
55
+ try {
56
+ var parts = new Intl.DateTimeFormat(locale, {
57
+ year: "numeric",
58
+ month: "numeric",
59
+ day: "numeric",
60
+ }).formatToParts(new Date(2026, 0, 2));
61
+ var tokens = parts.map(function (part) {
62
+ switch (part.type) {
63
+ case "year":
64
+ return "yyyy";
65
+ case "month":
66
+ return part.value.length > 1 ? "mm" : "m";
67
+ case "day":
68
+ return part.value.length > 1 ? "dd" : "d";
69
+ case "literal":
70
+ return part.value.replace(/[^\s./,-]/g, "");
71
+ default:
72
+ return "";
73
+ }
74
+ });
75
+ var built = tokens.join("").trim();
76
+ if (/y/.test(built) && /m/.test(built) && /d/.test(built))
77
+ pattern = built;
78
+ }
79
+ catch (_a) {
80
+ // An unknown locale keeps the en-US short date.
81
+ }
82
+ shortDateCache.set(locale, pattern);
83
+ return pattern;
84
+ };
85
+ exports.shortDatePattern = shortDatePattern;
86
+ /** The locale's long time as a number format (`h:mm:ss AM/PM` in en-US, `h:mm:ss` in de-DE). */
87
+ var longTimePattern = function (locale) {
88
+ if (locale === void 0) { locale = "en-US"; }
89
+ try {
90
+ var hour12 = new Intl.DateTimeFormat(locale, { hour: "numeric" }).resolvedOptions()
91
+ .hour12;
92
+ return hour12 === false ? "h:mm:ss" : "h:mm:ss AM/PM";
93
+ }
94
+ catch (_a) {
95
+ return "h:mm:ss AM/PM";
96
+ }
97
+ };
98
+ exports.longTimePattern = longTimePattern;
@@ -0,0 +1,19 @@
1
+ import type { CellInterface } from "@rowsncolumns/common-types";
2
+ import type { SplitPane } from "../types";
3
+ /** Twentieths of a point per CSS pixel (96 px = 72 pt = 1440 twips). */
4
+ export declare const TWIPS_PER_PIXEL = 15;
5
+ /**
6
+ * Excel's View ▸ Split at the active cell: the window splits above and left of it, so the cell
7
+ * starts the bottom-right pane. A cell in the first visible row splits only vertically (left /
8
+ * right), one in the first visible column only horizontally (top / bottom), and the first visible
9
+ * cell itself splits the window into four panes at its middle, as Excel does. `getColumnWidth` /
10
+ * `getRowHeight` are the on-screen sizes in px (at 100% zoom); `firstVisible` is the top-left
11
+ * cell of the scrolled window. Returns `undefined` when there is nothing to split.
12
+ */
13
+ export declare const splitPaneAtCell: (activeCell: CellInterface, firstVisible: CellInterface, getColumnWidth: (columnIndex: number) => number, getRowHeight: (rowIndex: number) => number) => SplitPane | undefined;
14
+ /** A split's positions in CSS px from the grid's top-left (`undefined` = no split on that axis). */
15
+ export declare const splitPanePixels: (pane: SplitPane | null | undefined) => {
16
+ x?: number;
17
+ y?: number;
18
+ };
19
+ //# sourceMappingURL=split-pane.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"split-pane.d.ts","sourceRoot":"","sources":["../../../api/split-pane.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,wEAAwE;AACxE,eAAO,MAAM,eAAe,KAAK,CAAC;AAUlC;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAC1B,YAAY,aAAa,EACzB,cAAc,aAAa,EAC3B,gBAAgB,CAAC,WAAW,EAAE,MAAM,KAAK,MAAM,EAC/C,cAAc,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,KACzC,SAAS,GAAG,SAmCd,CAAC;AAEF,oGAAoG;AACpG,eAAO,MAAM,eAAe,GAC1B,MAAM,SAAS,GAAG,IAAI,GAAG,SAAS,KACjC;IAAE,CAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,CAAA;CAI1B,CAAC"}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.splitPanePixels = exports.splitPaneAtCell = exports.TWIPS_PER_PIXEL = void 0;
4
+ /** Twentieths of a point per CSS pixel (96 px = 72 pt = 1440 twips). */
5
+ exports.TWIPS_PER_PIXEL = 15;
6
+ var columnLetters = function (column) {
7
+ var letters = "";
8
+ for (var n = column; n > 0; n = Math.floor((n - 1) / 26)) {
9
+ letters = String.fromCharCode(65 + ((n - 1) % 26)) + letters;
10
+ }
11
+ return letters;
12
+ };
13
+ /**
14
+ * Excel's View ▸ Split at the active cell: the window splits above and left of it, so the cell
15
+ * starts the bottom-right pane. A cell in the first visible row splits only vertically (left /
16
+ * right), one in the first visible column only horizontally (top / bottom), and the first visible
17
+ * cell itself splits the window into four panes at its middle, as Excel does. `getColumnWidth` /
18
+ * `getRowHeight` are the on-screen sizes in px (at 100% zoom); `firstVisible` is the top-left
19
+ * cell of the scrolled window. Returns `undefined` when there is nothing to split.
20
+ */
21
+ var splitPaneAtCell = function (activeCell, firstVisible, getColumnWidth, getRowHeight) {
22
+ var rowIndex = activeCell.rowIndex, columnIndex = activeCell.columnIndex;
23
+ if (rowIndex <= firstVisible.rowIndex && columnIndex <= firstVisible.columnIndex) {
24
+ // Excel splits the window at the middle when the active cell is its first cell.
25
+ var width_1 = 0;
26
+ var column = firstVisible.columnIndex;
27
+ var height_1 = 0;
28
+ var row = firstVisible.rowIndex;
29
+ // Half a default window: 10 columns and 20 rows.
30
+ for (var i = 0; i < 5; i++)
31
+ width_1 += getColumnWidth(column++);
32
+ for (var i = 0; i < 10; i++)
33
+ height_1 += getRowHeight(row++);
34
+ return {
35
+ xSplit: Math.round(width_1 * exports.TWIPS_PER_PIXEL),
36
+ ySplit: Math.round(height_1 * exports.TWIPS_PER_PIXEL),
37
+ topLeftCell: "".concat(columnLetters(column)).concat(row),
38
+ activePane: "bottomRight",
39
+ };
40
+ }
41
+ var width = 0;
42
+ for (var column = firstVisible.columnIndex; column < columnIndex; column++) {
43
+ width += getColumnWidth(column);
44
+ }
45
+ var height = 0;
46
+ for (var row = firstVisible.rowIndex; row < rowIndex; row++) {
47
+ height += getRowHeight(row);
48
+ }
49
+ if (width <= 0 && height <= 0)
50
+ return undefined;
51
+ var pane = {
52
+ topLeftCell: "".concat(columnLetters(Math.max(columnIndex, 1))).concat(Math.max(rowIndex, 1)),
53
+ };
54
+ if (width > 0)
55
+ pane.xSplit = Math.round(width * exports.TWIPS_PER_PIXEL);
56
+ if (height > 0)
57
+ pane.ySplit = Math.round(height * exports.TWIPS_PER_PIXEL);
58
+ pane.activePane =
59
+ width > 0 && height > 0 ? "bottomRight" : width > 0 ? "topRight" : "bottomLeft";
60
+ return pane;
61
+ };
62
+ exports.splitPaneAtCell = splitPaneAtCell;
63
+ /** A split's positions in CSS px from the grid's top-left (`undefined` = no split on that axis). */
64
+ var splitPanePixels = function (pane) {
65
+ var px = function (twips) {
66
+ return typeof twips === "number" && twips > 0 ? twips / exports.TWIPS_PER_PIXEL : undefined;
67
+ };
68
+ return { x: px(pane === null || pane === void 0 ? void 0 : pane.xSplit), y: px(pane === null || pane === void 0 ? void 0 : pane.ySplit) };
69
+ };
70
+ exports.splitPanePixels = splitPanePixels;
@@ -1 +1 @@
1
- {"version":3,"file":"cell-input-context.atom.d.ts","sourceRoot":"","sources":["../../../atoms/cell-input-context.atom.ts"],"names":[],"mappings":"AAoCA,eAAO,MAAM,mBAAmB;;;;oBAC+4uF,CAAC;qBAAwB,CAAC;;;;;;;;;;;CAD13uF,CAAC"}
1
+ {"version":3,"file":"cell-input-context.atom.d.ts","sourceRoot":"","sources":["../../../atoms/cell-input-context.atom.ts"],"names":[],"mappings":"AAoCA,eAAO,MAAM,mBAAmB;;;;oBAC+9xF,CAAC;qBAAwB,CAAC;;;;;;;;;;;CAD18xF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/canvas-grid/index.tsx"],"names":[],"mappings":"AAmEA,OAAO,KASN,MAAM,OAAO,CAAC;AAuQf,OAAO,KAAK,EAGV,QAAQ,EAYT,MAAM,aAAa,CAAC;AA4CrB,OAAO,KAAK,EACV,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EAEhB,MAAM,WAAW,CAAC;AAgkOnB,eAAO,MAAM,UAAU,EAA4C,CACjE,CAAC,SAAS,QAAQ,CAAC,GAAG,CAAC,EAEvB,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,GACvB,wBAAwB,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;CAAE,KAChE,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/canvas-grid/index.tsx"],"names":[],"mappings":"AAmEA,OAAO,KASN,MAAM,OAAO,CAAC;AAwQf,OAAO,KAAK,EAGV,QAAQ,EAYT,MAAM,aAAa,CAAC;AA4CrB,OAAO,KAAK,EACV,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EAEhB,MAAM,WAAW,CAAC;AAsoOnB,eAAO,MAAM,UAAU,EAA4C,CACjE,CAAC,SAAS,QAAQ,CAAC,GAAG,CAAC,EAEvB,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,GACvB,wBAAwB,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;CAAE,KAChE,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC"}