@ng-native/components 0.27.0 → 0.28.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.
Files changed (57) hide show
  1. package/android/src/main/java/dev/ngnative/components/ContextMenuPopup.kt +61 -19
  2. package/android/src/main/java/dev/ngnative/components/MenusModule.kt +22 -0
  3. package/android/src/main/java/dev/ngnative/components/Shortcut.kt +13 -4
  4. package/dist/context-menu.d.ts +14 -6
  5. package/dist/context-menu.js +30 -28
  6. package/dist/context-menu.js.map +1 -1
  7. package/dist/index.d.ts +3 -0
  8. package/dist/index.js +3 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/menu.d.ts +7 -4
  11. package/dist/menu.js +10 -4
  12. package/dist/menu.js.map +1 -1
  13. package/dist/modal.d.ts +6 -2
  14. package/dist/modal.js.map +1 -1
  15. package/dist/native-button.d.ts +8 -1
  16. package/dist/native-button.js +5 -1
  17. package/dist/native-button.js.map +1 -1
  18. package/dist/press-menu.d.ts +39 -0
  19. package/dist/press-menu.js +76 -0
  20. package/dist/press-menu.js.map +1 -0
  21. package/dist/pressable.d.ts +3 -0
  22. package/dist/pressable.js +6 -1
  23. package/dist/pressable.js.map +1 -1
  24. package/dist/reanimated.js +27 -3
  25. package/dist/reanimated.js.map +1 -1
  26. package/dist/settled-updates.d.ts +55 -0
  27. package/dist/settled-updates.js +77 -0
  28. package/dist/settled-updates.js.map +1 -0
  29. package/dist/sidebar-item.d.ts +18 -3
  30. package/dist/sidebar-item.js +29 -3
  31. package/dist/sidebar-item.js.map +1 -1
  32. package/dist/stand-ins/reanimated.d.ts +5 -0
  33. package/dist/stand-ins/reanimated.js +7 -0
  34. package/dist/stand-ins/reanimated.js.map +1 -1
  35. package/dist/sticky-rows.d.ts +120 -25
  36. package/dist/sticky-rows.js +265 -65
  37. package/dist/sticky-rows.js.map +1 -1
  38. package/dist/svg-icon.d.ts +9 -0
  39. package/dist/svg-icon.js +37 -0
  40. package/dist/svg-icon.js.map +1 -0
  41. package/dist/virtual-list-sticky-level.d.ts +39 -0
  42. package/dist/virtual-list-sticky-level.js +82 -0
  43. package/dist/virtual-list-sticky-level.js.map +1 -0
  44. package/dist/virtual-list-sticky.d.ts +19 -0
  45. package/dist/virtual-list-sticky.js +13 -0
  46. package/dist/virtual-list-sticky.js.map +1 -0
  47. package/dist/virtual-list.d.ts +6 -2
  48. package/dist/virtual-list.js +60 -43
  49. package/dist/virtual-list.js.map +1 -1
  50. package/dist/worklet-style.d.ts +11 -0
  51. package/dist/worklet-style.js +15 -1
  52. package/dist/worklet-style.js.map +1 -1
  53. package/dist/worklets.d.ts +5 -1
  54. package/dist/worklets.js.map +1 -1
  55. package/dist/written-props.js +1 -0
  56. package/dist/written-props.js.map +1 -1
  57. package/package.json +3 -3
@@ -1,36 +1,63 @@
1
1
  import { computed, signal } from '@angular/core';
2
2
  import { pinnedRange, } from '@ng-native/fabric';
3
3
  import { STICKY_SETTLE_MS } from "./sticky-headers.js";
4
+ const NONE = [];
5
+ /** A range native moves a view nowhere along. */
6
+ const STILL = { input: [0, 1], output: [0, 0] };
4
7
  /**
5
- * `<virtual-list>`'s sticky rows: which one holds the leading edge, the style that pins it, the
8
+ * The zIndex of a level 0 row where rows have levels, each level further in one under it. Fixed,
9
+ * not counted from the levels the list holds: a deeper level arriving would otherwise commit new
10
+ * props on every sticky row, and a view native is moving goes back to its place for a frame.
11
+ * Levels this deep and deeper share a zIndex of 1.
12
+ */
13
+ const FRONT = 100;
14
+ /**
15
+ * `<virtual-list>`'s sticky rows: which hold the leading edge, the style that pins each, the
6
16
  * header's pinned style, and, where the host moves views by the scroll on the native side, what
7
17
  * native is moving. The list's own share of `stickyIndices` and `stickyHeader`, as `StickyHeaders`
8
18
  * is `<scroll-view>`'s.
9
19
  *
20
+ * Rows pin at levels, when `virtualListStickyLevel` gives them: a row holds the edge under the
21
+ * rows of the levels further out than its own, and the next row at its level or further out pushes
22
+ * it off. Without levels every sticky row is at level 0, each pushed off by the next.
23
+ *
10
24
  * Pinning is not native: RN's `ScrollView.js` translates a sticky child against the scroll offset
11
25
  * in JavaScript, and a row here follows the offset the same way while it is the current one, by
12
26
  * its `top` when absolutely positioned and by a transform when in flow. Where native can move a
13
- * view by the scroll, each sticky row instead stays at its own place in the list and native
14
- * translates it on every frame the list scrolls, as RN's `ScrollViewStickyHeader` does; a
15
- * translate committed from each scroll event lands a frame or more late, and on a fast fling the
16
- * row shudders and comes away from the edge.
27
+ * view by the scroll, each sticky row, and a pinned header, instead stays at its own place in the
28
+ * list and native translates it on every frame the list scrolls, as RN's `ScrollViewStickyHeader`
29
+ * does; a translate committed from each scroll event lands a frame or more late, and on a fast
30
+ * fling the row shudders and comes away from the edge.
17
31
  */
