@rowsncolumns/spreadsheet 10.13.0 → 10.15.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 (71) hide show
  1. package/dist/cjs/api/split-pane.d.ts +1 -0
  2. package/dist/cjs/api/split-pane.d.ts.map +1 -1
  3. package/dist/cjs/api/split-pane.js +5 -1
  4. package/dist/cjs/atoms/cell-input-context.atom.d.ts.map +1 -1
  5. package/dist/cjs/components/canvas-grid/index.d.ts.map +1 -1
  6. package/dist/cjs/components/canvas-grid/index.js +225 -54
  7. package/dist/cjs/components/canvas-grid/typings.d.ts +20 -0
  8. package/dist/cjs/components/canvas-grid/typings.d.ts.map +1 -1
  9. package/dist/cjs/components/embeds/embed-draggable.d.ts +1 -1
  10. package/dist/cjs/components/embeds/embed-draggable.d.ts.map +1 -1
  11. package/dist/cjs/components/embeds/embed-draggable.js +24 -8
  12. package/dist/cjs/components/embeds/pane-copy.d.ts +35 -0
  13. package/dist/cjs/components/embeds/pane-copy.d.ts.map +1 -0
  14. package/dist/cjs/components/embeds/pane-copy.js +29 -0
  15. package/dist/cjs/hooks/object-spec-schema.generated.d.ts.map +1 -1
  16. package/dist/cjs/hooks/object-spec-schema.generated.js +12 -0
  17. package/dist/cjs/hooks/use-embeds-charts.d.ts +6 -1
  18. package/dist/cjs/hooks/use-embeds-charts.d.ts.map +1 -1
  19. package/dist/cjs/hooks/use-embeds-charts.js +46 -21
  20. package/dist/cjs/hooks/use-grid-children.d.ts +4 -2
  21. package/dist/cjs/hooks/use-grid-children.d.ts.map +1 -1
  22. package/dist/cjs/hooks/use-grid-children.js +74 -16
  23. package/dist/cjs/hooks/use-header-actions.d.ts +11 -1
  24. package/dist/cjs/hooks/use-header-actions.d.ts.map +1 -1
  25. package/dist/cjs/hooks/use-header-actions.js +16 -6
  26. package/dist/cjs/hooks/use-move-columns-rows.d.ts +7 -1
  27. package/dist/cjs/hooks/use-move-columns-rows.d.ts.map +1 -1
  28. package/dist/cjs/hooks/use-move-columns-rows.js +12 -10
  29. package/dist/cjs/hooks/use-shown-notes.d.ts +11 -1
  30. package/dist/cjs/hooks/use-shown-notes.d.ts.map +1 -1
  31. package/dist/cjs/hooks/use-shown-notes.js +34 -12
  32. package/dist/cjs/release-date.js +1 -1
  33. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  34. package/dist/cjs/types.d.ts +6 -0
  35. package/dist/cjs/types.d.ts.map +1 -1
  36. package/dist/esm/api/split-pane.d.ts +1 -0
  37. package/dist/esm/api/split-pane.d.ts.map +1 -1
  38. package/dist/esm/api/split-pane.js +5 -1
  39. package/dist/esm/atoms/cell-input-context.atom.d.ts.map +1 -1
  40. package/dist/esm/components/canvas-grid/index.d.ts.map +1 -1
  41. package/dist/esm/components/canvas-grid/index.js +176 -10
  42. package/dist/esm/components/canvas-grid/typings.d.ts +20 -0
  43. package/dist/esm/components/canvas-grid/typings.d.ts.map +1 -1
  44. package/dist/esm/components/embeds/embed-draggable.d.ts +1 -1
  45. package/dist/esm/components/embeds/embed-draggable.d.ts.map +1 -1
  46. package/dist/esm/components/embeds/embed-draggable.js +25 -9
  47. package/dist/esm/components/embeds/pane-copy.d.ts +35 -0
  48. package/dist/esm/components/embeds/pane-copy.d.ts.map +1 -0
  49. package/dist/esm/components/embeds/pane-copy.js +22 -0
  50. package/dist/esm/hooks/object-spec-schema.generated.d.ts.map +1 -1
  51. package/dist/esm/hooks/object-spec-schema.generated.js +12 -0
  52. package/dist/esm/hooks/use-embeds-charts.d.ts +6 -1
  53. package/dist/esm/hooks/use-embeds-charts.d.ts.map +1 -1
  54. package/dist/esm/hooks/use-embeds-charts.js +45 -20
  55. package/dist/esm/hooks/use-grid-children.d.ts +4 -2
  56. package/dist/esm/hooks/use-grid-children.d.ts.map +1 -1
  57. package/dist/esm/hooks/use-grid-children.js +59 -16
  58. package/dist/esm/hooks/use-header-actions.d.ts +11 -1
  59. package/dist/esm/hooks/use-header-actions.d.ts.map +1 -1
  60. package/dist/esm/hooks/use-header-actions.js +12 -2
  61. package/dist/esm/hooks/use-move-columns-rows.d.ts +7 -1
  62. package/dist/esm/hooks/use-move-columns-rows.d.ts.map +1 -1
  63. package/dist/esm/hooks/use-move-columns-rows.js +11 -7
  64. package/dist/esm/hooks/use-shown-notes.d.ts +11 -1
  65. package/dist/esm/hooks/use-shown-notes.d.ts.map +1 -1
  66. package/dist/esm/hooks/use-shown-notes.js +23 -12
  67. package/dist/esm/release-date.js +1 -1
  68. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  69. package/dist/esm/types.d.ts +6 -0
  70. package/dist/esm/types.d.ts.map +1 -1
  71. package/package.json +2 -2
@@ -96,7 +96,7 @@ var validateEmbeds = function (embedsOrCharts, sheetId) {
96
96
  });
97
97
  };
