@foldkit/ui 0.166.0-canary.7590156835c8 → 0.166.0-canary.9d0f28976e5e
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.
|
@@ -1,9 +1,43 @@
|
|
|
1
|
-
import { Effect,
|
|
2
|
-
import {
|
|
1
|
+
import { Effect, Schema } from 'effect';
|
|
2
|
+
import { Update } from 'foldkit';
|
|
3
3
|
import * as Command from 'foldkit/command';
|
|
4
4
|
import { type ChildAttribute, type Html, type TagName } from 'foldkit/html';
|
|
5
|
+
import * as Mount from 'foldkit/mount';
|
|
5
6
|
import { type View as SubmodelView } from 'foldkit/submodel';
|
|
6
|
-
|
|
7
|
+
/** Alignment of a row within the viewport after a programmatic scroll. */
|
|
8
|
+
export declare const ScrollAlignment: Schema.Literals<readonly ["Start", "Center", "End", "Nearest"]>;
|
|
9
|
+
export type ScrollAlignment = typeof ScrollAlignment.Type;
|
|
10
|
+
/** Logical destination for initial and programmatic scrolling. */
|
|
11
|
+
export declare const ScrollTarget: import("foldkit/schema").TaggedUnion<{
|
|
12
|
+
readonly Index: {
|
|
13
|
+
index: Schema.Number;
|
|
14
|
+
};
|
|
15
|
+
readonly Key: {
|
|
16
|
+
key: Schema.String;
|
|
17
|
+
};
|
|
18
|
+
readonly Offset: {
|
|
19
|
+
offset: Schema.Number;
|
|
20
|
+
};
|
|
21
|
+
readonly End: {};
|
|
22
|
+
}>;
|
|
23
|
+
export type ScrollTarget = typeof ScrollTarget.Type;
|
|
24
|
+
/** Outcome of applying a logical scroll request after the view commits. */
|
|
25
|
+
export declare const ApplyScrollOutcome: import("foldkit/schema").TaggedUnion<{
|
|
26
|
+
readonly Applied: {
|
|
27
|
+
scrollTop: Schema.Number;
|
|
28
|
+
scrollHeight: Schema.Number;
|
|
29
|
+
containerHeight: Schema.Number;
|
|
30
|
+
anchor: import("foldkit/schema").TaggedUnion<{
|
|
31
|
+
readonly None: {};
|
|
32
|
+
readonly Row: {
|
|
33
|
+
key: Schema.String;
|
|
34
|
+
index: Schema.Number;
|
|
35
|
+
viewportOffset: Schema.Number;
|
|
36
|
+
};
|
|
37
|
+
}>;
|
|
38
|
+
};
|
|
39
|
+
readonly Skipped: {};
|
|
40
|
+
}>;
|
|
7
41
|
/** Schema for the virtual list's state. Tracks scroll position, container
|
|
8
42
|
* measurement, and any in-flight programmatic scroll. */
|
|
9
43
|
export declare const Model: Schema.Struct<{
|
|
@@ -13,13 +47,80 @@ export declare const Model: Schema.Struct<{
|
|
|
13
47
|
readonly measurement: import("foldkit/schema").TaggedUnion<{
|
|
14
48
|
readonly Unmeasured: {};
|
|
15
49
|
readonly Measured: {
|
|
50
|
+
containerWidth: Schema.Number;
|
|
16
51
|
containerHeight: Schema.Number;
|
|
17
52
|
};
|
|
18
53
|
}>;
|
|
54
|
+
readonly viewportAnchor: import("foldkit/schema").TaggedUnion<{
|
|
55
|
+
readonly Offset: {
|
|
56
|
+
scrollTop: Schema.Number;
|
|
57
|
+
};
|
|
58
|
+
readonly Row: {
|
|
59
|
+
key: Schema.String;
|
|
60
|
+
index: Schema.Number;
|
|
61
|
+
viewportOffset: Schema.Number;
|
|
62
|
+
};
|
|
63
|
+
readonly End: {};
|
|
64
|
+
}>;
|
|
65
|
+
readonly measuredRowHeights: Schema.$Record<Schema.String, Schema.Number>;
|
|
66
|
+
readonly layoutVersion: Schema.Number;
|
|
67
|
+
readonly initialScroll: import("foldkit/schema").TaggedUnion<{
|
|
68
|
+
readonly Applied: {};
|
|
69
|
+
readonly Pending: {
|
|
70
|
+
target: import("foldkit/schema").TaggedUnion<{
|
|
71
|
+
readonly Index: {
|
|
72
|
+
index: Schema.Number;
|
|
73
|
+
};
|
|
74
|
+
readonly Key: {
|
|
75
|
+
key: Schema.String;
|
|
76
|
+
};
|
|
77
|
+
readonly Offset: {
|
|
78
|
+
offset: Schema.Number;
|
|
79
|
+
};
|
|
80
|
+
readonly End: {};
|
|
81
|
+
}>;
|
|
82
|
+
alignment: Schema.Literals<readonly ["Start", "Center", "End", "Nearest"]>;
|
|
83
|
+
};
|
|
84
|
+
}>;
|
|
85
|
+
readonly endBehavior: import("foldkit/schema").TaggedUnion<{
|
|
86
|
+
readonly PreserveAnchor: {};
|
|
87
|
+
readonly Follow: {
|
|
88
|
+
thresholdPx: Schema.Number;
|
|
89
|
+
};
|
|
90
|
+
}>;
|
|
19
91
|
readonly pendingScroll: import("foldkit/schema").TaggedUnion<{
|
|
20
92
|
readonly Idle: {};
|
|
21
|
-
readonly
|
|
22
|
-
|
|
93
|
+
readonly Pending: {
|
|
94
|
+
request: import("foldkit/schema").TaggedUnion<{
|
|
95
|
+
readonly Target: {
|
|
96
|
+
target: import("foldkit/schema").TaggedUnion<{
|
|
97
|
+
readonly Index: {
|
|
98
|
+
index: Schema.Number;
|
|
99
|
+
};
|
|
100
|
+
readonly Key: {
|
|
101
|
+
key: Schema.String;
|
|
102
|
+
};
|
|
103
|
+
readonly Offset: {
|
|
104
|
+
offset: Schema.Number;
|
|
105
|
+
};
|
|
106
|
+
readonly End: {};
|
|
107
|
+
}>;
|
|
108
|
+
alignment: Schema.Literals<readonly ["Start", "Center", "End", "Nearest"]>;
|
|
109
|
+
};
|
|
110
|
+
readonly Anchor: {
|
|
111
|
+
anchor: import("foldkit/schema").TaggedUnion<{
|
|
112
|
+
readonly Offset: {
|
|
113
|
+
scrollTop: Schema.Number;
|
|
114
|
+
};
|
|
115
|
+
readonly Row: {
|
|
116
|
+
key: Schema.String;
|
|
117
|
+
index: Schema.Number;
|
|
118
|
+
viewportOffset: Schema.Number;
|
|
119
|
+
};
|
|
120
|
+
readonly End: {};
|
|
121
|
+
}>;
|
|
122
|
+
};
|
|
123
|
+
}>;
|
|
23
124
|
version: Schema.Number;
|
|
24
125
|
};
|
|
25
126
|
}>;
|
|
@@ -28,37 +129,125 @@ export declare const Model: Schema.Struct<{
|
|
|
28
129
|
export type Model = typeof Model.Type;
|
|
29
130
|
/** Union of all messages the virtual list component can produce. */
|
|
30
131
|
export declare const Message: import("foldkit/message").MessageUnion<{
|
|
31
|
-
readonly
|
|
132
|
+
readonly ObservedContainerScroll: {
|
|
32
133
|
scrollTop: Schema.Number;
|
|
134
|
+
scrollHeight: Schema.Number;
|
|
135
|
+
containerHeight: Schema.Number;
|
|
136
|
+
anchor: import("foldkit/schema").TaggedUnion<{
|
|
137
|
+
readonly None: {};
|
|
138
|
+
readonly Row: {
|
|
139
|
+
key: Schema.String;
|
|
140
|
+
index: Schema.Number;
|
|
141
|
+
viewportOffset: Schema.Number;
|
|
142
|
+
};
|
|
143
|
+
}>;
|
|
33
144
|
};
|
|
34
|
-
readonly
|
|
145
|
+
readonly ResizedContainer: {
|
|
146
|
+
containerWidth: Schema.Number;
|
|
35
147
|
containerHeight: Schema.Number;
|
|
36
148
|
};
|
|
149
|
+
readonly MeasuredRows: {
|
|
150
|
+
measurements: Schema.$Array<Schema.Struct<{
|
|
151
|
+
readonly key: Schema.String;
|
|
152
|
+
readonly height: Schema.Number;
|
|
153
|
+
readonly layoutVersion: Schema.Number;
|
|
154
|
+
}>>;
|
|
155
|
+
};
|
|
37
156
|
readonly CompletedApplyScroll: {
|
|
38
157
|
version: Schema.Number;
|
|
158
|
+
outcome: import("foldkit/schema").TaggedUnion<{
|
|
159
|
+
readonly Applied: {
|
|
160
|
+
scrollTop: Schema.Number;
|
|
161
|
+
scrollHeight: Schema.Number;
|
|
162
|
+
containerHeight: Schema.Number;
|
|
163
|
+
anchor: import("foldkit/schema").TaggedUnion<{
|
|
164
|
+
readonly None: {};
|
|
165
|
+
readonly Row: {
|
|
166
|
+
key: Schema.String;
|
|
167
|
+
index: Schema.Number;
|
|
168
|
+
viewportOffset: Schema.Number;
|
|
169
|
+
};
|
|
170
|
+
}>;
|
|
171
|
+
};
|
|
172
|
+
readonly Skipped: {};
|
|
173
|
+
}>;
|
|
39
174
|
};
|
|
40
175
|
}>;
|
|
41
|
-
export type ScrolledContainer = typeof Message.ScrolledContainer.Type;
|
|
42
|
-
export type MeasuredContainer = typeof Message.MeasuredContainer.Type;
|
|
43
176
|
export type Message = typeof Message.Type;
|
|
44
177
|
/** Configuration for creating a virtual list model with `init`. */
|
|
45
178
|
export type InitConfig = Readonly<{
|
|
46
179
|
id: string;
|
|
47
180
|
rowHeightPx: number;
|
|
48
181
|
initialScrollTop?: number;
|
|
182
|
+
initialScroll?: Readonly<{
|
|
183
|
+
target: ScrollTarget;
|
|
184
|
+
alignment?: ScrollAlignment;
|
|
185
|
+
}>;
|
|
186
|
+
followEnd?: Readonly<{
|
|
187
|
+
thresholdPx?: number;
|
|
188
|
+
}>;
|
|
49
189
|
}>;
|
|
50
190
|
/** Creates an initial virtual list model from a config. The container starts
|
|
51
|
-
* in `Unmeasured` state
|
|
52
|
-
* `Measured`. */
|
|
191
|
+
* in `Unmeasured` state until its Mount reports the first measurement. */
|
|
53
192
|
export declare const init: (config: InitConfig) => Model;
|
|
54
193
|
export declare const ApplyScroll: Command.CommandDefinitionWithArgs<"ApplyScroll", {
|
|
55
194
|
id: Schema.String;
|
|
56
|
-
|
|
195
|
+
request: import("foldkit/schema").TaggedUnion<{
|
|
196
|
+
readonly Target: {
|
|
197
|
+
target: import("foldkit/schema").TaggedUnion<{
|
|
198
|
+
readonly Index: {
|
|
199
|
+
index: Schema.Number;
|
|
200
|
+
};
|
|
201
|
+
readonly Key: {
|
|
202
|
+
key: Schema.String;
|
|
203
|
+
};
|
|
204
|
+
readonly Offset: {
|
|
205
|
+
offset: Schema.Number;
|
|
206
|
+
};
|
|
207
|
+
readonly End: {};
|
|
208
|
+
}>;
|
|
209
|
+
alignment: Schema.Literals<readonly ["Start", "Center", "End", "Nearest"]>;
|
|
210
|
+
};
|
|
211
|
+
readonly Anchor: {
|
|
212
|
+
anchor: import("foldkit/schema").TaggedUnion<{
|
|
213
|
+
readonly Offset: {
|
|
214
|
+
scrollTop: Schema.Number;
|
|
215
|
+
};
|
|
216
|
+
readonly Row: {
|
|
217
|
+
key: Schema.String;
|
|
218
|
+
index: Schema.Number;
|
|
219
|
+
viewportOffset: Schema.Number;
|
|
220
|
+
};
|
|
221
|
+
readonly End: {};
|
|
222
|
+
}>;
|
|
223
|
+
};
|
|
224
|
+
}>;
|
|
57
225
|
version: Schema.Number;
|
|
58
226
|
}, Effect.Effect<{
|
|
59
227
|
readonly _tag: "CompletedApplyScroll";
|
|
60
228
|
readonly version: number;
|
|
229
|
+
readonly outcome: {
|
|
230
|
+
readonly _tag: "Applied";
|
|
231
|
+
readonly scrollTop: number;
|
|
232
|
+
readonly scrollHeight: number;
|
|
233
|
+
readonly containerHeight: number;
|
|
234
|
+
readonly anchor: {
|
|
235
|
+
readonly _tag: "None";
|
|
236
|
+
} | {
|
|
237
|
+
readonly _tag: "Row";
|
|
238
|
+
readonly key: string;
|
|
239
|
+
readonly index: number;
|
|
240
|
+
readonly viewportOffset: number;
|
|
241
|
+
};
|
|
242
|
+
} | {
|
|
243
|
+
readonly _tag: "Skipped";
|
|
244
|
+
};
|
|
61
245
|
}, never, never>>;
|
|
246
|
+
type ScrollReturn = Update.Return<Model, Message>;
|
|
247
|
+
/** Options shared by row-targeted programmatic scrolling helpers. */
|
|
248
|
+
export type ScrollToOptions = Readonly<{
|
|
249
|
+
alignment?: ScrollAlignment;
|
|
250
|
+
}>;
|
|
62
251
|
/** Processes a VirtualList Message and returns the next Model and optional Commands. */
|
|
63
252
|
export declare const update: (model: Model, message: Message) => Readonly<{
|
|
64
253
|
model: {
|
|
@@ -67,158 +256,213 @@ export declare const update: (model: Model, message: Message) => Readonly<{
|
|
|
67
256
|
readonly scrollTop: number;
|
|
68
257
|
readonly measurement: {
|
|
69
258
|
readonly _tag: "Measured";
|
|
259
|
+
readonly containerWidth: number;
|
|
70
260
|
readonly containerHeight: number;
|
|
71
261
|
} | {
|
|
72
262
|
readonly _tag: "Unmeasured";
|
|
73
263
|
};
|
|
264
|
+
readonly viewportAnchor: {
|
|
265
|
+
readonly _tag: "End";
|
|
266
|
+
} | {
|
|
267
|
+
readonly _tag: "Row";
|
|
268
|
+
readonly key: string;
|
|
269
|
+
readonly index: number;
|
|
270
|
+
readonly viewportOffset: number;
|
|
271
|
+
} | {
|
|
272
|
+
readonly _tag: "Offset";
|
|
273
|
+
readonly scrollTop: number;
|
|
274
|
+
};
|
|
275
|
+
readonly measuredRowHeights: {
|
|
276
|
+
readonly [x: string]: number;
|
|
277
|
+
};
|
|
278
|
+
readonly layoutVersion: number;
|
|
279
|
+
readonly initialScroll: {
|
|
280
|
+
readonly _tag: "Applied";
|
|
281
|
+
} | {
|
|
282
|
+
readonly _tag: "Pending";
|
|
283
|
+
readonly target: {
|
|
284
|
+
readonly _tag: "End";
|
|
285
|
+
} | {
|
|
286
|
+
readonly _tag: "Index";
|
|
287
|
+
readonly index: number;
|
|
288
|
+
} | {
|
|
289
|
+
readonly _tag: "Key";
|
|
290
|
+
readonly key: string;
|
|
291
|
+
} | {
|
|
292
|
+
readonly _tag: "Offset";
|
|
293
|
+
readonly offset: number;
|
|
294
|
+
};
|
|
295
|
+
readonly alignment: "Center" | "End" | "Nearest" | "Start";
|
|
296
|
+
};
|
|
297
|
+
readonly endBehavior: {
|
|
298
|
+
readonly _tag: "Follow";
|
|
299
|
+
readonly thresholdPx: number;
|
|
300
|
+
} | {
|
|
301
|
+
readonly _tag: "PreserveAnchor";
|
|
302
|
+
};
|
|
74
303
|
readonly pendingScroll: {
|
|
75
304
|
readonly _tag: "Idle";
|
|
76
305
|
} | {
|
|
77
|
-
readonly _tag: "
|
|
78
|
-
readonly
|
|
306
|
+
readonly _tag: "Pending";
|
|
307
|
+
readonly request: {
|
|
308
|
+
readonly _tag: "Anchor";
|
|
309
|
+
readonly anchor: {
|
|
310
|
+
readonly _tag: "End";
|
|
311
|
+
} | {
|
|
312
|
+
readonly _tag: "Row";
|
|
313
|
+
readonly key: string;
|
|
314
|
+
readonly index: number;
|
|
315
|
+
readonly viewportOffset: number;
|
|
316
|
+
} | {
|
|
317
|
+
readonly _tag: "Offset";
|
|
318
|
+
readonly scrollTop: number;
|
|
319
|
+
};
|
|
320
|
+
} | {
|
|
321
|
+
readonly _tag: "Target";
|
|
322
|
+
readonly target: {
|
|
323
|
+
readonly _tag: "End";
|
|
324
|
+
} | {
|
|
325
|
+
readonly _tag: "Index";
|
|
326
|
+
readonly index: number;
|
|
327
|
+
} | {
|
|
328
|
+
readonly _tag: "Key";
|
|
329
|
+
readonly key: string;
|
|
330
|
+
} | {
|
|
331
|
+
readonly _tag: "Offset";
|
|
332
|
+
readonly offset: number;
|
|
333
|
+
};
|
|
334
|
+
readonly alignment: "Center" | "End" | "Nearest" | "Start";
|
|
335
|
+
};
|
|
79
336
|
readonly version: number;
|
|
80
337
|
};
|
|
81
338
|
readonly pendingScrollVersion: number;
|
|
82
339
|
};
|
|
83
340
|
commands?: Update.Commands<{
|
|
84
|
-
readonly _tag: "ScrolledContainer";
|
|
85
|
-
readonly scrollTop: number;
|
|
86
|
-
} | {
|
|
87
|
-
readonly _tag: "MeasuredContainer";
|
|
88
|
-
readonly containerHeight: number;
|
|
89
|
-
} | {
|
|
90
341
|
readonly _tag: "CompletedApplyScroll";
|
|
91
342
|
readonly version: number;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
/** Programmatically scrolls the container so the row at `index` is visible.
|
|
97
|
-
* Returns the next Model and a Command that mutates `element.scrollTop`. The
|
|
98
|
-
* natural scroll event then flows back through `ScrolledContainer` and the
|
|
99
|
-
* component re-renders the new visible slice.
|
|
100
|
-
*
|
|
101
|
-
* Uses version-based cancellation: each call increments
|
|
102
|
-
* `pendingScrollVersion` so a stale `CompletedApplyScroll` (e.g. from a
|
|
103
|
-
* previous in-flight scroll) is ignored when its version no longer matches.
|
|
104
|
-
*
|
|
105
|
-
* Should be called after the container has rendered. If the container is not
|
|
106
|
-
* yet in the DOM the Command silently no-ops (the Model still transitions
|
|
107
|
-
* through `ScrollingToIndex` → `Idle` via the version-matched completion).
|
|
108
|
-
*
|
|
109
|
-
* Assumes uniform row heights: target scroll position is computed as
|
|
110
|
-
* `index * model.rowHeightPx`. For variable-height rows, use
|
|
111
|
-
* `scrollToIndexVariable`. */
|
|
112
|
-
export declare const scrollToIndex: (model: Model, index: number) => ScrollReturn;
|
|
113
|
-
/** Variable-height counterpart of `scrollToIndex`. Walks the heights of items
|
|
114
|
-
* before `index` to compute the target `scrollTop`. Use this when rendering
|
|
115
|
-
* the list with `itemToRowHeightPx`; use `scrollToIndex` for uniform heights.
|
|
116
|
-
*
|
|
117
|
-
* Out-of-range indices clamp to the corresponding edge: negative or zero
|
|
118
|
-
* scrolls to the top, indices past the end scroll past the last row.
|
|
119
|
-
*
|
|
120
|
-
* Note: when restoring `initialScrollTop` on the first measurement of a
|
|
121
|
-
* variable-height list, the runtime falls back to uniform-height math (using
|
|
122
|
-
* `model.rowHeightPx`) because items aren't reachable from the `update`
|
|
123
|
-
* function. Consumers who need an accurate initial scroll on a
|
|
124
|
-
* variable-height list should call `scrollToIndexVariable` after the first
|
|
125
|
-
* `MeasuredContainer` arrives. */
|
|
126
|
-
export declare const scrollToIndexVariable: <Item>(model: Model, items: ReadonlyArray<Item>, itemToRowHeightPx: (item: Item, index: number) => number, index: number) => ScrollReturn;
|
|
127
|
-
/** Slice of the data array that the view should render, plus the spacer
|
|
128
|
-
* heights that keep the scrollbar physically correct. The first row in the
|
|
129
|
-
* slice corresponds to data index `startIndex`. */
|
|
130
|
-
export type VisibleWindow = Readonly<{
|
|
131
|
-
startIndex: number;
|
|
132
|
-
endIndex: number;
|
|
133
|
-
topSpacerHeight: number;
|
|
134
|
-
bottomSpacerHeight: number;
|
|
135
|
-
}>;
|
|
136
|
-
/** Computes the visible slice of a data array given the current scroll
|
|
137
|
-
* position, container height, row height, and an overscan buffer.
|
|
138
|
-
*
|
|
139
|
-
* Assumes uniform row heights via `model.rowHeightPx`. For variable-height
|
|
140
|
-
* rows, use `visibleWindowVariable`.
|
|
141
|
-
*
|
|
142
|
-
* Returns `Option.none()` when the container has not yet been measured;
|
|
143
|
-
* callers should render a placeholder (or `Html.empty`) and wait for the
|
|
144
|
-
* first `MeasuredContainer` message. */
|
|
145
|
-
export declare const visibleWindow: (model: Model, itemCount: number, overscan: number) => Option.Option<VisibleWindow>;
|
|
146
|
-
/** Variable-height counterpart of `visibleWindow`. Walks the heights of every
|
|
147
|
-
* item to build a prefix-sum array, then locates the visible slice with two
|
|
148
|
-
* linear searches.
|
|
149
|
-
*
|
|
150
|
-
* Cost is O(N) per call, walking the whole `items` array once to build the
|
|
151
|
-
* prefix sums. For lists in the 10k-item range, this comfortably fits inside
|
|
152
|
-
* a 60Hz scroll budget. Larger lists or hotter scroll paths can layer a
|
|
153
|
-
* prefix-sum cache invalidated when items change; that lives behind the same
|
|
154
|
-
* return shape so consumers don't have to know.
|
|
155
|
-
*
|
|
156
|
-
* Returns `Option.none()` when the container has not yet been measured. */
|
|
157
|
-
export declare const visibleWindowVariable: <Item>(model: Model, items: ReadonlyArray<Item>, itemToRowHeightPx: (item: Item, index: number) => number, overscan: number) => Option.Option<VisibleWindow>;
|
|
158
|
-
/** Subscriptions that track the container's scroll position and size.
|
|
159
|
-
*
|
|
160
|
-
* - **scroll**: listens for `scroll` events on the container element and
|
|
161
|
-
* emits `ScrolledContainer` with the new `scrollTop`.
|
|
162
|
-
* - **resize**: observes the container with `ResizeObserver` and emits
|
|
163
|
-
* `MeasuredContainer` with the new height.
|
|
164
|
-
*
|
|
165
|
-
* A `MutationObserver` watches the document for the container element
|
|
166
|
-
* appearing and disappearing, so the listeners attach the moment the
|
|
167
|
-
* element is inserted into the DOM and clean up when it is removed. This
|
|
168
|
-
* makes the subscription robust across SPA route changes: navigating to a
|
|
169
|
-
* page that mounts the list, away, and back all reattach correctly without
|
|
170
|
-
* the consumer having to teach the framework about navigation. */
|
|
171
|
-
export declare const subscriptions: {
|
|
172
|
-
readonly containerEvents: Subscription.EntryWithoutKeepAlive<{
|
|
173
|
-
readonly id: string;
|
|
174
|
-
readonly rowHeightPx: number;
|
|
175
|
-
readonly scrollTop: number;
|
|
176
|
-
readonly measurement: {
|
|
177
|
-
readonly _tag: "Measured";
|
|
343
|
+
readonly outcome: {
|
|
344
|
+
readonly _tag: "Applied";
|
|
345
|
+
readonly scrollTop: number;
|
|
346
|
+
readonly scrollHeight: number;
|
|
178
347
|
readonly containerHeight: number;
|
|
348
|
+
readonly anchor: {
|
|
349
|
+
readonly _tag: "None";
|
|
350
|
+
} | {
|
|
351
|
+
readonly _tag: "Row";
|
|
352
|
+
readonly key: string;
|
|
353
|
+
readonly index: number;
|
|
354
|
+
readonly viewportOffset: number;
|
|
355
|
+
};
|
|
179
356
|
} | {
|
|
180
|
-
readonly _tag: "
|
|
357
|
+
readonly _tag: "Skipped";
|
|
181
358
|
};
|
|
182
|
-
|
|
183
|
-
|
|
359
|
+
} | {
|
|
360
|
+
readonly _tag: "MeasuredRows";
|
|
361
|
+
readonly measurements: readonly {
|
|
362
|
+
readonly key: string;
|
|
363
|
+
readonly height: number;
|
|
364
|
+
readonly layoutVersion: number;
|
|
365
|
+
}[];
|
|
366
|
+
} | {
|
|
367
|
+
readonly _tag: "ObservedContainerScroll";
|
|
368
|
+
readonly scrollTop: number;
|
|
369
|
+
readonly scrollHeight: number;
|
|
370
|
+
readonly containerHeight: number;
|
|
371
|
+
readonly anchor: {
|
|
372
|
+
readonly _tag: "None";
|
|
184
373
|
} | {
|
|
185
|
-
readonly _tag: "
|
|
374
|
+
readonly _tag: "Row";
|
|
375
|
+
readonly key: string;
|
|
186
376
|
readonly index: number;
|
|
187
|
-
readonly
|
|
377
|
+
readonly viewportOffset: number;
|
|
188
378
|
};
|
|
189
|
-
readonly pendingScrollVersion: number;
|
|
190
|
-
}, {
|
|
191
|
-
readonly _tag: "ScrolledContainer";
|
|
192
|
-
readonly scrollTop: number;
|
|
193
379
|
} | {
|
|
194
|
-
readonly _tag: "
|
|
380
|
+
readonly _tag: "ResizedContainer";
|
|
381
|
+
readonly containerWidth: number;
|
|
195
382
|
readonly containerHeight: number;
|
|
383
|
+
}, never>;
|
|
384
|
+
outMessage?: never;
|
|
385
|
+
}>;
|
|
386
|
+
/** Programmatically scrolls to a logical target. */
|
|
387
|
+
export declare const scrollTo: (model: Model, target: ScrollTarget, options?: ScrollToOptions) => ScrollReturn;
|
|
388
|
+
/** Programmatically scrolls the container so the row at `index` is visible.
|
|
389
|
+
* The next view resolves the logical index with its current sizing mode, and
|
|
390
|
+
* the Command aligns the live rendered row. */
|
|
391
|
+
export declare const scrollToIndex: (model: Model, index: number, options?: ScrollToOptions) => ScrollReturn;
|
|
392
|
+
/** Programmatically scrolls to the row whose `itemToKey` result matches
|
|
393
|
+
* `key`. The next view resolves the key against its current items. */
|
|
394
|
+
export declare const scrollToKey: (model: Model, key: string, options?: ScrollToOptions) => ScrollReturn;
|
|
395
|
+
/** Programmatically scrolls to an exact pixel offset from the start of the
|
|
396
|
+
* list. Negative offsets clamp to zero. */
|
|
397
|
+
export declare const scrollToOffset: (model: Model, offset: number) => ScrollReturn;
|
|
398
|
+
/** Programmatically scrolls to the end of the list. */
|
|
399
|
+
export declare const scrollToEnd: (model: Model) => ScrollReturn;
|
|
400
|
+
/** Notifies VirtualList that its parent-owned items changed. The next view
|
|
401
|
+
* resolves the stored stable-key anchor against the new items, and the
|
|
402
|
+
* Command restores that anchor after the DOM patch. */
|
|
403
|
+
export declare const informItemsChanged: (model: Model, itemKeys: ReadonlyArray<string>) => ScrollReturn;
|
|
404
|
+
/** Alignment of content when its total height is shorter than the viewport. */
|
|
405
|
+
export declare const ContentAlignment: Schema.Literals<readonly ["Start", "End"]>;
|
|
406
|
+
export type ContentAlignment = typeof ContentAlignment.Type;
|
|
407
|
+
/** Container-owned Mount that tracks scrolling, container resizing, and
|
|
408
|
+
* rendered row measurements for dynamic-height lists. */
|
|
409
|
+
export declare const ObserveVirtualList: Mount.MountDefinitionWithArgs<"ObserveVirtualList", {
|
|
410
|
+
id: Schema.String;
|
|
411
|
+
}, {
|
|
412
|
+
readonly _tag: "MeasuredRows";
|
|
413
|
+
readonly measurements: readonly {
|
|
414
|
+
readonly key: string;
|
|
415
|
+
readonly height: number;
|
|
416
|
+
readonly layoutVersion: number;
|
|
417
|
+
}[];
|
|
418
|
+
} | {
|
|
419
|
+
readonly _tag: "ObservedContainerScroll";
|
|
420
|
+
readonly scrollTop: number;
|
|
421
|
+
readonly scrollHeight: number;
|
|
422
|
+
readonly containerHeight: number;
|
|
423
|
+
readonly anchor: {
|
|
424
|
+
readonly _tag: "None";
|
|
196
425
|
} | {
|
|
197
|
-
readonly _tag: "
|
|
198
|
-
readonly
|
|
199
|
-
|
|
200
|
-
readonly
|
|
201
|
-
}, never> & {
|
|
202
|
-
readonly __subscription: never;
|
|
426
|
+
readonly _tag: "Row";
|
|
427
|
+
readonly key: string;
|
|
428
|
+
readonly index: number;
|
|
429
|
+
readonly viewportOffset: number;
|
|
203
430
|
};
|
|
204
|
-
}
|
|
431
|
+
} | {
|
|
432
|
+
readonly _tag: "ResizedContainer";
|
|
433
|
+
readonly containerWidth: number;
|
|
434
|
+
readonly containerHeight: number;
|
|
435
|
+
}>;
|
|
205
436
|
/** Per-render view inputs passed to `view` via `h.submodel`'s `viewInputs` field.
|
|
206
437
|
*
|
|
207
|
-
* VirtualList
|
|
208
|
-
*
|
|
209
|
-
|
|
210
|
-
* Subscription's stream into their parent Message in their own
|
|
211
|
-
* `subscriptions` definition. */
|
|
212
|
-
export type ViewInputs<Item> = Readonly<{
|
|
438
|
+
* VirtualList owns scroll and resize observation through a Mount on its
|
|
439
|
+
* container. Dynamic rows are measured by the same lifecycle owner. */
|
|
440
|
+
type BaseViewInputs<Item> = Readonly<{
|
|
213
441
|
items: ReadonlyArray<Item>;
|
|
214
442
|
itemToKey: (item: Item, index: number) => string;
|
|
215
443
|
itemToView: (item: Item, index: number) => Html;
|
|
216
|
-
itemToRowHeightPx?: (item: Item, index: number) => number;
|
|
217
444
|
overscan?: number;
|
|
218
445
|
rowElement?: Exclude<TagName, 'textarea'>;
|
|
219
446
|
containerClassName?: string;
|
|
220
447
|
containerAttributes?: ReadonlyArray<ChildAttribute>;
|
|
448
|
+
contentAlignment?: ContentAlignment;
|
|
449
|
+
}>;
|
|
450
|
+
/** Mutually exclusive configuration for fixed, exact variable, or measured
|
|
451
|
+
* dynamic row heights. */
|
|
452
|
+
export type RowHeightInputs<Item> = Readonly<{
|
|
453
|
+
itemToRowHeightPx?: undefined;
|
|
454
|
+
dynamicRowHeights?: undefined;
|
|
455
|
+
itemToEstimatedRowHeightPx?: never;
|
|
456
|
+
}> | Readonly<{
|
|
457
|
+
itemToRowHeightPx?: never;
|
|
458
|
+
dynamicRowHeights: true;
|
|
459
|
+
itemToEstimatedRowHeightPx?: (item: Item, index: number) => number;
|
|
460
|
+
}> | Readonly<{
|
|
461
|
+
itemToRowHeightPx: (item: Item, index: number) => number;
|
|
462
|
+
dynamicRowHeights?: never;
|
|
463
|
+
itemToEstimatedRowHeightPx?: never;
|
|
221
464
|
}>;
|
|
465
|
+
export type ViewInputs<Item> = BaseViewInputs<Item> & RowHeightInputs<Item>;
|
|
222
466
|
/** Renders a virtualized list. Only items inside the viewport (plus an
|
|
223
467
|
* overscan buffer) are mounted; spacer elements above and below the
|
|
224
468
|
* slice keep the scrollbar's apparent total height correct.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/virtualList/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/virtualList/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EAON,MAAM,EAGP,MAAM,QAAQ,CAAA;AACf,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,IAAI,EACT,KAAK,OAAO,EAEb,MAAM,cAAc,CAAA;AAErB,OAAO,KAAK,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