@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,351 @@
|
|
|
1
|
+
// What Page Layout view draws around the cells: the desk between pages, each
|
|
2
|
+
// page's white margins, the rulers, and the header and footer in the top and
|
|
3
|
+
// bottom margins, editable in place (Excel: click the header area of a page,
|
|
4
|
+
// type in its left, center or right section; click a cell to finish).
|
|
5
|
+
//
|
|
6
|
+
// The cells themselves are the grid's: the grid leaves the margins and the
|
|
7
|
+
// desk empty (`Grid`'s `getRowGap` / `getColumnGap`), and this layer, placed
|
|
8
|
+
// in the grid's children with the grid's own offsets, covers exactly that
|
|
9
|
+
// space — so gridlines and spilled text stop at the page edge.
|
|
10
|
+
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
11
|
+
import { DPI } from "../print-preview/settings";
|
|
12
|
+
import { resolveHeaderFooter } from "../print-preview/sheet-page-setup";
|
|
13
|
+
import { PAGE_LAYOUT_RULER_SIZE } from "./compute-page-layout";
|
|
14
|
+
import { buildHeaderFooter, headerFooterKey, parseHeaderFooter, withHeaderFooterText, } from "./header-footer-codes";
|
|
15
|
+
export const PAGE_LAYOUT_DESK_COLOR = "#E6E6E6";
|
|
16
|
+
const PAPER_COLOR = "#FFFFFF";
|
|
17
|
+
const RULER_COLOR = "#F3F3F3";
|
|
18
|
+
const RULER_MARGIN_COLOR = "#D9D9D9";
|
|
19
|
+
const RULER_TICK_COLOR = "#8A8A8A";
|
|
20
|
+
const ZONE_HOVER_BORDER = "#A6A6A6";
|
|
21
|
+
const PLACEHOLDER_COLOR = "#7F7F7F";
|
|
22
|
+
/** Excel's default header / footer font: Calibri 11 pt. */
|
|
23
|
+
const HEADER_FONT_PX = (11 * DPI) / 72;
|
|
24
|
+
const SECTIONS = ["left", "center", "right"];
|
|
25
|
+
const visibleBands = (bandOf, start, stop, count) => {
|
|
26
|
+
const first = Math.max(0, bandOf(Math.max(1, start ?? 1)) - 1);
|
|
27
|
+
const lastBand = bandOf(Math.max(1, stop ?? 1));
|
|
28
|
+
const last = Math.min(count - 1, (lastBand === -1 ? count - 1 : lastBand) + 1);
|
|
29
|
+
const bands = [];
|
|
30
|
+
for (let band = first; band <= last; band++)
|
|
31
|
+
bands.push(band);
|
|
32
|
+
return bands;
|
|
33
|
+
};
|
|
34
|
+
/** The pages the grid's rendered rows and columns touch, and where they sit. */
|
|
35
|
+
export const getVisiblePageBoxes = (layout, zoom, grid) => {
|
|
36
|
+
const { getRowOffset, getColumnOffset } = grid;
|
|
37
|
+
if (!getRowOffset || !getColumnOffset)
|
|
38
|
+
return [];
|
|
39
|
+
const rows = visibleBands(layout.rowBandOf, grid.rowStartIndex, grid.rowStopIndex, layout.rowBands.length);
|
|
40
|
+
const columns = visibleBands(layout.columnBandOf, grid.columnStartIndex, grid.columnStopIndex, layout.columnBands.length);
|
|
41
|
+
const boxes = [];
|
|
42
|
+
for (const rowBand of rows) {
|
|
43
|
+
const rowSpan = layout.rowBands[rowBand];
|
|
44
|
+
const usedTop = getRowOffset(rowSpan.start);
|
|
45
|
+
const top = usedTop - layout.margins.top * zoom;
|
|
46
|
+
for (const columnBand of columns) {
|
|
47
|
+
const columnSpan = layout.columnBands[columnBand];
|
|
48
|
+
const usedLeft = getColumnOffset(columnSpan.start);
|
|
49
|
+
const left = usedLeft - layout.margins.left * zoom;
|
|
50
|
+
boxes.push({
|
|
51
|
+
rowBand,
|
|
52
|
+
columnBand,
|
|
53
|
+
page: layout.pageAt(rowBand, columnBand),
|
|
54
|
+
left,
|
|
55
|
+
top,
|
|
56
|
+
width: layout.paper.width * zoom,
|
|
57
|
+
height: layout.paper.height * zoom,
|
|
58
|
+
usedLeft,
|
|
59
|
+
usedTop,
|
|
60
|
+
usedRight: usedLeft + columnSpan.size * zoom,
|
|
61
|
+
usedBottom: usedTop + rowSpan.size * zoom,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return boxes;
|
|
66
|
+
};
|
|
67
|
+
const rect = (key, left, top, width, height, background, extra) => width > 0 && height > 0 ? (React.createElement("div", { key: key, style: {
|
|
68
|
+
position: "absolute",
|
|
69
|
+
left,
|
|
70
|
+
top,
|
|
71
|
+
width,
|
|
72
|
+
height,
|
|
73
|
+
background,
|
|
74
|
+
// The desk and the margins are not cells: a click there selects none.
|
|
75
|
+
pointerEvents: "auto",
|
|
76
|
+
...extra,
|
|
77
|
+
} })) : null;
|
|
78
|
+
/** A ruler along one edge of a page: inches, ticks every eighth, the margins shaded. */
|
|
79
|
+
const Ruler = ({ orientation, left, top, length, thickness, zoom, marginStart, marginEnd, }) => {
|
|
80
|
+
const horizontal = orientation === "horizontal";
|
|
81
|
+
const eighth = (DPI / 8) * zoom;
|
|
82
|
+
const ticks = [];
|
|
83
|
+
const count = Math.floor(length / eighth);
|
|
84
|
+
for (let i = 1; i <= count; i++) {
|
|
85
|
+
const at = i * eighth;
|
|
86
|
+
const inch = i % 8 === 0;
|
|
87
|
+
const half = i % 4 === 0;
|
|
88
|
+
const size = inch
|
|
89
|
+
? thickness * 0.5
|
|
90
|
+
: half
|
|
91
|
+
? thickness * 0.3
|
|
92
|
+
: thickness * 0.18;
|
|
93
|
+
ticks.push(React.createElement("div", { key: i, style: {
|
|
94
|
+
position: "absolute",
|
|
95
|
+
background: RULER_TICK_COLOR,
|
|
96
|
+
...(horizontal
|
|
97
|
+
? { left: at, bottom: 0, width: 1, height: size }
|
|
98
|
+
: { top: at, right: 0, height: 1, width: size }),
|
|
99
|
+
} }));
|
|
100
|
+
if (inch) {
|
|
101
|
+
ticks.push(React.createElement("span", { key: `n${i}`, style: {
|
|
102
|
+
position: "absolute",
|
|
103
|
+
fontSize: Math.max(8, 9 * zoom),
|
|
104
|
+
lineHeight: 1,
|
|
105
|
+
color: RULER_TICK_COLOR,
|
|
106
|
+
...(horizontal
|
|
107
|
+
? { left: at - 3, top: 1 }
|
|
108
|
+
: { top: at - 4, left: 1 }),
|
|
109
|
+
} }, i / 8));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return (React.createElement("div", { "data-page-layout-ruler": orientation, style: {
|
|
113
|
+
position: "absolute",
|
|
114
|
+
left,
|
|
115
|
+
top,
|
|
116
|
+
width: horizontal ? length : thickness,
|
|
117
|
+
height: horizontal ? thickness : length,
|
|
118
|
+
background: RULER_COLOR,
|
|
119
|
+
overflow: "hidden",
|
|
120
|
+
} },
|
|
121
|
+
React.createElement("div", { style: {
|
|
122
|
+
position: "absolute",
|
|
123
|
+
background: RULER_MARGIN_COLOR,
|
|
124
|
+
...(horizontal
|
|
125
|
+
? { left: 0, top: 0, height: thickness, width: marginStart }
|
|
126
|
+
: { left: 0, top: 0, width: thickness, height: marginStart }),
|
|
127
|
+
} }),
|
|
128
|
+
React.createElement("div", { style: {
|
|
129
|
+
position: "absolute",
|
|
130
|
+
background: RULER_MARGIN_COLOR,
|
|
131
|
+
...(horizontal
|
|
132
|
+
? { right: 0, top: 0, height: thickness, width: marginEnd }
|
|
133
|
+
: { left: 0, bottom: 0, width: thickness, height: marginEnd }),
|
|
134
|
+
} }),
|
|
135
|
+
ticks));
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* One page's header (or footer): three sections across the space between
|
|
139
|
+
* the left and right margins. Shows what prints; in edit mode, the stored
|
|
140
|
+
* text with Excel's display codes.
|
|
141
|
+
*/
|
|
142
|
+
const HeaderFooterZone = ({ kind, box, layout, zoom, stored, context, editing, editable, onStartEdit, onCommit, onCancel, }) => {
|
|
143
|
+
const { margins } = layout;
|
|
144
|
+
const left = box.left + margins.left * zoom;
|
|
145
|
+
const width = box.width - (margins.left + margins.right) * zoom;
|
|
146
|
+
const fontSize = HEADER_FONT_PX * zoom * layout.scale;
|
|
147
|
+
const minHeight = Math.max(fontSize * 1.4, 16 * zoom);
|
|
148
|
+
const position = kind === "header"
|
|
149
|
+
? { top: box.top + margins.header * zoom }
|
|
150
|
+
: { top: box.top + box.height - margins.footer * zoom - minHeight };
|
|
151
|
+
const resolved = resolveHeaderFooter(stored, {
|
|
152
|
+
pageNumber: layout.firstPageNumber - 1 + box.page.ordinal,
|
|
153
|
+
pageCount: layout.pageCount,
|
|
154
|
+
...context,
|
|
155
|
+
});
|
|
156
|
+
const empty = !resolved;
|
|
157
|
+
const groupRef = useRef(null);
|
|
158
|
+
// Escape discards: a blur that follows (the editor unmounting) must not commit.
|
|
159
|
+
const cancelledRef = useRef(false);
|
|
160
|
+
const [draft, setDraft] = useState();
|
|
161
|
+
useEffect(() => {
|
|
162
|
+
cancelledRef.current = false;
|
|
163
|
+
if (editing)
|
|
164
|
+
setDraft(parseHeaderFooter(stored));
|
|
165
|
+
else
|
|
166
|
+
setDraft(undefined);
|
|
167
|
+
// Start from the stored text each time editing starts.
|
|
168
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
169
|
+
}, [editing !== undefined]);
|
|
170
|
+
const zoneLabel = kind === "header" ? "Header" : "Footer";
|
|
171
|
+
const common = {
|
|
172
|
+
position: "absolute",
|
|
173
|
+
left,
|
|
174
|
+
width,
|
|
175
|
+
minHeight,
|
|
176
|
+
display: "flex",
|
|
177
|
+
pointerEvents: "auto",
|
|
178
|
+
fontFamily: "Calibri, Carlito, Arial, sans-serif",
|
|
179
|
+
fontSize,
|
|
180
|
+
lineHeight: 1.2,
|
|
181
|
+
color: "#000",
|
|
182
|
+
...position,
|
|
183
|
+
};
|
|
184
|
+
if (editing && draft) {
|
|
185
|
+
return (React.createElement("div", { ref: groupRef, role: "group", "aria-label": zoneLabel, "data-page-layout-zone": kind, "data-editing": "", style: { ...common, outline: `1px dashed ${ZONE_HOVER_BORDER}` }, onMouseDown: (event) => event.stopPropagation(), onBlur: (event) => {
|
|
186
|
+
if (cancelledRef.current)
|
|
187
|
+
return;
|
|
188
|
+
if (groupRef.current?.contains(event.relatedTarget))
|
|
189
|
+
return;
|
|
190
|
+
onCommit(draft);
|
|
191
|
+
} }, SECTIONS.map((section) => (React.createElement("textarea", { key: section, "aria-label": `${zoneLabel} ${section} section`, "data-page-layout-section": section, autoFocus: section === editing, value: draft[section].text, rows: Math.max(1, draft[section].text.split("\n").length), onChange: (event) => setDraft({
|
|
192
|
+
...draft,
|
|
193
|
+
[section]: { ...draft[section], text: event.target.value },
|
|
194
|
+
}), onKeyDown: (event) => {
|
|
195
|
+
event.stopPropagation();
|
|
196
|
+
if (event.key === "Escape") {
|
|
197
|
+
event.preventDefault();
|
|
198
|
+
cancelledRef.current = true;
|
|
199
|
+
onCancel();
|
|
200
|
+
}
|
|
201
|
+
}, style: {
|
|
202
|
+
flex: 1,
|
|
203
|
+
minWidth: 0,
|
|
204
|
+
resize: "none",
|
|
205
|
+
border: `1px solid ${ZONE_HOVER_BORDER}`,
|
|
206
|
+
background: PAPER_COLOR,
|
|
207
|
+
font: "inherit",
|
|
208
|
+
textAlign: section,
|
|
209
|
+
padding: 1,
|
|
210
|
+
outline: "none",
|
|
211
|
+
} })))));
|
|
212
|
+
}
|
|
213
|
+
return (React.createElement("div", { role: "group", "aria-label": zoneLabel, "data-page-layout-zone": kind, className: "group", style: { ...common, cursor: editable ? "text" : undefined }, onMouseDown: (event) => {
|
|
214
|
+
// The margin is not a cell: a click here never selects one.
|
|
215
|
+
event.stopPropagation();
|
|
216
|
+
} }, SECTIONS.map((section) => (React.createElement("div", { key: section, "data-page-layout-section": section, onClick: editable ? () => onStartEdit(section) : undefined, className: editable
|
|
217
|
+
? "group-hover:outline group-hover:outline-1 group-hover:outline-dashed"
|
|
218
|
+
: undefined, style: {
|
|
219
|
+
flex: 1,
|
|
220
|
+
minWidth: 0,
|
|
221
|
+
whiteSpace: "pre-wrap",
|
|
222
|
+
overflow: "hidden",
|
|
223
|
+
textAlign: section,
|
|
224
|
+
outlineColor: ZONE_HOVER_BORDER,
|
|
225
|
+
} },
|
|
226
|
+
resolved?.[section] ?? "",
|
|
227
|
+
empty && editable && section === "center" ? (React.createElement("span", { "data-page-layout-placeholder": kind, className: kind === "footer" ? "invisible group-hover:visible" : undefined, style: {
|
|
228
|
+
color: PLACEHOLDER_COLOR,
|
|
229
|
+
fontSize: Math.max(10, 12 * zoom),
|
|
230
|
+
} }, kind === "header"
|
|
231
|
+
? "Click to add header"
|
|
232
|
+
: "Click to add footer")) : null)))));
|
|
233
|
+
};
|
|
234
|
+
/** Body layer: desk, margins, rulers, headers and footers of the visible pages. */
|
|
235
|
+
export const PageLayoutChrome = ({ layout, zoom, grid, headerFooter, context, onChangeHeaderFooter, }) => {
|
|
236
|
+
// Read on every grid render: the offsets move with resizes and scrolling.
|
|
237
|
+
const boxes = getVisiblePageBoxes(layout, zoom, grid);
|
|
238
|
+
const [editing, setEditing] = useState();
|
|
239
|
+
const commit = useCallback((kind, ordinal, sections) => {
|
|
240
|
+
setEditing(undefined);
|
|
241
|
+
const key = headerFooterKey(headerFooter, kind, ordinal);
|
|
242
|
+
const before = headerFooter?.[key] ?? undefined;
|
|
243
|
+
const after = buildHeaderFooter(sections);
|
|
244
|
+
if ((before ?? "") === (after ?? ""))
|
|
245
|
+
return;
|
|
246
|
+
onChangeHeaderFooter?.(withHeaderFooterText(headerFooter, key, after));
|
|
247
|
+
}, [headerFooter, onChangeHeaderFooter]);
|
|
248
|
+
const { scrollLeft, scrollTop, containerWidth, containerHeight } = grid;
|
|
249
|
+
const viewLeft = scrollLeft + grid.frozenColumnWidth;
|
|
250
|
+
const viewTop = scrollTop + grid.frozenRowHeight;
|
|
251
|
+
const viewRight = scrollLeft + containerWidth;
|
|
252
|
+
const viewBottom = scrollTop + containerHeight;
|
|
253
|
+
const ruler = layout.rulers ? PAGE_LAYOUT_RULER_SIZE * zoom : 0;
|
|
254
|
+
const nodes = [];
|
|
255
|
+
// Desk: above and between page rows, left of and between page columns.
|
|
256
|
+
const rowTops = new Map();
|
|
257
|
+
const columnLefts = new Map();
|
|
258
|
+
for (const box of boxes) {
|
|
259
|
+
if (!rowTops.has(box.rowBand))
|
|
260
|
+
rowTops.set(box.rowBand, box);
|
|
261
|
+
if (!columnLefts.has(box.columnBand))
|
|
262
|
+
columnLefts.set(box.columnBand, box);
|
|
263
|
+
}
|
|
264
|
+
for (const [rowBand, box] of rowTops) {
|
|
265
|
+
const above = rowTops.get(rowBand - 1);
|
|
266
|
+
const from = rowBand === 0
|
|
267
|
+
? Math.min(grid.frozenRowHeight, box.top)
|
|
268
|
+
: above
|
|
269
|
+
? above.top + above.height
|
|
270
|
+
: box.top - layout.deskGap * zoom - ruler;
|
|
271
|
+
nodes.push(rect(`desk-r${rowBand}`, viewLeft, from, viewRight - viewLeft, box.top - from, PAGE_LAYOUT_DESK_COLOR));
|
|
272
|
+
}
|
|
273
|
+
for (const [columnBand, box] of columnLefts) {
|
|
274
|
+
const before = columnLefts.get(columnBand - 1);
|
|
275
|
+
const from = columnBand === 0
|
|
276
|
+
? Math.min(grid.frozenColumnWidth, box.left)
|
|
277
|
+
: before
|
|
278
|
+
? before.left + before.width
|
|
279
|
+
: box.left - layout.deskGap * zoom - ruler;
|
|
280
|
+
nodes.push(rect(`desk-c${columnBand}`, from, viewTop, box.left - from, viewBottom - viewTop, PAGE_LAYOUT_DESK_COLOR));
|
|
281
|
+
}
|
|
282
|
+
// Below the last page row / right of the last page column the sheet ends.
|
|
283
|
+
const lastRow = layout.rowBands.length - 1;
|
|
284
|
+
const lastColumn = layout.columnBands.length - 1;
|
|
285
|
+
for (const box of boxes) {
|
|
286
|
+
const key = `${box.rowBand}:${box.columnBand}`;
|
|
287
|
+
const right = box.left + box.width;
|
|
288
|
+
const bottom = box.top + box.height;
|
|
289
|
+
// White margins around the cells (the leftover of a short page included).
|
|
290
|
+
nodes.push(rect(`m-t${key}`, box.left, box.top, box.width, box.usedTop - box.top, PAPER_COLOR), rect(`m-b${key}`, box.left, box.usedBottom, box.width, bottom - box.usedBottom, PAPER_COLOR), rect(`m-l${key}`, box.left, box.usedTop, box.usedLeft - box.left, box.usedBottom - box.usedTop, PAPER_COLOR), rect(`m-r${key}`, box.usedRight, box.usedTop, right - box.usedRight, box.usedBottom - box.usedTop, PAPER_COLOR));
|
|
291
|
+
if (box.rowBand === lastRow) {
|
|
292
|
+
nodes.push(rect(`desk-end-r${key}`, box.left - layout.deskGap * zoom - ruler, bottom, box.width + layout.deskGap * zoom + ruler, Math.max(0, viewBottom - bottom), PAGE_LAYOUT_DESK_COLOR));
|
|
293
|
+
}
|
|
294
|
+
if (box.columnBand === lastColumn) {
|
|
295
|
+
nodes.push(rect(`desk-end-c${key}`, right, box.top - layout.deskGap * zoom - ruler, Math.max(0, viewRight - right), box.height + layout.deskGap * zoom + ruler, PAGE_LAYOUT_DESK_COLOR));
|
|
296
|
+
}
|
|
297
|
+
if (layout.rulers) {
|
|
298
|
+
nodes.push(React.createElement(Ruler, { key: `ruler-h${key}`, orientation: "horizontal", left: box.left, top: box.top - ruler, length: box.width, thickness: ruler, zoom: zoom, marginStart: layout.margins.left * zoom, marginEnd: layout.margins.right * zoom }), React.createElement(Ruler, { key: `ruler-v${key}`, orientation: "vertical", left: box.left - ruler, top: box.top, length: box.height, thickness: ruler, zoom: zoom, marginStart: layout.margins.top * zoom, marginEnd: layout.margins.bottom * zoom }));
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
// Headers and footers, on the pages that print.
|
|
302
|
+
const editable = !!onChangeHeaderFooter;
|
|
303
|
+
for (const box of boxes) {
|
|
304
|
+
const page = box.page;
|
|
305
|
+
if (!page)
|
|
306
|
+
continue;
|
|
307
|
+
for (const kind of ["header", "footer"]) {
|
|
308
|
+
const isEditing = editing?.kind === kind &&
|
|
309
|
+
editing.rowBand === box.rowBand &&
|
|
310
|
+
editing.columnBand === box.columnBand;
|
|
311
|
+
const key = headerFooterKey(headerFooter, kind, page.ordinal);
|
|
312
|
+
nodes.push(React.createElement(HeaderFooterZone, { key: `${kind}-${box.rowBand}:${box.columnBand}`, kind: kind, box: { ...box, page }, layout: layout, zoom: zoom, stored: headerFooter?.[key] ?? undefined, context: context, editing: isEditing ? editing.section : undefined, editable: editable, onStartEdit: (section) => setEditing({
|
|
313
|
+
kind,
|
|
314
|
+
rowBand: box.rowBand,
|
|
315
|
+
columnBand: box.columnBand,
|
|
316
|
+
section,
|
|
317
|
+
}), onCommit: (sections) => commit(kind, page.ordinal, sections), onCancel: () => setEditing(undefined) }));
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return (React.createElement("div", { "data-page-layout-view": "", style: { position: "absolute", left: 0, top: 0 } }, nodes));
|
|
321
|
+
};
|
|
322
|
+
/** Frozen heading strips: the desk between pages under the column / beside the row headings. */
|
|
323
|
+
export const PageLayoutHeadingGaps = ({ layout, zoom, grid, axis, }) => {
|
|
324
|
+
const boxes = getVisiblePageBoxes(layout, zoom, grid);
|
|
325
|
+
const seen = new Set();
|
|
326
|
+
const nodes = [];
|
|
327
|
+
for (const box of boxes) {
|
|
328
|
+
const band = axis === "columns" ? box.columnBand : box.rowBand;
|
|
329
|
+
if (seen.has(band))
|
|
330
|
+
continue;
|
|
331
|
+
seen.add(band);
|
|
332
|
+
// Everything of the heading strip outside the page's cells is desk.
|
|
333
|
+
if (axis === "columns") {
|
|
334
|
+
const previous = boxes.find((b) => b.columnBand === band - 1);
|
|
335
|
+
const from = previous ? previous.usedRight : grid.frozenColumnWidth;
|
|
336
|
+
nodes.push(rect(`hc${band}`, from, 0, box.usedLeft - from, grid.frozenRowHeight, PAGE_LAYOUT_DESK_COLOR));
|
|
337
|
+
if (band === layout.columnBands.length - 1) {
|
|
338
|
+
nodes.push(rect(`hc-end`, box.usedRight, 0, Math.max(0, grid.scrollLeft + grid.containerWidth - box.usedRight), grid.frozenRowHeight, PAGE_LAYOUT_DESK_COLOR));
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
const previous = boxes.find((b) => b.rowBand === band - 1);
|
|
343
|
+
const from = previous ? previous.usedBottom : grid.frozenRowHeight;
|
|
344
|
+
nodes.push(rect(`hr${band}`, 0, from, grid.frozenColumnWidth, box.usedTop - from, PAGE_LAYOUT_DESK_COLOR));
|
|
345
|
+
if (band === layout.rowBands.length - 1) {
|
|
346
|
+
nodes.push(rect(`hr-end`, 0, box.usedBottom, grid.frozenColumnWidth, Math.max(0, grid.scrollTop + grid.containerHeight - box.usedBottom), PAGE_LAYOUT_DESK_COLOR));
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return React.createElement(React.Fragment, null, nodes);
|
|
351
|
+
};
|
|
@@ -103,6 +103,11 @@ export type PageLayoutInput = {
|
|
|
103
103
|
rowBreaks?: readonly number[];
|
|
104
104
|
columnBreaks?: readonly number[];
|
|
105
105
|
};
|
|
106
|
+
export declare const sliceAxis: (start: number, end: number, getSize: (i: number) => number, limit: number, scale: number, breaks?: ReadonlySet<number>) => Array<{
|
|
107
|
+
start: number;
|
|
108
|
+
end: number;
|
|
109
|
+
size: number;
|
|
110
|
+
}>;
|
|
106
111
|
export declare const computePageLayout: (input: PageLayoutInput) => PageBlock[];
|
|
107
112
|
/**
|
|
108
113
|
* Total natural width / height of the print range (unscaled). Used by
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-page-layout.d.ts","sourceRoot":"","sources":["../../../../components/print-preview/use-page-layout.ts"],"names":[],"mappings":"AAcA,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;I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AC5C,CAAC;AAWF;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAAI,8GAUhC,gBAAgB,KAAG,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,CA8C/C,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,MAAM,CAAC;IAChD,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;IAC3C,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd;;;;;OAKG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;OAKG;IACH,aAAa,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/C,gBAAgB,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAClD;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC,CAAC;
|
|
1
|
+
{"version":3,"file":"use-page-layout.d.ts","sourceRoot":"","sources":["../../../../components/print-preview/use-page-layout.ts"],"names":[],"mappings":"AAcA,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EA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;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAsBpD,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,OAAO,eAAe,KAAG,SAAS,EAuGnE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,GACvB,UAAU,MAAM,EAChB,QAAQ,MAAM,EACd,aAAa,MAAM,EACnB,WAAW,MAAM,EACjB,gBAAgB,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,EACrC,cAAc,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,KAClC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAMjC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,GACvB,MAAM,KAAK,GAAG,WAAW,GAAG,UAAU,GAAG,QAAQ,EACjD,aAAa,MAAM,EACnB,YAAY,MAAM,EAClB,aAAa,MAAM,EACnB,cAAc,MAAM,EACpB,eAAe,MAAM,KACpB,MAmBF,CAAC"}
|
|
@@ -80,7 +80,7 @@ export const placeChartsOnPages = ({ charts, sheetId, blocks, startRow, startCol
|
|
|
80
80
|
* early, spilling the last column onto its own page.
|
|
81
81
|
*/
|
|
82
82
|
const EPSILON = 0.5;
|
|
83
|
-
const sliceAxis = (start, end, getSize, limit, scale, breaks = new Set()) => {
|
|
83
|
+
export const sliceAxis = (start, end, getSize, limit, scale, breaks = new Set()) => {
|
|
84
84
|
const bands = [];
|
|
85
85
|
if (start > end || limit <= 0)
|
|
86
86
|
return bands;
|
package/dist/esm/helpers.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CellInterface, GridRange } from "@rowsncolumns/grid";
|
|
2
2
|
import type { CellTooltipVariants } from "@rowsncolumns/ui";
|
|
3
|
+
import type { IndexRanges } from "./api/index-ranges";
|
|
3
4
|
import type { AXIS, Border, CellData, Color, ConditionType, ConditionValue, FilterSpec, FilterView, HorizontalAlign, Sheet, SheetCoordinate, SheetRange, SortOrder, StructuredValue, StyleReference, TableTheme, TableView, VerticalAlign } from "./types";
|
|
4
5
|
export declare const isFirefox: boolean;
|
|
5
6
|
export declare const isMac: boolean;
|
|
@@ -112,6 +113,11 @@ export declare const definedProps: <T extends Record<string, any> | undefined |
|
|
|
112
113
|
export declare const isGridRange: (maybeCellOrRange: CellInterface | GridRange) => maybeCellOrRange is GridRange;
|
|
113
114
|
export declare const addIndent: (text: string, indent: number, alignment: HorizontalAlign) => string;
|
|
114
115
|
export declare const generateMultiDimTitle: (dims: number[] | undefined, axis: AXIS) => string | null;
|
|
116
|
+
/**
|
|
117
|
+
* `generateMultiDimTitle` over bands: "C-E" / "3-5" for one unbroken band of
|
|
118
|
+
* two or more, otherwise nothing. O(1) whatever the band's length.
|
|
119
|
+
*/
|
|
120
|
+
export declare const generateMultiDimTitleFromRanges: (ranges: IndexRanges | undefined, axis: AXIS) => string | null;
|
|
115
121
|
export declare const createArrayRange: (start: number, end: number) => number[];
|
|
116
122
|
export declare const isInSequence: (arr: number[]) => boolean;
|
|
117
123
|
export declare const getCurrencySymbol: (locale: string | undefined, currency: string) => string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAMnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAMnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAO5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAA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return null;
|
|
353
353
|
};
|
|
354
|
+
/**
|
|
355
|
+
* `generateMultiDimTitle` over bands: "C-E" / "3-5" for one unbroken band of
|
|
356
|
+
* two or more, otherwise nothing. O(1) whatever the band's length.
|
|
357
|
+
*/
|
|
358
|
+
export const generateMultiDimTitleFromRanges = (ranges, axis) => {
|
|
359
|
+
if (!ranges || !ranges.isContiguous || ranges.length < 2) {
|
|
360
|
+
return null;
|
|
361
|
+
}
|
|
362
|
+
const first = ranges.first;
|
|
363
|
+
const last = ranges.last;
|
|
364
|
+
if (axis === "y") {
|
|
365
|
+
return number2Alpha(first - 1) + "-" + number2Alpha(last - 1);
|
|
366
|
+
}
|
|
367
|
+
return first + "-" + last;
|
|
368
|
+
};
|
|
354
369
|
export const createArrayRange = (start, end) => {
|
|
355
370
|
return Array.from({ length: end - start + 1 }).map((_, index) => start + index);
|
|
356
371
|
};
|
|
@@ -4,19 +4,21 @@ import { Direction } from "@rowsncolumns/grid";
|
|
|
4
4
|
import type { FormulaLocale } from "@rowsncolumns/utils";
|
|
5
5
|
import type { CellDiff } from "@rowsncolumns/version-comparison";
|
|
6
6
|
import React from "react";
|
|
7
|
+
import type { IndexRanges } from "../api/index-ranges";
|
|
7
8
|
import type { ErrorCheckKind } from "../api/error-checking";
|
|
8
9
|
import type { CanvasGridProps, SpreadsheetTheme } from "../components/canvas-grid/typings";
|
|
9
10
|
import type { CellData, CellFormat, Color, DataValidationRule, ErrorValue, SortOrder, TextFormat } from "../types";
|
|
11
|
+
import type { SelectedIndexes } from "./use-selected-rows-columns";
|
|
10
12
|
import type { useSizer } from "./use-sizer";
|
|
11
13
|
export type CellRendererProps<T extends CellData = CellData> = {
|
|
12
14
|
scale: number;
|
|
13
15
|
sheetId: number;
|
|
14
16
|
isRowHeader(columnIndex: number): boolean;
|
|
15
17
|
isColumnHeader(rowIndex: number): boolean;
|
|
16
|
-
selectedRows:
|
|
17
|
-
selectedColumns:
|
|
18
|
-
selectedRowHeaders:
|
|
19
|
-
selectedColumnHeaders:
|
|
18
|
+
selectedRows: SelectedIndexes;
|
|
19
|
+
selectedColumns: SelectedIndexes;
|
|
20
|
+
selectedRowHeaders: IndexRanges;
|
|
21
|
+
selectedColumnHeaders: IndexRanges;
|
|
20
22
|
cellBackgroundColor: string;
|
|
21
23
|
headerBorderColor: string;
|
|
22
24
|
headerBackgroundColor: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-cell-renderer.d.ts","sourceRoot":"","sources":["../../../hooks/use-cell-renderer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,4BAA4B,CAAC;AACnF,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAQ/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,KAAsB,MAAM,OAAO,CAAC;AAG3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EACjB,MAAM,mCAAmC,CAAC;AAoB3C,OAAO,KAAK,EACV,QAAQ,EACR,UAAU,EACV,KAAK,EACL,kBAAkB,EAClB,UAAU,EACV,SAAS,EACT,UAAU,EACX,MAAM,UAAU,CAAC;AAGlB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ,IAAI;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1C,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1C,YA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,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAAE,k3CA6E5D,iBAAiB,CAAC,CAAC,CAAC,uBAynBX,aAAa,uCA5mBb,aAAa,gCA2fb,aAAa,uCApFb,aAAa,mDAoRb,aAAa,EAAE,uBA0B1B,CAAC"}
|
|
@@ -16,6 +16,7 @@ import { getCellBordersForRendering } from "../helpers/merged-cell-borders";
|
|
|
16
16
|
import { getStringifiedColor } from "../themes";
|
|
17
17
|
import { applyShowZeros } from "./show-zeros";
|
|
18
18
|
import { useCellDiffHighlight } from "./use-cell-diff-highlight";
|
|
19
|
+
import { isIndexSelected } from "./use-selected-rows-columns";
|
|
19
20
|
export const useCellRenderer = ({ sheetId, scale, showGridLines, showZeros, isRowHeader, isColumnHeader, selectedRows, selectedColumns, selectedRowHeaders, selectedColumnHeaders, cellBackgroundColor, headerBorderColor, headerBackgroundColor, headerColor, headerActiveBackgroundColor, headerSelectedBackgroundColor, headerSelectedColor, headerTableBackgroundColor, headerTableActiveBackgroundColor, headerTableSelectedBackgroundColor, chipBackgroundColor, filterIconColor, showCalculatedColumnIcon, enableTextOverflow, showHeaders, theme, getDefaultHorizontalAlignment, isTableFilterVisible, columnContainsTable, rowsContainsTable, canOverflowToNextCell, getTableHeaderSortOrder, getDataValidation, getErrorValue, formulaLocale, locale, getEffectiveValue, getSparklineGroup, getFormattedValue, getNote, getComment, getEffectiveCellFormat, getCellBounds, getCellImageUrl, getCellMetaType, getRowHeaderText, getColumnHeaderText, getMaximumOverflowTextWidth, getCenterAcrossSelectionSpan, activeCell, getTextDimension, getCellGroupingInfo, getTextFormatRuns, onRequestEdit, onFilterClick, onCheckboxClick, isTableHeader, isTableTotalsCell, onTotalsArrowClick, isCalculatedColumnHeader, isTableHeaderFilterActive, HeaderCell, Cell, StructuredResult, gridLineWidth, getErrorCheck, circleInvalidData = false, showNotes, showComments, defaultFontSizePoint, lineHeightMode, readonly, onExpandCollapse, onOverflow, isComparing = false, getCellDiff, }) => {
|
|
20
21
|
// Version comparison diff highlighting - only active when isComparing is true
|
|
21
22
|
const { mergeCellFormatWithDiff, getDiffHighlight } = useCellDiffHighlight(isComparing ? getCellDiff : undefined);
|
|
@@ -276,11 +277,11 @@ export const useCellRenderer = ({ sheetId, scale, showGridLines, showZeros, isRo
|
|
|
276
277
|
if (rowHeader || colHeader) {
|
|
277
278
|
const isCorner = rowHeader === colHeader;
|
|
278
279
|
const isActive = colHeader
|
|
279
|
-
? selectedColumns
|
|
280
|
-
: selectedRows
|
|
280
|
+
? isIndexSelected(selectedColumns, columnIndex)
|
|
281
|
+
: isIndexSelected(selectedRows, rowIndex);
|
|
281
282
|
const isEntireRowColumnSelected = colHeader
|
|
282
|
-
? selectedColumnHeaders
|
|
283
|
-
: selectedRowHeaders
|
|
283
|
+
? selectedColumnHeaders.has(columnIndex)
|
|
284
|
+
: selectedRowHeaders.has(rowIndex);
|
|
284
285
|
const containsTable = colHeader
|
|
285
286
|
? columnContainsTable(columnIndex)
|
|
286
287
|
: rowsContainsTable(rowIndex);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-context-setter.d.ts","sourceRoot":"","sources":["../../../hooks/use-context-setter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAG3E,eAAO,MAAM,gBAAgB,GAC3B,cAAc,KAAK,CAAC,YAAY,CAAC,iBAAiB,CAAC,EACnD,cAAc,iBAAiB,
|
|
1
|
+
{"version":3,"file":"use-context-setter.d.ts","sourceRoot":"","sources":["../../../hooks/use-context-setter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAG3E,eAAO,MAAM,gBAAgB,GAC3B,cAAc,KAAK,CAAC,YAAY,CAAC,iBAAiB,CAAC,EACnD,cAAc,iBAAiB,SA6MhC,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { useSetSpreadsheetContext } from "../atoms/sheet-context.atom";
|
|
|
3
3
|
import { useIsomorphicLayoutEffect } from "./use-isomorphic-layout-effect";
|
|
4
4
|
export const useContextSetter = (forwardedRef, contextValue) => {
|
|
5
5
|
const setSpreadsheetContext = useSetSpreadsheetContext();
|
|
6
|
-
const { submitEditor, cancelEditor, commit, makeEditable, editCell, getNextFocusableCell, onEditorKeyDown, scrollToCell, scrollToChart, scrollToBottom, focusSheet, canEditCell, isSheetProtected, isWorkbookProtected, getSheetProtection, getSelectionsFromFormula, getAddressFromSelection, getR1C1AddressFromSelection, tokenizer, localeTokenizer, formulaLocale, referenceStyle, setEditorValue, getCellBounds, getTableNames, getStructuredProperties, getNamedRanges, getTableColumnNames, updateSelectionStartEndReference, getCellDimensions, getRowHeight, getContentfulGridRangeAroundCell, getCellCoordsFromOffset, getCellOffsetFromCoords, getEffectiveValuesFromRange, getSheetDimensions, getFinalRowHeight, getColumnWidth, getSheetId, getSheetName, onInsertNote, onPinToolTip, onUnpinTooltip, showCellPopover, showFilterMenu, redrawGrid, flash, navigateToSheetRange, mark, unmark, exportRange, getViewPort, setActiveCell, getGridRef, getMentions, dispatchEvent, splitTextToColumns, copy, cut, paste, } = contextValue;
|
|
6
|
+
const { submitEditor, cancelEditor, commit, makeEditable, editCell, getNextFocusableCell, onEditorKeyDown, scrollToCell, scrollToChart, selectAllObjects, scrollToBottom, focusSheet, canEditCell, isSheetProtected, isWorkbookProtected, getSheetProtection, getSelectionsFromFormula, getAddressFromSelection, getR1C1AddressFromSelection, tokenizer, localeTokenizer, formulaLocale, referenceStyle, setEditorValue, getCellBounds, getTableNames, getStructuredProperties, getNamedRanges, getTableColumnNames, updateSelectionStartEndReference, getCellDimensions, getRowHeight, getContentfulGridRangeAroundCell, getCellCoordsFromOffset, getCellOffsetFromCoords, getEffectiveValuesFromRange, getSheetDimensions, getFinalRowHeight, getColumnWidth, getSheetId, getSheetName, onInsertNote, onPinToolTip, onUnpinTooltip, showCellPopover, showFilterMenu, redrawGrid, flash, navigateToSheetRange, mark, unmark, exportRange, getViewPort, setActiveCell, getGridRef, getMentions, dispatchEvent, splitTextToColumns, copy, cut, paste, } = contextValue;
|
|
7
7
|
// Expose grid methods in context and ref
|
|
8
8
|
const imperativeHandleRefs = useMemo(() => ({
|
|
9
9
|
submitEditor,
|
|
@@ -15,6 +15,7 @@ export const useContextSetter = (forwardedRef, contextValue) => {
|
|
|
15
15
|
onEditorKeyDown,
|
|
16
16
|
scrollToCell,
|
|
17
17
|
scrollToChart,
|
|
18
|
+
selectAllObjects,
|
|
18
19
|
scrollToBottom,
|
|
19
20
|
focusSheet,
|
|
20
21
|
canEditCell,
|
|
@@ -76,6 +77,7 @@ export const useContextSetter = (forwardedRef, contextValue) => {
|
|
|
76
77
|
onEditorKeyDown,
|
|
77
78
|
scrollToCell,
|
|
78
79
|
scrollToChart,
|
|
80
|
+
selectAllObjects,
|
|
79
81
|
scrollToBottom,
|
|
80
82
|
focusSheet,
|
|
81
83
|
canEditCell,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-copy-paste-cut.d.ts","sourceRoot":"","sources":["../../../hooks/use-copy-paste-cut.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"use-copy-paste-cut.d.ts","sourceRoot":"","sources":["../../../hooks/use-copy-paste-cut.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAcvE,OAAO,KAAK,EACV,eAAe,EAEhB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,uCAAuC,CAAC;AAK/C,MAAM,MAAM,oBAAoB,GAAG;IACjC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,UAAU,EAAE,aAAa,CAAC;IAC1B;;OAEG;IACH,U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AU7B,oBAAoB;;;;2BAoZG,mBAAmB;;IA4DzC,wEAAwE;;IAExE,kDAAkD;;;;wBAjS9C,cAAc;yBAqEd,cAAc;uBA3Bd,cAAc;kCA8HD,aAAa;CAkIjC,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { getHotkeyKey } from "@rowsncolumns/utils";
|
|
|
3
3
|
import { useCallback, useRef, useState } from "react";
|
|
4
4
|
import { createSelectionFromCell } from "../api/copy-paste";
|
|
5
5
|
import { isSelectionACell } from "../api/selections";
|
|
6
|
-
import { useCellEditorInstance, useGetCellBounds, usePasteMenuState, useShowPasteMenu, } from "../atoms";
|
|
6
|
+
import { useCellEditorInstance, useGetCellBounds, usePasteMenuState, useSetCopiedSheetRange, useShowPasteMenu, } from "../atoms";
|
|
7
7
|
import { PASTE_OPTIONS, pasteOptionForRequest, } from "../components/selection/paste-options";
|
|
8
8
|
import { DEFAULT_ARRAY } from "../config";
|
|
9
9
|
import { useCallbackRef } from "./use-callback-ref";
|
|
@@ -38,6 +38,7 @@ const MODIFIER_KEYS = new Set(["Control", "Shift", "Alt", "Meta", "OS"]);
|
|
|
38
38
|
export const useCopyPasteCut = ({ selections, activeCell, sheetId, readonly = false, onPaste, onCopy, onCut, onReapplyPaste, focusSheet, }) => {
|
|
39
39
|
const cellEditorInstance = useCellEditorInstance();
|
|
40
40
|
const getCellBounds = useGetCellBounds();
|
|
41
|
+
const setCopiedSheetRange = useSetCopiedSheetRange();
|
|
41
42
|
const [copiedSelections, setCopiedSelections] = useState(DEFAULT_ARRAY);
|
|
42
43
|
// SheetId of the copied selection
|
|
43
44
|
const copiedSheetIdRef = useRef(undefined);
|
|
@@ -168,7 +169,8 @@ export const useCopyPasteCut = ({ selections, activeCell, sheetId, readonly = fa
|
|
|
168
169
|
return;
|
|
169
170
|
}
|
|
170
171
|
setCopiedSelections(DEFAULT_ARRAY);
|
|
171
|
-
|
|
172
|
+
setCopiedSheetRange(undefined);
|
|
173
|
+
}, [setCopiedSheetRange]);
|
|
172
174
|
// Dismissing the cut marquee (Esc, or an Insert Cut Cells that consumed it)
|
|
173
175
|
// also cancels the pending cut — Excel drops the cut with the marquee.
|
|
174
176
|
const cancelCut = useCallback(() => {
|
|
@@ -176,7 +178,8 @@ export const useCopyPasteCut = ({ selections, activeCell, sheetId, readonly = fa
|
|
|
176
178
|
setIsCutPending(false);
|
|
177
179
|
initialCopiedSelectionRef.current = undefined;
|
|
178
180
|
setCopiedSelections(DEFAULT_ARRAY);
|
|
179
|
-
|
|
181
|
+
setCopiedSheetRange(undefined);
|
|
182
|
+
}, [setCopiedSheetRange]);
|
|
180
183
|
// Copy current selection. Returns false when the consumer refused the copy
|
|
181
184
|
// (e.g. a multi-area selection Excel won't copy): the clipboard, the copied
|
|
182
185
|
// highlight and the default browser action are then left untouched.
|
|
@@ -199,8 +202,12 @@ export const useCopyPasteCut = ({ selections, activeCell, sheetId, readonly = fa
|
|
|
199
202
|
// Set initial copied selections
|
|
200
203
|
// So users can paste selection multiple times
|
|
201
204
|
initialCopiedSelectionRef.current = currentSelections;
|
|
205
|
+
// What Paste Special ▸ Linked Picture links to: a single-area copy only.
|
|
206
|
+
setCopiedSheetRange(!isCutOperation && currentSelections.length === 1
|
|
207
|
+
? { sheetId: copiedSheetIdRef.current, ...currentSelections[0].range }
|
|
208
|
+
: undefined);
|
|
202
209
|
return true;
|
|
203
|
-
}, [onCopyRef, getSelections, getActiveSheetId, sheetId]);
|
|
210
|
+
}, [onCopyRef, getSelections, getActiveSheetId, sheetId, setCopiedSheetRange]);
|
|
204
211
|
// Cut operation. A readonly grid cannot remove the cells, so the gesture
|
|
205
212
|
// degrades to a copy: the clipboard still receives the selection, but no
|
|
206
213
|
// cut is pending and `onCut` is never reached.
|