@rowsncolumns/spreadsheet 10.8.1 → 10.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/api/index-ranges.d.ts +36 -0
- package/dist/cjs/api/index-ranges.d.ts.map +1 -0
- package/dist/cjs/api/index-ranges.js +178 -0
- package/dist/cjs/api/multi-selection.d.ts +15 -0
- package/dist/cjs/api/multi-selection.d.ts.map +1 -1
- package/dist/cjs/api/multi-selection.js +40 -1
- package/dist/cjs/atoms/cell-input-context.atom.d.ts.map +1 -1
- package/dist/cjs/atoms/copied-range.atom.d.ts +13 -0
- package/dist/cjs/atoms/copied-range.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/copied-range.atom.js +15 -0
- package/dist/cjs/atoms/index.d.ts +2 -0
- package/dist/cjs/atoms/index.d.ts.map +1 -1
- package/dist/cjs/atoms/index.js +2 -0
- package/dist/cjs/atoms/selected-chart-embed.atom.d.ts +27 -1
- package/dist/cjs/atoms/selected-chart-embed.atom.d.ts.map +1 -1
- package/dist/cjs/atoms/selected-chart-embed.atom.js +66 -3
- package/dist/cjs/atoms/selected-object-formula.atom.d.ts +12 -0
- package/dist/cjs/atoms/selected-object-formula.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/selected-object-formula.atom.js +19 -0
- package/dist/cjs/components/canvas-grid/helpers.d.ts +14 -0
- package/dist/cjs/components/canvas-grid/helpers.d.ts.map +1 -1
- package/dist/cjs/components/canvas-grid/helpers.js +52 -1
- package/dist/cjs/components/canvas-grid/index.d.ts.map +1 -1
- package/dist/cjs/components/canvas-grid/index.js +309 -94
- package/dist/cjs/components/canvas-grid/typings.d.ts +71 -4
- package/dist/cjs/components/canvas-grid/typings.d.ts.map +1 -1
- package/dist/cjs/components/cell-input/formula-bar-cell-input.d.ts.map +1 -1
- package/dist/cjs/components/cell-input/formula-bar-cell-input.js +7 -3
- package/dist/cjs/components/cell-structured/cell-image.d.ts +17 -3
- package/dist/cjs/components/cell-structured/cell-image.d.ts.map +1 -1
- package/dist/cjs/components/cell-structured/cell-image.js +15 -4
- package/dist/cjs/components/cell-structured/index.d.ts +2 -2
- package/dist/cjs/components/cell-structured/index.d.ts.map +1 -1
- package/dist/cjs/components/cell-structured/index.js +3 -2
- package/dist/cjs/components/context-menu/index.d.ts +19 -3
- package/dist/cjs/components/context-menu/index.d.ts.map +1 -1
- package/dist/cjs/components/context-menu/index.js +69 -47
- package/dist/cjs/components/embeds/embed-component.d.ts +7 -1
- package/dist/cjs/components/embeds/embed-component.d.ts.map +1 -1
- package/dist/cjs/components/embeds/embed-component.js +5 -1
- package/dist/cjs/components/embeds/embed-draggable.d.ts +3 -1
- package/dist/cjs/components/embeds/embed-draggable.d.ts.map +1 -1
- package/dist/cjs/components/embeds/embed-draggable.js +10 -1
- package/dist/cjs/components/embeds/index.d.ts +1 -0
- package/dist/cjs/components/embeds/index.d.ts.map +1 -1
- package/dist/cjs/components/embeds/index.js +1 -0
- package/dist/cjs/components/embeds/linked-picture.d.ts +54 -0
- package/dist/cjs/components/embeds/linked-picture.d.ts.map +1 -0
- package/dist/cjs/components/embeds/linked-picture.js +217 -0
- package/dist/cjs/components/outline-gutter/index.d.ts.map +1 -1
- package/dist/cjs/components/outline-gutter/index.js +96 -48
- package/dist/cjs/components/outline-gutter/offsets.d.ts +32 -0
- package/dist/cjs/components/outline-gutter/offsets.d.ts.map +1 -0
- package/dist/cjs/components/outline-gutter/offsets.js +59 -0
- package/dist/cjs/components/page-layout-view/compute-page-layout.d.ts +86 -0
- package/dist/cjs/components/page-layout-view/compute-page-layout.d.ts.map +1 -0
- package/dist/cjs/components/page-layout-view/compute-page-layout.js +196 -0
- package/dist/cjs/components/page-layout-view/header-footer-codes.d.ts +32 -0
- package/dist/cjs/components/page-layout-view/header-footer-codes.d.ts.map +1 -0
- package/dist/cjs/components/page-layout-view/header-footer-codes.js +173 -0
- package/dist/cjs/components/page-layout-view/index.d.ts +4 -0
- package/dist/cjs/components/page-layout-view/index.d.ts.map +1 -0
- package/dist/cjs/components/page-layout-view/index.js +17 -0
- package/dist/cjs/components/page-layout-view/page-layout-chrome.d.ts +50 -0
- package/dist/cjs/components/page-layout-view/page-layout-chrome.d.ts.map +1 -0
- package/dist/cjs/components/page-layout-view/page-layout-chrome.js +432 -0
- package/dist/cjs/components/print-preview/use-page-layout.d.ts +5 -0
- package/dist/cjs/components/print-preview/use-page-layout.d.ts.map +1 -1
- package/dist/cjs/components/print-preview/use-page-layout.js +4 -3
- package/dist/cjs/helpers.d.ts +6 -0
- package/dist/cjs/helpers.d.ts.map +1 -1
- package/dist/cjs/helpers.js +17 -1
- package/dist/cjs/hooks/use-cell-renderer.d.ts +6 -4
- package/dist/cjs/hooks/use-cell-renderer.d.ts.map +1 -1
- package/dist/cjs/hooks/use-cell-renderer.js +5 -4
- package/dist/cjs/hooks/use-context-setter.d.ts.map +1 -1
- package/dist/cjs/hooks/use-context-setter.js +3 -1
- package/dist/cjs/hooks/use-copy-paste-cut.d.ts.map +1 -1
- package/dist/cjs/hooks/use-copy-paste-cut.js +9 -3
- package/dist/cjs/hooks/use-editor-submit.d.ts +17 -1
- package/dist/cjs/hooks/use-editor-submit.d.ts.map +1 -1
- package/dist/cjs/hooks/use-editor-submit.js +43 -4
- package/dist/cjs/hooks/use-embeds-charts.d.ts +13 -2
- package/dist/cjs/hooks/use-embeds-charts.d.ts.map +1 -1
- package/dist/cjs/hooks/use-embeds-charts.js +151 -17
- package/dist/cjs/hooks/use-get-tooltip.d.ts +6 -1
- package/dist/cjs/hooks/use-get-tooltip.d.ts.map +1 -1
- package/dist/cjs/hooks/use-get-tooltip.js +4 -2
- package/dist/cjs/hooks/use-grid-children.d.ts +3 -1
- package/dist/cjs/hooks/use-grid-children.d.ts.map +1 -1
- package/dist/cjs/hooks/use-grid-children.js +10 -5
- package/dist/cjs/hooks/use-header-actions.d.ts +6 -3
- package/dist/cjs/hooks/use-header-actions.d.ts.map +1 -1
- package/dist/cjs/hooks/use-header-actions.js +7 -8
- package/dist/cjs/hooks/use-keyboard-handler.d.ts +7 -5
- package/dist/cjs/hooks/use-keyboard-handler.d.ts.map +1 -1
- package/dist/cjs/hooks/use-keyboard-handler.js +14 -31
- package/dist/cjs/hooks/use-move-columns-rows.d.ts +5 -2
- package/dist/cjs/hooks/use-move-columns-rows.d.ts.map +1 -1
- package/dist/cjs/hooks/use-move-columns-rows.js +36 -32
- package/dist/cjs/hooks/use-selected-rows-columns.d.ts +24 -6
- package/dist/cjs/hooks/use-selected-rows-columns.d.ts.map +1 -1
- package/dist/cjs/hooks/use-selected-rows-columns.js +42 -35
- package/dist/cjs/hooks/use-selection.d.ts +10 -1
- package/dist/cjs/hooks/use-selection.d.ts.map +1 -1
- package/dist/cjs/hooks/use-selection.js +35 -18
- package/dist/cjs/hooks/use-shown-notes.d.ts +56 -0
- package/dist/cjs/hooks/use-shown-notes.d.ts.map +1 -0
- package/dist/cjs/hooks/use-shown-notes.js +142 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/release-date.js +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/cjs/types.d.ts +36 -1
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/cjs/utils/z-order.d.ts +12 -0
- package/dist/cjs/utils/z-order.d.ts.map +1 -1
- package/dist/cjs/utils/z-order.js +56 -1
- package/dist/esm/api/index-ranges.d.ts +36 -0
- package/dist/esm/api/index-ranges.d.ts.map +1 -0
- package/dist/esm/api/index-ranges.js +114 -0
- package/dist/esm/api/multi-selection.d.ts +15 -0
- package/dist/esm/api/multi-selection.d.ts.map +1 -1
- package/dist/esm/api/multi-selection.js +21 -0
- package/dist/esm/atoms/cell-input-context.atom.d.ts.map +1 -1
- package/dist/esm/atoms/copied-range.atom.d.ts +13 -0
- package/dist/esm/atoms/copied-range.atom.d.ts.map +1 -0
- package/dist/esm/atoms/copied-range.atom.js +10 -0
- package/dist/esm/atoms/index.d.ts +2 -0
- package/dist/esm/atoms/index.d.ts.map +1 -1
- package/dist/esm/atoms/index.js +2 -0
- package/dist/esm/atoms/selected-chart-embed.atom.d.ts +27 -1
- package/dist/esm/atoms/selected-chart-embed.atom.d.ts.map +1 -1
- package/dist/esm/atoms/selected-chart-embed.atom.js +63 -3
- package/dist/esm/atoms/selected-object-formula.atom.d.ts +12 -0
- package/dist/esm/atoms/selected-object-formula.atom.d.ts.map +1 -0
- package/dist/esm/atoms/selected-object-formula.atom.js +10 -0
- package/dist/esm/components/canvas-grid/helpers.d.ts +14 -0
- package/dist/esm/components/canvas-grid/helpers.d.ts.map +1 -1
- package/dist/esm/components/canvas-grid/helpers.js +38 -0
- package/dist/esm/components/canvas-grid/index.d.ts.map +1 -1
- package/dist/esm/components/canvas-grid/index.js +233 -29
- package/dist/esm/components/canvas-grid/typings.d.ts +71 -4
- package/dist/esm/components/canvas-grid/typings.d.ts.map +1 -1
- package/dist/esm/components/cell-input/formula-bar-cell-input.d.ts.map +1 -1
- package/dist/esm/components/cell-input/formula-bar-cell-input.js +7 -3
- package/dist/esm/components/cell-structured/cell-image.d.ts +17 -3
- package/dist/esm/components/cell-structured/cell-image.d.ts.map +1 -1
- package/dist/esm/components/cell-structured/cell-image.js +15 -4
- package/dist/esm/components/cell-structured/index.d.ts +2 -2
- package/dist/esm/components/cell-structured/index.d.ts.map +1 -1
- package/dist/esm/components/cell-structured/index.js +3 -3
- package/dist/esm/components/context-menu/index.d.ts +19 -3
- package/dist/esm/components/context-menu/index.d.ts.map +1 -1
- package/dist/esm/components/context-menu/index.js +67 -45
- package/dist/esm/components/embeds/embed-component.d.ts +7 -1
- package/dist/esm/components/embeds/embed-component.d.ts.map +1 -1
- package/dist/esm/components/embeds/embed-component.js +5 -1
- package/dist/esm/components/embeds/embed-draggable.d.ts +3 -1
- package/dist/esm/components/embeds/embed-draggable.d.ts.map +1 -1
- package/dist/esm/components/embeds/embed-draggable.js +10 -1
- package/dist/esm/components/embeds/index.d.ts +1 -0
- package/dist/esm/components/embeds/index.d.ts.map +1 -1
- package/dist/esm/components/embeds/index.js +1 -0
- package/dist/esm/components/embeds/linked-picture.d.ts +54 -0
- package/dist/esm/components/embeds/linked-picture.d.ts.map +1 -0
- package/dist/esm/components/embeds/linked-picture.js +193 -0
- package/dist/esm/components/outline-gutter/index.d.ts.map +1 -1
- package/dist/esm/components/outline-gutter/index.js +90 -45
- package/dist/esm/components/outline-gutter/offsets.d.ts +32 -0
- package/dist/esm/components/outline-gutter/offsets.d.ts.map +1 -0
- package/dist/esm/components/outline-gutter/offsets.js +46 -0
- package/dist/esm/components/page-layout-view/compute-page-layout.d.ts +86 -0
- package/dist/esm/components/page-layout-view/compute-page-layout.d.ts.map +1 -0
- package/dist/esm/components/page-layout-view/compute-page-layout.js +152 -0
- package/dist/esm/components/page-layout-view/header-footer-codes.d.ts +32 -0
- package/dist/esm/components/page-layout-view/header-footer-codes.d.ts.map +1 -0
- package/dist/esm/components/page-layout-view/header-footer-codes.js +149 -0
- package/dist/esm/components/page-layout-view/index.d.ts +4 -0
- package/dist/esm/components/page-layout-view/index.d.ts.map +1 -0
- package/dist/esm/components/page-layout-view/index.js +3 -0
- package/dist/esm/components/page-layout-view/page-layout-chrome.d.ts +50 -0
- package/dist/esm/components/page-layout-view/page-layout-chrome.d.ts.map +1 -0
- package/dist/esm/components/page-layout-view/page-layout-chrome.js +351 -0
- package/dist/esm/components/print-preview/use-page-layout.d.ts +5 -0
- package/dist/esm/components/print-preview/use-page-layout.d.ts.map +1 -1
- package/dist/esm/components/print-preview/use-page-layout.js +1 -1
- package/dist/esm/helpers.d.ts +6 -0
- package/dist/esm/helpers.d.ts.map +1 -1
- package/dist/esm/helpers.js +15 -0
- package/dist/esm/hooks/use-cell-renderer.d.ts +6 -4
- package/dist/esm/hooks/use-cell-renderer.d.ts.map +1 -1
- package/dist/esm/hooks/use-cell-renderer.js +5 -4
- package/dist/esm/hooks/use-context-setter.d.ts.map +1 -1
- package/dist/esm/hooks/use-context-setter.js +3 -1
- package/dist/esm/hooks/use-copy-paste-cut.d.ts.map +1 -1
- package/dist/esm/hooks/use-copy-paste-cut.js +11 -4
- package/dist/esm/hooks/use-editor-submit.d.ts +17 -1
- package/dist/esm/hooks/use-editor-submit.d.ts.map +1 -1
- package/dist/esm/hooks/use-editor-submit.js +40 -2
- package/dist/esm/hooks/use-embeds-charts.d.ts +13 -2
- package/dist/esm/hooks/use-embeds-charts.d.ts.map +1 -1
- package/dist/esm/hooks/use-embeds-charts.js +146 -18
- package/dist/esm/hooks/use-get-tooltip.d.ts +6 -1
- package/dist/esm/hooks/use-get-tooltip.d.ts.map +1 -1
- package/dist/esm/hooks/use-get-tooltip.js +4 -2
- package/dist/esm/hooks/use-grid-children.d.ts +3 -1
- package/dist/esm/hooks/use-grid-children.d.ts.map +1 -1
- package/dist/esm/hooks/use-grid-children.js +6 -1
- package/dist/esm/hooks/use-header-actions.d.ts +6 -3
- package/dist/esm/hooks/use-header-actions.d.ts.map +1 -1
- package/dist/esm/hooks/use-header-actions.js +7 -8
- package/dist/esm/hooks/use-keyboard-handler.d.ts +7 -5
- package/dist/esm/hooks/use-keyboard-handler.d.ts.map +1 -1
- package/dist/esm/hooks/use-keyboard-handler.js +16 -19
- package/dist/esm/hooks/use-move-columns-rows.d.ts +5 -2
- package/dist/esm/hooks/use-move-columns-rows.d.ts.map +1 -1
- package/dist/esm/hooks/use-move-columns-rows.js +13 -9
- package/dist/esm/hooks/use-selected-rows-columns.d.ts +24 -6
- package/dist/esm/hooks/use-selected-rows-columns.d.ts.map +1 -1
- package/dist/esm/hooks/use-selected-rows-columns.js +38 -34
- package/dist/esm/hooks/use-selection.d.ts +10 -1
- package/dist/esm/hooks/use-selection.d.ts.map +1 -1
- package/dist/esm/hooks/use-selection.js +33 -16
- package/dist/esm/hooks/use-shown-notes.d.ts +56 -0
- package/dist/esm/hooks/use-shown-notes.d.ts.map +1 -0
- package/dist/esm/hooks/use-shown-notes.js +128 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/release-date.js +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/esm/types.d.ts +36 -1
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/utils/z-order.d.ts +12 -0
- package/dist/esm/utils/z-order.d.ts.map +1 -1
- package/dist/esm/utils/z-order.js +59 -0
- package/dist/spreadsheet.min.css +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
// Excel's linked picture (Paste Special ▸ Linked Picture, the Camera command):
|
|
2
|
+
// a picture of a cell range that stays live. The grid draws the range itself —
|
|
3
|
+
// values with their number formats, fills, fonts, borders, merged cells, at the
|
|
4
|
+
// source's column widths and row heights — scaled to the picture's frame, and
|
|
5
|
+
// redraws whenever the cells it reads change (the host hands a new source
|
|
6
|
+
// accessor on every data change).
|
|
7
|
+
//
|
|
8
|
+
// The cell drawing reuses the print renderer's HTML cell styling
|
|
9
|
+
// (`cellInlineStyle` / `describePrintCell`) so a linked picture, a printed page
|
|
10
|
+
// and the canvas agree on what a cell looks like.
|
|
11
|
+
import { cellToAddress, sanitizeSheetName } from "@rowsncolumns/utils";
|
|
12
|
+
import React, { memo, useMemo } from "react";
|
|
13
|
+
import { cellInlineStyle } from "../print-preview/cell-styles";
|
|
14
|
+
import { describePrintCell } from "../print-preview/print-cells";
|
|
15
|
+
export const isLinkedPictureSpec = (spec) => spec?.type === "linkedPicture";
|
|
16
|
+
/**
|
|
17
|
+
* A linked picture's formula as Excel shows it in the formula bar while the
|
|
18
|
+
* picture is selected: `=$A$1:$C$5` on its own sheet, `=Sheet1!$A$1:$C$5` /
|
|
19
|
+
* `='My Data'!$A$1:$C$5` on another, `=#REF!` once its source was deleted.
|
|
20
|
+
*/
|
|
21
|
+
export const linkedPictureFormula = (sourceRange, pictureSheetId, getSheetName) => {
|
|
22
|
+
if (!sourceRange)
|
|
23
|
+
return "=#REF!";
|
|
24
|
+
const start = cellToAddress({
|
|
25
|
+
rowIndex: sourceRange.startRowIndex,
|
|
26
|
+
columnIndex: sourceRange.startColumnIndex,
|
|
27
|
+
}, true, true);
|
|
28
|
+
const single = sourceRange.startRowIndex === sourceRange.endRowIndex &&
|
|
29
|
+
sourceRange.startColumnIndex === sourceRange.endColumnIndex;
|
|
30
|
+
const end = single
|
|
31
|
+
? ""
|
|
32
|
+
: `:${cellToAddress({
|
|
33
|
+
rowIndex: sourceRange.endRowIndex,
|
|
34
|
+
columnIndex: sourceRange.endColumnIndex,
|
|
35
|
+
}, true, true)}`;
|
|
36
|
+
if (sourceRange.sheetId === pictureSheetId)
|
|
37
|
+
return `=${start}${end}`;
|
|
38
|
+
const name = getSheetName?.(sourceRange.sheetId);
|
|
39
|
+
if (name === undefined)
|
|
40
|
+
return "=#REF!";
|
|
41
|
+
return `=${sanitizeSheetName(name)}!${start}${end}`;
|
|
42
|
+
};
|
|
43
|
+
const dimensionSize = (meta, fallback) => meta?.hiddenByUser || meta?.hiddenByFilter || meta?.hiddenByGroup
|
|
44
|
+
? 0
|
|
45
|
+
: meta?.size ?? fallback;
|
|
46
|
+
/**
|
|
47
|
+
* A {@link GetLinkedPictureSource} over the host's sheet list and its
|
|
48
|
+
* workbook-wide cell accessors (`useSpreadsheetState`'s): a picture of any
|
|
49
|
+
* sheet reads that sheet's sizes, merges and gridline setting.
|
|
50
|
+
*/
|
|
51
|
+
export const createLinkedPictureSourceResolver = ({ sheets, getFormattedValue, getEffectiveFormat, getCellData, defaultRowHeight, defaultColumnWidth, }) => {
|
|
52
|
+
return (range) => {
|
|
53
|
+
const sheet = sheets?.find((s) => s.sheetId === range.sheetId);
|
|
54
|
+
if (!sheet)
|
|
55
|
+
return undefined;
|
|
56
|
+
const sheetId = range.sheetId;
|
|
57
|
+
const rowFallback = sheet.defaultRowHeight ?? defaultRowHeight;
|
|
58
|
+
const columnFallback = sheet.defaultColumnWidth ?? defaultColumnWidth;
|
|
59
|
+
return {
|
|
60
|
+
getFormattedValue: (r, c) => getFormattedValue?.(sheetId, r, c),
|
|
61
|
+
getEffectiveFormat: (r, c) => getEffectiveFormat?.(sheetId, r, c),
|
|
62
|
+
getCellData: getCellData
|
|
63
|
+
? (r, c) => getCellData(sheetId, r, c)
|
|
64
|
+
: undefined,
|
|
65
|
+
getRowHeight: (r) => dimensionSize(sheet.rowMetadata?.[r], rowFallback),
|
|
66
|
+
getColumnWidth: (c) => dimensionSize(sheet.columnMetadata?.[c], columnFallback),
|
|
67
|
+
merges: sheet.merges,
|
|
68
|
+
showGridLines: sheet.showGridLines ?? true,
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
const GRIDLINE_COLOR = "#e2e2e3";
|
|
73
|
+
/**
|
|
74
|
+
* Draw a linked picture: the source range as a table at its natural size,
|
|
75
|
+
* stretched to the frame. A deleted source (`#REF!`) or one this host cannot
|
|
76
|
+
* read draws blank, as Excel's picture does.
|
|
77
|
+
*/
|
|
78
|
+
export const LinkedPictureView = memo(({ sourceRange, source, width, height }) => {
|
|
79
|
+
const layout = useMemo(() => {
|
|
80
|
+
if (!sourceRange || !source)
|
|
81
|
+
return undefined;
|
|
82
|
+
const rows = [];
|
|
83
|
+
for (let r = sourceRange.startRowIndex; r <= sourceRange.endRowIndex; r++) {
|
|
84
|
+
const size = source.getRowHeight(r);
|
|
85
|
+
if (size > 0)
|
|
86
|
+
rows.push({ index: r, size });
|
|
87
|
+
}
|
|
88
|
+
const columns = [];
|
|
89
|
+
for (let c = sourceRange.startColumnIndex; c <= sourceRange.endColumnIndex; c++) {
|
|
90
|
+
const size = source.getColumnWidth(c);
|
|
91
|
+
if (size > 0)
|
|
92
|
+
columns.push({ index: c, size });
|
|
93
|
+
}
|
|
94
|
+
// Merges clipped to the picture: the anchor renders with a span, the
|
|
95
|
+
// cells it covers are skipped (Excel paints the merge from its top-left).
|
|
96
|
+
const skip = new Set();
|
|
97
|
+
const spans = new Map();
|
|
98
|
+
const visibleRows = new Set(rows.map((r) => r.index));
|
|
99
|
+
const visibleColumns = new Set(columns.map((c) => c.index));
|
|
100
|
+
for (const m of source.merges ?? []) {
|
|
101
|
+
const r0 = Math.max(m.startRowIndex, sourceRange.startRowIndex);
|
|
102
|
+
const r1 = Math.min(m.endRowIndex, sourceRange.endRowIndex);
|
|
103
|
+
const c0 = Math.max(m.startColumnIndex, sourceRange.startColumnIndex);
|
|
104
|
+
const c1 = Math.min(m.endColumnIndex, sourceRange.endColumnIndex);
|
|
105
|
+
if (r0 > r1 || c0 > c1)
|
|
106
|
+
continue;
|
|
107
|
+
let anchor;
|
|
108
|
+
let rowSpan = 0;
|
|
109
|
+
let colSpan = 0;
|
|
110
|
+
for (let r = r0; r <= r1; r++)
|
|
111
|
+
if (visibleRows.has(r))
|
|
112
|
+
rowSpan++;
|
|
113
|
+
for (let c = c0; c <= c1; c++)
|
|
114
|
+
if (visibleColumns.has(c))
|
|
115
|
+
colSpan++;
|
|
116
|
+
for (let r = r0; r <= r1; r++) {
|
|
117
|
+
if (!visibleRows.has(r))
|
|
118
|
+
continue;
|
|
119
|
+
for (let c = c0; c <= c1; c++) {
|
|
120
|
+
if (!visibleColumns.has(c))
|
|
121
|
+
continue;
|
|
122
|
+
const key = `${r}:${c}`;
|
|
123
|
+
if (anchor === undefined) {
|
|
124
|
+
anchor = key;
|
|
125
|
+
spans.set(key, { rowSpan, colSpan });
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
skip.add(key);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
rows,
|
|
135
|
+
columns,
|
|
136
|
+
skip,
|
|
137
|
+
spans,
|
|
138
|
+
width: columns.reduce((sum, c) => sum + c.size, 0),
|
|
139
|
+
height: rows.reduce((sum, r) => sum + r.size, 0),
|
|
140
|
+
};
|
|
141
|
+
}, [sourceRange, source]);
|
|
142
|
+
const frame = {
|
|
143
|
+
position: "relative",
|
|
144
|
+
width,
|
|
145
|
+
height,
|
|
146
|
+
overflow: "hidden",
|
|
147
|
+
backgroundColor: "white",
|
|
148
|
+
};
|
|
149
|
+
if (!layout || !source || layout.width === 0 || layout.height === 0) {
|
|
150
|
+
return React.createElement("div", { "data-linked-picture": "blank", style: frame });
|
|
151
|
+
}
|
|
152
|
+
const showGridLines = source.showGridLines ?? true;
|
|
153
|
+
const table = {
|
|
154
|
+
borderCollapse: "collapse",
|
|
155
|
+
tableLayout: "fixed",
|
|
156
|
+
width: layout.width,
|
|
157
|
+
height: layout.height,
|
|
158
|
+
fontFamily: "Arial, sans-serif",
|
|
159
|
+
fontSize: 12,
|
|
160
|
+
color: "#000",
|
|
161
|
+
transform: `scale(${width / layout.width}, ${height / layout.height})`,
|
|
162
|
+
transformOrigin: "0 0",
|
|
163
|
+
pointerEvents: "none",
|
|
164
|
+
};
|
|
165
|
+
return (React.createElement("div", { "data-linked-picture": "live", style: frame },
|
|
166
|
+
React.createElement("table", { style: table },
|
|
167
|
+
React.createElement("colgroup", null, layout.columns.map((c) => (React.createElement("col", { key: c.index, style: { width: c.size } })))),
|
|
168
|
+
React.createElement("tbody", null, layout.rows.map((row) => (React.createElement("tr", { key: row.index, style: { height: row.size } }, layout.columns.map((column) => {
|
|
169
|
+
const key = `${row.index}:${column.index}`;
|
|
170
|
+
if (layout.skip.has(key))
|
|
171
|
+
return null;
|
|
172
|
+
const span = layout.spans.get(key);
|
|
173
|
+
const format = source.getEffectiveFormat(row.index, column.index);
|
|
174
|
+
const value = source.getFormattedValue(row.index, column.index) ?? "";
|
|
175
|
+
const info = describePrintCell(source.getCellData?.(row.index, column.index), value);
|
|
176
|
+
const alignment = format?.horizontalAlignment ?? info.defaultAlignment;
|
|
177
|
+
const style = {
|
|
178
|
+
...cellInlineStyle(format, false),
|
|
179
|
+
...(alignment === "right" || alignment === "center"
|
|
180
|
+
? { textAlign: alignment }
|
|
181
|
+
: null),
|
|
182
|
+
};
|
|
183
|
+
if (showGridLines) {
|
|
184
|
+
// Gridlines sit under any explicit border, as on the sheet.
|
|
185
|
+
style.borderTop ??= `1px solid ${GRIDLINE_COLOR}`;
|
|
186
|
+
style.borderRight ??= `1px solid ${GRIDLINE_COLOR}`;
|
|
187
|
+
style.borderBottom ??= `1px solid ${GRIDLINE_COLOR}`;
|
|
188
|
+
style.borderLeft ??= `1px solid ${GRIDLINE_COLOR}`;
|
|
189
|
+
}
|
|
190
|
+
return (React.createElement("td", { key: key, "data-cell": key, rowSpan: span?.rowSpan, colSpan: span?.colSpan, style: style }, info.imageUrl ? (React.createElement("img", { src: info.imageUrl, alt: "", style: { width: "100%", height: "100%", objectFit: "contain" } })) : (value)));
|
|
191
|
+
}))))))));
|
|
192
|
+
});
|
|
193
|
+
LinkedPictureView.displayName = "LinkedPictureView";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/outline-gutter/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/outline-gutter/index.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAA0D,MAAM,OAAO,CAAC;AAE/E,OAAO,EACL,oBAAoB,EAKpB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAwDvD,KAAK,iBAAiB,GAClB,CAAC,mBAAmB,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,GAC1C,IAAI,GACJ,SAAS,CAAC;AAgGd,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,iBAAiB,CAAC;IACnC;;wEAEoE;IACpE,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,kEAAkE;IAClE,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,qBAAqB,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1E,mBAAmB,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IACxE;kCAC8B;IAC9B,iBAAiB,CAAC,CAChB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,KAAK,GAAG,QAAQ,EACtB,KAAK,EAAE,MAAM,GACZ,IAAI,CAAC;CACT,CAAC;AAEF,eAAO,MAAM,mBAAmB,qJAS3B,wBAAwB,8BA8N5B,CAAC;AAGF,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,+DAA+D;IAC/D,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,kBAAkB,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IACpE,gBAAgB,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAClE;6DACyD;IACzD,iBAAiB,CAAC,CAChB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,KAAK,GAAG,QAAQ,EACtB,KAAK,EAAE,MAAM,GACZ,IAAI,CAAC;CACT,CAAC;AAEF,eAAO,MAAM,gBAAgB,+HAQxB,qBAAqB,8BA4MzB,CAAC;AAGF;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,GACnC,UAAU,CAAC,mBAAmB,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,GAAG,IAAI,GAAG,SAAS,KACtE,MAIF,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -19,52 +19,63 @@
|
|
|
19
19
|
//
|
|
20
20
|
// Bracket lines and the "1 / 2 / 3" level bar are intentionally minimal
|
|
21
21
|
// here — the goal is a functional MVP. Polish can layer on later.
|
|
22
|
+
import { MinusIcon, PlusIcon } from "@rowsncolumns/icons";
|
|
23
|
+
import { Button } from "@rowsncolumns/ui";
|
|
22
24
|
import React, { memo, useCallback, useEffect, useMemo, useState } from "react";
|
|
23
25
|
import { COLUMN_HEADER_HEIGHT, DEFAULT_COLUMN_WIDTH, DEFAULT_ROW_HEIGHT, OUTLINE_GUTTER_LEVEL_PX, OUTLINE_GUTTER_PAD_PX, ROW_HEADER_WIDTH, } from "../../config";
|
|
26
|
+
import { useResizeObserver } from "../../hooks/use-resize-observer";
|
|
24
27
|
import { scrollSubscriber } from "../../signals/scroll-subscriber";
|
|
25
|
-
import {
|
|
26
|
-
import { MinusIcon, PlusIcon } from "@rowsncolumns/icons";
|
|
28
|
+
import { buildOffsetIndex, cellAtOffset, offsetAt, sizeAt } from "./offsets";
|
|
27
29
|
/**
|
|
28
|
-
*
|
|
29
|
-
* (
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*/
|
|
34
|
-
const computeOffset = (metadata, index, defaultSize) => {
|
|
35
|
-
if (index <= 1)
|
|
36
|
-
return 0;
|
|
37
|
-
let offset = 0;
|
|
38
|
-
for (let i = 1; i < index; i++) {
|
|
39
|
-
const meta = metadata?.[i];
|
|
40
|
-
const hidden = !!(meta?.hiddenByUser ||
|
|
41
|
-
meta?.hiddenByFilter ||
|
|
42
|
-
meta?.hiddenByGroup);
|
|
43
|
-
if (hidden)
|
|
44
|
-
continue;
|
|
45
|
-
offset += meta?.size ?? defaultSize;
|
|
46
|
-
}
|
|
47
|
-
return offset;
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* Track the grid's live scroll position and re-render on every update.
|
|
51
|
-
* Subscribes to `scrollSubscriber` (the rxjs Subject CanvasGrid emits
|
|
52
|
-
* to inside `handleScroll`). Used by the outline gutters so they slide
|
|
53
|
-
* in sync with the canvas.
|
|
30
|
+
* Track the grid's live scroll position. Subscribes to
|
|
31
|
+
* `scrollSubscriber` (the rxjs Subject CanvasGrid emits to inside
|
|
32
|
+
* `handleScroll`) and coalesces updates to one re-render per animation
|
|
33
|
+
* frame — the grid can emit several scroll events per frame. Used by
|
|
34
|
+
* the outline gutters so they slide in sync with the canvas.
|
|
54
35
|
*/
|
|
55
36
|
const useGridScrollPosition = () => {
|
|
56
37
|
const [scroll, setScroll] = useState({ scrollTop: 0, scrollLeft: 0 });
|
|
57
38
|
useEffect(() => {
|
|
39
|
+
let frame = null;
|
|
40
|
+
let pending = { scrollTop: 0, scrollLeft: 0 };
|
|
41
|
+
const flush = () => {
|
|
42
|
+
frame = null;
|
|
43
|
+
setScroll((prev) => prev.scrollTop === pending.scrollTop &&
|
|
44
|
+
prev.scrollLeft === pending.scrollLeft
|
|
45
|
+
? prev
|
|
46
|
+
: pending);
|
|
47
|
+
};
|
|
58
48
|
const sub = scrollSubscriber.subscribe((pos) => {
|
|
59
|
-
|
|
49
|
+
pending = {
|
|
60
50
|
scrollTop: pos.scrollTop ?? 0,
|
|
61
51
|
scrollLeft: pos.scrollLeft ?? 0,
|
|
62
|
-
}
|
|
52
|
+
};
|
|
53
|
+
if (typeof requestAnimationFrame === "undefined")
|
|
54
|
+
flush();
|
|
55
|
+
else if (frame === null)
|
|
56
|
+
frame = requestAnimationFrame(flush);
|
|
63
57
|
});
|
|
64
|
-
return () =>
|
|
58
|
+
return () => {
|
|
59
|
+
sub.unsubscribe();
|
|
60
|
+
if (frame !== null)
|
|
61
|
+
cancelAnimationFrame(frame);
|
|
62
|
+
};
|
|
65
63
|
}, []);
|
|
66
64
|
return scroll;
|
|
67
65
|
};
|
|
66
|
+
/**
|
|
67
|
+
* Length (px) of the gutter strip along its scrolling axis. Falls back
|
|
68
|
+
* to the window size until the strip has been measured (and during
|
|
69
|
+
* SSR), so the first paint is already bounded to roughly one screen.
|
|
70
|
+
*/
|
|
71
|
+
const FALLBACK_VIEWPORT_PX = 2000;
|
|
72
|
+
const resolveViewportSize = (measured, fallback) => measured > 0
|
|
73
|
+
? measured
|
|
74
|
+
: fallback && fallback > 0
|
|
75
|
+
? fallback
|
|
76
|
+
: FALLBACK_VIEWPORT_PX;
|
|
77
|
+
/** Extra cells rendered past each viewport edge. */
|
|
78
|
+
const OVERSCAN_CELLS = 1;
|
|
68
79
|
/**
|
|
69
80
|
* Walk the dimension's outline levels and emit a summary marker for
|
|
70
81
|
* each (nested) group. A summary is the cell ADJACENT to the group
|
|
@@ -154,9 +165,10 @@ export const ColumnOutlineGutter = memo(({ sheetId, columnMetadata, rowMetadata,
|
|
|
154
165
|
// sits to the right of the row gutter).
|
|
155
166
|
const leftInset = useMemo(() => computeOutlineGutterSize(rowMetadata), [rowMetadata]);
|
|
156
167
|
const maxColumnOutlineLevel = useMemo(() => computeMaxOutlineLevel(columnMetadata), [columnMetadata]);
|
|
157
|
-
const
|
|
158
|
-
|
|
168
|
+
const columnOffsets = useMemo(() => buildOffsetIndex(columnMetadata, DEFAULT_COLUMN_WIDTH), [columnMetadata]);
|
|
169
|
+
const getColumnOffset = useCallback((columnIndex) => offsetAt(columnOffsets, columnIndex) + ROW_HEADER_WIDTH, [columnOffsets]);
|
|
159
170
|
const { scrollLeft } = useGridScrollPosition();
|
|
171
|
+
const [stripRef, stripRect] = useResizeObserver();
|
|
160
172
|
const summaries = useMemo(() => maxColumnOutlineLevel > 0
|
|
161
173
|
? findSummaries(columnMetadata, summaryRight)
|
|
162
174
|
: [], [columnMetadata, maxColumnOutlineLevel, summaryRight]);
|
|
@@ -188,7 +200,15 @@ export const ColumnOutlineGutter = memo(({ sheetId, columnMetadata, rowMetadata,
|
|
|
188
200
|
// to this boundary so they never bleed into the level-selector
|
|
189
201
|
// lane or the row-header column above the grid.
|
|
190
202
|
const summaryMinX = leftInset + ROW_HEADER_WIDTH;
|
|
191
|
-
|
|
203
|
+
// Right edge of the strip in its own coord space. Anything past it
|
|
204
|
+
// is clipped by `overflow-hidden`, so it is never rendered.
|
|
205
|
+
const viewportMaxX = leftInset +
|
|
206
|
+
resolveViewportSize(stripRect.width, typeof window === "undefined" ? undefined : window.innerWidth);
|
|
207
|
+
// Columns intersecting the strip, for the per-column dots.
|
|
208
|
+
const firstVisibleColumn = Math.max(1, cellAtOffset(columnOffsets, scrollLeft) - OVERSCAN_CELLS);
|
|
209
|
+
const lastVisibleColumn = cellAtOffset(columnOffsets, scrollLeft + viewportMaxX - summaryMinX) +
|
|
210
|
+
OVERSCAN_CELLS;
|
|
211
|
+
return (React.createElement("div", { ref: stripRef, "data-testid": "column-outline-gutter", className: "bg-rnc-background relative overflow-hidden border-l border-r border-r-rnc-border border-l-rnc-border border-solid border-t-rnc-border border-t border-b-0", style: {
|
|
192
212
|
height: gutterHeight,
|
|
193
213
|
paddingLeft: leftInset,
|
|
194
214
|
} },
|
|
@@ -205,6 +225,9 @@ export const ColumnOutlineGutter = memo(({ sheetId, columnMetadata, rowMetadata,
|
|
|
205
225
|
// x=0 of the strip lines up with the grid's content origin.
|
|
206
226
|
const buttonX = getColumnOffset(index) - scrollLeft + leftInset;
|
|
207
227
|
const lineStartX = getColumnOffset(startIndex) - scrollLeft + leftInset + 2;
|
|
228
|
+
// The whole group sits right of the strip: nothing to paint.
|
|
229
|
+
if (Math.min(buttonX, lineStartX) > viewportMaxX)
|
|
230
|
+
return null;
|
|
208
231
|
const y = (level - 1) * OUTLINE_GUTTER_LEVEL_PX + OUTLINE_GUTTER_PAD_PX / 2;
|
|
209
232
|
const lineCenterY = y + 6;
|
|
210
233
|
// Gap (in px) the bracket line should leave before the
|
|
@@ -213,15 +236,20 @@ export const ColumnOutlineGutter = memo(({ sheetId, columnMetadata, rowMetadata,
|
|
|
213
236
|
// Length of the small downward "hook" tick at the start of
|
|
214
237
|
// the bracket (matches Excel's outline visual).
|
|
215
238
|
const hookLength = 4;
|
|
216
|
-
// One small dot per grouped column, centered on each
|
|
217
|
-
// and aligned with the bracket line (Excel's outline
|
|
239
|
+
// One small dot per visible grouped column, centered on each
|
|
240
|
+
// cell and aligned with the bracket line (Excel's outline
|
|
241
|
+
// visual). Only columns inside the strip are walked; hidden
|
|
242
|
+
// (zero-width) columns get no dot.
|
|
218
243
|
const childIndices = [];
|
|
219
244
|
if (!collapsed) {
|
|
220
245
|
const [from, to] = summaryRight
|
|
221
246
|
? [startIndex, index - 1]
|
|
222
247
|
: [index + 1, startIndex];
|
|
223
|
-
|
|
224
|
-
|
|
248
|
+
const end = Math.min(to, lastVisibleColumn);
|
|
249
|
+
for (let c = Math.max(from, firstVisibleColumn); c <= end; c++) {
|
|
250
|
+
if (sizeAt(columnOffsets, c) > 0)
|
|
251
|
+
childIndices.push(c);
|
|
252
|
+
}
|
|
225
253
|
}
|
|
226
254
|
const showSummary = buttonX >= summaryMinX;
|
|
227
255
|
// Clip the bracket line / hook / dots to the level-selector
|
|
@@ -273,9 +301,10 @@ ColumnOutlineGutter.displayName = "ColumnOutlineGutter";
|
|
|
273
301
|
export const RowOutlineGutter = memo(({ sheetId, rowMetadata, summaryBelow = true, onCollapseRowGroup, onExpandRowGroup, onSetOutlineDepth, }) => {
|
|
274
302
|
const topInset = 0;
|
|
275
303
|
const maxRowOutlineLevel = useMemo(() => computeMaxOutlineLevel(rowMetadata), [rowMetadata]);
|
|
276
|
-
const
|
|
277
|
-
|
|
304
|
+
const rowOffsets = useMemo(() => buildOffsetIndex(rowMetadata, DEFAULT_ROW_HEIGHT), [rowMetadata]);
|
|
305
|
+
const getRowOffset = useCallback((rowIndex) => offsetAt(rowOffsets, rowIndex) + COLUMN_HEADER_HEIGHT, [rowOffsets]);
|
|
278
306
|
const { scrollTop } = useGridScrollPosition();
|
|
307
|
+
const [stripRef, stripRect] = useResizeObserver();
|
|
279
308
|
const summaries = useMemo(() => maxRowOutlineLevel > 0 ? findSummaries(rowMetadata, summaryBelow) : [], [rowMetadata, maxRowOutlineLevel, summaryBelow]);
|
|
280
309
|
// Dedup buttons by index (outermost level wins) — matches Excel.
|
|
281
310
|
// See the matching `ColumnOutlineGutter` block for the rationale.
|
|
@@ -301,7 +330,15 @@ export const RowOutlineGutter = memo(({ sheetId, rowMetadata, summaryBelow = tru
|
|
|
301
330
|
// to this boundary so they never bleed into the level-selector
|
|
302
331
|
// row or the column-header band beside the grid.
|
|
303
332
|
const summaryMinY = topInset + COLUMN_HEADER_HEIGHT;
|
|
304
|
-
|
|
333
|
+
// Bottom edge of the strip in its own coord space. Anything below
|
|
334
|
+
// it is clipped by `overflow-hidden`, so it is never rendered.
|
|
335
|
+
const viewportMaxY = topInset +
|
|
336
|
+
resolveViewportSize(stripRect.height, typeof window === "undefined" ? undefined : window.innerHeight);
|
|
337
|
+
// Rows intersecting the strip, for the per-row dots.
|
|
338
|
+
const firstVisibleRow = Math.max(1, cellAtOffset(rowOffsets, scrollTop) - OVERSCAN_CELLS);
|
|
339
|
+
const lastVisibleRow = cellAtOffset(rowOffsets, scrollTop + viewportMaxY - summaryMinY) +
|
|
340
|
+
OVERSCAN_CELLS;
|
|
341
|
+
return (React.createElement("div", { ref: stripRef, "data-testid": "row-outline-gutter", className: "bg-rnc-background relative overflow-hidden border-t border-b border-t-rnc-border border-b-rnc-border border-solid border-l-rnc-border border-l border-r-0", style: {
|
|
305
342
|
width: gutterWidth,
|
|
306
343
|
paddingTop: topInset,
|
|
307
344
|
} },
|
|
@@ -316,6 +353,9 @@ export const RowOutlineGutter = memo(({ sheetId, rowMetadata, summaryBelow = tru
|
|
|
316
353
|
summaries.map(({ index, startIndex, collapsed, level }) => {
|
|
317
354
|
const buttonY = getRowOffset(index) - scrollTop + topInset;
|
|
318
355
|
const lineStartY = getRowOffset(startIndex) - scrollTop + topInset + 2;
|
|
356
|
+
// The whole group sits below the strip: nothing to paint.
|
|
357
|
+
if (Math.min(buttonY, lineStartY) > viewportMaxY)
|
|
358
|
+
return null;
|
|
319
359
|
const x = (level - 1) * OUTLINE_GUTTER_LEVEL_PX + OUTLINE_GUTTER_PAD_PX / 2;
|
|
320
360
|
const lineCenterX = x + 6;
|
|
321
361
|
// Gap before the button + length of the rightward "hook"
|
|
@@ -323,15 +363,20 @@ export const RowOutlineGutter = memo(({ sheetId, rowMetadata, summaryBelow = tru
|
|
|
323
363
|
// row axis is just the column axis rotated 90°).
|
|
324
364
|
const lineButtonGap = 4;
|
|
325
365
|
const hookLength = 4;
|
|
326
|
-
// One small dot per grouped row, centered on each
|
|
327
|
-
// aligned with the bracket line (Excel's outline
|
|
366
|
+
// One small dot per visible grouped row, centered on each
|
|
367
|
+
// row and aligned with the bracket line (Excel's outline
|
|
368
|
+
// visual). Only rows inside the strip are walked; hidden
|
|
369
|
+
// (zero-height) rows get no dot.
|
|
328
370
|
const childIndices = [];
|
|
329
371
|
if (!collapsed) {
|
|
330
372
|
const [from, to] = summaryBelow
|
|
331
373
|
? [startIndex, index - 1]
|
|
332
374
|
: [index + 1, startIndex];
|
|
333
|
-
|
|
334
|
-
|
|
375
|
+
const end = Math.min(to, lastVisibleRow);
|
|
376
|
+
for (let c = Math.max(from, firstVisibleRow); c <= end; c++) {
|
|
377
|
+
if (sizeAt(rowOffsets, c) > 0)
|
|
378
|
+
childIndices.push(c);
|
|
379
|
+
}
|
|
335
380
|
}
|
|
336
381
|
const showSummary = buttonY >= summaryMinY;
|
|
337
382
|
// Clip the bracket line / hook / dots to the level-selector
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { DimensionProperties } from "../../types";
|
|
2
|
+
type DimensionMetadata = (DimensionProperties | null | undefined)[] | null | undefined;
|
|
3
|
+
/**
|
|
4
|
+
* Prefix sums of cell sizes along one axis, so the outline gutters can
|
|
5
|
+
* look up a cell's pixel offset in O(1) and the cell at an offset in
|
|
6
|
+
* O(log n) instead of walking the metadata on every call.
|
|
7
|
+
*
|
|
8
|
+
* `prefix[i]` is the offset of cell `i` from the first DATA cell
|
|
9
|
+
* (index 1): the summed size of cells `1..i-1`. Hidden cells
|
|
10
|
+
* (`hiddenByUser` / `hiddenByFilter` / `hiddenByGroup`) contribute 0.
|
|
11
|
+
* Cells past the end of the metadata array use `defaultSize`.
|
|
12
|
+
*/
|
|
13
|
+
export type OffsetIndex = {
|
|
14
|
+
prefix: Float64Array;
|
|
15
|
+
/** Number of stored prefix entries minus one (>= 1). */
|
|
16
|
+
last: number;
|
|
17
|
+
defaultSize: number;
|
|
18
|
+
};
|
|
19
|
+
export declare const isHiddenDimension: (meta: DimensionProperties | null | undefined) => boolean;
|
|
20
|
+
export declare const buildOffsetIndex: (metadata: DimensionMetadata, defaultSize: number) => OffsetIndex;
|
|
21
|
+
/** Pixel offset of cell `index` from the first data cell. */
|
|
22
|
+
export declare const offsetAt: (index: OffsetIndex, cell: number) => number;
|
|
23
|
+
/** Rendered size of cell `cell` (0 when hidden). */
|
|
24
|
+
export declare const sizeAt: (index: OffsetIndex, cell: number) => number;
|
|
25
|
+
/**
|
|
26
|
+
* Largest cell index `>= 1` whose offset is `<= offset` — i.e. the
|
|
27
|
+
* visible cell that covers `offset` (hidden cells before it share its
|
|
28
|
+
* offset, so the largest index is the one actually painted there).
|
|
29
|
+
*/
|
|
30
|
+
export declare const cellAtOffset: (index: OffsetIndex, offset: number) => number;
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=offsets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"offsets.d.ts","sourceRoot":"","sources":["../../../../components/outline-gutter/offsets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,KAAK,iBAAiB,GAClB,CAAC,mBAAmB,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,GAC1C,IAAI,GACJ,SAAS,CAAC;AAEd;;;;;;;;;GASG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,YAAY,CAAC;IACrB,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,MAAM,mBAAmB,GAAG,IAAI,GAAG,SAAS,KAC3C,OACoE,CAAC;AAExE,eAAO,MAAM,gBAAgB,GAC3B,UAAU,iBAAiB,EAC3B,aAAa,MAAM,KAClB,WAUF,CAAC;AAEF,6DAA6D;AAC7D,eAAO,MAAM,QAAQ,GAAI,OAAO,WAAW,EAAE,MAAM,MAAM,KAAG,MAI3D,CAAC;AAEF,oDAAoD;AACpD,eAAO,MAAM,MAAM,GAAI,OAAO,WAAW,EAAE,MAAM,MAAM,KAAG,MACP,CAAC;AAEpD;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,WAAW,EAAE,QAAQ,MAAM,KAAG,MAcjE,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export const isHiddenDimension = (meta) => !!(meta?.hiddenByUser || meta?.hiddenByFilter || meta?.hiddenByGroup);
|
|
2
|
+
export const buildOffsetIndex = (metadata, defaultSize) => {
|
|
3
|
+
const last = Math.max(metadata?.length ?? 0, 1);
|
|
4
|
+
const prefix = new Float64Array(last + 1);
|
|
5
|
+
let offset = 0;
|
|
6
|
+
for (let i = 1; i <= last; i++) {
|
|
7
|
+
prefix[i] = offset;
|
|
8
|
+
const meta = metadata?.[i];
|
|
9
|
+
if (!isHiddenDimension(meta))
|
|
10
|
+
offset += meta?.size ?? defaultSize;
|
|
11
|
+
}
|
|
12
|
+
return { prefix, last, defaultSize };
|
|
13
|
+
};
|
|
14
|
+
/** Pixel offset of cell `index` from the first data cell. */
|
|
15
|
+
export const offsetAt = (index, cell) => {
|
|
16
|
+
if (cell <= 1)
|
|
17
|
+
return 0;
|
|
18
|
+
if (cell <= index.last)
|
|
19
|
+
return index.prefix[cell];
|
|
20
|
+
return index.prefix[index.last] + (cell - index.last) * index.defaultSize;
|
|
21
|
+
};
|
|
22
|
+
/** Rendered size of cell `cell` (0 when hidden). */
|
|
23
|
+
export const sizeAt = (index, cell) => offsetAt(index, cell + 1) - offsetAt(index, cell);
|
|
24
|
+
/**
|
|
25
|
+
* Largest cell index `>= 1` whose offset is `<= offset` — i.e. the
|
|
26
|
+
* visible cell that covers `offset` (hidden cells before it share its
|
|
27
|
+
* offset, so the largest index is the one actually painted there).
|
|
28
|
+
*/
|
|
29
|
+
export const cellAtOffset = (index, offset) => {
|
|
30
|
+
const { prefix, last, defaultSize } = index;
|
|
31
|
+
if (offset <= 0)
|
|
32
|
+
return 1;
|
|
33
|
+
if (offset >= prefix[last]) {
|
|
34
|
+
return last + Math.floor((offset - prefix[last]) / defaultSize);
|
|
35
|
+
}
|
|
36
|
+
let lo = 1;
|
|
37
|
+
let hi = last - 1;
|
|
38
|
+
while (lo < hi) {
|
|
39
|
+
const mid = (lo + hi + 1) >>> 1;
|
|
40
|
+
if (prefix[mid] <= offset)
|
|
41
|
+
lo = mid;
|
|
42
|
+
else
|
|
43
|
+
hi = mid - 1;
|
|
44
|
+
}
|
|
45
|
+
return lo;
|
|
46
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { SheetPrintSettings } from "../../types";
|
|
2
|
+
/** Desk shown between two pages and around the first one, in paper px. */
|
|
3
|
+
export declare const PAGE_LAYOUT_DESK_GAP = 12;
|
|
4
|
+
/** Height of the horizontal ruler / width of the vertical ruler, in paper px. */
|
|
5
|
+
export declare const PAGE_LAYOUT_RULER_SIZE = 18;
|
|
6
|
+
export type PageLayoutBand = {
|
|
7
|
+
/** First and last row (or column) on the page, 1-based inclusive. */
|
|
8
|
+
start: number;
|
|
9
|
+
end: number;
|
|
10
|
+
/** Paper px the band's rows (or columns) take at the print scale. */
|
|
11
|
+
size: number;
|
|
12
|
+
};
|
|
13
|
+
export type PageLayoutPage = {
|
|
14
|
+
rowBand: number;
|
|
15
|
+
columnBand: number;
|
|
16
|
+
/** Print order among the printed pages, 1-based. */
|
|
17
|
+
ordinal: number;
|
|
18
|
+
};
|
|
19
|
+
export type SheetPageLayout = {
|
|
20
|
+
/** Print scale (1 = 100 %): the sheet is drawn at zoom × `scale`. */
|
|
21
|
+
scale: number;
|
|
22
|
+
/** The paper in paper px (orientation applied). */
|
|
23
|
+
paper: {
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
|
+
};
|
|
27
|
+
/** Margins in paper px; `header` / `footer` are the header and footer distances from the edge. */
|
|
28
|
+
margins: {
|
|
29
|
+
top: number;
|
|
30
|
+
bottom: number;
|
|
31
|
+
left: number;
|
|
32
|
+
right: number;
|
|
33
|
+
header: number;
|
|
34
|
+
footer: number;
|
|
35
|
+
};
|
|
36
|
+
/** The printable box inside the margins, in paper px. */
|
|
37
|
+
content: {
|
|
38
|
+
width: number;
|
|
39
|
+
height: number;
|
|
40
|
+
};
|
|
41
|
+
/** Desk between pages (paper px) and whether rulers are drawn in it. */
|
|
42
|
+
deskGap: number;
|
|
43
|
+
rulers: boolean;
|
|
44
|
+
/** Row / column bands: each page is one row band × one column band. */
|
|
45
|
+
rowBands: PageLayoutBand[];
|
|
46
|
+
columnBands: PageLayoutBand[];
|
|
47
|
+
/** The printed pages (inside the print area, else the used range), in print order. */
|
|
48
|
+
pages: PageLayoutPage[];
|
|
49
|
+
/** Number of printed pages (`&[Pages]`). */
|
|
50
|
+
pageCount: number;
|
|
51
|
+
/** `&[Page]` of the first printed page (`<pageSetup firstPageNumber>`). */
|
|
52
|
+
firstPageNumber: number;
|
|
53
|
+
/**
|
|
54
|
+
* Sheet px the grid leaves empty before a row / column (`Grid`'s
|
|
55
|
+
* `getRowGap` / `getColumnGap`): the leftover of the previous page, its
|
|
56
|
+
* bottom (right) margin, the desk and this page's top (left) margin.
|
|
57
|
+
*/
|
|
58
|
+
getRowGap: (rowIndex: number) => number;
|
|
59
|
+
getColumnGap: (columnIndex: number) => number;
|
|
60
|
+
/** The row / column band a 1-based row / column falls in (-1 outside the sheet). */
|
|
61
|
+
rowBandOf: (rowIndex: number) => number;
|
|
62
|
+
columnBandOf: (columnIndex: number) => number;
|
|
63
|
+
/** The printed page at a band pair, if that page prints. */
|
|
64
|
+
pageAt: (rowBand: number, columnBand: number) => PageLayoutPage | undefined;
|
|
65
|
+
};
|
|
66
|
+
export type ComputeSheetPageLayoutInput = {
|
|
67
|
+
printSettings: SheetPrintSettings | null | undefined;
|
|
68
|
+
/** Rows / columns of the sheet (1-based, the last index). */
|
|
69
|
+
rowCount: number;
|
|
70
|
+
columnCount: number;
|
|
71
|
+
/** Height / width of a 1-based row / column in sheet px; 0 when hidden. */
|
|
72
|
+
getRowHeight: (rowIndex: number) => number;
|
|
73
|
+
getColumnWidth: (columnIndex: number) => number;
|
|
74
|
+
/** The used range: the last row / column with content. */
|
|
75
|
+
dataRowCount: number;
|
|
76
|
+
dataColumnCount: number;
|
|
77
|
+
/** View ▸ Ruler. @default true */
|
|
78
|
+
rulers?: boolean;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Pages `rowCount` × `columnCount` the way Excel's Page Layout view does.
|
|
82
|
+
* A sheet with no page setup uses Excel's defaults (Letter, portrait,
|
|
83
|
+
* Normal margins, 100 %).
|
|
84
|
+
*/
|
|
85
|
+
export declare const computeSheetPageLayout: ({ printSettings: stored, rowCount, columnCount, getRowHeight, getColumnWidth, dataRowCount, dataColumnCount, rulers, }: ComputeSheetPageLayoutInput) => SheetPageLayout;
|
|
86
|
+
//# sourceMappingURL=compute-page-layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compute-page-layout.d.ts","sourceRoot":"","sources":["../../../../components/page-layout-view/compute-page-layout.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAmBtD,0EAA0E;AAC1E,eAAO,MAAM,oBAAoB,KAAK,CAAC;AACvC,iFAAiF;AACjF,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAKzC,MAAM,MAAM,cAAc,GAAG;IAC3B,qEAAqE;IACrE,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,qEAAqE;IACrE,KAAK,EAAE,MAAM,CAAC;IACd,mDAAmD;IACnD,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACzC,kGAAkG;IAClG,OAAO,EAAE;QACP,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,yDAAyD;IACzD,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3C,wEAAwE;IACxE,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,uEAAuE;IACvE,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,WAAW,EAAE,cAAc,EAAE,CAAC;IAC9B,sFAAsF;IACtF,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,2EAA2E;IAC3E,eAAe,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;IACxC,YAAY,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9C,oFAAoF;IACpF,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;IACxC,YAAY,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9C,4DAA4D;IAC5D,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,cAAc,GAAG,SAAS,CAAC;CAC7E,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,aAAa,EAAE,kBAAkB,GAAG,IAAI,GAAG,SAAS,CAAC;IACrD,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,2EAA2E;IAC3E,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;IAC3C,cAAc,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,MAAM,CAAC;IAChD,0DAA0D;IAC1D,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,kCAAkC;IAClC,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AA2BF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GAAI,wHASpC,2BAA2B,KAAG,eA4IhC,CAAC"}
|