@rowsncolumns/spreadsheet 10.10.5 → 10.13.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 (190) hide show
  1. package/dist/cjs/api/split-pane.d.ts +10 -0
  2. package/dist/cjs/api/split-pane.d.ts.map +1 -1
  3. package/dist/cjs/api/split-pane.js +29 -1
  4. package/dist/cjs/atoms/calculated-column-fill.atom.d.ts +6 -2
  5. package/dist/cjs/atoms/calculated-column-fill.atom.d.ts.map +1 -1
  6. package/dist/cjs/atoms/calculated-column-fill.atom.js +6 -2
  7. package/dist/cjs/atoms/cell-input-context.atom.d.ts.map +1 -1
  8. package/dist/cjs/atoms/fill-options.atom.d.ts +5 -0
  9. package/dist/cjs/atoms/fill-options.atom.d.ts.map +1 -1
  10. package/dist/cjs/atoms/table-auto-expansion.atom.d.ts +5 -2
  11. package/dist/cjs/atoms/table-auto-expansion.atom.d.ts.map +1 -1
  12. package/dist/cjs/atoms/table-auto-expansion.atom.js +5 -2
  13. package/dist/cjs/components/autocorrect-options-smart-tag/index.d.ts +37 -0
  14. package/dist/cjs/components/autocorrect-options-smart-tag/index.d.ts.map +1 -0
  15. package/dist/cjs/components/autocorrect-options-smart-tag/index.js +84 -0
  16. package/dist/cjs/components/canvas-grid/index.d.ts.map +1 -1
  17. package/dist/cjs/components/canvas-grid/index.js +327 -115
  18. package/dist/cjs/components/canvas-grid/typings.d.ts +33 -1
  19. package/dist/cjs/components/canvas-grid/typings.d.ts.map +1 -1
  20. package/dist/cjs/components/embeds/chart-component.d.ts +9 -0
  21. package/dist/cjs/components/embeds/chart-component.d.ts.map +1 -1
  22. package/dist/cjs/components/embeds/embed-component.d.ts +9 -0
  23. package/dist/cjs/components/embeds/embed-component.d.ts.map +1 -1
  24. package/dist/cjs/components/embeds/embed-component.js +13 -114
  25. package/dist/cjs/components/embeds/embed-draggable.d.ts +17 -2
  26. package/dist/cjs/components/embeds/embed-draggable.d.ts.map +1 -1
  27. package/dist/cjs/components/embeds/embed-draggable.js +323 -25
  28. package/dist/cjs/components/embeds/object-focus.d.ts +32 -0
  29. package/dist/cjs/components/embeds/object-focus.d.ts.map +1 -0
  30. package/dist/cjs/components/embeds/object-focus.js +140 -0
  31. package/dist/cjs/components/embeds/page-gaps.d.ts +67 -0
  32. package/dist/cjs/components/embeds/page-gaps.d.ts.map +1 -0
  33. package/dist/cjs/components/embeds/page-gaps.js +159 -0
  34. package/dist/cjs/components/embeds/slicer-component.d.ts +9 -0
  35. package/dist/cjs/components/embeds/slicer-component.d.ts.map +1 -1
  36. package/dist/cjs/components/embeds/text-box-view.d.ts +18 -0
  37. package/dist/cjs/components/embeds/text-box-view.d.ts.map +1 -0
  38. package/dist/cjs/components/embeds/text-box-view.js +130 -0
  39. package/dist/cjs/components/filter-box/filter-by-color.d.ts.map +1 -1
  40. package/dist/cjs/components/filter-box/filter-by-color.js +10 -3
  41. package/dist/cjs/components/filter-box/index.d.ts.map +1 -1
  42. package/dist/cjs/components/filter-box/index.js +5 -1
  43. package/dist/cjs/components/print-preview/page-block.d.ts +46 -0
  44. package/dist/cjs/components/print-preview/page-block.d.ts.map +1 -1
  45. package/dist/cjs/components/print-preview/page-block.js +111 -6
  46. package/dist/cjs/components/print-preview/print-cells.d.ts +5 -0
  47. package/dist/cjs/components/print-preview/print-cells.d.ts.map +1 -1
  48. package/dist/cjs/components/print-preview/print-cells.js +1 -0
  49. package/dist/cjs/components/print-preview/print-preview-dialog.d.ts +16 -2
  50. package/dist/cjs/components/print-preview/print-preview-dialog.d.ts.map +1 -1
  51. package/dist/cjs/components/print-preview/print-preview-dialog.js +246 -14
  52. package/dist/cjs/components/print-preview/settings.d.ts +8 -0
  53. package/dist/cjs/components/print-preview/settings.d.ts.map +1 -1
  54. package/dist/cjs/components/print-preview/settings.js +4 -1
  55. package/dist/cjs/components/print-preview/sheet-page-setup.d.ts.map +1 -1
  56. package/dist/cjs/components/print-preview/sheet-page-setup.js +14 -2
  57. package/dist/cjs/components/selection/fill-options-menu.d.ts +8 -1
  58. package/dist/cjs/components/selection/fill-options-menu.d.ts.map +1 -1
  59. package/dist/cjs/components/selection/fill-options-menu.js +5 -3
  60. package/dist/cjs/components/selection/index.d.ts +1 -1
  61. package/dist/cjs/components/selection/index.d.ts.map +1 -1
  62. package/dist/cjs/components/selection/index.js +5 -6
  63. package/dist/cjs/components/selection/types.d.ts +13 -8
  64. package/dist/cjs/components/selection/types.d.ts.map +1 -1
  65. package/dist/cjs/components/sheet-background/index.d.ts +26 -0
  66. package/dist/cjs/components/sheet-background/index.d.ts.map +1 -0
  67. package/dist/cjs/components/sheet-background/index.js +106 -0
  68. package/dist/cjs/components/sort-range-dialog/index.d.ts.map +1 -1
  69. package/dist/cjs/components/sort-range-dialog/index.js +6 -3
  70. package/dist/cjs/hooks/object-clipboard-payload.d.ts +58 -0
  71. package/dist/cjs/hooks/object-clipboard-payload.d.ts.map +1 -0
  72. package/dist/cjs/hooks/object-clipboard-payload.js +488 -0
  73. package/dist/cjs/hooks/object-spec-schema.generated.d.ts +24 -0
  74. package/dist/cjs/hooks/object-spec-schema.generated.d.ts.map +1 -0
  75. package/dist/cjs/hooks/object-spec-schema.generated.js +4767 -0
  76. package/dist/cjs/hooks/use-chart-clipboard.d.ts +55 -9
  77. package/dist/cjs/hooks/use-chart-clipboard.d.ts.map +1 -1
  78. package/dist/cjs/hooks/use-chart-clipboard.js +307 -55
  79. package/dist/cjs/hooks/use-embeds-charts.d.ts +7 -1
  80. package/dist/cjs/hooks/use-embeds-charts.d.ts.map +1 -1
  81. package/dist/cjs/hooks/use-embeds-charts.js +74 -14
  82. package/dist/cjs/hooks/use-grid-children.d.ts +8 -2
  83. package/dist/cjs/hooks/use-grid-children.d.ts.map +1 -1
  84. package/dist/cjs/hooks/use-grid-children.js +71 -4
  85. package/dist/cjs/hooks/use-selection-renderer.d.ts +16 -5
  86. package/dist/cjs/hooks/use-selection-renderer.d.ts.map +1 -1
  87. package/dist/cjs/hooks/use-selection-renderer.js +59 -32
  88. package/dist/cjs/index.d.ts +2 -0
  89. package/dist/cjs/index.d.ts.map +1 -1
  90. package/dist/cjs/index.js +1 -0
  91. package/dist/cjs/release-date.js +1 -1
  92. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  93. package/dist/cjs/types.d.ts +58 -0
  94. package/dist/cjs/types.d.ts.map +1 -1
  95. package/dist/esm/api/split-pane.d.ts +10 -0
  96. package/dist/esm/api/split-pane.d.ts.map +1 -1
  97. package/dist/esm/api/split-pane.js +25 -0
  98. package/dist/esm/atoms/calculated-column-fill.atom.d.ts +6 -2
  99. package/dist/esm/atoms/calculated-column-fill.atom.d.ts.map +1 -1
  100. package/dist/esm/atoms/calculated-column-fill.atom.js +6 -2
  101. package/dist/esm/atoms/cell-input-context.atom.d.ts.map +1 -1
  102. package/dist/esm/atoms/fill-options.atom.d.ts +5 -0
  103. package/dist/esm/atoms/fill-options.atom.d.ts.map +1 -1
  104. package/dist/esm/atoms/table-auto-expansion.atom.d.ts +5 -2
  105. package/dist/esm/atoms/table-auto-expansion.atom.d.ts.map +1 -1
  106. package/dist/esm/atoms/table-auto-expansion.atom.js +5 -2
  107. package/dist/esm/components/autocorrect-options-smart-tag/index.d.ts +37 -0
  108. package/dist/esm/components/autocorrect-options-smart-tag/index.d.ts.map +1 -0
  109. package/dist/esm/components/autocorrect-options-smart-tag/index.js +87 -0
  110. package/dist/esm/components/canvas-grid/index.d.ts.map +1 -1
  111. package/dist/esm/components/canvas-grid/index.js +248 -52
  112. package/dist/esm/components/canvas-grid/typings.d.ts +33 -1
  113. package/dist/esm/components/canvas-grid/typings.d.ts.map +1 -1
  114. package/dist/esm/components/embeds/chart-component.d.ts +9 -0
  115. package/dist/esm/components/embeds/chart-component.d.ts.map +1 -1
  116. package/dist/esm/components/embeds/embed-component.d.ts +9 -0
  117. package/dist/esm/components/embeds/embed-component.d.ts.map +1 -1
  118. package/dist/esm/components/embeds/embed-component.js +12 -113
  119. package/dist/esm/components/embeds/embed-draggable.d.ts +17 -2
  120. package/dist/esm/components/embeds/embed-draggable.d.ts.map +1 -1
  121. package/dist/esm/components/embeds/embed-draggable.js +314 -19
  122. package/dist/esm/components/embeds/object-focus.d.ts +32 -0
  123. package/dist/esm/components/embeds/object-focus.d.ts.map +1 -0
  124. package/dist/esm/components/embeds/object-focus.js +118 -0
  125. package/dist/esm/components/embeds/page-gaps.d.ts +67 -0
  126. package/dist/esm/components/embeds/page-gaps.d.ts.map +1 -0
  127. package/dist/esm/components/embeds/page-gaps.js +86 -0
  128. package/dist/esm/components/embeds/slicer-component.d.ts +9 -0
  129. package/dist/esm/components/embeds/slicer-component.d.ts.map +1 -1
  130. package/dist/esm/components/embeds/text-box-view.d.ts +18 -0
  131. package/dist/esm/components/embeds/text-box-view.d.ts.map +1 -0
  132. package/dist/esm/components/embeds/text-box-view.js +118 -0
  133. package/dist/esm/components/filter-box/filter-by-color.d.ts.map +1 -1
  134. package/dist/esm/components/filter-box/filter-by-color.js +9 -2
  135. package/dist/esm/components/filter-box/index.d.ts.map +1 -1
  136. package/dist/esm/components/filter-box/index.js +5 -1
  137. package/dist/esm/components/print-preview/page-block.d.ts +46 -0
  138. package/dist/esm/components/print-preview/page-block.d.ts.map +1 -1
  139. package/dist/esm/components/print-preview/page-block.js +122 -4
  140. package/dist/esm/components/print-preview/print-cells.d.ts +5 -0
  141. package/dist/esm/components/print-preview/print-cells.d.ts.map +1 -1
  142. package/dist/esm/components/print-preview/print-cells.js +1 -0
  143. package/dist/esm/components/print-preview/print-preview-dialog.d.ts +16 -2
  144. package/dist/esm/components/print-preview/print-preview-dialog.d.ts.map +1 -1
  145. package/dist/esm/components/print-preview/print-preview-dialog.js +195 -4
  146. package/dist/esm/components/print-preview/settings.d.ts +8 -0
  147. package/dist/esm/components/print-preview/settings.d.ts.map +1 -1
  148. package/dist/esm/components/print-preview/settings.js +4 -1
  149. package/dist/esm/components/print-preview/sheet-page-setup.d.ts.map +1 -1
  150. package/dist/esm/components/print-preview/sheet-page-setup.js +14 -0
  151. package/dist/esm/components/selection/fill-options-menu.d.ts +8 -1
  152. package/dist/esm/components/selection/fill-options-menu.d.ts.map +1 -1
  153. package/dist/esm/components/selection/fill-options-menu.js +5 -3
  154. package/dist/esm/components/selection/index.d.ts +1 -1
  155. package/dist/esm/components/selection/index.d.ts.map +1 -1
  156. package/dist/esm/components/selection/index.js +5 -6
  157. package/dist/esm/components/selection/types.d.ts +13 -8
  158. package/dist/esm/components/selection/types.d.ts.map +1 -1
  159. package/dist/esm/components/sheet-background/index.d.ts +26 -0
  160. package/dist/esm/components/sheet-background/index.d.ts.map +1 -0
  161. package/dist/esm/components/sheet-background/index.js +93 -0
  162. package/dist/esm/components/sort-range-dialog/index.d.ts.map +1 -1
  163. package/dist/esm/components/sort-range-dialog/index.js +5 -2
  164. package/dist/esm/hooks/object-clipboard-payload.d.ts +58 -0
  165. package/dist/esm/hooks/object-clipboard-payload.d.ts.map +1 -0
  166. package/dist/esm/hooks/object-clipboard-payload.js +404 -0
  167. package/dist/esm/hooks/object-spec-schema.generated.d.ts +24 -0
  168. package/dist/esm/hooks/object-spec-schema.generated.d.ts.map +1 -0
  169. package/dist/esm/hooks/object-spec-schema.generated.js +4764 -0
  170. package/dist/esm/hooks/use-chart-clipboard.d.ts +55 -9
  171. package/dist/esm/hooks/use-chart-clipboard.d.ts.map +1 -1
  172. package/dist/esm/hooks/use-chart-clipboard.js +298 -53
  173. package/dist/esm/hooks/use-embeds-charts.d.ts +7 -1
  174. package/dist/esm/hooks/use-embeds-charts.d.ts.map +1 -1
  175. package/dist/esm/hooks/use-embeds-charts.js +72 -14
  176. package/dist/esm/hooks/use-grid-children.d.ts +8 -2
  177. package/dist/esm/hooks/use-grid-children.d.ts.map +1 -1
  178. package/dist/esm/hooks/use-grid-children.js +71 -4
  179. package/dist/esm/hooks/use-selection-renderer.d.ts +16 -5
  180. package/dist/esm/hooks/use-selection-renderer.d.ts.map +1 -1
  181. package/dist/esm/hooks/use-selection-renderer.js +54 -28
  182. package/dist/esm/index.d.ts +2 -0
  183. package/dist/esm/index.d.ts.map +1 -1
  184. package/dist/esm/index.js +1 -0
  185. package/dist/esm/release-date.js +1 -1
  186. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  187. package/dist/esm/types.d.ts +58 -0
  188. package/dist/esm/types.d.ts.map +1 -1
  189. package/dist/spreadsheet.min.css +1 -1
  190. package/package.json +4 -4
