@rowsncolumns/spreadsheet 10.14.0 → 10.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/dist/cjs/api/editor-formula.d.ts +40 -0
  2. package/dist/cjs/api/editor-formula.d.ts.map +1 -0
  3. package/dist/cjs/api/editor-formula.js +87 -0
  4. package/dist/cjs/atoms/cell-input-context.atom.d.ts.map +1 -1
  5. package/dist/cjs/components/autocorrect-options-smart-tag/index.d.ts +22 -8
  6. package/dist/cjs/components/autocorrect-options-smart-tag/index.d.ts.map +1 -1
  7. package/dist/cjs/components/autocorrect-options-smart-tag/index.js +107 -22
  8. package/dist/cjs/components/canvas-grid/index.d.ts.map +1 -1
  9. package/dist/cjs/components/canvas-grid/index.js +114 -22
  10. package/dist/cjs/components/canvas-grid/typings.d.ts +8 -0
  11. package/dist/cjs/components/canvas-grid/typings.d.ts.map +1 -1
  12. package/dist/cjs/components/cell-input/cell-input.d.ts.map +1 -1
  13. package/dist/cjs/components/cell-input/cell-input.js +3 -1
  14. package/dist/cjs/components/embeds/embed-draggable.d.ts.map +1 -1
  15. package/dist/cjs/components/embeds/embed-draggable.js +42 -18
  16. package/dist/cjs/components/embeds/object-focus.d.ts +16 -3
  17. package/dist/cjs/components/embeds/object-focus.d.ts.map +1 -1
  18. package/dist/cjs/components/embeds/object-focus.js +62 -6
  19. package/dist/cjs/components/outline-gutter/index.d.ts +11 -3
  20. package/dist/cjs/components/outline-gutter/index.d.ts.map +1 -1
  21. package/dist/cjs/components/outline-gutter/index.js +11 -6
  22. package/dist/cjs/components/selection/index.d.ts +1 -1
  23. package/dist/cjs/components/selection/index.d.ts.map +1 -1
  24. package/dist/cjs/components/selection/index.js +2 -2
  25. package/dist/cjs/components/selection/types.d.ts +2 -0
  26. package/dist/cjs/components/selection/types.d.ts.map +1 -1
  27. package/dist/cjs/hooks/object-spec-schema.generated.d.ts.map +1 -1
  28. package/dist/cjs/hooks/object-spec-schema.generated.js +16 -0
  29. package/dist/cjs/hooks/use-editable.d.ts.map +1 -1
  30. package/dist/cjs/hooks/use-editable.js +5 -1
  31. package/dist/cjs/hooks/use-editor-change.d.ts.map +1 -1
  32. package/dist/cjs/hooks/use-editor-change.js +3 -1
  33. package/dist/cjs/hooks/use-embeds-charts.d.ts.map +1 -1
  34. package/dist/cjs/hooks/use-embeds-charts.js +32 -16
  35. package/dist/cjs/hooks/use-flash-fill-suggestion.d.ts.map +1 -1
  36. package/dist/cjs/hooks/use-flash-fill-suggestion.js +15 -4
  37. package/dist/cjs/hooks/use-grid-children.d.ts +7 -1
  38. package/dist/cjs/hooks/use-grid-children.d.ts.map +1 -1
  39. package/dist/cjs/hooks/use-grid-children.js +8 -2
  40. package/dist/cjs/hooks/use-header-actions.d.ts +11 -1
  41. package/dist/cjs/hooks/use-header-actions.d.ts.map +1 -1
  42. package/dist/cjs/hooks/use-header-actions.js +16 -6
  43. package/dist/cjs/hooks/use-move-columns-rows.d.ts +7 -1
  44. package/dist/cjs/hooks/use-move-columns-rows.d.ts.map +1 -1
  45. package/dist/cjs/hooks/use-move-columns-rows.js +12 -10
  46. package/dist/cjs/hooks/use-selection-renderer.d.ts.map +1 -1
  47. package/dist/cjs/hooks/use-selection-renderer.js +18 -4
  48. package/dist/cjs/release-date.js +1 -1
  49. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  50. package/dist/cjs/types.d.ts +17 -0
  51. package/dist/cjs/types.d.ts.map +1 -1
  52. package/dist/esm/api/editor-formula.d.ts +40 -0
  53. package/dist/esm/api/editor-formula.d.ts.map +1 -0
  54. package/dist/esm/api/editor-formula.js +76 -0
  55. package/dist/esm/atoms/cell-input-context.atom.d.ts.map +1 -1
  56. package/dist/esm/components/autocorrect-options-smart-tag/index.d.ts +22 -8
  57. package/dist/esm/components/autocorrect-options-smart-tag/index.d.ts.map +1 -1
  58. package/dist/esm/components/autocorrect-options-smart-tag/index.js +103 -22
  59. package/dist/esm/components/canvas-grid/index.d.ts.map +1 -1
  60. package/dist/esm/components/canvas-grid/index.js +111 -23
  61. package/dist/esm/components/canvas-grid/typings.d.ts +8 -0
  62. package/dist/esm/components/canvas-grid/typings.d.ts.map +1 -1
  63. package/dist/esm/components/cell-input/cell-input.d.ts.map +1 -1
  64. package/dist/esm/components/cell-input/cell-input.js +4 -2
  65. package/dist/esm/components/embeds/embed-draggable.d.ts.map +1 -1
  66. package/dist/esm/components/embeds/embed-draggable.js +41 -20
  67. package/dist/esm/components/embeds/object-focus.d.ts +16 -3
  68. package/dist/esm/components/embeds/object-focus.d.ts.map +1 -1
  69. package/dist/esm/components/embeds/object-focus.js +38 -2
  70. package/dist/esm/components/outline-gutter/index.d.ts +11 -3
  71. package/dist/esm/components/outline-gutter/index.d.ts.map +1 -1
  72. package/dist/esm/components/outline-gutter/index.js +11 -6
  73. package/dist/esm/components/selection/index.d.ts +1 -1
  74. package/dist/esm/components/selection/index.d.ts.map +1 -1
  75. package/dist/esm/components/selection/index.js +2 -2
  76. package/dist/esm/components/selection/types.d.ts +2 -0
  77. package/dist/esm/components/selection/types.d.ts.map +1 -1
  78. package/dist/esm/hooks/object-spec-schema.generated.d.ts.map +1 -1
  79. package/dist/esm/hooks/object-spec-schema.generated.js +16 -0
  80. package/dist/esm/hooks/use-editable.d.ts.map +1 -1
  81. package/dist/esm/hooks/use-editable.js +6 -2
  82. package/dist/esm/hooks/use-editor-change.d.ts.map +1 -1
  83. package/dist/esm/hooks/use-editor-change.js +4 -2
  84. package/dist/esm/hooks/use-embeds-charts.d.ts.map +1 -1
  85. package/dist/esm/hooks/use-embeds-charts.js +32 -16
  86. package/dist/esm/hooks/use-flash-fill-suggestion.d.ts.map +1 -1
  87. package/dist/esm/hooks/use-flash-fill-suggestion.js +15 -4
  88. package/dist/esm/hooks/use-grid-children.d.ts +7 -1
  89. package/dist/esm/hooks/use-grid-children.d.ts.map +1 -1
  90. package/dist/esm/hooks/use-grid-children.js +7 -1
  91. package/dist/esm/hooks/use-header-actions.d.ts +11 -1
  92. package/dist/esm/hooks/use-header-actions.d.ts.map +1 -1
  93. package/dist/esm/hooks/use-header-actions.js +12 -2
  94. package/dist/esm/hooks/use-move-columns-rows.d.ts +7 -1
  95. package/dist/esm/hooks/use-move-columns-rows.d.ts.map +1 -1
  96. package/dist/esm/hooks/use-move-columns-rows.js +11 -7
  97. package/dist/esm/hooks/use-selection-renderer.d.ts.map +1 -1
  98. package/dist/esm/hooks/use-selection-renderer.js +18 -4
  99. package/dist/esm/release-date.js +1 -1
  100. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  101. package/dist/esm/types.d.ts +17 -0
  102. package/dist/esm/types.d.ts.map +1 -1
  103. package/dist/spreadsheet.min.css +1 -1
  104. package/package.json +3 -3
