@fileverse-dev/dsheet 3.0.0 → 3.0.1-formula-1

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 (51) hide show
  1. package/dist/{constants-yStXQJiK.js → constants-Cdz6oSCq.js} +5 -7
  2. package/dist/constants.js +1 -1
  3. package/dist/editor/components/editor-workbook-sync.d.ts +1 -1
  4. package/dist/editor/components/sidebar/use-right-panels.d.ts +1 -1
  5. package/dist/editor/components/sidebars/named-ranges.d.ts +2 -0
  6. package/dist/editor/constants/shared-constants.d.ts +0 -2
  7. package/dist/editor/hooks/use-celldata-compaction.d.ts +23 -0
  8. package/dist/editor/hooks/use-xlsx-import-impl.d.ts +2 -1
  9. package/dist/editor/hooks/use-xlsx-import.d.ts +2 -1
  10. package/dist/editor/utils/compact-committed-celldata.d.ts +28 -0
  11. package/dist/editor/utils/config-ydoc-update.d.ts +20 -0
  12. package/dist/editor/utils/defined-names-ydoc.d.ts +31 -0
  13. package/dist/editor/utils/update-ydoc.d.ts +2 -2
  14. package/dist/editor/utils/xlsx-defined-names.d.ts +41 -0
  15. package/dist/executeStringFunction-DMPoSj5F.js +32826 -0
  16. package/dist/formula.js +1 -1
  17. package/dist/{index-CBzFxleP.js → index-DAVuAF9T.js} +23852 -26202
  18. package/dist/index.es.js +39 -39
  19. package/dist/jszip.min-CEyB-71x.js +2319 -0
  20. package/dist/sheet-engine/core/api/cell.d.ts +0 -20
  21. package/dist/sheet-engine/core/api/common.d.ts +2 -1
  22. package/dist/sheet-engine/core/api/index.d.ts +1 -0
  23. package/dist/sheet-engine/core/api/sheet-flowdata-lifecycle.d.ts +17 -0
  24. package/dist/sheet-engine/core/api/sheet.d.ts +5 -0
  25. package/dist/sheet-engine/core/context.d.ts +3 -1
  26. package/dist/sheet-engine/core/index.d.ts +2 -2
  27. package/dist/sheet-engine/core/modules/formula-snapshot-eval.d.ts +11 -0
  28. package/dist/sheet-engine/core/modules/formula-worker-bridge.d.ts +1 -0
  29. package/dist/sheet-engine/core/modules/formula.d.ts +27 -0
  30. package/dist/sheet-engine/core/modules/index.d.ts +3 -2
  31. package/dist/sheet-engine/core/modules/namedRanges.d.ts +53 -0
  32. package/dist/sheet-engine/core/modules/sheet-metadata-hooks.d.ts +4 -0
  33. package/dist/sheet-engine/core/modules/sheet.d.ts +17 -1
  34. package/dist/sheet-engine/core/paste/paste-border-utils.d.ts +23 -0
  35. package/dist/sheet-engine/core/settings.d.ts +3 -1
  36. package/dist/sheet-engine/core/types.d.ts +20 -0
  37. package/dist/sheet-engine/core/utils/border-config-utils.d.ts +16 -0
  38. package/dist/sheet-engine/core/utils/cell-persist-utils.d.ts +10 -0
  39. package/dist/sheet-engine/core/utils/range-format.d.ts +71 -0
  40. package/dist/sheet-engine/core/utils/ydoc-celldata-changes.d.ts +40 -0
  41. package/dist/sheet-engine/react/components/NamedRanges/index.d.ts +4 -0
  42. package/dist/sheet-engine/react/components/Workbook/api.d.ts +8 -1
  43. package/dist/sheet-engine/react/components/Workbook/index.d.ts +5 -1
  44. package/dist/style.css +1 -1
  45. package/dist/use-xlsx-import-impl-DzthrhwA.js +1595 -0
  46. package/dist/xlsx-defined-names-D2KoICbm.js +117 -0
  47. package/dist/xlsx-export-impl-b2z4De4f.js +818 -0
  48. package/package.json +2 -2
  49. package/dist/executeStringFunction-C5hEkx9z.js +0 -27694
  50. package/dist/use-xlsx-import-impl-C_npga_I.js +0 -1537
  51. package/dist/xlsx-export-impl-C2cU3lhm.js +0 -3126
@@ -6,26 +6,6 @@ export declare function getCellValue(ctx: Context, row: number, column: number,
6
6
  type?: keyof Cell;
7
7
  }): any;
8
8
  export declare function setCellValue(ctx: Context, row: number, column: number, value: any, cellInput: HTMLDivElement | null, options?: CommonOptions, callAfterUpdate?: boolean): void;
9
- /**
10
- * Apply a cell value coming from a remote RTC peer, verbatim.
11
- *
12
- * This differs from `setCellValue` in two important ways and must be used for
13
- * every Yjs-driven remote apply:
14
- *
15
- * 1. It NEVER runs the formula engine and NEVER fires the local-edit hooks
16
- * (`onLocalCellEdit` / `afterUpdateCell`). The peer already computed the
17
- * value, so we use the synced `v`/`m`/`f` as-is. This avoids both
18
- * recomputation divergence and an update loop back into Yjs.
19
- *
20
- * 2. It PRESERVES the formula calc list. The regular `setCellValue` object
21
- * branch calls `delFunctionGroup`, which removes the cell from `calcChain`
22
- * and strips its dependency edges. Because `execFunctionGroup` walks
23
- * `calcChain` to decide what to recompute, dropping a formula cell there
24
- * permanently breaks its reactivity on that client (even after RTC stops).
25
- * Here we instead keep formula cells registered via
26
- * `insertUpdateFunctionGroup`, so they stay reactive to future local edits
27
- * on both owner and peer.
28
- */
29
9
  export declare function applyRemoteCellValue(ctx: Context, row: number, column: number, value: any, options?: CommonOptions): void;
30
10
  export declare function clearCell(ctx: Context, row: number, column: number, options?: CommonOptions): void;
31
11
  export declare function setCellFormat(ctx: Context, row: number, column: number, attr: keyof Cell, value: any, options?: CommonOptions): void;
@@ -1,12 +1,13 @@
1
1
  import { Context } from '../context';
2
2
  import { CellMatrix, CellWithRowAndCol, Sheet } from '../types';
3
+ import { CellFormatRange } from '../utils/range-format';
3
4
 
4
5
  export type CommonOptions = {
5
6
  index?: number;
6
7
  id?: string;
7
8
  };
8
9
  export declare const dataToCelldata: (data: CellMatrix | undefined) => CellWithRowAndCol[];
9
- export declare const celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number, colCount?: number) => CellMatrix | null;
10
+ export declare const celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number, colCount?: number, cellFormatRanges?: CellFormatRange[]) => CellMatrix | null;
10
11
  export declare function getSheet(ctx: Context, options?: CommonOptions): Sheet;
