@nubisco/ui 5.59.1 → 5.60.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.
Files changed (79) hide show
  1. package/dist/{Blueprint-CQxC02e5.cjs → Blueprint-B1vqK1QL.cjs} +1 -1
  2. package/dist/{Blueprint-Dnliv-77.js → Blueprint-CRTuGw8u.js} +1 -1
  3. package/dist/Spreadsheet-DD0OS-sF.cjs +4 -0
  4. package/dist/Spreadsheet-DN8_9s4Q.js +2215 -0
  5. package/dist/all.cjs +1 -1
  6. package/dist/all.mjs +15 -14
  7. package/dist/components/Blueprint.cjs +1 -1
  8. package/dist/components/Blueprint.mjs +1 -1
  9. package/dist/components/Spreadsheet.cjs +1 -1
  10. package/dist/components/Spreadsheet.d.ts +98 -2
  11. package/dist/components/Spreadsheet.mjs +1 -1
  12. package/dist/components/Spreadsheet.vue.d.ts +23 -2
  13. package/dist/components/Spreadsheet.vue.d.ts.map +1 -1
  14. package/dist/components/spreadsheet/sheetLook.d.ts +39 -0
  15. package/dist/components/spreadsheet/sheetLook.d.ts.map +1 -0
  16. package/dist/composables/useNbStrings.composable.cjs +1 -1
  17. package/dist/composables/useNbStrings.composable.d.ts +6 -0
  18. package/dist/composables/useNbStrings.composable.d.ts.map +1 -1
  19. package/dist/composables/useNbStrings.composable.mjs +4 -0
  20. package/dist/formula/criteria.d.ts +15 -0
  21. package/dist/formula/criteria.d.ts.map +1 -0
  22. package/dist/formula/evaluator.d.ts +11 -0
  23. package/dist/formula/evaluator.d.ts.map +1 -0
  24. package/dist/formula/functions/define.d.ts +16 -0
  25. package/dist/formula/functions/define.d.ts.map +1 -0
  26. package/dist/formula/functions/index.d.ts +9 -0
  27. package/dist/formula/functions/index.d.ts.map +1 -0
  28. package/dist/formula/functions/information.d.ts +3 -0
  29. package/dist/formula/functions/information.d.ts.map +1 -0
  30. package/dist/formula/functions/logical.d.ts +3 -0
  31. package/dist/formula/functions/logical.d.ts.map +1 -0
  32. package/dist/formula/functions/lookup.d.ts +3 -0
  33. package/dist/formula/functions/lookup.d.ts.map +1 -0
  34. package/dist/formula/functions/math.d.ts +13 -0
  35. package/dist/formula/functions/math.d.ts.map +1 -0
  36. package/dist/formula/functions/statistical.d.ts +3 -0
  37. package/dist/formula/functions/statistical.d.ts.map +1 -0
  38. package/dist/formula/functions/text.d.ts +3 -0
  39. package/dist/formula/functions/text.d.ts.map +1 -0
  40. package/dist/formula/index.cjs +1 -0
  41. package/dist/formula/index.d.ts +13 -0
  42. package/dist/formula/index.d.ts.map +1 -0
  43. package/dist/formula/index.mjs +2 -0
  44. package/dist/formula/parser.d.ts +10 -0
  45. package/dist/formula/parser.d.ts.map +1 -0
  46. package/dist/formula/references.d.ts +14 -0
  47. package/dist/formula/references.d.ts.map +1 -0
  48. package/dist/formula/refs.d.ts +20 -0
  49. package/dist/formula/refs.d.ts.map +1 -0
  50. package/dist/formula/sheet.d.ts +10 -0
  51. package/dist/formula/sheet.d.ts.map +1 -0
  52. package/dist/formula/syntax.d.ts +14 -0
  53. package/dist/formula/syntax.d.ts.map +1 -0
  54. package/dist/formula/tokenizer.d.ts +11 -0
  55. package/dist/formula/tokenizer.d.ts.map +1 -0
  56. package/dist/formula/types.d.ts +150 -0
  57. package/dist/formula/types.d.ts.map +1 -0
  58. package/dist/formula/values.d.ts +46 -0
  59. package/dist/formula/values.d.ts.map +1 -0
  60. package/dist/formula-Bic1LaPK.js +1969 -0
  61. package/dist/formula-CoCixvl3.cjs +1 -0
  62. package/dist/index.cjs +1 -1
  63. package/dist/index.mjs +9 -8
  64. package/dist/{main-I6bzKhGk.cjs → main-vJqUlyCN.cjs} +1 -1
  65. package/dist/{main-zCF9LQQU.js → main-wtHGDDYS.js} +1 -1
  66. package/dist/main.d.ts +2 -1
  67. package/dist/main.d.ts.map +1 -1
  68. package/dist/styles/Spreadsheet.css +1 -1
  69. package/dist/ui.css +1 -1
  70. package/dist/utils/csv.helper.cjs +5 -0
  71. package/dist/utils/csv.helper.d.ts +22 -0
  72. package/dist/utils/csv.helper.d.ts.map +1 -0
  73. package/dist/utils/csv.helper.mjs +46 -0
  74. package/package.json +7 -1
  75. package/src/utils/csv.helper.ts +96 -0
  76. package/dist/Spreadsheet-BwGhq9vm.cjs +0 -4
  77. package/dist/Spreadsheet-C9MeO5MD.js +0 -1455
  78. /package/dist/{pixi-scene-D1jzgzHL.js → pixi-scene-CShpsLDx.js} +0 -0
  79. /package/dist/{pixi-scene-BGTSD1-G.cjs → pixi-scene-OJo1IXN4.cjs} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"information.d.ts","sourceRoot":"","sources":["../../../src/formula/functions/information.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAanD,eAAO,MAAM,qBAAqB,EAAE,mBAAmB,EAgEtD,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { IFunctionDefinition } from './define';
2
+ export declare const LOGICAL_FUNCTIONS: IFunctionDefinition[];
3
+ //# sourceMappingURL=logical.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logical.d.ts","sourceRoot":"","sources":["../../../src/formula/functions/logical.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AA+CnD,eAAO,MAAM,iBAAiB,EAAE,mBAAmB,EAqJlD,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { type IFunctionDefinition } from './define';
2
+ export declare const LOOKUP_FUNCTIONS: IFunctionDefinition[];
3
+ //# sourceMappingURL=lookup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../../../src/formula/functions/lookup.ts"],"names":[],"mappings":"AAaA,OAAO,EAAc,KAAK,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAkH/D,eAAO,MAAM,gBAAgB,EAAE,mBAAmB,EAwMjD,CAAA"}
@@ -0,0 +1,13 @@
1
+ import type { IFormulaError, TValue } from '../types';
2
+ import { type IFunctionDefinition } from './define';
3
+ /** The criteria pairs of SUMIFS, AVERAGEIFS and COUNTIFS, as a per-cell test. */
4
+ export declare function criteriaPairs(args: TValue[], shape?: {
5
+ rows: number;
6
+ cols: number;
7
+ }): ((r: number, c: number) => boolean) | IFormulaError;
8
+ /** The numbers of a range where a test passes. Errors in matching cells win. */
9
+ export declare function matchingNumbers(values: TValue, passes: (r: number, c: number) => boolean, rows: number, cols: number): number[] | IFormulaError;
10
+ export declare function sumIf(args: TValue[]): number[] | IFormulaError;
11
+ export declare function sumIfs(args: TValue[]): number[] | IFormulaError;
12
+ export declare const MATH_FUNCTIONS: IFunctionDefinition[];
13
+ //# sourceMappingURL=math.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../../src/formula/functions/math.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAoB,MAAM,EAAE,MAAM,UAAU,CAAA;AASvE,OAAO,EAAuB,KAAK,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAuBxE,iFAAiF;AACjF,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EAAE,EACd,KAAK,CAAC,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACrC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,aAAa,CAmBrD;AAED,gFAAgF;AAChF,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,OAAO,EACzC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,MAAM,EAAE,GAAG,aAAa,CAY1B;AAID,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,aAAa,CAU9D;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,aAAa,CAK/D;AAwBD,eAAO,MAAM,cAAc,EAAE,mBAAmB,EAmT/C,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { type IFunctionDefinition } from './define';
2
+ export declare const STATISTICAL_FUNCTIONS: IFunctionDefinition[];
3
+ //# sourceMappingURL=statistical.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statistical.d.ts","sourceRoot":"","sources":["../../../src/formula/functions/statistical.ts"],"names":[],"mappings":"AAYA,OAAO,EAAc,KAAK,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAwC/D,eAAO,MAAM,qBAAqB,EAAE,mBAAmB,EAmNtD,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { type IFunctionDefinition } from './define';
2
+ export declare const TEXT_FUNCTIONS: IFunctionDefinition[];
3
+ //# sourceMappingURL=text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/formula/functions/text.ts"],"names":[],"mappings":"AAeA,OAAO,EAAc,KAAK,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAyE/D,eAAO,MAAM,cAAc,EAAE,mBAAmB,EAgR/C,CAAA"}
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../formula-CoCixvl3.cjs`);exports.CANONICAL_SYNTAX=e.d,exports.FORMULA_FUNCTIONS=e.n,exports.columnLetters=e.p,exports.createFormulaSheet=e.t,exports.findFunctions=e.r,exports.formatRef=e.m,exports.isFormula=e.l,exports.isFormulaError=e.u,exports.lettersToColumn=e.h,exports.parseRef=e._,exports.referencesIn=e.i,exports.shiftFormula=e.a,exports.syntaxForLocale=e.o,exports.toCanonical=e.s,exports.toLocalized=e.c,exports.tokenize=e.f;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * A spreadsheet formula engine with no dependencies, used by the sheet mode
3
+ * of NbSpreadsheet and available on its own as `@nubisco/ui/formula`.
4
+ */
5
+ export type { IFormulaError, IFormulaFunction, IFormulaRange, IFormulaReference, IFormulaSheet, IFormulaSyntax, IFormulaToken, TFormulaCategory, TFormulaCells, TFormulaCellValue, TFormulaErrorCode, TFormulaTokenType, TFormulaValue, } from './types';
6
+ export { isFormula, isFormulaError } from './values';
7
+ export { CANONICAL_SYNTAX, syntaxForLocale, toCanonical, toLocalized, } from './syntax';
8
+ export { tokenize } from './tokenizer';
9
+ export { columnLetters, formatRef, lettersToColumn, parseRef } from './refs';
10
+ export { referencesIn, shiftFormula } from './references';
11
+ export { FORMULA_FUNCTIONS, findFunctions } from './functions';
12
+ export { createFormulaSheet } from './sheet';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/formula/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,GACd,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AACpD,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,WAAW,GACZ,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAC5E,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AACzD,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA"}
@@ -0,0 +1,2 @@
1
+ import { _ as e, a as t, c as n, d as r, f as i, h as a, i as o, l as s, m as c, n as l, o as u, p as d, r as f, s as p, t as m, u as h } from "../formula-Bic1LaPK.js";
2
+ export { r as CANONICAL_SYNTAX, l as FORMULA_FUNCTIONS, d as columnLetters, m as createFormulaSheet, f as findFunctions, c as formatRef, s as isFormula, h as isFormulaError, a as lettersToColumn, e as parseRef, o as referencesIn, t as shiftFormula, u as syntaxForLocale, p as toCanonical, n as toLocalized, i as tokenize };
@@ -0,0 +1,10 @@
1
+ import type { IFormulaSyntax, TAstNode } from './types';
2
+ /**
3
+ * Parses a formula (with or without its leading '=') into a tree. It never
4
+ * throws: a formula that cannot be read becomes a single #ERROR! node, which
5
+ * evaluates to that error with a message saying what went wrong.
6
+ */
7
+ export declare function parseFormula(formula: string, syntax?: IFormulaSyntax): TAstNode;
8
+ /** Every reference and range a formula reads, for the dependency graph. */
9
+ export declare function collectReferences(node: TAstNode, into?: TAstNode[]): TAstNode[];
10
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/formula/parser.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,cAAc,EAEd,QAAQ,EAET,MAAM,SAAS,CAAA;AAyBhB;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,MAAM,GAAE,cAAiC,GACxC,QAAQ,CA8KV;AAED,2EAA2E;AAC3E,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,QAAQ,EACd,IAAI,GAAE,QAAQ,EAAO,GACpB,QAAQ,EAAE,CAuBZ"}
@@ -0,0 +1,14 @@
1
+ import type { IFormulaReference, IFormulaSyntax } from './types';
2
+ /**
3
+ * The references and ranges in a formula with their positions in the given
4
+ * text, so an editor can colour each one and outline the cells it points at.
5
+ */
6
+ export declare function referencesIn(formula: string, syntax?: IFormulaSyntax): IFormulaReference[];
7
+ /**
8
+ * Moves the relative references of a formula by an offset, for fill and for
9
+ * copy and paste. '$'-absolute columns and rows stay where they are. A
10
+ * reference pushed above row 1 or left of column A becomes #REF!. Everything
11
+ * else in the text is kept as it was, whitespace included.
12
+ */
13
+ export declare function shiftFormula(formula: string, rows: number, cols: number): string;
14
+ //# sourceMappingURL=references.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../../src/formula/references.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAEhE;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,MAAM,GAAE,cAAiC,GACxC,iBAAiB,EAAE,CAwBrB;AA8DD;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,MAAM,CASR"}
@@ -0,0 +1,20 @@
1
+ import type { IFormulaRange } from './types';
2
+ /** 0 -> 'A', 25 -> 'Z', 26 -> 'AA'. */
3
+ export declare function columnLetters(col: number): string;
4
+ /** 'A' -> 0, 'AA' -> 26. Case-insensitive. Returns -1 for anything that is not letters. */
5
+ export declare function lettersToColumn(letters: string): number;
6
+ /** 'B3' -> { row: 2, col: 1 }, 0-based. Accepts '$' markers and lowercase. */
7
+ export declare function parseRef(ref: string): {
8
+ row: number;
9
+ col: number;
10
+ } | null;
11
+ /** { row: 2, col: 1 } -> 'B3'. Never writes '$' markers. */
12
+ export declare function formatRef(row: number, col: number): string;
13
+ /**
14
+ * Reads the text of a range token ('A1:B2', 'A:B', '1:3', with optional
15
+ * '$') into a normalised rectangle. Whole columns and whole rows run to
16
+ * Infinity on their open side.
17
+ */
18
+ export declare function parseRangeText(text: string): IFormulaRange | null;
19
+ export declare function normaliseRange(r1: number, c1: number, r2: number, c2: number): IFormulaRange;
20
+ //# sourceMappingURL=refs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refs.d.ts","sourceRoot":"","sources":["../../src/formula/refs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE5C,uCAAuC;AACvC,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CASjD;AAED,2FAA2F;AAC3F,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAMvD;AAID,8EAA8E;AAC9E,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAIzE;AAED,4DAA4D;AAC5D,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAyBjE;AAED,wBAAgB,cAAc,CAC5B,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,GACT,aAAa,CAOf"}
@@ -0,0 +1,10 @@
1
+ import type { IFormulaSheet } from './types';
2
+ /**
3
+ * Evaluates the formulas of a sheet. Each compute() builds the dependency
4
+ * graph from the references the formulas read, finds the cycles in it, and
5
+ * evaluates the cells in dependency order. Evaluating in that order means a
6
+ * cell never waits on another through the call stack, so a chain of
7
+ * thousands of cells is as safe as a short one.
8
+ */
9
+ export declare function createFormulaSheet(): IFormulaSheet;
10
+ //# sourceMappingURL=sheet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sheet.d.ts","sourceRoot":"","sources":["../../src/formula/sheet.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,aAAa,EAMd,MAAM,SAAS,CAAA;AAsChB;;;;;;GAMG;AACH,wBAAgB,kBAAkB,IAAI,aAAa,CAsIlD"}
@@ -0,0 +1,14 @@
1
+ import { CANONICAL_SYNTAX } from './tokenizer';
2
+ import type { IFormulaSyntax } from './types';
3
+ export { CANONICAL_SYNTAX };
4
+ /**
5
+ * The syntax people in a locale expect. Where the decimal mark is a comma,
6
+ * the comma cannot also separate arguments, so the separator becomes ';'
7
+ * (as Excel and Google Sheets do in those locales).
8
+ */
9
+ export declare function syntaxForLocale(locale?: string): IFormulaSyntax;
10
+ /** What a person typed in their locale's syntax, as the text to store. */
11
+ export declare function toCanonical(formula: string, from: IFormulaSyntax): string;
12
+ /** Stored formula text, as the editor shows it in a locale's syntax. */
13
+ export declare function toLocalized(formula: string, to: IFormulaSyntax): string;
14
+ //# sourceMappingURL=syntax.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syntax.d.ts","sourceRoot":"","sources":["../../src/formula/syntax.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAY,MAAM,aAAa,CAAA;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,EAAE,gBAAgB,EAAE,CAAA;AAE3B;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,cAAc,CAS/D;AAmBD,0EAA0E;AAC1E,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,MAAM,CAEzE;AAED,wEAAwE;AACxE,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,cAAc,GAAG,MAAM,CAEvE"}
@@ -0,0 +1,11 @@
1
+ import type { IFormulaSyntax, IFormulaToken } from './types';
2
+ /** How formulas are stored: English function names, '.' decimal, ',' between arguments. */
3
+ export declare const CANONICAL_SYNTAX: IFormulaSyntax;
4
+ export declare const ERROR_LITERALS: readonly ["#DIV/0!", "#VALUE!", "#REF!", "#NAME?", "#N/A", "#NUM!", "#NULL!", "#ERROR!"];
5
+ /**
6
+ * Splits a formula into tokens. It never throws: anything it cannot read
7
+ * becomes an 'invalid' token, so the concatenated token texts are always
8
+ * the input, which is what highlighting and the locale round trip rely on.
9
+ */
10
+ export declare function tokenize(formula: string, syntax?: IFormulaSyntax): IFormulaToken[];
11
+ //# sourceMappingURL=tokenizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenizer.d.ts","sourceRoot":"","sources":["../../src/formula/tokenizer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAqB,MAAM,SAAS,CAAA;AAE/E,2FAA2F;AAC3F,eAAO,MAAM,gBAAgB,EAAE,cAGX,CAAA;AAEpB,eAAO,MAAM,cAAc,0FASjB,CAAA;AA0CV;;;;GAIG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,MAAM,EACf,MAAM,GAAE,cAAiC,GACxC,aAAa,EAAE,CAsEjB"}
@@ -0,0 +1,150 @@
1
+ /** The error codes a formula can produce, the same set Excel and Google Sheets show. */
2
+ export type TFormulaErrorCode = '#DIV/0!' | '#VALUE!' | '#REF!' | '#NAME?' | '#N/A' | '#NUM!' | '#NULL!' | '#ERROR!';
3
+ /**
4
+ * An error value. The code is what a cell shows, the message is a short
5
+ * English sentence for a tooltip, such as 'Circular reference'.
6
+ */
7
+ export interface IFormulaError {
8
+ error: TFormulaErrorCode;
9
+ message: string;
10
+ }
11
+ /** What a formula evaluates to. */
12
+ export type TFormulaValue = number | string | boolean | null | IFormulaError;
13
+ /** What a cell in sheet mode holds: a literal, or a formula as a string starting with '='. */
14
+ export type TFormulaCellValue = string | number | boolean | null;
15
+ /** A sheet's cells keyed by A1-style references ('A1', 'B12', 'AA3'). */
16
+ export type TFormulaCells = Record<string, TFormulaCellValue>;
17
+ /**
18
+ * A rectangle of cells, 0-based and inclusive, always normalised so that
19
+ * r1 <= r2 and c1 <= c2. A whole-column range has r2 = Infinity and a
20
+ * whole-row range has c2 = Infinity.
21
+ */
22
+ export interface IFormulaRange {
23
+ r1: number;
24
+ c1: number;
25
+ r2: number;
26
+ c2: number;
27
+ }
28
+ /** The two locale-dependent parts of formula syntax. */
29
+ export interface IFormulaSyntax {
30
+ decimal: '.' | ',';
31
+ separator: ',' | ';';
32
+ }
33
+ export type TFormulaTokenType = 'number' | 'string' | 'boolean' | 'error' | 'reference' | 'range' | 'function' | 'name' | 'operator' | 'paren' | 'separator' | 'whitespace' | 'invalid';
34
+ /** One token of a formula, with its position in the text it came from. */
35
+ export interface IFormulaToken {
36
+ type: TFormulaTokenType;
37
+ text: string;
38
+ start: number;
39
+ end: number;
40
+ }
41
+ /** A reference or range found in a formula, with its position in the text. */
42
+ export interface IFormulaReference {
43
+ start: number;
44
+ end: number;
45
+ text: string;
46
+ range: IFormulaRange;
47
+ }
48
+ export type TFormulaCategory = 'math' | 'statistical' | 'logical' | 'text' | 'lookup' | 'information';
49
+ /** What autocomplete and the reference page know about a function. */
50
+ export interface IFormulaFunction {
51
+ name: string;
52
+ category: TFormulaCategory;
53
+ /** How the call is written, optional arguments in brackets, e.g. 'SUMIF(range, criterion, [sum_range])'. */
54
+ syntax: string;
55
+ /** One plain sentence. */
56
+ description: string;
57
+ minArgs: number;
58
+ /** Infinity for a function that takes any number of arguments. */
59
+ maxArgs: number;
60
+ }
61
+ export interface IFormulaSheet {
62
+ /**
63
+ * Computes every formula cell and returns ref -> value for the formula
64
+ * cells only. Parsed formulas are reused across calls, keyed by their text.
65
+ */
66
+ compute(cells: TFormulaCells): Map<string, TFormulaValue>;
67
+ /**
68
+ * Evaluates a canonical formula against the cells and results of the last
69
+ * compute(). References are the absolute positions as written. Meant for
70
+ * rules such as conditional formatting.
71
+ */
72
+ evaluate(formula: string): TFormulaValue;
73
+ /** How many parsed formulas the sheet is holding on to, for tests and diagnostics. */
74
+ readonly cacheSize: number;
75
+ }
76
+ /** A single value flowing through evaluation. */
77
+ export type TScalar = TFormulaValue;
78
+ /**
79
+ * A rectangle of values: a range read from the sheet, or an array produced
80
+ * by an operator over ranges. Range cells are read lazily, so a large range
81
+ * costs nothing until a function walks it.
82
+ */
83
+ export interface IMatrix {
84
+ kind: 'matrix';
85
+ rows: number;
86
+ cols: number;
87
+ get(row: number, col: number): TScalar;
88
+ /** Where a matrix read from the sheet starts, 0-based. ROW and COLUMN need it. */
89
+ origin?: {
90
+ row: number;
91
+ col: number;
92
+ };
93
+ }
94
+ export type TValue = TScalar | IMatrix;
95
+ /** What evaluation needs from the sheet around it. */
96
+ export interface IEvalContext {
97
+ cell(row: number, col: number): TScalar;
98
+ /** The used area of the sheet, which bounds whole-column and whole-row ranges. */
99
+ extent: {
100
+ rows: number;
101
+ cols: number;
102
+ };
103
+ /** The cell holding the formula, when there is one. */
104
+ at?: {
105
+ row: number;
106
+ col: number;
107
+ };
108
+ }
109
+ export type TAstNode = {
110
+ type: 'number';
111
+ value: number;
112
+ } | {
113
+ type: 'string';
114
+ value: string;
115
+ } | {
116
+ type: 'boolean';
117
+ value: boolean;
118
+ } | {
119
+ type: 'error';
120
+ error: IFormulaError;
121
+ } | {
122
+ type: 'ref';
123
+ row: number;
124
+ col: number;
125
+ } | {
126
+ type: 'range';
127
+ range: IFormulaRange;
128
+ } | {
129
+ type: 'name';
130
+ name: string;
131
+ } | {
132
+ type: 'missing';
133
+ } | {
134
+ type: 'call';
135
+ name: string;
136
+ args: TAstNode[];
137
+ } | {
138
+ type: 'unary';
139
+ op: '-' | '+';
140
+ operand: TAstNode;
141
+ } | {
142
+ type: 'percent';
143
+ operand: TAstNode;
144
+ } | {
145
+ type: 'binary';
146
+ op: string;
147
+ left: TAstNode;
148
+ right: TAstNode;
149
+ };
150
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/formula/types.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,MAAM,MAAM,iBAAiB,GACzB,SAAS,GACT,SAAS,GACT,O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AQ,CAAA;CAAE,CAAA"}
@@ -0,0 +1,46 @@
1
+ import type { IEvalContext, IFormulaError, IFormulaRange, IMatrix, TFormulaErrorCode, TScalar, TValue } from './types';
2
+ export declare function formulaError(code: TFormulaErrorCode, message?: string): IFormulaError;
3
+ /** True for a string starting with '=' that has something after it. */
4
+ export declare function isFormula(value: unknown): value is string;
5
+ export declare function isFormulaError(value: unknown): value is IFormulaError;
6
+ export declare function isMatrix(value: unknown): value is IMatrix;
7
+ export declare function arrayMatrix(rows: number, cols: number, data: TScalar[]): IMatrix;
8
+ /** A matrix over sheet cells. Open-ended ranges stop at the used area of the sheet. */
9
+ export declare function rangeMatrix(ctx: IEvalContext, range: IFormulaRange): IMatrix;
10
+ /** Any value as a matrix, so functions that take ranges also take a single value. */
11
+ export declare function asMatrix(value: TValue): IMatrix;
12
+ /** Visits every cell, row by row. Returning true from the visitor stops the walk. */
13
+ export declare function eachCell(matrix: IMatrix, visit: (value: TScalar, row: number, col: number) => boolean | void): void;
14
+ /**
15
+ * A value where one value is expected. A single cell is its value. A range
16
+ * of any other size is #VALUE!, since there is no implicit intersection.
17
+ */
18
+ export declare function scalar(value: TValue): TScalar;
19
+ /** Reads text that looks like a number ('3', ' -1.5 ', '2e3', '50%'), or null. */
20
+ export declare function parseNumericText(text: string): number | null;
21
+ export declare function toNumber(value: TScalar): number | IFormulaError;
22
+ /** Numbers as text the way a spreadsheet shows them: at most 15 significant digits. */
23
+ export declare function numberToText(value: number): string;
24
+ export declare function toText(value: TScalar): string | IFormulaError;
25
+ export declare function toBoolean(value: TScalar): boolean | IFormulaError;
26
+ export declare const numberArg: (value: TValue) => number | IFormulaError;
27
+ export declare const textArg: (value: TValue) => string | IFormulaError;
28
+ export declare const booleanArg: (value: TValue) => boolean | IFormulaError;
29
+ /** An optional number argument: absent or left empty means the default. */
30
+ export declare function optionalNumber(args: TValue[], index: number, fallback: number): number | IFormulaError;
31
+ /**
32
+ * Orders two non-error values as a spreadsheet does: numbers before text
33
+ * before booleans, text compared without regard to case. A blank takes the
34
+ * empty value of the other side's type.
35
+ */
36
+ export declare function compareValues(a: string | number | boolean | null, b: string | number | boolean | null): number;
37
+ /**
38
+ * Collects the numbers of aggregate arguments the way Excel does. Values
39
+ * read from ranges and references count only when they are numbers, so text
40
+ * and booleans there are skipped. Values written directly as arguments are
41
+ * converted, so TRUE counts as 1 and '3' as 3. Errors anywhere win.
42
+ */
43
+ export declare function collectNumbers(args: TValue[]): number[] | IFormulaError;
44
+ /** A non-finite number becomes #NUM!, since a cell cannot show Infinity or NaN. */
45
+ export declare function finite(value: TValue): TValue;
46
+ //# sourceMappingURL=values.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"values.d.ts","sourceRoot":"","sources":["../../src/formula/values.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,aAAa,EACb,OAAO,EACP,iBAAiB,EACjB,OAAO,EACP,MAAM,EACP,MAAM,SAAS,CAAA;AAahB,wBAAgB,YAAY,CAC1B,IAAI,EAAE,iBAAiB,EACvB,OAAO,CAAC,EAAE,MAAM,GACf,aAAa,CAEf;AAED,uEAAuE;AACvE,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAEzD;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CASrE;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAMzD;AAED,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EAAE,GACd,OAAO,CAOT;AAED,uFAAuF;AACvF,wBAAgB,WAAW,CAAC,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAW5E;AAED,qFAAqF;AACrF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE/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