@@ -1,18 +1,94 @@
1
1
  import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuPortal, DropdownMenuSeparator, DropdownMenuTrigger, IconButton, } from "@rowsncolumns/ui";
2
- import React, { useState } from "react";
3
- /** Excel's AutoCorrect Options lightning bolt. */
4
- const LightningIcon = () => (React.createElement("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": "true" },
5
- React.createElement("path", { d: "M13 2 4 14h6l-1 8 9-12h-6l1-8z" })));
2
+ import React, { useEffect, useRef, useState } from "react";
3
+ const placementStyle = (placement, { x, y, width, height, }) => {
4
+ const beside = placement === "outside" || placement === "above-bar";
5
+ const below = placement === "outside" || placement === "left-of-bar";
6
+ return {
7
+ left: beside ? x + width + 2 : x + width,
8
+ top: y + height,
9
+ transform: beside && below
10
+ ? undefined
11
+ : `translate(${beside ? "0" : "-100%"}, ${below ? "0" : "-100%"})`,
12
+ };
13
+ };
14
+ /** The nearest ancestor that clips its content: the pane the button is drawn in. */
15
+ const clipOf = (node) => {
16
+ const view = node.ownerDocument.defaultView;
17
+ for (let el = node.parentElement; el; el = el.parentElement) {
18
+ const overflow = view?.getComputedStyle(el).overflow ?? "";
19
+ if (overflow && overflow !== "visible")
20
+ return el;
21
+ }
22
+ return null;
23
+ };
24
+ const THRESHOLDS = Array.from({ length: 25 }, (_, i) => i / 24);
25
+ /**
26
+ * Keeps the button whole inside the pane it is drawn in: an invisible box at the button's own
27
+ * place is watched against the pane (an `IntersectionObserver`, so a pane scrolling the cell toward
28
+ * its edge is seen too), and the button is moved back inside by as much as that box sticks out —
29
+ * a cell one row above a split bar or the window's edge, where hanging below the cell would cut
30
+ * the button. Without `IntersectionObserver` (jsdom) the button stays at its place.
31
+ */
32
+ const useKeepInsidePane = (deps) => {
33
+ const sentinelRef = useRef(null);
34
+ const [shift, setShift] = useState({ x: 0, y: 0 });
35
+ useEffect(() => {
36
+ const sentinel = sentinelRef.current;
37
+ const IO = sentinel?.ownerDocument.defaultView?.IntersectionObserver;
38
+ if (!sentinel || !IO)
39
+ return;
40
+ const root = clipOf(sentinel);
41
+ if (!root)
42
+ return;
43
+ const observer = new IO((entries) => {
44
+ const entry = entries[entries.length - 1];
45
+ const box = entry.boundingClientRect;
46
+ const bounds = entry.rootBounds ?? root.getBoundingClientRect();
47
+ const x = box.right > bounds.right
48
+ ? bounds.right - box.right
49
+ : box.left < bounds.left
50
+ ? bounds.left - box.left
51
+ : 0;
52
+ const y = box.bottom > bounds.bottom
53
+ ? bounds.bottom - box.bottom
54
+ : box.top < bounds.top
55
+ ? bounds.top - box.top
56
+ : 0;
57
+ setShift((prev) => (prev.x === x && prev.y === y ? prev : { x, y }));
58
+ }, { root, threshold: THRESHOLDS });
59
+ observer.observe(sentinel);
60
+ return () => observer.disconnect();
61
+ // eslint-disable-next-line react-hooks/exhaustive-deps
62
+ }, deps);
63
+ return { sentinelRef, shift };
64
+ };
65
+ /**
66
+ * The AutoCorrect Options glyph: a letter "A" with a lightning bolt at its shoulder, and a ▾ for
67
+ * the menu the button opens — the same reading as Excel's button, drawn here from scratch. Every
68
+ * mark is a path (no font), so it reads the same at 1× on every system.
69
+ */
70
+ const AutoCorrectGlyph = () => (React.createElement("svg", { width: "20", height: "14", viewBox: "0 0 20 14", "aria-hidden": "true", "data-testid": "autocorrect-options-glyph" },
71
+ React.createElement("path", { d: "M1.2 13 5 2.2 8.8 13M2.6 9.4h4.8", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinejoin: "round" }),
72
+ React.createElement("path", { d: "M12.6 0.6 9.2 6.2h2.3l-1 4.4 4.1-6.1h-2.3l1.5-3.9z", fill: "#E8A317" }),
73
+ React.createElement("path", { d: "M15.6 7h4l-2 2.6z", fill: "currentColor" })));
6
74
  /**
7
- * Excel's AutoCorrect Options smart tag beside the cell an edit grew a table from, or typed a
8
- * table column's formula into — ONE button, carrying the entries of both when one edit did both
9
- * (a formula typed in the column right of a table): "Undo Table AutoExpansion" / "Stop
10
- * Automatically Expanding Tables", and "Undo Calculated Column" (or "Overwrite all cells in this
11
- * column with this formula") / "Stop automatically creating calculated columns". An entry the
12
- * host cannot carry out is not offered; with none left, no button.
75
+ * Excel's AutoCorrect Options smart tag, hanging from the bottom-right corner of the cell an edit
76
+ * grew a table from, or typed a table column's formula into — ONE button, carrying the entries of
77
+ * both when one edit did both (a formula typed in the column right of a table): "Undo Table
78
+ * AutoExpansion" / "Stop Automatically Expanding Tables", and "Undo Calculated Column" (or
79
+ * "Overwrite all cells in this column with this formula") / "Stop automatically creating
80
+ * calculated columns". An entry the host cannot carry out is not offered; with none left, no
81
+ * button.
13
82
  */
