@floor/vlist 0.6.2 → 0.7.1
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.md +70 -75
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/vlist.d.ts +7 -5
- package/dist/vlist.js +1 -0
- package/package.json +12 -28
- package/dist/adapters/index.d.ts +0 -20
- package/dist/adapters/index.d.ts.map +0 -1
- package/dist/adapters/react.d.ts +0 -119
- package/dist/adapters/react.d.ts.map +0 -1
- package/dist/adapters/svelte.d.ts +0 -198
- package/dist/adapters/svelte.d.ts.map +0 -1
- package/dist/adapters/vue.d.ts +0 -151
- package/dist/adapters/vue.d.ts.map +0 -1
- package/dist/builder/context.d.ts.map +0 -1
- package/dist/builder/core.d.ts.map +0 -1
- package/dist/builder/data.d.ts.map +0 -1
- package/dist/builder/index.d.ts.map +0 -1
- package/dist/builder/types.d.ts.map +0 -1
- package/dist/compression/index.js +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/core/core.js +0 -1
- package/dist/core/full.d.ts +0 -22
- package/dist/core/full.d.ts.map +0 -1
- package/dist/core/index.js +0 -1
- package/dist/core/lite.d.ts +0 -129
- package/dist/core/lite.d.ts.map +0 -1
- package/dist/core/minimal.d.ts +0 -104
- package/dist/core/minimal.d.ts.map +0 -1
- package/dist/core-light.d.ts +0 -104
- package/dist/core-light.d.ts.map +0 -1
- package/dist/core-light.js +0 -1
- package/dist/core.d.ts +0 -129
- package/dist/core.d.ts.map +0 -1
- package/dist/data/index.js +0 -1
- package/dist/events/emitter.d.ts.map +0 -1
- package/dist/events/index.d.ts.map +0 -1
- package/dist/features/async/index.d.ts.map +0 -1
- package/dist/features/async/manager.d.ts.map +0 -1
- package/dist/features/async/placeholder.d.ts.map +0 -1
- package/dist/features/async/plugin.d.ts.map +0 -1
- package/dist/features/async/sparse.d.ts.map +0 -1
- package/dist/features/grid/index.d.ts.map +0 -1
- package/dist/features/grid/layout.d.ts.map +0 -1
- package/dist/features/grid/plugin.d.ts.map +0 -1
- package/dist/features/grid/renderer.d.ts.map +0 -1
- package/dist/features/grid/types.d.ts.map +0 -1
- package/dist/features/page/index.d.ts.map +0 -1
- package/dist/features/page/plugin.d.ts.map +0 -1
- package/dist/features/scale/index.d.ts.map +0 -1
- package/dist/features/scale/plugin.d.ts.map +0 -1
- package/dist/features/scrollbar/controller.d.ts.map +0 -1
- package/dist/features/scrollbar/index.d.ts.map +0 -1
- package/dist/features/scrollbar/plugin.d.ts.map +0 -1
- package/dist/features/scrollbar/scrollbar.d.ts.map +0 -1
- package/dist/features/sections/index.d.ts.map +0 -1
- package/dist/features/sections/layout.d.ts.map +0 -1
- package/dist/features/sections/plugin.d.ts.map +0 -1
- package/dist/features/sections/sticky.d.ts.map +0 -1
- package/dist/features/sections/types.d.ts.map +0 -1
- package/dist/features/selection/index.d.ts.map +0 -1
- package/dist/features/selection/plugin.d.ts.map +0 -1
- package/dist/features/selection/state.d.ts.map +0 -1
- package/dist/features/snapshots/index.d.ts.map +0 -1
- package/dist/features/snapshots/plugin.d.ts.map +0 -1
- package/dist/groups/index.js +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/plugins/compression/index.d.ts +0 -10
- package/dist/plugins/compression/index.d.ts.map +0 -1
- package/dist/plugins/compression/plugin.d.ts +0 -42
- package/dist/plugins/compression/plugin.d.ts.map +0 -1
- package/dist/plugins/data/index.d.ts +0 -9
- package/dist/plugins/data/index.d.ts.map +0 -1
- package/dist/plugins/data/manager.d.ts +0 -103
- package/dist/plugins/data/manager.d.ts.map +0 -1
- package/dist/plugins/data/placeholder.d.ts +0 -62
- package/dist/plugins/data/placeholder.d.ts.map +0 -1
- package/dist/plugins/data/plugin.d.ts +0 -60
- package/dist/plugins/data/plugin.d.ts.map +0 -1
- package/dist/plugins/data/sparse.d.ts +0 -91
- package/dist/plugins/data/sparse.d.ts.map +0 -1
- package/dist/plugins/grid/index.d.ts +0 -9
- package/dist/plugins/grid/index.d.ts.map +0 -1
- package/dist/plugins/grid/layout.d.ts +0 -29
- package/dist/plugins/grid/layout.d.ts.map +0 -1
- package/dist/plugins/grid/plugin.d.ts +0 -48
- package/dist/plugins/grid/plugin.d.ts.map +0 -1
- package/dist/plugins/grid/renderer.d.ts +0 -55
- package/dist/plugins/grid/renderer.d.ts.map +0 -1
- package/dist/plugins/grid/types.d.ts +0 -71
- package/dist/plugins/grid/types.d.ts.map +0 -1
- package/dist/plugins/groups/index.d.ts +0 -10
- package/dist/plugins/groups/index.d.ts.map +0 -1
- package/dist/plugins/groups/layout.d.ts +0 -46
- package/dist/plugins/groups/layout.d.ts.map +0 -1
- package/dist/plugins/groups/plugin.d.ts +0 -64
- package/dist/plugins/groups/plugin.d.ts.map +0 -1
- package/dist/plugins/groups/sticky.d.ts +0 -33
- package/dist/plugins/groups/sticky.d.ts.map +0 -1
- package/dist/plugins/groups/types.d.ts +0 -86
- package/dist/plugins/groups/types.d.ts.map +0 -1
- package/dist/plugins/scroll/controller.d.ts +0 -121
- package/dist/plugins/scroll/controller.d.ts.map +0 -1
- package/dist/plugins/scroll/index.d.ts +0 -8
- package/dist/plugins/scroll/index.d.ts.map +0 -1
- package/dist/plugins/scroll/plugin.d.ts +0 -60
- package/dist/plugins/scroll/plugin.d.ts.map +0 -1
- package/dist/plugins/scroll/scrollbar.d.ts +0 -73
- package/dist/plugins/scroll/scrollbar.d.ts.map +0 -1
- package/dist/plugins/selection/index.d.ts +0 -7
- package/dist/plugins/selection/index.d.ts.map +0 -1
- package/dist/plugins/selection/plugin.d.ts +0 -44
- package/dist/plugins/selection/plugin.d.ts.map +0 -1
- package/dist/plugins/selection/state.d.ts +0 -102
- package/dist/plugins/selection/state.d.ts.map +0 -1
- package/dist/plugins/snapshots/index.d.ts +0 -8
- package/dist/plugins/snapshots/index.d.ts.map +0 -1
- package/dist/plugins/snapshots/plugin.d.ts +0 -44
- package/dist/plugins/snapshots/plugin.d.ts.map +0 -1
- package/dist/plugins/window/index.d.ts +0 -8
- package/dist/plugins/window/index.d.ts.map +0 -1
- package/dist/plugins/window/plugin.d.ts +0 -53
- package/dist/plugins/window/plugin.d.ts.map +0 -1
- package/dist/react/index.js +0 -1
- package/dist/react/react.js +0 -1
- package/dist/render/compression.d.ts +0 -116
- package/dist/render/compression.d.ts.map +0 -1
- package/dist/render/heights.d.ts +0 -63
- package/dist/render/heights.d.ts.map +0 -1
- package/dist/render/index.d.ts +0 -9
- package/dist/render/index.d.ts.map +0 -1
- package/dist/render/renderer.d.ts +0 -103
- package/dist/render/renderer.d.ts.map +0 -1
- package/dist/render/virtual.d.ts +0 -139
- package/dist/render/virtual.d.ts.map +0 -1
- package/dist/rendering/heights.d.ts.map +0 -1
- package/dist/rendering/index.d.ts.map +0 -1
- package/dist/rendering/renderer.d.ts.map +0 -1
- package/dist/rendering/scale.d.ts.map +0 -1
- package/dist/rendering/viewport.d.ts.map +0 -1
- package/dist/scroll/index.js +0 -1
- package/dist/svelte/index.js +0 -1
- package/dist/svelte/svelte.js +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/vlist.d.ts.map +0 -1
- package/dist/vue/index.js +0 -1
- package/dist/vue/vue.js +0 -1
- package/dist/window/index.js +0 -1
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vlist - Placeholder System
|
|
3
|
-
* Smart placeholder generation for loading states
|
|
4
|
-
*
|
|
5
|
-
* Key features:
|
|
6
|
-
* - Analyzes loaded data to generate realistic placeholders
|
|
7
|
-
* - Supports masked text with configurable character
|
|
8
|
-
* - Random length variance for natural appearance
|
|
9
|
-
* - Efficient placeholder detection
|
|
10
|
-
*/
|
|
11
|
-
import type { VListItem } from "../../types";
|
|
12
|
-
/** Placeholder configuration */
|
|
13
|
-
export interface PlaceholderConfig {
|
|
14
|
-
/** Enable placeholder generation (default: true) */
|
|
15
|
-
enabled?: boolean;
|
|
16
|
-
/** Character used for masking text (default: '█') */
|
|
17
|
-
maskCharacter?: string;
|
|
18
|
-
/** Add random variance to text lengths (default: true) */
|
|
19
|
-
randomVariance?: boolean;
|
|
20
|
-
/** Maximum items to sample for structure analysis (default: 20) */
|
|
21
|
-
maxSampleSize?: number;
|
|
22
|
-
/** Custom placeholder generator */
|
|
23
|
-
customGenerator?: (index: number) => VListItem;
|
|
24
|
-
}
|
|
25
|
-
/** Placeholder manager instance */
|
|
26
|
-
export interface PlaceholderManager<T extends VListItem = VListItem> {
|
|
27
|
-
/** Analyze data structure from sample items */
|
|
28
|
-
analyzeStructure: (items: T[]) => void;
|
|
29
|
-
/** Check if structure has been analyzed */
|
|
30
|
-
hasAnalyzedStructure: () => boolean;
|
|
31
|
-
/** Generate a single placeholder item */
|
|
32
|
-
generate: (index: number) => T;
|
|
33
|
-
/** Generate multiple placeholder items */
|
|
34
|
-
generateRange: (start: number, end: number) => T[];
|
|
35
|
-
/** Check if an item is a placeholder */
|
|
36
|
-
isPlaceholder: (item: unknown) => boolean;
|
|
37
|
-
/** Get the placeholder flag key */
|
|
38
|
-
getPlaceholderKey: () => string;
|
|
39
|
-
/** Clear analyzed structure */
|
|
40
|
-
clear: () => void;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Create a placeholder manager
|
|
44
|
-
*/
|
|
45
|
-
export declare const createPlaceholderManager: <T extends VListItem = VListItem>(config?: PlaceholderConfig) => PlaceholderManager<T>;
|
|
46
|
-
/**
|
|
47
|
-
* Check if an item is a placeholder (standalone function)
|
|
48
|
-
*/
|
|
49
|
-
export declare const isPlaceholderItem: (item: unknown) => boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Filter out placeholder items from an array
|
|
52
|
-
*/
|
|
53
|
-
export declare const filterPlaceholders: <T extends VListItem>(items: T[]) => T[];
|
|
54
|
-
/**
|
|
55
|
-
* Count non-placeholder items in an array
|
|
56
|
-
*/
|
|
57
|
-
export declare const countRealItems: <T extends VListItem>(items: (T | undefined)[]) => number;
|
|
58
|
-
/**
|
|
59
|
-
* Replace placeholders in a sparse array with real items
|
|
60
|
-
*/
|
|
61
|
-
export declare const replacePlaceholders: <T extends VListItem>(target: (T | undefined)[], items: T[], offset: number) => number;
|
|
62
|
-
//# sourceMappingURL=placeholder.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"placeholder.d.ts","sourceRoot":"","sources":["../../../src/plugins/data/placeholder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAM7C,gCAAgC;AAChC,MAAM,WAAW,iBAAiB;IAChC,oDAAoD;IACpD,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,qDAAqD;IACrD,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,0DAA0D;IAC1D,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB,mEAAmE;IACnE,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,mCAAmC;IACnC,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,SAAS,CAAC;CAChD;AAiBD,mCAAmC;AACnC,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS;IACjE,+CAA+C;IAC/C,gBAAgB,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;IAEvC,2CAA2C;IAC3C,oBAAoB,EAAE,MAAM,OAAO,CAAC;IAEpC,yCAAyC;IACzC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,CAAC;IAE/B,0CAA0C;IAC1C,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC,EAAE,CAAC;IAEnD,wCAAwC;IACxC,aAAa,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC;IAE1C,mCAAmC;IACnC,iBAAiB,EAAE,MAAM,MAAM,CAAC;IAEhC,+BAA+B;IAC/B,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAeD;;GAEG;AACH,eAAO,MAAM,wBAAwB,GAAI,CAAC,SAAS,SAAS,GAAG,SAAS,EACtE,SAAQ,iBAAsB,KAC7B,kBAAkB,CAAC,CAAC,CA+OtB,CAAC;AAMF;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,OAAO,KAAG,OAMjD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,SAAS,EAAE,OAAO,CAAC,EAAE,KAAG,CAAC,EAErE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,SAAS,EAChD,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,EAAE,KACvB,MAUF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,SAAS,EACrD,QAAQ,CAAC,CAAC,GAAG,SAAS,CAAC,EAAE,EACzB,OAAO,CAAC,EAAE,EACV,QAAQ,MAAM,KACb,MAiBF,CAAC"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vlist/data - Builder Plugin
|
|
3
|
-
* Wraps async data loading with sparse storage into a VListPlugin 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
|
-
*
|
|
15
|
-
* Added methods: reload
|
|
16
|
-
* Added events: load:start, load:end, error
|
|
17
|
-
*/
|
|
18
|
-
import type { VListItem, VListAdapter } from "../../types";
|
|
19
|
-
import type { VListPlugin } from "../../builder/types";
|
|
20
|
-
/** Data plugin configuration */
|
|
21
|
-
export interface DataPluginConfig<T extends VListItem = VListItem> {
|
|
22
|
-
/** Async data source (required) */
|
|
23
|
-
adapter: VListAdapter<T>;
|
|
24
|
-
/** Loading behavior configuration */
|
|
25
|
-
loading?: {
|
|
26
|
-
/** Velocity threshold above which data loading is skipped (px/ms). Default: 25 */
|
|
27
|
-
cancelThreshold?: number;
|
|
28
|
-
/** Velocity threshold for preloading (px/ms). Default: 2 */
|
|
29
|
-
preloadThreshold?: number;
|
|
30
|
-
/** Number of items to preload in scroll direction. Default: 50 */
|
|
31
|
-
preloadAhead?: number;
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Create a data plugin for the builder.
|
|
36
|
-
*
|
|
37
|
-
* Adds async data loading with sparse storage, placeholders, and infinite scroll.
|
|
38
|
-
*
|
|
39
|
-
* ```ts
|
|
40
|
-
* import { vlist } from 'vlist/builder'
|
|
41
|
-
* import { withData } from 'vlist/data'
|
|
42
|
-
*
|
|
43
|
-
* const list = vlist({
|
|
44
|
-
* container: '#app',
|
|
45
|
-
* item: { height: 48, template: renderItem },
|
|
46
|
-
* })
|
|
47
|
-
* .use(withData({
|
|
48
|
-
* adapter: {
|
|
49
|
-
* read: async ({ offset, limit }) => {
|
|
50
|
-
* const res = await fetch(`/api/items?offset=${offset}&limit=${limit}`)
|
|
51
|
-
* const data = await res.json()
|
|
52
|
-
* return { items: data.items, total: data.total, hasMore: data.hasMore }
|
|
53
|
-
* }
|
|
54
|
-
* }
|
|
55
|
-
* }))
|
|
56
|
-
* .build()
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
59
|
-
export declare const withData: <T extends VListItem = VListItem>(config: DataPluginConfig<T>) => VListPlugin<T>;
|
|
60
|
-
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/data/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAS,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,qBAAqB,CAAC;AAiBvE,gCAAgC;AAChC,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS;IAC/D,mCAAmC;IACnC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IAEzB,qCAAqC;IACrC,OAAO,CAAC,EAAE;QACR,kFAAkF;QAClF,eAAe,CAAC,EAAE,MAAM,CAAC;QAEzB,4DAA4D;QAC5D,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAE1B,kEAAkE;QAClE,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAMD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,SAAS,GAAG,SAAS,EACtD,QAAQ,gBAAgB,CAAC,CAAC,CAAC,KAC1B,WAAW,CAAC,CAAC,CAiOf,CAAC"}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vlist - Sparse Storage
|
|
3
|
-
* Efficient storage for million+ item virtual lists
|
|
4
|
-
*/
|
|
5
|
-
import type { VListItem, Range } from "../../types";
|
|
6
|
-
/** Configuration for sparse storage */
|
|
7
|
-
export interface SparseStorageConfig {
|
|
8
|
-
/** Number of items per chunk (default: 100) */
|
|
9
|
-
chunkSize?: number;
|
|
10
|
-
/** Maximum items to keep in memory (default: 5000) */
|
|
11
|
-
maxCachedItems?: number;
|
|
12
|
-
/** Extra items to keep around visible range during eviction (default: 200) */
|
|
13
|
-
evictionBuffer?: number;
|
|
14
|
-
/** Callback when items are evicted */
|
|
15
|
-
onEvict?: (evictedCount: number, evictedRanges: number[]) => void;
|
|
16
|
-
}
|
|
17
|
-
/** Storage statistics */
|
|
18
|
-
export interface SparseStorageStats {
|
|
19
|
-
/** Total items declared (may be larger than loaded) */
|
|
20
|
-
totalItems: number;
|
|
21
|
-
/** Number of items currently in memory */
|
|
22
|
-
cachedItems: number;
|
|
23
|
-
/** Number of chunks in memory */
|
|
24
|
-
cachedChunks: number;
|
|
25
|
-
/** Chunk size */
|
|
26
|
-
chunkSize: number;
|
|
27
|
-
/** Maximum cached items allowed */
|
|
28
|
-
maxCachedItems: number;
|
|
29
|
-
/** Memory efficiency (cachedItems / totalItems) */
|
|
30
|
-
memoryEfficiency: number;
|
|
31
|
-
}
|
|
32
|
-
/** Sparse storage instance */
|
|
33
|
-
export interface SparseStorage<T extends VListItem = VListItem> {
|
|
34
|
-
readonly chunkSize: number;
|
|
35
|
-
readonly maxCachedItems: number;
|
|
36
|
-
/** Get total item count */
|
|
37
|
-
getTotal: () => number;
|
|
38
|
-
/** Set total item count (for virtual scrolling height) */
|
|
39
|
-
setTotal: (total: number) => void;
|
|
40
|
-
/** Get item at index (undefined if not loaded) */
|
|
41
|
-
get: (index: number) => T | undefined;
|
|
42
|
-
/** Check if item at index is loaded */
|
|
43
|
-
has: (index: number) => boolean;
|
|
44
|
-
/** Set item at index */
|
|
45
|
-
set: (index: number, item: T) => void;
|
|
46
|
-
/** Set multiple items starting at offset */
|
|
47
|
-
setRange: (offset: number, items: T[]) => void;
|
|
48
|
-
/** Delete item at index */
|
|
49
|
-
delete: (index: number) => boolean;
|
|
50
|
-
/** Get items in range (includes undefined for unloaded) */
|
|
51
|
-
getRange: (start: number, end: number) => (T | undefined)[];
|
|
52
|
-
/** Check if range is fully loaded */
|
|
53
|
-
isRangeLoaded: (start: number, end: number) => boolean;
|
|
54
|
-
/** Get loaded ranges */
|
|
55
|
-
getLoadedRanges: () => Range[];
|
|
56
|
-
/** Find unloaded ranges within a given range */
|
|
57
|
-
findUnloadedRanges: (start: number, end: number) => Range[];
|
|
58
|
-
/** Get chunk index for item index */
|
|
59
|
-
getChunkIndex: (itemIndex: number) => number;
|
|
60
|
-
/** Check if chunk is loaded */
|
|
61
|
-
isChunkLoaded: (chunkIndex: number) => boolean;
|
|
62
|
-
/** Mark chunk as accessed (for LRU) */
|
|
63
|
-
touchChunk: (chunkIndex: number) => void;
|
|
64
|
-
/** Mark all chunks in a range as accessed with a single Date.now() call */
|
|
65
|
-
touchChunksForRange: (start: number, end: number) => void;
|
|
66
|
-
/** Evict chunks far from visible range */
|
|
67
|
-
evictDistant: (visibleStart: number, visibleEnd: number) => number;
|
|
68
|
-
/** Force eviction to meet memory limit */
|
|
69
|
-
evictToLimit: () => number;
|
|
70
|
-
/** Get storage statistics */
|
|
71
|
-
getStats: () => SparseStorageStats;
|
|
72
|
-
/** Get cached item count */
|
|
73
|
-
getCachedCount: () => number;
|
|
74
|
-
/** Clear all data */
|
|
75
|
-
clear: () => void;
|
|
76
|
-
/** Reset to initial state */
|
|
77
|
-
reset: () => void;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Create sparse storage for efficient large list handling
|
|
81
|
-
*/
|
|
82
|
-
export declare const createSparseStorage: <T extends VListItem = VListItem>(config?: SparseStorageConfig) => SparseStorage<T>;
|
|
83
|
-
/**
|
|
84
|
-
* Merge adjacent/overlapping ranges
|
|
85
|
-
*/
|
|
86
|
-
export declare const mergeRanges: (ranges: Range[]) => Range[];
|
|
87
|
-
/**
|
|
88
|
-
* Calculate ranges that need to be loaded
|
|
89
|
-
*/
|
|
90
|
-
export declare const calculateMissingRanges: (needed: Range, loaded: Range[], chunkSize: number) => Range[];
|
|
91
|
-
//# sourceMappingURL=sparse.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sparse.d.ts","sourceRoot":"","sources":["../../../src/plugins/data/sparse.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vlist - Grid Domain
|
|
3
|
-
* 2D grid/card layout with virtualized rows
|
|
4
|
-
*/
|
|
5
|
-
export { withGrid, type GridPluginConfig } from "./plugin";
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/grid/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,QAAQ,EAAE,KAAK,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAG3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAG5C,OAAO,EAAE,kBAAkB,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAGnE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vlist - Grid Layout
|
|
3
|
-
* Pure O(1) calculations for mapping between flat item indices and grid positions.
|
|
4
|
-
*
|
|
5
|
-
* The grid transforms a flat list into rows:
|
|
6
|
-
* Items: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
|
7
|
-
* Grid (columns=4):
|
|
8
|
-
* Row 0: [0, 1, 2, 3]
|
|
9
|
-
* Row 1: [4, 5, 6, 7]
|
|
10
|
-
* Row 2: [8, 9] ← partially filled last row
|
|
11
|
-
*
|
|
12
|
-
* All operations are O(1) — integer division and modulo only.
|
|
13
|
-
*/
|
|
14
|
-
import type { GridConfig, GridLayout } from "./types";
|
|
15
|
-
/**
|
|
16
|
-
* Extended grid config with optional groups support
|
|
17
|
-
*/
|
|
18
|
-
export interface GridConfigWithGroups extends GridConfig {
|
|
19
|
-
/** Optional: check if an item index is a group header (for groups-aware layout) */
|
|
20
|
-
isHeaderFn?: (index: number) => boolean;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Create a GridLayout instance.
|
|
24
|
-
*
|
|
25
|
-
* @param config - Grid configuration (columns, gap, optional isHeaderFn)
|
|
26
|
-
* @returns GridLayout with O(1) mapping functions (or groups-aware if isHeaderFn provided)
|
|
27
|
-
*/
|
|
28
|
-
export declare const createGridLayout: (config: GridConfigWithGroups) => GridLayout;
|
|
29
|
-
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/plugins/grid/layout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAA2B,MAAM,SAAS,CAAC;AAE/E;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,UAAU;IACtD,mFAAmF;IACnF,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;CACzC;AAMD;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,oBAAoB,KAAG,UA4R/D,CAAC"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vlist/grid - Builder Plugin
|
|
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 direction: '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 { VListPlugin } from "../../builder/types";
|
|
22
|
-
/** Grid plugin configuration */
|
|
23
|
-
export interface GridPluginConfig {
|
|
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 plugin 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: GridPluginConfig) => VListPlugin<T>;
|
|
48
|
-
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/grid/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,qBAAqB,CAAC;AAUvE,gCAAgC;AAChC,MAAM,WAAW,gBAAgB;IAC/B,yCAAyC;IACzC,OAAO,EAAE,MAAM,CAAC;IAEhB,+CAA+C;IAC/C,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAMD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,SAAS,GAAG,SAAS,EACtD,QAAQ,gBAAgB,KACvB,WAAW,CAAC,CAAC,CA4Zf,CAAC"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vlist - Grid Renderer
|
|
3
|
-
* Renders items in a 2D grid layout within the virtual scroll container.
|
|
4
|
-
*
|
|
5
|
-
* Extends the base renderer pattern but positions items using both
|
|
6
|
-
* row offsets (translateY from the height cache) and column offsets
|
|
7
|
-
* (translateX calculated from column index and container width).
|
|
8
|
-
*
|
|
9
|
-
* Key differences from the list renderer:
|
|
10
|
-
* - Items are positioned with translate(x, y) instead of just translateY(y)
|
|
11
|
-
* - Item width is set to columnWidth (containerWidth / columns - gaps)
|
|
12
|
-
* - The "index" in the rendered map is the FLAT ITEM INDEX (not row index)
|
|
13
|
-
* - Row offsets come from the height cache (which operates on row indices)
|
|
14
|
-
* - Column offsets are calculated from itemIndex % columns
|
|
15
|
-
*/
|
|
16
|
-
import type { VListItem, ItemTemplate, Range } from "../../types";
|
|
17
|
-
import type { HeightCache } from "../../render/heights";
|
|
18
|
-
import type { CompressionContext } from "../../render/renderer";
|
|
19
|
-
import type { GridLayout } from "./types";
|
|
20
|
-
/** Grid renderer instance */
|
|
21
|
-
export interface GridRenderer<T extends VListItem = VListItem> {
|
|
22
|
-
/** Render items for a flat item range, positioned in a 2D grid */
|
|
23
|
-
render: (items: T[], range: Range, selectedIds: Set<string | number>, focusedIndex: number, compressionCtx?: CompressionContext) => void;
|
|
24
|
-
/** Update item positions (for compressed scrolling) */
|
|
25
|
-
updatePositions: (compressionCtx: CompressionContext) => void;
|
|
26
|
-
/** Update a single item */
|
|
27
|
-
updateItem: (index: number, item: T, isSelected: boolean, isFocused: boolean) => void;
|
|
28
|
-
/** Update only CSS classes on a rendered item (no template re-evaluation) */
|
|
29
|
-
updateItemClasses: (index: number, isSelected: boolean, isFocused: boolean) => void;
|
|
30
|
-
/** Get rendered item element by flat item index */
|
|
31
|
-
getElement: (index: number) => HTMLElement | undefined;
|
|
32
|
-
/** Update container width (call on resize) */
|
|
33
|
-
updateContainerWidth: (width: number) => void;
|
|
34
|
-
/** Clear all rendered items */
|
|
35
|
-
clear: () => void;
|
|
36
|
-
/** Destroy renderer and cleanup */
|
|
37
|
-
destroy: () => void;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Create a grid renderer for managing DOM elements in a 2D layout.
|
|
41
|
-
*
|
|
42
|
-
* The grid renderer receives flat item ranges (not row ranges) and
|
|
43
|
-
* positions each item at the correct (row, col) coordinate.
|
|
44
|
-
*
|
|
45
|
-
* @param itemsContainer - The DOM element that holds rendered items
|
|
46
|
-
* @param template - Item template function
|
|
47
|
-
* @param heightCache - Height cache operating on ROW indices
|
|
48
|
-
* @param gridLayout - Grid layout for row/col calculations
|
|
49
|
-
* @param classPrefix - CSS class prefix
|
|
50
|
-
* @param initialContainerWidth - Initial container width for column sizing
|
|
51
|
-
* @param totalItemsGetter - Optional getter for total item count (for aria-setsize)
|
|
52
|
-
* @param ariaIdPrefix - Optional unique prefix for element IDs (for aria-activedescendant)
|
|
53
|
-
*/
|
|
54
|
-
export declare const createGridRenderer: <T extends VListItem = VListItem>(itemsContainer: HTMLElement, template: ItemTemplate<T>, heightCache: HeightCache, gridLayout: GridLayout, classPrefix: string, initialContainerWidth: number, totalItemsGetter?: () => number, ariaIdPrefix?: string) => GridRenderer<T>;
|
|
55
|
-
//# sourceMappingURL=renderer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../../src/plugins/grid/renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,YAAY,EAEZ,KAAK,EAEN,MAAM,aAAa,CAAC;AAOrB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAO1C,6BAA6B;AAC7B,MAAM,WAAW,YAAY,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS;IAC3D,kEAAkE;IAClE,MAAM,EAAE,CACN,KAAK,EAAE,CAAC,EAAE,EACV,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EACjC,YAAY,EAAE,MAAM,EACpB,cAAc,CAAC,EAAE,kBAAkB,KAChC,IAAI,CAAC;IAEV,uDAAuD;IACvD,eAAe,EAAE,CAAC,cAAc,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAE9D,2BAA2B;IAC3B,UAAU,EAAE,CACV,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,CAAC,EACP,UAAU,EAAE,OAAO,EACnB,SAAS,EAAE,OAAO,KACf,IAAI,CAAC;IAEV,6EAA6E;IAC7E,iBAAiB,EAAE,CACjB,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,OAAO,EACnB,SAAS,EAAE,OAAO,KACf,IAAI,CAAC;IAEV,mDAAmD;IACnD,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,CAAC;IAEvD,8CAA8C;IAC9C,oBAAoB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAE9C,+BAA+B;IAC/B,KAAK,EAAE,MAAM,IAAI,CAAC;IAElB,mCAAmC;IACnC,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAoDD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,SAAS,GAAG,SAAS,EAChE,gBAAgB,WAAW,EAC3B,UAAU,YAAY,CAAC,CAAC,CAAC,EACzB,aAAa,WAAW,EACxB,YAAY,UAAU,EACtB,aAAa,MAAM,EACnB,uBAAuB,MAAM,EAC7B,mBAAmB,MAAM,MAAM,EAC/B,eAAe,MAAM,KACpB,YAAY,CAAC,CAAC,CAmahB,CAAC"}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vlist - Grid Types
|
|
3
|
-
* Types for grid/card layout mode
|
|
4
|
-
*
|
|
5
|
-
* Grid layout transforms a flat list of items into a 2D grid where:
|
|
6
|
-
* - Virtualization operates on ROWS (not individual items)
|
|
7
|
-
* - Each row contains `columns` items side by side
|
|
8
|
-
* - Items are positioned using row/column coordinates
|
|
9
|
-
* - Compression applies to row count, not item count
|
|
10
|
-
*/
|
|
11
|
-
import type { GridConfig } from "../../types";
|
|
12
|
-
export type { GridConfig };
|
|
13
|
-
/** Row/column position of an item */
|
|
14
|
-
export interface GridPosition {
|
|
15
|
-
/** Row index (0-based) */
|
|
16
|
-
row: number;
|
|
17
|
-
/** Column index (0-based) */
|
|
18
|
-
col: number;
|
|
19
|
-
}
|
|
20
|
-
/** Flat item range corresponding to a row range */
|
|
21
|
-
export interface ItemRange {
|
|
22
|
-
/** First item index (inclusive) */
|
|
23
|
-
start: number;
|
|
24
|
-
/** Last item index (inclusive) */
|
|
25
|
-
end: number;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* GridLayout — maps between flat item indices and row/column positions.
|
|
29
|
-
*
|
|
30
|
-
* The virtualizer sees "rows" as its unit of work. Each row contains
|
|
31
|
-
* up to `columns` items. The last row may be partially filled.
|
|
32
|
-
*
|
|
33
|
-
* All operations are O(1) — just integer division and modulo.
|
|
34
|
-
*/
|
|
35
|
-
export interface GridLayout {
|
|
36
|
-
/** Number of columns */
|
|
37
|
-
readonly columns: number;
|
|
38
|
-
/** Gap between items in pixels */
|
|
39
|
-
readonly gap: number;
|
|
40
|
-
/** Update grid configuration without recreating the layout */
|
|
41
|
-
update: (config: Partial<GridConfig>) => void;
|
|
42
|
-
/** Get total number of rows for a given item count */
|
|
43
|
-
getTotalRows: (totalItems: number) => number;
|
|
44
|
-
/** Get the row/col position for a flat item index */
|
|
45
|
-
getPosition: (itemIndex: number) => GridPosition;
|
|
46
|
-
/** Get the row index for a flat item index */
|
|
47
|
-
getRow: (itemIndex: number) => number;
|
|
48
|
-
/** Get the column index for a flat item index */
|
|
49
|
-
getCol: (itemIndex: number) => number;
|
|
50
|
-
/**
|
|
51
|
-
* Get the flat item range for a range of rows.
|
|
52
|
-
* The last row may be partially filled (end is clamped to totalItems - 1).
|
|
53
|
-
*/
|
|
54
|
-
getItemRange: (rowStart: number, rowEnd: number, totalItems: number) => ItemRange;
|
|
55
|
-
/**
|
|
56
|
-
* Get the flat item index from a row and column.
|
|
57
|
-
* Returns -1 if out of bounds.
|
|
58
|
-
*/
|
|
59
|
-
getItemIndex: (row: number, col: number, totalItems: number) => number;
|
|
60
|
-
/**
|
|
61
|
-
* Calculate column width given container width.
|
|
62
|
-
* Accounts for gaps: width = (containerWidth - (columns - 1) * gap) / columns
|
|
63
|
-
*/
|
|
64
|
-
getColumnWidth: (containerWidth: number) => number;
|
|
65
|
-
/**
|
|
66
|
-
* Calculate the X offset for a column index.
|
|
67
|
-
* offset = col * (columnWidth + gap)
|
|
68
|
-
*/
|
|
69
|
-
getColumnOffset: (col: number, containerWidth: number) => number;
|
|
70
|
-
}
|
|
71
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/plugins/grid/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,YAAY,EAAE,UAAU,EAAE,CAAC;AAM3B,qCAAqC;AACrC,MAAM,WAAW,YAAY;IAC3B,0BAA0B;IAC1B,GAAG,EAAE,MAAM,CAAC;IAEZ,6BAA6B;IAC7B,GAAG,EAAE,MAAM,CAAC;CACb;AAED,mDAAmD;AACnD,MAAM,WAAW,SAAS;IACxB,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;IAEd,kCAAkC;IAClC,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU;IACzB,wBAAwB;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,kCAAkC;IAClC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB,8DAA8D;IAC9D,MAAM,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;IAE9C,sDAAsD;IACtD,YAAY,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,CAAC;IAE7C,qDAAqD;IACrD,WAAW,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,YAAY,CAAC;IAEjD,8CAA8C;IAC9C,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;IAEtC,iDAAiD;IACjD,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;IAEtC;;;OAGG;IACH,YAAY,EAAE,CACZ,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,KACf,SAAS,CAAC;IAEf;;;OAGG;IACH,YAAY,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,MAAM,CAAC;IAEvE;;;OAGG;IACH,cAAc,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,MAAM,CAAC;IAEnD;;;OAGG;IACH,eAAe,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,KAAK,MAAM,CAAC;CAClE"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vlist - Groups Domain
|
|
3
|
-
* Sticky headers and grouped lists
|
|
4
|
-
*/
|
|
5
|
-
export { withGroups, type GroupsPluginConfig } from "./plugin";
|
|
6
|
-
export type { GroupsConfig, GroupBoundary, LayoutEntry, GroupHeaderItem, GroupLayout, StickyHeader, } from "./types";
|
|
7
|
-
export { isGroupHeader } from "./types";
|
|
8
|
-
export { createGroupLayout, buildLayoutItems, createGroupedHeightFn, } from "./layout";
|
|
9
|
-
export { createStickyHeader } from "./sticky";
|
|
10
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/groups/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,UAAU,EAAE,KAAK,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAG/D,YAAY,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EACX,eAAe,EACf,WAAW,EACX,YAAY,GACb,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGxC,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vlist - Group Layout
|
|
3
|
-
* Computes group boundaries and maps between data indices and layout indices.
|
|
4
|
-
*
|
|
5
|
-
* The layout transforms a flat items array into a "layout" that includes
|
|
6
|
-
* group header pseudo-items interspersed at group boundaries:
|
|
7
|
-
*
|
|
8
|
-
* Data: [item0, item1, item2, item3, item4, item5]
|
|
9
|
-
* Groups: [ A, A, A, B, B, C ]
|
|
10
|
-
* Layout: [headerA, item0, item1, item2, headerB, item3, item4, headerC, item5]
|
|
11
|
-
* Index: [ 0, 1, 2, 3, 4, 5, 6, 7, 8 ]
|
|
12
|
-
*
|
|
13
|
-
* All lookups are O(log g) where g = number of groups, using binary search
|
|
14
|
-
* on the sorted group boundaries array.
|
|
15
|
-
*/
|
|
16
|
-
import type { GroupsConfig, GroupBoundary, GroupLayout, GroupHeaderItem } from "./types";
|
|
17
|
-
import type { VListItem } from "../../types";
|
|
18
|
-
/**
|
|
19
|
-
* Build the transformed layout items array with header pseudo-items inserted
|
|
20
|
-
* at group boundaries.
|
|
21
|
-
*
|
|
22
|
-
* @param items - Original data items
|
|
23
|
-
* @param groups - Computed group boundaries
|
|
24
|
-
* @returns Array of items and header pseudo-items in layout order
|
|
25
|
-
*/
|
|
26
|
-
export declare const buildLayoutItems: <T extends VListItem>(items: T[], groups: readonly GroupBoundary[]) => Array<T | GroupHeaderItem>;
|
|
27
|
-
/**
|
|
28
|
-
* Create a height function for the layout that returns the correct height
|
|
29
|
-
* for both group headers and data items.
|
|
30
|
-
*
|
|
31
|
-
* @param layout - The group layout instance
|
|
32
|
-
* @param itemHeight - Original item height config (number or function)
|
|
33
|
-
* @returns A height function (layoutIndex) => number suitable for HeightCache
|
|
34
|
-
*/
|
|
35
|
-
export declare const createGroupedHeightFn: (layout: GroupLayout, itemHeight: number | ((index: number) => number)) => ((layoutIndex: number) => number);
|
|
36
|
-
/**
|
|
37
|
-
* Create a GroupLayout instance.
|
|
38
|
-
*
|
|
39
|
-
* The layout computes group boundaries from items and provides efficient
|
|
40
|
-
* O(log g) mappings between data indices and layout indices.
|
|
41
|
-
*
|
|
42
|
-
* @param itemCount - Number of data items
|
|
43
|
-
* @param config - Groups configuration
|
|
44
|
-
*/
|
|
45
|
-
export declare const createGroupLayout: (itemCount: number, config: GroupsConfig) => GroupLayout;
|
|
46
|
-
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/plugins/groups/layout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EAEX,eAAe,EAChB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AA+G7C;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,SAAS,EAClD,OAAO,CAAC,EAAE,EACV,QAAQ,SAAS,aAAa,EAAE,KAC/B,KAAK,CAAC,CAAC,GAAG,eAAe,CA0B3B,CAAC;AAMF;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,GAChC,QAAQ,WAAW,EACnB,YAAY,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,KAC/C,CAAC,CAAC,WAAW,EAAE,MAAM,KAAK,MAAM,CAelC,CAAC;AAMF;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAC5B,WAAW,MAAM,EACjB,QAAQ,YAAY,KACnB,WAkIF,CAAC"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vlist/groups - Builder Plugin
|
|
3
|
-
* Adds grouped lists with sticky section headers.
|
|
4
|
-
*
|
|
5
|
-
* Priority: 10 (runs first — transforms item list and height function before rendering)
|
|
6
|
-
*
|
|
7
|
-
* What it wires:
|
|
8
|
-
* - Transforms item list — inserts header items at group boundaries
|
|
9
|
-
* - Replaces height function — headers use headerHeight, data items use configured item.height
|
|
10
|
-
* - Unified template — dispatches to headerTemplate for headers, user template for items
|
|
11
|
-
* - Sticky header DOM — creates a positioned header element that updates as you scroll
|
|
12
|
-
* - Index mapping — translates between data indices and layout indices
|
|
13
|
-
* - CSS class — adds .vlist--grouped to the root element
|
|
14
|
-
*
|
|
15
|
-
* Restrictions:
|
|
16
|
-
* - Items must be pre-sorted by group
|
|
17
|
-
* - Cannot be combined with direction: 'horizontal'
|
|
18
|
-
*
|
|
19
|
-
* Can be combined with:
|
|
20
|
-
* - withGrid for grouped 2D layouts
|
|
21
|
-
* - reverse: true (sticky header shows current section as you scroll up through history)
|
|
22
|
-
*/
|
|
23
|
-
import type { VListItem } from "../../types";
|
|
24
|
-
import type { VListPlugin } from "../../builder/types";
|
|
25
|
-
/** Groups plugin configuration */
|
|
26
|
-
export interface GroupsPluginConfig {
|
|
27
|
-
/** Returns group key for item at index (required) */
|
|
28
|
-
getGroupForIndex: (index: number) => string;
|
|
29
|
-
/** Height of group headers in pixels (required) */
|
|
30
|
-
headerHeight: number;
|
|
31
|
-
/** Render function for headers (required) */
|
|
32
|
-
headerTemplate: (key: string, groupIndex: number) => HTMLElement | string;
|
|
33
|
-
/** Enable sticky headers — iOS Contacts style (default: true) */
|
|
34
|
-
sticky?: boolean;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Create a groups plugin for the builder.
|
|
38
|
-
*
|
|
39
|
-
* Adds grouped lists with sticky section headers.
|
|
40
|
-
*
|
|
41
|
-
* ```ts
|
|
42
|
-
* import { vlist } from 'vlist/builder'
|
|
43
|
-
* import { withGroups } from 'vlist/groups'
|
|
44
|
-
*
|
|
45
|
-
* const contacts = vlist({
|
|
46
|
-
* container: '#contacts',
|
|
47
|
-
* item: { height: 56, template: renderContact },
|
|
48
|
-
* items: sortedContacts,
|
|
49
|
-
* })
|
|
50
|
-
* .use(withGroups({
|
|
51
|
-
* getGroupForIndex: (i) => sortedContacts[i].lastName[0],
|
|
52
|
-
* headerHeight: 32,
|
|
53
|
-
* headerTemplate: (letter) => {
|
|
54
|
-
* const el = document.createElement('div')
|
|
55
|
-
* el.className = 'letter-header'
|
|
56
|
-
* el.textContent = letter
|
|
57
|
-
* return el
|
|
58
|
-
* },
|
|
59
|
-
* }))
|
|
60
|
-
* .build()
|
|
61
|
-
* ```
|
|
62
|
-
*/
|
|
63
|
-
export declare const withGroups: <T extends VListItem = VListItem>(config: GroupsPluginConfig) => VListPlugin<T>;
|
|
64
|
-
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/groups/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,qBAAqB,CAAC;AAuBvE,kCAAkC;AAClC,MAAM,WAAW,kBAAkB;IACjC,qDAAqD;IACrD,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAE5C,mDAAmD;IACnD,YAAY,EAAE,MAAM,CAAC;IAErB,6CAA6C;IAC7C,cAAc,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,WAAW,GAAG,MAAM,CAAC;IAE1E,iEAAiE;IACjE,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,SAAS,GAAG,SAAS,EACxD,QAAQ,kBAAkB,KACzB,WAAW,CAAC,CAAC,CAmRf,CAAC"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vlist - Sticky Header
|
|
3
|
-
* Manages a floating header element that "sticks" to the top of the viewport
|
|
4
|
-
* and transitions smoothly when the next group's header approaches.
|
|
5
|
-
*
|
|
6
|
-
* The sticky header is a separate DOM element positioned absolutely at the
|
|
7
|
-
* top of the root container. It overlays the scrolling content and shows
|
|
8
|
-
* the current group's header. When the next group's inline header scrolls
|
|
9
|
-
* into view, the sticky header is pushed upward to create the classic
|
|
10
|
-
* iOS Contacts-style transition effect.
|
|
11
|
-
*
|
|
12
|
-
* Layout:
|
|
13
|
-
* .vlist (root, position: relative)
|
|
14
|
-
* ├── .vlist-sticky-header (position: absolute, top: 0, z-index: 5)
|
|
15
|
-
* │ └── (content rendered by headerTemplate)
|
|
16
|
-
* └── .vlist-viewport
|
|
17
|
-
* └── .vlist-content
|
|
18
|
-
* └── .vlist-items
|
|
19
|
-
*/
|
|
20
|
-
import type { GroupLayout, GroupsConfig, StickyHeader } from "./types";
|
|
21
|
-
import type { HeightCache } from "../../render/heights";
|
|
22
|
-
/**
|
|
23
|
-
* Create a sticky header manager.
|
|
24
|
-
*
|
|
25
|
-
* @param root - The vlist root element (.vlist) — sticky header is appended here
|
|
26
|
-
* @param layout - Group layout for index/group resolution
|
|
27
|
-
* @param heightCache - The LAYOUT height cache (includes headers)
|
|
28
|
-
* @param config - Groups configuration (headerTemplate, headerHeight)
|
|
29
|
-
* @param classPrefix - CSS class prefix (default: 'vlist')
|
|
30
|
-
* @returns StickyHeader instance
|
|
31
|
-
*/
|
|
32
|
-
export declare const createStickyHeader: (root: HTMLElement, layout: GroupLayout, heightCache: HeightCache, config: GroupsConfig, classPrefix: string) => StickyHeader;
|
|
33
|
-
//# sourceMappingURL=sticky.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sticky.d.ts","sourceRoot":"","sources":["../../../src/plugins/groups/sticky.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAMxD;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,GAC7B,MAAM,WAAW,EACjB,QAAQ,WAAW,EACnB,aAAa,WAAW,EACxB,QAAQ,YAAY,EACpB,aAAa,MAAM,KAClB,YAgMF,CAAC"}
|