@bevelo/virtual 0.0.0-stage → 0.1.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.
@@ -0,0 +1,248 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_measure = require("../measure-Dg1HYDei.cjs");
3
+ // src/pure/headers.ts
4
+ /**
5
+ * @stable — follows semver.
6
+ */
7
+ /**
8
+ * Computes the header rows visible when the body has scrolled by `scrollY`.
9
+ *
10
+ * This is the vertical range maths applied to the header stack instead of the
11
+ * body: prefix sums are built once and the two edges are found with binary
12
+ * searches, so a deep grouped header costs O(n) to lay out and O(log n) per
13
+ * scroll frame. The rows come back in body coordinates, so the renderer does
14
+ * not have to keep its own running total in sync with the scroll position.
15
+ *
16
+ * Unlike {@link computeRange} the scroll is **not** clamped to
17
+ * `total - viewportHeight`. A header band is not a scroller: when the body has
18
+ * scrolled past the whole band there is nothing left to pin, and clamping would
19
+ * pin the last viewport-height of headers forever. Reporting an empty slice is
20
+ * what lets the caller unpin the band (or show a compact summary) at that
21
+ * point. A caller that wants a permanently pinned band passes `scrollY: 0` and
22
+ * lets the band's own clipping handle a header stack taller than the viewport.
23
+ *
24
+ * A row is visible when its half-open extent intersects
25
+ * `[scrollY, scrollY + viewportHeight)`: a row ending exactly at the scroll
26
+ * offset has scrolled past, and a row starting exactly at the bottom edge has
27
+ * not started yet.
28
+ */
29
+ function headerBand({ heights, scrollY, viewportHeight }) {
30
+ const count = require_measure.normalizeCount(heights.length);
31
+ if (count === 0) return {
32
+ rows: [],
33
+ offset: 0
34
+ };
35
+ const ends = new Float64Array(count + 1);
36
+ let running = 0;
37
+ for (let index = 0; index < count; index += 1) {
38
+ running += require_measure.sanitizeSize(heights[index] ?? 0);
39
+ ends[index + 1] = running;
40
+ }
41
+ const total = running;
42
+ const viewport = require_measure.normalizeLength(viewportHeight);
43
+ const scroll = Math.min(require_measure.normalizeLength(scrollY), total);
44
+ if (scroll >= total) return {
45
+ rows: [],
46
+ offset: total
47
+ };
48
+ const start = firstIndexEndingAfter(ends, count, scroll);
49
+ if (viewport === 0) return {
50
+ rows: [],
51
+ offset: ends[start] ?? 0
52
+ };
53
+ const end = firstIndexStartingAtOrAfter(ends, count, scroll + viewport);
54
+ const rows = [];
55
+ for (let index = start; index < end; index += 1) {
56
+ const y = ends[index] ?? 0;
57
+ rows.push({
58
+ index,
59
+ y,
60
+ height: (ends[index + 1] ?? 0) - y
61
+ });
62
+ }
63
+ return {
64
+ rows,
65
+ offset: ends[start] ?? 0
66
+ };
67
+ }
68
+ /**
69
+ * Resolves grouped header rows to column start indices.
70
+ *
71
+ * Spans are validated instead of coerced: a span that is not a whole number
72
+ * >= 1 is a structural bug in the column definition, not data, and silently
73
+ * rounding it would leave the header cells misaligned with the body columns in
74
+ * a way that only shows up as a visual shift. For the same reason passing
75
+ * `columnCount` makes a span total that disagrees with the grid throw: the
76
+ * renderer can then use `colSpan` and the group's `start` without a second
77
+ * consistency check of its own.
78
+ *
79
+ * `columnCount` is optional so the function can also resolve a header band
80
+ * before the grid reports its own count; the returned total span is the column
81
+ * count in that case, which is exactly the value a caller checks against.
82
+ */
83
+ function groupedHeaders(groups, columnCount) {
84
+ if (columnCount !== void 0) {
85
+ if (!Number.isInteger(columnCount) || columnCount < 0) throw new RangeError(`groupedHeaders columnCount must be a whole number >= 0, received ${String(columnCount)}`);
86
+ }
87
+ const resolved = [];
88
+ let start = 0;
89
+ for (const group of groups) {
90
+ if (!Number.isInteger(group.span) || group.span < 1) throw new RangeError(`header group '${group.id}' needs a whole span >= 1, received ${String(group.span)}`);
91
+ resolved.push({
92
+ id: group.id,
93
+ start,
94
+ span: group.span
95
+ });
96
+ start += group.span;
97
+ }
98
+ if (columnCount !== void 0 && start !== columnCount) throw new RangeError(`header groups span ${start} columns but the grid has ${columnCount}`);
99
+ return resolved;
100
+ }
101
+ /**
102
+ * Windows a wide column set for horizontal scrolling.
103
+ *
104
+ * The same shape as {@link computeRange}, transposed: prefix sums are built
105
+ * once from the widths and the two edges are found by binary search, never by
106
+ * scanning columns. That matters for a grid with tens of thousands of columns:
107
+ * a scan per scroll frame is O(n) while the prefix sums make it O(log n).
108
+ *
109
+ * The scroll offset is clamped to `total - viewportWidth`, because a real
110
+ * scroller clamps `scrollLeft`; without the clamp a stale large offset would
111
+ * render an empty window until the browser sent a corrected scroll event. A
112
+ * viewport wider than the columns therefore always starts at column zero.
113
+ */
114
+ function columnWindow({ widths, scrollX, viewportWidth, overscan }) {
115
+ const count = require_measure.normalizeCount(widths.length);
116
+ if (count === 0) return {
117
+ start: 0,
118
+ end: 0,
119
+ offset: 0,
120
+ total: 0
121
+ };
122
+ const range = require_measure.computeRange({
123
+ count,
124
+ scroll: scrollX,
125
+ viewport: viewportWidth,
126
+ estimate: (index) => require_measure.sanitizeSize(widths[index] ?? 0),
127
+ ...overscan === void 0 ? {} : { overscan }
128
+ });
129
+ return {
130
+ start: range.start,
131
+ end: range.end,
132
+ offset: range.offset,
133
+ total: range.total
134
+ };
135
+ }
136
+ /**
137
+ * The window over a prefix-sum index, for a grid whose columns are lazily measured.
138
+ *
139
+ * The array-shaped {@link columnWindow} has to materialise every width before it can binary
140
+ * search, which is the wrong cost for a sheet with 50,000 columns: the window is 20 of them.
141
+ * This takes the index instead, so the frame costs O(log n) whether the grid has fifty
142
+ * columns or fifty thousand.
143
+ */
144
+ function columnWindowFromIndex(index, options) {
145
+ const rangeIndex = require_measure.toRangeIndex(index);
146
+ const range = require_measure.computeRange({
147
+ count: rangeIndex.count,
148
+ scroll: options.scrollX,
149
+ viewport: options.viewportWidth,
150
+ estimate: () => 0,
151
+ index: rangeIndex,
152
+ ...options.overscan === void 0 ? {} : { overscan: options.overscan }
153
+ });
154
+ return {
155
+ start: range.start,
156
+ end: range.end,
157
+ offset: range.offset,
158
+ total: range.total
159
+ };
160
+ }
161
+ function columnWidthCount(widths) {
162
+ return Array.isArray(widths) ? require_measure.normalizeCount(widths.length) : require_measure.normalizeCount(widths.count);
163
+ }
164
+ function readColumnWidth(widths, index) {
165
+ return Array.isArray(widths) ? require_measure.sanitizeSize(widths[index] ?? 0) : require_measure.sanitizeSize(widths.sizeOf(index));
166
+ }
167
+ /**
168
+ * Left offsets for the frozen leading columns.
169
+ *
170
+ * Frozen columns are painted outside the horizontal window, at their natural
171
+ * positions, so this is a straight prefix sum rather than range maths. Accepts
172
+ * either a plain width array or a indexed SizeSource (so a 50k-column sheet can
173
+ * read only the frozen prefix in O(frozenCount)). The frozen count is clamped to
174
+ * the column count.
175
+ */
176
+ function stickyColumnOffsets(widths, frozenCount) {
177
+ const frozen = clampFrozenCount(frozenCount, columnWidthCount(widths));
178
+ const offsets = [];
179
+ let running = 0;
180
+ for (let index = 0; index < frozen; index += 1) {
181
+ const width = readColumnWidth(widths, index);
182
+ offsets.push({
183
+ index,
184
+ offset: running,
185
+ width
186
+ });
187
+ running += width;
188
+ }
189
+ return offsets;
190
+ }
191
+ /**
192
+ * Right offsets for frozen trailing columns, returned in ascending index order.
193
+ *
194
+ * Each entry's `offset` is its distance in pixels from the trailing edge of the
195
+ * grid (0 for the last column, growing leftward).
196
+ */
197
+ function stickyTrailingColumnOffsets(widths, trailingCount) {
198
+ const count = columnWidthCount(widths);
199
+ const frozen = clampFrozenCount(trailingCount, count);
200
+ if (frozen === 0) return [];
201
+ const start = count - frozen;
202
+ const offsets = new Array(frozen);
203
+ let running = 0;
204
+ for (let index = count - 1; index >= start; index -= 1) {
205
+ const width = readColumnWidth(widths, index);
206
+ offsets[index - start] = {
207
+ index,
208
+ offset: running,
209
+ width
210
+ };
211
+ running += width;
212
+ }
213
+ return offsets;
214
+ }
215
+ /** Freeze counts are whole and non-negative; Infinity means "every column". */
216
+ function clampFrozenCount(value, count) {
217
+ if (value === Infinity) return count;
218
+ if (!Number.isFinite(value) || value <= 0) return 0;
219
+ return Math.min(Math.floor(value), count);
220
+ }
221
+ /** Smallest `index` in `[0, count]` whose end (prefix of index + 1) is past `offset`. */
222
+ function firstIndexEndingAfter(ends, count, offset) {
223
+ let low = 0;
224
+ let high = count;
225
+ while (low < high) {
226
+ const middle = low + high >>> 1;
227
+ if ((ends[middle + 1] ?? 0) <= offset) low = middle + 1;
228
+ else high = middle;
229
+ }
230
+ return low;
231
+ }
232
+ /** Smallest `index` in `[0, count]` whose start (prefix of index) is at or past `offset`. */
233
+ function firstIndexStartingAtOrAfter(ends, count, offset) {
234
+ let low = 0;
235
+ let high = count;
236
+ while (low < high) {
237
+ const middle = low + high >>> 1;
238
+ if ((ends[middle] ?? 0) < offset) low = middle + 1;
239
+ else high = middle;
240
+ }
241
+ return low;
242
+ }
243
+ exports.columnWindow = columnWindow;
244
+ exports.columnWindowFromIndex = columnWindowFromIndex;
245
+ exports.groupedHeaders = groupedHeaders;
246
+ exports.headerBand = headerBand;
247
+ exports.stickyColumnOffsets = stickyColumnOffsets;
248
+ exports.stickyTrailingColumnOffsets = stickyTrailingColumnOffsets;
@@ -0,0 +1,173 @@
1
+ import { a as SizeSource, c as SizeIndex, m as RangeIndex } from "../grid-BzP7CurM.cjs";
2
+ /** One header row inside the band, positioned in body coordinates. */
3
+ export interface HeaderRow {
4
+ /** Row index in the stacked header, from the top. */
5
+ readonly index: number;
6
+ /** Body-coordinate top edge, i.e. the sum of the heights above this row. */
7
+ readonly y: number;
8
+ /** Row height in pixels; never negative and never NaN. */
9
+ readonly height: number;
10
+ }
11
+ /** The slice of the header band that is visible at a given body scroll. */
12
+ export interface HeaderBand {
13
+ /**
14
+ * The visible rows, top to bottom. A row is reported whole even when the
15
+ * scroll cuts through it: a pinned band pins whole rows, so the caller clips
16
+ * at the band's edge rather than half-painting a row.
17
+ */
18
+ readonly rows: readonly HeaderRow[];
19
+ /**
20
+ * Body-coordinate offset of the first reported row — the translate that puts
21
+ * the slice at the band's top. Equals the band's total height when no row is
22
+ * visible.
23
+ */
24
+ readonly offset: number;
25
+ }
26
+ /** Everything {@link headerBand} needs. */
27
+ export interface HeaderBandOptions {
28
+ /** Heights of the header rows, top to bottom. Invalid values count as zero. */
29
+ readonly heights: readonly number[];
30
+ /** How far the body has been scrolled, in pixels. */
31
+ readonly scrollY: number;
32
+ /** Visible height of the band area, in pixels. */
33
+ readonly viewportHeight: number;
34
+ }
35
+ /**
36
+ * Computes the header rows visible when the body has scrolled by `scrollY`.
37
+ *
38
+ * This is the vertical range maths applied to the header stack instead of the
39
+ * body: prefix sums are built once and the two edges are found with binary
40
+ * searches, so a deep grouped header costs O(n) to lay out and O(log n) per
41
+ * scroll frame. The rows come back in body coordinates, so the renderer does
42
+ * not have to keep its own running total in sync with the scroll position.
43
+ *
44
+ * Unlike {@link computeRange} the scroll is **not** clamped to
45
+ * `total - viewportHeight`. A header band is not a scroller: when the body has
46
+ * scrolled past the whole band there is nothing left to pin, and clamping would
47
+ * pin the last viewport-height of headers forever. Reporting an empty slice is
48
+ * what lets the caller unpin the band (or show a compact summary) at that
49
+ * point. A caller that wants a permanently pinned band passes `scrollY: 0` and
50
+ * lets the band's own clipping handle a header stack taller than the viewport.
51
+ *
52
+ * A row is visible when its half-open extent intersects
53
+ * `[scrollY, scrollY + viewportHeight)`: a row ending exactly at the scroll
54
+ * offset has scrolled past, and a row starting exactly at the bottom edge has
55
+ * not started yet.
56
+ */
57
+ export declare function headerBand({ heights, scrollY, viewportHeight }: HeaderBandOptions): HeaderBand;
58
+ /** A group of consecutive columns in a grouped header, as authored. */
59
+ export interface HeaderGroup {
60
+ /** Stable identity, used as the key by the renderer. */
61
+ readonly id: string;
62
+ /** Number of columns the group covers; a whole number >= 1. */
63
+ readonly span: number;
64
+ /** Optional label for the renderer; it is not part of the resolved output. */
65
+ readonly label?: string;
66
+ }
67
+ /** A group resolved to the column grid: where it starts and how wide it is. */
68
+ export interface ResolvedHeaderGroup {
69
+ readonly id: string;
70
+ /** First column index covered by the group. */
71
+ readonly start: number;
72
+ /** Column count, unchanged from the input. */
73
+ readonly span: number;
74
+ }
75
+ /**
76
+ * Resolves grouped header rows to column start indices.
77
+ *
78
+ * Spans are validated instead of coerced: a span that is not a whole number
79
+ * >= 1 is a structural bug in the column definition, not data, and silently
80
+ * rounding it would leave the header cells misaligned with the body columns in
81
+ * a way that only shows up as a visual shift. For the same reason passing
82
+ * `columnCount` makes a span total that disagrees with the grid throw: the
83
+ * renderer can then use `colSpan` and the group's `start` without a second
84
+ * consistency check of its own.
85
+ *
86
+ * `columnCount` is optional so the function can also resolve a header band
87
+ * before the grid reports its own count; the returned total span is the column
88
+ * count in that case, which is exactly the value a caller checks against.
89
+ */
90
+ export declare function groupedHeaders(groups: readonly HeaderGroup[], columnCount?: number): readonly ResolvedHeaderGroup[];
91
+ /** The horizontal render window, the mirror of the body `Range`. */
92
+ export interface ColumnWindow {
93
+ /** First rendered column, inclusive. */
94
+ readonly start: number;
95
+ /** Last rendered column, exclusive. */
96
+ readonly end: number;
97
+ /**
98
+ * Prefix-sum offset of `start`, i.e. the absolute pixel position of the first
99
+ * rendered column. The consumer translates by this inside the scroller, so a
100
+ * column cut by the viewport edge is positioned by the scroller's own scroll,
101
+ * not by a per-column offset.
102
+ */
103
+ readonly offset: number;
104
+ /** Pixel width of the whole column set. */
105
+ readonly total: number;
106
+ }
107
+ /** Everything {@link columnWindow} needs. */
108
+ export interface ColumnWindowOptions {
109
+ /** Column widths left to right. Invalid values count as zero. */
110
+ readonly widths: readonly number[];
111
+ /** Horizontal scroll offset of the scroller, in pixels. */
112
+ readonly scrollX: number;
113
+ /** Visible width of the viewport, in pixels. */
114
+ readonly viewportWidth: number;
115
+ /** Extra columns on each side; defaults to {@link DEFAULT_OVERSCAN}. */
116
+ readonly overscan?: number;
117
+ }
118
+ /**
119
+ * Windows a wide column set for horizontal scrolling.
120
+ *
121
+ * The same shape as {@link computeRange}, transposed: prefix sums are built
122
+ * once from the widths and the two edges are found by binary search, never by
123
+ * scanning columns. That matters for a grid with tens of thousands of columns:
124
+ * a scan per scroll frame is O(n) while the prefix sums make it O(log n).
125
+ *
126
+ * The scroll offset is clamped to `total - viewportWidth`, because a real
127
+ * scroller clamps `scrollLeft`; without the clamp a stale large offset would
128
+ * render an empty window until the browser sent a corrected scroll event. A
129
+ * viewport wider than the columns therefore always starts at column zero.
130
+ */
131
+ export declare function columnWindow({ widths, scrollX, viewportWidth, overscan }: ColumnWindowOptions): ColumnWindow;
132
+ /**
133
+ * The window over a prefix-sum index, for a grid whose columns are lazily measured.
134
+ *
135
+ * The array-shaped {@link columnWindow} has to materialise every width before it can binary
136
+ * search, which is the wrong cost for a sheet with 50,000 columns: the window is 20 of them.
137
+ * This takes the index instead, so the frame costs O(log n) whether the grid has fifty
138
+ * columns or fifty thousand.
139
+ */
140
+ export declare function columnWindowFromIndex(index: RangeIndex | SizeIndex, options: {
141
+ readonly scrollX: number;
142
+ readonly viewportWidth: number;
143
+ readonly overscan?: number;
144
+ }): ColumnWindow;
145
+ /** What column width sources sticky column helpers accept. */
146
+ export type StickyColumnWidths = readonly number[] | (SizeSource & {
147
+ readonly count: number;
148
+ });
149
+ /** A frozen column: its index, its edge offset, and its width. */
150
+ export interface StickyColumnOffset {
151
+ readonly index: number;
152
+ /** Pixels from the grid's pinned edge (left for leading, right for trailing). */
153
+ readonly offset: number;
154
+ /** Sanitised column width. */
155
+ readonly width: number;
156
+ }
157
+ /**
158
+ * Left offsets for the frozen leading columns.
159
+ *
160
+ * Frozen columns are painted outside the horizontal window, at their natural
161
+ * positions, so this is a straight prefix sum rather than range maths. Accepts
162
+ * either a plain width array or a indexed SizeSource (so a 50k-column sheet can
163
+ * read only the frozen prefix in O(frozenCount)). The frozen count is clamped to
164
+ * the column count.
165
+ */
166
+ export declare function stickyColumnOffsets(widths: StickyColumnWidths, frozenCount: number): readonly StickyColumnOffset[];
167
+ /**
168
+ * Right offsets for frozen trailing columns, returned in ascending index order.
169
+ *
170
+ * Each entry's `offset` is its distance in pixels from the trailing edge of the
171
+ * grid (0 for the last column, growing leftward).
172
+ */
173
+ export declare function stickyTrailingColumnOffsets(widths: StickyColumnWidths, trailingCount: number): readonly StickyColumnOffset[];
@@ -0,0 +1,173 @@
1
+ import { a as SizeSource, c as SizeIndex, m as RangeIndex } from "../grid-BzP7CurM.js";
2
+ /** One header row inside the band, positioned in body coordinates. */
3
+ export interface HeaderRow {
4
+ /** Row index in the stacked header, from the top. */
5
+ readonly index: number;
6
+ /** Body-coordinate top edge, i.e. the sum of the heights above this row. */
7
+ readonly y: number;
8
+ /** Row height in pixels; never negative and never NaN. */
9
+ readonly height: number;
10
+ }
11
+ /** The slice of the header band that is visible at a given body scroll. */
12
+ export interface HeaderBand {
13
+ /**
14
+ * The visible rows, top to bottom. A row is reported whole even when the
15
+ * scroll cuts through it: a pinned band pins whole rows, so the caller clips
16
+ * at the band's edge rather than half-painting a row.
17
+ */
18
+ readonly rows: readonly HeaderRow[];
19
+ /**
20
+ * Body-coordinate offset of the first reported row — the translate that puts
21
+ * the slice at the band's top. Equals the band's total height when no row is
22
+ * visible.
23
+ */
24
+ readonly offset: number;
25
+ }
26
+ /** Everything {@link headerBand} needs. */
27
+ export interface HeaderBandOptions {
28
+ /** Heights of the header rows, top to bottom. Invalid values count as zero. */
29
+ readonly heights: readonly number[];
30
+ /** How far the body has been scrolled, in pixels. */
31
+ readonly scrollY: number;
32
+ /** Visible height of the band area, in pixels. */
33
+ readonly viewportHeight: number;
34
+ }
35
+ /**
36
+ * Computes the header rows visible when the body has scrolled by `scrollY`.
37
+ *
38
+ * This is the vertical range maths applied to the header stack instead of the
39
+ * body: prefix sums are built once and the two edges are found with binary
40
+ * searches, so a deep grouped header costs O(n) to lay out and O(log n) per
41
+ * scroll frame. The rows come back in body coordinates, so the renderer does
42
+ * not have to keep its own running total in sync with the scroll position.
43
+ *
44
+ * Unlike {@link computeRange} the scroll is **not** clamped to
45
+ * `total - viewportHeight`. A header band is not a scroller: when the body has
46
+ * scrolled past the whole band there is nothing left to pin, and clamping would
47
+ * pin the last viewport-height of headers forever. Reporting an empty slice is
48
+ * what lets the caller unpin the band (or show a compact summary) at that
49
+ * point. A caller that wants a permanently pinned band passes `scrollY: 0` and
50
+ * lets the band's own clipping handle a header stack taller than the viewport.
51
+ *
52
+ * A row is visible when its half-open extent intersects
53
+ * `[scrollY, scrollY + viewportHeight)`: a row ending exactly at the scroll
54
+ * offset has scrolled past, and a row starting exactly at the bottom edge has
55
+ * not started yet.
56
+ */
57
+ export declare function headerBand({ heights, scrollY, viewportHeight }: HeaderBandOptions): HeaderBand;
58
+ /** A group of consecutive columns in a grouped header, as authored. */
59
+ export interface HeaderGroup {
60
+ /** Stable identity, used as the key by the renderer. */
61
+ readonly id: string;
62
+ /** Number of columns the group covers; a whole number >= 1. */
63
+ readonly span: number;
64
+ /** Optional label for the renderer; it is not part of the resolved output. */
65
+ readonly label?: string;
66
+ }
67
+ /** A group resolved to the column grid: where it starts and how wide it is. */
68
+ export interface ResolvedHeaderGroup {
69
+ readonly id: string;
70
+ /** First column index covered by the group. */
71
+ readonly start: number;
72
+ /** Column count, unchanged from the input. */
73
+ readonly span: number;
74
+ }
75
+ /**
76
+ * Resolves grouped header rows to column start indices.
77
+ *
78
+ * Spans are validated instead of coerced: a span that is not a whole number
79
+ * >= 1 is a structural bug in the column definition, not data, and silently
80
+ * rounding it would leave the header cells misaligned with the body columns in
81
+ * a way that only shows up as a visual shift. For the same reason passing
82
+ * `columnCount` makes a span total that disagrees with the grid throw: the
83
+ * renderer can then use `colSpan` and the group's `start` without a second
84
+ * consistency check of its own.
85
+ *
86
+ * `columnCount` is optional so the function can also resolve a header band
87
+ * before the grid reports its own count; the returned total span is the column
88
+ * count in that case, which is exactly the value a caller checks against.
89
+ */
90
+ export declare function groupedHeaders(groups: readonly HeaderGroup[], columnCount?: number): readonly ResolvedHeaderGroup[];
91
+ /** The horizontal render window, the mirror of the body `Range`. */
92
+ export interface ColumnWindow {
93
+ /** First rendered column, inclusive. */
94
+ readonly start: number;
95
+ /** Last rendered column, exclusive. */
96
+ readonly end: number;
97
+ /**
98
+ * Prefix-sum offset of `start`, i.e. the absolute pixel position of the first
99
+ * rendered column. The consumer translates by this inside the scroller, so a
100
+ * column cut by the viewport edge is positioned by the scroller's own scroll,
101
+ * not by a per-column offset.
102
+ */
103
+ readonly offset: number;
104
+ /** Pixel width of the whole column set. */
105
+ readonly total: number;
106
+ }
107
+ /** Everything {@link columnWindow} needs. */
108
+ export interface ColumnWindowOptions {
109
+ /** Column widths left to right. Invalid values count as zero. */
110
+ readonly widths: readonly number[];
111
+ /** Horizontal scroll offset of the scroller, in pixels. */
112
+ readonly scrollX: number;
113
+ /** Visible width of the viewport, in pixels. */
114
+ readonly viewportWidth: number;
115
+ /** Extra columns on each side; defaults to {@link DEFAULT_OVERSCAN}. */
116
+ readonly overscan?: number;
117
+ }
118
+ /**
119
+ * Windows a wide column set for horizontal scrolling.
120
+ *
121
+ * The same shape as {@link computeRange}, transposed: prefix sums are built
122
+ * once from the widths and the two edges are found by binary search, never by
123
+ * scanning columns. That matters for a grid with tens of thousands of columns:
124
+ * a scan per scroll frame is O(n) while the prefix sums make it O(log n).
125
+ *
126
+ * The scroll offset is clamped to `total - viewportWidth`, because a real
127
+ * scroller clamps `scrollLeft`; without the clamp a stale large offset would
128
+ * render an empty window until the browser sent a corrected scroll event. A
129
+ * viewport wider than the columns therefore always starts at column zero.
130
+ */
131
+ export declare function columnWindow({ widths, scrollX, viewportWidth, overscan }: ColumnWindowOptions): ColumnWindow;
132
+ /**
133
+ * The window over a prefix-sum index, for a grid whose columns are lazily measured.
134
+ *
135
+ * The array-shaped {@link columnWindow} has to materialise every width before it can binary
136
+ * search, which is the wrong cost for a sheet with 50,000 columns: the window is 20 of them.
137
+ * This takes the index instead, so the frame costs O(log n) whether the grid has fifty
138
+ * columns or fifty thousand.
139
+ */
140
+ export declare function columnWindowFromIndex(index: RangeIndex | SizeIndex, options: {
141
+ readonly scrollX: number;
142
+ readonly viewportWidth: number;
143
+ readonly overscan?: number;
144
+ }): ColumnWindow;
145
+ /** What column width sources sticky column helpers accept. */
146
+ export type StickyColumnWidths = readonly number[] | (SizeSource & {
147
+ readonly count: number;
148
+ });
149
+ /** A frozen column: its index, its edge offset, and its width. */
150
+ export interface StickyColumnOffset {
151
+ readonly index: number;
152
+ /** Pixels from the grid's pinned edge (left for leading, right for trailing). */
153
+ readonly offset: number;
154
+ /** Sanitised column width. */
155
+ readonly width: number;
156
+ }
157
+ /**
158
+ * Left offsets for the frozen leading columns.
159
+ *
160
+ * Frozen columns are painted outside the horizontal window, at their natural
161
+ * positions, so this is a straight prefix sum rather than range maths. Accepts
162
+ * either a plain width array or a indexed SizeSource (so a 50k-column sheet can
163
+ * read only the frozen prefix in O(frozenCount)). The frozen count is clamped to
164
+ * the column count.
165
+ */
166
+ export declare function stickyColumnOffsets(widths: StickyColumnWidths, frozenCount: number): readonly StickyColumnOffset[];
167
+ /**
168
+ * Right offsets for frozen trailing columns, returned in ascending index order.
169
+ *
170
+ * Each entry's `offset` is its distance in pixels from the trailing edge of the
171
+ * grid (0 for the last column, growing leftward).
172
+ */
173
+ export declare function stickyTrailingColumnOffsets(widths: StickyColumnWidths, trailingCount: number): readonly StickyColumnOffset[];