@rowsncolumns/spreadsheet 10.15.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.
- package/dist/cjs/api/editor-formula.d.ts +40 -0
- package/dist/cjs/api/editor-formula.d.ts.map +1 -0
- package/dist/cjs/api/editor-formula.js +87 -0
- package/dist/cjs/atoms/cell-input-context.atom.d.ts.map +1 -1
- package/dist/cjs/components/autocorrect-options-smart-tag/index.d.ts +22 -8
- package/dist/cjs/components/autocorrect-options-smart-tag/index.d.ts.map +1 -1
- package/dist/cjs/components/autocorrect-options-smart-tag/index.js +107 -22
- package/dist/cjs/components/canvas-grid/frozen-start.d.ts +130 -0
- package/dist/cjs/components/canvas-grid/frozen-start.d.ts.map +1 -0
- package/dist/cjs/components/canvas-grid/frozen-start.js +266 -0
- package/dist/cjs/components/canvas-grid/index.d.ts.map +1 -1
- package/dist/cjs/components/canvas-grid/index.js +515 -71
- package/dist/cjs/components/canvas-grid/typings.d.ts +24 -8
- package/dist/cjs/components/canvas-grid/typings.d.ts.map +1 -1
- package/dist/cjs/components/cell-input/cell-input.d.ts.map +1 -1
- package/dist/cjs/components/cell-input/cell-input.js +3 -1
- package/dist/cjs/components/embeds/embed-draggable.d.ts.map +1 -1
- package/dist/cjs/components/embeds/embed-draggable.js +42 -19
- 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/embeds/object-focus.d.ts +16 -3
- package/dist/cjs/components/embeds/object-focus.d.ts.map +1 -1
- package/dist/cjs/components/embeds/object-focus.js +62 -6
- package/dist/cjs/components/outline-gutter/index.d.ts +11 -3
- package/dist/cjs/components/outline-gutter/index.d.ts.map +1 -1
- package/dist/cjs/components/outline-gutter/index.js +11 -6
- package/dist/cjs/components/selection/index.d.ts +1 -1
- package/dist/cjs/components/selection/index.d.ts.map +1 -1
- package/dist/cjs/components/selection/index.js +2 -2
- package/dist/cjs/components/selection/types.d.ts +2 -0
- package/dist/cjs/components/selection/types.d.ts.map +1 -1
- package/dist/cjs/hooks/object-spec-schema.generated.d.ts.map +1 -1
- package/dist/cjs/hooks/object-spec-schema.generated.js +16 -0
- package/dist/cjs/hooks/use-editable.d.ts.map +1 -1
- package/dist/cjs/hooks/use-editable.js +5 -1
- package/dist/cjs/hooks/use-editor-change.d.ts.map +1 -1
- package/dist/cjs/hooks/use-editor-change.js +3 -1
- 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-flash-fill-suggestion.d.ts.map +1 -1
- package/dist/cjs/hooks/use-flash-fill-suggestion.js +15 -4
- package/dist/cjs/hooks/use-grid-children.d.ts +27 -2
- package/dist/cjs/hooks/use-grid-children.d.ts.map +1 -1
- package/dist/cjs/hooks/use-grid-children.js +61 -21
- 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 +5 -3
- package/dist/cjs/hooks/use-selection-renderer.d.ts.map +1 -1
- package/dist/cjs/hooks/use-selection-renderer.js +18 -4
- 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 +24 -0
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/esm/api/editor-formula.d.ts +40 -0
- package/dist/esm/api/editor-formula.d.ts.map +1 -0
- package/dist/esm/api/editor-formula.js +76 -0
- package/dist/esm/atoms/cell-input-context.atom.d.ts.map +1 -1
- package/dist/esm/components/autocorrect-options-smart-tag/index.d.ts +22 -8
- package/dist/esm/components/autocorrect-options-smart-tag/index.d.ts.map +1 -1
- package/dist/esm/components/autocorrect-options-smart-tag/index.js +103 -22
- package/dist/esm/components/canvas-grid/frozen-start.d.ts +130 -0
- package/dist/esm/components/canvas-grid/frozen-start.d.ts.map +1 -0
- package/dist/esm/components/canvas-grid/frozen-start.js +222 -0
- package/dist/esm/components/canvas-grid/index.d.ts.map +1 -1
- package/dist/esm/components/canvas-grid/index.js +439 -20
- package/dist/esm/components/canvas-grid/typings.d.ts +24 -8
- package/dist/esm/components/canvas-grid/typings.d.ts.map +1 -1
- package/dist/esm/components/cell-input/cell-input.d.ts.map +1 -1
- package/dist/esm/components/cell-input/cell-input.js +4 -2
- package/dist/esm/components/embeds/embed-draggable.d.ts.map +1 -1
- package/dist/esm/components/embeds/embed-draggable.js +34 -14
- 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/embeds/object-focus.d.ts +16 -3
- package/dist/esm/components/embeds/object-focus.d.ts.map +1 -1
- package/dist/esm/components/embeds/object-focus.js +38 -2
- package/dist/esm/components/outline-gutter/index.d.ts +11 -3
- package/dist/esm/components/outline-gutter/index.d.ts.map +1 -1
- package/dist/esm/components/outline-gutter/index.js +11 -6
- package/dist/esm/components/selection/index.d.ts +1 -1
- package/dist/esm/components/selection/index.d.ts.map +1 -1
- package/dist/esm/components/selection/index.js +2 -2
- package/dist/esm/components/selection/types.d.ts +2 -0
- package/dist/esm/components/selection/types.d.ts.map +1 -1
- package/dist/esm/hooks/object-spec-schema.generated.d.ts.map +1 -1
- package/dist/esm/hooks/object-spec-schema.generated.js +16 -0
- package/dist/esm/hooks/use-editable.d.ts.map +1 -1
- package/dist/esm/hooks/use-editable.js +6 -2
- package/dist/esm/hooks/use-editor-change.d.ts.map +1 -1
- package/dist/esm/hooks/use-editor-change.js +4 -2
- 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-flash-fill-suggestion.d.ts.map +1 -1
- package/dist/esm/hooks/use-flash-fill-suggestion.js +15 -4
- package/dist/esm/hooks/use-grid-children.d.ts +27 -2
- package/dist/esm/hooks/use-grid-children.d.ts.map +1 -1
- package/dist/esm/hooks/use-grid-children.js +53 -16
- 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 +5 -3
- package/dist/esm/hooks/use-selection-renderer.d.ts.map +1 -1
- package/dist/esm/hooks/use-selection-renderer.js +18 -4
- 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 +24 -0
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/spreadsheet.min.css +1 -1
- package/package.json +3 -3
|
@@ -31,8 +31,8 @@ import { useActiveEditor } from "../../atoms/active-editor.atom";
|
|
|
31
31
|
import { useFlashFillSuggestion, } from "../../hooks/use-flash-fill-suggestion";
|
|
32
32
|
import { useAddWatch, useIsWatchWindowMounted, useSetWatchWindowContext, } from "../../atoms/watch-window.atom";
|
|
33
33
|
import { editingCellAtom, useEditingCell } from "../../atoms/editing-cell.atom";
|
|
34
|
-
import { selectedChartEmbedAtom } from "../../atoms/selected-chart-embed.atom";
|
|
35
|
-
import { objectFocusTargetsAtom, sheetFocusTargetsAtom, } from "../embeds/object-focus";
|
|
34
|
+
import { selectedChartEmbedAtom, selectedObjectGroupAtom, } from "../../atoms/selected-chart-embed.atom";
|
|
35
|
+
import { objectFocusTargetOf, objectFocusTargetsAtom, sheetFocusTargetsAtom, } from "../embeds/object-focus";
|
|
36
36
|
import { useSetEnterKeyDirection } from "../../atoms/enter-key-direction.atom";
|
|
37
37
|
import { useCellEditorInstance, useSetFormulabarEditorValue, useSetFormulaBarTextFormatRuns, } from "../../atoms/formula-bar-editor-value.atom";
|
|
38
38
|
import { useFormulaCanSelectCells, useFormulaSelectionMode, useSetFormulaSelectionState, } from "../../atoms/formula-selection-state.atom";
|
|
@@ -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 = {
|
|
@@ -159,8 +161,12 @@ function isDetachedEditor(editor) {
|
|
|
159
161
|
const element = editor.el?.();
|
|
160
162
|
return element != null && !element.isConnected;
|
|
161
163
|
}
|
|
164
|
+
/** An empty object list, stable across renders ("For objects, show: none"). */
|
|
165
|
+
const EMPTY_OBJECTS = [];
|
|
166
|
+
/** "For objects, show: placeholders": an object's frame drawn with nothing in it. */
|
|
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" }));
|
|
162
168
|
function CanvasGridComponent(props, forwardedRef) {
|
|
163
|
-
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, 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,
|
|
164
170
|
// Host-driven filter props. `hostHiddenRowRanges`
|
|
165
171
|
// supplies compact [start, end] hidden-row tuples; `getFilterValues` supplies a
|
|
166
172
|
// column's distinct values. Both let a million-row filter render without scanning
|
|
@@ -366,8 +372,32 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
366
372
|
const scale = zoomScale * (pageLayout?.scale ?? 1);
|
|
367
373
|
// Page Layout draws its own pages: no Page Break Preview over them.
|
|
368
374
|
const pageBreakPreview = pageLayout ? undefined : pageBreakPreviewProp;
|
|
369
|
-
|
|
370
|
-
|
|
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;
|
|
371
401
|
/**
|
|
372
402
|
* View ▸ Split. The grid wants pixels from the first body cell; the sheet stores twentieths of a
|
|
373
403
|
* point. Page Layout view draws pages rather than a window, so it never splits.
|
|
@@ -818,15 +848,206 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
818
848
|
visibleColumnStartIndex: 0,
|
|
819
849
|
visibleColumnStopIndex: 0,
|
|
820
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
|
+
]);
|
|
821
993
|
/**
|
|
822
994
|
* Get cell coordinates from x and y position
|
|
823
995
|
* @param x
|
|
824
996
|
* @param y
|
|
825
997
|
* @returns
|
|
826
998
|
*/
|
|
827
|
-
|
|
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]);
|
|
828
1049
|
/** The cell at a point in sheet coordinates, whatever is scrolled (`GridRef`). */
|
|
829
|
-
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]);
|
|
830
1051
|
/**
|
|
831
1052
|
* Get cells coords
|
|
832
1053
|
* caters to merged cells
|
|
@@ -872,8 +1093,10 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
872
1093
|
// Delete removes the chart instead of clearing the active cell.
|
|
873
1094
|
const selectedObject = store.get(selectedChartEmbedAtom);
|
|
874
1095
|
if (selectedObject !== undefined && !store.get(editingCellAtom)) {
|
|
875
|
-
|
|
876
|
-
|
|
1096
|
+
// On a split sheet the object may be drawn in several panes: the copy holding focus keeps
|
|
1097
|
+
// it, else the first copy still drawn takes it.
|
|
1098
|
+
const target = objectFocusTargetOf(store.get(objectFocusTargetsAtom), selectedObject, gridContainer);
|
|
1099
|
+
if (target && gridContainer) {
|
|
877
1100
|
if (activeElement !== target)
|
|
878
1101
|
target.focus({ preventScroll: true });
|
|
879
1102
|
return;
|
|
@@ -1826,6 +2049,16 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
1826
2049
|
/**
|
|
1827
2050
|
* Exports a data region as image
|
|
1828
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]);
|
|
1829
2062
|
const exportRange = useExportRange({
|
|
1830
2063
|
sheetId,
|
|
1831
2064
|
cellBackgroundColor,
|
|
@@ -1845,6 +2078,9 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
1845
2078
|
scrollTo,
|
|
1846
2079
|
scale: zoomScale,
|
|
1847
2080
|
onChangeScale,
|
|
2081
|
+
reachesAboveFrozenStart: rangeReachesAboveFrozenStart,
|
|
2082
|
+
setFrozenStartSuspended,
|
|
2083
|
+
isFrozenStartSuspended,
|
|
1848
2084
|
});
|
|
1849
2085
|
/**
|
|
1850
2086
|
* Get all cell selections from formula string
|
|
@@ -2207,6 +2443,23 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
2207
2443
|
defaultSize: defaultColumnWidth,
|
|
2208
2444
|
exceptions: sizeHintExceptions(columnMetadata),
|
|
2209
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]);
|
|
2210
2463
|
/**
|
|
2211
2464
|
* Get actual cell width with merged cells
|
|
2212
2465
|
*/
|
|
@@ -2305,6 +2558,8 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
2305
2558
|
columnCount,
|
|
2306
2559
|
frozenColumns,
|
|
2307
2560
|
frozenRows,
|
|
2561
|
+
frozenRowStart: rowsAboveFrozenStart + 1,
|
|
2562
|
+
frozenColumnStart: columnsAboveFrozenStart + 1,
|
|
2308
2563
|
selectionLeftBound,
|
|
2309
2564
|
selectionTopBound,
|
|
2310
2565
|
isHiddenColumn,
|
|
@@ -2407,6 +2662,8 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
2407
2662
|
const { getColumnWidth, getRowHeight, getCellDimensions, getCellDimensionsStable, getTextDimension, } = useSizer({
|
|
2408
2663
|
frozenRows,
|
|
2409
2664
|
frozenColumns,
|
|
2665
|
+
frozenRowStart: rowsAboveFrozenStart + 1,
|
|
2666
|
+
frozenColumnStart: columnsAboveFrozenStart + 1,
|
|
2410
2667
|
scale,
|
|
2411
2668
|
minColumnDimension: MIN_COLUMN_WIDTH,
|
|
2412
2669
|
minRowDimension: defaultRowHeight,
|
|
@@ -3538,7 +3795,7 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
3538
3795
|
* Get context Menu component
|
|
3539
3796
|
*/
|
|
3540
3797
|
const getContextMenu = useCallback((cell) => {
|
|
3541
|
-
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 }));
|
|
3542
3799
|
}, [
|
|
3543
3800
|
isRestricted,
|
|
3544
3801
|
activeCell,
|
|
@@ -3562,6 +3819,8 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
3562
3819
|
onClearContents,
|
|
3563
3820
|
onFreezeColumn,
|
|
3564
3821
|
onFreezeRow,
|
|
3822
|
+
freezeColumnsUpTo,
|
|
3823
|
+
freezeRowsUpTo,
|
|
3565
3824
|
focusSheet,
|
|
3566
3825
|
onSortColumn,
|
|
3567
3826
|
copy,
|
|
@@ -3951,6 +4210,7 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
3951
4210
|
getViewPort,
|
|
3952
4211
|
frozenRows,
|
|
3953
4212
|
frozenColumns,
|
|
4213
|
+
frozenRowStart: rowsAboveFrozenStart + 1,
|
|
3954
4214
|
selectionTopBound,
|
|
3955
4215
|
showHeaderMenuButton,
|
|
3956
4216
|
scale,
|
|
@@ -4091,18 +4351,133 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
4091
4351
|
getEffectiveFormat,
|
|
4092
4352
|
getCellData,
|
|
4093
4353
|
]);
|
|
4354
|
+
// Excel's "For objects, show" (⌃6): "none" leaves the objects out of the object layer, so none is
|
|
4355
|
+
// drawn, clicked, tabbed to or selected; "placeholders" draws each one's frame with an empty box
|
|
4356
|
+
// in place of its content. Pictures in cells are cell content and are not affected.
|
|
4357
|
+
const objectsHidden = showObjects === "none";
|
|
4358
|
+
const objectPlaceholders = showObjects === "placeholders";
|
|
4359
|
+
// While objects are hidden no object stays selected: one selected when ⌃6 hides it, and one
|
|
4360
|
+
// selected later (a paste, insert or duplicate, an undo / redo restoring a selection) that
|
|
4361
|
+
// nobody can see and Delete could not reach. The keyboard goes back to the sheet when it was on
|
|
4362
|
+
// the object (its frame is gone, so focus fell to the page) or in the grid; focus somewhere else
|
|
4363
|
+
// (the formula bar, a dialog, a side pane) stays where it is.
|
|
4364
|
+
useEffect(() => {
|
|
4365
|
+
if (!objectsHidden)
|
|
4366
|
+
return;
|
|
4367
|
+
const deselect = () => {
|
|
4368
|
+
if (store.get(selectedChartEmbedAtom) === undefined)
|
|
4369
|
+
return;
|
|
4370
|
+
const ownerDocument = getOwnerDocument(gridContainerRef.current);
|
|
4371
|
+
const active = ownerDocument?.activeElement ?? null;
|
|
4372
|
+
const keyboardOnSheet = !active ||
|
|
4373
|
+
active === ownerDocument?.body ||
|
|
4374
|
+
(gridContainerRef.current?.contains(active) ?? false);
|
|
4375
|
+
store.set(selectedObjectGroupAtom, undefined);
|
|
4376
|
+
store.set(selectedChartEmbedAtom, undefined);
|
|
4377
|
+
if (keyboardOnSheet)
|
|
4378
|
+
focusSheet();
|
|
4379
|
+
};
|
|
4380
|
+
deselect();
|
|
4381
|
+
return store.sub(selectedChartEmbedAtom, deselect);
|
|
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]);
|
|
4094
4469
|
const { chartComponents, embedComponents, slicerComponents, contextMenuComponent: embedContextMenuComponent, onMouseDown: onMouseDownCharts, requestChartContextMenu, selectAllObjects: selectAllObjectsUnstable, } = useEmbedsCharts({
|
|
4095
4470
|
pageLayout,
|
|
4096
4471
|
getLinkedPictureSource,
|
|
4097
4472
|
getSheetName,
|
|
4098
|
-
charts,
|
|
4099
|
-
embeds,
|
|
4100
|
-
slicers,
|
|
4473
|
+
charts: objectsHidden ? EMPTY_OBJECTS : shownCharts,
|
|
4474
|
+
embeds: objectsHidden ? EMPTY_OBJECTS : shownEmbeds,
|
|
4475
|
+
slicers: objectsHidden ? EMPTY_OBJECTS : shownSlicers,
|
|
4101
4476
|
sheetId,
|
|
4102
4477
|
scale,
|
|
4103
4478
|
frozenRows,
|
|
4104
4479
|
frozenColumns,
|
|
4105
|
-
getCellOffsetFromCoords,
|
|
4480
|
+
getCellOffsetFromCoords: objectCellOffset,
|
|
4106
4481
|
getAbsolutePositionFromOffset,
|
|
4107
4482
|
getCellCoordsFromOffset,
|
|
4108
4483
|
getCellCoordsFromSheetOffset,
|
|
@@ -4132,9 +4507,9 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
4132
4507
|
pivotTables,
|
|
4133
4508
|
getFormattedValue,
|
|
4134
4509
|
locale,
|
|
4135
|
-
getChartComponent,
|
|
4136
|
-
getEmbedComponent,
|
|
4137
|
-
getSlicerComponent,
|
|
4510
|
+
getChartComponent: objectPlaceholders ? getObjectPlaceholder : getChartComponent,
|
|
4511
|
+
getEmbedComponent: objectPlaceholders ? getObjectPlaceholder : getEmbedComponent,
|
|
4512
|
+
getSlicerComponent: objectPlaceholders ? getObjectPlaceholder : getSlicerComponent,
|
|
4138
4513
|
getBounds: getChartBounds,
|
|
4139
4514
|
theme,
|
|
4140
4515
|
backgroundColor: cellBackgroundColor,
|
|
@@ -4949,6 +5324,8 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
4949
5324
|
focusSheet,
|
|
4950
5325
|
rowCount,
|
|
4951
5326
|
columnCount,
|
|
5327
|
+
rowsAboveFrozenStart,
|
|
5328
|
+
columnsAboveFrozenStart,
|
|
4952
5329
|
HiddenRowMarkers,
|
|
4953
5330
|
HiddenColumnMarkers,
|
|
4954
5331
|
});
|
|
@@ -5162,6 +5539,38 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
5162
5539
|
* row dimension changes
|
|
5163
5540
|
*/
|
|
5164
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
|
+
}
|
|
5165
5574
|
// Callback when sheet changes
|
|
5166
5575
|
useSheetChangeHandler(sheetId,
|
|
5167
5576
|
// Immediate callback for imperative methods
|
|
@@ -5299,6 +5708,12 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
5299
5708
|
/**
|
|
5300
5709
|
* Insert components inside the grid viewport
|
|
5301
5710
|
*/
|
|
5711
|
+
const clipAboveFrozenStart = useMemo(() => rowsAboveFrozenStart || columnsAboveFrozenStart
|
|
5712
|
+
? {
|
|
5713
|
+
rows: rowsAboveFrozenStart > 0,
|
|
5714
|
+
columns: columnsAboveFrozenStart > 0,
|
|
5715
|
+
}
|
|
5716
|
+
: undefined, [rowsAboveFrozenStart, columnsAboveFrozenStart]);
|
|
5302
5717
|
const baseGridChildren = useGridChildren({
|
|
5303
5718
|
stickyEditor,
|
|
5304
5719
|
editorComponent,
|
|
@@ -5325,6 +5740,10 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
5325
5740
|
// at, and the two can disagree (the independent review's finding 6).
|
|
5326
5741
|
editorPaneId: editorPaneIdRef.current,
|
|
5327
5742
|
getCellOffsetFromCoords,
|
|
5743
|
+
clipAboveFrozenStart,
|
|
5744
|
+
objectCellOffset: rowsAboveFrozenStart || columnsAboveFrozenStart
|
|
5745
|
+
? objectCellOffset
|
|
5746
|
+
: undefined,
|
|
5328
5747
|
});
|
|
5329
5748
|
const sheetNameForLayout = pageLayout ? getSheetName?.(sheetId) ?? "" : "";
|
|
5330
5749
|
const handleChangeHeaderFooter = useCallback((headerFooter) => onChangeHeaderFooter?.(sheetId, headerFooter), [onChangeHeaderFooter, sheetId]);
|
|
@@ -5416,7 +5835,7 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
5416
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" },
|
|
5417
5836
|
React.createElement("div", { className: "space-y-2" },
|
|
5418
5837
|
React.createElement(Skeleton, { className: "h-4 w-[250px]" }),
|
|
5419
|
-
React.createElement(Skeleton, { className: "h-4 w-[250px]" })))) : (React.createElement(BaseGrid, { ref: gridRef, overscanCount: overscanCount, rowCount: sheetRowCount, columnCount: sheetColumnCount, rowHeight:
|
|
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,
|
|
5420
5839
|
// Freeze Panes and Split are mutually exclusive: the grid is told the SHEET's frozen
|
|
5421
5840
|
// counts, not the heading band added above.
|
|
5422
5841
|
sheetFrozenRows: frozenRowCount ?? 0, sheetFrozenColumns: frozenColumnCount ?? 0, activeCell: activeCell, selections: formulaMode ? formulaSelections : selections, FillHandle: FillHandle, showFillHandle: showFillHandle,
|
|
@@ -5424,7 +5843,7 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
5424
5843
|
// Options, Insert Options on a lone active cell) need its copies per pane.
|
|
5425
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,
|
|
5426
5845
|
// Dimension of fill handle
|
|
5427
|
-
scrollToCellOffset: 4, scrollbarSize: scrollbarSize, isHiddenCell: isHiddenCell, isHiddenColumn:
|
|
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 })),
|
|
5428
5847
|
React.createElement(RtlMirrorLayer, { rightToLeft: rightToLeft }, tooltipComponent),
|
|
5429
5848
|
stickyEditor ? (React.createElement(RtlMirrorLayer, { rightToLeft: rightToLeft }, editorComponent)) : null,
|
|
5430
5849
|
React.createElement(RtlMirrorLayer, { rightToLeft: rightToLeft },
|