@rowsncolumns/spreadsheet 10.17.0 → 10.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/cjs/atoms/cell-input-context.atom.d.ts.map +1 -1
  2. package/dist/cjs/components/canvas-grid/frozen-start.d.ts +130 -0
  3. package/dist/cjs/components/canvas-grid/frozen-start.d.ts.map +1 -0
  4. package/dist/cjs/components/canvas-grid/frozen-start.js +266 -0
  5. package/dist/cjs/components/canvas-grid/index.d.ts.map +1 -1
  6. package/dist/cjs/components/canvas-grid/index.js +474 -66
  7. package/dist/cjs/components/canvas-grid/typings.d.ts +16 -8
  8. package/dist/cjs/components/canvas-grid/typings.d.ts.map +1 -1
  9. package/dist/cjs/components/embeds/embed-draggable.d.ts.map +1 -1
  10. package/dist/cjs/components/embeds/embed-draggable.js +10 -8
  11. package/dist/cjs/components/embeds/object-cell-offset.d.ts +10 -0
  12. package/dist/cjs/components/embeds/object-cell-offset.d.ts.map +1 -0
  13. package/dist/cjs/components/embeds/object-cell-offset.js +12 -0
  14. package/dist/cjs/hooks/use-export-range.d.ts +12 -1
  15. package/dist/cjs/hooks/use-export-range.d.ts.map +1 -1
  16. package/dist/cjs/hooks/use-export-range.js +75 -35
  17. package/dist/cjs/hooks/use-grid-children.d.ts +20 -1
  18. package/dist/cjs/hooks/use-grid-children.d.ts.map +1 -1
  19. package/dist/cjs/hooks/use-grid-children.js +53 -19
  20. package/dist/cjs/hooks/use-header-actions.d.ts +3 -1
  21. package/dist/cjs/hooks/use-header-actions.d.ts.map +1 -1
  22. package/dist/cjs/hooks/use-header-actions.js +5 -4
  23. package/dist/cjs/hooks/use-hidden-dimension-markers.d.ts +7 -1
  24. package/dist/cjs/hooks/use-hidden-dimension-markers.d.ts.map +1 -1
  25. package/dist/cjs/hooks/use-hidden-dimension-markers.js +9 -5
  26. package/dist/cjs/hooks/use-selection-interceptors.d.ts +7 -1
  27. package/dist/cjs/hooks/use-selection-interceptors.d.ts.map +1 -1
  28. package/dist/cjs/hooks/use-selection-interceptors.js +5 -3
  29. package/dist/cjs/hooks/use-sizer.d.ts +9 -1
  30. package/dist/cjs/hooks/use-sizer.d.ts.map +1 -1
  31. package/dist/cjs/hooks/use-sizer.js +5 -3
  32. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  33. package/dist/cjs/types.d.ts +7 -0
  34. package/dist/cjs/types.d.ts.map +1 -1
  35. package/dist/esm/atoms/cell-input-context.atom.d.ts.map +1 -1
  36. package/dist/esm/components/canvas-grid/frozen-start.d.ts +130 -0
  37. package/dist/esm/components/canvas-grid/frozen-start.d.ts.map +1 -0
  38. package/dist/esm/components/canvas-grid/frozen-start.js +222 -0
  39. package/dist/esm/components/canvas-grid/index.d.ts.map +1 -1
  40. package/dist/esm/components/canvas-grid/index.js +397 -13
  41. package/dist/esm/components/canvas-grid/typings.d.ts +16 -8
  42. package/dist/esm/components/canvas-grid/typings.d.ts.map +1 -1
  43. package/dist/esm/components/embeds/embed-draggable.d.ts.map +1 -1
  44. package/dist/esm/components/embeds/embed-draggable.js +3 -1
  45. package/dist/esm/components/embeds/object-cell-offset.d.ts +10 -0
  46. package/dist/esm/components/embeds/object-cell-offset.d.ts.map +1 -0
  47. package/dist/esm/components/embeds/object-cell-offset.js +9 -0
  48. package/dist/esm/hooks/use-export-range.d.ts +12 -1
  49. package/dist/esm/hooks/use-export-range.d.ts.map +1 -1
  50. package/dist/esm/hooks/use-export-range.js +31 -4
  51. package/dist/esm/hooks/use-grid-children.d.ts +20 -1
  52. package/dist/esm/hooks/use-grid-children.d.ts.map +1 -1
  53. package/dist/esm/hooks/use-grid-children.js +46 -15
  54. package/dist/esm/hooks/use-header-actions.d.ts +3 -1
  55. package/dist/esm/hooks/use-header-actions.d.ts.map +1 -1
  56. package/dist/esm/hooks/use-header-actions.js +3 -2
  57. package/dist/esm/hooks/use-hidden-dimension-markers.d.ts +7 -1
  58. package/dist/esm/hooks/use-hidden-dimension-markers.d.ts.map +1 -1
  59. package/dist/esm/hooks/use-hidden-dimension-markers.js +7 -3
  60. package/dist/esm/hooks/use-selection-interceptors.d.ts +7 -1
  61. package/dist/esm/hooks/use-selection-interceptors.d.ts.map +1 -1
  62. package/dist/esm/hooks/use-selection-interceptors.js +5 -3
  63. package/dist/esm/hooks/use-sizer.d.ts +9 -1
  64. package/dist/esm/hooks/use-sizer.d.ts.map +1 -1
  65. package/dist/esm/hooks/use-sizer.js +5 -3
  66. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  67. package/dist/esm/types.d.ts +7 -0
  68. package/dist/esm/types.d.ts.map +1 -1
  69. package/package.json +2 -2
