@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,25 +1,51 @@
|
|
|
1
1
|
import { useState, useCallback, useRef, useEffect } from 'react'
|
|
2
2
|
|
|
3
3
|
export interface KeyboardOptimizationConfig {
|
|
4
|
-
enableKeyboardDetection
|
|
4
|
+
enableKeyboardDetection?: boolean
|
|
5
|
+
enableAutoOptimization?: boolean
|
|
6
|
+
enablePerformanceMonitoring?: boolean
|
|
7
|
+
enableBatteryOptimization?: boolean
|
|
8
|
+
enableAccessibilitySupport?: boolean
|
|
9
|
+
keyboardDetectionInterval?: number
|
|
10
|
+
performanceThreshold?: number
|
|
11
|
+
}
|
|
5
12
|
|
|
6
13
|
export interface KeyboardState {
|
|
7
|
-
isVisible
|
|
14
|
+
isVisible: boolean
|
|
15
|
+
height: number
|
|
16
|
+
type: 'default' | 'numeric' | 'email' | 'tel' | 'url' | 'search' | 'decimal'
|
|
17
|
+
orientation: 'portrait' | 'landscape'
|
|
18
|
+
platform: 'ios' | 'android' | 'unknown'
|
|
19
|
+
language: string
|
|
20
|
+
inputMode: string
|
|
21
|
+
autoCapitalize: string
|
|
22
|
+
autoComplete: string
|
|
23
|
+
autoCorrect: string
|
|
24
|
+
spellCheck: boolean
|
|
25
|
+
}
|
|
8
26
|
|
|
9
27
|
export interface KeyboardOptimization {
|
|
10
|
-
id
|
|
28
|
+
id: string
|
|
29
|
+
name: string
|
|
30
|
+
type: 'keyboard' | 'input' | 'performance' | 'accessibility'
|
|
31
|
+
applied: boolean
|
|
32
|
+
impact: 'low' | 'medium' | 'high'
|
|
33
|
+
description: string
|
|
34
|
+
keyboardType?: string
|
|
35
|
+
inputMode?: string
|
|
36
|
+
}
|
|
11
37
|
|
|
12
38
|
export interface MobileKeyboardOptimizationCallbacks {
|
|
13
|
-
onKeyboardStateChanged
|
|
14
|
-
onOptimizationApplied
|
|
15
|
-
onPerformanceOptimized
|
|
16
|
-
onBatteryOptimized
|
|
17
|
-
onAccessibilityEnhanced
|
|
39
|
+
onKeyboardStateChanged?: (state: KeyboardState) => void
|
|
40
|
+
onOptimizationApplied?: (optimization: KeyboardOptimization) => void
|
|
41
|
+
onPerformanceOptimized?: (optimization: string) => void
|
|
42
|
+
onBatteryOptimized?: (strategy: string) => void
|
|
43
|
+
onAccessibilityEnhanced?: (feature: string) => void
|
|
18
44
|
}
|
|
19
45
|
|
|
20
46
|
export const useMobileKeyboardOptimization = (
|
|
21
|
-
config= {},
|
|
22
|
-
callbacks= {}
|
|
47
|
+
config: KeyboardOptimizationConfig = {},
|
|
48
|
+
callbacks: MobileKeyboardOptimizationCallbacks = {}
|
|
23
49
|
) => {
|
|
24
50
|
const {
|
|
25
51
|
enableKeyboardDetection = true,
|
|
@@ -32,25 +58,27 @@ export const useMobileKeyboardOptimization = (
|
|
|
32
58
|
} = config
|
|
33
59
|
|
|
34
60
|
const [keyboardState, setKeyboardState] = useState<KeyboardState>({
|
|
35
|
-
isVisible,
|
|
36
|
-
height,
|
|
37
|
-
type,
|
|
38
|
-
orientation,
|
|
39
|
-
platform,
|
|
40
|
-
language,
|
|
41
|
-
inputMode,
|
|
42
|
-
autoCapitalize,
|
|
43
|
-
autoComplete,
|
|
44
|
-
autoCorrect,
|
|
45
|
-
spellCheck
|
|
61
|
+
isVisible: false,
|
|
62
|
+
height: 0,
|
|
63
|
+
type: 'default',
|
|
64
|
+
orientation: 'portrait',
|
|
65
|
+
platform: 'unknown',
|
|
66
|
+
language: 'en-US',
|
|
67
|
+
inputMode: 'text',
|
|
68
|
+
autoCapitalize: 'sentences',
|
|
69
|
+
autoComplete: 'on',
|
|
70
|
+
autoCorrect: 'on',
|
|
71
|
+
spellCheck: true
|
|
72
|
+
})
|
|
46
73
|
|
|
47
74
|
const [optimizations, setOptimizations] = useState<KeyboardOptimization[]>([])
|
|
48
75
|
const [isOptimizing, setIsOptimizing] = useState(false)
|
|
49
76
|
const [performanceMetrics, setPerformanceMetrics] = useState({
|
|
50
|
-
frameRate,
|
|
51
|
-
inputLatency,
|
|
52
|
-
keyboardResponseTime,
|
|
53
|
-
memoryUsage
|
|
77
|
+
frameRate: 60,
|
|
78
|
+
inputLatency: 0,
|
|
79
|
+
keyboardResponseTime: 0,
|
|
80
|
+
memoryUsage: 0
|
|
81
|
+
})
|
|
54
82
|
|
|
55
83
|
const keyboardDetectionRef = useRef<number | null>(null)
|
|
56
84
|
const performanceTimerRef = useRef<number | null>(null)
|
|
@@ -68,7 +96,8 @@ export const useMobileKeyboardOptimization = (
|
|
|
68
96
|
|
|
69
97
|
// Detect device orientation
|
|
70
98
|
const detectOrientation = useCallback(() => {
|
|
71
|
-
return window.innerHeight > window.innerWidth ? 'portrait'
|
|
99
|
+
return window.innerHeight > window.innerWidth ? 'portrait' : 'landscape'
|
|
100
|
+
}, [])
|
|
72
101
|
|
|
73
102
|
// Detect keyboard visibility
|
|
74
103
|
const detectKeyboardVisibility = useCallback(() => {
|
|
@@ -82,12 +111,14 @@ export const useMobileKeyboardOptimization = (
|
|
|
82
111
|
setKeyboardState(prev => ({
|
|
83
112
|
...prev,
|
|
84
113
|
isVisible,
|
|
85
|
-
height
|
|
114
|
+
height: isVisible ? heightDifference : 0
|
|
115
|
+
}))
|
|
86
116
|
|
|
87
117
|
callbacks.onKeyboardStateChanged?.({
|
|
88
118
|
...keyboardState,
|
|
89
119
|
isVisible,
|
|
90
|
-
height
|
|
120
|
+
height: isVisible ? heightDifference : 0
|
|
121
|
+
})
|
|
91
122
|
}
|
|
92
123
|
|
|
93
124
|
lastKeyboardHeightRef.current = currentHeight
|
|
@@ -128,7 +159,7 @@ export const useMobileKeyboardOptimization = (
|
|
|
128
159
|
|
|
129
160
|
setPerformanceMetrics(prev => ({
|
|
130
161
|
...prev,
|
|
131
|
-
frameRate,
|
|
162
|
+
frameRate: fps,
|
|
132
163
|
inputLatency
|
|
133
164
|
}))
|
|
134
165
|
|
|
@@ -149,28 +180,30 @@ export const useMobileKeyboardOptimization = (
|
|
|
149
180
|
}, [enablePerformanceMonitoring])
|
|
150
181
|
|
|
151
182
|
// Keyboard type optimization
|
|
152
|
-
const optimizeKeyboardType = useCallback((inputType) => {
|
|
183
|
+
const optimizeKeyboardType = useCallback((inputType: string) => {
|
|
153
184
|
setIsOptimizing(true)
|
|
154
185
|
|
|
155
186
|
setTimeout(() => {
|
|
156
|
-
const keyboardOptimizations] = [
|
|
187
|
+
const keyboardOptimizations: KeyboardOptimization[] = [
|
|
157
188
|
{
|
|
158
|
-
id,
|
|
159
|
-
name,
|
|
160
|
-
type,
|
|
161
|
-
applied,
|
|
162
|
-
impact,
|
|
163
|
-
description} input`,
|
|
164
|
-
keyboardType,
|
|
165
|
-
inputMode
|
|
189
|
+
id: 'keyboard-type-1',
|
|
190
|
+
name: 'Keyboard Type Optimization',
|
|
191
|
+
type: 'keyboard',
|
|
192
|
+
applied: true,
|
|
193
|
+
impact: 'high',
|
|
194
|
+
description: `Optimized keyboard type for ${inputType} input`,
|
|
195
|
+
keyboardType: inputType,
|
|
196
|
+
inputMode: inputType
|
|
197
|
+
},
|
|
166
198
|
{
|
|
167
|
-
id,
|
|
168
|
-
name,
|
|
169
|
-
type,
|
|
170
|
-
applied,
|
|
171
|
-
impact,
|
|
172
|
-
description,
|
|
173
|
-
inputMode
|
|
199
|
+
id: 'keyboard-type-2',
|
|
200
|
+
name: 'Input Mode Enhancement',
|
|
201
|
+
type: 'input',
|
|
202
|
+
applied: true,
|
|
203
|
+
impact: 'medium',
|
|
204
|
+
description: 'Enhanced input mode for better mobile experience',
|
|
205
|
+
inputMode: inputType
|
|
206
|
+
}
|
|
174
207
|
]
|
|
175
208
|
|
|
176
209
|
setOptimizations(prev => [...prev, ...keyboardOptimizations])
|
|
@@ -183,27 +216,29 @@ export const useMobileKeyboardOptimization = (
|
|
|
183
216
|
}, [callbacks])
|
|
184
217
|
|
|
185
218
|
// Input behavior optimization
|
|
186
|
-
const optimizeInputBehavior = useCallback((inputType) => {
|
|
219
|
+
const optimizeInputBehavior = useCallback((inputType: string) => {
|
|
187
220
|
setIsOptimizing(true)
|
|
188
221
|
|
|
189
222
|
setTimeout(() => {
|
|
190
|
-
const inputOptimizations] = [
|
|
223
|
+
const inputOptimizations: KeyboardOptimization[] = [
|
|
191
224
|
{
|
|
192
|
-
id,
|
|
193
|
-
name,
|
|
194
|
-
type,
|
|
195
|
-
applied,
|
|
196
|
-
impact,
|
|
197
|
-
description,
|
|
198
|
-
inputMode
|
|
225
|
+
id: 'input-behavior-1',
|
|
226
|
+
name: 'Auto-capitalization Optimization',
|
|
227
|
+
type: 'input',
|
|
228
|
+
applied: true,
|
|
229
|
+
impact: 'medium',
|
|
230
|
+
description: 'Optimized auto-capitalization for mobile input',
|
|
231
|
+
inputMode: inputType
|
|
232
|
+
},
|
|
199
233
|
{
|
|
200
|
-
id,
|
|
201
|
-
name,
|
|
202
|
-
type,
|
|
203
|
-
applied,
|
|
204
|
-
impact,
|
|
205
|
-
description,
|
|
206
|
-
inputMode
|
|
234
|
+
id: 'input-behavior-2',
|
|
235
|
+
name: 'Autocomplete Enhancement',
|
|
236
|
+
type: 'input',
|
|
237
|
+
applied: true,
|
|
238
|
+
impact: 'medium',
|
|
239
|
+
description: 'Enhanced autocomplete for better user experience',
|
|
240
|
+
inputMode: inputType
|
|
241
|
+
}
|
|
207
242
|
]
|
|
208
243
|
|
|
209
244
|
setOptimizations(prev => [...prev, ...inputOptimizations])
|
|
@@ -222,21 +257,23 @@ export const useMobileKeyboardOptimization = (
|
|
|
222
257
|
setIsOptimizing(true)
|
|
223
258
|
|
|
224
259
|
setTimeout(() => {
|
|
225
|
-
const performanceOptimizations] = [
|
|
260
|
+
const performanceOptimizations: KeyboardOptimization[] = [
|
|
226
261
|
{
|
|
227
|
-
id,
|
|
228
|
-
name,
|
|
229
|
-
type,
|
|
230
|
-
applied,
|
|
231
|
-
impact,
|
|
232
|
-
description
|
|
262
|
+
id: 'performance-1',
|
|
263
|
+
name: 'Input Latency Optimization',
|
|
264
|
+
type: 'performance',
|
|
265
|
+
applied: true,
|
|
266
|
+
impact: 'high',
|
|
267
|
+
description: 'Reduced input latency for smoother typing experience'
|
|
268
|
+
},
|
|
233
269
|
{
|
|
234
|
-
id,
|
|
235
|
-
name,
|
|
236
|
-
type,
|
|
237
|
-
applied,
|
|
238
|
-
impact,
|
|
239
|
-
description
|
|
270
|
+
id: 'performance-2',
|
|
271
|
+
name: 'Frame Rate Optimization',
|
|
272
|
+
type: 'performance',
|
|
273
|
+
applied: true,
|
|
274
|
+
impact: 'medium',
|
|
275
|
+
description: 'Optimized frame rate for keyboard interactions'
|
|
276
|
+
}
|
|
240
277
|
]
|
|
241
278
|
|
|
242
279
|
setOptimizations(prev => [...prev, ...performanceOptimizations])
|
|
@@ -255,21 +292,23 @@ export const useMobileKeyboardOptimization = (
|
|
|
255
292
|
setIsOptimizing(true)
|
|
256
293
|
|
|
257
294
|
setTimeout(() => {
|
|
258
|
-
const batteryOptimizations] = [
|
|
295
|
+
const batteryOptimizations: KeyboardOptimization[] = [
|
|
259
296
|
{
|
|
260
|
-
id,
|
|
261
|
-
name,
|
|
262
|
-
type,
|
|
263
|
-
applied,
|
|
264
|
-
impact,
|
|
265
|
-
description
|
|
297
|
+
id: 'battery-1',
|
|
298
|
+
name: 'Battery-Conscious Keyboard',
|
|
299
|
+
type: 'performance',
|
|
300
|
+
applied: true,
|
|
301
|
+
impact: 'medium',
|
|
302
|
+
description: 'Battery-optimized keyboard behavior'
|
|
303
|
+
},
|
|
266
304
|
{
|
|
267
|
-
id,
|
|
268
|
-
name,
|
|
269
|
-
type,
|
|
270
|
-
applied,
|
|
271
|
-
impact,
|
|
272
|
-
description
|
|
305
|
+
id: 'battery-2',
|
|
306
|
+
name: 'Efficient Input Processing',
|
|
307
|
+
type: 'performance',
|
|
308
|
+
applied: true,
|
|
309
|
+
impact: 'low',
|
|
310
|
+
description: 'Efficient input processing for battery optimization'
|
|
311
|
+
}
|
|
273
312
|
]
|
|
274
313
|
|
|
275
314
|
setOptimizations(prev => [...prev, ...batteryOptimizations])
|
|
@@ -288,21 +327,23 @@ export const useMobileKeyboardOptimization = (
|
|
|
288
327
|
setIsOptimizing(true)
|
|
289
328
|
|
|
290
329
|
setTimeout(() => {
|
|
291
|
-
const accessibilityFeatures] = [
|
|
330
|
+
const accessibilityFeatures: KeyboardOptimization[] = [
|
|
292
331
|
{
|
|
293
|
-
id,
|
|
294
|
-
name,
|
|
295
|
-
type,
|
|
296
|
-
applied,
|
|
297
|
-
impact,
|
|
298
|
-
description
|
|
332
|
+
id: 'accessibility-1',
|
|
333
|
+
name: 'Keyboard Navigation',
|
|
334
|
+
type: 'accessibility',
|
|
335
|
+
applied: true,
|
|
336
|
+
impact: 'high',
|
|
337
|
+
description: 'Enhanced keyboard navigation support'
|
|
338
|
+
},
|
|
299
339
|
{
|
|
300
|
-
id,
|
|
301
|
-
name,
|
|
302
|
-
type,
|
|
303
|
-
applied,
|
|
304
|
-
impact,
|
|
305
|
-
description
|
|
340
|
+
id: 'accessibility-2',
|
|
341
|
+
name: 'Screen Reader Support',
|
|
342
|
+
type: 'accessibility',
|
|
343
|
+
applied: true,
|
|
344
|
+
impact: 'medium',
|
|
345
|
+
description: 'Improved screen reader compatibility'
|
|
346
|
+
}
|
|
306
347
|
]
|
|
307
348
|
|
|
308
349
|
setOptimizations(prev => [...prev, ...accessibilityFeatures])
|
|
@@ -315,7 +356,7 @@ export const useMobileKeyboardOptimization = (
|
|
|
315
356
|
}, [enableAccessibilitySupport, callbacks])
|
|
316
357
|
|
|
317
358
|
// Auto-optimize based on input type
|
|
318
|
-
const autoOptimizeForInputType = useCallback((inputType) => {
|
|
359
|
+
const autoOptimizeForInputType = useCallback((inputType: string) => {
|
|
319
360
|
optimizeKeyboardType(inputType)
|
|
320
361
|
optimizeInputBehavior(inputType)
|
|
321
362
|
optimizePerformance()
|
|
@@ -325,7 +366,7 @@ export const useMobileKeyboardOptimization = (
|
|
|
325
366
|
|
|
326
367
|
// Get keyboard optimization recommendations
|
|
327
368
|
const getOptimizationRecommendations = useCallback(() => {
|
|
328
|
-
const recommendations] = []
|
|
369
|
+
const recommendations: string[] = []
|
|
329
370
|
|
|
330
371
|
if (performanceMetrics.frameRate < performanceThreshold) {
|
|
331
372
|
recommendations.push('Consider reducing keyboard animation complexity to improve frame rate')
|
|
@@ -412,18 +453,18 @@ export const useMobileKeyboardOptimization = (
|
|
|
412
453
|
autoOptimizeForInputType,
|
|
413
454
|
|
|
414
455
|
// Utility functions
|
|
415
|
-
isKeyboardVisible) => keyboardState.isVisible,
|
|
416
|
-
getKeyboardHeight) => keyboardState.height,
|
|
417
|
-
getPlatform) => keyboardState.platform,
|
|
418
|
-
getOrientation) => keyboardState.orientation,
|
|
419
|
-
getOptimizationStatus) => ({
|
|
420
|
-
keyboard=> o.type === 'keyboard'),
|
|
421
|
-
input=> o.type === 'input'),
|
|
422
|
-
performance=> o.type === 'performance'),
|
|
423
|
-
accessibility=> o.type === 'accessibility')
|
|
456
|
+
isKeyboardVisible: () => keyboardState.isVisible,
|
|
457
|
+
getKeyboardHeight: () => keyboardState.height,
|
|
458
|
+
getPlatform: () => keyboardState.platform,
|
|
459
|
+
getOrientation: () => keyboardState.orientation,
|
|
460
|
+
getOptimizationStatus: () => ({
|
|
461
|
+
keyboard: optimizations.some(o => o.type === 'keyboard'),
|
|
462
|
+
input: optimizations.some(o => o.type === 'input'),
|
|
463
|
+
performance: optimizations.some(o => o.type === 'performance'),
|
|
464
|
+
accessibility: optimizations.some(o => o.type === 'accessibility')
|
|
424
465
|
}),
|
|
425
466
|
getOptimizationRecommendations,
|
|
426
|
-
clearOptimizations) => setOptimizations([])
|
|
467
|
+
clearOptimizations: () => setOptimizations([])
|
|
427
468
|
}
|
|
428
469
|
}
|
|
429
470
|
|
|
@@ -1,25 +1,45 @@
|
|
|
1
1
|
import { useState, useEffect, useCallback, useRef } from 'react'
|
|
2
2
|
|
|
3
3
|
export interface TouchTarget {
|
|
4
|
-
id
|
|
4
|
+
id: string
|
|
5
|
+
x: number
|
|
6
|
+
y: number
|
|
7
|
+
width: number
|
|
8
|
+
height: number
|
|
9
|
+
minSize: number
|
|
10
|
+
isOptimized: boolean
|
|
11
|
+
}
|
|
5
12
|
|
|
6
13
|
export interface TouchEvent {
|
|
7
|
-
type
|
|
8
|
-
|
|
14
|
+
type: 'tap' | 'double-tap' | 'long-press' | 'swipe' | 'pinch'
|
|
15
|
+
target: TouchTarget
|
|
16
|
+
coordinates: { x: number; y: number }
|
|
17
|
+
timestamp: number
|
|
18
|
+
duration?: number
|
|
19
|
+
distance?: number
|
|
20
|
+
}
|
|
9
21
|
|
|
10
22
|
export interface MobileLayoutConfig {
|
|
11
|
-
enableTouchTargetOptimization
|
|
23
|
+
enableTouchTargetOptimization?: boolean
|
|
24
|
+
enableGestureSupport?: boolean
|
|
25
|
+
enableTouchFeedback?: boolean
|
|
26
|
+
enablePerformanceOptimization?: boolean
|
|
27
|
+
minTouchTargetSize?: number
|
|
28
|
+
touchFeedbackDuration?: number
|
|
29
|
+
gestureThreshold?: number
|
|
30
|
+
longPressDelay?: number
|
|
31
|
+
}
|
|
12
32
|
|
|
13
33
|
export interface MobileLayoutCallbacks {
|
|
14
|
-
onTouchTargetOptimized
|
|
15
|
-
onGestureDetected
|
|
16
|
-
onTouchFeedback
|
|
17
|
-
onPerformanceOptimization
|
|
34
|
+
onTouchTargetOptimized?: (target: TouchTarget) => void
|
|
35
|
+
onGestureDetected?: (event: TouchEvent) => void
|
|
36
|
+
onTouchFeedback?: (type: string, target: TouchTarget) => void
|
|
37
|
+
onPerformanceOptimization?: (optimization: string) => void
|
|
18
38
|
}
|
|
19
39
|
|
|
20
40
|
export const useMobileLayout = (
|
|
21
|
-
config= {},
|
|
22
|
-
callbacks= {}
|
|
41
|
+
config: MobileLayoutConfig = {},
|
|
42
|
+
callbacks: MobileLayoutCallbacks = {}
|
|
23
43
|
) => {
|
|
24
44
|
const {
|
|
25
45
|
enableTouchTargetOptimization = true,
|
|
@@ -37,7 +57,7 @@ export const useMobileLayout = (
|
|
|
37
57
|
const [isOptimizing, setIsOptimizing] = useState(false)
|
|
38
58
|
const [optimizations, setOptimizations] = useState<string[]>([])
|
|
39
59
|
|
|
40
|
-
const touchStartRef = useRef<{ x; y; timestamp} | null>(null)
|
|
60
|
+
const touchStartRef = useRef<{ x: number; y: number; timestamp: number } | null>(null)
|
|
41
61
|
const longPressTimerRef = useRef<number | null>(null)
|
|
42
62
|
const touchFeedbackRef = useRef<HTMLDivElement | null>(null)
|
|
43
63
|
|
|
@@ -51,7 +71,7 @@ export const useMobileLayout = (
|
|
|
51
71
|
setTimeout(() => {
|
|
52
72
|
const optimizedTargets = touchTargets.map(target => ({
|
|
53
73
|
...target,
|
|
54
|
-
isOptimized
|
|
74
|
+
isOptimized: target.width >= minTouchTargetSize && target.height >= minTouchTargetSize
|
|
55
75
|
}))
|
|
56
76
|
|
|
57
77
|
setTouchTargets(optimizedTargets)
|
|
@@ -69,10 +89,10 @@ export const useMobileLayout = (
|
|
|
69
89
|
}, [enableTouchTargetOptimization, touchTargets, minTouchTargetSize, callbacks])
|
|
70
90
|
|
|
71
91
|
// Add touch target
|
|
72
|
-
const addTouchTarget = useCallback((target, 'isOptimized'>) => {
|
|
73
|
-
const newTarget= {
|
|
92
|
+
const addTouchTarget = useCallback((target: Omit<TouchTarget, 'isOptimized'>) => {
|
|
93
|
+
const newTarget: TouchTarget = {
|
|
74
94
|
...target,
|
|
75
|
-
isOptimized
|
|
95
|
+
isOptimized: target.width >= minTouchTargetSize && target.height >= minTouchTargetSize
|
|
76
96
|
}
|
|
77
97
|
|
|
78
98
|
setTouchTargets(prev => [...prev, newTarget])
|
|
@@ -83,12 +103,12 @@ export const useMobileLayout = (
|
|
|
83
103
|
}, [minTouchTargetSize, callbacks])
|
|
84
104
|
|
|
85
105
|
// Remove touch target
|
|
86
|
-
const removeTouchTarget = useCallback((id) => {
|
|
106
|
+
const removeTouchTarget = useCallback((id: string) => {
|
|
87
107
|
setTouchTargets(prev => prev.filter(target => target.id !== id))
|
|
88
108
|
}, [])
|
|
89
109
|
|
|
90
110
|
// Touch feedback
|
|
91
|
-
const showTouchFeedback = useCallback((type, target) => {
|
|
111
|
+
const showTouchFeedback = useCallback((type: string, target: TouchTarget) => {
|
|
92
112
|
if (!enableTouchFeedback) return
|
|
93
113
|
|
|
94
114
|
callbacks.onTouchFeedback?.(type, target)
|
|
@@ -98,12 +118,12 @@ export const useMobileLayout = (
|
|
|
98
118
|
const feedback = document.createElement('div')
|
|
99
119
|
feedback.className = `absolute rounded-full bg-cs-primary/20 pointer-events-none transition-all duration-${touchFeedbackDuration}ms`
|
|
100
120
|
feedback.style.cssText = `
|
|
101
|
-
left}px;
|
|
102
|
-
top}px;
|
|
103
|
-
width}px;
|
|
104
|
-
height}px;
|
|
105
|
-
transform);
|
|
106
|
-
opacity;
|
|
121
|
+
left: ${target.x}px;
|
|
122
|
+
top: ${target.y}px;
|
|
123
|
+
width: ${target.width}px;
|
|
124
|
+
height: ${target.height}px;
|
|
125
|
+
transform: scale(1.2);
|
|
126
|
+
opacity: 0.8;
|
|
107
127
|
`
|
|
108
128
|
|
|
109
129
|
touchFeedbackRef.current.appendChild(feedback)
|
|
@@ -124,7 +144,7 @@ export const useMobileLayout = (
|
|
|
124
144
|
}, [enableTouchFeedback, touchFeedbackDuration, callbacks])
|
|
125
145
|
|
|
126
146
|
// Gesture detection
|
|
127
|
-
const detectGesture = useCallback((startEvent, endEvent)=> {
|
|
147
|
+
const detectGesture = useCallback((startEvent: TouchEvent, endEvent: TouchEvent): TouchEvent | null => {
|
|
128
148
|
if (!enableGestureSupport) return null
|
|
129
149
|
|
|
130
150
|
const start = touchStartRef.current
|
|
@@ -135,21 +155,23 @@ export const useMobileLayout = (
|
|
|
135
155
|
const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY)
|
|
136
156
|
const duration = endEvent.timestamp - start.timestamp
|
|
137
157
|
|
|
138
|
-
let gestureType] = 'tap'
|
|
158
|
+
let gestureType: TouchEvent['type'] = 'tap'
|
|
139
159
|
|
|
140
160
|
if (distance > gestureThreshold) {
|
|
141
161
|
if (Math.abs(deltaX) > Math.abs(deltaY)) {
|
|
142
|
-
gestureType = deltaX > 0 ? 'swipe'
|
|
143
|
-
|
|
162
|
+
gestureType = deltaX > 0 ? 'swipe' : 'swipe'
|
|
163
|
+
} else {
|
|
164
|
+
gestureType = deltaY > 0 ? 'swipe' : 'swipe'
|
|
165
|
+
}
|
|
144
166
|
} else if (duration > longPressDelay) {
|
|
145
167
|
gestureType = 'long-press'
|
|
146
168
|
}
|
|
147
169
|
|
|
148
|
-
const gesture= {
|
|
149
|
-
type,
|
|
150
|
-
target,
|
|
151
|
-
coordinates,
|
|
152
|
-
timestamp,
|
|
170
|
+
const gesture: TouchEvent = {
|
|
171
|
+
type: gestureType,
|
|
172
|
+
target: startEvent.target,
|
|
173
|
+
coordinates: endEvent.coordinates,
|
|
174
|
+
timestamp: endEvent.timestamp,
|
|
153
175
|
duration,
|
|
154
176
|
distance
|
|
155
177
|
}
|
|
@@ -161,22 +183,22 @@ export const useMobileLayout = (
|
|
|
161
183
|
}, [enableGestureSupport, gestureThreshold, longPressDelay, callbacks])
|
|
162
184
|
|
|
163
185
|
// Touch event handlers
|
|
164
|
-
const handleTouchStart = useCallback((event, target) => {
|
|
186
|
+
const handleTouchStart = useCallback((event: React.TouchEvent, target: TouchTarget) => {
|
|
165
187
|
const touch = event.touches[0]
|
|
166
188
|
|
|
167
189
|
touchStartRef.current = {
|
|
168
|
-
x,
|
|
169
|
-
y,
|
|
170
|
-
timestamp)
|
|
190
|
+
x: touch.clientX,
|
|
191
|
+
y: touch.clientY,
|
|
192
|
+
timestamp: Date.now()
|
|
171
193
|
}
|
|
172
194
|
|
|
173
195
|
// Start long press timer
|
|
174
196
|
longPressTimerRef.current = window.setTimeout(() => {
|
|
175
|
-
const longPressEvent= {
|
|
176
|
-
type,
|
|
197
|
+
const longPressEvent: TouchEvent = {
|
|
198
|
+
type: 'long-press',
|
|
177
199
|
target,
|
|
178
|
-
coordinates, y},
|
|
179
|
-
timestamp)
|
|
200
|
+
coordinates: { x: touch.clientX, y: touch.clientY },
|
|
201
|
+
timestamp: Date.now()
|
|
180
202
|
}
|
|
181
203
|
|
|
182
204
|
setActiveGestures(prev => [...prev, longPressEvent])
|
|
@@ -187,7 +209,7 @@ export const useMobileLayout = (
|
|
|
187
209
|
showTouchFeedback('touch-start', target)
|
|
188
210
|
}, [longPressDelay, callbacks, showTouchFeedback])
|
|
189
211
|
|
|
190
|
-
const handleTouchEnd = useCallback((event, target) => {
|
|
212
|
+
const handleTouchEnd = useCallback((event: React.TouchEvent, target: TouchTarget) => {
|
|
191
213
|
if (longPressTimerRef.current) {
|
|
192
214
|
clearTimeout(longPressTimerRef.current)
|
|
193
215
|
longPressTimerRef.current = null
|
|
@@ -195,15 +217,15 @@ export const useMobileLayout = (
|
|
|
195
217
|
|
|
196
218
|
const touch = event.changedTouches[0]
|
|
197
219
|
const gesture = detectGesture({
|
|
198
|
-
type,
|
|
220
|
+
type: 'tap',
|
|
199
221
|
target,
|
|
200
|
-
coordinates, y},
|
|
201
|
-
timestamp)
|
|
222
|
+
coordinates: { x: touch.clientX, y: touch.clientY },
|
|
223
|
+
timestamp: Date.now()
|
|
202
224
|
}, {
|
|
203
|
-
type,
|
|
225
|
+
type: 'tap',
|
|
204
226
|
target,
|
|
205
|
-
coordinates, y},
|
|
206
|
-
timestamp)
|
|
227
|
+
coordinates: { x: touch.clientX, y: touch.clientY },
|
|
228
|
+
timestamp: Date.now()
|
|
207
229
|
})
|
|
208
230
|
if (gesture) {
|
|
209
231
|
showTouchFeedback(gesture.type, target)
|
|
@@ -270,10 +292,10 @@ export const useMobileLayout = (
|
|
|
270
292
|
optimizePerformance,
|
|
271
293
|
|
|
272
294
|
// Computed values
|
|
273
|
-
touchTargetCount,
|
|
274
|
-
optimizedTargetCount=> t.isOptimized).length,
|
|
275
|
-
gestureCount,
|
|
276
|
-
isTouchOptimized=> t.isOptimized)
|
|
295
|
+
touchTargetCount: touchTargets.length,
|
|
296
|
+
optimizedTargetCount: touchTargets.filter(t => t.isOptimized).length,
|
|
297
|
+
gestureCount: activeGestures.length,
|
|
298
|
+
isTouchOptimized: touchTargets.every(t => t.isOptimized)
|
|
277
299
|
}
|
|
278
300
|
}
|
|
279
301
|
|