mtrl-addons 0.2.2 → 0.2.3

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.
Files changed (128) hide show
  1. package/{src/components/index.ts → dist/components/index.d.ts} +0 -2
  2. package/dist/components/vlist/config.d.ts +86 -0
  3. package/{src/components/vlist/constants.ts → dist/components/vlist/constants.d.ts} +10 -11
  4. package/dist/components/vlist/features/api.d.ts +7 -0
  5. package/{src/components/vlist/features/index.ts → dist/components/vlist/features/index.d.ts} +0 -2
  6. package/dist/components/vlist/features/selection.d.ts +6 -0
  7. package/dist/components/vlist/features/viewport.d.ts +9 -0
  8. package/dist/components/vlist/features.d.ts +31 -0
  9. package/{src/components/vlist/index.ts → dist/components/vlist/index.d.ts} +1 -10
  10. package/dist/components/vlist/types.d.ts +596 -0
  11. package/dist/components/vlist/vlist.d.ts +29 -0
  12. package/dist/core/compose/features/gestures/index.d.ts +86 -0
  13. package/dist/core/compose/features/gestures/longpress.d.ts +85 -0
  14. package/dist/core/compose/features/gestures/pan.d.ts +108 -0
  15. package/dist/core/compose/features/gestures/pinch.d.ts +111 -0
  16. package/dist/core/compose/features/gestures/rotate.d.ts +111 -0
  17. package/dist/core/compose/features/gestures/swipe.d.ts +149 -0
  18. package/dist/core/compose/features/gestures/tap.d.ts +79 -0
  19. package/{src/core/compose/features/index.ts → dist/core/compose/features/index.d.ts} +1 -2
  20. package/{src/core/compose/index.ts → dist/core/compose/index.d.ts} +2 -11
  21. package/{src/core/gestures/index.ts → dist/core/gestures/index.d.ts} +1 -20
  22. package/dist/core/gestures/longpress.d.ts +23 -0
  23. package/dist/core/gestures/manager.d.ts +14 -0
  24. package/dist/core/gestures/pan.d.ts +12 -0
  25. package/dist/core/gestures/pinch.d.ts +14 -0
  26. package/dist/core/gestures/rotate.d.ts +14 -0
  27. package/dist/core/gestures/swipe.d.ts +20 -0
  28. package/dist/core/gestures/tap.d.ts +12 -0
  29. package/dist/core/gestures/types.d.ts +320 -0
  30. package/dist/core/gestures/utils.d.ts +57 -0
  31. package/dist/core/index.d.ts +13 -0
  32. package/dist/core/layout/config.d.ts +33 -0
  33. package/dist/core/layout/index.d.ts +51 -0
  34. package/dist/core/layout/jsx.d.ts +65 -0
  35. package/dist/core/layout/schema.d.ts +112 -0
  36. package/dist/core/layout/types.d.ts +69 -0
  37. package/dist/core/viewport/constants.d.ts +105 -0
  38. package/dist/core/viewport/features/base.d.ts +14 -0
  39. package/dist/core/viewport/features/collection.d.ts +41 -0
  40. package/dist/core/viewport/features/events.d.ts +13 -0
  41. package/{src/core/viewport/features/index.ts → dist/core/viewport/features/index.d.ts} +0 -7
  42. package/dist/core/viewport/features/item-size.d.ts +30 -0
  43. package/dist/core/viewport/features/loading.d.ts +34 -0
  44. package/dist/core/viewport/features/momentum.d.ts +17 -0
  45. package/dist/core/viewport/features/performance.d.ts +53 -0
  46. package/dist/core/viewport/features/placeholders.d.ts +38 -0
  47. package/dist/core/viewport/features/rendering.d.ts +16 -0
  48. package/dist/core/viewport/features/scrollbar.d.ts +26 -0
  49. package/dist/core/viewport/features/scrolling.d.ts +16 -0
  50. package/dist/core/viewport/features/utils.d.ts +43 -0
  51. package/dist/core/viewport/features/virtual.d.ts +18 -0
  52. package/{src/core/viewport/index.ts → dist/core/viewport/index.d.ts} +1 -17
  53. package/dist/core/viewport/types.d.ts +96 -0
  54. package/dist/core/viewport/utils/speed-tracker.d.ts +22 -0
  55. package/dist/core/viewport/viewport.d.ts +11 -0
  56. package/{src/index.ts → dist/index.d.ts} +0 -4
  57. package/dist/index.js +5143 -0
  58. package/dist/index.mjs +5111 -0
  59. package/dist/styles.css +254 -0
  60. package/dist/styles.css.map +1 -0
  61. package/package.json +5 -1
  62. package/.cursorrules +0 -117
  63. package/AI.md +0 -39
  64. package/CLAUDE.md +0 -882
  65. package/build.js +0 -377
  66. package/scripts/analyze-orphaned-functions.ts +0 -387
  67. package/scripts/debug/vlist-selection.ts +0 -121
  68. package/src/components/vlist/config.ts +0 -323
  69. package/src/components/vlist/features/api.ts +0 -626
  70. package/src/components/vlist/features/selection.ts +0 -436
  71. package/src/components/vlist/features/viewport.ts +0 -59
  72. package/src/components/vlist/features.ts +0 -112
  73. package/src/components/vlist/types.ts +0 -723
  74. package/src/components/vlist/vlist.ts +0 -92
  75. package/src/core/compose/features/gestures/index.ts +0 -227
  76. package/src/core/compose/features/gestures/longpress.ts +0 -383
  77. package/src/core/compose/features/gestures/pan.ts +0 -424
  78. package/src/core/compose/features/gestures/pinch.ts +0 -475
  79. package/src/core/compose/features/gestures/rotate.ts +0 -485
  80. package/src/core/compose/features/gestures/swipe.ts +0 -492
  81. package/src/core/compose/features/gestures/tap.ts +0 -334
  82. package/src/core/gestures/longpress.ts +0 -68
  83. package/src/core/gestures/manager.ts +0 -418
  84. package/src/core/gestures/pan.ts +0 -48
  85. package/src/core/gestures/pinch.ts +0 -58
  86. package/src/core/gestures/rotate.ts +0 -58
  87. package/src/core/gestures/swipe.ts +0 -66
  88. package/src/core/gestures/tap.ts +0 -45
  89. package/src/core/gestures/types.ts +0 -387
  90. package/src/core/gestures/utils.ts +0 -128
  91. package/src/core/index.ts +0 -43
  92. package/src/core/layout/config.ts +0 -102
  93. package/src/core/layout/index.ts +0 -168
  94. package/src/core/layout/jsx.ts +0 -174
  95. package/src/core/layout/schema.ts +0 -1044
  96. package/src/core/layout/types.ts +0 -95
  97. package/src/core/viewport/constants.ts +0 -145
  98. package/src/core/viewport/features/base.ts +0 -73
  99. package/src/core/viewport/features/collection.ts +0 -1182
  100. package/src/core/viewport/features/events.ts +0 -130
  101. package/src/core/viewport/features/item-size.ts +0 -271
  102. package/src/core/viewport/features/loading.ts +0 -263
  103. package/src/core/viewport/features/momentum.ts +0 -269
  104. package/src/core/viewport/features/performance.ts +0 -161
  105. package/src/core/viewport/features/placeholders.ts +0 -335
  106. package/src/core/viewport/features/rendering.ts +0 -962
  107. package/src/core/viewport/features/scrollbar.ts +0 -434
  108. package/src/core/viewport/features/scrolling.ts +0 -634
  109. package/src/core/viewport/features/utils.ts +0 -94
  110. package/src/core/viewport/features/virtual.ts +0 -525
  111. package/src/core/viewport/types.ts +0 -133
  112. package/src/core/viewport/utils/speed-tracker.ts +0 -79
  113. package/src/core/viewport/viewport.ts +0 -265
  114. package/test/benchmarks/layout/advanced.test.ts +0 -656
  115. package/test/benchmarks/layout/comparison.test.ts +0 -519
  116. package/test/benchmarks/layout/performance-comparison.test.ts +0 -274
  117. package/test/benchmarks/layout/real-components.test.ts +0 -733
  118. package/test/benchmarks/layout/simple.test.ts +0 -321
  119. package/test/benchmarks/layout/stress.test.ts +0 -990
  120. package/test/collection/basic.test.ts +0 -304
  121. package/test/components/vlist-selection.test.ts +0 -240
  122. package/test/components/vlist.test.ts +0 -63
  123. package/test/core/collection/adapter.test.ts +0 -161
  124. package/test/core/collection/collection.test.ts +0 -394
  125. package/test/core/layout/layout.test.ts +0 -201
  126. package/test/utils/dom-helpers.ts +0 -275
  127. package/test/utils/performance-helpers.ts +0 -392
  128. package/tsconfig.json +0 -20
