mtrl-addons 0.2.1 → 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 -9
- 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 +6 -1
- package/src/styles/components/_vlist.scss +234 -213
- package/.cursorrules +0 -117
- package/AI.md +0 -241
- package/build.js +0 -201
- 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 -322
- package/src/components/vlist/features/selection.ts +0 -444
- package/src/components/vlist/features/viewport.ts +0 -65
- package/src/components/vlist/features.ts +0 -112
- package/src/components/vlist/types.ts +0 -591
- 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 -1001
- package/src/core/layout/types.ts +0 -95
- package/src/core/viewport/constants.ts +0 -140
- package/src/core/viewport/features/base.ts +0 -73
- package/src/core/viewport/features/collection.ts +0 -882
- 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 -260
- 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 -568
- package/src/core/viewport/features/scrollbar.ts +0 -434
- package/src/core/viewport/features/scrolling.ts +0 -618
- package/src/core/viewport/features/utils.ts +0 -88
- package/src/core/viewport/features/virtual.ts +0 -384
- 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 -246
- 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
package/src/core/layout/types.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
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
|
-
|
|
7
|
-
// Re-export core types from schema processor for backward compatibility
|
|
8
|
-
import type {
|
|
9
|
-
LayoutConfig,
|
|
10
|
-
LayoutItemConfig,
|
|
11
|
-
LayoutOptions,
|
|
12
|
-
LayoutResult,
|
|
13
|
-
} from "./schema";
|
|
14
|
-
|
|
15
|
-
export type { LayoutConfig, LayoutItemConfig, LayoutOptions, LayoutResult };
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Interface for component-like objects
|
|
19
|
-
*/
|
|
20
|
-
export interface ComponentLike {
|
|
21
|
-
/** DOM element reference */
|
|
22
|
-
element: any;
|
|
23
|
-
/** Optional method to clean up resources */
|
|
24
|
-
destroy?: () => void;
|
|
25
|
-
/** Allow additional properties */
|
|
26
|
-
[key: string]: any;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Extended options for element creation
|
|
31
|
-
* Used in object-based schemas
|
|
32
|
-
*/
|
|
33
|
-
export interface ElementOptions extends Record<string, any> {
|
|
34
|
-
/** Layout configuration for the element */
|
|
35
|
-
layout?: LayoutConfig;
|
|
36
|
-
|
|
37
|
-
/** Layout item configuration */
|
|
38
|
-
layoutItem?: LayoutItemConfig;
|
|
39
|
-
|
|
40
|
-
/** CSS classes to apply (with automatic mtrl- prefix) */
|
|
41
|
-
class?: string;
|
|
42
|
-
|
|
43
|
-
/** Additional CSS classes (alias for class) */
|
|
44
|
-
className?: string;
|
|
45
|
-
|
|
46
|
-
/** CSS classes to apply without prefix */
|
|
47
|
-
rawClass?: string | string[];
|
|
48
|
-
|
|
49
|
-
/** HTML tag name for createElement */
|
|
50
|
-
tag?: string;
|
|
51
|
-
|
|
52
|
-
/** Text content for the element */
|
|
53
|
-
textContent?: string;
|
|
54
|
-
|
|
55
|
-
/** Inline styles */
|
|
56
|
-
style?: Record<string, string | number>;
|
|
57
|
-
|
|
58
|
-
/** HTML attributes */
|
|
59
|
-
attributes?: Record<string, string>;
|
|
60
|
-
|
|
61
|
-
/** Event handlers */
|
|
62
|
-
events?: Record<string, Function>;
|
|
63
|
-
|
|
64
|
-
/** Legacy event handler support */
|
|
65
|
-
event?: Record<string, Function>;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Definition for a single element in object-based layout schemas
|
|
70
|
-
*/
|
|
71
|
-
export interface ElementDefinition {
|
|
72
|
-
/** Optional name to reference the element */
|
|
73
|
-
name?: string;
|
|
74
|
-
|
|
75
|
-
/** Creator function that produces a DOM element or ComponentLike */
|
|
76
|
-
creator?: (options?: Record<string, any>) => any;
|
|
77
|
-
|
|
78
|
-
/** Options to pass to the creator function */
|
|
79
|
-
options?: ElementOptions;
|
|
80
|
-
|
|
81
|
-
/** Child elements to create and attach */
|
|
82
|
-
children?: Record<string, ElementDefinition>;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Schema for object-based layout creation
|
|
87
|
-
* Array-based schemas are handled directly as arrays
|
|
88
|
-
*/
|
|
89
|
-
export interface Schema {
|
|
90
|
-
/** Root element definition */
|
|
91
|
-
element?: ElementDefinition;
|
|
92
|
-
|
|
93
|
-
/** Additional elements */
|
|
94
|
-
[key: string]: ElementDefinition | undefined;
|
|
95
|
-
}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
// src/core/viewport/constants.ts
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Viewport Constants
|
|
5
|
-
* Centralized constants for all viewport functionality
|
|
6
|
-
* Consolidated from viewport, viewport/features, and list-manager constants
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
export const VIEWPORT_CONSTANTS = {
|
|
10
|
-
// Virtual scrolling defaults
|
|
11
|
-
VIRTUAL_SCROLL: {
|
|
12
|
-
DEFAULT_ITEM_SIZE: 48,
|
|
13
|
-
OVERSCAN_BUFFER: 2,
|
|
14
|
-
SCROLL_SENSITIVITY: 0.7,
|
|
15
|
-
MAX_VIRTUAL_SIZE: 100 * 1000 * 1000, // 100M pixels - modern browsers can handle this
|
|
16
|
-
AUTO_DETECT_ITEM_SIZE: true, // Enable automatic item size detection
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
// Scrolling settings
|
|
20
|
-
SCROLLING: {
|
|
21
|
-
OVERSCAN: 1, // From features/constants
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
// Rendering settings
|
|
25
|
-
RENDERING: {
|
|
26
|
-
// Element recycling
|
|
27
|
-
DEFAULT_MAX_POOL_SIZE: 100,
|
|
28
|
-
CLASSES: {
|
|
29
|
-
ITEM: "viewport-item",
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
// Loading settings
|
|
34
|
-
LOADING: {
|
|
35
|
-
CANCEL_THRESHOLD: 2, // px/ms - velocity above which loads cancel
|
|
36
|
-
MAX_CONCURRENT_REQUESTS: 1, // Parallel requests allowed
|
|
37
|
-
DEFAULT_RANGE_SIZE: 20, // Items per request
|
|
38
|
-
DEBOUNCE_LOADING: 150, // Debounce delay (ms)
|
|
39
|
-
MIN_RANGE_SIZE: 10, // Minimum items per load
|
|
40
|
-
MAX_RANGE_SIZE: 100, // Maximum items per load
|
|
41
|
-
REQUEST_TIMEOUT: 5000, // Request timeout (ms)
|
|
42
|
-
RETRY_ATTEMPTS: 2, // Failed request retries
|
|
43
|
-
RETRY_DELAY: 1000, // Delay between retries (ms)
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
// Request queue configuration (from features/constants)
|
|
47
|
-
REQUEST_QUEUE: {
|
|
48
|
-
ENABLED: true, // Enable request queuing
|
|
49
|
-
MAX_QUEUE_SIZE: 1, // Max queued requests
|
|
50
|
-
MAX_ACTIVE_REQUESTS: 2, // Max concurrent active requests
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
// Placeholder settings
|
|
54
|
-
PLACEHOLDER: {
|
|
55
|
-
MASK_CHARACTER: "X", // Updated from list-manager
|
|
56
|
-
CLASS: "viewport-item--placeholder",
|
|
57
|
-
MAX_SAMPLE_SIZE: 20,
|
|
58
|
-
PLACEHOLDER_FLAG: "_placeholder",
|
|
59
|
-
RANDOM_LENGTH_VARIANCE: true,
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
// Speed tracking (from list-manager)
|
|
63
|
-
SPEED_TRACKING: {
|
|
64
|
-
// Velocity calculation
|
|
65
|
-
DECELERATION_FACTOR: 0.85, // velocity decay per frame
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
// Momentum settings
|
|
69
|
-
MOMENTUM: {
|
|
70
|
-
ENABLED: false, // Enable momentum by default
|
|
71
|
-
DECELERATION_FACTOR: 0.85, // How quickly velocity decreases per frame
|
|
72
|
-
MIN_VELOCITY: 0.1, // Minimum velocity before stopping (px/ms)
|
|
73
|
-
MIN_DURATION: 300, // Maximum gesture duration to trigger momentum (ms)
|
|
74
|
-
MIN_VELOCITY_THRESHOLD: 0.5, // Minimum velocity to trigger momentum (px/ms)
|
|
75
|
-
FRAME_TIME: 16, // Assumed frame time for calculations (ms)
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
// Initial load configuration (from list-manager)
|
|
79
|
-
INITIAL_LOAD: {
|
|
80
|
-
STRATEGY: "placeholders", // "placeholders" | "direct" | "progressive"
|
|
81
|
-
VIEWPORT_MULTIPLIER: 1.5, // load 1.5x viewport capacity
|
|
82
|
-
MIN_ITEMS: 10,
|
|
83
|
-
MAX_ITEMS: 100,
|
|
84
|
-
PLACEHOLDER_COUNT: 20, // default placeholder count
|
|
85
|
-
SHOW_LOADING_STATE: true,
|
|
86
|
-
LOADING_DELAY: 100, // ms - delay before showing loading state
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
// Scrollbar settings (from list-manager)
|
|
90
|
-
SCROLLBAR: {
|
|
91
|
-
// CSS classes
|
|
92
|
-
CLASSES: {
|
|
93
|
-
SCROLLBAR: "viewport__scrollbar",
|
|
94
|
-
SCROLLBAR_TRACK: "viewport__scrollbar-track",
|
|
95
|
-
SCROLLBAR_THUMB: "viewport__scrollbar-thumb",
|
|
96
|
-
SCROLLBAR_VISIBLE: "viewport__scrollbar--visible",
|
|
97
|
-
SCROLLBAR_DRAGGING: "viewport__scrollbar--dragging",
|
|
98
|
-
SCROLLBAR_THUMB_DRAGGING: "viewport__scrollbar-thumb--dragging",
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
|
|
102
|
-
// Orientation (from list-manager)
|
|
103
|
-
ORIENTATION: {
|
|
104
|
-
DEFAULT_ORIENTATION: "vertical",
|
|
105
|
-
DEFAULT_CROSS_AXIS_ALIGNMENT: "stretch",
|
|
106
|
-
REVERSE_DIRECTION: false,
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
PAGINATION: {
|
|
110
|
-
DEFAULT_STRATEGY: "offset" as "offset" | "page" | "cursor",
|
|
111
|
-
DEFAULT_LIMIT: 20,
|
|
112
|
-
STRATEGIES: {
|
|
113
|
-
PAGE: "page" as const,
|
|
114
|
-
OFFSET: "offset" as const,
|
|
115
|
-
CURSOR: "cursor" as const,
|
|
116
|
-
},
|
|
117
|
-
CURSOR_CLEANUP_INTERVAL: 60000, // Clean up old cursors every minute
|
|
118
|
-
MAX_CURSOR_MAP_SIZE: 1000, // Maximum number of cursors to keep in memory
|
|
119
|
-
// Cursor-specific virtual sizing
|
|
120
|
-
CURSOR_SCROLL_MARGIN_MULTIPLIER: 3, // Multiply rangeSize by this for scroll margin
|
|
121
|
-
CURSOR_MIN_VIRTUAL_SIZE_MULTIPLIER: 3, // Minimum virtual size as multiplier of rangeSize
|
|
122
|
-
},
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Type for overriding constants at runtime
|
|
127
|
-
*/
|
|
128
|
-
export type ViewportConstants = typeof VIEWPORT_CONSTANTS;
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Helper function to merge user constants with defaults
|
|
132
|
-
*/
|
|
133
|
-
export function mergeConstants(
|
|
134
|
-
userConstants: Partial<ViewportConstants> = {}
|
|
135
|
-
): ViewportConstants {
|
|
136
|
-
return {
|
|
137
|
-
...VIEWPORT_CONSTANTS,
|
|
138
|
-
...userConstants,
|
|
139
|
-
};
|
|
140
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
// src/core/viewport/features/base.ts
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Base Viewport Feature - Sets up core viewport structure
|
|
5
|
-
* Provides the foundation for other viewport features
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type { ViewportContext, ViewportComponent } from "../types";
|
|
9
|
-
import { wrapInitialize, getViewportState } from "./utils";
|
|
10
|
-
|
|
11
|
-
export interface BaseConfig {
|
|
12
|
-
className?: string;
|
|
13
|
-
orientation?: "vertical" | "horizontal";
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Base feature for viewport
|
|
18
|
-
* Sets up the DOM structure and core styles
|
|
19
|
-
*/
|
|
20
|
-
export const withBase = (config: BaseConfig = {}) => {
|
|
21
|
-
return <T extends ViewportContext & ViewportComponent>(component: T): T => {
|
|
22
|
-
const { className = "mtrl-viewport", orientation = "vertical" } = config;
|
|
23
|
-
|
|
24
|
-
// Use the shared wrapper utility
|
|
25
|
-
wrapInitialize(component, () => {
|
|
26
|
-
const element = component.element;
|
|
27
|
-
if (!element) return;
|
|
28
|
-
|
|
29
|
-
// Create viewport structure
|
|
30
|
-
let viewportElement = element.querySelector(
|
|
31
|
-
".mtrl-viewport"
|
|
32
|
-
) as HTMLElement;
|
|
33
|
-
|
|
34
|
-
if (!viewportElement) {
|
|
35
|
-
viewportElement = document.createElement("div");
|
|
36
|
-
viewportElement.className = className;
|
|
37
|
-
viewportElement.style.cssText = `
|
|
38
|
-
position: relative;
|
|
39
|
-
width: 100%;
|
|
40
|
-
height: 100%;
|
|
41
|
-
overflow: hidden;
|
|
42
|
-
`;
|
|
43
|
-
|
|
44
|
-
// Set orientation
|
|
45
|
-
viewportElement.setAttribute("data-orientation", orientation);
|
|
46
|
-
|
|
47
|
-
// Create items container
|
|
48
|
-
const itemsContainer = document.createElement("div");
|
|
49
|
-
itemsContainer.className = "mtrl-viewport-items";
|
|
50
|
-
itemsContainer.style.cssText = `
|
|
51
|
-
position: relative;
|
|
52
|
-
width: 100%;
|
|
53
|
-
`;
|
|
54
|
-
|
|
55
|
-
viewportElement.appendChild(itemsContainer);
|
|
56
|
-
element.appendChild(viewportElement);
|
|
57
|
-
|
|
58
|
-
// Update viewport state with containers using utility
|
|
59
|
-
const state = getViewportState(component);
|
|
60
|
-
if (state) {
|
|
61
|
-
state.viewportElement = viewportElement;
|
|
62
|
-
state.itemsContainer = itemsContainer;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Store references on component
|
|
66
|
-
(component as any).viewportElement = viewportElement;
|
|
67
|
-
(component as any).itemsContainer = itemsContainer;
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
return component;
|
|
72
|
-
};
|
|
73
|
-
};
|