@hua-labs/motion-core 2.2.2 → 2.2.3

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/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as react from 'react';
2
- import { CSSProperties, RefObject } from 'react';
2
+ import react__default, { CSSProperties, RefObject } from 'react';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
4
 
4
5
  /**
5
6
  * HUA Motion Core - 의존성 제로 모션 엔진
@@ -35,7 +36,7 @@ interface MotionOptions {
35
36
  onComplete?: () => void;
36
37
  onCancel?: () => void;
37
38
  }
38
- interface Motion {
39
+ interface Motion$1 {
39
40
  id: string;
40
41
  element: HTMLElement;
41
42
  isRunning: boolean;
@@ -72,7 +73,7 @@ declare class MotionEngine {
72
73
  /**
73
74
  * 모션 상태 확인
74
75
  */
75
- getMotion(motionId: string): Motion | undefined;
76
+ getMotion(motionId: string): Motion$1 | undefined;
76
77
  /**
77
78
  * 실행 중인 모션 수
78
79
  */
@@ -677,9 +678,25 @@ declare function useSmartMotion<T extends HTMLElement = HTMLDivElement>(options?
677
678
  * 내부에서 선택된 type에 맞는 로직만 실행 (6개 훅 동시 호출 제거)
678
679
  */
679
680
 
681
+ interface MotionEffects {
682
+ fade?: boolean | {
683
+ targetOpacity?: number;
684
+ };
685
+ slide?: boolean | {
686
+ direction?: 'up' | 'down' | 'left' | 'right';
687
+ distance?: number;
688
+ };
689
+ scale?: boolean | {
690
+ from?: number;
691
+ to?: number;
692
+ };
693
+ bounce?: boolean;
694
+ }
680
695
  interface UseUnifiedMotionOptions extends Omit<BaseMotionOptions, 'autoStart'> {
681
- /** Motion type to use */
682
- type: EntranceType;
696
+ /** Motion type to use (single effect mode) */
697
+ type?: EntranceType;
698
+ /** Multiple effects to combine (multi-effect mode) */
699
+ effects?: MotionEffects;
683
700
  /** Auto start animation @default true */
684
701
  autoStart?: boolean;
685
702
  /** Slide distance (px) for slide types @default 50 */
@@ -1044,6 +1061,193 @@ declare function useGestureMotion(options: GestureMotionOptions): {
1044
1061
  isActive: boolean;
1045
1062
  };
1046
1063
 
1064
+ interface TypewriterOptions {
1065
+ /** 타이핑할 텍스트 */
1066
+ text: string;
1067
+ /** 글자당 딜레이 (ms) @default 50 */
1068
+ speed?: number;
1069
+ /** 시작 딜레이 (ms) @default 0 */
1070
+ delay?: number;
1071
+ /** 활성화 여부 @default true */
1072
+ enabled?: boolean;
1073
+ /** 완료 콜백 */
1074
+ onComplete?: () => void;
1075
+ }
1076
+ interface TypewriterReturn {
1077
+ /** 현재 표시 중인 텍스트 */
1078
+ displayText: string;
1079
+ /** 타이핑 진행 중 여부 */
1080
+ isTyping: boolean;
1081
+ /** 진행률 (0-1) */
1082
+ progress: number;
1083
+ /** 타이핑 재시작 */
1084
+ restart: () => void;
1085
+ }
1086
+ /**
1087
+ * useTypewriter - 타이핑 효과 훅
1088
+ *
1089
+ * @example
1090
+ * ```tsx
1091
+ * const { displayText, isTyping } = useTypewriter({ text: 'Hello, world!' })
1092
+ * return <h1>{displayText}<span className="animate-pulse">|</span></h1>
1093
+ * ```
1094
+ */
1095
+ declare function useTypewriter(options: TypewriterOptions): TypewriterReturn;
1096
+
1097
+ interface CustomCursorOptions {
1098
+ /** 활성화 여부 @default true */
1099
+ enabled?: boolean;
1100
+ /** 커서 크기 (px) @default 32 */
1101
+ size?: number;
1102
+ /** 스프링 스무딩 (0-1, 낮을수록 부드러움) @default 0.15 */
1103
+ smoothing?: number;
1104
+ /** 호버 시 스케일 @default 1.5 */
1105
+ hoverScale?: number;
1106
+ /** data-cursor 속성 요소 감지 @default true */
1107
+ detectLabels?: boolean;
1108
+ }
1109
+ interface CustomCursorReturn {
1110
+ /** 커서 x 좌표 (smoothed) */
1111
+ x: number;
1112
+ /** 커서 y 좌표 (smoothed) */
1113
+ y: number;
1114
+ /** 호버 중인 요소의 data-cursor 값 */
1115
+ label: string | null;
1116
+ /** 호버 상태 여부 */
1117
+ isHovering: boolean;
1118
+ /** 커서 스타일 (CSS variables 포함) */
1119
+ style: CSSProperties;
1120
+ /** 커서 가시 여부 */
1121
+ isVisible: boolean;
1122
+ }
1123
+ /**
1124
+ * useCustomCursor - 커스텀 커서 효과 훅
1125
+ *
1126
+ * 마우스를 따라다니는 커스텀 커서를 구현합니다.
1127
+ * 스프링 보간으로 부드러운 추적, data-cursor 라벨 감지.
1128
+ *
1129
+ * @example
1130
+ * ```tsx
1131
+ * const cursor = useCustomCursor()
1132
+ * return (
1133
+ * <>
1134
+ * <div style={cursor.style} className="custom-cursor" />
1135
+ * <button data-cursor="Click me">Hover me</button>
1136
+ * </>
1137
+ * )
1138
+ * ```
1139
+ */
1140
+ declare function useCustomCursor(options?: CustomCursorOptions): CustomCursorReturn;
1141
+
1142
+ interface MagneticCursorOptions {
1143
+ /** 자석 끌림 강도 (0-1) @default 0.3 */
1144
+ strength?: number;
1145
+ /** 자석 작동 반경 (px) @default 100 */
1146
+ radius?: number;
1147
+ /** 활성화 여부 @default true */
1148
+ enabled?: boolean;
1149
+ }
1150
+ interface MagneticCursorReturn<T extends HTMLElement = HTMLElement> {
1151
+ /** 자석 대상 요소에 연결할 ref */
1152
+ ref: React.RefObject<T | null>;
1153
+ /** 마우스 이벤트 핸들러 */
1154
+ handlers: {
1155
+ onMouseMove: (e: React.MouseEvent) => void;
1156
+ onMouseLeave: () => void;
1157
+ };
1158
+ /** 요소에 적용할 transform 스타일 */
1159
+ style: CSSProperties;
1160
+ }
1161
+ /**
1162
+ * useMagneticCursor - 자석 커서 효과 훅
1163
+ *
1164
+ * 마우스가 요소 근처에 오면 요소가 마우스 쪽으로 끌려오는 효과.
1165
+ * 버튼, 아이콘 등에 적용하면 인터랙티브 느낌 향상.
1166
+ *
1167
+ * @example
1168
+ * ```tsx
1169
+ * const magnetic = useMagneticCursor<HTMLButtonElement>({ strength: 0.4 })
1170
+ * return <button ref={magnetic.ref} style={magnetic.style} {...magnetic.handlers}>Click</button>
1171
+ * ```
1172
+ */
1173
+ declare function useMagneticCursor<T extends HTMLElement = HTMLElement>(options?: MagneticCursorOptions): MagneticCursorReturn<T>;
1174
+
1175
+ interface SmoothScrollOptions {
1176
+ /** 활성화 여부 @default true */
1177
+ enabled?: boolean;
1178
+ /** 스무딩 계수 (0-1, 낮을수록 부드러움) @default 0.1 */
1179
+ lerp?: number;
1180
+ /** 마우스 휠 배율 @default 1 */
1181
+ wheelMultiplier?: number;
1182
+ /** 터치 배율 @default 2 */
1183
+ touchMultiplier?: number;
1184
+ /** 방향 @default 'vertical' */
1185
+ direction?: 'vertical' | 'horizontal';
1186
+ /** 콜백: 스크롤 값 변경 시 */
1187
+ onScroll?: (scroll: number) => void;
1188
+ }
1189
+ interface SmoothScrollReturn {
1190
+ /** 현재 스크롤 위치 (smoothed) */
1191
+ scroll: number;
1192
+ /** 목표 스크롤 위치 */
1193
+ targetScroll: number;
1194
+ /** 스크롤 진행률 (0-1) */
1195
+ progress: number;
1196
+ /** 특정 위치로 스크롤 */
1197
+ scrollTo: (target: number | HTMLElement, options?: {
1198
+ offset?: number;
1199
+ }) => void;
1200
+ /** 스크롤 중지 */
1201
+ stop: () => void;
1202
+ }
1203
+ /**
1204
+ * useSmoothScroll - 부드러운 스크롤 훅
1205
+ *
1206
+ * lenis 스타일의 smooth scrolling. 네이티브 스크롤을 가로채서
1207
+ * lerp 보간으로 부드러운 스크롤 경험을 제공합니다.
1208
+ *
1209
+ * @example
1210
+ * ```tsx
1211
+ * const { scroll, progress, scrollTo } = useSmoothScroll({ lerp: 0.08 })
1212
+ * return <button onClick={() => scrollTo(document.getElementById('section')!)}>Go</button>
1213
+ * ```
1214
+ */
1215
+ declare function useSmoothScroll(options?: SmoothScrollOptions): SmoothScrollReturn;
1216
+
1217
+ interface ElementProgressOptions {
1218
+ /** 요소가 뷰포트 아래에서 시작되는 위치 (0 = 하단, 1 = 상단) @default 0 */
1219
+ start?: number;
1220
+ /** 요소가 뷰포트 위에서 끝나는 위치 @default 1 */
1221
+ end?: number;
1222
+ /** 클램프 여부 @default true */
1223
+ clamp?: boolean;
1224
+ }
1225
+ interface ElementProgressReturn<T extends HTMLElement = HTMLElement> {
1226
+ /** 대상 요소 ref */
1227
+ ref: React.RefObject<T | null>;
1228
+ /** 요소의 스크롤 진행률 (0-1) */
1229
+ progress: number;
1230
+ /** 요소가 뷰포트 안에 있는지 */
1231
+ isInView: boolean;
1232
+ }
1233
+ /**
1234
+ * useElementProgress - 요소 단위 스크롤 진행률 훅
1235
+ *
1236
+ * useScrollProgress의 확장판. 페이지 전체가 아니라
1237
+ * 특정 요소가 뷰포트를 통과하는 진행률을 추적합니다.
1238
+ *
1239
+ * @example
1240
+ * ```tsx
1241
+ * const { ref, progress, isInView } = useElementProgress<HTMLDivElement>()
1242
+ * return (
1243
+ * <div ref={ref} style={{ opacity: progress }}>
1244
+ * Fades in as you scroll
1245
+ * </div>
1246
+ * )
1247
+ * ```
1248
+ */
1249
+ declare function useElementProgress<T extends HTMLElement = HTMLElement>(options?: ElementProgressOptions): ElementProgressReturn<T>;
1250
+
1047
1251
  declare const MOTION_PRESETS: PresetConfig;
1048
1252
  declare const PAGE_MOTIONS: Record<PageType, PageMotionsConfig>;
1049
1253
  /**
@@ -1086,4 +1290,77 @@ declare const easingPresets: {
1086
1290
  };
1087
1291
  declare function getPresetEasing(preset: keyof typeof easingPresets): EasingFunction;
1088
1292
 
1089
- export { type BaseMotionOptions, type BaseMotionReturn, type BounceOptions, type EasingFunction, type EasingType, type EntranceType, type FadeInOptions, type GestureConfig, type GestureOptions$1 as GestureOptions, type GradientOptions, type HoverMotionOptions, type InViewOptions, type InViewReturn, type InteractionReturn, MOTION_PRESETS, type Motion, type MotionCallback, type MotionConfig, type MotionDirection$1 as MotionDirection, type MotionEasing, type MotionElement, MotionEngine, type MotionFrame, type MotionOptions, type MotionPreset, type MotionProgressCallback, type MotionState$1 as MotionState, type MotionStateCallback, type MotionTrigger, type MotionType$1 as MotionType, type MouseOptions, type MouseReturn, type OptimizationConfig, type OrchestrationConfig, PAGE_MOTIONS, type PageMotionElement, type PageMotionRef, type PageMotionsConfig, type PageType, type PerformanceMetrics, PerformanceOptimizer, type PerformanceOptimizerMetrics, type PresetConfig, type PulseOptions, type ReducedMotionReturn, type RepeatOptions, type ScaleOptions, type ScrollRevealMotionType, type ScrollRevealOptions, type SlideOptions, type SpringConfig, type SpringOptions, type ToggleMotionOptions, TransitionEffects, type TransitionOptions, type TransitionType, type UseUnifiedMotionOptions, type WindowSizeOptions, type WindowSizeReturn, applyEasing, easeIn, easeInOut, easeInOutQuad, easeInQuad, easeOut, easeOutQuad, easingPresets, getAvailableEasings, getEasing, getMotionPreset, getPagePreset, getPresetEasing, isEasingFunction, isValidEasing, linear, mergeWithPreset, motionEngine, performanceOptimizer, safeApplyEasing, transitionEffects, useBounceIn, useClickToggle, useFadeIn, useFocusToggle, useGesture, useGestureMotion, useGradient, useHoverMotion, useInView, useMotionState, useMouse, usePageMotions, usePulse, useReducedMotion, useRepeat, useScaleIn, useScrollProgress, useScrollReveal, useSimplePageMotion, useSlideDown, useSlideLeft, useSlideRight, useSlideUp, useSmartMotion, useSpringMotion, useToggleMotion, useUnifiedMotion, useWindowSize };
1293
+ type MotionAs = 'div' | 'span' | 'section' | 'article' | 'header' | 'footer' | 'main' | 'nav';
1294
+ interface MotionProps extends react__default.HTMLAttributes<HTMLElement> {
1295
+ /** HTML 요소 타입 @default 'div' */
1296
+ as?: MotionAs;
1297
+ /** 모션 타입 */
1298
+ type?: EntranceType;
1299
+ /** 멀티이펙트 */
1300
+ effects?: MotionEffects;
1301
+ /** 스크롤 기반 reveal 모드 */
1302
+ scroll?: boolean | ScrollRevealOptions;
1303
+ /** 딜레이 (ms) */
1304
+ delay?: number;
1305
+ /** 지속시간 (ms) */
1306
+ duration?: number;
1307
+ children: react__default.ReactNode;
1308
+ }
1309
+ /**
1310
+ * Motion wrapper component
1311
+ *
1312
+ * ref/style 수동 연결 없이 모션을 적용하는 래퍼 컴포넌트.
1313
+ *
1314
+ * @example
1315
+ * // 기본 fadeIn
1316
+ * <Motion>content</Motion>
1317
+ *
1318
+ * // 스크롤 reveal
1319
+ * <Motion scroll delay={200} className="grid grid-cols-3">...</Motion>
1320
+ *
1321
+ * // 커스텀 요소 + 타입
1322
+ * <Motion as="section" type="slideUp" duration={800}>...</Motion>
1323
+ */
1324
+ declare function Motion({ as: Component, type, effects, scroll, delay, duration, children, className, style: userStyle, ...rest }: MotionProps): react_jsx_runtime.JSX.Element;
1325
+
1326
+ interface UseStaggerOptions {
1327
+ /** 자식 아이템 개수 */
1328
+ count: number;
1329
+ /** 아이템 간 딜레이 (ms) @default 100 */
1330
+ staggerDelay?: number;
1331
+ /** 전체 시작 딜레이 (ms) @default 0 */
1332
+ baseDelay?: number;
1333
+ /** 애니메이션 지속시간 (ms) @default 700 */
1334
+ duration?: number;
1335
+ /** 모션 타입 @default 'fadeIn' */
1336
+ motionType?: ScrollRevealMotionType;
1337
+ /** IntersectionObserver 임계값 @default 0.1 */
1338
+ threshold?: number;
1339
+ /** 이징 함수 @default 'ease-out' */
1340
+ easing?: string;
1341
+ }
1342
+ interface UseStaggerReturn {
1343
+ /** 부모 컨테이너 ref — IntersectionObserver 연결 */
1344
+ containerRef: RefObject<HTMLDivElement | null>;
1345
+ /** 자식 아이템별 style 배열 */
1346
+ styles: CSSProperties[];
1347
+ /** 전체 visible 여부 */
1348
+ isVisible: boolean;
1349
+ }
1350
+ /**
1351
+ * useStagger — 리스트 아이템에 순차 딜레이를 적용하는 훅
1352
+ *
1353
+ * 단일 IntersectionObserver로 컨테이너를 관찰하고,
1354
+ * 자식 아이템별로 CSS transition-delay를 자동 계산합니다.
1355
+ *
1356
+ * @example
1357
+ * const stagger = useStagger({ count: items.length, staggerDelay: 100 });
1358
+ * <div ref={stagger.containerRef}>
1359
+ * {items.map((item, i) => (
1360
+ * <div style={stagger.styles[i]} key={i}>{item}</div>
1361
+ * ))}
1362
+ * </div>
1363
+ */
1364
+ declare function useStagger(options: UseStaggerOptions): UseStaggerReturn;
1365
+
1366
+ export { type BaseMotionOptions, type BaseMotionReturn, type BounceOptions, type CustomCursorOptions, type CustomCursorReturn, type EasingFunction, type EasingType, type ElementProgressOptions, type ElementProgressReturn, type EntranceType, type FadeInOptions, type GestureConfig, type GestureOptions$1 as GestureOptions, type GradientOptions, type HoverMotionOptions, type InViewOptions, type InViewReturn, type InteractionReturn, MOTION_PRESETS, type MagneticCursorOptions, type MagneticCursorReturn, Motion, type MotionCallback, type MotionConfig, type MotionDirection$1 as MotionDirection, type MotionEasing, type MotionEffects, type MotionElement, MotionEngine, type MotionFrame, type Motion$1 as MotionInstance, type MotionOptions, type MotionPreset, type MotionProgressCallback, type MotionProps, type MotionState$1 as MotionState, type MotionStateCallback, type MotionTrigger, type MotionType$1 as MotionType, type MouseOptions, type MouseReturn, type OptimizationConfig, type OrchestrationConfig, PAGE_MOTIONS, type PageMotionElement, type PageMotionRef, type PageMotionsConfig, type PageType, type PerformanceMetrics, PerformanceOptimizer, type PerformanceOptimizerMetrics, type PresetConfig, type PulseOptions, type ReducedMotionReturn, type RepeatOptions, type ScaleOptions, type ScrollRevealMotionType, type ScrollRevealOptions, type SlideOptions, type SmoothScrollOptions, type SmoothScrollReturn, type SpringConfig, type SpringOptions, type ToggleMotionOptions, TransitionEffects, type TransitionOptions, type TransitionType, type TypewriterOptions, type TypewriterReturn, type UseStaggerOptions, type UseStaggerReturn, type UseUnifiedMotionOptions, type WindowSizeOptions, type WindowSizeReturn, applyEasing, easeIn, easeInOut, easeInOutQuad, easeInQuad, easeOut, easeOutQuad, easingPresets, getAvailableEasings, getEasing, getMotionPreset, getPagePreset, getPresetEasing, isEasingFunction, isValidEasing, linear, mergeWithPreset, motionEngine, performanceOptimizer, safeApplyEasing, transitionEffects, useBounceIn, useClickToggle, useCustomCursor, useElementProgress, useFadeIn, useFocusToggle, useGesture, useGestureMotion, useGradient, useHoverMotion, useInView, useMagneticCursor, useMotionState, useMouse, usePageMotions, usePulse, useReducedMotion, useRepeat, useScaleIn, useScrollProgress, useScrollReveal, useSimplePageMotion, useSlideDown, useSlideLeft, useSlideRight, useSlideUp, useSmartMotion, useSmoothScroll, useSpringMotion, useStagger, useToggleMotion, useTypewriter, useUnifiedMotion, useWindowSize };