@@ -9,6 +9,7 @@ import { DEFAULT_OVERLAY_POSITION } from "../config";
9
9
  import { canCopyImageToClipboard, copyPngToClipboard, } from "../utils/copy-as-picture";
10
10
  import { pivotChartFieldButtonsVisible, togglePivotChartFieldButtons, } from "../utils/pivot-chart-field-buttons";
11
11
  import { getStackingRanks, planGroupZOrderChange, stackingKey, } from "../utils/z-order";
12
+ import { resolvePageGaps, toGapFree, toScreen, } from "../components/embeds/page-gaps";
12
13
  import { DefaultContextMenuWrapper, } from "./use-context-menu";
13
14
  /**
14
15
  * The cell an object's top-left corner actually sits in: its anchor cell
@@ -85,7 +86,23 @@ const validateEmbeds = (embedsOrCharts, sheetId) => {
85
86
  return obj;
86
87
  });
87
88
  };
88
- export const useEmbedsCharts = ({ scale = 1, charts, embeds, slicers, sheetId, frozenRows = 0, frozenColumns = 0, getCellOffsetFromCoords, getCellCoordsFromOffset, getAbsolutePositionFromOffset, getRelativePositionFromOffset, ContextMenuWrapper = DefaultContextMenuWrapper, focusSheet, getBounds, selectedColor = "#1a73e8", onMoveChart, onResizeChart, chartClipboard, onMoveEmbed, onResizeEmbed, onDeleteChart, onUpdateChart, onChangeZOrder, onDeleteEmbed, onRequestEditEmbed, onMoveSlicer, onResizeSlicer, onDeleteSlicer, onDeleteObjects, onRequestEditSlicer, onFilterTable, onFilterPivot, tables, pivotTables, getFormattedValue, getLinkedPictureSource, getSheetName, getChartComponent = defaultGetChartComponent, getEmbedComponent = defaultGetEmbedComponent, getSlicerComponent = defaultGetSlicerComponent, readonly, locale, theme, backgroundColor, disabled, }) => {
89
+ export const useEmbedsCharts = ({ scale = 1, charts, embeds, slicers, sheetId, frozenRows = 0, frozenColumns = 0, getCellOffsetFromCoords, getCellCoordsFromOffset, getAbsolutePositionFromOffset, getRelativePositionFromOffset, ContextMenuWrapper = DefaultContextMenuWrapper, focusSheet, getBounds, selectedColor = "#1a73e8", onMoveChart, onResizeChart, chartClipboard, onMoveEmbed, onResizeEmbed, onDeleteChart, onUpdateChart, onChangeZOrder, onDeleteEmbed, onRequestEditEmbed, onMoveSlicer, onResizeSlicer, onDeleteSlicer, onDeleteObjects, onRequestEditSlicer, onFilterTable, onFilterPivot, tables, pivotTables, getFormattedValue, getLinkedPictureSource, getSheetName, getChartComponent = defaultGetChartComponent, getEmbedComponent = defaultGetEmbedComponent, getSlicerComponent = defaultGetSlicerComponent, readonly, locale, theme, backgroundColor, disabled, pageLayout, }) => {
90
+ /**
91
+ * Page Layout view: the row and column each page starts at and the gap before it (grid pixels),
92
+ * for `EmbedDraggable`'s `pageGaps`; resolved into grid coordinates where they are used.
93
+ */
94
+ const pageGaps = useMemo(() => {
95
+ if (!pageLayout)
96
+ return undefined;
97
+ const axis = (bands, gapBefore) => bands.flatMap((band) => {
98
+ const gap = gapBefore(band.start) * scale;
99
+ return gap > 0 ? [{ index: band.start, gap }] : [];
100
+ });
101
+ return {
102
+ columns: axis(pageLayout.columnBands, pageLayout.getColumnGap),
103
+ rows: axis(pageLayout.rowBands, pageLayout.getRowGap),
104
+ };
105
+ }, [pageLayout, scale]);
89
106
  const [selectedIndex, setSelectedIndex] = useSelectedChartEmbed();