11
12
  export declare function getSheetWithLatestCelldata(ctx: Context, options?: CommonOptions): {
12
13
  celldata: CellWithRowAndCol[];
@@ -7,5 +7,6 @@ export * from './rowcol';
7
7
  export * from './range';
8
8
  export * from './merge';
9
9
  export * from './sheet';
10
+ export * from './sheet-flowdata-lifecycle';
10
11
  export * from './workbook';
11
12
  export * from '../modules/error-state-helpers';
@@ -0,0 +1,17 @@
1
+ import { Context } from '../context';
2
+
3
+ /** Drop cached dense-sheet set (e.g. after structural workbook changes). */
4
+ export declare function invalidateSheetsRequiredDenseCache(): void;
5
+ /**
6
+ * Sheets that must keep dense `data` while `activeSheetId` is active:
7
+ * the active tab, tabs its formulas read, and tabs with formulas that read it.
8
+ */
9
+ export declare function getSheetsRequiredDense(ctx: Context, activeSheetId: string): Set<string>;
10
+ /** Sheets the formula worker needs dense — active refs plus any tab with formulas. */
11
+ export declare function getSheetsNeededForWorkerSnapshot(ctx: Context): Set<string>;
12
+ export declare function demoteSheetToCelldata(ctx: Context, sheetId: string): void;
13
+ /**
14
+ * On tab switch: persist outgoing config, demote tabs not needed dense,
15
+ * hydrate active tab + cross-sheet references.
16
+ */
17
+ export declare function syncAndDemoteInactiveFlowdata(ctx: Context, activeSheetId: string, previousSheetId: string | null): Set<string>;
@@ -5,6 +5,11 @@ import { CellMatrix, Sheet } from '../types';
5
5
  export declare function getAllSheets(ctx: Context): Sheet[];
6
6
  export { getSheet };
7
7
  export declare function initSheetData(draftCtx: Context, index: number, newData: Sheet): CellMatrix | null;
8
+ /** Build dense `data` from sparse `celldata` when a sheet is activated or referenced. */
9
+ export declare function ensureSheetFlowdata(ctx: Context, options?: {
10
+ index?: number;
11
+ id?: string;
12
+ }): CellMatrix | null;
8
13
  export declare function hideSheet(ctx: Context, sheetId: string): void;
9
14
  export declare function showSheet(ctx: Context, sheetId: string): void;
10
15
  export declare function copySheet(ctx: Context, sheetId: string): void;
@@ -1,4 +1,4 @@
1
- import { SheetConfig, Sheet, Selection, Cell, CommentBox, Rect, Image, Presence, LinkCardProps, FilterOptions, RangeDialogProps, DataRegulationProps, ConditionRulesProps, GlobalCache, CellError } from './types';
1
+ import { SheetConfig, Sheet, Selection, Cell, CommentBox, Rect, Image, Presence, LinkCardProps, FilterOptions, RangeDialogProps, DataRegulationProps, ConditionRulesProps, GlobalCache, CellError, DefinedName } from './types';
2
2
  import { FormulaCache } from './modules';
3
3
  import { FormulaAsyncEvalJob } from './modules/formula-async-eval';
4
4
  import { DateBaseLocale, Hooks } from './settings';
@@ -116,6 +116,8 @@ export type Context = {
116
116
  currentSheetId: string;
117
117
  calculateSheetId: string;
118
118
  config: SheetConfig;
119
+ /** Workbook-level named ranges (synced via Yjs `${dsheetId}:definedNames`). */
120
+ definedNames: DefinedName[];
119
121
  visibledatarow: number[];
120
122
  visibledatacolumn: number[];
121
123
  ch_width: number;
@@ -7,11 +7,11 @@ export { defaultSettings } from './settings';
7
7
  export type { Settings, Hooks, DateBaseLocale } from './settings';
8
8
  export { handleCopy, handleGlobalKeyDown, handlePaste, handlePasteByClick, fixPositionOnFrozenCells, handleCellAreaMouseDown, handleCellAreaDoubleClick, handleContextMenu, mouseRender, handleOverlayMouseMove, handleOverlayMouseUp, handleRowHeaderMouseDown, handleColumnHeaderMouseDown, handleColSizeHandleMouseDown, handleColSizeHandleDoubleClick, handleRowSizeHandleMouseDown, handleColFreezeHandleMouseDown, handleRowFreezeHandleMouseDown, describeMatchedShortcut, isBrowserZoomShortcut, isOpenShortcutsModalShortcut, isFormulaListShortcut, } from './events';
9
9
  export * from './locale';
10
- export { getBorderInfoComputeRange, getBorderInfoCompute, normalizedCellAttr, normalizedAttr, getCellValue, setCellValue, getRealCellValue, mergeBorder, cancelNormalSelected, updateCell, getRangetxt, getRangeByTxt, isValidRangeText, getInlineStringHTML, applyLinkToSelection, getHyperlinksFromInlineSegments, getUniformLinkFromWindowSelectionInEditor, getHyperlinkAtCaretInContentEditable, getStyleByCell, clearSelectedCellFormat, clearRowsCellsFormat, clearColumnsCellsFormat, clipboard, moveToEnd, getRangeRectsByCharacterOffset, getDateBaseLocale, getCanonicalDateEditFormat, getDateEditFormatForCell, isUsDateBaseLocale, normalizeDateBaseLocale, shouldPreserveDateFormatForEdit, setDateBaseLocale, update, is_date, valueShowEs, isTypedCurrencyDisplayFormat, isCurrencyLikeNumberFormat, buildFiatCurrencyFormat, quoteSsfLiteral, FormulaCache, groupValuesRefresh, execFunctionGroup, runFormulaEvalChunk, applyWorkerFormulaChunkResults, isFormulaEvalPending, FORMULA_ASYNC_CHUNK_SIZE, FORMULA_ASYNC_EVAL_THRESHOLD, FORMULA_WORKER_CHUNK_SIZE, FORMULA_WORKER_THRESHOLD, setCaretPosition, getrangeseleciton, getFormulaEditorOwner, rangeHightlightselected, handleFormulaInput, israngeseleciton, createRangeHightlight, maybeRecoverDirtyRangeSelection, getFormulaRangeIndexAtCaret, isCaretAtValidFormulaRangeInsertionPoint, isLegacyFormulaRangeMode, markRangeSelectionDirty, setFormulaEditorOwner, functionHTMLGenerate, suppressFormulaRangeSelectionForInitialEdit, rangeSetValue, getFormulaRangeIndexForKeyboardSync, createFormulaRangeSelect, isFormulaReferenceInputMode, seedFormulaFuncSelectedRangeFromLastSelection, initFreeze, isInlineStringCell, getInlineStringNoStyle, rowLocation, rowLocationByIndex, colLocation, colLocationByIndex, insertRowCol, deleteRowCol, hideSelected, showSelected, isShowHidenCR, getFilterHiddenRowsUnionFromFilterMap, getFilterHiddenRowsUnion, ensureManualHiddenInitialized, rebuildRowHiddenUnion, scrollToHighlightCell, selectTitlesMap, selectTitlesRange, defaultLuckysheetSelectRanges, normalizeSelection, syncPrimaryCellActiveFromSelection, selectionIsExactlyOneMergeBlock, setPrimaryCellActive, advancePrimaryCellInLastMultiSelection, snapSheetSelectionFocusToCellPreserveMultiRange, moveHighlightCell, deleteSelectedCellText, selectAll, fixRowStyleOverflowInFreeze, fixColumnStyleOverflowInFreeze, calcSelectionInfo, addSheet, deleteSheet, editSheetName, changeSheet, updateFormat, autoSelectionFormula, handleBold, handleItalic, handleStrikeThrough, handleUnderline, handleHorizontalAlign, handleVerticalAlign, handleTextColor, handleTextBackground, handleBorder, handleMerge, mergeSelectionHasValues, handleSort, getRemoveDuplicatesPreview, removeDuplicates, getRemoveDuplicatesErrorMessage, handleFreeze, handleTextSize, handleSum, handleLink, captureLinkEditorOpenSnapshot, isHyperlinkCreationBlocked, toolbarItemClickHandler, toolbarItemSelectedFunc, handleScreenShot, insertImage, showImgChooser, drawArrow, setEditingComment, removeEditingComment, removeOverShowComment, newComment, editComment, deleteComment, showComments, showHideComment, showHideAllComments, onCommentBoxMoveStart, removeActiveImage, cancelActiveImgItem, onImageMoveStart, onImageResizeStart, createDropCellRange, sortSelection, sortSheetBySelectedColumn, searchAll, searchNext, replace, replaceAll, replaceAllScoped, getSearchIndexArr, getSearchIndexArrAsync, getFindRangeOnCurrentSheet, getQuickSearchIndexArr, getQuickSearchHiddenConfig, getCellHyperlinks, getHyperlinkDisplayTextInCell, getInlineLinkPlainRange, getUniformLinkCoveringPlainRange, getUniformLinkAtPlainOffset, removeHyperlinkForLink, updateHyperlinkForLink, syncLinkCardAfterHyperlinkChange, expandCellRectForMerge, shouldQuickSearchUseAsync, runQuickSearchIndexArrAsync, QUICK_SEARCH_ASYNC_ROW_THRESHOLD, parseRangeText, getCellRowColumn, getCellHyperlink, saveHyperlink, removeHyperlink, showLinkCard, goToLink, isLinkValid, createFilterOptions, clearFilter, clearFilterForColumn, toggleViewerFilter, createFilter, applySheetFilterState, getFilterColumnValues, getFilterColumnColors, orderbydatafiler, saveFilter, onCellsMoveStart, cfSplitRange, updateMoreCell, getRegStr, getDataArr, applyLocation, getOptionValue, getSelectRange, getDropdownList, setDropdownValue, confirmMessage, setConditionRules, CF_DATE_DEFAULT_FORMAT, parseCfDateConditionForUi, formatCfDatePresetSnapshot, parseDdMmYyyyToSerial, handleOverlayTouchStart, handleOverlayTouchEnd, MAX_ZOOM_RATIO, MIN_ZOOM_RATIO, jfrefreshgrid, sanitizeDuneUrl, insertDuneChart, onIframeMoveStart, onIframeResizeStart, onIframeMove, onIframeMoveEnd, onIframeResize, onIframeResizeEnd, setCellError, clearCellError, detectDateFormat, isdatatypemulti, diff, isdatetime, isRealNull, isRealNum, isNumericCellType, iscelldata, getcellrange, cancelFunctionrangeSelected, seletedHighlistByindex, spillSortResult, execfunction, insertUpdateFunctionGroup, remapFormulaReferencesByMap, checkCF, getComputeMap, cancelPaintModel, hideCRCount, getdatabyselection, } from './modules';
10
+ export { getBorderInfoComputeRange, getBorderInfoCompute, normalizedCellAttr, normalizedAttr, getCellValue, setCellValue, getRealCellValue, mergeBorder, cancelNormalSelected, updateCell, getRangetxt, getRangeByTxt, isValidRangeText, getInlineStringHTML, applyLinkToSelection, getHyperlinksFromInlineSegments, getUniformLinkFromWindowSelectionInEditor, getHyperlinkAtCaretInContentEditable, getStyleByCell, clearSelectedCellFormat, clearRowsCellsFormat, clearColumnsCellsFormat, clipboard, moveToEnd, getRangeRectsByCharacterOffset, getDateBaseLocale, getCanonicalDateEditFormat, getDateEditFormatForCell, isUsDateBaseLocale, normalizeDateBaseLocale, shouldPreserveDateFormatForEdit, setDateBaseLocale, update, is_date, valueShowEs, isTypedCurrencyDisplayFormat, isCurrencyLikeNumberFormat, buildFiatCurrencyFormat, quoteSsfLiteral, FormulaCache, groupValuesRefresh, execFunctionGroup, runFormulaEvalChunk, applyWorkerFormulaChunkResults, isFormulaEvalPending, FORMULA_ASYNC_CHUNK_SIZE, FORMULA_ASYNC_EVAL_THRESHOLD, FORMULA_WORKER_CHUNK_SIZE, FORMULA_WORKER_THRESHOLD, setCaretPosition, getrangeseleciton, getFormulaEditorOwner, rangeHightlightselected, handleFormulaInput, israngeseleciton, createRangeHightlight, maybeRecoverDirtyRangeSelection, getFormulaRangeIndexAtCaret, isCaretAtValidFormulaRangeInsertionPoint, isLegacyFormulaRangeMode, markRangeSelectionDirty, setFormulaEditorOwner, functionHTMLGenerate, suppressFormulaRangeSelectionForInitialEdit, ensureFormulaRangeToSheet, shouldPreserveFormulaEditOnSheetSwitch, activateSheetForNavigation, returnToFormulaOriginSheet, rangeSetValue, getFormulaRangeIndexForKeyboardSync, createFormulaRangeSelect, isFormulaReferenceInputMode, seedFormulaFuncSelectedRangeFromLastSelection, initFreeze, isInlineStringCell, getInlineStringNoStyle, rowLocation, rowLocationByIndex, colLocation, colLocationByIndex, insertRowCol, deleteRowCol, hideSelected, showSelected, isShowHidenCR, getFilterHiddenRowsUnionFromFilterMap, getFilterHiddenRowsUnion, ensureManualHiddenInitialized, rebuildRowHiddenUnion, scrollToHighlightCell, selectTitlesMap, selectTitlesRange, defaultLuckysheetSelectRanges, normalizeSelection, syncPrimaryCellActiveFromSelection, selectionIsExactlyOneMergeBlock, setPrimaryCellActive, advancePrimaryCellInLastMultiSelection, snapSheetSelectionFocusToCellPreserveMultiRange, moveHighlightCell, deleteSelectedCellText, selectAll, fixRowStyleOverflowInFreeze, fixColumnStyleOverflowInFreeze, calcSelectionInfo, addSheet, deleteSheet, editSheetName, changeSheet, updateFormat, autoSelectionFormula, handleBold, handleItalic, handleStrikeThrough, handleUnderline, handleHorizontalAlign, handleVerticalAlign, handleTextColor, handleTextBackground, handleBorder, handleMerge, mergeSelectionHasValues, handleSort, getRemoveDuplicatesPreview, removeDuplicates, getRemoveDuplicatesErrorMessage, handleFreeze, handleTextSize, handleSum, handleLink, captureLinkEditorOpenSnapshot, isHyperlinkCreationBlocked, toolbarItemClickHandler, toolbarItemSelectedFunc, handleScreenShot, insertImage, showImgChooser, drawArrow, setEditingComment, removeEditingComment, removeOverShowComment, newComment, editComment, deleteComment, showComments, showHideComment, showHideAllComments, onCommentBoxMoveStart, removeActiveImage, cancelActiveImgItem, onImageMoveStart, onImageResizeStart, createDropCellRange, sortSelection, sortSheetBySelectedColumn, searchAll, searchNext, replace, replaceAll, replaceAllScoped, getSearchIndexArr, getSearchIndexArrAsync, getFindRangeOnCurrentSheet, getQuickSearchIndexArr, getQuickSearchHiddenConfig, getCellHyperlinks, getHyperlinkDisplayTextInCell, getInlineLinkPlainRange, getUniformLinkCoveringPlainRange, getUniformLinkAtPlainOffset, removeHyperlinkForLink, updateHyperlinkForLink, syncLinkCardAfterHyperlinkChange, expandCellRectForMerge, shouldQuickSearchUseAsync, runQuickSearchIndexArrAsync, QUICK_SEARCH_ASYNC_ROW_THRESHOLD, parseRangeText, getCellRowColumn, getCellHyperlink, saveHyperlink, removeHyperlink, showLinkCard, goToLink, isLinkValid, createFilterOptions, clearFilter, clearFilterForColumn, toggleViewerFilter, createFilter, applySheetFilterState, getFilterColumnValues, getFilterColumnColors, orderbydatafiler, saveFilter, onCellsMoveStart, cfSplitRange, updateMoreCell, getRegStr, getDataArr, applyLocation, getOptionValue, getSelectRange, getDropdownList, setDropdownValue, confirmMessage, setConditionRules, CF_DATE_DEFAULT_FORMAT, parseCfDateConditionForUi, formatCfDatePresetSnapshot, parseDdMmYyyyToSerial, handleOverlayTouchStart, handleOverlayTouchEnd, MAX_ZOOM_RATIO, MIN_ZOOM_RATIO, jfrefreshgrid, sanitizeDuneUrl, insertDuneChart, onIframeMoveStart, onIframeResizeStart, onIframeMove, onIframeMoveEnd, onIframeResize, onIframeResizeEnd, setCellError, clearCellError, detectDateFormat, isdatatypemulti, diff, isdatetime, isRealNull, isRealNum, isNumericCellType, iscelldata, getcellrange, cancelFunctionrangeSelected, seletedHighlistByindex, spillSortResult, execfunction, insertUpdateFunctionGroup, remapFormulaReferencesByMap, refreshFormulasUsingDefinedNames, checkCF, getComputeMap, isValidDefinedNameIdentifier, getDefinedNameDisplayRange, findDefinedNameForSelection, findDefinedNameByName, resolveDefinedNameForFormula, addDefinedName, updateDefinedName, deleteDefinedName, selectDefinedName, openNamedRangesSidebar, scheduleDefinedNamesSync, shiftDefinedNamesOnInsert, shiftDefinedNamesOnDelete, removeDefinedNamesForSheet, cancelPaintModel, hideCRCount, getdatabyselection, } from './modules';
11
11
  export type { FilterDate, FilterValue, FilterColor } from './modules';
12
12
  export { getFreezeState, toggleFreeze, indexToColumnChar, escapeScriptTag, escapeHTMLTag, getSheetIndex, replaceHtml, isAllowEdit, isAllowEditReadOnly, filterPatch, patchToOp, opToPatch, inverseRowColOptions, } from './utils';
13
13
  export type { PatchOptions, ChangedSheet } from './utils';
14
- export type { Op, Cell, CellWithRowAndCol, CellMatrix, HyperlinkEntry, Selection, Presence, Sheet, GlobalCache, SingleRange, Range, SearchResult, LinkCardProps, LiveQueryData, Freezen, } from './types';
14
+ export type { Op, Cell, CellWithRowAndCol, CellMatrix, HyperlinkEntry, Selection, Presence, Sheet, GlobalCache, SingleRange, Range, SearchResult, LinkCardProps, LiveQueryData, Freezen, DefinedName, } from './types';
15
15
  export type { RemoveDuplicatesColumnOption, RemoveDuplicatesError, RemoveDuplicatesOptions, RemoveDuplicatesPreview, RemoveDuplicatesResult, } from './modules';
16
16
  export type { CheckModes, HyperlinkMap, FindSearchScope, ReplaceScope, SearchHiddenConfig, SearchNextResult, ReplaceAllResult, } from './modules/searchReplace';
17
17
  export { cellFadeAnimator, markCellChanged } from './animate';
@@ -28,6 +28,17 @@ export type SnapshotEvalInput = {
28
28
  f: unknown;
29
29
  }>;
30
30
  formulas: SnapshotFormulaCell[];
31
+ /** Workbook-level named ranges for VARIABLE resolution. */
32
+ definedNames?: Array<{
33
+ name: string;
34
+ sheetId: string;
35
+ range: {
36
+ row: [number, number];
37
+ column: [number, number];
38
+ };
39
+ scope?: 'workbook' | 'sheet';
40
+ localSheetId?: string;
41
+ }>;
31
42
  };
32
43
  export type SnapshotEvalOutput = {
33
44
  execFunctionGlobalData: Record<string, {
@@ -2,6 +2,7 @@ import { Context } from '../context';
2
2
  import { SnapshotEvalInput, SnapshotEvalOutput, SnapshotFormulaCell, evalFormulasInSnapshot } from './formula-snapshot-eval';
3
3
  import { FORMULA_WORKER_CHUNK_SIZE } from './formula-async-eval';
4
4
 
5
+ export declare function invalidateFormulaWorkerSnapshot(): void;
5
6
  export declare function buildSnapshotEvalInput(ctx: Context, formulas: SnapshotFormulaCell[]): SnapshotEvalInput;
6
7
  export declare function buildWorkerEvalInput(ctx: Context, formulas: SnapshotFormulaCell[]): Omit<SnapshotEvalInput, 'sheets'>;
7
8
  export declare function initFormulaWorkerSnapshot(ctx: Context, snapshotKey: string): boolean;
@@ -31,6 +31,11 @@ export declare class FormulaCache {
31
31
  /** True after arrow/Shift+arrow moved `func_selectedrange` without updating yellow selection. */
32
32
  formulaKeyboardRefSync?: boolean;
33
33
  formulaEditorOwner?: 'cell' | 'fx' | null;
34
+ /**
35
+ * Set when switching sheets while a formula edit stays open so InputBox/Fx
36
+ * can restore focus/caret for continued keyboard ref picking.
37
+ */
38
+ refocusFormulaEditorAfterSheetSwitch?: boolean;
34
39
  functionRangeIndex?: number[];
35
40
  functionRangeGlobalOffset?: number | null;
36
41
  functionlistMap: any;
@@ -80,6 +85,11 @@ export declare function groupValuesRefresh(ctx: Context): void;
80
85
  export declare function applyWorkerFormulaChunkResults(ctx: Context, output: SnapshotEvalOutput, impactedByCircular: Set<string>, cycleNodes: Set<string>, calcChainKeys?: string[], data?: CellMatrix | null): void;
81
86
  /** Run up to `chunkSize` formulas from an async job. Returns true when job is complete. */
82
87
  export declare function runFormulaEvalChunk(ctx: Context, job: FormulaAsyncEvalJob, chunkSize?: number): boolean;
88
+ /**
89
+ * Re-evaluate formula cells that reference the given defined names
90
+ * (e.g. after a named range was edited, shifted, or deleted).
91
+ */
92
+ export declare function refreshFormulasUsingDefinedNames(ctx: Context, names: string[]): void;
83
93
  export declare function execFunctionGroup(ctx: Context, origin_r: number, origin_c: number, value: any, id?: string, data?: any, isForce?: boolean): void;
84
94
  /**
85
95
  * Before the first `moveHighlightCell/Range(..., "rangeOfFormula")` while editing
@@ -102,6 +112,23 @@ export declare function getLastFormulaRangeIndex($editor: HTMLDivElement): numbe
102
112
  export declare function getFormulaRangeIndexAtCaret($editor: HTMLDivElement): number | null;
103
113
  export declare function setFormulaEditorOwner(ctx: Context, owner: 'cell' | 'fx' | null): void;
104
114
  export declare function getFormulaEditorOwner(ctx: Context): 'cell' | 'fx' | null;
115
+ /**
116
+ * Record the sheet where the formula edit started so cross-sheet picks can emit
117
+ * `SheetName!A1` via `rangeSetValue` / `getRangetxt`.
118
+ */
119
+ export declare function ensureFormulaRangeToSheet(ctx: Context): void;
120
+ /** True while an in-cell / fx formula edit should survive sheet-tab switches. */
121
+ export declare function shouldPreserveFormulaEditOnSheetSwitch(ctx: Context): boolean;
122
+ /**
123
+ * Activate another sheet from tab click or Alt/Option+Arrow navigation.
124
+ * Returns whether the sheet changed and whether formula edit was preserved.
125
+ */
126
+ export declare function activateSheetForNavigation(ctx: Context, targetSheetId: string): 'preserved-formula' | 'cancel-edit' | false;
127
+ /**
128
+ * Switch back to the formula's origin sheet (and restore its scroll/selection)
129
+ * before commit or cancel. Returns true when a switch happened.
130
+ */
131
+ export declare function returnToFormulaOriginSheet(ctx: Context): boolean;
105
132
  /**
106
133
  * True when the formula text looks like a truncated A1-style range: LHS has a row
107
134
  * number but RHS after ":" is only column letters (e.g. =A1:A after deleting the
@@ -4,7 +4,7 @@ export { default as clipboard } from './clipboard';
4
4
  export { moveToEnd, getRangeRectsByCharacterOffset } from './cursor';
5
5
  export { getDateBaseLocale, getCanonicalDateEditFormat, getDateEditFormatForCell, isUsDateBaseLocale, normalizeDateBaseLocale, shouldPreserveDateFormatForEdit, setDateBaseLocale, } from './date-base-locale';
6
6
  export { update, is_date, valueShowEs, isTypedCurrencyDisplayFormat, isCurrencyLikeNumberFormat, buildFiatCurrencyFormat, quoteSsfLiteral, } from './format';
7
- export { FormulaCache, groupValuesRefresh, setCaretPosition, getrangeseleciton, getFormulaEditorOwner, rangeHightlightselected, handleFormulaInput, israngeseleciton, createRangeHightlight, createFormulaRangeSelect, maybeRecoverDirtyRangeSelection, delFunctionGroup, functionHTMLGenerate, onFormulaRangeDragEnd, rangeDrag, rangeSetValue, remapFormulaReferencesByMap, getFormulaRangeIndexAtCaret, isCaretAtValidFormulaRangeInsertionPoint, isLegacyFormulaRangeMode, markRangeSelectionDirty, getFormulaRangeIndexForKeyboardSync, isFormulaReferenceInputMode, seedFormulaFuncSelectedRangeFromLastSelection, functionStrChange, setFormulaEditorOwner, getAllFunctionGroup, suppressFormulaRangeSelectionForInitialEdit, } from './formula';
7
+ export { FormulaCache, groupValuesRefresh, setCaretPosition, getrangeseleciton, getFormulaEditorOwner, rangeHightlightselected, handleFormulaInput, israngeseleciton, createRangeHightlight, createFormulaRangeSelect, maybeRecoverDirtyRangeSelection, delFunctionGroup, functionHTMLGenerate, onFormulaRangeDragEnd, rangeDrag, rangeSetValue, remapFormulaReferencesByMap, getFormulaRangeIndexAtCaret, isCaretAtValidFormulaRangeInsertionPoint, isLegacyFormulaRangeMode, markRangeSelectionDirty, getFormulaRangeIndexForKeyboardSync, isFormulaReferenceInputMode, seedFormulaFuncSelectedRangeFromLastSelection, functionStrChange, setFormulaEditorOwner, getAllFunctionGroup, suppressFormulaRangeSelectionForInitialEdit, ensureFormulaRangeToSheet, shouldPreserveFormulaEditOnSheetSwitch, activateSheetForNavigation, returnToFormulaOriginSheet, } from './formula';
8
8
  export { FORMULA_ASYNC_CHUNK_SIZE, FORMULA_ASYNC_EVAL_THRESHOLD, FORMULA_WORKER_CHUNK_SIZE, FORMULA_WORKER_THRESHOLD, isFormulaEvalPending, } from './formula-async-eval';
9
9
  export type { FormulaAsyncEvalJob } from './formula-async-eval';
10
10
  export { initFreeze } from './freeze';
@@ -42,6 +42,7 @@ export { sanitizeDuneUrl, insertDuneChart, onIframeMoveStart, onIframeResizeStar
42
42
  export { setCellError, clearCellError, overShowError, } from './error-state-helpers';
43
43
  export { checkCellIsLocked } from './protection';
44
44
  export { detectDateFormat, isdatatypemulti, diff, isdatetime, isRealNull, isRealNum, isNumericCellType, } from './validation';
45
- export { iscelldata, getcellrange, execfunction, execFunctionGroup, runFormulaEvalChunk, applyWorkerFormulaChunkResults, insertUpdateFunctionGroup, functionCopy, } from './formula';
45
+ export { iscelldata, getcellrange, execfunction, execFunctionGroup, refreshFormulasUsingDefinedNames, runFormulaEvalChunk, applyWorkerFormulaChunkResults, insertUpdateFunctionGroup, functionCopy, } from './formula';
46
46
  export { checkCF, getComputeMap } from './ConditionFormat';
47
+ export { isValidDefinedNameIdentifier, getDefinedNameDisplayRange, findDefinedNameForSelection, findDefinedNameByName, resolveDefinedNameForFormula, addDefinedName, updateDefinedName, deleteDefinedName, selectDefinedName, openNamedRangesSidebar, scheduleDefinedNamesSync, shiftDefinedNamesOnInsert, shiftDefinedNamesOnDelete, removeDefinedNamesForSheet, } from './namedRanges';
47
48
  export { getdatabyselection, getQKBorder } from './cell';
@@ -0,0 +1,53 @@
1
+ import { Context } from '../context';
2
+ import { DefinedName, SingleRange } from '../types';
3
+
4
+ /** Excel/Google: names must start with letter/underscore; no spaces; not a cell ref. */
5
+ export declare function isValidDefinedNameIdentifier(name: string): boolean;
6
+ export declare function getDefinedNameDisplayRange(ctx: Context, dn: DefinedName): string;
7
+ export declare function findDefinedNameForSelection(ctx: Context): DefinedName | null;
8
+ export declare function findDefinedNameByName(ctx: Context, name: string, excludeId?: string): DefinedName | null;
9
+ /**
10
+ * Resolve a formula VARIABLE (e.g. `=SUM(Custom)`) to a defined name.
11
+ * Prefers sheet-scoped names matching `formulaSheetId`, then workbook-scoped.
12
+ */
13
+ export declare function resolveDefinedNameForFormula(definedNames: DefinedName[] | undefined | null, name: string, formulaSheetId?: string): DefinedName | null;
14
+ export declare function addDefinedName(ctx: Context, input: {
15
+ name: string;
16
+ sheetId: string;
17
+ range: SingleRange;
18
+ scope?: DefinedName['scope'];
19
+ localSheetId?: string;
20
+ }): {
21
+ ok: true;
22
+ namedRange: DefinedName;
23
+ } | {
24
+ ok: false;
25
+ error: string;
26
+ };
27
+ export declare function updateDefinedName(ctx: Context, id: string, patch: {
28
+ name?: string;
29
+ sheetId?: string;
30
+ range?: SingleRange;
31
+ }): {
32
+ ok: true;
33
+ namedRange: DefinedName;
34
+ } | {
35
+ ok: false;
36
+ error: string;
37
+ };
38
+ export declare function deleteDefinedName(ctx: Context, id: string): boolean;
39
+ /** Jump to a named range (switch sheet if needed) and select its cells. */
40
+ export declare function selectDefinedName(ctx: Context, id: string): boolean;
41
+ export declare function openNamedRangesSidebar(): void;
42
+ /**
43
+ * Defer Yjs sync until after Immer applies the draft (same pattern as
44
+ * sheet-metadata-hooks). Capture the hook fn — not `ctx.hooks` — so the
45
+ * draft proxy is not read after revoke.
46
+ */
47
+ export declare function scheduleDefinedNamesSync(ctx: Context): void;
48
+ /** Shift named ranges on the given sheet after row/col insert. Returns affected names. */
49
+ export declare function shiftDefinedNamesOnInsert(ctx: Context, sheetId: string, type: 'row' | 'column', index: number, count: number, direction: 'lefttop' | 'rightbottom'): string[];
50
+ /** Shift/remove named ranges on the given sheet after row/col delete. */
51
+ export declare function shiftDefinedNamesOnDelete(ctx: Context, sheetId: string, type: 'row' | 'column', start: number, end: number): string[];
52
+ /** Drop named ranges that pointed at a deleted sheet. */
53
+ export declare function removeDefinedNamesForSheet(ctx: Context, deletedSheetId: string): string[];
@@ -3,5 +3,9 @@ import { Context } from '../context';
3
3
  /**
4
4
  * Defer sheet-level metadata hooks until after React applies Immer updates, so
5
5
  * getSheet() / Yjs diff see dataVerification, CF rules, and hyperlinks from paste/cut.
6
+ *
7
+ * Capture the hook fns themselves (not `ctx.hooks`): paste runs inside produce,
8
+ * and reading a draft `hooks` proxy after it is revoked throws
9
+ * "Cannot perform 'get' on a proxy that has been revoked".
6
10
  */
7
11
  export declare function scheduleSheetMetadataSyncHooks(ctx: Context): void;
@@ -1,7 +1,23 @@
1
1
  import { Context } from '../context';
2
2
  import { Settings } from '../settings';
3
- import { CellMatrix, Sheet } from '../types';
3
+ import { CellMatrix, Sheet, SheetConfig } from '../types';
4
+ import { CellFormatRange } from '../utils/range-format';
4
5
 
6
+ /**
7
+ * Persist active ctx.config onto ONE sheet file only.
8
+ * If Immer wrote keys (e.g. cellFormatRanges) on file.config but not ctx.config,
9
+ * keep those instead of wiping them with a blind replace.
10
+ * Never touches other sheets.
11
+ */
12
+ export declare function assignActiveConfigToSheetFile(file: Sheet, activeConfig: SheetConfig | undefined): void;
13
+ /**
14
+ * Promote format-only cells in a rectangle into cellFormatRanges.
15
+ * Scans only [r1..r2]×[c1..c2]. Returns new ranges if anything changed.
16
+ *
17
+ * Writes through luckysheetfile[i].config (same as toolbar) so Immer undo
18
+ * history tracks the change and peers get the reverse via afterConfigChanges.
19
+ */
20
+ export declare function syncFormatOnlyRectIntoRanges(ctx: Context, cfg: SheetConfig | undefined, data: CellMatrix | null | undefined, r1: number, r2: number, c1: number, c2: number): CellFormatRange[] | null;
5
21
  export declare function storeSheetParamALL(ctx: Context): void;
6
22
  export declare function changeSheet(ctx: Context, id: string, isPivotInitial?: boolean, isNewSheet?: boolean, isCopySheet?: boolean): void;
7
23
  export declare function addSheet(ctx: Context, settings?: Required<Settings>, newSheetID?: string | undefined, // if action is from websocket, there will be a new sheetID
@@ -0,0 +1,23 @@
1
+ export declare function isTransparentBorderColor(color: string): boolean;
2
+ export declare function isMeaningfulBorderSide(side: {
3
+ style?: number;
4
+ color?: string;
5
+ } | undefined): boolean;
6
+ export declare function filterMeaningfulBorderSides(sides: {
7
+ l?: {
8
+ style?: number;
9
+ color?: string;
10
+ };
11
+ r?: {
12
+ style?: number;
13
+ color?: string;
14
+ };
15
+ t?: {
16
+ style?: number;
17
+ color?: string;
18
+ };
19
+ b?: {
20
+ style?: number;
21
+ color?: string;
22
+ };
23
+ }): typeof sides;
@@ -22,8 +22,10 @@ export type Hooks = {
22
22
  filterChange?: () => void;
23
23
  cellDataChange?: () => void;
24
24
  hyperlinkChange?: () => void;
25
+ /** Workbook-level named ranges (definedNames) changed — sync to Yjs. */
26
+ definedNamesChange?: () => void;
25
27
  updateCellYdoc?: (changes: SheetChangePath[]) => void;
26
- updateAllCell?: (sheetId: string) => void;
28
+ updateAllCell?: (sheetId: string, caller?: string) => void;
27
29
  beforeUpdateCell?: (r: number, c: number, value: any) => boolean;
28
30
  /** Clears RTC remote-apply lock so local edits can run data-block formulas. */
29
31
  onLocalCellEdit?: () => void;
@@ -1,5 +1,6 @@
1
1
  import { Patch as ImmerPatch } from 'immer';
2
2
  import { PatchOptions } from './utils';
3
+ import { CellFormatRange } from './utils/range-format';
3
4
 
4
5
  export type Op = {
5
6
  op: 'replace' | 'remove' | 'add' | 'insertRowCol' | 'deleteRowCol' | 'addSheet' | 'deleteSheet';
@@ -140,10 +141,29 @@ export type SheetConfig = {
140
141
  customHeight?: Record<string, number>;
141
142
  customWidth?: Record<string, number>;
142
143
  borderInfo?: any[];
144
+ /** Range-level cell formatting for empty cells (toolbar bulk format). */
145
+ cellFormatRanges?: CellFormatRange[];
143
146
  authority?: any;
144
147
  rowReadOnly?: Record<number, number>;
145
148
  colReadOnly?: Record<number, number>;
146
149
  };
150
+ /**
151
+ * Workbook-level named range (Google Sheets / Excel definedNames).
152
+ * Runtime list lives on Context; persisted in Yjs as `${dsheetId}:definedNames`.
153
+ */
154
+ export type DefinedName = {
155
+ id: string;
156
+ name: string;
157
+ sheetId: string;
158
+ range: {
159
+ row: [number, number];
160
+ column: [number, number];
161
+ };
162
+ scope: 'workbook' | 'sheet';
163
+ /** When scope === 'sheet', which sheet owns the name. */
164
+ localSheetId?: string;
165
+ comment?: string;
166
+ };
147
167
  export type Image = {
148
168
  id: string;
149
169
  width: number;
@@ -0,0 +1,16 @@
1
+ import { Context } from '../context';
2
+
3
+ export type BorderSelection = {
4
+ row: [number, number];
5
+ column: [number, number];
6
+ };
7
+ /**
8
+ * Remap borderInfo after a row/column reorder (header drag).
9
+ * Uses the same old→new index map as remapCellFormatRanges.
10
+ * O(border entries × span) — only runs on drag drop, not per-frame.
11
+ */
12
+ export declare function remapBorderInfo(borderInfo: any[] | undefined, axis: 'row' | 'column', indexMap: Record<number, number>): any[];
13
+ /** Remove border entries overlapping a single selection (cell + range types). */
14
+ export declare function removeBorderInfoForSelection(borderInfo: any[], rowSt: number, rowEd: number, colSt: number, colEd: number): any[];
15
+ export declare function removeBorderInfoInSelections(borderInfo: any[] | undefined, selections: BorderSelection[]): any[];
16
+ export declare function syncBorderInfoToYdoc(ctx: Context, borderInfo: any[]): void;
@@ -0,0 +1,10 @@
1
+ import { Cell } from '../types';
2
+
3
+ export declare const CELL_FORMAT_ATTRS: readonly ["tb", "ht", "vt", "tr", "fs", "ff", "fc", "bl", "it", "un", "cl", "bg", "ct"];
4
+ export type CellFormatAttr = (typeof CELL_FORMAT_ATTRS)[number];
5
+ export declare function hasCellMeaningfulContent(cell: Cell | string | number | boolean | null | undefined): boolean;
6
+ export declare function isFormatOnlyEmptyCell(cell: Cell | string | number | boolean | null | undefined): boolean;
7
+ /** Pull only present format attrs from a format-only empty cell (cheap, no clone). */
8
+ export declare function extractCellFormatAttrs(cell: Cell | string | number | boolean | null | undefined): Partial<Record<CellFormatAttr, unknown>> | null;
9
+ export declare function shouldPersistCelldataCell(cell: Cell | string | number | boolean | null | undefined): boolean;
10
+ export declare function celldataEntryEqual(existing: unknown, next: unknown): boolean;
@@ -0,0 +1,71 @@
1
+ import { Cell, CellMatrix, CellWithRowAndCol, Sheet } from '../types';
2
+
3
+ export type CellFormatRange = {
4
+ row: [number, number];
5
+ column: [number, number];
6
+ tb?: string;
7
+ ht?: number | string;
8
+ vt?: number | string;
9
+ tr?: string;
10
+ fs?: number;
11
+ ff?: number | string;
12
+ fc?: string;
13
+ bl?: number;
14
+ it?: number;
15
+ un?: number;
16
+ cl?: number;
17
+ bg?: string;
18
+ ct?: Cell["ct"];
19
+ };
20
+ declare function rangesEqual(a: CellFormatRange[] | undefined, b: CellFormatRange[] | undefined): boolean;
21
+ /** Merge overlapping/adjacent ranges that carry identical format attrs. */
22
+ export declare function normalizeCellFormatRanges(ranges: CellFormatRange[] | undefined): CellFormatRange[];
23
+ /**
24
+ * Remap format ranges after a row or column permutation, such as header
25
+ * drag-and-drop. A contiguous source range can become multiple rectangles
26
+ * when the moved indices are no longer contiguous.
27
+ */
28
+ export declare function remapCellFormatRanges(ranges: CellFormatRange[] | undefined, axis: "row" | "column", indexMap: Record<number, number>): CellFormatRange[];
29
+ /**
30
+ * Move format ranges with a cut-and-paste cell block move. Formatting in both
31
+ * the old source and the overwritten destination is cleared; only the source
32
+ * intersection is translated to the target rectangle.
33
+ */
34
+ export declare function moveCellFormatRanges(ranges: CellFormatRange[] | undefined, source: Pick<CellFormatRange, "row" | "column">, target: Pick<CellFormatRange, "row" | "column">): CellFormatRange[];
35
+ export declare function getCellFormatRangeGridBounds(ranges: CellFormatRange[] | undefined): {
36
+ maxRow: number;
37
+ maxCol: number;
38
+ } | null;
39
+ export declare function upsertCellFormatRange(ranges: CellFormatRange[] | undefined, rowSt: number, rowEd: number, colSt: number, colEd: number, attrs: Partial<CellFormatRange>): {
40
+ ranges: CellFormatRange[];
41
+ changed: boolean;
42
+ };
43
+ /**
44
+ * When a cell loses meaningful content but keeps style, put that style back
45
+ * into cellFormatRanges as a 1x1 (normalize merges with neighbours).
46
+ */
47
+ export declare function migrateFormatOnlyCellIntoRanges(ranges: CellFormatRange[] | undefined, r: number, c: number, cell: Cell | string | number | boolean | null | undefined): {
48
+ ranges: CellFormatRange[];
49
+ changed: boolean;
50
+ };
51
+ /**
52
+ * Scan a dense-data rectangle and move any format-only cells into
53
+ * cellFormatRanges. Adjacent identical styles merge via normalize.
54
+ */
55
+ export declare function migrateFormatOnlyCellsFromData(ranges: CellFormatRange[] | undefined, data: CellMatrix | null | undefined, r1: number, r2: number, c1: number, c2: number): {
56
+ ranges: CellFormatRange[];
57
+ changed: boolean;
58
+ };
59
+ export declare function punchHoleInCellFormatRanges(ranges: CellFormatRange[] | undefined, r: number, c: number): CellFormatRange[];
60
+ export declare function punchRectHoleInCellFormatRanges(ranges: CellFormatRange[] | undefined, rowSt: number, rowEd: number, colSt: number, colEd: number): CellFormatRange[];
61
+ export declare function shiftCellFormatRangesOnInsert(ranges: CellFormatRange[] | undefined, type: "row" | "column", index: number, count: number, direction: "lefttop" | "rightbottom"): CellFormatRange[];
62
+ export declare function shiftCellFormatRangesOnDelete(ranges: CellFormatRange[] | undefined, type: "row" | "column", start: number, end: number): CellFormatRange[];
63
+ export declare function applyCellFormatRangesToData(data: CellMatrix | null | undefined, ranges: CellFormatRange[] | undefined): void;
64
+ export declare function buildSheetDataMatrixForExport(sheet: {
65
+ data?: CellMatrix | null;
66
+ celldata?: CellWithRowAndCol[];
67
+ row?: number;
68
+ column?: number;
69
+ config?: Sheet["config"];
70
+ }): CellMatrix;
71
+ export { rangesEqual };
@@ -0,0 +1,40 @@
1
+ import { Context } from '../context';
2
+ import { Cell, CellWithRowAndCol } from '../types';
3
+
4
+ export type CelldataYdocChange = {
5
+ sheetId: string;
6
+ path: string[];
7
+ key?: string;
8
+ value: any;
9
+ type?: 'update' | 'delete';
10
+ };
11
+ /** Cheap equality before deep compare — hot path for structural diffs. */
12
+ export declare function cellsEqualForYdocPersist(before: unknown, after: unknown): boolean;
13
+ /**
14
+ * Snapshot persisted cells in a range.
15
+ * Prefer sparse `celldata` when provided — O(populated cells), not O(range area).
16
+ */
17
+ export declare function snapshotPersistedCelldataInRange(data: unknown[][] | null | undefined, r1: number, r2: number, c1: number, c2: number, celldata?: CellWithRowAndCol[] | null): Map<string, Cell | string | number | boolean>;
18
+ export declare function appendCelldataDiffChange(changes: CelldataYdocChange[], sheetId: string, r: number, c: number, cell: unknown, beforePersisted?: Map<string, Cell | string | number | boolean>): void;
19
+ export declare function buildCelldataChangesForRange(sheetId: string, data: unknown[][], r1: number, r2: number, c1: number, c2: number, beforePersisted?: Map<string, Cell | string | number | boolean>): CelldataYdocChange[];
20
+ export declare function emitCelldataRangeDiffToYdoc(ctx: Context, sheetId: string, data: unknown[][], r1: number, r2: number, c1: number, c2: number, beforePersisted?: Map<string, Cell | string | number | boolean>): void;
21
+ export type MergeBounds = {
22
+ minR: number;
23
+ minC: number;
24
+ maxR: number;
25
+ maxC: number;
26
+ };
27
+ /** Disturbed range for insert row/col — snapshot only rows/cols that may shift. */
28
+ export declare function getInsertRowColSnapshotBounds(type: 'row' | 'column', index: number, direction: 'lefttop' | 'rightbottom', rowCount: number, colCount: number, mergeBounds: MergeBounds | null): {
29
+ r1: number;
30
+ r2: number;
31
+ c1: number;
32
+ c2: number;
33
+ };
34
+ /** Disturbed range for delete row/col — from deletion point to sheet edge. */
35
+ export declare function getDeleteRowColSnapshotBounds(type: 'row' | 'column', start: number, rowCount: number, colCount: number, mergeBounds: MergeBounds | null): {
36
+ r1: number;
37
+ r2: number;
38
+ c1: number;
39
+ c2: number;
40
+ };
@@ -0,0 +1,4 @@
1
+ import { default as React } from 'react';
2
+
3
+ declare const NamedRanges: React.FC;
4
+ export default NamedRanges;
@@ -1,3 +1,4 @@
1
+ import { CellFormatRange } from '../../../core/utils/range-format';
1
2
  import { api, Cell, Context, Op, Range, Selection, Presence, Settings, SingleRange, Sheet, CellMatrix, CellWithRowAndCol, GlobalCache, LiveQueryData } from '../../../core';
2
3
  import { getCryptoPrice } from '../../utils/cryptoApi';
3
4
  import { SetContextOptions } from '../../context';
@@ -148,6 +149,12 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
148
149
  } | null;
149
150
  }, options?: api.CommonOptions) => void;
150
151
  setSheetMapField: (field: string, value: Record<string, any> | null | undefined, options?: api.CommonOptions) => void;
152
+ /** Merge keys into a map-backed sheet field without replacing the whole map. */
153
+ patchSheetMapField: (field: string, updates: Record<string, any>, deleteKeys?: string[], options?: api.CommonOptions) => void;
154
+ /** Merge sub-keys into sheet.config without replacing the whole config object. */
155
+ setSheetConfigFields: (partial: Record<string, any>, options?: api.CommonOptions & {
156
+ deleteKeys?: string[];
157
+ }) => void;
151
158
  setSheetConditionFormatRules: (rules: any[], options?: api.CommonOptions) => void;
152
159
  scroll: (options: {
153
160
  scrollLeft?: number;
@@ -166,7 +173,7 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
166
173
  calculateSubSheetFormula: (id: string) => void;
167
174
  calculateCellReferencedSubSheetFormula: (id: string, refCell?: string[]) => void;
168
175
  dataToCelldata: (data: CellMatrix | undefined) => CellWithRowAndCol[];
169
- celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number, colCount?: number) => CellMatrix | null;
176
+ celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number, colCount?: number, cellFormatRanges?: CellFormatRange[]) => CellMatrix | null;
170
177
  insertFunction: (selectedFuncIndex: number, filteredFunctionList: any[], callback?: () => void) => void;
171
178
  getLocaleContext: () => any;
172
179
  getWorkbookContext: () => Context;
@@ -150,6 +150,10 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
150
150
  } | null;
151
151
  }, options?: api.CommonOptions) => void;
152
152
  setSheetMapField: (field: string, value: Record<string, any> | null | undefined, options?: api.CommonOptions) => void;
153
+ patchSheetMapField: (field: string, updates: Record<string, any>, deleteKeys?: string[], options?: api.CommonOptions) => void;
154
+ setSheetConfigFields: (partial: Record<string, any>, options?: api.CommonOptions & {
155
+ deleteKeys?: string[];
156
+ }) => void;
153
157
  setSheetConditionFormatRules: (rules: any[], options?: api.CommonOptions) => void;
154
158
  scroll: (options: {
155
159
  scrollLeft?: number;
@@ -168,7 +172,7 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
168
172
  calculateSubSheetFormula: (id: string) => void;
169
173
  calculateCellReferencedSubSheetFormula: (id: string, refCell?: string[]) => void;
170
174
  dataToCelldata: (data: CellMatrix | undefined) => CellWithRowAndCol[];
171
- celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number, colCount?: number) => CellMatrix | null;
175
+ celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number, colCount?: number, cellFormatRanges?: import('../../../core/utils/range-format').CellFormatRange[]) => CellMatrix | null;
172
176
  insertFunction: (selectedFuncIndex: number, filteredFunctionList: any[], callback?: () => void) => void;
173
177
  getLocaleContext: () => any;
174
178
  getWorkbookContext: () => Context;