@@ -1,723 +0,0 @@
1
- /**
2
- * VList Types - Virtual List with direct viewport integration
3
- */
4
-
5
- import type { BaseComponent, ElementComponent } from "mtrl";
6
-
7
- /** Options for removeItemById */
8
- export interface RemoveItemOptions {
9
- /** Track as pending removal to filter from future fetches (default: true) */
10
- trackPending?: boolean;
11
- /** Timeout in ms to clear pending removal (default: 5000) */
12
- pendingTimeout?: number;
13
- }
14
- // Collection types are not exposed by mtrl; define minimal interfaces locally
15
- export interface CollectionItem {
16
- id: string | number;
17
- [key: string]: any;
18
- }
19
-
20
- export interface CollectionConfig<T = any> {
21
- adapter?: {
22
- read(params?: any): Promise<{ items: T[]; meta?: any; error?: any }>;
23
- };
24
- }
25
-
26
- export interface Collection<T = any> {
27
- loadMissingRanges?: (
28
- range: { start: number; end: number },
29
- reason?: string,
30
- ) => Promise<void>;
31
- }
32
- import type { ViewportComponent } from "../../core/viewport/types";
33
-
34
- /**
35
- * List item interface - extends collection item
36
- */
37
- export interface ListItem extends CollectionItem {}
38
-
39
- /**
40
- * List adapter interface - extends collection adapter
41
- */
42
- export interface ListAdapter<T extends ListItem = ListItem> {
43
- read(params?: ListAdapterParams): Promise<ListAdapterResponse<T>>;
44
- write?(items: T[]): Promise<ListAdapterResponse<T>>;
45
- delete?(ids: string[]): Promise<ListAdapterResponse<T>>;
46
- }
47
-
48
- /**
49
- * List adapter parameters
50
- */
51
- export interface ListAdapterParams {
52
- page?: number;
53
- pageSize?: number;
54
- offset?: number;
55
- cursor?: string;
56
- search?: string;
57
- filters?: Record<string, any>;
58
- sort?: {
59
- field: string;
60
- direction: "asc" | "desc";
61
- }[];
62
- }
63
-
64
- /**
65
- * List adapter response
66
- */
67
- export interface ListAdapterResponse<T extends ListItem = ListItem> {
68
- items: T[];
69
- meta?: {
70
- total?: number;
71
- page?: number;
72
- pageSize?: number;
73
- hasNext?: boolean;
74
- hasPrev?: boolean;
75
- cursor?: string;
76
- };
77
- error?: {
78
- message: string;
79
- code?: string;
80
- };
81
- }
82
-
83
- /**
84
- * List template definition
85
- */
86
- export type ListTemplate = (item: any, index: number) => string | HTMLElement;
87
-
88
- /**
89
- * List item template function
90
- */
91
- export type ListItemTemplate<T = any> = (
92
- item: T,
93
- index: number,
94
- ) => string | HTMLElement;
95
-
96
- /**
97
- * List scroll behavior configuration
98
- */
99
- export interface ListScrollConfig {
100
- /** Enable virtual scrolling */
101
- virtual?: boolean;
102
- /** Item size (fixed) or 'auto' for dynamic - height for vertical, width for horizontal */
103
- itemSize?: number | "auto";
104
- /** Number of items to render outside viewport */
105
- overscan?: number;
106
- /** Enable scroll animations */
107
- animation?: boolean;
108
- /** Restore scroll position on reload */
109
- restorePosition?: boolean;
110
- /** Enable item measurement for dynamic sizing (default: false) */
111
- measureItems?: boolean;
112
- }
113
-
114
- /**
115
- * List styling configuration
116
- */
117
- export interface ListStyleConfig {
118
- /** CSS class prefix */
119
- prefix?: string;
120
- /** Component name for class generation */
121
- componentName?: string;
122
- /** Additional CSS classes */
123
- className?: string;
124
- /** List variant */
125
- variant?: "default" | "dense" | "comfortable";
126
- /** List density */
127
- density?: "default" | "compact" | "comfortable";
128
- }
129
-
130
- /**
131
- * List event handlers
132
- */
133
- export interface ListEventHandlers<T = any> {
134
- /** Item click handler */
135
- onItemClick?: (item: T, index: number, event: MouseEvent) => void;
136
- /** Item selection change */
137
- onSelectionChange?: (selectedItems: T[], selectedIndices: number[]) => void;
138
- /** Scroll event */
139
- onScroll?: (scrollTop: number, direction: "up" | "down" | "none") => void;
140
- /** Viewport change event */
141
- onViewportChange?: (visibleRange: { start: number; end: number }) => void;
142
- /** Load more data event */
143
- onLoadMore?: (direction: "forward" | "backward") => void | Promise<void>;
144
- }
145
-
146
- /**
147
- * List selection configuration
148
- */
149
- export interface ListSelectionConfig {
150
- /** Enable selection */
151
- enabled?: boolean;
152
- /** Selection mode */
153
- mode?: "single" | "multiple" | "none";
154
- /** Initially selected indices */
155
- selectedIndices?: number[];
156
- /** Selection change callback */
157
- onSelectionChange?: (selectedItems: any[], selectedIndices: number[]) => void;
158
- /** Require keyboard modifiers for multi-select (default: false) */
159
- requireModifiers?: boolean;
160
- }
161
-
162
- /**
163
- * List orientation configuration
164
- */
165
- export interface ListOrientationConfig {
166
- /** List orientation */
167
- orientation?: "horizontal" | "vertical";
168
- /** Whether to auto-detect orientation based on container */
169
- autoDetect?: boolean;
170
- /** Reverse direction (RTL for horizontal, bottom-to-top for vertical) */
171
- reverse?: boolean;
172
- /** Cross-axis alignment */
173
- crossAxisAlignment?: "start" | "center" | "end" | "stretch";
174
- }
175
-
176
- /**
177
- * List pagination configuration
178
- */
179
- export interface ListPaginationConfig {
180
- /** Pagination strategy */
181
- strategy?: "page" | "offset" | "cursor";
182
- /** Fixed page size/limit (overrides viewport-based calculation) */
183
- limit?: number;
184
- }
185
-
186
- /**
187
- * Complete List component configuration
188
- */
189
- export interface ListConfig<T extends ListItem = ListItem>
190
- extends ListStyleConfig {
191
- // Data layer (Collection) configuration
192
- collection?: Partial<CollectionConfig<T>>;
193
-
194
- // Performance layer (List Manager) configuration
195
- listManager?: Partial<any>;
196
-
197
- // Pagination configuration
198
- pagination?: ListPaginationConfig;
199
-
200
- // Presentation layer configuration
201
- /** Container element or selector */
202
- container?: HTMLElement | string;
203
-
204
- /** List orientation configuration */
205
- orientation?: ListOrientationConfig;
206
-
207
- /** Item template function */
208
- template?: ListItemTemplate<T>;
209
-
210
- /** Static items (for non-API lists) */
211
- items?: T[];
212
-
213
- /** Data adapter (can be passed at top level or nested under collection) */
214
- adapter?: ListAdapter<T>;
215
-
216
- /** Scroll behavior configuration */
217
- scroll?: ListScrollConfig;
218
-
219
- /** Selection configuration */
220
- selection?: ListSelectionConfig;
221
-
222
- /** Event handlers */
223
- on?: ListEventHandlers<T>;
224
-
225
- /** Enable debugging */
226
- debug?: boolean;
227
-
228
- /** Accessibility label */
229
- ariaLabel?: string;
230
-
231
- /** Loading message template */
232
- loadingTemplate?: string | (() => string | HTMLElement);
233
-
234
- /** Empty state template */
235
- emptyTemplate?: string | (() => string | HTMLElement);
236
-
237
- /** Error state template */
238
- errorTemplate?: string | ((error: Error) => string | HTMLElement);
239
- }
240
-
241
- /**
242
- * List state interface
243
- */
244
- export interface ListState {
245
- /** Current loading state */
246
- isLoading: boolean;
247
-
248
- /** Current error state */
249
- error: Error | null;
250
-
251
- /** Whether list is empty */
252
- isEmpty: boolean;
253
-
254
- /** Current scroll position */
255
- scrollTop: number;
256
-
257
- /** Current visible range */
258
- visibleRange: { start: number; end: number; count: number };
259
-
260
- /** Current render range */
261
- renderRange: { start: number; end: number; count: number };
262
-
263
- /** Selected item indices */
264
- selectedIndices: number[];
265
-
266
- /** Total number of items */
267
- totalItems: number;
268
-
269
- /** Whether virtual scrolling is active */
270
- isVirtual: boolean;
271
-
272
- /** Whether scrolling animations are enabled */
273
- animationEnabled: boolean;
274
- }
275
-
276
- /**
277
- * List item rendering context
278
- */
279
- export interface ListItemContext<T = any> {
280
- /** Item data */
281
- item: T;
282
-
283
- /** Item index */
284
- index: number;
285
-
286
- /** Whether item is selected */
287
- isSelected: boolean;
288
-
289
- /** Whether item is visible in viewport */
290
- isVisible: boolean;
291
-
292
- /** Whether item is in render range */
293
- isInRenderRange: boolean;
294
-
295
- /** Item element (if rendered) */
296
- element?: HTMLElement;
297
- }
298
-
299
- /**
300
- * List component events
301
- */
302
- export interface ListEvents<T = any> {
303
- /** Item clicked */
304
- "item:click": { item: T; index: number; event: MouseEvent };
305
-
306
- /** Item selected/deselected */
307
- "item:selection:change": { item: T; index: number; isSelected: boolean };
308
-
309
- /** Selection changed */
310
- "selection:change": { selectedItems: T[]; selectedIndices: number[] };
311
-
312
- /** Scroll position changed */
313
- "scroll:change": { scrollTop: number; direction: "up" | "down" | "none" };
314
-
315
- /** Viewport changed */
316
- "viewport:change": {
317
- visibleRange: { start: number; end: number; count: number };
318
- };
319
-
320
- /** Load more triggered */
321
- "load:more": { direction: "forward" | "backward" };
322
-
323
- /** Data loaded */
324
- "data:loaded": { items: T[]; total: number };
325
-
326
- /** Loading state changed */
327
- "loading:change": { isLoading: boolean };
328
-
329
- /** Error occurred */
330
- error: { error: Error };
331
-
332
- /** List rendered */
333
- "render:complete": {
334
- renderRange: { start: number; end: number; count: number };
335
- };
336
-
337
- /** Item updated */
338
- "item:updated": {
339
- item: T;
340
- index: number;
341
- previousItem: T;
342
- wasVisible: boolean;
343
- };
344
-
345
- /** Viewport range loaded (data available for range) */
346
- "viewport:range-loaded": {
347
- range: { start: number; end: number };
348
- };
349
- }
350
-
351
- /**
352
- * List component API
353
- */
354
- export interface ListAPI<T extends ListItem = ListItem> {
355
- // Data management
356
- /** Load data */
357
- loadData(): Promise<void>;
358
-
359
- /** Reload data */
360
- reload(): Promise<void>;
361
-
362
- /** Clear all data */
363
- clear(): void;
364
-
365
- /** Add items */
366
- addItems(items: T[], position?: "start" | "end"): void;
367
-
368
- /** Remove items by indices */
369
- removeItems(indices: number[]): void;
370
-
371
- /**
372
- * Remove item at a specific index
373
- * Removes the item from the collection, updates totalItems, and triggers re-render
374
- * @param index - The index of the item to remove
375
- * @returns true if item was found and removed, false otherwise
376
- */
377
- removeItem(index: number): boolean;
378
-
379
- /**
380
- * Remove item by ID
381
- * Finds the item in the collection by its ID and removes it
382
- * Updates totalItems and triggers re-render of visible items
383
- * Optionally tracks as pending removal to filter from future fetches
384
- * @param id - The item ID to find and remove
385
- * @param options - Remove options (trackPending, pendingTimeout)
386
- * @returns true if item was found and removed, false otherwise
387
- */
388
- removeItemById(id: string | number, options?: RemoveItemOptions): boolean;
389
-
390
- /**
391
- * Check if an item ID is pending removal
392
- * @param id - The item ID to check
393
- * @returns true if the item is pending removal
394
- */
395
- isPendingRemoval(id: string | number): boolean;
396
-
397
- /**
398
- * Get all pending removal IDs
399
- * @returns Set of pending removal IDs
400
- */
401
- getPendingRemovals(): Set<string | number>;
402
-
403
- /**
404
- * Clear a specific pending removal
405
- * @param id - The item ID to clear from pending removals
406
- */
407
- clearPendingRemoval(id: string | number): void;
408
-
409
- /**
410
- * Clear all pending removals
411
- */
412
- clearAllPendingRemovals(): void;
413
-
414
- /**
415
- * Filter items array to exclude pending removals
416
- * Utility method for use in collection adapters
417
- * @param items - Array of items to filter
418
- * @returns Filtered array without pending removal items
419
- */
420
- filterPendingRemovals<I extends { id?: any; _id?: any }>(items: I[]): I[];
421
-
422
- /** Update item at index */
423
- updateItem(index: number, item: T): void;
424
-
425
- /**
426
- * Update item by ID
427
- * Finds the item in the collection by its ID and updates it with new data
428
- * Re-renders the item if currently visible in the viewport
429
- * @param id - The item ID to find
430
- * @param data - Partial data to merge with existing item, or full item replacement
431
- * @param options - Update options
432
- * @returns true if item was found and updated, false otherwise
433
- */
434
- updateItemById(
435
- id: string | number,
436
- data: Partial<T>,
437
- options?: {
438
- /** If true, replace the entire item instead of merging (default: false) */
439
- replace?: boolean;
440
- /** If true, re-render even if not visible (default: false) */
441
- forceRender?: boolean;
442
- },
443
- ): boolean;
444
-
445
- /** Get item at index */
446
- getItem(index: number): T | undefined;
447
-
448
- /** Get all items */
449
- getItems(): T[];
450
-
451
- /** Get total item count */
452
- getItemCount(): number;
453
-
454
- // Scrolling
455
- /** Scroll to item index */
456
- scrollToIndex(
457
- index: number,
458
- alignment?: "start" | "center" | "end",
459
- ): Promise<void>;
460
-
461
- /** Scroll to top */
462
- scrollToTop(): Promise<void>;
463
-
464
- /** Scroll to bottom */
465
- scrollToBottom(): Promise<void>;
466
-
467
- /** Get current scroll position */
468
- getScrollPosition(): number;
469
-
470
- // Animation control
471
- /** Enable or disable scroll animations */
472
- setAnimationEnabled(enabled: boolean): void;
473
-
474
- /** Get current animation enabled state */
475
- getAnimationEnabled(): boolean;
476
-
477
- /** Toggle animation on/off */
478
- toggleAnimation(): void;
479
-
480
- // Selection
481
- /** Select items by indices */
482
- selectItems(indices: number[]): void;
483
-
484
- /** Deselect items by indices */
485
- deselectItems(indices: number[]): void;
486
-
487
- /** Clear selection */
488
- clearSelection(): void;
489
-
490
- /** Get selected items */
491
- getSelectedItems(): T[];
492
-
493
- /** Get selected indices */
494
- getSelectedIndices(): number[];
495
-
496
- /** Check if item is selected */
497
- isSelected(index: number): boolean;
498
-
499
- /** Select an item by its ID
500
- * @param id - The ID of the item to select
501
- * @param silent - If true, selection won't emit change event (default: false)
502
- */
503
- selectById(id: string | number, silent?: boolean): boolean;
504
-
505
- /**
506
- * Select item at index, scrolling and waiting for data if needed
507
- * Handles virtual scrolling by loading data before selecting
508
- */
509
- selectAtIndex(index: number): Promise<boolean>;
510
-
511
- /**
512
- * Select next item relative to current selection
513
- * Handles virtual scrolling by loading data before selecting
514
- * @returns Promise resolving to true if selection changed, false if at end
515
- */
516
- selectNext(): Promise<boolean>;
517
-
518
- /**
519
- * Select previous item relative to current selection
520
- * Handles virtual scrolling by loading data before selecting
521
- * @returns Promise resolving to true if selection changed, false if at start
522
- */
523
- selectPrevious(): Promise<boolean>;
524
-
525
- // State
526
- /** Get current list state */
527
- getState(): ListState;
528
-
529
- /** Check if list is loading */
530
- isLoading(): boolean;
531
-
532
- /** Check if list has error */
533
- hasError(): boolean;
534
-
535
- /** Check if list is empty */
536
- isEmpty(): boolean;
537
-
538
- // Rendering
539
- /** Force re-render */
540
- render(): void;
541
-
542
- /** Update viewport */
543
- updateViewport(): void;
544
-
545
- /** Get visible range */
546
- getVisibleRange(): { start: number; end: number; count: number };
547
-
548
- /** Get render range */
549
- getRenderRange(): { start: number; end: number; count: number };
550
-
551
- // Templates
552
- /** Update item template */
553
- setTemplate(template: ListItemTemplate<T>): void;
554
-
555
- /** Set loading template */
556
- setLoadingTemplate(template: string | (() => string | HTMLElement)): void;
557
-
558
- /** Set empty template */
559
- setEmptyTemplate(template: string | (() => string | HTMLElement)): void;
560
-
561
- /** Set error template */
562
- setErrorTemplate(
563
- template: string | ((error: Error) => string | HTMLElement),
564
- ): void;
565
-
566
- // Configuration
567
- /** Update list configuration */
568
- updateConfig(config: Partial<ListConfig<T>>): void;
569
-
570
- /** Get current configuration */
571
- getConfig(): ListConfig<T>;
572
- }
573
-
574
- /**
575
- * List component interface (extends mtrl component patterns)
576
- */
577
- export interface ListComponent<T extends ListItem = ListItem>
578
- extends BaseComponent,
579
- ElementComponent,
580
- ListAPI<T> {
581
- /** Collection instance (data layer) */
582
- collection: Collection<T>;
583
-
584
- /** List manager instance (performance layer) */
585
- listManager: any;
586
-
587
- /** Current list state */
588
- state: ListState;
589
-
590
- /** List configuration */
591
- config: ListConfig<T>;
592
-
593
- /** Component lifecycle methods */
594
- lifecycle: {
595
- init(): void;
596
- destroy(): void;
597
- update(): void;
598
- };
599
-
600
- /** Event system (inherited from BaseComponent) */
601
- on<K extends keyof ListEvents<T>>(
602
- event: K,
603
- handler: (payload: ListEvents<T>[K]) => void,
604
- ): void;
605
- emit<K extends keyof ListEvents<T>>(
606
- event: K,
607
- payload: ListEvents<T>[K],
608
- ): void;
609
- off<K extends keyof ListEvents<T>>(
610
- event: K,
611
- handler?: (payload: ListEvents<T>[K]) => void,
612
- ): void;
613
- }
614
-
615
- /**
616
- * List performance metrics
617
- */
618
- export interface ListPerformanceMetrics {
619
- renderCount: number;
620
- scrollCount: number;
621
- averageRenderTime: number;
622
- averageScrollTime: number;
623
- memoryUsage: number;
624
- virtualizedItems: number;
625
- recycledElements: number;
626
- }
627
-
628
- /**
629
- * List feature options
630
- */
631
- export interface ListFeatures {
632
- virtualScroll?: boolean;
633
- selection?: boolean;
634
- styling?: boolean;
635
- performance?: boolean;
636
- }
637
-
638
- /**
639
- * VList configuration interface
640
- */
641
- export interface VListConfig<T extends ListItem = ListItem> {
642
- // Container
643
- parent?: HTMLElement | string;
644
- container?: HTMLElement | string; // Also support container
645
-
646
- // Basic properties
647
- class?: string;
648
- className?: string; // Also support className
649
- prefix?: string;
650
- ariaLabel?: string;
651
- debug?: boolean;
652
-
653
- // Initial scroll position (0-based index)
654
- // When set, VList will start loading from this position instead of 0
655
- initialScrollIndex?: number;
656
-
657
- // ID of item to select after initial load completes
658
- // Works with initialScrollIndex to scroll to position and then select the item
659
- selectId?: string | number;
660
-
661
- // Whether to automatically load data on initialization (default: true)
662
- // Set to false to defer loading until manually triggered
663
- autoLoad?: boolean;
664
-
665
- // Data source
666
- items?: T[];
667
-
668
- // Template for rendering items
669
- template?: (
670
- item: T,
671
- index: number,
672
- ) => string | HTMLElement | any[] | Record<string, any>;
673
-
674
- // Collection configuration
675
- collection?: {
676
- adapter?: ListAdapter<T>;
677
- transform?: (item: T) => T;
678
- };
679
-
680
- // Pagination configuration
681
- pagination?: {
682
- strategy?: "page" | "offset" | "cursor";
683
- limit?: number;
684
- };
685
-
686
- // Virtual scrolling configuration
687
- virtual?: {
688
- itemSize?: number;
689
- overscan?: number;
690
- };
691
-
692
- // Scrolling configuration
693
- scrolling?: {
694
- orientation?: "vertical" | "horizontal";
695
- animation?: boolean;
696
- measureItems?: boolean;
697
- };
698
-
699
- // Performance settings
700
- performance?: {
701
- recycleElements?: boolean;
702
- bufferSize?: number;
703
- renderDebounce?: number;
704
- maxConcurrentRequests?: number;
705
- /** Velocity threshold (px/ms) above which data loading is cancelled and placeholders are shown. Default: 2 */
706
- cancelLoadThreshold?: number;
707
- };
708
-
709
- // Selection configuration
710
- selection?: ListSelectionConfig;
711
-
712
- // Event handlers
713
- on?: ListEventHandlers<T>;
714
- }
715
-
716
- export type VListComponent<T extends ListItem = ListItem> = ListComponent<T> & {
717
- viewport: ViewportComponent["viewport"];
718
- };
719
-
720
- export type VListItem = ListItem;
721
- export type VListAPI<T extends ListItem = ListItem> = ListAPI<T>;
722
- export type VListState = ListState;
723
- export type VListEvents<T = any> = ListEvents<T>;