@a3s-lab/office 0.35.0 → 0.37.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 +34 -10
- package/dist/0~7048.js +590 -3
- package/dist/0~spreadsheet-editor.js +515 -44
- package/dist/0~work-office-diagnostics.js +1 -1
- package/dist/3266.js +549 -10
- package/dist/4121.js +2202 -1942
- package/dist/8715.js +299 -299
- package/dist/core.js +41 -4
- package/dist/internal/features/work/editors/spreadsheet-calculation-model.d.ts +1 -1
- package/dist/internal/features/work/editors/spreadsheet-calculation-projection.d.ts +5 -2
- package/dist/internal/features/work/editors/spreadsheet-table-calculated-columns.d.ts +42 -0
- package/dist/internal/features/work/editors/spreadsheet-table-totals.d.ts +39 -0
- package/dist/internal/features/work/editors/spreadsheet-table.d.ts +11 -1
- package/dist/internal/features/work/work-types.d.ts +20 -1
- package/dist/internal/kernel/office-kernel-protocol.d.ts +1 -1
- package/dist/internal/kernel/office-kernel-spreadsheet-fallback-formula.d.ts +11 -0
- package/dist/internal/kernel/office-kernel-spreadsheet-protocol.d.ts +18 -0
- package/dist/internal/kernel/office-kernel-spreadsheet-structured-reference.d.ts +48 -0
- package/dist/office-kernel.wasm +0 -0
- package/dist/office-kernel.worker.js +598 -3
- package/dist/styles.css +120 -0
- package/docs/latest/en/browser-editor-architecture.md +27 -8
- package/package.json +4 -1
package/dist/core.js
CHANGED
|
@@ -5,7 +5,7 @@ import { OFFICE_COLLABORATION_PROTOCOL as WORK_OFFICE_COLLABORATION_PROTOCOL, Of
|
|
|
5
5
|
import { directChildren, OoxmlPackage as work_ooxml_package_OoxmlPackage, parseXml, firstDescendant, directChild, descendants, createArtifact as createWorkArtifact, xmlContainsAnyElement, createOfficeId as createWorkId, attribute as work_ooxml_package_attribute } from "./4121.js";
|
|
6
6
|
import { fileNameWithoutExtension, work_file_download_downloadBlob, mountWorkLiveDocumentCapture, importWorkDocumentFile, moveWorkSourceBlob, materializeWorkDocumentContent as work_document_model_codec_materializeWorkDocumentContent, createWorkDocumentModel, work_file_download_safeFileName, documentPageSurfaceGeometryForElement, registerSourceBlob as rememberWorkSourceBlob, documentModelForContent, readSourceBlob as readWorkSourceBlob, createWorkDocumentExtensions, positionWorkLiveDocumentCapture, createWorkDocumentBlob } from "./4174.js";
|
|
7
7
|
import { normalizeSpreadsheetPrintTitleRows, sparseMatrixColumnCount, normalizeSpreadsheetPrintArea, parseSpreadsheetPrintTitles, isValidSpreadsheetDefinedName, formatSpreadsheetCellRanges, stripSpreadsheetSheetQualifier, editableSpreadsheetFormula, sparseArrayEntries, qualifySpreadsheetRange, refreshSpreadsheetPivotTables, parseSpreadsheetCellRanges, normalizeSpreadsheetPrintTitleColumns } from "./8715.js";
|
|
8
|
-
import { xlsxColorMatches, xlsxRichTextCellText, spreadsheetCellValueWithDiagonalBorder, xlsxRichTextStyleOrigins, normalizeSpreadsheetDataValidationErrorStyle, directXlsxAlignment, spreadsheetTextOrientationFromXlsx, directXlsxFontStyle, hasXlsxDirectFontStyle, applyImportedXlsxRichText, xlsxStyleCollectionIndex,
|
|
8
|
+
import { xlsxColorMatches, xlsxRichTextCellText, spreadsheetCellValueWithDiagonalBorder, xlsxRichTextStyleOrigins, normalizeSpreadsheetDataValidationErrorStyle, directXlsxAlignment, spreadsheetTableTotalsFunctionToOoxml, spreadsheetTextOrientationFromXlsx, directXlsxFontStyle, hasXlsxDirectFontStyle, applyImportedXlsxRichText, xlsxStyleCollectionIndex, sheetHasXlsxRichTextCells, spreadsheetExplicitTextOrientationFromCell, activeXlsxNativeFill, readXlsxRichTextCells, normalizeSpreadsheetDateValidationBoundary, createXlsxRichTextReadContext, boundedSpreadsheetDataValidationText, xlsxNativeFillKey, xlsxBooleanAttribute, xlsxAlignmentMatches, xlsxBorderLineMatches, spreadsheetTextOrientationCellStyle, spreadsheetTableTotalsFunctionFromOoxml, spreadsheetDateValidationFormula, spreadsheetDiagonalBorderFromCellValue, xlsxUnderlineStyle, spreadsheetUnderlineCellValueFromXlsx, xlsxToggleEnabled, normalizeSpreadsheetTableTotalsLabel, activeXlsxSemanticColorOrigin, writeXlsxRichTextCells, xlsxNativeFillSemanticColors, normalizeSpreadsheetTableCalculatedFormula, normalizeSpreadsheetTableTotalsFormula, spreadsheetUnderlineCellValueFromSheetJs } from "./3266.js";
|
|
9
9
|
import { freezeImportedSpreadsheetCell, readXlsxGradientFill, withXlsxPatternFill, xlsxCellStyleOriginSemanticColors, setXlsxToggleChild, withXlsxCellStyleOrigin, normalizeSpreadsheetConditionalVisualOptions, xlsxColorElementMatchesOrigin, withXlsxGradientFill, ensureXlsxStyleCollection, xlsxCellStyleOrigin, xlsxSemanticColorOriginKey, readXlsxPatternFill, isSpreadsheetConditionalComparisonOperator, registerImportedSpreadsheetMatrix, defaultSpreadsheetConditionalIconThresholds, readXlsxSemanticColorOrigin, setXlsxUnderlineChild, xlsxGradientFillFallbackColor, setXlsxColorChild, createXlsxColorResolver, resolveXlsxColor, setXlsxBorderLine, normalizeSpreadsheetConditionalIconSetFormat, defaultSpreadsheetDataBarOptions, defaultXlsxBorder, prepareXlsxSemanticPalette, importedSheetProtectionAuthority, defaultSpreadsheetColorScaleThresholds, xlsxRgbColor, writeXlsxAlignment, xlsxGradientFillKey, applyXlsxSemanticColorOrigin, spreadsheetConditionalComparisonNeedsUpperValue, sheetHasProtectionState, xlsxWorksheetCellEntries, isSpreadsheetConditionalIconSetName, setXlsxValueChild, defaultXlsxFill, spreadsheetConditionalThresholdsEqual, spreadsheetConditionalIconSetCount } from "./9333.js";
|
|
10
10
|
import { updateSpreadsheetWorksheetCompatibilitySummary, inspectXlsxPivotTables, readXlsxWorksheetCharts, createXlsxFormulaCell, patchXlsxWorksheetDrawings, readXlsxWorksheetImages, writeXlsxProtection, xlsxWorksheetChartsToSheet, readXlsxFormulaFeaturesFromPackage, emptySpreadsheetWorksheetCompatibilitySummary, createSpreadsheetFormulaMetadata, createXlsxErrorCell, xlsxWorksheetImagesToSheet, readXlsxProtection, patchXlsxFormulaFeatures, patchXlsxPivotTables, writeXlsxPageSetup, XlsxCellProtectionWriter, applyImportedXlsxPivotTables, readXlsxPageSetup } from "./4166.js";
|
|
11
11
|
import { WorkFileImportController, materializeWorkFileSource } from "./9356.js";
|
|
@@ -2700,9 +2700,27 @@ function parseXlsxTable(document1, partPath) {
|
|
|
2700
2700
|
if (!name || !range || !columnsElement) return null;
|
|
2701
2701
|
const columns = directChildren(columnsElement, 'tableColumn').flatMap((column)=>{
|
|
2702
2702
|
const columnName = work_ooxml_package_attribute(column, 'name');
|
|
2703
|
-
|
|
2703
|
+
if (null === columnName) return [];
|
|
2704
|
+
const calculatedFormula = normalizeSpreadsheetTableCalculatedFormula(directChild(column, 'calculatedColumnFormula')?.textContent);
|
|
2705
|
+
const totalsFunction = spreadsheetTableTotalsFunctionFromOoxml(work_ooxml_package_attribute(column, 'totalsRowFunction'));
|
|
2706
|
+
const totalsLabel = normalizeSpreadsheetTableTotalsLabel(work_ooxml_package_attribute(column, 'totalsRowLabel'));
|
|
2707
|
+
const totalsFormula = normalizeSpreadsheetTableTotalsFormula(directChild(column, 'totalsRowFormula')?.textContent);
|
|
2708
|
+
const normalizedTotalsFunction = totalsFormula ? 'custom' : totalsFunction;
|
|
2709
|
+
return [
|
|
2704
2710
|
{
|
|
2705
|
-
name: columnName
|
|
2711
|
+
name: columnName,
|
|
2712
|
+
...calculatedFormula ? {
|
|
2713
|
+
calculatedFormula
|
|
2714
|
+
} : {},
|
|
2715
|
+
...normalizedTotalsFunction ? {
|
|
2716
|
+
totalsFunction: normalizedTotalsFunction
|
|
2717
|
+
} : {},
|
|
2718
|
+
...totalsLabel && !totalsFormula ? {
|
|
2719
|
+
totalsLabel
|
|
2720
|
+
} : {},
|
|
2721
|
+
...totalsFormula ? {
|
|
2722
|
+
totalsFormula
|
|
2723
|
+
} : {}
|
|
2706
2724
|
}
|
|
2707
2725
|
];
|
|
2708
2726
|
});
|
|
@@ -2742,7 +2760,26 @@ function xlsxTableXml(table, tableId, namespace) {
|
|
|
2742
2760
|
]);
|
|
2743
2761
|
const displayName = table.displayName?.trim() || table.name;
|
|
2744
2762
|
const filter = table.headerRow ? xlsxTableAutoFilterXml(table.filters, reference, table.totalsRow) : '';
|
|
2745
|
-
const columns = table.columns.map((column, index)
|
|
2763
|
+
const columns = table.columns.map((column, index)=>{
|
|
2764
|
+
const formula = normalizeSpreadsheetTableCalculatedFormula(column.calculatedFormula);
|
|
2765
|
+
const formulaElement = formula ? `<calculatedColumnFormula>${work_xlsx_tables_escapeXml(formula.replace(/^=/, ''))}</calculatedColumnFormula>` : '';
|
|
2766
|
+
const totalsFunction = spreadsheetTableTotalsFunctionToOoxml(column.totalsFunction);
|
|
2767
|
+
const totalsLabel = normalizeSpreadsheetTableTotalsLabel(column.totalsLabel);
|
|
2768
|
+
const totalsFormula = normalizeSpreadsheetTableTotalsFormula(column.totalsFormula);
|
|
2769
|
+
const attributes = [
|
|
2770
|
+
`id="${index + 1}"`,
|
|
2771
|
+
`name="${work_xlsx_tables_escapeXml(column.name)}"`,
|
|
2772
|
+
...totalsFunction ? [
|
|
2773
|
+
`totalsRowFunction="${work_xlsx_tables_escapeXml(totalsFunction)}"`
|
|
2774
|
+
] : [],
|
|
2775
|
+
...totalsLabel && !totalsFormula ? [
|
|
2776
|
+
`totalsRowLabel="${work_xlsx_tables_escapeXml(totalsLabel)}"`
|
|
2777
|
+
] : []
|
|
2778
|
+
].join(' ');
|
|
2779
|
+
const totalsFormulaElement = totalsFormula ? `<totalsRowFormula>${work_xlsx_tables_escapeXml(totalsFormula.replace(/^=/, ''))}</totalsRowFormula>` : '';
|
|
2780
|
+
const children = `${formulaElement}${totalsFormulaElement}`;
|
|
2781
|
+
return children ? `<tableColumn ${attributes}>${children}</tableColumn>` : `<tableColumn ${attributes}/>`;
|
|
2782
|
+
}).join('');
|
|
2746
2783
|
const styleName = tableStyleName(table.style);
|
|
2747
2784
|
const style = styleName ? `<tableStyleInfo name="${styleName}" showColumnStripes="${booleanToken(table.showColumnStripes)}" showFirstColumn="${booleanToken(table.showFirstColumn)}" showLastColumn="${booleanToken(table.showLastColumn)}" showRowStripes="${booleanToken(table.showRowStripes)}"/>` : '';
|
|
2748
2785
|
return [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Op, type Sheet } from '@fortune-sheet/core';
|
|
2
2
|
import type { OfficeKernelSpreadsheetCalculatedCell, OfficeKernelSpreadsheetCoordinate, OfficeKernelSpreadsheetSessionUpdate } from '../../../kernel/office-kernel-protocol';
|
|
3
|
-
import type { SpreadsheetCalculationCommand } from './spreadsheet-command-controller';
|
|
4
3
|
import { type SpreadsheetKernelFallbackCell, type SpreadsheetKernelWorkbook } from './spreadsheet-calculation-projection';
|
|
4
|
+
import type { SpreadsheetCalculationCommand } from './spreadsheet-command-controller';
|
|
5
5
|
export declare function spreadsheetCalculationTargets(workbook: SpreadsheetKernelWorkbook, command: SpreadsheetCalculationCommand): OfficeKernelSpreadsheetCoordinate[] | undefined;
|
|
6
6
|
export declare function spreadsheetCalculationSessionUpdate(previous: SpreadsheetKernelWorkbook | null, current: SpreadsheetKernelWorkbook, baseDocumentRevision: number, forceReplace?: boolean): OfficeKernelSpreadsheetSessionUpdate;
|
|
7
7
|
export declare function spreadsheetCalculationFallbackCells(workbook: SpreadsheetKernelWorkbook, command: SpreadsheetCalculationCommand, includeDataTables?: boolean): SpreadsheetKernelFallbackCell[];
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { Op, Sheet } from '@fortune-sheet/core';
|
|
2
2
|
import type { OfficeKernelSpreadsheetCoordinate, OfficeKernelSpreadsheetInputCell, OfficeKernelSpreadsheetInputSheet, OfficeKernelSpreadsheetSessionCellChange } from '../../../kernel/office-kernel-protocol';
|
|
3
|
-
import type { WorkSpreadsheetContent, WorkSpreadsheetFormulaRangeType, WorkSpreadsheetSheet } from '../work-types';
|
|
3
|
+
import type { WorkSpreadsheetContent, WorkSpreadsheetFormulaRangeType, WorkSpreadsheetSheet, WorkSpreadsheetTable } from '../work-types';
|
|
4
4
|
export declare const SPREADSHEET_KERNEL_MAX_PATCH_CELLS = 10000;
|
|
5
|
+
type SpreadsheetKernelSheet = Sheet & {
|
|
6
|
+
tables?: WorkSpreadsheetTable[];
|
|
7
|
+
};
|
|
5
8
|
export interface SpreadsheetKernelWorkbook {
|
|
6
9
|
fallbackCells: SpreadsheetKernelFallbackCell[];
|
|
7
10
|
sheets: OfficeKernelSpreadsheetInputSheet[];
|
|
@@ -34,7 +37,7 @@ export declare function createSpreadsheetKernelWorkbook(content: Pick<WorkSpread
|
|
|
34
37
|
* snapshot from the updated controlled content.
|
|
35
38
|
*/
|
|
36
39
|
export declare function prepareSpreadsheetKernelWorkbook(content: Pick<WorkSpreadsheetContent, 'sheets'>): SpreadsheetKernelWorkbookPreparation;
|
|
37
|
-
export declare function refreshSpreadsheetKernelWorkbook(sheets: readonly
|
|
40
|
+
export declare function refreshSpreadsheetKernelWorkbook(sheets: readonly SpreadsheetKernelSheet[], fallbackCells: readonly SpreadsheetKernelFallbackCell[]): SpreadsheetKernelWorkbook | null;
|
|
38
41
|
export declare function projectSpreadsheetKernelWorkbookOperations(previous: SpreadsheetKernelWorkbook, sheets: readonly WorkSpreadsheetSheet[], operations: readonly Op[]): SpreadsheetKernelOperationProjection | null;
|
|
39
42
|
export declare function spreadsheetOperationsMayChangeCalculation(operations: readonly Op[], workbook?: SpreadsheetKernelWorkbook | null): boolean;
|
|
40
43
|
export declare function spreadsheetKernelCellKey(cell: Pick<OfficeKernelSpreadsheetInputCell, 'row' | 'column'>): string;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Cell } from '@fortune-sheet/core';
|
|
2
|
+
import type { WorkSpreadsheetSheet, WorkSpreadsheetTable, WorkSpreadsheetTableColumn } from '../work-types';
|
|
3
|
+
/** Keep calculated-column metadata small enough to cross every editor boundary. */
|
|
4
|
+
export declare const MAX_SPREADSHEET_TABLE_CALCULATED_FORMULA_LENGTH = 8192;
|
|
5
|
+
/**
|
|
6
|
+
* Normalizes the editable form of a table-column formula. Native table parts
|
|
7
|
+
* omit the leading `=`, while cell formulas and the calculation kernel keep
|
|
8
|
+
* it. Unsafe or external formulas are deliberately not treated as automatic
|
|
9
|
+
* fill rules.
|
|
10
|
+
*/
|
|
11
|
+
export declare function normalizeSpreadsheetTableCalculatedFormula(value: unknown): string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Finds a shared current-row formula already authored in a table column.
|
|
14
|
+
* Ordinary one-off A1 formulas are intentionally ignored so inserting a row
|
|
15
|
+
* cannot unexpectedly overwrite a user's manual exception.
|
|
16
|
+
*/
|
|
17
|
+
export declare function inferredSpreadsheetTableCalculatedFormula(sheet: WorkSpreadsheetSheet, table: WorkSpreadsheetTable, columnOffset: number): string | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Reconciles declared calculated-column formulas with formulas authored in the
|
|
20
|
+
* controlled cell matrix. A conflicting column is made manual instead of
|
|
21
|
+
* guessing which formula should be copied into a new row.
|
|
22
|
+
*/
|
|
23
|
+
export declare function reconcileSpreadsheetTableCalculatedColumns(sheet: WorkSpreadsheetSheet, table: WorkSpreadsheetTable): WorkSpreadsheetTableColumn[];
|
|
24
|
+
/** Returns true only for a formula safe to copy into a new table row. */
|
|
25
|
+
export declare function isSpreadsheetTableCalculatedFormula(value: unknown): value is string;
|
|
26
|
+
/**
|
|
27
|
+
* Applies calculated-column formulas to newly inserted body rows. The helper
|
|
28
|
+
* deliberately edits only empty cells; copied values and authored exceptions
|
|
29
|
+
* remain authoritative. Both Fortune's dense matrix and sparse `celldata`
|
|
30
|
+
* storage are updated without materializing unrelated rows or columns.
|
|
31
|
+
*/
|
|
32
|
+
export declare function fillSpreadsheetTableCalculatedColumns(sheet: WorkSpreadsheetSheet, table: WorkSpreadsheetTable, rows: readonly number[]): WorkSpreadsheetSheet;
|
|
33
|
+
export declare function spreadsheetTableCellAt(sheet: WorkSpreadsheetSheet, row: number, column: number): Cell | null;
|
|
34
|
+
export declare function spreadsheetTableCellIsEmpty(cell: Cell | null | undefined): boolean;
|
|
35
|
+
/** Copy visual cell metadata without carrying a stale cached formula result. */
|
|
36
|
+
export declare function spreadsheetCellWithCalculatedFormula(source: Cell | null | undefined, formula: string): Cell;
|
|
37
|
+
/** Iterate formula-bearing cells without forcing a dense worksheet matrix. */
|
|
38
|
+
export declare function spreadsheetTableFormulaCells(sheet: WorkSpreadsheetSheet): Array<{
|
|
39
|
+
cell: Cell;
|
|
40
|
+
column: number;
|
|
41
|
+
row: number;
|
|
42
|
+
}>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { WorkSpreadsheetSheet, WorkSpreadsheetTable, WorkSpreadsheetTableColumn, WorkSpreadsheetTableTotalsFunction } from '../work-types';
|
|
2
|
+
export declare const MAX_SPREADSHEET_TABLE_TOTALS_FORMULA_LENGTH = 8192;
|
|
3
|
+
export declare const MAX_SPREADSHEET_TABLE_TOTALS_LABEL_LENGTH = 255;
|
|
4
|
+
export declare const DEFAULT_SPREADSHEET_TABLE_TOTALS_LABEL = "Total";
|
|
5
|
+
/** The closed function set exposed by the Table Design totals menu. */
|
|
6
|
+
export declare const SPREADSHEET_TABLE_TOTALS_FUNCTIONS: readonly ["sum", "average", "count", "countNums", "max", "min", "stdDev", "stdDevP", "var", "varP", "custom"];
|
|
7
|
+
export interface SpreadsheetTableTotalsColumnPatch {
|
|
8
|
+
totalsFormula?: string | null;
|
|
9
|
+
totalsFunction?: WorkSpreadsheetTableTotalsFunction | null;
|
|
10
|
+
totalsLabel?: string | null;
|
|
11
|
+
}
|
|
12
|
+
export declare function spreadsheetTableTotalsFunctionLabel(value: WorkSpreadsheetTableTotalsFunction | undefined): string;
|
|
13
|
+
export declare function normalizeSpreadsheetTableTotalsFunction(value: unknown): WorkSpreadsheetTableTotalsFunction | undefined;
|
|
14
|
+
/** Normalize a table totals formula to the editable leading-equals form. */
|
|
15
|
+
export declare function normalizeSpreadsheetTableTotalsFormula(value: unknown): string | undefined;
|
|
16
|
+
export declare function normalizeSpreadsheetTableTotalsLabel(value: unknown): string | undefined;
|
|
17
|
+
export declare function spreadsheetTableTotalsFunctionFromOoxml(value: unknown): WorkSpreadsheetTableTotalsFunction | undefined;
|
|
18
|
+
export declare function spreadsheetTableTotalsFunctionToOoxml(value: WorkSpreadsheetTableTotalsFunction | undefined): string | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Returns the formula that should be placed in one totals-row cell. Native
|
|
21
|
+
* aggregate functions use SUBTOTAL so filtered-out rows stay excluded; a
|
|
22
|
+
* custom rule uses its explicit formula.
|
|
23
|
+
*/
|
|
24
|
+
export declare function spreadsheetTableTotalsFormula(table: WorkSpreadsheetTable, columnOffset: number): string | undefined;
|
|
25
|
+
export declare function spreadsheetTableTotalsColumnPatch(columns: readonly WorkSpreadsheetTableColumn[], patches: Readonly<Record<string, SpreadsheetTableTotalsColumnPatch>> | readonly (SpreadsheetTableTotalsColumnPatch | null | undefined)[] | undefined): WorkSpreadsheetTableColumn[] | null;
|
|
26
|
+
/** Apply the native default label used when a totals row is first enabled. */
|
|
27
|
+
export declare function withDefaultSpreadsheetTableTotalsLabel(columns: readonly WorkSpreadsheetTableColumn[], totalsRow: boolean): WorkSpreadsheetTableColumn[];
|
|
28
|
+
/** True when a proposed totals row would overwrite a populated cell. */
|
|
29
|
+
export declare function spreadsheetTableTotalsRowHasContent(sheet: WorkSpreadsheetSheet, table: WorkSpreadsheetTable, row?: number): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Synchronize totals-row cells after a table metadata change. Explicitly
|
|
32
|
+
* changed column metadata owns the target cell; untouched manual cells remain
|
|
33
|
+
* authoritative. The helper works with Fortune's dense and sparse forms.
|
|
34
|
+
*/
|
|
35
|
+
export declare function synchronizeSpreadsheetTableTotalsRow(sheet: WorkSpreadsheetSheet, previousTable: WorkSpreadsheetTable | undefined, nextTable: WorkSpreadsheetTable, options?: {
|
|
36
|
+
force?: boolean;
|
|
37
|
+
}): WorkSpreadsheetSheet;
|
|
38
|
+
/** Reconcile metadata after a user edits a totals-row cell directly. */
|
|
39
|
+
export declare function reconcileSpreadsheetTableTotalsColumns(sheet: WorkSpreadsheetSheet, table: WorkSpreadsheetTable, editedOffsets?: ReadonlySet<number>): WorkSpreadsheetTableColumn[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Selection } from '@fortune-sheet/core';
|
|
2
2
|
import type { WorkSpreadsheetContent, WorkSpreadsheetSheet, WorkSpreadsheetTable, WorkSpreadsheetTableStyle } from '../work-types';
|
|
3
3
|
import { type SpreadsheetCellRange } from './spreadsheet-cell-range';
|
|
4
|
+
import { type SpreadsheetTableTotalsColumnPatch } from './spreadsheet-table-totals';
|
|
4
5
|
export { MAX_SPREADSHEET_TABLE_CELLS } from './spreadsheet-table-limits';
|
|
5
6
|
export interface SpreadsheetTableTarget {
|
|
6
7
|
sheetId: string;
|
|
@@ -9,6 +10,7 @@ export interface SpreadsheetTableTarget {
|
|
|
9
10
|
export interface SpreadsheetTableDialogValue {
|
|
10
11
|
headerRow: boolean;
|
|
11
12
|
rangeReference: string;
|
|
13
|
+
totalsRow?: boolean;
|
|
12
14
|
}
|
|
13
15
|
export interface SpreadsheetTableDialogSource {
|
|
14
16
|
name: string;
|
|
@@ -24,6 +26,10 @@ export interface SpreadsheetTableRequest {
|
|
|
24
26
|
range: SpreadsheetCellRange;
|
|
25
27
|
sheetId: string;
|
|
26
28
|
style?: WorkSpreadsheetTableStyle;
|
|
29
|
+
/** Create the table with a native totals row appended to the range. */
|
|
30
|
+
totalsRow?: boolean;
|
|
31
|
+
/** Initial per-column totals metadata, keyed by zero-based table offset. */
|
|
32
|
+
totalsColumns?: Readonly<Record<string, SpreadsheetTableTotalsColumnPatch>> | readonly (SpreadsheetTableTotalsColumnPatch | null | undefined)[];
|
|
27
33
|
}
|
|
28
34
|
export type SpreadsheetTableValidation = {
|
|
29
35
|
columns: string[];
|
|
@@ -36,7 +42,7 @@ export type SpreadsheetTableValidation = {
|
|
|
36
42
|
message: string;
|
|
37
43
|
ok: false;
|
|
38
44
|
};
|
|
39
|
-
export type SpreadsheetTableErrorCode = 'auto-filter-overlap' | 'invalid-column-name' | 'invalid-name' | 'invalid-range' | 'invalid-style' | 'merged-range' | 'name-conflict' | 'out-of-bounds' | 'protected-range' | 'pivot-table' | 'range-too-large' | 'sheet-not-found' | 'table-overlap';
|
|
45
|
+
export type SpreadsheetTableErrorCode = 'auto-filter-overlap' | 'invalid-column-name' | 'invalid-name' | 'invalid-range' | 'invalid-style' | 'invalid-totals' | 'merged-range' | 'name-conflict' | 'out-of-bounds' | 'protected-range' | 'pivot-table' | 'range-too-large' | 'sheet-not-found' | 'table-overlap' | 'totals-row-content';
|
|
40
46
|
export interface SpreadsheetTableDesignPatch {
|
|
41
47
|
name?: string;
|
|
42
48
|
showColumnStripes?: boolean;
|
|
@@ -44,6 +50,10 @@ export interface SpreadsheetTableDesignPatch {
|
|
|
44
50
|
showLastColumn?: boolean;
|
|
45
51
|
showRowStripes?: boolean;
|
|
46
52
|
style?: WorkSpreadsheetTableStyle;
|
|
53
|
+
/** Toggle the native totals row. Enabling appends one row to the table. */
|
|
54
|
+
totalsRow?: boolean;
|
|
55
|
+
/** Update per-column totals function, label, or custom formula. */
|
|
56
|
+
totalsColumns?: Readonly<Record<string, SpreadsheetTableTotalsColumnPatch>> | readonly (SpreadsheetTableTotalsColumnPatch | null | undefined)[];
|
|
47
57
|
}
|
|
48
58
|
export declare function createSpreadsheetTableDialogSource(content: WorkSpreadsheetContent, target: SpreadsheetTableTarget): SpreadsheetTableDialogSource | null;
|
|
49
59
|
export declare function spreadsheetTableRangeFromText(value: string): SpreadsheetCellRange | null;
|
|
@@ -236,7 +236,26 @@ export type WorkSpreadsheetTableStyle = {
|
|
|
236
236
|
};
|
|
237
237
|
export interface WorkSpreadsheetTableColumn {
|
|
238
238
|
name: string;
|
|
239
|
-
|
|
239
|
+
/**
|
|
240
|
+
* A bounded native table calculated-column formula. The controlled model
|
|
241
|
+
* stores the editable form with a leading `=`; XLSX table parts omit it.
|
|
242
|
+
*/
|
|
243
|
+
calculatedFormula?: string;
|
|
244
|
+
/**
|
|
245
|
+
* Native totals-row aggregation. An omitted value means that the totals
|
|
246
|
+
* cell is not owned by the table. The controlled model uses camelCase names
|
|
247
|
+
* while XLSX table parts use their OOXML spellings.
|
|
248
|
+
*/
|
|
249
|
+
totalsFunction?: WorkSpreadsheetTableTotalsFunction;
|
|
250
|
+
/** Optional text label rendered in this column's totals-row cell. */
|
|
251
|
+
totalsLabel?: string;
|
|
252
|
+
/**
|
|
253
|
+
* A bounded custom totals-row formula. The controlled model stores the
|
|
254
|
+
* editable form with a leading `=`; XLSX table parts omit it.
|
|
255
|
+
*/
|
|
256
|
+
totalsFormula?: string;
|
|
257
|
+
}
|
|
258
|
+
export type WorkSpreadsheetTableTotalsFunction = 'sum' | 'average' | 'count' | 'countNums' | 'max' | 'min' | 'stdDev' | 'stdDevP' | 'var' | 'varP' | 'custom';
|
|
240
259
|
export type WorkSpreadsheetDynamicFilter = 'above-average' | 'below-average' | 'tomorrow' | 'today' | 'yesterday' | 'next-week' | 'this-week' | 'last-week' | 'next-month' | 'this-month' | 'last-month' | 'next-quarter' | 'this-quarter' | 'last-quarter' | 'next-year' | 'this-year' | 'last-year' | 'year-to-date' | 'quarter-1' | 'quarter-2' | 'quarter-3' | 'quarter-4' | 'month-1' | 'month-2' | 'month-3' | 'month-4' | 'month-5' | 'month-6' | 'month-7' | 'month-8' | 'month-9' | 'month-10' | 'month-11' | 'month-12';
|
|
241
260
|
export type WorkSpreadsheetTableFilterCriteria = {
|
|
242
261
|
type: 'values';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OFFICE_KERNEL_PROTOCOL_VERSION } from './office-kernel-version';
|
|
2
|
+
export type { OfficeKernelSpreadsheetCalculatedCell, OfficeKernelSpreadsheetCalculationIssue, OfficeKernelSpreadsheetCalculationRequest, OfficeKernelSpreadsheetCalculationResult, OfficeKernelSpreadsheetCoordinate, OfficeKernelSpreadsheetError, OfficeKernelSpreadsheetInputCell, OfficeKernelSpreadsheetInputSheet, OfficeKernelSpreadsheetInputTable, OfficeKernelSpreadsheetSessionCalculationRequest, OfficeKernelSpreadsheetSessionCalculationResult, OfficeKernelSpreadsheetSessionCalculationScope, OfficeKernelSpreadsheetSessionCalculationStats, OfficeKernelSpreadsheetSessionCellChange, OfficeKernelSpreadsheetSessionUpdate, OfficeKernelSpreadsheetValue, } from './office-kernel-spreadsheet-protocol';
|
|
2
3
|
export { OFFICE_KERNEL_PROTOCOL_VERSION };
|
|
3
|
-
export type { OfficeKernelSpreadsheetCalculatedCell, OfficeKernelSpreadsheetCalculationIssue, OfficeKernelSpreadsheetCalculationRequest, OfficeKernelSpreadsheetCalculationResult, OfficeKernelSpreadsheetCoordinate, OfficeKernelSpreadsheetError, OfficeKernelSpreadsheetInputCell, OfficeKernelSpreadsheetInputSheet, OfficeKernelSpreadsheetSessionCalculationRequest, OfficeKernelSpreadsheetSessionCalculationResult, OfficeKernelSpreadsheetSessionCalculationScope, OfficeKernelSpreadsheetSessionCalculationStats, OfficeKernelSpreadsheetSessionCellChange, OfficeKernelSpreadsheetSessionUpdate, OfficeKernelSpreadsheetValue, } from './office-kernel-spreadsheet-protocol';
|
|
4
4
|
import type { OfficeKernelSpreadsheetCalculationRequest, OfficeKernelSpreadsheetCalculationResult, OfficeKernelSpreadsheetSessionCalculationRequest, OfficeKernelSpreadsheetSessionCalculationResult } from './office-kernel-spreadsheet-protocol';
|
|
5
5
|
export type OfficeKernelEngine = 'wasm' | 'javascript';
|
|
6
6
|
export interface OfficeKernelPageMetrics {
|
|
@@ -1,3 +1,14 @@
|
|
|
1
1
|
export declare const browserScalarFunctionArities: Map<string, readonly [minimum: number, maximum: number]>;
|
|
2
2
|
export declare function normalizeSpreadsheetFunctionName(name: string): string;
|
|
3
|
+
/**
|
|
4
|
+
* Evaluate the bounded browser implementation of `SUBTOTAL`.
|
|
5
|
+
*
|
|
6
|
+
* Fortune delegates unknown functions to Formula.js. Formula.js returns an
|
|
7
|
+
* undefined value for an unknown function number, which the parser can then
|
|
8
|
+
* coerce into a boolean. Keeping this small implementation here makes the
|
|
9
|
+
* JavaScript fallback deterministic and aligned with the Rust kernel. The
|
|
10
|
+
* calculation request does not carry hidden-row metadata yet, so the 1–11
|
|
11
|
+
* and 101–111 function-number families intentionally have the same result.
|
|
12
|
+
*/
|
|
13
|
+
export declare function evaluateParserSubtotal(parameters: readonly unknown[]): unknown;
|
|
3
14
|
export declare function normalizeFormulaForFortuneParser(formula: string): string;
|
|
@@ -29,10 +29,28 @@ export interface OfficeKernelSpreadsheetInputCell {
|
|
|
29
29
|
formula?: string;
|
|
30
30
|
value: OfficeKernelSpreadsheetValue;
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* The bounded table metadata needed to resolve native structured references.
|
|
34
|
+
* Ranges are zero-based and inclusive, matching the controlled workbook
|
|
35
|
+
* model. Styling, filters, and drawing metadata intentionally stay outside
|
|
36
|
+
* the calculation kernel.
|
|
37
|
+
*/
|
|
38
|
+
export interface OfficeKernelSpreadsheetInputTable {
|
|
39
|
+
name: string;
|
|
40
|
+
displayName?: string;
|
|
41
|
+
startRow: number;
|
|
42
|
+
endRow: number;
|
|
43
|
+
startColumn: number;
|
|
44
|
+
endColumn: number;
|
|
45
|
+
columns: string[];
|
|
46
|
+
headerRow: boolean;
|
|
47
|
+
totalsRow: boolean;
|
|
48
|
+
}
|
|
32
49
|
export interface OfficeKernelSpreadsheetInputSheet {
|
|
33
50
|
id: string;
|
|
34
51
|
name: string;
|
|
35
52
|
cells: OfficeKernelSpreadsheetInputCell[];
|
|
53
|
+
tables?: OfficeKernelSpreadsheetInputTable[];
|
|
36
54
|
}
|
|
37
55
|
export interface OfficeKernelSpreadsheetCalculationRequest {
|
|
38
56
|
protocol: typeof OFFICE_KERNEL_PROTOCOL_VERSION;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { OfficeKernelSpreadsheetInputSheet } from './office-kernel-spreadsheet-protocol';
|
|
2
|
+
export interface SpreadsheetStructuredRowSelection {
|
|
3
|
+
all: boolean;
|
|
4
|
+
headers: boolean;
|
|
5
|
+
data: boolean;
|
|
6
|
+
totals: boolean;
|
|
7
|
+
current: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface SpreadsheetStructuredReference {
|
|
10
|
+
tableName?: string;
|
|
11
|
+
firstColumn?: string;
|
|
12
|
+
lastColumn?: string;
|
|
13
|
+
rows: SpreadsheetStructuredRowSelection;
|
|
14
|
+
}
|
|
15
|
+
export interface SpreadsheetStructuredReferenceArea {
|
|
16
|
+
sheetId: string;
|
|
17
|
+
sheetName: string;
|
|
18
|
+
startRow: number;
|
|
19
|
+
endRow: number;
|
|
20
|
+
startColumn: number;
|
|
21
|
+
endColumn: number;
|
|
22
|
+
}
|
|
23
|
+
export type SpreadsheetStructuredReferenceErrorKind = 'invalid' | 'unsupported' | 'missing-table' | 'missing-column';
|
|
24
|
+
export declare class SpreadsheetStructuredReferenceError extends Error {
|
|
25
|
+
readonly kind: SpreadsheetStructuredReferenceErrorKind;
|
|
26
|
+
constructor(kind: SpreadsheetStructuredReferenceErrorKind, message: string);
|
|
27
|
+
}
|
|
28
|
+
/** Parse one bounded table-reference token using the OOXML column grammar. */
|
|
29
|
+
export declare function parseSpreadsheetStructuredReference(reference: string): SpreadsheetStructuredReference;
|
|
30
|
+
/**
|
|
31
|
+
* Catalog the semantic tables in a workbook and resolve references to bounded
|
|
32
|
+
* zero-based rectangular areas. The catalog deliberately contains no cells;
|
|
33
|
+
* values remain in the calculation evaluator so dependencies stay observable.
|
|
34
|
+
*/
|
|
35
|
+
export declare class SpreadsheetStructuredReferenceCatalog {
|
|
36
|
+
readonly sheets: readonly OfficeKernelSpreadsheetInputSheet[];
|
|
37
|
+
private readonly definitions;
|
|
38
|
+
private readonly byName;
|
|
39
|
+
private readonly bySheet;
|
|
40
|
+
constructor(sheets: readonly OfficeKernelSpreadsheetInputSheet[]);
|
|
41
|
+
resolve(qualifier: string | undefined, reference: string, currentSheet: OfficeKernelSpreadsheetInputSheet, currentColumn: number, currentRow: number): SpreadsheetStructuredReferenceArea[];
|
|
42
|
+
private resolveTable;
|
|
43
|
+
private resolveColumns;
|
|
44
|
+
private resolveRows;
|
|
45
|
+
private dataRows;
|
|
46
|
+
}
|
|
47
|
+
/** Expand structured tokens to A1 ranges before invoking the scalar parser. */
|
|
48
|
+
export declare function expandSpreadsheetStructuredReferences(formula: string, catalog: SpreadsheetStructuredReferenceCatalog, currentSheet: OfficeKernelSpreadsheetInputSheet, currentRow: number, currentColumn: number): string;
|
package/dist/office-kernel.wasm
CHANGED
|
Binary file
|