vlist 1.7.4 → 1.7.6

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 CHANGED
@@ -1,8 +1,8 @@
1
1
  # vlist
2
2
 
3
- The virtual list library for every framework. Accessible by default, batteries-included, with composable features — in 10.5 KB.
3
+ The virtual list library for every framework. Accessible by default, batteries-included, with composable features — in 11.2 KB.
4
4
 
5
- **v1.7.4** — [Changelog](./CHANGELOG.md)
5
+ **v1.7.6** — [Changelog](./CHANGELOG.md)
6
6
 
7
7
  [![npm version](https://img.shields.io/npm/v/vlist.svg)](https://www.npmjs.com/package/vlist)
8
8
  [![CI](https://github.com/floor/vlist/actions/workflows/ci.yml/badge.svg)](https://github.com/floor/vlist/actions/workflows/ci.yml)
@@ -11,7 +11,7 @@ The virtual list library for every framework. Accessible by default, batteries-i
11
11
  - **New: `withSortable()`** — drag-and-drop reordering with auto-scroll, keyboard support, and ARIA announcements
12
12
  - **Accessible** — WAI-ARIA, 2D keyboard navigation, focus recovery, screen-reader DOM ordering, ARIA live region
13
13
  - **Zero dependencies** — framework-agnostic core with tiny adapters for Vue, Svelte, Solid, React
14
- - **10.6 KB gzipped** — composable features with perfect tree-shaking
14
+ - **11.2 KB gzipped** — composable features with perfect tree-shaking
15
15
  - **Constant memory** — ~0.1 MB overhead at any scale, from 10K to 1M+ items
16
16
  - **Grid, masonry, table, groups, async, selection, sortable, scale** — all opt-in
17
17
  - **Vertical & horizontal** — single axis-neutral code path, every feature works in both orientations
@@ -94,19 +94,19 @@ const list = vlist({
94
94
 
95
95
  | Feature | Size | Description |
96
96
  |---------|------|-------------|
97
- | **Base** | 10.6 KB | Virtualization, ARIA, keyboard nav, gap, padding |
98
- | `withAsync()` | +4.6 KB | Lazy loading with velocity-aware fetching |
99
- | `withSelection()` | +3.0 KB | Single/multiple selection with 2D keyboard nav |
97
+ | **Base** | 11.2 KB | Virtualization, ARIA, keyboard nav, gap, padding |
98
+ | `withAsync()` | +4.5 KB | Lazy loading with velocity-aware fetching |
99
+ | `withSelection()` | +3.2 KB | Single/multiple selection with 2D keyboard nav |
100
100
  | `withScale()` | +3.7 KB | 1M+ items via scroll compression |
101
- | `withGroups()` | +2.7 KB | Sticky/inline headers |
101
+ | `withGroups()` | +4.6 KB | Sticky/inline headers with async group discovery |
102
102
  | `withAutoSize()` | +0.9 KB | Auto-measure items via ResizeObserver |
103
- | `withScrollbar()` | +1.7 KB | Custom scrollbar UI |
104
- | `withGrid()` | +3.9 KB | 2D grid layout |
105
- | `withMasonry()` | +3.3 KB | Pinterest-style masonry with lane-aware keyboard nav |
103
+ | `withScrollbar()` | +1.8 KB | Custom scrollbar UI |
104
+ | `withGrid()` | +4.0 KB | 2D grid layout |
105
+ | `withMasonry()` | +3.5 KB | Pinterest-style masonry with lane-aware keyboard nav |
106
106
  | `withTable()` | +5.5 KB | Data table with columns, resize, sort |
107
- | `withPage()` | +0.8 KB | Window-level scrolling |
107
+ | `withPage()` | +0.7 KB | Window-level scrolling |
108
108
  | `withSortable()` | +3.0 KB | Drag-and-drop reordering with auto-scroll |
109
- | `withSnapshots()` | +1.1 KB | Scroll position save/restore |
109
+ | `withSnapshots()` | +1.3 KB | Scroll position save/restore |
110
110
 
111
111
  ## Examples
112
112
 
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # vlist
2
2
 
3
- The virtual list library for every framework. Accessible by default, batteries-included, with composable features — in 10.6 KB.
3
+ The virtual list library for every framework. Accessible by default, batteries-included, with composable features — in 11.2 KB.
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/vlist.svg)](https://www.npmjs.com/package/vlist)
6
6
  [![CI](https://github.com/floor/vlist/actions/workflows/ci.yml/badge.svg)](https://github.com/floor/vlist/actions/workflows/ci.yml)
@@ -9,7 +9,7 @@ The virtual list library for every framework. Accessible by default, batteries-i
9
9
  - **New: `withSortable()`** — drag-and-drop reordering with auto-scroll, keyboard support, and ARIA announcements
10
10
  - **Zero dependencies** — framework-agnostic core, tiny adapters for Vue, Svelte, Solid, React
11
11
  - **Accessible** — WAI-ARIA, 2D keyboard navigation, focus recovery, screen-reader DOM ordering
12
- - **10.6 KB gzipped** — composable features with perfect tree-shaking
12
+ - **11.2 KB gzipped** — composable features with perfect tree-shaking
13
13
  - **Constant memory** — ~0.1 MB overhead at any scale, from 10K to 1M+ items
14
14
  - **Vertical & horizontal** — single axis-neutral code path, every feature works in both orientations
15
15
 
@@ -54,19 +54,19 @@ const list = vlist({ container: '#app', items, item: { height: 200, template: re
54
54
 
55
55
  | Feature | Size | Description |
56
56
  |---------|------|-------------|
57
- | **Base** | 10.6 KB | Virtualization, ARIA, keyboard nav, gap, padding |
58
- | `withAsync()` | +4.6 KB | Lazy loading with velocity-aware fetching |
59
- | `withSelection()` | +3.0 KB | Single/multiple selection with 2D keyboard nav |
57
+ | **Base** | 11.2 KB | Virtualization, ARIA, keyboard nav, gap, padding |
58
+ | `withAsync()` | +4.5 KB | Lazy loading with velocity-aware fetching |
59
+ | `withSelection()` | +3.2 KB | Single/multiple selection with 2D keyboard nav |
60
60
  | `withScale()` | +3.7 KB | 1M+ items via scroll compression |
61
- | `withGroups()` | +2.7 KB | Sticky/inline headers |
61
+ | `withGroups()` | +4.6 KB | Sticky/inline headers with async group discovery |
62
62
  | `withAutoSize()` | +0.9 KB | Auto-measure items via ResizeObserver |
63
- | `withScrollbar()` | +1.7 KB | Custom scrollbar UI |
64
- | `withGrid()` | +3.9 KB | 2D grid layout |
65
- | `withMasonry()` | +3.3 KB | Pinterest-style masonry with lane-aware keyboard nav |
63
+ | `withScrollbar()` | +1.8 KB | Custom scrollbar UI |
64
+ | `withGrid()` | +4.0 KB | 2D grid layout |
65
+ | `withMasonry()` | +3.5 KB | Pinterest-style masonry with lane-aware keyboard nav |
66
66
  | `withTable()` | +5.5 KB | Data table with columns, resize, sort |
67
- | `withPage()` | +0.8 KB | Window-level scrolling |
67
+ | `withPage()` | +0.7 KB | Window-level scrolling |
68
68
  | `withSortable()` | +3.0 KB | Drag-and-drop reordering with auto-scroll |
69
- | `withSnapshots()` | +1.1 KB | Scroll position save/restore |
69
+ | `withSnapshots()` | +1.3 KB | Scroll position save/restore |
70
70
 
71
71
  ## Framework Adapters
72
72
 
@@ -87,4 +87,4 @@ const list = vlist({ container: '#app', items, item: { height: 200, template: re
87
87
 
88
88
  ## Acknowledgments
89
89
 
90
- Thanks to [Alexander Klaiber](https://github.com/aklaiber) for graciously transferring the `vlist` package name on npm.
90
+ Thanks to Alexander Klaiber for graciously transferring the `vlist` package name on npm.
@@ -36,6 +36,7 @@ export interface SimpleDataManager<T extends VListItem = VListItem> {
36
36
  getStorage: () => unknown;
37
37
  getPlaceholders: () => unknown;
38
38
  getItem: (index: number) => T | undefined;
39
+ getIndexById: (id: string | number) => number;
39
40
  isItemLoaded: (index: number) => boolean;
40
41
  getItemsInRange: (start: number, end: number) => T[];
41
42
  setTotal: (total: number) => void;
@@ -162,5 +162,5 @@ export interface MDeps<T extends VListItem = VListItem> {
162
162
  }
163
163
  export declare const createMaterializeCtx: <T extends VListItem = VListItem>($: MRefs<T>, deps: MDeps<T>) => BuilderContext<T>;
164
164
  export declare const createDefaultDataProxy: <T extends VListItem = VListItem>($: MRefs<T>, deps: Pick<MDeps<T>, "rendered" | "itemState" | "contentSizeHandlers" | "applyTemplate" | "updateContentSize">, ctx: BuilderContext<T>) => any;
165
- export declare const createDefaultScrollProxy: <T extends VListItem = VListItem>($: MRefs<T>, deps: Pick<MDeps<T>, "dom" | "classPrefix">) => any;
165
+ export declare const createDefaultScrollProxy: <T extends VListItem = VListItem>($: MRefs<T>, deps: Pick<MDeps<T>, "dom" | "classPrefix" | "onScrollFrame">) => any;
166
166
  //# sourceMappingURL=materialize.d.ts.map
@@ -346,6 +346,15 @@ export interface BuilderContext<T extends VListItem = VListItem> {
346
346
  * native DOM scrollTop (which can't represent compressed scroll space).
347
347
  */
348
348
  setScrollFns(getTop: () => number, setTop: (pos: number) => void): void;
349
+ /**
350
+ * Trigger the full scroll pipeline (render, events, afterScroll, velocity
351
+ * tracking, idle scheduling) using the current scroll position from $.sgt().
352
+ *
353
+ * Use this from animation loops (e.g. scale feature's smooth scroll) instead
354
+ * of scrollController.scrollTo() — it avoids the double-render caused by the
355
+ * scrollTo proxy calling $.rfn() after $.sst already triggered onScrollFrame.
356
+ */
357
+ triggerScrollFrame(): void;
349
358
  /**
350
359
  * Set the scroll target element (default: viewport).
351
360
  * Used by window mode feature to use window instead of viewport for scroll events.
@@ -67,5 +67,5 @@ export interface GridRenderer<T extends VListItem = VListItem> {
67
67
  * @param ariaIdPrefix - Optional unique prefix for element IDs (for aria-activedescendant)
68
68
  * @param isHorizontal - Whether layout is horizontal (scrolls right)
69
69
  */
70
- export declare const createGridRenderer: <T extends VListItem = VListItem>(itemsContainer: HTMLElement, template: ItemTemplate<T>, sizeCache: SizeCache, gridLayout: GridLayout, classPrefix: string, initialContainerWidth: number, totalItemsGetter?: () => number, ariaIdPrefix?: string, isHorizontal?: boolean) => GridRenderer<T>;
70
+ export declare const createGridRenderer: <T extends VListItem = VListItem>(itemsContainer: HTMLElement, template: ItemTemplate<T>, sizeCache: SizeCache, gridLayout: GridLayout, classPrefix: string, initialContainerWidth: number, totalItemsGetter?: () => number, ariaIdPrefix?: string, isHorizontal?: boolean, ariaPosInSetGetter?: (layoutIndex: number) => number) => GridRenderer<T>;
71
71
  //# sourceMappingURL=renderer.d.ts.map
@@ -0,0 +1,68 @@
1
+ /**
2
+ * vlist - Async Group Bridge
3
+ * Virtual group layer that bridges withAsync's sparse data manager with
4
+ * withGroups' layout system.
5
+ *
6
+ * Instead of physically inserting header pseudo-items into the data array
7
+ * (which is impossible with sparse storage), this bridge:
8
+ * - Observes items as they load via onItemsLoaded callbacks
9
+ * - Discovers group boundaries incrementally from loaded data
10
+ * - Maps between "data indices" (what the async manager knows) and
11
+ * "layout indices" (what the renderer sees, including header slots)
12
+ * - Provides header/item resolution at render time
13
+ *
14
+ * Group boundaries are only computed for contiguous loaded ranges.
15
+ * Unloaded gaps have no headers — placeholders render as regular items.
16
+ * When gaps fill in, boundaries are recomputed.
17
+ */
18
+ import type { VListItem } from "../../types";
19
+ import type { GroupBoundary, GroupHeaderItem } from "./types";
20
+ /** Configuration for the async group bridge */
21
+ export interface AsyncBridgeConfig {
22
+ /** Determine group key for an item */
23
+ getGroupForIndex: (index: number, item?: any) => string;
24
+ /** Header height in pixels (resolved for current orientation) */
25
+ headerHeight: number;
26
+ }
27
+ /** Async group bridge instance */
28
+ export interface AsyncGroupBridge {
29
+ /** Process newly loaded items — updates group boundaries */
30
+ onItemsLoaded(items: VListItem[], offset: number, total: number): void;
31
+ /** Total layout entries (data items + discovered headers) */
32
+ readonly totalEntries: number;
33
+ /** Number of discovered groups */
34
+ readonly groupCount: number;
35
+ /** All discovered group boundaries */
36
+ readonly groups: readonly GroupBoundary[];
37
+ /** Check if a layout index is a group header */
38
+ isHeader(layoutIndex: number): boolean;
39
+ /** Get the group header item at a layout index (undefined if not a header) */
40
+ getHeaderItem(layoutIndex: number): GroupHeaderItem | undefined;
41
+ /** Map layout index → data index (-1 if it's a header) */
42
+ layoutToDataIndex(layoutIndex: number): number;
43
+ /** Map data index → layout index */
44
+ dataToLayoutIndex(dataIndex: number): number;
45
+ /** Get header height for a group */
46
+ getHeaderHeight(groupIndex: number): number;
47
+ /** Get the group boundary at a layout index */
48
+ getGroupAtLayoutIndex(layoutIndex: number): GroupBoundary;
49
+ /** Get the group boundary at a data index */
50
+ getGroupAtDataIndex(dataIndex: number): GroupBoundary;
51
+ /** Remove item at data index — shifts group keys and rebuilds */
52
+ removeAt(dataIndex: number): void;
53
+ /** Reset all state (e.g. on reload) */
54
+ reset(): void;
55
+ }
56
+ /**
57
+ * Create an async group bridge.
58
+ *
59
+ * The bridge discovers group boundaries incrementally as items load from
60
+ * the async adapter. It maintains a mapping between data indices (sparse
61
+ * storage) and layout indices (data items + group headers).
62
+ *
63
+ * @param config - Bridge configuration
64
+ * @param getItem - Item accessor from the async data manager
65
+ * @param isItemLoaded - Check if an item at index is loaded (not placeholder)
66
+ */
67
+ export declare const createAsyncGroupBridge: (config: AsyncBridgeConfig, _getItem: (index: number) => VListItem | undefined, _isItemLoaded: (index: number) => boolean) => AsyncGroupBridge;
68
+ //# sourceMappingURL=async-bridge.d.ts.map
@@ -17,6 +17,7 @@
17
17
  *
18
18
  * Can be combined with:
19
19
  * - withGrid for grouped 2D layouts
20
+ * - withAsync for grouped lists with async pagination
20
21
  * - reverse: true (sticky header shows current section as you scroll up through history)
21
22
  * - orientation: 'horizontal' (sticky headers stick to left edge, push left when next header approaches)
22
23
  */
@@ -25,7 +26,7 @@ import type { VListFeature } from "../../builder/types";
25
26
  /** Groups feature configuration */
26
27
  export interface GroupsFeatureConfig {
27
28
  /** Returns group key for item at index (required) */
28
- getGroupForIndex: (index: number) => string;
29
+ getGroupForIndex: (index: number, item?: any) => string;
29
30
  /** Group header configuration — mirrors the `item` config shape */
30
31
  header?: {
31
32
  /** Header size in pixels — vertical scrolling (default) */
@@ -7,4 +7,5 @@ export type { GroupsConfig, GroupBoundary, LayoutEntry, GroupHeaderItem, GroupLa
7
7
  export { isGroupHeader } from "./types";
8
8
  export { createGroupLayout, buildLayoutItems, createGroupedSizeFn, } from "./layout";
9
9
  export { createStickyHeader } from "./sticky";
10
+ export { createAsyncGroupBridge, type AsyncBridgeConfig, type AsyncGroupBridge } from "./async-bridge";
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -43,5 +43,5 @@ export declare const createGroupedSizeFn: (layout: GroupLayout, itemSize: number
43
43
  * @param itemCount - Number of data items
44
44
  * @param config - Groups configuration
45
45
  */
46
- export declare const createGroupLayout: (itemCount: number, config: GroupsConfig) => GroupLayout;
46
+ export declare const createGroupLayout: (itemCount: number, config: GroupsConfig, getItem?: (index: number) => any) => GroupLayout;
47
47
  //# sourceMappingURL=layout.d.ts.map
@@ -17,5 +17,5 @@
17
17
  */
18
18
  import type { GroupLayout, StickyHeader } from "./types";
19
19
  import type { SizeCache } from "../../rendering/sizes";
20
- export declare const createStickyHeader: (root: HTMLElement, layout: GroupLayout, sizeCache: SizeCache, renderInto: (slot: HTMLElement, groupIndex: number) => void, classPrefix: string, horizontal?: boolean, stickyOffset?: number) => StickyHeader;
20
+ export declare const createStickyHeader: (root: HTMLElement, layout: GroupLayout, sizeCache: SizeCache, renderInto: (slot: HTMLElement, groupIndex: number) => void, classPrefix: string, horizontal?: boolean, stickyOffset?: number, getCompressionRatio?: () => number) => StickyHeader;
21
21
  //# sourceMappingURL=sticky.d.ts.map
@@ -67,8 +67,11 @@ export interface GroupLayout {
67
67
  /**
68
68
  * Rebuild the layout from scratch.
69
69
  * Call when items change (setItems, append, prepend, remove, etc.)
70
+ *
71
+ * @param itemCount - Number of data items
72
+ * @param getItem - Optional item accessor for passing items to getGroupForIndex
70
73
  */
71
- rebuild: (itemCount: number) => void;
74
+ rebuild: (itemCount: number, getItem?: (index: number) => any) => void;
72
75
  }
73
76
  /** Sticky header manager */
74
77
  export interface StickyHeader {
@@ -51,5 +51,5 @@ export interface MasonryRenderer<T extends VListItem = VListItem> {
51
51
  * @param totalItemsGetter - Optional getter for total item count (for aria-setsize)
52
52
  * @param ariaIdPrefix - Optional unique prefix for element IDs (for aria-activedescendant)
53
53
  */
54
- export declare const createMasonryRenderer: <T extends VListItem = VListItem>(itemsContainer: HTMLElement, template: ItemTemplate<T>, classPrefix: string, isHorizontal?: boolean, totalItemsGetter?: () => number, ariaIdPrefix?: string) => MasonryRenderer<T>;
54
+ export declare const createMasonryRenderer: <T extends VListItem = VListItem>(itemsContainer: HTMLElement, template: ItemTemplate<T>, classPrefix: string, isHorizontal?: boolean, totalItemsGetter?: () => number, ariaIdPrefix?: string, ariaPosInSetGetter?: (layoutIndex: number) => number) => MasonryRenderer<T>;
55
55
  //# sourceMappingURL=renderer.d.ts.map