@pixerate/editor 0.23.0 → 0.24.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 +96 -1
- package/THIRD_PARTY_NOTICES.md +51 -0
- package/dist/agent/index.cjs +9 -8
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +4 -3
- package/dist/agent/index.d.ts +4 -3
- package/dist/agent/index.js +3 -2
- package/dist/agent/index.js.map +1 -1
- package/dist/canvas/index.cjs +1210 -17
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +318 -1
- package/dist/canvas/index.d.ts +318 -1
- package/dist/canvas/index.js +1199 -6
- package/dist/canvas/index.js.map +1 -1
- package/dist/{chunk-QBJ22YZR.js → chunk-3CN2WD3X.js} +1354 -206
- package/dist/chunk-3CN2WD3X.js.map +1 -0
- package/dist/{chunk-JJDLPEWL.js → chunk-3LV6RRPH.js} +2 -2
- package/dist/{chunk-MJZBNWG7.js → chunk-5S3Z4PPF.js} +78 -557
- package/dist/chunk-5S3Z4PPF.js.map +1 -0
- package/dist/chunk-664LQYFJ.js +115 -0
- package/dist/chunk-664LQYFJ.js.map +1 -0
- package/dist/{chunk-AA4ZEVCC.cjs → chunk-D27YFC46.cjs} +101 -580
- package/dist/chunk-D27YFC46.cjs.map +1 -0
- package/dist/chunk-D6FH2YAX.cjs +131 -0
- package/dist/chunk-D6FH2YAX.cjs.map +1 -0
- package/dist/{chunk-4SUNJZWB.cjs → chunk-FD4LPFAE.cjs} +48 -200
- package/dist/chunk-FD4LPFAE.cjs.map +1 -0
- package/dist/chunk-FODNLX5N.js +749 -0
- package/dist/chunk-FODNLX5N.js.map +1 -0
- package/dist/{chunk-OYXSKQFR.js → chunk-FPENXAEJ.js} +35 -187
- package/dist/chunk-FPENXAEJ.js.map +1 -0
- package/dist/chunk-HLIMTC6N.js +1 -0
- package/dist/chunk-HLIMTC6N.js.map +1 -0
- package/dist/{chunk-QGHGJ56O.js → chunk-ITBSKI26.js} +1483 -19
- package/dist/chunk-ITBSKI26.js.map +1 -0
- package/dist/{chunk-XDMXXC4Z.cjs → chunk-MA2F5KHF.cjs} +350 -227
- package/dist/chunk-MA2F5KHF.cjs.map +1 -0
- package/dist/{chunk-RIKBJLS2.cjs → chunk-MCSJFWAO.cjs} +1356 -208
- package/dist/chunk-MCSJFWAO.cjs.map +1 -0
- package/dist/chunk-MKA3AHLV.cjs +256 -0
- package/dist/chunk-MKA3AHLV.cjs.map +1 -0
- package/dist/chunk-OLZJXL4R.cjs +749 -0
- package/dist/chunk-OLZJXL4R.cjs.map +1 -0
- package/dist/chunk-OXSV64JX.js +689 -0
- package/dist/chunk-OXSV64JX.js.map +1 -0
- package/dist/chunk-P3RQ5UJE.cjs +689 -0
- package/dist/chunk-P3RQ5UJE.cjs.map +1 -0
- package/dist/chunk-P6ODPZ4W.js +256 -0
- package/dist/chunk-P6ODPZ4W.js.map +1 -0
- package/dist/chunk-PGNZKFQS.js +685 -0
- package/dist/chunk-PGNZKFQS.js.map +1 -0
- package/dist/chunk-PL4JB3BF.cjs +1 -0
- package/dist/chunk-PL4JB3BF.cjs.map +1 -0
- package/dist/{chunk-GVSMRPHB.cjs → chunk-SBCZ6RN5.cjs} +1568 -104
- package/dist/chunk-SBCZ6RN5.cjs.map +1 -0
- package/dist/{chunk-CL37JGFW.cjs → chunk-SML64VJG.cjs} +4 -4
- package/dist/{chunk-CL37JGFW.cjs.map → chunk-SML64VJG.cjs.map} +1 -1
- package/dist/chunk-TNNJXF46.cjs +115 -0
- package/dist/chunk-TNNJXF46.cjs.map +1 -0
- package/dist/chunk-U5HZSFCS.js +131 -0
- package/dist/chunk-U5HZSFCS.js.map +1 -0
- package/dist/{chunk-K3R5NG2D.js → chunk-U5KWZU4X.js} +251 -128
- package/dist/chunk-U5KWZU4X.js.map +1 -0
- package/dist/chunk-XNORY7M6.cjs +685 -0
- package/dist/chunk-XNORY7M6.cjs.map +1 -0
- package/dist/commands/index.d.cts +5 -353
- package/dist/commands/index.d.ts +5 -353
- package/dist/comment-store-BEMgVlAA.d.cts +135 -0
- package/dist/comment-store-BEMgVlAA.d.ts +135 -0
- package/dist/compare/index.cjs +15 -0
- package/dist/compare/index.cjs.map +1 -0
- package/dist/compare/index.d.cts +58 -0
- package/dist/compare/index.d.ts +58 -0
- package/dist/compare/index.js +15 -0
- package/dist/compare/index.js.map +1 -0
- package/dist/{controller-pePCJLT1.d.cts → controller-BhLLAoi8.d.cts} +45 -4
- package/dist/{controller-pePCJLT1.d.ts → controller-BhLLAoi8.d.ts} +45 -4
- package/dist/documents-BQjzJNe2.d.ts +76 -0
- package/dist/documents-KRTPhvst.d.cts +76 -0
- package/dist/extensions/index.cjs +53 -5
- package/dist/extensions/index.cjs.map +1 -1
- package/dist/extensions/index.d.cts +7 -3
- package/dist/extensions/index.d.ts +7 -3
- package/dist/extensions/index.js +52 -4
- package/dist/generation/index.cjs +1373 -0
- package/dist/generation/index.cjs.map +1 -0
- package/dist/generation/index.d.cts +554 -0
- package/dist/generation/index.d.ts +554 -0
- package/dist/generation/index.js +1373 -0
- package/dist/generation/index.js.map +1 -0
- package/dist/grammar/index.cjs +48 -3
- package/dist/grammar/index.cjs.map +1 -1
- package/dist/grammar/index.d.cts +322 -100
- package/dist/grammar/index.d.ts +322 -100
- package/dist/grammar/index.js +54 -9
- package/dist/image-editor/index.cjs +1831 -30
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +590 -3
- package/dist/image-editor/index.d.ts +590 -3
- package/dist/image-editor/index.js +1807 -6
- package/dist/image-editor/index.js.map +1 -1
- package/dist/{index-CCr_z9kF.d.cts → index-BhJBSm2d.d.cts} +370 -4
- package/dist/{index-Ck6ajwXh.d.ts → index-fJrlkJCd.d.ts} +370 -4
- package/dist/index.cjs +162 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -8
- package/dist/index.d.ts +14 -8
- package/dist/index.js +174 -37
- package/dist/index.js.map +1 -1
- package/dist/migrate-iTlm3a8h.d.cts +112 -0
- package/dist/migrate-iTlm3a8h.d.ts +112 -0
- package/dist/persistence/index.cjs +676 -0
- package/dist/persistence/index.cjs.map +1 -0
- package/dist/persistence/index.d.cts +347 -0
- package/dist/persistence/index.d.ts +347 -0
- package/dist/persistence/index.js +676 -0
- package/dist/persistence/index.js.map +1 -0
- package/dist/{registry-D5-R90p0.d.cts → registry-BDe-vlv3.d.ts} +2 -40
- package/dist/registry-D32LpIc4.d.cts +354 -0
- package/dist/{registry-D5-R90p0.d.ts → registry-DnzpgY27.d.cts} +2 -40
- package/dist/registry-evKTP4ls.d.ts +354 -0
- package/dist/schema-DYDGdYL9.d.cts +41 -0
- package/dist/schema-DYDGdYL9.d.ts +41 -0
- package/dist/serializers/index.cjs +4 -3
- package/dist/serializers/index.cjs.map +1 -1
- package/dist/serializers/index.d.cts +2 -1
- package/dist/serializers/index.d.ts +2 -1
- package/dist/serializers/index.js +3 -2
- package/dist/sourcemap-C8AH3MBQ.d.cts +91 -0
- package/dist/sourcemap-DA1Evhrv.d.ts +91 -0
- package/dist/spreadsheet/index.cjs +37 -3
- package/dist/spreadsheet/index.cjs.map +1 -1
- package/dist/spreadsheet/index.d.cts +188 -17
- package/dist/spreadsheet/index.d.ts +188 -17
- package/dist/spreadsheet/index.js +43 -9
- package/dist/{tokens-CyLZmIei.d.cts → tokens-D7yXvUU6.d.cts} +15 -2
- package/dist/{tokens-CyLZmIei.d.ts → tokens-D7yXvUU6.d.ts} +15 -2
- package/dist/{track-changes-BSF58RK0.d.ts → track-changes-BK5sVf4_.d.cts} +18 -136
- package/dist/{track-changes-BSF58RK0.d.cts → track-changes-CDjCrwKe.d.ts} +18 -136
- package/package.json +16 -1
- package/dist/chunk-4SUNJZWB.cjs.map +0 -1
- package/dist/chunk-AA4ZEVCC.cjs.map +0 -1
- package/dist/chunk-AXV2ZW34.cjs +0 -118
- package/dist/chunk-AXV2ZW34.cjs.map +0 -1
- package/dist/chunk-B2ZRLN4S.js +0 -118
- package/dist/chunk-B2ZRLN4S.js.map +0 -1
- package/dist/chunk-GVSMRPHB.cjs.map +0 -1
- package/dist/chunk-K3R5NG2D.js.map +0 -1
- package/dist/chunk-MJZBNWG7.js.map +0 -1
- package/dist/chunk-OYXSKQFR.js.map +0 -1
- package/dist/chunk-QBJ22YZR.js.map +0 -1
- package/dist/chunk-QGHGJ56O.js.map +0 -1
- package/dist/chunk-RIKBJLS2.cjs.map +0 -1
- package/dist/chunk-XDMXXC4Z.cjs.map +0 -1
- /package/dist/{chunk-JJDLPEWL.js.map → chunk-3LV6RRPH.js.map} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as ASTNode, r as FormulaErrorCode, v as FormulaRange, a as CellData, c as CellFormat, G as GroupAggregate, O as SortDirection, e as CellRange, d as CellPosition, p as FilterRule, S as SpreadsheetController } from '../controller-
|
|
2
|
-
export { B as BinaryOpNode, C as CellCoordinate, b as CellDep, f as CellRefNode, g as CellValueReader, h as ColumnBinding, i as ColumnType, j as CsvExportOptions, k as CsvImportOptions, D as DEFAULT_COLUMN_WIDTH, l as DEFAULT_ROW_HEIGHT, m as DataSourceBinder, n as DependencyGraph, E as EvaluationContext, F as FORMULA_ERRORS, o as FilterOperator, q as FormulaDiagnostic, s as FormulaEvaluationResult, t as FormulaEvaluator, u as FormulaParser, w as FormulaToken, x as FormulaTokenType, y as FunctionCallNode, z as GroupSummary, L as LiteralNode, M as MAX_FORMULA_ARRAY_SIZE, N as NameNode, H as NewFilterRule, P as ParsedSpreadsheetClipboard, I as PropertyRefNode, R as RangeNode, J as RowType, K as SPREADSHEET_CLIPBOARD_MIME, Q as SortKey, T as SpillRefNode, U as SpreadsheetCellSpan, V as SpreadsheetClipboardCell, W as SpreadsheetClipboardData, X as SpreadsheetClipboardPayload, Y as SpreadsheetClipboardSource, Z as SpreadsheetColumn, _ as SpreadsheetControllerOptions, $ as SpreadsheetDataSource, a0 as SpreadsheetDataSourceField, a1 as SpreadsheetDocument, a2 as SpreadsheetFilterState, a3 as SpreadsheetGrouping, a4 as SpreadsheetRow, a5 as SpreadsheetRowGroup, a6 as SpreadsheetRowSection, a7 as SpreadsheetSpill, a8 as SpreadsheetTableSettings, a9 as SpreadsheetViewColumn, aa as SpreadsheetViewModel, ab as SpreadsheetViewRow, ac as StructuralChange, ad as UnaryOpNode, ae as WHOLE_COLUMN_END_ROW, af as buildSpreadsheetView, ag as colNameToIndex, ah as columnDependencyKey, ai as compareNumbers, aj as compareValues, ak as computeRowGroups, al as createSpreadsheetClipboardData, am as describeFormulaError, an as extractCellDependencies, ao as getRowSection, ap as getTableSections, aq as indexToColName, ar as isFormulaError, as as mapFormulaReferences, at as numberToText, au as offsetFormulaReferences, av as parseCellReference, aw as parseFormula, ax as parseHtmlTable, ay as parseRange, az as readSpreadsheetClipboard, aA as rebaseClipboardRows, aB as remapFormulaReferences, aC as rowPassesFilters, aD as serializeHtmlTable, aE as shiftFormulaReferences, aF as sortCompareValues, aG as tokenizeFormula } from '../controller-
|
|
1
|
+
import { A as ASTNode, r as FormulaErrorCode, v as FormulaRange, a as CellData, c as CellFormat, G as GroupAggregate, O as SortDirection, e as CellRange, d as CellPosition, p as FilterRule, S as SpreadsheetController } from '../controller-BhLLAoi8.js';
|
|
2
|
+
export { B as BinaryOpNode, C as CellCoordinate, b as CellDep, f as CellRefNode, g as CellValueReader, h as ColumnBinding, i as ColumnType, j as CsvExportOptions, k as CsvImportOptions, D as DEFAULT_COLUMN_WIDTH, l as DEFAULT_ROW_HEIGHT, m as DataSourceBinder, n as DependencyGraph, E as EvaluationContext, F as FORMULA_ERRORS, o as FilterOperator, q as FormulaDiagnostic, s as FormulaEvaluationResult, t as FormulaEvaluator, u as FormulaParser, w as FormulaToken, x as FormulaTokenType, y as FunctionCallNode, z as GroupSummary, L as LiteralNode, M as MAX_FORMULA_ARRAY_SIZE, N as NameNode, H as NewFilterRule, P as ParsedSpreadsheetClipboard, I as PropertyRefNode, R as RangeNode, J as RowType, K as SPREADSHEET_CLIPBOARD_MIME, Q as SortKey, T as SpillRefNode, U as SpreadsheetCellSpan, V as SpreadsheetClipboardCell, W as SpreadsheetClipboardData, X as SpreadsheetClipboardPayload, Y as SpreadsheetClipboardSource, Z as SpreadsheetColumn, _ as SpreadsheetControllerOptions, $ as SpreadsheetDataSource, a0 as SpreadsheetDataSourceField, a1 as SpreadsheetDocument, a2 as SpreadsheetFilterState, a3 as SpreadsheetGrouping, a4 as SpreadsheetRow, a5 as SpreadsheetRowGroup, a6 as SpreadsheetRowSection, a7 as SpreadsheetSpill, a8 as SpreadsheetTableSettings, a9 as SpreadsheetViewColumn, aa as SpreadsheetViewModel, ab as SpreadsheetViewRow, ac as StructuralChange, ad as UnaryOpNode, ae as WHOLE_COLUMN_END_ROW, af as buildSpreadsheetView, ag as colNameToIndex, ah as columnDependencyKey, ai as compareNumbers, aj as compareValues, ak as computeRowGroups, al as createSpreadsheetClipboardData, am as describeFormulaError, an as extractCellDependencies, ao as getRowSection, ap as getTableSections, aq as indexToColName, ar as isFormulaError, as as mapFormulaReferences, at as numberToText, au as offsetFormulaReferences, av as parseCellReference, aw as parseFormula, ax as parseHtmlTable, ay as parseRange, az as readSpreadsheetClipboard, aA as rebaseClipboardRows, aB as remapFormulaReferences, aC as rowPassesFilters, aD as serializeHtmlTable, aE as shiftFormulaReferences, aF as sortCompareValues, aG as tokenizeFormula } from '../controller-BhLLAoi8.js';
|
|
3
3
|
import { I as ImportAdapterRegistry, c as ImportAdapter, h as ImportInput, a as ImportOutcome } from '../registry-GJI4gToU.js';
|
|
4
4
|
|
|
5
5
|
type FormulaFunctionCategory = 'math' | 'statistical' | 'logical' | 'text' | 'lookup' | 'date' | 'information';
|
|
@@ -211,21 +211,147 @@ declare function wildcardToRegExp(pattern: string): RegExp;
|
|
|
211
211
|
*/
|
|
212
212
|
declare function parseCriteria(criterion: unknown): FormulaCriteriaPredicate;
|
|
213
213
|
|
|
214
|
+
/** Number format code parsing: sections, bracket tags and tokens. */
|
|
215
|
+
/** Colour from a `[Red]` or `[ColorN]` section tag (`color1`…`color56` = palette index). */
|
|
216
|
+
type NumberFormatColor = 'black' | 'blue' | 'cyan' | 'green' | 'magenta' | 'red' | 'white' | 'yellow' | `color${number}`;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* The General format squeezed into `maxChars` characters, as Excel shows it
|
|
220
|
+
* in a narrow column: fewer decimals, then scientific notation; `null` when
|
|
221
|
+
* even that does not fit (the caller paints `####`).
|
|
222
|
+
*/
|
|
223
|
+
declare function formatGeneralFit(n: number, maxChars: number): string | null;
|
|
224
|
+
|
|
225
|
+
/** Built-in number formats (ECMA-376 §18.8.30, en-US). */
|
|
226
|
+
/**
|
|
227
|
+
* Built-in format code for an id (0–49, en-US), e.g. 14 → `m/d/yyyy`.
|
|
228
|
+
* Locale-specific ids (23–36) and unknown ids return undefined.
|
|
229
|
+
*/
|
|
230
|
+
declare function builtinNumberFormat(id: number): string | undefined;
|
|
231
|
+
/** Id of a built-in format code. Matching ignores case and backslash escapes. */
|
|
232
|
+
declare function builtinNumberFormatId(code: string): number | undefined;
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Longest number format code, in characters, that is parsed (Excel's own
|
|
236
|
+
* limit). A longer code displays its value as General and makes `TEXT`
|
|
237
|
+
* return `#VALUE!`. The cap also bounds work that scales with the code.
|
|
238
|
+
*/
|
|
239
|
+
declare const MAX_NUMBER_FORMAT_CODE_CHARS = 255;
|
|
240
|
+
/** Best guess at the ribbon's number-format category. */
|
|
241
|
+
type NumberFormatKind = 'general' | 'number' | 'currency' | 'accounting' | 'date' | 'time' | 'percentage' | 'fraction' | 'scientific' | 'text'
|
|
242
|
+
/** Zip codes, phone numbers, social security numbers. */
|
|
243
|
+
| 'special' | 'custom';
|
|
244
|
+
/** A value formatted with a number format, ready to paint. */
|
|
245
|
+
interface FormattedNumberValue {
|
|
246
|
+
text: string;
|
|
247
|
+
/** Colour from a `[Red]` / `[ColorN]` tag of the section used. */
|
|
248
|
+
color?: NumberFormatColor;
|
|
249
|
+
/**
|
|
250
|
+
* Repeat-fill character from `*x` and its position (UTF-16 index) in
|
|
251
|
+
* `text`; a renderer may repeat it to fill the cell width.
|
|
252
|
+
*/
|
|
253
|
+
fill?: {
|
|
254
|
+
char: string;
|
|
255
|
+
index: number;
|
|
256
|
+
};
|
|
257
|
+
/** True for numbers (right-aligned by default); text, booleans and errors are false. */
|
|
258
|
+
numeric: boolean;
|
|
259
|
+
}
|
|
260
|
+
/** A parsed number format code. Parsing never fails: malformed parts become literal text. */
|
|
261
|
+
declare class NumberFormat {
|
|
262
|
+
readonly code: string;
|
|
263
|
+
private readonly general;
|
|
264
|
+
private readonly sections;
|
|
265
|
+
/** Sections that apply to numbers (a trailing text section is excluded). */
|
|
266
|
+
private readonly numSections;
|
|
267
|
+
/** Index of the section that applies to text, if any. */
|
|
268
|
+
private readonly textSection;
|
|
269
|
+
private constructor();
|
|
270
|
+
/**
|
|
271
|
+
* Parses a format code. Never throws: unknown or malformed parts degrade to
|
|
272
|
+
* literal text, and a code longer than 255 characters degrades to General.
|
|
273
|
+
*/
|
|
274
|
+
static parse(code: string): NumberFormat;
|
|
275
|
+
/** `parse` without the 255-character cap (for tests that reach renderer edge cases). */
|
|
276
|
+
static parseUncapped(code: string): NumberFormat;
|
|
277
|
+
/** Like `parse`, but remembers recently parsed codes (bounded), so formatting many values parses a code once. */
|
|
278
|
+
static parseCached(code: string): NumberFormat;
|
|
279
|
+
static general(): NumberFormat;
|
|
280
|
+
isGeneral(): boolean;
|
|
281
|
+
private numberSections;
|
|
282
|
+
/** True when the code contains date or time tokens. */
|
|
283
|
+
isDate(): boolean;
|
|
284
|
+
isPercent(): boolean;
|
|
285
|
+
/** True for a pure text format such as `@`. */
|
|
286
|
+
isText(): boolean;
|
|
287
|
+
/** Best guess at the format category. */
|
|
288
|
+
kind(): NumberFormatKind;
|
|
289
|
+
/**
|
|
290
|
+
* Picks the number section for `v`, and whether the minus sign is dropped
|
|
291
|
+
* (a negative section shows the absolute value). Null means General.
|
|
292
|
+
*/
|
|
293
|
+
private select;
|
|
294
|
+
/**
|
|
295
|
+
* Formats a number. `overflow` is true when the value can't be shown (a
|
|
296
|
+
* date out of range, painted as `########`).
|
|
297
|
+
*/
|
|
298
|
+
formatNumber(n: number): FormattedNumberValue & {
|
|
299
|
+
overflow: boolean;
|
|
300
|
+
};
|
|
301
|
+
/** Formats text through the text section (`@`), or returns it unchanged. */
|
|
302
|
+
formatText(text: string): FormattedNumberValue;
|
|
303
|
+
/**
|
|
304
|
+
* Formats a cell value: numbers through the number sections, ISO date text
|
|
305
|
+
* (`2026-03-04`, `2026-03-04 18:00:00`) and `Date`s as serial numbers, other
|
|
306
|
+
* text through the text section; booleans show TRUE/FALSE and error values
|
|
307
|
+
* themselves.
|
|
308
|
+
*/
|
|
309
|
+
format(value: unknown): FormattedNumberValue;
|
|
310
|
+
}
|
|
311
|
+
/** Empties the parse cache used by `NumberFormat.parseCached` (mainly for tests). */
|
|
312
|
+
declare function clearNumberFormatCache(): void;
|
|
214
313
|
/**
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
* `$1,200.50`, `0%` for `10%`, `m/d/yyyy` for `3/4/2026`). Other numbers use
|
|
218
|
-
* up to 15 significant digits and booleans show as TRUE/FALSE.
|
|
314
|
+
* 1900-system serial number of a date value: ISO date text (with an optional
|
|
315
|
+
* time) or a `Date` (its local date and time). Null for anything else.
|
|
219
316
|
*/
|
|
220
|
-
declare function
|
|
317
|
+
declare function dateValueToSerial(value: unknown): number | null;
|
|
318
|
+
/** Formats a cell value with a format code (see `NumberFormat.format`). */
|
|
319
|
+
declare function formatNumberFormatValue(value: unknown, code: string): FormattedNumberValue;
|
|
221
320
|
/**
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
|
|
321
|
+
* The `TEXT()` worksheet function: formats a value with a format code.
|
|
322
|
+
* Blanks count as 0; numeric and date text (`"5"`, `"3/4/2026"`,
|
|
323
|
+
* `"2026-03-04"`) is converted to a number first; other text and booleans
|
|
324
|
+
* (as TRUE/FALSE) go through the text section, or are returned as is.
|
|
325
|
+
* Errors: the value's own error, `#VALUE!` for a code over 255 characters or
|
|
326
|
+
* a date out of range, `#NUM!` for a non-finite number.
|
|
327
|
+
*/
|
|
328
|
+
declare function formatTextFunction(value: unknown, code: string): {
|
|
329
|
+
text: string;
|
|
330
|
+
} | {
|
|
331
|
+
error: string;
|
|
332
|
+
};
|
|
333
|
+
/** CSS colour for a format colour (`red` → `#FF0000`, `color10` → `#008000`). */
|
|
334
|
+
declare function numberFormatColorToCss(color: NumberFormatColor): string;
|
|
335
|
+
|
|
336
|
+
type DisplayCell = Pick<CellData, 'value' | 'error' | 'numberFormat' | 'format'>;
|
|
337
|
+
/**
|
|
338
|
+
* How a cell is shown: its error, or its value formatted with its number
|
|
339
|
+
* format code (`numberFormat`: set explicitly, inherited from the column, or
|
|
340
|
+
* chosen for typed input, e.g. `"$"#,##0.00` for `$1,200.50`). Numbers in a
|
|
341
|
+
* cell with a `currency` / `percentage` / `date` `CellFormat` but no code use
|
|
342
|
+
* that kind's code. Without a code (General), numbers use up to 15
|
|
343
|
+
* significant digits and booleans show as TRUE/FALSE.
|
|
344
|
+
*
|
|
345
|
+
* `numeric` is true for numbers (and dates shown through a date format):
|
|
346
|
+
* grids right-align those. `color` comes from a `[Red]` / `[ColorN]` tag.
|
|
347
|
+
*/
|
|
348
|
+
declare function formatCellForDisplay(cell: DisplayCell | null | undefined): FormattedNumberValue;
|
|
349
|
+
/** The text a cell shows (see `formatCellForDisplay`). Used by grids, CSV export and the clipboard. */
|
|
350
|
+
declare function formatCellDisplay(cell: DisplayCell | null | undefined): string;
|
|
351
|
+
/**
|
|
352
|
+
* Formats a value with a number format code, as `TEXT()` does (see
|
|
353
|
+
* `formatTextFunction`). Null when the value can't be shown with that code
|
|
354
|
+
* (a date out of range, a code over 255 characters, an error value).
|
|
229
355
|
*/
|
|
230
356
|
declare function formatValueWithCode(value: unknown, format: string): string | null;
|
|
231
357
|
|
|
@@ -276,6 +402,34 @@ declare function parseCellInput(input: string): ParsedCellInput;
|
|
|
276
402
|
*/
|
|
277
403
|
declare function parseNumberText(text: string): number | null;
|
|
278
404
|
|
|
405
|
+
/**
|
|
406
|
+
* Common number formats offered by the "Format cells" menu, and the mapping
|
|
407
|
+
* between format codes and the coarser `CellFormat` kinds.
|
|
408
|
+
*/
|
|
409
|
+
|
|
410
|
+
interface NumberFormatPreset {
|
|
411
|
+
id: 'general' | 'number' | 'currency' | 'percent' | 'date' | 'time';
|
|
412
|
+
label: string;
|
|
413
|
+
code: string;
|
|
414
|
+
}
|
|
415
|
+
/** Presets of the "Format cells" menu (en-US). */
|
|
416
|
+
declare const NUMBER_FORMAT_PRESETS: readonly NumberFormatPreset[];
|
|
417
|
+
/**
|
|
418
|
+
* Format code for a `CellFormat` kind, used to display numbers in cells that
|
|
419
|
+
* have a kind but no format code: `currency` → `"$"#,##0.00`, `percentage` →
|
|
420
|
+
* `0%`, `date` → `m/d/yyyy`. Other kinds (`number`, `text` — the default of
|
|
421
|
+
* new columns —, `badge`, `status`, `assignee`) display as General (undefined).
|
|
422
|
+
*/
|
|
423
|
+
declare function numberFormatForCellFormat(format: CellFormat | undefined): string | undefined;
|
|
424
|
+
/**
|
|
425
|
+
* `CellFormat` kind matching a format code (`"$"#,##0.00` → `currency`,
|
|
426
|
+
* `0%` → `percentage`, `m/d/yyyy` → `date`, `0.00` → `number`, `@` → `text`);
|
|
427
|
+
* undefined for General, times and custom codes.
|
|
428
|
+
*/
|
|
429
|
+
declare function cellFormatForNumberFormat(code: string): CellFormat | undefined;
|
|
430
|
+
/** True for an empty or `General` code. */
|
|
431
|
+
declare const isGeneralNumberFormat: (code: string | undefined) => boolean;
|
|
432
|
+
|
|
279
433
|
/**
|
|
280
434
|
* RFC 4180 CSV (and other delimiter-separated values) parsing and
|
|
281
435
|
* serialization.
|
|
@@ -401,8 +555,25 @@ interface SpreadsheetMenuItem {
|
|
|
401
555
|
disabled?: boolean;
|
|
402
556
|
/** Draw a divider before this item. */
|
|
403
557
|
separatorBefore?: boolean;
|
|
404
|
-
|
|
558
|
+
/** The item is the current choice of its group (e.g. the cell's number format). */
|
|
559
|
+
checked?: boolean;
|
|
560
|
+
/**
|
|
561
|
+
* Ask for text before running (e.g. a custom number format code): the
|
|
562
|
+
* editor prompts with `label` and `defaultValue`, then calls `run(text)`;
|
|
563
|
+
* cancelling skips `run`.
|
|
564
|
+
*/
|
|
565
|
+
input?: {
|
|
566
|
+
label: string;
|
|
567
|
+
defaultValue?: string;
|
|
568
|
+
};
|
|
569
|
+
run: (input?: string) => void;
|
|
405
570
|
}
|
|
571
|
+
/**
|
|
572
|
+
* Runs a menu item the way the editors do: an item with `input` first asks
|
|
573
|
+
* for text with `ask` (default `window.prompt`) and is skipped when that is
|
|
574
|
+
* cancelled. Returns whether `run` was called.
|
|
575
|
+
*/
|
|
576
|
+
declare function runSpreadsheetMenuItem(item: SpreadsheetMenuItem, ask?: (label: string, defaultValue: string) => string | null | undefined): boolean;
|
|
406
577
|
/**
|
|
407
578
|
* Where to place a `position: fixed` menu opened at `point` so it stays inside
|
|
408
579
|
* the viewport: it flips to the left of / above the pointer when it would
|
|
@@ -437,7 +608,7 @@ declare function getSpreadsheetMenuItems(controller: SpreadsheetController, cell
|
|
|
437
608
|
* state syncing: the controller reports changes through `onDocumentChange`
|
|
438
609
|
* and `onSelectionChange`.
|
|
439
610
|
*/
|
|
440
|
-
declare const SPREADSHEET_TABLE_ACTIONS: readonly ["sortRows", "getFilterState", "setFilterRules", "addFilterRule", "updateFilterRule", "removeFilterRule", "clearFilters", "setFiltersEnabled", "toggleFilters", "setHeaderRowCount", "setFooterRowCount", "setHeaderColumnCount", "setFrozenRowCount", "setFrozenColumnCount", "hideRows", "unhideRows", "hideColumns", "unhideColumns", "unhideAll", "getMerges", "getMergeAt", "mergeCells", "unmergeCells", "autofill", "groupRowsBy", "ungroupRows", "setGroupSummary", "setGroupCollapsed", "toggleGroupCollapsed", "getGroups", "transposeRange", "exportToCsv", "importFromCsv", "copyToClipboardData", "pasteClipboardData"];
|
|
611
|
+
declare const SPREADSHEET_TABLE_ACTIONS: readonly ["sortRows", "getFilterState", "setFilterRules", "addFilterRule", "updateFilterRule", "removeFilterRule", "clearFilters", "setFiltersEnabled", "toggleFilters", "setHeaderRowCount", "setFooterRowCount", "setHeaderColumnCount", "setFrozenRowCount", "setFrozenColumnCount", "hideRows", "unhideRows", "hideColumns", "unhideColumns", "unhideAll", "getMerges", "getMergeAt", "mergeCells", "unmergeCells", "autofill", "groupRowsBy", "ungroupRows", "setGroupSummary", "setGroupCollapsed", "toggleGroupCollapsed", "getGroups", "transposeRange", "setCellNumberFormat", "setColumnNumberFormat", "exportToCsv", "importFromCsv", "copyToClipboardData", "pasteClipboardData"];
|
|
441
612
|
type SpreadsheetTableActionName = (typeof SPREADSHEET_TABLE_ACTIONS)[number];
|
|
442
613
|
type SpreadsheetTableActions = Pick<SpreadsheetController, SpreadsheetTableActionName>;
|
|
443
614
|
/** The table operations of `controller`, bound so they can be passed around. */
|
|
@@ -485,4 +656,4 @@ interface ImportFileIntoSpreadsheetOptions {
|
|
|
485
656
|
*/
|
|
486
657
|
declare function importFileIntoSpreadsheet(controller: SpreadsheetController, input: ImportInput, options: ImportFileIntoSpreadsheetOptions): Promise<ImportOutcome<SpreadsheetImport>>;
|
|
487
658
|
|
|
488
|
-
export { ASTNode, CellData, CellFormat, type CellInputFormatKind, CellPosition, CellRange, type CsvParseOptions, type CsvSerializeOptions, type FillDirection, FilterRule, type FormulaActiveCall, type FormulaArgument, type FormulaArgumentSpec, type FormulaArgumentType, type FormulaCaretContext, type FormulaCriteriaPredicate, FormulaErrorCode, type FormulaFunctionCategory, type FormulaFunctionContext, type FormulaFunctionDefinition, type FormulaFunctionSuggestion, type FormulaHints, FormulaRange, type FormulaSignaturePart, GroupAggregate, type ImportFileIntoSpreadsheetOptions, type ParsedCellInput, SPREADSHEET_IMPORT_ADAPTERS, SPREADSHEET_TABLE_ACTIONS, SortDirection, SpreadsheetController, type SpreadsheetImport, type SpreadsheetImportAdapter, type SpreadsheetMenuItem, type SpreadsheetTableActionName, type SpreadsheetTableActions, aggregateValues, applyFormulaSuggestion, bindSpreadsheetTableActions, checkFormulaArgumentCount, clampMenuPosition, compareCellValues, computeFillTarget, csvImportAdapter, escapeCsvField, fillSeries, formatCellDisplay, formatValueWithCode, getFillDirection, getFormulaArgumentSpecIndex, getFormulaCaretContext, getFormulaFunction, getFormulaHints, getFormulaSignature, getFormulaSignatureParts, getSpreadsheetMenuItems, importFileIntoSpreadsheet, isBlankValue, isSingleCellRange, listFormulaFunctions, matchesFilterRule, normalizeRange, parseCellInput, parseCriteria, parseCsv, parseNumberText, parseTsv, rangeContains, rangeContainsRange, rangesIntersect, registerFormulaFunction, registerSpreadsheetImportAdapters, roundFloat, searchFormulaFunctions, serialFromYmd, serializeCsv, serializeTsv, toNumber, tsvImportAdapter, unregisterFormulaFunction, wildcardToRegExp };
|
|
659
|
+
export { ASTNode, CellData, CellFormat, type CellInputFormatKind, CellPosition, CellRange, type CsvParseOptions, type CsvSerializeOptions, type FillDirection, FilterRule, type FormattedNumberValue, type FormulaActiveCall, type FormulaArgument, type FormulaArgumentSpec, type FormulaArgumentType, type FormulaCaretContext, type FormulaCriteriaPredicate, FormulaErrorCode, type FormulaFunctionCategory, type FormulaFunctionContext, type FormulaFunctionDefinition, type FormulaFunctionSuggestion, type FormulaHints, FormulaRange, type FormulaSignaturePart, GroupAggregate, type ImportFileIntoSpreadsheetOptions, MAX_NUMBER_FORMAT_CODE_CHARS, NUMBER_FORMAT_PRESETS, NumberFormat, type NumberFormatColor, type NumberFormatKind, type NumberFormatPreset, type ParsedCellInput, SPREADSHEET_IMPORT_ADAPTERS, SPREADSHEET_TABLE_ACTIONS, SortDirection, SpreadsheetController, type SpreadsheetImport, type SpreadsheetImportAdapter, type SpreadsheetMenuItem, type SpreadsheetTableActionName, type SpreadsheetTableActions, aggregateValues, applyFormulaSuggestion, bindSpreadsheetTableActions, builtinNumberFormat, builtinNumberFormatId, cellFormatForNumberFormat, checkFormulaArgumentCount, clampMenuPosition, clearNumberFormatCache, compareCellValues, computeFillTarget, csvImportAdapter, dateValueToSerial, escapeCsvField, fillSeries, formatCellDisplay, formatCellForDisplay, formatGeneralFit, formatNumberFormatValue, formatTextFunction, formatValueWithCode, getFillDirection, getFormulaArgumentSpecIndex, getFormulaCaretContext, getFormulaFunction, getFormulaHints, getFormulaSignature, getFormulaSignatureParts, getSpreadsheetMenuItems, importFileIntoSpreadsheet, isBlankValue, isGeneralNumberFormat, isSingleCellRange, listFormulaFunctions, matchesFilterRule, normalizeRange, numberFormatColorToCss, numberFormatForCellFormat, parseCellInput, parseCriteria, parseCsv, parseNumberText, parseTsv, rangeContains, rangeContainsRange, rangesIntersect, registerFormulaFunction, registerSpreadsheetImportAdapters, roundFloat, runSpreadsheetMenuItem, searchFormulaFunctions, serialFromYmd, serializeCsv, serializeTsv, toNumber, tsvImportAdapter, unregisterFormulaFunction, wildcardToRegExp };
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
DEFAULT_ROW_HEIGHT,
|
|
4
4
|
DataSourceBinder,
|
|
5
5
|
DependencyGraph,
|
|
6
|
+
NUMBER_FORMAT_PRESETS,
|
|
6
7
|
SPREADSHEET_CLIPBOARD_MIME,
|
|
7
8
|
SPREADSHEET_IMPORT_ADAPTERS,
|
|
8
9
|
SPREADSHEET_TABLE_ACTIONS,
|
|
@@ -11,6 +12,7 @@ import {
|
|
|
11
12
|
applyFormulaSuggestion,
|
|
12
13
|
bindSpreadsheetTableActions,
|
|
13
14
|
buildSpreadsheetView,
|
|
15
|
+
cellFormatForNumberFormat,
|
|
14
16
|
clampMenuPosition,
|
|
15
17
|
columnDependencyKey,
|
|
16
18
|
compareCellValues,
|
|
@@ -18,9 +20,11 @@ import {
|
|
|
18
20
|
computeRowGroups,
|
|
19
21
|
createSpreadsheetClipboardData,
|
|
20
22
|
csvImportAdapter,
|
|
21
|
-
escapeCsvField,
|
|
22
23
|
extractCellDependencies,
|
|
23
24
|
fillSeries,
|
|
25
|
+
formatCellDisplay,
|
|
26
|
+
formatCellForDisplay,
|
|
27
|
+
formatValueWithCode,
|
|
24
28
|
getFillDirection,
|
|
25
29
|
getFormulaCaretContext,
|
|
26
30
|
getFormulaHints,
|
|
@@ -29,14 +33,14 @@ import {
|
|
|
29
33
|
getTableSections,
|
|
30
34
|
importFileIntoSpreadsheet,
|
|
31
35
|
isBlankValue,
|
|
36
|
+
isGeneralNumberFormat,
|
|
32
37
|
isSingleCellRange,
|
|
33
38
|
mapFormulaReferences,
|
|
34
39
|
matchesFilterRule,
|
|
35
40
|
normalizeRange,
|
|
41
|
+
numberFormatForCellFormat,
|
|
36
42
|
offsetFormulaReferences,
|
|
37
|
-
parseCsv,
|
|
38
43
|
parseHtmlTable,
|
|
39
|
-
parseTsv,
|
|
40
44
|
rangeContains,
|
|
41
45
|
rangeContainsRange,
|
|
42
46
|
rangesIntersect,
|
|
@@ -46,26 +50,39 @@ import {
|
|
|
46
50
|
remapFormulaReferences,
|
|
47
51
|
roundFloat,
|
|
48
52
|
rowPassesFilters,
|
|
49
|
-
|
|
53
|
+
runSpreadsheetMenuItem,
|
|
50
54
|
serializeHtmlTable,
|
|
51
|
-
serializeTsv,
|
|
52
55
|
shiftFormulaReferences,
|
|
53
56
|
toNumber,
|
|
54
57
|
tsvImportAdapter
|
|
55
|
-
} from "../chunk-
|
|
58
|
+
} from "../chunk-U5KWZU4X.js";
|
|
59
|
+
import {
|
|
60
|
+
escapeCsvField,
|
|
61
|
+
parseCsv,
|
|
62
|
+
parseTsv,
|
|
63
|
+
serializeCsv,
|
|
64
|
+
serializeTsv
|
|
65
|
+
} from "../chunk-664LQYFJ.js";
|
|
56
66
|
import {
|
|
57
67
|
FORMULA_ERRORS,
|
|
58
68
|
FormulaEvaluator,
|
|
59
69
|
FormulaParser,
|
|
60
70
|
MAX_FORMULA_ARRAY_SIZE,
|
|
71
|
+
MAX_NUMBER_FORMAT_CODE_CHARS,
|
|
72
|
+
NumberFormat,
|
|
61
73
|
WHOLE_COLUMN_END_ROW,
|
|
74
|
+
builtinNumberFormat,
|
|
75
|
+
builtinNumberFormatId,
|
|
62
76
|
checkFormulaArgumentCount,
|
|
77
|
+
clearNumberFormatCache,
|
|
63
78
|
colNameToIndex,
|
|
64
79
|
compareNumbers,
|
|
65
80
|
compareValues,
|
|
81
|
+
dateValueToSerial,
|
|
66
82
|
describeFormulaError,
|
|
67
|
-
|
|
68
|
-
|
|
83
|
+
formatGeneralFit,
|
|
84
|
+
formatNumberFormatValue,
|
|
85
|
+
formatTextFunction,
|
|
69
86
|
getFormulaArgumentSpecIndex,
|
|
70
87
|
getFormulaFunction,
|
|
71
88
|
getFormulaSignature,
|
|
@@ -73,6 +90,7 @@ import {
|
|
|
73
90
|
indexToColName,
|
|
74
91
|
isFormulaError,
|
|
75
92
|
listFormulaFunctions,
|
|
93
|
+
numberFormatColorToCss,
|
|
76
94
|
numberToText,
|
|
77
95
|
parseCellInput,
|
|
78
96
|
parseCellReference,
|
|
@@ -87,7 +105,7 @@ import {
|
|
|
87
105
|
tokenizeFormula,
|
|
88
106
|
unregisterFormulaFunction,
|
|
89
107
|
wildcardToRegExp
|
|
90
|
-
} from "../chunk-
|
|
108
|
+
} from "../chunk-3CN2WD3X.js";
|
|
91
109
|
export {
|
|
92
110
|
DEFAULT_COLUMN_WIDTH,
|
|
93
111
|
DEFAULT_ROW_HEIGHT,
|
|
@@ -97,6 +115,9 @@ export {
|
|
|
97
115
|
FormulaEvaluator,
|
|
98
116
|
FormulaParser,
|
|
99
117
|
MAX_FORMULA_ARRAY_SIZE,
|
|
118
|
+
MAX_NUMBER_FORMAT_CODE_CHARS,
|
|
119
|
+
NUMBER_FORMAT_PRESETS,
|
|
120
|
+
NumberFormat,
|
|
100
121
|
SPREADSHEET_CLIPBOARD_MIME,
|
|
101
122
|
SPREADSHEET_IMPORT_ADAPTERS,
|
|
102
123
|
SPREADSHEET_TABLE_ACTIONS,
|
|
@@ -106,8 +127,12 @@ export {
|
|
|
106
127
|
applyFormulaSuggestion,
|
|
107
128
|
bindSpreadsheetTableActions,
|
|
108
129
|
buildSpreadsheetView,
|
|
130
|
+
builtinNumberFormat,
|
|
131
|
+
builtinNumberFormatId,
|
|
132
|
+
cellFormatForNumberFormat,
|
|
109
133
|
checkFormulaArgumentCount,
|
|
110
134
|
clampMenuPosition,
|
|
135
|
+
clearNumberFormatCache,
|
|
111
136
|
colNameToIndex,
|
|
112
137
|
columnDependencyKey,
|
|
113
138
|
compareCellValues,
|
|
@@ -117,11 +142,16 @@ export {
|
|
|
117
142
|
computeRowGroups,
|
|
118
143
|
createSpreadsheetClipboardData,
|
|
119
144
|
csvImportAdapter,
|
|
145
|
+
dateValueToSerial,
|
|
120
146
|
describeFormulaError,
|
|
121
147
|
escapeCsvField,
|
|
122
148
|
extractCellDependencies,
|
|
123
149
|
fillSeries,
|
|
124
150
|
formatCellDisplay,
|
|
151
|
+
formatCellForDisplay,
|
|
152
|
+
formatGeneralFit,
|
|
153
|
+
formatNumberFormatValue,
|
|
154
|
+
formatTextFunction,
|
|
125
155
|
formatValueWithCode,
|
|
126
156
|
getFillDirection,
|
|
127
157
|
getFormulaArgumentSpecIndex,
|
|
@@ -137,11 +167,14 @@ export {
|
|
|
137
167
|
indexToColName,
|
|
138
168
|
isBlankValue,
|
|
139
169
|
isFormulaError,
|
|
170
|
+
isGeneralNumberFormat,
|
|
140
171
|
isSingleCellRange,
|
|
141
172
|
listFormulaFunctions,
|
|
142
173
|
mapFormulaReferences,
|
|
143
174
|
matchesFilterRule,
|
|
144
175
|
normalizeRange,
|
|
176
|
+
numberFormatColorToCss,
|
|
177
|
+
numberFormatForCellFormat,
|
|
145
178
|
numberToText,
|
|
146
179
|
offsetFormulaReferences,
|
|
147
180
|
parseCellInput,
|
|
@@ -163,6 +196,7 @@ export {
|
|
|
163
196
|
remapFormulaReferences,
|
|
164
197
|
roundFloat,
|
|
165
198
|
rowPassesFilters,
|
|
199
|
+
runSpreadsheetMenuItem,
|
|
166
200
|
searchFormulaFunctions,
|
|
167
201
|
serialFromYmd,
|
|
168
202
|
serializeCsv,
|
|
@@ -33,11 +33,24 @@ interface Token {
|
|
|
33
33
|
description?: string;
|
|
34
34
|
/** Conditional tags only. */
|
|
35
35
|
conditional?: ConditionalKind;
|
|
36
|
+
/**
|
|
37
|
+
* Opening conditional tags written as a comparison (`{?amount>100}`,
|
|
38
|
+
* closed by `{/amount}`) only. `value` is then the variable name.
|
|
39
|
+
*/
|
|
40
|
+
comparison?: ConditionComparison;
|
|
41
|
+
}
|
|
42
|
+
/** Operators accepted in a comparison condition such as `{?amount>=100}`. */
|
|
43
|
+
type ComparisonOperator = "=" | "<>" | "<" | ">" | "<=" | ">=";
|
|
44
|
+
/** The comparison part of a conditional tag: `{?status=paid}` → `{ operator: "=", operand: "paid" }`. */
|
|
45
|
+
interface ConditionComparison {
|
|
46
|
+
operator: ComparisonOperator;
|
|
47
|
+
/** Right-hand side, unquoted. */
|
|
48
|
+
operand: string;
|
|
36
49
|
}
|
|
37
50
|
/** Values supplied for `{variable}` slots and `{?variable}` conditions. */
|
|
38
51
|
type PromptValue = string | number | boolean | null | undefined;
|
|
39
52
|
type PromptValues = Record<string, PromptValue>;
|
|
40
|
-
type PromptDiagnosticCode = "unclosed-section" | "unexpected-close";
|
|
53
|
+
type PromptDiagnosticCode = "unclosed-section" | "unexpected-close" | "invalid-condition";
|
|
41
54
|
/**
|
|
42
55
|
* A recoverable grammar problem. The offending tag is treated as literal text.
|
|
43
56
|
* Offsets are relative to the text that contained the tag: the input prompt,
|
|
@@ -73,4 +86,4 @@ interface ColorGradient {
|
|
|
73
86
|
to: string;
|
|
74
87
|
}
|
|
75
88
|
|
|
76
|
-
export { type ColorGradient as C, INSTRUCTION_REGEX as I, type
|
|
89
|
+
export { type ColorGradient as C, INSTRUCTION_REGEX as I, type PromptValues as P, type Template as T, VARIABLE_REGEX as V, type PromptDiagnostic as a, type Token as b, type ComparisonOperator as c, type ConditionComparison as d, type ConditionalKind as e, type PromptDiagnosticCode as f, type PromptValue as g, TEMPLATE_REGEX as h, type TemplateVersion as i, type TokenType as j, instructionRegex as k, templateRegex as t, variableRegex as v };
|
|
@@ -33,11 +33,24 @@ interface Token {
|
|
|
33
33
|
description?: string;
|
|
34
34
|
/** Conditional tags only. */
|
|
35
35
|
conditional?: ConditionalKind;
|
|
36
|
+
/**
|
|
37
|
+
* Opening conditional tags written as a comparison (`{?amount>100}`,
|
|
38
|
+
* closed by `{/amount}`) only. `value` is then the variable name.
|
|
39
|
+
*/
|
|
40
|
+
comparison?: ConditionComparison;
|
|
41
|
+
}
|
|
42
|
+
/** Operators accepted in a comparison condition such as `{?amount>=100}`. */
|
|
43
|
+
type ComparisonOperator = "=" | "<>" | "<" | ">" | "<=" | ">=";
|
|
44
|
+
/** The comparison part of a conditional tag: `{?status=paid}` → `{ operator: "=", operand: "paid" }`. */
|
|
45
|
+
interface ConditionComparison {
|
|
46
|
+
operator: ComparisonOperator;
|
|
47
|
+
/** Right-hand side, unquoted. */
|
|
48
|
+
operand: string;
|
|
36
49
|
}
|
|
37
50
|
/** Values supplied for `{variable}` slots and `{?variable}` conditions. */
|
|
38
51
|
type PromptValue = string | number | boolean | null | undefined;
|
|
39
52
|
type PromptValues = Record<string, PromptValue>;
|
|
40
|
-
type PromptDiagnosticCode = "unclosed-section" | "unexpected-close";
|
|
53
|
+
type PromptDiagnosticCode = "unclosed-section" | "unexpected-close" | "invalid-condition";
|
|
41
54
|
/**
|
|
42
55
|
* A recoverable grammar problem. The offending tag is treated as literal text.
|
|
43
56
|
* Offsets are relative to the text that contained the tag: the input prompt,
|
|
@@ -73,4 +86,4 @@ interface ColorGradient {
|
|
|
73
86
|
to: string;
|
|
74
87
|
}
|
|
75
88
|
|
|
76
|
-
export { type ColorGradient as C, INSTRUCTION_REGEX as I, type
|
|
89
|
+
export { type ColorGradient as C, INSTRUCTION_REGEX as I, type PromptValues as P, type Template as T, VARIABLE_REGEX as V, type PromptDiagnostic as a, type Token as b, type ComparisonOperator as c, type ConditionComparison as d, type ConditionalKind as e, type PromptDiagnosticCode as f, type PromptValue as g, TEMPLATE_REGEX as h, type TemplateVersion as i, type TokenType as j, instructionRegex as k, templateRegex as t, variableRegex as v };
|