18
32
  export class StickyRows {
19
- /** Whether native moves sticky rows. */
33
+ /** Whether native moves sticky rows and the pinned header. */
20
34
  native;
21
- /** The leading edge of the viewport in content space, kept only while anything is pinned. */
22
- leading = signal(0, /* @ts-ignore */
23
- ...(ngDevMode ? [{ debugName: "leading" }] : /* istanbul ignore next */ []));
24
- offset = this.leading.asReadonly();
35
+ /**
36
+ * Where the scroll view is along its axis, header and all: 0 until native says otherwise, since
37
+ * Android sends no scroll event until the list moves.
38
+ */
39
+ along = signal(0, /* @ts-ignore */
40
+ ...(ngDevMode ? [{ debugName: "along" }] : /* istanbul ignore next */ []));
41
+ /** The leading edge of the viewport in content space, past the header at its current size. */
42
+ offset = computed(() => this.along() - this.list.headerHeight(), /* @ts-ignore */
43
+ ...(ngDevMode ? [{ debugName: "offset" }] : /* istanbul ignore next */ []));
25
44
  engine;
26
45
  node;
27
46
  list;
28
- /** The offset once scrolling pauses, which the settled translate of a native-moved row is from. */
47
+ /**
48
+ * Where the scroll view is once scrolling pauses, header and all, which the settled translate of
49
+ * a native-moved row is from.
50
+ */
29
51
  settled = signal(0, /* @ts-ignore */
30
52
  ...(ngDevMode ? [{ debugName: "settled" }] : /* istanbul ignore next */ []));
31
53
  settleTimer;
32
54
  /** What native is moving, by row view, with the transform kept beside the translate. */
33
55
  drives = new Map();
56
+ /**
57
+ * What native moves the header by, once it has been pinned. Kept, moving it nowhere, when it no
58
+ * longer is: native goes on drawing a translate it set after its drive is gone.
59
+ */
60
+ headerDrive = null;
34
61
  /** The list scrolled itself, and native has not drawn its sticky rows there yet. */
35
62
  jumped = false;
36
63
  /** Native has reported reaching the target, so this pass's drives are the last to need telling. */
@@ -43,6 +70,10 @@ export class StickyRows {
43
70
  reported;
44
71
  /** Where native's latest event of all said it was, header and all. */
45
72
  nativeAt = 0;
73
+ /** The axis the list scrolled along when native said so, until then none. */
74
+ nativeAxis;
75
+ /** No scroll event has come for `STICKY_SETTLE_MS`, so none is on its way to draw a new graph. */
76
+ resting = true;
46
77
  /**
47
78
  * Scroll end events still to come, one for each jump that moved native, as iOS sends one. Kept
48
79
  * across jumps: one that landed has its end still to come, and must not be taken for the next's.
@@ -58,57 +89,130 @@ export class StickyRows {
58
89
  this.native = engine.drivesScroll;
59
90
  }
60
91
  /** Whether the scroll offset is needed as a signal, which only pinning needs. */
61
- pinning = computed(() => this.list.header() || this.list.indices().length > 0, /* @ts-ignore */
92
+ pinning = computed(() => this.list.header() || this.rows().size > 0, /* @ts-ignore */
62
93
  ...(ngDevMode ? [{ debugName: "pinning" }] : /* istanbul ignore next */ []));
63
- /** Each sticky row, and the one after it, which pushes it off. */
64
- next = computed(() => {
65
- const sticky = this.list.indices();
66
- return new Map(sticky.map((index, at) => [index, sticky[at + 1]]));
94
+ /**
95
+ * Each sticky row's level, in list order: the rows of `stickyIndices` at level 0, and with a
96
+ * level function every row it gives one. Rows that size themselves take level 0 alone: where a
97
+ * deeper row pins depends on the heights of the rows over it. A sticky index given for rows not
98
+ * there yet pins nothing and pushes nothing off until its row arrives.
99
+ */
100
+ levels = computed(() => {
101
+ const indices = this.list.indices();
102
+ const levelOf = this.list.levels?.levelOf();
103
+ const items = this.list.items();
104
+ const levels = [];
105
+ if (!levelOf) {
106
+ for (const index of indices)
107
+ if (index < items.length)
108
+ levels.push([index, 0]);
109
+ return levels;
110
+ }
111
+ const outermost = new Set(indices);
112
+ const flow = this.list.measuring();
113
+ items.forEach((item, index) => {
114
+ const level = outermost.has(index) ? 0 : levelOf(item, index);
115
+ if (level !== null && !(flow && level > 0))
116
+ levels.push([index, level]);
117
+ });
118
+ return levels;
67
119
  }, /* @ts-ignore */
68
- ...(ngDevMode ? [{ debugName: "next" }] : /* istanbul ignore next */ []));
120
+ ...(ngDevMode ? [{ debugName: "levels" }] : /* istanbul ignore next */ []));
121
+ /** Each sticky row, with the rows it pins under and the one that pushes it off. */
122
+ rows = computed(() => {
123
+ const rows = new Map();
124
+ // The rows a row here would pin under: each deeper than the one before it.
125
+ const open = [];
126
+ for (const [index, level] of this.levels()) {
127
+ while (open.length > 0 && rows.get(open.at(-1)).level >= level) {
128
+ rows.get(open.pop()).next = index;
129
+ }
130
+ rows.set(index, { level, above: [...open], next: undefined });
131
+ open.push(index);
132
+ }
133
+ return rows;
134
+ }, /* @ts-ignore */
135
+ ...(ngDevMode ? [{ debugName: "rows" }] : /* istanbul ignore next */ []));
69
136
  /**
70
- * The sticky row currently holding the leading edge: the last one at or before the offset.
71
- * Null when the list has scrolled back above the first of them.
137
+ * For each sticky row in list order, the least offset that reaches it or a row after it. Where a
138
+ * row starts to hold never comes before where the row before it does, unless a negative `rowGap`
139
+ * overlaps the rows, and this stays in order either way, so `pinned` can halve over it.
140
+ */
141
+ reach = computed(() => {
142
+ const order = this.levels();
143
+ const reach = new Array(order.length);
144
+ let least = Infinity;
145
+ for (let at = order.length - 1; at >= 0; at--) {
146
+ least = Math.min(least, this.startOf(order[at][0]));
147
+ reach[at] = least;
148
+ }
149
+ return reach;
150
+ }, /* @ts-ignore */
151
+ ...(ngDevMode ? [{ debugName: "reach" }] : /* istanbul ignore next */ []));
152
+ /**
153
+ * The sticky rows currently holding the leading edge, outermost first: the last one the offset
154
+ * has reached, under the rows it pins under. Empty when the list has scrolled back above the
155
+ * first of them.
72
156
  */
73
157
  pinned = computed(() => {
74
- const sticky = this.list.indices();
75
- if (sticky.length === 0)
76
- return null;
158
+ const order = this.levels();
159
+ if (order.length === 0)
160
+ return NONE;
77
161
  const offset = this.offset();
78
- let pinned = null;
79
- for (const index of sticky) {
80
- if (this.list.topOf(index) <= offset)
81
- pinned = index;
162
+ // The last row the offset has reached is the last whose `reach` it has, found by halving.
163
+ const reach = this.reach();
164
+ let low = 0;
165
+ let high = order.length;
166
+ while (low < high) {
167
+ const middle = (low + high) >> 1;
168
+ if (reach[middle] <= offset)
169
+ low = middle + 1;
82
170
  else
83
- break;
171
+ high = middle;
84
172
  }
85
- return pinned;
86
- }, /* @ts-ignore */
87
- ...(ngDevMode ? [{ debugName: "pinned" }] : /* istanbul ignore next */ []));
173
+ if (low === 0)
174
+ return NONE;
175
+ const pinned = order[low - 1][0];
176
+ return [...this.rows().get(pinned).above, pinned];
177
+ }, { ...(ngDevMode ? { debugName: "pinned" } : /* istanbul ignore next */ {}), equal: (a, b) => a.length === b.length && a.every((index, at) => index === b[at]) });
88
178
  /**
89
179
  * The header's translation while it is pinned: the scroll position, held back at zero by an
90
- * overscroll and at the first sticky row, which pushes it off.
180
+ * overscroll and at the first sticky row, which pushes it off. Where native moves it, the
181
+ * translate native had reached when scrolling paused, as for a sticky row.
91
182
  */
92
183
  headerStyle = computed(() => {
93
184
  const flip = this.list.flipText();
94
185
  if (!this.list.header())
95
186
  return flip ? { transform: flip } : undefined;
96
- const along = this.offset() + this.list.headerHeight();
97
- const first = this.list.indices()[0];
98
- const limit = first === undefined ? Infinity : this.list.topOf(first);
99
- const shift = Math.min(Math.max(0, along), limit);
187
+ const along = this.native ? this.settled() : this.along();
188
+ const shift = Math.min(Math.max(0, along), this.headerLimit());
100
189
  const move = shift > 0 ? `${this.list.horizontal() ? 'translateX' : 'translateY'}(${shift}px)` : '';
101
190
  const transform = [move, flip ?? ''].filter(Boolean).join(' ');
102
191
  return transform ? { zIndex: 1, transform } : { zIndex: 1 };
103
192
  }, /* @ts-ignore */
104
193
  ...(ngDevMode ? [{ debugName: "headerStyle" }] : /* istanbul ignore next */ []));
105
- /** A pinned row in flow, moved from where flow put it to the leading edge by a transform. */
106
- flowStyle(at) {
107
- const shift = Math.max(0, this.offset() - at);
194
+ /**
195
+ * The pinned row `index` in flow, moved by a transform from `at`, where flow put it, to the leading
196
+ * edge, until the next sticky row reaches it there and pushes it off.
197
+ */
198
+ flowStyle(index, at) {
199
+ const shift = Math.max(0, Math.min(this.offset(), this.stopOf(index)) - at);
108
200
  const move = `${this.list.horizontal() ? 'translateX' : 'translateY'}(${shift}px)`;
109
201
  const flip = this.list.flipText();
110
202
  return { ...this.list.flowSpacing(), zIndex: 1, transform: flip ? `${move} ${flip}` : move };
111
203
  }
204
+ /**
205
+ * A pinned row placed by its `top`: under the rows it pins under, until the next row at its
206
+ * level or further out reaches it there and pushes it off.
207
+ */
208
+ slotStyle(index) {
209
+ const at = Math.min(this.offset(), this.stopOf(index)) + this.above(index);
210
+ return {
211
+ ...this.list.slotStyle(index),
212
+ [this.list.horizontal() ? 'left' : 'top']: at,
213
+ zIndex: this.zIndexOf(index),
214
+ };
215
+ }
112
216
  /**
113
217
  * A sticky row native moves: at its own place, with the translate native had reached when
114
218
  * scrolling paused, so the props agree with what is on screen.
@@ -118,9 +222,10 @@ export class StickyRows {
118
222
  const style = this.list.measuring()
119
223
  ? { ...this.list.flowSpacing() }
120
224
  : { ...this.list.slotStyle(index) };
121
- style['zIndex'] = 1;
122
- const top = this.list.topOf(index);
123
- const shift = Math.min(Math.max(0, this.settled() - top), this.stopOf(index) - top);
225
+ style['zIndex'] = this.zIndexOf(index);
226
+ const start = this.startOf(index);
227
+ const settled = this.settled() - this.list.headerHeight();
228
+ const shift = Math.min(Math.max(0, settled - start), this.stopOf(index) - start);
124
229
  const move = shift > 0 ? `${horizontal ? 'translateX' : 'translateY'}(${shift}px)` : '';
125
230
  const transform = [move, this.list.flipText() ?? ''].filter(Boolean).join(' ');
126
231
  if (transform)
@@ -133,7 +238,7 @@ export class StickyRows {
133
238
  * back. Apart from that, `kind`, the row's `itemType`.
134
239
  */
135
240
  recyclingType(index, kind) {
136
- if (!this.next().has(index))
241
+ if (!this.rows().has(index))
137
242
  return kind;
138
243
  let type = this.typeOfKind.get(kind);
139
244
  if (!type) {
@@ -147,26 +252,33 @@ export class StickyRows {
147
252
  isType(type) {
148
253
  return this.types.has(type);
149
254
  }
150
- /** The list scrolled, to `offset` in content space and `along` in the scroll view. */
151
- scrolled(offset, along) {
255
+ /** The list scrolled, to `along` in the scroll view. */
256
+ scrolled(along) {
152
257
  this.nativeAt = along;
258
+ this.nativeAxis = this.list.horizontal() ? 'x' : 'y';
153
259
  if (this.jumped) {
154
260
  this.reported = along;
155
261
  // An event from before the jump, or on the way, is not where it lands.
156
262
  if (Math.abs(along - this.jumpedTo) <= 1)
157
263
  this.landed = true;
158
264
  }
159
- // A pinned row follows the scroll continuously, so with sticky rows the offset has to be a
160
- // signal - and only then. Without them this stays out of change detection, and a fling that
161
- // moves no row in or out of the window costs none.
162
- if (!this.pinning())
163
- return;
164
- this.leading.set(offset);
265
+ // A pinned row follows the scroll continuously, so the offset is a signal. Nothing reads it
266
+ // until a row or the header is pinned, so without them this stays out of change detection,
267
+ // and a fling that moves no row in or out of the window costs none. It is kept all the same:
268
+ // a row that turns sticky in a scrolled list is pinned where the list is, not where it was.
269
+ this.along.set(along);
165
270
  if (!this.native)
166
271
  return;
167
- // See `STICKY_SETTLE_MS`.
168
272
  clearTimeout(this.settleTimer);
169
- this.settleTimer = setTimeout(() => this.settled.set(offset), STICKY_SETTLE_MS);
273
+ this.resting = false;
274
+ const settle = () => {
275
+ this.resting = true;
276
+ this.settled.set(along);
277
+ };
278
+ if (!this.pinning())
279
+ return settle();
280
+ // See `STICKY_SETTLE_MS`.
281
+ this.settleTimer = setTimeout(settle, STICKY_SETTLE_MS);
170
282
  }
171
283
  /** The list is scrolling itself, to `to` in the scroll view, where native has not drawn yet. */
172
284
  jumping(to, animated) {
@@ -199,12 +311,12 @@ export class StickyRows {
199
311
  this.landed = true;
200
312
  }
201
313
  /**
202
- * Hand each rendered sticky row's view to native to move, and let go of the rest. `views` are
203
- * the rendered rows' views in the same order as `rows`. Each is only asked for where there is a
204
- * drive to make or let go.
314
+ * Hand each rendered sticky row's view to native to move, and let go of the rest, and the
315
+ * header's view, `header`, while it is pinned. `views` are the rendered rows' views in the same
316
+ * order as `rows`. Each is only asked for where there is a drive to make or let go.
205
317
  */
206
- drive(rows, views) {
207
- if (!this.pinning() && this.drives.size === 0)
318
+ drive(rows, views, header) {
319
+ if (!this.pinning() && this.drives.size === 0 && !this.headerDrive)
208
320
  return;
209
321
  const rendered = views();
210
322
  const axis = this.list.horizontal() ? 'x' : 'y';
@@ -233,7 +345,7 @@ export class StickyRows {
233
345
  if (held?.statics === statics)
234
346
  return held.drive.update(next.range, from);
235
347
  held?.drive.stop();
236
- const drive = this.engine.driveByScroll(view, this.node, axis, next.range, next.statics, from);
348
+ const drive = this.engine.driveByScroll(view, this.node, axis, next.range, next.statics, held ? this.remadeFrom(axis, from) : from);
237
349
  if (drive)
238
350
  this.drives.set(view, { drive, statics });
239
351
  });
@@ -243,30 +355,118 @@ export class StickyRows {
243
355
  held.drive.stop();
244
356
  this.drives.delete(view);
245
357
  }
358
+ this.driveHeader(header, axis, from);
246
359
  if (this.landed)
247
360
  this.jumped = this.landed = false;
248
361
  }
362
+ /**
363
+ * Hand the header to native to move while it is pinned, by the scroll view's offset until the
364
+ * first sticky row pushes it off. Unpinned, it is moved nowhere.
365
+ */
366
+ driveHeader(view, axis, from) {
367
+ const pinned = this.list.header();
368
+ if (!pinned && !this.headerDrive)
369
+ return;
370
+ const range = pinned ? this.headerRange() : STILL;
371
+ const held = this.headerDrive;
372
+ const moved = JSON.stringify(range);
373
+ const at = this.headerFrom(pinned, moved, axis, from);
374
+ const statics = this.list.flip() ?? [];
375
+ // The axis too: a list turned horizontal moves the header along x.
376
+ const key = axis + JSON.stringify(statics);
377
+ if (held?.statics === key) {
378
+ held.pinned = pinned;
379
+ held.range = moved;
380
+ return held.drive.update(range, at);
381
+ }
382
+ held?.drive.stop();
383
+ const drive = this.engine.driveByScroll(view(), this.node, axis, range, statics, held ? (at ?? this.remadeFrom(axis, from)) : at);
384
+ this.headerDrive = drive && { drive, statics: key, pinned, range: moved };
385
+ }
386
+ /**
387
+ * Where native is told the scroll view is for the header's drive, `pinned` and moved by the range
388
+ * `moved`. Pinned, let go, or moved by a new range at rest, native has no new scroll event to draw
389
+ * it from: it is told where it last said it was. Mid-scroll the next event draws it, and what
390
+ * native last said trails it, and what it said along the other axis says nothing of `axis`. After a
391
+ * jump, `from`, where the list scrolled itself.
392
+ */
393
+ headerFrom(pinned, moved, axis, from) {
394
+ const held = this.headerDrive;
395
+ const changed = held?.pinned !== pinned || (this.resting && held.range !== moved);
396
+ if (!changed)
397
+ return from;
398
+ return from ?? (this.nativeAxis === axis ? this.nativeAt : undefined);
399
+ }
400
+ /**
401
+ * Where native is told the scroll view is for a drive made again along `axis`, as for a flip. The
402
+ * one it replaces may have been the last to read the offset, so the new one starts from nothing,
403
+ * and at rest no scroll event comes to draw it: it is told where native last said it was, unless
404
+ * that was along the other axis. After a jump, `from`.
405
+ */
406
+ remadeFrom(axis, from) {
407
+ return from ?? (this.resting && this.nativeAxis === axis ? this.nativeAt : undefined);
408
+ }
409
+ /** How native moves the pinned header. A first sticky row at the very top holds it in place. */
410
+ headerRange() {
411
+ const limit = this.headerLimit();
412
+ return limit > 0 ? pinnedRange(0, limit) : STILL;
413
+ }
414
+ /** How far the header moves before the first sticky row pushes it off: to that row's top. */
415
+ headerLimit() {
416
+ const [first] = this.rows().keys();
417
+ return first === undefined ? Infinity : this.list.topOf(first);
418
+ }
249
419
  destroy() {
250
420
  clearTimeout(this.settleTimer);
251
421
  for (const held of this.drives.values())
252
422
  held.drive.stop();
423
+ this.headerDrive?.drive.stop();
424
+ }
425
+ /** The size of the rows a sticky row pins under, which is how far from the edge it holds. */
426
+ above(index) {
427
+ let size = 0;
428
+ for (const over of this.rows().get(index)?.above ?? NONE)
429
+ size += this.list.heightOf(over);
430
+ return size;
253
431
  }
254
- /** Where a sticky row stops, pushed off by the next: that row's top, less this row's size. */
432
+ /**
433
+ * A deeper row is drawn under the rows it pins under, and every sticky row over the rest. See
434
+ * `FRONT`. Without levels a sticky row's zIndex is 1, as it was before there were any.
435
+ */
436
+ zIndexOf(index) {
437
+ if (!this.list.levels?.levelOf())
438
+ return 1;
439
+ return Math.max(1, FRONT - (this.rows().get(index)?.level ?? 0));
440
+ }
441
+ /** The offset a sticky row starts to hold from: where its top meets the rows it pins under. */
442
+ startOf(index) {
443
+ return this.list.topOf(index) - this.above(index);
444
+ }
445
+ /**
446
+ * The offset a sticky row stops holding at, pushed off by the next: where that row's top meets
447
+ * this row's far edge.
448
+ */
255
449
  stopOf(index) {
256
- const next = this.next().get(index);
257
- return next === undefined ? Infinity : this.list.topOf(next) - this.list.heightOf(index);
450
+ const next = this.rows().get(index)?.next;
451
+ if (next === undefined)
452
+ return Infinity;
453
+ return this.list.topOf(next) - this.list.heightOf(index) - this.above(index);
258
454
  }
259
455
  /**
260
456
  * How native moves a rendered row, or null when it does not: along the scroll view's own
261
- * offset, which counts the header, from the row's top until the next sticky row pushes it off.
457
+ * offset, which counts the header, from where the row meets the rows it pins under until the
458
+ * next sticky row pushes it off. A row the next one follows with no space between them holds
459
+ * nowhere, so native moves it nowhere: it is not let go, since native keeps the translate it
460
+ * had moved a row by.
262
461
  */
263
462
  driveOf(row) {
264
- if (!this.native || row.parked || !this.next().has(row.index))
463
+ if (!this.native || row.parked || !this.rows().has(row.index))
265
464
  return null;
266
465
  const header = this.list.headerHeight();
267
- const start = header + this.list.topOf(row.index);
466
+ const start = header + this.startOf(row.index);
467
+ const stop = header + this.stopOf(row.index);
268
468
  return {
269
- range: pinnedRange(start, header + this.stopOf(row.index)),
469
+ range: stop > start ? pinnedRange(start, stop) : { input: [start, start + 1], output: [0, 0] },
270
470
  statics: this.list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CAAC;IAED,8FAA8F;IACtF,MAAM,CAAC,KAAa;QAC1B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACpC,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC3F,CAAC;IAED;;;OAGG;IACK,OAAO,CAAC,GAAQ;QACtB,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAC3E,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;QACxC,MAAM,KAAK,GAAG,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAClD,OAAO;YACL,KAAK,EAAE,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAC1D,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE;SAChC,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { computed, signal, type Signal } from '@angular/core';\nimport {\n type HostEngine,\n type HostNode,\n type ScrollDrive,\n type ScrollRange,\n type StaticTransform,\n pinnedRange,\n} from '@ng-native/fabric';\nimport { STICKY_SETTLE_MS } from './sticky-headers.ts';\n\n/** What `StickyRows` needs of the list whose rows it pins. */\nexport interface StickyRowsList {\n /** The sticky rows' indices, as `stickyIndices` gives them. */\n readonly indices: Signal<readonly number[]>;\n /** Whether the list header is pinned too, as `stickyHeader` says. */\n readonly header: Signal<boolean>;\n readonly headerHeight: Signal<number>;\n horizontal(): boolean;\n /** Rows size themselves and are laid out in flow. */\n measuring(): boolean;\n topOf(index: number): number;\n heightOf(index: number): number;\n /** An absolutely positioned row's style, at its own place. */\n slotStyle(index: number): Record<string, unknown>;\n /** What places a row in flow. */\n flowSpacing(): Record<string, unknown>;\n /** The list's flip, as transforms and as CSS text, when it is inverted. */\n flip(): readonly StaticTransform[] | undefined;\n flipText(): string | undefined;\n}\n\n/** A row as the list renders it, for what `StickyRows` reads of it. */\ninterface Row {\n readonly index: number;\n readonly parked?: boolean;\n}\n\n/**\n * `<virtual-list>`'s sticky rows: which one holds the leading edge, the style that pins it, the\n * header's pinned style, and, where the host moves views by the scroll on the native side, what\n * native is moving. The list's own share of `stickyIndices` and `stickyHeader`, as `StickyHeaders`\n * is `<scroll-view>`'s.\n *\n * Pinning is not native: RN's `ScrollView.js` translates a sticky child against the scroll offset\n * in JavaScript, and a row here follows the offset the same way while it is the current one, by\n * its `top` when absolutely positioned and by a transform when in flow. Where native can move a\n * view by the scroll, each sticky row instead stays at its own place in the list and native\n * translates it on every frame the list scrolls, as RN's `ScrollViewStickyHeader` does; a\n * translate committed from each scroll event lands a frame or more late, and on a fast fling the\n * row shudders and comes away from the edge.\n */\nexport class StickyRows {\n /** Whether native moves sticky rows. */\n readonly native: boolean;\n /** The leading edge of the viewport in content space, kept only while anything is pinned. */\n private readonly leading = signal(0);\n readonly offset = this.leading.asReadonly();\n\n private readonly engine: HostEngine;\n private readonly node: HostNode;\n private readonly list: StickyRowsList;\n /** The offset once scrolling pauses, which the settled translate of a native-moved row is from. */\n private readonly settled = signal(0);\n private settleTimer: ReturnType<typeof setTimeout> | undefined;\n /** What native is moving, by row view, with the transform kept beside the translate. */\n private readonly drives = new Map<HostNode, { drive: ScrollDrive; statics: string }>();\n /** The list scrolled itself, and native has not drawn its sticky rows there yet. */\n private jumped = false;\n /** Native has reported reaching the target, so this pass's drives are the last to need telling. */\n private landed = false;\n /** Where the list scrolled itself to, in the scroll view, which native reports with its event. */\n private jumpedTo = 0;\n /** Whether that scroll is animated, so native is still at its start until it reports. */\n private jumpAnimated = false;\n /** Where native's latest event since the jump said the scroll view was, header and all. */\n private reported: number | undefined;\n /** Where native's latest event of all said it was, header and all. */\n private nativeAt = 0;\n /**\n * Scroll end events still to come, one for each jump that moved native, as iOS sends one. Kept\n * across jumps: one that landed has its end still to come, and must not be taken for the next's.\n */\n private ends = 0;\n /** The recycling type of a sticky row of each `itemType`: apart from plain rows of it. */\n private readonly typeOfKind = new Map<unknown, symbol>();\n private readonly types = new Set<unknown>();\n\n constructor(engine: HostEngine, node: HostNode, list: StickyRowsList) {\n this.engine = engine;\n this.node = node;\n this.list = list;\n this.native = engine.drivesScroll;\n }\n\n /** Whether the scroll offset is needed as a signal, which only pinning needs. */\n private readonly pinning = computed(() => this.list.header() || this.list.indices().length > 0);\n\n /** Each sticky row, and the one after it, which pushes it off. */\n readonly next = computed(() => {\n const sticky = this.list.indices();\n return new Map(sticky.map((index, at) => [index, sticky[at + 1]]));\n });\n\n /**\n * The sticky row currently holding the leading edge: the last one at or before the offset.\n * Null when the list has scrolled back above the first of them.\n */\n readonly pinned = computed<number | null>(() => {\n const sticky = this.list.indices();\n if (sticky.length === 0) return null;\n const offset = this.offset();\n\n let pinned: number | null = null;\n for (const index of sticky) {\n if (this.list.topOf(index) <= offset) pinned = index;\n else break;\n }\n return pinned;\n });\n\n /**\n * The header's translation while it is pinned: the scroll position, held back at zero by an\n * overscroll and at the first sticky row, which pushes it off.\n */\n readonly headerStyle = computed(() => {\n const flip = this.list.flipText();\n if (!this.list.header()) return flip ? { transform: flip } : undefined;\n const along = this.offset() + this.list.headerHeight();\n const first = this.list.indices()[0];\n const limit = first === undefined ? Infinity : this.list.topOf(first);\n const shift = Math.min(Math.max(0, along), limit);\n const move =\n shift > 0 ? `${this.list.horizontal() ? 'translateX' : 'translateY'}(${shift}px)` : '';\n const transform = [move, flip ?? ''].filter(Boolean).join(' ');\n return transform ? { zIndex: 1, transform } : { zIndex: 1 };\n });\n\n /** A pinned row in flow, moved from where flow put it to the leading edge by a transform. */\n flowStyle(at: number): Record<string, unknown> {\n const shift = Math.max(0, this.offset() - at);\n const move = `${this.list.horizontal() ? 'translateX' : 'translateY'}(${shift}px)`;\n const flip = this.list.flipText();\n return { ...this.list.flowSpacing(), zIndex: 1, transform: flip ? `${move} ${flip}` : move };\n }\n\n /**\n * A sticky row native moves: at its own place, with the translate native had reached when\n * scrolling paused, so the props agree with what is on screen.\n */\n style(index: number): Record<string, unknown> {\n const horizontal = this.list.horizontal();\n const style: Record<string, unknown> = this.list.measuring()\n ? { ...this.list.flowSpacing() }\n : { ...this.list.slotStyle(index) };\n style['zIndex'] = 1;\n const top = this.list.topOf(index);\n const shift = Math.min(Math.max(0, this.settled() - top), this.stopOf(index) - top);\n const move = shift > 0 ? `${horizontal ? 'translateX' : 'translateY'}(${shift}px)` : '';\n const transform = [move, this.list.flipText() ?? ''].filter(Boolean).join(' ');\n if (transform) style['transform'] = transform;\n return style;\n }\n\n /**\n * The recycling type of a row: a sticky row is a type of its own, since native keeps the\n * translate it moved one by, and a plain row taking its slot commits no transform to put it\n * back. Apart from that, `kind`, the row's `itemType`.\n */\n recyclingType(index: number, kind: unknown): unknown {\n if (!this.next().has(index)) return kind;\n let type = this.typeOfKind.get(kind);\n if (!type) {\n type = Symbol('sticky');\n this.typeOfKind.set(kind, type);\n this.types.add(type);\n }\n return type;\n }\n\n /** Whether a recycling type is a sticky row's. */\n isType(type: unknown): boolean {\n return this.types.has(type);\n }\n\n /** The list scrolled, to `offset` in content space and `along` in the scroll view. */\n scrolled(offset: number, along: number): void {\n this.nativeAt = along;\n if (this.jumped) {\n this.reported = along;\n // An event from before the jump, or on the way, is not where it lands.\n if (Math.abs(along - this.jumpedTo) <= 1) this.landed = true;\n }\n // A pinned row follows the scroll continuously, so with sticky rows the offset has to be a\n // signal - and only then. Without them this stays out of change detection, and a fling that\n // moves no row in or out of the window costs none.\n if (!this.pinning()) return;\n this.leading.set(offset);\n if (!this.native) return;\n // See `STICKY_SETTLE_MS`.\n clearTimeout(this.settleTimer);\n this.settleTimer = setTimeout(() => this.settled.set(offset), STICKY_SETTLE_MS);\n }\n\n /** The list is scrolling itself, to `to` in the scroll view, where native has not drawn yet. */\n jumping(to: number, animated: boolean): void {\n // To where native last said it was, with no earlier jump on its way: it moves nothing and\n // reports nothing. With one, native moves and comes back, and reports that.\n const pending = this.jumped && !this.landed;\n if (Math.abs(to - (pending ? this.jumpedTo : this.nativeAt)) > 1) this.ends++;\n this.jumped = pending || Math.abs(to - this.nativeAt) > 1;\n this.landed = false;\n this.jumpedTo = to;\n this.jumpAnimated = animated;\n this.reported = undefined;\n }\n\n /** The user took the scroll over: native's own events move the rows from here. */\n dragged(): void {\n this.jumped = this.landed = false;\n // Android sends no end for a jump that is not animated, so none is waited for past a drag.\n this.ends = 0;\n }\n\n /**\n * A scroll came to rest. The last of the jumps on their way has landed, wherever it did: iOS\n * does not stop a scroll at the end of the content, so it can rest past where the list said,\n * and what moves it next (a tap on the status bar) is not a drag.\n */\n rested(): void {\n if (this.ends > 0) this.ends--;\n if (this.jumped && this.ends === 0) this.landed = true;\n }\n\n /**\n * Hand each rendered sticky row's view to native to move, and let go of the rest. `views` are\n * the rendered rows' views in the same order as `rows`. Each is only asked for where there is a\n * drive to make or let go.\n */\n drive(rows: () => readonly Row[], views: () => readonly HostNode[]): void {\n if (!this.pinning() && this.drives.size === 0) return;\n const rendered = views();\n const axis = this.list.horizontal() ? 'x' : 'y';\n const live = new Set<HostNode>();\n // After the list scrolled itself, where native is: it draws a graph when its offset changes,\n // and after a jump the offset of a drive just made may not. What native last reported, or\n // before it has, the target of a jump that is not animated. An animated one only once it has\n // landed: on the way native's offset changes every frame, so it draws a new graph anyway, and\n // the offset here trails native's and would set every pinned row back a frame. The same holds\n // mid-fling, which is why nothing is told outside a jump.\n const from = !this.jumped\n ? undefined\n : this.jumpAnimated\n ? this.landed\n ? this.reported\n : undefined\n : (this.reported ?? this.jumpedTo);\n rows().forEach((row, at) => {\n const view = rendered[at];\n const next = this.driveOf(row);\n if (!view || !next) return;\n live.add(view);\n const statics = JSON.stringify(next.statics);\n const held = this.drives.get(view);\n if (held?.statics === statics) return held.drive.update(next.range, from);\n held?.drive.stop();\n const drive = this.engine.driveByScroll(\n view,\n this.node,\n axis,\n next.range,\n next.statics,\n from,\n );\n if (drive) this.drives.set(view, { drive, statics });\n });\n for (const [view, held] of this.drives) {\n if (live.has(view)) continue;\n held.drive.stop();\n this.drives.delete(view);\n }\n if (this.landed) this.jumped = this.landed = false;\n }\n\n destroy(): void {\n clearTimeout(this.settleTimer);\n for (const held of this.drives.values()) held.drive.stop();\n }\n\n /** Where a sticky row stops, pushed off by the next: that row's top, less this row's size. */\n private stopOf(index: number): number {\n const next = this.next().get(index);\n return next === undefined ? Infinity : this.list.topOf(next) - this.list.heightOf(index);\n }\n\n /**\n * How native moves a rendered row, or null when it does not: along the scroll view's own\n * offset, which counts the header, from the row's top until the next sticky row pushes it off.\n */\n private driveOf(row: Row): { range: ScrollRange; statics: readonly StaticTransform[] } | null {\n if (!this.native || row.parked || !this.next().has(row.index)) return null;\n const header = this.list.headerHeight();\n const start = header + this.list.topOf(row.index);\n return {\n range: pinnedRange(start, header + this.stopOf(row.index)),\n statics: this.list.flip() ?? [],\n };\n }\n}\n"]}
1
+ {"version":3,"file":"sticky-rows.js","sourceRoot":"","sources":["../src/sticky-rows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AAC9D,OAAO,EAML,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AA2CvD,MAAM,IAAI,GAAsB,EAAE,CAAC;AAEnC,iDAAiD;AACjD,MAAM,KAAK,GAAgB,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE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,CAAC,CAAC;IAC/E,CAAC;IAED;;;;;;OAMG;IACK,OAAO,CAAC,GAAQ;QACtB,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAC3E,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;QACxC,MAAM,KAAK,GAAG,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC/C,MAAM,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC7C,OAAO;YACL,KAAK,EACH,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;YACzF,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE;SAChC,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { computed, signal, type Signal } from '@angular/core';\nimport {\n type HostEngine,\n type HostNode,\n type ScrollDrive,\n type ScrollRange,\n type StaticTransform,\n pinnedRange,\n} from '@ng-native/fabric';\nimport { STICKY_SETTLE_MS } from './sticky-headers.ts';\nimport type { VirtualListSticky } from './virtual-list-sticky.ts';\n\n/** What `StickyRows` needs of the list whose rows it pins. */\nexport interface StickyRowsList {\n /** The sticky rows' indices, as `stickyIndices` gives them. */\n readonly indices: Signal<readonly number[]>;\n /** The rows' levels, when a directive on the list gives them, read from the items. */\n readonly levels: VirtualListSticky | null;\n readonly items: Signal<readonly unknown[]>;\n /** Whether the list header is pinned too, as `stickyHeader` says. */\n readonly header: Signal<boolean>;\n readonly headerHeight: Signal<number>;\n horizontal(): boolean;\n /** Rows size themselves and are laid out in flow. */\n measuring(): boolean;\n topOf(index: number): number;\n heightOf(index: number): number;\n /** An absolutely positioned row's style, at its own place. */\n slotStyle(index: number): Record<string, unknown>;\n /** What places a row in flow. */\n flowSpacing(): Record<string, unknown>;\n /** The list's flip, as transforms and as CSS text, when it is inverted. */\n flip(): readonly StaticTransform[] | undefined;\n flipText(): string | undefined;\n}\n\n/** A row as the list renders it, for what `StickyRows` reads of it. */\ninterface Row {\n readonly index: number;\n readonly parked?: boolean;\n}\n\n/** A sticky row: how deep it is, the rows it pins under, and the row that pushes it off. */\ninterface StickyRow {\n /** 0 for the outermost. The rows of `stickyIndices` are all at 0. */\n readonly level: number;\n /** The nearest row before it of each level further out, outermost first. */\n readonly above: readonly number[];\n /** The next row at its level or further out, if there is one. */\n next: number | undefined;\n}\n\nconst NONE: readonly number[] = [];\n\n/** A range native moves a view nowhere along. */\nconst STILL: ScrollRange = { input: [0, 1], output: [0, 0] };\n\n/**\n * The zIndex of a level 0 row where rows have levels, each level further in one under it. Fixed,\n * not counted from the levels the list holds: a deeper level arriving would otherwise commit new\n * props on every sticky row, and a view native is moving goes back to its place for a frame.\n * Levels this deep and deeper share a zIndex of 1.\n */\nconst FRONT = 100;\n\n/**\n * `<virtual-list>`'s sticky rows: which hold the leading edge, the style that pins each, the\n * header's pinned style, and, where the host moves views by the scroll on the native side, what\n * native is moving. The list's own share of `stickyIndices` and `stickyHeader`, as `StickyHeaders`\n * is `<scroll-view>`'s.\n *\n * Rows pin at levels, when `virtualListStickyLevel` gives them: a row holds the edge under the\n * rows of the levels further out than its own, and the next row at its level or further out pushes\n * it off. Without levels every sticky row is at level 0, each pushed off by the next.\n *\n * Pinning is not native: RN's `ScrollView.js` translates a sticky child against the scroll offset\n * in JavaScript, and a row here follows the offset the same way while it is the current one, by\n * its `top` when absolutely positioned and by a transform when in flow. Where native can move a\n * view by the scroll, each sticky row, and a pinned header, instead stays at its own place in the\n * list and native translates it on every frame the list scrolls, as RN's `ScrollViewStickyHeader`\n * does; a translate committed from each scroll event lands a frame or more late, and on a fast\n * fling the row shudders and comes away from the edge.\n */\nexport class StickyRows {\n /** Whether native moves sticky rows and the pinned header. */\n readonly native: boolean;\n /**\n * Where the scroll view is along its axis, header and all: 0 until native says otherwise, since\n * Android sends no scroll event until the list moves.\n */\n private readonly along = signal(0);\n /** The leading edge of the viewport in content space, past the header at its current size. */\n readonly offset = computed(() => this.along() - this.list.headerHeight());\n\n private readonly engine: HostEngine;\n private readonly node: HostNode;\n private readonly list: StickyRowsList;\n /**\n * Where the scroll view is once scrolling pauses, header and all, which the settled translate of\n * a native-moved row is from.\n */\n private readonly settled = signal(0);\n private settleTimer: ReturnType<typeof setTimeout> | undefined;\n /** What native is moving, by row view, with the transform kept beside the translate. */\n private readonly drives = new Map<HostNode, { drive: ScrollDrive; statics: string }>();\n /**\n * What native moves the header by, once it has been pinned. Kept, moving it nowhere, when it no\n * longer is: native goes on drawing a translate it set after its drive is gone.\n */\n private headerDrive: {\n drive: ScrollDrive;\n statics: string;\n pinned: boolean;\n range: string;\n } | null = null;\n /** The list scrolled itself, and native has not drawn its sticky rows there yet. */\n private jumped = false;\n /** Native has reported reaching the target, so this pass's drives are the last to need telling. */\n private landed = false;\n /** Where the list scrolled itself to, in the scroll view, which native reports with its event. */\n private jumpedTo = 0;\n /** Whether that scroll is animated, so native is still at its start until it reports. */\n private jumpAnimated = false;\n /** Where native's latest event since the jump said the scroll view was, header and all. */\n private reported: number | undefined;\n /** Where native's latest event of all said it was, header and all. */\n private nativeAt = 0;\n /** The axis the list scrolled along when native said so, until then none. */\n private nativeAxis: 'x' | 'y' | undefined;\n /** No scroll event has come for `STICKY_SETTLE_MS`, so none is on its way to draw a new graph. */\n private resting = true;\n /**\n * Scroll end events still to come, one for each jump that moved native, as iOS sends one. Kept\n * across jumps: one that landed has its end still to come, and must not be taken for the next's.\n */\n private ends = 0;\n /** The recycling type of a sticky row of each `itemType`: apart from plain rows of it. */\n private readonly typeOfKind = new Map<unknown, symbol>();\n private readonly types = new Set<unknown>();\n\n constructor(engine: HostEngine, node: HostNode, list: StickyRowsList) {\n this.engine = engine;\n this.node = node;\n this.list = list;\n this.native = engine.drivesScroll;\n }\n\n /** Whether the scroll offset is needed as a signal, which only pinning needs. */\n private readonly pinning = computed(() => this.list.header() || this.rows().size > 0);\n\n /**\n * Each sticky row's level, in list order: the rows of `stickyIndices` at level 0, and with a\n * level function every row it gives one. Rows that size themselves take level 0 alone: where a\n * deeper row pins depends on the heights of the rows over it. A sticky index given for rows not\n * there yet pins nothing and pushes nothing off until its row arrives.\n */\n private readonly levels = computed<readonly (readonly [index: number, level: number])[]>(() => {\n const indices = this.list.indices();\n const levelOf = this.list.levels?.levelOf();\n const items = this.list.items();\n const levels: [number, number][] = [];\n if (!levelOf) {\n for (const index of indices) if (index < items.length) levels.push([index, 0]);\n return levels;\n }\n const outermost = new Set(indices);\n const flow = this.list.measuring();\n items.forEach((item, index) => {\n const level = outermost.has(index) ? 0 : levelOf(item, index);\n if (level !== null && !(flow && level > 0)) levels.push([index, level]);\n });\n return levels;\n });\n\n /** Each sticky row, with the rows it pins under and the one that pushes it off. */\n readonly rows = computed(() => {\n const rows = new Map<number, StickyRow>();\n // The rows a row here would pin under: each deeper than the one before it.\n const open: number[] = [];\n for (const [index, level] of this.levels()) {\n while (open.length > 0 && rows.get(open.at(-1)!)!.level >= level) {\n rows.get(open.pop()!)!.next = index;\n }\n rows.set(index, { level, above: [...open], next: undefined });\n open.push(index);\n }\n return rows;\n });\n\n /**\n * For each sticky row in list order, the least offset that reaches it or a row after it. Where a\n * row starts to hold never comes before where the row before it does, unless a negative `rowGap`\n * overlaps the rows, and this stays in order either way, so `pinned` can halve over it.\n */\n private readonly reach = computed(() => {\n const order = this.levels();\n const reach = new Array<number>(order.length);\n let least = Infinity;\n for (let at = order.length - 1; at >= 0; at--) {\n least = Math.min(least, this.startOf(order[at]![0]));\n reach[at] = least;\n }\n return reach;\n });\n\n /**\n * The sticky rows currently holding the leading edge, outermost first: the last one the offset\n * has reached, under the rows it pins under. Empty when the list has scrolled back above the\n * first of them.\n */\n readonly pinned = computed<readonly number[]>(\n () => {\n const order = this.levels();\n if (order.length === 0) return NONE;\n const offset = this.offset();\n\n // The last row the offset has reached is the last whose `reach` it has, found by halving.\n const reach = this.reach();\n let low = 0;\n let high = order.length;\n while (low < high) {\n const middle = (low + high) >> 1;\n if (reach[middle]! <= offset) low = middle + 1;\n else high = middle;\n }\n if (low === 0) return NONE;\n const pinned = order[low - 1]![0];\n return [...this.rows().get(pinned)!.above, pinned];\n },\n // The same rows are the same pinning: where native moves them, a scroll then re-renders none.\n { equal: (a, b) => a.length === b.length && a.every((index, at) => index === b[at]) },\n );\n\n /**\n * The header's translation while it is pinned: the scroll position, held back at zero by an\n * overscroll and at the first sticky row, which pushes it off. Where native moves it, the\n * translate native had reached when scrolling paused, as for a sticky row.\n */\n readonly headerStyle = computed(() => {\n const flip = this.list.flipText();\n if (!this.list.header()) return flip ? { transform: flip } : undefined;\n const along = this.native ? this.settled() : this.along();\n const shift = Math.min(Math.max(0, along), this.headerLimit());\n const move =\n shift > 0 ? `${this.list.horizontal() ? 'translateX' : 'translateY'}(${shift}px)` : '';\n const transform = [move, flip ?? ''].filter(Boolean).join(' ');\n return transform ? { zIndex: 1, transform } : { zIndex: 1 };\n });\n\n /**\n * The pinned row `index` in flow, moved by a transform from `at`, where flow put it, to the leading\n * edge, until the next sticky row reaches it there and pushes it off.\n */\n flowStyle(index: number, at: number): Record<string, unknown> {\n const shift = Math.max(0, Math.min(this.offset(), this.stopOf(index)) - at);\n const move = `${this.list.horizontal() ? 'translateX' : 'translateY'}(${shift}px)`;\n const flip = this.list.flipText();\n return { ...this.list.flowSpacing(), zIndex: 1, transform: flip ? `${move} ${flip}` : move };\n }\n\n /**\n * A pinned row placed by its `top`: under the rows it pins under, until the next row at its\n * level or further out reaches it there and pushes it off.\n */\n slotStyle(index: number): Record<string, unknown> {\n const at = Math.min(this.offset(), this.stopOf(index)) + this.above(index);\n return {\n ...this.list.slotStyle(index),\n [this.list.horizontal() ? 'left' : 'top']: at,\n zIndex: this.zIndexOf(index),\n };\n }\n\n /**\n * A sticky row native moves: at its own place, with the translate native had reached when\n * scrolling paused, so the props agree with what is on screen.\n */\n style(index: number): Record<string, unknown> {\n const horizontal = this.list.horizontal();\n const style: Record<string, unknown> = this.list.measuring()\n ? { ...this.list.flowSpacing() }\n : { ...this.list.slotStyle(index) };\n style['zIndex'] = this.zIndexOf(index);\n const start = this.startOf(index);\n const settled = this.settled() - this.list.headerHeight();\n const shift = Math.min(Math.max(0, settled - start), this.stopOf(index) - start);\n const move = shift > 0 ? `${horizontal ? 'translateX' : 'translateY'}(${shift}px)` : '';\n const transform = [move, this.list.flipText() ?? ''].filter(Boolean).join(' ');\n if (transform) style['transform'] = transform;\n return style;\n }\n\n /**\n * The recycling type of a row: a sticky row is a type of its own, since native keeps the\n * translate it moved one by, and a plain row taking its slot commits no transform to put it\n * back. Apart from that, `kind`, the row's `itemType`.\n */\n recyclingType(index: number, kind: unknown): unknown {\n if (!this.rows().has(index)) return kind;\n let type = this.typeOfKind.get(kind);\n if (!type) {\n type = Symbol('sticky');\n this.typeOfKind.set(kind, type);\n this.types.add(type);\n }\n return type;\n }\n\n /** Whether a recycling type is a sticky row's. */\n isType(type: unknown): boolean {\n return this.types.has(type);\n }\n\n /** The list scrolled, to `along` in the scroll view. */\n scrolled(along: number): void {\n this.nativeAt = along;\n this.nativeAxis = this.list.horizontal() ? 'x' : 'y';\n if (this.jumped) {\n this.reported = along;\n // An event from before the jump, or on the way, is not where it lands.\n if (Math.abs(along - this.jumpedTo) <= 1) this.landed = true;\n }\n // A pinned row follows the scroll continuously, so the offset is a signal. Nothing reads it\n // until a row or the header is pinned, so without them this stays out of change detection,\n // and a fling that moves no row in or out of the window costs none. It is kept all the same:\n // a row that turns sticky in a scrolled list is pinned where the list is, not where it was.\n this.along.set(along);\n if (!this.native) return;\n clearTimeout(this.settleTimer);\n this.resting = false;\n const settle = () => {\n this.resting = true;\n this.settled.set(along);\n };\n if (!this.pinning()) return settle();\n // See `STICKY_SETTLE_MS`.\n this.settleTimer = setTimeout(settle, STICKY_SETTLE_MS);\n }\n\n /** The list is scrolling itself, to `to` in the scroll view, where native has not drawn yet. */\n jumping(to: number, animated: boolean): void {\n // To where native last said it was, with no earlier jump on its way: it moves nothing and\n // reports nothing. With one, native moves and comes back, and reports that.\n const pending = this.jumped && !this.landed;\n if (Math.abs(to - (pending ? this.jumpedTo : this.nativeAt)) > 1) this.ends++;\n this.jumped = pending || Math.abs(to - this.nativeAt) > 1;\n this.landed = false;\n this.jumpedTo = to;\n this.jumpAnimated = animated;\n this.reported = undefined;\n }\n\n /** The user took the scroll over: native's own events move the rows from here. */\n dragged(): void {\n this.jumped = this.landed = false;\n // Android sends no end for a jump that is not animated, so none is waited for past a drag.\n this.ends = 0;\n }\n\n /**\n * A scroll came to rest. The last of the jumps on their way has landed, wherever it did: iOS\n * does not stop a scroll at the end of the content, so it can rest past where the list said,\n * and what moves it next (a tap on the status bar) is not a drag.\n */\n rested(): void {\n if (this.ends > 0) this.ends--;\n if (this.jumped && this.ends === 0) this.landed = true;\n }\n\n /**\n * Hand each rendered sticky row's view to native to move, and let go of the rest, and the\n * header's view, `header`, while it is pinned. `views` are the rendered rows' views in the same\n * order as `rows`. Each is only asked for where there is a drive to make or let go.\n */\n drive(\n rows: () => readonly Row[],\n views: () => readonly HostNode[],\n header: () => HostNode,\n ): void {\n if (!this.pinning() && this.drives.size === 0 && !this.headerDrive) return;\n const rendered = views();\n const axis = this.list.horizontal() ? 'x' : 'y';\n const live = new Set<HostNode>();\n // After the list scrolled itself, where native is: it draws a graph when its offset changes,\n // and after a jump the offset of a drive just made may not. What native last reported, or\n // before it has, the target of a jump that is not animated. An animated one only once it has\n // landed: on the way native's offset changes every frame, so it draws a new graph anyway, and\n // the offset here trails native's and would set every pinned row back a frame. The same holds\n // mid-fling, which is why nothing is told outside a jump.\n const from = !this.jumped\n ? undefined\n : this.jumpAnimated\n ? this.landed\n ? this.reported\n : undefined\n : (this.reported ?? this.jumpedTo);\n rows().forEach((row, at) => {\n const view = rendered[at];\n const next = this.driveOf(row);\n if (!view || !next) return;\n live.add(view);\n const statics = JSON.stringify(next.statics);\n const held = this.drives.get(view);\n if (held?.statics === statics) return held.drive.update(next.range, from);\n held?.drive.stop();\n const drive = this.engine.driveByScroll(\n view,\n this.node,\n axis,\n next.range,\n next.statics,\n held ? this.remadeFrom(axis, from) : from,\n );\n if (drive) this.drives.set(view, { drive, statics });\n });\n for (const [view, held] of this.drives) {\n if (live.has(view)) continue;\n held.drive.stop();\n this.drives.delete(view);\n }\n this.driveHeader(header, axis, from);\n if (this.landed) this.jumped = this.landed = false;\n }\n\n /**\n * Hand the header to native to move while it is pinned, by the scroll view's offset until the\n * first sticky row pushes it off. Unpinned, it is moved nowhere.\n */\n private driveHeader(view: () => HostNode, axis: 'x' | 'y', from: number | undefined): void {\n const pinned = this.list.header();\n if (!pinned && !this.headerDrive) return;\n const range = pinned ? this.headerRange() : STILL;\n const held = this.headerDrive;\n const moved = JSON.stringify(range);\n const at = this.headerFrom(pinned, moved, axis, from);\n const statics = this.list.flip() ?? [];\n // The axis too: a list turned horizontal moves the header along x.\n const key = axis + JSON.stringify(statics);\n if (held?.statics === key) {\n held.pinned = pinned;\n held.range = moved;\n return held.drive.update(range, at);\n }\n held?.drive.stop();\n const drive = this.engine.driveByScroll(\n view(),\n this.node,\n axis,\n range,\n statics,\n held ? (at ?? this.remadeFrom(axis, from)) : at,\n );\n this.headerDrive = drive && { drive, statics: key, pinned, range: moved };\n }\n\n /**\n * Where native is told the scroll view is for the header's drive, `pinned` and moved by the range\n * `moved`. Pinned, let go, or moved by a new range at rest, native has no new scroll event to draw\n * it from: it is told where it last said it was. Mid-scroll the next event draws it, and what\n * native last said trails it, and what it said along the other axis says nothing of `axis`. After a\n * jump, `from`, where the list scrolled itself.\n */\n private headerFrom(\n pinned: boolean,\n moved: string,\n axis: 'x' | 'y',\n from: number | undefined,\n ): number | undefined {\n const held = this.headerDrive;\n const changed = held?.pinned !== pinned || (this.resting && held.range !== moved);\n if (!changed) return from;\n return from ?? (this.nativeAxis === axis ? this.nativeAt : undefined);\n }\n\n /**\n * Where native is told the scroll view is for a drive made again along `axis`, as for a flip. The\n * one it replaces may have been the last to read the offset, so the new one starts from nothing,\n * and at rest no scroll event comes to draw it: it is told where native last said it was, unless\n * that was along the other axis. After a jump, `from`.\n */\n private remadeFrom(axis: 'x' | 'y', from: number | undefined): number | undefined {\n return from ?? (this.resting && this.nativeAxis === axis ? this.nativeAt : undefined);\n }\n\n /** How native moves the pinned header. A first sticky row at the very top holds it in place. */\n private headerRange(): ScrollRange {\n const limit = this.headerLimit();\n return limit > 0 ? pinnedRange(0, limit) : STILL;\n }\n\n /** How far the header moves before the first sticky row pushes it off: to that row's top. */\n private headerLimit(): number {\n const [first] = this.rows().keys();\n return first === undefined ? Infinity : this.list.topOf(first);\n }\n\n destroy(): void {\n clearTimeout(this.settleTimer);\n for (const held of this.drives.values()) held.drive.stop();\n this.headerDrive?.drive.stop();\n }\n\n /** The size of the rows a sticky row pins under, which is how far from the edge it holds. */\n private above(index: number): number {\n let size = 0;\n for (const over of this.rows().get(index)?.above ?? NONE) size += this.list.heightOf(over);\n return size;\n }\n\n /**\n * A deeper row is drawn under the rows it pins under, and every sticky row over the rest. See\n * `FRONT`. Without levels a sticky row's zIndex is 1, as it was before there were any.\n */\n private zIndexOf(index: number): number {\n if (!this.list.levels?.levelOf()) return 1;\n return Math.max(1, FRONT - (this.rows().get(index)?.level ?? 0));\n }\n\n /** The offset a sticky row starts to hold from: where its top meets the rows it pins under. */\n private startOf(index: number): number {\n return this.list.topOf(index) - this.above(index);\n }\n\n /**\n * The offset a sticky row stops holding at, pushed off by the next: where that row's top meets\n * this row's far edge.\n */\n private stopOf(index: number): number {\n const next = this.rows().get(index)?.next;\n if (next === undefined) return Infinity;\n return this.list.topOf(next) - this.list.heightOf(index) - this.above(index);\n }\n\n /**\n * How native moves a rendered row, or null when it does not: along the scroll view's own\n * offset, which counts the header, from where the row meets the rows it pins under until the\n * next sticky row pushes it off. A row the next one follows with no space between them holds\n * nowhere, so native moves it nowhere: it is not let go, since native keeps the translate it\n * had moved a row by.\n */\n private driveOf(row: Row): { range: ScrollRange; statics: readonly StaticTransform[] } | null {\n if (!this.native || row.parked || !this.rows().has(row.index)) return null;\n const header = this.list.headerHeight();\n const start = header + this.startOf(row.index);\n const stop = header + this.stopOf(row.index);\n return {\n range:\n stop > start ? pinnedRange(start, stop) : { input: [start, start + 1], output: [0, 0] },\n statics: this.list.flip() ?? [],\n };\n }\n}\n"]}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The markup to commit as `svgIcon` for an icon, or undefined when it is not `{ svg }`. Says once,
3
+ * in development, when the markup is no `<svg>` element (the icon's name in place of its markup is
4
+ * the usual slip), and with `offDesktop` when the platform running draws a symbol or a drawable for
5
+ * the element but no SVG, since either shows no icon.
6
+ */
7
+ export declare function svgIconMarkup(icon: {
8
+ readonly svg?: string;
9
+ } | object | undefined, element: string, offDesktop?: boolean): string | undefined;