90
107
  // Excel's multi-object selection (Shift/Ctrl-click, Select All Objects): every selected object.
91
108
  const selectedObjectIds = useSelectedObjectIds();
@@ -305,6 +322,16 @@ export const useEmbedsCharts = ({ scale = 1, charts, embeds, slicers, sheetId, f
305
322
  if (onRequestEditEmbed && !readonly) {
306
323
  actions.onRequestEdit = () => onRequestEditEmbed(embed);
307
324
  }
325
+ // Cut / Copy / Paste on a picture, shape or text box, as on a chart.
326
+ if (chartClipboard) {
327
+ if (!readonly && onDeleteEmbed) {
328
+ actions.onCut = () => chartClipboard.cutEmbed(id);
329
+ }
330
+ actions.onCopy = () => chartClipboard.copyEmbed(id);
331
+ if (chartClipboard.hasChartOnClipboard()) {
332
+ actions.onPaste = () => chartClipboard.pasteChart();
333
+ }
334
+ }
308
335
  Object.assign(actions, getArrangeActions({ kind: "embed", id }));
309
336
  if (onDeleteEmbed && !readonly) {
310
337
  actions.onDelete = () => onDeleteEmbed(id);
@@ -382,19 +409,27 @@ export const useEmbedsCharts = ({ scale = 1, charts, embeds, slicers, sheetId, f
382
409
  handleContextMenuCloseAutoFocus,
383
410
  ]);
384
411
  const getCellPositionAt = useCallback((x, y) => {
385
- const position = getAbsolutePositionFromOffset(x, y);
412
+ // A point on the sheet's far edge (an object's corner flush with the last column's right
413
+ // edge or the last row's bottom) names the last column / row, as a point past the edge
414
+ // does (`getCellPosition` pulls it to the edge's last pixel), never the column or row after
415
+ // it: that is stored data (`anchorCell` / `toCell`), and a cell past the sheet does not exist.
416
+ const bounds = getBounds();
417
+ const lookupX = bounds.right !== undefined && x >= bounds.right ? bounds.right - 1 : x;
418
+ const lookupY = bounds.bottom !== undefined && y >= bounds.bottom ? bounds.bottom - 1 : y;
419
+ const position = getAbsolutePositionFromOffset(lookupX, lookupY);
386
420
  // Use includeFrozen=true to detect cells in all regions
387
421
  const anchorCell = getCellCoordsFromOffset(position?.x ?? 0, position?.y ?? 0, true);
388
422
  const cellPosition = anchorCell
389
423
  ? getCellOffsetFromCoords(anchorCell)
390
424
  : undefined;
391
425
  if (anchorCell && cellPosition) {
392
- return [anchorCell, x - cellPosition.x, y - cellPosition.y];
426
+ return [anchorCell, lookupX - cellPosition.x, lookupY - cellPosition.y];
393
427
  }
394
428
  }, [
395
429
  getCellOffsetFromCoords,
396
430
  getCellCoordsFromOffset,
397
431
  getAbsolutePositionFromOffset,
432
+ getBounds,
398
433
  ]);
399
434
  /**
400
435
  * Anchor cell + pixel offsets for a point in grid pixel space. A point past
@@ -433,17 +468,27 @@ export const useEmbedsCharts = ({ scale = 1, charts, embeds, slicers, sheetId, f
433
468
  * space) as its second anchor — Excel rewrites `to` on every move and
434
469
  * resize. `moveOnly` / `absolute` objects keep a pixel size instead.
435
470
  */
436
- const getToAnchor = useCallback((overlay, right, bottom) => {
471
+ const getToAnchor = useCallback((overlay, x, y, width, height) => {
437
472
  if (!isMoveAndSizePlacement(overlay)) {
438
473
  return undefined;
439
474
  }
475
+ // In Page Layout view the far corner lies past the gaps the object crosses.
476
+ const gaps = pageGaps
477
+ ? resolvePageGaps(pageGaps, getCellOffsetFromCoords)
478
+ : undefined;
479
+ const right = gaps
480
+ ? toScreen(gaps.x, toGapFree(gaps.x, x) + width)
481
+ : x + width;
482
+ const bottom = gaps
483
+ ? toScreen(gaps.y, toGapFree(gaps.y, y) + height)
484
+ : y + height;
440
485
  const position = getCellPosition(right, bottom);
441
486
  if (!position) {
442
487
  return undefined;
443
488
  }
444
489
  const [toCell, toOffsetXPixels, toOffsetYPixels] = position;
445
490
  return { toCell, toOffsetXPixels, toOffsetYPixels };
446
- }, [getCellPosition]);
491
+ }, [getCellPosition, pageGaps, getCellOffsetFromCoords]);
447
492
  const getChartOverlay = useCallback((id) => charts?.find((chart) => chart.chartId === id)?.position
448
493
  ?.overlayPosition, [charts]);
449
494
  const getEmbedOverlay = useCallback((id) => embeds?.find((embed) => embed.embedId === id)?.position
@@ -457,7 +502,7 @@ export const useEmbedsCharts = ({ scale = 1, charts, embeds, slicers, sheetId, f
457
502
  return;
458
503
  }
459
504
  const [anchorCell, offsetXPixels, offsetYPixels] = position;
460
- onMoveChart?.(id, anchorCell, offsetXPixels, offsetYPixels, getToAnchor(getChartOverlay(id), x + width, y + height));
505
+ onMoveChart?.(id, anchorCell, offsetXPixels, offsetYPixels, getToAnchor(getChartOverlay(id), x, y, width, height));
461
506
  }, [onMoveChart, getCellPosition, getToAnchor, getChartOverlay]);
462
507
  // Callback when resizes an embed
463
508
  const handleEmbedResize = useCallback((id, x, y, width, height) => {
@@ -466,7 +511,7 @@ export const useEmbedsCharts = ({ scale = 1, charts, embeds, slicers, sheetId, f
466
511
  return;
467
512
  }
468
513
  const [anchorCell, offsetXPixels, offsetYPixels] = position;
469
- onResizeEmbed?.(id, sheetId, anchorCell, offsetXPixels, offsetYPixels, width, height, getToAnchor(getEmbedOverlay(id), x + width * scale, y + height * scale));
514
+ onResizeEmbed?.(id, sheetId, anchorCell, offsetXPixels, offsetYPixels, width, height, getToAnchor(getEmbedOverlay(id), x, y, width * scale, height * scale));
470
515
  }, [onResizeEmbed, sheetId, scale, getCellPosition, getToAnchor, getEmbedOverlay]);
471
516
  // Callback when user moves a chart
472
517
  const handleEmbedMove = useCallback((id, x, y, width, height) => {
@@ -475,7 +520,7 @@ export const useEmbedsCharts = ({ scale = 1, charts, embeds, slicers, sheetId, f
475
520
  return;
476
521
  }
477
522
  const [anchorCell, offsetXPixels, offsetYPixels] = position;
478
- onMoveEmbed?.(id, sheetId, anchorCell, offsetXPixels, offsetYPixels, getToAnchor(getEmbedOverlay(id), x + width, y + height));
523
+ onMoveEmbed?.(id, sheetId, anchorCell, offsetXPixels, offsetYPixels, getToAnchor(getEmbedOverlay(id), x, y, width, height));
479
524
  }, [onMoveEmbed, sheetId, getCellPosition, getToAnchor, getEmbedOverlay]);
480
525
  // Callback when resizes a chart
481
526
  const handleResize = useCallback((id, x, y, width, height) => {
@@ -484,7 +529,7 @@ export const useEmbedsCharts = ({ scale = 1, charts, embeds, slicers, sheetId, f
484
529
  return;
485
530
  }
486
531
  const [anchorCell, offsetXPixels, offsetYPixels] = position;
487
- onResizeChart?.(id, anchorCell, offsetXPixels, offsetYPixels, width, height, getToAnchor(getChartOverlay(id), x + width * scale, y + height * scale));
532
+ onResizeChart?.(id, anchorCell, offsetXPixels, offsetYPixels, width, height, getToAnchor(getChartOverlay(id), x, y, width * scale, height * scale));
488
533
  }, [onResizeChart, scale, getCellPosition, getToAnchor, getChartOverlay]);
489
534
  // Callback when user resizes a slicer
490
535
  const handleSlicerResize = useCallback((id, x, y, width, height) => {
@@ -493,7 +538,7 @@ export const useEmbedsCharts = ({ scale = 1, charts, embeds, slicers, sheetId, f
493
538
  return;
494
539
  }
495
540
  const [anchorCell, offsetXPixels, offsetYPixels] = position;
496
- onResizeSlicer?.(id, sheetId, anchorCell, offsetXPixels, offsetYPixels, width, height, getToAnchor(getSlicerOverlay(id), x + width * scale, y + height * scale));
541
+ onResizeSlicer?.(id, sheetId, anchorCell, offsetXPixels, offsetYPixels, width, height, getToAnchor(getSlicerOverlay(id), x, y, width * scale, height * scale));
497
542
  }, [onResizeSlicer, sheetId, scale, getCellPosition, getToAnchor, getSlicerOverlay]);
498
543
  // Callback when user moves a slicer
499
544
  const handleSlicerMove = useCallback((id, x, y, width, height) => {
@@ -502,7 +547,7 @@ export const useEmbedsCharts = ({ scale = 1, charts, embeds, slicers, sheetId, f
502
547
  return;
503
548
  }
504
549
  const [anchorCell, offsetXPixels, offsetYPixels] = position;
505
- onMoveSlicer?.(id, sheetId, anchorCell, offsetXPixels, offsetYPixels, getToAnchor(getSlicerOverlay(id), x + width, y + height));
550
+ onMoveSlicer?.(id, sheetId, anchorCell, offsetXPixels, offsetYPixels, getToAnchor(getSlicerOverlay(id), x, y, width, height));
506
551
  }, [onMoveSlicer, sheetId, getCellPosition, getToAnchor, getSlicerOverlay]);
507
552
  // The frozen-pane layer an object renders in: the cell its top-left corner
508
553
  // actually sits in (anchor walked forward by the pixel offsets) against the
@@ -544,10 +589,11 @@ export const useEmbedsCharts = ({ scale = 1, charts, embeds, slicers, sheetId, f
544
589
  ? (id, e) => chartClipboard.cutChart(id, e.nativeEvent)
545
590
  : undefined, onPaste: chartClipboard
546
591
  ? (_id, e) => chartClipboard.pasteChart(e.nativeEvent)
547
- : undefined, onDeselect: handleDeselect, onRequestContextMenu: handleChartContextMenu, snapToGrid: snapToCellGrid, draggable: readonly ? false : draggable ?? undefined, resizable: readonly ? false : resizable ?? undefined }, (width, height) => getChartComponent?.({
592
+ : undefined, onDeselect: handleDeselect, onRequestContextMenu: handleChartContextMenu, snapToGrid: snapToCellGrid, draggable: readonly ? false : draggable ?? undefined, resizable: readonly ? false : resizable ?? undefined, pageGaps: pageGaps }, (width, height, pageLayoutPiece) => getChartComponent?.({
548
593
  chart,
549
594
  width,
550
595
  height,
596
+ pageLayoutPiece,
551
597
  theme,
552
598
  backgroundColor,
553
599
  isSelected,
@@ -566,6 +612,7 @@ export const useEmbedsCharts = ({ scale = 1, charts, embeds, slicers, sheetId, f
566
612
  return result;
567
613
  }, [
568
614
  disabled,
615
+ pageGaps,
569
616
  readonly,
570
617
  scale,
571
618
  charts,
@@ -632,10 +679,17 @@ export const useEmbedsCharts = ({ scale = 1, charts, embeds, slicers, sheetId, f
632
679
  const bounds = getBounds();
633
680
  const isSelected = isObjectSelected(embedId);
634
681
  const finalBorderColor = isSelected ? selectedColor : borderColor;
635
- result[placementOf(overlayPosition)].push(React.createElement(EmbedDraggable, { key: embedId, anchorCell: anchorCell, id: embedId, isSelected: isSelected, zIndex: zIndex, borderColor: finalBorderColor ?? undefined, onPointerDown: (e) => pressObject(embedId, e, setSelectedIndex), onSelectAllObjects: selectAllObjects, height: (heightPixels ?? 0) * scale, width: (widthPixels ?? 0) * scale, offsetXPixels: offsetXPixels ?? 0, offsetYPixels: offsetYPixels ?? 0, ...getOverlayToAnchorProps(overlayPosition), onResize: handleEmbedResize, onMove: handleEmbedMove, bounds: bounds, scale: scale, onDelete: deleteFromKeyboard("embed", onDeleteEmbed), onDeselect: handleDeselect, onRequestContextMenu: handleEmbedContextMenu, snapToGrid: snapToCellGrid, lockAspectRatio: lockAspectRatio ?? undefined, resizable: readonly ? false : resizable ?? undefined, draggable: readonly ? false : draggable ?? undefined }, (width, height) => getEmbedComponent?.({
682
+ result[placementOf(overlayPosition)].push(React.createElement(EmbedDraggable, { key: embedId, anchorCell: anchorCell, id: embedId, isSelected: isSelected, zIndex: zIndex, borderColor: finalBorderColor ?? undefined, onPointerDown: (e) => pressObject(embedId, e, setSelectedIndex), onSelectAllObjects: selectAllObjects, height: (heightPixels ?? 0) * scale, width: (widthPixels ?? 0) * scale, offsetXPixels: offsetXPixels ?? 0, offsetYPixels: offsetYPixels ?? 0, ...getOverlayToAnchorProps(overlayPosition), onResize: handleEmbedResize, onMove: handleEmbedMove, bounds: bounds, scale: scale, onDelete: deleteFromKeyboard("embed", onDeleteEmbed), onDuplicate: chartClipboard?.duplicateEmbed, onCopy: chartClipboard
683
+ ? (id, e) => chartClipboard.copyEmbed(id, e.nativeEvent)
684
+ : undefined, onCut: chartClipboard
685
+ ? (id, e) => chartClipboard.cutEmbed(id, e.nativeEvent)
686
+ : undefined, onPaste: chartClipboard
687
+ ? (_id, e) => chartClipboard.pasteChart(e.nativeEvent)
688
+ : undefined, onDeselect: handleDeselect, onRequestContextMenu: handleEmbedContextMenu, snapToGrid: snapToCellGrid, lockAspectRatio: lockAspectRatio ?? undefined, resizable: readonly ? false : resizable ?? undefined, draggable: readonly ? false : draggable ?? undefined, pageGaps: pageGaps }, (width, height, pageLayoutPiece) => getEmbedComponent?.({
636
689
  embed,
637
690
  width,
638
691
  height,
692
+ pageLayoutPiece,
639
693
  theme,
640
694
  backgroundColor,
641
695
  isSelected,
@@ -649,6 +703,7 @@ export const useEmbedsCharts = ({ scale = 1, charts, embeds, slicers, sheetId, f
649
703
  return result;
650
704
  }, [
651
705
  disabled,
706
+ pageGaps,
652
707
  scale,
653
708
  embeds,
654
709
  sheetId,
@@ -672,6 +727,7 @@ export const useEmbedsCharts = ({ scale = 1, charts, embeds, slicers, sheetId, f
672
727
  backgroundColor,
673
728
  placementOf,
674
729
  stackingRankOf,
730
+ chartClipboard,
675
731
  getLinkedPictureSource,
676
732
  ]);
677
733
  // Slicer components — always above charts and embeds, as before z-order;
@@ -697,10 +753,11 @@ export const useEmbedsCharts = ({ scale = 1, charts, embeds, slicers, sheetId, f
697
753
  const finalBorderColor = isSelected ? selectedColor : borderColor;
698
754
  result[placementOf(overlayPosition)].push(React.createElement(EmbedDraggable, { key: slicerId, anchorCell: anchorCell, id: slicerId, isSelected: isSelected, zIndex: stackingRanks.size + 1, borderColor: typeof finalBorderColor === "string"
699
755
  ? finalBorderColor
700
- : undefined, onPointerDown: (e) => pressObject(slicerId, e, setSelectedIndex), onSelectAllObjects: selectAllObjects, height: (heightPixels ?? 0) * scale, width: (widthPixels ?? 0) * scale, offsetXPixels: offsetXPixels ?? 0, offsetYPixels: offsetYPixels ?? 0, ...getOverlayToAnchorProps(overlayPosition), onResize: handleSlicerResize, onMove: handleSlicerMove, bounds: bounds, scale: scale, onDelete: deleteFromKeyboard("slicer", onDeleteSlicer), onDeselect: handleDeselect, snapToGrid: snapToCellGrid, resizable: readonly ? false : resizable ?? undefined, draggable: readonly ? false : draggable ?? undefined }, (width, height) => getSlicerComponent?.({
756
+ : undefined, onPointerDown: (e) => pressObject(slicerId, e, setSelectedIndex), onSelectAllObjects: selectAllObjects, height: (heightPixels ?? 0) * scale, width: (widthPixels ?? 0) * scale, offsetXPixels: offsetXPixels ?? 0, offsetYPixels: offsetYPixels ?? 0, ...getOverlayToAnchorProps(overlayPosition), onResize: handleSlicerResize, onMove: handleSlicerMove, bounds: bounds, scale: scale, onDelete: deleteFromKeyboard("slicer", onDeleteSlicer), onDeselect: handleDeselect, snapToGrid: snapToCellGrid, resizable: readonly ? false : resizable ?? undefined, draggable: readonly ? false : draggable ?? undefined, pageGaps: pageGaps }, (width, height, pageLayoutPiece) => getSlicerComponent?.({
701
757
  slicer,
702
758
  width,
703
759
  height,
760
+ pageLayoutPiece,
704
761
  theme,
705
762
  backgroundColor,
706
763
  isSelected,
@@ -717,6 +774,7 @@ export const useEmbedsCharts = ({ scale = 1, charts, embeds, slicers, sheetId, f
717
774
  return result;
718
775
  }, [
719
776
  disabled,
777
+ pageGaps,
720
778
  scale,
721
779
  slicers,
722
780
  sheetId,
@@ -1,4 +1,4 @@
1
- import type { GridChildrenProps } from "@rowsncolumns/grid";
1
+ import type { GridChildrenProps, GridPane } from "@rowsncolumns/grid";
2
2
  import React from "react";
3
3
  import type { CanvasGridProps } from "../components/canvas-grid/typings";
4
4
  import type { SheetCoordinate, SheetRange } from "../types";
@@ -23,12 +23,18 @@ type UseGridChildrenProps = {
23
23
  cellExpandComponent: React.JSX.Element | null | undefined;
24
24
  /** Trace precedents / dependents arrows; they scroll with the body. */
25
25
  arrowComponents?: CanvasGridProps["arrowComponents"];
26
+ /**
27
+ * Excel's View ▸ Split: the pane the open editor belongs to — recorded when the edit started,
28
+ * and the same one the editor is positioned by. The pane last pointed at is used only when
29
+ * nothing is being edited.
30
+ */
31
+ editorPaneId?: GridPane["id"];
26
32
  popoverRange?: SheetRange | SheetCoordinate;
27
33
  gridLineWidth?: number;
28
34
  frozenColumns: number;
29
35
  frozenRows: number;
30
36
  };
31
- export declare const useGridChildren: ({ stickyEditor, editorComponent, shownNoteComponents, chartComponents, embedComponents, slicerComponents, pivotPlaceholders, tableResizers, hiddenColumnMarkers, frozenHiddenColumnMarkers, hiddenRowMarkers, frozenHiddenRowMarkers, gridLineWidth, frozenColumns, frozenRows, headerMenuComponent, isHeaderMenuInFrozenColumn, popoverRange, popoverComponent, cellExpandComponent, arrowComponents, }: UseGridChildrenProps) => (props: GridChildrenProps) => React.JSX.Element;
37
+ export declare const useGridChildren: ({ stickyEditor, editorComponent, shownNoteComponents, chartComponents, embedComponents, slicerComponents, pivotPlaceholders, tableResizers, hiddenColumnMarkers, frozenHiddenColumnMarkers, hiddenRowMarkers, frozenHiddenRowMarkers, gridLineWidth, frozenColumns, frozenRows, headerMenuComponent, isHeaderMenuInFrozenColumn, popoverRange, popoverComponent, cellExpandComponent, arrowComponents, editorPaneId, }: UseGridChildrenProps) => (props: GridChildrenProps) => React.JSX.Element;
32
38
  export declare const StyledGridChildren: ({ className, elevate, ...props }: React.HTMLAttributes<HTMLDivElement> & {
33
39
  elevate?: boolean;
34
40
  }) => React.JSX.Element;
@@ -1 +1 @@
1
-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AAG,IAAI,GAAG,SAAS,CAAC;IAC1D,uEAAuE;IACvE,eAAe,CAAC,EAAE,eAAe,CAAC,iBAAiB,CAAC,CAAC;IACrD;;;;OAIG;IACH,YAAY,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC9B,YAAY,CAAC,EAAE,UAAU,GAAG,eAAe,CAAC;IAC5C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,wZAuB7B,oBAAoB,aAiBX,iBAAiB,sBA6O5B,CAAC;AA+BF,eAAO,MAAM,kBAAkB,GAAI,kCAIhC,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,sBAS9D,CAAC"}
@@ -2,7 +2,9 @@ import { cn } from "@rowsncolumns/ui";
2
2
  import React, { useCallback } from "react";
3
3
  import { useEditingCellCoordinate } from "../atoms";
4
4
  import { isSheetRange } from "../helpers";
5
- export const useGridChildren = ({ stickyEditor, editorComponent, shownNoteComponents, chartComponents, embedComponents, slicerComponents, pivotPlaceholders, tableResizers, hiddenColumnMarkers, frozenHiddenColumnMarkers, hiddenRowMarkers, frozenHiddenRowMarkers, gridLineWidth = 1, frozenColumns, frozenRows, headerMenuComponent, isHeaderMenuInFrozenColumn, popoverRange, popoverComponent, cellExpandComponent, arrowComponents, }) => {
5
+ /** Shared, so a sheet with no split hands the same empty list to every render. */
6
+ const EMPTY_PANES = [];
7
+ export const useGridChildren = ({ stickyEditor, editorComponent, shownNoteComponents, chartComponents, embedComponents, slicerComponents, pivotPlaceholders, tableResizers, hiddenColumnMarkers, frozenHiddenColumnMarkers, hiddenRowMarkers, frozenHiddenRowMarkers, gridLineWidth = 1, frozenColumns, frozenRows, headerMenuComponent, isHeaderMenuInFrozenColumn, popoverRange, popoverComponent, cellExpandComponent, arrowComponents, editorPaneId, }) => {
6
8
  const editingCellCoordinate = useEditingCellCoordinate();
7
9
  // Quite a bit of logic for non sticky editor
8
10
  // Remove if majority dont use this
@@ -10,7 +12,30 @@ export const useGridChildren = ({ stickyEditor, editorComponent, shownNoteCompon
10
12
  // Popover placement
11
13
  const popoverPlacement = getCellPlacement(popoverRange, frozenRows, frozenColumns);
12
14
  return useCallback((props) => {
13
- const { frozenRowHeight, frozenColumnWidth, scrollLeft, scrollTop } = props;
15
+ const { frozenRowHeight, frozenColumnWidth, scrollLeft, scrollTop, panes = EMPTY_PANES, activePaneId, } = props;
16
+ /**
17
+ * Excel's View ▸ Split: the body is drawn as panes that scroll on their own, so what lies
18
+ * over it is drawn per pane too. A sheet with no split has no panes and takes the single
19
+ * block below, unchanged.
20
+ */
21
+ const isSplit = panes.length > 1;
22
+ /**
23
+ * Two notions, deliberately apart. The EDITOR belongs to the pane the edit started in and
24
+ * stays there while that pane scrolls. Everything else that exists once — the comment /
25
+ * note / validation popover, the cell-expand box — belongs to the pane last pointed at, so
26
+ * a popover opened after an edit in another pane is drawn where it was opened.
27
+ */
28
+ const editorOwningPaneId = panes.find((pane) => pane.id === (editorPaneId ?? activePaneId))?.id ??
29
+ panes[0]?.id;
30
+ const overlayOwningPaneId = panes.find((pane) => pane.id === activePaneId)?.id ?? panes[0]?.id;
31
+ /** The bottom of the leading pane: what the frozen column strip is cut off at. */
32
+ const leadingBottom = panes[0]
33
+ ? panes[0].rect.y + panes[0].rect.height
34
+ : undefined;
35
+ /** The right edge of the leading column band: where the frozen row strip is cut off. */
36
+ const leadingRight = panes.length > 1 && panes[0] && panes.some((pane) => pane.columnBand === 1)
37
+ ? panes[0].rect.x + panes[0].rect.width
38
+ : undefined;
14
39
  return (React.createElement(React.Fragment, null,
15
40
  React.createElement(StyledGridChildren, { elevate: true, style: {
16
41
  top: 0,
@@ -26,7 +51,42 @@ export const useGridChildren = ({ stickyEditor, editorComponent, shownNoteCompon
26
51
  : `translate(-${scrollLeft + frozenColumnWidth}px, 0)`,
27
52
  pointerEvents: "all",
28
53
  } }, headerMenuComponent)),
29
- React.createElement(StyledGridChildren, { style: {
54
+ isSplit ? (panes.map((pane, index) => {
55
+ // An object anchored to a cell (a chart, a picture, a note, a slicer, a trace
56
+ // arrow) is ONE piece of DOM with its own drag state: drawing it in both panes
57
+ // would duplicate it, so it is drawn in the leading pane and clipped there. It is
58
+ // never drawn at a wrong position — a pane it does not belong to simply does not
59
+ // show it. The editor and the popover exist once too, and belong to the pane being
60
+ // worked in.
61
+ const isLeading = index === 0;
62
+ const isEditorPane = pane.id === editorOwningPaneId;
63
+ const isOverlayPane = pane.id === overlayOwningPaneId;
64
+ return (React.createElement(StyledGridChildren, { key: `pane-children-${pane.id}`, style: {
65
+ top: pane.rect.y + gridLineWidth,
66
+ left: pane.rect.x + gridLineWidth,
67
+ width: pane.rect.width,
68
+ height: pane.rect.height,
69
+ } },
70
+ React.createElement("div", { style: {
71
+ transform: `translate(-${pane.scrollLeft + pane.rect.x}px, -${pane.scrollTop + pane.rect.y}px)`,
72
+ } },
73
+ isLeading ? tableResizers : null,
74
+ !stickyEditor &&
75
+ stickyEditorPlacement === "body" &&
76
+ isEditorPane
77
+ ? editorComponent
78
+ : null,
79
+ isLeading ? chartComponents.body : null,
80
+ isLeading ? shownNoteComponents?.body : null,
81
+ isLeading ? embedComponents?.body : null,
82
+ isLeading ? slicerComponents?.body : null,
83
+ isLeading ? pivotPlaceholders : null,
84
+ popoverPlacement === "body" && isOverlayPane
85
+ ? popoverComponent
86
+ : null,
87
+ isOverlayPane ? cellExpandComponent : null,
88
+ isLeading ? arrowComponents : null)));
89
+ })) : (React.createElement(StyledGridChildren, { style: {
30
90
  top: frozenRowHeight + gridLineWidth,
31
91
  left: frozenColumnWidth + gridLineWidth,
32
92
  } },
@@ -44,9 +104,12 @@ export const useGridChildren = ({ stickyEditor, editorComponent, shownNoteCompon
44
104
  pivotPlaceholders,
45
105
  popoverPlacement === "body" ? popoverComponent : null,
46
106
  cellExpandComponent,
47
- arrowComponents)),
107
+ arrowComponents))),
48
108
  React.createElement(StyledGridChildren, { style: {
49
109
  left: frozenColumnWidth + gridLineWidth,
110
+ width: leadingRight === undefined
111
+ ? undefined
112
+ : leadingRight - frozenColumnWidth - gridLineWidth,
50
113
  } },
51
114
  React.createElement("div", {
52
115
  // className="relative z-[1]"
@@ -64,6 +127,9 @@ export const useGridChildren = ({ stickyEditor, editorComponent, shownNoteCompon
64
127
  popoverPlacement === "row" ? popoverComponent : null)),
65
128
  React.createElement(StyledGridChildren, { style: {
66
129
  top: frozenRowHeight + gridLineWidth,
130
+ height: leadingBottom === undefined
131
+ ? undefined
132
+ : leadingBottom - frozenRowHeight - gridLineWidth,
67
133
  } },
68
134
  React.createElement("div", {
69
135
  // className="relative z-[1]"/
@@ -111,6 +177,7 @@ export const useGridChildren = ({ stickyEditor, editorComponent, shownNoteCompon
111
177
  popoverPlacement,
112
178
  cellExpandComponent,
113
179
  arrowComponents,
180
+ editorPaneId,
114
181
  ]);
115
182
  };
116
183
  /**
@@ -5,12 +5,17 @@ import type { FillOptionsRequest } from "../atoms/fill-options.atom";
5
5
  import type { InsertOptionsRequest } from "../atoms/insert-options.atom";
6
6
  import { type FlashFillOptionsRequest } from "../atoms/flash-fill-options.atom";
7
7
  import type { FlashFillOption } from "../components/flash-fill-options-smart-tag";
8
- import { type CalculatedColumnFill, type CalculatedColumnOption } from "../api/calculated-column-fill";
9
- import { type TableAutoExpansion, type TableAutoExpansionOption } from "../api/table-auto-expansion";
8
+ import type { CalculatedColumnFill, CalculatedColumnOption } from "../api/calculated-column-fill";
9
+ import type { TableAutoExpansion, TableAutoExpansionOption } from "../api/table-auto-expansion";
10
10
  import type { CanvasGridProps, SelectionAttributes } from "../components/canvas-grid/typings";
11
11
  import type { SelectionNewProps } from "../components/selection/types";
12
12
  import type { AutoFillType, SheetRange } from "../types";
13
13
  import type { useFlash } from "./use-flash";
14
+ /**
15
+ * The border style `CanvasGrid` puts on the cell a pending AutoCorrect Options tag belongs to
16
+ * (its `metadata.autoCorrect` lists which: `"table"`, `"calculated"`).
17
+ */
18
+ export declare const AUTOCORRECT_ANCHOR_TYPE = "autocorrect-anchor";
14
19
  export type UseSelectionRendererProps = {
15
20
  selectionCount: number;
16
21
  fillHandleSize?: number;
@@ -54,22 +59,28 @@ export type UseSelectionRendererProps = {
54
59
  onChooseFillType?(fillType: AutoFillType): void;
55
60
  onOpenFillSeriesDialog?(): void;
56
61
  onCloseFillOptions?(): void;
62
+ onFillOptionsOpenChange?(open: boolean): void;
57
63
  /**
58
64
  * Pending Insert Options smart tag (rendered once, on the first selection
59
65
  * that overlaps the inserted band — or the lone active cell).
60
66
  */
61
67
  insertOptions?: InsertOptionsRequest | null;
62
68
  onChooseInsertOption?(option: InsertFormatOption): void;
63
- /** Pending AutoCorrect smart tag (rendered on the active cell while it stays near the grown table). */
69
+ /** Pending AutoCorrect smart tag after a table grew (drawn beside its `anchor` cell). */
64
70
  tableAutoExpansion?: TableAutoExpansion | null;
65
71
  canStopAutoExpandingTables?: boolean;
72
+ /** The host passed `onUndoTableAutoExpansion`: "Undo Table AutoExpansion" can be offered. */
73
+ canUndoTableAutoExpansion?: boolean;
66
74
  onChooseTableAutoExpansionOption?(option: TableAutoExpansionOption): void;
67
75
  /** Pending Flash Fill Options smart tag (rendered on the active cell the fill ran from). */
68
76
  flashFillOptions?: FlashFillOptionsRequest | null;
69
77
  onChooseFlashFillOption?(option: FlashFillOption): void;
70
- /** Pending calculated-column smart tag (rendered on the active cell while it stays in the column). */
78
+ /** Pending calculated-column smart tag (drawn beside its `anchor` cell, merged with the table one). */
71
79
  calculatedColumnFill?: CalculatedColumnFill | null;
72
80
  canStopAutoCalculatedColumns?: boolean;
81
+ /** The host passed `onUndoCalculatedColumn` / `onOverwriteCalculatedColumn`. */
82
+ canUndoCalculatedColumn?: boolean;
83
+ canOverwriteCalculatedColumn?: boolean;
73
84
  onChooseCalculatedColumnOption?(option: CalculatedColumnOption): void;
74
85
  /** The active cell's error-checking flag, when it carries the green ◤ (smart tag beside it). */
75
86
  errorCheck?: SelectionNewProps["errorCheck"];
@@ -91,5 +102,5 @@ export type UseSelectionRendererProps = {
91
102
  */
92
103
  isFillShrink?: boolean;
93
104
  };
94
- export declare const useSelectionRenderer: ({ sheetId, selectionCount, selectionBackgroundColor, selectionBorderColor, selectionStrokeWidth, showActiveCellBorderInSelection, onSelectionMouseDown, onChangeActiveCell, onChangeSelections, onRequestEditTable, onRequestEditPivotTable, onMouseDownResizeHandle, onMouseDownChartSourceResizeHandle, onMouseDownMoveSelection, isDraggingMoveSelection, onFlashEnd, getSheetName, resizeHandleSize, showSelectionResizeHandles, resizeHandleBorderColor, SelectionTitleComponent, isResizingTable, fillHandleSize, showFillHandle, enableMagicFill, MagicFillComponent, MagicFillContent, readonly, showPasteMenu, fillOptions, onChooseFillType, onOpenFillSeriesDialog, onCloseFillOptions, insertOptions, onChooseInsertOption, tableAutoExpansion, canStopAutoExpandingTables, onChooseTableAutoExpansionOption, flashFillOptions, onChooseFlashFillOption, calculatedColumnFill, canStopAutoCalculatedColumns, onChooseCalculatedColumnOption, errorCheck, errorCheckMenuOpen, onErrorCheckMenuOpenChange, enableCellDragAndDrop, onChooseErrorCheckOption, hoveredCell, onSplitTextToColumns, onChoosePasteOption, onRemoveQuickEdit, onAddQuickEdit, QuickEdit, PasteMenu, SuggestionAction, cachedHoveredSelectionIds, isFillShrink, }: UseSelectionRendererProps) => (props: SelectionProps<SelectionAttributes>) => React.JSX.Element | null;
105
+ export declare const useSelectionRenderer: ({ sheetId, selectionCount, selectionBackgroundColor, selectionBorderColor, selectionStrokeWidth, showActiveCellBorderInSelection, onSelectionMouseDown, onChangeActiveCell, onChangeSelections, onRequestEditTable, onRequestEditPivotTable, onMouseDownResizeHandle, onMouseDownChartSourceResizeHandle, onMouseDownMoveSelection, isDraggingMoveSelection, onFlashEnd, getSheetName, resizeHandleSize, showSelectionResizeHandles, resizeHandleBorderColor, SelectionTitleComponent, isResizingTable, fillHandleSize, showFillHandle, enableMagicFill, MagicFillComponent, MagicFillContent, readonly, showPasteMenu, fillOptions, onChooseFillType, onOpenFillSeriesDialog, onCloseFillOptions, onFillOptionsOpenChange, insertOptions, onChooseInsertOption, tableAutoExpansion, canStopAutoExpandingTables, canUndoTableAutoExpansion, onChooseTableAutoExpansionOption, flashFillOptions, onChooseFlashFillOption, calculatedColumnFill, canStopAutoCalculatedColumns, canUndoCalculatedColumn, canOverwriteCalculatedColumn, onChooseCalculatedColumnOption, errorCheck, errorCheckMenuOpen, onErrorCheckMenuOpenChange, enableCellDragAndDrop, onChooseErrorCheckOption, hoveredCell, onSplitTextToColumns, onChoosePasteOption, onRemoveQuickEdit, onAddQuickEdit, QuickEdit, PasteMenu, SuggestionAction, cachedHoveredSelectionIds, isFillShrink, }: UseSelectionRendererProps) => (props: SelectionProps<SelectionAttributes>) => React.JSX.Element | null;
95
106
  //# sourceMappingURL=use-selection-renderer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-selection-renderer.d.ts","sourceRoot":"","sources":["../../../hooks/use-selection-renderer.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAKlB,KAAK,aAAa,EAClB,KAAK,cAAc,EACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAA8B,MAAM,OAAO,CAAC;AAGnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAShE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAErE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAEL,KAAK,uBAAuB,EAE7B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC;AAClF,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAE5B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAEL,KAAK,kBAA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I,CAAC;IACnD,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,gFAAgF;IAChF,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,8BAA8B,CAAC,CAAC,MAAM,EAAE,sBAAsB,GAAG,IAAI,CAAC;IACtE,gGAAgG;IAChG,UAAU,CAAC,EAAE,iBAAiB,CAAC,YAAY,CAAC,CAAC;IAC7C,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,0BAA0B,CAAC,EAAE,iBAAiB,CAAC,4BAA4B,CAAC,CAAC;IAC7E,wGAAwG;IACxG,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,wBAAwB,CAAC,EAAE,iBAAiB,CAAC,0BAA0B,CAAC,CAAC;IACzE,oBAAoB,EAAE,eAAe,CAAC,sBAAsB,CAAC,CAAC;IAC9D,gEAAgE;IAChE,mBAAmB,CAAC,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;IAC/D,WAAW,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IACnC,iBAAiB,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;IAC3C,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;IACxC,yBAAyB,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IAChD;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAyBF,eAAO,MAAM,oBAAoB,GAAI,gyCA+DlC,yBAAyB,aAOhB,cAAc,CAAC,mBAAmB,CAAC,6BAoW9C,CAAC"}
@@ -5,10 +5,13 @@ import { getSelectionFill, getSelectionFillOpacity, getSelectionStroke, getSelec
5
5
  import { useFormulaSelectionIndex } from "../atoms";
6
6
  import { useFormulaModeValue } from "../atoms/formula-mode.atom";
7
7
  import { countRangeCells, keepsFlashFillOptionsTag, } from "../atoms/flash-fill-options.atom";
8
- import { keepsCalculatedColumnTag, } from "../api/calculated-column-fill";
9
- import { keepsTableAutoExpansionTag, } from "../api/table-auto-expansion";
10
8
  import { DEFAULT_ACTIVE_CELL } from "../config";
11
9
  import { Selection } from "./../components/selection";
10
+ /**
11
+ * The border style `CanvasGrid` puts on the cell a pending AutoCorrect Options tag belongs to
12
+ * (its `metadata.autoCorrect` lists which: `"table"`, `"calculated"`).
13
+ */
14
+ export const AUTOCORRECT_ANCHOR_TYPE = "autocorrect-anchor";
12
15
  /** Excel greys the cells a fill-handle drag-back is about to clear. */
13
16
  const FILL_SHRINK_COLOR = "#808080";
14
17
  const FILL_SHRINK_OPACITY = 0.25;
@@ -29,7 +32,7 @@ const anchorsInsertOptions = (insertOptions, range, type, index, isEmptySelectio
29
32
  : range.startColumnIndex <= bandEnd &&
30
33
  range.endColumnIndex >= insertOptions.start;
31
34
  };
32
- export const useSelectionRenderer = ({ sheetId, selectionCount, selectionBackgroundColor, selectionBorderColor, selectionStrokeWidth, showActiveCellBorderInSelection, onSelectionMouseDown, onChangeActiveCell, onChangeSelections, onRequestEditTable, onRequestEditPivotTable, onMouseDownResizeHandle, onMouseDownChartSourceResizeHandle, onMouseDownMoveSelection, isDraggingMoveSelection, onFlashEnd, getSheetName, resizeHandleSize = 6, showSelectionResizeHandles, resizeHandleBorderColor, SelectionTitleComponent, isResizingTable, fillHandleSize, showFillHandle, enableMagicFill, MagicFillComponent, MagicFillContent, readonly, showPasteMenu, fillOptions, onChooseFillType, onOpenFillSeriesDialog, onCloseFillOptions, insertOptions, onChooseInsertOption, tableAutoExpansion, canStopAutoExpandingTables = false, onChooseTableAutoExpansionOption, flashFillOptions, onChooseFlashFillOption, calculatedColumnFill, canStopAutoCalculatedColumns = false, onChooseCalculatedColumnOption, errorCheck, errorCheckMenuOpen = false, onErrorCheckMenuOpenChange, enableCellDragAndDrop = true, onChooseErrorCheckOption, hoveredCell, onSplitTextToColumns, onChoosePasteOption, onRemoveQuickEdit, onAddQuickEdit, QuickEdit, PasteMenu, SuggestionAction, cachedHoveredSelectionIds, isFillShrink = false, }) => {
35
+ export const useSelectionRenderer = ({ sheetId, selectionCount, selectionBackgroundColor, selectionBorderColor, selectionStrokeWidth, showActiveCellBorderInSelection, onSelectionMouseDown, onChangeActiveCell, onChangeSelections, onRequestEditTable, onRequestEditPivotTable, onMouseDownResizeHandle, onMouseDownChartSourceResizeHandle, onMouseDownMoveSelection, isDraggingMoveSelection, onFlashEnd, getSheetName, resizeHandleSize = 6, showSelectionResizeHandles, resizeHandleBorderColor, SelectionTitleComponent, isResizingTable, fillHandleSize, showFillHandle, enableMagicFill, MagicFillComponent, MagicFillContent, readonly, showPasteMenu, fillOptions, onChooseFillType, onOpenFillSeriesDialog, onCloseFillOptions, onFillOptionsOpenChange, insertOptions, onChooseInsertOption, tableAutoExpansion, canStopAutoExpandingTables = false, canUndoTableAutoExpansion = false, onChooseTableAutoExpansionOption, flashFillOptions, onChooseFlashFillOption, calculatedColumnFill, canStopAutoCalculatedColumns = false, canUndoCalculatedColumn = false, canOverwriteCalculatedColumn = false, onChooseCalculatedColumnOption, errorCheck, errorCheckMenuOpen = false, onErrorCheckMenuOpenChange, enableCellDragAndDrop = true, onChooseErrorCheckOption, hoveredCell, onSplitTextToColumns, onChoosePasteOption, onRemoveQuickEdit, onAddQuickEdit, QuickEdit, PasteMenu, SuggestionAction, cachedHoveredSelectionIds, isFillShrink = false, }) => {
33
36
  const formulaMode = useFormulaModeValue();
34
37
  const selectionIndex = useFormulaSelectionIndex();
35
38
  const hoveredCellRef = useRef(hoveredCell);
@@ -37,6 +40,27 @@ export const useSelectionRenderer = ({ sheetId, selectionCount, selectionBackgro
37
40
  hoveredCellRef.current = hoveredCell;
38
41
  return useCallback((props) => {
39
42
  const { activeCell, selection, index, range, type, inProgress, draggable = true, duration, } = props;
43
+ // The grid draws a range selection with `selection` and no `range`, and
44
+ // the active cell with `activeCell`; only border styles carry `range`.
45
+ const selectionRange = range ?? selection?.range;
46
+ const anchorRange = selectionRange ??
47
+ (type === "activeCell" && activeCell
48
+ ? {
49
+ startRowIndex: activeCell.rowIndex,
50
+ endRowIndex: activeCell.rowIndex,
51
+ startColumnIndex: activeCell.columnIndex,
52
+ endColumnIndex: activeCell.columnIndex,
53
+ }
54
+ : undefined);
55
+ // Smart tags anchored to the active cell or a selection are drawn once:
56
+ // on the copy the grid marks as holding the corner they hang from.
57
+ const activeCellTagAt = (corner) => type === "activeCell" && Boolean(corner) && activeCell !== undefined;
58
+ // The AutoCorrect Options tag belongs to the cell its edit was made in, not to the cursor:
59
+ // `CanvasGrid` marks that cell with an anchor border style, and the tag is drawn beside its
60
+ // top-right corner, on the copy that holds it.
61
+ const autoCorrectKinds = type === AUTOCORRECT_ANCHOR_TYPE && props.holdsTopRightCorner
62
+ ? (props.metadata?.autoCorrect ?? [])
63
+ : undefined;
40
64
  const isFill = type === "fill";
41
65
  const isActiveCell = type === "activeCell";
42
66
  const isSelection = type === "selection";
@@ -125,42 +149,40 @@ export const useSelectionRenderer = ({ sheetId, selectionCount, selectionBackgro
125
149
  }
126
150
  }
127
151
  }, isHovered: isHovered, TitleComponent: SelectionTitleComponent, onRequestEditTable: onRequestEditTable, onRequestEditPivotTable: onRequestEditPivotTable, fillHandleSize: fillHandleSize, showFillHandle: showFillHandle, onFlashEnd: onFlashEnd, duration: duration, enableMagicFill: formulaMode ? false : enableMagicFill, MagicFillComponent: MagicFillComponent, readonly: readonly, showPasteMenu: showPasteMenu, fillOptions: fillOptions &&
128
- range &&
152
+ selectionRange &&
153
+ props.holdsCorner &&
129
154
  fillOptions.sheetId === sheetId &&
130
- isAreasEqual(fillOptions.fillSelection.range, range)
155
+ isAreasEqual(fillOptions.fillSelection.range, selectionRange)
131
156
  ? fillOptions
132
- : undefined, onChooseFillType: onChooseFillType, onOpenFillSeriesDialog: onOpenFillSeriesDialog, onCloseFillOptions: onCloseFillOptions, insertOptions: insertOptions &&
133
- range &&
157
+ : undefined, onChooseFillType: onChooseFillType, onOpenFillSeriesDialog: onOpenFillSeriesDialog, onCloseFillOptions: onCloseFillOptions, onFillOptionsOpenChange: onFillOptionsOpenChange, insertOptions: insertOptions &&
158
+ anchorRange &&
159
+ props.holdsBottomLeftCorner &&
134
160
  insertOptions.sheetId === sheetId &&
135
- anchorsInsertOptions(insertOptions, range, type, index, isEmptySelections)
161
+ anchorsInsertOptions(insertOptions, anchorRange, type, index, isEmptySelections)
136
162
  ? insertOptions
137
163
  : undefined, onChooseInsertOption: onChooseInsertOption, tableAutoExpansion: tableAutoExpansion &&
138
- range &&
139
- type === "activeCell" &&
140
- keepsTableAutoExpansionTag(tableAutoExpansion, sheetId, {
141
- rowIndex: range.startRowIndex,
142
- columnIndex: range.startColumnIndex,
143
- })
144
- ? { canStop: canStopAutoExpandingTables }
164
+ tableAutoExpansion.sheetId === sheetId &&
165
+ autoCorrectKinds?.includes("table")
166
+ ? {
167
+ canUndo: canUndoTableAutoExpansion,
168
+ canStop: canStopAutoExpandingTables,
169
+ }
145
170
  : undefined, onChooseTableAutoExpansionOption: onChooseTableAutoExpansionOption, flashFillOptions: flashFillOptions &&
146
- range &&
147
- type === "activeCell" &&
148
- keepsFlashFillOptionsTag(flashFillOptions, sheetId, {
149
- rowIndex: range.startRowIndex,
150
- columnIndex: range.startColumnIndex,
151
- })
171
+ activeCellTagAt(props.holdsTopRightCorner) &&
172
+ keepsFlashFillOptionsTag(flashFillOptions, sheetId, activeCell)
152
173
  ? {
153
174
  changedCount: countRangeCells(flashFillOptions.changed),
154
175
  blankCount: countRangeCells(flashFillOptions.blank),
155
176
  }
156
177
  : undefined, onChooseFlashFillOption: onChooseFlashFillOption, calculatedColumnFill: calculatedColumnFill &&
157
- range &&
158
- type === "activeCell" &&
159
- keepsCalculatedColumnTag(calculatedColumnFill, sheetId, {
160
- rowIndex: range.startRowIndex,
161
- columnIndex: range.startColumnIndex,
162
- })
163
- ? { kind: calculatedColumnFill.kind, canStop: canStopAutoCalculatedColumns }
178
+ calculatedColumnFill.sheetId === sheetId &&
179
+ autoCorrectKinds?.includes("calculated")
180
+ ? {
181
+ kind: calculatedColumnFill.kind,
182
+ canUndo: canUndoCalculatedColumn,
183
+ canOverwrite: canOverwriteCalculatedColumn,
184
+ canStop: canStopAutoCalculatedColumns,
185
+ }
164
186
  : undefined, onChooseCalculatedColumnOption: onChooseCalculatedColumnOption, errorCheck: type === "activeCell" ? errorCheck : undefined, errorCheckMenuOpen: errorCheckMenuOpen, onErrorCheckMenuOpenChange: onErrorCheckMenuOpenChange, onChooseErrorCheckOption: onChooseErrorCheckOption, sheetId: sheetId, MagicFillContent: MagicFillContent, QuickEdit: QuickEdit, PasteMenu: PasteMenu, onChoosePasteOption: onChoosePasteOption, SuggestionAction: SuggestionAction, onSplitTextToColumns: (delimiter) => {
165
187
  // Active cell
166
188
  const newActiveCell = range
@@ -209,15 +231,19 @@ export const useSelectionRenderer = ({ sheetId, selectionCount, selectionBackgro
209
231
  onChooseFillType,
210
232
  onOpenFillSeriesDialog,
211
233
  onCloseFillOptions,
234
+ onFillOptionsOpenChange,
212
235
  insertOptions,
213
236
  onChooseInsertOption,
214
237
  tableAutoExpansion,
215
238
  canStopAutoExpandingTables,
239
+ canUndoTableAutoExpansion,
216
240
  onChooseTableAutoExpansionOption,
217
241
  flashFillOptions,
218
242
  onChooseFlashFillOption,
219
243
  calculatedColumnFill,
220
244
  canStopAutoCalculatedColumns,
245
+ canUndoCalculatedColumn,
246
+ canOverwriteCalculatedColumn,
221
247
  onChooseCalculatedColumnOption,
222
248
  errorCheck,
223
249
  errorCheckMenuOpen,