@rowsncolumns/spreadsheet 10.17.0 → 10.19.1
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/fill-series.d.ts +18 -0
- package/dist/cjs/api/fill-series.d.ts.map +1 -1
- package/dist/cjs/api/fill-series.js +95 -1
- package/dist/cjs/atoms/cell-input-context.atom.d.ts.map +1 -1
- package/dist/cjs/atoms/fill-series-dialog.atom.d.ts +6 -0
- package/dist/cjs/atoms/fill-series-dialog.atom.d.ts.map +1 -1
- package/dist/cjs/atoms/frozen-area-sent.atom.d.ts +42 -0
- package/dist/cjs/atoms/frozen-area-sent.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/frozen-area-sent.atom.js +29 -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/undo-redo-sent.atom.d.ts +25 -0
- package/dist/cjs/atoms/undo-redo-sent.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/undo-redo-sent.atom.js +23 -0
- package/dist/cjs/components/canvas-grid/frozen-start.d.ts +145 -0
- package/dist/cjs/components/canvas-grid/frozen-start.d.ts.map +1 -0
- package/dist/cjs/components/canvas-grid/frozen-start.js +273 -0
- package/dist/cjs/components/canvas-grid/index.d.ts.map +1 -1
- package/dist/cjs/components/canvas-grid/index.js +585 -70
- package/dist/cjs/components/canvas-grid/typings.d.ts +31 -8
- package/dist/cjs/components/canvas-grid/typings.d.ts.map +1 -1
- package/dist/cjs/components/embeds/embed-draggable.d.ts.map +1 -1
- package/dist/cjs/components/embeds/embed-draggable.js +10 -8
- package/dist/cjs/components/embeds/object-cell-offset.d.ts +10 -0
- package/dist/cjs/components/embeds/object-cell-offset.d.ts.map +1 -0
- package/dist/cjs/components/embeds/object-cell-offset.js +12 -0
- package/dist/cjs/components/fill-series-dialog/index.d.ts +10 -1
- package/dist/cjs/components/fill-series-dialog/index.d.ts.map +1 -1
- package/dist/cjs/components/fill-series-dialog/index.js +14 -4
- package/dist/cjs/hooks/use-export-range.d.ts +12 -1
- package/dist/cjs/hooks/use-export-range.d.ts.map +1 -1
- package/dist/cjs/hooks/use-export-range.js +75 -35
- package/dist/cjs/hooks/use-grid-children.d.ts +20 -1
- package/dist/cjs/hooks/use-grid-children.d.ts.map +1 -1
- package/dist/cjs/hooks/use-grid-children.js +53 -19
- package/dist/cjs/hooks/use-header-actions.d.ts +3 -1
- package/dist/cjs/hooks/use-header-actions.d.ts.map +1 -1
- package/dist/cjs/hooks/use-header-actions.js +5 -4
- package/dist/cjs/hooks/use-hidden-dimension-markers.d.ts +7 -1
- package/dist/cjs/hooks/use-hidden-dimension-markers.d.ts.map +1 -1
- package/dist/cjs/hooks/use-hidden-dimension-markers.js +9 -5
- package/dist/cjs/hooks/use-selection-interceptors.d.ts +7 -1
- package/dist/cjs/hooks/use-selection-interceptors.d.ts.map +1 -1
- package/dist/cjs/hooks/use-selection-interceptors.js +14 -3
- package/dist/cjs/hooks/use-selection.d.ts +8 -1
- package/dist/cjs/hooks/use-selection.d.ts.map +1 -1
- package/dist/cjs/hooks/use-selection.js +39 -9
- package/dist/cjs/hooks/use-sizer.d.ts +9 -1
- package/dist/cjs/hooks/use-sizer.d.ts.map +1 -1
- package/dist/cjs/hooks/use-sizer.js +5 -3
- package/dist/cjs/release-date.js +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/cjs/types.d.ts +7 -0
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/esm/api/fill-series.d.ts +18 -0
- package/dist/esm/api/fill-series.d.ts.map +1 -1
- package/dist/esm/api/fill-series.js +89 -0
- package/dist/esm/atoms/cell-input-context.atom.d.ts.map +1 -1
- package/dist/esm/atoms/fill-series-dialog.atom.d.ts +6 -0
- package/dist/esm/atoms/fill-series-dialog.atom.d.ts.map +1 -1
- package/dist/esm/atoms/frozen-area-sent.atom.d.ts +42 -0
- package/dist/esm/atoms/frozen-area-sent.atom.d.ts.map +1 -0
- package/dist/esm/atoms/frozen-area-sent.atom.js +21 -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/undo-redo-sent.atom.d.ts +25 -0
- package/dist/esm/atoms/undo-redo-sent.atom.d.ts.map +1 -0
- package/dist/esm/atoms/undo-redo-sent.atom.js +18 -0
- package/dist/esm/components/canvas-grid/frozen-start.d.ts +145 -0
- package/dist/esm/components/canvas-grid/frozen-start.d.ts.map +1 -0
- package/dist/esm/components/canvas-grid/frozen-start.js +229 -0
- package/dist/esm/components/canvas-grid/index.d.ts.map +1 -1
- package/dist/esm/components/canvas-grid/index.js +507 -16
- package/dist/esm/components/canvas-grid/typings.d.ts +31 -8
- package/dist/esm/components/canvas-grid/typings.d.ts.map +1 -1
- package/dist/esm/components/embeds/embed-draggable.d.ts.map +1 -1
- package/dist/esm/components/embeds/embed-draggable.js +3 -1
- package/dist/esm/components/embeds/object-cell-offset.d.ts +10 -0
- package/dist/esm/components/embeds/object-cell-offset.d.ts.map +1 -0
- package/dist/esm/components/embeds/object-cell-offset.js +9 -0
- package/dist/esm/components/fill-series-dialog/index.d.ts +10 -1
- package/dist/esm/components/fill-series-dialog/index.d.ts.map +1 -1
- package/dist/esm/components/fill-series-dialog/index.js +14 -4
- package/dist/esm/hooks/use-export-range.d.ts +12 -1
- package/dist/esm/hooks/use-export-range.d.ts.map +1 -1
- package/dist/esm/hooks/use-export-range.js +31 -4
- package/dist/esm/hooks/use-grid-children.d.ts +20 -1
- package/dist/esm/hooks/use-grid-children.d.ts.map +1 -1
- package/dist/esm/hooks/use-grid-children.js +46 -15
- package/dist/esm/hooks/use-header-actions.d.ts +3 -1
- package/dist/esm/hooks/use-header-actions.d.ts.map +1 -1
- package/dist/esm/hooks/use-header-actions.js +3 -2
- package/dist/esm/hooks/use-hidden-dimension-markers.d.ts +7 -1
- package/dist/esm/hooks/use-hidden-dimension-markers.d.ts.map +1 -1
- package/dist/esm/hooks/use-hidden-dimension-markers.js +7 -3
- package/dist/esm/hooks/use-selection-interceptors.d.ts +7 -1
- package/dist/esm/hooks/use-selection-interceptors.d.ts.map +1 -1
- package/dist/esm/hooks/use-selection-interceptors.js +15 -4
- package/dist/esm/hooks/use-selection.d.ts +8 -1
- package/dist/esm/hooks/use-selection.d.ts.map +1 -1
- package/dist/esm/hooks/use-selection.js +35 -5
- package/dist/esm/hooks/use-sizer.d.ts +9 -1
- package/dist/esm/hooks/use-sizer.d.ts.map +1 -1
- package/dist/esm/hooks/use-sizer.js +5 -3
- package/dist/esm/release-date.js +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/esm/types.d.ts +7 -0
- package/dist/esm/types.d.ts.map +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import type { CellInterface, CellPosition, ItemSizeHint } from "@rowsncolumns/grid";
|
|
2
|
+
/**
|
|
3
|
+
* A sheet frozen while scrolled (demo-app-monorepo#57258 W-5): Excel's Freeze Panes on a sheet
|
|
4
|
+
* scrolled to row 40 freezes from row 40, and rows 1 … 39 stay out of view above the frozen band
|
|
5
|
+
* (`<sheetView topLeftCell>` of a frozen view, stored as `frozenRowStart` / `frozenColumnStart`).
|
|
6
|
+
*
|
|
7
|
+
* The grid draws this with two things only: the rows / columns above the start get NO SIZE in what
|
|
8
|
+
* the grid lays out, and the grid's frozen count covers them (`start − 1 + count`). Everything that
|
|
9
|
+
* is not layout (copy, paste, fill, sort, filters, Find, auto-fit, export, print, the stored sizes)
|
|
10
|
+
* keeps reading the sheet's own sizes and sees those rows as ordinary rows. With no start (or a
|
|
11
|
+
* start of 1) every helper here hands back what it was given, so nothing changes.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* How many rows (or columns) sit above the frozen start: `start − 1`, or 0 when there is no start,
|
|
15
|
+
* the start is 1, nothing is frozen on that axis, or the frozen area would run past the sheet (the
|
|
16
|
+
* engine does not store such a start; a hand-edited document is drawn as if it had none).
|
|
17
|
+
*/
|
|
18
|
+
export declare const linesAboveFrozenStart: (start: number | null | undefined, frozenCount: number | null | undefined, lineCount: number) => number;
|
|
19
|
+
/** Whether a grid row / column index (1-based sheet line) lies above the frozen start. */
|
|
20
|
+
export declare const isAboveFrozenStart: (index: number, linesAbove: number) => boolean;
|
|
21
|
+
/** The grid's size function: lines above the start have no size. The same function without a start. */
|
|
22
|
+
export declare const sizeAboveFrozenStartZero: (size: (index: number) => number, linesAbove: number) => ((index: number) => number);
|
|
23
|
+
type Range = {
|
|
24
|
+
start: number;
|
|
25
|
+
end: number;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* The grid's visible row ranges without the rows above the start: the grid treats rows outside
|
|
29
|
+
* them as having no height (its size-hint path never asks their size). The same array without a
|
|
30
|
+
* start.
|
|
31
|
+
*/
|
|
32
|
+
export declare const rangesWithoutLinesAboveFrozenStart: <T extends Range>(ranges: T[], linesAbove: number) => T[];
|
|
33
|
+
/**
|
|
34
|
+
* The grid's column size hint with the columns above the start listed as exceptions (the grid then
|
|
35
|
+
* asks their size, which is 0). At most 16,383 columns; the same hint without a start.
|
|
36
|
+
*/
|
|
37
|
+
export declare const sizeHintWithLinesAboveFrozenStart: (hint: ItemSizeHint, linesAbove: number) => ItemSizeHint;
|
|
38
|
+
/**
|
|
39
|
+
* The sum of the sheet's own (unscaled) sizes of lines `from … to`, measured the way the grid's
|
|
40
|
+
* size hint describes them: `defaultSize` for every line between exceptions, `size(e)` for an
|
|
41
|
+
* exception, 0 for a line outside `visibleRanges` (rows hidden by a filter). O(exceptions and ranges
|
|
42
|
+
* in the span), whatever its length, so a start at row 1,000,000 costs no more than one at row 40.
|
|
43
|
+
*/
|
|
44
|
+
export declare const sumLineSizes: ({ from, to, size, hint, visibleRanges, }: {
|
|
45
|
+
from: number;
|
|
46
|
+
to: number;
|
|
47
|
+
size: (index: number) => number;
|
|
48
|
+
hint: ItemSizeHint;
|
|
49
|
+
visibleRanges?: Range[];
|
|
50
|
+
}) => number;
|
|
51
|
+
/**
|
|
52
|
+
* Where an OBJECT lays out a cell (charts, pictures, slicers): the grid's own answer, except for a
|
|
53
|
+
* cell above the frozen start, which is placed where it would be if those lines kept their size:
|
|
54
|
+
* that far above the first frozen line. An object anchored there is then drawn cut at the top of
|
|
55
|
+
* the frozen band (or not at all, when it lies wholly above), never squashed onto the band's edge.
|
|
56
|
+
* `distanceAbove(axis, index)` is the scaled distance from the line's top / left edge to the start.
|
|
57
|
+
*/
|
|
58
|
+
export declare const objectCellOffsetAboveFrozenStart: ({ getCellOffsetFromCoords, rowsAbove, columnsAbove, rowSize, columnSize, distanceAbove, }: {
|
|
59
|
+
getCellOffsetFromCoords: (cell: CellInterface) => CellPosition | undefined;
|
|
60
|
+
rowsAbove: number;
|
|
61
|
+
columnsAbove: number;
|
|
62
|
+
/** Scaled size of one line, as the sheet stores it. */
|
|
63
|
+
rowSize: (index: number) => number;
|
|
64
|
+
columnSize: (index: number) => number;
|
|
65
|
+
distanceAbove: (axis: "row" | "column", index: number) => number;
|
|
66
|
+
}) => (cell: CellInterface) => CellPosition | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Freeze Panes up to a line ("Freeze up to Row 45"): Excel freezes from the top line on screen,
|
|
69
|
+
* `firstShown`, so the count is measured from there and the start is sent when it is not line 1. A
|
|
70
|
+
* line above `firstShown` (reached with the keyboard on a sheet frozen from a start) freezes from
|
|
71
|
+
* line 1. 0 unfreezes, and an unfreeze carries no start.
|
|
72
|
+
*/
|
|
73
|
+
export declare const freezeUpTo: (line: number, firstShown: number) => {
|
|
74
|
+
count: number;
|
|
75
|
+
start?: number;
|
|
76
|
+
};
|
|
77
|
+
/** One axis of a frozen area as the grid lays it out: lines above the start, frozen lines. */
|
|
78
|
+
export type FrozenAxis = {
|
|
79
|
+
lines: number;
|
|
80
|
+
count: number;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* What this window just sent that may change the frozen area: a freeze or unfreeze (with the area
|
|
84
|
+
* it asked for and where the view was), or an undo / redo. Read by the next change on the axis,
|
|
85
|
+
* whatever it turns out to be, and dropped then.
|
|
86
|
+
*/
|
|
87
|
+
export type PendingFreeze = {
|
|
88
|
+
kind: "freeze";
|
|
89
|
+
expected: FrozenAxis;
|
|
90
|
+
scrollBefore: number;
|
|
91
|
+
} | {
|
|
92
|
+
kind: "undo";
|
|
93
|
+
} | {
|
|
94
|
+
kind: "redo";
|
|
95
|
+
};
|
|
96
|
+
/** The last freeze or unfreeze from a start this window made, while nothing else has changed the area. */
|
|
97
|
+
export type LocalFreeze = {
|
|
98
|
+
before: FrozenAxis;
|
|
99
|
+
after: FrozenAxis;
|
|
100
|
+
scrollBefore: number;
|
|
101
|
+
};
|
|
102
|
+
/** Where the view was on one axis before a frozen area changed, read in the old layout. */
|
|
103
|
+
export type FrozenViewSnapshot = {
|
|
104
|
+
/** The first scrolling line on screen. */
|
|
105
|
+
topLine: number;
|
|
106
|
+
/** How far into it the view was scrolled (px). */
|
|
107
|
+
intoLine: number;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Where one axis of the view goes when its frozen area changes and a start is involved
|
|
111
|
+
* (demo-app-monorepo#57258 W-5). `undefined` = leave the scroll position as it is (every change
|
|
112
|
+
* without a start, as before).
|
|
113
|
+
*
|
|
114
|
+
* The rule: **a window's view is repositioned only by a freeze, unfreeze, undo or redo that this
|
|
115
|
+
* window itself just sent, and by nothing else.** `pending` is what this window just sent; the change
|
|
116
|
+
* that follows reads it and drops it, matched or not.
|
|
117
|
+
*
|
|
118
|
+
* - **This window's freeze or unfreeze** (`pending.kind` "freeze", and the area is the one it asked
|
|
119
|
+
* for): freezing from a start puts the scrolling area right below the band (0); unfreezing keeps
|
|
120
|
+
* the start's line first on screen. Remembered as `local`, for this window's undo / redo of it.
|
|
121
|
+
* - **This window's undo** (`pending.kind` "undo", taking the area from `local.after` back to
|
|
122
|
+
* `local.before`): back where the view was before the freeze. Its **redo**: as the freeze did.
|
|
123
|
+
* - **Anything else** (another window's freeze, unfreeze, undo or redo, or a change that does not
|
|
124
|
+
* match what this window sent): the same line stays first on screen, at the same depth; the scroll
|
|
125
|
+
* moves by the band's change. When that line now lies in the band or above the start it cannot
|
|
126
|
+
* stay: the view lands on the first scrolling line (0). `local` is forgotten: a later change of the
|
|
127
|
+
* same shape is someone else's.
|
|
128
|
+
*
|
|
129
|
+
* `offset(index)` is a line's offset in the NEW layout; scroll positions are measured from the first
|
|
130
|
+
* scrolling line, as the grid's are.
|
|
131
|
+
*/
|
|
132
|
+
export declare const frozenStartScroll: ({ before, after, pending, local, snapshot, offset, }: {
|
|
133
|
+
before: FrozenAxis;
|
|
134
|
+
after: FrozenAxis;
|
|
135
|
+
pending?: PendingFreeze;
|
|
136
|
+
local?: LocalFreeze;
|
|
137
|
+
snapshot?: FrozenViewSnapshot;
|
|
138
|
+
offset: (index: number) => number;
|
|
139
|
+
}) => {
|
|
140
|
+
scroll?: number;
|
|
141
|
+
consumed: boolean;
|
|
142
|
+
local?: LocalFreeze;
|
|
143
|
+
};
|
|
144
|
+
export {};
|
|
145
|
+
//# sourceMappingURL=frozen-start.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frozen-start.d.ts","sourceRoot":"","sources":["../../../../components/canvas-grid/frozen-start.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEpF;;;;;;;;;;GAUG;AAEH;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAChC,OAAO,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,aAAa,MAAM,GAAG,IAAI,GAAG,SAAS,EACtC,WAAW,MAAM,KAChB,MAOF,CAAC;AAEF,0FAA0F;AAC1F,eAAO,MAAM,kBAAkB,GAAI,OAAO,MAAM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OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,WAAW,CAAA;CAgC5D,CAAC"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A sheet frozen while scrolled (demo-app-monorepo#57258 W-5): Excel's Freeze Panes on a sheet
|
|
3
|
+
* scrolled to row 40 freezes from row 40, and rows 1 … 39 stay out of view above the frozen band
|
|
4
|
+
* (`<sheetView topLeftCell>` of a frozen view, stored as `frozenRowStart` / `frozenColumnStart`).
|
|
5
|
+
*
|
|
6
|
+
* The grid draws this with two things only: the rows / columns above the start get NO SIZE in what
|
|
7
|
+
* the grid lays out, and the grid's frozen count covers them (`start − 1 + count`). Everything that
|
|
8
|
+
* is not layout (copy, paste, fill, sort, filters, Find, auto-fit, export, print, the stored sizes)
|
|
9
|
+
* keeps reading the sheet's own sizes and sees those rows as ordinary rows. With no start (or a
|
|
10
|
+
* start of 1) every helper here hands back what it was given, so nothing changes.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* How many rows (or columns) sit above the frozen start: `start − 1`, or 0 when there is no start,
|
|
14
|
+
* the start is 1, nothing is frozen on that axis, or the frozen area would run past the sheet (the
|
|
15
|
+
* engine does not store such a start; a hand-edited document is drawn as if it had none).
|
|
16
|
+
*/
|
|
17
|
+
export const linesAboveFrozenStart = (start, frozenCount, lineCount) => {
|
|
18
|
+
const count = Math.floor(Number(frozenCount ?? 0));
|
|
19
|
+
if (!Number.isFinite(count) || count <= 0)
|
|
20
|
+
return 0;
|
|
21
|
+
const first = Math.floor(Number(start ?? 1));
|
|
22
|
+
if (!Number.isFinite(first) || first <= 1)
|
|
23
|
+
return 0;
|
|
24
|
+
if (first - 1 + count > lineCount)
|
|
25
|
+
return 0;
|
|
26
|
+
return first - 1;
|
|
27
|
+
};
|
|
28
|
+
/** Whether a grid row / column index (1-based sheet line) lies above the frozen start. */
|
|
29
|
+
export const isAboveFrozenStart = (index, linesAbove) => linesAbove > 0 && index >= 1 && index <= linesAbove;
|
|
30
|
+
/** The grid's size function: lines above the start have no size. The same function without a start. */
|
|
31
|
+
export const sizeAboveFrozenStartZero = (size, linesAbove) => linesAbove > 0
|
|
32
|
+
? (index) => (isAboveFrozenStart(index, linesAbove) ? 0 : size(index))
|
|
33
|
+
: size;
|
|
34
|
+
/**
|
|
35
|
+
* The grid's visible row ranges without the rows above the start: the grid treats rows outside
|
|
36
|
+
* them as having no height (its size-hint path never asks their size). The same array without a
|
|
37
|
+
* start.
|
|
38
|
+
*/
|
|
39
|
+
export const rangesWithoutLinesAboveFrozenStart = (ranges, linesAbove) => {
|
|
40
|
+
if (linesAbove <= 0)
|
|
41
|
+
return ranges;
|
|
42
|
+
const next = [];
|
|
43
|
+
for (const range of ranges) {
|
|
44
|
+
if (range.end < 1 || range.start > linesAbove) {
|
|
45
|
+
next.push(range);
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (range.start < 1)
|
|
49
|
+
next.push({ ...range, end: 0 });
|
|
50
|
+
if (range.end > linesAbove)
|
|
51
|
+
next.push({ ...range, start: linesAbove + 1 });
|
|
52
|
+
}
|
|
53
|
+
return next;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* The grid's column size hint with the columns above the start listed as exceptions (the grid then
|
|
57
|
+
* asks their size, which is 0). At most 16,383 columns; the same hint without a start.
|
|
58
|
+
*/
|
|
59
|
+
export const sizeHintWithLinesAboveFrozenStart = (hint, linesAbove) => {
|
|
60
|
+
if (linesAbove <= 0)
|
|
61
|
+
return hint;
|
|
62
|
+
const { exceptions } = hint;
|
|
63
|
+
const merged = [];
|
|
64
|
+
for (let i = 1; i <= linesAbove; i++)
|
|
65
|
+
merged.push(i);
|
|
66
|
+
for (let i = 0; i < exceptions.length; i++) {
|
|
67
|
+
if (exceptions[i] < 1 || exceptions[i] > linesAbove)
|
|
68
|
+
merged.push(exceptions[i]);
|
|
69
|
+
}
|
|
70
|
+
merged.sort((a, b) => a - b);
|
|
71
|
+
return { defaultSize: hint.defaultSize, exceptions: merged };
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* The sum of the sheet's own (unscaled) sizes of lines `from … to`, measured the way the grid's
|
|
75
|
+
* size hint describes them: `defaultSize` for every line between exceptions, `size(e)` for an
|
|
76
|
+
* exception, 0 for a line outside `visibleRanges` (rows hidden by a filter). O(exceptions and ranges
|
|
77
|
+
* in the span), whatever its length, so a start at row 1,000,000 costs no more than one at row 40.
|
|
78
|
+
*/
|
|
79
|
+
export const sumLineSizes = ({ from, to, size, hint, visibleRanges, }) => {
|
|
80
|
+
if (to < from)
|
|
81
|
+
return 0;
|
|
82
|
+
const { exceptions, defaultSize } = hint;
|
|
83
|
+
const isVisible = (index) => {
|
|
84
|
+
if (!visibleRanges)
|
|
85
|
+
return true;
|
|
86
|
+
let low = 0;
|
|
87
|
+
let high = visibleRanges.length - 1;
|
|
88
|
+
while (low <= high) {
|
|
89
|
+
const middle = (low + high) >> 1;
|
|
90
|
+
const range = visibleRanges[middle];
|
|
91
|
+
if (index < range.start)
|
|
92
|
+
high = middle - 1;
|
|
93
|
+
else if (index > range.end)
|
|
94
|
+
low = middle + 1;
|
|
95
|
+
else
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
return false;
|
|
99
|
+
};
|
|
100
|
+
let visibleCount = 0;
|
|
101
|
+
if (visibleRanges) {
|
|
102
|
+
for (const range of visibleRanges) {
|
|
103
|
+
const start = Math.max(range.start, from);
|
|
104
|
+
const end = Math.min(range.end, to);
|
|
105
|
+
if (end >= start)
|
|
106
|
+
visibleCount += end - start + 1;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
visibleCount = to - from + 1;
|
|
111
|
+
}
|
|
112
|
+
let total = visibleCount * defaultSize;
|
|
113
|
+
let low = 0;
|
|
114
|
+
let high = exceptions.length;
|
|
115
|
+
while (low < high) {
|
|
116
|
+
const middle = (low + high) >> 1;
|
|
117
|
+
if (exceptions[middle] < from)
|
|
118
|
+
low = middle + 1;
|
|
119
|
+
else
|
|
120
|
+
high = middle;
|
|
121
|
+
}
|
|
122
|
+
for (let i = low; i < exceptions.length && exceptions[i] <= to; i++) {
|
|
123
|
+
const index = exceptions[i];
|
|
124
|
+
total += size(index) - (isVisible(index) ? defaultSize : 0);
|
|
125
|
+
}
|
|
126
|
+
return total;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Where an OBJECT lays out a cell (charts, pictures, slicers): the grid's own answer, except for a
|
|
130
|
+
* cell above the frozen start, which is placed where it would be if those lines kept their size:
|
|
131
|
+
* that far above the first frozen line. An object anchored there is then drawn cut at the top of
|
|
132
|
+
* the frozen band (or not at all, when it lies wholly above), never squashed onto the band's edge.
|
|
133
|
+
* `distanceAbove(axis, index)` is the scaled distance from the line's top / left edge to the start.
|
|
134
|
+
*/
|
|
135
|
+
export const objectCellOffsetAboveFrozenStart = ({ getCellOffsetFromCoords, rowsAbove, columnsAbove, rowSize, columnSize, distanceAbove, }) => {
|
|
136
|
+
if (rowsAbove <= 0 && columnsAbove <= 0)
|
|
137
|
+
return getCellOffsetFromCoords;
|
|
138
|
+
return (cell) => {
|
|
139
|
+
const rowAbove = isAboveFrozenStart(cell.rowIndex, rowsAbove);
|
|
140
|
+
const columnAbove = isAboveFrozenStart(cell.columnIndex, columnsAbove);
|
|
141
|
+
if (!rowAbove && !columnAbove)
|
|
142
|
+
return getCellOffsetFromCoords(cell);
|
|
143
|
+
const own = getCellOffsetFromCoords({
|
|
144
|
+
rowIndex: rowAbove ? rowsAbove + 1 : cell.rowIndex,
|
|
145
|
+
columnIndex: columnAbove ? columnsAbove + 1 : cell.columnIndex,
|
|
146
|
+
});
|
|
147
|
+
if (!own)
|
|
148
|
+
return own;
|
|
149
|
+
return {
|
|
150
|
+
x: columnAbove ? own.x - distanceAbove("column", cell.columnIndex) : own.x,
|
|
151
|
+
y: rowAbove ? own.y - distanceAbove("row", cell.rowIndex) : own.y,
|
|
152
|
+
width: columnAbove ? columnSize(cell.columnIndex) : own.width,
|
|
153
|
+
height: rowAbove ? rowSize(cell.rowIndex) : own.height,
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Freeze Panes up to a line ("Freeze up to Row 45"): Excel freezes from the top line on screen,
|
|
159
|
+
* `firstShown`, so the count is measured from there and the start is sent when it is not line 1. A
|
|
160
|
+
* line above `firstShown` (reached with the keyboard on a sheet frozen from a start) freezes from
|
|
161
|
+
* line 1. 0 unfreezes, and an unfreeze carries no start.
|
|
162
|
+
*/
|
|
163
|
+
export const freezeUpTo = (line, firstShown) => {
|
|
164
|
+
if (line <= 0)
|
|
165
|
+
return { count: 0 };
|
|
166
|
+
const start = firstShown > 1 && firstShown <= line ? firstShown : 1;
|
|
167
|
+
return start > 1 ? { count: line - start + 1, start } : { count: line };
|
|
168
|
+
};
|
|
169
|
+
const sameAxis = (a, b) => a.lines === b.lines && a.count === b.count;
|
|
170
|
+
/**
|
|
171
|
+
* Where one axis of the view goes when its frozen area changes and a start is involved
|
|
172
|
+
* (demo-app-monorepo#57258 W-5). `undefined` = leave the scroll position as it is (every change
|
|
173
|
+
* without a start, as before).
|
|
174
|
+
*
|
|
175
|
+
* The rule: **a window's view is repositioned only by a freeze, unfreeze, undo or redo that this
|
|
176
|
+
* window itself just sent, and by nothing else.** `pending` is what this window just sent; the change
|
|
177
|
+
* that follows reads it and drops it, matched or not.
|
|
178
|
+
*
|
|
179
|
+
* - **This window's freeze or unfreeze** (`pending.kind` "freeze", and the area is the one it asked
|
|
180
|
+
* for): freezing from a start puts the scrolling area right below the band (0); unfreezing keeps
|
|
181
|
+
* the start's line first on screen. Remembered as `local`, for this window's undo / redo of it.
|
|
182
|
+
* - **This window's undo** (`pending.kind` "undo", taking the area from `local.after` back to
|
|
183
|
+
* `local.before`): back where the view was before the freeze. Its **redo**: as the freeze did.
|
|
184
|
+
* - **Anything else** (another window's freeze, unfreeze, undo or redo, or a change that does not
|
|
185
|
+
* match what this window sent): the same line stays first on screen, at the same depth; the scroll
|
|
186
|
+
* moves by the band's change. When that line now lies in the band or above the start it cannot
|
|
187
|
+
* stay: the view lands on the first scrolling line (0). `local` is forgotten: a later change of the
|
|
188
|
+
* same shape is someone else's.
|
|
189
|
+
*
|
|
190
|
+
* `offset(index)` is a line's offset in the NEW layout; scroll positions are measured from the first
|
|
191
|
+
* scrolling line, as the grid's are.
|
|
192
|
+
*/
|
|
193
|
+
export const frozenStartScroll = ({ before, after, pending, local, snapshot, offset, }) => {
|
|
194
|
+
if (sameAxis(before, after))
|
|
195
|
+
return { consumed: false, local };
|
|
196
|
+
const withStart = before.lines > 0 || after.lines > 0;
|
|
197
|
+
const firstScrolling = 1 + after.lines + after.count;
|
|
198
|
+
const asSent = () => {
|
|
199
|
+
if (after.lines > 0)
|
|
200
|
+
return 0;
|
|
201
|
+
if (before.lines > 0 && after.lines === 0 && after.count === 0) {
|
|
202
|
+
return Math.max(0, offset(before.lines + 1) - offset(1));
|
|
203
|
+
}
|
|
204
|
+
return undefined;
|
|
205
|
+
};
|
|
206
|
+
const consumed = pending !== undefined;
|
|
207
|
+
if (pending?.kind === "freeze" && sameAxis(after, pending.expected)) {
|
|
208
|
+
return {
|
|
209
|
+
scroll: asSent(),
|
|
210
|
+
consumed,
|
|
211
|
+
local: withStart ? { before, after, scrollBefore: pending.scrollBefore } : undefined,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
if (pending?.kind === "undo" && local && sameAxis(before, local.after) && sameAxis(after, local.before)) {
|
|
215
|
+
return { scroll: local.scrollBefore, consumed, local };
|
|
216
|
+
}
|
|
217
|
+
if (pending?.kind === "redo" && local && sameAxis(before, local.before) && sameAxis(after, local.after)) {
|
|
218
|
+
return { scroll: asSent(), consumed, local };
|
|
219
|
+
}
|
|
220
|
+
if (!withStart || !snapshot)
|
|
221
|
+
return { consumed, local: undefined };
|
|
222
|
+
if (snapshot.topLine < firstScrolling)
|
|
223
|
+
return { scroll: 0, consumed, local: undefined };
|
|
224
|
+
return {
|
|
225
|
+
scroll: Math.max(0, offset(snapshot.topLine) + snapshot.intoLine - offset(firstScrolling)),
|
|
226
|
+
consumed,
|
|
227
|
+
local: undefined,
|
|
228
|
+
};
|
|
229
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/canvas-grid/index.tsx"],"names":[],"mappings":"AAqEA,OAAO,KASN,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/canvas-grid/index.tsx"],"names":[],"mappings":"AAqEA,OAAO,KASN,MAAM,OAAO,CAAC;AAuRf,OAAO,KAAK,EAGV,QAAQ,EAcT,MAAM,aAAa,CAAC;AA0DrB,OAAO,KAAK,EACV,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EAEhB,MAAM,WAAW,CAAC;AAkuQnB,eAAO,MAAM,UAAU,EAA4C,CACjE,CAAC,SAAS,QAAQ,CAAC,GAAG,CAAC,EAEvB,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,GACvB,wBAAwB,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;CAAE,KAChE,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC"}
|