@rakeyshgidwani/roger-ui-bank-theme-stan-design 0.2.9 → 0.2.10
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/CHANGELOG.md +1 -1
- package/dist/components/ui/accessibility-demo.esm.js +30 -24
- package/dist/components/ui/accessibility-demo.js +30 -24
- package/dist/components/ui/advanced-component-architecture-demo.esm.js +235 -179
- package/dist/components/ui/advanced-component-architecture-demo.js +235 -179
- package/dist/components/ui/advanced-transition-system-demo.esm.js +110 -64
- package/dist/components/ui/advanced-transition-system-demo.js +110 -64
- package/dist/components/ui/advanced-transition-system.esm.js +166 -122
- package/dist/components/ui/advanced-transition-system.js +166 -122
- package/dist/components/ui/animation/animated-container.esm.js +52 -29
- package/dist/components/ui/animation/animated-container.js +52 -29
- package/dist/components/ui/animation/staggered-container.esm.js +18 -9
- package/dist/components/ui/animation/staggered-container.js +18 -9
- package/dist/components/ui/animation-demo.esm.js +67 -35
- package/dist/components/ui/animation-demo.js +67 -35
- package/dist/components/ui/badge.esm.js +9 -6
- package/dist/components/ui/badge.js +9 -6
- package/dist/components/ui/battery-conscious-animation-demo.esm.js +122 -87
- package/dist/components/ui/battery-conscious-animation-demo.js +122 -87
- package/dist/components/ui/border-radius-shadow-demo.esm.js +23 -12
- package/dist/components/ui/border-radius-shadow-demo.js +23 -12
- package/dist/components/ui/button.esm.js +8 -2
- package/dist/components/ui/button.js +8 -2
- package/dist/components/ui/card.esm.js +33 -8
- package/dist/components/ui/card.js +33 -8
- package/dist/components/ui/checkbox.esm.js +3 -3
- package/dist/components/ui/checkbox.js +3 -3
- package/dist/components/ui/color-preview.esm.js +68 -45
- package/dist/components/ui/color-preview.js +68 -45
- package/dist/components/ui/data-display/chart.esm.js +112 -84
- package/dist/components/ui/data-display/chart.js +112 -84
- package/dist/components/ui/data-display/data-grid-simple.esm.js +1 -1
- package/dist/components/ui/data-display/data-grid-simple.js +1 -1
- package/dist/components/ui/data-display/data-grid.esm.js +80 -67
- package/dist/components/ui/data-display/data-grid.js +80 -67
- package/dist/components/ui/data-display/list.esm.js +53 -45
- package/dist/components/ui/data-display/list.js +53 -45
- package/dist/components/ui/data-display/table.esm.js +62 -54
- package/dist/components/ui/data-display/table.js +62 -54
- package/dist/components/ui/data-display/timeline.esm.js +39 -34
- package/dist/components/ui/data-display/timeline.js +39 -34
- package/dist/components/ui/data-display/tree.esm.js +116 -84
- package/dist/components/ui/data-display/tree.js +116 -84
- package/dist/components/ui/data-display/types.esm.js +389 -364
- package/dist/components/ui/data-display/types.js +389 -364
- package/dist/components/ui/enterprise-mobile-experience-demo.esm.js +120 -70
- package/dist/components/ui/enterprise-mobile-experience-demo.js +120 -70
- package/dist/components/ui/enterprise-mobile-experience.esm.js +124 -73
- package/dist/components/ui/enterprise-mobile-experience.js +124 -73
- package/dist/components/ui/feedback/alert.esm.js +22 -15
- package/dist/components/ui/feedback/alert.js +22 -15
- package/dist/components/ui/feedback/progress.esm.js +47 -24
- package/dist/components/ui/feedback/progress.js +47 -24
- package/dist/components/ui/feedback/skeleton.esm.js +39 -29
- package/dist/components/ui/feedback/skeleton.js +39 -29
- package/dist/components/ui/feedback/toast.esm.js +62 -38
- package/dist/components/ui/feedback/toast.js +62 -38
- package/dist/components/ui/feedback/types.esm.js +83 -83
- package/dist/components/ui/feedback/types.js +83 -83
- package/dist/components/ui/font-preview.esm.js +41 -39
- package/dist/components/ui/font-preview.js +41 -39
- package/dist/components/ui/form-demo.esm.js +150 -113
- package/dist/components/ui/form-demo.js +150 -113
- package/dist/components/ui/hardware-acceleration-demo.esm.js +137 -87
- package/dist/components/ui/hardware-acceleration-demo.js +137 -87
- package/dist/components/ui/input.esm.js +4 -1
- package/dist/components/ui/input.js +4 -1
- package/dist/components/ui/layout-demo.esm.js +81 -56
- package/dist/components/ui/layout-demo.js +81 -56
- package/dist/components/ui/layouts/adaptive-layout.esm.js +27 -8
- package/dist/components/ui/layouts/adaptive-layout.js +27 -8
- package/dist/components/ui/layouts/desktop-layout.esm.js +39 -19
- package/dist/components/ui/layouts/desktop-layout.js +39 -19
- package/dist/components/ui/layouts/mobile-layout.esm.js +19 -9
- package/dist/components/ui/layouts/mobile-layout.js +19 -9
- package/dist/components/ui/layouts/tablet-layout.esm.js +28 -14
- package/dist/components/ui/layouts/tablet-layout.js +28 -14
- package/dist/components/ui/mobile-form-validation.esm.js +120 -87
- package/dist/components/ui/mobile-form-validation.js +120 -87
- package/dist/components/ui/mobile-input-demo.esm.js +19 -13
- package/dist/components/ui/mobile-input-demo.js +19 -13
- package/dist/components/ui/mobile-input.esm.js +185 -120
- package/dist/components/ui/mobile-input.js +185 -120
- package/dist/components/ui/mobile-skeleton-loading-demo.esm.js +128 -111
- package/dist/components/ui/mobile-skeleton-loading-demo.js +128 -111
- package/dist/components/ui/navigation/breadcrumb.esm.js +17 -14
- package/dist/components/ui/navigation/breadcrumb.js +17 -14
- package/dist/components/ui/navigation/index.esm.js +23 -1
- package/dist/components/ui/navigation/index.js +23 -1
- package/dist/components/ui/navigation/menu.esm.js +49 -35
- package/dist/components/ui/navigation/menu.js +49 -35
- package/dist/components/ui/navigation/navigation-demo.esm.js +81 -74
- package/dist/components/ui/navigation/navigation-demo.js +81 -74
- package/dist/components/ui/navigation/pagination.esm.js +62 -50
- package/dist/components/ui/navigation/pagination.js +62 -50
- package/dist/components/ui/navigation/sidebar.esm.js +56 -42
- package/dist/components/ui/navigation/sidebar.js +56 -42
- package/dist/components/ui/navigation/stepper.esm.js +34 -23
- package/dist/components/ui/navigation/stepper.js +34 -23
- package/dist/components/ui/navigation/tabs.esm.js +32 -21
- package/dist/components/ui/navigation/tabs.js +32 -21
- package/dist/components/ui/navigation/types.esm.js +196 -195
- package/dist/components/ui/navigation/types.js +196 -195
- package/dist/components/ui/overlay/backdrop.esm.js +17 -16
- package/dist/components/ui/overlay/backdrop.js +17 -16
- package/dist/components/ui/overlay/focus-manager.esm.js +21 -19
- package/dist/components/ui/overlay/focus-manager.js +21 -19
- package/dist/components/ui/overlay/index.esm.js +22 -2
- package/dist/components/ui/overlay/index.js +22 -2
- package/dist/components/ui/overlay/modal.esm.js +38 -34
- package/dist/components/ui/overlay/modal.js +38 -34
- package/dist/components/ui/overlay/overlay-manager.esm.js +25 -20
- package/dist/components/ui/overlay/overlay-manager.js +25 -20
- package/dist/components/ui/overlay/popover.esm.js +74 -58
- package/dist/components/ui/overlay/popover.js +74 -58
- package/dist/components/ui/overlay/portal.esm.js +7 -7
- package/dist/components/ui/overlay/portal.js +7 -7
- package/dist/components/ui/overlay/tooltip.esm.js +54 -39
- package/dist/components/ui/overlay/tooltip.js +54 -39
- package/dist/components/ui/overlay/types.esm.js +132 -131
- package/dist/components/ui/overlay/types.js +132 -131
- package/dist/components/ui/performance-demo.esm.js +135 -88
- package/dist/components/ui/performance-demo.js +135 -88
- package/dist/components/ui/semantic-input-system-demo.esm.js +117 -80
- package/dist/components/ui/semantic-input-system-demo.js +117 -80
- package/dist/components/ui/theme-customizer.esm.js +84 -52
- package/dist/components/ui/theme-customizer.js +84 -52
- package/dist/components/ui/theme-preview.esm.js +95 -43
- package/dist/components/ui/theme-preview.js +95 -43
- package/dist/components/ui/theme-switcher.esm.js +70 -44
- package/dist/components/ui/theme-switcher.js +70 -44
- package/dist/components/ui/theme-toggle.esm.js +3 -3
- package/dist/components/ui/theme-toggle.js +3 -3
- package/dist/components/ui/token-demo.esm.js +33 -21
- package/dist/components/ui/token-demo.js +33 -21
- package/dist/components/ui/touch-demo.esm.js +102 -73
- package/dist/components/ui/touch-demo.js +102 -73
- package/dist/components/ui/touch-friendly-interface-demo.esm.js +102 -64
- package/dist/components/ui/touch-friendly-interface-demo.js +102 -64
- package/dist/components/ui/touch-friendly-interface.esm.js +85 -61
- package/dist/components/ui/touch-friendly-interface.js +85 -61
- package/dist/hooks/use-accessibility-support.esm.js +115 -85
- package/dist/hooks/use-accessibility-support.js +115 -85
- package/dist/hooks/use-adaptive-layout.esm.js +56 -33
- package/dist/hooks/use-adaptive-layout.js +56 -33
- package/dist/hooks/use-advanced-patterns.esm.js +57 -42
- package/dist/hooks/use-advanced-patterns.js +57 -42
- package/dist/hooks/use-advanced-transition-system.esm.js +112 -71
- package/dist/hooks/use-advanced-transition-system.js +112 -71
- package/dist/hooks/use-animation-profile.esm.js +63 -34
- package/dist/hooks/use-animation-profile.js +63 -34
- package/dist/hooks/use-battery-animations.esm.js +80 -55
- package/dist/hooks/use-battery-animations.js +80 -55
- package/dist/hooks/use-battery-conscious-loading.esm.js +166 -123
- package/dist/hooks/use-battery-conscious-loading.js +166 -123
- package/dist/hooks/use-battery-optimization.esm.js +78 -55
- package/dist/hooks/use-battery-optimization.js +78 -55
- package/dist/hooks/use-battery-status.esm.js +73 -51
- package/dist/hooks/use-battery-status.js +73 -51
- package/dist/hooks/use-component-performance.esm.js +62 -47
- package/dist/hooks/use-component-performance.js +62 -47
- package/dist/hooks/use-device-loading-states.esm.js +152 -109
- package/dist/hooks/use-device-loading-states.js +152 -109
- package/dist/hooks/use-device.esm.js +25 -14
- package/dist/hooks/use-device.js +25 -14
- package/dist/hooks/use-enterprise-mobile-experience.esm.js +137 -88
- package/dist/hooks/use-enterprise-mobile-experience.js +137 -88
- package/dist/hooks/use-form-feedback.esm.js +124 -81
- package/dist/hooks/use-form-feedback.js +124 -81
- package/dist/hooks/use-form-performance.esm.js +127 -92
- package/dist/hooks/use-form-performance.js +127 -92
- package/dist/hooks/use-frame-rate.esm.js +56 -37
- package/dist/hooks/use-frame-rate.js +56 -37
- package/dist/hooks/use-gestures.esm.js +96 -72
- package/dist/hooks/use-gestures.js +96 -72
- package/dist/hooks/use-hardware-acceleration.esm.js +65 -37
- package/dist/hooks/use-hardware-acceleration.js +65 -37
- package/dist/hooks/use-input-accessibility.esm.js +157 -119
- package/dist/hooks/use-input-accessibility.js +157 -119
- package/dist/hooks/use-input-performance.esm.js +139 -104
- package/dist/hooks/use-input-performance.js +139 -104
- package/dist/hooks/use-layout-performance.esm.js +50 -29
- package/dist/hooks/use-layout-performance.js +50 -29
- package/dist/hooks/use-loading-accessibility.esm.js +209 -169
- package/dist/hooks/use-loading-accessibility.js +209 -169
- package/dist/hooks/use-loading-performance.esm.js +117 -93
- package/dist/hooks/use-loading-performance.js +117 -93
- package/dist/hooks/use-memory-usage.esm.js +57 -38
- package/dist/hooks/use-memory-usage.js +57 -38
- package/dist/hooks/use-mobile-form-layout.esm.js +111 -74
- package/dist/hooks/use-mobile-form-layout.js +111 -74
- package/dist/hooks/use-mobile-form-validation.esm.js +211 -144
- package/dist/hooks/use-mobile-form-validation.js +211 -144
- package/dist/hooks/use-mobile-keyboard-optimization.esm.js +154 -113
- package/dist/hooks/use-mobile-keyboard-optimization.js +154 -113
- package/dist/hooks/use-mobile-layout.esm.js +73 -51
- package/dist/hooks/use-mobile-layout.js +73 -51
- package/dist/hooks/use-mobile-optimization.esm.js +72 -44
- package/dist/hooks/use-mobile-optimization.js +72 -44
- package/dist/hooks/use-mobile-skeleton.esm.js +97 -64
- package/dist/hooks/use-mobile-skeleton.js +97 -64
- package/dist/hooks/use-mobile-touch.esm.js +128 -93
- package/dist/hooks/use-mobile-touch.js +128 -93
- package/dist/hooks/use-performance-throttling.esm.js +72 -48
- package/dist/hooks/use-performance-throttling.js +72 -48
- package/dist/hooks/use-performance.esm.js +90 -52
- package/dist/hooks/use-performance.js +90 -52
- package/dist/hooks/use-reusable-architecture.esm.js +94 -65
- package/dist/hooks/use-reusable-architecture.js +94 -65
- package/dist/hooks/use-semantic-input-types.esm.js +166 -124
- package/dist/hooks/use-semantic-input-types.js +166 -124
- package/dist/hooks/use-semantic-input.esm.js +178 -126
- package/dist/hooks/use-semantic-input.js +178 -126
- package/dist/hooks/use-tablet-layout.esm.js +67 -38
- package/dist/hooks/use-tablet-layout.js +67 -38
- package/dist/hooks/use-touch-friendly-input.esm.js +193 -149
- package/dist/hooks/use-touch-friendly-input.js +193 -149
- package/dist/hooks/use-touch-friendly-interface.esm.js +99 -67
- package/dist/hooks/use-touch-friendly-interface.js +99 -67
- package/dist/hooks/use-touch-optimization.esm.js +99 -72
- package/dist/hooks/use-touch-optimization.js +99 -72
- package/dist/index.esm.js +289 -280
- package/dist/index.js +289 -280
- package/dist/lib/utils.esm.js +1 -1
- package/dist/lib/utils.js +1 -1
- package/dist/plugins/theme-css-generator.esm.js +104 -55
- package/dist/plugins/theme-css-generator.js +104 -55
- package/dist/provider.esm.js +4 -4
- package/dist/provider.js +4 -4
- package/dist/styles.css +1 -1
- package/dist/theme.esm.js +633 -468
- package/dist/theme.js +633 -468
- package/dist/themes/ThemeContext.esm.js +15 -15
- package/dist/themes/ThemeContext.js +15 -15
- package/dist/themes/ThemeProvider.esm.js +25 -22
- package/dist/themes/ThemeProvider.js +25 -22
- package/dist/themes/accessibility.esm.js +147 -108
- package/dist/themes/accessibility.js +147 -108
- package/dist/themes/aria-patterns.esm.js +198 -162
- package/dist/themes/aria-patterns.js +198 -162
- package/dist/themes/base-themes.esm.js +14 -11
- package/dist/themes/base-themes.js +14 -11
- package/dist/themes/colorManager.esm.js +101 -83
- package/dist/themes/colorManager.js +101 -83
- package/dist/themes/examples/dark-theme.esm.js +133 -103
- package/dist/themes/examples/dark-theme.js +133 -103
- package/dist/themes/examples/minimal-theme.esm.js +83 -61
- package/dist/themes/examples/minimal-theme.js +83 -61
- package/dist/themes/focus-management.esm.js +202 -143
- package/dist/themes/focus-management.js +202 -143
- package/dist/themes/fontLoader.esm.js +28 -19
- package/dist/themes/fontLoader.js +28 -19
- package/dist/themes/high-contrast.esm.js +152 -104
- package/dist/themes/high-contrast.js +152 -104
- package/dist/themes/inheritance.esm.js +35 -27
- package/dist/themes/inheritance.js +35 -27
- package/dist/themes/keyboard-navigation.esm.js +152 -123
- package/dist/themes/keyboard-navigation.js +152 -123
- package/dist/themes/motion-reduction.esm.js +193 -133
- package/dist/themes/motion-reduction.js +193 -133
- package/dist/themes/navigation.esm.js +146 -146
- package/dist/themes/navigation.js +146 -146
- package/dist/themes/screen-reader.esm.js +159 -94
- package/dist/themes/screen-reader.js +159 -94
- package/dist/themes/systemThemeDetector.esm.js +42 -34
- package/dist/themes/systemThemeDetector.js +42 -34
- package/dist/themes/themeCSSUpdater.esm.js +21 -9
- package/dist/themes/themeCSSUpdater.js +21 -9
- package/dist/themes/themePersistence.esm.js +68 -47
- package/dist/themes/themePersistence.js +68 -47
- package/dist/themes/themes/stan-design.esm.js +633 -468
- package/dist/themes/themes/stan-design.js +633 -468
- package/dist/themes/types.esm.js +301 -287
- package/dist/themes/types.js +301 -287
- package/dist/themes/useSystemTheme.esm.js +4 -4
- package/dist/themes/useSystemTheme.js +4 -4
- package/dist/themes/useTheme.esm.js +4 -4
- package/dist/themes/useTheme.js +4 -4
- package/dist/themes/validation.esm.js +128 -77
- package/dist/themes/validation.js +128 -77
- package/dist/tokens/index.esm.js +15 -4
- package/dist/tokens/index.js +15 -4
- package/dist/tokens/tokenExporter.esm.js +87 -61
- package/dist/tokens/tokenExporter.js +87 -61
- package/dist/tokens/tokenGenerator.esm.js +86 -77
- package/dist/tokens/tokenGenerator.js +86 -77
- package/dist/tokens/tokenManager.esm.js +64 -51
- package/dist/tokens/tokenManager.js +64 -51
- package/dist/tokens/tokenValidator.esm.js +193 -147
- package/dist/tokens/tokenValidator.js +193 -147
- package/dist/tokens/types.esm.js +49 -35
- package/dist/tokens/types.js +49 -35
- package/dist/utils/bundle-analyzer.esm.js +83 -65
- package/dist/utils/bundle-analyzer.js +83 -65
- package/dist/utils/bundle-splitting.esm.js +142 -117
- package/dist/utils/bundle-splitting.js +142 -117
- package/dist/utils/lazy-loading.esm.js +132 -106
- package/dist/utils/lazy-loading.js +132 -106
- package/dist/utils/performance-monitor.esm.js +170 -129
- package/dist/utils/performance-monitor.js +170 -129
- package/dist/utils/tree-shaking.esm.js +69 -61
- package/dist/utils/tree-shaking.js +69 -61
- package/package.json +1 -1
- package/src/index.ts +146 -146
|
@@ -1,50 +1,66 @@
|
|
|
1
1
|
import { useState, useEffect, useCallback, useRef, useMemo } from 'react'
|
|
2
2
|
|
|
3
3
|
export interface GestureConfig {
|
|
4
|
-
minSwipeDistance
|
|
4
|
+
minSwipeDistance: number
|
|
5
|
+
maxSwipeTime: number
|
|
6
|
+
minPinchDistance: number
|
|
7
|
+
enableHapticFeedback: boolean
|
|
8
|
+
enableSoundFeedback: boolean
|
|
9
|
+
}
|
|
5
10
|
|
|
6
11
|
export interface SwipeGesture {
|
|
7
|
-
direction
|
|
12
|
+
direction: 'up' | 'down' | 'left' | 'right'
|
|
13
|
+
distance: number
|
|
14
|
+
velocity: number
|
|
15
|
+
duration: number
|
|
16
|
+
}
|
|
8
17
|
|
|
9
18
|
export interface PinchGesture {
|
|
10
|
-
scale
|
|
11
|
-
|
|
19
|
+
scale: number
|
|
20
|
+
center: { x: number; y: number }
|
|
21
|
+
distance: number
|
|
22
|
+
}
|
|
12
23
|
|
|
13
24
|
export interface GestureCallbacks {
|
|
14
|
-
onSwipe
|
|
15
|
-
onPinch
|
|
16
|
-
onTap
|
|
17
|
-
onLongPress
|
|
18
|
-
onTouchStart
|
|
19
|
-
onTouchEnd
|
|
25
|
+
onSwipe?: (gesture: SwipeGesture) => void
|
|
26
|
+
onPinch?: (gesture: PinchGesture) => void
|
|
27
|
+
onTap?: (position: { x: number; y: number }) => void
|
|
28
|
+
onLongPress?: (position: { x: number; y: number }) => void
|
|
29
|
+
onTouchStart?: (position: { x: number; y: number }) => void
|
|
30
|
+
onTouchEnd?: (position: { x: number; y: number }) => void
|
|
20
31
|
}
|
|
21
32
|
|
|
22
33
|
export interface GestureState {
|
|
23
|
-
isTracking
|
|
34
|
+
isTracking: boolean
|
|
35
|
+
currentGesture: 'none' | 'swipe' | 'pinch' | 'tap' | 'longPress'
|
|
36
|
+
lastGesture: SwipeGesture | PinchGesture | null
|
|
37
|
+
touchCount: number
|
|
38
|
+
}
|
|
24
39
|
|
|
25
40
|
export const useGestures = (
|
|
26
|
-
elementRef
|
|
27
|
-
callbacks= {},
|
|
28
|
-
config= {}
|
|
41
|
+
elementRef: React.RefObject<HTMLElement>,
|
|
42
|
+
callbacks: GestureCallbacks = {},
|
|
43
|
+
config: Partial<GestureConfig> = {}
|
|
29
44
|
) => {
|
|
30
|
-
const defaultConfig= {
|
|
31
|
-
minSwipeDistance,
|
|
32
|
-
maxSwipeTime,
|
|
33
|
-
minPinchDistance,
|
|
34
|
-
enableHapticFeedback,
|
|
35
|
-
enableSoundFeedback,
|
|
45
|
+
const defaultConfig: GestureConfig = {
|
|
46
|
+
minSwipeDistance: 50,
|
|
47
|
+
maxSwipeTime: 300,
|
|
48
|
+
minPinchDistance: 20,
|
|
49
|
+
enableHapticFeedback: true,
|
|
50
|
+
enableSoundFeedback: false,
|
|
36
51
|
...config
|
|
37
52
|
}
|
|
38
53
|
|
|
39
54
|
const [gestureState, setGestureState] = useState<GestureState>({
|
|
40
|
-
isTracking,
|
|
41
|
-
currentGesture,
|
|
42
|
-
lastGesture,
|
|
43
|
-
touchCount
|
|
55
|
+
isTracking: false,
|
|
56
|
+
currentGesture: 'none',
|
|
57
|
+
lastGesture: null,
|
|
58
|
+
touchCount: 0
|
|
59
|
+
})
|
|
44
60
|
|
|
45
|
-
const touchStartRef = useRef<{ x; y; time} | null>(null)
|
|
61
|
+
const touchStartRef = useRef<{ x: number; y: number; time: number } | null>(null)
|
|
46
62
|
const touchStartDistanceRef = useRef<number>(0)
|
|
47
|
-
const touchStartCenterRef = useRef<{ x; y} | null>(null)
|
|
63
|
+
const touchStartCenterRef = useRef<{ x: number; y: number } | null>(null)
|
|
48
64
|
const longPressTimerRef = useRef<NodeJS.Timeout | null>(null)
|
|
49
65
|
const lastTapTimeRef = useRef<number>(0)
|
|
50
66
|
|
|
@@ -80,25 +96,25 @@ export const useGestures = (
|
|
|
80
96
|
}, [defaultConfig.enableSoundFeedback])
|
|
81
97
|
|
|
82
98
|
// Calculate distance between two points
|
|
83
|
-
const calculateDistance = useCallback((p1; y}, p2; y}) => {
|
|
99
|
+
const calculateDistance = useCallback((p1: { x: number; y: number }, p2: { x: number; y: number }) => {
|
|
84
100
|
const dx = p2.x - p1.x
|
|
85
101
|
const dy = p2.y - p1.y
|
|
86
102
|
return Math.sqrt(dx * dx + dy * dy)
|
|
87
103
|
}, [])
|
|
88
104
|
|
|
89
105
|
// Calculate center point between two touches
|
|
90
|
-
const calculateCenter = useCallback((touches) => {
|
|
106
|
+
const calculateCenter = useCallback((touches: TouchList) => {
|
|
91
107
|
let x = 0
|
|
92
108
|
let y = 0
|
|
93
109
|
for (let i = 0; i < touches.length; i++) {
|
|
94
110
|
x += touches[i].clientX
|
|
95
111
|
y += touches[i].clientY
|
|
96
112
|
}
|
|
97
|
-
return { x, y}
|
|
113
|
+
return { x: x / touches.length, y: y / touches.length }
|
|
98
114
|
}, [])
|
|
99
115
|
|
|
100
116
|
// Handle touch start
|
|
101
|
-
const handleTouchStart = useCallback((event) => {
|
|
117
|
+
const handleTouchStart = useCallback((event: TouchEvent) => {
|
|
102
118
|
event.preventDefault()
|
|
103
119
|
|
|
104
120
|
const touches = event.touches
|
|
@@ -107,39 +123,39 @@ export const useGestures = (
|
|
|
107
123
|
if (touchCount === 1) {
|
|
108
124
|
const touch = touches[0]
|
|
109
125
|
touchStartRef.current = {
|
|
110
|
-
x,
|
|
111
|
-
y,
|
|
112
|
-
time)
|
|
126
|
+
x: touch.clientX,
|
|
127
|
+
y: touch.clientY,
|
|
128
|
+
time: Date.now()
|
|
113
129
|
}
|
|
114
130
|
|
|
115
131
|
// Start long press timer
|
|
116
132
|
longPressTimerRef.current = setTimeout(() => {
|
|
117
133
|
if (touchStartRef.current) {
|
|
118
|
-
const position = { x, y}
|
|
119
|
-
setGestureState(prev => ({ ...prev, currentGesture}))
|
|
134
|
+
const position = { x: touch.clientX, y: touch.clientY }
|
|
135
|
+
setGestureState(prev => ({ ...prev, currentGesture: 'longPress' }))
|
|
120
136
|
callbacks.onLongPress?.(position)
|
|
121
137
|
triggerHapticFeedback()
|
|
122
138
|
}
|
|
123
139
|
}, 500)
|
|
124
140
|
|
|
125
|
-
callbacks.onTouchStart?.({ x, y})
|
|
141
|
+
callbacks.onTouchStart?.({ x: touch.clientX, y: touch.clientY })
|
|
126
142
|
} else if (touchCount === 2) {
|
|
127
143
|
// Pinch gesture start
|
|
128
144
|
const center = calculateCenter(touches)
|
|
129
145
|
const distance = calculateDistance(
|
|
130
|
-
{ x].clientX, y].clientY },
|
|
131
|
-
{ x].clientX, y].clientY }
|
|
146
|
+
{ x: touches[0].clientX, y: touches[0].clientY },
|
|
147
|
+
{ x: touches[1].clientX, y: touches[1].clientY }
|
|
132
148
|
)
|
|
133
149
|
|
|
134
150
|
touchStartCenterRef.current = center
|
|
135
151
|
touchStartDistanceRef.current = distance
|
|
136
152
|
}
|
|
137
153
|
|
|
138
|
-
setGestureState(prev => ({ ...prev, isTracking, touchCount }))
|
|
154
|
+
setGestureState(prev => ({ ...prev, isTracking: true, touchCount }))
|
|
139
155
|
}, [callbacks, calculateCenter, calculateDistance, triggerHapticFeedback])
|
|
140
156
|
|
|
141
157
|
// Handle touch move
|
|
142
|
-
const handleTouchMove = useCallback((event) => {
|
|
158
|
+
const handleTouchMove = useCallback((event: TouchEvent) => {
|
|
143
159
|
event.preventDefault()
|
|
144
160
|
|
|
145
161
|
const touches = event.touches
|
|
@@ -155,27 +171,27 @@ export const useGestures = (
|
|
|
155
171
|
// Handle pinch gesture
|
|
156
172
|
const center = calculateCenter(touches)
|
|
157
173
|
const distance = calculateDistance(
|
|
158
|
-
{ x].clientX, y].clientY },
|
|
159
|
-
{ x].clientX, y].clientY }
|
|
174
|
+
{ x: touches[0].clientX, y: touches[0].clientY },
|
|
175
|
+
{ x: touches[1].clientX, y: touches[1].clientY }
|
|
160
176
|
)
|
|
161
177
|
|
|
162
178
|
const scale = distance / touchStartDistanceRef.current
|
|
163
179
|
|
|
164
180
|
if (Math.abs(scale - 1) * 100 > defaultConfig.minPinchDistance) {
|
|
165
|
-
const pinchGesture= {
|
|
181
|
+
const pinchGesture: PinchGesture = {
|
|
166
182
|
scale,
|
|
167
183
|
center,
|
|
168
184
|
distance
|
|
169
185
|
}
|
|
170
186
|
|
|
171
|
-
setGestureState(prev => ({ ...prev, currentGesture, lastGesture}))
|
|
187
|
+
setGestureState(prev => ({ ...prev, currentGesture: 'pinch', lastGesture: pinchGesture }))
|
|
172
188
|
callbacks.onPinch?.(pinchGesture)
|
|
173
189
|
}
|
|
174
190
|
}
|
|
175
191
|
}, [callbacks, calculateCenter, calculateDistance, defaultConfig.minPinchDistance])
|
|
176
192
|
|
|
177
193
|
// Handle touch end
|
|
178
|
-
const handleTouchEnd = useCallback((event) => {
|
|
194
|
+
const handleTouchEnd = useCallback((event: TouchEvent) => {
|
|
179
195
|
event.preventDefault()
|
|
180
196
|
|
|
181
197
|
const touches = event.changedTouches
|
|
@@ -193,19 +209,22 @@ export const useGestures = (
|
|
|
193
209
|
|
|
194
210
|
if (distance >= defaultConfig.minSwipeDistance && duration <= defaultConfig.maxSwipeTime) {
|
|
195
211
|
// Determine swipe direction
|
|
196
|
-
let direction
|
|
197
|
-
|
|
198
|
-
direction =
|
|
212
|
+
let direction: 'up' | 'down' | 'left' | 'right'
|
|
213
|
+
if (Math.abs(dx) > Math.abs(dy)) {
|
|
214
|
+
direction = dx > 0 ? 'right' : 'left'
|
|
215
|
+
} else {
|
|
216
|
+
direction = dy > 0 ? 'down' : 'up'
|
|
217
|
+
}
|
|
199
218
|
|
|
200
219
|
const velocity = distance / duration
|
|
201
|
-
const swipeGesture= {
|
|
220
|
+
const swipeGesture: SwipeGesture = {
|
|
202
221
|
direction,
|
|
203
222
|
distance,
|
|
204
223
|
velocity,
|
|
205
224
|
duration
|
|
206
225
|
}
|
|
207
226
|
|
|
208
|
-
setGestureState(prev => ({ ...prev, currentGesture, lastGesture}))
|
|
227
|
+
setGestureState(prev => ({ ...prev, currentGesture: 'swipe', lastGesture: swipeGesture }))
|
|
209
228
|
callbacks.onSwipe?.(swipeGesture)
|
|
210
229
|
triggerHapticFeedback()
|
|
211
230
|
triggerSoundFeedback()
|
|
@@ -216,7 +235,7 @@ export const useGestures = (
|
|
|
216
235
|
|
|
217
236
|
if (timeSinceLastTap < 300) {
|
|
218
237
|
// Double tap detected
|
|
219
|
-
const position = { x, y}
|
|
238
|
+
const position = { x: touch.clientX, y: touch.clientY }
|
|
220
239
|
callbacks.onTap?.(position)
|
|
221
240
|
triggerHapticFeedback()
|
|
222
241
|
}
|
|
@@ -231,14 +250,14 @@ export const useGestures = (
|
|
|
231
250
|
}
|
|
232
251
|
|
|
233
252
|
touchStartRef.current = null
|
|
234
|
-
callbacks.onTouchEnd?.({ x, y})
|
|
253
|
+
callbacks.onTouchEnd?.({ x: touch.clientX, y: touch.clientY })
|
|
235
254
|
} else if (touchCount === 0) {
|
|
236
255
|
// All touches ended
|
|
237
256
|
touchStartCenterRef.current = null
|
|
238
257
|
touchStartDistanceRef.current = 0
|
|
239
258
|
}
|
|
240
259
|
|
|
241
|
-
setGestureState(prev => ({ ...prev, isTracking, currentGesture}))
|
|
260
|
+
setGestureState(prev => ({ ...prev, isTracking: false, currentGesture: 'none' }))
|
|
242
261
|
}, [callbacks, defaultConfig.minSwipeDistance, defaultConfig.maxSwipeTime, triggerHapticFeedback, triggerSoundFeedback])
|
|
243
262
|
|
|
244
263
|
// Set up event listeners
|
|
@@ -246,9 +265,9 @@ export const useGestures = (
|
|
|
246
265
|
const element = elementRef.current
|
|
247
266
|
if (!element) return
|
|
248
267
|
|
|
249
|
-
element.addEventListener('touchstart', handleTouchStart, { passive})
|
|
250
|
-
element.addEventListener('touchmove', handleTouchMove, { passive})
|
|
251
|
-
element.addEventListener('touchend', handleTouchEnd, { passive})
|
|
268
|
+
element.addEventListener('touchstart', handleTouchStart, { passive: false })
|
|
269
|
+
element.addEventListener('touchmove', handleTouchMove, { passive: false })
|
|
270
|
+
element.addEventListener('touchend', handleTouchEnd, { passive: false })
|
|
252
271
|
|
|
253
272
|
return () => {
|
|
254
273
|
element.removeEventListener('touchstart', handleTouchStart)
|
|
@@ -265,10 +284,11 @@ export const useGestures = (
|
|
|
265
284
|
// Utility functions
|
|
266
285
|
const resetGestureState = useCallback(() => {
|
|
267
286
|
setGestureState({
|
|
268
|
-
isTracking,
|
|
269
|
-
currentGesture,
|
|
270
|
-
lastGesture,
|
|
271
|
-
touchCount
|
|
287
|
+
isTracking: false,
|
|
288
|
+
currentGesture: 'none',
|
|
289
|
+
lastGesture: null,
|
|
290
|
+
touchCount: 0
|
|
291
|
+
})
|
|
272
292
|
}, [])
|
|
273
293
|
|
|
274
294
|
const isGestureActive = useMemo(() => gestureState.isTracking, [gestureState.isTracking])
|
|
@@ -286,29 +306,33 @@ export const useGestures = (
|
|
|
286
306
|
|
|
287
307
|
// Convenience hooks for specific gestures
|
|
288
308
|
export const useSwipeGesture = (
|
|
289
|
-
elementRef
|
|
290
|
-
onSwipe) => void,
|
|
291
|
-
config
|
|
309
|
+
elementRef: React.RefObject<HTMLElement>,
|
|
310
|
+
onSwipe: (gesture: SwipeGesture) => void,
|
|
311
|
+
config?: Partial<GestureConfig>
|
|
312
|
+
) => {
|
|
292
313
|
return useGestures(elementRef, { onSwipe }, config)
|
|
293
314
|
}
|
|
294
315
|
|
|
295
316
|
export const usePinchGesture = (
|
|
296
|
-
elementRef
|
|
297
|
-
onPinch) => void,
|
|
298
|
-
config
|
|
317
|
+
elementRef: React.RefObject<HTMLElement>,
|
|
318
|
+
onPinch: (gesture: PinchGesture) => void,
|
|
319
|
+
config?: Partial<GestureConfig>
|
|
320
|
+
) => {
|
|
299
321
|
return useGestures(elementRef, { onPinch }, config)
|
|
300
322
|
}
|
|
301
323
|
|
|
302
324
|
export const useTapGesture = (
|
|
303
|
-
elementRef
|
|
304
|
-
onTap; y}) => void,
|
|
305
|
-
config
|
|
325
|
+
elementRef: React.RefObject<HTMLElement>,
|
|
326
|
+
onTap: (position: { x: number; y: number }) => void,
|
|
327
|
+
config?: Partial<GestureConfig>
|
|
328
|
+
) => {
|
|
306
329
|
return useGestures(elementRef, { onTap }, config)
|
|
307
330
|
}
|
|
308
331
|
|
|
309
332
|
export const useLongPressGesture = (
|
|
310
|
-
elementRef
|
|
311
|
-
onLongPress; y}) => void,
|
|
312
|
-
config
|
|
333
|
+
elementRef: React.RefObject<HTMLElement>,
|
|
334
|
+
onLongPress: (position: { x: number; y: number }) => void,
|
|
335
|
+
config?: Partial<GestureConfig>
|
|
336
|
+
) => {
|
|
313
337
|
return useGestures(elementRef, { onLongPress }, config)
|
|
314
338
|
}
|
|
@@ -1,24 +1,45 @@
|
|
|
1
1
|
import { useState, useEffect, useCallback, useRef } from 'react'
|
|
2
2
|
|
|
3
3
|
export interface GPUInfo {
|
|
4
|
-
vendor
|
|
4
|
+
vendor: string
|
|
5
|
+
renderer: string
|
|
6
|
+
version: string
|
|
7
|
+
isWebGLSupported: boolean
|
|
8
|
+
isWebGL2Supported: boolean
|
|
9
|
+
maxTextureSize: number
|
|
10
|
+
maxAnisotropy: number
|
|
11
|
+
maxPrecision: string
|
|
12
|
+
}
|
|
5
13
|
|
|
6
14
|
export interface HardwareAccelerationMetrics {
|
|
7
|
-
fps
|
|
15
|
+
fps: number
|
|
16
|
+
frameTime: number
|
|
17
|
+
memoryUsage: number
|
|
18
|
+
gpuUtilization: number
|
|
19
|
+
batteryImpact: number
|
|
20
|
+
performanceScore: number
|
|
21
|
+
}
|
|
8
22
|
|
|
9
23
|
export interface HardwareAccelerationConfig {
|
|
10
|
-
enableGPUMonitoring
|
|
24
|
+
enableGPUMonitoring?: boolean
|
|
25
|
+
enablePerformanceTracking?: boolean
|
|
26
|
+
enableBatteryOptimization?: boolean
|
|
27
|
+
enableAutomaticOptimization?: boolean
|
|
28
|
+
fpsTarget?: number
|
|
29
|
+
memoryThreshold?: number
|
|
30
|
+
batteryLowThreshold?: number
|
|
31
|
+
}
|
|
11
32
|
|
|
12
33
|
export interface HardwareAccelerationCallbacks {
|
|
13
|
-
onGPUDetected
|
|
14
|
-
onPerformanceWarning
|
|
15
|
-
onBatteryWarning
|
|
16
|
-
onOptimizationApplied
|
|
34
|
+
onGPUDetected?: (gpuInfo: GPUInfo) => void
|
|
35
|
+
onPerformanceWarning?: (warning: string, metrics: HardwareAccelerationMetrics) => void
|
|
36
|
+
onBatteryWarning?: (level: number, isLow: boolean) => void
|
|
37
|
+
onOptimizationApplied?: (optimization: string) => void
|
|
17
38
|
}
|
|
18
39
|
|
|
19
40
|
export const useHardwareAcceleration = (
|
|
20
|
-
config= {},
|
|
21
|
-
callbacks= {}
|
|
41
|
+
config: HardwareAccelerationConfig = {},
|
|
42
|
+
callbacks: HardwareAccelerationCallbacks = {}
|
|
22
43
|
) => {
|
|
23
44
|
const {
|
|
24
45
|
enableGPUMonitoring = true,
|
|
@@ -32,12 +53,13 @@ export const useHardwareAcceleration = (
|
|
|
32
53
|
|
|
33
54
|
const [gpuInfo, setGpuInfo] = useState<GPUInfo | null>(null)
|
|
34
55
|
const [metrics, setMetrics] = useState<HardwareAccelerationMetrics>({
|
|
35
|
-
fps,
|
|
36
|
-
frameTime,
|
|
37
|
-
memoryUsage,
|
|
38
|
-
gpuUtilization,
|
|
39
|
-
batteryImpact,
|
|
40
|
-
performanceScore
|
|
56
|
+
fps: 60,
|
|
57
|
+
frameTime: 16.67,
|
|
58
|
+
memoryUsage: 0,
|
|
59
|
+
gpuUtilization: 0,
|
|
60
|
+
batteryImpact: 0,
|
|
61
|
+
performanceScore: 100
|
|
62
|
+
})
|
|
41
63
|
const [isOptimizing, setIsOptimizing] = useState(false)
|
|
42
64
|
const [optimizations, setOptimizations] = useState<string[]>([])
|
|
43
65
|
const [isHardwareAccelerated, setIsHardwareAccelerated] = useState(false)
|
|
@@ -49,7 +71,7 @@ export const useHardwareAcceleration = (
|
|
|
49
71
|
const performanceTimerRef = useRef<number | null>(null)
|
|
50
72
|
|
|
51
73
|
// GPU capability detection
|
|
52
|
-
const detectGPU = useCallback(()=> {
|
|
74
|
+
const detectGPU = useCallback((): GPUInfo | null => {
|
|
53
75
|
if (!enableGPUMonitoring) return null
|
|
54
76
|
|
|
55
77
|
try {
|
|
@@ -58,18 +80,21 @@ export const useHardwareAcceleration = (
|
|
|
58
80
|
|
|
59
81
|
if (!gl) {
|
|
60
82
|
return {
|
|
61
|
-
vendor,
|
|
62
|
-
renderer,
|
|
63
|
-
version,
|
|
64
|
-
isWebGLSupported,
|
|
65
|
-
isWebGL2Supported,
|
|
66
|
-
maxTextureSize,
|
|
67
|
-
maxAnisotropy,
|
|
68
|
-
maxPrecision
|
|
83
|
+
vendor: 'Unknown',
|
|
84
|
+
renderer: 'WebGL not supported',
|
|
85
|
+
version: 'Unknown',
|
|
86
|
+
isWebGLSupported: false,
|
|
87
|
+
isWebGL2Supported: false,
|
|
88
|
+
maxTextureSize: 0,
|
|
89
|
+
maxAnisotropy: 0,
|
|
90
|
+
maxPrecision: 'Unknown'
|
|
91
|
+
}
|
|
69
92
|
}
|
|
70
93
|
|
|
71
94
|
const debugInfo = gl.getExtension('WEBGL_debug_renderer_info')
|
|
72
|
-
const vendor = debugInfo ? gl.getParameter(debugInfo.UNMASKED_VENDOR_WEBGL)
|
|
95
|
+
const vendor = debugInfo ? gl.getParameter(debugInfo.UNMASKED_VENDOR_WEBGL) : 'Unknown'
|
|
96
|
+
const renderer = debugInfo ? gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL) : 'Unknown'
|
|
97
|
+
const version = gl.getParameter(gl.VERSION) || 'Unknown'
|
|
73
98
|
|
|
74
99
|
// Check WebGL2 support
|
|
75
100
|
const canvas2 = document.createElement('canvas')
|
|
@@ -81,11 +106,11 @@ export const useHardwareAcceleration = (
|
|
|
81
106
|
const maxAnisotropy = gl.getParameter((gl as any).MAX_TEXTURE_MAX_ANISOTROPY_EXT) || 0
|
|
82
107
|
const maxPrecision = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT)?.precision?.toString() || 'Unknown'
|
|
83
108
|
|
|
84
|
-
const gpuInfo= {
|
|
109
|
+
const gpuInfo: GPUInfo = {
|
|
85
110
|
vendor,
|
|
86
111
|
renderer,
|
|
87
112
|
version,
|
|
88
|
-
isWebGLSupported,
|
|
113
|
+
isWebGLSupported: true,
|
|
89
114
|
isWebGL2Supported,
|
|
90
115
|
maxTextureSize,
|
|
91
116
|
maxAnisotropy,
|
|
@@ -97,7 +122,7 @@ export const useHardwareAcceleration = (
|
|
|
97
122
|
|
|
98
123
|
return gpuInfo
|
|
99
124
|
} catch (error) {
|
|
100
|
-
console.warn('GPU detection failed, error)
|
|
125
|
+
console.warn('GPU detection failed:', error)
|
|
101
126
|
return null
|
|
102
127
|
}
|
|
103
128
|
}, [enableGPUMonitoring, callbacks])
|
|
@@ -128,7 +153,7 @@ export const useHardwareAcceleration = (
|
|
|
128
153
|
|
|
129
154
|
const performanceScore = Math.round((fpsScore + timeScore + memoryScore + gpuScore) / 4)
|
|
130
155
|
|
|
131
|
-
const newMetrics= {
|
|
156
|
+
const newMetrics: HardwareAccelerationMetrics = {
|
|
132
157
|
fps,
|
|
133
158
|
frameTime,
|
|
134
159
|
memoryUsage,
|
|
@@ -166,7 +191,7 @@ export const useHardwareAcceleration = (
|
|
|
166
191
|
applyBatteryOptimizations()
|
|
167
192
|
}
|
|
168
193
|
} catch (error) {
|
|
169
|
-
console.warn('Battery API not available, error)
|
|
194
|
+
console.warn('Battery API not available:', error)
|
|
170
195
|
}
|
|
171
196
|
}, [enableBatteryOptimization, batteryLowThreshold, callbacks])
|
|
172
197
|
|
|
@@ -199,7 +224,7 @@ export const useHardwareAcceleration = (
|
|
|
199
224
|
setIsOptimizing(true)
|
|
200
225
|
|
|
201
226
|
setTimeout(() => {
|
|
202
|
-
const optimizations] = []
|
|
227
|
+
const optimizations: string[] = []
|
|
203
228
|
|
|
204
229
|
if (metrics.fps < fpsTarget * 0.8) {
|
|
205
230
|
optimizations.push('Hardware acceleration optimized for better FPS')
|
|
@@ -261,7 +286,7 @@ export const useHardwareAcceleration = (
|
|
|
261
286
|
}
|
|
262
287
|
}
|
|
263
288
|
} catch (error) {
|
|
264
|
-
console.warn('Hardware acceleration initialization failed, error)
|
|
289
|
+
console.warn('Hardware acceleration initialization failed:', error)
|
|
265
290
|
}
|
|
266
291
|
}, [detectGPU, enablePerformanceTracking, enableBatteryOptimization, checkBatteryStatus, measurePerformance])
|
|
267
292
|
|
|
@@ -303,11 +328,14 @@ export const useHardwareAcceleration = (
|
|
|
303
328
|
checkHardwareAcceleration,
|
|
304
329
|
|
|
305
330
|
// Computed values
|
|
306
|
-
isGPUSupported,
|
|
307
|
-
isWebGL2Supported,
|
|
308
|
-
performanceLevel
|
|
309
|
-
|
|
310
|
-
|
|
331
|
+
isGPUSupported: !!gpuInfo?.isWebGLSupported,
|
|
332
|
+
isWebGL2Supported: !!gpuInfo?.isWebGL2Supported,
|
|
333
|
+
performanceLevel: metrics.performanceScore >= 90 ? 'excellent' :
|
|
334
|
+
metrics.performanceScore >= 80 ? 'good' :
|
|
335
|
+
metrics.performanceScore >= 70 ? 'fair' : 'poor',
|
|
336
|
+
needsOptimization: metrics.performanceScore < 70,
|
|
337
|
+
batteryOptimized: metrics.batteryImpact < 50
|
|
338
|
+
}
|
|
311
339
|
}
|
|
312
340
|
|
|
313
341
|
export default useHardwareAcceleration
|