@floor/vlist 0.5.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/LICENSE +21 -0
- package/README.md +839 -0
- package/dist/adapters/index.d.ts +20 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/react.d.ts +119 -0
- package/dist/adapters/react.d.ts.map +1 -0
- package/dist/adapters/svelte.d.ts +198 -0
- package/dist/adapters/svelte.d.ts.map +1 -0
- package/dist/adapters/vue.d.ts +151 -0
- package/dist/adapters/vue.d.ts.map +1 -0
- package/dist/builder/context.d.ts +36 -0
- package/dist/builder/context.d.ts.map +1 -0
- package/dist/builder/core.d.ts +16 -0
- package/dist/builder/core.d.ts.map +1 -0
- package/dist/builder/data.d.ts +71 -0
- package/dist/builder/data.d.ts.map +1 -0
- package/dist/builder/index.d.ts +25 -0
- package/dist/builder/index.d.ts.map +1 -0
- package/dist/builder/index.js +1 -0
- package/dist/builder/types.d.ts +269 -0
- package/dist/builder/types.d.ts.map +1 -0
- package/dist/compression/index.js +1 -0
- package/dist/constants.d.ts +65 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/core/index.js +1 -0
- package/dist/core-light.d.ts +104 -0
- package/dist/core-light.d.ts.map +1 -0
- package/dist/core-light.js +1 -0
- package/dist/core.d.ts +129 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/data/index.js +1 -0
- package/dist/events/emitter.d.ts +20 -0
- package/dist/events/emitter.d.ts.map +1 -0
- package/dist/events/index.d.ts +6 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/grid/index.js +1 -0
- package/dist/groups/index.js +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/plugins/compression/index.d.ts +10 -0
- package/dist/plugins/compression/index.d.ts.map +1 -0
- package/dist/plugins/compression/plugin.d.ts +42 -0
- package/dist/plugins/compression/plugin.d.ts.map +1 -0
- package/dist/plugins/data/index.d.ts +9 -0
- package/dist/plugins/data/index.d.ts.map +1 -0
- package/dist/plugins/data/manager.d.ts +103 -0
- package/dist/plugins/data/manager.d.ts.map +1 -0
- package/dist/plugins/data/placeholder.d.ts +62 -0
- package/dist/plugins/data/placeholder.d.ts.map +1 -0
- package/dist/plugins/data/plugin.d.ts +60 -0
- package/dist/plugins/data/plugin.d.ts.map +1 -0
- package/dist/plugins/data/sparse.d.ts +91 -0
- package/dist/plugins/data/sparse.d.ts.map +1 -0
- package/dist/plugins/grid/index.d.ts +9 -0
- package/dist/plugins/grid/index.d.ts.map +1 -0
- package/dist/plugins/grid/layout.d.ts +29 -0
- package/dist/plugins/grid/layout.d.ts.map +1 -0
- package/dist/plugins/grid/plugin.d.ts +48 -0
- package/dist/plugins/grid/plugin.d.ts.map +1 -0
- package/dist/plugins/grid/renderer.d.ts +55 -0
- package/dist/plugins/grid/renderer.d.ts.map +1 -0
- package/dist/plugins/grid/types.d.ts +71 -0
- package/dist/plugins/grid/types.d.ts.map +1 -0
- package/dist/plugins/groups/index.d.ts +10 -0
- package/dist/plugins/groups/index.d.ts.map +1 -0
- package/dist/plugins/groups/layout.d.ts +46 -0
- package/dist/plugins/groups/layout.d.ts.map +1 -0
- package/dist/plugins/groups/plugin.d.ts +63 -0
- package/dist/plugins/groups/plugin.d.ts.map +1 -0
- package/dist/plugins/groups/sticky.d.ts +33 -0
- package/dist/plugins/groups/sticky.d.ts.map +1 -0
- package/dist/plugins/groups/types.d.ts +86 -0
- package/dist/plugins/groups/types.d.ts.map +1 -0
- package/dist/plugins/scroll/controller.d.ts +121 -0
- package/dist/plugins/scroll/controller.d.ts.map +1 -0
- package/dist/plugins/scroll/index.d.ts +8 -0
- package/dist/plugins/scroll/index.d.ts.map +1 -0
- package/dist/plugins/scroll/plugin.d.ts +60 -0
- package/dist/plugins/scroll/plugin.d.ts.map +1 -0
- package/dist/plugins/scroll/scrollbar.d.ts +73 -0
- package/dist/plugins/scroll/scrollbar.d.ts.map +1 -0
- package/dist/plugins/selection/index.d.ts +7 -0
- package/dist/plugins/selection/index.d.ts.map +1 -0
- package/dist/plugins/selection/plugin.d.ts +44 -0
- package/dist/plugins/selection/plugin.d.ts.map +1 -0
- package/dist/plugins/selection/state.d.ts +102 -0
- package/dist/plugins/selection/state.d.ts.map +1 -0
- package/dist/plugins/snapshots/index.d.ts +8 -0
- package/dist/plugins/snapshots/index.d.ts.map +1 -0
- package/dist/plugins/snapshots/plugin.d.ts +44 -0
- package/dist/plugins/snapshots/plugin.d.ts.map +1 -0
- package/dist/plugins/window/index.d.ts +8 -0
- package/dist/plugins/window/index.d.ts.map +1 -0
- package/dist/plugins/window/plugin.d.ts +53 -0
- package/dist/plugins/window/plugin.d.ts.map +1 -0
- package/dist/react/index.js +1 -0
- package/dist/render/compression.d.ts +116 -0
- package/dist/render/compression.d.ts.map +1 -0
- package/dist/render/heights.d.ts +63 -0
- package/dist/render/heights.d.ts.map +1 -0
- package/dist/render/index.d.ts +9 -0
- package/dist/render/index.d.ts.map +1 -0
- package/dist/render/renderer.d.ts +103 -0
- package/dist/render/renderer.d.ts.map +1 -0
- package/dist/render/virtual.d.ts +139 -0
- package/dist/render/virtual.d.ts.map +1 -0
- package/dist/scroll/index.js +1 -0
- package/dist/selection/index.js +1 -0
- package/dist/snapshots/index.js +1 -0
- package/dist/svelte/index.js +1 -0
- package/dist/types.d.ts +559 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/vlist-extras.css +1 -0
- package/dist/vlist.css +1 -0
- package/dist/vlist.d.ts +22 -0
- package/dist/vlist.d.ts.map +1 -0
- package/dist/vue/index.js +1 -0
- package/dist/window/index.js +1 -0
- package/package.json +137 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var B=()=>{return{name:"withSnapshots",priority:50,methods:["getScrollSnapshot","restoreScroll"],setup(v){v.methods.set("getScrollSnapshot",()=>{let q=v.scrollController.getScrollTop(),y=v.getCachedCompression(),k=v.getVirtualTotal(),j=v.methods.get("getSelected"),A=j&&j().length>0?j():void 0;if(k===0){let u={index:0,offsetInItem:0};if(A)u.selectedIds=A;return u}let w,b;if(y.isCompressed){let U=q/y.virtualHeight*k;w=Math.max(0,Math.min(Math.floor(U),k-1)),b=(U-w)*v.heightCache.getHeight(w)}else w=v.heightCache.indexAtOffset(q),b=q-v.heightCache.getOffset(w);b=Math.max(0,b);let S={index:w,offsetInItem:b};if(A)S.selectedIds=A;return S}),v.methods.set("restoreScroll",(q)=>{let{index:y,offsetInItem:k,selectedIds:j}=q,A=v.getCachedCompression(),w=v.getVirtualTotal();if(w===0)return;let b=Math.max(0,Math.min(y,w-1)),S;if(A.isCompressed){let U=v.heightCache.getHeight(b),z=U>0?k/U:0;S=(b+z)/w*A.virtualHeight}else S=v.heightCache.getOffset(b)+k;let u=Math.max(0,A.virtualHeight-v.state.viewportState.containerHeight);if(S=Math.max(0,Math.min(S,u)),v.scrollController.scrollTo(S),j&&j.length>0){let U=v.methods.get("select");if(U)U(...j)}})}}};export{B as withSnapshots};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createVList as A}from"vlist";function C(z,k){let j=A({...k.config,container:z});if(k.onInstance)k.onInstance(j);return{update(q){if(q.config.items)j.setItems(q.config.items);if(q.onInstance)q.onInstance(j)},destroy(){j.destroy()}}}function F(z,k,j){return z.on(k,j)}export{C as vlist,F as onVListEvent};
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,559 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vlist - Core Types
|
|
3
|
+
* Minimal, clean interfaces for the virtual list
|
|
4
|
+
*/
|
|
5
|
+
/** Base event map with index signature */
|
|
6
|
+
export type EventMap = Record<string, unknown>;
|
|
7
|
+
/** Base item interface - must have an id */
|
|
8
|
+
export interface VListItem {
|
|
9
|
+
id: string | number;
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
}
|
|
12
|
+
/** Groups configuration for createVList */
|
|
13
|
+
export interface GroupsConfig {
|
|
14
|
+
/**
|
|
15
|
+
* Determine which group an item belongs to.
|
|
16
|
+
* Called with the DATA index (index into the original items array).
|
|
17
|
+
* Items with the same group key are grouped together.
|
|
18
|
+
*
|
|
19
|
+
* Items MUST be pre-sorted by group — the function is called in order
|
|
20
|
+
* and a new header is inserted whenever the return value changes.
|
|
21
|
+
*/
|
|
22
|
+
getGroupForIndex: (index: number) => string;
|
|
23
|
+
/**
|
|
24
|
+
* Height of group header elements in pixels.
|
|
25
|
+
* - `number` — Fixed height for all headers
|
|
26
|
+
* - `(group: string, groupIndex: number) => number` — Variable height per group
|
|
27
|
+
*/
|
|
28
|
+
headerHeight: number | ((group: string, groupIndex: number) => number);
|
|
29
|
+
/**
|
|
30
|
+
* Template function to render a group header.
|
|
31
|
+
* Receives the group key and the group's sequential index (0-based).
|
|
32
|
+
*/
|
|
33
|
+
headerTemplate: (group: string, groupIndex: number) => string | HTMLElement;
|
|
34
|
+
/**
|
|
35
|
+
* Enable sticky headers (default: true).
|
|
36
|
+
* When true, the current group's header "sticks" to the top of the
|
|
37
|
+
* viewport and is pushed out by the next group's header approaching.
|
|
38
|
+
*/
|
|
39
|
+
sticky?: boolean;
|
|
40
|
+
}
|
|
41
|
+
/** Grid configuration for createVList */
|
|
42
|
+
export interface GridConfig {
|
|
43
|
+
/**
|
|
44
|
+
* Number of columns in the grid.
|
|
45
|
+
* Item width = containerWidth / columns (minus gaps).
|
|
46
|
+
*
|
|
47
|
+
* Must be a positive integer ≥ 1.
|
|
48
|
+
*/
|
|
49
|
+
columns: number;
|
|
50
|
+
/**
|
|
51
|
+
* Gap between grid items in pixels (default: 0).
|
|
52
|
+
* Applied both horizontally (between columns) and vertically (between rows).
|
|
53
|
+
*/
|
|
54
|
+
gap?: number;
|
|
55
|
+
}
|
|
56
|
+
/** Item-specific configuration */
|
|
57
|
+
/** Context provided to height function in grid mode */
|
|
58
|
+
export interface GridHeightContext {
|
|
59
|
+
/** Current container width */
|
|
60
|
+
containerWidth: number;
|
|
61
|
+
/** Number of columns */
|
|
62
|
+
columns: number;
|
|
63
|
+
/** Gap between items in pixels */
|
|
64
|
+
gap: number;
|
|
65
|
+
/** Calculated column width */
|
|
66
|
+
columnWidth: number;
|
|
67
|
+
}
|
|
68
|
+
export interface ItemConfig<T extends VListItem = VListItem> {
|
|
69
|
+
/**
|
|
70
|
+
* Item height in pixels (required for vertical scrolling, cross-axis size for horizontal)
|
|
71
|
+
*
|
|
72
|
+
* - `number` — Fixed height for all items (fast path, zero overhead)
|
|
73
|
+
* - `(index: number) => number` — Variable height per item (prefix-sum based lookups)
|
|
74
|
+
* - `(index: number, context?: GridHeightContext) => number` — Dynamic height based on grid state
|
|
75
|
+
*
|
|
76
|
+
* In grid mode, the height function receives grid context as a second parameter,
|
|
77
|
+
* allowing you to calculate height based on column width to maintain aspect ratios:
|
|
78
|
+
*
|
|
79
|
+
* ```ts
|
|
80
|
+
* height: (index, context) => {
|
|
81
|
+
* if (context) {
|
|
82
|
+
* return context.columnWidth * 0.75; // 4:3 aspect ratio
|
|
83
|
+
* }
|
|
84
|
+
* return 200; // fallback for non-grid
|
|
85
|
+
* }
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* Required when `direction` is `'vertical'` (default).
|
|
89
|
+
* Optional when `direction` is `'horizontal'` (used as cross-axis size).
|
|
90
|
+
*/
|
|
91
|
+
height?: number | ((index: number, context?: GridHeightContext) => number);
|
|
92
|
+
/**
|
|
93
|
+
* Item width in pixels (required for horizontal scrolling)
|
|
94
|
+
*
|
|
95
|
+
* - `number` — Fixed width for all items (fast path, zero overhead)
|
|
96
|
+
* - `(index: number) => number` — Variable width per item (prefix-sum based lookups)
|
|
97
|
+
*
|
|
98
|
+
* Required when `direction` is `'horizontal'`.
|
|
99
|
+
* Ignored when `direction` is `'vertical'` (default).
|
|
100
|
+
*/
|
|
101
|
+
width?: number | ((index: number) => number);
|
|
102
|
+
/** Template function to render each item */
|
|
103
|
+
template: ItemTemplate<T>;
|
|
104
|
+
}
|
|
105
|
+
/** Main configuration for createVList */
|
|
106
|
+
export interface VListConfig<T extends VListItem = VListItem> {
|
|
107
|
+
/** Container element or selector */
|
|
108
|
+
container: HTMLElement | string;
|
|
109
|
+
/**
|
|
110
|
+
* Scroll direction (default: 'vertical').
|
|
111
|
+
*
|
|
112
|
+
* - `'vertical'` — Standard top-to-bottom scrolling (default)
|
|
113
|
+
* - `'horizontal'` — Left-to-right scrolling (carousel, timeline, etc.)
|
|
114
|
+
*
|
|
115
|
+
* When `'horizontal'`:
|
|
116
|
+
* - `item.width` is required (main-axis size for virtualization)
|
|
117
|
+
* - `item.height` is optional (cross-axis size, can be set via CSS)
|
|
118
|
+
* - Items are positioned with `translateX` instead of `translateY`
|
|
119
|
+
* - The viewport scrolls on the X axis
|
|
120
|
+
*
|
|
121
|
+
* Cannot be combined with `groups`, `grid`, or `reverse`.
|
|
122
|
+
*/
|
|
123
|
+
direction?: "vertical" | "horizontal";
|
|
124
|
+
/** Item configuration (height and template) */
|
|
125
|
+
item: ItemConfig<T>;
|
|
126
|
+
/** Static items array (optional if using adapter) */
|
|
127
|
+
items?: T[];
|
|
128
|
+
/** Async data adapter for infinite scroll */
|
|
129
|
+
adapter?: VListAdapter<T>;
|
|
130
|
+
/** Number of extra items to render outside viewport (default: 3) */
|
|
131
|
+
overscan?: number;
|
|
132
|
+
/** Selection configuration */
|
|
133
|
+
selection?: SelectionConfig;
|
|
134
|
+
/**
|
|
135
|
+
* External scroll element for document/window scrolling.
|
|
136
|
+
* @deprecated Use `scroll.element` instead.
|
|
137
|
+
*/
|
|
138
|
+
scrollElement?: Window;
|
|
139
|
+
/** Scroll behavior configuration */
|
|
140
|
+
scroll?: ScrollConfig;
|
|
141
|
+
/**
|
|
142
|
+
* Custom scrollbar configuration.
|
|
143
|
+
* @deprecated Use `scroll.scrollbar` instead.
|
|
144
|
+
*/
|
|
145
|
+
scrollbar?: ScrollbarConfig;
|
|
146
|
+
/** Loading behavior configuration */
|
|
147
|
+
loading?: LoadingConfig;
|
|
148
|
+
/**
|
|
149
|
+
* Scroll idle detection timeout in ms (default: 150).
|
|
150
|
+
* @deprecated Use `scroll.idleTimeout` instead.
|
|
151
|
+
*/
|
|
152
|
+
idleTimeout?: number;
|
|
153
|
+
/** Custom CSS class prefix (default: 'vlist') */
|
|
154
|
+
classPrefix?: string;
|
|
155
|
+
/** Accessible label for the listbox (sets aria-label on the root element) */
|
|
156
|
+
ariaLabel?: string;
|
|
157
|
+
/**
|
|
158
|
+
* Groups configuration for sticky headers / grouped lists.
|
|
159
|
+
* When set, items are automatically grouped and section headers
|
|
160
|
+
* are inserted at group boundaries.
|
|
161
|
+
*
|
|
162
|
+
* Items MUST be pre-sorted by group — a new header is inserted
|
|
163
|
+
* whenever `getGroupForIndex` returns a different value.
|
|
164
|
+
*/
|
|
165
|
+
groups?: GroupsConfig;
|
|
166
|
+
/**
|
|
167
|
+
* Layout mode (default: 'list').
|
|
168
|
+
* - `'list'` — Standard vertical list (one item per row)
|
|
169
|
+
* - `'grid'` — 2D grid layout (multiple items per row, requires `grid` config)
|
|
170
|
+
*
|
|
171
|
+
* In grid mode:
|
|
172
|
+
* - Virtualization operates on ROWS, not individual items
|
|
173
|
+
* - Each row contains `grid.columns` items side by side
|
|
174
|
+
* - Item width is automatically calculated: (containerWidth - gaps) / columns
|
|
175
|
+
* - Compression applies to row count, not item count
|
|
176
|
+
*/
|
|
177
|
+
layout?: "list" | "grid";
|
|
178
|
+
/**
|
|
179
|
+
* Grid configuration (required when `layout: 'grid'`).
|
|
180
|
+
*
|
|
181
|
+
* ```ts
|
|
182
|
+
* createVList({
|
|
183
|
+
* container: '#gallery',
|
|
184
|
+
* layout: 'grid',
|
|
185
|
+
* grid: { columns: 4, gap: 8 },
|
|
186
|
+
* item: {
|
|
187
|
+
* height: 200,
|
|
188
|
+
* template: (item) => `<img src="${item.thumbnail}" />`,
|
|
189
|
+
* },
|
|
190
|
+
* items: photos,
|
|
191
|
+
* });
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
grid?: GridConfig;
|
|
195
|
+
/**
|
|
196
|
+
* Reverse mode for chat-style UIs.
|
|
197
|
+
* When enabled:
|
|
198
|
+
* - The list starts scrolled to the bottom (newest items visible)
|
|
199
|
+
* - `appendItems()` auto-scrolls to bottom if the user was already at bottom
|
|
200
|
+
* - `prependItems()` preserves scroll position (older messages load above without jumping)
|
|
201
|
+
* - With an adapter, "load more" triggers near the TOP (loading older content)
|
|
202
|
+
*
|
|
203
|
+
* Items stay in chronological order (oldest = index 0, newest = last).
|
|
204
|
+
* Cannot be combined with `groups` or `grid` layout.
|
|
205
|
+
*
|
|
206
|
+
* ```ts
|
|
207
|
+
* const chat = createVList({
|
|
208
|
+
* container: '#messages',
|
|
209
|
+
* reverse: true,
|
|
210
|
+
* item: { height: 60, template: messageTemplate },
|
|
211
|
+
* items: messages,
|
|
212
|
+
* });
|
|
213
|
+
*
|
|
214
|
+
* chat.appendItems([newMessage]); // auto-scrolls to bottom
|
|
215
|
+
* chat.prependItems(olderMessages); // scroll position preserved
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
reverse?: boolean;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Configuration options that can be updated dynamically without recreating the instance.
|
|
222
|
+
* Used by the update() method.
|
|
223
|
+
*/
|
|
224
|
+
export interface VListUpdateConfig {
|
|
225
|
+
/**
|
|
226
|
+
* Grid configuration (columns and gap).
|
|
227
|
+
* Only applicable when layout is 'grid'.
|
|
228
|
+
*/
|
|
229
|
+
grid?: {
|
|
230
|
+
columns?: number;
|
|
231
|
+
gap?: number;
|
|
232
|
+
};
|
|
233
|
+
/**
|
|
234
|
+
* Item height (for variable height updates).
|
|
235
|
+
* Can be a number or a function.
|
|
236
|
+
*/
|
|
237
|
+
itemHeight?: number | ((index: number) => number);
|
|
238
|
+
/**
|
|
239
|
+
* Selection mode.
|
|
240
|
+
* Changes selection behavior without recreating the list.
|
|
241
|
+
*/
|
|
242
|
+
selectionMode?: SelectionMode;
|
|
243
|
+
/**
|
|
244
|
+
* Overscan value (number of items to render outside viewport).
|
|
245
|
+
*/
|
|
246
|
+
overscan?: number;
|
|
247
|
+
}
|
|
248
|
+
/** Loading behavior configuration */
|
|
249
|
+
export interface LoadingConfig {
|
|
250
|
+
/**
|
|
251
|
+
* Velocity threshold above which data loading is skipped (px/ms)
|
|
252
|
+
* When scrolling faster than this, loading is deferred until scroll stops.
|
|
253
|
+
* Default: 25 px/ms
|
|
254
|
+
*/
|
|
255
|
+
cancelThreshold?: number;
|
|
256
|
+
/**
|
|
257
|
+
* Velocity threshold for preloading (px/ms)
|
|
258
|
+
* When scrolling faster than this but slower than cancelThreshold,
|
|
259
|
+
* extra items are preloaded in the scroll direction.
|
|
260
|
+
* Default: 2 px/ms
|
|
261
|
+
*/
|
|
262
|
+
preloadThreshold?: number;
|
|
263
|
+
/**
|
|
264
|
+
* Number of extra items to preload ahead of scroll direction
|
|
265
|
+
* Only applies when velocity is between preloadThreshold and cancelThreshold.
|
|
266
|
+
* Default: 50 items
|
|
267
|
+
*/
|
|
268
|
+
preloadAhead?: number;
|
|
269
|
+
}
|
|
270
|
+
/** Scroll position snapshot for save/restore */
|
|
271
|
+
export interface ScrollSnapshot {
|
|
272
|
+
/** First visible item index */
|
|
273
|
+
index: number;
|
|
274
|
+
/** Pixel offset within the first visible item (how far it's scrolled off) */
|
|
275
|
+
offsetInItem: number;
|
|
276
|
+
/** Selected item IDs (optional, included for convenience) */
|
|
277
|
+
selectedIds?: Array<string | number>;
|
|
278
|
+
}
|
|
279
|
+
/** Options for scrollToIndex / scrollToItem */
|
|
280
|
+
export interface ScrollToOptions {
|
|
281
|
+
/** Alignment within the viewport (default: 'start') */
|
|
282
|
+
align?: "start" | "center" | "end";
|
|
283
|
+
/** Scroll behavior (default: 'auto' = instant) */
|
|
284
|
+
behavior?: "auto" | "smooth";
|
|
285
|
+
/** Animation duration in ms (default: 300, only used with behavior: 'smooth') */
|
|
286
|
+
duration?: number;
|
|
287
|
+
}
|
|
288
|
+
/** Scroll behavior configuration */
|
|
289
|
+
export interface ScrollConfig {
|
|
290
|
+
/** Enable mouse wheel scrolling (default: true) */
|
|
291
|
+
wheel?: boolean;
|
|
292
|
+
/**
|
|
293
|
+
* Wrap around when scrolling past boundaries (default: false).
|
|
294
|
+
*
|
|
295
|
+
* When `true`, `scrollToIndex` wraps around:
|
|
296
|
+
* - Index past the last item → wraps to the beginning
|
|
297
|
+
* - Negative index → wraps from the end
|
|
298
|
+
*
|
|
299
|
+
* Useful for carousels, wizards, and circular navigation.
|
|
300
|
+
*/
|
|
301
|
+
wrap?: boolean;
|
|
302
|
+
/**
|
|
303
|
+
* Scrollbar mode (default: custom scrollbar).
|
|
304
|
+
*
|
|
305
|
+
* - *omitted* — Custom scrollbar (default), native scrollbar hidden via CSS
|
|
306
|
+
* - `'native'` — Browser native scrollbar (falls back to custom in compressed mode)
|
|
307
|
+
* - `'none'` — No scrollbar at all (native hidden, custom not created)
|
|
308
|
+
* - `ScrollbarOptions` — Custom scrollbar with fine-tuning options
|
|
309
|
+
*/
|
|
310
|
+
scrollbar?: "native" | "none" | ScrollbarOptions;
|
|
311
|
+
/** External scroll element for window scrolling */
|
|
312
|
+
element?: Window;
|
|
313
|
+
/** Scroll idle detection timeout in ms (default: 150) */
|
|
314
|
+
idleTimeout?: number;
|
|
315
|
+
}
|
|
316
|
+
/** Custom scrollbar fine-tuning options */
|
|
317
|
+
export interface ScrollbarOptions {
|
|
318
|
+
/** Auto-hide scrollbar after idle (default: true) */
|
|
319
|
+
autoHide?: boolean;
|
|
320
|
+
/** Auto-hide delay in milliseconds (default: 1000) */
|
|
321
|
+
autoHideDelay?: number;
|
|
322
|
+
/** Minimum thumb size in pixels (default: 30) */
|
|
323
|
+
minThumbSize?: number;
|
|
324
|
+
/**
|
|
325
|
+
* Show scrollbar when hovering near the scrollbar edge (default: true).
|
|
326
|
+
* When true, an invisible hover zone is placed along the scrollbar edge.
|
|
327
|
+
* Moving the mouse into this zone reveals the scrollbar; it stays visible
|
|
328
|
+
* as long as the cursor remains over the zone or the track.
|
|
329
|
+
*/
|
|
330
|
+
showOnHover?: boolean;
|
|
331
|
+
/**
|
|
332
|
+
* Width of the invisible hover zone in pixels (default: 16).
|
|
333
|
+
* Only used when `showOnHover` is true.
|
|
334
|
+
* A wider zone makes the scrollbar easier to discover;
|
|
335
|
+
* a narrower zone avoids interference with content near the edge.
|
|
336
|
+
*/
|
|
337
|
+
hoverZoneWidth?: number;
|
|
338
|
+
/**
|
|
339
|
+
* Show scrollbar when the mouse enters the list viewport (default: true).
|
|
340
|
+
* When false, the scrollbar only appears on scroll or when hovering
|
|
341
|
+
* near the scrollbar edge (if `showOnHover` is true).
|
|
342
|
+
*/
|
|
343
|
+
showOnViewportEnter?: boolean;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Scrollbar configuration.
|
|
347
|
+
* @deprecated Use `scroll.scrollbar` in `ScrollConfig` instead.
|
|
348
|
+
*/
|
|
349
|
+
export interface ScrollbarConfig {
|
|
350
|
+
/** Enable scrollbar (default: true) */
|
|
351
|
+
enabled?: boolean;
|
|
352
|
+
/** Auto-hide scrollbar after idle (default: true) */
|
|
353
|
+
autoHide?: boolean;
|
|
354
|
+
/** Auto-hide delay in milliseconds (default: 1000) */
|
|
355
|
+
autoHideDelay?: number;
|
|
356
|
+
/** Minimum thumb size in pixels (default: 30) */
|
|
357
|
+
minThumbSize?: number;
|
|
358
|
+
}
|
|
359
|
+
/** Item template function */
|
|
360
|
+
export type ItemTemplate<T = VListItem> = (item: T, index: number, state: ItemState) => string | HTMLElement;
|
|
361
|
+
/** State passed to template */
|
|
362
|
+
export interface ItemState {
|
|
363
|
+
selected: boolean;
|
|
364
|
+
focused: boolean;
|
|
365
|
+
}
|
|
366
|
+
/** Selection mode */
|
|
367
|
+
export type SelectionMode = "none" | "single" | "multiple";
|
|
368
|
+
/** Selection configuration */
|
|
369
|
+
export interface SelectionConfig {
|
|
370
|
+
/** Selection mode (default: 'none') */
|
|
371
|
+
mode?: SelectionMode;
|
|
372
|
+
/** Initially selected item IDs */
|
|
373
|
+
initial?: Array<string | number>;
|
|
374
|
+
}
|
|
375
|
+
/** Selection state */
|
|
376
|
+
export interface SelectionState {
|
|
377
|
+
/** Currently selected item IDs */
|
|
378
|
+
selected: Set<string | number>;
|
|
379
|
+
/** Currently focused item index (-1 if none) */
|
|
380
|
+
focusedIndex: number;
|
|
381
|
+
}
|
|
382
|
+
/** Adapter for async data loading */
|
|
383
|
+
export interface VListAdapter<T extends VListItem = VListItem> {
|
|
384
|
+
/** Fetch items for a range */
|
|
385
|
+
read: (params: AdapterParams) => Promise<AdapterResponse<T>>;
|
|
386
|
+
}
|
|
387
|
+
/** Parameters passed to adapter.read */
|
|
388
|
+
export interface AdapterParams {
|
|
389
|
+
/** Starting offset */
|
|
390
|
+
offset: number;
|
|
391
|
+
/** Number of items to fetch */
|
|
392
|
+
limit: number;
|
|
393
|
+
/** Optional cursor for cursor-based pagination */
|
|
394
|
+
cursor: string | undefined;
|
|
395
|
+
}
|
|
396
|
+
/** Response from adapter.read */
|
|
397
|
+
export interface AdapterResponse<T extends VListItem = VListItem> {
|
|
398
|
+
/** Fetched items */
|
|
399
|
+
items: T[];
|
|
400
|
+
/** Total count (if known) */
|
|
401
|
+
total?: number;
|
|
402
|
+
/** Next cursor (for cursor-based pagination) */
|
|
403
|
+
cursor?: string;
|
|
404
|
+
/** Whether more items exist */
|
|
405
|
+
hasMore?: boolean;
|
|
406
|
+
}
|
|
407
|
+
/** Visible range of items */
|
|
408
|
+
export interface Range {
|
|
409
|
+
start: number;
|
|
410
|
+
end: number;
|
|
411
|
+
}
|
|
412
|
+
/** Viewport state */
|
|
413
|
+
export interface ViewportState {
|
|
414
|
+
/** Current scroll position */
|
|
415
|
+
scrollTop: number;
|
|
416
|
+
/** Container height */
|
|
417
|
+
containerHeight: number;
|
|
418
|
+
/** Total content height (may be capped for compression) */
|
|
419
|
+
totalHeight: number;
|
|
420
|
+
/** Actual total height without compression (totalItems × itemHeight) */
|
|
421
|
+
actualHeight: number;
|
|
422
|
+
/** Whether compression is active */
|
|
423
|
+
isCompressed: boolean;
|
|
424
|
+
/** Compression ratio (1 = no compression, <1 = compressed) */
|
|
425
|
+
compressionRatio: number;
|
|
426
|
+
/** Visible item range */
|
|
427
|
+
visibleRange: Range;
|
|
428
|
+
/** Render range (includes overscan) */
|
|
429
|
+
renderRange: Range;
|
|
430
|
+
}
|
|
431
|
+
/** Event types and their payloads */
|
|
432
|
+
export interface VListEvents<T extends VListItem = VListItem> extends EventMap {
|
|
433
|
+
/** Item clicked */
|
|
434
|
+
"item:click": {
|
|
435
|
+
item: T;
|
|
436
|
+
index: number;
|
|
437
|
+
event: MouseEvent;
|
|
438
|
+
};
|
|
439
|
+
/** Item double-clicked */
|
|
440
|
+
"item:dblclick": {
|
|
441
|
+
item: T;
|
|
442
|
+
index: number;
|
|
443
|
+
event: MouseEvent;
|
|
444
|
+
};
|
|
445
|
+
/** Selection changed */
|
|
446
|
+
"selection:change": {
|
|
447
|
+
selected: Array<string | number>;
|
|
448
|
+
items: T[];
|
|
449
|
+
};
|
|
450
|
+
/** Scroll position changed */
|
|
451
|
+
scroll: {
|
|
452
|
+
scrollTop: number;
|
|
453
|
+
direction: "up" | "down";
|
|
454
|
+
};
|
|
455
|
+
/** Scroll velocity changed */
|
|
456
|
+
"velocity:change": {
|
|
457
|
+
velocity: number;
|
|
458
|
+
reliable: boolean;
|
|
459
|
+
};
|
|
460
|
+
/** Visible range changed */
|
|
461
|
+
"range:change": {
|
|
462
|
+
range: Range;
|
|
463
|
+
};
|
|
464
|
+
/** Data loading started */
|
|
465
|
+
"load:start": {
|
|
466
|
+
offset: number;
|
|
467
|
+
limit: number;
|
|
468
|
+
};
|
|
469
|
+
/** Data loading completed */
|
|
470
|
+
"load:end": {
|
|
471
|
+
items: T[];
|
|
472
|
+
total?: number;
|
|
473
|
+
};
|
|
474
|
+
/** Error occurred */
|
|
475
|
+
error: {
|
|
476
|
+
error: Error;
|
|
477
|
+
context: string;
|
|
478
|
+
};
|
|
479
|
+
/** Container resized */
|
|
480
|
+
resize: {
|
|
481
|
+
height: number;
|
|
482
|
+
width: number;
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
/** Event handler type */
|
|
486
|
+
export type EventHandler<T> = (payload: T) => void;
|
|
487
|
+
/** Unsubscribe function */
|
|
488
|
+
export type Unsubscribe = () => void;
|
|
489
|
+
/** VList instance API */
|
|
490
|
+
export interface VList<T extends VListItem = VListItem> {
|
|
491
|
+
/** The root DOM element */
|
|
492
|
+
readonly element: HTMLElement;
|
|
493
|
+
/** Current items */
|
|
494
|
+
readonly items: readonly T[];
|
|
495
|
+
/** Total item count */
|
|
496
|
+
readonly total: number;
|
|
497
|
+
/** Set items (replaces all) */
|
|
498
|
+
setItems: (items: T[]) => void;
|
|
499
|
+
/** Append items */
|
|
500
|
+
appendItems: (items: T[]) => void;
|
|
501
|
+
/** Prepend items */
|
|
502
|
+
prependItems: (items: T[]) => void;
|
|
503
|
+
/** Update a single item by ID */
|
|
504
|
+
updateItem: (id: string | number, updates: Partial<T>) => void;
|
|
505
|
+
/** Remove item by ID */
|
|
506
|
+
removeItem: (id: string | number) => void;
|
|
507
|
+
/** Reload data (clears and re-fetches if using adapter) */
|
|
508
|
+
reload: () => Promise<void>;
|
|
509
|
+
/** Update configuration without recreating the instance */
|
|
510
|
+
update: (config: Partial<VListUpdateConfig>) => void;
|
|
511
|
+
/** Scroll to specific index */
|
|
512
|
+
scrollToIndex: (index: number, alignOrOptions?: "start" | "center" | "end" | ScrollToOptions) => void;
|
|
513
|
+
/** Scroll to specific item by ID */
|
|
514
|
+
scrollToItem: (id: string | number, alignOrOptions?: "start" | "center" | "end" | ScrollToOptions) => void;
|
|
515
|
+
/** Cancel any in-progress smooth scroll animation */
|
|
516
|
+
cancelScroll: () => void;
|
|
517
|
+
/** Get current scroll position */
|
|
518
|
+
getScrollPosition: () => number;
|
|
519
|
+
/** Get a snapshot of the current scroll position for save/restore */
|
|
520
|
+
getScrollSnapshot: () => ScrollSnapshot;
|
|
521
|
+
/** Restore scroll position (and optionally selection) from a snapshot */
|
|
522
|
+
restoreScroll: (snapshot: ScrollSnapshot) => void;
|
|
523
|
+
/** Select item(s) by ID */
|
|
524
|
+
select: (...ids: Array<string | number>) => void;
|
|
525
|
+
/** Deselect item(s) by ID */
|
|
526
|
+
deselect: (...ids: Array<string | number>) => void;
|
|
527
|
+
/** Toggle selection */
|
|
528
|
+
toggleSelect: (id: string | number) => void;
|
|
529
|
+
/** Select all items */
|
|
530
|
+
selectAll: () => void;
|
|
531
|
+
/** Clear selection */
|
|
532
|
+
clearSelection: () => void;
|
|
533
|
+
/** Get selected item IDs */
|
|
534
|
+
getSelected: () => Array<string | number>;
|
|
535
|
+
/** Get selected items */
|
|
536
|
+
getSelectedItems: () => T[];
|
|
537
|
+
/** Subscribe to an event */
|
|
538
|
+
on: <K extends keyof VListEvents<T>>(event: K, handler: EventHandler<VListEvents<T>[K]>) => Unsubscribe;
|
|
539
|
+
/** Unsubscribe from an event */
|
|
540
|
+
off: <K extends keyof VListEvents<T>>(event: K, handler: EventHandler<VListEvents<T>[K]>) => void;
|
|
541
|
+
/** Destroy the instance and cleanup */
|
|
542
|
+
destroy: () => void;
|
|
543
|
+
}
|
|
544
|
+
/** Internal state */
|
|
545
|
+
export interface InternalState<T extends VListItem = VListItem> {
|
|
546
|
+
items: T[];
|
|
547
|
+
total: number;
|
|
548
|
+
viewport: ViewportState;
|
|
549
|
+
selection: SelectionState;
|
|
550
|
+
isLoading: boolean;
|
|
551
|
+
cursor?: string;
|
|
552
|
+
hasMore: boolean;
|
|
553
|
+
}
|
|
554
|
+
/** Rendered item tracking */
|
|
555
|
+
export interface RenderedItem {
|
|
556
|
+
index: number;
|
|
557
|
+
element: HTMLElement;
|
|
558
|
+
}
|
|
559
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","source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B,gBAAgB,EAAE,MAAM,CAAC,EAAE,CAAC;IAG5B,4BAA4B;IAC5B,EAAE,EAAE,CAAC,CAAC,SAAS,MAAM,WAAW,CAAC,CAAC,CAAC,EACjC,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KACrC,WAAW,CAAC;IAEjB,gCAAgC;IAChC,GAAG,EAAE,CAAC,CAAC,SAAS,MAAM,WAAW,CAAC,CAAC,CAAC,EAClC,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KACrC,IAAI,CAAC;IAGV,uCAAuC;IACvC,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAMD,qBAAqB;AACrB,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS;IAC5D,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,aAAa,CAAC;IACxB,SAAS,EAAE,cAAc,CAAC;IAC1B,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,6BAA6B;AAC7B,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,WAAW,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.vlist--compact .vlist-item{padding:0.5rem 0.75rem}.vlist--compact .vlist-item--selected{padding-left:calc(0.75rem - 4px)}.vlist--comfortable .vlist-item{padding:1rem 1.25rem}.vlist--comfortable .vlist-item--selected{padding-left:calc(1.25rem - 4px)}.vlist--borderless{border:none;border-radius:0}.vlist--borderless .vlist-item{border-bottom:none}.vlist--striped .vlist-item:nth-child(even){background-color:var(--vlist-bg-hover)}.vlist--striped .vlist-item:nth-child(even):hover{background-color:var(--vlist-bg-selected)}.vlist-loading{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background-color:rgba(255,255,255,0.8);backdrop-filter:blur(4px);z-index:20}.dark .vlist-loading{background-color:rgba(17,24,39,0.8)}.vlist-loading-spinner{width:2rem;height:2rem;border:4px solid var(--vlist-border);border-top-color:var(--vlist-focus-ring);border-radius:50%;animation:vlist-spin 1s linear infinite}@keyframes vlist-spin{to{transform:rotate(360deg)}}.vlist-empty{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;color:var(--vlist-text-muted);padding:2rem;text-align:center}.vlist-empty-icon{width:3rem;height:3rem;margin-bottom:1rem;opacity:0.5}.vlist-empty-text{font-size:1.125rem;font-weight:500}.vlist-empty-subtext{font-size:0.875rem;margin-top:0.25rem;opacity:0.75}.vlist-scrollbar-hide{scrollbar-width:none;-ms-overflow-style:none}.vlist-scrollbar-hide::-webkit-scrollbar{display:none}@keyframes vlist-fade-in{from{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}.vlist-item--enter{animation:vlist-fade-in 0.2s ease-out}.vlist--animate .vlist-item{transition:background-color var(--vlist-transition-duration) var(--vlist-transition-timing),transform 0.2s ease-out,opacity 0.2s ease-out}
|
package/dist/vlist.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:root{--vlist-bg:#ffffff;--vlist-bg-hover:#f9fafb;--vlist-bg-selected:#eff6ff;--vlist-bg-selected-hover:#dbeafe;--vlist-border:#e5e7eb;--vlist-border-selected:#3b82f6;--vlist-text:#111827;--vlist-text-muted:#6b7280;--vlist-focus-ring:#3b82f6;--vlist-scrollbar-thumb:#d1d5db;--vlist-scrollbar-thumb-hover:#9ca3af;--vlist-scrollbar-width:8px;--vlist-scrollbar-track-bg:transparent;--vlist-scrollbar-custom-thumb-bg:rgba(0,0,0,0.3);--vlist-scrollbar-custom-thumb-hover-bg:rgba(0,0,0,0.5);--vlist-scrollbar-custom-thumb-radius:4px;--vlist-item-padding-x:1rem;--vlist-item-padding-y:0.75rem;--vlist-border-radius:0.5rem;--vlist-transition-duration:150ms;--vlist-transition-timing:ease-in-out}@media (prefers-color-scheme:dark){:root{--vlist-bg:#111827;--vlist-bg-hover:#1f2937;--vlist-bg-selected:rgba(59,130,246,0.2);--vlist-bg-selected-hover:rgba(59,130,246,0.3);--vlist-border:#374151;--vlist-border-selected:#3b82f6;--vlist-text:#f9fafb;--vlist-text-muted:#9ca3af;--vlist-scrollbar-thumb:#4b5563;--vlist-scrollbar-thumb-hover:#6b7280;--vlist-scrollbar-custom-thumb-bg:rgba(255,255,255,0.3);--vlist-scrollbar-custom-thumb-hover-bg:rgba(255,255,255,0.5)}}.dark{--vlist-bg:#111827;--vlist-bg-hover:#1f2937;--vlist-bg-selected:rgba(59,130,246,0.2);--vlist-bg-selected-hover:rgba(59,130,246,0.3);--vlist-border:#374151;--vlist-border-selected:#3b82f6;--vlist-text:#f9fafb;--vlist-text-muted:#9ca3af;--vlist-scrollbar-thumb:#4b5563;--vlist-scrollbar-thumb-hover:#6b7280;--vlist-scrollbar-custom-thumb-bg:rgba(255,255,255,0.3);--vlist-scrollbar-custom-thumb-hover-bg:rgba(255,255,255,0.5)}.vlist{position:relative;width:100%;height:100%;overflow:hidden;background-color:var(--vlist-bg);color:var(--vlist-text);border:1px solid var(--vlist-border);border-radius:var(--vlist-border-radius);outline:none}.vlist:focus{outline:none}.vlist:focus-visible{outline:2px solid var(--vlist-focus-ring);outline-offset:2px}.vlist-viewport{width:100%;height:100%;overflow:auto;scrollbar-width:thin;scrollbar-color:var(--vlist-scrollbar-thumb) transparent}.vlist-viewport::-webkit-scrollbar{width:6px;height:6px}.vlist-viewport::-webkit-scrollbar-track{background:transparent}.vlist-viewport::-webkit-scrollbar-thumb{background-color:var(--vlist-scrollbar-thumb);border-radius:3px}.vlist-viewport::-webkit-scrollbar-thumb:hover{background-color:var(--vlist-scrollbar-thumb-hover)}.vlist-content{position:relative;width:100%}.vlist-items{position:relative;width:100%;contain:layout style}.vlist-item{position:absolute;top:0;left:0;right:0;display:flex;align-items:center;padding:var(--vlist-item-padding-y) var(--vlist-item-padding-x);border-bottom:1px solid var(--vlist-border);background-color:var(--vlist-bg);cursor:pointer;user-select:none;transition:background-color var(--vlist-transition-duration) var(--vlist-transition-timing);contain:content;box-sizing:border-box}.vlist--scrolling .vlist-item{transition:none}.vlist-item:hover{background-color:var(--vlist-bg-hover)}.vlist-item--selected{background-color:var(--vlist-bg-selected)}.vlist-item--selected:hover{background-color:var(--vlist-bg-selected-hover)}.vlist-item--focused-visible{outline:2px solid var(--vlist-focus-ring);outline-offset:-2px;z-index:1}.vlist-item--selected.vlist-item--focused{outline-color:var(--vlist-border-selected)}.vlist-scrollbar{position:absolute;top:0;right:0;width:var(--vlist-scrollbar-width);height:100%;background-color:var(--vlist-scrollbar-track-bg);opacity:0;transition:opacity 0.2s ease-out;z-index:10;pointer-events:none}.vlist-scrollbar-hover{position:absolute;top:0;right:0;height:100%;z-index:9;pointer-events:auto}.vlist-scrollbar-hover--horizontal{top:auto;right:auto;bottom:0;left:0;width:100%;height:auto}.vlist-scrollbar--visible{opacity:1;pointer-events:auto}.vlist-scrollbar-thumb{position:absolute;top:0;left:0;right:0;width:100%;background-color:var(--vlist-scrollbar-custom-thumb-bg);border-radius:var(--vlist-scrollbar-custom-thumb-radius);cursor:pointer;transition:background-color 0.15s ease-out}.vlist-scrollbar-thumb:hover{background-color:var(--vlist-scrollbar-custom-thumb-hover-bg)}.vlist-scrollbar--dragging{opacity:1;pointer-events:auto}.vlist-scrollbar--dragging .vlist-scrollbar-thumb{background-color:var(--vlist-scrollbar-custom-thumb-hover-bg)}.vlist--grouped .vlist-item[data-id^="__group_header_"]{cursor:default;background-color:var(--vlist-group-header-bg,#f3f4f6);border-bottom:1px solid var(--vlist-border);z-index:1}.vlist--grouped .vlist-item[data-id^="__group_header_"]:hover{background-color:var(--vlist-group-header-bg,#f3f4f6)}.vlist-sticky-header{background-color:var(--vlist-group-header-bg,#f3f4f6);border-bottom:1px solid var(--vlist-border);contain:content}@media (prefers-color-scheme:dark){:root{--vlist-group-header-bg:#1e2433}}.dark{--vlist-group-header-bg:#1e2433}.vlist--scrolling .vlist-sticky-header{transition:none}.vlist--grid .vlist-items{contain:layout style}.vlist-grid-item{position:absolute;top:0;left:0;display:flex;align-items:center;justify-content:center;padding:var(--vlist-item-padding-y) var(--vlist-item-padding-x);background-color:var(--vlist-bg);cursor:pointer;user-select:none;transition:background-color var(--vlist-transition-duration) var(--vlist-transition-timing);contain:content;box-sizing:border-box;overflow:hidden}.vlist--grid .vlist-item{right:auto;border-bottom:none}.vlist--scrolling .vlist-grid-item{transition:none}.vlist-grid-item:hover{background-color:var(--vlist-bg-hover)}.vlist-grid-item.vlist-item--selected{background-color:var(--vlist-bg-selected)}.vlist-grid-item.vlist-item--selected:hover{background-color:var(--vlist-bg-selected-hover)}.vlist-grid-item.vlist-item--focused-visible{outline:2px solid var(--vlist-focus-ring);outline-offset:-2px;z-index:1}.vlist--horizontal{overflow:hidden}.vlist--horizontal .vlist-viewport{overflow-x:auto;overflow-y:hidden}.vlist--horizontal .vlist-content{height:100%;width:auto}.vlist--horizontal .vlist-items{height:100%;width:auto}.vlist--horizontal .vlist-item{position:absolute;top:0;bottom:0;left:0;right:auto;display:flex;align-items:center;justify-content:center;border-bottom:none;border-right:1px solid var(--vlist-border)}.vlist-scrollbar--horizontal{top:auto;right:auto;bottom:0;left:0;width:100%;height:var(--vlist-scrollbar-width)}.vlist-scrollbar--horizontal .vlist-scrollbar-thumb{top:0;left:0;width:auto;height:100%}.vlist-viewport--custom-scrollbar{scrollbar-width:none;-ms-overflow-style:none}.vlist-viewport--custom-scrollbar::-webkit-scrollbar{display:none}
|
package/dist/vlist.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vlist - Virtual List (Builder-based)
|
|
3
|
+
*
|
|
4
|
+
* This is the new default entry point that uses the builder pattern internally.
|
|
5
|
+
* It provides full backwards compatibility with the monolithic API while maintaining
|
|
6
|
+
* modularity and smaller bundle sizes through automatic plugin application.
|
|
7
|
+
*
|
|
8
|
+
* For the legacy monolithic implementation, use 'vlist/full' instead.
|
|
9
|
+
*/
|
|
10
|
+
import type { VListConfig, VListItem, VList } from "./types";
|
|
11
|
+
/**
|
|
12
|
+
* Create a virtual list instance.
|
|
13
|
+
*
|
|
14
|
+
* This is a convenience wrapper around the builder pattern that automatically
|
|
15
|
+
* includes plugins based on the configuration provided, maintaining full backwards
|
|
16
|
+
* compatibility with the monolithic API.
|
|
17
|
+
*
|
|
18
|
+
* @param config - Virtual list configuration
|
|
19
|
+
* @returns Virtual list instance with full API
|
|
20
|
+
*/
|
|
21
|
+
export declare const createVList: <T extends VListItem = VListItem>(config: VListConfig<T>) => VList<T>;
|
|
22
|
+
//# sourceMappingURL=vlist.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vlist.d.ts","sourceRoot":"","sources":["../src/vlist.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAYH,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAE7D;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,SAAS,GAAG,SAAS,EACzD,QAAQ,WAAW,CAAC,CAAC,CAAC,KACrB,KAAK,CAAC,CAAC,CA6IT,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ref as D,shallowRef as E,onMounted as F,onBeforeUnmount as z,watch as A,isRef as G,unref as H}from"vue";import{createVList as J}from"vlist";function O(q){let x=D(null),k=E(null);if(F(()=>{let j=x.value;if(!j)return;let y=H(q);k.value=J({...y,container:j})}),z(()=>{k.value?.destroy(),k.value=null}),G(q))A(()=>q.value.items,(j)=>{if(k.value&&j)k.value.setItems(j)});return{containerRef:x,instance:k}}function P(q,x,k){let j=null;A(q,(y)=>{if(j)j(),j=null;if(y)j=y.on(x,k)},{immediate:!0}),z(()=>{if(j)j(),j=null})}export{P as useVListEvent,O as useVList};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var K=()=>{let E=null;return{name:"withWindow",priority:5,setup(P){let{dom:S,state:k,config:V,emitter:I}=P;S.root.style.overflow="visible",S.root.style.height="auto",S.viewport.classList.remove(`${V.classPrefix}-viewport--custom-scrollbar`),P.disableViewportResize(),P.setScrollTarget(window),P.setScrollFns(()=>{let y=S.viewport.getBoundingClientRect();if(V.horizontal)return Math.max(0,-y.left);else return Math.max(0,-y.top)},(y)=>{let b=S.viewport.getBoundingClientRect();if(V.horizontal){let j=b.left+window.scrollX;window.scrollTo(j+y,window.scrollY)}else{let j=b.top+window.scrollY;window.scrollTo(window.scrollX,j+y)}}),P.setContainerDimensions({width:()=>window.innerWidth,height:()=>window.innerHeight}),k.viewportState.containerWidth=window.innerWidth,k.viewportState.containerHeight=window.innerHeight;let{innerHeight:B,innerWidth:F}=window,G=()=>{let{innerWidth:y,innerHeight:b}=window,j=V.horizontal?y:b,J=V.horizontal?F:B;if(Math.abs(j-J)<=1)return;B=b,F=y,k.viewportState.containerWidth=y,k.viewportState.containerHeight=b,I.emit("resize",{width:y,height:b});for(let q=0;q<P.resizeHandlers.length;q++)P.resizeHandlers[q](y,b);P.renderIfNeeded()};window.addEventListener("resize",G,{passive:!0}),E=()=>{window.removeEventListener("resize",G)},P.destroyHandlers.push(E)},destroy(){if(E)E(),E=null}}};export{K as withWindow};
|