@rakeyshgidwani/roger-ui-bank-theme-stan-design 0.1.3 → 0.1.5
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/index.d.ts +131 -131
- package/dist/index.esm.js +148 -148
- package/dist/index.js +148 -148
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/components/ui/accessibility-demo.tsx +271 -0
- package/src/components/ui/advanced-component-architecture-demo.tsx +916 -0
- package/src/components/ui/advanced-transition-system-demo.tsx +670 -0
- package/src/components/ui/advanced-transition-system.tsx +395 -0
- package/src/components/ui/animation/animated-container.tsx +166 -0
- package/src/components/ui/animation/index.ts +19 -0
- package/src/components/ui/animation/staggered-container.tsx +68 -0
- package/src/components/ui/animation-demo.tsx +250 -0
- package/src/components/ui/badge.tsx +33 -0
- package/src/components/ui/battery-conscious-animation-demo.tsx +568 -0
- package/src/components/ui/border-radius-shadow-demo.tsx +187 -0
- package/src/components/ui/button.tsx +36 -0
- package/src/components/ui/card.tsx +207 -0
- package/src/components/ui/checkbox.tsx +30 -0
- package/src/components/ui/color-preview.tsx +411 -0
- package/src/components/ui/data-display/chart.tsx +653 -0
- package/src/components/ui/data-display/data-grid-simple.tsx +76 -0
- package/src/components/ui/data-display/data-grid.tsx +680 -0
- package/src/components/ui/data-display/list.tsx +456 -0
- package/src/components/ui/data-display/table.tsx +482 -0
- package/src/components/ui/data-display/timeline.tsx +441 -0
- package/src/components/ui/data-display/tree.tsx +602 -0
- package/src/components/ui/data-display/types.ts +536 -0
- package/src/components/ui/enterprise-mobile-experience-demo.tsx +749 -0
- package/src/components/ui/enterprise-mobile-experience.tsx +464 -0
- package/src/components/ui/feedback/alert.tsx +157 -0
- package/src/components/ui/feedback/progress.tsx +292 -0
- package/src/components/ui/feedback/skeleton.tsx +185 -0
- package/src/components/ui/feedback/toast.tsx +280 -0
- package/src/components/ui/feedback/types.ts +125 -0
- package/src/components/ui/font-preview.tsx +288 -0
- package/src/components/ui/form-demo.tsx +553 -0
- package/src/components/ui/hardware-acceleration-demo.tsx +547 -0
- package/src/components/ui/input.tsx +35 -0
- package/src/components/ui/label.tsx +16 -0
- package/src/components/ui/layout-demo.tsx +367 -0
- package/src/components/ui/layouts/adaptive-layout.tsx +139 -0
- package/src/components/ui/layouts/desktop-layout.tsx +224 -0
- package/src/components/ui/layouts/index.ts +10 -0
- package/src/components/ui/layouts/mobile-layout.tsx +162 -0
- package/src/components/ui/layouts/tablet-layout.tsx +197 -0
- package/src/components/ui/mobile-form-validation.tsx +451 -0
- package/src/components/ui/mobile-input-demo.tsx +201 -0
- package/src/components/ui/mobile-input.tsx +281 -0
- package/src/components/ui/mobile-skeleton-loading-demo.tsx +638 -0
- package/src/components/ui/navigation/breadcrumb.tsx +158 -0
- package/src/components/ui/navigation/index.ts +36 -0
- package/src/components/ui/navigation/menu.tsx +374 -0
- package/src/components/ui/navigation/navigation-demo.tsx +324 -0
- package/src/components/ui/navigation/pagination.tsx +272 -0
- package/src/components/ui/navigation/sidebar.tsx +383 -0
- package/src/components/ui/navigation/stepper.tsx +303 -0
- package/src/components/ui/navigation/tabs.tsx +205 -0
- package/src/components/ui/navigation/types.ts +299 -0
- package/src/components/ui/overlay/backdrop.tsx +81 -0
- package/src/components/ui/overlay/focus-manager.tsx +143 -0
- package/src/components/ui/overlay/index.ts +36 -0
- package/src/components/ui/overlay/modal.tsx +270 -0
- package/src/components/ui/overlay/overlay-manager.tsx +110 -0
- package/src/components/ui/overlay/popover.tsx +462 -0
- package/src/components/ui/overlay/portal.tsx +79 -0
- package/src/components/ui/overlay/tooltip.tsx +303 -0
- package/src/components/ui/overlay/types.ts +196 -0
- package/src/components/ui/performance-demo.tsx +596 -0
- package/src/components/ui/semantic-input-system-demo.tsx +502 -0
- package/src/components/ui/semantic-input-system-demo.tsx.disabled +873 -0
- package/src/components/ui/tablet-layout.tsx +192 -0
- package/src/components/ui/theme-customizer.tsx +386 -0
- package/src/components/ui/theme-preview.tsx +310 -0
- package/src/components/ui/theme-switcher.tsx +264 -0
- package/src/components/ui/theme-toggle.tsx +38 -0
- package/src/components/ui/token-demo.tsx +195 -0
- package/src/components/ui/touch-demo.tsx +462 -0
- package/src/components/ui/touch-friendly-interface-demo.tsx +519 -0
- package/src/components/ui/touch-friendly-interface.tsx +296 -0
- package/src/hooks/index.ts +190 -0
- package/src/hooks/use-accessibility-support.ts +518 -0
- package/src/hooks/use-adaptive-layout.ts +289 -0
- package/src/hooks/use-advanced-patterns.ts +294 -0
- package/src/hooks/use-advanced-transition-system.ts +393 -0
- package/src/hooks/use-animation-profile.ts +288 -0
- package/src/hooks/use-battery-animations.ts +384 -0
- package/src/hooks/use-battery-conscious-loading.ts +475 -0
- package/src/hooks/use-battery-optimization.ts +330 -0
- package/src/hooks/use-battery-status.ts +299 -0
- package/src/hooks/use-component-performance.ts +344 -0
- package/src/hooks/use-device-loading-states.ts +459 -0
- package/src/hooks/use-device.tsx +110 -0
- package/src/hooks/use-enterprise-mobile-experience.ts +488 -0
- package/src/hooks/use-form-feedback.ts +403 -0
- package/src/hooks/use-form-performance.ts +513 -0
- package/src/hooks/use-frame-rate.ts +251 -0
- package/src/hooks/use-gestures.ts +338 -0
- package/src/hooks/use-hardware-acceleration.ts +341 -0
- package/src/hooks/use-input-accessibility.ts +455 -0
- package/src/hooks/use-input-performance.ts +506 -0
- package/src/hooks/use-layout-performance.ts +319 -0
- package/src/hooks/use-loading-accessibility.ts +535 -0
- package/src/hooks/use-loading-performance.ts +473 -0
- package/src/hooks/use-memory-usage.ts +287 -0
- package/src/hooks/use-mobile-form-layout.ts +464 -0
- package/src/hooks/use-mobile-form-validation.ts +518 -0
- package/src/hooks/use-mobile-keyboard-optimization.ts +472 -0
- package/src/hooks/use-mobile-layout.ts +302 -0
- package/src/hooks/use-mobile-optimization.ts +406 -0
- package/src/hooks/use-mobile-skeleton.ts +402 -0
- package/src/hooks/use-mobile-touch.ts +414 -0
- package/src/hooks/use-performance-throttling.ts +348 -0
- package/src/hooks/use-performance.ts +316 -0
- package/src/hooks/use-reusable-architecture.ts +414 -0
- package/src/hooks/use-semantic-input-types.ts +357 -0
- package/src/hooks/use-semantic-input.ts +565 -0
- package/src/hooks/use-tablet-layout.ts +384 -0
- package/src/hooks/use-touch-friendly-input.ts +524 -0
- package/src/hooks/use-touch-friendly-interface.ts +331 -0
- package/src/hooks/use-touch-optimization.ts +375 -0
- package/src/index.ts +279 -279
- package/src/lib/utils.ts +6 -0
- package/src/themes/README.md +272 -0
- package/src/themes/ThemeContext.tsx +31 -0
- package/src/themes/ThemeProvider.tsx +232 -0
- package/src/themes/accessibility/index.ts +27 -0
- package/src/themes/accessibility.ts +259 -0
- package/src/themes/aria-patterns.ts +420 -0
- package/src/themes/base-themes.ts +55 -0
- package/src/themes/colorManager.ts +380 -0
- package/src/themes/examples/dark-theme.ts +154 -0
- package/src/themes/examples/minimal-theme.ts +108 -0
- package/src/themes/focus-management.ts +701 -0
- package/src/themes/fontLoader.ts +201 -0
- package/src/themes/high-contrast.ts +621 -0
- package/src/themes/index.ts +19 -0
- package/src/themes/inheritance.ts +227 -0
- package/src/themes/keyboard-navigation.ts +550 -0
- package/src/themes/motion-reduction.ts +662 -0
- package/src/themes/navigation.ts +238 -0
- package/src/themes/screen-reader.ts +645 -0
- package/src/themes/systemThemeDetector.ts +182 -0
- package/src/themes/themeCSSUpdater.ts +262 -0
- package/src/themes/themePersistence.ts +238 -0
- package/src/themes/themes/default.ts +586 -0
- package/src/themes/themes/harvey.ts +554 -0
- package/src/themes/themes/stan-design.ts +683 -0
- package/src/themes/types.ts +460 -0
- package/src/themes/useSystemTheme.ts +48 -0
- package/src/themes/useTheme.ts +87 -0
- package/src/themes/validation.ts +462 -0
- package/src/tokens/index.ts +34 -0
- package/src/tokens/tokenExporter.ts +397 -0
- package/src/tokens/tokenGenerator.ts +276 -0
- package/src/tokens/tokenManager.ts +248 -0
- package/src/tokens/tokenValidator.ts +543 -0
- package/src/tokens/types.ts +78 -0
- package/src/utils/bundle-analyzer.ts +260 -0
- package/src/utils/bundle-splitting.ts +483 -0
- package/src/utils/lazy-loading.ts +441 -0
- package/src/utils/performance-monitor.ts +513 -0
- package/src/utils/tree-shaking.ts +274 -0
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
import { useState, useEffect, useCallback, useRef } from 'react'
|
|
2
|
+
|
|
3
|
+
export interface FeedbackState {
|
|
4
|
+
type: 'none' | 'success' | 'error' | 'warning' | 'info'
|
|
5
|
+
message: string
|
|
6
|
+
isVisible: boolean
|
|
7
|
+
isAnimating: boolean
|
|
8
|
+
duration: number
|
|
9
|
+
timestamp: number
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface FeedbackConfig {
|
|
13
|
+
enableAnimations: boolean
|
|
14
|
+
enableTouchFeedback: boolean
|
|
15
|
+
enableHapticFeedback: boolean
|
|
16
|
+
enableSoundFeedback: boolean
|
|
17
|
+
defaultDuration: number
|
|
18
|
+
animationDuration: number
|
|
19
|
+
enableAutoHide: boolean
|
|
20
|
+
enableAccessibility: boolean
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface FeedbackCallbacks {
|
|
24
|
+
onFeedbackShow?: (feedback: FeedbackState) => void
|
|
25
|
+
onFeedbackHide?: (feedback: FeedbackState) => void
|
|
26
|
+
onFeedbackComplete?: (feedback: FeedbackState) => void
|
|
27
|
+
onAccessibilityAnnounce?: (message: string) => void
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface FormFeedbackState {
|
|
31
|
+
currentFeedback: FeedbackState
|
|
32
|
+
feedbackHistory: FeedbackState[]
|
|
33
|
+
isAnimating: boolean
|
|
34
|
+
accessibilityEnabled: boolean
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const useFormFeedback = (
|
|
38
|
+
callbacks: FeedbackCallbacks = {},
|
|
39
|
+
config: Partial<FeedbackConfig> = {}
|
|
40
|
+
) => {
|
|
41
|
+
const defaultConfig: FeedbackConfig = {
|
|
42
|
+
enableAnimations: true,
|
|
43
|
+
enableTouchFeedback: true,
|
|
44
|
+
enableHapticFeedback: true,
|
|
45
|
+
enableSoundFeedback: false,
|
|
46
|
+
defaultDuration: 3000,
|
|
47
|
+
animationDuration: 300,
|
|
48
|
+
enableAutoHide: true,
|
|
49
|
+
enableAccessibility: true,
|
|
50
|
+
...config
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const [feedbackState, setFeedbackState] = useState<FormFeedbackState>({
|
|
54
|
+
currentFeedback: {
|
|
55
|
+
type: 'none',
|
|
56
|
+
message: '',
|
|
57
|
+
isVisible: false,
|
|
58
|
+
isAnimating: false,
|
|
59
|
+
duration: defaultConfig.defaultDuration,
|
|
60
|
+
timestamp: 0
|
|
61
|
+
},
|
|
62
|
+
feedbackHistory: [],
|
|
63
|
+
isAnimating: false,
|
|
64
|
+
accessibilityEnabled: defaultConfig.enableAccessibility
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
const hideTimerRef = useRef<NodeJS.Timeout | null>(null)
|
|
68
|
+
const animationTimerRef = useRef<NodeJS.Timeout | null>(null)
|
|
69
|
+
const audioContextRef = useRef<AudioContext | null>(null)
|
|
70
|
+
|
|
71
|
+
// Initialize audio context if supported
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (defaultConfig.enableSoundFeedback && 'AudioContext' in window) {
|
|
74
|
+
audioContextRef.current = new (window.AudioContext || (window as any).webkitAudioContext)()
|
|
75
|
+
}
|
|
76
|
+
}, [defaultConfig.enableSoundFeedback])
|
|
77
|
+
|
|
78
|
+
// Trigger haptic feedback
|
|
79
|
+
const triggerHapticFeedback = useCallback((intensity: 'light' | 'medium' | 'strong' = 'medium') => {
|
|
80
|
+
if (!defaultConfig.enableHapticFeedback || !('vibrate' in navigator)) return
|
|
81
|
+
|
|
82
|
+
const vibrationPattern = {
|
|
83
|
+
light: 20,
|
|
84
|
+
medium: 50,
|
|
85
|
+
strong: 100
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
navigator.vibrate(vibrationPattern[intensity])
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.warn('Haptic feedback not supported:', error)
|
|
92
|
+
}
|
|
93
|
+
}, [defaultConfig.enableHapticFeedback])
|
|
94
|
+
|
|
95
|
+
// Trigger sound feedback
|
|
96
|
+
const triggerSoundFeedback = useCallback((type: 'success' | 'error' | 'warning' | 'info' = 'success') => {
|
|
97
|
+
if (!defaultConfig.enableSoundFeedback || !audioContextRef.current) return
|
|
98
|
+
|
|
99
|
+
try {
|
|
100
|
+
const audioContext = audioContextRef.current
|
|
101
|
+
const oscillator = audioContext.createOscillator()
|
|
102
|
+
const gainNode = audioContext.createGain()
|
|
103
|
+
|
|
104
|
+
oscillator.connect(gainNode)
|
|
105
|
+
gainNode.connect(audioContext.destination)
|
|
106
|
+
|
|
107
|
+
const soundConfig = {
|
|
108
|
+
success: { frequency: 800, duration: 0.1, volume: 0.1 },
|
|
109
|
+
error: { frequency: 400, duration: 0.2, volume: 0.15 },
|
|
110
|
+
warning: { frequency: 600, duration: 0.15, volume: 0.12 },
|
|
111
|
+
info: { frequency: 1000, duration: 0.08, volume: 0.08 }
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const config = soundConfig[type]
|
|
115
|
+
oscillator.frequency.setValueAtTime(config.frequency, audioContext.currentTime)
|
|
116
|
+
gainNode.gain.setValueAtTime(config.volume, audioContext.currentTime)
|
|
117
|
+
|
|
118
|
+
oscillator.start(audioContext.currentTime)
|
|
119
|
+
oscillator.stop(audioContext.currentTime + config.duration)
|
|
120
|
+
} catch (error) {
|
|
121
|
+
console.warn('Sound feedback not supported:', error)
|
|
122
|
+
}
|
|
123
|
+
}, [defaultConfig.enableSoundFeedback])
|
|
124
|
+
|
|
125
|
+
// Announce feedback for accessibility
|
|
126
|
+
const announceAccessibility = useCallback((message: string) => {
|
|
127
|
+
if (!defaultConfig.enableAccessibility) return
|
|
128
|
+
|
|
129
|
+
// Create a live region for screen readers
|
|
130
|
+
let liveRegion = document.getElementById('form-feedback-live-region')
|
|
131
|
+
if (!liveRegion) {
|
|
132
|
+
liveRegion = document.createElement('div')
|
|
133
|
+
liveRegion.id = 'form-feedback-live-region'
|
|
134
|
+
liveRegion.setAttribute('aria-live', 'polite')
|
|
135
|
+
liveRegion.setAttribute('aria-atomic', 'true')
|
|
136
|
+
liveRegion.style.position = 'absolute'
|
|
137
|
+
liveRegion.style.left = '-10000px'
|
|
138
|
+
liveRegion.style.width = '1px'
|
|
139
|
+
liveRegion.style.height = '1px'
|
|
140
|
+
liveRegion.style.overflow = 'hidden'
|
|
141
|
+
document.body.appendChild(liveRegion)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
liveRegion.textContent = message
|
|
145
|
+
callbacks.onAccessibilityAnnounce?.(message)
|
|
146
|
+
}, [defaultConfig.enableAccessibility, callbacks])
|
|
147
|
+
|
|
148
|
+
// Show feedback with animation
|
|
149
|
+
const showFeedback = useCallback((
|
|
150
|
+
type: FeedbackState['type'],
|
|
151
|
+
message: string,
|
|
152
|
+
duration?: number,
|
|
153
|
+
options?: { skipAnimation?: boolean; skipSound?: boolean; skipHaptic?: boolean }
|
|
154
|
+
) => {
|
|
155
|
+
// Clear existing timers
|
|
156
|
+
if (hideTimerRef.current) {
|
|
157
|
+
clearTimeout(hideTimerRef.current)
|
|
158
|
+
hideTimerRef.current = null
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (animationTimerRef.current) {
|
|
162
|
+
clearTimeout(animationTimerRef.current)
|
|
163
|
+
animationTimerRef.current = null
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const feedback: FeedbackState = {
|
|
167
|
+
type,
|
|
168
|
+
message,
|
|
169
|
+
isVisible: true,
|
|
170
|
+
isAnimating: !options?.skipAnimation && defaultConfig.enableAnimations,
|
|
171
|
+
duration: duration || defaultConfig.defaultDuration,
|
|
172
|
+
timestamp: Date.now()
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Start animation
|
|
176
|
+
if (feedback.isAnimating) {
|
|
177
|
+
setFeedbackState(prev => ({
|
|
178
|
+
...prev,
|
|
179
|
+
currentFeedback: feedback,
|
|
180
|
+
isAnimating: true
|
|
181
|
+
}))
|
|
182
|
+
|
|
183
|
+
// End animation after animation duration
|
|
184
|
+
animationTimerRef.current = setTimeout(() => {
|
|
185
|
+
setFeedbackState(prev => ({
|
|
186
|
+
...prev,
|
|
187
|
+
isAnimating: false
|
|
188
|
+
}))
|
|
189
|
+
}, defaultConfig.animationDuration)
|
|
190
|
+
} else {
|
|
191
|
+
setFeedbackState(prev => ({
|
|
192
|
+
...prev,
|
|
193
|
+
currentFeedback: feedback,
|
|
194
|
+
isAnimating: false
|
|
195
|
+
}))
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Add to history
|
|
199
|
+
setFeedbackState(prev => ({
|
|
200
|
+
...prev,
|
|
201
|
+
feedbackHistory: [feedback, ...prev.feedbackHistory.slice(0, 9)] // Keep last 10
|
|
202
|
+
}))
|
|
203
|
+
|
|
204
|
+
// Trigger feedback based on type
|
|
205
|
+
if (!options?.skipHaptic) {
|
|
206
|
+
switch (type) {
|
|
207
|
+
case 'success':
|
|
208
|
+
triggerHapticFeedback('light')
|
|
209
|
+
break
|
|
210
|
+
case 'error':
|
|
211
|
+
triggerHapticFeedback('strong')
|
|
212
|
+
break
|
|
213
|
+
case 'warning':
|
|
214
|
+
triggerHapticFeedback('medium')
|
|
215
|
+
break
|
|
216
|
+
case 'info':
|
|
217
|
+
triggerHapticFeedback('light')
|
|
218
|
+
break
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (!options?.skipSound) {
|
|
223
|
+
triggerSoundFeedback(type === 'none' ? 'success' : type)
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Announce for accessibility
|
|
227
|
+
announceAccessibility(message)
|
|
228
|
+
|
|
229
|
+
// Auto-hide if enabled
|
|
230
|
+
if (defaultConfig.enableAutoHide && feedback.duration > 0) {
|
|
231
|
+
hideTimerRef.current = setTimeout(() => {
|
|
232
|
+
hideFeedback()
|
|
233
|
+
}, feedback.duration)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
callbacks.onFeedbackShow?.(feedback)
|
|
237
|
+
}, [
|
|
238
|
+
defaultConfig.enableAnimations,
|
|
239
|
+
defaultConfig.defaultDuration,
|
|
240
|
+
defaultConfig.animationDuration,
|
|
241
|
+
defaultConfig.enableAutoHide,
|
|
242
|
+
triggerHapticFeedback,
|
|
243
|
+
triggerSoundFeedback,
|
|
244
|
+
announceAccessibility,
|
|
245
|
+
callbacks
|
|
246
|
+
])
|
|
247
|
+
|
|
248
|
+
// Hide feedback
|
|
249
|
+
const hideFeedback = useCallback(() => {
|
|
250
|
+
if (hideTimerRef.current) {
|
|
251
|
+
clearTimeout(hideTimerRef.current)
|
|
252
|
+
hideTimerRef.current = null
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (animationTimerRef.current) {
|
|
256
|
+
clearTimeout(animationTimerRef.current)
|
|
257
|
+
animationTimerRef.current = null
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
setFeedbackState(prev => ({
|
|
261
|
+
...prev,
|
|
262
|
+
currentFeedback: {
|
|
263
|
+
...prev.currentFeedback,
|
|
264
|
+
isVisible: false,
|
|
265
|
+
isAnimating: false
|
|
266
|
+
},
|
|
267
|
+
isAnimating: false
|
|
268
|
+
}))
|
|
269
|
+
|
|
270
|
+
callbacks.onFeedbackHide?.(feedbackState.currentFeedback)
|
|
271
|
+
}, [feedbackState.currentFeedback, callbacks])
|
|
272
|
+
|
|
273
|
+
// Show success feedback
|
|
274
|
+
const showSuccess = useCallback((message: string, duration?: number, options?: any) => {
|
|
275
|
+
showFeedback('success', message, duration, options)
|
|
276
|
+
}, [showFeedback])
|
|
277
|
+
|
|
278
|
+
// Show error feedback
|
|
279
|
+
const showError = useCallback((message: string, duration?: number, options?: any) => {
|
|
280
|
+
showFeedback('error', message, duration, options)
|
|
281
|
+
}, [showFeedback])
|
|
282
|
+
|
|
283
|
+
// Show warning feedback
|
|
284
|
+
const showWarning = useCallback((message: string, duration?: number, options?: any) => {
|
|
285
|
+
showFeedback('warning', message, duration, options)
|
|
286
|
+
}, [showFeedback])
|
|
287
|
+
|
|
288
|
+
// Show info feedback
|
|
289
|
+
const showInfo = useCallback((message: string, duration?: number, options?: any) => {
|
|
290
|
+
showFeedback('info', message, duration, options)
|
|
291
|
+
}, [showFeedback])
|
|
292
|
+
|
|
293
|
+
// Clear all feedback
|
|
294
|
+
const clearFeedback = useCallback(() => {
|
|
295
|
+
hideFeedback()
|
|
296
|
+
setFeedbackState(prev => ({
|
|
297
|
+
...prev,
|
|
298
|
+
feedbackHistory: []
|
|
299
|
+
}))
|
|
300
|
+
}, [hideFeedback])
|
|
301
|
+
|
|
302
|
+
// Get feedback classes for styling
|
|
303
|
+
const getFeedbackClasses = useCallback(() => {
|
|
304
|
+
const { currentFeedback, isAnimating } = feedbackState
|
|
305
|
+
|
|
306
|
+
if (!currentFeedback.isVisible) return ''
|
|
307
|
+
|
|
308
|
+
const classes = ['form-feedback']
|
|
309
|
+
|
|
310
|
+
// Add type class
|
|
311
|
+
if (currentFeedback.type !== 'none') {
|
|
312
|
+
classes.push(`form-feedback-${currentFeedback.type}`)
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// Add animation classes
|
|
316
|
+
if (isAnimating) {
|
|
317
|
+
classes.push('form-feedback-animating')
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
if (currentFeedback.isVisible) {
|
|
321
|
+
classes.push('form-feedback-visible')
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
return classes.join(' ')
|
|
325
|
+
}, [feedbackState])
|
|
326
|
+
|
|
327
|
+
// Get feedback icon
|
|
328
|
+
const getFeedbackIcon = useCallback((type: FeedbackState['type']) => {
|
|
329
|
+
switch (type) {
|
|
330
|
+
case 'success':
|
|
331
|
+
return '✅'
|
|
332
|
+
case 'error':
|
|
333
|
+
return '❌'
|
|
334
|
+
case 'warning':
|
|
335
|
+
return '⚠️'
|
|
336
|
+
case 'info':
|
|
337
|
+
return 'ℹ️'
|
|
338
|
+
default:
|
|
339
|
+
return ''
|
|
340
|
+
}
|
|
341
|
+
}, [])
|
|
342
|
+
|
|
343
|
+
// Check if feedback is visible
|
|
344
|
+
const isFeedbackVisible = useCallback(() => {
|
|
345
|
+
return feedbackState.currentFeedback.isVisible
|
|
346
|
+
}, [feedbackState.currentFeedback.isVisible])
|
|
347
|
+
|
|
348
|
+
// Get current feedback type
|
|
349
|
+
const getCurrentFeedbackType = useCallback(() => {
|
|
350
|
+
return feedbackState.currentFeedback.type
|
|
351
|
+
}, [feedbackState.currentFeedback.type])
|
|
352
|
+
|
|
353
|
+
// Clean up timers on unmount
|
|
354
|
+
useEffect(() => {
|
|
355
|
+
return () => {
|
|
356
|
+
if (hideTimerRef.current) {
|
|
357
|
+
clearTimeout(hideTimerRef.current)
|
|
358
|
+
}
|
|
359
|
+
if (animationTimerRef.current) {
|
|
360
|
+
clearTimeout(animationTimerRef.current)
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}, [])
|
|
364
|
+
|
|
365
|
+
return {
|
|
366
|
+
feedbackState,
|
|
367
|
+
showFeedback,
|
|
368
|
+
showSuccess,
|
|
369
|
+
showError,
|
|
370
|
+
showWarning,
|
|
371
|
+
showInfo,
|
|
372
|
+
hideFeedback,
|
|
373
|
+
clearFeedback,
|
|
374
|
+
getFeedbackClasses,
|
|
375
|
+
getFeedbackIcon,
|
|
376
|
+
isFeedbackVisible,
|
|
377
|
+
getCurrentFeedbackType,
|
|
378
|
+
triggerHapticFeedback,
|
|
379
|
+
triggerSoundFeedback
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// Convenience hook for basic form feedback
|
|
384
|
+
export const useBasicFormFeedback = () => {
|
|
385
|
+
return useFormFeedback({}, {
|
|
386
|
+
enableAnimations: true,
|
|
387
|
+
enableTouchFeedback: false,
|
|
388
|
+
enableHapticFeedback: false,
|
|
389
|
+
enableSoundFeedback: false,
|
|
390
|
+
enableAccessibility: true
|
|
391
|
+
})
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// Convenience hook for enhanced form feedback
|
|
395
|
+
export const useEnhancedFormFeedback = () => {
|
|
396
|
+
return useFormFeedback({}, {
|
|
397
|
+
enableAnimations: true,
|
|
398
|
+
enableTouchFeedback: true,
|
|
399
|
+
enableHapticFeedback: true,
|
|
400
|
+
enableSoundFeedback: true,
|
|
401
|
+
enableAccessibility: true
|
|
402
|
+
})
|
|
403
|
+
}
|