@fileverse-dev/dsheet 4.0.0 → 4.0.1-ref

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.
@@ -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, copyActiveImage, cutActiveImage, pasteImageItem, loadImageFromFile, getImageClipboard, getImageCutSourceId, 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, copyActiveImage, cutActiveImage, pasteImageItem, loadImageFromFile, getImageClipboard, getImageCutSourceId, 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, {
@@ -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[];
@@ -22,6 +22,8 @@ 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
28
  updateAllCell?: (sheetId: string, caller?: string) => void;
27
29
  beforeUpdateCell?: (r: number, c: number, value: any) => boolean;
@@ -147,6 +147,23 @@ export type SheetConfig = {
147
147
  rowReadOnly?: Record<number, number>;
148
148
  colReadOnly?: Record<number, number>;
149
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
+ };
150
167
  export type Image = {
151
168
  id: string;
152
169
  width: number;
@@ -0,0 +1,4 @@
1
+ import { default as React } from 'react';
2
+
3
+ declare const NamedRanges: React.FC;
4
+ export default NamedRanges;