markupr 2.1.8 → 2.5.0
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/README.md +292 -15
- package/dist/cli/index.mjs +3593 -0
- package/dist/main/index.mjs +743 -220
- package/dist/mcp/index.mjs +4053 -0
- package/package.json +32 -7
- package/.claude/commands/review-feedback.md +0 -47
- package/.eslintrc.json +0 -35
- package/.github/CODEOWNERS +0 -16
- package/.github/FUNDING.yml +0 -1
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -56
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -54
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -89
- package/.github/dependabot.yml +0 -70
- package/.github/workflows/ci.yml +0 -184
- package/.github/workflows/deploy-landing.yml +0 -134
- package/.github/workflows/nightly.yml +0 -288
- package/.github/workflows/release.yml +0 -318
- package/CHANGELOG.md +0 -127
- package/CLAUDE.md +0 -137
- package/CODE_OF_CONDUCT.md +0 -9
- package/CONTRIBUTING.md +0 -390
- package/PRODUCT_VISION.md +0 -277
- package/SECURITY.md +0 -51
- package/SIGNING_INSTRUCTIONS.md +0 -284
- package/assets/DMG_BACKGROUND_INSTRUCTIONS.md +0 -130
- package/assets/svg-source/dmg-background.svg +0 -70
- package/assets/svg-source/icon.svg +0 -20
- package/assets/svg-source/tray-icon-processing.svg +0 -7
- package/assets/svg-source/tray-icon-recording.svg +0 -7
- package/assets/svg-source/tray-icon.svg +0 -6
- package/assets/tray-complete.png +0 -0
- package/assets/tray-complete@2x.png +0 -0
- package/assets/tray-completeTemplate.png +0 -0
- package/assets/tray-completeTemplate@2x.png +0 -0
- package/assets/tray-error.png +0 -0
- package/assets/tray-error@2x.png +0 -0
- package/assets/tray-errorTemplate.png +0 -0
- package/assets/tray-errorTemplate@2x.png +0 -0
- package/assets/tray-icon-processing.png +0 -0
- package/assets/tray-icon-processing@2x.png +0 -0
- package/assets/tray-icon-processingTemplate.png +0 -0
- package/assets/tray-icon-processingTemplate@2x.png +0 -0
- package/assets/tray-icon-recording.png +0 -0
- package/assets/tray-icon-recording@2x.png +0 -0
- package/assets/tray-icon-recordingTemplate.png +0 -0
- package/assets/tray-icon-recordingTemplate@2x.png +0 -0
- package/assets/tray-icon.png +0 -0
- package/assets/tray-icon@2x.png +0 -0
- package/assets/tray-iconTemplate.png +0 -0
- package/assets/tray-iconTemplate@2x.png +0 -0
- package/assets/tray-idle.png +0 -0
- package/assets/tray-idle@2x.png +0 -0
- package/assets/tray-idleTemplate.png +0 -0
- package/assets/tray-idleTemplate@2x.png +0 -0
- package/assets/tray-processing-0.png +0 -0
- package/assets/tray-processing-0@2x.png +0 -0
- package/assets/tray-processing-0Template.png +0 -0
- package/assets/tray-processing-0Template@2x.png +0 -0
- package/assets/tray-processing-1.png +0 -0
- package/assets/tray-processing-1@2x.png +0 -0
- package/assets/tray-processing-1Template.png +0 -0
- package/assets/tray-processing-1Template@2x.png +0 -0
- package/assets/tray-processing-2.png +0 -0
- package/assets/tray-processing-2@2x.png +0 -0
- package/assets/tray-processing-2Template.png +0 -0
- package/assets/tray-processing-2Template@2x.png +0 -0
- package/assets/tray-processing-3.png +0 -0
- package/assets/tray-processing-3@2x.png +0 -0
- package/assets/tray-processing-3Template.png +0 -0
- package/assets/tray-processing-3Template@2x.png +0 -0
- package/assets/tray-processing.png +0 -0
- package/assets/tray-processing@2x.png +0 -0
- package/assets/tray-processingTemplate.png +0 -0
- package/assets/tray-processingTemplate@2x.png +0 -0
- package/assets/tray-recording.png +0 -0
- package/assets/tray-recording@2x.png +0 -0
- package/assets/tray-recordingTemplate.png +0 -0
- package/assets/tray-recordingTemplate@2x.png +0 -0
- package/build/DMG_BACKGROUND_SPEC.md +0 -50
- package/build/dmg-background.png +0 -0
- package/build/dmg-background@2x.png +0 -0
- package/build/entitlements.mac.inherit.plist +0 -27
- package/build/entitlements.mac.plist +0 -41
- package/build/favicon-16.png +0 -0
- package/build/favicon-180.png +0 -0
- package/build/favicon-192.png +0 -0
- package/build/favicon-32.png +0 -0
- package/build/favicon-48.png +0 -0
- package/build/favicon-512.png +0 -0
- package/build/favicon-64.png +0 -0
- package/build/icon-128.png +0 -0
- package/build/icon-16.png +0 -0
- package/build/icon-24.png +0 -0
- package/build/icon-256.png +0 -0
- package/build/icon-32.png +0 -0
- package/build/icon-48.png +0 -0
- package/build/icon-64.png +0 -0
- package/build/icon.icns +0 -0
- package/build/icon.ico +0 -0
- package/build/icon.iconset/icon_128x128.png +0 -0
- package/build/icon.iconset/icon_128x128@2x.png +0 -0
- package/build/icon.iconset/icon_16x16.png +0 -0
- package/build/icon.iconset/icon_16x16@2x.png +0 -0
- package/build/icon.iconset/icon_256x256.png +0 -0
- package/build/icon.iconset/icon_256x256@2x.png +0 -0
- package/build/icon.iconset/icon_32x32.png +0 -0
- package/build/icon.iconset/icon_32x32@2x.png +0 -0
- package/build/icon.iconset/icon_512x512.png +0 -0
- package/build/icon.iconset/icon_512x512@2x.png +0 -0
- package/build/icon.png +0 -0
- package/build/installer-header.bmp +0 -0
- package/build/installer-header.png +0 -0
- package/build/installer-sidebar.bmp +0 -0
- package/build/installer-sidebar.png +0 -0
- package/build/installer.nsh +0 -45
- package/build/overlay-processing.png +0 -0
- package/build/overlay-recording.png +0 -0
- package/build/toolbar-record.png +0 -0
- package/build/toolbar-screenshot.png +0 -0
- package/build/toolbar-settings.png +0 -0
- package/build/toolbar-stop.png +0 -0
- package/dist/preload/index.mjs +0 -907
- package/dist/renderer/assets/index-CCmUjl9K.js +0 -19495
- package/dist/renderer/assets/index-CUqz_Gs6.css +0 -2270
- package/dist/renderer/index.html +0 -27
- package/docs/AI_AGENT_QUICKSTART.md +0 -42
- package/docs/AI_PIPELINE_DESIGN.md +0 -595
- package/docs/API.md +0 -514
- package/docs/ARCHITECTURE.md +0 -460
- package/docs/CONFIGURATION.md +0 -336
- package/docs/DEVELOPMENT.md +0 -508
- package/docs/EXPORT_FORMATS.md +0 -451
- package/docs/GETTING_STARTED.md +0 -236
- package/docs/KEYBOARD_SHORTCUTS.md +0 -334
- package/docs/TROUBLESHOOTING.md +0 -418
- package/docs/landing/index.html +0 -672
- package/docs/landing/script.js +0 -342
- package/docs/landing/styles.css +0 -1543
- package/electron-builder.yml +0 -140
- package/electron.vite.config.ts +0 -63
- package/railway.json +0 -12
- package/scripts/build.mjs +0 -51
- package/scripts/generate-icons.mjs +0 -314
- package/scripts/generate-installer-images.cjs +0 -253
- package/scripts/generate-tray-icons.mjs +0 -258
- package/scripts/notarize.cjs +0 -180
- package/scripts/one-click-clean-test.sh +0 -147
- package/scripts/postinstall.mjs +0 -36
- package/scripts/setup-markupr.sh +0 -55
- package/setup +0 -17
- package/site/index.html +0 -1835
- package/site/package.json +0 -11
- package/site/railway.json +0 -12
- package/site/server.js +0 -31
- package/src/main/AutoUpdater.ts +0 -392
- package/src/main/CrashRecovery.ts +0 -655
- package/src/main/ErrorHandler.ts +0 -703
- package/src/main/HotkeyManager.ts +0 -399
- package/src/main/MenuManager.ts +0 -529
- package/src/main/PermissionManager.ts +0 -420
- package/src/main/SessionController.ts +0 -1465
- package/src/main/TrayManager.ts +0 -540
- package/src/main/ai/AIPipelineManager.ts +0 -199
- package/src/main/ai/ClaudeAnalyzer.ts +0 -339
- package/src/main/ai/ImageOptimizer.ts +0 -176
- package/src/main/ai/StructuredMarkdownBuilder.ts +0 -379
- package/src/main/ai/index.ts +0 -16
- package/src/main/ai/types.ts +0 -258
- package/src/main/analysis/ClarificationGenerator.ts +0 -385
- package/src/main/analysis/FeedbackAnalyzer.ts +0 -531
- package/src/main/analysis/index.ts +0 -19
- package/src/main/audio/AudioCapture.ts +0 -978
- package/src/main/audio/audioUtils.ts +0 -100
- package/src/main/audio/index.ts +0 -20
- package/src/main/capture/index.ts +0 -1
- package/src/main/index.ts +0 -1693
- package/src/main/ipc/captureHandlers.ts +0 -272
- package/src/main/ipc/index.ts +0 -45
- package/src/main/ipc/outputHandlers.ts +0 -302
- package/src/main/ipc/sessionHandlers.ts +0 -56
- package/src/main/ipc/settingsHandlers.ts +0 -471
- package/src/main/ipc/types.ts +0 -56
- package/src/main/ipc/windowHandlers.ts +0 -277
- package/src/main/output/ClipboardService.ts +0 -369
- package/src/main/output/ExportService.ts +0 -539
- package/src/main/output/FileManager.ts +0 -416
- package/src/main/output/MarkdownGenerator.ts +0 -791
- package/src/main/output/MarkdownPatcher.ts +0 -299
- package/src/main/output/index.ts +0 -186
- package/src/main/output/sessionAdapter.ts +0 -207
- package/src/main/output/templates/html-template.ts +0 -553
- package/src/main/pipeline/FrameExtractor.ts +0 -330
- package/src/main/pipeline/PostProcessor.ts +0 -399
- package/src/main/pipeline/TranscriptAnalyzer.ts +0 -226
- package/src/main/pipeline/index.ts +0 -36
- package/src/main/platform/WindowsTaskbar.ts +0 -600
- package/src/main/platform/index.ts +0 -16
- package/src/main/settings/SettingsManager.ts +0 -730
- package/src/main/settings/index.ts +0 -19
- package/src/main/transcription/ModelDownloadManager.ts +0 -494
- package/src/main/transcription/TierManager.ts +0 -219
- package/src/main/transcription/TranscriptionRecoveryService.ts +0 -340
- package/src/main/transcription/WhisperService.ts +0 -748
- package/src/main/transcription/index.ts +0 -56
- package/src/main/transcription/types.ts +0 -135
- package/src/main/windows/PopoverManager.ts +0 -284
- package/src/main/windows/TaskbarIntegration.ts +0 -452
- package/src/main/windows/index.ts +0 -23
- package/src/preload/index.ts +0 -1047
- package/src/renderer/App.tsx +0 -515
- package/src/renderer/AppWrapper.tsx +0 -28
- package/src/renderer/assets/logo-dark.svg +0 -7
- package/src/renderer/assets/logo.svg +0 -7
- package/src/renderer/audio/AudioCaptureRenderer.ts +0 -454
- package/src/renderer/capture/ScreenRecordingRenderer.ts +0 -492
- package/src/renderer/components/AnnotationOverlay.tsx +0 -836
- package/src/renderer/components/AudioWaveform.tsx +0 -811
- package/src/renderer/components/ClarificationQuestions.tsx +0 -656
- package/src/renderer/components/CountdownTimer.tsx +0 -495
- package/src/renderer/components/CrashRecoveryDialog.tsx +0 -632
- package/src/renderer/components/DonateButton.tsx +0 -127
- package/src/renderer/components/ErrorBoundary.tsx +0 -308
- package/src/renderer/components/ExportDialog.tsx +0 -872
- package/src/renderer/components/HotkeyHint.tsx +0 -261
- package/src/renderer/components/KeyboardShortcuts.tsx +0 -787
- package/src/renderer/components/ModelDownloadDialog.tsx +0 -844
- package/src/renderer/components/Onboarding.tsx +0 -1830
- package/src/renderer/components/ProcessingOverlay.tsx +0 -157
- package/src/renderer/components/RecordingOverlay.tsx +0 -423
- package/src/renderer/components/SessionHistory.tsx +0 -1746
- package/src/renderer/components/SessionReview.tsx +0 -1321
- package/src/renderer/components/SettingsPanel.tsx +0 -217
- package/src/renderer/components/Skeleton.tsx +0 -347
- package/src/renderer/components/StatusIndicator.tsx +0 -86
- package/src/renderer/components/ThemeProvider.tsx +0 -429
- package/src/renderer/components/Tooltip.tsx +0 -370
- package/src/renderer/components/TranscriptionPreview.tsx +0 -183
- package/src/renderer/components/TranscriptionTierSelector.tsx +0 -640
- package/src/renderer/components/UpdateNotification.tsx +0 -377
- package/src/renderer/components/WindowSelector.tsx +0 -947
- package/src/renderer/components/index.ts +0 -99
- package/src/renderer/components/primitives/ApiKeyInput.tsx +0 -98
- package/src/renderer/components/primitives/ColorPicker.tsx +0 -65
- package/src/renderer/components/primitives/DangerButton.tsx +0 -45
- package/src/renderer/components/primitives/DirectoryPicker.tsx +0 -41
- package/src/renderer/components/primitives/Dropdown.tsx +0 -34
- package/src/renderer/components/primitives/KeyRecorder.tsx +0 -117
- package/src/renderer/components/primitives/SettingsSection.tsx +0 -32
- package/src/renderer/components/primitives/Slider.tsx +0 -43
- package/src/renderer/components/primitives/Toggle.tsx +0 -36
- package/src/renderer/components/primitives/index.ts +0 -10
- package/src/renderer/components/settings/AdvancedTab.tsx +0 -174
- package/src/renderer/components/settings/AppearanceTab.tsx +0 -77
- package/src/renderer/components/settings/GeneralTab.tsx +0 -40
- package/src/renderer/components/settings/HotkeysTab.tsx +0 -79
- package/src/renderer/components/settings/RecordingTab.tsx +0 -84
- package/src/renderer/components/settings/index.ts +0 -9
- package/src/renderer/components/settings/settingsStyles.ts +0 -673
- package/src/renderer/components/settings/tabConfig.tsx +0 -85
- package/src/renderer/components/settings/useSettingsPanel.ts +0 -447
- package/src/renderer/contexts/ProcessingContext.tsx +0 -227
- package/src/renderer/contexts/RecordingContext.tsx +0 -683
- package/src/renderer/contexts/UIContext.tsx +0 -326
- package/src/renderer/contexts/index.ts +0 -24
- package/src/renderer/donateMessages.ts +0 -69
- package/src/renderer/hooks/index.ts +0 -75
- package/src/renderer/hooks/useAnimation.tsx +0 -544
- package/src/renderer/hooks/useTheme.ts +0 -313
- package/src/renderer/index.html +0 -26
- package/src/renderer/main.tsx +0 -52
- package/src/renderer/styles/animations.css +0 -1093
- package/src/renderer/styles/app-shell.css +0 -662
- package/src/renderer/styles/globals.css +0 -515
- package/src/renderer/styles/theme.ts +0 -578
- package/src/renderer/types/electron.d.ts +0 -385
- package/src/shared/hotkeys.ts +0 -283
- package/src/shared/types.ts +0 -809
- package/tests/clipboard.test.ts +0 -228
- package/tests/e2e/criticalPaths.test.ts +0 -594
- package/tests/feedbackAnalyzer.test.ts +0 -303
- package/tests/integration/sessionFlow.test.ts +0 -583
- package/tests/markdownGenerator.test.ts +0 -418
- package/tests/output.test.ts +0 -96
- package/tests/setup.ts +0 -486
- package/tests/unit/appIntegration.test.ts +0 -676
- package/tests/unit/appViewState.test.ts +0 -281
- package/tests/unit/audioIpcChannels.test.ts +0 -17
- package/tests/unit/exportService.test.ts +0 -492
- package/tests/unit/hotkeys.test.ts +0 -92
- package/tests/unit/navigationPreload.test.ts +0 -94
- package/tests/unit/onboardingFlow.test.ts +0 -345
- package/tests/unit/permissionManager.test.ts +0 -175
- package/tests/unit/permissionManagerExpanded.test.ts +0 -296
- package/tests/unit/screenRecordingRenderer.test.ts +0 -368
- package/tests/unit/sessionController.test.ts +0 -515
- package/tests/unit/tierManager.test.ts +0 -61
- package/tests/unit/tierManagerExpanded.test.ts +0 -142
- package/tests/unit/transcriptAnalyzer.test.ts +0 -64
- package/tsconfig.json +0 -25
- package/vitest.config.ts +0 -46
|
@@ -1,544 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* markupr - Animation Hooks
|
|
3
|
-
*
|
|
4
|
-
* Programmatic animation utilities for React components.
|
|
5
|
-
* Provides hooks for staggered animations, spring physics,
|
|
6
|
-
* and animation lifecycle management.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import React, { useState, useEffect, useCallback, useRef, useMemo } from 'react';
|
|
10
|
-
|
|
11
|
-
// ============================================================================
|
|
12
|
-
// Types
|
|
13
|
-
// ============================================================================
|
|
14
|
-
|
|
15
|
-
export interface AnimationConfig {
|
|
16
|
-
duration?: number;
|
|
17
|
-
delay?: number;
|
|
18
|
-
easing?: string;
|
|
19
|
-
fill?: 'none' | 'forwards' | 'backwards' | 'both';
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface StaggerConfig extends AnimationConfig {
|
|
23
|
-
baseDelay?: number;
|
|
24
|
-
staggerDelay?: number;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface SpringConfig {
|
|
28
|
-
stiffness?: number;
|
|
29
|
-
damping?: number;
|
|
30
|
-
mass?: number;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface AnimatedItem<T> {
|
|
34
|
-
item: T;
|
|
35
|
-
style: React.CSSProperties;
|
|
36
|
-
className?: string;
|
|
37
|
-
index: number;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export type AnimationState = 'idle' | 'entering' | 'entered' | 'exiting' | 'exited';
|
|
41
|
-
|
|
42
|
-
// ============================================================================
|
|
43
|
-
// CSS Variables for Spring Physics
|
|
44
|
-
// ============================================================================
|
|
45
|
-
|
|
46
|
-
// Pre-computed spring curves for common presets
|
|
47
|
-
export const SPRING_PRESETS = {
|
|
48
|
-
// Bouncy, playful feel
|
|
49
|
-
bounce: 'cubic-bezier(0.34, 1.56, 0.64, 1)',
|
|
50
|
-
// Smooth, professional feel
|
|
51
|
-
smooth: 'cubic-bezier(0.16, 1, 0.3, 1)',
|
|
52
|
-
// Quick snap
|
|
53
|
-
snap: 'cubic-bezier(0.68, -0.55, 0.265, 1.55)',
|
|
54
|
-
// Gentle ease
|
|
55
|
-
gentle: 'cubic-bezier(0.25, 0.46, 0.45, 0.94)',
|
|
56
|
-
// Standard ease out
|
|
57
|
-
easeOut: 'cubic-bezier(0.0, 0, 0.2, 1)',
|
|
58
|
-
} as const;
|
|
59
|
-
|
|
60
|
-
// ============================================================================
|
|
61
|
-
// useStaggeredAnimation Hook
|
|
62
|
-
// ============================================================================
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Creates staggered animation styles for a list of items.
|
|
66
|
-
* Each item receives a progressively delayed animation.
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* const animatedItems = useStaggeredAnimation(items, {
|
|
70
|
-
* baseDelay: 100,
|
|
71
|
-
* staggerDelay: 50,
|
|
72
|
-
* });
|
|
73
|
-
*
|
|
74
|
-
* return animatedItems.map(({ item, style, index }) => (
|
|
75
|
-
* <div key={index} style={style} className="ff-list-item-enter">
|
|
76
|
-
* {item.name}
|
|
77
|
-
* </div>
|
|
78
|
-
* ));
|
|
79
|
-
*/
|
|
80
|
-
export function useStaggeredAnimation<T>(
|
|
81
|
-
items: T[],
|
|
82
|
-
config: StaggerConfig = {}
|
|
83
|
-
): AnimatedItem<T>[] {
|
|
84
|
-
const {
|
|
85
|
-
baseDelay = 0,
|
|
86
|
-
staggerDelay = 50,
|
|
87
|
-
duration = 250,
|
|
88
|
-
easing = SPRING_PRESETS.smooth,
|
|
89
|
-
fill = 'both',
|
|
90
|
-
} = config;
|
|
91
|
-
|
|
92
|
-
return useMemo(() => {
|
|
93
|
-
return items.map((item, index) => ({
|
|
94
|
-
item,
|
|
95
|
-
index,
|
|
96
|
-
style: {
|
|
97
|
-
animationDelay: `${baseDelay + index * staggerDelay}ms`,
|
|
98
|
-
animationDuration: `${duration}ms`,
|
|
99
|
-
animationTimingFunction: easing,
|
|
100
|
-
animationFillMode: fill,
|
|
101
|
-
},
|
|
102
|
-
className: 'ff-list-item-enter',
|
|
103
|
-
}));
|
|
104
|
-
}, [items, baseDelay, staggerDelay, duration, easing, fill]);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// ============================================================================
|
|
108
|
-
// useAnimationState Hook
|
|
109
|
-
// ============================================================================
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Manages enter/exit animation lifecycle.
|
|
113
|
-
* Useful for components that need to animate out before unmounting.
|
|
114
|
-
*
|
|
115
|
-
* @example
|
|
116
|
-
* const { state, triggerEnter, triggerExit, shouldRender } = useAnimationState({
|
|
117
|
-
* isVisible: props.open,
|
|
118
|
-
* enterDuration: 250,
|
|
119
|
-
* exitDuration: 150,
|
|
120
|
-
* });
|
|
121
|
-
*
|
|
122
|
-
* if (!shouldRender) return null;
|
|
123
|
-
*
|
|
124
|
-
* return (
|
|
125
|
-
* <div className={state === 'entering' ? 'ff-dialog-enter' : 'ff-dialog-exit'}>
|
|
126
|
-
* ...
|
|
127
|
-
* </div>
|
|
128
|
-
* );
|
|
129
|
-
*/
|
|
130
|
-
export function useAnimationState(config: {
|
|
131
|
-
isVisible: boolean;
|
|
132
|
-
enterDuration?: number;
|
|
133
|
-
exitDuration?: number;
|
|
134
|
-
onEntered?: () => void;
|
|
135
|
-
onExited?: () => void;
|
|
136
|
-
}) {
|
|
137
|
-
const {
|
|
138
|
-
isVisible,
|
|
139
|
-
enterDuration = 250,
|
|
140
|
-
exitDuration = 150,
|
|
141
|
-
onEntered,
|
|
142
|
-
onExited,
|
|
143
|
-
} = config;
|
|
144
|
-
|
|
145
|
-
const [state, setState] = useState<AnimationState>(isVisible ? 'entered' : 'exited');
|
|
146
|
-
const timeoutRef = useRef<NodeJS.Timeout>();
|
|
147
|
-
|
|
148
|
-
useEffect(() => {
|
|
149
|
-
if (timeoutRef.current) {
|
|
150
|
-
clearTimeout(timeoutRef.current);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
if (isVisible) {
|
|
154
|
-
setState('entering');
|
|
155
|
-
timeoutRef.current = setTimeout(() => {
|
|
156
|
-
setState('entered');
|
|
157
|
-
onEntered?.();
|
|
158
|
-
}, enterDuration);
|
|
159
|
-
} else if (state !== 'exited') {
|
|
160
|
-
setState('exiting');
|
|
161
|
-
timeoutRef.current = setTimeout(() => {
|
|
162
|
-
setState('exited');
|
|
163
|
-
onExited?.();
|
|
164
|
-
}, exitDuration);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
return () => {
|
|
168
|
-
if (timeoutRef.current) {
|
|
169
|
-
clearTimeout(timeoutRef.current);
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
}, [isVisible, enterDuration, exitDuration, onEntered, onExited, state]);
|
|
173
|
-
|
|
174
|
-
const triggerEnter = useCallback(() => {
|
|
175
|
-
setState('entering');
|
|
176
|
-
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
177
|
-
timeoutRef.current = setTimeout(() => {
|
|
178
|
-
setState('entered');
|
|
179
|
-
onEntered?.();
|
|
180
|
-
}, enterDuration);
|
|
181
|
-
}, [enterDuration, onEntered]);
|
|
182
|
-
|
|
183
|
-
const triggerExit = useCallback(() => {
|
|
184
|
-
setState('exiting');
|
|
185
|
-
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
186
|
-
timeoutRef.current = setTimeout(() => {
|
|
187
|
-
setState('exited');
|
|
188
|
-
onExited?.();
|
|
189
|
-
}, exitDuration);
|
|
190
|
-
}, [exitDuration, onExited]);
|
|
191
|
-
|
|
192
|
-
return {
|
|
193
|
-
state,
|
|
194
|
-
isEntering: state === 'entering',
|
|
195
|
-
isEntered: state === 'entered',
|
|
196
|
-
isExiting: state === 'exiting',
|
|
197
|
-
isExited: state === 'exited',
|
|
198
|
-
shouldRender: state !== 'exited',
|
|
199
|
-
triggerEnter,
|
|
200
|
-
triggerExit,
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// ============================================================================
|
|
205
|
-
// useCountAnimation Hook
|
|
206
|
-
// ============================================================================
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Animates a number counting up or down.
|
|
210
|
-
*
|
|
211
|
-
* @example
|
|
212
|
-
* const { displayValue, isAnimating } = useCountAnimation(totalItems, {
|
|
213
|
-
* duration: 500,
|
|
214
|
-
* });
|
|
215
|
-
*
|
|
216
|
-
* return <span className={isAnimating ? 'ff-counter-increment' : ''}>{displayValue}</span>;
|
|
217
|
-
*/
|
|
218
|
-
export function useCountAnimation(
|
|
219
|
-
targetValue: number,
|
|
220
|
-
config: { duration?: number; startValue?: number } = {}
|
|
221
|
-
) {
|
|
222
|
-
const { duration = 300, startValue } = config;
|
|
223
|
-
const [displayValue, setDisplayValue] = useState(startValue ?? targetValue);
|
|
224
|
-
const [isAnimating, setIsAnimating] = useState(false);
|
|
225
|
-
const previousValueRef = useRef(targetValue);
|
|
226
|
-
const animationRef = useRef<number>();
|
|
227
|
-
|
|
228
|
-
useEffect(() => {
|
|
229
|
-
if (targetValue === previousValueRef.current) return;
|
|
230
|
-
|
|
231
|
-
const startVal = previousValueRef.current;
|
|
232
|
-
const diff = targetValue - startVal;
|
|
233
|
-
const startTime = performance.now();
|
|
234
|
-
|
|
235
|
-
setIsAnimating(true);
|
|
236
|
-
|
|
237
|
-
const animate = (currentTime: number) => {
|
|
238
|
-
const elapsed = currentTime - startTime;
|
|
239
|
-
const progress = Math.min(elapsed / duration, 1);
|
|
240
|
-
|
|
241
|
-
// Ease out cubic
|
|
242
|
-
const eased = 1 - Math.pow(1 - progress, 3);
|
|
243
|
-
const currentValue = Math.round(startVal + diff * eased);
|
|
244
|
-
|
|
245
|
-
setDisplayValue(currentValue);
|
|
246
|
-
|
|
247
|
-
if (progress < 1) {
|
|
248
|
-
animationRef.current = requestAnimationFrame(animate);
|
|
249
|
-
} else {
|
|
250
|
-
setIsAnimating(false);
|
|
251
|
-
previousValueRef.current = targetValue;
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
animationRef.current = requestAnimationFrame(animate);
|
|
256
|
-
|
|
257
|
-
return () => {
|
|
258
|
-
if (animationRef.current) {
|
|
259
|
-
cancelAnimationFrame(animationRef.current);
|
|
260
|
-
}
|
|
261
|
-
};
|
|
262
|
-
}, [targetValue, duration]);
|
|
263
|
-
|
|
264
|
-
return { displayValue, isAnimating };
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
// ============================================================================
|
|
268
|
-
// usePulse Hook
|
|
269
|
-
// ============================================================================
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Triggers a one-shot pulse animation.
|
|
273
|
-
*
|
|
274
|
-
* @example
|
|
275
|
-
* const { isPulsing, triggerPulse, pulseClassName } = usePulse();
|
|
276
|
-
*
|
|
277
|
-
* <button onClick={() => { save(); triggerPulse(); }} className={pulseClassName}>
|
|
278
|
-
* Save
|
|
279
|
-
* </button>
|
|
280
|
-
*/
|
|
281
|
-
export function usePulse(duration = 300) {
|
|
282
|
-
const [isPulsing, setIsPulsing] = useState(false);
|
|
283
|
-
const timeoutRef = useRef<NodeJS.Timeout>();
|
|
284
|
-
|
|
285
|
-
const triggerPulse = useCallback(() => {
|
|
286
|
-
if (timeoutRef.current) {
|
|
287
|
-
clearTimeout(timeoutRef.current);
|
|
288
|
-
}
|
|
289
|
-
setIsPulsing(true);
|
|
290
|
-
timeoutRef.current = setTimeout(() => {
|
|
291
|
-
setIsPulsing(false);
|
|
292
|
-
}, duration);
|
|
293
|
-
}, [duration]);
|
|
294
|
-
|
|
295
|
-
useEffect(() => {
|
|
296
|
-
return () => {
|
|
297
|
-
if (timeoutRef.current) {
|
|
298
|
-
clearTimeout(timeoutRef.current);
|
|
299
|
-
}
|
|
300
|
-
};
|
|
301
|
-
}, []);
|
|
302
|
-
|
|
303
|
-
return {
|
|
304
|
-
isPulsing,
|
|
305
|
-
triggerPulse,
|
|
306
|
-
pulseClassName: isPulsing ? 'ff-success-pulse' : '',
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
// ============================================================================
|
|
311
|
-
// useShake Hook
|
|
312
|
-
// ============================================================================
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* Triggers a shake animation for error feedback.
|
|
316
|
-
*
|
|
317
|
-
* @example
|
|
318
|
-
* const { isShaking, triggerShake, shakeClassName } = useShake();
|
|
319
|
-
*
|
|
320
|
-
* if (hasError) {
|
|
321
|
-
* triggerShake();
|
|
322
|
-
* }
|
|
323
|
-
*
|
|
324
|
-
* return <div className={shakeClassName}>...</div>;
|
|
325
|
-
*/
|
|
326
|
-
export function useShake(duration = 500) {
|
|
327
|
-
const [isShaking, setIsShaking] = useState(false);
|
|
328
|
-
const timeoutRef = useRef<NodeJS.Timeout>();
|
|
329
|
-
|
|
330
|
-
const triggerShake = useCallback(() => {
|
|
331
|
-
if (timeoutRef.current) {
|
|
332
|
-
clearTimeout(timeoutRef.current);
|
|
333
|
-
}
|
|
334
|
-
setIsShaking(true);
|
|
335
|
-
timeoutRef.current = setTimeout(() => {
|
|
336
|
-
setIsShaking(false);
|
|
337
|
-
}, duration);
|
|
338
|
-
}, [duration]);
|
|
339
|
-
|
|
340
|
-
useEffect(() => {
|
|
341
|
-
return () => {
|
|
342
|
-
if (timeoutRef.current) {
|
|
343
|
-
clearTimeout(timeoutRef.current);
|
|
344
|
-
}
|
|
345
|
-
};
|
|
346
|
-
}, []);
|
|
347
|
-
|
|
348
|
-
return {
|
|
349
|
-
isShaking,
|
|
350
|
-
triggerShake,
|
|
351
|
-
shakeClassName: isShaking ? 'ff-error-shake' : '',
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
// ============================================================================
|
|
356
|
-
// useRipple Hook
|
|
357
|
-
// ============================================================================
|
|
358
|
-
|
|
359
|
-
interface Ripple {
|
|
360
|
-
id: number;
|
|
361
|
-
x: number;
|
|
362
|
-
y: number;
|
|
363
|
-
size: number;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
* Creates material-design style ripple effects on click.
|
|
368
|
-
*
|
|
369
|
-
* @example
|
|
370
|
-
* const { ripples, createRipple, RippleContainer } = useRipple();
|
|
371
|
-
*
|
|
372
|
-
* return (
|
|
373
|
-
* <button onClick={createRipple} style={{ position: 'relative', overflow: 'hidden' }}>
|
|
374
|
-
* Click me
|
|
375
|
-
* <RippleContainer />
|
|
376
|
-
* </button>
|
|
377
|
-
* );
|
|
378
|
-
*/
|
|
379
|
-
export function useRipple(duration = 600) {
|
|
380
|
-
const [ripples, setRipples] = useState<Ripple[]>([]);
|
|
381
|
-
const nextIdRef = useRef(0);
|
|
382
|
-
|
|
383
|
-
const createRipple = useCallback(
|
|
384
|
-
(event: React.MouseEvent<HTMLElement>) => {
|
|
385
|
-
const element = event.currentTarget;
|
|
386
|
-
const rect = element.getBoundingClientRect();
|
|
387
|
-
|
|
388
|
-
const size = Math.max(rect.width, rect.height) * 2;
|
|
389
|
-
const x = event.clientX - rect.left - size / 2;
|
|
390
|
-
const y = event.clientY - rect.top - size / 2;
|
|
391
|
-
|
|
392
|
-
const newRipple: Ripple = {
|
|
393
|
-
id: nextIdRef.current++,
|
|
394
|
-
x,
|
|
395
|
-
y,
|
|
396
|
-
size,
|
|
397
|
-
};
|
|
398
|
-
|
|
399
|
-
setRipples((prev) => [...prev, newRipple]);
|
|
400
|
-
|
|
401
|
-
setTimeout(() => {
|
|
402
|
-
setRipples((prev) => prev.filter((r) => r.id !== newRipple.id));
|
|
403
|
-
}, duration);
|
|
404
|
-
},
|
|
405
|
-
[duration]
|
|
406
|
-
);
|
|
407
|
-
|
|
408
|
-
const RippleContainer: React.FC = () => (
|
|
409
|
-
<>
|
|
410
|
-
{ripples.map((ripple) => (
|
|
411
|
-
<span
|
|
412
|
-
key={ripple.id}
|
|
413
|
-
className="ff-ripple"
|
|
414
|
-
style={{
|
|
415
|
-
left: ripple.x,
|
|
416
|
-
top: ripple.y,
|
|
417
|
-
width: ripple.size,
|
|
418
|
-
height: ripple.size,
|
|
419
|
-
}}
|
|
420
|
-
/>
|
|
421
|
-
))}
|
|
422
|
-
</>
|
|
423
|
-
);
|
|
424
|
-
|
|
425
|
-
return { ripples, createRipple, RippleContainer };
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
// ============================================================================
|
|
429
|
-
// useDelayedRender Hook
|
|
430
|
-
// ============================================================================
|
|
431
|
-
|
|
432
|
-
/**
|
|
433
|
-
* Delays rendering of children to create staggered mount effects.
|
|
434
|
-
*
|
|
435
|
-
* @example
|
|
436
|
-
* const shouldRender = useDelayedRender(300);
|
|
437
|
-
*
|
|
438
|
-
* return shouldRender ? <HeavyComponent /> : <Skeleton />;
|
|
439
|
-
*/
|
|
440
|
-
export function useDelayedRender(delay: number, initialValue = false): boolean {
|
|
441
|
-
const [shouldRender, setShouldRender] = useState(initialValue);
|
|
442
|
-
|
|
443
|
-
useEffect(() => {
|
|
444
|
-
const timeout = setTimeout(() => {
|
|
445
|
-
setShouldRender(true);
|
|
446
|
-
}, delay);
|
|
447
|
-
|
|
448
|
-
return () => clearTimeout(timeout);
|
|
449
|
-
}, [delay]);
|
|
450
|
-
|
|
451
|
-
return shouldRender;
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
// ============================================================================
|
|
455
|
-
// useAnimatedValue Hook
|
|
456
|
-
// ============================================================================
|
|
457
|
-
|
|
458
|
-
/**
|
|
459
|
-
* Animates a value from one number to another using requestAnimationFrame.
|
|
460
|
-
* Returns current interpolated value.
|
|
461
|
-
*
|
|
462
|
-
* @example
|
|
463
|
-
* const animatedHeight = useAnimatedValue(isExpanded ? 300 : 0, { duration: 300 });
|
|
464
|
-
*
|
|
465
|
-
* return <div style={{ height: animatedHeight }}>...</div>;
|
|
466
|
-
*/
|
|
467
|
-
export function useAnimatedValue(
|
|
468
|
-
targetValue: number,
|
|
469
|
-
config: { duration?: number; easing?: (t: number) => number } = {}
|
|
470
|
-
): number {
|
|
471
|
-
const { duration = 300, easing = (t) => 1 - Math.pow(1 - t, 3) } = config;
|
|
472
|
-
|
|
473
|
-
const [currentValue, setCurrentValue] = useState(targetValue);
|
|
474
|
-
const startValueRef = useRef(targetValue);
|
|
475
|
-
const startTimeRef = useRef<number | null>(null);
|
|
476
|
-
const animationRef = useRef<number>();
|
|
477
|
-
|
|
478
|
-
useEffect(() => {
|
|
479
|
-
if (currentValue === targetValue) return;
|
|
480
|
-
|
|
481
|
-
startValueRef.current = currentValue;
|
|
482
|
-
startTimeRef.current = null;
|
|
483
|
-
|
|
484
|
-
const animate = (time: number) => {
|
|
485
|
-
if (startTimeRef.current === null) {
|
|
486
|
-
startTimeRef.current = time;
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
const elapsed = time - startTimeRef.current;
|
|
490
|
-
const progress = Math.min(elapsed / duration, 1);
|
|
491
|
-
const easedProgress = easing(progress);
|
|
492
|
-
|
|
493
|
-
const newValue =
|
|
494
|
-
startValueRef.current + (targetValue - startValueRef.current) * easedProgress;
|
|
495
|
-
|
|
496
|
-
setCurrentValue(newValue);
|
|
497
|
-
|
|
498
|
-
if (progress < 1) {
|
|
499
|
-
animationRef.current = requestAnimationFrame(animate);
|
|
500
|
-
}
|
|
501
|
-
};
|
|
502
|
-
|
|
503
|
-
animationRef.current = requestAnimationFrame(animate);
|
|
504
|
-
|
|
505
|
-
return () => {
|
|
506
|
-
if (animationRef.current) {
|
|
507
|
-
cancelAnimationFrame(animationRef.current);
|
|
508
|
-
}
|
|
509
|
-
};
|
|
510
|
-
}, [targetValue, duration, easing, currentValue]);
|
|
511
|
-
|
|
512
|
-
return currentValue;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
// ============================================================================
|
|
516
|
-
// useReducedMotion Hook
|
|
517
|
-
// ============================================================================
|
|
518
|
-
|
|
519
|
-
/**
|
|
520
|
-
* Detects user's reduced motion preference.
|
|
521
|
-
*
|
|
522
|
-
* @example
|
|
523
|
-
* const prefersReducedMotion = useReducedMotion();
|
|
524
|
-
*
|
|
525
|
-
* const animationDuration = prefersReducedMotion ? 0 : 300;
|
|
526
|
-
*/
|
|
527
|
-
export function useReducedMotion(): boolean {
|
|
528
|
-
const [prefersReducedMotion, setPrefersReducedMotion] = useState(false);
|
|
529
|
-
|
|
530
|
-
useEffect(() => {
|
|
531
|
-
const mediaQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
|
|
532
|
-
setPrefersReducedMotion(mediaQuery.matches);
|
|
533
|
-
|
|
534
|
-
const handler = (event: MediaQueryListEvent) => {
|
|
535
|
-
setPrefersReducedMotion(event.matches);
|
|
536
|
-
};
|
|
537
|
-
|
|
538
|
-
mediaQuery.addEventListener('change', handler);
|
|
539
|
-
return () => mediaQuery.removeEventListener('change', handler);
|
|
540
|
-
}, []);
|
|
541
|
-
|
|
542
|
-
return prefersReducedMotion;
|
|
543
|
-
}
|
|
544
|
-
|