vlist 1.9.1 → 2.0.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.
- package/README.github.md +104 -97
- package/README.md +46 -33
- package/dist/constants.d.ts +11 -6
- package/dist/constants.js +83 -0
- package/dist/core/create.d.ts +10 -0
- package/dist/core/create.js +740 -0
- package/dist/core/dom.d.ts +8 -0
- package/dist/core/dom.js +47 -0
- package/dist/core/hooks.d.ts +16 -0
- package/dist/core/hooks.js +67 -0
- package/dist/core/index.d.ts +17 -0
- package/dist/core/index.js +13 -0
- package/dist/core/pipeline.d.ts +51 -0
- package/dist/core/pipeline.js +307 -0
- package/dist/core/pool.d.ts +9 -0
- package/dist/core/pool.js +42 -0
- package/dist/core/scroll.d.ts +32 -0
- package/dist/core/scroll.js +137 -0
- package/dist/core/sizes.d.ts +8 -0
- package/dist/core/sizes.js +6 -0
- package/dist/core/state.d.ts +47 -0
- package/dist/core/state.js +56 -0
- package/dist/core/types.d.ts +187 -0
- package/dist/core/types.js +7 -0
- package/dist/{builder → core}/velocity.d.ts +1 -1
- package/dist/core/velocity.js +33 -0
- package/dist/events/emitter.js +60 -0
- package/dist/events/index.js +6 -0
- package/dist/index.d.ts +28 -19
- package/dist/index.js +28 -1
- package/dist/internals.d.ts +11 -7
- package/dist/internals.js +60 -1
- package/dist/plugins/a11y/index.d.ts +2 -0
- package/dist/plugins/a11y/index.js +1 -0
- package/dist/plugins/a11y/plugin.d.ts +13 -0
- package/dist/plugins/a11y/plugin.js +259 -0
- package/dist/{features → plugins}/async/index.d.ts +1 -1
- package/dist/plugins/async/index.js +12 -0
- package/dist/{features → plugins}/async/manager.d.ts +5 -1
- package/dist/plugins/async/manager.js +568 -0
- package/dist/plugins/async/placeholder.js +154 -0
- package/dist/plugins/async/plugin.d.ts +48 -0
- package/dist/plugins/async/plugin.js +311 -0
- package/dist/plugins/async/sparse.js +540 -0
- package/dist/plugins/autosize/index.d.ts +5 -0
- package/dist/plugins/autosize/index.js +4 -0
- package/dist/plugins/autosize/plugin.d.ts +19 -0
- package/dist/plugins/autosize/plugin.js +185 -0
- package/dist/plugins/grid/index.d.ts +7 -0
- package/dist/plugins/grid/index.js +5 -0
- package/dist/plugins/grid/layout.js +275 -0
- package/dist/plugins/grid/plugin.d.ts +23 -0
- package/dist/plugins/grid/plugin.js +347 -0
- package/dist/plugins/grid/renderer.js +525 -0
- package/dist/plugins/grid/types.js +11 -0
- package/dist/plugins/groups/async-bridge.js +246 -0
- package/dist/{features → plugins}/groups/index.d.ts +1 -1
- package/dist/plugins/groups/index.js +13 -0
- package/dist/plugins/groups/layout.js +294 -0
- package/dist/plugins/groups/plugin.d.ts +22 -0
- package/dist/plugins/groups/plugin.js +571 -0
- package/dist/plugins/groups/sticky.js +255 -0
- package/dist/plugins/groups/types.js +12 -0
- package/dist/plugins/masonry/index.d.ts +8 -0
- package/dist/plugins/masonry/index.js +6 -0
- package/dist/plugins/masonry/layout.js +261 -0
- package/dist/plugins/masonry/plugin.d.ts +32 -0
- package/dist/plugins/masonry/plugin.js +381 -0
- package/dist/plugins/masonry/renderer.js +354 -0
- package/dist/plugins/masonry/types.js +9 -0
- package/dist/plugins/page/index.d.ts +5 -0
- package/dist/plugins/page/index.js +5 -0
- package/dist/plugins/page/plugin.d.ts +21 -0
- package/dist/plugins/page/plugin.js +166 -0
- package/dist/plugins/scale/index.d.ts +5 -0
- package/dist/plugins/scale/index.js +4 -0
- package/dist/plugins/scale/plugin.d.ts +24 -0
- package/dist/plugins/scale/plugin.js +507 -0
- package/dist/plugins/scrollbar/controller.js +574 -0
- package/dist/plugins/scrollbar/index.d.ts +7 -0
- package/dist/plugins/scrollbar/index.js +6 -0
- package/dist/plugins/scrollbar/plugin.d.ts +20 -0
- package/dist/plugins/scrollbar/plugin.js +93 -0
- package/dist/plugins/scrollbar/scrollbar.js +556 -0
- package/dist/plugins/selection/index.d.ts +6 -0
- package/dist/plugins/selection/index.js +7 -0
- package/dist/plugins/selection/plugin.d.ts +16 -0
- package/dist/plugins/selection/plugin.js +601 -0
- package/dist/{features → plugins}/selection/state.d.ts +8 -0
- package/dist/plugins/selection/state.js +332 -0
- package/dist/plugins/snapshots/index.d.ts +5 -0
- package/dist/plugins/snapshots/index.js +5 -0
- package/dist/plugins/snapshots/plugin.d.ts +17 -0
- package/dist/plugins/snapshots/plugin.js +301 -0
- package/dist/plugins/sortable/index.d.ts +6 -0
- package/dist/plugins/sortable/index.js +6 -0
- package/dist/plugins/sortable/plugin.d.ts +34 -0
- package/dist/plugins/sortable/plugin.js +753 -0
- package/dist/plugins/table/header.js +501 -0
- package/dist/{features → plugins}/table/index.d.ts +1 -1
- package/dist/plugins/table/index.js +12 -0
- package/dist/plugins/table/layout.js +211 -0
- package/dist/plugins/table/plugin.d.ts +20 -0
- package/dist/plugins/table/plugin.js +391 -0
- package/dist/plugins/table/renderer.js +625 -0
- package/dist/plugins/table/types.js +12 -0
- package/dist/plugins/transition/index.d.ts +5 -0
- package/dist/plugins/transition/index.js +5 -0
- package/dist/plugins/transition/plugin.d.ts +22 -0
- package/dist/plugins/transition/plugin.js +405 -0
- package/dist/rendering/aria.js +23 -0
- package/dist/rendering/index.js +18 -0
- package/dist/rendering/measured.js +98 -0
- package/dist/rendering/renderer.js +586 -0
- package/dist/rendering/scale.js +267 -0
- package/dist/rendering/scroll.js +71 -0
- package/dist/rendering/sizes.js +193 -0
- package/dist/rendering/sort.js +65 -0
- package/dist/rendering/viewport.js +268 -0
- package/dist/size.json +1 -1
- package/dist/types.js +5 -0
- package/dist/utils/padding.d.ts +2 -4
- package/dist/utils/padding.js +49 -0
- package/dist/utils/stats.js +124 -0
- package/dist/vlist-grid.css +1 -1
- package/dist/vlist-masonry.css +1 -1
- package/dist/vlist-table.css +1 -1
- package/dist/vlist.css +1 -1
- package/package.json +9 -4
- package/dist/builder/a11y.d.ts +0 -16
- package/dist/builder/api.d.ts +0 -21
- package/dist/builder/context.d.ts +0 -36
- package/dist/builder/core.d.ts +0 -16
- package/dist/builder/data.d.ts +0 -71
- package/dist/builder/dom.d.ts +0 -15
- package/dist/builder/index.d.ts +0 -25
- package/dist/builder/materialize.d.ts +0 -166
- package/dist/builder/pool.d.ts +0 -10
- package/dist/builder/range.d.ts +0 -10
- package/dist/builder/scroll.d.ts +0 -24
- package/dist/builder/types.d.ts +0 -512
- package/dist/features/async/feature.d.ts +0 -72
- package/dist/features/autosize/feature.d.ts +0 -34
- package/dist/features/autosize/index.d.ts +0 -2
- package/dist/features/grid/feature.d.ts +0 -48
- package/dist/features/grid/index.d.ts +0 -9
- package/dist/features/groups/feature.d.ts +0 -75
- package/dist/features/masonry/feature.d.ts +0 -45
- package/dist/features/masonry/index.d.ts +0 -9
- package/dist/features/page/feature.d.ts +0 -109
- package/dist/features/page/index.d.ts +0 -9
- package/dist/features/scale/feature.d.ts +0 -42
- package/dist/features/scale/index.d.ts +0 -10
- package/dist/features/scrollbar/feature.d.ts +0 -81
- package/dist/features/scrollbar/index.d.ts +0 -8
- package/dist/features/selection/feature.d.ts +0 -91
- package/dist/features/selection/index.d.ts +0 -7
- package/dist/features/snapshots/feature.d.ts +0 -79
- package/dist/features/snapshots/index.d.ts +0 -9
- package/dist/features/sortable/feature.d.ts +0 -101
- package/dist/features/sortable/index.d.ts +0 -6
- package/dist/features/table/feature.d.ts +0 -67
- package/dist/features/transition/feature.d.ts +0 -30
- package/dist/features/transition/index.d.ts +0 -9
- /package/dist/{features → plugins}/async/placeholder.d.ts +0 -0
- /package/dist/{features → plugins}/async/sparse.d.ts +0 -0
- /package/dist/{features → plugins}/grid/layout.d.ts +0 -0
- /package/dist/{features → plugins}/grid/renderer.d.ts +0 -0
- /package/dist/{features → plugins}/grid/types.d.ts +0 -0
- /package/dist/{features → plugins}/groups/async-bridge.d.ts +0 -0
- /package/dist/{features → plugins}/groups/layout.d.ts +0 -0
- /package/dist/{features → plugins}/groups/sticky.d.ts +0 -0
- /package/dist/{features → plugins}/groups/types.d.ts +0 -0
- /package/dist/{features → plugins}/masonry/layout.d.ts +0 -0
- /package/dist/{features → plugins}/masonry/renderer.d.ts +0 -0
- /package/dist/{features → plugins}/masonry/types.d.ts +0 -0
- /package/dist/{features → plugins}/scrollbar/controller.d.ts +0 -0
- /package/dist/{features → plugins}/scrollbar/scrollbar.d.ts +0 -0
- /package/dist/{features → plugins}/table/header.d.ts +0 -0
- /package/dist/{features → plugins}/table/layout.d.ts +0 -0
- /package/dist/{features → plugins}/table/renderer.d.ts +0 -0
- /package/dist/{features → plugins}/table/types.d.ts +0 -0
package/dist/builder/types.d.ts
DELETED
|
@@ -1,512 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vlist/builder - Types
|
|
3
|
-
* Feature interface, builder config, builder context, and return types
|
|
4
|
-
*/
|
|
5
|
-
import type { VListItem, VListEvents, ItemConfig, ItemTemplate, Range, ViewportState, EventHandler, Unsubscribe, ScrollToOptions, ScrollSnapshot, VListAdapter, GridConfig, MasonryConfig, GroupsConfig, SelectionConfig, ScrollbarOptions } from "../types";
|
|
6
|
-
import type { DOMStructure, Renderer, SizeCache, CompressionContext } from "../rendering";
|
|
7
|
-
import type { CompressionState } from "../rendering/viewport";
|
|
8
|
-
import type { SimpleDataManager } from "./data";
|
|
9
|
-
import type { ScrollController } from "../features/scrollbar/controller";
|
|
10
|
-
import type { Emitter } from "../events";
|
|
11
|
-
/** Options for the reload() method. */
|
|
12
|
-
export interface ReloadOptions {
|
|
13
|
-
/**
|
|
14
|
-
* Skip the initial page-1 load after resetting state.
|
|
15
|
-
* When true, reload() clears data and DOM but does NOT call loadInitial().
|
|
16
|
-
* The caller is responsible for loading data (e.g. via restoreScroll).
|
|
17
|
-
*
|
|
18
|
-
* Automatically set to true when `snapshot` is provided with meaningful data.
|
|
19
|
-
*/
|
|
20
|
-
skipInitialLoad?: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Snapshot to restore after resetting state.
|
|
23
|
-
*
|
|
24
|
-
* When provided with meaningful data (total > 0 and index > 0),
|
|
25
|
-
* reload() automatically:
|
|
26
|
-
* 1. Skips loadInitial() (no wasted page-1 request)
|
|
27
|
-
* 2. Calls restoreScroll(snapshot) to load data at the target position
|
|
28
|
-
*
|
|
29
|
-
* This eliminates the need for the consumer to manually coordinate
|
|
30
|
-
* skipInitialLoad and restoreScroll after reload.
|
|
31
|
-
*
|
|
32
|
-
* ```ts
|
|
33
|
-
* // Before: manual coordination
|
|
34
|
-
* const hasRestorable = snapshot && snapshot.total > 0 && snapshot.index > 0;
|
|
35
|
-
* await list.reload(hasRestorable ? { skipInitialLoad: true } : undefined);
|
|
36
|
-
* if (hasRestorable) list.restoreScroll(snapshot);
|
|
37
|
-
*
|
|
38
|
-
* // After: vlist handles it
|
|
39
|
-
* await list.reload({ snapshot });
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
snapshot?: ScrollSnapshot;
|
|
43
|
-
}
|
|
44
|
-
/** Configuration accepted by the builder's vlist() factory */
|
|
45
|
-
export interface BuilderConfig<T extends VListItem = VListItem> {
|
|
46
|
-
/** Container element or selector */
|
|
47
|
-
container: HTMLElement | string;
|
|
48
|
-
/** Item configuration (height/width and template) */
|
|
49
|
-
item: ItemConfig<T>;
|
|
50
|
-
/** Static items array (optional if using adapter via feature) */
|
|
51
|
-
items?: T[];
|
|
52
|
-
/** Number of extra items to render outside viewport (default: 3) */
|
|
53
|
-
overscan?: number;
|
|
54
|
-
/** Custom CSS class prefix (default: 'vlist') */
|
|
55
|
-
classPrefix?: string;
|
|
56
|
-
/** Accessible label for the listbox */
|
|
57
|
-
ariaLabel?: string;
|
|
58
|
-
/** Accessibility behavior configuration. */
|
|
59
|
-
accessibility?: {
|
|
60
|
-
/**
|
|
61
|
-
* Announce visible range changes through the built-in live region.
|
|
62
|
-
*
|
|
63
|
-
* Defaults to false because frequent range updates can be noisy during
|
|
64
|
-
* keyboard navigation, touchpad scrolling, and repeated scroll pauses.
|
|
65
|
-
*/
|
|
66
|
-
announceVisibleRange?: boolean;
|
|
67
|
-
/**
|
|
68
|
-
* Debounce delay in ms for visible range announcements.
|
|
69
|
-
*
|
|
70
|
-
* Only used when `announceVisibleRange` is true. Default: 750.
|
|
71
|
-
*/
|
|
72
|
-
rangeAnnouncementDebounce?: number;
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* Layout orientation (default: 'vertical')
|
|
76
|
-
* - 'vertical' — Standard top-to-bottom scrolling
|
|
77
|
-
* - 'horizontal' — Left-to-right scrolling
|
|
78
|
-
*/
|
|
79
|
-
orientation?: "vertical" | "horizontal";
|
|
80
|
-
/**
|
|
81
|
-
* Padding around the list content (default: 0).
|
|
82
|
-
*
|
|
83
|
-
* Works exactly like CSS `padding` — adds inset space between the
|
|
84
|
-
* viewport edge and the items. Applied as CSS padding on the content
|
|
85
|
-
* element, so it works identically for list, grid, and masonry
|
|
86
|
-
* layouts with zero positioning overhead.
|
|
87
|
-
*
|
|
88
|
-
* Follows CSS shorthand convention:
|
|
89
|
-
* - `number` — Equal padding on all four sides
|
|
90
|
-
* - `[vertical, horizontal]` — Top/bottom and left/right
|
|
91
|
-
* - `[top, right, bottom, left]` — Per-side (CSS order)
|
|
92
|
-
*
|
|
93
|
-
* ```ts
|
|
94
|
-
* padding: 16 // 16px all sides
|
|
95
|
-
* padding: [16, 12] // 16px top/bottom, 12px left/right
|
|
96
|
-
* padding: [16, 12, 20, 8] // top, right, bottom, left
|
|
97
|
-
* ```
|
|
98
|
-
*/
|
|
99
|
-
padding?: number | [number, number] | [number, number, number, number];
|
|
100
|
-
/**
|
|
101
|
-
* Enable built-in keyboard navigation and item-level focus (default: true).
|
|
102
|
-
*
|
|
103
|
-
* When `true`, the list handles Arrow Up/Down, Home/End key presses
|
|
104
|
-
* to move focus between items (WAI-ARIA listbox pattern).
|
|
105
|
-
*
|
|
106
|
-
* Set to `false` to disable all built-in keyboard handling, useful
|
|
107
|
-
* when the host application provides its own keyboard navigation or
|
|
108
|
-
* when the list is non-interactive.
|
|
109
|
-
*
|
|
110
|
-
* Replaces the former `accessible` option.
|
|
111
|
-
*/
|
|
112
|
-
interactive?: boolean;
|
|
113
|
-
/**
|
|
114
|
-
* Show focus ring on mouse click (default: false).
|
|
115
|
-
* By default, clicking an item updates the focused index but does not
|
|
116
|
-
* show the focus ring — matching the web platform's :focus-visible
|
|
117
|
-
* convention. Set to true for file-manager or spreadsheet-style UIs
|
|
118
|
-
* where the focus indicator doubles as a "current item" marker.
|
|
119
|
-
*
|
|
120
|
-
* Applies to the baseline single-select keyboard navigation. When
|
|
121
|
-
* using withSelection(), pass focusOnClick in its own config instead.
|
|
122
|
-
*/
|
|
123
|
-
focusOnClick?: boolean;
|
|
124
|
-
/** @deprecated Use `interactive` instead */
|
|
125
|
-
accessible?: boolean;
|
|
126
|
-
/** Reverse mode for chat UIs */
|
|
127
|
-
reverse?: boolean;
|
|
128
|
-
/** Scroll behavior configuration (non-scrollbar options) */
|
|
129
|
-
scroll?: {
|
|
130
|
-
/** Enable mouse wheel scrolling (default: true) */
|
|
131
|
-
wheel?: boolean;
|
|
132
|
-
/** Wrap around when scrolling past boundaries (default: false) */
|
|
133
|
-
wrap?: boolean;
|
|
134
|
-
/**
|
|
135
|
-
* Native scrollbar gutter behavior (default: 'auto').
|
|
136
|
-
* - `'auto'` — default browser behavior
|
|
137
|
-
* - `'stable'` — reserves space via `scrollbar-gutter: stable`
|
|
138
|
-
*/
|
|
139
|
-
gutter?: "auto" | "stable";
|
|
140
|
-
/** Scroll idle detection timeout in ms (default: 150) */
|
|
141
|
-
idleTimeout?: number;
|
|
142
|
-
/** External scroll element for window scrolling */
|
|
143
|
-
element?: Window;
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Extended configuration accepted by framework adapters (React, Vue, Svelte, SolidJS).
|
|
148
|
-
*
|
|
149
|
-
* Adds convenience fields that adapters translate into `.use(withX())` calls
|
|
150
|
-
* automatically. For the core builder, use `BuilderConfig` directly.
|
|
151
|
-
*/
|
|
152
|
-
export interface VListConfig<T extends VListItem = VListItem> extends Omit<BuilderConfig<T>, "scroll"> {
|
|
153
|
-
/** Scroll behavior configuration — extends core scroll config with scrollbar shorthand. */
|
|
154
|
-
scroll?: BuilderConfig["scroll"] & {
|
|
155
|
-
/** Scrollbar mode (shorthand — same as top-level `scrollbar`). */
|
|
156
|
-
scrollbar?: "native" | "none" | ScrollbarOptions;
|
|
157
|
-
};
|
|
158
|
-
/** Layout mode (default: list). Set to `'grid'` or `'masonry'` with matching config. */
|
|
159
|
-
layout?: "list" | "grid" | "masonry";
|
|
160
|
-
/** Grid configuration — used when `layout` is `'grid'`. */
|
|
161
|
-
grid?: GridConfig;
|
|
162
|
-
/** Masonry configuration — used when `layout` is `'masonry'`. */
|
|
163
|
-
masonry?: MasonryConfig;
|
|
164
|
-
/** Async data adapter — enables `withAsync()`. Omit `items` when using an adapter. */
|
|
165
|
-
adapter?: VListAdapter<T>;
|
|
166
|
-
/** Loading behavior for async adapter. */
|
|
167
|
-
loading?: {
|
|
168
|
-
/** Velocity threshold above which data loading is skipped (px/ms). Default: 5 */
|
|
169
|
-
cancelThreshold?: number;
|
|
170
|
-
/** Velocity threshold for preloading (px/ms). Default: 2 */
|
|
171
|
-
preloadThreshold?: number;
|
|
172
|
-
/** Number of items to preload in scroll direction. Default: 50 */
|
|
173
|
-
preloadAhead?: number;
|
|
174
|
-
};
|
|
175
|
-
/** Section grouping configuration — enables `withGroups()`. */
|
|
176
|
-
groups?: GroupsConfig;
|
|
177
|
-
/** Selection configuration — enables `withSelection()`. */
|
|
178
|
-
selection?: SelectionConfig;
|
|
179
|
-
/** Top-level scrollbar shorthand (alternative to `scroll.scrollbar`). */
|
|
180
|
-
scrollbar?: "native" | "none" | ScrollbarOptions;
|
|
181
|
-
}
|
|
182
|
-
/** Resolved configuration stored inside BuilderContext */
|
|
183
|
-
export interface ResolvedBuilderConfig {
|
|
184
|
-
readonly overscan: number;
|
|
185
|
-
readonly classPrefix: string;
|
|
186
|
-
readonly reverse: boolean;
|
|
187
|
-
readonly wrap: boolean;
|
|
188
|
-
readonly horizontal: boolean;
|
|
189
|
-
readonly ariaIdPrefix: string;
|
|
190
|
-
readonly interactive: boolean;
|
|
191
|
-
}
|
|
192
|
-
/** Cached compression state */
|
|
193
|
-
export interface CachedCompression {
|
|
194
|
-
state: CompressionState;
|
|
195
|
-
totalItems: number;
|
|
196
|
-
}
|
|
197
|
-
/** Builder state */
|
|
198
|
-
export interface BuilderState {
|
|
199
|
-
viewportState: ViewportState;
|
|
200
|
-
lastRenderRange: Range;
|
|
201
|
-
isInitialized: boolean;
|
|
202
|
-
isDestroyed: boolean;
|
|
203
|
-
cachedCompression: CachedCompression | null;
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* BuilderContext — the internal interface that features receive during setup.
|
|
207
|
-
*
|
|
208
|
-
* Provides access to all core components plus registration points for
|
|
209
|
-
* handlers, methods, and cleanup callbacks.
|
|
210
|
-
*/
|
|
211
|
-
export interface BuilderContext<T extends VListItem = VListItem> {
|
|
212
|
-
readonly dom: DOMStructure;
|
|
213
|
-
readonly sizeCache: SizeCache;
|
|
214
|
-
readonly emitter: Emitter<VListEvents<T>>;
|
|
215
|
-
readonly config: ResolvedBuilderConfig;
|
|
216
|
-
/** The raw user-provided builder config (for features that need original values) */
|
|
217
|
-
readonly rawConfig: BuilderConfig<T>;
|
|
218
|
-
/**
|
|
219
|
-
* Adjust a raw scroll position (from calculateScrollToIndex or similar)
|
|
220
|
-
* to account for CSS padding on the content element.
|
|
221
|
-
*
|
|
222
|
-
* CSS padding expands the scrollable area beyond `getTotalSize()`, so
|
|
223
|
-
* the max-scroll clamp must include the padding. The position itself
|
|
224
|
-
* is unchanged — CSS padding already offsets items visually.
|
|
225
|
-
*
|
|
226
|
-
* No-op when padding is 0 — returns the input unchanged.
|
|
227
|
-
*/
|
|
228
|
-
adjustScrollPosition(position: number): number;
|
|
229
|
-
renderer: Renderer<T>;
|
|
230
|
-
dataManager: SimpleDataManager<T>;
|
|
231
|
-
scrollController: ScrollController;
|
|
232
|
-
state: BuilderState;
|
|
233
|
-
/**
|
|
234
|
-
* Features register lightweight callbacks that run after each
|
|
235
|
-
* scroll-triggered render. These are NOT on the hot path —
|
|
236
|
-
* they run after DOM updates are complete.
|
|
237
|
-
*/
|
|
238
|
-
afterScroll: Array<(scrollPosition: number, direction: string) => void>;
|
|
239
|
-
/**
|
|
240
|
-
* Features register callbacks that run after a batch of new items
|
|
241
|
-
* is rendered. Receives the newly rendered items with their indices
|
|
242
|
-
* and DOM elements. Used by withAutoSize for ResizeObserver observation.
|
|
243
|
-
*/
|
|
244
|
-
afterRenderBatch: Array<(items: ReadonlyArray<{
|
|
245
|
-
index: number;
|
|
246
|
-
element: HTMLElement;
|
|
247
|
-
}>) => void>;
|
|
248
|
-
/**
|
|
249
|
-
* Features register callbacks that run when scrolling becomes idle.
|
|
250
|
-
* Use this for deferred work that should not run on the hot scroll path
|
|
251
|
-
* (e.g. reordering DOM children for accessibility).
|
|
252
|
-
*/
|
|
253
|
-
idleHandlers: Array<() => void>;
|
|
254
|
-
/**
|
|
255
|
-
* Features register handlers for user interaction events.
|
|
256
|
-
* These are attached as DOM event listeners during .build().
|
|
257
|
-
*/
|
|
258
|
-
clickHandlers: Array<(event: MouseEvent) => void>;
|
|
259
|
-
contextMenuHandlers: Array<(event: MouseEvent) => void>;
|
|
260
|
-
keydownHandlers: Array<(event: KeyboardEvent) => void>;
|
|
261
|
-
resizeHandlers: Array<(width: number, height: number) => void>;
|
|
262
|
-
contentSizeHandlers: Array<() => void>;
|
|
263
|
-
destroyHandlers: Array<() => void>;
|
|
264
|
-
/** Features register public methods by name. Exposed on the returned API. */
|
|
265
|
-
methods: Map<string, Function>;
|
|
266
|
-
replaceTemplate(template: ItemTemplate<T>): void;
|
|
267
|
-
replaceRenderer(renderer: Renderer<T>): void;
|
|
268
|
-
replaceDataManager(dataManager: SimpleDataManager<T>): void;
|
|
269
|
-
replaceScrollController(scrollController: ScrollController): void;
|
|
270
|
-
getItemsForRange(range: Range): T[];
|
|
271
|
-
getAllLoadedItems(): T[];
|
|
272
|
-
getVirtualTotal(): number;
|
|
273
|
-
getCachedCompression(): CompressionState;
|
|
274
|
-
getCompressionContext(): CompressionContext;
|
|
275
|
-
renderIfNeeded(): void;
|
|
276
|
-
forceRender(): void;
|
|
277
|
-
/**
|
|
278
|
-
* Remove all rendered DOM elements and return them to the pool.
|
|
279
|
-
* Used by reload to force a full re-render from scratch, bypassing
|
|
280
|
-
* the ID-based optimization that skips template updates for same-ID items.
|
|
281
|
-
*/
|
|
282
|
-
invalidateRendered(): void;
|
|
283
|
-
/**
|
|
284
|
-
* Get current render functions (for wrapping by selection/other features).
|
|
285
|
-
* Call this BEFORE setRenderFns to capture the current functions.
|
|
286
|
-
*/
|
|
287
|
-
getRenderFns(): {
|
|
288
|
-
renderIfNeeded: () => void;
|
|
289
|
-
forceRender: () => void;
|
|
290
|
-
};
|
|
291
|
-
/**
|
|
292
|
-
* Get current container width (for grid feature).
|
|
293
|
-
* This returns the width detected by ResizeObserver, which is more reliable
|
|
294
|
-
* than viewport.clientWidth in test environments.
|
|
295
|
-
*/
|
|
296
|
-
getContainerWidth(): number;
|
|
297
|
-
/**
|
|
298
|
-
* Replace the virtual-total function.
|
|
299
|
-
* Used by grid/groups features that change what "total" means
|
|
300
|
-
* (e.g. row count instead of item count).
|
|
301
|
-
*/
|
|
302
|
-
setVirtualTotalFn(fn: () => number): void;
|
|
303
|
-
/**
|
|
304
|
-
* Used by groups feature to inject grouped size function and by grid to add gap.
|
|
305
|
-
*/
|
|
306
|
-
rebuildSizeCache(total?: number): void;
|
|
307
|
-
/**
|
|
308
|
-
* Set a new effective size config function/value.
|
|
309
|
-
* Features that change sizes (groups, grid) call this before rebuildSizeCache.
|
|
310
|
-
*/
|
|
311
|
-
setSizeConfig(config: number | ((index: number) => number)): void;
|
|
312
|
-
/**
|
|
313
|
-
* Update content size on the main axis (height for vertical, width for horizontal).
|
|
314
|
-
*/
|
|
315
|
-
updateContentSize(totalSize: number): void;
|
|
316
|
-
/**
|
|
317
|
-
* Update compression mode when total items changes.
|
|
318
|
-
* Called by the core after data changes and by features that alter totals.
|
|
319
|
-
*/
|
|
320
|
-
updateCompressionMode(): void;
|
|
321
|
-
/**
|
|
322
|
-
* Replace the visible-range calculation function.
|
|
323
|
-
* Used by withCompression to inject compressed range calculation.
|
|
324
|
-
*/
|
|
325
|
-
setVisibleRangeFn(fn: (scrollTop: number, containerHeight: number, sc: SizeCache, totalItems: number, out: Range) => void): void;
|
|
326
|
-
/**
|
|
327
|
-
* Calculate the visible range using the current visible-range function.
|
|
328
|
-
* This uses the compression-aware version if withScale has replaced it.
|
|
329
|
-
* Used by withTable and withGrid to correctly compute ranges in compressed mode.
|
|
330
|
-
*/
|
|
331
|
-
getVisibleRange(scrollTop: number, containerHeight: number, totalItems: number, out: Range): void;
|
|
332
|
-
/**
|
|
333
|
-
* Replace the scroll-to-index position calculator.
|
|
334
|
-
* Used by withCompression to inject compressed position calculation.
|
|
335
|
-
*/
|
|
336
|
-
setScrollToPosFn(fn: (index: number, sc: SizeCache, containerHeight: number, totalItems: number, align: "start" | "center" | "end") => number): void;
|
|
337
|
-
/**
|
|
338
|
-
* Get the current scroll-to-index position calculator.
|
|
339
|
-
* Returns the compression-aware version if withScale has replaced it.
|
|
340
|
-
*/
|
|
341
|
-
getScrollToPos(index: number, containerHeight: number, totalItems: number, align: "start" | "center" | "end"): number;
|
|
342
|
-
/**
|
|
343
|
-
* Replace the item positioning function.
|
|
344
|
-
* Used by withCompression to inject compressed item positioning.
|
|
345
|
-
*/
|
|
346
|
-
setPositionElementFn(fn: (element: HTMLElement, index: number) => void): void;
|
|
347
|
-
/**
|
|
348
|
-
* Replace the item-class updater used by the renderer proxy.
|
|
349
|
-
* Used by withTable to inject its own class-update logic (the core
|
|
350
|
-
* rendered Map is empty in table mode — the table renderer owns the DOM).
|
|
351
|
-
*/
|
|
352
|
-
setUpdateItemClassesFn(fn: (index: number, isSelected: boolean, isFocused: boolean) => void): void;
|
|
353
|
-
/**
|
|
354
|
-
* Replace the render functions.
|
|
355
|
-
* Used by grid/groups features that need to completely replace the render logic
|
|
356
|
-
* (e.g., to convert row ranges to item ranges for grid rendering).
|
|
357
|
-
*/
|
|
358
|
-
setRenderFns(renderIfNeeded: () => void, forceRender: () => void): void;
|
|
359
|
-
/**
|
|
360
|
-
* Replace the scroll get/set functions.
|
|
361
|
-
* Used by withCompression to manage a virtual scroll position that bypasses
|
|
362
|
-
* native DOM scrollTop (which can't represent compressed scroll space).
|
|
363
|
-
*/
|
|
364
|
-
setScrollFns(getTop: () => number, setTop: (pos: number) => void): void;
|
|
365
|
-
/**
|
|
366
|
-
* Trigger the full scroll pipeline (render, events, afterScroll, velocity
|
|
367
|
-
* tracking, idle scheduling) using the current scroll position from $.sgt().
|
|
368
|
-
*
|
|
369
|
-
* Use this from animation loops (e.g. scale feature's smooth scroll) instead
|
|
370
|
-
* of scrollController.scrollTo() — it avoids the double-render caused by the
|
|
371
|
-
* scrollTo proxy calling $.rfn() after $.sst already triggered onScrollFrame.
|
|
372
|
-
*/
|
|
373
|
-
triggerScrollFrame(): void;
|
|
374
|
-
/**
|
|
375
|
-
* Set the scroll target element (default: viewport).
|
|
376
|
-
* Used by window mode feature to use window instead of viewport for scroll events.
|
|
377
|
-
*/
|
|
378
|
-
setScrollTarget(target: HTMLElement | Window): void;
|
|
379
|
-
/**
|
|
380
|
-
* Get the current scroll target element.
|
|
381
|
-
* Returns the element/window that scroll events are bound to.
|
|
382
|
-
*/
|
|
383
|
-
getScrollTarget(): HTMLElement | Window;
|
|
384
|
-
/**
|
|
385
|
-
* Override container dimension getters.
|
|
386
|
-
* Used by window mode feature to use window.innerWidth/innerHeight instead
|
|
387
|
-
* of viewport.clientWidth/clientHeight.
|
|
388
|
-
*/
|
|
389
|
-
setContainerDimensions(getter: {
|
|
390
|
-
width: () => number;
|
|
391
|
-
height: () => number;
|
|
392
|
-
}): void;
|
|
393
|
-
/**
|
|
394
|
-
* Disable the ResizeObserver on the viewport element.
|
|
395
|
-
* Used by window mode feature where the viewport doesn't need observation
|
|
396
|
-
* (window resize is used instead).
|
|
397
|
-
*/
|
|
398
|
-
disableViewportResize(): void;
|
|
399
|
-
/**
|
|
400
|
-
* Disable the wheel handler attached to the viewport.
|
|
401
|
-
* Used by window mode feature where wheel events should trigger native
|
|
402
|
-
* window scrolling instead of manual scroll position updates.
|
|
403
|
-
*/
|
|
404
|
-
disableWheelHandler(): void;
|
|
405
|
-
/**
|
|
406
|
-
* Get the current stripe-index function.
|
|
407
|
-
* Maps a layout index to the index used for even/odd striping.
|
|
408
|
-
* Default: identity (returns the index as-is).
|
|
409
|
-
* When groups override this, group headers return -1 (skip striping)
|
|
410
|
-
* and data items return a contiguous data-only index.
|
|
411
|
-
*/
|
|
412
|
-
getStripeIndexFn(): (index: number) => number;
|
|
413
|
-
/**
|
|
414
|
-
* Replace the stripe-index function.
|
|
415
|
-
* Used by the groups feature when `striped: "data"` to exclude
|
|
416
|
-
* group headers from the even/odd alternation.
|
|
417
|
-
*/
|
|
418
|
-
setStripeIndexFn(fn: (index: number) => number): void;
|
|
419
|
-
/**
|
|
420
|
-
* Returns the current item-to-scroll-index mapping function.
|
|
421
|
-
* Identity for flat lists; floor(index/columns) for grids where the
|
|
422
|
-
* size cache is indexed by row, not by flat item index.
|
|
423
|
-
*/
|
|
424
|
-
getItemToScrollIndexFn(): (index: number) => number;
|
|
425
|
-
/**
|
|
426
|
-
* Replace the item-to-scroll-index mapping function.
|
|
427
|
-
* Called by withGrid to convert flat item indices to row indices
|
|
428
|
-
* so that scrollToFocus uses the correct size-cache entry.
|
|
429
|
-
*/
|
|
430
|
-
setItemToScrollIndexFn(fn: (index: number) => number): void;
|
|
431
|
-
}
|
|
432
|
-
/**
|
|
433
|
-
* VListFeature — the interface for builder features.
|
|
434
|
-
*
|
|
435
|
-
* Each feature:
|
|
436
|
-
* - Has a unique name (used for deduplication and error messages)
|
|
437
|
-
* - Optionally declares a priority (lower runs first, default: 50)
|
|
438
|
-
* - Implements setup() which receives BuilderContext and wires in handlers/methods
|
|
439
|
-
* - Optionally implements destroy() for cleanup
|
|
440
|
-
* - Optionally declares methods it adds and features it conflicts with
|
|
441
|
-
*/
|
|
442
|
-
export interface VListFeature<T extends VListItem = VListItem> {
|
|
443
|
-
/** Unique feature name (used for deduplication and error messages) */
|
|
444
|
-
readonly name: string;
|
|
445
|
-
/** Execution priority — lower runs first (default: 50) */
|
|
446
|
-
readonly priority?: number;
|
|
447
|
-
/** Setup function — receives BuilderContext, wires handlers and methods */
|
|
448
|
-
setup(ctx: BuilderContext<T>): void;
|
|
449
|
-
/** Cleanup function — called on destroy */
|
|
450
|
-
destroy?(): void;
|
|
451
|
-
/** Methods this feature adds to the public API */
|
|
452
|
-
readonly methods?: readonly string[];
|
|
453
|
-
/** Features this feature conflicts with (cannot be combined) */
|
|
454
|
-
readonly conflicts?: readonly string[];
|
|
455
|
-
}
|
|
456
|
-
/** Factory function that returns a feature */
|
|
457
|
-
export type FeatureFactory<T extends VListItem = VListItem> = VListFeature<T>;
|
|
458
|
-
/** Chainable builder interface */
|
|
459
|
-
export interface VListBuilder<T extends VListItem = VListItem> {
|
|
460
|
-
/** Register a feature. Chainable. */
|
|
461
|
-
use(feature: VListFeature<T>): VListBuilder<T>;
|
|
462
|
-
/** Materialize the virtual list. Creates DOM, initializes features, returns API. */
|
|
463
|
-
build(): VList<T>;
|
|
464
|
-
}
|
|
465
|
-
/**
|
|
466
|
-
* VList instance API — returned by `vlist(config).build()`.
|
|
467
|
-
*
|
|
468
|
-
* Always-available methods (data, scroll, events, lifecycle) are required.
|
|
469
|
-
* Feature methods (selection, snapshots, grid, etc.) are optional —
|
|
470
|
-
* they exist on the instance only when the corresponding feature is
|
|
471
|
-
* registered via `.use()`.
|
|
472
|
-
*/
|
|
473
|
-
export interface VList<T extends VListItem = VListItem> {
|
|
474
|
-
/** The root DOM element */
|
|
475
|
-
readonly element: HTMLElement;
|
|
476
|
-
/** Current items */
|
|
477
|
-
readonly items: readonly T[];
|
|
478
|
-
/** Total item count */
|
|
479
|
-
readonly total: number;
|
|
480
|
-
setItems: (items: T[]) => void;
|
|
481
|
-
appendItems: (items: T[]) => void;
|
|
482
|
-
prependItems: (items: T[]) => void;
|
|
483
|
-
updateItem: (id: string | number, updates: Partial<T>) => void;
|
|
484
|
-
insertItem: (item: T, index?: number) => void;
|
|
485
|
-
/** @deprecated Use `insertItem` instead. */
|
|
486
|
-
addItem: (item: T, index?: number) => void;
|
|
487
|
-
removeItem: (id: string | number) => void;
|
|
488
|
-
removeItems: (ids: ReadonlyArray<string | number>) => number;
|
|
489
|
-
getItemAt: (index: number) => T | undefined;
|
|
490
|
-
getIndexById: (id: string | number) => number;
|
|
491
|
-
reload: (options?: ReloadOptions) => Promise<void>;
|
|
492
|
-
scrollToIndex: (index: number, alignOrOptions?: "start" | "center" | "end" | ScrollToOptions) => void;
|
|
493
|
-
cancelScroll: () => void;
|
|
494
|
-
getScrollPosition: () => number;
|
|
495
|
-
on: <K extends keyof VListEvents<T>>(event: K, handler: EventHandler<VListEvents<T>[K]>) => Unsubscribe;
|
|
496
|
-
off: <K extends keyof VListEvents<T>>(event: K, handler: EventHandler<VListEvents<T>[K]>) => void;
|
|
497
|
-
destroy: () => void;
|
|
498
|
-
select?: (...ids: Array<string | number>) => void;
|
|
499
|
-
deselect?: (...ids: Array<string | number>) => void;
|
|
500
|
-
toggleSelect?: (id: string | number) => void;
|
|
501
|
-
selectAll?: () => void;
|
|
502
|
-
clearSelection?: () => void;
|
|
503
|
-
getSelected?: () => Array<string | number>;
|
|
504
|
-
getSelectedItems?: () => T[];
|
|
505
|
-
selectNext?: () => void;
|
|
506
|
-
selectPrevious?: () => void;
|
|
507
|
-
getScrollSnapshot?: () => ScrollSnapshot;
|
|
508
|
-
restoreScroll?: (snapshot: ScrollSnapshot) => void;
|
|
509
|
-
isSorting?: () => boolean;
|
|
510
|
-
[key: string]: unknown;
|
|
511
|
-
}
|
|
512
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vlist/data - Builder Feature
|
|
3
|
-
* Wraps async data loading with sparse storage into a VListFeature for the composable builder.
|
|
4
|
-
*
|
|
5
|
-
* Priority: 20 (runs before scrollbar and selection, after grid/groups)
|
|
6
|
-
*
|
|
7
|
-
* What it wires:
|
|
8
|
-
* - Replaces data manager — swaps the simple in-memory store with sparse storage
|
|
9
|
-
* - Scroll boundary detection — triggers loadMore() near the bottom (or top in reverse)
|
|
10
|
-
* - Velocity-aware loading — skips data fetching during fast scrolling, loads on idle
|
|
11
|
-
* - Placeholder generation — creates skeleton items for unloaded ranges
|
|
12
|
-
* - Request deduplication — prevents duplicate fetches for the same range
|
|
13
|
-
* - Idle handler — loads any pending ranges when scrolling stops
|
|
14
|
-
* - Snapshot-aware reload — reload({ snapshot }) skips page-1 and auto-restores position
|
|
15
|
-
*
|
|
16
|
-
* Added methods: reload, loadVisibleRange
|
|
17
|
-
* Added events: load:start, load:end, error
|
|
18
|
-
*/
|
|
19
|
-
import type { VListItem, VListAdapter } from "../../types";
|
|
20
|
-
import type { VListFeature } from "../../builder/types";
|
|
21
|
-
/** Data feature configuration */
|
|
22
|
-
export interface DataFeatureConfig<T extends VListItem = VListItem> {
|
|
23
|
-
/** Async data source (required) */
|
|
24
|
-
adapter: VListAdapter<T>;
|
|
25
|
-
/** Total number of items (optional - if not provided, adapter must return it) */
|
|
26
|
-
total?: number;
|
|
27
|
-
/** Whether to automatically load initial data. Default: true */
|
|
28
|
-
autoLoad?: boolean;
|
|
29
|
-
/** Storage configuration */
|
|
30
|
-
storage?: {
|
|
31
|
-
/** Number of items per chunk. Default: 100 */
|
|
32
|
-
chunkSize?: number;
|
|
33
|
-
/** Maximum cached items before eviction. Default: 10000 */
|
|
34
|
-
maxCachedItems?: number;
|
|
35
|
-
};
|
|
36
|
-
/** Loading behavior configuration */
|
|
37
|
-
loading?: {
|
|
38
|
-
/** Velocity threshold above which data loading is skipped (px/ms). Default: 5 */
|
|
39
|
-
cancelThreshold?: number;
|
|
40
|
-
/** Velocity threshold for preloading (px/ms). Default: 2 */
|
|
41
|
-
preloadThreshold?: number;
|
|
42
|
-
/** Number of items to preload in scroll direction. Default: 50 */
|
|
43
|
-
preloadAhead?: number;
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Create a data feature for the builder.
|
|
48
|
-
*
|
|
49
|
-
* Adds async data loading with sparse storage, placeholders, and infinite scroll.
|
|
50
|
-
*
|
|
51
|
-
* ```ts
|
|
52
|
-
* import { vlist } from 'vlist/builder'
|
|
53
|
-
* import { withData } from 'vlist/data'
|
|
54
|
-
*
|
|
55
|
-
* const list = vlist({
|
|
56
|
-
* container: '#app',
|
|
57
|
-
* item: { height: 48, template: renderItem },
|
|
58
|
-
* })
|
|
59
|
-
* .use(withData({
|
|
60
|
-
* adapter: {
|
|
61
|
-
* read: async ({ offset, limit }) => {
|
|
62
|
-
* const res = await fetch(`/api/items?offset=${offset}&limit=${limit}`)
|
|
63
|
-
* const data = await res.json()
|
|
64
|
-
* return { items: data.items, total: data.total, hasMore: data.hasMore }
|
|
65
|
-
* }
|
|
66
|
-
* }
|
|
67
|
-
* }))
|
|
68
|
-
* .build()
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
export declare const withAsync: <T extends VListItem = VListItem>(config: DataFeatureConfig<T>) => VListFeature<T>;
|
|
72
|
-
//# sourceMappingURL=feature.d.ts.map
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vlist/autosize — Auto-Size Measurement Feature
|
|
3
|
-
*
|
|
4
|
-
* Enables dynamic item measurement via ResizeObserver for items with
|
|
5
|
-
* unknown sizes (Mode B). Items are rendered with no explicit main-axis
|
|
6
|
-
* size, measured once by a ResizeObserver, and then pinned to their
|
|
7
|
-
* measured size for all subsequent renders.
|
|
8
|
-
*
|
|
9
|
-
* Priority: 5 (runs before grid/masonry at 10 so the measured cache
|
|
10
|
-
* is in place before layout features wrap it)
|
|
11
|
-
*
|
|
12
|
-
* Requires: `item.estimatedHeight` or `item.estimatedWidth` in config
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* import { vlist, withAutoSize } from 'vlist';
|
|
17
|
-
*
|
|
18
|
-
* vlist({
|
|
19
|
-
* container: '#app',
|
|
20
|
-
* item: { estimatedHeight: 60, template: (item) => `<div>${item.name}</div>` },
|
|
21
|
-
* items: data,
|
|
22
|
-
* })
|
|
23
|
-
* .use(withAutoSize())
|
|
24
|
-
* .build();
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
import type { VListItem } from "../../types";
|
|
28
|
-
import type { VListFeature } from "../../builder/types";
|
|
29
|
-
/**
|
|
30
|
-
* Create an auto-size measurement feature for items with unknown sizes.
|
|
31
|
-
* Reads `estimatedHeight`/`estimatedWidth` from the builder config.
|
|
32
|
-
*/
|
|
33
|
-
export declare const withAutoSize: <T extends VListItem = VListItem>() => VListFeature<T>;
|
|
34
|
-
//# sourceMappingURL=feature.d.ts.map
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vlist/grid - Builder Feature
|
|
3
|
-
* Switches from list layout to a 2D grid with configurable columns and gap.
|
|
4
|
-
*
|
|
5
|
-
* Priority: 10 (runs first — replaces the renderer before anything else renders)
|
|
6
|
-
*
|
|
7
|
-
* What it wires:
|
|
8
|
-
* - Replaces renderer — swaps the list renderer with a grid renderer
|
|
9
|
-
* - Redefines virtual total — the virtualizer sees rows, not items
|
|
10
|
-
* - Column width calculation — recalculated on resize
|
|
11
|
-
* - Item positioning — each item gets translateX (column) and translateY (row)
|
|
12
|
-
* - CSS class — adds .vlist--grid to the root element
|
|
13
|
-
*
|
|
14
|
-
* Restrictions:
|
|
15
|
-
* - Cannot be combined with orientation: 'horizontal'
|
|
16
|
-
* - Cannot be combined with reverse: true
|
|
17
|
-
*
|
|
18
|
-
* Can be combined with withGroups for grouped 2D layouts.
|
|
19
|
-
*/
|
|
20
|
-
import type { VListItem } from "../../types";
|
|
21
|
-
import type { VListFeature } from "../../builder/types";
|
|
22
|
-
/** Grid feature configuration */
|
|
23
|
-
export interface GridFeatureConfig {
|
|
24
|
-
/** Number of columns (required, >= 1) */
|
|
25
|
-
columns: number;
|
|
26
|
-
/** Gap between items in pixels (default: 0) */
|
|
27
|
-
gap?: number;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Create a grid feature for the builder.
|
|
31
|
-
*
|
|
32
|
-
* Switches from list layout to a 2D grid with configurable columns and gap.
|
|
33
|
-
*
|
|
34
|
-
* ```ts
|
|
35
|
-
* import { vlist } from 'vlist/builder'
|
|
36
|
-
* import { withGrid } from 'vlist/grid'
|
|
37
|
-
*
|
|
38
|
-
* const gallery = vlist({
|
|
39
|
-
* container: '#gallery',
|
|
40
|
-
* item: { height: 200, template: renderPhoto },
|
|
41
|
-
* items: photos,
|
|
42
|
-
* })
|
|
43
|
-
* .use(withGrid({ columns: 4, gap: 8 }))
|
|
44
|
-
* .build()
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
export declare const withGrid: <T extends VListItem = VListItem>(config: GridFeatureConfig) => VListFeature<T>;
|
|
48
|
-
//# sourceMappingURL=feature.d.ts.map
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vlist - Grid Domain
|
|
3
|
-
* 2D grid/card layout with virtualized rows
|
|
4
|
-
*/
|
|
5
|
-
export { withGrid, type GridFeatureConfig } from "./feature";
|
|
6
|
-
export { createGridLayout } from "./layout";
|
|
7
|
-
export { createGridRenderer, type GridRenderer } from "./renderer";
|
|
8
|
-
export type { GridConfig, GridLayout, GridPosition, ItemRange } from "./types";
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|