mtrl-addons 0.2.2 → 0.2.4

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 (129) 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 +16 -2
  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/index.ts +0 -7
  67. package/scripts/analyze-orphaned-functions.ts +0 -387
  68. package/scripts/debug/vlist-selection.ts +0 -121
  69. package/src/components/vlist/config.ts +0 -323
  70. package/src/components/vlist/features/api.ts +0 -626
  71. package/src/components/vlist/features/selection.ts +0 -436
  72. package/src/components/vlist/features/viewport.ts +0 -59
  73. package/src/components/vlist/features.ts +0 -112
  74. package/src/components/vlist/types.ts +0 -723
  75. package/src/components/vlist/vlist.ts +0 -92
  76. package/src/core/compose/features/gestures/index.ts +0 -227
  77. package/src/core/compose/features/gestures/longpress.ts +0 -383
  78. package/src/core/compose/features/gestures/pan.ts +0 -424
  79. package/src/core/compose/features/gestures/pinch.ts +0 -475
  80. package/src/core/compose/features/gestures/rotate.ts +0 -485
  81. package/src/core/compose/features/gestures/swipe.ts +0 -492
  82. package/src/core/compose/features/gestures/tap.ts +0 -334
  83. package/src/core/gestures/longpress.ts +0 -68
  84. package/src/core/gestures/manager.ts +0 -418
  85. package/src/core/gestures/pan.ts +0 -48
  86. package/src/core/gestures/pinch.ts +0 -58
  87. package/src/core/gestures/rotate.ts +0 -58
  88. package/src/core/gestures/swipe.ts +0 -66
  89. package/src/core/gestures/tap.ts +0 -45
  90. package/src/core/gestures/types.ts +0 -387
  91. package/src/core/gestures/utils.ts +0 -128
  92. package/src/core/index.ts +0 -43
  93. package/src/core/layout/config.ts +0 -102
  94. package/src/core/layout/index.ts +0 -168
  95. package/src/core/layout/jsx.ts +0 -174
  96. package/src/core/layout/schema.ts +0 -1044
  97. package/src/core/layout/types.ts +0 -95
  98. package/src/core/viewport/constants.ts +0 -145
  99. package/src/core/viewport/features/base.ts +0 -73
  100. package/src/core/viewport/features/collection.ts +0 -1182
  101. package/src/core/viewport/features/events.ts +0 -130
  102. package/src/core/viewport/features/item-size.ts +0 -271
  103. package/src/core/viewport/features/loading.ts +0 -263
  104. package/src/core/viewport/features/momentum.ts +0 -269
  105. package/src/core/viewport/features/performance.ts +0 -161
  106. package/src/core/viewport/features/placeholders.ts +0 -335
  107. package/src/core/viewport/features/rendering.ts +0 -962
  108. package/src/core/viewport/features/scrollbar.ts +0 -434
  109. package/src/core/viewport/features/scrolling.ts +0 -634
  110. package/src/core/viewport/features/utils.ts +0 -94
  111. package/src/core/viewport/features/virtual.ts +0 -525
  112. package/src/core/viewport/types.ts +0 -133
  113. package/src/core/viewport/utils/speed-tracker.ts +0 -79
  114. package/src/core/viewport/viewport.ts +0 -265
  115. package/test/benchmarks/layout/advanced.test.ts +0 -656
  116. package/test/benchmarks/layout/comparison.test.ts +0 -519
  117. package/test/benchmarks/layout/performance-comparison.test.ts +0 -274
  118. package/test/benchmarks/layout/real-components.test.ts +0 -733
  119. package/test/benchmarks/layout/simple.test.ts +0 -321
  120. package/test/benchmarks/layout/stress.test.ts +0 -990
  121. package/test/collection/basic.test.ts +0 -304
  122. package/test/components/vlist-selection.test.ts +0 -240
  123. package/test/components/vlist.test.ts +0 -63
  124. package/test/core/collection/adapter.test.ts +0 -161
  125. package/test/core/collection/collection.test.ts +0 -394
  126. package/test/core/layout/layout.test.ts +0 -201
  127. package/test/utils/dom-helpers.ts +0 -275
  128. package/test/utils/performance-helpers.ts +0 -392
  129. package/tsconfig.json +0 -20
