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
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/gestures
|
|
3
|
+
* @description Long press gesture detection
|
|
4
|
+
*/
|
|
5
|
+
import { LongPressEvent, GestureDetectionContext } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* Detect long press gesture
|
|
8
|
+
*
|
|
9
|
+
* This is slightly different from other gesture detectors as it sets up a timer
|
|
10
|
+
* and returns a callback function that will be triggered when the timer completes.
|
|
11
|
+
*
|
|
12
|
+
* @param context - Gesture detection context
|
|
13
|
+
* @param callback - Function to call when long press is detected
|
|
14
|
+
* @returns Cleanup function to cancel the long press detection
|
|
15
|
+
*/
|
|
16
|
+
export declare function detectLongPress(context: GestureDetectionContext, callback: (event: LongPressEvent) => void): () => void;
|
|
17
|
+
/**
|
|
18
|
+
* Check if movement would cancel a long press
|
|
19
|
+
*
|
|
20
|
+
* @param context - Gesture detection context
|
|
21
|
+
* @returns Whether the long press should be canceled
|
|
22
|
+
*/
|
|
23
|
+
export declare function shouldCancelLongPress(context: GestureDetectionContext): boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/gestures
|
|
3
|
+
* @description Gesture management system for handling touch and mouse interactions
|
|
4
|
+
*/
|
|
5
|
+
import { GestureConfig, GestureManager, GESTURE_TYPES, SWIPE_DIRECTIONS } from './types';
|
|
6
|
+
export { GESTURE_TYPES, SWIPE_DIRECTIONS };
|
|
7
|
+
/**
|
|
8
|
+
* Creates a gesture manager for handling touch and mouse interactions
|
|
9
|
+
*
|
|
10
|
+
* @param element - DOM element to attach gesture recognition to
|
|
11
|
+
* @param config - Configuration options
|
|
12
|
+
* @returns Gesture manager instance
|
|
13
|
+
*/
|
|
14
|
+
export declare const createGestureManager: (element: HTMLElement, config?: GestureConfig) => GestureManager;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/gestures
|
|
3
|
+
* @description Pan gesture detection
|
|
4
|
+
*/
|
|
5
|
+
import { PanEvent, GestureDetectionContext } from "./types";
|
|
6
|
+
/**
|
|
7
|
+
* Detect pan gesture
|
|
8
|
+
*
|
|
9
|
+
* @param context - Gesture detection context
|
|
10
|
+
* @returns Pan event or null if no significant movement
|
|
11
|
+
*/
|
|
12
|
+
export declare function detectPan(context: GestureDetectionContext): PanEvent | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/gestures
|
|
3
|
+
* @description Pinch gesture detection
|
|
4
|
+
*/
|
|
5
|
+
import { PinchEvent, GestureDetectionContext } from "./types";
|
|
6
|
+
/**
|
|
7
|
+
* Detect pinch gesture
|
|
8
|
+
*
|
|
9
|
+
* @param context - Gesture detection context
|
|
10
|
+
* @param touch1 - First touch point
|
|
11
|
+
* @param touch2 - Second touch point
|
|
12
|
+
* @returns Pinch event or null if no pinch detected
|
|
13
|
+
*/
|
|
14
|
+
export declare function detectPinch(context: GestureDetectionContext, touch1: Touch, touch2: Touch): PinchEvent | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/gestures
|
|
3
|
+
* @description Rotate gesture detection
|
|
4
|
+
*/
|
|
5
|
+
import { RotateEvent, GestureDetectionContext } from "./types";
|
|
6
|
+
/**
|
|
7
|
+
* Detect rotate gesture
|
|
8
|
+
*
|
|
9
|
+
* @param context - Gesture detection context
|
|
10
|
+
* @param touch1 - First touch point
|
|
11
|
+
* @param touch2 - Second touch point
|
|
12
|
+
* @returns Rotate event or null if no rotation detected
|
|
13
|
+
*/
|
|
14
|
+
export declare function detectRotate(context: GestureDetectionContext, touch1: Touch, touch2: Touch): RotateEvent | null;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/gestures
|
|
3
|
+
* @description Swipe gesture detection
|
|
4
|
+
*/
|
|
5
|
+
import { SwipeEvent, GestureDetectionContext, SWIPE_DIRECTIONS } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* Determine swipe direction based on delta X and Y
|
|
8
|
+
*
|
|
9
|
+
* @param deltaX - Distance moved in X direction
|
|
10
|
+
* @param deltaY - Distance moved in Y direction
|
|
11
|
+
* @returns Direction of the swipe
|
|
12
|
+
*/
|
|
13
|
+
export declare function getSwipeDirection(deltaX: number, deltaY: number): SWIPE_DIRECTIONS;
|
|
14
|
+
/**
|
|
15
|
+
* Detect swipe gesture
|
|
16
|
+
*
|
|
17
|
+
* @param context - Gesture detection context
|
|
18
|
+
* @returns Swipe event or null if no swipe detected
|
|
19
|
+
*/
|
|
20
|
+
export declare function detectSwipe(context: GestureDetectionContext): SwipeEvent | null;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/gestures
|
|
3
|
+
* @description Tap gesture detection
|
|
4
|
+
*/
|
|
5
|
+
import { TapEvent, GestureDetectionContext } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* Detect tap gesture
|
|
8
|
+
*
|
|
9
|
+
* @param context - Gesture detection context
|
|
10
|
+
* @returns Tap event or null if no tap detected
|
|
11
|
+
*/
|
|
12
|
+
export declare function detectTap(context: GestureDetectionContext): TapEvent | null;
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/gestures
|
|
3
|
+
* @description Type definitions for the gesture system
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Types of gestures supported by the system
|
|
7
|
+
*/
|
|
8
|
+
export declare enum GESTURE_TYPES {
|
|
9
|
+
TAP = "tap",
|
|
10
|
+
SWIPE = "swipe",
|
|
11
|
+
SWIPE_LEFT = "swipeleft",
|
|
12
|
+
SWIPE_RIGHT = "swiperight",
|
|
13
|
+
SWIPE_UP = "swipeup",
|
|
14
|
+
SWIPE_DOWN = "swipedown",
|
|
15
|
+
PINCH = "pinch",
|
|
16
|
+
ROTATE = "rotate",
|
|
17
|
+
LONG_PRESS = "longpress",
|
|
18
|
+
PAN = "pan"
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Direction of swipe gestures
|
|
22
|
+
*/
|
|
23
|
+
export declare enum SWIPE_DIRECTIONS {
|
|
24
|
+
UP = "up",
|
|
25
|
+
DOWN = "down",
|
|
26
|
+
LEFT = "left",
|
|
27
|
+
RIGHT = "right"
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Configuration options for gesture recognition
|
|
31
|
+
*/
|
|
32
|
+
export interface GestureConfig {
|
|
33
|
+
/**
|
|
34
|
+
* Minimum distance (in pixels) to recognize a swipe
|
|
35
|
+
* @default 30
|
|
36
|
+
*/
|
|
37
|
+
swipeThreshold?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Maximum time (in ms) in which a swipe must be completed
|
|
40
|
+
* @default 300
|
|
41
|
+
*/
|
|
42
|
+
swipeTimeThreshold?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Time (in ms) to recognize a long press
|
|
45
|
+
* @default 500
|
|
46
|
+
*/
|
|
47
|
+
longPressTime?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Distance threshold (in pixels) for tap recognition
|
|
50
|
+
* @default 10
|
|
51
|
+
*/
|
|
52
|
+
tapDistanceThreshold?: number;
|
|
53
|
+
/**
|
|
54
|
+
* Whether to prevent default behaviors on touch events
|
|
55
|
+
* @default true
|
|
56
|
+
*/
|
|
57
|
+
preventDefault?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Whether to stop event propagation
|
|
60
|
+
* @default false
|
|
61
|
+
*/
|
|
62
|
+
stopPropagation?: boolean;
|
|
63
|
+
[key: string]: any;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Base gesture event data
|
|
67
|
+
*/
|
|
68
|
+
export interface GestureEvent {
|
|
69
|
+
/**
|
|
70
|
+
* Type of the gesture
|
|
71
|
+
*/
|
|
72
|
+
type: string;
|
|
73
|
+
/**
|
|
74
|
+
* Original DOM event
|
|
75
|
+
*/
|
|
76
|
+
originalEvent: Event;
|
|
77
|
+
/**
|
|
78
|
+
* Element the gesture was triggered on
|
|
79
|
+
*/
|
|
80
|
+
target: EventTarget;
|
|
81
|
+
/**
|
|
82
|
+
* Timestamp when the gesture started
|
|
83
|
+
*/
|
|
84
|
+
startTime: number;
|
|
85
|
+
/**
|
|
86
|
+
* Timestamp when the gesture ended
|
|
87
|
+
*/
|
|
88
|
+
endTime: number;
|
|
89
|
+
/**
|
|
90
|
+
* Gesture duration in milliseconds
|
|
91
|
+
*/
|
|
92
|
+
duration: number;
|
|
93
|
+
/**
|
|
94
|
+
* Whether default behavior was prevented
|
|
95
|
+
*/
|
|
96
|
+
defaultPrevented: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Prevent default behavior
|
|
99
|
+
*/
|
|
100
|
+
preventDefault: () => void;
|
|
101
|
+
/**
|
|
102
|
+
* Stop event propagation
|
|
103
|
+
*/
|
|
104
|
+
stopPropagation: () => void;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Tap gesture event data
|
|
108
|
+
*/
|
|
109
|
+
export interface TapEvent extends GestureEvent {
|
|
110
|
+
type: 'tap';
|
|
111
|
+
/**
|
|
112
|
+
* Number of taps (for double tap detection)
|
|
113
|
+
*/
|
|
114
|
+
count: number;
|
|
115
|
+
/**
|
|
116
|
+
* X position of the tap
|
|
117
|
+
*/
|
|
118
|
+
x: number;
|
|
119
|
+
/**
|
|
120
|
+
* Y position of the tap
|
|
121
|
+
*/
|
|
122
|
+
y: number;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Swipe gesture event data
|
|
126
|
+
*/
|
|
127
|
+
export interface SwipeEvent extends GestureEvent {
|
|
128
|
+
type: 'swipe' | 'swipeleft' | 'swiperight' | 'swipeup' | 'swipedown';
|
|
129
|
+
/**
|
|
130
|
+
* Direction of the swipe
|
|
131
|
+
*/
|
|
132
|
+
direction: 'up' | 'down' | 'left' | 'right';
|
|
133
|
+
/**
|
|
134
|
+
* Distance swiped in the X direction
|
|
135
|
+
*/
|
|
136
|
+
deltaX: number;
|
|
137
|
+
/**
|
|
138
|
+
* Distance swiped in the Y direction
|
|
139
|
+
*/
|
|
140
|
+
deltaY: number;
|
|
141
|
+
/**
|
|
142
|
+
* Total distance swiped
|
|
143
|
+
*/
|
|
144
|
+
distance: number;
|
|
145
|
+
/**
|
|
146
|
+
* Velocity of the swipe in pixels per millisecond
|
|
147
|
+
*/
|
|
148
|
+
velocity: number;
|
|
149
|
+
/**
|
|
150
|
+
* Start X position
|
|
151
|
+
*/
|
|
152
|
+
startX: number;
|
|
153
|
+
/**
|
|
154
|
+
* Start Y position
|
|
155
|
+
*/
|
|
156
|
+
startY: number;
|
|
157
|
+
/**
|
|
158
|
+
* End X position
|
|
159
|
+
*/
|
|
160
|
+
endX: number;
|
|
161
|
+
/**
|
|
162
|
+
* End Y position
|
|
163
|
+
*/
|
|
164
|
+
endY: number;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Long press gesture event data
|
|
168
|
+
*/
|
|
169
|
+
export interface LongPressEvent extends GestureEvent {
|
|
170
|
+
type: 'longpress';
|
|
171
|
+
/**
|
|
172
|
+
* X position of the long press
|
|
173
|
+
*/
|
|
174
|
+
x: number;
|
|
175
|
+
/**
|
|
176
|
+
* Y position of the long press
|
|
177
|
+
*/
|
|
178
|
+
y: number;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Pinch gesture event data
|
|
182
|
+
*/
|
|
183
|
+
export interface PinchEvent extends GestureEvent {
|
|
184
|
+
type: 'pinch';
|
|
185
|
+
/**
|
|
186
|
+
* Scale factor of the pinch (>1 for zoom in, <1 for zoom out)
|
|
187
|
+
*/
|
|
188
|
+
scale: number;
|
|
189
|
+
/**
|
|
190
|
+
* Center X position of the pinch
|
|
191
|
+
*/
|
|
192
|
+
centerX: number;
|
|
193
|
+
/**
|
|
194
|
+
* Center Y position of the pinch
|
|
195
|
+
*/
|
|
196
|
+
centerY: number;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Rotate gesture event data
|
|
200
|
+
*/
|
|
201
|
+
export interface RotateEvent extends GestureEvent {
|
|
202
|
+
type: 'rotate';
|
|
203
|
+
/**
|
|
204
|
+
* Rotation angle in degrees
|
|
205
|
+
*/
|
|
206
|
+
rotation: number;
|
|
207
|
+
/**
|
|
208
|
+
* Center X position of the rotation
|
|
209
|
+
*/
|
|
210
|
+
centerX: number;
|
|
211
|
+
/**
|
|
212
|
+
* Center Y position of the rotation
|
|
213
|
+
*/
|
|
214
|
+
centerY: number;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Pan gesture event data
|
|
218
|
+
*/
|
|
219
|
+
export interface PanEvent extends GestureEvent {
|
|
220
|
+
type: 'pan';
|
|
221
|
+
/**
|
|
222
|
+
* Distance panned in the X direction
|
|
223
|
+
*/
|
|
224
|
+
deltaX: number;
|
|
225
|
+
/**
|
|
226
|
+
* Distance panned in the Y direction
|
|
227
|
+
*/
|
|
228
|
+
deltaY: number;
|
|
229
|
+
/**
|
|
230
|
+
* Start X position
|
|
231
|
+
*/
|
|
232
|
+
startX: number;
|
|
233
|
+
/**
|
|
234
|
+
* Start Y position
|
|
235
|
+
*/
|
|
236
|
+
startY: number;
|
|
237
|
+
/**
|
|
238
|
+
* Current X position
|
|
239
|
+
*/
|
|
240
|
+
currentX: number;
|
|
241
|
+
/**
|
|
242
|
+
* Current Y position
|
|
243
|
+
*/
|
|
244
|
+
currentY: number;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Union type of all gesture events
|
|
248
|
+
*/
|
|
249
|
+
export type AnyGestureEvent = TapEvent | SwipeEvent | LongPressEvent | PinchEvent | RotateEvent | PanEvent;
|
|
250
|
+
/**
|
|
251
|
+
* Handler for gesture events
|
|
252
|
+
*/
|
|
253
|
+
export type GestureHandler = (event: AnyGestureEvent) => void;
|
|
254
|
+
/**
|
|
255
|
+
* Gesture state for tracking touch interactions
|
|
256
|
+
*/
|
|
257
|
+
export interface GestureState {
|
|
258
|
+
active: boolean;
|
|
259
|
+
startTime: number;
|
|
260
|
+
startX: number;
|
|
261
|
+
startY: number;
|
|
262
|
+
lastX: number;
|
|
263
|
+
lastY: number;
|
|
264
|
+
currentX: number;
|
|
265
|
+
currentY: number;
|
|
266
|
+
touchCount: number;
|
|
267
|
+
longPressTimer: number | null;
|
|
268
|
+
startDistance: number;
|
|
269
|
+
startAngle: number;
|
|
270
|
+
lastTapTime: number;
|
|
271
|
+
tapCount: number;
|
|
272
|
+
target: EventTarget | null;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Context for gesture detection
|
|
276
|
+
*/
|
|
277
|
+
export interface GestureDetectionContext {
|
|
278
|
+
state: GestureState;
|
|
279
|
+
options: Required<GestureConfig>;
|
|
280
|
+
originalEvent: Event;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Gesture manager interface
|
|
284
|
+
*/
|
|
285
|
+
export interface GestureManager {
|
|
286
|
+
/**
|
|
287
|
+
* Add an event listener for a gesture
|
|
288
|
+
* @param eventType - Gesture type
|
|
289
|
+
* @param handler - Event handler
|
|
290
|
+
* @returns Gesture manager for chaining
|
|
291
|
+
*/
|
|
292
|
+
on: (eventType: string, handler: GestureHandler) => GestureManager;
|
|
293
|
+
/**
|
|
294
|
+
* Remove an event listener for a gesture
|
|
295
|
+
* @param eventType - Gesture type
|
|
296
|
+
* @param handler - Event handler
|
|
297
|
+
* @returns Gesture manager for chaining
|
|
298
|
+
*/
|
|
299
|
+
off: (eventType: string, handler: GestureHandler) => GestureManager;
|
|
300
|
+
/**
|
|
301
|
+
* Check if a gesture is supported on the current device
|
|
302
|
+
* @param gestureType - Type of gesture to check
|
|
303
|
+
* @returns Whether the gesture is supported
|
|
304
|
+
*/
|
|
305
|
+
isSupported: (gestureType: string) => boolean;
|
|
306
|
+
/**
|
|
307
|
+
* Enable gesture recognition
|
|
308
|
+
* @returns Gesture manager for chaining
|
|
309
|
+
*/
|
|
310
|
+
enable: () => GestureManager;
|
|
311
|
+
/**
|
|
312
|
+
* Disable gesture recognition
|
|
313
|
+
* @returns Gesture manager for chaining
|
|
314
|
+
*/
|
|
315
|
+
disable: () => GestureManager;
|
|
316
|
+
/**
|
|
317
|
+
* Clean up event listeners
|
|
318
|
+
*/
|
|
319
|
+
destroy: () => void;
|
|
320
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/gestures
|
|
3
|
+
* @description Utility functions for gesture detection
|
|
4
|
+
*/
|
|
5
|
+
import { GestureEvent, GestureState } from "./types";
|
|
6
|
+
/**
|
|
7
|
+
* Calculate distance between two points
|
|
8
|
+
*
|
|
9
|
+
* @param x1 - X coordinate of first point
|
|
10
|
+
* @param y1 - Y coordinate of first point
|
|
11
|
+
* @param x2 - X coordinate of second point
|
|
12
|
+
* @param y2 - Y coordinate of second point
|
|
13
|
+
* @returns Distance between the points
|
|
14
|
+
*/
|
|
15
|
+
export declare function getDistance(x1: number, y1: number, x2: number, y2: number): number;
|
|
16
|
+
/**
|
|
17
|
+
* Calculate angle between two points in degrees (0-360)
|
|
18
|
+
*
|
|
19
|
+
* @param x1 - X coordinate of first point
|
|
20
|
+
* @param y1 - Y coordinate of first point
|
|
21
|
+
* @param x2 - X coordinate of second point
|
|
22
|
+
* @param y2 - Y coordinate of second point
|
|
23
|
+
* @returns Angle in degrees
|
|
24
|
+
*/
|
|
25
|
+
export declare function getAngle(x1: number, y1: number, x2: number, y2: number): number;
|
|
26
|
+
/**
|
|
27
|
+
* Create a base gesture event
|
|
28
|
+
*
|
|
29
|
+
* @param type - Type of gesture
|
|
30
|
+
* @param originalEvent - Original DOM event
|
|
31
|
+
* @param state - Current gesture state
|
|
32
|
+
* @returns Base gesture event object
|
|
33
|
+
*/
|
|
34
|
+
export declare function createGestureEvent(type: string, originalEvent: Event, state: GestureState): GestureEvent;
|
|
35
|
+
/**
|
|
36
|
+
* Detect if the device supports touch events
|
|
37
|
+
*
|
|
38
|
+
* @returns Whether touch is supported
|
|
39
|
+
*/
|
|
40
|
+
export declare function hasTouchSupport(): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Detect if the device supports pointer events
|
|
43
|
+
*
|
|
44
|
+
* @returns Whether pointer events are supported
|
|
45
|
+
*/
|
|
46
|
+
export declare function hasPointerSupport(): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Extract normalized touch coordinates from an event
|
|
49
|
+
* Works with mouse events, touch events and pointer events
|
|
50
|
+
*
|
|
51
|
+
* @param e - DOM event
|
|
52
|
+
* @returns Object with clientX and clientY coordinates
|
|
53
|
+
*/
|
|
54
|
+
export declare function getTouchCoordinates(e: MouseEvent | TouchEvent | PointerEvent): {
|
|
55
|
+
clientX: number;
|
|
56
|
+
clientY: number;
|
|
57
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core Module Exports
|
|
3
|
+
*
|
|
4
|
+
* Central export point for all core functionality
|
|
5
|
+
*/
|
|
6
|
+
export * from "./compose";
|
|
7
|
+
export { createLayout, applyLayoutClasses, cleanupLayoutClasses, } from "./layout";
|
|
8
|
+
export type { LayoutConfig } from "./layout/types";
|
|
9
|
+
export { createViewport } from "./viewport";
|
|
10
|
+
export type { ViewportConfig, ViewportComponent, ViewportContext, ItemRange, ViewportInfo, } from "./viewport/types";
|
|
11
|
+
export { createGestureManager } from "./gestures";
|
|
12
|
+
export type { GestureManager, GestureConfig, GestureEvent, TapEvent, SwipeEvent, LongPressEvent, PinchEvent, RotateEvent, PanEvent, AnyGestureEvent, GestureHandler, } from "./gestures";
|
|
13
|
+
export * from "./compose";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/layout/config
|
|
3
|
+
* @description Essential layout configuration utilities
|
|
4
|
+
* Core functionality is integrated into schema.ts for better performance
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Helper function to clean up previous layout classes from an element
|
|
8
|
+
* Useful for dynamic class management
|
|
9
|
+
*
|
|
10
|
+
* @param element - Element to clean layout classes from
|
|
11
|
+
*/
|
|
12
|
+
export declare function cleanupLayoutClasses(element: any): void;
|
|
13
|
+
/**
|
|
14
|
+
* Helper function to get the layout type from element classes
|
|
15
|
+
*
|
|
16
|
+
* @param element - Element to check
|
|
17
|
+
* @returns Layout type if found, empty string otherwise
|
|
18
|
+
*/
|
|
19
|
+
export declare function getLayoutType(element: any): string;
|
|
20
|
+
/**
|
|
21
|
+
* Gets the configured prefix for the layout system
|
|
22
|
+
* @returns Current prefix with dash
|
|
23
|
+
*/
|
|
24
|
+
export declare function getLayoutPrefix(): string;
|
|
25
|
+
/**
|
|
26
|
+
* Sets layout classes on an element dynamically
|
|
27
|
+
* Useful for programmatic layout updates
|
|
28
|
+
*
|
|
29
|
+
* @param element - Target element
|
|
30
|
+
* @param layoutType - Layout type to apply
|
|
31
|
+
* @param classes - Additional classes to apply
|
|
32
|
+
*/
|
|
33
|
+
export declare function setLayoutClasses(element: any, layoutType: string, classes?: string[]): void;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/layout
|
|
3
|
+
* @description Unified layout system for mtrl-addons
|
|
4
|
+
* Provides array, object, and JSX-based layout creation with integrated optimizations
|
|
5
|
+
*/
|
|
6
|
+
import { clearClassCache, clearFragmentPool } from "./schema";
|
|
7
|
+
export { createLayout, processClassNames, isComponent, flattenLayout, applyLayoutClasses, applyLayoutItemClasses, createLayoutResult, clearClassCache, clearFragmentPool, } from "./schema";
|
|
8
|
+
export type { LayoutConfig, LayoutItemConfig, LayoutOptions, LayoutResult, ComponentLike, ElementOptions, ElementDefinition, Schema, } from "./types";
|
|
9
|
+
export { cleanupLayoutClasses, getLayoutType, getLayoutPrefix, setLayoutClasses, } from "./config";
|
|
10
|
+
export { h, Fragment, createJsxLayout, component, renderElements, jsx, } from "./jsx";
|
|
11
|
+
export { createLayout as default } from "./schema";
|
|
12
|
+
/**
|
|
13
|
+
* Convenience function to create a layout with common patterns
|
|
14
|
+
* Provides a simpler API for common use cases
|
|
15
|
+
*/
|
|
16
|
+
export declare function layout(type?: "stack" | "row" | "grid" | "flex", options?: Record<string, any>): any;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a responsive grid layout
|
|
19
|
+
* Automatically handles responsive breakpoints
|
|
20
|
+
*/
|
|
21
|
+
export declare function grid(columns?: number | "auto-fit" | "auto-fill", options?: Record<string, any>): any;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a flexible row layout
|
|
24
|
+
* Automatically handles mobile stacking
|
|
25
|
+
*/
|
|
26
|
+
export declare function row(options?: Record<string, any>): any;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a vertical stack layout
|
|
29
|
+
* Default layout type with consistent spacing
|
|
30
|
+
*/
|
|
31
|
+
export declare function stack(options?: Record<string, any>): any;
|
|
32
|
+
/**
|
|
33
|
+
* Creates a layout from a template function
|
|
34
|
+
* Useful for dynamic layouts
|
|
35
|
+
*/
|
|
36
|
+
export declare function template(fn: (props: Record<string, any>) => any, props?: Record<string, any>): any;
|
|
37
|
+
/**
|
|
38
|
+
* Performance utilities for layout management
|
|
39
|
+
*/
|
|
40
|
+
export declare const performance: {
|
|
41
|
+
clearCache: typeof clearClassCache;
|
|
42
|
+
clearFragmentPool: typeof clearFragmentPool;
|
|
43
|
+
/**
|
|
44
|
+
* Clears all cached resources
|
|
45
|
+
*/
|
|
46
|
+
clearAll(): void;
|
|
47
|
+
/**
|
|
48
|
+
* Gets current cache stats
|
|
49
|
+
*/
|
|
50
|
+
getStats(): Record<string, any>;
|
|
51
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/layout/jsx
|
|
3
|
+
* @description JSX-like syntax support for layout creation
|
|
4
|
+
* Provides a simple h() function for creating elements without React dependency
|
|
5
|
+
*/
|
|
6
|
+
import type { LayoutResult } from "./types";
|
|
7
|
+
/**
|
|
8
|
+
* Fragment symbol for JSX fragments
|
|
9
|
+
*/
|
|
10
|
+
export declare const Fragment: unique symbol;
|
|
11
|
+
/**
|
|
12
|
+
* JSX-like hyperscript function
|
|
13
|
+
* Creates elements in a React-like syntax without React dependency
|
|
14
|
+
*
|
|
15
|
+
* @param tag - HTML tag name, component function, or Fragment
|
|
16
|
+
* @param props - Element properties and attributes
|
|
17
|
+
* @param children - Child elements
|
|
18
|
+
* @returns DOM element or component
|
|
19
|
+
*/
|
|
20
|
+
export declare function h(tag: string | Function | typeof Fragment, props?: Record<string, any> | null, ...children: any[]): any;
|
|
21
|
+
/**
|
|
22
|
+
* Creates a layout using JSX-like syntax
|
|
23
|
+
* Provides a bridge between JSX and the layout system
|
|
24
|
+
*
|
|
25
|
+
* @param jsxElement - JSX element created with h()
|
|
26
|
+
* @param parentElement - Parent element to attach to
|
|
27
|
+
* @returns Layout result
|
|
28
|
+
*/
|
|
29
|
+
export declare function createJsxLayout(jsxElement: any, parentElement?: any): LayoutResult;
|
|
30
|
+
/**
|
|
31
|
+
* Utility to create a simple component from a function
|
|
32
|
+
* Useful for creating reusable JSX components
|
|
33
|
+
*
|
|
34
|
+
* @param fn - Component function
|
|
35
|
+
* @returns Component that can be used in JSX
|
|
36
|
+
*/
|
|
37
|
+
export declare function component(fn: (props: Record<string, any>) => any): Function;
|
|
38
|
+
/**
|
|
39
|
+
* Utility to render multiple JSX elements
|
|
40
|
+
* Useful for creating lists or collections
|
|
41
|
+
*
|
|
42
|
+
* @param elements - Array of JSX elements
|
|
43
|
+
* @param parentElement - Parent element to attach to
|
|
44
|
+
* @returns Array of layout results
|
|
45
|
+
*/
|
|
46
|
+
export declare function renderElements(elements: any[], parentElement?: any): LayoutResult[];
|
|
47
|
+
/**
|
|
48
|
+
* Common JSX element creators for convenience
|
|
49
|
+
*/
|
|
50
|
+
export declare const jsx: {
|
|
51
|
+
div: (props?: Record<string, any>, ...children: any[]) => any;
|
|
52
|
+
span: (props?: Record<string, any>, ...children: any[]) => any;
|
|
53
|
+
p: (props?: Record<string, any>, ...children: any[]) => any;
|
|
54
|
+
button: (props?: Record<string, any>, ...children: any[]) => any;
|
|
55
|
+
input: (props?: Record<string, any>) => any;
|
|
56
|
+
img: (props?: Record<string, any>) => any;
|
|
57
|
+
a: (props?: Record<string, any>, ...children: any[]) => any;
|
|
58
|
+
ul: (props?: Record<string, any>, ...children: any[]) => any;
|
|
59
|
+
li: (props?: Record<string, any>, ...children: any[]) => any;
|
|
60
|
+
section: (props?: Record<string, any>, ...children: any[]) => any;
|
|
61
|
+
header: (props?: Record<string, any>, ...children: any[]) => any;
|
|
62
|
+
footer: (props?: Record<string, any>, ...children: any[]) => any;
|
|
63
|
+
main: (props?: Record<string, any>, ...children: any[]) => any;
|
|
64
|
+
article: (props?: Record<string, any>, ...children: any[]) => any;
|
|
65
|
+
};
|