98
98
  var useEmbedsCharts = function (_a) {
99
- var _b = _a.scale, scale = _b === void 0 ? 1 : _b, charts = _a.charts, embeds = _a.embeds, slicers = _a.slicers, sheetId = _a.sheetId, _c = _a.frozenRows, frozenRows = _c === void 0 ? 0 : _c, _d = _a.frozenColumns, frozenColumns = _d === void 0 ? 0 : _d, getCellOffsetFromCoords = _a.getCellOffsetFromCoords, getCellCoordsFromOffset = _a.getCellCoordsFromOffset, getAbsolutePositionFromOffset = _a.getAbsolutePositionFromOffset, getRelativePositionFromOffset = _a.getRelativePositionFromOffset, _e = _a.ContextMenuWrapper, ContextMenuWrapper = _e === void 0 ? use_context_menu_1.DefaultContextMenuWrapper : _e, focusSheet = _a.focusSheet, getBounds = _a.getBounds, _f = _a.selectedColor, selectedColor = _f === void 0 ? "#1a73e8" : _f, onMoveChart = _a.onMoveChart, onResizeChart = _a.onResizeChart, chartClipboard = _a.chartClipboard, onMoveEmbed = _a.onMoveEmbed, onResizeEmbed = _a.onResizeEmbed, onDeleteChart = _a.onDeleteChart, onUpdateChart = _a.onUpdateChart, onChangeZOrder = _a.onChangeZOrder, onDeleteEmbed = _a.onDeleteEmbed, onRequestEditEmbed = _a.onRequestEditEmbed, onMoveSlicer = _a.onMoveSlicer, onResizeSlicer = _a.onResizeSlicer, onDeleteSlicer = _a.onDeleteSlicer, onDeleteObjects = _a.onDeleteObjects, onRequestEditSlicer = _a.onRequestEditSlicer, onFilterTable = _a.onFilterTable, onFilterPivot = _a.onFilterPivot, tables = _a.tables, pivotTables = _a.pivotTables, getFormattedValue = _a.getFormattedValue, getLinkedPictureSource = _a.getLinkedPictureSource, getSheetName = _a.getSheetName, _g = _a.getChartComponent, getChartComponent = _g === void 0 ? defaultGetChartComponent : _g, _h = _a.getEmbedComponent, getEmbedComponent = _h === void 0 ? defaultGetEmbedComponent : _h, _j = _a.getSlicerComponent, getSlicerComponent = _j === void 0 ? defaultGetSlicerComponent : _j, readonly = _a.readonly, locale = _a.locale, theme = _a.theme, backgroundColor = _a.backgroundColor, disabled = _a.disabled, pageLayout = _a.pageLayout;
99
+ var _b = _a.scale, scale = _b === void 0 ? 1 : _b, charts = _a.charts, embeds = _a.embeds, slicers = _a.slicers, sheetId = _a.sheetId, _c = _a.frozenRows, frozenRows = _c === void 0 ? 0 : _c, _d = _a.frozenColumns, frozenColumns = _d === void 0 ? 0 : _d, getCellOffsetFromCoords = _a.getCellOffsetFromCoords, getCellCoordsFromOffset = _a.getCellCoordsFromOffset, getCellCoordsFromSheetOffset = _a.getCellCoordsFromSheetOffset, getAbsolutePositionFromOffset = _a.getAbsolutePositionFromOffset, getRelativePositionFromOffset = _a.getRelativePositionFromOffset, _e = _a.ContextMenuWrapper, ContextMenuWrapper = _e === void 0 ? use_context_menu_1.DefaultContextMenuWrapper : _e, focusSheet = _a.focusSheet, getBounds = _a.getBounds, _f = _a.selectedColor, selectedColor = _f === void 0 ? "#1a73e8" : _f, onMoveChart = _a.onMoveChart, onResizeChart = _a.onResizeChart, chartClipboard = _a.chartClipboard, onMoveEmbed = _a.onMoveEmbed, onResizeEmbed = _a.onResizeEmbed, onDeleteChart = _a.onDeleteChart, onUpdateChart = _a.onUpdateChart, onChangeZOrder = _a.onChangeZOrder, onDeleteEmbed = _a.onDeleteEmbed, onRequestEditEmbed = _a.onRequestEditEmbed, onMoveSlicer = _a.onMoveSlicer, onResizeSlicer = _a.onResizeSlicer, onDeleteSlicer = _a.onDeleteSlicer, onDeleteObjects = _a.onDeleteObjects, onRequestEditSlicer = _a.onRequestEditSlicer, onFilterTable = _a.onFilterTable, onFilterPivot = _a.onFilterPivot, tables = _a.tables, pivotTables = _a.pivotTables, getFormattedValue = _a.getFormattedValue, getLinkedPictureSource = _a.getLinkedPictureSource, getSheetName = _a.getSheetName, _g = _a.getChartComponent, getChartComponent = _g === void 0 ? defaultGetChartComponent : _g, _h = _a.getEmbedComponent, getEmbedComponent = _h === void 0 ? defaultGetEmbedComponent : _h, _j = _a.getSlicerComponent, getSlicerComponent = _j === void 0 ? defaultGetSlicerComponent : _j, readonly = _a.readonly, locale = _a.locale, theme = _a.theme, backgroundColor = _a.backgroundColor, disabled = _a.disabled, pageLayout = _a.pageLayout;
100
100
  /**
101
101
  * Page Layout view: the row and column each page starts at and the gap before it (grid pixels),
102
102
  * for `EmbedDraggable`'s `pageGaps`; resolved into grid coordinates where they are used.
@@ -428,7 +428,6 @@ var useEmbedsCharts = function (_a) {
428
428
  handleContextMenuCloseAutoFocus,
429
429
  ]);
430
430
  var getCellPositionAt = (0, react_1.useCallback)(function (x, y) {
431
- var _a, _b;
432
431
  // A point on the sheet's far edge (an object's corner flush with the last column's right
433
432
  // edge or the last row's bottom) names the last column / row, as a point past the edge
434
433
  // does (`getCellPosition` pulls it to the edge's last pixel), never the column or row after
@@ -436,9 +435,18 @@ var useEmbedsCharts = function (_a) {
436
435
  var bounds = getBounds();
437
436
  var lookupX = bounds.right !== undefined && x >= bounds.right ? bounds.right - 1 : x;
438
437
  var lookupY = bounds.bottom !== undefined && y >= bounds.bottom ? bounds.bottom - 1 : y;
439
- var position = getAbsolutePositionFromOffset(lookupX, lookupY);
440
- // Use includeFrozen=true to detect cells in all regions
441
- var anchorCell = getCellCoordsFromOffset((_a = position === null || position === void 0 ? void 0 : position.x) !== null && _a !== void 0 ? _a : 0, (_b = position === null || position === void 0 ? void 0 : position.y) !== null && _b !== void 0 ? _b : 0, true);
438
+ // An object's corners are in SHEET coordinates (it is laid out from its anchor cell's
439
+ // offset), so the cell is read there directly: through the page it would be read again
440
+ // through the scroll position of the window, or of the pane under it on a split sheet, and
441
+ // a sheet scrolled by 200 px would store E21 − 189 px for what is E12 + 0.
442
+ var anchorCell = getCellCoordsFromSheetOffset
443
+ ? getCellCoordsFromSheetOffset(lookupX, lookupY)
444
+ : (function () {
445
+ var _a, _b;
446
+ var position = getAbsolutePositionFromOffset(lookupX, lookupY);
447
+ // Use includeFrozen=true to detect cells in all regions
448
+ return getCellCoordsFromOffset((_a = position === null || position === void 0 ? void 0 : position.x) !== null && _a !== void 0 ? _a : 0, (_b = position === null || position === void 0 ? void 0 : position.y) !== null && _b !== void 0 ? _b : 0, true);
449
+ })();
442
450
  var cellPosition = anchorCell
443
451
  ? getCellOffsetFromCoords(anchorCell)
444
452
  : undefined;
@@ -448,6 +456,7 @@ var useEmbedsCharts = function (_a) {
448
456
  }, [
449
457
  getCellOffsetFromCoords,
450
458
  getCellCoordsFromOffset,
459
+ getCellCoordsFromSheetOffset,
451
460
  getAbsolutePositionFromOffset,
452
461
  getBounds,
453
462
  ]);
@@ -471,6 +480,20 @@ var useEmbedsCharts = function (_a) {
471
480
  }
472
481
  return getCellPositionAt(clampedX, clampedY);
473
482
  }, [getCellPositionAt, getBounds]);
483
+ /**
484
+ * What a gesture STORES for a point: its cell and the offset inside it in sheet pixels — 100 %
485
+ * zoom, as an object's size is stored and as xlsx writes it — whatever the zoom the gesture
486
+ * was made at. The layout (and `getCellPosition`) is in zoomed pixels; at any zoom but 100 %
487
+ * the offset is divided by the zoom and rounded to a whole pixel, so the same gesture on the
488
+ * sheet stores the same anchor at every zoom. At 100 % the offset is stored as measured.
489
+ */
490
+ var getStoredPosition = (0, react_1.useCallback)(function (x, y) {
491
+ var position = getCellPosition(x, y);
492
+ if (!position || scale === 1)
493
+ return position;
494
+ var _a = tslib_1.__read(position, 3), cell = _a[0], offsetX = _a[1], offsetY = _a[2];
495
+ return [cell, Math.round(offsetX / scale), Math.round(offsetY / scale)];
496
+ }, [getCellPosition, scale]);
474
497
  // Alt-drag / Alt-resize: nearest cell corner to a point, in the same pixel space the objects are laid out in
475
498
  var snapToCellGrid = (0, react_1.useCallback)(function (x, y) {
476
499
  var position = getCellPosition(x, y);
@@ -503,13 +526,13 @@ var useEmbedsCharts = function (_a) {
503
526
  var bottom = gaps
504
527
  ? (0, page_gaps_1.toScreen)(gaps.y, (0, page_gaps_1.toGapFree)(gaps.y, y) + height)
505
528
  : y + height;
506
- var position = getCellPosition(right, bottom);
529
+ var position = getStoredPosition(right, bottom);
507
530
  if (!position) {
508
531
  return undefined;
509
532
  }
510
533
  var _a = tslib_1.__read(position, 3), toCell = _a[0], toOffsetXPixels = _a[1], toOffsetYPixels = _a[2];
511
534
  return { toCell: toCell, toOffsetXPixels: toOffsetXPixels, toOffsetYPixels: toOffsetYPixels };
512
- }, [getCellPosition, pageGaps, getCellOffsetFromCoords]);
535
+ }, [getStoredPosition, pageGaps, getCellOffsetFromCoords]);
513
536
  var getChartOverlay = (0, react_1.useCallback)(function (id) {
514
537
  var _a, _b;
515
538
  return (_b = (_a = charts === null || charts === void 0 ? void 0 : charts.find(function (chart) { return chart.chartId === id; })) === null || _a === void 0 ? void 0 : _a.position) === null || _b === void 0 ? void 0 : _b.overlayPosition;
@@ -524,58 +547,58 @@ var useEmbedsCharts = function (_a) {
524
547
  }, [slicers]);
525
548
  // Callback when user moves a chart
526
549
  var handleMove = (0, react_1.useCallback)(function (id, x, y, width, height) {
527
- var position = getCellPosition(x, y);
550
+ var position = getStoredPosition(x, y);
528
551
  if (!position) {
529
552
  return;
530
553
  }
531
554
  var _a = tslib_1.__read(position, 3), anchorCell = _a[0], offsetXPixels = _a[1], offsetYPixels = _a[2];
532
555
  onMoveChart === null || onMoveChart === void 0 ? void 0 : onMoveChart(id, anchorCell, offsetXPixels, offsetYPixels, getToAnchor(getChartOverlay(id), x, y, width, height));
533
- }, [onMoveChart, getCellPosition, getToAnchor, getChartOverlay]);
556
+ }, [onMoveChart, getStoredPosition, getToAnchor, getChartOverlay]);
534
557
  // Callback when resizes an embed