@@ -0,0 +1,85 @@
1
+ /**
2
+ * @module core/compose/features/gestures
3
+ * @description Adds long press gesture recognition to components
4
+ */
5
+ import type { BaseComponent, ElementComponent } from "mtrl";
6
+ import { LongPressEvent, GestureHandler } from "../../../gestures";
7
+ /**
8
+ * Configuration for long press gesture feature
9
+ */
10
+ export interface LongPressGestureConfig {
11
+ /**
12
+ * Time (in ms) to recognize a long press
13
+ * @default 500
14
+ */
15
+ longPressTime?: number;
16
+ /**
17
+ * Distance threshold (in pixels) for movement that cancels long press
18
+ * @default 10
19
+ */
20
+ moveThreshold?: number;
21
+ /**
22
+ * Whether to prevent default behaviors on touch events
23
+ * @default true
24
+ */
25
+ preventDefault?: boolean;
26
+ /**
27
+ * Handler for long press gesture
28
+ */
29
+ onLongPress?: GestureHandler;
30
+ /**
31
+ * Whether to enable long press recognition immediately
32
+ * @default true
33
+ */
34
+ enabled?: boolean;
35
+ [key: string]: any;
36
+ }
37
+ /**
38
+ * Component with long press gesture recognition capabilities
39
+ */
40
+ export interface LongPressGestureComponent extends BaseComponent {
41
+ /**
42
+ * Add a long press event handler
43
+ * @param handler - Event handler function
44
+ * @returns Component for chaining
45
+ */
46
+ onLongPress: (handler: (event: LongPressEvent) => void) => LongPressGestureComponent;
47
+ /**
48
+ * Remove a long press event handler
49
+ * @param handler - Event handler function
50
+ * @returns Component for chaining
51
+ */
52
+ offLongPress: (handler: (event: LongPressEvent) => void) => LongPressGestureComponent;
53
+ /**
54
+ * Enable long press recognition
55
+ * @returns Component for chaining
56
+ */
57
+ enableLongPress: () => LongPressGestureComponent;
58
+ /**
59
+ * Disable long press recognition
60
+ * @returns Component for chaining
61
+ */
62
+ disableLongPress: () => LongPressGestureComponent;
63
+ }
64
+ /**
65
+ * Adds long press gesture recognition to a component.
66
+ * This is a lightweight alternative to the full gesture system,
67
+ * focused only on long press detection.
68
+ *
69
+ * @param config - Configuration object containing long press settings
70
+ * @returns Function that enhances a component with long press capabilities
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * // Add long press gesture recognition to a component
75
+ * const component = pipe(
76
+ * createBase,
77
+ * withElement(...),
78
+ * withLongPressGesture({
79
+ * longPressTime: 800,
80
+ * onLongPress: (e) => showContextMenu(e.x, e.y)
81
+ * })
82
+ * )(config);
83
+ * ```
84
+ */
85
+ export declare const withLongPressGesture: (config?: LongPressGestureConfig) => <C extends ElementComponent>(component: C) => C & LongPressGestureComponent;
@@ -0,0 +1,108 @@
1
+ /**
2
+ * @module core/compose/features/gestures
3
+ * @description Adds pan gesture recognition to components
4
+ */
5
+ import type { BaseComponent, ElementComponent } from "mtrl";
6
+ import { PanEvent, GestureHandler } from "../../../gestures";
7
+ /**
8
+ * Configuration for pan gesture feature
9
+ */
10
+ export interface PanGestureConfig {
11
+ /**
12
+ * Whether to prevent default behaviors on touch events
13
+ * @default true
14
+ */
15
+ preventDefault?: boolean;
16
+ /**
17
+ * Handler for pan start (first movement)
18
+ */
19
+ onPanStart?: GestureHandler;
20
+ /**
21
+ * Handler for pan move (continuous updates during pan)
22
+ */
23
+ onPan?: GestureHandler;
24
+ /**
25
+ * Handler for pan end (touch/mouse release)
26
+ */
27
+ onPanEnd?: GestureHandler;
28
+ /**
29
+ * Whether to enable pan recognition immediately
30
+ * @default true
31
+ */
32
+ enabled?: boolean;
33
+ [key: string]: any;
34
+ }
35
+ /**
36
+ * Component with pan gesture recognition capabilities
37
+ */
38
+ export interface PanGestureComponent extends BaseComponent {
39
+ /**
40
+ * Add a handler for pan start
41
+ * @param handler - Event handler function
42
+ * @returns Component for chaining
43
+ */
44
+ onPanStart: (handler: (event: PanEvent) => void) => PanGestureComponent;
45
+ /**
46
+ * Add a handler for pan move (continuous updates)
47
+ * @param handler - Event handler function
48
+ * @returns Component for chaining
49
+ */
50
+ onPan: (handler: (event: PanEvent) => void) => PanGestureComponent;
51
+ /**
52
+ * Add a handler for pan end
53
+ * @param handler - Event handler function
54
+ * @returns Component for chaining
55
+ */
56
+ onPanEnd: (handler: (event: PanEvent) => void) => PanGestureComponent;
57
+ /**
58
+ * Remove a pan start handler
59
+ * @param handler - Event handler function
60
+ * @returns Component for chaining
61
+ */
62
+ offPanStart: (handler: (event: PanEvent) => void) => PanGestureComponent;
63
+ /**
64
+ * Remove a pan move handler
65
+ * @param handler - Event handler function
66
+ * @returns Component for chaining
67
+ */
68
+ offPan: (handler: (event: PanEvent) => void) => PanGestureComponent;
69
+ /**
70
+ * Remove a pan end handler
71
+ * @param handler - Event handler function
72
+ * @returns Component for chaining
73
+ */
74
+ offPanEnd: (handler: (event: PanEvent) => void) => PanGestureComponent;
75
+ /**
76
+ * Enable pan recognition
77
+ * @returns Component for chaining
78
+ */
79
+ enablePan: () => PanGestureComponent;
80
+ /**
81
+ * Disable pan recognition
82
+ * @returns Component for chaining
83
+ */
84
+ disablePan: () => PanGestureComponent;
85
+ }
86
+ /**
87
+ * Adds pan gesture recognition to a component.
88
+ * This is a lightweight alternative to the full gesture system,
89
+ * focused only on pan detection.
90
+ *
91
+ * @param config - Configuration object containing pan settings
92
+ * @returns Function that enhances a component with pan capabilities
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * // Add pan gesture recognition to a component
97
+ * const component = pipe(
98
+ * createBase,
99
+ * withElement(...),
100
+ * withPanGesture({
101
+ * onPanStart: (e) => startDrag(e),
102
+ * onPan: (e) => updateDragPosition(e),
103
+ * onPanEnd: (e) => endDrag(e)
104
+ * })
105
+ * )(config);
106
+ * ```
107
+ */
108
+ export declare const withPanGesture: (config?: PanGestureConfig) => <C extends ElementComponent>(component: C) => C & PanGestureComponent;
@@ -0,0 +1,111 @@
1
+ /**
2
+ * @module core/compose/features/gestures
3
+ * @description Adds pinch gesture recognition to components
4
+ */
5
+ import type { BaseComponent, ElementComponent } from "mtrl";
6
+ import { PinchEvent, GestureHandler } from "../../../gestures";
7
+ /**
8
+ * Configuration for pinch gesture feature
9
+ */
10
+ export interface PinchGestureConfig {
11
+ /**
12
+ * Whether to prevent default behaviors on touch events
13
+ * @default true
14
+ */
15
+ preventDefault?: boolean;
16
+ /**
17
+ * Handler for pinch gesture
18
+ */
19
+ onPinch?: GestureHandler;
20
+ /**
21
+ * Handler for pinch start
22
+ */
23
+ onPinchStart?: GestureHandler;
24
+ /**
25
+ * Handler for pinch end
26
+ */
27
+ onPinchEnd?: GestureHandler;
28
+ /**
29
+ * Whether to enable pinch recognition immediately
30
+ * @default true
31
+ */
32
+ enabled?: boolean;
33
+ [key: string]: any;
34
+ }
35
+ /**
36
+ * Component with pinch gesture recognition capabilities
37
+ */
38
+ export interface PinchGestureComponent extends BaseComponent {
39
+ /**
40
+ * Add a pinch event handler
41
+ * @param handler - Event handler function
42
+ * @returns Component for chaining
43
+ */
44
+ onPinch: (handler: (event: PinchEvent) => void) => PinchGestureComponent;
45
+ /**
46
+ * Add a pinch start event handler
47
+ * @param handler - Event handler function
48
+ * @returns Component for chaining
49
+ */
50
+ onPinchStart: (handler: (event: PinchEvent) => void) => PinchGestureComponent;
51
+ /**
52
+ * Add a pinch end event handler
53
+ * @param handler - Event handler function
54
+ * @returns Component for chaining
55
+ */
56
+ onPinchEnd: (handler: (event: PinchEvent) => void) => PinchGestureComponent;
57
+ /**
58
+ * Remove a pinch event handler
59
+ * @param handler - Event handler function
60
+ * @returns Component for chaining
61
+ */
62
+ offPinch: (handler: (event: PinchEvent) => void) => PinchGestureComponent;
63
+ /**
64
+ * Remove a pinch start event handler
65
+ * @param handler - Event handler function
66
+ * @returns Component for chaining
67
+ */
68
+ offPinchStart: (handler: (event: PinchEvent) => void) => PinchGestureComponent;
69
+ /**
70
+ * Remove a pinch end event handler
71
+ * @param handler - Event handler function
72
+ * @returns Component for chaining
73
+ */
74
+ offPinchEnd: (handler: (event: PinchEvent) => void) => PinchGestureComponent;
75
+ /**
76
+ * Enable pinch recognition
77
+ * @returns Component for chaining
78
+ */
79
+ enablePinch: () => PinchGestureComponent;
80
+ /**
81
+ * Disable pinch recognition
82
+ * @returns Component for chaining
83
+ */
84
+ disablePinch: () => PinchGestureComponent;
85
+ /**
86
+ * Check if pinch gestures are supported on the current device
87
+ * @returns Whether pinch gestures are supported
88
+ */
89
+ isPinchSupported: () => boolean;
90
+ }
91
+ /**
92
+ * Adds pinch gesture recognition to a component.
93
+ * This is a lightweight alternative to the full gesture system,
94
+ * focused only on pinch detection.
95
+ *
96
+ * @param config - Configuration object containing pinch settings
97
+ * @returns Function that enhances a component with pinch capabilities
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * // Add pinch gesture recognition to a component
102
+ * const component = pipe(
103
+ * createBase,
104
+ * withElement(...),
105
+ * withPinchGesture({
106
+ * onPinch: (e) => updateZoom(e.scale)
107
+ * })
108
+ * )(config);
109
+ * ```
110
+ */
111
+ export declare const withPinchGesture: (config?: PinchGestureConfig) => <C extends ElementComponent>(component: C) => C & PinchGestureComponent;
@@ -0,0 +1,111 @@
1
+ /**
2
+ * @module core/compose/features/gestures
3
+ * @description Adds rotate gesture recognition to components
4
+ */
5
+ import type { BaseComponent, ElementComponent } from "mtrl";
6
+ import { RotateEvent, GestureHandler } from "../../../gestures";
7
+ /**
8
+ * Configuration for rotate gesture feature
9
+ */
10
+ export interface RotateGestureConfig {
11
+ /**
12
+ * Whether to prevent default behaviors on touch events
13
+ * @default true
14
+ */
15
+ preventDefault?: boolean;
16
+ /**
17
+ * Handler for rotate gesture
18
+ */
19
+ onRotate?: GestureHandler;
20
+ /**
21
+ * Handler for rotate start
22
+ */
23
+ onRotateStart?: GestureHandler;
24
+ /**
25
+ * Handler for rotate end
26
+ */
27
+ onRotateEnd?: GestureHandler;
28
+ /**
29
+ * Whether to enable rotate recognition immediately
30
+ * @default true
31
+ */
32
+ enabled?: boolean;
33
+ [key: string]: any;
34
+ }
35
+ /**
36
+ * Component with rotate gesture recognition capabilities
37
+ */
38
+ export interface RotateGestureComponent extends BaseComponent {
39
+ /**
40
+ * Add a rotate event handler
41
+ * @param handler - Event handler function
42
+ * @returns Component for chaining
43
+ */
44
+ onRotate: (handler: (event: RotateEvent) => void) => RotateGestureComponent;
45
+ /**
46
+ * Add a rotate start event handler
47
+ * @param handler - Event handler function
48
+ * @returns Component for chaining
49
+ */
50
+ onRotateStart: (handler: (event: RotateEvent) => void) => RotateGestureComponent;
51
+ /**
52
+ * Add a rotate end event handler
53
+ * @param handler - Event handler function
54
+ * @returns Component for chaining
55
+ */
56
+ onRotateEnd: (handler: (event: RotateEvent) => void) => RotateGestureComponent;
57
+ /**
58
+ * Remove a rotate event handler
59
+ * @param handler - Event handler function
60
+ * @returns Component for chaining
61
+ */
62
+ offRotate: (handler: (event: RotateEvent) => void) => RotateGestureComponent;
63
+ /**
64
+ * Remove a rotate start event handler
65
+ * @param handler - Event handler function
66
+ * @returns Component for chaining
67
+ */
68
+ offRotateStart: (handler: (event: RotateEvent) => void) => RotateGestureComponent;
69
+ /**
70
+ * Remove a rotate end event handler
71
+ * @param handler - Event handler function
72
+ * @returns Component for chaining
73
+ */
74
+ offRotateEnd: (handler: (event: RotateEvent) => void) => RotateGestureComponent;
75
+ /**
76
+ * Enable rotate recognition
77
+ * @returns Component for chaining
78
+ */
79
+ enableRotate: () => RotateGestureComponent;
80
+ /**
81
+ * Disable rotate recognition
82
+ * @returns Component for chaining
83
+ */
84
+ disableRotate: () => RotateGestureComponent;
85
+ /**
86
+ * Check if rotate gestures are supported on the current device
87
+ * @returns Whether rotate gestures are supported
88
+ */
89
+ isRotateSupported: () => boolean;
90
+ }
91
+ /**
92
+ * Adds rotate gesture recognition to a component.
93
+ * This is a lightweight alternative to the full gesture system,
94
+ * focused only on rotate detection.
95
+ *
96
+ * @param config - Configuration object containing rotate settings
97
+ * @returns Function that enhances a component with rotate capabilities
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * // Add rotate gesture recognition to a component
102
+ * const component = pipe(
103
+ * createBase,
104
+ * withElement(...),
105
+ * withRotateGesture({
106
+ * onRotate: (e) => updateRotation(e.rotation)
107
+ * })
108
+ * )(config);
109
+ * ```
110
+ */
111
+ export declare const withRotateGesture: (config?: RotateGestureConfig) => <C extends ElementComponent>(component: C) => C & RotateGestureComponent;
@@ -0,0 +1,149 @@
1
+ /**
2
+ * @module core/compose/features/gestures
3
+ * @description Adds swipe gesture recognition to components
4
+ */
5
+ import type { BaseComponent, ElementComponent } from "mtrl";
6
+ import { SwipeEvent, GestureHandler } from "../../../gestures";
7
+ /**
8
+ * Configuration for swipe gesture feature
9
+ */
10
+ export interface SwipeGestureConfig {
11
+ /**
12
+ * Minimum distance (in pixels) to recognize a swipe
13
+ * @default 30
14
+ */
15
+ swipeThreshold?: number;
16
+ /**
17
+ * Maximum time (in ms) in which a swipe must be completed
18
+ * @default 300
19
+ */
20
+ swipeTimeThreshold?: number;
21
+ /**
22
+ * Whether to prevent default behaviors on touch events
23
+ * @default true
24
+ */
25
+ preventDefault?: boolean;
26
+ /**
27
+ * Handler for any swipe direction
28
+ */
29
+ onSwipe?: GestureHandler;
30
+ /**
31
+ * Handler specifically for left swipes
32
+ */
33
+ onSwipeLeft?: GestureHandler;
34
+ /**
35
+ * Handler specifically for right swipes
36
+ */
37
+ onSwipeRight?: GestureHandler;
38
+ /**
39
+ * Handler specifically for up swipes
40
+ */
41
+ onSwipeUp?: GestureHandler;
42
+ /**
43
+ * Handler specifically for down swipes
44
+ */
45
+ onSwipeDown?: GestureHandler;
46
+ /**
47
+ * Whether to enable swipe recognition immediately
48
+ * @default true
49
+ */
50
+ enabled?: boolean;
51
+ [key: string]: any;
52
+ }
53
+ /**
54
+ * Component with swipe gesture recognition capabilities
55
+ */
56
+ export interface SwipeGestureComponent extends BaseComponent {
57
+ /**
58
+ * Add a handler for any swipe direction
59
+ * @param handler - Event handler function
60
+ * @returns Component for chaining
61
+ */
62
+ onSwipe: (handler: (event: SwipeEvent) => void) => SwipeGestureComponent;
63
+ /**
64
+ * Add a handler specifically for left swipes
65
+ * @param handler - Event handler function
66
+ * @returns Component for chaining
67
+ */
68
+ onSwipeLeft: (handler: (event: SwipeEvent) => void) => SwipeGestureComponent;
69
+ /**
70
+ * Add a handler specifically for right swipes
71
+ * @param handler - Event handler function
72
+ * @returns Component for chaining
73
+ */
74
+ onSwipeRight: (handler: (event: SwipeEvent) => void) => SwipeGestureComponent;
75
+ /**
76
+ * Add a handler specifically for up swipes
77
+ * @param handler - Event handler function
78
+ * @returns Component for chaining
79
+ */
80
+ onSwipeUp: (handler: (event: SwipeEvent) => void) => SwipeGestureComponent;
81
+ /**
82
+ * Add a handler specifically for down swipes
83
+ * @param handler - Event handler function
84
+ * @returns Component for chaining
85
+ */
86
+ onSwipeDown: (handler: (event: SwipeEvent) => void) => SwipeGestureComponent;
87
+ /**
88
+ * Remove a swipe event handler for any direction
89
+ * @param handler - Event handler function
90
+ * @returns Component for chaining
91
+ */
92
+ offSwipe: (handler: (event: SwipeEvent) => void) => SwipeGestureComponent;
93
+ /**
94
+ * Remove a left swipe event handler
95
+ * @param handler - Event handler function
96
+ * @returns Component for chaining
97
+ */
98
+ offSwipeLeft: (handler: (event: SwipeEvent) => void) => SwipeGestureComponent;
99
+ /**
100
+ * Remove a right swipe event handler
101
+ * @param handler - Event handler function
102
+ * @returns Component for chaining
103
+ */
104
+ offSwipeRight: (handler: (event: SwipeEvent) => void) => SwipeGestureComponent;
105
+ /**
106
+ * Remove an up swipe event handler
107
+ * @param handler - Event handler function
108
+ * @returns Component for chaining
109
+ */
110
+ offSwipeUp: (handler: (event: SwipeEvent) => void) => SwipeGestureComponent;
111
+ /**
112
+ * Remove a down swipe event handler
113
+ * @param handler - Event handler function
114
+ * @returns Component for chaining
115
+ */
116
+ offSwipeDown: (handler: (event: SwipeEvent) => void) => SwipeGestureComponent;
117
+ /**
118
+ * Enable swipe recognition
119
+ * @returns Component for chaining
120
+ */
121
+ enableSwipe: () => SwipeGestureComponent;
122
+ /**
123
+ * Disable swipe recognition
124
+ * @returns Component for chaining
125
+ */
126
+ disableSwipe: () => SwipeGestureComponent;
127
+ }
128
+ /**
129
+ * Adds swipe gesture recognition to a component.
130
+ * This is a lightweight alternative to the full gesture system,
131
+ * focused only on swipe detection.
132
+ *
133
+ * @param config - Configuration object containing swipe settings
134
+ * @returns Function that enhances a component with swipe capabilities
135
+ *
136
+ * @example
137
+ * ```ts
138
+ * // Add swipe gesture recognition to a component
139
+ * const component = pipe(
140
+ * createBase,
141
+ * withElement(...),
142
+ * withSwipeGesture({
143
+ * onSwipeLeft: () => showNextPage(),
144
+ * onSwipeRight: () => showPreviousPage()
145
+ * })
146
+ * )(config);
147
+ * ```
148
+ */
149
+ export declare const withSwipeGesture: (config?: SwipeGestureConfig) => <C extends ElementComponent>(component: C) => C & SwipeGestureComponent;
@@ -0,0 +1,79 @@
1
+ /**
2
+ * @module core/compose/features/gestures
3
+ * @description Adds tap gesture recognition to components
4
+ */
5
+ import type { BaseComponent, ElementComponent } from "mtrl";
6
+ import { TapEvent, GestureHandler } from "../../../gestures";
7
+ /**
8
+ * Configuration for tap gesture feature
9
+ */
10
+ export interface TapGestureConfig {
11
+ /**
12
+ * Distance threshold (in pixels) for tap recognition
13
+ * @default 10
14
+ */
15
+ tapDistanceThreshold?: number;
16
+ /**
17
+ * Whether to prevent default behaviors on touch events
18
+ * @default true
19
+ */
20
+ preventDefault?: boolean;
21
+ /**
22
+ * Handler for tap gesture
23
+ */
24
+ onTap?: GestureHandler;
25
+ /**
26
+ * Whether to enable tap recognition immediately
27
+ * @default true
28
+ */
29
+ enabled?: boolean;
30
+ [key: string]: any;
31
+ }
32
+ /**
33
+ * Component with tap gesture recognition capabilities
34
+ */
35
+ export interface TapGestureComponent extends BaseComponent {
36
+ /**
37
+ * Add a tap event handler
38
+ * @param handler - Event handler function
39
+ * @returns Component for chaining
40
+ */
41
+ onTap: (handler: (event: TapEvent) => void) => TapGestureComponent;
42
+ /**
43
+ * Remove a tap event handler
44
+ * @param handler - Event handler function
45
+ * @returns Component for chaining
46
+ */
47
+ offTap: (handler: (event: TapEvent) => void) => TapGestureComponent;
48
+ /**
49
+ * Enable tap recognition
50
+ * @returns Component for chaining
51
+ */
52
+ enableTap: () => TapGestureComponent;
53
+ /**
54
+ * Disable tap recognition
55
+ * @returns Component for chaining
56
+ */
57
+ disableTap: () => TapGestureComponent;
58
+ }
59
+ /**
60
+ * Adds tap gesture recognition to a component.
61
+ * This is a lightweight alternative to the full gesture system,
62
+ * focused only on tap detection.
63
+ *
64
+ * @param config - Configuration object containing tap settings
65
+ * @returns Function that enhances a component with tap capabilities
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * // Add tap gesture recognition to a component
70
+ * const component = pipe(
71
+ * createBase,
72
+ * withElement(...),
73
+ * withTapGesture({
74
+ * onTap: (e) => console.log('Tapped at', e.x, e.y)
75
+ * })
76
+ * )(config);
77
+ * ```
78
+ */
79
+ export declare const withTapGesture: (config?: TapGestureConfig) => <C extends ElementComponent>(component: C) => C & TapGestureComponent;
@@ -1,3 +1,2 @@
1
1
  export { withGestures } from './gestures';
