vlist 3.0.0-next.3 → 3.0.0-next.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.github.md +28 -26
- package/README.md +25 -25
- package/dist/config.d.ts +35 -10
- package/dist/config.js +1 -1
- package/dist/core/dom.d.ts +21 -1
- package/dist/core/fold.d.ts +52 -0
- package/dist/core/pool.d.ts +8 -1
- package/dist/core/runway.d.ts +23 -1
- package/dist/core/types.d.ts +18 -0
- package/dist/index.js +1 -1
- package/dist/internals.js +1 -1
- package/dist/plugins/carousel/plugin.d.ts +12 -4
- package/dist/plugins/groups/async-bridge.d.ts +6 -6
- package/dist/plugins/groups/layout.d.ts +2 -2
- package/dist/plugins/groups/plugin.d.ts +4 -4
- package/dist/plugins/groups/sticky.d.ts +2 -1
- package/dist/plugins/groups/types.d.ts +2 -2
- package/dist/plugins/search/plugin.d.ts +3 -0
- package/dist/plugins/selection/plugin.d.ts +3 -3
- package/dist/plugins/sortable/plugin.d.ts +3 -0
- package/dist/plugins/tree/layout.d.ts +2 -0
- package/dist/rendering/sizes.d.ts +12 -0
- package/dist/size.json +1 -1
- package/dist/synthetic.js +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/utils/apply-scroll-behavior.d.ts +15 -0
- package/dist/vlist-tree.css +1 -1
- package/dist/vlist.css +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrap-mode fold: re-key mounted rows and shift the render window.
|
|
3
|
+
*
|
|
4
|
+
* A fold moves every virtual index by whole laps; the nodes and their paint
|
|
5
|
+
* positions are unchanged. Re-keying the map (and the `id` that encodes the
|
|
6
|
+
* virtual index) lets the next commit find them instead of releasing,
|
|
7
|
+
* re-templating and re-inserting the viewport. Lives here — not in pipeline
|
|
8
|
+
* or create — so a native list that never wraps does not import it (runway
|
|
9
|
+
* is pulled by carousel). The synthetic handler imports it because wrap
|
|
10
|
+
* folds for that entry go through commit(), not wrapRebase; putting the
|
|
11
|
+
* import in create.ts would charge every native list.
|
|
12
|
+
*
|
|
13
|
+
* Shifted with the fold: the typed-array window (`shiftWindow`), carousel
|
|
14
|
+
* `intendedVi`, velocity `_lp`, `lastEventScrollPos`, `id` (virtual index),
|
|
15
|
+
* `aria-activedescendant` (resolved to the same node after its id rewrite),
|
|
16
|
+
* `oddClass` when `indexShift` is odd (stripe is virtual-index parity).
|
|
17
|
+
* Fold-invariant: `data-index` / `aria-posinset` (public index), selection
|
|
18
|
+
* `focusedIndex` (data space under `indexMap`), snapshots (`dataIndex`).
|
|
19
|
+
*/
|
|
20
|
+
import type { EngineState } from "./state";
|
|
21
|
+
import type { WrapConfig } from "./runway";
|
|
22
|
+
/**
|
|
23
|
+
* Move every `rendered` key by `-indexShift` without touching the DOM tree.
|
|
24
|
+
* `data-index` / `aria-posinset` carry the public index and stay put.
|
|
25
|
+
*
|
|
26
|
+
* `aria-activedescendant` is resolved after every id rewrite: a uniform shift
|
|
27
|
+
* can make two nodes share an id mid-loop, so rewriting the attribute from a
|
|
28
|
+
* reconstructed old id in that window can point at the wrong node.
|
|
29
|
+
*/
|
|
30
|
+
export declare function rekeyRendered(rendered: Map<number, HTMLElement>, indexShift: number, prefix: string, content: HTMLElement, oddClass?: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* Shift the committed render window by whole laps after a wrap fold.
|
|
33
|
+
*
|
|
34
|
+
* Virtual indices and offsets move with the logical origin; shifting them
|
|
35
|
+
* (and `prevBaseOffset`) keeps the range-unchanged fast path honest so the
|
|
36
|
+
* next frame does not treat identical paint as a new window.
|
|
37
|
+
*/
|
|
38
|
+
export declare function shiftWindow(state: EngineState, indexShift: number, pixelShift: number): void;
|
|
39
|
+
/**
|
|
40
|
+
* How many whole laps to fold by, for a drift from home measured in laps; 0 for none.
|
|
41
|
+
*
|
|
42
|
+
* An owner that folds every lap (threshold 1) keeps its position in
|
|
43
|
+
* `[home, home + lap)`: the floor, so that leaving the home lap backwards folds
|
|
44
|
+
* at once, exactly as leaving it forwards does. Truncation folded forwards on
|
|
45
|
+
* leaving the lap but backwards only a whole lap later — a carousel could rest in
|
|
46
|
+
* the lap before home at index 0, where a leading peek needs index -1: a blank
|
|
47
|
+
* peek, then a pop. A larger threshold keeps the symmetric dead zone it always had.
|
|
48
|
+
*/
|
|
49
|
+
export declare function wrapLaps(driftLaps: number, threshold: number): number;
|
|
50
|
+
/** Re-key mounted rows and shift window state for a wrap fold, before the next render. */
|
|
51
|
+
export declare function applyWrapFold(wrap: WrapConfig, shift: number, state: EngineState, content: HTMLElement, rendered: Map<number, HTMLElement> | undefined, prefix: string, oddClass?: string): void;
|
|
52
|
+
//# sourceMappingURL=fold.d.ts.map
|
package/dist/core/pool.d.ts
CHANGED
|
@@ -2,7 +2,14 @@
|
|
|
2
2
|
* vlist — Element Pool
|
|
3
3
|
*
|
|
4
4
|
* acquire() = pop or create, release() = reset + push.
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
|
+
* No fixed cap. A cap of 100 dropped a window of 300 cells on a jump, and the
|
|
7
|
+
* next frame cloned 200 of them again. The pool still grows to the most rows
|
|
8
|
+
* that were on screen at once, and that peak does not fall on its own:
|
|
9
|
+
* release() only pushes, so a list that shrinks keeps every spare node until
|
|
10
|
+
* trim() drops them back to the number currently mounted. Core trims when
|
|
11
|
+
* scrolling has gone idle, and after a data change that is not mid-scroll, so
|
|
12
|
+
* a jump during a gesture still reuses the previous window.
|
|
6
13
|
*/
|
|
7
14
|
import type { ElementPool } from "./types";
|
|
8
15
|
export declare function createPool(classPrefix: string): ElementPool;
|
package/dist/core/runway.d.ts
CHANGED
|
@@ -56,7 +56,13 @@ export interface BoundedScrollHandler extends ScrollHandler {
|
|
|
56
56
|
export interface WrapConfig {
|
|
57
57
|
/** Current lap period in virtual px (`realTotal × stepSize`). */
|
|
58
58
|
readonly lapSize: () => number;
|
|
59
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* Real items in one lap (e.g. the carousel's `realTotal`). The wrap handler
|
|
61
|
+
* uses this to re-key mounted elements on a fold so the same DOM nodes
|
|
62
|
+
* survive the virtual-index shift — only the key changed; paint did not.
|
|
63
|
+
*/
|
|
64
|
+
readonly itemsPerLap: () => number;
|
|
65
|
+
/** Logical position to fold back toward (the home lap). */
|
|
60
66
|
readonly home: () => number;
|
|
61
67
|
/** Fold the logical position back toward `home` once it drifts this many laps away. */
|
|
62
68
|
readonly thresholdLaps: number;
|
|
@@ -80,6 +86,22 @@ export interface BoundedScrollConfig {
|
|
|
80
86
|
/** Infinite-loop config (carousel). When set, the logical position wraps by
|
|
81
87
|
* whole laps toward `home` instead of clamping to a maximum. */
|
|
82
88
|
readonly wrap?: WrapConfig;
|
|
89
|
+
/**
|
|
90
|
+
* Mounted row map. A wrap fold re-keys it in place so phase 2 finds the
|
|
91
|
+
* same nodes; omitted when the handler is constructed without a viewport.
|
|
92
|
+
*/
|
|
93
|
+
readonly rendered?: Map<number, HTMLElement>;
|
|
94
|
+
/**
|
|
95
|
+
* Class prefix for rewriting `id` / `aria-activedescendant` on a wrap fold.
|
|
96
|
+
* Passed explicitly — a prefix containing `-content` cannot be recovered
|
|
97
|
+
* from the content element's class name.
|
|
98
|
+
*/
|
|
99
|
+
readonly classPrefix?: string;
|
|
100
|
+
/**
|
|
101
|
+
* Stripe class (`{prefix}-item--odd`). Re-toggled on a wrap fold when
|
|
102
|
+
* `indexShift` is odd, so virtual-index parity survives the re-key.
|
|
103
|
+
*/
|
|
104
|
+
readonly oddClass?: string;
|
|
83
105
|
/** @internal Coordinate fold: shift core telemetry references before rendering. */
|
|
84
106
|
readonly onFold?: (shift: number) => void;
|
|
85
107
|
/** Called synchronously per frame — triggers the 2-phase pipeline. */
|
package/dist/core/types.d.ts
CHANGED
|
@@ -56,6 +56,8 @@ export interface ElementPool {
|
|
|
56
56
|
acquire(): HTMLElement;
|
|
57
57
|
release(element: HTMLElement): void;
|
|
58
58
|
readonly size: number;
|
|
59
|
+
/** Drop spare nodes until at most `keep` remain. Does not touch mounted rows. */
|
|
60
|
+
trim(keep: number): void;
|
|
59
61
|
clear(): void;
|
|
60
62
|
}
|
|
61
63
|
/**
|
|
@@ -152,6 +154,16 @@ export interface NavCapability {
|
|
|
152
154
|
lr?: number;
|
|
153
155
|
scrollIndex?: (itemIndex: number) => number;
|
|
154
156
|
navigate?: (currentIndex: number, key: string, total: number) => number;
|
|
157
|
+
/**
|
|
158
|
+
* Bring this navigation / focus index into view, the layout plugin's way.
|
|
159
|
+
* The index is the same space as `nav.total` (carousel: logical item
|
|
160
|
+
* index; grid: item index) — not a size-cache index and not a layout
|
|
161
|
+
* index that counts group headers or carousel laps.
|
|
162
|
+
* `selectNext` / `selectPrevious` call this when present so a plugin that
|
|
163
|
+
* owns motion (carousel snap, current virtual lap) reveals the item
|
|
164
|
+
* without selection falling back to a raw size-cache offset.
|
|
165
|
+
*/
|
|
166
|
+
reveal?: (index: number) => void;
|
|
155
167
|
}): void;
|
|
156
168
|
get(): {
|
|
157
169
|
ud: number;
|
|
@@ -159,6 +171,12 @@ export interface NavCapability {
|
|
|
159
171
|
scrollIndex: ((itemIndex: number) => number) | null;
|
|
160
172
|
navigate: ((currentIndex: number, key: string, total: number) => number) | null;
|
|
161
173
|
total: (() => number) | null;
|
|
174
|
+
/**
|
|
175
|
+
* Always present on the returned object: the owner's reveal, or `null`
|
|
176
|
+
* when no plugin published one. Plugin authors must read this property
|
|
177
|
+
* rather than treating a missing key as "no owner".
|
|
178
|
+
*/
|
|
179
|
+
reveal: ((index: number) => void) | null;
|
|
162
180
|
};
|
|
163
181
|
}
|
|
164
182
|
/**
|