@rowsncolumns/spreadsheet 10.8.2 → 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 +7 -0
- package/dist/cjs/components/canvas-grid/helpers.d.ts.map +1 -1
- package/dist/cjs/components/canvas-grid/helpers.js +35 -1
- package/dist/cjs/components/canvas-grid/index.d.ts.map +1 -1
- package/dist/cjs/components/canvas-grid/index.js +282 -90
- package/dist/cjs/components/canvas-grid/typings.d.ts +65 -3
- 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/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-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 +7 -0
- package/dist/esm/components/canvas-grid/helpers.d.ts.map +1 -1
- package/dist/esm/components/canvas-grid/helpers.js +22 -0
- package/dist/esm/components/canvas-grid/index.d.ts.map +1 -1
- package/dist/esm/components/canvas-grid/index.js +207 -26
- package/dist/esm/components/canvas-grid/typings.d.ts +65 -3
- 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/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-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 +3 -3
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { EmbeddedObject } from "../../types";
|
|
3
3
|
import type { CanvasGridProps, SpreadsheetTheme } from "../canvas-grid/typings";
|
|
4
|
+
import { type GetLinkedPictureSource } from "./linked-picture";
|
|
4
5
|
export type EmbedComponentProps = {
|
|
5
6
|
embed: EmbeddedObject;
|
|
6
7
|
theme: SpreadsheetTheme;
|
|
@@ -12,6 +13,11 @@ export type EmbedComponentProps = {
|
|
|
12
13
|
readonly?: boolean;
|
|
13
14
|
onDeleteEmbed: CanvasGridProps["onDeleteEmbed"];
|
|
14
15
|
onRequestEditEmbed: CanvasGridProps["onRequestEditEmbed"];
|
|
16
|
+
/**
|
|
17
|
+
* Reads a linked picture's source range (see `CanvasGridProps.getLinkedPictureSource`).
|
|
18
|
+
* A new function whenever the source cells change is what redraws the picture.
|
|
19
|
+
*/
|
|
20
|
+
getLinkedPictureSource?: GetLinkedPictureSource;
|
|
15
21
|
};
|
|
16
|
-
export declare const EmbedComponent: React.MemoExoticComponent<({ embed, width, height, readonly, isSelected, onDeleteEmbed, onRequestEditEmbed, theme, }: EmbedComponentProps) => React.JSX.Element>;
|
|
22
|
+
export declare const EmbedComponent: React.MemoExoticComponent<({ embed, width, height, readonly, isSelected, onDeleteEmbed, onRequestEditEmbed, theme, getLinkedPictureSource, }: EmbedComponentProps) => React.JSX.Element>;
|
|
17
23
|
//# sourceMappingURL=embed-component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embed-component.d.ts","sourceRoot":"","sources":["../../../../components/embeds/embed-component.tsx"],"names":[],"mappings":"AASA,OAAO,KAAe,MAAM,OAAO,CAAC;AAEpC,OAAO,KAAK,EACV,cAAc,EAKf,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"embed-component.d.ts","sourceRoot":"","sources":["../../../../components/embeds/embed-component.tsx"],"names":[],"mappings":"AASA,OAAO,KAAe,MAAM,OAAO,CAAC;AAEpC,OAAO,KAAK,EACV,cAAc,EAKf,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAIhF,OAAO,EACL,KAAK,sBAAsB,EAG5B,MAAM,kBAAkB,CAAC;AAE1B,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,cAAc,CAAC;IACtB,KAAK,EAAE,gBAAgB,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,eAAe,CAAC,eAAe,CAAC,CAAC;IAChD,kBAAkB,EAAE,eAAe,CAAC,oBAAoB,CAAC,CAAC;IAC1D;;;OAGG;IACH,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;CACjD,CAAC;AAEF,eAAO,MAAM,cAAc,gJAWtB,mBAAmB,uBA4OvB,CAAC"}
|
|
@@ -4,7 +4,8 @@ import React, { memo } from "react";
|
|
|
4
4
|
import { getStringifiedColor, resolveThemeFontFamily } from "../../themes";
|
|
5
5
|
import { resolveCanvasTextAlign } from "../cell/alignment";
|
|
6
6
|
import { ShapeSvg } from "./shape-svg";
|
|
7
|
-
|
|
7
|
+
import { isLinkedPictureSpec, LinkedPictureView, } from "./linked-picture";
|
|
8
|
+
export const EmbedComponent = memo(({ embed, width, height, readonly, isSelected, onDeleteEmbed, onRequestEditEmbed, theme, getLinkedPictureSource, }) => {
|
|
8
9
|
const renderTextBox = (spec) => {
|
|
9
10
|
const backgroundColor = spec.backgroundColor
|
|
10
11
|
? getStringifiedColor(spec.backgroundColor, theme)
|
|
@@ -105,6 +106,9 @@ export const EmbedComponent = memo(({ embed, width, height, readonly, isSelected
|
|
|
105
106
|
};
|
|
106
107
|
return (React.createElement("div", { className: "flex-1 flex break-words flex-col" },
|
|
107
108
|
embed?.spec.type === "image" ? (React.createElement("img", { className: "max-w-full max-h-full", alt: embed.spec.description, draggable: false, width: width, height: height, src: embed.spec.imageUrl, crossOrigin: "anonymous" })) : null,
|
|
109
|
+
isLinkedPictureSpec(embed?.spec) ? (React.createElement(LinkedPictureView, { sourceRange: embed.spec.sourceRange, source: embed.spec.sourceRange
|
|
110
|
+
? getLinkedPictureSource?.(embed.spec.sourceRange)
|
|
111
|
+
: undefined, width: width, height: height })) : null,
|
|
108
112
|
embed?.spec.type === "textbox"
|
|
109
113
|
? renderTextBox(embed.spec)
|
|
110
114
|
: null,
|
|
@@ -69,6 +69,8 @@ type EmbedDraggableProps = Omit<React.HTMLAttributes<HTMLDivElement>, "id" | "on
|
|
|
69
69
|
* @param id
|
|
70
70
|
*/
|
|
71
71
|
onDeselect?(id: string | number): void;
|
|
72
|
+
/** Ctrl/Cmd+A with the object selected: select every object on the sheet (Excel). */
|
|
73
|
+
onSelectAllObjects?(): void;
|
|
72
74
|
/**
|
|
73
75
|
* Double-click on the object (Excel opens the format pane; the chart
|
|
74
76
|
* editor here)
|
|
@@ -95,6 +97,6 @@ type EmbedDraggableProps = Omit<React.HTMLAttributes<HTMLDivElement>, "id" | "on
|
|
|
95
97
|
anchorCell: CellInterface;
|
|
96
98
|
children: (width: number, height: number) => React.ReactNode;
|
|
97
99
|
};
|
|
98
|
-
export declare const EmbedDraggable: ({ id, scale, height, width, offsetXPixels, offsetYPixels, isSelected, borderColor, lockAspectRatio, zIndex, resizable, draggable, children, onMove, onResize, onDelete, onDuplicate, onCopy, onCut, onPaste, onDeselect, onDoubleClick, snapToGrid, onRequestContextMenu, onMouseMove, onPointerDown, bounds, anchorCell, toCell, toOffsetXPixels, toOffsetYPixels, }: EmbedDraggableProps) => React.JSX.Element;
|
|
100
|
+
export declare const EmbedDraggable: ({ id, scale, height, width, offsetXPixels, offsetYPixels, isSelected, borderColor, lockAspectRatio, zIndex, resizable, draggable, children, onMove, onResize, onDelete, onDuplicate, onCopy, onCut, onPaste, onDeselect, onDoubleClick, snapToGrid, onRequestContextMenu, onMouseMove, onPointerDown, onSelectAllObjects, bounds, anchorCell, toCell, toOffsetXPixels, toOffsetYPixels, }: EmbedDraggableProps) => React.JSX.Element;
|
|
99
101
|
export {};
|
|
100
102
|
//# sourceMappingURL=embed-draggable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embed-draggable.d.ts","sourceRoot":"","sources":["../../../../components/embeds/embed-draggable.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGxD,OAAO,KAAwC,MAAM,OAAO,CAAC;AAC7D,OAAO,KAAK,EACV,eAAe,EAGhB,MAAM,iBAAiB,CAAC;AAOzB,KAAK,mBAAmB,GAAG,IAAI,CAC7B,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAClC,IAAI,GACJ,UAAU,GACV,UAAU,GACV,QAAQ,GACR,OAAO,GACP,SAAS,GACT,eAAe,CAClB,GAAG;IACF,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;;OAMG;IACH,MAAM,CAAC,CACL,EAAE,EAAE,MAAM,GAAG,MAAM,EACnB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,IAAI,CAA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tB,IAAI,CAAC;IACR;;OAEG;IACH,UAAU,EAAE,aAAa,CAAC;IAC1B,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC;CAC9D,CAAC;AA4DF,eAAO,MAAM,cAAc,GAAI,
|
|
1
|
+
{"version":3,"file":"embed-draggable.d.ts","sourceRoot":"","sources":["../../../../components/embeds/embed-draggable.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGxD,OAAO,KAAwC,MAAM,OAAO,CAAC;AAC7D,OAAO,KAAK,EACV,eAAe,EAGhB,MAAM,iBAAiB,CAAC;AAOzB,KAAK,mBAAmB,GAAG,IAAI,CAC7B,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAClC,IAAI,GACJ,UAAU,GACV,UAAU,GACV,QAAQ,GACR,OAAO,GACP,SAAS,GACT,eAAe,CAClB,GAAG;IACF,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,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AE,MAAM,GAAG;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;IACxE;;;;OAIG;IACH,oBAAoB,CAAC,CACnB,EAAE,EAAE,MAAM,GAAG,MAAM,EACnB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,cAAc,GACtB,IAAI,CAAC;IACR;;OAEG;IACH,UAAU,EAAE,aAAa,CAAC;IAC1B,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC;CAC9D,CAAC;AA4DF,eAAO,MAAM,cAAc,GAAI,2XAiC5B,mBAAmB,sBAyWrB,CAAC"}
|
|
@@ -34,7 +34,7 @@ const resizeHandles = [
|
|
|
34
34
|
"nw",
|
|
35
35
|
"sw",
|
|
36
36
|
];
|
|
37
|
-
export const EmbedDraggable = ({ id, scale = 1, height, width, offsetXPixels, offsetYPixels, isSelected, borderColor, lockAspectRatio, zIndex, resizable = true, draggable = true, children, onMove, onResize, onDelete, onDuplicate, onCopy, onCut, onPaste, onDeselect, onDoubleClick, snapToGrid, onRequestContextMenu, onMouseMove, onPointerDown, bounds, anchorCell, toCell, toOffsetXPixels = 0, toOffsetYPixels = 0, }) => {
|
|
37
|
+
export const EmbedDraggable = ({ id, scale = 1, height, width, offsetXPixels, offsetYPixels, isSelected, borderColor, lockAspectRatio, zIndex, resizable = true, draggable = true, children, onMove, onResize, onDelete, onDuplicate, onCopy, onCut, onPaste, onDeselect, onDoubleClick, snapToGrid, onRequestContextMenu, onMouseMove, onPointerDown, onSelectAllObjects, bounds, anchorCell, toCell, toOffsetXPixels = 0, toOffsetYPixels = 0, }) => {
|
|
38
38
|
const { getCellOffsetFromCoords } = useGridContext();
|
|
39
39
|
const position = getCellOffsetFromCoords?.(anchorCell);
|
|
40
40
|
const x = (position?.x ?? 0) + offsetXPixels;
|
|
@@ -241,6 +241,15 @@ export const EmbedDraggable = ({ id, scale = 1, height, width, offsetXPixels, of
|
|
|
241
241
|
onDuplicate(id);
|
|
242
242
|
return;
|
|
243
243
|
}
|
|
244
|
+
if ((e.metaKey || e.ctrlKey) &&
|
|
245
|
+
!e.altKey &&
|
|
246
|
+
!e.shiftKey &&
|
|
247
|
+
e.key.toLowerCase() === "a" &&
|
|
248
|
+
onSelectAllObjects) {
|
|
249
|
+
e.preventDefault();
|
|
250
|
+
onSelectAllObjects();
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
244
253
|
if (e.key === "Escape") {
|
|
245
254
|
e.preventDefault();
|
|
246
255
|
onDeselect?.(id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/embeds/index.tsx"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/embeds/index.tsx"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { CellData, CellFormat, GridRange, SheetRange } from "@rowsncolumns/common-types";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import type { EmbedLinkedPictureSpec, Sheet } from "../../types";
|
|
4
|
+
/** Reads the cells, sizes and merges of a linked picture's source sheet. */
|
|
5
|
+
export type LinkedPictureSource = {
|
|
6
|
+
getFormattedValue(rowIndex: number, columnIndex: number): string | null | undefined;
|
|
7
|
+
getEffectiveFormat(rowIndex: number, columnIndex: number): CellFormat | null | undefined;
|
|
8
|
+
getCellData?(rowIndex: number, columnIndex: number): CellData | null | undefined;
|
|
9
|
+
/** Unscaled pixel height; `0` for a hidden row (Excel leaves it out of the picture). */
|
|
10
|
+
getRowHeight(rowIndex: number): number;
|
|
11
|
+
/** Unscaled pixel width; `0` for a hidden column. */
|
|
12
|
+
getColumnWidth(columnIndex: number): number;
|
|
13
|
+
merges?: GridRange[] | null;
|
|
14
|
+
/** The source sheet shows gridlines — Excel then draws them in the picture too. */
|
|
15
|
+
showGridLines?: boolean;
|
|
16
|
+
};
|
|
17
|
+
/** Resolve the source accessor for a linked picture's range (`undefined`: not readable here). */
|
|
18
|
+
export type GetLinkedPictureSource = (range: SheetRange) => LinkedPictureSource | undefined;
|
|
19
|
+
export declare const isLinkedPictureSpec: (spec: {
|
|
20
|
+
type?: string;
|
|
21
|
+
} | null | undefined) => spec is EmbedLinkedPictureSpec;
|
|
22
|
+
/**
|
|
23
|
+
* A linked picture's formula as Excel shows it in the formula bar while the
|
|
24
|
+
* picture is selected: `=$A$1:$C$5` on its own sheet, `=Sheet1!$A$1:$C$5` /
|
|
25
|
+
* `='My Data'!$A$1:$C$5` on another, `=#REF!` once its source was deleted.
|
|
26
|
+
*/
|
|
27
|
+
export declare const linkedPictureFormula: (sourceRange: SheetRange | null | undefined, pictureSheetId: number, getSheetName?: (sheetId: number) => string | undefined) => string;
|
|
28
|
+
/**
|
|
29
|
+
* A {@link GetLinkedPictureSource} over the host's sheet list and its
|
|
30
|
+
* workbook-wide cell accessors (`useSpreadsheetState`'s): a picture of any
|
|
31
|
+
* sheet reads that sheet's sizes, merges and gridline setting.
|
|
32
|
+
*/
|
|
33
|
+
export declare const createLinkedPictureSourceResolver: ({ sheets, getFormattedValue, getEffectiveFormat, getCellData, defaultRowHeight, defaultColumnWidth, }: {
|
|
34
|
+
sheets: readonly Sheet[] | null | undefined;
|
|
35
|
+
getFormattedValue?: (sheetId: number, rowIndex: number, columnIndex: number) => string | null | undefined;
|
|
36
|
+
getEffectiveFormat?: (sheetId: number, rowIndex: number, columnIndex: number) => CellFormat | null | undefined;
|
|
37
|
+
getCellData?: (sheetId: number, rowIndex: number, columnIndex: number) => CellData | null | undefined;
|
|
38
|
+
defaultRowHeight: number;
|
|
39
|
+
defaultColumnWidth: number;
|
|
40
|
+
}) => GetLinkedPictureSource;
|
|
41
|
+
export type LinkedPictureViewProps = {
|
|
42
|
+
sourceRange: SheetRange | null | undefined;
|
|
43
|
+
source: LinkedPictureSource | undefined;
|
|
44
|
+
/** The frame the picture is stretched to (Excel scales a resized picture). */
|
|
45
|
+
width: number;
|
|
46
|
+
height: number;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Draw a linked picture: the source range as a table at its natural size,
|
|
50
|
+
* stretched to the frame. A deleted source (`#REF!`) or one this host cannot
|
|
51
|
+
* read draws blank, as Excel's picture does.
|
|
52
|
+
*/
|
|
53
|
+
export declare const LinkedPictureView: React.MemoExoticComponent<({ sourceRange, source, width, height }: LinkedPictureViewProps) => React.JSX.Element>;
|
|
54
|
+
//# sourceMappingURL=linked-picture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linked-picture.d.ts","sourceRoot":"","sources":["../../../../components/embeds/linked-picture.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,QAAQ,EACR,UAAU,EACV,SAAS,EACT,UAAU,EACX,MAAM,4BAA4B,CAAC;AAGpC,OAAO,KAAwB,MAAM,OAAO,CAAC;AAE7C,OAAO,KAAK,EAAuB,sBAAsB,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAItF,4EAA4E;AAC5E,MAAM,MAAM,mBAAmB,GAAG;IAChC,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACpF,kBAAkB,CAChB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,GAClB,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC;IACjC,WAAW,CAAC,CAAC,QAAQ,EAAE,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M,EAChB,WAAW,EAAE,MAAM,KAChB,QAAQ,GAAG,IAAI,GAAG,SAAS,CAAC;IACjC,gBAAgB,EAAE,MAAM,CAAC;IACzB,kBAAkB,EAAE,MAAM,CAAC;CAC5B,KAAG,sBAoBH,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,WAAW,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC;IAC3C,MAAM,EAAE,mBAAmB,GAAG,SAAS,CAAC;IACxC,8EAA8E;IAC9E,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAIF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,qEACa,sBAAsB,uBAoJhE,CAAC"}
|
|
@@ -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;;wE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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
|