535
558
  var handleEmbedResize = (0, react_1.useCallback)(function (id, x, y, width, height) {
536
- var position = getCellPosition(x, y);
559
+ var position = getStoredPosition(x, y);
537
560
  if (!position) {
538
561
  return;
539
562
  }
540
563
  var _a = tslib_1.__read(position, 3), anchorCell = _a[0], offsetXPixels = _a[1], offsetYPixels = _a[2];
541
564
  onResizeEmbed === null || onResizeEmbed === void 0 ? void 0 : onResizeEmbed(id, sheetId, anchorCell, offsetXPixels, offsetYPixels, width, height, getToAnchor(getEmbedOverlay(id), x, y, width * scale, height * scale));
542
- }, [onResizeEmbed, sheetId, scale, getCellPosition, getToAnchor, getEmbedOverlay]);
565
+ }, [onResizeEmbed, sheetId, scale, getStoredPosition, getToAnchor, getEmbedOverlay]);
543
566
  // Callback when user moves a chart
544
567
  var handleEmbedMove = (0, react_1.useCallback)(function (id, x, y, width, height) {
545
- var position = getCellPosition(x, y);
568
+ var position = getStoredPosition(x, y);
546
569
  if (!position) {
547
570
  return;
548
571
  }
549
572
  var _a = tslib_1.__read(position, 3), anchorCell = _a[0], offsetXPixels = _a[1], offsetYPixels = _a[2];
550
573
  onMoveEmbed === null || onMoveEmbed === void 0 ? void 0 : onMoveEmbed(id, sheetId, anchorCell, offsetXPixels, offsetYPixels, getToAnchor(getEmbedOverlay(id), x, y, width, height));
551
- }, [onMoveEmbed, sheetId, getCellPosition, getToAnchor, getEmbedOverlay]);
574
+ }, [onMoveEmbed, sheetId, getStoredPosition, getToAnchor, getEmbedOverlay]);
552
575
  // Callback when resizes a chart
553
576
  var handleResize = (0, react_1.useCallback)(function (id, x, y, width, height) {
554
- var position = getCellPosition(x, y);
577
+ var position = getStoredPosition(x, y);
555
578
  if (!position) {
556
579
  return;
557
580
  }
558
581
  var _a = tslib_1.__read(position, 3), anchorCell = _a[0], offsetXPixels = _a[1], offsetYPixels = _a[2];
559
582
  onResizeChart === null || onResizeChart === void 0 ? void 0 : onResizeChart(id, anchorCell, offsetXPixels, offsetYPixels, width, height, getToAnchor(getChartOverlay(id), x, y, width * scale, height * scale));
560
- }, [onResizeChart, scale, getCellPosition, getToAnchor, getChartOverlay]);
583
+ }, [onResizeChart, scale, getStoredPosition, getToAnchor, getChartOverlay]);
561
584
  // Callback when user resizes a slicer
562
585
  var handleSlicerResize = (0, react_1.useCallback)(function (id, x, y, width, height) {
563
- var position = getCellPosition(x, y);
586
+ var position = getStoredPosition(x, y);
564
587
  if (!position) {
565
588
  return;
566
589
  }
567
590
  var _a = tslib_1.__read(position, 3), anchorCell = _a[0], offsetXPixels = _a[1], offsetYPixels = _a[2];
568
591
  onResizeSlicer === null || onResizeSlicer === void 0 ? void 0 : onResizeSlicer(id, sheetId, anchorCell, offsetXPixels, offsetYPixels, width, height, getToAnchor(getSlicerOverlay(id), x, y, width * scale, height * scale));
569
- }, [onResizeSlicer, sheetId, scale, getCellPosition, getToAnchor, getSlicerOverlay]);
592
+ }, [onResizeSlicer, sheetId, scale, getStoredPosition, getToAnchor, getSlicerOverlay]);
570
593
  // Callback when user moves a slicer
571
594
  var handleSlicerMove = (0, react_1.useCallback)(function (id, x, y, width, height) {
572
- var position = getCellPosition(x, y);
595
+ var position = getStoredPosition(x, y);
573
596
  if (!position) {
574
597
  return;
575
598
  }
576
599
  var _a = tslib_1.__read(position, 3), anchorCell = _a[0], offsetXPixels = _a[1], offsetYPixels = _a[2];
577
600
  onMoveSlicer === null || onMoveSlicer === void 0 ? void 0 : onMoveSlicer(id, sheetId, anchorCell, offsetXPixels, offsetYPixels, getToAnchor(getSlicerOverlay(id), x, y, width, height));
578
- }, [onMoveSlicer, sheetId, getCellPosition, getToAnchor, getSlicerOverlay]);
601
+ }, [onMoveSlicer, sheetId, getStoredPosition, getToAnchor, getSlicerOverlay]);
579
602
  // The frozen-pane layer an object renders in: the cell its top-left corner
580
603
  // actually sits in (anchor walked forward by the pixel offsets) against the
581
604
  // frozen counts. Charts, pictures / embeds and slicers share it, so an object
@@ -583,9 +606,11 @@ var useEmbedsCharts = function (_a) {
583
606
  var placementOf = (0, react_1.useCallback)(function (_a) {
584
607
  var anchorCell = _a.anchorCell, offsetXPixels = _a.offsetXPixels, offsetYPixels = _a.offsetYPixels;
585
608
  return (0, exports.getOverlayPlacement)(anchorCell
586
- ? (0, exports.resolveOverlayCell)(anchorCell, offsetXPixels !== null && offsetXPixels !== void 0 ? offsetXPixels : 0, offsetYPixels !== null && offsetYPixels !== void 0 ? offsetYPixels : 0, getCellOffsetFromCoords, frozenRows, frozenColumns)
609
+ ? (0, exports.resolveOverlayCell)(anchorCell,
610
+ // Offsets are stored in sheet pixels; the cells are measured zoomed.
611
+ (offsetXPixels !== null && offsetXPixels !== void 0 ? offsetXPixels : 0) * scale, (offsetYPixels !== null && offsetYPixels !== void 0 ? offsetYPixels : 0) * scale, getCellOffsetFromCoords, frozenRows, frozenColumns)
587
612
  : anchorCell, frozenRows, frozenColumns);
588
- }, [frozenRows, frozenColumns, getCellOffsetFromCoords]);
613
+ }, [frozenRows, frozenColumns, getCellOffsetFromCoords, scale]);
589
614
  // Chart components - categorized by frozen pane placement
