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.
- package/{src/components/index.ts → dist/components/index.d.ts} +0 -2
- package/dist/components/vlist/config.d.ts +86 -0
- package/{src/components/vlist/constants.ts → dist/components/vlist/constants.d.ts} +10 -11
- package/dist/components/vlist/features/api.d.ts +7 -0
- package/{src/components/vlist/features/index.ts → dist/components/vlist/features/index.d.ts} +0 -2
- package/dist/components/vlist/features/selection.d.ts +6 -0
- package/dist/components/vlist/features/viewport.d.ts +9 -0
- package/dist/components/vlist/features.d.ts +31 -0
- package/{src/components/vlist/index.ts → dist/components/vlist/index.d.ts} +1 -10
- package/dist/components/vlist/types.d.ts +596 -0
- package/dist/components/vlist/vlist.d.ts +29 -0
- package/dist/core/compose/features/gestures/index.d.ts +86 -0
- package/dist/core/compose/features/gestures/longpress.d.ts +85 -0
- package/dist/core/compose/features/gestures/pan.d.ts +108 -0
- package/dist/core/compose/features/gestures/pinch.d.ts +111 -0
- package/dist/core/compose/features/gestures/rotate.d.ts +111 -0
- package/dist/core/compose/features/gestures/swipe.d.ts +149 -0
- package/dist/core/compose/features/gestures/tap.d.ts +79 -0
- package/{src/core/compose/features/index.ts → dist/core/compose/features/index.d.ts} +1 -2
- package/{src/core/compose/index.ts → dist/core/compose/index.d.ts} +2 -11
- package/{src/core/gestures/index.ts → dist/core/gestures/index.d.ts} +1 -20
- package/dist/core/gestures/longpress.d.ts +23 -0
- package/dist/core/gestures/manager.d.ts +14 -0
- package/dist/core/gestures/pan.d.ts +12 -0
- package/dist/core/gestures/pinch.d.ts +14 -0
- package/dist/core/gestures/rotate.d.ts +14 -0
- package/dist/core/gestures/swipe.d.ts +20 -0
- package/dist/core/gestures/tap.d.ts +12 -0
- package/dist/core/gestures/types.d.ts +320 -0
- package/dist/core/gestures/utils.d.ts +57 -0
- package/dist/core/index.d.ts +13 -0
- package/dist/core/layout/config.d.ts +33 -0
- package/dist/core/layout/index.d.ts +51 -0
- package/dist/core/layout/jsx.d.ts +65 -0
- package/dist/core/layout/schema.d.ts +112 -0
- package/dist/core/layout/types.d.ts +69 -0
- package/dist/core/viewport/constants.d.ts +105 -0
- package/dist/core/viewport/features/base.d.ts +14 -0
- package/dist/core/viewport/features/collection.d.ts +41 -0
- package/dist/core/viewport/features/events.d.ts +13 -0
- package/{src/core/viewport/features/index.ts → dist/core/viewport/features/index.d.ts} +0 -7
- package/dist/core/viewport/features/item-size.d.ts +30 -0
- package/dist/core/viewport/features/loading.d.ts +34 -0
- package/dist/core/viewport/features/momentum.d.ts +17 -0
- package/dist/core/viewport/features/performance.d.ts +53 -0
- package/dist/core/viewport/features/placeholders.d.ts +38 -0
- package/dist/core/viewport/features/rendering.d.ts +16 -0
- package/dist/core/viewport/features/scrollbar.d.ts +26 -0
- package/dist/core/viewport/features/scrolling.d.ts +16 -0
- package/dist/core/viewport/features/utils.d.ts +43 -0
- package/dist/core/viewport/features/virtual.d.ts +18 -0
- package/{src/core/viewport/index.ts → dist/core/viewport/index.d.ts} +1 -17
- package/dist/core/viewport/types.d.ts +96 -0
- package/dist/core/viewport/utils/speed-tracker.d.ts +22 -0
- package/dist/core/viewport/viewport.d.ts +11 -0
- package/{src/index.ts → dist/index.d.ts} +0 -4
- package/dist/index.js +5143 -0
- package/dist/index.mjs +5111 -0
- package/dist/styles.css +254 -0
- package/dist/styles.css.map +1 -0
- package/package.json +5 -1
- package/.cursorrules +0 -117
- package/AI.md +0 -39
- package/CLAUDE.md +0 -882
- package/build.js +0 -377
- package/scripts/analyze-orphaned-functions.ts +0 -387
- package/scripts/debug/vlist-selection.ts +0 -121
- package/src/components/vlist/config.ts +0 -323
- package/src/components/vlist/features/api.ts +0 -626
- package/src/components/vlist/features/selection.ts +0 -436
- package/src/components/vlist/features/viewport.ts +0 -59
- package/src/components/vlist/features.ts +0 -112
- package/src/components/vlist/types.ts +0 -723
- package/src/components/vlist/vlist.ts +0 -92
- package/src/core/compose/features/gestures/index.ts +0 -227
- package/src/core/compose/features/gestures/longpress.ts +0 -383
- package/src/core/compose/features/gestures/pan.ts +0 -424
- package/src/core/compose/features/gestures/pinch.ts +0 -475
- package/src/core/compose/features/gestures/rotate.ts +0 -485
- package/src/core/compose/features/gestures/swipe.ts +0 -492
- package/src/core/compose/features/gestures/tap.ts +0 -334
- package/src/core/gestures/longpress.ts +0 -68
- package/src/core/gestures/manager.ts +0 -418
- package/src/core/gestures/pan.ts +0 -48
- package/src/core/gestures/pinch.ts +0 -58
- package/src/core/gestures/rotate.ts +0 -58
- package/src/core/gestures/swipe.ts +0 -66
- package/src/core/gestures/tap.ts +0 -45
- package/src/core/gestures/types.ts +0 -387
- package/src/core/gestures/utils.ts +0 -128
- package/src/core/index.ts +0 -43
- package/src/core/layout/config.ts +0 -102
- package/src/core/layout/index.ts +0 -168
- package/src/core/layout/jsx.ts +0 -174
- package/src/core/layout/schema.ts +0 -1044
- package/src/core/layout/types.ts +0 -95
- package/src/core/viewport/constants.ts +0 -145
- package/src/core/viewport/features/base.ts +0 -73
- package/src/core/viewport/features/collection.ts +0 -1182
- package/src/core/viewport/features/events.ts +0 -130
- package/src/core/viewport/features/item-size.ts +0 -271
- package/src/core/viewport/features/loading.ts +0 -263
- package/src/core/viewport/features/momentum.ts +0 -269
- package/src/core/viewport/features/performance.ts +0 -161
- package/src/core/viewport/features/placeholders.ts +0 -335
- package/src/core/viewport/features/rendering.ts +0 -962
- package/src/core/viewport/features/scrollbar.ts +0 -434
- package/src/core/viewport/features/scrolling.ts +0 -634
- package/src/core/viewport/features/utils.ts +0 -94
- package/src/core/viewport/features/virtual.ts +0 -525
- package/src/core/viewport/types.ts +0 -133
- package/src/core/viewport/utils/speed-tracker.ts +0 -79
- package/src/core/viewport/viewport.ts +0 -265
- package/test/benchmarks/layout/advanced.test.ts +0 -656
- package/test/benchmarks/layout/comparison.test.ts +0 -519
- package/test/benchmarks/layout/performance-comparison.test.ts +0 -274
- package/test/benchmarks/layout/real-components.test.ts +0 -733
- package/test/benchmarks/layout/simple.test.ts +0 -321
- package/test/benchmarks/layout/stress.test.ts +0 -990
- package/test/collection/basic.test.ts +0 -304
- package/test/components/vlist-selection.test.ts +0 -240
- package/test/components/vlist.test.ts +0 -63
- package/test/core/collection/adapter.test.ts +0 -161
- package/test/core/collection/collection.test.ts +0 -394
- package/test/core/layout/layout.test.ts +0 -201
- package/test/utils/dom-helpers.ts +0 -275
- package/test/utils/performance-helpers.ts +0 -392
- package/tsconfig.json +0 -20
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/layout/schema
|
|
3
|
+
* @description Unified layout schema processor with integrated optimizations
|
|
4
|
+
* Consolidates array, object, JSX, and template processing with built-in performance enhancements
|
|
5
|
+
*/
|
|
6
|
+
export interface LayoutConfig {
|
|
7
|
+
/** Base layout type */
|
|
8
|
+
type?: "stack" | "row" | "grid" | string;
|
|
9
|
+
/** Spacing between elements */
|
|
10
|
+
gap?: number | string;
|
|
11
|
+
/** Additional CSS classes */
|
|
12
|
+
class?: string;
|
|
13
|
+
/** Alignment of items along the cross axis */
|
|
14
|
+
align?: "start" | "center" | "end" | "stretch";
|
|
15
|
+
/** Alignment of items along the main axis */
|
|
16
|
+
justify?: "start" | "center" | "end" | "between" | "around" | "evenly";
|
|
17
|
+
/** Whether and how items should wrap */
|
|
18
|
+
wrap?: boolean | "reverse" | "nowrap";
|
|
19
|
+
/** Whether row items should stack vertically on mobile */
|
|
20
|
+
mobileStack?: boolean;
|
|
21
|
+
/** Whether row items should scroll horizontally on mobile */
|
|
22
|
+
mobileScroll?: boolean;
|
|
23
|
+
/** Number of columns or automatic sizing method */
|
|
24
|
+
columns?: number | "auto-fit" | "auto-fill";
|
|
25
|
+
/** Whether to use dense packing algorithm for grid */
|
|
26
|
+
dense?: boolean;
|
|
27
|
+
/** Whether grid items should adjust height automatically */
|
|
28
|
+
autoHeight?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface LayoutItemConfig {
|
|
31
|
+
/** Column width in a 12-column grid */
|
|
32
|
+
width?: number;
|
|
33
|
+
/** Width on small screens */
|
|
34
|
+
sm?: number;
|
|
35
|
+
/** Width on medium screens */
|
|
36
|
+
md?: number;
|
|
37
|
+
/** Width on large screens */
|
|
38
|
+
lg?: number;
|
|
39
|
+
/** Width on extra-large screens */
|
|
40
|
+
xl?: number;
|
|
41
|
+
/** Number of grid columns to span */
|
|
42
|
+
span?: number;
|
|
43
|
+
/** Number of grid rows to span */
|
|
44
|
+
rowSpan?: number;
|
|
45
|
+
/** Display order */
|
|
46
|
+
order?: number | "first" | "last";
|
|
47
|
+
/** Self-alignment within container */
|
|
48
|
+
align?: "start" | "center" | "end" | "stretch";
|
|
49
|
+
/** Whether item should automatically size */
|
|
50
|
+
auto?: boolean;
|
|
51
|
+
}
|
|
52
|
+
export interface LayoutOptions {
|
|
53
|
+
/** Default creator function to use if not specified in schema */
|
|
54
|
+
creator?: Function;
|
|
55
|
+
/** Whether to apply CSS class prefix @default true */
|
|
56
|
+
prefix?: boolean;
|
|
57
|
+
/** Additional options */
|
|
58
|
+
[key: string]: any;
|
|
59
|
+
}
|
|
60
|
+
export interface LayoutResult {
|
|
61
|
+
/** The raw layout object with all components */
|
|
62
|
+
layout: Record<string, any>;
|
|
63
|
+
/** Reference to the root element for convenience */
|
|
64
|
+
element: HTMLElement | any;
|
|
65
|
+
/** Flattened component map */
|
|
66
|
+
component: Record<string, any>;
|
|
67
|
+
/** Gets a component by name */
|
|
68
|
+
get(name: string): any;
|
|
69
|
+
/** Gets all components in a flattened map */
|
|
70
|
+
getAll(): Record<string, any>;
|
|
71
|
+
/** Destroys the layout, cleaning up all components */
|
|
72
|
+
destroy(): void;
|
|
73
|
+
}
|
|
74
|
+
type ComponentLike = {
|
|
75
|
+
element: HTMLElement;
|
|
76
|
+
[key: string]: any;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Checks if a value is a component object (has an element property)
|
|
80
|
+
*/
|
|
81
|
+
declare function isComponent(value: any): value is ComponentLike;
|
|
82
|
+
/**
|
|
83
|
+
* Optimized class processing with minimal string operations
|
|
84
|
+
* Handles arrays, strings, className aliases, and rawClass efficiently
|
|
85
|
+
*/
|
|
86
|
+
declare function processClassNames(options: Record<string, any>, skipPrefix?: boolean): Record<string, any>;
|
|
87
|
+
/**
|
|
88
|
+
* Applies layout classes based on configuration
|
|
89
|
+
* Uses integrated caching for optimal performance
|
|
90
|
+
*/
|
|
91
|
+
declare function applyLayoutClasses(element: HTMLElement, layoutConfig: LayoutConfig): void;
|
|
92
|
+
/**
|
|
93
|
+
* Applies layout item classes based on configuration
|
|
94
|
+
* Uses integrated caching for optimal performance
|
|
95
|
+
*/
|
|
96
|
+
declare function applyLayoutItemClasses(element: HTMLElement, itemConfig: LayoutItemConfig): void;
|
|
97
|
+
/**
|
|
98
|
+
* Flattens a nested layout into a simple object with element and component references
|
|
99
|
+
*/
|
|
100
|
+
declare function flattenLayout(layout: Record<string, any>): Record<string, any>;
|
|
101
|
+
/**
|
|
102
|
+
* Creates a layout result object with utility functions
|
|
103
|
+
*/
|
|
104
|
+
declare function createLayoutResult(layout: Record<string, any>): LayoutResult;
|
|
105
|
+
/**
|
|
106
|
+
* Creates a layout from various schema formats
|
|
107
|
+
* Unified processor for arrays, objects, JSX, and HTML strings
|
|
108
|
+
*/
|
|
109
|
+
export declare function createLayout(schema: any, parentElement?: HTMLElement | null, options?: LayoutOptions): LayoutResult;
|
|
110
|
+
export declare function clearClassCache(): void;
|
|
111
|
+
export declare function clearFragmentPool(): void;
|
|
112
|
+
export { processClassNames, isComponent, flattenLayout, applyLayoutClasses, applyLayoutItemClasses, createLayoutResult, };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/layout/types
|
|
3
|
+
* @description Essential type definitions for layout creation system
|
|
4
|
+
* Core types are defined in schema.ts for better tree-shaking
|
|
5
|
+
*/
|
|
6
|
+
import type { LayoutConfig, LayoutItemConfig, LayoutOptions, LayoutResult } from "./schema";
|
|
7
|
+
export type { LayoutConfig, LayoutItemConfig, LayoutOptions, LayoutResult };
|
|
8
|
+
/**
|
|
9
|
+
* Interface for component-like objects
|
|
10
|
+
*/
|
|
11
|
+
export interface ComponentLike {
|
|
12
|
+
/** DOM element reference */
|
|
13
|
+
element: any;
|
|
14
|
+
/** Optional method to clean up resources */
|
|
15
|
+
destroy?: () => void;
|
|
16
|
+
/** Allow additional properties */
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Extended options for element creation
|
|
21
|
+
* Used in object-based schemas
|
|
22
|
+
*/
|
|
23
|
+
export interface ElementOptions extends Record<string, any> {
|
|
24
|
+
/** Layout configuration for the element */
|
|
25
|
+
layout?: LayoutConfig;
|
|
26
|
+
/** Layout item configuration */
|
|
27
|
+
layoutItem?: LayoutItemConfig;
|
|
28
|
+
/** CSS classes to apply (with automatic mtrl- prefix) */
|
|
29
|
+
class?: string;
|
|
30
|
+
/** Additional CSS classes (alias for class) */
|
|
31
|
+
className?: string;
|
|
32
|
+
/** CSS classes to apply without prefix */
|
|
33
|
+
rawClass?: string | string[];
|
|
34
|
+
/** HTML tag name for createElement */
|
|
35
|
+
tag?: string;
|
|
36
|
+
/** Text content for the element */
|
|
37
|
+
textContent?: string;
|
|
38
|
+
/** Inline styles */
|
|
39
|
+
style?: Record<string, string | number>;
|
|
40
|
+
/** HTML attributes */
|
|
41
|
+
attributes?: Record<string, string>;
|
|
42
|
+
/** Event handlers */
|
|
43
|
+
events?: Record<string, Function>;
|
|
44
|
+
/** Legacy event handler support */
|
|
45
|
+
event?: Record<string, Function>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Definition for a single element in object-based layout schemas
|
|
49
|
+
*/
|
|
50
|
+
export interface ElementDefinition {
|
|
51
|
+
/** Optional name to reference the element */
|
|
52
|
+
name?: string;
|
|
53
|
+
/** Creator function that produces a DOM element or ComponentLike */
|
|
54
|
+
creator?: (options?: Record<string, any>) => any;
|
|
55
|
+
/** Options to pass to the creator function */
|
|
56
|
+
options?: ElementOptions;
|
|
57
|
+
/** Child elements to create and attach */
|
|
58
|
+
children?: Record<string, ElementDefinition>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Schema for object-based layout creation
|
|
62
|
+
* Array-based schemas are handled directly as arrays
|
|
63
|
+
*/
|
|
64
|
+
export interface Schema {
|
|
65
|
+
/** Root element definition */
|
|
66
|
+
element?: ElementDefinition;
|
|
67
|
+
/** Additional elements */
|
|
68
|
+
[key: string]: ElementDefinition | undefined;
|
|
69
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Viewport Constants
|
|
3
|
+
* Centralized constants for all viewport functionality
|
|
4
|
+
* Consolidated from viewport, viewport/features, and list-manager constants
|
|
5
|
+
*/
|
|
6
|
+
export declare const VIEWPORT_CONSTANTS: {
|
|
7
|
+
VIRTUAL_SCROLL: {
|
|
8
|
+
DEFAULT_ITEM_SIZE: number;
|
|
9
|
+
OVERSCAN_BUFFER: number;
|
|
10
|
+
SCROLL_SENSITIVITY: number;
|
|
11
|
+
MAX_VIRTUAL_SIZE: number;
|
|
12
|
+
AUTO_DETECT_ITEM_SIZE: boolean;
|
|
13
|
+
};
|
|
14
|
+
SCROLLING: {
|
|
15
|
+
OVERSCAN: number;
|
|
16
|
+
};
|
|
17
|
+
RENDERING: {
|
|
18
|
+
DEFAULT_MAX_POOL_SIZE: number;
|
|
19
|
+
CLASSES: {
|
|
20
|
+
ITEM: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
LOADING: {
|
|
24
|
+
CANCEL_THRESHOLD: number;
|
|
25
|
+
MAX_CONCURRENT_REQUESTS: number;
|
|
26
|
+
DEFAULT_RANGE_SIZE: number;
|
|
27
|
+
DEBOUNCE_LOADING: number;
|
|
28
|
+
MIN_RANGE_SIZE: number;
|
|
29
|
+
MAX_RANGE_SIZE: number;
|
|
30
|
+
REQUEST_TIMEOUT: number;
|
|
31
|
+
RETRY_ATTEMPTS: number;
|
|
32
|
+
RETRY_DELAY: number;
|
|
33
|
+
};
|
|
34
|
+
REQUEST_QUEUE: {
|
|
35
|
+
ENABLED: boolean;
|
|
36
|
+
MAX_QUEUE_SIZE: number;
|
|
37
|
+
MAX_ACTIVE_REQUESTS: number;
|
|
38
|
+
};
|
|
39
|
+
PLACEHOLDER: {
|
|
40
|
+
MASK_CHARACTER: string;
|
|
41
|
+
CLASS: string;
|
|
42
|
+
MAX_SAMPLE_SIZE: number;
|
|
43
|
+
PLACEHOLDER_FLAG: string;
|
|
44
|
+
RANDOM_LENGTH_VARIANCE: boolean;
|
|
45
|
+
};
|
|
46
|
+
SPEED_TRACKING: {
|
|
47
|
+
DECELERATION_FACTOR: number;
|
|
48
|
+
};
|
|
49
|
+
MOMENTUM: {
|
|
50
|
+
ENABLED: boolean;
|
|
51
|
+
DECELERATION_FACTOR: number;
|
|
52
|
+
MIN_VELOCITY: number;
|
|
53
|
+
MIN_DURATION: number;
|
|
54
|
+
MIN_VELOCITY_THRESHOLD: number;
|
|
55
|
+
FRAME_TIME: number;
|
|
56
|
+
};
|
|
57
|
+
INITIAL_LOAD: {
|
|
58
|
+
STRATEGY: string;
|
|
59
|
+
VIEWPORT_MULTIPLIER: number;
|
|
60
|
+
MIN_ITEMS: number;
|
|
61
|
+
MAX_ITEMS: number;
|
|
62
|
+
PLACEHOLDER_COUNT: number;
|
|
63
|
+
SHOW_LOADING_STATE: boolean;
|
|
64
|
+
LOADING_DELAY: number;
|
|
65
|
+
};
|
|
66
|
+
SELECTION: {
|
|
67
|
+
SELECTED_CLASS: string;
|
|
68
|
+
};
|
|
69
|
+
SCROLLBAR: {
|
|
70
|
+
CLASSES: {
|
|
71
|
+
SCROLLBAR: string;
|
|
72
|
+
SCROLLBAR_TRACK: string;
|
|
73
|
+
SCROLLBAR_THUMB: string;
|
|
74
|
+
SCROLLBAR_VISIBLE: string;
|
|
75
|
+
SCROLLBAR_DRAGGING: string;
|
|
76
|
+
SCROLLBAR_THUMB_DRAGGING: string;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
ORIENTATION: {
|
|
80
|
+
DEFAULT_ORIENTATION: string;
|
|
81
|
+
DEFAULT_CROSS_AXIS_ALIGNMENT: string;
|
|
82
|
+
REVERSE_DIRECTION: boolean;
|
|
83
|
+
};
|
|
84
|
+
PAGINATION: {
|
|
85
|
+
DEFAULT_STRATEGY: "offset" | "page" | "cursor";
|
|
86
|
+
DEFAULT_LIMIT: number;
|
|
87
|
+
STRATEGIES: {
|
|
88
|
+
PAGE: "page";
|
|
89
|
+
OFFSET: "offset";
|
|
90
|
+
CURSOR: "cursor";
|
|
91
|
+
};
|
|
92
|
+
CURSOR_CLEANUP_INTERVAL: number;
|
|
93
|
+
MAX_CURSOR_MAP_SIZE: number;
|
|
94
|
+
CURSOR_SCROLL_MARGIN_MULTIPLIER: number;
|
|
95
|
+
CURSOR_MIN_VIRTUAL_SIZE_MULTIPLIER: number;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Type for overriding constants at runtime
|
|
100
|
+
*/
|
|
101
|
+
export type ViewportConstants = typeof VIEWPORT_CONSTANTS;
|
|
102
|
+
/**
|
|
103
|
+
* Helper function to merge user constants with defaults
|
|
104
|
+
*/
|
|
105
|
+
export declare function mergeConstants(userConstants?: Partial<ViewportConstants>): ViewportConstants;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base Viewport Feature - Sets up core viewport structure
|
|
3
|
+
* Provides the foundation for other viewport features
|
|
4
|
+
*/
|
|
5
|
+
import type { ViewportContext, ViewportComponent } from "../types";
|
|
6
|
+
export interface BaseConfig {
|
|
7
|
+
className?: string;
|
|
8
|
+
orientation?: "vertical" | "horizontal";
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Base feature for viewport
|
|
12
|
+
* Sets up the DOM structure and core styles
|
|
13
|
+
*/
|
|
14
|
+
export declare const withBase: (config?: BaseConfig) => <T extends ViewportContext & ViewportComponent>(component: T) => T;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collection Feature - Data management and range loading
|
|
3
|
+
* Handles collection integration, pagination, and data fetching
|
|
4
|
+
*/
|
|
5
|
+
import type { ViewportContext, ViewportComponent } from "../types";
|
|
6
|
+
export interface CollectionConfig {
|
|
7
|
+
collection?: any;
|
|
8
|
+
rangeSize?: number;
|
|
9
|
+
strategy?: "offset" | "page" | "cursor";
|
|
10
|
+
transform?: (item: any) => any;
|
|
11
|
+
cancelLoadThreshold?: number;
|
|
12
|
+
maxConcurrentRequests?: number;
|
|
13
|
+
enableRequestQueue?: boolean;
|
|
14
|
+
maxQueueSize?: number;
|
|
15
|
+
loadOnDragEnd?: boolean;
|
|
16
|
+
initialScrollIndex?: number;
|
|
17
|
+
selectId?: string | number;
|
|
18
|
+
autoLoad?: boolean;
|
|
19
|
+
autoSelectFirst?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface CollectionComponent {
|
|
22
|
+
collection: {
|
|
23
|
+
loadRange: (offset: number, limit: number) => Promise<any[]>;
|
|
24
|
+
loadMissingRanges: (range: {
|
|
25
|
+
start: number;
|
|
26
|
+
end: number;
|
|
27
|
+
}, caller?: string) => Promise<void>;
|
|
28
|
+
getLoadedRanges: () => Set<number>;
|
|
29
|
+
getPendingRanges: () => Set<number>;
|
|
30
|
+
clearFailedRanges: () => void;
|
|
31
|
+
retryFailedRange: (rangeId: number) => Promise<any[]>;
|
|
32
|
+
setTotalItems: (total: number) => void;
|
|
33
|
+
getTotalItems: () => number;
|
|
34
|
+
getCurrentCursor: () => string | null;
|
|
35
|
+
getCursorForPage: (page: number) => string | null;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Adds collection functionality to viewport component
|
|
40
|
+
*/
|
|
41
|
+
export declare function withCollection(config?: CollectionConfig): <T extends ViewportContext & ViewportComponent>(component: T) => T & CollectionComponent;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Events Feature - Centralized event system for viewport
|
|
3
|
+
* Provides event emission and subscription for inter-feature communication
|
|
4
|
+
*/
|
|
5
|
+
import type { ViewportContext, ViewportComponent } from "../types";
|
|
6
|
+
export interface EventsConfig {
|
|
7
|
+
debug?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Events feature for viewport
|
|
11
|
+
* Centralizes all event handling for viewport features
|
|
12
|
+
*/
|
|
13
|
+
export declare const withEvents: (config?: EventsConfig) => <T extends ViewportContext & ViewportComponent>(component: T) => T;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// src/core/list-manager/features/viewport/index.ts
|
|
2
|
-
|
|
3
1
|
export { withBase } from "./base";
|
|
4
2
|
export { withCollection } from "./collection";
|
|
5
3
|
export { withEvents } from "./events";
|
|
@@ -10,11 +8,6 @@ export { withScrolling } from "./scrolling";
|
|
|
10
8
|
export { withVirtual } from "./virtual";
|
|
11
9
|
export { withPerformance } from "./performance";
|
|
12
10
|
export { withMomentum } from "./momentum";
|
|
13
|
-
|
|
14
|
-
// Utility exports
|
|
15
11
|
export { createItemSizeManager } from "./item-size";
|
|
16
12
|
export { createLoadingManager } from "./loading";
|
|
17
|
-
// No createElementFromTemplate util here; remove incorrect export
|
|
18
|
-
|
|
19
|
-
// Types
|
|
20
13
|
export type { PlaceholderComponent, PlaceholderConfig } from "./placeholders";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Item Size Management
|
|
3
|
+
* Handles item measurement, caching, and size estimation for virtual scrolling
|
|
4
|
+
* Works with both vertical (height) and horizontal (width) orientations
|
|
5
|
+
*/
|
|
6
|
+
export interface ItemSizeManager {
|
|
7
|
+
measureItem(element: HTMLElement, index: number, orientation?: "vertical" | "horizontal"): number;
|
|
8
|
+
hasMeasuredSize(index: number): boolean;
|
|
9
|
+
getMeasuredSize(index: number): number;
|
|
10
|
+
getMeasuredSizes(): Map<number, number>;
|
|
11
|
+
cacheItemSize(index: number, size: number): void;
|
|
12
|
+
clearCache(): void;
|
|
13
|
+
getItemSize(): number;
|
|
14
|
+
updateItemSize(): void;
|
|
15
|
+
calculateTotalSize(totalItems?: number): number;
|
|
16
|
+
getStats(): any;
|
|
17
|
+
onSizeUpdated?: (totalSize: number) => void;
|
|
18
|
+
onItemSizeChanged?: (newEstimate: number) => void;
|
|
19
|
+
}
|
|
20
|
+
export interface ItemSizeConfig {
|
|
21
|
+
initialEstimate?: number;
|
|
22
|
+
orientation?: "vertical" | "horizontal";
|
|
23
|
+
cacheSize?: number;
|
|
24
|
+
onSizeUpdated?: (totalSize: number) => void;
|
|
25
|
+
onItemSizeChanged?: (newEstimate: number) => void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Creates an item size manager for measuring and caching item dimensions
|
|
29
|
+
*/
|
|
30
|
+
export declare const createItemSizeManager: (config?: ItemSizeConfig) => ItemSizeManager;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loading - Velocity-based intelligent data loading for viewport
|
|
3
|
+
*
|
|
4
|
+
* This viewport module manages data loading based on scroll velocity.
|
|
5
|
+
* When scrolling fast, it cancels loads to prevent server overload.
|
|
6
|
+
*/
|
|
7
|
+
import type { ItemRange } from "../types";
|
|
8
|
+
type ListManagerComponent = any;
|
|
9
|
+
export interface LoadingConfig {
|
|
10
|
+
cancelLoadThreshold?: number;
|
|
11
|
+
maxConcurrentRequests?: number;
|
|
12
|
+
enableRequestQueue?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface LoadingManager {
|
|
15
|
+
requestLoad(range: ItemRange, priority: "high" | "normal" | "low"): void;
|
|
16
|
+
updateVelocity(velocity: number, direction: "forward" | "backward"): void;
|
|
17
|
+
cancelPendingLoads(): void;
|
|
18
|
+
getStats(): LoadingStats;
|
|
19
|
+
isRangeLoading(range: ItemRange): boolean;
|
|
20
|
+
}
|
|
21
|
+
interface LoadingStats {
|
|
22
|
+
pendingRequests: number;
|
|
23
|
+
completedRequests: number;
|
|
24
|
+
failedRequests: number;
|
|
25
|
+
cancelledRequests: number;
|
|
26
|
+
currentVelocity: number;
|
|
27
|
+
canLoad: boolean;
|
|
28
|
+
queuedRequests: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Creates a loading manager that handles data loading based on scroll velocity
|
|
32
|
+
*/
|
|
33
|
+
export declare const createLoadingManager: (component: ListManagerComponent, config?: LoadingConfig) => LoadingManager;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Momentum Feature - Adds inertial scrolling to viewport
|
|
3
|
+
* Provides smooth deceleration after touch/mouse drag gestures
|
|
4
|
+
*/
|
|
5
|
+
import type { ViewportComponent, ViewportContext } from "../types";
|
|
6
|
+
interface MomentumConfig {
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
deceleration?: number;
|
|
9
|
+
minVelocity?: number;
|
|
10
|
+
minDuration?: number;
|
|
11
|
+
minVelocityThreshold?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Adds momentum scrolling to viewport
|
|
15
|
+
*/
|
|
16
|
+
export declare const withMomentum: (config?: MomentumConfig) => <T extends ViewportContext & ViewportComponent>(component: T) => T;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/compose/features
|
|
3
|
+
* @description Performance tracking feature for components
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Performance metrics interface
|
|
7
|
+
*/
|
|
8
|
+
export interface PerformanceMetrics {
|
|
9
|
+
renderCount: number;
|
|
10
|
+
scrollCount: number;
|
|
11
|
+
averageRenderTime: number;
|
|
12
|
+
averageScrollTime: number;
|
|
13
|
+
memoryUsage: number;
|
|
14
|
+
virtualizedItems: number;
|
|
15
|
+
recycledElements: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Performance configuration
|
|
19
|
+
*/
|
|
20
|
+
export interface PerformanceConfig {
|
|
21
|
+
recycleElements?: boolean;
|
|
22
|
+
bufferSize?: number;
|
|
23
|
+
trackMemory?: boolean;
|
|
24
|
+
maxSamples?: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Component with performance tracking capabilities
|
|
28
|
+
*/
|
|
29
|
+
export interface PerformanceComponent {
|
|
30
|
+
getMetrics: () => PerformanceMetrics;
|
|
31
|
+
resetMetrics: () => any;
|
|
32
|
+
_trackScroll?: (startTime: number) => void;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Adds performance tracking to a component
|
|
36
|
+
*
|
|
37
|
+
* @param config - Performance configuration
|
|
38
|
+
* @returns Component enhancer that adds performance tracking
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const component = pipe(
|
|
43
|
+
* createBase,
|
|
44
|
+
* withElement(),
|
|
45
|
+
* withPerformance({
|
|
46
|
+
* recycleElements: true,
|
|
47
|
+
* bufferSize: 50,
|
|
48
|
+
* trackMemory: true
|
|
49
|
+
* })
|
|
50
|
+
* )(config);
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function withPerformance(config?: PerformanceConfig): (component: any) => any & PerformanceComponent;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Placeholder Feature - Smart placeholder generation
|
|
3
|
+
* Analyzes first loaded data to generate realistic masked placeholders
|
|
4
|
+
* Shows placeholders while data is loading
|
|
5
|
+
*/
|
|
6
|
+
import type { ViewportContext } from "../types";
|
|
7
|
+
import type { CollectionComponent } from "./collection";
|
|
8
|
+
/**
|
|
9
|
+
* Configuration for placeholder feature
|
|
10
|
+
*/
|
|
11
|
+
export interface PlaceholderConfig {
|
|
12
|
+
enabled?: boolean;
|
|
13
|
+
analyzeFirstLoad?: boolean;
|
|
14
|
+
maskCharacter?: string;
|
|
15
|
+
randomLengthVariance?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface PlaceholderComponent {
|
|
18
|
+
placeholders: {
|
|
19
|
+
analyzeDataStructure: (items: any[]) => void;
|
|
20
|
+
hasAnalyzedStructure: () => boolean;
|
|
21
|
+
generatePlaceholderItem: (index: number) => any;
|
|
22
|
+
generatePlaceholderItems: (range: {
|
|
23
|
+
start: number;
|
|
24
|
+
end: number;
|
|
25
|
+
}) => any[];
|
|
26
|
+
showPlaceholders: (range: {
|
|
27
|
+
start: number;
|
|
28
|
+
end: number;
|
|
29
|
+
}) => void;
|
|
30
|
+
isPlaceholder: (item: any) => boolean;
|
|
31
|
+
replacePlaceholders: (items: any[], offset: number) => void;
|
|
32
|
+
clear: () => void;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Adds placeholder functionality to viewport component
|
|
37
|
+
*/
|
|
38
|
+
export declare function withPlaceholders(config?: PlaceholderConfig): <T extends ViewportContext & CollectionComponent>(component: T) => T & PlaceholderComponent;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rendering Feature - Item rendering and positioning for viewport
|
|
3
|
+
* Handles DOM element creation, positioning, recycling, and updates
|
|
4
|
+
*/
|
|
5
|
+
import type { ViewportContext, ViewportComponent } from "../types";
|
|
6
|
+
export interface RenderingConfig {
|
|
7
|
+
template?: (item: any, index: number) => string | HTMLElement | any[] | Record<string, any>;
|
|
8
|
+
overscan?: number;
|
|
9
|
+
measureItems?: boolean;
|
|
10
|
+
enableRecycling?: boolean;
|
|
11
|
+
maxPoolSize?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Rendering feature for viewport
|
|
15
|
+
*/
|
|
16
|
+
export declare const withRendering: (config?: RenderingConfig) => <T extends ViewportContext & ViewportComponent>(component: T) => T;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scrollbar Feature - Custom scrollbar implementation
|
|
3
|
+
* Provides visual scroll indication and drag-to-scroll functionality
|
|
4
|
+
*/
|
|
5
|
+
import type { ViewportContext, ViewportComponent } from "../types";
|
|
6
|
+
export interface ScrollbarConfig {
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
autoHide?: boolean;
|
|
9
|
+
thumbMinHeight?: number;
|
|
10
|
+
thumbColor?: string;
|
|
11
|
+
trackColor?: string;
|
|
12
|
+
borderRadius?: number;
|
|
13
|
+
fadeTimeout?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface ScrollbarComponent {
|
|
16
|
+
scrollbar: {
|
|
17
|
+
show: () => void;
|
|
18
|
+
hide: () => void;
|
|
19
|
+
updateBounds: (totalVirtualSize: number, containerSize: number) => void;
|
|
20
|
+
updatePosition: (scrollPosition: number) => void;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Adds scrollbar functionality to viewport component
|
|
25
|
+
*/
|
|
26
|
+
export declare function withScrollbar(config?: ScrollbarConfig): <T extends ViewportContext & ViewportComponent>(component: T) => T & ScrollbarComponent;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scrolling Feature - Virtual scrolling with integrated velocity tracking
|
|
3
|
+
* Handles wheel events, touch/mouse events, scroll position management, velocity measurement, and momentum scrolling
|
|
4
|
+
*/
|
|
5
|
+
import type { ViewportContext, ViewportComponent } from "../types";
|
|
6
|
+
export interface ScrollingConfig {
|
|
7
|
+
orientation?: "vertical" | "horizontal";
|
|
8
|
+
sensitivity?: number;
|
|
9
|
+
smoothing?: boolean;
|
|
10
|
+
idleTimeout?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Scrolling feature for viewport
|
|
14
|
+
* Handles wheel events, velocity tracking, and idle detection
|
|
15
|
+
*/
|
|
16
|
+
export declare const withScrolling: (config?: ScrollingConfig) => <T extends ViewportContext & ViewportComponent>(component: T) => T;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utilities for viewport features
|
|
3
|
+
* Eliminates code duplication across features
|
|
4
|
+
*/
|
|
5
|
+
import type { ViewportContext, ViewportComponent } from "../types";
|
|
6
|
+
/**
|
|
7
|
+
* Wraps viewport initialization with feature-specific logic
|
|
8
|
+
* Eliminates the repeated initialization hook pattern
|
|
9
|
+
*/
|
|
10
|
+
export declare function wrapInitialize<T extends ViewportContext & ViewportComponent>(component: T, featureInit: () => void): void;
|
|
11
|
+
/**
|
|
12
|
+
* Wraps component destroy with cleanup logic
|
|
13
|
+
* Eliminates the repeated destroy hook pattern
|
|
14
|
+
*/
|
|
15
|
+
export declare function wrapDestroy<T extends Record<string, any>>(component: T, cleanup: () => void): void;
|
|
16
|
+
/**
|
|
17
|
+
* Gets viewport state with proper typing
|
|
18
|
+
* Eliminates repeated (component.viewport as any).state
|
|
19
|
+
*/
|
|
20
|
+
export declare function getViewportState(component: ViewportComponent): any;
|
|
21
|
+
/**
|
|
22
|
+
* Checks if an item is a placeholder
|
|
23
|
+
* Eliminates duplicated placeholder detection logic
|
|
24
|
+
*/
|
|
25
|
+
export declare function isPlaceholder(item: any): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a range key for deduplication
|
|
28
|
+
* Used by multiple features for tracking ranges
|
|
29
|
+
*/
|
|
30
|
+
export declare function getRangeKey(range: {
|
|
31
|
+
start: number;
|
|
32
|
+
end: number;
|
|
33
|
+
}): string;
|
|
34
|
+
/**
|
|
35
|
+
* Clamps a value between min and max
|
|
36
|
+
* Used by multiple features for boundary checking
|
|
37
|
+
*/
|
|
38
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
39
|
+
/**
|
|
40
|
+
* Stores a function reference on the component for later access
|
|
41
|
+
* Eliminates pattern like (component as any)._featureFunction = fn
|
|
42
|
+
*/
|
|
43
|
+
export declare function storeFeatureFunction<T extends Record<string, any>>(component: T, name: string, fn: Function): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Virtual Feature - Core virtual scrolling calculations
|
|
3
|
+
* Handles visible range calculation and total virtual size management
|
|
4
|
+
*/
|
|
5
|
+
import type { ViewportContext, ViewportComponent } from "../types";
|
|
6
|
+
export interface VirtualConfig {
|
|
7
|
+
itemSize?: number;
|
|
8
|
+
overscan?: number;
|
|
9
|
+
orientation?: "vertical" | "horizontal";
|
|
10
|
+
autoDetectItemSize?: boolean;
|
|
11
|
+
debug?: boolean;
|
|
12
|
+
initialScrollIndex?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Virtual scrolling feature for viewport
|
|
16
|
+
* Handles visible range calculations with compression for large datasets
|
|
17
|
+
*/
|
|
18
|
+
export declare const withVirtual: (config?: VirtualConfig) => <T extends ViewportContext & ViewportComponent>(component: T) => T;
|