2
-
3
- export type { GesturesComponent, GesturesFeatureConfig } from './gestures';
2
+ export type { GesturesComponent, GesturesFeatureConfig } from './gestures';
@@ -1,15 +1,6 @@
1
- export {
2
- withGestures
3
- } from './features/gestures';
4
-
5
- // Gesture features
1
+ export { withGestures } from './features/gestures';
6
2
  export { withTapGesture } from './features/gestures/tap';
7
3
  export { withSwipeGesture } from './features/gestures/swipe';
8
4
  export { withLongPressGesture } from './features/gestures/longpress';
9
5
  export { withPanGesture } from './features/gestures/pan';
10
-
11
-
12
- export type {
13
- GesturesComponent,
14
- GesturesFeatureConfig
15
- } from './features';
6
+ export type { GesturesComponent, GesturesFeatureConfig } from './features';
@@ -1,10 +1,7 @@
1
- // src/core/gestures/index.ts
2
1
  /**
3
2
  * @module core/gestures
4
3
  * @description Modular gesture recognition system for touch and mouse interactions
5
4
  */
6
-
7
- // Export core gesture utilities and types
8
5
  export { createGestureManager, GESTURE_TYPES, SWIPE_DIRECTIONS } from './manager';
9
6
  export { detectTap } from './tap';
10
7
  export { detectSwipe } from './swipe';
@@ -12,20 +9,4 @@ export { detectLongPress } from './longpress';
12
9
  export { detectPinch } from './pinch';
13
10
  export { detectRotate } from './rotate';
14
11
  export { detectPan } from './pan';
15
-
16
- // Export types
17
- export type {
18
- GestureManager,
19
- GestureConfig,
20
- GestureEvent,
21
- TapEvent,
22
- SwipeEvent,
23
- LongPressEvent,
24
- PinchEvent,
25
- RotateEvent,
26
- PanEvent,
27
- AnyGestureEvent,
28
- GestureHandler,
29
- GestureState,
30
- GestureDetectionContext
31
- } from './types';
12
+ export type { GestureManager, GestureConfig, GestureEvent, TapEvent, SwipeEvent, LongPressEvent, PinchEvent, RotateEvent, PanEvent, AnyGestureEvent, GestureHandler, GestureState, GestureDetectionContext } from './types';