14
- export const AutoCorrectOptionsSmartTag = ({ x, y, width, tableAutoExpansion, onChooseTableAutoExpansionOption, calculatedColumn, onChooseCalculatedColumnOption, }) => {
83
+ export const AutoCorrectOptionsSmartTag = ({ x, y, width, height, tableAutoExpansion, onChooseTableAutoExpansionOption, calculatedColumn, onChooseCalculatedColumnOption, placement = "outside", }) => {
15
84
  const [open, setOpen] = useState(false);
85
+ const { sentinelRef, shift } = useKeepInsidePane([
86
+ placement,
87
+ x,
88
+ y,
89
+ width,
90
+ height,
91
+ ]);
16
92
  const tableEntries = tableAutoExpansion && onChooseTableAutoExpansionOption
17
93
  ? [
18
94
  ...(tableAutoExpansion.canUndo
@@ -46,7 +122,8 @@ export const AutoCorrectOptionsSmartTag = ({ x, y, width, tableAutoExpansion, on
46
122
  },
47
123
  ]
48
124
  : []),
49
- ...(calculatedColumn.kind !== "filled" && calculatedColumn.canOverwrite
125
+ ...(calculatedColumn.kind !== "filled" &&
126
+ calculatedColumn.canOverwrite
50
127
  ? [
51
128
  {
52
129
  key: "column-overwrite",
@@ -73,15 +150,19 @@ export const AutoCorrectOptionsSmartTag = ({ x, y, width, tableAutoExpansion, on
73
150
  tableEntries.length ? "table-auto-expansion" : undefined,
74
151
  columnEntries.length ? "calculated-column" : undefined,
75
152
  ].filter(Boolean);
76
- return (React.createElement("div", { className: "absolute pointer-events-auto flex items-start justify-start", style: { left: x + width + 2, top: y }, onMouseDown: (e) => e.stopPropagation(), "data-testid": "autocorrect-options", "data-autocorrect": kinds.join(" ") },
77
- React.createElement(DropdownMenu, { modal: false, open: open, onOpenChange: setOpen },
78
- React.createElement(DropdownMenuTrigger, { asChild: true },
79
- React.createElement(IconButton, { tooltip: "AutoCorrect Options", "aria-label": "AutoCorrect Options", className: "shadow-sm bg-rnc-background border-rnc-border border border-solid rounded-md" },
80
- React.createElement(LightningIcon, null))),
81
- React.createElement(DropdownMenuPortal, null,
82
- React.createElement(DropdownMenuContent, { align: "start", onCloseAutoFocus: (event) => event.preventDefault() },
83
- tableEntries.map((entry) => (React.createElement(DropdownMenuItem, { key: entry.key, onSelect: entry.onSelect }, entry.label))),
84
- tableEntries.length && columnEntries.length ? (React.createElement(DropdownMenuSeparator, null)) : null,
85
- columnEntries.map((entry) => (React.createElement(DropdownMenuItem, { key: entry.key, onSelect: entry.onSelect }, entry.label))))))));
153
+ return (React.createElement("div", { className: "absolute pointer-events-auto flex items-start justify-start", style: placementStyle(placement, { x, y, width, height }), onMouseDown: (e) => e.stopPropagation(), "data-testid": "autocorrect-options", "data-autocorrect": kinds.join(" "), "data-placement": placement },
154
+ React.createElement("div", { ref: sentinelRef, "aria-hidden": "true", className: "absolute inset-0 invisible pointer-events-none" }),
155
+ React.createElement("div", { style: shift.x || shift.y
156
+ ? { transform: `translate(${shift.x}px, ${shift.y}px)` }
157
+ : undefined },
158
+ React.createElement(DropdownMenu, { modal: false, open: open, onOpenChange: setOpen },
159
+ React.createElement(DropdownMenuTrigger, { asChild: true },
160
+ React.createElement(IconButton, { tooltip: "AutoCorrect Options", "aria-label": "AutoCorrect Options", className: "shadow-sm bg-rnc-background border-rnc-border border border-solid rounded-md" },
161
+ React.createElement(AutoCorrectGlyph, null))),
162
+ React.createElement(DropdownMenuPortal, null,
163
+ React.createElement(DropdownMenuContent, { align: "start", onCloseAutoFocus: (event) => event.preventDefault() },
164
+ tableEntries.map((entry) => (React.createElement(DropdownMenuItem, { key: entry.key, onSelect: entry.onSelect }, entry.label))),
165
+ tableEntries.length && columnEntries.length ? (React.createElement(DropdownMenuSeparator, null)) : null,
166
+ columnEntries.map((entry) => (React.createElement(DropdownMenuItem, { key: entry.key, onSelect: entry.onSelect }, entry.label)))))))));
86
167
  };
87
168
  AutoCorrectOptionsSmartTag.displayName = "AutoCorrectOptionsSmartTag";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/canvas-grid/index.tsx"],"names":[],"mappings":"AAqEA,OAAO,KASN,MAAM,OAAO,CAAC;AA4Qf,OAAO,KAAK,EAGV,QAAQ,EAYT,MAAM,aAAa,CAAC;AA4CrB,OAAO,KAAK,EACV,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EAEhB,MAAM,WAAW,CAAC;AAigPnB,eAAO,MAAM,UAAU,EAA4C,CACjE,CAAC,SAAS,QAAQ,CAAC,GAAG,CAAC,EAEvB,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,GACvB,wBAAwB,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;CAAE,KAChE,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/canvas-grid/index.tsx"],"names":[],"mappings":"AAqEA,OAAO,KASN,MAAM,OAAO,CAAC;AAiRf,OAAO,KAAK,EAGV,QAAQ,EAYT,MAAM,aAAa,CAAC;AA4CrB,OAAO,KAAK,EACV,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EAEhB,MAAM,WAAW,CAAC;AAknPnB,eAAO,MAAM,UAAU,EAA4C,CACjE,CAAC,SAAS,QAAQ,CAAC,GAAG,CAAC,EAEvB,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,GACvB,wBAAwB,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;CAAE,KAChE,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC"}
@@ -10,6 +10,7 @@ import { useAtomValue, useStore } from "jotai";
10
10
  import merge from "lodash/merge";
11
11
  import throttle from "lodash/throttle";
12
12
  import React, { forwardRef, memo, startTransition, useCallback, useEffect, useMemo, useRef, useState, } from "react";
13
+ import { flushSync } from "react-dom";
13
14
  import { getBandedCells } from "../../api/banded-ranges";
14
15
  import { splitPaneFromPixels, splitPanePixels } from "../../api/split-pane";
15
16
  import { excelEditValueOfNumber } from "../../api/excel-edit-value";
@@ -30,8 +31,8 @@ import { useActiveEditor } from "../../atoms/active-editor.atom";
30
31
  import { useFlashFillSuggestion, } from "../../hooks/use-flash-fill-suggestion";
31
32
  import { useAddWatch, useIsWatchWindowMounted, useSetWatchWindowContext, } from "../../atoms/watch-window.atom";
32
33
  import { editingCellAtom, useEditingCell } from "../../atoms/editing-cell.atom";
33
- import { selectedChartEmbedAtom } from "../../atoms/selected-chart-embed.atom";
34
- 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";
35
36
  import { useSetEnterKeyDirection } from "../../atoms/enter-key-direction.atom";
36
37
  import { useCellEditorInstance, useSetFormulabarEditorValue, useSetFormulaBarTextFormatRuns, } from "../../atoms/formula-bar-editor-value.atom";
37
38
  import { useFormulaCanSelectCells, useFormulaSelectionMode, useSetFormulaSelectionState, } from "../../atoms/formula-selection-state.atom";
@@ -158,8 +159,12 @@ function isDetachedEditor(editor) {
158
159
  const element = editor.el?.();
159
160
  return element != null && !element.isConnected;
160
161
  }
162
+ /** An empty object list, stable across renders ("For objects, show: none"). */
163
+ const EMPTY_OBJECTS = [];
164
+ /** "For objects, show: placeholders": an object's frame drawn with nothing in it. */
165
+ 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" }));
161
166
  function CanvasGridComponent(props, forwardedRef) {
162
- 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,
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,
163
168
  // Host-driven filter props. `hostHiddenRowRanges`
164
169
  // supplies compact [start, end] hidden-row tuples; `getFilterValues` supplies a
165
170
  // column's distinct values. Both let a million-row filter render without scanning
@@ -871,8 +876,10 @@ function CanvasGridComponent(props, forwardedRef) {
871
876
  // Delete removes the chart instead of clearing the active cell.
872
877
  const selectedObject = store.get(selectedChartEmbedAtom);
873
878
  if (selectedObject !== undefined && !store.get(editingCellAtom)) {
874
- const target = store.get(objectFocusTargetsAtom).get(selectedObject);
875
- if (target?.isConnected && gridContainer?.contains(target)) {
879
+ // On a split sheet the object may be drawn in several panes: the copy holding focus keeps
880
+ // it, else the first copy still drawn takes it.
881
+ const target = objectFocusTargetOf(store.get(objectFocusTargetsAtom), selectedObject, gridContainer);
882
+ if (target && gridContainer) {
876
883
  if (activeElement !== target)
877
884
  target.focus({ preventScroll: true });
878
885
  return;
@@ -938,6 +945,8 @@ function CanvasGridComponent(props, forwardedRef) {
938
945
  const getScrollPosition = useCallback(() => gridRef.current?.getScrollPosition() ?? DEFAULT_SCROLL_POSITION, []);
939
946
  /** The pane the pointer is over on a split sheet (`handleMouseMove`); `undefined` otherwise. */
940
947
  const hoveredPaneIdRef = useRef(undefined);
948
+ /** Where the pointer is on the page, from every move over the grid (not throttled). */
949
+ const pointerRef = useRef(undefined);
941
950
  /** The pane the open editor belongs to; set when the edit starts (`handleBeforeEdit`). */
942
951
  const editorPaneIdRef = useRef(undefined);
943
952
  /**
@@ -974,26 +983,56 @@ function CanvasGridComponent(props, forwardedRef) {
974
983
  // eslint-disable-next-line react-hooks/exhaustive-deps
975
984
  }, [paneScrollTick]);
976
985
  /**
977
- * What the heading resizer is placed by: the offset of the band the pointer is over, so a
978
- * heading border is grabbed where that band draws it. A sheet with no split answers exactly what
979
- * `getScrollPosition` answers.
986
+ * What a heading is drawn offset by, on a split sheet: the drawn offset of the band of headings
987
+ * that draws it — the band under the pointer when that one draws it (the pointer's position is
988
+ * read from the heading, not from the pane last hovered), else the first band that does. A
989
+ * sheet with no split answers exactly what `getScrollPosition` answers.
980
990
  */
981
- const getHeadingScrollPosition = useCallback(() => {
991
+ const getHeadingScrollPositionFor = useCallback((cell) => {
982
992
  const grid = gridRef.current;
983
993
  if (!grid)
984
994
  return DEFAULT_SCROLL_POSITION;
985
995
  if (!grid.getActivePane())
986
996
  return grid.getScrollPosition();
987
- const pane = grid
988
- .getPanes()
989
- .find((candidate) => candidate.id === hoveredPaneIdRef.current);
997
+ const panes = grid.getPanes();
998
+ const pointer = pointerRef.current;
999
+ const underPointer = pointer
1000
+ ? grid.getPaneFromOffset(pointer.clientX, pointer.clientY)
1001
+ : undefined;
1002
+ // The band under the pointer comes first: once the column bands scroll apart, one heading
1003
+ // can be drawn in both (split at D8, the window scrolled 400 px: F is at 147–247 in the
1004
+ // left band and 553–653 in the right), and only the pointer says which border is meant.
1005
+ // The fallback below takes the first band that draws it, which grabs the wrong one.
1006
+ let pane = underPointer ?? panes.find((p) => p.id === hoveredPaneIdRef.current);
1007
+ const box = cell ? grid.getCellOffsetFromCoords(cell) : undefined;
1008
+ if (cell && box) {
1009
+ const columnHeading = isColumnHeader(cell.rowIndex);
1010
+ const draws = (p) => columnHeading
1011
+ ? p.rowBand === 0 &&
1012
+ box.x - p.offsetLeft < p.rect.x + p.rect.width &&
1013
+ box.x + box.width - p.offsetLeft > p.rect.x
1014
+ : p.columnBand === 0 &&
1015
+ box.y - p.offsetTop < p.rect.y + p.rect.height &&
1016
+ box.y + box.height - p.offsetTop > p.rect.y;
1017
+ if (!pane || !draws(pane))
1018
+ pane = panes.find(draws) ?? pane;
1019
+ }
990
1020
  if (!pane)
991
1021
  return grid.getScrollPosition();
992
1022
  return { scrollLeft: pane.offsetLeft, scrollTop: pane.offsetTop };
993
- // The tick and the hovered cell are the dependencies on purpose: a pane scrolling, or the
994
- // pointer moving to another heading or band, must place the resizer again.
995
- // eslint-disable-next-line react-hooks/exhaustive-deps
996
- }, [paneScrollTick, hoveredCell]);
1023
+ }, [isColumnHeader]);
1024
+ /**
1025
+ * What the heading resizer is placed by: the band that draws the hovered heading. The tick and
1026
+ * the hovered cell are the dependencies on purpose: a pane scrolling, or the pointer moving to
1027
+ * another heading or band, must place the resizer again.
1028
+ */
1029
+ const getHeadingScrollPosition = useCallback(() => getHeadingScrollPositionFor(hoveredCell),
1030
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1031
+ [getHeadingScrollPositionFor, paneScrollTick, hoveredCell]);
1032
+ /** The same for the move handle over selected columns or rows (`useMoveColumnsAndRows`). */
1033
+ const getMoveHandleScrollPosition = useCallback((cell) => getHeadingScrollPositionFor(cell),
1034
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1035
+ [getHeadingScrollPositionFor, paneScrollTick]);
997
1036
  // Does the column contains a table
998
1037
  const columnContainsTable = useCallback((columnIndex) => {
999
1038
  const [_, tableColumnHeaderIds] = tableHeaderCells;
@@ -3893,6 +3932,7 @@ function CanvasGridComponent(props, forwardedRef) {
3893
3932
  containerWidth: width - scrollbarSize,
3894
3933
  containerHeight: height - scrollbarSize,
3895
3934
  getScrollPosition,
3935
+ getHeadingScrollPosition: getMoveHandleScrollPosition,
3896
3936
  onChangeSelections,
3897
3937
  onChangeActiveCell,
3898
3938
  activeCell,
@@ -3908,6 +3948,7 @@ function CanvasGridComponent(props, forwardedRef) {
3908
3948
  const { headerMenuComponent, isHeaderMenuInFrozenColumn, headerResizer, isDragging: isDraggingHeader, } = useHeaderActions({
3909
3949
  activeCell: isSelectionInProgress || isFilling || isDragging ? null : hoveredCell,
3910
3950
  getScrollPosition: getHeadingScrollPosition,
3951
+ getWindowScrollPosition: getScrollPosition,
3911
3952
  getCellOffsetFromCoords,
3912
3953
  getRelativePositionFromOffset,
3913
3954
  showContextMenu,
@@ -4056,13 +4097,42 @@ function CanvasGridComponent(props, forwardedRef) {
4056
4097
  getEffectiveFormat,
4057
4098
  getCellData,
4058
4099
  ]);
4100
+ // Excel's "For objects, show" (⌃6): "none" leaves the objects out of the object layer, so none is
4101
+ // drawn, clicked, tabbed to or selected; "placeholders" draws each one's frame with an empty box
4102
+ // in place of its content. Pictures in cells are cell content and are not affected.
4103
+ const objectsHidden = showObjects === "none";
4104
+ const objectPlaceholders = showObjects === "placeholders";
4105
+ // While objects are hidden no object stays selected: one selected when ⌃6 hides it, and one
4106
+ // selected later (a paste, insert or duplicate, an undo / redo restoring a selection) that
4107
+ // nobody can see and Delete could not reach. The keyboard goes back to the sheet when it was on
4108
+ // the object (its frame is gone, so focus fell to the page) or in the grid; focus somewhere else
4109
+ // (the formula bar, a dialog, a side pane) stays where it is.
4110
+ useEffect(() => {
4111
+ if (!objectsHidden)
4112
+ return;
4113
+ const deselect = () => {
4114
+ if (store.get(selectedChartEmbedAtom) === undefined)
4115
+ return;
4116
+ const ownerDocument = getOwnerDocument(gridContainerRef.current);
4117
+ const active = ownerDocument?.activeElement ?? null;
4118
+ const keyboardOnSheet = !active ||
4119
+ active === ownerDocument?.body ||
4120
+ (gridContainerRef.current?.contains(active) ?? false);
4121
+ store.set(selectedObjectGroupAtom, undefined);
4122
+ store.set(selectedChartEmbedAtom, undefined);
4123
+ if (keyboardOnSheet)
4124
+ focusSheet();
4125
+ };
4126
+ deselect();
4127
+ return store.sub(selectedChartEmbedAtom, deselect);
4128
+ }, [objectsHidden, store, focusSheet, gridContainerRef]);
4059
4129
  const { chartComponents, embedComponents, slicerComponents, contextMenuComponent: embedContextMenuComponent, onMouseDown: onMouseDownCharts, requestChartContextMenu, selectAllObjects: selectAllObjectsUnstable, } = useEmbedsCharts({
4060
4130
  pageLayout,
4061
4131
  getLinkedPictureSource,
4062
4132
  getSheetName,
4063
- charts,
4064
- embeds,
4065
- slicers,
4133
+ charts: objectsHidden ? EMPTY_OBJECTS : charts,
4134
+ embeds: objectsHidden ? EMPTY_OBJECTS : embeds,
4135
+ slicers: objectsHidden ? EMPTY_OBJECTS : slicers,
4066
4136
  sheetId,
4067
4137
  scale,
4068
4138
  frozenRows,
@@ -4097,9 +4167,9 @@ function CanvasGridComponent(props, forwardedRef) {
4097
4167
  pivotTables,
4098
4168
  getFormattedValue,
4099
4169
  locale,
4100
- getChartComponent,
4101
- getEmbedComponent,
4102
- getSlicerComponent,
4170
+ getChartComponent: objectPlaceholders ? getObjectPlaceholder : getChartComponent,
4171
+ getEmbedComponent: objectPlaceholders ? getObjectPlaceholder : getEmbedComponent,
4172
+ getSlicerComponent: objectPlaceholders ? getObjectPlaceholder : getSlicerComponent,
4103
4173
  getBounds: getChartBounds,
4104
4174
  theme,
4105
4175
  backgroundColor: cellBackgroundColor,
@@ -4262,10 +4332,28 @@ function CanvasGridComponent(props, forwardedRef) {
4262
4332
  clearTableHitZone,
4263
4333
  ]);
4264
4334
  // Mouse move throttler
4265
- const mouseMoveThrottler = useCallbackRef(throttle(handleMouseMove, mouseMoveThrottleTimeout, {
4335
+ const throttledMouseMove = useCallbackRef(throttle(handleMouseMove, mouseMoveThrottleTimeout, {
4266
4336
  trailing: true,
4267
4337
  leading: true,
4268
4338
  }));
4339
+ /**
4340
+ * Every move is recorded; over the headings it is handled at once, not throttled, on every
4341
+ * sheet: the resize zone of a heading border must be where the pointer is now, not where it was
4342
+ * up to a throttle interval ago, or a press right after the pointer arrives on the heading (from
4343
+ * the body, or from another pane) grabs nothing and selects instead.
4344
+ */
4345
+ const mouseMoveThrottler = useCallbackRef((e) => {
4346
+ pointerRef.current = { clientX: e.clientX, clientY: e.clientY };
4347
+ const coords = getCellCoordsFromOffset(e.clientX, e.clientY);
4348
+ if (coords &&
4349
+ (isColumnHeader(coords.rowIndex) || isRowHeader(coords.columnIndex))) {
4350
+ // Committed before this event returns, so the resize zone is in place before the press
4351
+ // that may follow at once (a move's update is otherwise rendered a frame later).
4352
+ flushSync(() => handleMouseMove(e));
4353
+ return;
4354
+ }
4355
+ throttledMouseMove(e);
4356
+ });
4269
4357
  /**
4270
4358
  * Pointer type of the last press on the grid. A browser that reports touch
4271
4359
  * support (`isTouchDevice`) can still be driven by a mouse, trackpad or pen
@@ -434,6 +434,14 @@ export type CanvasGridProps<T extends CellData = CellData<any, any>> = {
434
434
  * this sheet; the value itself is untouched.
435
435
  */
436
436
  showZeros?: Maybe<boolean>;
437
+ /**
438
+ * The workbook's "For objects, show" (Excel ⌃6, `<workbookPr showObjects>`; the engine's
439
+ * `documentFacets().showObjects`): `"none"` hides charts, pictures, shapes, text boxes, form
440
+ * controls and slicers (they cannot be clicked, tabbed to or selected); `"placeholders"` draws
441
+ * each as an empty frame of its size, which can still be selected and moved; absent or `"all"`
442
+ * draws everything. Pictures placed IN a cell are cell content and always draw.
443
+ */
444
+ showObjects?: Maybe<"all" | "placeholders" | "none">;
437
445
  /**
438
446
  * View ▸ Split: the sheet's stored split window (`<pane state="split">`). The body is drawn as
439
447
  * panes that scroll on their own, and moving or removing the bar is reported through