@rowsncolumns/spreadsheet 10.17.0 → 10.19.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.
- package/dist/cjs/api/fill-series.d.ts +18 -0
- package/dist/cjs/api/fill-series.d.ts.map +1 -1
- package/dist/cjs/api/fill-series.js +95 -1
- package/dist/cjs/atoms/cell-input-context.atom.d.ts.map +1 -1
- package/dist/cjs/atoms/fill-series-dialog.atom.d.ts +6 -0
- package/dist/cjs/atoms/fill-series-dialog.atom.d.ts.map +1 -1
- package/dist/cjs/atoms/frozen-area-sent.atom.d.ts +42 -0
- package/dist/cjs/atoms/frozen-area-sent.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/frozen-area-sent.atom.js +29 -0
- package/dist/cjs/atoms/index.d.ts +2 -0
- package/dist/cjs/atoms/index.d.ts.map +1 -1
- package/dist/cjs/atoms/index.js +2 -0
- package/dist/cjs/atoms/undo-redo-sent.atom.d.ts +25 -0
- package/dist/cjs/atoms/undo-redo-sent.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/undo-redo-sent.atom.js +23 -0
- package/dist/cjs/components/canvas-grid/frozen-start.d.ts +145 -0
- package/dist/cjs/components/canvas-grid/frozen-start.d.ts.map +1 -0
- package/dist/cjs/components/canvas-grid/frozen-start.js +273 -0
- package/dist/cjs/components/canvas-grid/index.d.ts.map +1 -1
- package/dist/cjs/components/canvas-grid/index.js +585 -70
- package/dist/cjs/components/canvas-grid/typings.d.ts +31 -8
- package/dist/cjs/components/canvas-grid/typings.d.ts.map +1 -1
- package/dist/cjs/components/embeds/embed-draggable.d.ts.map +1 -1
- package/dist/cjs/components/embeds/embed-draggable.js +10 -8
- package/dist/cjs/components/embeds/object-cell-offset.d.ts +10 -0
- package/dist/cjs/components/embeds/object-cell-offset.d.ts.map +1 -0
- package/dist/cjs/components/embeds/object-cell-offset.js +12 -0
- package/dist/cjs/components/fill-series-dialog/index.d.ts +10 -1
- package/dist/cjs/components/fill-series-dialog/index.d.ts.map +1 -1
- package/dist/cjs/components/fill-series-dialog/index.js +14 -4
- package/dist/cjs/hooks/use-export-range.d.ts +12 -1
- package/dist/cjs/hooks/use-export-range.d.ts.map +1 -1
- package/dist/cjs/hooks/use-export-range.js +75 -35
- package/dist/cjs/hooks/use-grid-children.d.ts +20 -1
- package/dist/cjs/hooks/use-grid-children.d.ts.map +1 -1
- package/dist/cjs/hooks/use-grid-children.js +53 -19
- package/dist/cjs/hooks/use-header-actions.d.ts +3 -1
- package/dist/cjs/hooks/use-header-actions.d.ts.map +1 -1
- package/dist/cjs/hooks/use-header-actions.js +5 -4
- package/dist/cjs/hooks/use-hidden-dimension-markers.d.ts +7 -1
- package/dist/cjs/hooks/use-hidden-dimension-markers.d.ts.map +1 -1
- package/dist/cjs/hooks/use-hidden-dimension-markers.js +9 -5
- package/dist/cjs/hooks/use-selection-interceptors.d.ts +7 -1
- package/dist/cjs/hooks/use-selection-interceptors.d.ts.map +1 -1
- package/dist/cjs/hooks/use-selection-interceptors.js +14 -3
- package/dist/cjs/hooks/use-selection.d.ts +8 -1
- package/dist/cjs/hooks/use-selection.d.ts.map +1 -1
- package/dist/cjs/hooks/use-selection.js +39 -9
- package/dist/cjs/hooks/use-sizer.d.ts +9 -1
- package/dist/cjs/hooks/use-sizer.d.ts.map +1 -1
- package/dist/cjs/hooks/use-sizer.js +5 -3
- package/dist/cjs/release-date.js +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/cjs/types.d.ts +7 -0
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/esm/api/fill-series.d.ts +18 -0
- package/dist/esm/api/fill-series.d.ts.map +1 -1
- package/dist/esm/api/fill-series.js +89 -0
- package/dist/esm/atoms/cell-input-context.atom.d.ts.map +1 -1
- package/dist/esm/atoms/fill-series-dialog.atom.d.ts +6 -0
- package/dist/esm/atoms/fill-series-dialog.atom.d.ts.map +1 -1
- package/dist/esm/atoms/frozen-area-sent.atom.d.ts +42 -0
- package/dist/esm/atoms/frozen-area-sent.atom.d.ts.map +1 -0
- package/dist/esm/atoms/frozen-area-sent.atom.js +21 -0
- package/dist/esm/atoms/index.d.ts +2 -0
- package/dist/esm/atoms/index.d.ts.map +1 -1
- package/dist/esm/atoms/index.js +2 -0
- package/dist/esm/atoms/undo-redo-sent.atom.d.ts +25 -0
- package/dist/esm/atoms/undo-redo-sent.atom.d.ts.map +1 -0
- package/dist/esm/atoms/undo-redo-sent.atom.js +18 -0
- package/dist/esm/components/canvas-grid/frozen-start.d.ts +145 -0
- package/dist/esm/components/canvas-grid/frozen-start.d.ts.map +1 -0
- package/dist/esm/components/canvas-grid/frozen-start.js +229 -0
- package/dist/esm/components/canvas-grid/index.d.ts.map +1 -1
- package/dist/esm/components/canvas-grid/index.js +507 -16
- package/dist/esm/components/canvas-grid/typings.d.ts +31 -8
- package/dist/esm/components/canvas-grid/typings.d.ts.map +1 -1
- package/dist/esm/components/embeds/embed-draggable.d.ts.map +1 -1
- package/dist/esm/components/embeds/embed-draggable.js +3 -1
- package/dist/esm/components/embeds/object-cell-offset.d.ts +10 -0
- package/dist/esm/components/embeds/object-cell-offset.d.ts.map +1 -0
- package/dist/esm/components/embeds/object-cell-offset.js +9 -0
- package/dist/esm/components/fill-series-dialog/index.d.ts +10 -1
- package/dist/esm/components/fill-series-dialog/index.d.ts.map +1 -1
- package/dist/esm/components/fill-series-dialog/index.js +14 -4
- package/dist/esm/hooks/use-export-range.d.ts +12 -1
- package/dist/esm/hooks/use-export-range.d.ts.map +1 -1
- package/dist/esm/hooks/use-export-range.js +31 -4
- package/dist/esm/hooks/use-grid-children.d.ts +20 -1
- package/dist/esm/hooks/use-grid-children.d.ts.map +1 -1
- package/dist/esm/hooks/use-grid-children.js +46 -15
- package/dist/esm/hooks/use-header-actions.d.ts +3 -1
- package/dist/esm/hooks/use-header-actions.d.ts.map +1 -1
- package/dist/esm/hooks/use-header-actions.js +3 -2
- package/dist/esm/hooks/use-hidden-dimension-markers.d.ts +7 -1
- package/dist/esm/hooks/use-hidden-dimension-markers.d.ts.map +1 -1
- package/dist/esm/hooks/use-hidden-dimension-markers.js +7 -3
- package/dist/esm/hooks/use-selection-interceptors.d.ts +7 -1
- package/dist/esm/hooks/use-selection-interceptors.d.ts.map +1 -1
- package/dist/esm/hooks/use-selection-interceptors.js +15 -4
- package/dist/esm/hooks/use-selection.d.ts +8 -1
- package/dist/esm/hooks/use-selection.d.ts.map +1 -1
- package/dist/esm/hooks/use-selection.js +35 -5
- package/dist/esm/hooks/use-sizer.d.ts +9 -1
- package/dist/esm/hooks/use-sizer.d.ts.map +1 -1
- package/dist/esm/hooks/use-sizer.js +5 -3
- package/dist/esm/release-date.js +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/esm/types.d.ts +7 -0
- package/dist/esm/types.d.ts.map +1 -1
- package/package.json +3 -2
|
@@ -44,6 +44,9 @@ 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";
|
|
48
|
+
import { useNoteUndoRedoSent, useUndoRedoSentValue } from "../../atoms/undo-redo-sent.atom";
|
|
49
|
+
import { useFrozenAreaSentValue } from "../../atoms/frozen-area-sent.atom";
|
|
47
50
|
import { useCellPopover } from "../../hooks/use-cell-popover";
|
|
48
51
|
import { useCellRenderer } from "../../hooks/use-cell-renderer";
|
|
49
52
|
import { blocksOverflow, walkOverflowColumns } from "./overflow";
|
|
@@ -64,7 +67,7 @@ import { useEditorCancel } from "../../hooks/use-editor-cancel";
|
|
|
64
67
|
import { useEditorChange } from "../../hooks/use-editor-change";
|
|
65
68
|
import { useEditorKeydown } from "../../hooks/use-editor-keydown";
|
|
66
69
|
import { useEditorSubmit, } from "../../hooks/use-editor-submit";
|
|
67
|
-
import { useEmbedsCharts } from "../../hooks/use-embeds-charts";
|
|
70
|
+
import { getOverlayToAnchorProps, useEmbedsCharts, } from "../../hooks/use-embeds-charts";
|
|
68
71
|
import { alwaysTrue, isSameNoteWindow, NOTE_INITIAL_WINDOW, noteWindowForViewport, useShownNotes, } from "../../hooks/use-shown-notes";
|
|
69
72
|
import { createLinkedPictureSourceResolver, } from "../embeds/linked-picture";
|
|
70
73
|
import { ChartSheetView } from "../chart-sheet-view";
|
|
@@ -126,6 +129,7 @@ import { PivotPlaceholder } from "../pivot-placeholder";
|
|
|
126
129
|
import { SelectionTitle } from "../selection/title";
|
|
127
130
|
import { StructuredResultRenderer as DefaultStructuredResult } from "./../cell-structured";
|
|
128
131
|
import { activeCellAccessibleText, getNestedPropertyNames, imageCellAccessibleValue, sizeHintExceptions, } from "./helpers";
|
|
132
|
+
import { freezeUpTo, frozenStartScroll, isAboveFrozenStart, linesAboveFrozenStart, objectCellOffsetAboveFrozenStart, rangesWithoutLinesAboveFrozenStart, sizeAboveFrozenStartZero, sizeHintWithLinesAboveFrozenStart, sumLineSizes, } from "./frozen-start";
|
|
129
133
|
import { imageResultUrl } from "../cell-structured/cell-image";
|
|
130
134
|
/** Off screen but read by screen readers. */
|
|
131
135
|
const VISUALLY_HIDDEN = {
|
|
@@ -164,7 +168,7 @@ const EMPTY_OBJECTS = [];
|
|
|
164
168
|
/** "For objects, show: placeholders": an object's frame drawn with nothing in it. */
|
|
165
169
|
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
170
|
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,
|
|
171
|
+
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, getDate1904, parseCellEntryNumber, 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
172
|
// Host-driven filter props. `hostHiddenRowRanges`
|
|
169
173
|
// supplies compact [start, end] hidden-row tuples; `getFilterValues` supplies a
|
|
170
174
|
// column's distinct values. Both let a million-row filter render without scanning
|
|
@@ -370,8 +374,32 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
370
374
|
const scale = zoomScale * (pageLayout?.scale ?? 1);
|
|
371
375
|
// Page Layout draws its own pages: no Page Break Preview over them.
|
|
372
376
|
const pageBreakPreview = pageLayout ? undefined : pageBreakPreviewProp;
|
|
373
|
-
|
|
374
|
-
|
|
377
|
+
// A sheet frozen while scrolled: the rows / columns above the frozen start are out of view. The
|
|
378
|
+
// grid lays them out with no size and its frozen band covers them, so the band shows the start
|
|
379
|
+
// and the body scrolls from the line after the frozen area (`frozen-start.ts`).
|
|
380
|
+
const sheetRowsAboveFrozenStart = pageLayout
|
|
381
|
+
? 0
|
|
382
|
+
: linesAboveFrozenStart(frozenRowStart, frozenRowCount, Math.min(MAX_ROW_COUNT, rowCount));
|
|
383
|
+
const sheetColumnsAboveFrozenStart = pageLayout
|
|
384
|
+
? 0
|
|
385
|
+
: linesAboveFrozenStart(frozenColumnStart, frozenColumnCount, Math.min(MAX_COLUMN_COUNT, columnCount));
|
|
386
|
+
// While an export captures a range reaching above / left of the start, the grid is drawn as if
|
|
387
|
+
// that axis were not frozen: every line its own size (`useExportRange`).
|
|
388
|
+
const [frozenStartSuspended, setFrozenStartSuspended] = useState(false);
|
|
389
|
+
const frozenStartSuspendedRef = useRef(frozenStartSuspended);
|
|
390
|
+
frozenStartSuspendedRef.current = frozenStartSuspended;
|
|
391
|
+
const suspendFrozenRows = frozenStartSuspended && sheetRowsAboveFrozenStart > 0;
|
|
392
|
+
const suspendFrozenColumns = frozenStartSuspended && sheetColumnsAboveFrozenStart > 0;
|
|
393
|
+
const rowsAboveFrozenStart = suspendFrozenRows ? 0 : sheetRowsAboveFrozenStart;
|
|
394
|
+
const columnsAboveFrozenStart = suspendFrozenColumns
|
|
395
|
+
? 0
|
|
396
|
+
: sheetColumnsAboveFrozenStart;
|
|
397
|
+
const frozenRows = pageLayout || suspendFrozenRows
|
|
398
|
+
? 1
|
|
399
|
+
: rowsAboveFrozenStart + (frozenRowCount ?? 0) + 1;
|
|
400
|
+
const frozenColumns = pageLayout || suspendFrozenColumns
|
|
401
|
+
? 1
|
|
402
|
+
: columnsAboveFrozenStart + (frozenColumnCount ?? 0) + 1;
|
|
375
403
|
/**
|
|
376
404
|
* View ▸ Split. The grid wants pixels from the first body cell; the sheet stores twentieths of a
|
|
377
405
|
* point. Page Layout view draws pages rather than a window, so it never splits.
|
|
@@ -822,15 +850,291 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
822
850
|
visibleColumnStartIndex: 0,
|
|
823
851
|
visibleColumnStopIndex: 0,
|
|
824
852
|
}, [scale]);
|
|
853
|
+
/**
|
|
854
|
+
* Freeze Panes from the menu ("Freeze up to Row 12"): Excel freezes from the top line on screen,
|
|
855
|
+
* so on a sheet scrolled to row 40 the frozen area is rows 40 … 12's row and rows above it stay
|
|
856
|
+
* out of view. The command carries how many lines are frozen and, when that is not line 1, the
|
|
857
|
+
* first of them. On a sheet already frozen the area keeps its start. A line above the start
|
|
858
|
+
* (reached with the keyboard) freezes from line 1. 0 unfreezes: the start goes with it.
|
|
859
|
+
*/
|
|
860
|
+
// A host that does not hand the grid `frozenRowStart` / `frozenColumnStart` at all (one written
|
|
861
|
+
// before frozen starts) could not show the start it would store: it freezes from line 1 as before.
|
|
862
|
+
const hostShowsFrozenRowStart = "frozenRowStart" in props;
|
|
863
|
+
const hostShowsFrozenColumnStart = "frozenColumnStart" in props;
|
|
864
|
+
const firstShownRowForFreeze = useCallback(() => {
|
|
865
|
+
if (!hostShowsFrozenRowStart)
|
|
866
|
+
return 1;
|
|
867
|
+
if ((frozenRowCount ?? 0) > 0)
|
|
868
|
+
return rowsAboveFrozenStart + 1;
|
|
869
|
+
return Math.max(1, getViewPort().visibleRowStartIndex ?? 1);
|
|
870
|
+
}, [hostShowsFrozenRowStart, frozenRowCount, rowsAboveFrozenStart, getViewPort]);
|
|
871
|
+
const firstShownColumnForFreeze = useCallback(() => {
|
|
872
|
+
if (!hostShowsFrozenColumnStart)
|
|
873
|
+
return 1;
|
|
874
|
+
if ((frozenColumnCount ?? 0) > 0)
|
|
875
|
+
return columnsAboveFrozenStart + 1;
|
|
876
|
+
return Math.max(1, getViewPort().visibleColumnStartIndex ?? 1);
|
|
877
|
+
}, [
|
|
878
|
+
hostShowsFrozenColumnStart,
|
|
879
|
+
frozenColumnCount,
|
|
880
|
+
columnsAboveFrozenStart,
|
|
881
|
+
getViewPort,
|
|
882
|
+
]);
|
|
883
|
+
// What this window just sent that may change the frozen area (a freeze, an unfreeze, an undo, a
|
|
884
|
+
// redo), and the last freeze from a start it made: only those move this window's view
|
|
885
|
+
// (`frozenStartScroll`). A mark lives until the grid next commits: the change it was sent for
|
|
886
|
+
// arrives in that same render (the host applies it while handling the event), and a mark the next
|
|
887
|
+
// render did not use is dropped, whatever arrives later.
|
|
888
|
+
const pendingFreezeRef = useRef({});
|
|
889
|
+
const localFreezeRef = useRef({});
|
|
890
|
+
const noteUndoRedoSent = useNoteUndoRedoSent();
|
|
891
|
+
const markHistorySent = useCallback((kind) => {
|
|
892
|
+
pendingFreezeRef.current = { rows: { kind }, columns: { kind } };
|
|
893
|
+
noteUndoRedoSent(kind);
|
|
894
|
+
}, [noteUndoRedoSent]);
|
|
895
|
+
// An undo / redo this window sent outside the grid (the host's toolbar through the engine hook,
|
|
896
|
+
// or a host calling `useNoteUndoRedoSent`), counted: one the grid has not seen yet is this
|
|
897
|
+
// window's.
|
|
898
|
+
const undoRedoSent = useUndoRedoSentValue();
|
|
899
|
+
const seenUndoRedoRef = useRef(undoRedoSent?.seq);
|
|
900
|
+
// A freeze / unfreeze this window sent outside the grid's own menu (a host ribbon through the
|
|
901
|
+
// engine hook, or a host calling `useNoteFrozenAreaSent`), counted, with the area it asked for.
|
|
902
|
+
const frozenAreaSent = useFrozenAreaSentValue();
|
|
903
|
+
const seenFrozenAreaRef = useRef(frozenAreaSent?.seq);
|
|
904
|
+
const freezeRowsUpTo = useCallback((freezeSheetId, rowIndex) => {
|
|
905
|
+
if (!onFreezeRow)
|
|
906
|
+
return;
|
|
907
|
+
const { count, start } = freezeUpTo(rowIndex, rowIndex > 0 ? firstShownRowForFreeze() : 1);
|
|
908
|
+
const expected = {
|
|
909
|
+
lines: linesAboveFrozenStart(start, count, Math.min(MAX_ROW_COUNT, rowCount)),
|
|
910
|
+
count,
|
|
911
|
+
};
|
|
912
|
+
// A freeze that asks for the area already there changes nothing: it leaves no mark.
|
|
913
|
+
pendingFreezeRef.current.rows =
|
|
914
|
+
expected.lines === rowsAboveFrozenStart && expected.count === (frozenRowCount ?? 0)
|
|
915
|
+
? undefined
|
|
916
|
+
: {
|
|
917
|
+
kind: "freeze",
|
|
918
|
+
expected,
|
|
919
|
+
scrollBefore: gridRef.current?.getScrollPosition().scrollTop ?? 0,
|
|
920
|
+
};
|
|
921
|
+
if (start)
|
|
922
|
+
onFreezeRow(freezeSheetId, count, start);
|
|
923
|
+
else
|
|
924
|
+
onFreezeRow(freezeSheetId, count);
|
|
925
|
+
}, [onFreezeRow, firstShownRowForFreeze, rowCount, rowsAboveFrozenStart, frozenRowCount]);
|
|
926
|
+
const freezeColumnsUpTo = useCallback((freezeSheetId, columnIndex) => {
|
|
927
|
+
if (!onFreezeColumn)
|
|
928
|
+
return;
|
|
929
|
+
const { count, start } = freezeUpTo(columnIndex, columnIndex > 0 ? firstShownColumnForFreeze() : 1);
|
|
930
|
+
const expected = {
|
|
931
|
+
lines: linesAboveFrozenStart(start, count, Math.min(MAX_COLUMN_COUNT, columnCount)),
|
|
932
|
+
count,
|
|
933
|
+
};
|
|
934
|
+
pendingFreezeRef.current.columns =
|
|
935
|
+
expected.lines === columnsAboveFrozenStart &&
|
|
936
|
+
expected.count === (frozenColumnCount ?? 0)
|
|
937
|
+
? undefined
|
|
938
|
+
: {
|
|
939
|
+
kind: "freeze",
|
|
940
|
+
expected,
|
|
941
|
+
scrollBefore: gridRef.current?.getScrollPosition().scrollLeft ?? 0,
|
|
942
|
+
};
|
|
943
|
+
if (start)
|
|
944
|
+
onFreezeColumn(freezeSheetId, count, start);
|
|
945
|
+
else
|
|
946
|
+
onFreezeColumn(freezeSheetId, count);
|
|
947
|
+
}, [
|
|
948
|
+
onFreezeColumn,
|
|
949
|
+
firstShownColumnForFreeze,
|
|
950
|
+
columnCount,
|
|
951
|
+
columnsAboveFrozenStart,
|
|
952
|
+
frozenColumnCount,
|
|
953
|
+
]);
|
|
954
|
+
/**
|
|
955
|
+
* Where the view is left when a frozen area with a start changes (`frozenStartScroll`): a Freeze
|
|
956
|
+
* Panes this window sent places it as Excel does (the scrolling area right below the band; an
|
|
957
|
+
* unfreeze keeps the start first on screen), this window's undo of it puts the view back, and
|
|
958
|
+
* anything else (another window's freeze, undo or redo) keeps the same line first on screen. A
|
|
959
|
+
* sheet frozen from line 1 scrolls exactly as before.
|
|
960
|
+
*/
|
|
961
|
+
const frozenStartViewRef = useRef({
|
|
962
|
+
sheetId,
|
|
963
|
+
suspended: frozenStartSuspended,
|
|
964
|
+
rows: rowsAboveFrozenStart,
|
|
965
|
+
rowCount: frozenRowCount ?? 0,
|
|
966
|
+
columns: columnsAboveFrozenStart,
|
|
967
|
+
columnCount: frozenColumnCount ?? 0,
|
|
968
|
+
});
|
|
969
|
+
/** Where the view was before the frozen area changed, read in the old layout (set while rendering). */
|
|
970
|
+
const frozenViewSnapshotRef = useRef({});
|
|
971
|
+
useIsomorphicLayoutEffect(() => {
|
|
972
|
+
const previous = frozenStartViewRef.current;
|
|
973
|
+
const next = {
|
|
974
|
+
sheetId,
|
|
975
|
+
suspended: frozenStartSuspended,
|
|
976
|
+
rows: rowsAboveFrozenStart,
|
|
977
|
+
rowCount: frozenRowCount ?? 0,
|
|
978
|
+
columns: columnsAboveFrozenStart,
|
|
979
|
+
columnCount: frozenColumnCount ?? 0,
|
|
980
|
+
};
|
|
981
|
+
frozenStartViewRef.current = next;
|
|
982
|
+
const snapshot = frozenViewSnapshotRef.current;
|
|
983
|
+
frozenViewSnapshotRef.current = {};
|
|
984
|
+
// A sheet switch, or an export drawing the grid without its start for a moment (it puts the
|
|
985
|
+
// scroll position back itself): the view is not moved.
|
|
986
|
+
if (previous.sheetId !== sheetId) {
|
|
987
|
+
pendingFreezeRef.current = {};
|
|
988
|
+
localFreezeRef.current = {};
|
|
989
|
+
return;
|
|
990
|
+
}
|
|
991
|
+
if (previous.suspended !== frozenStartSuspended)
|
|
992
|
+
return;
|
|
993
|
+
// An undo / redo this window sent through the engine hook (a toolbar) that the grid has not
|
|
994
|
+
// seen: this change is it.
|
|
995
|
+
const historyKind = undoRedoSent && undoRedoSent.seq !== seenUndoRedoRef.current ? undoRedoSent.kind : undefined;
|
|
996
|
+
// A freeze this window sent through the engine hook (a ribbon) that the grid has not seen: what it
|
|
997
|
+
// asked for, per axis, in the grid's terms. One that asks for the area already there leaves no mark.
|
|
998
|
+
const sentFreeze = frozenAreaSent &&
|
|
999
|
+
frozenAreaSent.seq !== seenFrozenAreaRef.current &&
|
|
1000
|
+
frozenAreaSent.sheetId === sheetId
|
|
1001
|
+
? frozenAreaSent
|
|
1002
|
+
: undefined;
|
|
1003
|
+
const freezeSentOn = (axis) => {
|
|
1004
|
+
const asked = sentFreeze?.[axis];
|
|
1005
|
+
if (!asked)
|
|
1006
|
+
return undefined;
|
|
1007
|
+
const was = axis === "rows"
|
|
1008
|
+
? { lines: previous.rows, count: previous.rowCount }
|
|
1009
|
+
: { lines: previous.columns, count: previous.columnCount };
|
|
1010
|
+
const count = asked.count ?? was.count;
|
|
1011
|
+
// `freeze-row` / `freeze-column` always say where they start (absent = line 1); an
|
|
1012
|
+
// `update-sheet` that names only a count keeps the start the area had, while it stays frozen.
|
|
1013
|
+
const start = asked.start !== undefined ? asked.start : count > 0 && was.count > 0 ? was.lines + 1 : 1;
|
|
1014
|
+
const expected = {
|
|
1015
|
+
lines: linesAboveFrozenStart(start, count, axis === "rows"
|
|
1016
|
+
? Math.min(MAX_ROW_COUNT, rowCount)
|
|
1017
|
+
: Math.min(MAX_COLUMN_COUNT, columnCount)),
|
|
1018
|
+
count,
|
|
1019
|
+
};
|
|
1020
|
+
if (expected.lines === was.lines && expected.count === was.count)
|
|
1021
|
+
return undefined;
|
|
1022
|
+
const position = gridRef.current?.getScrollPosition();
|
|
1023
|
+
return {
|
|
1024
|
+
kind: "freeze",
|
|
1025
|
+
expected,
|
|
1026
|
+
scrollBefore: (axis === "rows" ? position?.scrollTop : position?.scrollLeft) ?? 0,
|
|
1027
|
+
};
|
|
1028
|
+
};
|
|
1029
|
+
const place = (axis, offset) => {
|
|
1030
|
+
const pending = pendingFreezeRef.current[axis] ??
|
|
1031
|
+
freezeSentOn(axis) ??
|
|
1032
|
+
(historyKind ? { kind: historyKind } : undefined);
|
|
1033
|
+
const result = frozenStartScroll({
|
|
1034
|
+
before: axis === "rows"
|
|
1035
|
+
? { lines: previous.rows, count: previous.rowCount }
|
|
1036
|
+
: { lines: previous.columns, count: previous.columnCount },
|
|
1037
|
+
after: axis === "rows"
|
|
1038
|
+
? { lines: next.rows, count: next.rowCount }
|
|
1039
|
+
: { lines: next.columns, count: next.columnCount },
|
|
1040
|
+
pending,
|
|
1041
|
+
local: localFreezeRef.current[axis],
|
|
1042
|
+
snapshot: snapshot[axis],
|
|
1043
|
+
offset,
|
|
1044
|
+
});
|
|
1045
|
+
// Any change on the axis reads the mark: it is dropped, matched or not.
|
|
1046
|
+
const changed = axis === "rows"
|
|
1047
|
+
? previous.rows !== next.rows || previous.rowCount !== next.rowCount
|
|
1048
|
+
: previous.columns !== next.columns ||
|
|
1049
|
+
previous.columnCount !== next.columnCount;
|
|
1050
|
+
if (changed || result.consumed)
|
|
1051
|
+
pendingFreezeRef.current[axis] = undefined;
|
|
1052
|
+
localFreezeRef.current[axis] = result.local;
|
|
1053
|
+
return result.scroll;
|
|
1054
|
+
};
|
|
1055
|
+
const scrollTop = place("rows", getRowOffset);
|
|
1056
|
+
const scrollLeft = place("columns", getColumnOffset);
|
|
1057
|
+
const grid = gridRef.current;
|
|
1058
|
+
if (grid && (scrollTop !== undefined || scrollLeft !== undefined)) {
|
|
1059
|
+
const current = grid.getScrollPosition();
|
|
1060
|
+
// At once, as a sheet switch does: the frozen area changed under the view in this render.
|
|
1061
|
+
grid.scrollTo({
|
|
1062
|
+
scrollTop: scrollTop ?? current.scrollTop,
|
|
1063
|
+
scrollLeft: scrollLeft ?? current.scrollLeft,
|
|
1064
|
+
}, true);
|
|
1065
|
+
}
|
|
1066
|
+
}, [
|
|
1067
|
+
sheetId,
|
|
1068
|
+
frozenStartSuspended,
|
|
1069
|
+
rowsAboveFrozenStart,
|
|
1070
|
+
frozenRowCount,
|
|
1071
|
+
columnsAboveFrozenStart,
|
|
1072
|
+
frozenColumnCount,
|
|
1073
|
+
]);
|
|
1074
|
+
// After every commit (and after the effect above): what this window sent has had its render.
|
|
1075
|
+
useIsomorphicLayoutEffect(() => {
|
|
1076
|
+
pendingFreezeRef.current = {};
|
|
1077
|
+
seenUndoRedoRef.current = undoRedoSent?.seq;
|
|
1078
|
+
seenFrozenAreaRef.current = frozenAreaSent?.seq;
|
|
1079
|
+
});
|
|
825
1080
|
/**
|
|
826
1081
|
* Get cell coordinates from x and y position
|
|
827
1082
|
* @param x
|
|
828
1083
|
* @param y
|
|
829
1084
|
* @returns
|
|
830
1085
|
*/
|
|
831
|
-
|
|
1086
|
+
/**
|
|
1087
|
+
* A point never names a row / column above a frozen start: those have no size, so the only
|
|
1088
|
+
* point that can land on one is the top / left edge of the first frozen line, which is that
|
|
1089
|
+
* line's. A merged cell reaching down past the start keeps its own (top-left) cell.
|
|
1090
|
+
*/
|
|
1091
|
+
const pointCellBelowFrozenStart = useCallbackRef(useCallback((cell) => {
|
|
1092
|
+
if (!cell || (!rowsAboveFrozenStart && !columnsAboveFrozenStart)) {
|
|
1093
|
+
return cell;
|
|
1094
|
+
}
|
|
1095
|
+
const rowAbove = isAboveFrozenStart(cell.rowIndex, rowsAboveFrozenStart);
|
|
1096
|
+
const columnAbove = isAboveFrozenStart(cell.columnIndex, columnsAboveFrozenStart);
|
|
1097
|
+
if (!rowAbove && !columnAbove)
|
|
1098
|
+
return cell;
|
|
1099
|
+
const bounds = getCellBounds(cell);
|
|
1100
|
+
return {
|
|
1101
|
+
rowIndex: rowAbove && bounds.endRowIndex <= rowsAboveFrozenStart
|
|
1102
|
+
? rowsAboveFrozenStart + 1
|
|
1103
|
+
: cell.rowIndex,
|
|
1104
|
+
columnIndex: columnAbove && bounds.endColumnIndex <= columnsAboveFrozenStart
|
|
1105
|
+
? columnsAboveFrozenStart + 1
|
|
1106
|
+
: cell.columnIndex,
|
|
1107
|
+
};
|
|
1108
|
+
}, [rowsAboveFrozenStart, columnsAboveFrozenStart, getCellBounds]));
|
|
1109
|
+
const getCellCoordsFromOffset = useCallback((x, y, includeFrozen) => {
|
|
1110
|
+
const grid = gridRef.current;
|
|
1111
|
+
const cell = pointCellBelowFrozenStart(grid?.getCellCoordsFromOffset(x, y, includeFrozen));
|
|
1112
|
+
if (includeFrozen !== false ||
|
|
1113
|
+
!cell ||
|
|
1114
|
+
!grid ||
|
|
1115
|
+
(!rowsAboveFrozenStart && !columnsAboveFrozenStart)) {
|
|
1116
|
+
return cell;
|
|
1117
|
+
}
|
|
1118
|
+
// A selection drag reads the body under the pointer, so a pointer over the column headings
|
|
1119
|
+
// names the row the body would scroll back to. Above a frozen start there is nothing to
|
|
1120
|
+
// scroll back to: as in Excel for Mac (checked 2026-11-18), the pointer over the headings
|
|
1121
|
+
// names the row just above the start, the selection takes it in (drawn cut at the band) and
|
|
1122
|
+
// nothing scrolls. Over the row headings, the column just left of the start (assumed: the
|
|
1123
|
+
// same rule).
|
|
1124
|
+
const position = grid.getRelativePositionFromOffset(x, y);
|
|
1125
|
+
if (!position)
|
|
1126
|
+
return cell;
|
|
1127
|
+
return {
|
|
1128
|
+
rowIndex: rowsAboveFrozenStart > 0 && position.y < grid.getRowOffset(1)
|
|
1129
|
+
? rowsAboveFrozenStart
|
|
1130
|
+
: cell.rowIndex,
|
|
1131
|
+
columnIndex: columnsAboveFrozenStart > 0 && position.x < grid.getColumnOffset(1)
|
|
1132
|
+
? columnsAboveFrozenStart
|
|
1133
|
+
: cell.columnIndex,
|
|
1134
|
+
};
|
|
1135
|
+
}, [scale, pointCellBelowFrozenStart, rowsAboveFrozenStart, columnsAboveFrozenStart]);
|
|
832
1136
|
/** The cell at a point in sheet coordinates, whatever is scrolled (`GridRef`). */
|
|
833
|
-
const getCellCoordsFromSheetOffset = useCallback((x, y) => gridRef.current?.getCellCoordsFromSheetOffset(x, y), [scale]);
|
|
1137
|
+
const getCellCoordsFromSheetOffset = useCallback((x, y) => pointCellBelowFrozenStart(gridRef.current?.getCellCoordsFromSheetOffset(x, y)), [scale, pointCellBelowFrozenStart]);
|
|
834
1138
|
/**
|
|
835
1139
|
* Get cells coords
|
|
836
1140
|
* caters to merged cells
|
|
@@ -1832,6 +2136,16 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
1832
2136
|
/**
|
|
1833
2137
|
* Exports a data region as image
|
|
1834
2138
|
*/
|
|
2139
|
+
const rangeReachesAboveFrozenStart = useCallback((range) => (sheetRowsAboveFrozenStart > 0 &&
|
|
2140
|
+
range.startRowIndex <= sheetRowsAboveFrozenStart) ||
|
|
2141
|
+
(sheetColumnsAboveFrozenStart > 0 &&
|
|
2142
|
+
range.startColumnIndex <= sheetColumnsAboveFrozenStart), [sheetRowsAboveFrozenStart, sheetColumnsAboveFrozenStart]);
|
|
2143
|
+
const isFrozenStartSuspended = useCallback(() => frozenStartSuspendedRef.current, []);
|
|
2144
|
+
// A capture interrupted by a sheet switch still ends with the start drawn: the suspension never
|
|
2145
|
+
// outlives the sheet it was made for (unmounting drops it with the component).
|
|
2146
|
+
useEffect(() => {
|
|
2147
|
+
setFrozenStartSuspended(false);
|
|
2148
|
+
}, [sheetId]);
|
|
1835
2149
|
const exportRange = useExportRange({
|
|
1836
2150
|
sheetId,
|
|
1837
2151
|
cellBackgroundColor,
|
|
@@ -1851,6 +2165,9 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
1851
2165
|
scrollTo,
|
|
1852
2166
|
scale: zoomScale,
|
|
1853
2167
|
onChangeScale,
|
|
2168
|
+
reachesAboveFrozenStart: rangeReachesAboveFrozenStart,
|
|
2169
|
+
setFrozenStartSuspended,
|
|
2170
|
+
isFrozenStartSuspended,
|
|
1854
2171
|
});
|
|
1855
2172
|
/**
|
|
1856
2173
|
* Get all cell selections from formula string
|
|
@@ -2213,6 +2530,23 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
2213
2530
|
defaultSize: defaultColumnWidth,
|
|
2214
2531
|
exceptions: sizeHintExceptions(columnMetadata),
|
|
2215
2532
|
}), [columnMetadata, defaultColumnWidth]);
|
|
2533
|
+
/**
|
|
2534
|
+
* What the GRID lays out, and nothing else: rows / columns above a frozen start have no size and
|
|
2535
|
+
* are left out of the visible row ranges, so they are neither drawn nor hit. Every other reader
|
|
2536
|
+
* (auto-fit, copy, fill, export, print, the sizes stored on the sheet) keeps `rowHeight` /
|
|
2537
|
+
* `columnWidth` / `visibleRowRanges` and sees them as ordinary rows. Without a start these are
|
|
2538
|
+
* the very same functions and arrays.
|
|
2539
|
+
*/
|
|
2540
|
+
const gridRowHeight = useMemo(() => sizeAboveFrozenStartZero(rowHeight, rowsAboveFrozenStart), [rowHeight, rowsAboveFrozenStart]);
|
|
2541
|
+
const gridColumnWidth = useMemo(() => sizeAboveFrozenStartZero(columnWidth, columnsAboveFrozenStart), [columnWidth, columnsAboveFrozenStart]);
|
|
2542
|
+
const gridVisibleRowRanges = useMemo(() => rangesWithoutLinesAboveFrozenStart(visibleRowRanges, rowsAboveFrozenStart), [visibleRowRanges, rowsAboveFrozenStart]);
|
|
2543
|
+
// The grid's body loops skip hidden columns; a column above the start is skipped there too, so a
|
|
2544
|
+
// zero-width cell left of the start never draws its text overflowing into the frozen band.
|
|
2545
|
+
const gridIsHiddenColumn = useMemo(() => columnsAboveFrozenStart > 0
|
|
2546
|
+
? (columnIndex) => isAboveFrozenStart(columnIndex, columnsAboveFrozenStart) ||
|
|
2547
|
+
isHiddenColumn(columnIndex)
|
|
2548
|
+
: isHiddenColumn, [isHiddenColumn, columnsAboveFrozenStart]);
|
|
2549
|
+
const gridColumnSizeHint = useMemo(() => sizeHintWithLinesAboveFrozenStart(columnSizeHint, columnsAboveFrozenStart), [columnSizeHint, columnsAboveFrozenStart]);
|
|
2216
2550
|
/**
|
|
2217
2551
|
* Get actual cell width with merged cells
|
|
2218
2552
|
*/
|
|
@@ -2311,6 +2645,8 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
2311
2645
|
columnCount,
|
|
2312
2646
|
frozenColumns,
|
|
2313
2647
|
frozenRows,
|
|
2648
|
+
frozenRowStart: rowsAboveFrozenStart + 1,
|
|
2649
|
+
frozenColumnStart: columnsAboveFrozenStart + 1,
|
|
2314
2650
|
selectionLeftBound,
|
|
2315
2651
|
selectionTopBound,
|
|
2316
2652
|
isHiddenColumn,
|
|
@@ -2413,6 +2749,8 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
2413
2749
|
const { getColumnWidth, getRowHeight, getCellDimensions, getCellDimensionsStable, getTextDimension, } = useSizer({
|
|
2414
2750
|
frozenRows,
|
|
2415
2751
|
frozenColumns,
|
|
2752
|
+
frozenRowStart: rowsAboveFrozenStart + 1,
|
|
2753
|
+
frozenColumnStart: columnsAboveFrozenStart + 1,
|
|
2416
2754
|
scale,
|
|
2417
2755
|
minColumnDimension: MIN_COLUMN_WIDTH,
|
|
2418
2756
|
minRowDimension: defaultRowHeight,
|
|
@@ -2792,6 +3130,7 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
2792
3130
|
if (!request || request.sheetId !== sheetId)
|
|
2793
3131
|
return;
|
|
2794
3132
|
if (option === "undo") {
|
|
3133
|
+
markHistorySent("undo");
|
|
2795
3134
|
onUndo?.();
|
|
2796
3135
|
}
|
|
2797
3136
|
else if (option === "select-blank" || option === "select-changed") {
|
|
@@ -2810,6 +3149,7 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
2810
3149
|
setFlashFillOptions,
|
|
2811
3150
|
sheetId,
|
|
2812
3151
|
onUndo,
|
|
3152
|
+
markHistorySent,
|
|
2813
3153
|
onChangeActiveCell,
|
|
2814
3154
|
onChangeSelections,
|
|
2815
3155
|
focusSheet,
|
|
@@ -2970,8 +3310,21 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
2970
3310
|
selection,
|
|
2971
3311
|
initialIn,
|
|
2972
3312
|
onApply: (spec) => applyFillSeriesSpec(sheetId, activeCell, selection, spec),
|
|
3313
|
+
locale,
|
|
3314
|
+
// Asked once, as the dialog opens (the rnc engine reads it through a formula preview).
|
|
3315
|
+
date1904: getDate1904?.() ?? false,
|
|
3316
|
+
parseStop: parseCellEntryNumber,
|
|
2973
3317
|
});
|
|
2974
|
-
}, [
|
|
3318
|
+
}, [
|
|
3319
|
+
selections,
|
|
3320
|
+
activeCell,
|
|
3321
|
+
sheetId,
|
|
3322
|
+
openFillSeriesDialog,
|
|
3323
|
+
applyFillSeriesSpec,
|
|
3324
|
+
locale,
|
|
3325
|
+
getDate1904,
|
|
3326
|
+
parseCellEntryNumber,
|
|
3327
|
+
]);
|
|
2975
3328
|
/** "Series…" on the right-drag fill menu: the drag's target is the range, its axis the default. */
|
|
2976
3329
|
const handleOpenFillSeriesDialog = useCallback(() => {
|
|
2977
3330
|
if (!fillOptions)
|
|
@@ -3059,6 +3412,9 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
3059
3412
|
getValue: getUserEnteredStringValue,
|
|
3060
3413
|
selectionLeftBound,
|
|
3061
3414
|
selectionTopBound,
|
|
3415
|
+
// The grid's frozen counts include the heading, so they are the first scrolling row / column.
|
|
3416
|
+
scrollingTopBound: frozenRows,
|
|
3417
|
+
scrollingLeftBound: frozenColumns,
|
|
3062
3418
|
canSelectionSpanMergedCells,
|
|
3063
3419
|
mouseDownInterceptor: onMouseDownInterceptor,
|
|
3064
3420
|
mouseMoveInterceptor: onMouseMoveInterceptor,
|
|
@@ -3544,7 +3900,7 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
3544
3900
|
* Get context Menu component
|
|
3545
3901
|
*/
|
|
3546
3902
|
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 }));
|
|
3903
|
+
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
3904
|
}, [
|
|
3549
3905
|
isRestricted,
|
|
3550
3906
|
activeCell,
|
|
@@ -3568,6 +3924,8 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
3568
3924
|
onClearContents,
|
|
3569
3925
|
onFreezeColumn,
|
|
3570
3926
|
onFreezeRow,
|
|
3927
|
+
freezeColumnsUpTo,
|
|
3928
|
+
freezeRowsUpTo,
|
|
3571
3929
|
focusSheet,
|
|
3572
3930
|
onSortColumn,
|
|
3573
3931
|
copy,
|
|
@@ -3686,15 +4044,17 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
3686
4044
|
const undoDroppingFillOptions = useMemo(() => onUndo
|
|
3687
4045
|
? () => {
|
|
3688
4046
|
dropSmartTags();
|
|
4047
|
+
markHistorySent("undo");
|
|
3689
4048
|
onUndo();
|
|
3690
4049
|
}
|
|
3691
|
-
: undefined, [onUndo, dropSmartTags]);
|
|
4050
|
+
: undefined, [onUndo, dropSmartTags, markHistorySent]);
|
|
3692
4051
|
const redoDroppingFillOptions = useMemo(() => onRedo
|
|
3693
4052
|
? () => {
|
|
3694
4053
|
dropSmartTags();
|
|
4054
|
+
markHistorySent("redo");
|
|
3695
4055
|
onRedo();
|
|
3696
4056
|
}
|
|
3697
|
-
: undefined, [onRedo, dropSmartTags]);
|
|
4057
|
+
: undefined, [onRedo, dropSmartTags, markHistorySent]);
|
|
3698
4058
|
const onKeyDownFormatting = useKeyboardHandler({
|
|
3699
4059
|
sheetId,
|
|
3700
4060
|
locale,
|
|
@@ -3957,6 +4317,7 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
3957
4317
|
getViewPort,
|
|
3958
4318
|
frozenRows,
|
|
3959
4319
|
frozenColumns,
|
|
4320
|
+
frozenRowStart: rowsAboveFrozenStart + 1,
|
|
3960
4321
|
selectionTopBound,
|
|
3961
4322
|
showHeaderMenuButton,
|
|
3962
4323
|
scale,
|
|
@@ -4126,18 +4487,104 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
4126
4487
|
deselect();
|
|
4127
4488
|
return store.sub(selectedChartEmbedAtom, deselect);
|
|
4128
4489
|
}, [objectsHidden, store, focusSheet, gridContainerRef]);
|
|
4490
|
+
/**
|
|
4491
|
+
* Objects on a sheet frozen while scrolled. An object is laid out from where its anchor cell
|
|
4492
|
+
* would be if the lines above the frozen start kept their size (`objectCellOffset`), so one
|
|
4493
|
+
* anchored above the start and reaching into the frozen band is drawn cut at the band's top /
|
|
4494
|
+
* left edge (`clipAboveFrozenStart` on the object layers), and one lying wholly above the start
|
|
4495
|
+
* is left out of the object layer: not drawn, clicked, tabbed to or selected, as with "For
|
|
4496
|
+
* objects, show: none". Without a start the objects are the props and the grid's own layout.
|
|
4497
|
+
*/
|
|
4498
|
+
const objectCellOffset = useMemo(() => objectCellOffsetAboveFrozenStart({
|
|
4499
|
+
getCellOffsetFromCoords,
|
|
4500
|
+
rowsAbove: rowsAboveFrozenStart,
|
|
4501
|
+
columnsAbove: columnsAboveFrozenStart,
|
|
4502
|
+
rowSize: (index) => rowHeight(index) * scale,
|
|
4503
|
+
columnSize: (index) => columnWidth(index) * scale,
|
|
4504
|
+
distanceAbove: (axis, index) => scale *
|
|
4505
|
+
(axis === "row"
|
|
4506
|
+
? sumLineSizes({
|
|
4507
|
+
from: index,
|
|
4508
|
+
to: rowsAboveFrozenStart,
|
|
4509
|
+
size: rowHeight,
|
|
4510
|
+
hint: rowSizeHint,
|
|
4511
|
+
visibleRanges: visibleRowRanges,
|
|
4512
|
+
})
|
|
4513
|
+
: sumLineSizes({
|
|
4514
|
+
from: index,
|
|
4515
|
+
to: columnsAboveFrozenStart,
|
|
4516
|
+
size: columnWidth,
|
|
4517
|
+
hint: columnSizeHint,
|
|
4518
|
+
})),
|
|
4519
|
+
}), [
|
|
4520
|
+
getCellOffsetFromCoords,
|
|
4521
|
+
rowsAboveFrozenStart,
|
|
4522
|
+
columnsAboveFrozenStart,
|
|
4523
|
+
rowHeight,
|
|
4524
|
+
columnWidth,
|
|
4525
|
+
rowSizeHint,
|
|
4526
|
+
columnSizeHint,
|
|
4527
|
+
visibleRowRanges,
|
|
4528
|
+
scale,
|
|
4529
|
+
]);
|
|
4530
|
+
const shownObjectsBelowFrozenStart = useCallback((objects) => {
|
|
4531
|
+
if (!objects || (!rowsAboveFrozenStart && !columnsAboveFrozenStart)) {
|
|
4532
|
+
return objects;
|
|
4533
|
+
}
|
|
4534
|
+
const bandTop = getRowOffset(rowsAboveFrozenStart + 1);
|
|
4535
|
+
const bandLeft = getColumnOffset(columnsAboveFrozenStart + 1);
|
|
4536
|
+
const shown = objects.filter((object) => {
|
|
4537
|
+
const overlay = object.position?.overlayPosition;
|
|
4538
|
+
if (!overlay?.anchorCell)
|
|
4539
|
+
return true;
|
|
4540
|
+
const anchorAbove = isAboveFrozenStart(overlay.anchorCell.rowIndex, rowsAboveFrozenStart) ||
|
|
4541
|
+
isAboveFrozenStart(overlay.anchorCell.columnIndex, columnsAboveFrozenStart);
|
|
4542
|
+
if (!anchorAbove)
|
|
4543
|
+
return true;
|
|
4544
|
+
const from = objectCellOffset(overlay.anchorCell);
|
|
4545
|
+
if (!from)
|
|
4546
|
+
return true;
|
|
4547
|
+
const left = from.x + (overlay.offsetXPixels ?? 0) * scale;
|
|
4548
|
+
const top = from.y + (overlay.offsetYPixels ?? 0) * scale;
|
|
4549
|
+
const toAnchor = getOverlayToAnchorProps(overlay);
|
|
4550
|
+
const to = toAnchor ? objectCellOffset(toAnchor.toCell) : undefined;
|
|
4551
|
+
const right = to
|
|
4552
|
+
? to.x + toAnchor.toOffsetXPixels * scale
|
|
4553
|
+
: left + (overlay.widthPixels ?? 0) * scale;
|
|
4554
|
+
const bottom = to
|
|
4555
|
+
? to.y + toAnchor.toOffsetYPixels * scale
|
|
4556
|
+
: top + (overlay.heightPixels ?? 0) * scale;
|
|
4557
|
+
return !((rowsAboveFrozenStart > 0 && bottom <= bandTop) ||
|
|
4558
|
+
(columnsAboveFrozenStart > 0 && right <= bandLeft));
|
|
4559
|
+
});
|
|
4560
|
+
return shown.length === objects.length ? objects : shown;
|
|
4561
|
+
},
|
|
4562
|
+
// `gridReady`: the cells can be placed only once the grid is mounted.
|
|
4563
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4564
|
+
[
|
|
4565
|
+
gridReady,
|
|
4566
|
+
rowsAboveFrozenStart,
|
|
4567
|
+
columnsAboveFrozenStart,
|
|
4568
|
+
getRowOffset,
|
|
4569
|
+
getColumnOffset,
|
|
4570
|
+
objectCellOffset,
|
|
4571
|
+
scale,
|
|
4572
|
+
]);
|
|
4573
|
+
const shownCharts = useMemo(() => shownObjectsBelowFrozenStart(charts), [charts, shownObjectsBelowFrozenStart]);
|
|
4574
|
+
const shownEmbeds = useMemo(() => shownObjectsBelowFrozenStart(embeds), [embeds, shownObjectsBelowFrozenStart]);
|
|
4575
|
+
const shownSlicers = useMemo(() => shownObjectsBelowFrozenStart(slicers), [slicers, shownObjectsBelowFrozenStart]);
|
|
4129
4576
|
const { chartComponents, embedComponents, slicerComponents, contextMenuComponent: embedContextMenuComponent, onMouseDown: onMouseDownCharts, requestChartContextMenu, selectAllObjects: selectAllObjectsUnstable, } = useEmbedsCharts({
|
|
4130
4577
|
pageLayout,
|
|
4131
4578
|
getLinkedPictureSource,
|
|
4132
4579
|
getSheetName,
|
|
4133
|
-
charts: objectsHidden ? EMPTY_OBJECTS :
|
|
4134
|
-
embeds: objectsHidden ? EMPTY_OBJECTS :
|
|
4135
|
-
slicers: objectsHidden ? EMPTY_OBJECTS :
|
|
4580
|
+
charts: objectsHidden ? EMPTY_OBJECTS : shownCharts,
|
|
4581
|
+
embeds: objectsHidden ? EMPTY_OBJECTS : shownEmbeds,
|
|
4582
|
+
slicers: objectsHidden ? EMPTY_OBJECTS : shownSlicers,
|
|
4136
4583
|
sheetId,
|
|
4137
4584
|
scale,
|
|
4138
4585
|
frozenRows,
|
|
4139
4586
|
frozenColumns,
|
|
4140
|
-
getCellOffsetFromCoords,
|
|
4587
|
+
getCellOffsetFromCoords: objectCellOffset,
|
|
4141
4588
|
getAbsolutePositionFromOffset,
|
|
4142
4589
|
getCellCoordsFromOffset,
|
|
4143
4590
|
getCellCoordsFromSheetOffset,
|
|
@@ -4984,6 +5431,8 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
4984
5431
|
focusSheet,
|
|
4985
5432
|
rowCount,
|
|
4986
5433
|
columnCount,
|
|
5434
|
+
rowsAboveFrozenStart,
|
|
5435
|
+
columnsAboveFrozenStart,
|
|
4987
5436
|
HiddenRowMarkers,
|
|
4988
5437
|
HiddenColumnMarkers,
|
|
4989
5438
|
});
|
|
@@ -5197,6 +5646,38 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
5197
5646
|
* row dimension changes
|
|
5198
5647
|
*/
|
|
5199
5648
|
useHiddenDimensions(columnMetadata, rowMetadata, sheetId, scale, resetLastMeasuredIndices, hostHiddenRowRanges, visibleRowRanges);
|
|
5649
|
+
// Before the frozen area's change is laid out: where the view is, in the old layout, so the effect
|
|
5650
|
+
// that places the view (`frozenStartScroll`) can keep the same line first on screen.
|
|
5651
|
+
const previousFrozenRowsForView = usePrevious(frozenRows);
|
|
5652
|
+
const previousFrozenColumnsForView = usePrevious(frozenColumns);
|
|
5653
|
+
if (gridRef.current &&
|
|
5654
|
+
previousFrozenRowsForView !== undefined &&
|
|
5655
|
+
previousFrozenColumnsForView !== undefined &&
|
|
5656
|
+
(previousFrozenRowsForView !== frozenRows ||
|
|
5657
|
+
previousFrozenColumnsForView !== frozenColumns)) {
|
|
5658
|
+
const grid = gridRef.current;
|
|
5659
|
+
const viewport = grid.getViewPort();
|
|
5660
|
+
const position = grid.getScrollPosition();
|
|
5661
|
+
const snapshotOf = (topLine, scroll, bandEnd, offset) => ({ topLine, intoLine: scroll + bandEnd - offset });
|
|
5662
|
+
frozenViewSnapshotRef.current = {
|
|
5663
|
+
rows: snapshotOf(viewport.visibleRowStartIndex, position.scrollTop, grid.getRowOffset(previousFrozenRowsForView), grid.getRowOffset(viewport.visibleRowStartIndex)),
|
|
5664
|
+
columns: snapshotOf(viewport.visibleColumnStartIndex, position.scrollLeft, grid.getColumnOffset(previousFrozenColumnsForView), grid.getColumnOffset(viewport.visibleColumnStartIndex)),
|
|
5665
|
+
};
|
|
5666
|
+
}
|
|
5667
|
+
// A frozen start that comes, goes or moves changes which lines the grid lays out with no size:
|
|
5668
|
+
// re-measure from the first line, in the same render, as the hook above does for hidden rows.
|
|
5669
|
+
const previousRowsAboveFrozenStart = usePrevious(rowsAboveFrozenStart);
|
|
5670
|
+
const previousColumnsAboveFrozenStart = usePrevious(columnsAboveFrozenStart);
|
|
5671
|
+
const rowsAboveFrozenStartChanged = previousRowsAboveFrozenStart !== undefined &&
|
|
5672
|
+
previousRowsAboveFrozenStart !== rowsAboveFrozenStart;
|
|
5673
|
+
const columnsAboveFrozenStartChanged = previousColumnsAboveFrozenStart !== undefined &&
|
|
5674
|
+
previousColumnsAboveFrozenStart !== columnsAboveFrozenStart;
|
|
5675
|
+
if (rowsAboveFrozenStartChanged || columnsAboveFrozenStartChanged) {
|
|
5676
|
+
resetLastMeasuredIndices({
|
|
5677
|
+
rowIndex: rowsAboveFrozenStartChanged ? 0 : undefined,
|
|
5678
|
+
columnIndex: columnsAboveFrozenStartChanged ? 0 : undefined,
|
|
5679
|
+
});
|
|
5680
|
+
}
|
|
5200
5681
|
// Callback when sheet changes
|
|
5201
5682
|
useSheetChangeHandler(sheetId,
|
|
5202
5683
|
// Immediate callback for imperative methods
|
|
@@ -5334,6 +5815,12 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
5334
5815
|
/**
|
|
5335
5816
|
* Insert components inside the grid viewport
|
|
5336
5817
|
*/
|
|
5818
|
+
const clipAboveFrozenStart = useMemo(() => rowsAboveFrozenStart || columnsAboveFrozenStart
|
|
5819
|
+
? {
|
|
5820
|
+
rows: rowsAboveFrozenStart > 0,
|
|
5821
|
+
columns: columnsAboveFrozenStart > 0,
|
|
5822
|
+
}
|
|
5823
|
+
: undefined, [rowsAboveFrozenStart, columnsAboveFrozenStart]);
|
|
5337
5824
|
const baseGridChildren = useGridChildren({
|
|
5338
5825
|
stickyEditor,
|
|
5339
5826
|
editorComponent,
|
|
@@ -5360,6 +5847,10 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
5360
5847
|
// at, and the two can disagree (the independent review's finding 6).
|
|
5361
5848
|
editorPaneId: editorPaneIdRef.current,
|
|
5362
5849
|
getCellOffsetFromCoords,
|
|
5850
|
+
clipAboveFrozenStart,
|
|
5851
|
+
objectCellOffset: rowsAboveFrozenStart || columnsAboveFrozenStart
|
|
5852
|
+
? objectCellOffset
|
|
5853
|
+
: undefined,
|
|
5363
5854
|
});
|
|
5364
5855
|
const sheetNameForLayout = pageLayout ? getSheetName?.(sheetId) ?? "" : "";
|
|
5365
5856
|
const handleChangeHeaderFooter = useCallback((headerFooter) => onChangeHeaderFooter?.(sheetId, headerFooter), [onChangeHeaderFooter, sheetId]);
|
|
@@ -5451,7 +5942,7 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
5451
5942
|
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
5943
|
React.createElement("div", { className: "space-y-2" },
|
|
5453
5944
|
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:
|
|
5945
|
+
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
5946
|
// Freeze Panes and Split are mutually exclusive: the grid is told the SHEET's frozen
|
|
5456
5947
|
// counts, not the heading band added above.
|
|
5457
5948
|
sheetFrozenRows: frozenRowCount ?? 0, sheetFrozenColumns: frozenColumnCount ?? 0, activeCell: activeCell, selections: formulaMode ? formulaSelections : selections, FillHandle: FillHandle, showFillHandle: showFillHandle,
|
|
@@ -5459,7 +5950,7 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
5459
5950
|
// Options, Insert Options on a lone active cell) need its copies per pane.
|
|
5460
5951
|
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
5952
|
// Dimension of fill handle
|
|
5462
|
-
scrollToCellOffset: 4, scrollbarSize: scrollbarSize, isHiddenCell: isHiddenCell, isHiddenColumn:
|
|
5953
|
+
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
5954
|
React.createElement(RtlMirrorLayer, { rightToLeft: rightToLeft }, tooltipComponent),
|
|
5464
5955
|
stickyEditor ? (React.createElement(RtlMirrorLayer, { rightToLeft: rightToLeft }, editorComponent)) : null,
|
|
5465
5956
|
React.createElement(RtlMirrorLayer, { rightToLeft: rightToLeft },
|