590
615
  var chartComponents = (0, react_1.useMemo)(function () {
591
616
  var _a;
@@ -1,4 +1,4 @@
1
- import type { GridChildrenProps, GridPane } from "@rowsncolumns/grid";
1
+ import type { CellInterface, CellPosition, 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";
@@ -30,11 +30,13 @@ type UseGridChildrenProps = {
30
30
  */
31
31
  editorPaneId?: GridPane["id"];
32
32
  popoverRange?: SheetRange | SheetCoordinate;
33
+ /** Where a cell is laid out: on a split sheet, what decides the pane a note or handle is in. */
34
+ getCellOffsetFromCoords?(cell: CellInterface): CellPosition | undefined;
33
35
  gridLineWidth?: number;
34
36
  frozenColumns: number;
35
37
  frozenRows: number;
36
38
  };
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;
39
+ 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, getCellOffsetFromCoords, }: UseGridChildrenProps) => (props: GridChildrenProps) => React.JSX.Element;
38
40
  export declare const StyledGridChildren: ({ className, elevate, ...props }: React.HTMLAttributes<HTMLDivElement> & {
39
41
  elevate?: boolean;
40
42
  }) => React.JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"use-grid-children.d.ts","sourceRoot":"","sources":["../../../hooks/use-grid-children.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,KAAsB,MAAM,OAAO,CAAC;AAG3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAEzE,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAK3D,K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Aa,GAAG,YAAY,GAAG,SAAS,CAAC;IACxE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,ibAwB7B,oBAAoB,aAiBX,iBAAiB,sBAsS5B,CAAC;AA+BF,eAAO,MAAM,kBAAkB,GAAI,kCAIhC,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,sBAS9D,CAAC"}
@@ -5,11 +5,12 @@ var tslib_1 = require("tslib");
5
5
  var ui_1 = require("@rowsncolumns/ui");
6
6
  var react_1 = tslib_1.__importStar(require("react"));
7
7
  var atoms_1 = require("../atoms");
8
+ var pane_copy_1 = require("../components/embeds/pane-copy");
8
9
  var helpers_1 = require("../helpers");
9
10
  /** Shared, so a sheet with no split hands the same empty list to every render. */
10
11
  var EMPTY_PANES = [];
11
12
  var useGridChildren = function (_a) {
12
- var stickyEditor = _a.stickyEditor, editorComponent = _a.editorComponent, shownNoteComponents = _a.shownNoteComponents, chartComponents = _a.chartComponents, embedComponents = _a.embedComponents, slicerComponents = _a.slicerComponents, pivotPlaceholders = _a.pivotPlaceholders, tableResizers = _a.tableResizers, hiddenColumnMarkers = _a.hiddenColumnMarkers, frozenHiddenColumnMarkers = _a.frozenHiddenColumnMarkers, hiddenRowMarkers = _a.hiddenRowMarkers, frozenHiddenRowMarkers = _a.frozenHiddenRowMarkers, _b = _a.gridLineWidth, gridLineWidth = _b === void 0 ? 1 : _b, frozenColumns = _a.frozenColumns, frozenRows = _a.frozenRows, headerMenuComponent = _a.headerMenuComponent, isHeaderMenuInFrozenColumn = _a.isHeaderMenuInFrozenColumn, popoverRange = _a.popoverRange, popoverComponent = _a.popoverComponent, cellExpandComponent = _a.cellExpandComponent, arrowComponents = _a.arrowComponents, editorPaneId = _a.editorPaneId;
13
+ var stickyEditor = _a.stickyEditor, editorComponent = _a.editorComponent, shownNoteComponents = _a.shownNoteComponents, chartComponents = _a.chartComponents, embedComponents = _a.embedComponents, slicerComponents = _a.slicerComponents, pivotPlaceholders = _a.pivotPlaceholders, tableResizers = _a.tableResizers, hiddenColumnMarkers = _a.hiddenColumnMarkers, frozenHiddenColumnMarkers = _a.frozenHiddenColumnMarkers, hiddenRowMarkers = _a.hiddenRowMarkers, frozenHiddenRowMarkers = _a.frozenHiddenRowMarkers, _b = _a.gridLineWidth, gridLineWidth = _b === void 0 ? 1 : _b, frozenColumns = _a.frozenColumns, frozenRows = _a.frozenRows, headerMenuComponent = _a.headerMenuComponent, isHeaderMenuInFrozenColumn = _a.isHeaderMenuInFrozenColumn, popoverRange = _a.popoverRange, popoverComponent = _a.popoverComponent, cellExpandComponent = _a.cellExpandComponent, arrowComponents = _a.arrowComponents, editorPaneId = _a.editorPaneId, getCellOffsetFromCoords = _a.getCellOffsetFromCoords;
13
14
  var editingCellCoordinate = (0, atoms_1.useEditingCellCoordinate)();
14
15
  // Quite a bit of logic for non sticky editor
15
16
  // Remove if majority dont use this
@@ -25,6 +26,8 @@ var useGridChildren = function (_a) {
25
26
  * block below, unchanged.
26
27
  */
27
28
  var isSplit = panes.length > 1;
29
+ /** What each pane's copy of an object is told: its pane, and all of them. */
30
+ var paneCopies = panes.map(function (pane) { return ({ paneId: pane.id, panes: panes }); });
28
31
  /**
29
32
  * Two notions, deliberately apart. The EDITOR belongs to the pane the edit started in and
30
33
  * stays there while that pane scrolls. Everything else that exists once — the comment /
@@ -34,6 +37,55 @@ var useGridChildren = function (_a) {
34
37
  var editorOwningPaneId = (_b = (_a = panes.find(function (pane) { return pane.id === (editorPaneId !== null && editorPaneId !== void 0 ? editorPaneId : activePaneId); })) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : (_c = panes[0]) === null || _c === void 0 ? void 0 : _c.id;
35
38
  var overlayOwningPaneId = (_e = (_d = panes.find(function (pane) { return pane.id === activePaneId; })) === null || _d === void 0 ? void 0 : _d.id) !== null && _e !== void 0 ? _e : (_f = panes[0]) === null || _f === void 0 ? void 0 : _f.id;
36
39
  /** The bottom of the leading pane: what the frozen column strip is cut off at. */
40
+ /**
41
+ * What exists once and belongs to a cell — a note shown on the sheet, a table's resize
42
+ * handle, a pivot table's placeholder — is drawn in the pane that shows its cell: the pane
43
+ * being worked in when it shows it, else the first that does, else the leading pane (where
44
+ * a cell no pane shows was drawn before, clipped). Excel draws such shapes in every pane
45
+ * they show in; these are drawn once because a shown note carries its own editing state.
46
+ */
47
+ var paneOfCell = function (cell) {
48
+ var _a, _b, _c, _d;
49
+ var box = cell ? getCellOffsetFromCoords === null || getCellOffsetFromCoords === void 0 ? void 0 : getCellOffsetFromCoords(cell) : undefined;
50
+ if (!box)
51
+ return (_a = panes[0]) === null || _a === void 0 ? void 0 : _a.id;
52
+ var showing = (0, pane_copy_1.panesShowing)(panes, box);
53
+ return (_d = ((_c = (_b = showing.find(function (pane) { return pane.id === overlayOwningPaneId; })) !== null && _b !== void 0 ? _b : showing[0]) !== null && _c !== void 0 ? _c : panes[0])) === null || _d === void 0 ? void 0 : _d.id;
54
+ };
55
+ var byPane = function (elements, cellOf) {
56
+ var e_1, _a;
57
+ var groups = new Map();
58
+ if (!isSplit || !elements)
59
+ return groups;
60
+ try {
61
+ for (var elements_1 = tslib_1.__values(elements), elements_1_1 = elements_1.next(); !elements_1_1.done; elements_1_1 = elements_1.next()) {
62
+ var element = elements_1_1.value;
63
+ var id = paneOfCell(cellOf(element));
64
+ var group = groups.get(id);
65
+ if (group)
66
+ group.push(element);
67
+ else
68
+ groups.set(id, [element]);
69
+ }
70
+ }
71
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
72
+ finally {
73
+ try {
74
+ if (elements_1_1 && !elements_1_1.done && (_a = elements_1.return)) _a.call(elements_1);
75
+ }
76
+ finally { if (e_1) throw e_1.error; }
77
+ }
78
+ return groups;
79
+ };
80
+ var notesByPane = byPane(shownNoteComponents === null || shownNoteComponents === void 0 ? void 0 : shownNoteComponents.body, function (element) { return element.props.cell; });
81
+ var tableResizersByPane = byPane(tableResizers, function (element) {
82
+ return element.props.cornerCell;
83
+ });
84
+ var pivotPlaceholdersByPane = byPane(pivotPlaceholders, function (element) {
85
+ var _a;
86
+ return (_a = element.props
87
+ .pivotTable) === null || _a === void 0 ? void 0 : _a.targetPosition;
88
+ });
37
89
  var leadingBottom = panes[0]
38
90
  ? panes[0].rect.y + panes[0].rect.height
39
91
  : undefined;
@@ -57,13 +109,17 @@ var useGridChildren = function (_a) {
57
109
  pointerEvents: "all",
58
110
  } }, headerMenuComponent)),