@@ -44,6 +44,7 @@ import { ARROW_DOWN_WIDTH, CALCULATED_ICON_WIDTH, CELL_HORIZONTAL_ALIGNMENT, CF_
44
44
  import { definedProps, getCellEffectiveValue, getCellFormattedValue, getCellUserEnteredValue, getDefaultColumnHeader, getR1C1ColumnHeader, getDefaultRowHeader, getExtendedValueBool, getExtendedValueError, getExtendedValueFormula, getExtendedValueNumber, getExtendedValueString, getTableHeaderCells, isFirefox, isStyleReference, isTouchDevice, toEditorRangeValuesAsync, } from "../../helpers";
45
45
  import { useBorderStyles } from "../../hooks/use-border-styles";
46
46
  import { useCallbackRef } from "../../hooks/use-callback-ref";
47
+ import { usePrevious } from "../../hooks/use-previous";
47
48
  import { useCellPopover } from "../../hooks/use-cell-popover";
48
49
  import { useCellRenderer } from "../../hooks/use-cell-renderer";
49
50
  import { blocksOverflow, walkOverflowColumns } from "./overflow";
@@ -64,7 +65,7 @@ import { useEditorCancel } from "../../hooks/use-editor-cancel";
64
65
  import { useEditorChange } from "../../hooks/use-editor-change";
65
66
  import { useEditorKeydown } from "../../hooks/use-editor-keydown";
66
67
  import { useEditorSubmit, } from "../../hooks/use-editor-submit";
67
- import { useEmbedsCharts } from "../../hooks/use-embeds-charts";
68
+ import { getOverlayToAnchorProps, useEmbedsCharts, } from "../../hooks/use-embeds-charts";
68
69
  import { alwaysTrue, isSameNoteWindow, NOTE_INITIAL_WINDOW, noteWindowForViewport, useShownNotes, } from "../../hooks/use-shown-notes";
69
70
  import { createLinkedPictureSourceResolver, } from "../embeds/linked-picture";
70
71
  import { ChartSheetView } from "../chart-sheet-view";
@@ -126,6 +127,7 @@ import { PivotPlaceholder } from "../pivot-placeholder";
126
127
  import { SelectionTitle } from "../selection/title";
127
128
  import { StructuredResultRenderer as DefaultStructuredResult } from "./../cell-structured";
128
129
  import { activeCellAccessibleText, getNestedPropertyNames, imageCellAccessibleValue, sizeHintExceptions, } from "./helpers";
130
+ import { freezeUpTo, frozenStartScroll, isAboveFrozenStart, linesAboveFrozenStart, objectCellOffsetAboveFrozenStart, rangesWithoutLinesAboveFrozenStart, sizeAboveFrozenStartZero, sizeHintWithLinesAboveFrozenStart, sumLineSizes, } from "./frozen-start";
129
131
  import { imageResultUrl } from "../cell-structured/cell-image";
130
132
  /** Off screen but read by screen readers. */
131
133
  const VISUALLY_HIDDEN = {
@@ -164,7 +166,7 @@ const EMPTY_OBJECTS = [];
164
166
  /** "For objects, show: placeholders": an object's frame drawn with nothing in it. */
165
167
  const getObjectPlaceholder = () => (React.createElement("div", { "data-testid": "object-placeholder", "aria-hidden": "true", className: "w-full h-full bg-rnc-muted/40 border border-dashed border-rnc-border" }));
166
168
  function CanvasGridComponent(props, forwardedRef) {
167
- const { licenseKey, sheetId, sheetType, ChartSheetView: ChartSheetViewComponent = ChartSheetView, instanceId, activeCell = DEFAULT_ACTIVE_CELL, selections = DEFAULT_ARRAY, frozenColumnCount = 0, frozenRowCount = 0, rowCount = DEFAULT_ROW_COUNT, columnCount = DEFAULT_COLUMN_COUNT, autoFocus, basicFilter, tables, namedRanges, bandedRanges = DEFAULT_ARRAY, tableBorderColor = "#008000", filterIconColor = FILTER_BUTTON_GLYPH_COLOR, conditionalFormats, showFilterIcon = true, showCalculatedColumnIcon = true, showHeaders = true, backgroundImageUrl, defaultColumnWidth = DEFAULT_COLUMN_WIDTH, defaultRowHeight = DEFAULT_ROW_HEIGHT, lineHeightMode = "fontMetrics", columnHeaderHeight = COLUMN_HEADER_HEIGHT, rowHeaderWidth = ROW_HEADER_WIDTH, gridLineColor = GRIDLINE_COLOR, cellBackgroundColor = DEFAULT_CELL_BACKGROUND_COLOR, cellColor = DEFAULT_CELL_COLOR, headerBorderColor = DEFAULT_HEADER_BORDER_COLOR, headerBackgroundColor = DEFAULT_HEADER_BG, headerColor = DEFAULT_HEADER_COLOR, headerActiveBackgroundColor = DEFAULT_HEADER_ACTIVE_BG, headerSelectedBackgroundColor = DEFAULT_HEADER_SELECTED_BG, headerSelectedColor = "white", headerTableBackgroundColor = DEFAULT_HEADER_TABLE_BG, headerTableActiveBackgroundColor = DEFAULT_HEADER_ACTIVE_TABLE_BG, headerTableSelectedBackgroundColor = DEFAULT_HEADER_SELECTED_TABLE_BG, frozenShadowColor = headerBorderColor, frozenShadowThickness = 1, selectionBackgroundColor = SELECTION_BG, selectionBorderColor = SELECTION_BORDER, selectionStrokeWidth, showActiveCellBorderInSelection, selectionDragBorderColor = SELECTION_BORDER, chartSelectedColor, chipBackgroundColor = CHIP_COLOR, merges = DEFAULT_ARRAY, borderStyles, protectedRanges, allowEditRanges, isWorkbookProtected: isWorkbookProtectedProp = false, getSheetProtection, pivotTables, charts, onUpdateChart, onChangeZOrder, embeds, slicers, rowMetadata = DEFAULT_ARRAY, columnMetadata = DEFAULT_ARRAY, scale: zoomScale = 1, zoomSpeed = 1, overscanCount = 3, enableEditOnEnterKey: enableEditOnEnterKeyProp, enterKeyDirection = "down", enableAutoCorrect, shouldHandleKeyDown, enableTextOverflow = true, showGridLines: _showGridLines, showZeros, showObjects, splitPane, enableCellDragAndDrop = true, alertBeforeOverwritingCells = true, autoPercentEntry = false, errorCheckingRules, staleCells, rightToLeft: _rightToLeft, pageBreaks, pageBreakPreview: pageBreakPreviewProp, workbookView, printSettings, onChangeHeaderFooter, showRulers = true, workbookTitle, showFormulas = false, protectFormulas = false, showFrozenSeparator = true, HeaderCell = DefaultHeaderCell, Cell = DefaultCell, SelectionTitleComponent = SelectionTitle, CellEditor = DefaultCellEditor, CellTooltip, ContextMenu = DefaultContextMenu, ContextMenuWrapper = DefaultContextMenuWrapper, FilterBox = DefaultFilterBox, HeaderMoveDragComponent = DefaultHeaderMoveDragComponent, SuggestionsDropdown, stickyEditor = true, scrollSnap = false, scrollThrottleTimeout, preventBrowserDefaultScroll, mouseMoveThrottleTimeout = 60, tooltipIntentInterval = 60, selectionPolicy, users, userId, renderCollaboratorCursor, functionDescriptions, showHeaderMenuButton = true, scrollbarSize = SCROLLBAR_SIZE, theme = defaultSpreadsheetTheme, showNotes = true, showAllNotes = false, isNoteVisible: isNoteVisibleProp, showComments = true, circleInvalidData = false, getIgnoredErrors, locale, formulaLocale: formulaLocaleProp, referenceStyle = "A1", agentSuggestions, onReviewSuggestion, onShowFormulas, getDataRowCount, getDataRegion, getArrayFormula, getChartComponent, getEmbedComponent, getLinkedPictureSource: getLinkedPictureSourceProp, getSlicerComponent, onChange, onChangeBatch, onChangeArrayFormula, onExpandCollapse, onPivotDrillDown, onDelete, onChangeEditorValue, onFill, onRequestCalculate, onRequestFunctionArguments, onChangeActiveCell, onChangeActiveSheet, onChangeSelections, getSheetName, getSheetId, getCellData, getNote: getNoteProp, getTextFormatRuns, getDataValidation, getEffectiveFormat, getFormattedValue: getFormattedValueProp, getTooltipContent, errorResolutionComponent, getEffectiveValue: getEffectiveValueProp, getSparklineGroup, getUserEnteredExtendedValue, getEffectiveExtendedValue, getSheetRowCount, getSheetColumnCount, getCellPopoverContent, onScroll, onPaneScroll, onViewPortChange, windowConditionalFormats = false, engineConditionalFormatResults = false, getConditionalFormatRuleStats, onResize, onAutoResize, onHideColumn, onHideRow, onShowColumn, onShowRow, onGroupRows, onUngroupRows, onCollapseRowGroup, onExpandRowGroup, onGroupColumns, onUngroupColumns, onCollapseColumnGroup, onExpandColumnGroup, onSetOutlineDepth, onDeleteRow, onDeleteColumn, onInsertRow, onInsertColumn, onChangeAutoExpandTables, onChangeAutoCalculatedColumns, onInsertCellsShiftDown, onInsertCellsShiftRight, onDeleteCellsShiftLeft, onDeleteCellsShiftUp, onClearContents, onMoveColumns, onMoveRows, onSelectNextSheet, onSelectPreviousSheet, onCreateNewSheet, onKeyDown, onChangeFormatting, onRepeatFormatting, onClearFormatting, onRequestEditProtectedRange, onRequestUnlockAllowEditRange, onMoveChart, onResizeChart, onDeleteChart, onCutChart, onCopyChart, objectClipboard = true, objectClipboardPolicy, onMoveEmbed, onResizeEmbed, onDeleteEmbed, onRequestEditEmbed, onMoveSlicer, onResizeSlicer, onDeleteSlicer, onDeleteObjects, onRequestEditSlicer, onFillRange, onFlashFill, onFlashFillSuggest, onAcceptFlashFill, disableFillRightShortcut, keymap, enableAutoComplete = true, onCalculateNow, onRequestGoTo, onMoveSelection, onInsertCutCells, onInsertCopiedCells, onInsertTime, onInsertDate, onInsertDateTime, onInsertAutoSum, onUndo, onRedo, batchHistory, onPaste, onReapplyPaste, onCopy, onCut, onSortColumn, onSortTable, onFilterTable, onFilterPivot, onResizeTable, onUndoTableAutoExpansion, onUndoCalculatedColumn, onOverwriteCalculatedColumn, onRequestEditTable, onRequestEditPivotTable, onRequestDeletePivotTable, onRequestCreatePivotChart, onRemoveTable, onCreateTable, onRequestCreateTable, onInsertTableColumn, onDeleteTableColumn, onInsertTableRow, onDeleteTableRow, onUpdateTable, onRequestResizeTable, onRequestInsertSlicer, onCreateBasicFilter, onRequestDefineNamedRange, onRequestFormatCells, onRequestConditionalFormat, onRequestDataValidation, onRequestInsertComment, onRequestInsertLink, onFreezeColumn, onFreezeRow, onUpdateNote, onProtectRange, onUnProtectRange, onSortRange, onRequestSearch, onRequestReplace, onRequestResize, getRowHeaderText = getDefaultRowHeader, getColumnHeaderText: getColumnHeaderTextProp, getAdditionalCellSpacing, tokenizer: defaultTokenizer = defaultFormulaTokenizer, onChangeScale, onRemoveLink, onSelectLink, onSplitTextToColumns, onRemoveDuplicates, onGoalSeek, onSubtotal, onAdvancedFilter, onRequestExpand, cellExpandPredicate, StructuredResult = DefaultStructuredResult, getMentions, getStructuredProperties: getStructuredPropertiesProp, getFunctionParameterSuggestions, shouldFetchFunctionParameters, MentionTagComponent, MentionDropdownItemComponent, showSelectionResizeHandles = true, enableMagicFill, enableQuickEdit = true, MagicFillComponent, MagicFillContent, QuickEdit, PasteMenu, SuggestionAction, HiddenRowMarkers, HiddenColumnMarkers, enableResizerOverflow, className, defaultFontSizePoint = DEFAULT_FONT_SIZE_PT, defaultCellFormat, readonly, isComparing = false, getCellDiff, enableDataBoundaryNavigation, footerHeight, footerComponent, arrowComponents,
169
+ const { licenseKey, sheetId, sheetType, ChartSheetView: ChartSheetViewComponent = ChartSheetView, instanceId, activeCell = DEFAULT_ACTIVE_CELL, selections = DEFAULT_ARRAY, frozenColumnCount = 0, frozenRowCount = 0, frozenRowStart, frozenColumnStart, rowCount = DEFAULT_ROW_COUNT, columnCount = DEFAULT_COLUMN_COUNT, autoFocus, basicFilter, tables, namedRanges, bandedRanges = DEFAULT_ARRAY, tableBorderColor = "#008000", filterIconColor = FILTER_BUTTON_GLYPH_COLOR, conditionalFormats, showFilterIcon = true, showCalculatedColumnIcon = true, showHeaders = true, backgroundImageUrl, defaultColumnWidth = DEFAULT_COLUMN_WIDTH, defaultRowHeight = DEFAULT_ROW_HEIGHT, lineHeightMode = "fontMetrics", columnHeaderHeight = COLUMN_HEADER_HEIGHT, rowHeaderWidth = ROW_HEADER_WIDTH, gridLineColor = GRIDLINE_COLOR, cellBackgroundColor = DEFAULT_CELL_BACKGROUND_COLOR, cellColor = DEFAULT_CELL_COLOR, headerBorderColor = DEFAULT_HEADER_BORDER_COLOR, headerBackgroundColor = DEFAULT_HEADER_BG, headerColor = DEFAULT_HEADER_COLOR, headerActiveBackgroundColor = DEFAULT_HEADER_ACTIVE_BG, headerSelectedBackgroundColor = DEFAULT_HEADER_SELECTED_BG, headerSelectedColor = "white", headerTableBackgroundColor = DEFAULT_HEADER_TABLE_BG, headerTableActiveBackgroundColor = DEFAULT_HEADER_ACTIVE_TABLE_BG, headerTableSelectedBackgroundColor = DEFAULT_HEADER_SELECTED_TABLE_BG, frozenShadowColor = headerBorderColor, frozenShadowThickness = 1, selectionBackgroundColor = SELECTION_BG, selectionBorderColor = SELECTION_BORDER, selectionStrokeWidth, showActiveCellBorderInSelection, selectionDragBorderColor = SELECTION_BORDER, chartSelectedColor, chipBackgroundColor = CHIP_COLOR, merges = DEFAULT_ARRAY, borderStyles, protectedRanges, allowEditRanges, isWorkbookProtected: isWorkbookProtectedProp = false, getSheetProtection, pivotTables, charts, onUpdateChart, onChangeZOrder, embeds, slicers, rowMetadata = DEFAULT_ARRAY, columnMetadata = DEFAULT_ARRAY, scale: zoomScale = 1, zoomSpeed = 1, overscanCount = 3, enableEditOnEnterKey: enableEditOnEnterKeyProp, enterKeyDirection = "down", enableAutoCorrect, shouldHandleKeyDown, enableTextOverflow = true, showGridLines: _showGridLines, showZeros, showObjects, splitPane, enableCellDragAndDrop = true, alertBeforeOverwritingCells = true, autoPercentEntry = false, errorCheckingRules, staleCells, rightToLeft: _rightToLeft, pageBreaks, pageBreakPreview: pageBreakPreviewProp, workbookView, printSettings, onChangeHeaderFooter, showRulers = true, workbookTitle, showFormulas = false, protectFormulas = false, showFrozenSeparator = true, HeaderCell = DefaultHeaderCell, Cell = DefaultCell, SelectionTitleComponent = SelectionTitle, CellEditor = DefaultCellEditor, CellTooltip, ContextMenu = DefaultContextMenu, ContextMenuWrapper = DefaultContextMenuWrapper, FilterBox = DefaultFilterBox, HeaderMoveDragComponent = DefaultHeaderMoveDragComponent, SuggestionsDropdown, stickyEditor = true, scrollSnap = false, scrollThrottleTimeout, preventBrowserDefaultScroll, mouseMoveThrottleTimeout = 60, tooltipIntentInterval = 60, selectionPolicy, users, userId, renderCollaboratorCursor, functionDescriptions, showHeaderMenuButton = true, scrollbarSize = SCROLLBAR_SIZE, theme = defaultSpreadsheetTheme, showNotes = true, showAllNotes = false, isNoteVisible: isNoteVisibleProp, showComments = true, circleInvalidData = false, getIgnoredErrors, locale, formulaLocale: formulaLocaleProp, referenceStyle = "A1", agentSuggestions, onReviewSuggestion, onShowFormulas, getDataRowCount, getDataRegion, getArrayFormula, getChartComponent, getEmbedComponent, getLinkedPictureSource: getLinkedPictureSourceProp, getSlicerComponent, onChange, onChangeBatch, onChangeArrayFormula, onExpandCollapse, onPivotDrillDown, onDelete, onChangeEditorValue, onFill, onRequestCalculate, onRequestFunctionArguments, onChangeActiveCell, onChangeActiveSheet, onChangeSelections, getSheetName, getSheetId, getCellData, getNote: getNoteProp, getTextFormatRuns, getDataValidation, getEffectiveFormat, getFormattedValue: getFormattedValueProp, getTooltipContent, errorResolutionComponent, getEffectiveValue: getEffectiveValueProp, getSparklineGroup, getUserEnteredExtendedValue, getEffectiveExtendedValue, getSheetRowCount, getSheetColumnCount, getCellPopoverContent, onScroll, onPaneScroll, onViewPortChange, windowConditionalFormats = false, engineConditionalFormatResults = false, getConditionalFormatRuleStats, onResize, onAutoResize, onHideColumn, onHideRow, onShowColumn, onShowRow, onGroupRows, onUngroupRows, onCollapseRowGroup, onExpandRowGroup, onGroupColumns, onUngroupColumns, onCollapseColumnGroup, onExpandColumnGroup, onSetOutlineDepth, onDeleteRow, onDeleteColumn, onInsertRow, onInsertColumn, onChangeAutoExpandTables, onChangeAutoCalculatedColumns, onInsertCellsShiftDown, onInsertCellsShiftRight, onDeleteCellsShiftLeft, onDeleteCellsShiftUp, onClearContents, onMoveColumns, onMoveRows, onSelectNextSheet, onSelectPreviousSheet, onCreateNewSheet, onKeyDown, onChangeFormatting, onRepeatFormatting, onClearFormatting, onRequestEditProtectedRange, onRequestUnlockAllowEditRange, onMoveChart, onResizeChart, onDeleteChart, onCutChart, onCopyChart, objectClipboard = true, objectClipboardPolicy, onMoveEmbed, onResizeEmbed, onDeleteEmbed, onRequestEditEmbed, onMoveSlicer, onResizeSlicer, onDeleteSlicer, onDeleteObjects, onRequestEditSlicer, onFillRange, onFlashFill, onFlashFillSuggest, onAcceptFlashFill, disableFillRightShortcut, keymap, enableAutoComplete = true, onCalculateNow, onRequestGoTo, onMoveSelection, onInsertCutCells, onInsertCopiedCells, onInsertTime, onInsertDate, onInsertDateTime, onInsertAutoSum, onUndo, onRedo, batchHistory, onPaste, onReapplyPaste, onCopy, onCut, onSortColumn, onSortTable, onFilterTable, onFilterPivot, onResizeTable, onUndoTableAutoExpansion, onUndoCalculatedColumn, onOverwriteCalculatedColumn, onRequestEditTable, onRequestEditPivotTable, onRequestDeletePivotTable, onRequestCreatePivotChart, onRemoveTable, onCreateTable, onRequestCreateTable, onInsertTableColumn, onDeleteTableColumn, onInsertTableRow, onDeleteTableRow, onUpdateTable, onRequestResizeTable, onRequestInsertSlicer, onCreateBasicFilter, onRequestDefineNamedRange, onRequestFormatCells, onRequestConditionalFormat, onRequestDataValidation, onRequestInsertComment, onRequestInsertLink, onFreezeColumn, onFreezeRow, onUpdateNote, onProtectRange, onUnProtectRange, onSortRange, onRequestSearch, onRequestReplace, onRequestResize, getRowHeaderText = getDefaultRowHeader, getColumnHeaderText: getColumnHeaderTextProp, getAdditionalCellSpacing, tokenizer: defaultTokenizer = defaultFormulaTokenizer, onChangeScale, onRemoveLink, onSelectLink, onSplitTextToColumns, onRemoveDuplicates, onGoalSeek, onSubtotal, onAdvancedFilter, onRequestExpand, cellExpandPredicate, StructuredResult = DefaultStructuredResult, getMentions, getStructuredProperties: getStructuredPropertiesProp, getFunctionParameterSuggestions, shouldFetchFunctionParameters, MentionTagComponent, MentionDropdownItemComponent, showSelectionResizeHandles = true, enableMagicFill, enableQuickEdit = true, MagicFillComponent, MagicFillContent, QuickEdit, PasteMenu, SuggestionAction, HiddenRowMarkers, HiddenColumnMarkers, enableResizerOverflow, className, defaultFontSizePoint = DEFAULT_FONT_SIZE_PT, defaultCellFormat, readonly, isComparing = false, getCellDiff, enableDataBoundaryNavigation, footerHeight, footerComponent, arrowComponents,
168
170
  // Host-driven filter props. `hostHiddenRowRanges`
169
171
  // supplies compact [start, end] hidden-row tuples; `getFilterValues` supplies a
170
172
  // column's distinct values. Both let a million-row filter render without scanning
@@ -370,8 +372,32 @@ function CanvasGridComponent(props, forwardedRef) {
370
372
  const scale = zoomScale * (pageLayout?.scale ?? 1);
371
373
  // Page Layout draws its own pages: no Page Break Preview over them.
372
374
  const pageBreakPreview = pageLayout ? undefined : pageBreakPreviewProp;
373
- const frozenRows = pageLayout ? 1 : (frozenRowCount ?? 0) + 1;
374
- const frozenColumns = pageLayout ? 1 : (frozenColumnCount ?? 0) + 1;
375
+ // A sheet frozen while scrolled: the rows / columns above the frozen start are out of view. The
376
+ // grid lays them out with no size and its frozen band covers them, so the band shows the start
377
+ // and the body scrolls from the line after the frozen area (`frozen-start.ts`).
378
+ const sheetRowsAboveFrozenStart = pageLayout
379
+ ? 0
380
+ : linesAboveFrozenStart(frozenRowStart, frozenRowCount, Math.min(MAX_ROW_COUNT, rowCount));
381
+ const sheetColumnsAboveFrozenStart = pageLayout
382
+ ? 0
383
+ : linesAboveFrozenStart(frozenColumnStart, frozenColumnCount, Math.min(MAX_COLUMN_COUNT, columnCount));
384
+ // While an export captures a range reaching above / left of the start, the grid is drawn as if
385
+ // that axis were not frozen: every line its own size (`useExportRange`).
386
+ const [frozenStartSuspended, setFrozenStartSuspended] = useState(false);
387
+ const frozenStartSuspendedRef = useRef(frozenStartSuspended);
388
+ frozenStartSuspendedRef.current = frozenStartSuspended;
389
+ const suspendFrozenRows = frozenStartSuspended && sheetRowsAboveFrozenStart > 0;
390
+ const suspendFrozenColumns = frozenStartSuspended && sheetColumnsAboveFrozenStart > 0;
391
+ const rowsAboveFrozenStart = suspendFrozenRows ? 0 : sheetRowsAboveFrozenStart;
392
+ const columnsAboveFrozenStart = suspendFrozenColumns
393
+ ? 0
394
+ : sheetColumnsAboveFrozenStart;
395
+ const frozenRows = pageLayout || suspendFrozenRows
396
+ ? 1
397
+ : rowsAboveFrozenStart + (frozenRowCount ?? 0) + 1;
398
+ const frozenColumns = pageLayout || suspendFrozenColumns
399
+ ? 1
400
+ : columnsAboveFrozenStart + (frozenColumnCount ?? 0) + 1;
375
401
  /**
376
402
  * View ▸ Split. The grid wants pixels from the first body cell; the sheet stores twentieths of a
377
403
  * point. Page Layout view draws pages rather than a window, so it never splits.
@@ -822,15 +848,206 @@ function CanvasGridComponent(props, forwardedRef) {
822
848
  visibleColumnStartIndex: 0,
823
849
  visibleColumnStopIndex: 0,
824
850
  }, [scale]);
851
+ /**
852
+ * Freeze Panes from the menu ("Freeze up to Row 12"): Excel freezes from the top line on screen,
853
+ * so on a sheet scrolled to row 40 the frozen area is rows 40 … 12's row and rows above it stay
854
+ * out of view. The command carries how many lines are frozen and, when that is not line 1, the
855
+ * first of them. On a sheet already frozen the area keeps its start. A line above the start
856
+ * (reached with the keyboard) freezes from line 1. 0 unfreezes: the start goes with it.
857
+ */
858
+ // A host that does not hand the grid `frozenRowStart` / `frozenColumnStart` at all (one written
859
+ // before frozen starts) could not show the start it would store: it freezes from line 1 as before.
860
+ const hostShowsFrozenRowStart = "frozenRowStart" in props;
861
+ const hostShowsFrozenColumnStart = "frozenColumnStart" in props;
862
+ const firstShownRowForFreeze = useCallback(() => {
863
+ if (!hostShowsFrozenRowStart)
864
+ return 1;
865
+ if ((frozenRowCount ?? 0) > 0)
866
+ return rowsAboveFrozenStart + 1;
867
+ return Math.max(1, getViewPort().visibleRowStartIndex ?? 1);
868
+ }, [hostShowsFrozenRowStart, frozenRowCount, rowsAboveFrozenStart, getViewPort]);
869
+ const firstShownColumnForFreeze = useCallback(() => {
870
+ if (!hostShowsFrozenColumnStart)
871
+ return 1;
872
+ if ((frozenColumnCount ?? 0) > 0)
873
+ return columnsAboveFrozenStart + 1;
874
+ return Math.max(1, getViewPort().visibleColumnStartIndex ?? 1);
875
+ }, [
876
+ hostShowsFrozenColumnStart,
877
+ frozenColumnCount,
878
+ columnsAboveFrozenStart,
879
+ getViewPort,
880
+ ]);
881
+ // The freezes this window sent and has not seen arrive yet, and the last one from a start it made:
882
+ // only those move this window's view the way a Freeze Panes does (`frozenStartScroll`).
883
+ const pendingFreezeRef = useRef({});
884
+ const localFreezeRef = useRef({});
885
+ const freezeRowsUpTo = useCallback((freezeSheetId, rowIndex) => {
886
+ if (!onFreezeRow)
887
+ return;
888
+ const { count, start } = freezeUpTo(rowIndex, rowIndex > 0 ? firstShownRowForFreeze() : 1);
889
+ pendingFreezeRef.current.rows = {
890
+ expected: {
891
+ lines: linesAboveFrozenStart(start, count, Math.min(MAX_ROW_COUNT, rowCount)),
892
+ count,
893
+ },
894
+ scrollBefore: gridRef.current?.getScrollPosition().scrollTop ?? 0,
895
+ };
896
+ if (start)
897
+ onFreezeRow(freezeSheetId, count, start);
898
+ else
899
+ onFreezeRow(freezeSheetId, count);
900
+ }, [onFreezeRow, firstShownRowForFreeze, rowCount]);
901
+ const freezeColumnsUpTo = useCallback((freezeSheetId, columnIndex) => {
902
+ if (!onFreezeColumn)
903
+ return;
904
+ const { count, start } = freezeUpTo(columnIndex, columnIndex > 0 ? firstShownColumnForFreeze() : 1);
905
+ pendingFreezeRef.current.columns = {
906
+ expected: {
907
+ lines: linesAboveFrozenStart(start, count, Math.min(MAX_COLUMN_COUNT, columnCount)),
908
+ count,
909
+ },
910
+ scrollBefore: gridRef.current?.getScrollPosition().scrollLeft ?? 0,
911
+ };
912
+ if (start)
913
+ onFreezeColumn(freezeSheetId, count, start);
914
+ else
915
+ onFreezeColumn(freezeSheetId, count);
916
+ }, [onFreezeColumn, firstShownColumnForFreeze, columnCount]);
917
+ /**
918
+ * Where the view is left when a frozen area with a start changes (`frozenStartScroll`): a Freeze
919
+ * Panes this window sent places it as Excel does (the scrolling area right below the band; an
920
+ * unfreeze keeps the start first on screen), this window's undo of it puts the view back, and
921
+ * anything else (another window's freeze, undo or redo) keeps the same line first on screen. A
922
+ * sheet frozen from line 1 scrolls exactly as before.
923
+ */
924
+ const frozenStartViewRef = useRef({
925
+ sheetId,
926
+ suspended: frozenStartSuspended,
927
+ rows: rowsAboveFrozenStart,
928
+ rowCount: frozenRowCount ?? 0,
929
+ columns: columnsAboveFrozenStart,
930
+ columnCount: frozenColumnCount ?? 0,
931
+ });
932
+ /** Where the view was before the frozen area changed, read in the old layout (set while rendering). */
933
+ const frozenViewSnapshotRef = useRef({});
934
+ useIsomorphicLayoutEffect(() => {
935
+ const previous = frozenStartViewRef.current;
936
+ const next = {
937
+ sheetId,
938
+ suspended: frozenStartSuspended,
939
+ rows: rowsAboveFrozenStart,
940
+ rowCount: frozenRowCount ?? 0,
941
+ columns: columnsAboveFrozenStart,
942
+ columnCount: frozenColumnCount ?? 0,
943
+ };
944
+ frozenStartViewRef.current = next;
945
+ const snapshot = frozenViewSnapshotRef.current;
946
+ frozenViewSnapshotRef.current = {};
947
+ // A sheet switch, or an export drawing the grid without its start for a moment (it puts the
948
+ // scroll position back itself): the view is not moved.
949
+ if (previous.sheetId !== sheetId) {
950
+ pendingFreezeRef.current = {};
951
+ localFreezeRef.current = {};
952
+ return;
953
+ }
954
+ if (previous.suspended !== frozenStartSuspended)
955
+ return;
956
+ const place = (axis, offset) => {
957
+ const result = frozenStartScroll({
958
+ before: axis === "rows"
959
+ ? { lines: previous.rows, count: previous.rowCount }
960
+ : { lines: previous.columns, count: previous.columnCount },
961
+ after: axis === "rows"
962
+ ? { lines: next.rows, count: next.rowCount }
963
+ : { lines: next.columns, count: next.columnCount },
964
+ pending: pendingFreezeRef.current[axis],
965
+ local: localFreezeRef.current[axis],
966
+ snapshot: snapshot[axis],
967
+ offset,
968
+ });
969
+ if (result.consumed)
970
+ pendingFreezeRef.current[axis] = undefined;
971
+ localFreezeRef.current[axis] = result.local;
972
+ return result.scroll;
973
+ };
974
+ const scrollTop = place("rows", getRowOffset);
975
+ const scrollLeft = place("columns", getColumnOffset);
976
+ const grid = gridRef.current;
977
+ if (grid && (scrollTop !== undefined || scrollLeft !== undefined)) {
978
+ const current = grid.getScrollPosition();
979
+ // At once, as a sheet switch does: the frozen area changed under the view in this render.
980
+ grid.scrollTo({
981
+ scrollTop: scrollTop ?? current.scrollTop,
982
+ scrollLeft: scrollLeft ?? current.scrollLeft,
983
+ }, true);
984
+ }
985
+ }, [
986
+ sheetId,
987
+ frozenStartSuspended,
988
+ rowsAboveFrozenStart,
989
+ frozenRowCount,
990
+ columnsAboveFrozenStart,
991
+ frozenColumnCount,
992
+ ]);
825
993
  /**
826
994
  * Get cell coordinates from x and y position
827
995
  * @param x
828
996
  * @param y
829
997
  * @returns
830
998
  */
831
- const getCellCoordsFromOffset = useCallback((x, y, includeFrozen) => gridRef.current?.getCellCoordsFromOffset(x, y, includeFrozen), [scale]);
999
+ /**
1000
+ * A point never names a row / column above a frozen start: those have no size, so the only
1001
+ * point that can land on one is the top / left edge of the first frozen line, which is that
1002
+ * line's. A merged cell reaching down past the start keeps its own (top-left) cell.
1003
+ */
1004
+ const pointCellBelowFrozenStart = useCallbackRef(useCallback((cell) => {
1005
+ if (!cell || (!rowsAboveFrozenStart && !columnsAboveFrozenStart)) {
1006
+ return cell;
1007
+ }
1008
+ const rowAbove = isAboveFrozenStart(cell.rowIndex, rowsAboveFrozenStart);
1009
+ const columnAbove = isAboveFrozenStart(cell.columnIndex, columnsAboveFrozenStart);
1010
+ if (!rowAbove && !columnAbove)
1011
+ return cell;
1012
+ const bounds = getCellBounds(cell);
1013
+ return {
1014
+ rowIndex: rowAbove && bounds.endRowIndex <= rowsAboveFrozenStart
1015
+ ? rowsAboveFrozenStart + 1
1016
+ : cell.rowIndex,
1017
+ columnIndex: columnAbove && bounds.endColumnIndex <= columnsAboveFrozenStart
1018
+ ? columnsAboveFrozenStart + 1
1019
+ : cell.columnIndex,
1020
+ };
1021
+ }, [rowsAboveFrozenStart, columnsAboveFrozenStart, getCellBounds]));
1022
+ const getCellCoordsFromOffset = useCallback((x, y, includeFrozen) => {
1023
+ const grid = gridRef.current;
1024
+ const cell = pointCellBelowFrozenStart(grid?.getCellCoordsFromOffset(x, y, includeFrozen));
1025
+ if (includeFrozen !== false ||
1026
+ !cell ||
1027
+ !grid ||
1028
+ (!rowsAboveFrozenStart && !columnsAboveFrozenStart)) {
1029
+ return cell;
1030
+ }
1031
+ // A selection drag reads the body under the pointer, so a pointer over the column headings
1032
+ // names the row the body would scroll back to. Above a frozen start there is nothing to
1033
+ // scroll back to: as in Excel for Mac (checked 2026-11-18), the pointer over the headings
1034
+ // names the row just above the start, the selection takes it in (drawn cut at the band) and
1035
+ // nothing scrolls. Over the row headings, the column just left of the start (assumed: the
1036
+ // same rule).
1037
+ const position = grid.getRelativePositionFromOffset(x, y);
1038
+ if (!position)
1039
+ return cell;
1040
+ return {
1041
+ rowIndex: rowsAboveFrozenStart > 0 && position.y < grid.getRowOffset(1)
1042
+ ? rowsAboveFrozenStart
1043
+ : cell.rowIndex,
1044
+ columnIndex: columnsAboveFrozenStart > 0 && position.x < grid.getColumnOffset(1)
1045
+ ? columnsAboveFrozenStart
1046
+ : cell.columnIndex,
1047
+ };
1048
+ }, [scale, pointCellBelowFrozenStart, rowsAboveFrozenStart, columnsAboveFrozenStart]);
832
1049
  /** The cell at a point in sheet coordinates, whatever is scrolled (`GridRef`). */
833
- const getCellCoordsFromSheetOffset = useCallback((x, y) => gridRef.current?.getCellCoordsFromSheetOffset(x, y), [scale]);
1050
+ const getCellCoordsFromSheetOffset = useCallback((x, y) => pointCellBelowFrozenStart(gridRef.current?.getCellCoordsFromSheetOffset(x, y)), [scale, pointCellBelowFrozenStart]);
834
1051
  /**
835
1052
  * Get cells coords
836
1053
  * caters to merged cells
@@ -1832,6 +2049,16 @@ function CanvasGridComponent(props, forwardedRef) {
1832
2049
  /**
1833
2050
  * Exports a data region as image
1834
2051
  */
2052
+ const rangeReachesAboveFrozenStart = useCallback((range) => (sheetRowsAboveFrozenStart > 0 &&
2053
+ range.startRowIndex <= sheetRowsAboveFrozenStart) ||
2054
+ (sheetColumnsAboveFrozenStart > 0 &&
2055
+ range.startColumnIndex <= sheetColumnsAboveFrozenStart), [sheetRowsAboveFrozenStart, sheetColumnsAboveFrozenStart]);
2056
+ const isFrozenStartSuspended = useCallback(() => frozenStartSuspendedRef.current, []);
2057
+ // A capture interrupted by a sheet switch still ends with the start drawn: the suspension never
2058
+ // outlives the sheet it was made for (unmounting drops it with the component).
2059
+ useEffect(() => {
2060
+ setFrozenStartSuspended(false);
2061
+ }, [sheetId]);
1835
2062
  const exportRange = useExportRange({
1836
2063
  sheetId,
1837
2064
  cellBackgroundColor,
@@ -1851,6 +2078,9 @@ function CanvasGridComponent(props, forwardedRef) {
1851
2078
  scrollTo,
1852
2079
  scale: zoomScale,
1853
2080
  onChangeScale,
2081
+ reachesAboveFrozenStart: rangeReachesAboveFrozenStart,
2082
+ setFrozenStartSuspended,
2083
+ isFrozenStartSuspended,
1854
2084
  });
1855
2085
  /**
1856
2086
  * Get all cell selections from formula string
@@ -2213,6 +2443,23 @@ function CanvasGridComponent(props, forwardedRef) {
2213
2443
  defaultSize: defaultColumnWidth,
2214
2444
  exceptions: sizeHintExceptions(columnMetadata),
2215
2445
  }), [columnMetadata, defaultColumnWidth]);
2446
+ /**
2447
+ * What the GRID lays out, and nothing else: rows / columns above a frozen start have no size and
2448
+ * are left out of the visible row ranges, so they are neither drawn nor hit. Every other reader
2449
+ * (auto-fit, copy, fill, export, print, the sizes stored on the sheet) keeps `rowHeight` /
2450
+ * `columnWidth` / `visibleRowRanges` and sees them as ordinary rows. Without a start these are
2451
+ * the very same functions and arrays.
2452
+ */
2453
+ const gridRowHeight = useMemo(() => sizeAboveFrozenStartZero(rowHeight, rowsAboveFrozenStart), [rowHeight, rowsAboveFrozenStart]);
2454
+ const gridColumnWidth = useMemo(() => sizeAboveFrozenStartZero(columnWidth, columnsAboveFrozenStart), [columnWidth, columnsAboveFrozenStart]);
2455
+ const gridVisibleRowRanges = useMemo(() => rangesWithoutLinesAboveFrozenStart(visibleRowRanges, rowsAboveFrozenStart), [visibleRowRanges, rowsAboveFrozenStart]);
2456
+ // The grid's body loops skip hidden columns; a column above the start is skipped there too, so a
2457
+ // zero-width cell left of the start never draws its text overflowing into the frozen band.
2458
+ const gridIsHiddenColumn = useMemo(() => columnsAboveFrozenStart > 0
2459
+ ? (columnIndex) => isAboveFrozenStart(columnIndex, columnsAboveFrozenStart) ||
2460
+ isHiddenColumn(columnIndex)
2461
+ : isHiddenColumn, [isHiddenColumn, columnsAboveFrozenStart]);
2462
+ const gridColumnSizeHint = useMemo(() => sizeHintWithLinesAboveFrozenStart(columnSizeHint, columnsAboveFrozenStart), [columnSizeHint, columnsAboveFrozenStart]);
2216
2463
  /**
2217
2464
  * Get actual cell width with merged cells
2218
2465
  */
@@ -2311,6 +2558,8 @@ function CanvasGridComponent(props, forwardedRef) {
2311
2558
  columnCount,
2312
2559
  frozenColumns,
2313
2560
  frozenRows,
2561
+ frozenRowStart: rowsAboveFrozenStart + 1,
2562
+ frozenColumnStart: columnsAboveFrozenStart + 1,
2314
2563
  selectionLeftBound,
2315
2564
  selectionTopBound,
2316
2565
  isHiddenColumn,
@@ -2413,6 +2662,8 @@ function CanvasGridComponent(props, forwardedRef) {
2413
2662
  const { getColumnWidth, getRowHeight, getCellDimensions, getCellDimensionsStable, getTextDimension, } = useSizer({
2414
2663
  frozenRows,
2415
2664
  frozenColumns,
2665
+ frozenRowStart: rowsAboveFrozenStart + 1,
2666
+ frozenColumnStart: columnsAboveFrozenStart + 1,
2416
2667
  scale,
2417
2668
  minColumnDimension: MIN_COLUMN_WIDTH,
2418
2669
  minRowDimension: defaultRowHeight,
@@ -3544,7 +3795,7 @@ function CanvasGridComponent(props, forwardedRef) {
3544
3795
  * Get context Menu component
3545
3796
  */
3546
3797
  const getContextMenu = useCallback((cell) => {
3547
- return (React.createElement(ContextMenu, { activeCell: activeCell, selections: selections, sheetId: sheetId, frozenRows: frozenRows, frozenColumns: frozenColumns, onHideColumn: isRestricted ? undefined : onHideColumn, onShowColumn: isRestricted ? undefined : onShowColumn, onShowRow: isRestricted ? undefined : onShowRow, onHideRow: isRestricted ? undefined : onHideRow, onGroupRows: isRestricted ? undefined : onGroupRows, onUngroupRows: isRestricted ? undefined : onUngroupRows, onGroupColumns: isRestricted ? undefined : onGroupColumns, onUngroupColumns: isRestricted ? undefined : onUngroupColumns, isHiddenColumn: isHiddenColumn, isHiddenRow: isHiddenRow, onDeleteColumn: onDeleteColumn, onDeleteRow: onDeleteRow, onInsertRow: insertRowWithOptions, onInsertColumn: insertColumnWithOptions, rowCount: rowCount, columnCount: columnCount, onInsertCellsShiftDown: onInsertCellsShiftDown, onInsertCellsShiftRight: onInsertCellsShiftRight, onDeleteCellsShiftLeft: onDeleteCellsShiftLeft, onDeleteCellsShiftUp: onDeleteCellsShiftUp, onClearContents: onClearContents, onFreezeColumn: onFreezeColumn, onFreezeRow: onFreezeRow, focusSheet: focusSheet, onSortColumn: onSortColumn, onInsertNote: onInsertNote, onProtectRange: onProtectRange, onUnProtectRange: onUnProtectRange, onSortRange: onSortRange, onRequestDefineNamedRange: onRequestDefineNamedRange, protectedRanges: protectedRanges, isRowHeader: isRowHeader(cell.columnIndex), isColumnHeader: isColumnHeader(cell.rowIndex), selectedRowHeaders: selectedRowHeaders, selectedColumnHeaders: selectedColumnHeaders, visibleRowRanges: visibleRowRanges, onCopy: copy, onCut: cut, hasCutSelection: isCutPending && copiedSheetId === sheetId, onInsertCutCells: insertCutCellsFromMenu, onPaste: paste, onRequestPasteSpecial: requestPasteSpecial, onRequestEvaluateFormula: requestEvaluateFormula, onRequestAddWatch: requestAddWatch, isActiveCellFormula: Boolean(getFormulaValue(sheetId, activeCell.rowIndex, activeCell.columnIndex)), onRequestResize: onRequestResize, isSheetFocused: isSheetFocused, tables: activeTables, pivotTables: pivotTables, basicFilter: basicFilter, onRequestEditTable: onRequestEditTable, onRequestResizeTable: onRequestResizeTable, onRequestInsertSlicer: onRequestInsertSlicer, onRequestEditPivotTable: onRequestEditPivotTable, onRemoveTable: onRemoveTable, onRequestDeletePivotTable: onRequestDeletePivotTable, onRequestCreatePivotChart: onRequestCreatePivotChart, onPivotDrillDown: onPivotDrillDown, onRequestFormatCells: onRequestFormatCells, onRequestConditionalFormat: onRequestConditionalFormat, onRequestDataValidation: onRequestDataValidation, onClearFormatting: onClearFormatting, onCreateTable: onCreateTable, onRequestCreateTable: onRequestCreateTable, onCreateBasicFilter: onCreateBasicFilter, onInsertTableColumn: onInsertTableColumn, onDeleteTableColumn: onDeleteTableColumn, onInsertTableRow: onInsertTableRow, onDeleteTableRow: onDeleteTableRow, onUpdateTable: onUpdateTable, onRequestEditCell: requestEditCell, onSelectRange: selectRangeFromMenu, onFilterTable: onFilterTable, onSortTable: onSortTable, getFormattedValue: getFormattedValue, getFormattedValuesFromRange: getFormattedValuesFromRange, isTableHeader: isTableHeader, readonly: readonly, onSplitTextToColumns: onSplitTextToColumns, onRemoveDuplicates: onRemoveDuplicates, onGoalSeek: onGoalSeek, onSubtotal: onSubtotal, onAdvancedFilter: onAdvancedFilter, onChange: onChange, getCellData: getCellData, onAddQuickEdit: onAddQuickEdit, enableMagicFill: enableMagicFill }));
3798
+ return (React.createElement(ContextMenu, { activeCell: activeCell, selections: selections, sheetId: sheetId, frozenRows: frozenRows, frozenColumns: frozenColumns, onHideColumn: isRestricted ? undefined : onHideColumn, onShowColumn: isRestricted ? undefined : onShowColumn, onShowRow: isRestricted ? undefined : onShowRow, onHideRow: isRestricted ? undefined : onHideRow, onGroupRows: isRestricted ? undefined : onGroupRows, onUngroupRows: isRestricted ? undefined : onUngroupRows, onGroupColumns: isRestricted ? undefined : onGroupColumns, onUngroupColumns: isRestricted ? undefined : onUngroupColumns, isHiddenColumn: isHiddenColumn, isHiddenRow: isHiddenRow, onDeleteColumn: onDeleteColumn, onDeleteRow: onDeleteRow, onInsertRow: insertRowWithOptions, onInsertColumn: insertColumnWithOptions, rowCount: rowCount, columnCount: columnCount, onInsertCellsShiftDown: onInsertCellsShiftDown, onInsertCellsShiftRight: onInsertCellsShiftRight, onDeleteCellsShiftLeft: onDeleteCellsShiftLeft, onDeleteCellsShiftUp: onDeleteCellsShiftUp, onClearContents: onClearContents, onFreezeColumn: onFreezeColumn ? freezeColumnsUpTo : undefined, onFreezeRow: onFreezeRow ? freezeRowsUpTo : undefined, focusSheet: focusSheet, onSortColumn: onSortColumn, onInsertNote: onInsertNote, onProtectRange: onProtectRange, onUnProtectRange: onUnProtectRange, onSortRange: onSortRange, onRequestDefineNamedRange: onRequestDefineNamedRange, protectedRanges: protectedRanges, isRowHeader: isRowHeader(cell.columnIndex), isColumnHeader: isColumnHeader(cell.rowIndex), selectedRowHeaders: selectedRowHeaders, selectedColumnHeaders: selectedColumnHeaders, visibleRowRanges: visibleRowRanges, onCopy: copy, onCut: cut, hasCutSelection: isCutPending && copiedSheetId === sheetId, onInsertCutCells: insertCutCellsFromMenu, onPaste: paste, onRequestPasteSpecial: requestPasteSpecial, onRequestEvaluateFormula: requestEvaluateFormula, onRequestAddWatch: requestAddWatch, isActiveCellFormula: Boolean(getFormulaValue(sheetId, activeCell.rowIndex, activeCell.columnIndex)), onRequestResize: onRequestResize, isSheetFocused: isSheetFocused, tables: activeTables, pivotTables: pivotTables, basicFilter: basicFilter, onRequestEditTable: onRequestEditTable, onRequestResizeTable: onRequestResizeTable, onRequestInsertSlicer: onRequestInsertSlicer, onRequestEditPivotTable: onRequestEditPivotTable, onRemoveTable: onRemoveTable, onRequestDeletePivotTable: onRequestDeletePivotTable, onRequestCreatePivotChart: onRequestCreatePivotChart, onPivotDrillDown: onPivotDrillDown, onRequestFormatCells: onRequestFormatCells, onRequestConditionalFormat: onRequestConditionalFormat, onRequestDataValidation: onRequestDataValidation, onClearFormatting: onClearFormatting, onCreateTable: onCreateTable, onRequestCreateTable: onRequestCreateTable, onCreateBasicFilter: onCreateBasicFilter, onInsertTableColumn: onInsertTableColumn, onDeleteTableColumn: onDeleteTableColumn, onInsertTableRow: onInsertTableRow, onDeleteTableRow: onDeleteTableRow, onUpdateTable: onUpdateTable, onRequestEditCell: requestEditCell, onSelectRange: selectRangeFromMenu, onFilterTable: onFilterTable, onSortTable: onSortTable, getFormattedValue: getFormattedValue, getFormattedValuesFromRange: getFormattedValuesFromRange, isTableHeader: isTableHeader, readonly: readonly, onSplitTextToColumns: onSplitTextToColumns, onRemoveDuplicates: onRemoveDuplicates, onGoalSeek: onGoalSeek, onSubtotal: onSubtotal, onAdvancedFilter: onAdvancedFilter, onChange: onChange, getCellData: getCellData, onAddQuickEdit: onAddQuickEdit, enableMagicFill: enableMagicFill }));
3548
3799
  }, [
3549
3800
  isRestricted,
3550
3801
  activeCell,
@@ -3568,6 +3819,8 @@ function CanvasGridComponent(props, forwardedRef) {
3568
3819
  onClearContents,
3569
3820
  onFreezeColumn,
3570
3821
  onFreezeRow,
3822
+ freezeColumnsUpTo,
3823
+ freezeRowsUpTo,
3571
3824
  focusSheet,
3572
3825
  onSortColumn,
3573
3826
  copy,
@@ -3957,6 +4210,7 @@ function CanvasGridComponent(props, forwardedRef) {
3957
4210
  getViewPort,
3958
4211
  frozenRows,
3959
4212
  frozenColumns,
4213
+ frozenRowStart: rowsAboveFrozenStart + 1,
3960
4214
  selectionTopBound,
3961
4215
  showHeaderMenuButton,
3962
4216
  scale,
@@ -4126,18 +4380,104 @@ function CanvasGridComponent(props, forwardedRef) {
4126
4380
  deselect();
4127
4381
  return store.sub(selectedChartEmbedAtom, deselect);
4128
4382
  }, [objectsHidden, store, focusSheet, gridContainerRef]);
4383
+ /**
4384
+ * Objects on a sheet frozen while scrolled. An object is laid out from where its anchor cell
4385
+ * would be if the lines above the frozen start kept their size (`objectCellOffset`), so one
4386
+ * anchored above the start and reaching into the frozen band is drawn cut at the band's top /
4387
+ * left edge (`clipAboveFrozenStart` on the object layers), and one lying wholly above the start
4388
+ * is left out of the object layer: not drawn, clicked, tabbed to or selected, as with "For
4389
+ * objects, show: none". Without a start the objects are the props and the grid's own layout.
4390
+ */
4391
+ const objectCellOffset = useMemo(() => objectCellOffsetAboveFrozenStart({
4392
+ getCellOffsetFromCoords,
4393
+ rowsAbove: rowsAboveFrozenStart,
4394
+ columnsAbove: columnsAboveFrozenStart,
4395
+ rowSize: (index) => rowHeight(index) * scale,
4396
+ columnSize: (index) => columnWidth(index) * scale,
4397
+ distanceAbove: (axis, index) => scale *
4398
+ (axis === "row"
4399
+ ? sumLineSizes({
4400
+ from: index,
4401
+ to: rowsAboveFrozenStart,
4402
+ size: rowHeight,
4403
+ hint: rowSizeHint,
4404
+ visibleRanges: visibleRowRanges,
4405
+ })
4406
+ : sumLineSizes({
4407
+ from: index,
4408
+ to: columnsAboveFrozenStart,
4409
+ size: columnWidth,
4410
+ hint: columnSizeHint,
4411
+ })),
4412
+ }), [
4413
+ getCellOffsetFromCoords,
4414
+ rowsAboveFrozenStart,
4415
+ columnsAboveFrozenStart,
4416
+ rowHeight,
4417
+ columnWidth,
4418
+ rowSizeHint,
4419
+ columnSizeHint,
4420
+ visibleRowRanges,
4421
+ scale,
4422
+ ]);
4423
+ const shownObjectsBelowFrozenStart = useCallback((objects) => {
4424
+ if (!objects || (!rowsAboveFrozenStart && !columnsAboveFrozenStart)) {
4425
+ return objects;
4426
+ }
4427
+ const bandTop = getRowOffset(rowsAboveFrozenStart + 1);
4428
+ const bandLeft = getColumnOffset(columnsAboveFrozenStart + 1);
4429
+ const shown = objects.filter((object) => {
4430
+ const overlay = object.position?.overlayPosition;
4431
+ if (!overlay?.anchorCell)
4432
+ return true;
4433
+ const anchorAbove = isAboveFrozenStart(overlay.anchorCell.rowIndex, rowsAboveFrozenStart) ||
4434
+ isAboveFrozenStart(overlay.anchorCell.columnIndex, columnsAboveFrozenStart);
4435
+ if (!anchorAbove)
4436
+ return true;
4437
+ const from = objectCellOffset(overlay.anchorCell);
4438
+ if (!from)
4439
+ return true;
4440
+ const left = from.x + (overlay.offsetXPixels ?? 0) * scale;
4441
+ const top = from.y + (overlay.offsetYPixels ?? 0) * scale;
4442
+ const toAnchor = getOverlayToAnchorProps(overlay);
4443
+ const to = toAnchor ? objectCellOffset(toAnchor.toCell) : undefined;
4444
+ const right = to
4445
+ ? to.x + toAnchor.toOffsetXPixels * scale
4446
+ : left + (overlay.widthPixels ?? 0) * scale;
4447
+ const bottom = to
4448
+ ? to.y + toAnchor.toOffsetYPixels * scale
4449
+ : top + (overlay.heightPixels ?? 0) * scale;
4450
+ return !((rowsAboveFrozenStart > 0 && bottom <= bandTop) ||
4451
+ (columnsAboveFrozenStart > 0 && right <= bandLeft));
4452
+ });
4453
+ return shown.length === objects.length ? objects : shown;
4454
+ },
4455
+ // `gridReady`: the cells can be placed only once the grid is mounted.
4456
+ // eslint-disable-next-line react-hooks/exhaustive-deps
4457
+ [
4458
+ gridReady,
4459
+ rowsAboveFrozenStart,
4460
+ columnsAboveFrozenStart,
4461
+ getRowOffset,
4462
+ getColumnOffset,
4463
+ objectCellOffset,
4464
+ scale,
4465
+ ]);
4466
+ const shownCharts = useMemo(() => shownObjectsBelowFrozenStart(charts), [charts, shownObjectsBelowFrozenStart]);
4467
+ const shownEmbeds = useMemo(() => shownObjectsBelowFrozenStart(embeds), [embeds, shownObjectsBelowFrozenStart]);
4468
+ const shownSlicers = useMemo(() => shownObjectsBelowFrozenStart(slicers), [slicers, shownObjectsBelowFrozenStart]);
4129
4469
  const { chartComponents, embedComponents, slicerComponents, contextMenuComponent: embedContextMenuComponent, onMouseDown: onMouseDownCharts, requestChartContextMenu, selectAllObjects: selectAllObjectsUnstable, } = useEmbedsCharts({
4130
4470
  pageLayout,
4131
4471
  getLinkedPictureSource,
4132
4472
  getSheetName,
4133
- charts: objectsHidden ? EMPTY_OBJECTS : charts,
4134
- embeds: objectsHidden ? EMPTY_OBJECTS : embeds,
4135
- slicers: objectsHidden ? EMPTY_OBJECTS : slicers,
4473
+ charts: objectsHidden ? EMPTY_OBJECTS : shownCharts,
4474
+ embeds: objectsHidden ? EMPTY_OBJECTS : shownEmbeds,
4475
+ slicers: objectsHidden ? EMPTY_OBJECTS : shownSlicers,
4136
4476
  sheetId,
4137
4477
  scale,
4138
4478
  frozenRows,
4139
4479
  frozenColumns,
4140
- getCellOffsetFromCoords,
4480
+ getCellOffsetFromCoords: objectCellOffset,
4141
4481
  getAbsolutePositionFromOffset,
4142
4482
  getCellCoordsFromOffset,
4143
4483
  getCellCoordsFromSheetOffset,
@@ -4984,6 +5324,8 @@ function CanvasGridComponent(props, forwardedRef) {
4984
5324
  focusSheet,
4985
5325
  rowCount,
4986
5326
  columnCount,
5327
+ rowsAboveFrozenStart,
5328
+ columnsAboveFrozenStart,
4987
5329
  HiddenRowMarkers,
4988
5330
  HiddenColumnMarkers,
4989
5331
  });
@@ -5197,6 +5539,38 @@ function CanvasGridComponent(props, forwardedRef) {
5197
5539
  * row dimension changes
5198
5540
  */
5199
5541
  useHiddenDimensions(columnMetadata, rowMetadata, sheetId, scale, resetLastMeasuredIndices, hostHiddenRowRanges, visibleRowRanges);
5542
+ // Before the frozen area's change is laid out: where the view is, in the old layout, so the effect
5543
+ // that places the view (`frozenStartScroll`) can keep the same line first on screen.
5544
+ const previousFrozenRowsForView = usePrevious(frozenRows);
5545
+ const previousFrozenColumnsForView = usePrevious(frozenColumns);
5546
+ if (gridRef.current &&
5547
+ previousFrozenRowsForView !== undefined &&
5548
+ previousFrozenColumnsForView !== undefined &&
5549
+ (previousFrozenRowsForView !== frozenRows ||
5550
+ previousFrozenColumnsForView !== frozenColumns)) {
5551
+ const grid = gridRef.current;
5552
+ const viewport = grid.getViewPort();
5553
+ const position = grid.getScrollPosition();
5554
+ const snapshotOf = (topLine, scroll, bandEnd, offset) => ({ topLine, intoLine: scroll + bandEnd - offset });
5555
+ frozenViewSnapshotRef.current = {
5556
+ rows: snapshotOf(viewport.visibleRowStartIndex, position.scrollTop, grid.getRowOffset(previousFrozenRowsForView), grid.getRowOffset(viewport.visibleRowStartIndex)),
5557
+ columns: snapshotOf(viewport.visibleColumnStartIndex, position.scrollLeft, grid.getColumnOffset(previousFrozenColumnsForView), grid.getColumnOffset(viewport.visibleColumnStartIndex)),
5558
+ };
5559
+ }
5560
+ // A frozen start that comes, goes or moves changes which lines the grid lays out with no size:
5561
+ // re-measure from the first line, in the same render, as the hook above does for hidden rows.
5562
+ const previousRowsAboveFrozenStart = usePrevious(rowsAboveFrozenStart);
5563
+ const previousColumnsAboveFrozenStart = usePrevious(columnsAboveFrozenStart);
5564
+ const rowsAboveFrozenStartChanged = previousRowsAboveFrozenStart !== undefined &&
5565
+ previousRowsAboveFrozenStart !== rowsAboveFrozenStart;
5566
+ const columnsAboveFrozenStartChanged = previousColumnsAboveFrozenStart !== undefined &&
5567
+ previousColumnsAboveFrozenStart !== columnsAboveFrozenStart;
5568
+ if (rowsAboveFrozenStartChanged || columnsAboveFrozenStartChanged) {
5569
+ resetLastMeasuredIndices({
5570
+ rowIndex: rowsAboveFrozenStartChanged ? 0 : undefined,
5571
+ columnIndex: columnsAboveFrozenStartChanged ? 0 : undefined,
5572
+ });
5573
+ }
5200
5574
  // Callback when sheet changes
5201
5575
  useSheetChangeHandler(sheetId,
5202
5576
  // Immediate callback for imperative methods
@@ -5334,6 +5708,12 @@ function CanvasGridComponent(props, forwardedRef) {
5334
5708
  /**
5335
5709
  * Insert components inside the grid viewport
5336
5710
  */
5711
+ const clipAboveFrozenStart = useMemo(() => rowsAboveFrozenStart || columnsAboveFrozenStart
5712
+ ? {
5713
+ rows: rowsAboveFrozenStart > 0,
5714
+ columns: columnsAboveFrozenStart > 0,
5715
+ }
5716
+ : undefined, [rowsAboveFrozenStart, columnsAboveFrozenStart]);
5337
5717
  const baseGridChildren = useGridChildren({
5338
5718
  stickyEditor,
5339
5719
  editorComponent,
@@ -5360,6 +5740,10 @@ function CanvasGridComponent(props, forwardedRef) {
5360
5740
  // at, and the two can disagree (the independent review's finding 6).
5361
5741
  editorPaneId: editorPaneIdRef.current,
5362
5742
  getCellOffsetFromCoords,
5743
+ clipAboveFrozenStart,
5744
+ objectCellOffset: rowsAboveFrozenStart || columnsAboveFrozenStart
5745
+ ? objectCellOffset
5746
+ : undefined,
5363
5747
  });
5364
5748
  const sheetNameForLayout = pageLayout ? getSheetName?.(sheetId) ?? "" : "";
5365
5749
  const handleChangeHeaderFooter = useCallback((headerFooter) => onChangeHeaderFooter?.(sheetId, headerFooter), [onChangeHeaderFooter, sheetId]);
@@ -5451,7 +5835,7 @@ function CanvasGridComponent(props, forwardedRef) {
5451
5835
  width === 0 || height === 0 ? (React.createElement("div", { className: "flex border-solid border-rnc-border border border-t border-b flex-1 justify-center items-center" },
5452
5836
  React.createElement("div", { className: "space-y-2" },
5453
5837
  React.createElement(Skeleton, { className: "h-4 w-[250px]" }),
5454
- React.createElement(Skeleton, { className: "h-4 w-[250px]" })))) : (React.createElement(BaseGrid, { ref: gridRef, overscanCount: overscanCount, rowCount: sheetRowCount, columnCount: sheetColumnCount, rowHeight: rowHeight, columnWidth: columnWidth, itemRenderer: cellRenderer, headerRenderer: headerCellRenderer, selectionRenderer: selectionRenderer, gridLineColor: gridLineColor, gridLineWidth: gridLineWidth, borderStyles: gridBorderStyles, mergedCells: merges, scale: scale, width: width, height: height, frozenColumns: frozenColumns, frozenRows: frozenRows, splitPane: splitPanePx, onSplitPaneChange: handleSplitPaneChange, onPaneScroll: handlePaneScroll,
5838
+ React.createElement(Skeleton, { className: "h-4 w-[250px]" })))) : (React.createElement(BaseGrid, { ref: gridRef, overscanCount: overscanCount, rowCount: sheetRowCount, columnCount: sheetColumnCount, rowHeight: gridRowHeight, columnWidth: gridColumnWidth, itemRenderer: cellRenderer, headerRenderer: headerCellRenderer, selectionRenderer: selectionRenderer, gridLineColor: gridLineColor, gridLineWidth: gridLineWidth, borderStyles: gridBorderStyles, mergedCells: merges, scale: scale, width: width, height: height, frozenColumns: frozenColumns, frozenRows: frozenRows, frozenRowStart: rowsAboveFrozenStart + 1, frozenColumnStart: columnsAboveFrozenStart + 1, splitPane: splitPanePx, onSplitPaneChange: handleSplitPaneChange, onPaneScroll: handlePaneScroll,
5455
5839
  // Freeze Panes and Split are mutually exclusive: the grid is told the SHEET's frozen
5456
5840
  // counts, not the heading band added above.
5457
5841
  sheetFrozenRows: frozenRowCount ?? 0, sheetFrozenColumns: frozenColumnCount ?? 0, activeCell: activeCell, selections: formulaMode ? formulaSelections : selections, FillHandle: FillHandle, showFillHandle: showFillHandle,
@@ -5459,7 +5843,7 @@ function CanvasGridComponent(props, forwardedRef) {
5459
5843
  // Options, Insert Options on a lone active cell) need its copies per pane.
5460
5844
  activeCellCorners: Boolean(flashFillOptions || (insertOptions && !selections?.length)), fillHandleSize: fillHandleSize, showGridLines: showGridLines, enableCellOverlay: true, enableCellBackground: true, enableSelectionDrag: enableSelectionDrag, showFrozenColumnShadow: showFrozenSeparator, showFrozenRowShadow: showFrozenSeparator, selectionBorderColor: selectionBorderColor, selectionBackgroundColor: selectionBackgroundColor, fillhandleBorderColor: cellBackgroundColor, isDraggingSelection: isDragging, fillSelection: fillShrinkOverlay ?? fillSelection, onPointerDown: handlePointerDown, onPointerUp: handlePointerUp, onMouseDown: handleMouseDown, onDoubleClick: handleDoubleClick, onFillHandleMouseDown: onFillHandleMouseDown, onFillHandleDoubleClick: onFillHandleDoubleClick,
5461
5845
  // Dimension of fill handle
5462
- scrollToCellOffset: 4, scrollbarSize: scrollbarSize, isHiddenCell: isHiddenCell, isHiddenColumn: isHiddenColumn, isHiddenRow: isHiddenRow, visibleRowRanges: visibleRowRanges, rowSizeHint: rowSizeHint, columnSizeHint: columnSizeHint, isHiddenOverlay: isHiddenOverlay, isHiddenBackground: isHiddenBackground, overlayRenderer: cellOverlayRenderer, backgroundRenderer: cellBackgroundRenderer, backgroundsRenderer: cellBackgroundsRenderer, shadowSettings: shadowSettings, onScroll: handleScroll, onViewPortChange: handleViewPortChange, autoFocus: autoFocus, snap: scrollSnap, scrollThrottleTimeout: scrollThrottleTimeout, preventBrowserDefaultScroll: preventBrowserDefaultScroll, showHeaders: showHeaders, gridChildren: gridChildren, onTouchStart: onTouchStart, onDimensionsChange: onDimensionsChange, extendScrollSize: isTouchDevice || isFirefox, isTouchDevice: isTouchDevice, frozenShadowThickness: frozenShadowThickness, onAfterScrollToCell: onAfterScrollToCell, estimatedRowHeight: defaultRowHeight, estimatedColumnWidth: defaultColumnWidth, footerHeight: footerHeight, footerComponent: footerComponent, getOverflowBuffer: getOverflowBuffer, getFrozenColumnOverflowCells: getFrozenColumnOverflowCells, rightToLeft: rightToLeft, getRowGap: pageLayout?.getRowGap, getColumnGap: pageLayout?.getColumnGap })),
5846
+ scrollToCellOffset: 4, scrollbarSize: scrollbarSize, isHiddenCell: isHiddenCell, isHiddenColumn: gridIsHiddenColumn, isHiddenRow: isHiddenRow, visibleRowRanges: gridVisibleRowRanges, rowSizeHint: rowSizeHint, columnSizeHint: gridColumnSizeHint, isHiddenOverlay: isHiddenOverlay, isHiddenBackground: isHiddenBackground, overlayRenderer: cellOverlayRenderer, backgroundRenderer: cellBackgroundRenderer, backgroundsRenderer: cellBackgroundsRenderer, shadowSettings: shadowSettings, onScroll: handleScroll, onViewPortChange: handleViewPortChange, autoFocus: autoFocus, snap: scrollSnap, scrollThrottleTimeout: scrollThrottleTimeout, preventBrowserDefaultScroll: preventBrowserDefaultScroll, showHeaders: showHeaders, gridChildren: gridChildren, onTouchStart: onTouchStart, onDimensionsChange: onDimensionsChange, extendScrollSize: isTouchDevice || isFirefox, isTouchDevice: isTouchDevice, frozenShadowThickness: frozenShadowThickness, onAfterScrollToCell: onAfterScrollToCell, estimatedRowHeight: defaultRowHeight, estimatedColumnWidth: defaultColumnWidth, footerHeight: footerHeight, footerComponent: footerComponent, getOverflowBuffer: getOverflowBuffer, getFrozenColumnOverflowCells: getFrozenColumnOverflowCells, rightToLeft: rightToLeft, getRowGap: pageLayout?.getRowGap, getColumnGap: pageLayout?.getColumnGap })),
5463
5847
  React.createElement(RtlMirrorLayer, { rightToLeft: rightToLeft }, tooltipComponent),
5464
5848
  stickyEditor ? (React.createElement(RtlMirrorLayer, { rightToLeft: rightToLeft }, editorComponent)) : null,
5465
5849
  React.createElement(RtlMirrorLayer, { rightToLeft: rightToLeft },