59
111
  isSplit ? (panes.map(function (pane, index) {
60
- // An object anchored to a cell (a chart, a picture, a note, a slicer, a trace
61
- // arrow) is ONE piece of DOM with its own drag state: drawing it in both panes
62
- // would duplicate it, so it is drawn in the leading pane and clipped there. It is
63
- // never drawn at a wrong position — a pane it does not belong to simply does not
64
- // show it. The editor and the popover exist once too, and belong to the pane being
65
- // worked in.
66
- var isLeading = index === 0;
112
+ // Charts, pictures, shapes and slicers are drawn in every pane they are visible in,
113
+ // as Excel draws them: each pane renders the object list inside a `PaneCopyContext`,
114
+ // and each copy draws itself only where it shows (`EmbedDraggable`). Every copy is
115
+ // the same object — selection, drag and resize work from any of them.
116
+ //
117
+ // A note shown on the sheet, a table's resize handle and a pivot placeholder are
118
+ // drawn in the pane that shows their cell (`paneOfCell`). Trace arrows are the
119
+ // host's drawing, laid out in sheet coordinates: every pane draws them and clips
120
+ // them, as Excel draws them in every pane they show in. A host places its own
121
+ // overlays per pane with `getGridRef()?.getDrawnRects(range)`. The editor and the
122
+ // popover exist once too, and belong to the pane being worked in.
67
123
  var isEditorPane = pane.id === editorOwningPaneId;
68
124
  var isOverlayPane = pane.id === overlayOwningPaneId;
69
125
  return (react_1.default.createElement(exports.StyledGridChildren, { key: "pane-children-".concat(pane.id), style: {
@@ -73,24 +129,25 @@ var useGridChildren = function (_a) {
73
129
  height: pane.rect.height,
74
130
  } },
75
131
  react_1.default.createElement("div", { style: {
76
- transform: "translate(-".concat(pane.scrollLeft + pane.rect.x, "px, -").concat(pane.scrollTop + pane.rect.y, "px)"),
132
+ transform: "translate(-".concat(pane.offsetLeft + pane.rect.x, "px, -").concat(pane.offsetTop + pane.rect.y, "px)"),
77
133
  } },
78
- isLeading ? tableResizers : null,
134
+ tableResizersByPane.get(pane.id),
79
135
  !stickyEditor &&
80
136
  stickyEditorPlacement === "body" &&
81
137
  isEditorPane
82
138
  ? editorComponent
83
139
  : null,
84
- isLeading ? chartComponents.body : null,
85
- isLeading ? shownNoteComponents === null || shownNoteComponents === void 0 ? void 0 : shownNoteComponents.body : null,
86
- isLeading ? embedComponents === null || embedComponents === void 0 ? void 0 : embedComponents.body : null,
87
- isLeading ? slicerComponents === null || slicerComponents === void 0 ? void 0 : slicerComponents.body : null,
88
- isLeading ? pivotPlaceholders : null,
140
+ react_1.default.createElement(pane_copy_1.PaneCopyContext.Provider, { value: paneCopies[index] },
141
+ chartComponents.body, embedComponents === null || embedComponents === void 0 ? void 0 :
142
+ embedComponents.body, slicerComponents === null || slicerComponents === void 0 ? void 0 :
143
+ slicerComponents.body),
144
+ notesByPane.get(pane.id),
145
+ pivotPlaceholdersByPane.get(pane.id),
89
146
  popoverPlacement === "body" && isOverlayPane
90
147
  ? popoverComponent
91
148
  : null,
92
149
  isOverlayPane ? cellExpandComponent : null,
93
- isLeading ? arrowComponents : null)));
150
+ arrowComponents)));
94
151
  })) : (react_1.default.createElement(exports.StyledGridChildren, { style: {
95
152
  top: frozenRowHeight + gridLineWidth,
96
153
  left: frozenColumnWidth + gridLineWidth,
@@ -183,6 +240,7 @@ var useGridChildren = function (_a) {
183
240
  cellExpandComponent,
184
241
  arrowComponents,
185
242
  editorPaneId,
243
+ getCellOffsetFromCoords,
186
244
  ]);
187
245
  };
188
246
  exports.useGridChildren = useGridChildren;
@@ -7,7 +7,17 @@ import type { useSelection } from "./use-selection";
7
7
  type UseHeaderActions = {
8
8
  backgroundColor?: string;
9
9
  activeCell?: CellInterface | null;
10
+ /**
11
+ * What the hovered heading is drawn offset by: the window's scroll position, or on a split
12
+ * sheet the offset of the band of headings under the pointer.
13
+ */
10
14
  getScrollPosition: () => ScrollCoords | undefined;
15
+ /**
16
+ * The window's own scroll position, which the layer the header menu is drawn in follows; on a
17
+ * split sheet the menu is shifted from it to the band its heading is drawn in. Defaults to
18
+ * `getScrollPosition`.
19
+ */
20
+ getWindowScrollPosition?: () => ScrollCoords | undefined;
11
21
  getCellOffsetFromCoords: (cell: CellInterface) => CellPosition | undefined;
12
22
  getRelativePositionFromOffset: (x: number, y: number) => PosXYRequired | null | undefined;
13
23
  /**
@@ -63,7 +73,7 @@ type UseHeaderActions = {
63
73
  * @param param0
64
74
  * @returns
65
75
  */
66
- export declare const useHeaderActions: ({ activeCell, getScrollPosition, getCellOffsetFromCoords, getRelativePositionFromOffset, onResize, onAutoFit, isRowHeader, isColumnHeader, showContextMenu, selectColumn, setActiveCell, getViewPort, isHiddenColumn, focusSheet, frozenRows, frozenColumns, showHeaderMenuButton, selectionTopBound, resizerDimension, headerBorderWidth, minDimension, containerHeight, containerWidth, backgroundColor, scale, headerMenuWidth, sheetId, selectedRowHeaders, selectedColumnHeaders, enableResizerOverflow, }: UseHeaderActions) => {
76
+ export declare const useHeaderActions: ({ activeCell, getScrollPosition, getWindowScrollPosition, getCellOffsetFromCoords, getRelativePositionFromOffset, onResize, onAutoFit, isRowHeader, isColumnHeader, showContextMenu, selectColumn, setActiveCell, getViewPort, isHiddenColumn, focusSheet, frozenRows, frozenColumns, showHeaderMenuButton, selectionTopBound, resizerDimension, headerBorderWidth, minDimension, containerHeight, containerWidth, backgroundColor, scale, headerMenuWidth, sheetId, selectedRowHeaders, selectedColumnHeaders, enableResizerOverflow, }: UseHeaderActions) => {
67
77
  headerMenuComponent: React.JSX.Element | null;
68
78
  isHeaderMenuInFrozenColumn: boolean;
69
79
  headerResizer: React.JSX.Element | null;
@@ -1 +1 @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AC,EAAE,OAAO,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,kBAAkB,EAAE,WAAW,CAAC;IAChC,qEAAqE;IACrE,qBAAqB,EAAE,WAAW,CAAC;IACnC,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,0gBAgC9B,gBAAgB;;;;;CA6WlB,CAAC"}
@@ -14,9 +14,9 @@ var use_isomorphic_layout_effect_1 = require("./use-isomorphic-layout-effect");
14
14
  * @returns
15
15
  */
16
16
  var useHeaderActions = function (_a) {
17
- var activeCell = _a.activeCell, getScrollPosition = _a.getScrollPosition, getCellOffsetFromCoords = _a.getCellOffsetFromCoords, getRelativePositionFromOffset = _a.getRelativePositionFromOffset, onResize = _a.onResize, onAutoFit = _a.onAutoFit, isRowHeader = _a.isRowHeader, isColumnHeader = _a.isColumnHeader, showContextMenu = _a.showContextMenu, selectColumn = _a.selectColumn, setActiveCell = _a.setActiveCell, getViewPort = _a.getViewPort, isHiddenColumn = _a.isHiddenColumn, focusSheet = _a.focusSheet, frozenRows = _a.frozenRows, frozenColumns = _a.frozenColumns, showHeaderMenuButton = _a.showHeaderMenuButton, selectionTopBound = _a.selectionTopBound, _b = _a.resizerDimension, resizerDimension = _b === void 0 ? 5 : _b, _c = _a.headerBorderWidth, headerBorderWidth = _c === void 0 ? 1 : _c, _d = _a.minDimension, minDimension = _d === void 0 ? 5 : _d, containerHeight = _a.containerHeight, containerWidth = _a.containerWidth, backgroundColor = _a.backgroundColor, _e = _a.scale, scale = _e === void 0 ? 1 : _e, _f = _a.headerMenuWidth, headerMenuWidth = _f === void 0 ? 16 * scale : _f, sheetId = _a.sheetId, selectedRowHeaders = _a.selectedRowHeaders, selectedColumnHeaders = _a.selectedColumnHeaders, _g = _a.enableResizerOverflow, enableResizerOverflow = _g === void 0 ? false : _g;
18
- var _h = tslib_1.__read((0, react_1.useState)(0), 2), dimension = _h[0], setDimension = _h[1];
19
- var _j = tslib_1.__read((0, react_1.useState)(false), 2), isDragging = _j[0], setIsDragging = _j[1];
17
+ var activeCell = _a.activeCell, getScrollPosition = _a.getScrollPosition, _b = _a.getWindowScrollPosition, getWindowScrollPosition = _b === void 0 ? getScrollPosition : _b, getCellOffsetFromCoords = _a.getCellOffsetFromCoords, getRelativePositionFromOffset = _a.getRelativePositionFromOffset, onResize = _a.onResize, onAutoFit = _a.onAutoFit, isRowHeader = _a.isRowHeader, isColumnHeader = _a.isColumnHeader, showContextMenu = _a.showContextMenu, selectColumn = _a.selectColumn, setActiveCell = _a.setActiveCell, getViewPort = _a.getViewPort, isHiddenColumn = _a.isHiddenColumn, focusSheet = _a.focusSheet, frozenRows = _a.frozenRows, frozenColumns = _a.frozenColumns, showHeaderMenuButton = _a.showHeaderMenuButton, selectionTopBound = _a.selectionTopBound, _c = _a.resizerDimension, resizerDimension = _c === void 0 ? 5 : _c, _d = _a.headerBorderWidth, headerBorderWidth = _d === void 0 ? 1 : _d, _e = _a.minDimension, minDimension = _e === void 0 ? 5 : _e, containerHeight = _a.containerHeight, containerWidth = _a.containerWidth, backgroundColor = _a.backgroundColor, _f = _a.scale, scale = _f === void 0 ? 1 : _f, _g = _a.headerMenuWidth, headerMenuWidth = _g === void 0 ? 16 * scale : _g, sheetId = _a.sheetId, selectedRowHeaders = _a.selectedRowHeaders, selectedColumnHeaders = _a.selectedColumnHeaders, _h = _a.enableResizerOverflow, enableResizerOverflow = _h === void 0 ? false : _h;
18
+ var _j = tslib_1.__read((0, react_1.useState)(0), 2), dimension = _j[0], setDimension = _j[1];
19
+ var _k = tslib_1.__read((0, react_1.useState)(false), 2), isDragging = _k[0], setIsDragging = _k[1];
20
20
  var dragStartPos = (0, react_1.useRef)(0);
21
21
  /** Document the in-flight gesture listens on (the grid may live in a popout window) */
22
22
  var gestureDocumentRef = (0, react_1.useRef)(null);
@@ -70,7 +70,7 @@ var useHeaderActions = function (_a) {
70
70
  * Header actions component
71
71
  */
72
72
  var headerMenuComponent = (0, react_1.useMemo)(function () {
73
- var _a;
73
+ var _a, _b, _c, _d, _e;
74
74
  if (!showHeaderMenuButton ||
75
75
  isDragging ||
76
76
  !activeCell ||
@@ -80,16 +80,23 @@ var useHeaderActions = function (_a) {
80
80
  return null;
81
81
  }
82
82
  // Only visible for column headers
83
- var _b = (_a = getCellOffsetFromCoords(activeCell)) !== null && _a !== void 0 ? _a : {}, _c = _b.x, x = _c === void 0 ? 0 : _c, _d = _b.y, y = _d === void 0 ? 0 : _d, _e = _b.width, width = _e === void 0 ? 0 : _e, _f = _b.height, height = _f === void 0 ? 0 : _f;
83
+ var _f = (_a = getCellOffsetFromCoords(activeCell)) !== null && _a !== void 0 ? _a : {}, _g = _f.x, x = _g === void 0 ? 0 : _g, _h = _f.y, y = _h === void 0 ? 0 : _h, _j = _f.width, width = _j === void 0 ? 0 : _j, _k = _f.height, height = _k === void 0 ? 0 : _k;
84
84
  var isSelected = isHeaderSelected(axisRef.current === "x" ? activeCell.rowIndex : activeCell.columnIndex);
85
85
  var isNextColumnHidden = isHiddenColumn(activeCell.columnIndex + 1);
86
86
  var spacing = (height - headerMenuWidth) / 2;
87
+ // The menu's layer follows the window's scroll; a heading in a band that scrolled on its own
88
+ // is drawn offset by that band instead (0 without a split, or in a frozen column).
89
+ var bandShift = activeCell.columnIndex < frozenColumns
90
+ ? 0
91
+ : ((_c = (_b = getScrollPosition()) === null || _b === void 0 ? void 0 : _b.scrollLeft) !== null && _c !== void 0 ? _c : 0) -
92
+ ((_e = (_d = getWindowScrollPosition()) === null || _d === void 0 ? void 0 : _d.scrollLeft) !== null && _e !== void 0 ? _e : 0);
87
93
  var left = x +
88
94
  // scrollLeft +
89
95
  width -
90
96
  headerMenuWidth -
91
97
  spacing +
92
- (isNextColumnHidden ? -hiddenMarkerDim + spacing : 0);
98
+ (isNextColumnHidden ? -hiddenMarkerDim + spacing : 0) -
99
+ bandShift;
93
100
  var top = y + (height - headerMenuWidth) / 2;
94
101
  return (react_1.default.createElement(header_menu_1.Headermenu, { left: left, top: top, dimension: headerMenuWidth, onClick: function (e) {
95
102
  showHeaderMenu(activeCell, e.nativeEvent.clientX, e.nativeEvent.clientY);
@@ -116,6 +123,9 @@ var useHeaderActions = function (_a) {
116
123
  isRowHeader,
117
124
  isHeaderSelected,
118
125
  scale,
126
+ frozenColumns,
127
+ getScrollPosition,
128
+ getWindowScrollPosition,
119
129
  ]);
120
130
  /**
121
131
  * Called when user drags header resize component
@@ -27,6 +27,12 @@ export type ColumnRowMoveOptions = {
27
27
  * Get current scroll position
28
28
  */
29
29
  getScrollPosition: () => ScrollCoords | undefined;
30
+ /**
31
+ * What a heading is drawn offset by — on a split sheet, the band of headings that draws it
32
+ * (each band scrolls on its own). The move handle over selected columns or rows is drawn, and
33
+ * its drag measured, by the band that draws their first one. Defaults to `getScrollPosition`.
34
+ */
35
+ getHeadingScrollPosition?: (cell: CellInterface) => ScrollCoords | undefined;
30
36
  onMouseMove?: (event: React.MouseEvent<HTMLDivElement>) => void;
31
37
  onChangeSelections: CanvasGridProps["onChangeSelections"];
32
38
  onChangeActiveCell: CanvasGridProps["onChangeActiveCell"];
@@ -41,7 +47,7 @@ export type ColumnRowMoveOptions = {
41
47
  * Column Row move hook
42
48
  * @param param0
43
49
  */
44
- export declare const useMoveColumnsAndRows: ({ getCellOffsetFromCoords, getCellCoordsFromOffset, getRelativePositionFromOffset, scrollToCell, focusSheet, columns, rows, selectionLeftBound, selectionTopBound, onMoveColumns, onMoveRows, containerWidth, containerHeight, rowCount, columnCount, sheetId, onChangeSelections, onChangeActiveCell, getScrollPosition, disabled, activeCell, HeaderMoveDragComponent: HeaderMoveDragComponentComponent, }: ColumnRowMoveOptions) => {
50
+ export declare const useMoveColumnsAndRows: ({ getCellOffsetFromCoords, getCellCoordsFromOffset, getRelativePositionFromOffset, scrollToCell, focusSheet, columns, rows, selectionLeftBound, selectionTopBound, onMoveColumns, onMoveRows, containerWidth, containerHeight, rowCount, columnCount, sheetId, onChangeSelections, onChangeActiveCell, getScrollPosition, getHeadingScrollPosition, disabled, activeCell, HeaderMoveDragComponent: HeaderMoveDragComponentComponent, }: ColumnRowMoveOptions) => {
45
51
  isDragging: boolean;
46
52
  draggableRows: React.JSX.Element | null;
47
53
  draggableColumns: React.JSX.Element | null;
@@ -1 +1 @@
1
- {"version":3,"file":"use-move-columns-rows.d.ts","sourceRoot":"","sources":["../../../hooks/use-move-columns-rows.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,qBAAqB,EACrB,aAAa,EACb,YAAY,EACb,MAAM,oBAAoB,CAAC;AAI5B,OAAO,KAAiD,MAAM,OAAO,CAAC;AAEtE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EACL,KAAK,kBAAkB,EAExB,MAAM,2BAA2B,CAAC;AAInC,MAAM,MAAM,oBAAoB,GAAG;IACjC;;;OAGG;IACH,uBAAuB,CAAC,IAAI,EAAE,aAAa,GAAG,YAAY,GAAG,SAAS,CAAC;IACvE,uBAAuB,CACrB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,aAAa,CAAC,EAAE,OAAO,GACtB,aAAa,GAAG,IAAI,GAAG,SAAS,CAAC;IACpC,6BAA6B,EAAE,CAC7B,CAAC,EAA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CAAC;IAC7E,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,KAAK,IAAI,CAAC;IAChE,kBAAkB,EAAE,eAAe,CAAC,oBAAoB,CAAC,CAAC;IAC1D,kBAAkB,EAAE,eAAe,CAAC,oBAAoB,CAAC,CAAC;IAC1D,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,aAAa,CAAC;IAC1B,uBAAuB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;CACnE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAAI,waAyBnC,oBAAoB;;;;CA6atB,CAAC"}
@@ -14,10 +14,10 @@ var use_isomorphic_layout_effect_1 = require("./use-isomorphic-layout-effect");
14
14
  * @param param0
15
15
  */
16
16
  var useMoveColumnsAndRows = function (_a) {
17
- var getCellOffsetFromCoords = _a.getCellOffsetFromCoords, getCellCoordsFromOffset = _a.getCellCoordsFromOffset, getRelativePositionFromOffset = _a.getRelativePositionFromOffset, scrollToCell = _a.scrollToCell, focusSheet = _a.focusSheet, _b = _a.columns, columns = _b === void 0 ? index_ranges_1.IndexRanges.EMPTY : _b, _c = _a.rows, rows = _c === void 0 ? index_ranges_1.IndexRanges.EMPTY : _c, _d = _a.selectionLeftBound, selectionLeftBound = _d === void 0 ? 0 : _d, _e = _a.selectionTopBound, selectionTopBound = _e === void 0 ? 0 : _e, onMoveColumns = _a.onMoveColumns, onMoveRows = _a.onMoveRows, containerWidth = _a.containerWidth, containerHeight = _a.containerHeight, rowCount = _a.rowCount, columnCount = _a.columnCount, sheetId = _a.sheetId, onChangeSelections = _a.onChangeSelections, onChangeActiveCell = _a.onChangeActiveCell, getScrollPosition = _a.getScrollPosition, disabled = _a.disabled, activeCell = _a.activeCell, _f = _a.HeaderMoveDragComponent, HeaderMoveDragComponentComponent = _f === void 0 ? header_move_1.HeaderMoveDragComponent : _f;
18
- var _g = tslib_1.__read((0, react_1.useState)(false), 2), isDragging = _g[0], setIsDragging = _g[1];
19
- var _h = tslib_1.__read((0, react_1.useState)(0), 2), offset = _h[0], setOffset = _h[1];
20
- var _j = tslib_1.__read((0, react_1.useState)(0), 2), dragOffset = _j[0], setDragOffset = _j[1];
17
+ var getCellOffsetFromCoords = _a.getCellOffsetFromCoords, getCellCoordsFromOffset = _a.getCellCoordsFromOffset, getRelativePositionFromOffset = _a.getRelativePositionFromOffset, scrollToCell = _a.scrollToCell, focusSheet = _a.focusSheet, _b = _a.columns, columns = _b === void 0 ? index_ranges_1.IndexRanges.EMPTY : _b, _c = _a.rows, rows = _c === void 0 ? index_ranges_1.IndexRanges.EMPTY : _c, _d = _a.selectionLeftBound, selectionLeftBound = _d === void 0 ? 0 : _d, _e = _a.selectionTopBound, selectionTopBound = _e === void 0 ? 0 : _e, onMoveColumns = _a.onMoveColumns, onMoveRows = _a.onMoveRows, containerWidth = _a.containerWidth, containerHeight = _a.containerHeight, rowCount = _a.rowCount, columnCount = _a.columnCount, sheetId = _a.sheetId, onChangeSelections = _a.onChangeSelections, onChangeActiveCell = _a.onChangeActiveCell, getScrollPosition = _a.getScrollPosition, _f = _a.getHeadingScrollPosition, getHeadingScrollPosition = _f === void 0 ? function () { return getScrollPosition(); } : _f, disabled = _a.disabled, activeCell = _a.activeCell, _g = _a.HeaderMoveDragComponent, HeaderMoveDragComponentComponent = _g === void 0 ? header_move_1.HeaderMoveDragComponent : _g;
18
+ var _h = tslib_1.__read((0, react_1.useState)(false), 2), isDragging = _h[0], setIsDragging = _h[1];
19
+ var _j = tslib_1.__read((0, react_1.useState)(0), 2), offset = _j[0], setOffset = _j[1];
20
+ var _k = tslib_1.__read((0, react_1.useState)(0), 2), dragOffset = _k[0], setDragOffset = _k[1];
21
21
  var gapRef = (0, react_1.useRef)(0);
22
22
  /** Document the in-flight gesture listens on (the grid may live in a popout window) */
23
23
  var gestureDocumentRef = (0, react_1.useRef)(null);
@@ -204,8 +204,8 @@ var useMoveColumnsAndRows = function (_a) {
204
204
  /**
205
205
  * Get the axis,
206
206
  */
207
- var scrollPosition = getScrollPosition();
208
- var coords = getCellCoordsFromOffset(e.nativeEvent.clientX - ((_a = scrollPosition === null || scrollPosition === void 0 ? void 0 : scrollPosition.scrollLeft) !== null && _a !== void 0 ? _a : 0), e.nativeEvent.clientY - ((_b = scrollPosition === null || scrollPosition === void 0 ? void 0 : scrollPosition.scrollTop) !== null && _b !== void 0 ? _b : 0), false);
207
+ var windowScroll = getScrollPosition();
208
+ var coords = getCellCoordsFromOffset(e.nativeEvent.clientX - ((_a = windowScroll === null || windowScroll === void 0 ? void 0 : windowScroll.scrollLeft) !== null && _a !== void 0 ? _a : 0), e.nativeEvent.clientY - ((_b = windowScroll === null || windowScroll === void 0 ? void 0 : windowScroll.scrollTop) !== null && _b !== void 0 ? _b : 0), false);
209
209
  if (!coords) {
210
210
  return;
211
211
  }
@@ -226,6 +226,7 @@ var useMoveColumnsAndRows = function (_a) {
226
226
  if ((0, utils_1.isNil)(pos)) {
227
227
  return;
228
228
  }
229
+ var scrollPosition = getHeadingScrollPosition(cell);
229
230
  var offset = axis === "x" ? (_e = pos.x) !== null && _e !== void 0 ? _e : 0 : (_f = pos.y) !== null && _f !== void 0 ? _f : 0;
230
231
  var relativePos = getRelativePositionFromOffset(e.nativeEvent.clientX, e.nativeEvent.clientY);
231
232
  if (!relativePos) {
@@ -250,6 +251,7 @@ var useMoveColumnsAndRows = function (_a) {
250
251
  columns,
251
252
  rows,
252
253
  getScrollPosition,
254
+ getHeadingScrollPosition,
253
255
  getCellCoordsFromOffset,
254
256
  getCellOffsetFromCoords,
255
257
  getRelativePositionFromOffset,
@@ -281,7 +283,7 @@ var useMoveColumnsAndRows = function (_a) {
281
283
  if (posLeft === undefined || posRight === undefined) {
282
284
  return null;
283
285
  }
284
- var scrollLeft = (_d = (_c = getScrollPosition()) === null || _c === void 0 ? void 0 : _c.scrollLeft) !== null && _d !== void 0 ? _d : 0;
286
+ var scrollLeft = (_d = (_c = getHeadingScrollPosition({ rowIndex: 0, columnIndex: min })) === null || _c === void 0 ? void 0 : _c.scrollLeft) !== null && _d !== void 0 ? _d : 0;
285
287
  var x = ((_e = posLeft.x) !== null && _e !== void 0 ? _e : 0) - scrollLeft;
286
288
  var width = ((_f = posRight.x) !== null && _f !== void 0 ? _f : 0) - ((_g = posLeft.x) !== null && _g !== void 0 ? _g : 0) + ((_h = posRight.width) !== null && _h !== void 0 ? _h : 0);
287
289
  var finalDragOffset = Math.max((_j = minLeft === null || minLeft === void 0 ? void 0 : minLeft.x) !== null && _j !== void 0 ? _j : 0, Math.min(containerWidth - width, dragOffset));
@@ -296,7 +298,7 @@ var useMoveColumnsAndRows = function (_a) {
296
298
  isDragging,
297
299
  offset,
298
300
  dragOffset,
299
- getScrollPosition,
301
+ getHeadingScrollPosition,
300
302
  containerWidth,
301
303
  containerHeight,
302
304
  getCellOffsetFromCoords,
@@ -329,7 +331,7 @@ var useMoveColumnsAndRows = function (_a) {
329
331
  if (posLeft === undefined || posRight === undefined) {
330
332
  return null;
331
333
  }
332
- var scrollTop = (_d = (_c = getScrollPosition()) === null || _c === void 0 ? void 0 : _c.scrollTop) !== null && _d !== void 0 ? _d : 0;
334
+ var scrollTop = (_d = (_c = getHeadingScrollPosition({ rowIndex: min, columnIndex: 0 })) === null || _c === void 0 ? void 0 : _c.scrollTop) !== null && _d !== void 0 ? _d : 0;
333
335
  var height = ((_e = posRight.y) !== null && _e !== void 0 ? _e : 0) - ((_f = posLeft.y) !== null && _f !== void 0 ? _f : 0) + ((_g = posRight.height) !== null && _g !== void 0 ? _g : 0);
334
336
  var finalDragOffset = Math.max((_h = minTop === null || minTop === void 0 ? void 0 : minTop.y) !== null && _h !== void 0 ? _h : 0, Math.min(containerHeight - height, dragOffset));
335
337
  var borderOffset = Math.max((_j = minTop === null || minTop === void 0 ? void 0 : minTop.y) !== null && _j !== void 0 ? _j : 0, // UP
@@ -343,7 +345,7 @@ var useMoveColumnsAndRows = function (_a) {
343
345
  isDragging,
344
346
  offset,
345
347
  dragOffset,
346
- getScrollPosition,
348
+ getHeadingScrollPosition,
347
349
  containerWidth,
348
350
  containerHeight,
349
351
  getCellOffsetFromCoords,
@@ -36,6 +36,11 @@ type UseShownNotesProps = {
36
36
  /** Notes are drawn at all (the grid's `showNotes`). */
37
37
  enabled: boolean;
38
38
  window: GridRange;
39
+ /**
40
+ * View ▸ Split: the windows of the panes that scroll on their own (their rows and columns are
41
+ * not the window's), each read like `window`. A note in two windows is drawn once.
42
+ */
43
+ paneWindows?: GridRange[];
39
44
  frozenRows: number;
40
45
  frozenColumns: number;
41
46
  readonly?: boolean;
@@ -46,11 +51,16 @@ type UseShownNotesProps = {
46
51
  /** Row and column sizes: a resize moves the boxes with their cells. */
47
52
  rowMetadata?: unknown;
48
53
  columnMetadata?: unknown;
54
+ /**
55
+ * Changes once the grid can place a cell: the first render comes before it is mounted, and
56
+ * every cell then reads as unplaced, so no box would be drawn until the window moved.
57
+ */
58
+ layoutKey?: unknown;
49
59
  };
50
60
  /**
51
61
  * The shown notes of the cells in `window`, laid out in the frozen-pane layer their cell sits in
52
62
  * (the same split charts and pictures use).
53
63
  */
54
- export declare const useShownNotes: ({ sheetId, showAllNotes, enabled, window, frozenRows, frozenColumns, readonly, getNote, isNoteVisible, getCellOffsetFromCoords, onUpdateNote, rowMetadata, columnMetadata, }: UseShownNotesProps) => CategorizedComponents<React.JSX.Element>;
64
+ export declare const useShownNotes: ({ sheetId, showAllNotes, enabled, window, paneWindows, frozenRows, frozenColumns, readonly, getNote, isNoteVisible, getCellOffsetFromCoords, onUpdateNote, rowMetadata, columnMetadata, layoutKey, }: UseShownNotesProps) => CategorizedComponents<React.JSX.Element>;
55
65
  export {};
56
66
  //# sourceMappingURL=use-shown-notes.d.ts.map