UNPKG

178 kBTypeScriptView Raw
1/// <reference types="react" />
2import * as React$1 from 'react';
3import { SVGAttributes as SVGAttributes$1, CSSProperties, PropsWithoutRef, RefAttributes, ReactHTML, DetailedHTMLFactory, HTMLAttributes, useEffect, RefObject as RefObject$1 } from 'react';
4import * as react_jsx_runtime from 'react/jsx-runtime';
5
6type EasingFunction = (v: number) => number;
7type EasingModifier = (easing: EasingFunction) => EasingFunction;
8type BezierDefinition = readonly [number, number, number, number];
9type EasingDefinition = BezierDefinition | "linear" | "easeIn" | "easeOut" | "easeInOut" | "circIn" | "circOut" | "circInOut" | "backIn" | "backOut" | "backInOut" | "anticipate";
10/**
11 * The easing function to use. Set as one of:
12 *
13 * - The name of an in-built easing function.
14 * - An array of four numbers to define a cubic bezier curve.
15 * - An easing function, that accepts and returns a progress value between `0` and `1`.
16 *
17 * @public
18 */
19type Easing = EasingDefinition | EasingFunction;
20
21type GenericKeyframesTarget<V> = V[] | Array<null | V>;
22/**
23 * @public
24 */
25type ResolvedKeyframesTarget = GenericKeyframesTarget<number> | GenericKeyframesTarget<string>;
26/**
27 * @public
28 */
29type KeyframesTarget = ResolvedKeyframesTarget | GenericKeyframesTarget<CustomValueType>;
30/**
31 * @public
32 */
33type ResolvedSingleTarget = string | number;
34/**
35 * @public
36 */
37type SingleTarget = ResolvedSingleTarget | CustomValueType;
38/**
39 * @public
40 */
41type ResolvedValueTarget = ResolvedSingleTarget | ResolvedKeyframesTarget;
42/**
43 * @public
44 */
45type ValueTarget = SingleTarget | KeyframesTarget;
46/**
47 * Options for orchestrating the timing of animations.
48 *
49 * @public
50 */
51interface Orchestration {
52 /**
53 * Delay the animation by this duration (in seconds). Defaults to `0`.
54 *
55 * @remarks
56 * ```javascript
57 * const transition = {
58 * delay: 0.2
59 * }
60 * ```
61 *
62 * @public
63 */
64 delay?: number;
65 /**
66 * Describes the relationship between the transition and its children. Set
67 * to `false` by default.
68 *
69 * @remarks
70 * When using variants, the transition can be scheduled in relation to its
71 * children with either `"beforeChildren"` to finish this transition before
72 * starting children transitions, `"afterChildren"` to finish children
73 * transitions before starting this transition.
74 *
75 * ```jsx
76 * const list = {
77 * hidden: {
78 * opacity: 0,
79 * transition: { when: "afterChildren" }
80 * }
81 * }
82 *
83 * const item = {
84 * hidden: {
85 * opacity: 0,
86 * transition: { duration: 2 }
87 * }
88 * }
89 *
90 * return (
91 * <motion.ul variants={list} animate="hidden">
92 * <motion.li variants={item} />
93 * <motion.li variants={item} />
94 * </motion.ul>
95 * )
96 * ```
97 *
98 * @public
99 */
100 when?: false | "beforeChildren" | "afterChildren" | string;
101 /**
102 * When using variants, children animations will start after this duration
103 * (in seconds). You can add the `transition` property to both the `Frame` and the `variant` directly. Adding it to the `variant` generally offers more flexibility, as it allows you to customize the delay per visual state.
104 *
105 * ```jsx
106 * const container = {
107 * hidden: { opacity: 0 },
108 * show: {
109 * opacity: 1,
110 * transition: {
111 * delayChildren: 0.5
112 * }
113 * }
114 * }
115 *
116 * const item = {
117 * hidden: { opacity: 0 },
118 * show: { opacity: 1 }
119 * }
120 *
121 * return (
122 * <motion.ul
123 * variants={container}
124 * initial="hidden"
125 * animate="show"
126 * >
127 * <motion.li variants={item} />
128 * <motion.li variants={item} />
129 * </motion.ul>
130 * )
131 * ```
132 *
133 * @public
134 */
135 delayChildren?: number;
136 /**
137 * When using variants, animations of child components can be staggered by this
138 * duration (in seconds).
139 *
140 * For instance, if `staggerChildren` is `0.01`, the first child will be
141 * delayed by `0` seconds, the second by `0.01`, the third by `0.02` and so
142 * on.
143 *
144 * The calculated stagger delay will be added to `delayChildren`.
145 *
146 * ```jsx
147 * const container = {
148 * hidden: { opacity: 0 },
149 * show: {
150 * opacity: 1,
151 * transition: {
152 * staggerChildren: 0.5
153 * }
154 * }
155 * }
156 *
157 * const item = {
158 * hidden: { opacity: 0 },
159 * show: { opacity: 1 }
160 * }
161 *
162 * return (
163 * <motion.ol
164 * variants={container}
165 * initial="hidden"
166 * animate="show"
167 * >
168 * <motion.li variants={item} />
169 * <motion.li variants={item} />
170 * </motion.ol>
171 * )
172 * ```
173 *
174 * @public
175 */
176 staggerChildren?: number;
177 /**
178 * The direction in which to stagger children.
179 *
180 * A value of `1` staggers from the first to the last while `-1`
181 * staggers from the last to the first.
182 *
183 * ```jsx
184 * const container = {
185 * hidden: { opacity: 0 },
186 * show: {
187 * opacity: 1,
188 * transition: {
189 * staggerChildren: 0.5,
190 * staggerDirection: -1
191 * }
192 * }
193 * }
194 *
195 * const item = {
196 * hidden: { opacity: 0 },
197 * show: { opacity: 1 }
198 * }
199 *
200 * return (
201 * <motion.ul
202 * variants={container}
203 * initial="hidden"
204 * animate="show"
205 * >
206 * <motion.li variants={item} size={50} />
207 * <motion.li variants={item} size={50} />
208 * </motion.ul>
209 * )
210 * ```
211 *
212 * @public
213 */
214 staggerDirection?: number;
215}
216interface Repeat {
217 /**
218 * The number of times to repeat the transition. Set to `Infinity` for perpetual repeating.
219 *
220 * Without setting `repeatType`, this will loop the animation.
221 *
222 * ```jsx
223 * <motion.div
224 * animate={{ rotate: 180 }}
225 * transition={{ repeat: Infinity, duration: 2 }}
226 * />
227 * ```
228 *
229 * @public
230 */
231 repeat?: number;
232 /**
233 * How to repeat the animation. This can be either:
234 *
235 * "loop": Repeats the animation from the start
236 *
237 * "reverse": Alternates between forward and backwards playback
238 *
239 * "mirror": Switches `from` and `to` alternately
240 *
241 * ```jsx
242 * <motion.div
243 * animate={{ rotate: 180 }}
244 * transition={{
245 * repeat: 1,
246 * repeatType: "reverse",
247 * duration: 2
248 * }}
249 * />
250 * ```
251 *
252 * @public
253 */
254 repeatType?: "loop" | "reverse" | "mirror";
255 /**
256 * When repeating an animation, `repeatDelay` will set the
257 * duration of the time to wait, in seconds, between each repetition.
258 *
259 * ```jsx
260 * <motion.div
261 * animate={{ rotate: 180 }}
262 * transition={{ repeat: Infinity, repeatDelay: 1 }}
263 * />
264 * ```
265 *
266 * @public
267 */
268 repeatDelay?: number;
269}
270/**
271 * An animation that animates between two or more values over a specific duration of time.
272 * This is the default animation for non-physical values like `color` and `opacity`.
273 *
274 * @public
275 */
276interface Tween extends Repeat {
277 /**
278 * Set `type` to `"tween"` to use a duration-based tween animation.
279 * If any non-orchestration `transition` values are set without a `type` property,
280 * this is used as the default animation.
281 *
282 * ```jsx
283 * <motion.path
284 * animate={{ pathLength: 1 }}
285 * transition={{ duration: 2, type: "tween" }}
286 * />
287 * ```
288 *
289 * @public
290 */
291 type?: "tween";
292 /**
293 * The duration of the tween animation. Set to `0.3` by default, 0r `0.8` if animating a series of keyframes.
294 *
295 * ```jsx
296 * const variants = {
297 * visible: {
298 * opacity: 1,
299 * transition: { duration: 2 }
300 * }
301 * }
302 * ```
303 *
304 * @public
305 */
306 duration?: number;
307 /**
308 * The easing function to use. Set as one of the below.
309 *
310 * - The name of an existing easing function.
311 *
312 * - An array of four numbers to define a cubic bezier curve.
313 *
314 * - An easing function, that accepts and returns a value `0-1`.
315 *
316 * If the animating value is set as an array of multiple values for a keyframes
317 * animation, `ease` can be set as an array of easing functions to set different easings between
318 * each of those values.
319 *
320 *
321 * ```jsx
322 * <motion.div
323 * animate={{ opacity: 0 }}
324 * transition={{ ease: [0.17, 0.67, 0.83, 0.67] }}
325 * />
326 * ```
327 *
328 * @public
329 */
330 ease?: Easing | Easing[];
331 /**
332 * When animating keyframes, `times` can be used to determine where in the animation each keyframe is reached.
333 * Each value in `times` is a value between `0` and `1`, representing `duration`.
334 *
335 * There must be the same number of `times` as there are keyframes.
336 * Defaults to an array of evenly-spread durations.
337 *
338 * ```jsx
339 * <motion.div
340 * animate={{ scale: [0, 1, 0.5, 1] }}
341 * transition={{ times: [0, 0.1, 0.9, 1] }}
342 * />
343 * ```
344 *
345 * @public
346 */
347 times?: number[];
348 /**
349 * When animating keyframes, `easings` can be used to define easing functions between each keyframe. This array should be one item fewer than the number of keyframes, as these easings apply to the transitions between the keyframes.
350 *
351 * ```jsx
352 * <motion.div
353 * animate={{ backgroundColor: ["#0f0", "#00f", "#f00"] }}
354 * transition={{ easings: ["easeIn", "easeOut"] }}
355 * />
356 * ```
357 *
358 * @public
359 */
360 easings?: Easing[];
361 /**
362 * The value to animate from.
363 * By default, this is the current state of the animating value.
364 *
365 * ```jsx
366 * <motion.div
367 * animate={{ rotate: 180 }}
368 * transition={{ from: 90, duration: 2 }}
369 * />
370 * ```
371 *
372 * @public
373 */
374 from?: number | string;
375}
376/**
377 * An animation that simulates spring physics for realistic motion.
378 * This is the default animation for physical values like `x`, `y`, `scale` and `rotate`.
379 *
380 * @public
381 */
382interface Spring extends Repeat {
383 /**
384 * Set `type` to `"spring"` to animate using spring physics for natural
385 * movement. Type is set to `"spring"` by default.
386 *
387 * ```jsx
388 * <motion.div
389 * animate={{ rotate: 180 }}
390 * transition={{ type: 'spring' }}
391 * />
392 * ```
393 *
394 * @public
395 */
396 type: "spring";
397 /**
398 * Stiffness of the spring. Higher values will create more sudden movement.
399 * Set to `100` by default.
400 *
401 * ```jsx
402 * <motion.section
403 * animate={{ rotate: 180 }}
404 * transition={{ type: 'spring', stiffness: 50 }}
405 * />
406 * ```
407 *
408 * @public
409 */
410 stiffness?: number;
411 /**
412 * Strength of opposing force. If set to 0, spring will oscillate
413 * indefinitely. Set to `10` by default.
414 *
415 * ```jsx
416 * <motion.a
417 * animate={{ rotate: 180 }}
418 * transition={{ type: 'spring', damping: 300 }}
419 * />
420 * ```
421 *
422 * @public
423 */
424 damping?: number;
425 /**
426 * Mass of the moving object. Higher values will result in more lethargic
427 * movement. Set to `1` by default.
428 *
429 * ```jsx
430 * <motion.feTurbulence
431 * animate={{ baseFrequency: 0.5 } as any}
432 * transition={{ type: "spring", mass: 0.5 }}
433 * />
434 * ```
435 *
436 * @public
437 */
438 mass?: number;
439 /**
440 * The duration of the animation, defined in seconds. Spring animations can be a maximum of 10 seconds.
441 *
442 * If `bounce` is set, this defaults to `0.8`.
443 *
444 * Note: `duration` and `bounce` will be overridden if `stiffness`, `damping` or `mass` are set.
445 *
446 * ```jsx
447 * <motion.div
448 * animate={{ x: 100 }}
449 * transition={{ type: "spring", duration: 0.8 }}
450 * />
451 * ```
452 *
453 * @public
454 */
455 duration?: number;
456 /**
457 * `bounce` determines the "bounciness" of a spring animation.
458 *
459 * `0` is no bounce, and `1` is extremely bouncy.
460 *
461 * If `duration` is set, this defaults to `0.25`.
462 *
463 * Note: `bounce` and `duration` will be overridden if `stiffness`, `damping` or `mass` are set.
464 *
465 * ```jsx
466 * <motion.div
467 * animate={{ x: 100 }}
468 * transition={{ type: "spring", bounce: 0.25 }}
469 * />
470 * ```
471 *
472 * @public
473 */
474 bounce?: number;
475 /**
476 * End animation if absolute speed (in units per second) drops below this
477 * value and delta is smaller than `restDelta`. Set to `0.01` by default.
478 *
479 * ```jsx
480 * <motion.div
481 * animate={{ rotate: 180 }}
482 * transition={{ type: 'spring', restSpeed: 0.5 }}
483 * />
484 * ```
485 *
486 * @public
487 */
488 restSpeed?: number;
489 /**
490 * End animation if distance is below this value and speed is below
491 * `restSpeed`. When animation ends, spring gets “snapped” to. Set to
492 * `0.01` by default.
493 *
494 * ```jsx
495 * <motion.div
496 * animate={{ rotate: 180 }}
497 * transition={{ type: 'spring', restDelta: 0.5 }}
498 * />
499 * ```
500 *
501 * @public
502 */
503 restDelta?: number;
504 /**
505 * The value to animate from.
506 * By default, this is the initial state of the animating value.
507 *
508 * ```jsx
509 * <motion.div
510 * animate={{ rotate: 180 }}
511 * transition={{ type: 'spring', from: 90 }}
512 * />
513 * ```
514 *
515 * @public
516 */
517 from?: number | string;
518 /**
519 * The initial velocity of the spring. By default this is the current velocity of the component.
520 *
521 * ```jsx
522 * <motion.div
523 * animate={{ rotate: 180 }}
524 * transition={{ type: 'spring', velocity: 2 }}
525 * />
526 * ```
527 *
528 * @public
529 */
530 velocity?: number;
531}
532/**
533 * An animation that decelerates a value based on its initial velocity,
534 * usually used to implement inertial scrolling.
535 *
536 * Optionally, `min` and `max` boundaries can be defined, and inertia
537 * will snap to these with a spring animation.
538 *
539 * This animation will automatically precalculate a target value,
540 * which can be modified with the `modifyTarget` property.
541 *
542 * This allows you to add snap-to-grid or similar functionality.
543 *
544 * Inertia is also the animation used for `dragTransition`, and can be configured via that prop.
545 *
546 * @public
547 */
548interface Inertia {
549 /**
550 * Set `type` to animate using the inertia animation. Set to `"tween"` by
551 * default. This can be used for natural deceleration, like momentum scrolling.
552 *
553 * ```jsx
554 * <motion.div
555 * animate={{ rotate: 180 }}
556 * transition={{ type: "inertia", velocity: 50 }}
557 * />
558 * ```
559 *
560 * @public
561 */
562 type: "inertia";
563 /**
564 * A function that receives the automatically-calculated target and returns a new one. Useful for snapping the target to a grid.
565 *
566 * ```jsx
567 * <motion.div
568 * drag
569 * dragTransition={{
570 * power: 0,
571 * // Snap calculated target to nearest 50 pixels
572 * modifyTarget: target => Math.round(target / 50) * 50
573 * }}
574 * />
575 * ```
576 *
577 * @public
578 */
579 modifyTarget?(v: number): number;
580 /**
581 * If `min` or `max` is set, this affects the stiffness of the bounce
582 * spring. Higher values will create more sudden movement. Set to `500` by
583 * default.
584 *
585 * ```jsx
586 * <motion.div
587 * drag
588 * dragTransition={{
589 * min: 0,
590 * max: 100,
591 * bounceStiffness: 100
592 * }}
593 * />
594 * ```
595 *
596 * @public
597 */
598 bounceStiffness?: number;
599 /**
600 * If `min` or `max` is set, this affects the damping of the bounce spring.
601 * If set to `0`, spring will oscillate indefinitely. Set to `10` by
602 * default.
603 *
604 * ```jsx
605 * <motion.div
606 * drag
607 * dragTransition={{
608 * min: 0,
609 * max: 100,
610 * bounceDamping: 8
611 * }}
612 * />
613 * ```
614 *
615 * @public
616 */
617 bounceDamping?: number;
618 /**
619 * A higher power value equals a further target. Set to `0.8` by default.
620 *
621 * ```jsx
622 * <motion.div
623 * drag
624 * dragTransition={{ power: 0.2 }}
625 * />
626 * ```
627 *
628 * @public
629 */
630 power?: number;
631 /**
632 * Adjusting the time constant will change the duration of the
633 * deceleration, thereby affecting its feel. Set to `700` by default.
634 *
635 * ```jsx
636 * <motion.div
637 * drag
638 * dragTransition={{ timeConstant: 200 }}
639 * />
640 * ```
641 *
642 * @public
643 */
644 timeConstant?: number;
645 /**
646 * End the animation if the distance to the animation target is below this value, and the absolute speed is below `restSpeed`.
647 * When the animation ends, the value gets snapped to the animation target. Set to `0.01` by default.
648 * Generally the default values provide smooth animation endings, only in rare cases should you need to customize these.
649 *
650 * ```jsx
651 * <motion.div
652 * drag
653 * dragTransition={{ restDelta: 10 }}
654 * />
655 * ```
656 *
657 * @public
658 */
659 restDelta?: number;
660 /**
661 * Minimum constraint. If set, the value will "bump" against this value (or immediately spring to it if the animation starts as less than this value).
662 *
663 * ```jsx
664 * <motion.div
665 * drag
666 * dragTransition={{ min: 0, max: 100 }}
667 * />
668 * ```
669 *
670 * @public
671 */
672 min?: number;
673 /**
674 * Maximum constraint. If set, the value will "bump" against this value (or immediately snap to it, if the initial animation value exceeds this value).
675 *
676 * ```jsx
677 * <motion.div
678 * drag
679 * dragTransition={{ min: 0, max: 100 }}
680 * />
681 * ```
682 *
683 * @public
684 */
685 max?: number;
686 /**
687 * The value to animate from. By default, this is the current state of the animating value.
688 *
689 * ```jsx
690 * <Frame
691 * drag
692 * dragTransition={{ from: 50 }}
693 * />
694 * ```
695 *
696 * @public
697 */
698 from?: number | string;
699 /**
700 * The initial velocity of the animation.
701 * By default this is the current velocity of the component.
702 *
703 * ```jsx
704 * <motion.div
705 * animate={{ rotate: 180 }}
706 * transition={{ type: 'inertia', velocity: 200 }}
707 * />
708 * ```
709 *
710 * @public
711 */
712 velocity?: number;
713}
714/**
715 * Keyframes tweens between multiple `values`.
716 *
717 * These tweens can be arranged using the `duration`, `easings`, and `times` properties.
718 */
719interface Keyframes {
720 /**
721 * Set `type` to `"keyframes"` to animate using the keyframes animation.
722 * Set to `"tween"` by default. This can be used to animate between a series of values.
723 *
724 * @public
725 */
726 type: "keyframes";
727 /**
728 * An array of numbers between 0 and 1, where `1` represents the `total` duration.
729 *
730 * Each value represents at which point during the animation each item in the animation target should be hit, so the array should be the same length as `values`.
731 *
732 * Defaults to an array of evenly-spread durations.
733 *
734 * @public
735 */
736 times?: number[];
737 /**
738 * An array of easing functions for each generated tween, or a single easing function applied to all tweens.
739 *
740 * This array should be one item less than `values`, as these easings apply to the transitions *between* the `values`.
741 *
742 * ```jsx
743 * const transition = {
744 * backgroundColor: {
745 * type: 'keyframes',
746 * easings: ['circIn', 'circOut']
747 * }
748 * }
749 * ```
750 *
751 * @public
752 */
753 ease?: Easing | Easing[];
754 /**
755 * The total duration of the animation. Set to `0.3` by default.
756 *
757 * ```jsx
758 * const transition = {
759 * type: "keyframes",
760 * duration: 2
761 * }
762 *
763 * <Frame
764 * animate={{ opacity: 0 }}
765 * transition={transition}
766 * />
767 * ```
768 *
769 * @public
770 */
771 duration?: number;
772 /**
773 * @public
774 */
775 repeatDelay?: number;
776}
777/**
778 * @public
779 */
780interface None {
781 /**
782 * Set `type` to `false` for an instant transition.
783 *
784 * @public
785 */
786 type: false;
787}
788/**
789 * @public
790 */
791type PermissiveTransitionDefinition = {
792 [key: string]: any;
793};
794/**
795 * @public
796 */
797type TransitionDefinition = Tween | Spring | Keyframes | Inertia | None | PermissiveTransitionDefinition;
798type TransitionMap = Orchestration & TransitionDefinition & {
799 [key: string]: TransitionDefinition;
800};
801/**
802 * Transition props
803 *
804 * @public
805 */
806type Transition$1 = (Orchestration & Repeat & TransitionDefinition) | (Orchestration & Repeat & TransitionMap);
807type Omit$1<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
808type CSSPropertiesWithoutTransitionOrSingleTransforms = Omit$1<CSSProperties, "transition" | "rotate" | "scale" | "perspective">;
809type SVGTransformAttributes = {
810 attrX?: number;
811 attrY?: number;
812 attrScale?: number;
813};
814type TargetProperties = CSSPropertiesWithoutTransitionOrSingleTransforms & SVGAttributes$1<SVGElement> & SVGTransformAttributes & TransformProperties & CustomStyles & SVGPathProperties & VariableKeyframesDefinition;
815/**
816 * @public
817 */
818type MakeCustomValueType<T> = {
819 [K in keyof T]: T[K] | CustomValueType;
820};
821/**
822 * @public
823 */
824type Target = MakeCustomValueType<TargetProperties>;
825/**
826 * @public
827 */
828type MakeKeyframes<T> = {
829 [K in keyof T]: T[K] | T[K][] | [null, ...T[K][]];
830};
831/**
832 * @public
833 */
834type TargetWithKeyframes = MakeKeyframes<Target>;
835/**
836 * An object that specifies values to animate to. Each value may be set either as
837 * a single value, or an array of values.
838 *
839 * It may also option contain these properties:
840 *
841 * - `transition`: Specifies transitions for all or individual values.
842 * - `transitionEnd`: Specifies values to set when the animation finishes.
843 *
844 * ```jsx
845 * const target = {
846 * x: "0%",
847 * opacity: 0,
848 * transition: { duration: 1 },
849 * transitionEnd: { display: "none" }
850 * }
851 * ```
852 *
853 * @public
854 */
855type TargetAndTransition = TargetWithKeyframes & {
856 transition?: Transition$1;
857 transitionEnd?: Target;
858};
859type TargetResolver = (custom: any, current: Target, velocity: Target) => TargetAndTransition | string;
860/**
861 * @public
862 */
863type Variant = TargetAndTransition | TargetResolver;
864/**
865 * @public
866 */
867type Variants = {
868 [key: string]: Variant;
869};
870/**
871 * @public
872 */
873interface CustomValueType {
874 mix: (from: any, to: any) => (p: number) => number | string;
875 toValue: () => number | string;
876}
877
878interface Point {
879 x: number;
880 y: number;
881}
882interface Axis {
883 min: number;
884 max: number;
885}
886interface Box {
887 x: Axis;
888 y: Axis;
889}
890interface BoundingBox {
891 top: number;
892 right: number;
893 bottom: number;
894 left: number;
895}
896interface AxisDelta {
897 translate: number;
898 scale: number;
899 origin: number;
900 originPoint: number;
901}
902interface Delta {
903 x: AxisDelta;
904 y: AxisDelta;
905}
906type TransformPoint = (point: Point) => Point;
907
908type ReducedMotionConfig = "always" | "never" | "user";
909/**
910 * @public
911 */
912interface MotionConfigContext {
913 /**
914 * Internal, exported only for usage in Framer
915 */
916 transformPagePoint: TransformPoint;
917 /**
918 * Internal. Determines whether this is a static context ie the Framer canvas. If so,
919 * it'll disable all dynamic functionality.
920 */
921 isStatic: boolean;
922 /**
923 * Defines a new default transition for the entire tree.
924 *
925 * @public
926 */
927 transition?: Transition$1;
928 /**
929 * If true, will respect the device prefersReducedMotion setting by switching
930 * transform animations off.
931 *
932 * @public
933 */
934 reducedMotion?: ReducedMotionConfig;
935 /**
936 * A custom `nonce` attribute used when wanting to enforce a Content Security Policy (CSP).
937 * For more details see:
938 * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/style-src#unsafe_inline_styles
939 *
940 * @public
941 */
942 nonce?: string;
943}
944/**
945 * @public
946 */
947declare const MotionConfigContext: React$1.Context<MotionConfigContext>;
948
949declare class NodeStack {
950 lead?: IProjectionNode;
951 prevLead?: IProjectionNode;
952 members: IProjectionNode[];
953 add(node: IProjectionNode): void;
954 remove(node: IProjectionNode): void;
955 relegate(node: IProjectionNode): boolean;
956 promote(node: IProjectionNode, preserveFollowOpacity?: boolean): void;
957 exitAnimationComplete(): void;
958 scheduleRender(): void;
959 /**
960 * Clear any leads that have been removed this render to prevent them from being
961 * used in future animations and to prevent memory leaks
962 */
963 removeLeadSnapshot(): void;
964}
965
966interface WithDepth {
967 depth: number;
968}
969
970declare class FlatTree {
971 private children;
972 private isDirty;
973 add(child: WithDepth): void;
974 remove(child: WithDepth): void;
975 forEach(callback: (child: WithDepth) => void): void;
976}
977
978interface SwitchLayoutGroup {
979 register?: (member: IProjectionNode) => void;
980 deregister?: (member: IProjectionNode) => void;
981}
982type InitialPromotionConfig = {
983 /**
984 * The initial transition to use when the elements in this group mount (and automatically promoted).
985 * Subsequent updates should provide a transition in the promote method.
986 */
987 transition?: Transition$1;
988 /**
989 * If the follow tree should preserve its opacity when the lead is promoted on mount
990 */
991 shouldPreserveFollowOpacity?: (member: IProjectionNode) => boolean;
992};
993type SwitchLayoutGroupContext = SwitchLayoutGroup & InitialPromotionConfig;
994/**
995 * Internal, exported only for usage in Framer
996 */
997declare const SwitchLayoutGroupContext: React$1.Context<SwitchLayoutGroupContext>;
998
999interface Measurements {
1000 animationId: number;
1001 measuredBox: Box;
1002 layoutBox: Box;
1003 latestValues: ResolvedValues;
1004 source: number;
1005}
1006type Phase = "snapshot" | "measure";
1007interface ScrollMeasurements {
1008 animationId: number;
1009 phase: Phase;
1010 offset: Point;
1011 isRoot: boolean;
1012 wasRoot: boolean;
1013}
1014type LayoutEvents = "willUpdate" | "didUpdate" | "beforeMeasure" | "measure" | "projectionUpdate" | "animationStart" | "animationComplete";
1015interface IProjectionNode<I = unknown> {
1016 id: number;
1017 animationId: number;
1018 parent?: IProjectionNode;
1019 relativeParent?: IProjectionNode;
1020 root?: IProjectionNode;
1021 children: Set<IProjectionNode>;
1022 path: IProjectionNode[];
1023 nodes?: FlatTree;
1024 depth: number;
1025 instance: I;
1026 mount: (node: I, isLayoutDirty?: boolean) => void;
1027 unmount: () => void;
1028 options: ProjectionNodeOptions;
1029 setOptions(options: ProjectionNodeOptions): void;
1030 layout?: Measurements;
1031 snapshot?: Measurements;
1032 target?: Box;
1033 relativeTarget?: Box;
1034 relativeTargetOrigin?: Box;
1035 targetDelta?: Delta;
1036 targetWithTransforms?: Box;
1037 scroll?: ScrollMeasurements;
1038 treeScale?: Point;
1039 projectionDelta?: Delta;
1040 projectionDeltaWithTransform?: Delta;
1041 latestValues: ResolvedValues;
1042 isLayoutDirty: boolean;
1043 isProjectionDirty: boolean;
1044 isSharedProjectionDirty: boolean;
1045 isTransformDirty: boolean;
1046 resolvedRelativeTargetAt?: number;
1047 shouldResetTransform: boolean;
1048 prevTransformTemplateValue: string | undefined;
1049 isUpdateBlocked(): boolean;
1050 updateManuallyBlocked: boolean;
1051 updateBlockedByResize: boolean;
1052 blockUpdate(): void;
1053 unblockUpdate(): void;
1054 isUpdating: boolean;
1055 needsReset: boolean;
1056 startUpdate(): void;
1057 willUpdate(notifyListeners?: boolean): void;
1058 didUpdate(): void;
1059 measure(removeTransform?: boolean): Measurements;
1060 measurePageBox(): Box;
1061 updateLayout(): void;
1062 updateSnapshot(): void;
1063 clearSnapshot(): void;
1064 updateScroll(phase?: Phase): void;
1065 scheduleUpdateProjection(): void;
1066 scheduleCheckAfterUnmount(): void;
1067 checkUpdateFailed(): void;
1068 sharedNodes: Map<string, NodeStack>;
1069 registerSharedNode(id: string, node: IProjectionNode): void;
1070 getStack(): NodeStack | undefined;
1071 isVisible: boolean;
1072 hide(): void;
1073 show(): void;
1074 scheduleRender(notifyAll?: boolean): void;
1075 getClosestProjectingParent(): IProjectionNode | undefined;
1076 setTargetDelta(delta: Delta): void;
1077 resetTransform(): void;
1078 resetSkewAndRotation(): void;
1079 applyTransform(box: Box, transformOnly?: boolean): Box;
1080 resolveTargetDelta(force?: boolean): void;
1081 calcProjection(): void;
1082 getProjectionStyles(styleProp?: MotionStyle): MotionStyle | undefined;
1083 clearMeasurements(): void;
1084 resetTree(): void;
1085 isProjecting(): boolean;
1086 animationValues?: ResolvedValues;
1087 currentAnimation?: AnimationPlaybackControls;
1088 isTreeAnimating?: boolean;
1089 isAnimationBlocked?: boolean;
1090 isTreeAnimationBlocked: () => boolean;
1091 setAnimationOrigin(delta: Delta): void;
1092 startAnimation(transition: Transition$1): void;
1093 finishAnimation(): void;
1094 hasCheckedOptimisedAppear: boolean;
1095 isLead(): boolean;
1096 promote(options?: {
1097 needsReset?: boolean;
1098 transition?: Transition$1;
1099 preserveFollowOpacity?: boolean;
1100 }): void;
1101 relegate(): boolean;
1102 resumeFrom?: IProjectionNode;
1103 resumingFrom?: IProjectionNode;
1104 isPresent?: boolean;
1105 addEventListener(name: LayoutEvents, handler: any): VoidFunction;
1106 notifyListeners(name: LayoutEvents, ...args: any): void;
1107 hasListeners(name: LayoutEvents): boolean;
1108 hasTreeAnimated: boolean;
1109 preserveOpacity?: boolean;
1110}
1111interface ProjectionNodeOptions {
1112 animate?: boolean;
1113 layoutScroll?: boolean;
1114 layoutRoot?: boolean;
1115 alwaysMeasureLayout?: boolean;
1116 onExitComplete?: VoidFunction;
1117 animationType?: "size" | "position" | "both" | "preserve-aspect";
1118 layoutId?: string;
1119 layout?: boolean | string;
1120 visualElement?: VisualElement;
1121 crossfade?: boolean;
1122 transition?: Transition$1;
1123 initialPromotionConfig?: InitialPromotionConfig;
1124}
1125
1126type AnimationType = "animate" | "whileHover" | "whileTap" | "whileDrag" | "whileFocus" | "whileInView" | "exit";
1127
1128type VisualElementAnimationOptions = {
1129 delay?: number;
1130 transitionOverride?: Transition$1;
1131 custom?: any;
1132 type?: AnimationType;
1133};
1134
1135interface AnimationState$1 {
1136 animateChanges: (type?: AnimationType) => Promise<any>;
1137 setActive: (type: AnimationType, isActive: boolean, options?: VisualElementAnimationOptions) => Promise<any>;
1138 setAnimateFunction: (fn: any) => void;
1139 getState: () => {
1140 [key: string]: AnimationTypeState;
1141 };
1142 reset: () => void;
1143}
1144interface AnimationTypeState {
1145 isActive: boolean;
1146 protectedKeys: {
1147 [key: string]: true;
1148 };
1149 needsAnimating: {
1150 [key: string]: boolean;
1151 };
1152 prevResolvedValues: {
1153 [key: string]: any;
1154 };
1155 prevProp?: VariantLabels | TargetAndTransition;
1156}
1157
1158/**
1159 * @public
1160 */
1161interface PresenceContextProps {
1162 id: string;
1163 isPresent: boolean;
1164 register: (id: string | number) => () => void;
1165 onExitComplete?: (id: string | number) => void;
1166 initial?: false | VariantLabels;
1167 custom?: any;
1168}
1169/**
1170 * @public
1171 */
1172declare const PresenceContext: React$1.Context<PresenceContextProps | null>;
1173
1174type UnresolvedKeyframes<T extends string | number> = Array<T | null>;
1175type ResolvedKeyframes<T extends string | number> = Array<T>;
1176type OnKeyframesResolved<T extends string | number> = (resolvedKeyframes: ResolvedKeyframes<T>, finalKeyframe: T) => void;
1177declare class KeyframeResolver<T extends string | number = any> {
1178 name?: string;
1179 element?: VisualElement<any>;
1180 finalKeyframe?: T;
1181 suspendedScrollY?: number;
1182 protected unresolvedKeyframes: UnresolvedKeyframes<string | number>;
1183 private motionValue?;
1184 private onComplete;
1185 /**
1186 * Track whether this resolver has completed. Once complete, it never
1187 * needs to attempt keyframe resolution again.
1188 */
1189 private isComplete;
1190 /**
1191 * Track whether this resolver is async. If it is, it'll be added to the
1192 * resolver queue and flushed in the next frame. Resolvers that aren't going
1193 * to trigger read/write thrashing don't need to be async.
1194 */
1195 private isAsync;
1196 /**
1197 * Track whether this resolver needs to perform a measurement
1198 * to resolve its keyframes.
1199 */
1200 needsMeasurement: boolean;
1201 /**
1202 * Track whether this resolver is currently scheduled to resolve
1203 * to allow it to be cancelled and resumed externally.
1204 */
1205 isScheduled: boolean;
1206 constructor(unresolvedKeyframes: UnresolvedKeyframes<string | number>, onComplete: OnKeyframesResolved<T>, name?: string, motionValue?: MotionValue<T>, element?: VisualElement<any>, isAsync?: boolean);
1207 scheduleResolve(): void;
1208 readKeyframes(): void;
1209 setFinalKeyframe(): void;
1210 measureInitialState(): void;
1211 renderEndStyles(): void;
1212 measureEndState(): void;
1213 complete(): void;
1214 cancel(): void;
1215 resume(): void;
1216}
1217
1218/**
1219 * A VisualElement is an imperative abstraction around UI elements such as
1220 * HTMLElement, SVGElement, Three.Object3D etc.
1221 */
1222declare abstract class VisualElement<Instance = unknown, RenderState = unknown, Options extends {} = {}> {
1223 /**
1224 * VisualElements are arranged in trees mirroring that of the React tree.
1225 * Each type of VisualElement has a unique name, to detect when we're crossing
1226 * type boundaries within that tree.
1227 */
1228 abstract type: string;
1229 /**
1230 * An `Array.sort` compatible function that will compare two Instances and
1231 * compare their respective positions within the tree.
1232 */
1233 abstract sortInstanceNodePosition(a: Instance, b: Instance): number;
1234 /**
1235 * Measure the viewport-relative bounding box of the Instance.
1236 */
1237 abstract measureInstanceViewportBox(instance: Instance, props: MotionProps & Partial<MotionConfigContext>): Box;
1238 /**
1239 * When a value has been removed from all animation props we need to
1240 * pick a target to animate back to. For instance, for HTMLElements
1241 * we can look in the style prop.
1242 */
1243 abstract getBaseTargetFromProps(props: MotionProps, key: string): string | number | undefined | MotionValue;
1244 /**
1245 * When we first animate to a value we need to animate it *from* a value.
1246 * Often this have been specified via the initial prop but it might be
1247 * that the value needs to be read from the Instance.
1248 */
1249 abstract readValueFromInstance(instance: Instance, key: string, options: Options): string | number | null | undefined;
1250 /**
1251 * When a value has been removed from the VisualElement we use this to remove
1252 * it from the inherting class' unique render state.
1253 */
1254 abstract removeValueFromRenderState(key: string, renderState: RenderState): void;
1255 /**
1256 * Run before a React or VisualElement render, builds the latest motion
1257 * values into an Instance-specific format. For example, HTMLVisualElement
1258 * will use this step to build `style` and `var` values.
1259 */
1260 abstract build(renderState: RenderState, latestValues: ResolvedValues, props: MotionProps): void;
1261 /**
1262 * Apply the built values to the Instance. For example, HTMLElements will have
1263 * styles applied via `setProperty` and the style attribute, whereas SVGElements
1264 * will have values applied to attributes.
1265 */
1266 abstract renderInstance(instance: Instance, renderState: RenderState, styleProp?: MotionStyle, projection?: IProjectionNode): void;
1267 /**
1268 * If true, will-change will be applied to the element. Only HTMLVisualElements
1269 * currently support this.
1270 */
1271 applyWillChange: boolean;
1272 /**
1273 * If the component child is provided as a motion value, handle subscriptions
1274 * with the renderer-specific VisualElement.
1275 */
1276 handleChildMotionValue?(): void;
1277 /**
1278 * This method takes React props and returns found MotionValues. For example, HTML
1279 * MotionValues will be found within the style prop, whereas for Three.js within attribute arrays.
1280 *
1281 * This isn't an abstract method as it needs calling in the constructor, but it is
1282 * intended to be one.
1283 */
1284 scrapeMotionValuesFromProps(_props: MotionProps, _prevProps: MotionProps, _visualElement: VisualElement): {
1285 [key: string]: MotionValue | string | number;
1286 };
1287 /**
1288 * A reference to the current underlying Instance, e.g. a HTMLElement
1289 * or Three.Mesh etc.
1290 */
1291 current: Instance | null;
1292 /**
1293 * A reference to the parent VisualElement (if exists).
1294 */
1295 parent: VisualElement | undefined;
1296 /**
1297 * A set containing references to this VisualElement's children.
1298 */
1299 children: Set<VisualElement<unknown, unknown, {}>>;
1300 /**
1301 * The depth of this VisualElement within the overall VisualElement tree.
1302 */
1303 depth: number;
1304 /**
1305 * The current render state of this VisualElement. Defined by inherting VisualElements.
1306 */
1307 renderState: RenderState;
1308 /**
1309 * An object containing the latest static values for each of this VisualElement's
1310 * MotionValues.
1311 */
1312 latestValues: ResolvedValues;
1313 /**
1314 * Determine what role this visual element should take in the variant tree.
1315 */
1316 isVariantNode: boolean;
1317 isControllingVariants: boolean;
1318 /**
1319 * If this component is part of the variant tree, it should track
1320 * any children that are also part of the tree. This is essentially
1321 * a shadow tree to simplify logic around how to stagger over children.
1322 */
1323 variantChildren?: Set<VisualElement>;
1324 /**
1325 * Decides whether this VisualElement should animate in reduced motion
1326 * mode.
1327 *
1328 * TODO: This is currently set on every individual VisualElement but feels
1329 * like it could be set globally.
1330 */
1331 shouldReduceMotion: boolean | null;
1332 /**
1333 * Normally, if a component is controlled by a parent's variants, it can
1334 * rely on that ancestor to trigger animations further down the tree.
1335 * However, if a component is created after its parent is mounted, the parent
1336 * won't trigger that mount animation so the child needs to.
1337 *
1338 * TODO: This might be better replaced with a method isParentMounted
1339 */
1340 manuallyAnimateOnMount: boolean;
1341 /**
1342 * This can be set by AnimatePresence to force components that mount
1343 * at the same time as it to mount as if they have initial={false} set.
1344 */
1345 blockInitialAnimation: boolean;
1346 /**
1347 * A reference to this VisualElement's projection node, used in layout animations.
1348 */
1349 projection?: IProjectionNode;
1350 /**
1351 * A map of all motion values attached to this visual element. Motion
1352 * values are source of truth for any given animated value. A motion
1353 * value might be provided externally by the component via props.
1354 */
1355 values: Map<string, MotionValue<any>>;
1356 /**
1357 * The AnimationState, this is hydrated by the animation Feature.
1358 */
1359 animationState?: AnimationState$1;
1360 KeyframeResolver: typeof KeyframeResolver;
1361 /**
1362 * The options used to create this VisualElement. The Options type is defined
1363 * by the inheriting VisualElement and is passed straight through to the render functions.
1364 */
1365 readonly options: Options;
1366 /**
1367 * A reference to the latest props provided to the VisualElement's host React component.
1368 */
1369 props: MotionProps;
1370 prevProps?: MotionProps;
1371 presenceContext: PresenceContextProps | null;
1372 prevPresenceContext?: PresenceContextProps | null;
1373 /**
1374 * Cleanup functions for active features (hover/tap/exit etc)
1375 */
1376 private features;
1377 /**
1378 * A map of every subscription that binds the provided or generated
1379 * motion values onChange listeners to this visual element.
1380 */
1381 private valueSubscriptions;
1382 /**
1383 * A reference to the ReducedMotionConfig passed to the VisualElement's host React component.
1384 */
1385 private reducedMotionConfig;
1386 /**
1387 * On mount, this will be hydrated with a callback to disconnect
1388 * this visual element from its parent on unmount.
1389 */
1390 private removeFromVariantTree;
1391 /**
1392 * A reference to the previously-provided motion values as returned
1393 * from scrapeMotionValuesFromProps. We use the keys in here to determine
1394 * if any motion values need to be removed after props are updated.
1395 */
1396 private prevMotionValues;
1397 /**
1398 * When values are removed from all animation props we need to search
1399 * for a fallback value to animate to. These values are tracked in baseTarget.
1400 */
1401 private baseTarget;
1402 /**
1403 * Create an object of the values we initially animated from (if initial prop present).
1404 */
1405 private initialValues;
1406 /**
1407 * An object containing a SubscriptionManager for each active event.
1408 */
1409 private events;
1410 /**
1411 * An object containing an unsubscribe function for each prop event subscription.
1412 * For example, every "Update" event can have multiple subscribers via
1413 * VisualElement.on(), but only one of those can be defined via the onUpdate prop.
1414 */
1415 private propEventSubscriptions;
1416 constructor({ parent, props, presenceContext, reducedMotionConfig, blockInitialAnimation, visualState, }: VisualElementOptions<Instance, RenderState>, options?: Options);
1417 mount(instance: Instance): void;
1418 unmount(): void;
1419 private bindToMotionValue;
1420 sortNodePosition(other: VisualElement<Instance>): number;
1421 updateFeatures(): void;
1422 notifyUpdate: () => void;
1423 triggerBuild(): void;
1424 render: () => void;
1425 private renderScheduledAt;
1426 scheduleRender: () => void;
1427 /**
1428 * Measure the current viewport box with or without transforms.
1429 * Only measures axis-aligned boxes, rotate and skew must be manually
1430 * removed with a re-render to work.
1431 */
1432 measureViewportBox(): Box;
1433 getStaticValue(key: string): string | number;
1434 setStaticValue(key: string, value: string | number): void;
1435 /**
1436 * Update the provided props. Ensure any newly-added motion values are
1437 * added to our map, old ones removed, and listeners updated.
1438 */
1439 update(props: MotionProps, presenceContext: PresenceContextProps | null): void;
1440 getProps(): MotionProps;
1441 /**
1442 * Returns the variant definition with a given name.
1443 */
1444 getVariant(name: string): Variant | undefined;
1445 /**
1446 * Returns the defined default transition on this component.
1447 */
1448 getDefaultTransition(): Transition$1 | undefined;
1449 getTransformPagePoint(): any;
1450 getClosestVariantNode(): VisualElement | undefined;
1451 /**
1452 * Add a child visual element to our set of children.
1453 */
1454 addVariantChild(child: VisualElement): (() => boolean) | undefined;
1455 /**
1456 * Add a motion value and bind it to this visual element.
1457 */
1458 addValue(key: string, value: MotionValue): void;
1459 /**
1460 * Remove a motion value and unbind any active subscriptions.
1461 */
1462 removeValue(key: string): void;
1463 /**
1464 * Check whether we have a motion value for this key
1465 */
1466 hasValue(key: string): boolean;
1467 /**
1468 * Get a motion value for this key. If called with a default
1469 * value, we'll create one if none exists.
1470 */
1471 getValue(key: string): MotionValue | undefined;
1472 getValue(key: string, defaultValue: string | number | null): MotionValue;
1473 /**
1474 * If we're trying to animate to a previously unencountered value,
1475 * we need to check for it in our state and as a last resort read it
1476 * directly from the instance (which might have performance implications).
1477 */
1478 readValue(key: string, target?: string | number | null): any;
1479 /**
1480 * Set the base target to later animate back to. This is currently
1481 * only hydrated on creation and when we first read a value.
1482 */
1483 setBaseTarget(key: string, value: string | number): void;
1484 /**
1485 * Find the base target for a value thats been removed from all animation
1486 * props.
1487 */
1488 getBaseTarget(key: string): ResolvedValues[string] | undefined | null;
1489 on<EventName extends keyof VisualElementEventCallbacks>(eventName: EventName, callback: VisualElementEventCallbacks[EventName]): VoidFunction;
1490 notify<EventName extends keyof VisualElementEventCallbacks>(eventName: EventName, ...args: any): void;
1491}
1492
1493/**
1494 * An update function. It accepts a timestamp used to advance the animation.
1495 */
1496type Update = (timestamp: number) => void;
1497/**
1498 * Drivers accept a update function and call it at an interval. This interval
1499 * could be a synchronous loop, a setInterval, or tied to the device's framerate.
1500 */
1501interface DriverControls {
1502 start: () => void;
1503 stop: () => void;
1504 now: () => number;
1505}
1506type Driver = (update: Update) => DriverControls;
1507
1508interface SVGAttributes {
1509 accentHeight?: number | string | undefined;
1510 accumulate?: "none" | "sum" | undefined;
1511 additive?: "replace" | "sum" | undefined;
1512 alignmentBaseline?: "auto" | "baseline" | "before-edge" | "text-before-edge" | "middle" | "central" | "after-edge" | "text-after-edge" | "ideographic" | "alphabetic" | "hanging" | "mathematical" | "inherit" | undefined;
1513 allowReorder?: "no" | "yes" | undefined;
1514 alphabetic?: number | string | undefined;
1515 amplitude?: number | string | undefined;
1516 arabicForm?: "initial" | "medial" | "terminal" | "isolated" | undefined;
1517 ascent?: number | string | undefined;
1518 attributeName?: string | undefined;
1519 attributeType?: string | undefined;
1520 autoReverse?: boolean | undefined;
1521 azimuth?: number | string | undefined;
1522 baseFrequency?: number | string | undefined;
1523 baselineShift?: number | string | undefined;
1524 baseProfile?: number | string | undefined;
1525 bbox?: number | string | undefined;
1526 begin?: number | string | undefined;
1527 bias?: number | string | undefined;
1528 by?: number | string | undefined;
1529 calcMode?: number | string | undefined;
1530 capHeight?: number | string | undefined;
1531 clip?: number | string | undefined;
1532 clipPath?: string | undefined;
1533 clipPathUnits?: number | string | undefined;
1534 clipRule?: number | string | undefined;
1535 colorInterpolation?: number | string | undefined;
1536 colorInterpolationFilters?: "auto" | "sRGB" | "linearRGB" | "inherit" | undefined;
1537 colorProfile?: number | string | undefined;
1538 colorRendering?: number | string | undefined;
1539 contentScriptType?: number | string | undefined;
1540 contentStyleType?: number | string | undefined;
1541 cursor?: number | string | undefined;
1542 cx?: number | string | undefined;
1543 cy?: number | string | undefined;
1544 d?: string | undefined;
1545 decelerate?: number | string | undefined;
1546 descent?: number | string | undefined;
1547 diffuseConstant?: number | string | undefined;
1548 direction?: number | string | undefined;
1549 display?: number | string | undefined;
1550 divisor?: number | string | undefined;
1551 dominantBaseline?: number | string | undefined;
1552 dur?: number | string | undefined;
1553 dx?: number | string | undefined;
1554 dy?: number | string | undefined;
1555 edgeMode?: number | string | undefined;
1556 elevation?: number | string | undefined;
1557 enableBackground?: number | string | undefined;
1558 end?: number | string | undefined;
1559 exponent?: number | string | undefined;
1560 externalResourcesRequired?: boolean | undefined;
1561 fill?: string | undefined;
1562 fillOpacity?: number | string | undefined;
1563 fillRule?: "nonzero" | "evenodd" | "inherit" | undefined;
1564 filter?: string | undefined;
1565 filterRes?: number | string | undefined;
1566 filterUnits?: number | string | undefined;
1567 floodColor?: number | string | undefined;
1568 floodOpacity?: number | string | undefined;
1569 focusable?: boolean | "auto" | undefined;
1570 fontFamily?: string | undefined;
1571 fontSize?: number | string | undefined;
1572 fontSizeAdjust?: number | string | undefined;
1573 fontStretch?: number | string | undefined;
1574 fontStyle?: number | string | undefined;
1575 fontVariant?: number | string | undefined;
1576 fontWeight?: number | string | undefined;
1577 format?: number | string | undefined;
1578 fr?: number | string | undefined;
1579 from?: number | string | undefined;
1580 fx?: number | string | undefined;
1581 fy?: number | string | undefined;
1582 g1?: number | string | undefined;
1583 g2?: number | string | undefined;
1584 glyphName?: number | string | undefined;
1585 glyphOrientationHorizontal?: number | string | undefined;
1586 glyphOrientationVertical?: number | string | undefined;
1587 glyphRef?: number | string | undefined;
1588 gradientTransform?: string | undefined;
1589 gradientUnits?: string | undefined;
1590 hanging?: number | string | undefined;
1591 horizAdvX?: number | string | undefined;
1592 horizOriginX?: number | string | undefined;
1593 href?: string | undefined;
1594 ideographic?: number | string | undefined;
1595 imageRendering?: number | string | undefined;
1596 in2?: number | string | undefined;
1597 in?: string | undefined;
1598 intercept?: number | string | undefined;
1599 k1?: number | string | undefined;
1600 k2?: number | string | undefined;
1601 k3?: number | string | undefined;
1602 k4?: number | string | undefined;
1603 k?: number | string | undefined;
1604 kernelMatrix?: number | string | undefined;
1605 kernelUnitLength?: number | string | undefined;
1606 kerning?: number | string | undefined;
1607 keyPoints?: number | string | undefined;
1608 keySplines?: number | string | undefined;
1609 keyTimes?: number | string | undefined;
1610 lengthAdjust?: number | string | undefined;
1611 letterSpacing?: number | string | undefined;
1612 lightingColor?: number | string | undefined;
1613 limitingConeAngle?: number | string | undefined;
1614 local?: number | string | undefined;
1615 markerEnd?: string | undefined;
1616 markerHeight?: number | string | undefined;
1617 markerMid?: string | undefined;
1618 markerStart?: string | undefined;
1619 markerUnits?: number | string | undefined;
1620 markerWidth?: number | string | undefined;
1621 mask?: string | undefined;
1622 maskContentUnits?: number | string | undefined;
1623 maskUnits?: number | string | undefined;
1624 mathematical?: number | string | undefined;
1625 mode?: number | string | undefined;
1626 numOctaves?: number | string | undefined;
1627 offset?: number | string | undefined;
1628 opacity?: number | string | undefined;
1629 operator?: number | string | undefined;
1630 order?: number | string | undefined;
1631 orient?: number | string | undefined;
1632 orientation?: number | string | undefined;
1633 origin?: number | string | undefined;
1634 overflow?: number | string | undefined;
1635 overlinePosition?: number | string | undefined;
1636 overlineThickness?: number | string | undefined;
1637 paintOrder?: number | string | undefined;
1638 panose1?: number | string | undefined;
1639 path?: string | undefined;
1640 pathLength?: number | string | undefined;
1641 patternContentUnits?: string | undefined;
1642 patternTransform?: number | string | undefined;
1643 patternUnits?: string | undefined;
1644 pointerEvents?: number | string | undefined;
1645 points?: string | undefined;
1646 pointsAtX?: number | string | undefined;
1647 pointsAtY?: number | string | undefined;
1648 pointsAtZ?: number | string | undefined;
1649 preserveAlpha?: boolean | undefined;
1650 preserveAspectRatio?: string | undefined;
1651 primitiveUnits?: number | string | undefined;
1652 r?: number | string | undefined;
1653 radius?: number | string | undefined;
1654 refX?: number | string | undefined;
1655 refY?: number | string | undefined;
1656 renderingIntent?: number | string | undefined;
1657 repeatCount?: number | string | undefined;
1658 repeatDur?: number | string | undefined;
1659 requiredExtensions?: number | string | undefined;
1660 requiredFeatures?: number | string | undefined;
1661 restart?: number | string | undefined;
1662 result?: string | undefined;
1663 rotate?: number | string | undefined;
1664 rx?: number | string | undefined;
1665 ry?: number | string | undefined;
1666 scale?: number | string | undefined;
1667 seed?: number | string | undefined;
1668 shapeRendering?: number | string | undefined;
1669 slope?: number | string | undefined;
1670 spacing?: number | string | undefined;
1671 specularConstant?: number | string | undefined;
1672 specularExponent?: number | string | undefined;
1673 speed?: number | string | undefined;
1674 spreadMethod?: string | undefined;
1675 startOffset?: number | string | undefined;
1676 stdDeviation?: number | string | undefined;
1677 stemh?: number | string | undefined;
1678 stemv?: number | string | undefined;
1679 stitchTiles?: number | string | undefined;
1680 stopColor?: string | undefined;
1681 stopOpacity?: number | string | undefined;
1682 strikethroughPosition?: number | string | undefined;
1683 strikethroughThickness?: number | string | undefined;
1684 string?: number | string | undefined;
1685 stroke?: string | undefined;
1686 strokeDasharray?: string | number | undefined;
1687 strokeDashoffset?: string | number | undefined;
1688 strokeLinecap?: "butt" | "round" | "square" | "inherit" | undefined;
1689 strokeLinejoin?: "miter" | "round" | "bevel" | "inherit" | undefined;
1690 strokeMiterlimit?: number | string | undefined;
1691 strokeOpacity?: number | string | undefined;
1692 strokeWidth?: number | string | undefined;
1693 surfaceScale?: number | string | undefined;
1694 systemLanguage?: number | string | undefined;
1695 tableValues?: number | string | undefined;
1696 targetX?: number | string | undefined;
1697 targetY?: number | string | undefined;
1698 textAnchor?: string | undefined;
1699 textDecoration?: number | string | undefined;
1700 textLength?: number | string | undefined;
1701 textRendering?: number | string | undefined;
1702 to?: number | string | undefined;
1703 transform?: string | undefined;
1704 u1?: number | string | undefined;
1705 u2?: number | string | undefined;
1706 underlinePosition?: number | string | undefined;
1707 underlineThickness?: number | string | undefined;
1708 unicode?: number | string | undefined;
1709 unicodeBidi?: number | string | undefined;
1710 unicodeRange?: number | string | undefined;
1711 unitsPerEm?: number | string | undefined;
1712 vAlphabetic?: number | string | undefined;
1713 values?: string | undefined;
1714 vectorEffect?: number | string | undefined;
1715 version?: string | undefined;
1716 vertAdvY?: number | string | undefined;
1717 vertOriginX?: number | string | undefined;
1718 vertOriginY?: number | string | undefined;
1719 vHanging?: number | string | undefined;
1720 vIdeographic?: number | string | undefined;
1721 viewBox?: string | undefined;
1722 viewTarget?: number | string | undefined;
1723 visibility?: number | string | undefined;
1724 vMathematical?: number | string | undefined;
1725 widths?: number | string | undefined;
1726 wordSpacing?: number | string | undefined;
1727 writingMode?: number | string | undefined;
1728 x1?: number | string | undefined;
1729 x2?: number | string | undefined;
1730 x?: number | string | undefined;
1731 xChannelSelector?: string | undefined;
1732 xHeight?: number | string | undefined;
1733 xlinkActuate?: string | undefined;
1734 xlinkArcrole?: string | undefined;
1735 xlinkHref?: string | undefined;
1736 xlinkRole?: string | undefined;
1737 xlinkShow?: string | undefined;
1738 xlinkTitle?: string | undefined;
1739 xlinkType?: string | undefined;
1740 xmlBase?: string | undefined;
1741 xmlLang?: string | undefined;
1742 xmlns?: string | undefined;
1743 xmlnsXlink?: string | undefined;
1744 xmlSpace?: string | undefined;
1745 y1?: number | string | undefined;
1746 y2?: number | string | undefined;
1747 y?: number | string | undefined;
1748 yChannelSelector?: string | undefined;
1749 z?: number | string | undefined;
1750 zoomAndPan?: string | undefined;
1751}
1752
1753interface ProgressTimeline {
1754 currentTime: null | {
1755 value: number;
1756 };
1757 cancel?: VoidFunction;
1758}
1759
1760interface AnimationState<V> {
1761 value: V;
1762 done: boolean;
1763}
1764interface KeyframeGenerator<V> {
1765 calculatedDuration: null | number;
1766 next: (t: number) => AnimationState<V>;
1767}
1768
1769interface AnimationPlaybackLifecycles<V> {
1770 onUpdate?: (latest: V) => void;
1771 onPlay?: () => void;
1772 onComplete?: () => void;
1773 onRepeat?: () => void;
1774 onStop?: () => void;
1775}
1776type GeneratorFactory = (options: ValueAnimationOptions<any>) => KeyframeGenerator<any>;
1777type AnimationGeneratorType = GeneratorFactory | "decay" | "spring" | "keyframes" | "tween" | "inertia";
1778interface Transition extends AnimationPlaybackOptions, Omit<SpringOptions, "keyframes">, Omit<InertiaOptions$1, "keyframes">, KeyframeOptions {
1779 delay?: number;
1780 elapsed?: number;
1781 driver?: Driver;
1782 type?: AnimationGeneratorType;
1783 duration?: number;
1784 autoplay?: boolean;
1785 startTime?: number;
1786}
1787interface ValueAnimationTransition<V = any> extends Transition, AnimationPlaybackLifecycles<V> {
1788}
1789type ResolveKeyframes<V extends string | number> = (keyframes: V[], onComplete: OnKeyframesResolved<V>, name?: string, motionValue?: any) => KeyframeResolver<V>;
1790interface ValueAnimationOptions<V extends string | number = number> extends ValueAnimationTransition {
1791 keyframes: V[];
1792 name?: string;
1793 from?: V;
1794 isGenerator?: boolean;
1795}
1796interface ValueAnimationOptionsWithRenderContext<V extends string | number = number> extends ValueAnimationOptions<V> {
1797 KeyframeResolver?: typeof KeyframeResolver;
1798 motionValue?: MotionValue<V>;
1799 element?: VisualElement;
1800}
1801interface AnimationScope<T = any> {
1802 readonly current: T;
1803 animations: AnimationPlaybackControls[];
1804}
1805type StyleTransitions = {
1806 [K in keyof CSSStyleDeclarationWithTransform]?: Transition;
1807};
1808type SVGPathTransitions = {
1809 [K in keyof SVGPathProperties]: Transition;
1810};
1811type SVGTransitions = {
1812 [K in keyof SVGAttributes]: Transition;
1813};
1814type VariableTransitions = {
1815 [key: `--${string}`]: Transition;
1816};
1817type AnimationOptionsWithValueOverrides<V = any> = StyleTransitions & SVGPathTransitions & SVGTransitions & VariableTransitions & ValueAnimationTransition<V>;
1818interface DynamicAnimationOptions extends Omit<AnimationOptionsWithValueOverrides, "delay"> {
1819 delay?: number | DynamicOption<number>;
1820}
1821type ElementOrSelector = Element | Element[] | NodeListOf<Element> | string;
1822/**
1823 * @public
1824 */
1825interface AnimationPlaybackControls {
1826 time: number;
1827 speed: number;
1828 startTime: number | null;
1829 state?: AnimationPlayState;
1830 duration: number;
1831 stop: () => void;
1832 play: () => void;
1833 pause: () => void;
1834 complete: () => void;
1835 cancel: () => void;
1836 then: (onResolve: VoidFunction, onReject?: VoidFunction) => Promise<void>;
1837 attachTimeline?: (timeline: ProgressTimeline, fallback?: (animation: AnimationPlaybackControls) => VoidFunction) => VoidFunction;
1838}
1839type DynamicOption<T> = (i: number, total: number) => T;
1840interface CSSStyleDeclarationWithTransform extends Omit<CSSStyleDeclaration, "direction" | "transition" | "x" | "y" | "z"> {
1841 x: number | string;
1842 y: number | string;
1843 z: number | string;
1844 rotateX: number | string;
1845 rotateY: number | string;
1846 rotateZ: number | string;
1847 scaleX: number;
1848 scaleY: number;
1849 scaleZ: number;
1850 skewX: number | string;
1851 skewY: number | string;
1852}
1853type ValueKeyframe = string | number;
1854type UnresolvedValueKeyframe = ValueKeyframe | null;
1855type ValueKeyframesDefinition = ValueKeyframe | ValueKeyframe[] | UnresolvedValueKeyframe[];
1856type StyleKeyframesDefinition = {
1857 [K in keyof CSSStyleDeclarationWithTransform]?: ValueKeyframesDefinition;
1858};
1859type SVGKeyframesDefinition = {
1860 [K in keyof SVGAttributes]?: ValueKeyframesDefinition;
1861};
1862type VariableKeyframesDefinition = {
1863 [key: `--${string}`]: ValueKeyframesDefinition;
1864};
1865type SVGPathKeyframesDefinition = {
1866 [K in keyof SVGPathProperties]?: ValueKeyframesDefinition;
1867};
1868type DOMKeyframesDefinition = StyleKeyframesDefinition & SVGKeyframesDefinition & SVGPathKeyframesDefinition & VariableKeyframesDefinition;
1869interface VelocityOptions {
1870 velocity?: number;
1871 restSpeed?: number;
1872 restDelta?: number;
1873}
1874type RepeatType = "loop" | "reverse" | "mirror";
1875interface AnimationPlaybackOptions {
1876 repeat?: number;
1877 repeatType?: RepeatType;
1878 repeatDelay?: number;
1879}
1880interface DurationSpringOptions {
1881 duration?: number;
1882 bounce?: number;
1883}
1884interface SpringOptions extends DurationSpringOptions, VelocityOptions {
1885 stiffness?: number;
1886 damping?: number;
1887 mass?: number;
1888}
1889interface DecayOptions extends VelocityOptions {
1890 keyframes?: number[];
1891 power?: number;
1892 timeConstant?: number;
1893 modifyTarget?: (v: number) => number;
1894}
1895interface InertiaOptions$1 extends DecayOptions {
1896 bounceStiffness?: number;
1897 bounceDamping?: number;
1898 min?: number;
1899 max?: number;
1900}
1901interface KeyframeOptions {
1902 ease?: Easing | Easing[];
1903 times?: number[];
1904}
1905type AnimationDefinition = VariantLabels | TargetAndTransition | TargetResolver;
1906/**
1907 * @public
1908 */
1909interface AnimationControls {
1910 /**
1911 * Starts an animation on all linked components.
1912 *
1913 * @remarks
1914 *
1915 * ```jsx
1916 * controls.start("variantLabel")
1917 * controls.start({
1918 * x: 0,
1919 * transition: { duration: 1 }
1920 * })
1921 * ```
1922 *
1923 * @param definition - Properties or variant label to animate to
1924 * @param transition - Optional `transtion` to apply to a variant
1925 * @returns - A `Promise` that resolves when all animations have completed.
1926 *
1927 * @public
1928 */
1929 start(definition: AnimationDefinition, transitionOverride?: Transition): Promise<any>;
1930 /**
1931 * Instantly set to a set of properties or a variant.
1932 *
1933 * ```jsx
1934 * // With properties
1935 * controls.set({ opacity: 0 })
1936 *
1937 * // With variants
1938 * controls.set("hidden")
1939 * ```
1940 *
1941 * @privateRemarks
1942 * We could perform a similar trick to `.start` where this can be called before mount
1943 * and we maintain a list of of pending actions that get applied on mount. But the
1944 * expectation of `set` is that it happens synchronously and this would be difficult
1945 * to do before any children have even attached themselves. It's also poor practise
1946 * and we should discourage render-synchronous `.start` calls rather than lean into this.
1947 *
1948 * @public
1949 */
1950 set(definition: AnimationDefinition): void;
1951 /**
1952 * Stops animations on all linked components.
1953 *
1954 * ```jsx
1955 * controls.stop()
1956 * ```
1957 *
1958 * @public
1959 */
1960 stop(): void;
1961 mount(): () => void;
1962}
1963
1964/**
1965 * @public
1966 */
1967type Subscriber<T> = (v: T) => void;
1968/**
1969 * @public
1970 */
1971type PassiveEffect<T> = (v: T, safeSetter: (v: T) => void) => void;
1972interface MotionValueEventCallbacks<V> {
1973 animationStart: () => void;
1974 animationComplete: () => void;
1975 animationCancel: () => void;
1976 change: (latestValue: V) => void;
1977 renderRequest: () => void;
1978}
1979interface ResolvedValues$1 {
1980 [key: string]: string | number;
1981}
1982interface Owner {
1983 current: HTMLElement | unknown;
1984 getProps: () => {
1985 onUpdate?: (latest: ResolvedValues$1) => void;
1986 };
1987}
1988interface MotionValueOptions {
1989 owner?: Owner;
1990}
1991/**
1992 * `MotionValue` is used to track the state and velocity of motion values.
1993 *
1994 * @public
1995 */
1996declare class MotionValue<V = any> {
1997 /**
1998 * This will be replaced by the build step with the latest version number.
1999 * When MotionValues are provided to motion components, warn if versions are mixed.
2000 */
2001 version: string;
2002 /**
2003 * If a MotionValue has an owner, it was created internally within Framer Motion
2004 * and therefore has no external listeners. It is therefore safe to animate via WAAPI.
2005 */
2006 owner?: Owner;
2007 /**
2008 * The current state of the `MotionValue`.
2009 */
2010 private current;
2011 /**
2012 * The previous state of the `MotionValue`.
2013 */
2014 private prev;
2015 /**
2016 * The previous state of the `MotionValue` at the end of the previous frame.
2017 */
2018 private prevFrameValue;
2019 /**
2020 * The last time the `MotionValue` was updated.
2021 */
2022 private updatedAt;
2023 /**
2024 * The time `prevFrameValue` was updated.
2025 */
2026 private prevUpdatedAt;
2027 private stopPassiveEffect?;
2028 /**
2029 * A reference to the currently-controlling animation.
2030 */
2031 animation?: AnimationPlaybackControls;
2032 setCurrent(current: V): void;
2033 setPrevFrameValue(prevFrameValue?: V | undefined): void;
2034 /**
2035 * Adds a function that will be notified when the `MotionValue` is updated.
2036 *
2037 * It returns a function that, when called, will cancel the subscription.
2038 *
2039 * When calling `onChange` inside a React component, it should be wrapped with the
2040 * `useEffect` hook. As it returns an unsubscribe function, this should be returned
2041 * from the `useEffect` function to ensure you don't add duplicate subscribers..
2042 *
2043 * ```jsx
2044 * export const MyComponent = () => {
2045 * const x = useMotionValue(0)
2046 * const y = useMotionValue(0)
2047 * const opacity = useMotionValue(1)
2048 *
2049 * useEffect(() => {
2050 * function updateOpacity() {
2051 * const maxXY = Math.max(x.get(), y.get())
2052 * const newOpacity = transform(maxXY, [0, 100], [1, 0])
2053 * opacity.set(newOpacity)
2054 * }
2055 *
2056 * const unsubscribeX = x.on("change", updateOpacity)
2057 * const unsubscribeY = y.on("change", updateOpacity)
2058 *
2059 * return () => {
2060 * unsubscribeX()
2061 * unsubscribeY()
2062 * }
2063 * }, [])
2064 *
2065 * return <motion.div style={{ x }} />
2066 * }
2067 * ```
2068 *
2069 * @param subscriber - A function that receives the latest value.
2070 * @returns A function that, when called, will cancel this subscription.
2071 *
2072 * @deprecated
2073 */
2074 onChange(subscription: Subscriber<V>): () => void;
2075 /**
2076 * An object containing a SubscriptionManager for each active event.
2077 */
2078 private events;
2079 on<EventName extends keyof MotionValueEventCallbacks<V>>(eventName: EventName, callback: MotionValueEventCallbacks<V>[EventName]): VoidFunction;
2080 clearListeners(): void;
2081 /**
2082 * Sets the state of the `MotionValue`.
2083 *
2084 * @remarks
2085 *
2086 * ```jsx
2087 * const x = useMotionValue(0)
2088 * x.set(10)
2089 * ```
2090 *
2091 * @param latest - Latest value to set.
2092 * @param render - Whether to notify render subscribers. Defaults to `true`
2093 *
2094 * @public
2095 */
2096 set(v: V, render?: boolean): void;
2097 setWithVelocity(prev: V, current: V, delta: number): void;
2098 /**
2099 * Set the state of the `MotionValue`, stopping any active animations,
2100 * effects, and resets velocity to `0`.
2101 */
2102 jump(v: V, endAnimation?: boolean): void;
2103 updateAndNotify: (v: V, render?: boolean) => void;
2104 /**
2105 * Returns the latest state of `MotionValue`
2106 *
2107 * @returns - The latest state of `MotionValue`
2108 *
2109 * @public
2110 */
2111 get(): NonNullable<V>;
2112 /**
2113 * @public
2114 */
2115 getPrevious(): V | undefined;
2116 /**
2117 * Returns the latest velocity of `MotionValue`
2118 *
2119 * @returns - The latest velocity of `MotionValue`. Returns `0` if the state is non-numerical.
2120 *
2121 * @public
2122 */
2123 getVelocity(): number;
2124 hasAnimated: boolean;
2125 /**
2126 * Stop the currently active animation.
2127 *
2128 * @public
2129 */
2130 stop(): void;
2131 /**
2132 * Returns `true` if this value is currently animating.
2133 *
2134 * @public
2135 */
2136 isAnimating(): boolean;
2137 private clearAnimation;
2138 /**
2139 * Destroy and clean up subscribers to this `MotionValue`.
2140 *
2141 * The `MotionValue` hooks like `useMotionValue` and `useTransform` automatically
2142 * handle the lifecycle of the returned `MotionValue`, so this method is only necessary if you've manually
2143 * created a `MotionValue` via the `motionValue` function.
2144 *
2145 * @public
2146 */
2147 destroy(): void;
2148}
2149declare function motionValue<V>(init: V, options?: MotionValueOptions): MotionValue<V>;
2150
2151type RefObject<T> = {
2152 current: T | null;
2153};
2154
2155/**
2156 * Passed in to pan event handlers like `onPan` the `PanInfo` object contains
2157 * information about the current state of the tap gesture such as its
2158 * `point`, `delta`, `offset` and `velocity`.
2159 *
2160 * ```jsx
2161 * <motion.div onPan={(event, info) => {
2162 * console.log(info.point.x, info.point.y)
2163 * }} />
2164 * ```
2165 *
2166 * @public
2167 */
2168interface PanInfo {
2169 /**
2170 * Contains `x` and `y` values for the current pan position relative
2171 * to the device or page.
2172 *
2173 * ```jsx
2174 * function onPan(event, info) {
2175 * console.log(info.point.x, info.point.y)
2176 * }
2177 *
2178 * <motion.div onPan={onPan} />
2179 * ```
2180 *
2181 * @public
2182 */
2183 point: Point;
2184 /**
2185 * Contains `x` and `y` values for the distance moved since
2186 * the last event.
2187 *
2188 * ```jsx
2189 * function onPan(event, info) {
2190 * console.log(info.delta.x, info.delta.y)
2191 * }
2192 *
2193 * <motion.div onPan={onPan} />
2194 * ```
2195 *
2196 * @public
2197 */
2198 delta: Point;
2199 /**
2200 * Contains `x` and `y` values for the distance moved from
2201 * the first pan event.
2202 *
2203 * ```jsx
2204 * function onPan(event, info) {
2205 * console.log(info.offset.x, info.offset.y)
2206 * }
2207 *
2208 * <motion.div onPan={onPan} />
2209 * ```
2210 *
2211 * @public
2212 */
2213 offset: Point;
2214 /**
2215 * Contains `x` and `y` values for the current velocity of the pointer, in px/ms.
2216 *
2217 * ```jsx
2218 * function onPan(event, info) {
2219 * console.log(info.velocity.x, info.velocity.y)
2220 * }
2221 *
2222 * <motion.div onPan={onPan} />
2223 * ```
2224 *
2225 * @public
2226 */
2227 velocity: Point;
2228}
2229
2230interface DragControlOptions {
2231 snapToCursor?: boolean;
2232 cursorProgress?: Point;
2233}
2234
2235/**
2236 * Can manually trigger a drag gesture on one or more `drag`-enabled `motion` components.
2237 *
2238 * ```jsx
2239 * const dragControls = useDragControls()
2240 *
2241 * function startDrag(event) {
2242 * dragControls.start(event, { snapToCursor: true })
2243 * }
2244 *
2245 * return (
2246 * <>
2247 * <div onPointerDown={startDrag} />
2248 * <motion.div drag="x" dragControls={dragControls} />
2249 * </>
2250 * )
2251 * ```
2252 *
2253 * @public
2254 */
2255declare class DragControls {
2256 private componentControls;
2257 /**
2258 * Start a drag gesture on every `motion` component that has this set of drag controls
2259 * passed into it via the `dragControls` prop.
2260 *
2261 * ```jsx
2262 * dragControls.start(e, {
2263 * snapToCursor: true
2264 * })
2265 * ```
2266 *
2267 * @param event - PointerEvent
2268 * @param options - Options
2269 *
2270 * @public
2271 */
2272 start(event: React$1.PointerEvent | PointerEvent, options?: DragControlOptions): void;
2273}
2274/**
2275 * Usually, dragging is initiated by pressing down on a `motion` component with a `drag` prop
2276 * and moving it. For some use-cases, for instance clicking at an arbitrary point on a video scrubber, we
2277 * might want to initiate that dragging from a different component than the draggable one.
2278 *
2279 * By creating a `dragControls` using the `useDragControls` hook, we can pass this into
2280 * the draggable component's `dragControls` prop. It exposes a `start` method
2281 * that can start dragging from pointer events on other components.
2282 *
2283 * ```jsx
2284 * const dragControls = useDragControls()
2285 *
2286 * function startDrag(event) {
2287 * dragControls.start(event, { snapToCursor: true })
2288 * }
2289 *
2290 * return (
2291 * <>
2292 * <div onPointerDown={startDrag} />
2293 * <motion.div drag="x" dragControls={dragControls} />
2294 * </>
2295 * )
2296 * ```
2297 *
2298 * @public
2299 */
2300declare function useDragControls(): DragControls;
2301
2302type DragElastic = boolean | number | Partial<BoundingBox>;
2303/**
2304 * @public
2305 */
2306interface DragHandlers {
2307 /**
2308 * Callback function that fires when dragging starts.
2309 *
2310 * ```jsx
2311 * <motion.div
2312 * drag
2313 * onDragStart={
2314 * (event, info) => console.log(info.point.x, info.point.y)
2315 * }
2316 * />
2317 * ```
2318 *
2319 * @public
2320 */
2321 onDragStart?(event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo): void;
2322 /**
2323 * Callback function that fires when dragging ends.
2324 *
2325 * ```jsx
2326 * <motion.div
2327 * drag
2328 * onDragEnd={
2329 * (event, info) => console.log(info.point.x, info.point.y)
2330 * }
2331 * />
2332 * ```
2333 *
2334 * @public
2335 */
2336 onDragEnd?(event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo): void;
2337 /**
2338 * Callback function that fires when the component is dragged.
2339 *
2340 * ```jsx
2341 * <motion.div
2342 * drag
2343 * onDrag={
2344 * (event, info) => console.log(info.point.x, info.point.y)
2345 * }
2346 * />
2347 * ```
2348 *
2349 * @public
2350 */
2351 onDrag?(event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo): void;
2352 /**
2353 * Callback function that fires a drag direction is determined.
2354 *
2355 * ```jsx
2356 * <motion.div
2357 * drag
2358 * dragDirectionLock
2359 * onDirectionLock={axis => console.log(axis)}
2360 * />
2361 * ```
2362 *
2363 * @public
2364 */
2365 onDirectionLock?(axis: "x" | "y"): void;
2366 /**
2367 * Callback function that fires when drag momentum/bounce transition finishes.
2368 *
2369 * ```jsx
2370 * <motion.div
2371 * drag
2372 * onDragTransitionEnd={() => console.log('Drag transition complete')}
2373 * />
2374 * ```
2375 *
2376 * @public
2377 */
2378 onDragTransitionEnd?(): void;
2379}
2380/**
2381 * @public
2382 */
2383type InertiaOptions = Partial<Omit<Inertia, "velocity" | "type">>;
2384/**
2385 * @public
2386 */
2387interface DraggableProps extends DragHandlers {
2388 /**
2389 * Enable dragging for this element. Set to `false` by default.
2390 * Set `true` to drag in both directions.
2391 * Set `"x"` or `"y"` to only drag in a specific direction.
2392 *
2393 * ```jsx
2394 * <motion.div drag="x" />
2395 * ```
2396 */
2397 drag?: boolean | "x" | "y";
2398 /**
2399 * Properties or variant label to animate to while the drag gesture is recognised.
2400 *
2401 * ```jsx
2402 * <motion.div whileDrag={{ scale: 1.2 }} />
2403 * ```
2404 */
2405 whileDrag?: VariantLabels | TargetAndTransition;
2406 /**
2407 * If `true`, this will lock dragging to the initially-detected direction. Defaults to `false`.
2408 *
2409 * ```jsx
2410 * <motion.div drag dragDirectionLock />
2411 * ```
2412 */
2413 dragDirectionLock?: boolean;
2414 /**
2415 * Allows drag gesture propagation to child components. Set to `false` by
2416 * default.
2417 *
2418 * ```jsx
2419 * <motion.div drag="x" dragPropagation />
2420 * ```
2421 */
2422 dragPropagation?: boolean;
2423 /**
2424 * Applies constraints on the permitted draggable area.
2425 *
2426 * It can accept an object of optional `top`, `left`, `right`, and `bottom` values, measured in pixels.
2427 * This will define a distance the named edge of the draggable component.
2428 *
2429 * Alternatively, it can accept a `ref` to another component created with React's `useRef` hook.
2430 * This `ref` should be passed both to the draggable component's `dragConstraints` prop, and the `ref`
2431 * of the component you want to use as constraints.
2432 *
2433 * ```jsx
2434 * // In pixels
2435 * <motion.div
2436 * drag="x"
2437 * dragConstraints={{ left: 0, right: 300 }}
2438 * />
2439 *
2440 * // As a ref to another component
2441 * const MyComponent = () => {
2442 * const constraintsRef = useRef(null)
2443 *
2444 * return (
2445 * <motion.div ref={constraintsRef}>
2446 * <motion.div drag dragConstraints={constraintsRef} />
2447 * </motion.div>
2448 * )
2449 * }
2450 * ```
2451 */
2452 dragConstraints?: false | Partial<BoundingBox> | RefObject<Element>;
2453 /**
2454 * The degree of movement allowed outside constraints. 0 = no movement, 1 =
2455 * full movement.
2456 *
2457 * Set to `0.5` by default. Can also be set as `false` to disable movement.
2458 *
2459 * By passing an object of `top`/`right`/`bottom`/`left`, individual values can be set
2460 * per constraint. Any missing values will be set to `0`.
2461 *
2462 * ```jsx
2463 * <motion.div
2464 * drag
2465 * dragConstraints={{ left: 0, right: 300 }}
2466 * dragElastic={0.2}
2467 * />
2468 * ```
2469 */
2470 dragElastic?: DragElastic;
2471 /**
2472 * Apply momentum from the pan gesture to the component when dragging
2473 * finishes. Set to `true` by default.
2474 *
2475 * ```jsx
2476 * <motion.div
2477 * drag
2478 * dragConstraints={{ left: 0, right: 300 }}
2479 * dragMomentum={false}
2480 * />
2481 * ```
2482 */
2483 dragMomentum?: boolean;
2484 /**
2485 * Allows you to change dragging inertia parameters.
2486 * When releasing a draggable Frame, an animation with type `inertia` starts. The animation is based on your dragging velocity. This property allows you to customize it.
2487 * See {@link https://framer.com/api/animation/#inertia | Inertia} for all properties you can use.
2488 *
2489 * ```jsx
2490 * <motion.div
2491 * drag
2492 * dragTransition={{ bounceStiffness: 600, bounceDamping: 10 }}
2493 * />
2494 * ```
2495 */
2496 dragTransition?: InertiaOptions;
2497 /**
2498 * Usually, dragging is initiated by pressing down on a component and moving it. For some
2499 * use-cases, for instance clicking at an arbitrary point on a video scrubber, we
2500 * might want to initiate dragging from a different component than the draggable one.
2501 *
2502 * By creating a `dragControls` using the `useDragControls` hook, we can pass this into
2503 * the draggable component's `dragControls` prop. It exposes a `start` method
2504 * that can start dragging from pointer events on other components.
2505 *
2506 * ```jsx
2507 * const dragControls = useDragControls()
2508 *
2509 * function startDrag(event) {
2510 * dragControls.start(event, { snapToCursor: true })
2511 * }
2512 *
2513 * return (
2514 * <>
2515 * <div onPointerDown={startDrag} />
2516 * <motion.div drag="x" dragControls={dragControls} />
2517 * </>
2518 * )
2519 * ```
2520 */
2521 dragControls?: DragControls;
2522 /**
2523 * If true, element will snap back to its origin when dragging ends.
2524 *
2525 * Enabling this is the equivalent of setting all `dragConstraints` axes to `0`
2526 * with `dragElastic={1}`, but when used together `dragConstraints` can define
2527 * a wider draggable area and `dragSnapToOrigin` will ensure the element
2528 * animates back to its origin on release.
2529 */
2530 dragSnapToOrigin?: boolean;
2531 /**
2532 * By default, if `drag` is defined on a component then an event listener will be attached
2533 * to automatically initiate dragging when a user presses down on it.
2534 *
2535 * By setting `dragListener` to `false`, this event listener will not be created.
2536 *
2537 * ```jsx
2538 * const dragControls = useDragControls()
2539 *
2540 * function startDrag(event) {
2541 * dragControls.start(event, { snapToCursor: true })
2542 * }
2543 *
2544 * return (
2545 * <>
2546 * <div onPointerDown={startDrag} />
2547 * <motion.div
2548 * drag="x"
2549 * dragControls={dragControls}
2550 * dragListener={false}
2551 * />
2552 * </>
2553 * )
2554 * ```
2555 */
2556 dragListener?: boolean;
2557 /**
2558 * If `dragConstraints` is set to a React ref, this callback will call with the measured drag constraints.
2559 *
2560 * @public
2561 */
2562 onMeasureDragConstraints?: (constraints: BoundingBox) => BoundingBox | void;
2563 /**
2564 * Usually, dragging uses the layout project engine, and applies transforms to the underlying VisualElement.
2565 * Passing MotionValues as _dragX and _dragY instead applies drag updates to these motion values.
2566 * This allows you to manually control how updates from a drag gesture on an element is applied.
2567 *
2568 * @public
2569 */
2570 _dragX?: MotionValue<number>;
2571 /**
2572 * Usually, dragging uses the layout project engine, and applies transforms to the underlying VisualElement.
2573 * Passing MotionValues as _dragX and _dragY instead applies drag updates to these motion values.
2574 * This allows you to manually control how updates from a drag gesture on an element is applied.
2575 *
2576 * @public
2577 */
2578 _dragY?: MotionValue<number>;
2579}
2580
2581/**
2582 * @public
2583 */
2584interface LayoutProps {
2585 /**
2586 * If `true`, this component will automatically animate to its new position when
2587 * its layout changes.
2588 *
2589 * ```jsx
2590 * <motion.div layout />
2591 * ```
2592 *
2593 * This will perform a layout animation using performant transforms. Part of this technique
2594 * involved animating an element's scale. This can introduce visual distortions on children,
2595 * `boxShadow` and `borderRadius`.
2596 *
2597 * To correct distortion on immediate children, add `layout` to those too.
2598 *
2599 * `boxShadow` and `borderRadius` will automatically be corrected if they are already being
2600 * animated on this component. Otherwise, set them directly via the `initial` prop.
2601 *
2602 * If `layout` is set to `"position"`, the size of the component will change instantly and
2603 * only its position will animate.
2604 *
2605 * If `layout` is set to `"size"`, the position of the component will change instantly and
2606 * only its size will animate.
2607 *
2608 * If `layout` is set to `"preserve-aspect"`, the component will animate size & position if
2609 * the aspect ratio remains the same between renders, and just position if the ratio changes.
2610 *
2611 * @public
2612 */
2613 layout?: boolean | "position" | "size" | "preserve-aspect";
2614 /**
2615 * Enable shared layout transitions between different components with the same `layoutId`.
2616 *
2617 * When a component with a layoutId is removed from the React tree, and then
2618 * added elsewhere, it will visually animate from the previous component's bounding box
2619 * and its latest animated values.
2620 *
2621 * ```jsx
2622 * {items.map(item => (
2623 * <motion.li layout>
2624 * {item.name}
2625 * {item.isSelected && <motion.div layoutId="underline" />}
2626 * </motion.li>
2627 * ))}
2628 * ```
2629 *
2630 * If the previous component remains in the tree it will crossfade with the new component.
2631 *
2632 * @public
2633 */
2634 layoutId?: string;
2635 /**
2636 * A callback that will fire when a layout animation on this component starts.
2637 *
2638 * @public
2639 */
2640 onLayoutAnimationStart?(): void;
2641 /**
2642 * A callback that will fire when a layout animation on this component completes.
2643 *
2644 * @public
2645 */
2646 onLayoutAnimationComplete?(): void;
2647 /**
2648 * @public
2649 */
2650 layoutDependency?: any;
2651 /**
2652 * Whether a projection node should measure its scroll when it or its descendants update their layout.
2653 *
2654 * @public
2655 */
2656 layoutScroll?: boolean;
2657 /**
2658 * Whether an element should be considered a "layout root", where
2659 * all children will be forced to resolve relatively to it.
2660 * Currently used for `position: sticky` elements in Framer.
2661 */
2662 layoutRoot?: boolean;
2663 /**
2664 * Attached to a portal root to ensure we attach the child to the document root and don't
2665 * perform scale correction on it.
2666 */
2667 "data-framer-portal-id"?: string;
2668}
2669
2670/** @public */
2671interface EventInfo {
2672 point: Point;
2673}
2674
2675/**
2676 * @public
2677 */
2678interface FocusHandlers {
2679 /**
2680 * Properties or variant label to animate to while the focus gesture is recognised.
2681 *
2682 * ```jsx
2683 * <motion.input whileFocus={{ scale: 1.2 }} />
2684 * ```
2685 */
2686 whileFocus?: VariantLabels | TargetAndTransition;
2687}
2688/**
2689 * Passed in to tap event handlers like `onTap` the `TapInfo` object contains
2690 * information about the tap gesture such as it‘s location.
2691 *
2692 * ```jsx
2693 * function onTap(event, info) {
2694 * console.log(info.point.x, info.point.y)
2695 * }
2696 *
2697 * <motion.div onTap={onTap} />
2698 * ```
2699 *
2700 * @public
2701 */
2702interface TapInfo {
2703 /**
2704 * Contains `x` and `y` values for the tap gesture relative to the
2705 * device or page.
2706 *
2707 * ```jsx
2708 * function onTapStart(event, info) {
2709 * console.log(info.point.x, info.point.y)
2710 * }
2711 *
2712 * <motion.div onTapStart={onTapStart} />
2713 * ```
2714 *
2715 * @public
2716 */
2717 point: Point;
2718}
2719/**
2720 * @public
2721 */
2722interface TapHandlers {
2723 /**
2724 * Callback when the tap gesture successfully ends on this element.
2725 *
2726 * ```jsx
2727 * function onTap(event, info) {
2728 * console.log(info.point.x, info.point.y)
2729 * }
2730 *
2731 * <motion.div onTap={onTap} />
2732 * ```
2733 *
2734 * @param event - The originating pointer event.
2735 * @param info - An {@link TapInfo} object containing `x` and `y` values for the `point` relative to the device or page.
2736 */
2737 onTap?(event: MouseEvent | TouchEvent | PointerEvent, info: TapInfo): void;
2738 /**
2739 * Callback when the tap gesture starts on this element.
2740 *
2741 * ```jsx
2742 * function onTapStart(event, info) {
2743 * console.log(info.point.x, info.point.y)
2744 * }
2745 *
2746 * <motion.div onTapStart={onTapStart} />
2747 * ```
2748 *
2749 * @param event - The originating pointer event.
2750 * @param info - An {@link TapInfo} object containing `x` and `y` values for the `point` relative to the device or page.
2751 */
2752 onTapStart?(event: MouseEvent | TouchEvent | PointerEvent, info: TapInfo): void;
2753 /**
2754 * Callback when the tap gesture ends outside this element.
2755 *
2756 * ```jsx
2757 * function onTapCancel(event, info) {
2758 * console.log(info.point.x, info.point.y)
2759 * }
2760 *
2761 * <motion.div onTapCancel={onTapCancel} />
2762 * ```
2763 *
2764 * @param event - The originating pointer event.
2765 * @param info - An {@link TapInfo} object containing `x` and `y` values for the `point` relative to the device or page.
2766 */
2767 onTapCancel?(event: MouseEvent | TouchEvent | PointerEvent, info: TapInfo): void;
2768 /**
2769 * Properties or variant label to animate to while the component is pressed.
2770 *
2771 * ```jsx
2772 * <motion.div whileTap={{ scale: 0.8 }} />
2773 * ```
2774 */
2775 whileTap?: VariantLabels | TargetAndTransition;
2776 /**
2777 * If `true`, the tap gesture will attach its start listener to window.
2778 *
2779 * Note: This is not supported publically.
2780 */
2781 globalTapTarget?: boolean;
2782}
2783/**
2784 * @public
2785 */
2786interface PanHandlers {
2787 /**
2788 * Callback function that fires when the pan gesture is recognised on this element.
2789 *
2790 * **Note:** For pan gestures to work correctly with touch input, the element needs
2791 * touch scrolling to be disabled on either x/y or both axis with the
2792 * [touch-action](https://developer.mozilla.org/en-US/docs/Web/CSS/touch-action) CSS rule.
2793 *
2794 * ```jsx
2795 * function onPan(event, info) {
2796 * console.log(info.point.x, info.point.y)
2797 * }
2798 *
2799 * <motion.div onPan={onPan} />
2800 * ```
2801 *
2802 * @param event - The originating pointer event.
2803 * @param info - A {@link PanInfo} object containing `x` and `y` values for:
2804 *
2805 * - `point`: Relative to the device or page.
2806 * - `delta`: Distance moved since the last event.
2807 * - `offset`: Offset from the original pan event.
2808 * - `velocity`: Current velocity of the pointer.
2809 */
2810 onPan?(event: PointerEvent, info: PanInfo): void;
2811 /**
2812 * Callback function that fires when the pan gesture begins on this element.
2813 *
2814 * ```jsx
2815 * function onPanStart(event, info) {
2816 * console.log(info.point.x, info.point.y)
2817 * }
2818 *
2819 * <motion.div onPanStart={onPanStart} />
2820 * ```
2821 *
2822 * @param event - The originating pointer event.
2823 * @param info - A {@link PanInfo} object containing `x`/`y` values for:
2824 *
2825 * - `point`: Relative to the device or page.
2826 * - `delta`: Distance moved since the last event.
2827 * - `offset`: Offset from the original pan event.
2828 * - `velocity`: Current velocity of the pointer.
2829 */
2830 onPanStart?(event: PointerEvent, info: PanInfo): void;
2831 /**
2832 * Callback function that fires when we begin detecting a pan gesture. This
2833 * is analogous to `onMouseStart` or `onTouchStart`.
2834 *
2835 * ```jsx
2836 * function onPanSessionStart(event, info) {
2837 * console.log(info.point.x, info.point.y)
2838 * }
2839 *
2840 * <motion.div onPanSessionStart={onPanSessionStart} />
2841 * ```
2842 *
2843 * @param event - The originating pointer event.
2844 * @param info - An {@link EventInfo} object containing `x`/`y` values for:
2845 *
2846 * - `point`: Relative to the device or page.
2847 */
2848 onPanSessionStart?(event: PointerEvent, info: EventInfo): void;
2849 /**
2850 * Callback function that fires when the pan gesture ends on this element.
2851 *
2852 * ```jsx
2853 * function onPanEnd(event, info) {
2854 * console.log(info.point.x, info.point.y)
2855 * }
2856 *
2857 * <motion.div onPanEnd={onPanEnd} />
2858 * ```
2859 *
2860 * @param event - The originating pointer event.
2861 * @param info - A {@link PanInfo} object containing `x`/`y` values for:
2862 *
2863 * - `point`: Relative to the device or page.
2864 * - `delta`: Distance moved since the last event.
2865 * - `offset`: Offset from the original pan event.
2866 * - `velocity`: Current velocity of the pointer.
2867 */
2868 onPanEnd?(event: PointerEvent, info: PanInfo): void;
2869}
2870/**
2871 * @public
2872 */
2873interface HoverHandlers {
2874 /**
2875 * Properties or variant label to animate to while the hover gesture is recognised.
2876 *
2877 * ```jsx
2878 * <motion.div whileHover={{ scale: 1.2 }} />
2879 * ```
2880 */
2881 whileHover?: VariantLabels | TargetAndTransition;
2882 /**
2883 * Callback function that fires when pointer starts hovering over the component.
2884 *
2885 * ```jsx
2886 * <motion.div onHoverStart={() => console.log('Hover starts')} />
2887 * ```
2888 */
2889 onHoverStart?(event: MouseEvent, info: EventInfo): void;
2890 /**
2891 * Callback function that fires when pointer stops hovering over the component.
2892 *
2893 * ```jsx
2894 * <motion.div onHoverEnd={() => console.log("Hover ends")} />
2895 * ```
2896 */
2897 onHoverEnd?(event: MouseEvent, info: EventInfo): void;
2898}
2899
2900type ViewportEventHandler = (entry: IntersectionObserverEntry | null) => void;
2901interface ViewportOptions {
2902 root?: RefObject<Element>;
2903 once?: boolean;
2904 margin?: string;
2905 amount?: "some" | "all" | number;
2906}
2907interface ViewportProps {
2908 whileInView?: VariantLabels | TargetAndTransition;
2909 onViewportEnter?: ViewportEventHandler;
2910 onViewportLeave?: ViewportEventHandler;
2911 viewport?: ViewportOptions;
2912}
2913
2914/**
2915 * Either a string, or array of strings, that reference variants defined via the `variants` prop.
2916 * @public
2917 */
2918type VariantLabels = string | string[];
2919interface TransformProperties {
2920 x?: string | number;
2921 y?: string | number;
2922 z?: string | number;
2923 translateX?: string | number;
2924 translateY?: string | number;
2925 translateZ?: string | number;
2926 rotate?: string | number;
2927 rotateX?: string | number;
2928 rotateY?: string | number;
2929 rotateZ?: string | number;
2930 scale?: string | number;
2931 scaleX?: string | number;
2932 scaleY?: string | number;
2933 scaleZ?: string | number;
2934 skew?: string | number;
2935 skewX?: string | number;
2936 skewY?: string | number;
2937 originX?: string | number;
2938 originY?: string | number;
2939 originZ?: string | number;
2940 perspective?: string | number;
2941 transformPerspective?: string | number;
2942}
2943/**
2944 * @public
2945 */
2946interface SVGPathProperties {
2947 pathLength?: number;
2948 pathOffset?: number;
2949 pathSpacing?: number;
2950}
2951interface CustomStyles {
2952 /**
2953 * Framer Library custom prop types. These are not actually supported in Motion - preferably
2954 * we'd have a way of external consumers injecting supported styles into this library.
2955 */
2956 size?: string | number;
2957 radius?: string | number;
2958 shadow?: string;
2959 image?: string;
2960}
2961type MakeMotion<T> = MakeCustomValueType<{
2962 [K in keyof T]: T[K] | MotionValue<number> | MotionValue<string> | MotionValue<any>;
2963}>;
2964type MotionCSS = MakeMotion<Omit$1<CSSProperties, "rotate" | "scale" | "perspective">>;
2965/**
2966 * @public
2967 */
2968type MotionTransform = MakeMotion<TransformProperties>;
2969/**
2970 * @public
2971 */
2972type MotionStyle = MotionCSS & MotionTransform & MakeMotion<SVGPathProperties> & MakeCustomValueType<CustomStyles>;
2973/**
2974 * @public
2975 */
2976interface AnimationProps {
2977 /**
2978 * Properties, variant label or array of variant labels to start in.
2979 *
2980 * Set to `false` to initialise with the values in `animate` (disabling the mount animation)
2981 *
2982 * ```jsx
2983 * // As values
2984 * <motion.div initial={{ opacity: 1 }} />
2985 *
2986 * // As variant
2987 * <motion.div initial="visible" variants={variants} />
2988 *
2989 * // Multiple variants
2990 * <motion.div initial={["visible", "active"]} variants={variants} />
2991 *
2992 * // As false (disable mount animation)
2993 * <motion.div initial={false} animate={{ opacity: 0 }} />
2994 * ```
2995 */
2996 initial?: boolean | Target | VariantLabels;
2997 /**
2998 * Values to animate to, variant label(s), or `AnimationControls`.
2999 *
3000 * ```jsx
3001 * // As values
3002 * <motion.div animate={{ opacity: 1 }} />
3003 *
3004 * // As variant
3005 * <motion.div animate="visible" variants={variants} />
3006 *
3007 * // Multiple variants
3008 * <motion.div animate={["visible", "active"]} variants={variants} />
3009 *
3010 * // AnimationControls
3011 * <motion.div animate={animation} />
3012 * ```
3013 */
3014 animate?: AnimationControls | TargetAndTransition | VariantLabels | boolean;
3015 /**
3016 * A target to animate to when this component is removed from the tree.
3017 *
3018 * This component **must** be the first animatable child of an `AnimatePresence` to enable this exit animation.
3019 *
3020 * This limitation exists because React doesn't allow components to defer unmounting until after
3021 * an animation is complete. Once this limitation is fixed, the `AnimatePresence` component will be unnecessary.
3022 *
3023 * ```jsx
3024 * import { AnimatePresence, motion } from 'framer-motion'
3025 *
3026 * export const MyComponent = ({ isVisible }) => {
3027 * return (
3028 * <AnimatePresence>
3029 * {isVisible && (
3030 * <motion.div
3031 * initial={{ opacity: 0 }}
3032 * animate={{ opacity: 1 }}
3033 * exit={{ opacity: 0 }}
3034 * />
3035 * )}
3036 * </AnimatePresence>
3037 * )
3038 * }
3039 * ```
3040 */
3041 exit?: TargetAndTransition | VariantLabels;
3042 /**
3043 * Variants allow you to define animation states and organise them by name. They allow
3044 * you to control animations throughout a component tree by switching a single `animate` prop.
3045 *
3046 * Using `transition` options like `delayChildren` and `staggerChildren`, you can orchestrate
3047 * when children animations play relative to their parent.
3048
3049 *
3050 * After passing variants to one or more `motion` component's `variants` prop, these variants
3051 * can be used in place of values on the `animate`, `initial`, `whileFocus`, `whileTap` and `whileHover` props.
3052 *
3053 * ```jsx
3054 * const variants = {
3055 * active: {
3056 * backgroundColor: "#f00"
3057 * },
3058 * inactive: {
3059 * backgroundColor: "#fff",
3060 * transition: { duration: 2 }
3061 * }
3062 * }
3063 *
3064 * <motion.div variants={variants} animate="active" />
3065 * ```
3066 */
3067 variants?: Variants;
3068 /**
3069 * Default transition. If no `transition` is defined in `animate`, it will use the transition defined here.
3070 * ```jsx
3071 * const spring = {
3072 * type: "spring",
3073 * damping: 10,
3074 * stiffness: 100
3075 * }
3076 *
3077 * <motion.div transition={spring} animate={{ scale: 1.2 }} />
3078 * ```
3079 */
3080 transition?: Transition$1;
3081}
3082/**
3083 * @public
3084 */
3085interface MotionAdvancedProps {
3086 /**
3087 * Custom data to use to resolve dynamic variants differently for each animating component.
3088 *
3089 * ```jsx
3090 * const variants = {
3091 * visible: (custom) => ({
3092 * opacity: 1,
3093 * transition: { delay: custom * 0.2 }
3094 * })
3095 * }
3096 *
3097 * <motion.div custom={0} animate="visible" variants={variants} />
3098 * <motion.div custom={1} animate="visible" variants={variants} />
3099 * <motion.div custom={2} animate="visible" variants={variants} />
3100 * ```
3101 *
3102 * @public
3103 */
3104 custom?: any;
3105 /**
3106 * @public
3107 * Set to `false` to prevent inheriting variant changes from its parent.
3108 */
3109 inherit?: boolean;
3110 /**
3111 * @public
3112 * Set to `false` to prevent throwing an error when a `motion` component is used within a `LazyMotion` set to strict.
3113 */
3114 ignoreStrict?: boolean;
3115}
3116/**
3117 * Props for `motion` components.
3118 *
3119 * @public
3120 */
3121interface MotionProps extends AnimationProps, EventProps, PanHandlers, TapHandlers, HoverHandlers, FocusHandlers, ViewportProps, DraggableProps, LayoutProps, MotionAdvancedProps {
3122 /**
3123 *
3124 * The React DOM `style` prop, enhanced with support for `MotionValue`s and separate `transform` values.
3125 *
3126 * ```jsx
3127 * export const MyComponent = () => {
3128 * const x = useMotionValue(0)
3129 *
3130 * return <motion.div style={{ x, opacity: 1, scale: 0.5 }} />
3131 * }
3132 * ```
3133 */
3134 style?: MotionStyle;
3135 /**
3136 * By default, Framer Motion generates a `transform` property with a sensible transform order. `transformTemplate`
3137 * can be used to create a different order, or to append/preprend the automatically generated `transform` property.
3138 *
3139 * ```jsx
3140 * <motion.div
3141 * style={{ x: 0, rotate: 180 }}
3142 * transformTemplate={
3143 * ({ x, rotate }) => `rotate(${rotate}deg) translateX(${x}px)`
3144 * }
3145 * />
3146 * ```
3147 *
3148 * @param transform - The latest animated transform props.
3149 * @param generatedTransform - The transform string as automatically generated by Framer Motion
3150 *
3151 * @public
3152 */
3153 transformTemplate?(transform: TransformProperties, generatedTransform: string): string;
3154 children?: React.ReactNode | MotionValue<number> | MotionValue<string>;
3155 "data-framer-appear-id"?: string;
3156}
3157
3158interface VisualState<Instance, RenderState> {
3159 renderState: RenderState;
3160 latestValues: ResolvedValues;
3161 mount?: (instance: Instance) => void;
3162}
3163type UseVisualState<Instance, RenderState> = (props: MotionProps, isStatic: boolean) => VisualState<Instance, RenderState>;
3164interface UseVisualStateConfig<Instance, RenderState> {
3165 applyWillChange?: boolean;
3166 scrapeMotionValuesFromProps: ScrapeMotionValuesFromProps;
3167 createRenderState: () => RenderState;
3168 onMount?: (props: MotionProps, instance: Instance, visualState: VisualState<Instance, RenderState>) => void;
3169}
3170declare const makeUseVisualState: <I, RS>(config: UseVisualStateConfig<I, RS>) => UseVisualState<I, RS>;
3171
3172type ScrapeMotionValuesFromProps = (props: MotionProps, prevProps: MotionProps, visualElement?: VisualElement) => {
3173 [key: string]: MotionValue | string | number;
3174};
3175type VisualElementOptions<Instance, RenderState = any> = {
3176 visualState: VisualState<Instance, RenderState>;
3177 parent?: VisualElement<unknown>;
3178 variantParent?: VisualElement<unknown>;
3179 presenceContext: PresenceContextProps | null;
3180 props: MotionProps;
3181 blockInitialAnimation?: boolean;
3182 reducedMotionConfig?: ReducedMotionConfig;
3183};
3184/**
3185 * A generic set of string/number values
3186 */
3187interface ResolvedValues {
3188 [key: string]: string | number;
3189}
3190interface VisualElementEventCallbacks {
3191 BeforeLayoutMeasure: () => void;
3192 LayoutMeasure: (layout: Box, prevLayout?: Box) => void;
3193 LayoutUpdate: (layout: Axis, prevLayout: Axis) => void;
3194 Update: (latest: ResolvedValues) => void;
3195 AnimationStart: (definition: AnimationDefinition) => void;
3196 AnimationComplete: (definition: AnimationDefinition) => void;
3197 LayoutAnimationStart: () => void;
3198 LayoutAnimationComplete: () => void;
3199 SetAxisTarget: () => void;
3200 Unmount: () => void;
3201}
3202interface LayoutLifecycles {
3203 onBeforeLayoutMeasure?(box: Box): void;
3204 onLayoutMeasure?(box: Box, prevBox: Box): void;
3205}
3206interface AnimationLifecycles {
3207 /**
3208 * Callback with latest motion values, fired max once per frame.
3209 *
3210 * ```jsx
3211 * function onUpdate(latest) {
3212 * console.log(latest.x, latest.opacity)
3213 * }
3214 *
3215 * <motion.div animate={{ x: 100, opacity: 0 }} onUpdate={onUpdate} />
3216 * ```
3217 */
3218 onUpdate?(latest: ResolvedValues): void;
3219 /**
3220 * Callback when animation defined in `animate` begins.
3221 *
3222 * The provided callback will be called with the triggering animation definition.
3223 * If this is a variant, it'll be the variant name, and if a target object
3224 * then it'll be the target object.
3225 *
3226 * This way, it's possible to figure out which animation has started.
3227 *
3228 * ```jsx
3229 * function onStart() {
3230 * console.log("Animation started")
3231 * }
3232 *
3233 * <motion.div animate={{ x: 100 }} onAnimationStart={onStart} />
3234 * ```
3235 */
3236 onAnimationStart?(definition: AnimationDefinition): void;
3237 /**
3238 * Callback when animation defined in `animate` is complete.
3239 *
3240 * The provided callback will be called with the triggering animation definition.
3241 * If this is a variant, it'll be the variant name, and if a target object
3242 * then it'll be the target object.
3243 *
3244 * This way, it's possible to figure out which animation has completed.
3245 *
3246 * ```jsx
3247 * function onComplete() {
3248 * console.log("Animation completed")
3249 * }
3250 *
3251 * <motion.div
3252 * animate={{ x: 100 }}
3253 * onAnimationComplete={definition => {
3254 * console.log('Completed animating', definition)
3255 * }}
3256 * />
3257 * ```
3258 */
3259 onAnimationComplete?(definition: AnimationDefinition): void;
3260}
3261type EventProps = LayoutLifecycles & AnimationLifecycles;
3262type CreateVisualElement<Instance> = (Component: string | React.ComponentType<React.PropsWithChildren<unknown>>, options: VisualElementOptions<Instance>) => VisualElement<Instance>;
3263
3264type UnionStringArray$1<T extends Readonly<string[]>> = T[number];
3265declare const svgElements: readonly ["animate", "circle", "defs", "desc", "ellipse", "g", "image", "line", "filter", "marker", "mask", "metadata", "path", "pattern", "polygon", "polyline", "rect", "stop", "svg", "switch", "symbol", "text", "tspan", "use", "view", "clipPath", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "foreignObject", "linearGradient", "radialGradient", "textPath"];
3266type SVGElements = UnionStringArray$1<typeof svgElements>;
3267
3268type UnionStringArray<T extends Readonly<string[]>> = T[number];
3269declare const htmlElements: readonly ["a", "abbr", "address", "area", "article", "aside", "audio", "b", "base", "bdi", "bdo", "big", "blockquote", "body", "br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "iframe", "img", "input", "ins", "kbd", "keygen", "label", "legend", "li", "link", "main", "map", "mark", "menu", "menuitem", "meta", "meter", "nav", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "script", "section", "select", "small", "source", "span", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "u", "ul", "var", "video", "wbr", "webview"];
3270type HTMLElements = UnionStringArray<typeof htmlElements>;
3271
3272interface TransformOrigin {
3273 originX?: number | string;
3274 originY?: number | string;
3275 originZ?: number | string;
3276}
3277interface HTMLRenderState {
3278 /**
3279 * A mutable record of transforms we want to apply directly to the rendered Element
3280 * every frame. We use a mutable data structure to reduce GC during animations.
3281 */
3282 transform: ResolvedValues;
3283 /**
3284 * A mutable record of transform origins we want to apply directly to the rendered Element
3285 * every frame. We use a mutable data structure to reduce GC during animations.
3286 */
3287 transformOrigin: TransformOrigin;
3288 /**
3289 * A mutable record of styles we want to apply directly to the rendered Element
3290 * every frame. We use a mutable data structure to reduce GC during animations.
3291 */
3292 style: ResolvedValues;
3293 /**
3294 * A mutable record of CSS variables we want to apply directly to the rendered Element
3295 * every frame. We use a mutable data structure to reduce GC during animations.
3296 */
3297 vars: ResolvedValues;
3298}
3299/**
3300 * @public
3301 */
3302type ForwardRefComponent<T, P> = {
3303 readonly $$typeof: symbol;
3304} & ((props: PropsWithoutRef<P> & RefAttributes<T>) => JSX.Element);
3305/**
3306 * Support for React component props
3307 */
3308type UnwrapFactoryAttributes<F> = F extends DetailedHTMLFactory<infer P, any> ? P : never;
3309type UnwrapFactoryElement<F> = F extends DetailedHTMLFactory<any, infer P> ? P : never;
3310type HTMLAttributesWithoutMotionProps<Attributes extends HTMLAttributes<Element>, Element extends HTMLElement> = {
3311 [K in Exclude<keyof Attributes, keyof MotionProps>]?: Attributes[K];
3312};
3313/**
3314 * @public
3315 */
3316type HTMLMotionProps<TagName extends keyof ReactHTML> = HTMLAttributesWithoutMotionProps<UnwrapFactoryAttributes<ReactHTML[TagName]>, UnwrapFactoryElement<ReactHTML[TagName]>> & MotionProps;
3317/**
3318 * Motion-optimised versions of React's HTML components.
3319 *
3320 * @public
3321 */
3322type HTMLMotionComponents = {
3323 [K in HTMLElements]: ForwardRefComponent<UnwrapFactoryElement<ReactHTML[K]>, HTMLMotionProps<K>>;
3324};
3325
3326interface SVGAttributesWithoutMotionProps<T> extends Pick<SVGAttributes$1<T>, Exclude<keyof SVGAttributes$1<T>, keyof MotionProps>> {
3327}
3328/**
3329 * Blanket-accept any SVG attribute as a `MotionValue`
3330 * @public
3331 */
3332type SVGAttributesAsMotionValues<T> = MakeMotion<SVGAttributesWithoutMotionProps<T>>;
3333type UnwrapSVGFactoryElement<F> = F extends React.SVGProps<infer P> ? P : never;
3334/**
3335 * @public
3336 */
3337interface SVGMotionProps<T> extends SVGAttributesAsMotionValues<T>, MotionProps {
3338}
3339/**
3340 * Motion-optimised versions of React's SVG components.
3341 *
3342 * @public
3343 */
3344type SVGMotionComponents = {
3345 [K in SVGElements]: ForwardRefComponent<UnwrapSVGFactoryElement<JSX.IntrinsicElements[K]>, SVGMotionProps<UnwrapSVGFactoryElement<JSX.IntrinsicElements[K]>>>;
3346};
3347
3348declare abstract class Feature<T extends any = any> {
3349 isMounted: boolean;
3350 node: VisualElement<T>;
3351 constructor(node: VisualElement<T>);
3352 abstract mount(): void;
3353 abstract unmount(): void;
3354 update(): void;
3355}
3356
3357declare function MeasureLayout(props: MotionProps & {
3358 visualElement: VisualElement;
3359}): react_jsx_runtime.JSX.Element;
3360
3361interface FeatureClass<Props = unknown> {
3362 new (props: Props): Feature<Props>;
3363}
3364type HydratedFeatureDefinition = {
3365 isEnabled: (props: MotionProps) => boolean;
3366 Feature: FeatureClass<unknown>;
3367 ProjectionNode?: any;
3368 MeasureLayout?: typeof MeasureLayout;
3369};
3370interface HydratedFeatureDefinitions {
3371 animation?: HydratedFeatureDefinition;
3372 exit?: HydratedFeatureDefinition;
3373 drag?: HydratedFeatureDefinition;
3374 tap?: HydratedFeatureDefinition;
3375 focus?: HydratedFeatureDefinition;
3376 hover?: HydratedFeatureDefinition;
3377 pan?: HydratedFeatureDefinition;
3378 inView?: HydratedFeatureDefinition;
3379 layout?: HydratedFeatureDefinition;
3380}
3381type FeatureDefinition = {
3382 isEnabled: HydratedFeatureDefinition["isEnabled"];
3383 Feature?: HydratedFeatureDefinition["Feature"];
3384 ProjectionNode?: HydratedFeatureDefinition["ProjectionNode"];
3385 MeasureLayout?: HydratedFeatureDefinition["MeasureLayout"];
3386};
3387type FeatureDefinitions = {
3388 [K in keyof HydratedFeatureDefinitions]: FeatureDefinition;
3389};
3390type FeaturePackage = {
3391 Feature?: HydratedFeatureDefinition["Feature"];
3392 ProjectionNode?: HydratedFeatureDefinition["ProjectionNode"];
3393 MeasureLayout?: HydratedFeatureDefinition["MeasureLayout"];
3394};
3395type FeaturePackages = {
3396 [K in keyof HydratedFeatureDefinitions]: FeaturePackage;
3397};
3398interface FeatureBundle extends FeaturePackages {
3399 renderer: CreateVisualElement<any>;
3400}
3401type LazyFeatureBundle$1 = () => Promise<FeatureBundle>;
3402type RenderComponent<Instance, RenderState> = (Component: string | React$1.ComponentType<React$1.PropsWithChildren<unknown>>, props: MotionProps, ref: React$1.Ref<Instance>, visualState: VisualState<Instance, RenderState>, isStatic: boolean, visualElement?: VisualElement<Instance>) => any;
3403
3404interface MotionComponentConfig<Instance, RenderState> {
3405 preloadedFeatures?: FeatureBundle;
3406 createVisualElement?: CreateVisualElement<Instance>;
3407 useRender: RenderComponent<Instance, RenderState>;
3408 useVisualState: UseVisualState<Instance, RenderState>;
3409 Component: string | React$1.ComponentType<React$1.PropsWithChildren<unknown>>;
3410}
3411type MotionComponentProps<Props> = {
3412 [K in Exclude<keyof Props, keyof MotionProps>]?: Props[K];
3413} & MotionProps;
3414/**
3415 * Create a `motion` component.
3416 *
3417 * This function accepts a Component argument, which can be either a string (ie "div"
3418 * for `motion.div`), or an actual React component.
3419 *
3420 * Alongside this is a config option which provides a way of rendering the provided
3421 * component "offline", or outside the React render cycle.
3422 */
3423declare function createRendererMotionComponent<Props extends {}, Instance, RenderState>({ preloadedFeatures, createVisualElement, useRender, useVisualState, Component, }: MotionComponentConfig<Instance, RenderState>): React$1.ForwardRefExoticComponent<React$1.RefAttributes<unknown>>;
3424
3425declare const motion: (<Props, TagName extends string = "div">(Component: string | TagName | React$1.ForwardRefExoticComponent<Props>, { forwardMotionProps }?: {
3426 forwardMotionProps: boolean;
3427}) => TagName extends "symbol" | "object" | "map" | "filter" | "stop" | "clipPath" | "mask" | "marker" | "a" | "b" | "var" | "style" | "animate" | "progress" | "text" | "ruby" | "table" | "small" | "embed" | "sub" | "path" | "image" | "button" | "meter" | "textarea" | "circle" | "pre" | "caption" | "menu" | "menuitem" | "article" | "dialog" | "figure" | "form" | "img" | "link" | "main" | "option" | "switch" | "time" | "div" | "abbr" | "address" | "area" | "aside" | "audio" | "base" | "bdi" | "bdo" | "blockquote" | "body" | "br" | "canvas" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dl" | "dt" | "em" | "fieldset" | "figcaption" | "footer" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "input" | "ins" | "kbd" | "label" | "legend" | "li" | "mark" | "meta" | "nav" | "noscript" | "ol" | "optgroup" | "output" | "p" | "picture" | "q" | "rp" | "rt" | "s" | "samp" | "script" | "section" | "select" | "source" | "span" | "strong" | "summary" | "sup" | "tbody" | "td" | "tfoot" | "th" | "thead" | "title" | "tr" | "track" | "u" | "ul" | "video" | "wbr" | "big" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feDropShadow" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "foreignObject" | "g" | "line" | "linearGradient" | "metadata" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "svg" | "textPath" | "tspan" | "use" | "view" | "keygen" | "param" | "webview" ? DOMMotionComponents[TagName] : React$1.ForwardRefExoticComponent<MotionComponentProps<React$1.PropsWithChildren<Props>>>) & HTMLMotionComponents & SVGMotionComponents & {
3428 create: <Props, TagName extends string = "div">(Component: string | TagName | React$1.ForwardRefExoticComponent<Props>, { forwardMotionProps }?: {
3429 forwardMotionProps: boolean;
3430 }) => TagName extends "symbol" | "object" | "map" | "filter" | "stop" | "clipPath" | "mask" | "marker" | "a" | "b" | "var" | "style" | "animate" | "progress" | "text" | "ruby" | "table" | "small" | "embed" | "sub" | "path" | "image" | "button" | "meter" | "textarea" | "circle" | "pre" | "caption" | "menu" | "menuitem" | "article" | "dialog" | "figure" | "form" | "img" | "link" | "main" | "option" | "switch" | "time" | "div" | "abbr" | "address" | "area" | "aside" | "audio" | "base" | "bdi" | "bdo" | "blockquote" | "body" | "br" | "canvas" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dl" | "dt" | "em" | "fieldset" | "figcaption" | "footer" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "input" | "ins" | "kbd" | "label" | "legend" | "li" | "mark" | "meta" | "nav" | "noscript" | "ol" | "optgroup" | "output" | "p" | "picture" | "q" | "rp" | "rt" | "s" | "samp" | "script" | "section" | "select" | "source" | "span" | "strong" | "summary" | "sup" | "tbody" | "td" | "tfoot" | "th" | "thead" | "title" | "tr" | "track" | "u" | "ul" | "video" | "wbr" | "big" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feDropShadow" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "foreignObject" | "g" | "line" | "linearGradient" | "metadata" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "svg" | "textPath" | "tspan" | "use" | "view" | "keygen" | "param" | "webview" ? DOMMotionComponents[TagName] : React$1.ForwardRefExoticComponent<MotionComponentProps<React$1.PropsWithChildren<Props>>>;
3431};
3432
3433declare const m: (<Props, TagName extends string = "div">(Component: string | TagName | React$1.ForwardRefExoticComponent<Props>, { forwardMotionProps }?: {
3434 forwardMotionProps: boolean;
3435}) => TagName extends "symbol" | "object" | "map" | "filter" | "stop" | "clipPath" | "mask" | "marker" | "a" | "b" | "var" | "style" | "animate" | "progress" | "text" | "ruby" | "table" | "small" | "embed" | "sub" | "path" | "image" | "button" | "meter" | "textarea" | "circle" | "pre" | "caption" | "menu" | "menuitem" | "article" | "dialog" | "figure" | "form" | "img" | "link" | "main" | "option" | "switch" | "time" | "div" | "abbr" | "address" | "area" | "aside" | "audio" | "base" | "bdi" | "bdo" | "blockquote" | "body" | "br" | "canvas" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dl" | "dt" | "em" | "fieldset" | "figcaption" | "footer" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "input" | "ins" | "kbd" | "label" | "legend" | "li" | "mark" | "meta" | "nav" | "noscript" | "ol" | "optgroup" | "output" | "p" | "picture" | "q" | "rp" | "rt" | "s" | "samp" | "script" | "section" | "select" | "source" | "span" | "strong" | "summary" | "sup" | "tbody" | "td" | "tfoot" | "th" | "thead" | "title" | "tr" | "track" | "u" | "ul" | "video" | "wbr" | "big" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feDropShadow" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "foreignObject" | "g" | "line" | "linearGradient" | "metadata" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "svg" | "textPath" | "tspan" | "use" | "view" | "keygen" | "param" | "webview" ? DOMMotionComponents[TagName] : React$1.ForwardRefExoticComponent<MotionComponentProps<React$1.PropsWithChildren<Props>>>) & HTMLMotionComponents & SVGMotionComponents & {
3436 create: <Props, TagName extends string = "div">(Component: string | TagName | React$1.ForwardRefExoticComponent<Props>, { forwardMotionProps }?: {
3437 forwardMotionProps: boolean;
3438 }) => TagName extends "symbol" | "object" | "map" | "filter" | "stop" | "clipPath" | "mask" | "marker" | "a" | "b" | "var" | "style" | "animate" | "progress" | "text" | "ruby" | "table" | "small" | "embed" | "sub" | "path" | "image" | "button" | "meter" | "textarea" | "circle" | "pre" | "caption" | "menu" | "menuitem" | "article" | "dialog" | "figure" | "form" | "img" | "link" | "main" | "option" | "switch" | "time" | "div" | "abbr" | "address" | "area" | "aside" | "audio" | "base" | "bdi" | "bdo" | "blockquote" | "body" | "br" | "canvas" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dl" | "dt" | "em" | "fieldset" | "figcaption" | "footer" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "input" | "ins" | "kbd" | "label" | "legend" | "li" | "mark" | "meta" | "nav" | "noscript" | "ol" | "optgroup" | "output" | "p" | "picture" | "q" | "rp" | "rt" | "s" | "samp" | "script" | "section" | "select" | "source" | "span" | "strong" | "summary" | "sup" | "tbody" | "td" | "tfoot" | "th" | "thead" | "title" | "tr" | "track" | "u" | "ul" | "video" | "wbr" | "big" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feDropShadow" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "foreignObject" | "g" | "line" | "linearGradient" | "metadata" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "svg" | "textPath" | "tspan" | "use" | "view" | "keygen" | "param" | "webview" ? DOMMotionComponents[TagName] : React$1.ForwardRefExoticComponent<MotionComponentProps<React$1.PropsWithChildren<Props>>>;
3439};
3440
3441/**
3442 * @public
3443 */
3444interface AnimatePresenceProps {
3445 /**
3446 * By passing `initial={false}`, `AnimatePresence` will disable any initial animations on children
3447 * that are present when the component is first rendered.
3448 *
3449 * ```jsx
3450 * <AnimatePresence initial={false}>
3451 * {isVisible && (
3452 * <motion.div
3453 * key="modal"
3454 * initial={{ opacity: 0 }}
3455 * animate={{ opacity: 1 }}
3456 * exit={{ opacity: 0 }}
3457 * />
3458 * )}
3459 * </AnimatePresence>
3460 * ```
3461 *
3462 * @public
3463 */
3464 initial?: boolean;
3465 /**
3466 * When a component is removed, there's no longer a chance to update its props. So if a component's `exit`
3467 * prop is defined as a dynamic variant and you want to pass a new `custom` prop, you can do so via `AnimatePresence`.
3468 * This will ensure all leaving components animate using the latest data.
3469 *
3470 * @public
3471 */
3472 custom?: any;
3473 /**
3474 * Fires when all exiting nodes have completed animating out.
3475 *
3476 * @public
3477 */
3478 onExitComplete?: () => void;
3479 /**
3480 * Replace with `mode="wait"`
3481 *
3482 * @deprecated
3483 *
3484 * Replace with `mode="wait"`
3485 */
3486 exitBeforeEnter?: boolean;
3487 /**
3488 * Determines how to handle entering and exiting elements.
3489 *
3490 * - `"sync"`: Default. Elements animate in and out as soon as they're added/removed.
3491 * - `"popLayout"`: Exiting elements are "popped" from the page layout, allowing sibling
3492 * elements to immediately occupy their new layouts.
3493 * - `"wait"`: Only renders one component at a time. Wait for the exiting component to animate out
3494 * before animating the next component in.
3495 *
3496 * @public
3497 */
3498 mode?: "sync" | "popLayout" | "wait";
3499 /**
3500 * Internal. Used in Framer to flag that sibling children *shouldn't* re-render as a result of a
3501 * child being removed.
3502 */
3503 presenceAffectsLayout?: boolean;
3504}
3505
3506/**
3507 * `AnimatePresence` enables the animation of components that have been removed from the tree.
3508 *
3509 * When adding/removing more than a single child, every child **must** be given a unique `key` prop.
3510 *
3511 * Any `motion` components that have an `exit` property defined will animate out when removed from
3512 * the tree.
3513 *
3514 * ```jsx
3515 * import { motion, AnimatePresence } from 'framer-motion'
3516 *
3517 * export const Items = ({ items }) => (
3518 * <AnimatePresence>
3519 * {items.map(item => (
3520 * <motion.div
3521 * key={item.id}
3522 * initial={{ opacity: 0 }}
3523 * animate={{ opacity: 1 }}
3524 * exit={{ opacity: 0 }}
3525 * />
3526 * ))}
3527 * </AnimatePresence>
3528 * )
3529 * ```
3530 *
3531 * You can sequence exit animations throughout a tree using variants.
3532 *
3533 * If a child contains multiple `motion` components with `exit` props, it will only unmount the child
3534 * once all `motion` components have finished animating out. Likewise, any components using
3535 * `usePresence` all need to call `safeToRemove`.
3536 *
3537 * @public
3538 */
3539declare const AnimatePresence: React$1.FunctionComponent<React$1.PropsWithChildren<AnimatePresenceProps>>;
3540
3541type IsValidProp = (key: string) => boolean;
3542declare function filterProps(props: MotionProps, isDom: boolean, forwardMotionProps: boolean): MotionProps;
3543
3544interface MotionConfigProps extends Partial<MotionConfigContext> {
3545 children?: React$1.ReactNode;
3546 isValidProp?: IsValidProp;
3547}
3548/**
3549 * `MotionConfig` is used to set configuration options for all children `motion` components.
3550 *
3551 * ```jsx
3552 * import { motion, MotionConfig } from "framer-motion"
3553 *
3554 * export function App() {
3555 * return (
3556 * <MotionConfig transition={{ type: "spring" }}>
3557 * <motion.div animate={{ x: 100 }} />
3558 * </MotionConfig>
3559 * )
3560 * }
3561 * ```
3562 *
3563 * @public
3564 */
3565declare function MotionConfig({ children, isValidProp, ...config }: MotionConfigProps): react_jsx_runtime.JSX.Element;
3566
3567type LazyFeatureBundle = () => Promise<FeatureBundle>;
3568/**
3569 * @public
3570 */
3571interface LazyProps {
3572 children?: React.ReactNode;
3573 /**
3574 * Can be used to provide a feature bundle synchronously or asynchronously.
3575 *
3576 * ```jsx
3577 * // features.js
3578 * import { domAnimation } from "framer-motion"
3579 * export default domAnimation
3580 *
3581 * // index.js
3582 * import { LazyMotion, m } from "framer-motion"
3583 *
3584 * const loadFeatures = import("./features.js")
3585 * .then(res => res.default)
3586 *
3587 * function Component() {
3588 * return (
3589 * <LazyMotion features={loadFeatures}>
3590 * <m.div animate={{ scale: 1.5 }} />
3591 * </LazyMotion>
3592 * )
3593 * }
3594 * ```
3595 *
3596 * @public
3597 */
3598 features: FeatureBundle | LazyFeatureBundle;
3599 /**
3600 * If `true`, will throw an error if a `motion` component renders within
3601 * a `LazyMotion` component.
3602 *
3603 * ```jsx
3604 * // This component will throw an error that explains using a motion component
3605 * // instead of the m component will break the benefits of code-splitting.
3606 * function Component() {
3607 * return (
3608 * <LazyMotion features={domAnimation} strict>
3609 * <motion.div />
3610 * </LazyMotion>
3611 * )
3612 * }
3613 * ```
3614 *
3615 * @public
3616 */
3617 strict?: boolean;
3618}
3619
3620/**
3621 * Used in conjunction with the `m` component to reduce bundle size.
3622 *
3623 * `m` is a version of the `motion` component that only loads functionality
3624 * critical for the initial render.
3625 *
3626 * `LazyMotion` can then be used to either synchronously or asynchronously
3627 * load animation and gesture support.
3628 *
3629 * ```jsx
3630 * // Synchronous loading
3631 * import { LazyMotion, m, domAnimation } from "framer-motion"
3632 *
3633 * function App() {
3634 * return (
3635 * <LazyMotion features={domAnimation}>
3636 * <m.div animate={{ scale: 2 }} />
3637 * </LazyMotion>
3638 * )
3639 * }
3640 *
3641 * // Asynchronous loading
3642 * import { LazyMotion, m } from "framer-motion"
3643 *
3644 * function App() {
3645 * return (
3646 * <LazyMotion features={() => import('./path/to/domAnimation')}>
3647 * <m.div animate={{ scale: 2 }} />
3648 * </LazyMotion>
3649 * )
3650 * }
3651 * ```
3652 *
3653 * @public
3654 */
3655declare function LazyMotion({ children, features, strict }: LazyProps): react_jsx_runtime.JSX.Element;
3656
3657type InheritOption = boolean | "id";
3658interface Props$2 {
3659 id?: string;
3660 inherit?: InheritOption;
3661}
3662declare const LayoutGroup: React$1.FunctionComponent<React$1.PropsWithChildren<Props$2>>;
3663
3664interface Props$1<V> {
3665 /**
3666 * A HTML element to render this component as. Defaults to `"ul"`.
3667 *
3668 * @public
3669 */
3670 as?: keyof ReactHTML;
3671 /**
3672 * The axis to reorder along. By default, items will be draggable on this axis.
3673 * To make draggable on both axes, set `<Reorder.Item drag />`
3674 *
3675 * @public
3676 */
3677 axis?: "x" | "y";
3678 /**
3679 * A callback to fire with the new value order. For instance, if the values
3680 * are provided as a state from `useState`, this could be the set state function.
3681 *
3682 * @public
3683 */
3684 onReorder: (newOrder: V[]) => void;
3685 /**
3686 * The latest values state.
3687 *
3688 * ```jsx
3689 * function Component() {
3690 * const [items, setItems] = useState([0, 1, 2])
3691 *
3692 * return (
3693 * <Reorder.Group values={items} onReorder={setItems}>
3694 * {items.map((item) => <Reorder.Item key={item} value={item} />)}
3695 * </Reorder.Group>
3696 * )
3697 * }
3698 * ```
3699 *
3700 * @public
3701 */
3702 values: V[];
3703}
3704type ReorderGroupProps<V> = Props$1<V> & Omit<HTMLMotionProps<any>, "values"> & React$1.PropsWithChildren<{}>;
3705declare function ReorderGroupComponent<V>({ children, as, axis, onReorder, values, ...props }: ReorderGroupProps<V>, externalRef?: React$1.ForwardedRef<any>): react_jsx_runtime.JSX.Element;
3706declare const ReorderGroup: <V>(props: ReorderGroupProps<V> & {
3707 ref?: React$1.ForwardedRef<any>;
3708}) => ReturnType<typeof ReorderGroupComponent>;
3709
3710interface Props<V> {
3711 /**
3712 * A HTML element to render this component as. Defaults to `"li"`.
3713 *
3714 * @public
3715 */
3716 as?: keyof ReactHTML;
3717 /**
3718 * The value in the list that this component represents.
3719 *
3720 * @public
3721 */
3722 value: V;
3723 /**
3724 * A subset of layout options primarily used to disable layout="size"
3725 *
3726 * @public
3727 * @default true
3728 */
3729 layout?: true | "position";
3730}
3731type ReorderItemProps<V> = Props<V> & HTMLMotionProps<any> & React$1.PropsWithChildren<{}>;
3732declare function ReorderItemComponent<V>({ children, style, value, as, onDrag, layout, ...props }: ReorderItemProps<V>, externalRef?: React$1.ForwardedRef<any>): react_jsx_runtime.JSX.Element;
3733declare const ReorderItem: <V>(props: ReorderItemProps<V> & {
3734 ref?: React$1.ForwardedRef<any>;
3735}) => ReturnType<typeof ReorderItemComponent>;
3736
3737declare namespace namespace_d {
3738 export { ReorderGroup as Group, ReorderItem as Item };
3739}
3740
3741type ObjectTarget<O> = {
3742 [K in keyof O]?: O[K] | GenericKeyframesTarget<O[K]>;
3743};
3744type SequenceTime = number | "<" | `+${number}` | `-${number}` | `${string}`;
3745type SequenceLabel = string;
3746interface SequenceLabelWithTime {
3747 name: SequenceLabel;
3748 at: SequenceTime;
3749}
3750interface At {
3751 at?: SequenceTime;
3752}
3753type MotionValueSegment = [
3754 MotionValue,
3755 UnresolvedValueKeyframe | UnresolvedValueKeyframe[]
3756];
3757type MotionValueSegmentWithTransition = [
3758 MotionValue,
3759 UnresolvedValueKeyframe | UnresolvedValueKeyframe[],
3760 Transition & At
3761];
3762type DOMSegment = [ElementOrSelector, DOMKeyframesDefinition];
3763type DOMSegmentWithTransition = [
3764 ElementOrSelector,
3765 DOMKeyframesDefinition,
3766 DynamicAnimationOptions & At
3767];
3768type ObjectSegment<O extends {} = {}> = [O, ObjectTarget<O>];
3769type ObjectSegmentWithTransition<O extends {} = {}> = [
3770 O,
3771 ObjectTarget<O>,
3772 DynamicAnimationOptions & At
3773];
3774type Segment = ObjectSegment | ObjectSegmentWithTransition | SequenceLabel | SequenceLabelWithTime | MotionValueSegment | MotionValueSegmentWithTransition | DOMSegment | DOMSegmentWithTransition;
3775type AnimationSequence = Segment[];
3776interface SequenceOptions extends AnimationPlaybackOptions {
3777 delay?: number;
3778 duration?: number;
3779 defaultTransition?: Transition;
3780}
3781interface AbsoluteKeyframe {
3782 value: string | number | null;
3783 at: number;
3784 easing?: Easing;
3785}
3786type ValueSequence = AbsoluteKeyframe[];
3787interface SequenceMap {
3788 [key: string]: ValueSequence;
3789}
3790type ResolvedAnimationDefinition = {
3791 keyframes: {
3792 [key: string]: UnresolvedValueKeyframe[];
3793 };
3794 transition: {
3795 [key: string]: Transition;
3796 };
3797};
3798type ResolvedAnimationDefinitions = Map<Element | MotionValue, ResolvedAnimationDefinition>;
3799
3800/**
3801 * Creates an animation function that is optionally scoped
3802 * to a specific element.
3803 */
3804declare function createScopedAnimate(scope?: AnimationScope): {
3805 (sequence: AnimationSequence, options?: SequenceOptions): AnimationPlaybackControls;
3806 (value: string | MotionValue<string>, keyframes: string | GenericKeyframesTarget<string>, options?: ValueAnimationTransition<string>): AnimationPlaybackControls;
3807 (value: number | MotionValue<number>, keyframes: number | GenericKeyframesTarget<number>, options?: ValueAnimationTransition<number>): AnimationPlaybackControls;
3808 <V>(value: V | MotionValue<V>, keyframes: V | GenericKeyframesTarget<V>, options?: ValueAnimationTransition<V>): AnimationPlaybackControls;
3809 (element: ElementOrSelector, keyframes: DOMKeyframesDefinition, options?: DynamicAnimationOptions): AnimationPlaybackControls;
3810 <O extends {}>(object: O | O[], keyframes: ObjectTarget<O>, options?: DynamicAnimationOptions): AnimationPlaybackControls;
3811};
3812declare const animate: {
3813 (sequence: AnimationSequence, options?: SequenceOptions): AnimationPlaybackControls;
3814 (value: string | MotionValue<string>, keyframes: string | GenericKeyframesTarget<string>, options?: ValueAnimationTransition<string>): AnimationPlaybackControls;
3815 (value: number | MotionValue<number>, keyframes: number | GenericKeyframesTarget<number>, options?: ValueAnimationTransition<number>): AnimationPlaybackControls;
3816 <V>(value: V | MotionValue<V>, keyframes: V | GenericKeyframesTarget<V>, options?: ValueAnimationTransition<V>): AnimationPlaybackControls;
3817 (element: ElementOrSelector, keyframes: DOMKeyframesDefinition, options?: DynamicAnimationOptions): AnimationPlaybackControls;
3818 <O extends {}>(object: O | O[], keyframes: ObjectTarget<O>, options?: DynamicAnimationOptions): AnimationPlaybackControls;
3819};
3820
3821declare class GroupPlaybackControls implements AnimationPlaybackControls {
3822 animations: AnimationPlaybackControls[];
3823 constructor(animations: Array<AnimationPlaybackControls | undefined>);
3824 then(onResolve: VoidFunction, onReject?: VoidFunction): Promise<void>;
3825 /**
3826 * TODO: Filter out cancelled or stopped animations before returning
3827 */
3828 private getAll;
3829 private setAll;
3830 attachTimeline(timeline: any, fallback: (animation: AnimationPlaybackControls) => VoidFunction): () => void;
3831 get time(): number;
3832 set time(time: number);
3833 get speed(): number;
3834 set speed(speed: number);
3835 get startTime(): any;
3836 get duration(): number;
3837 private runAll;
3838 play(): void;
3839 pause(): void;
3840 stop: () => void;
3841 cancel(): void;
3842 complete(): void;
3843}
3844
3845declare const animateMini: (elementOrSelector: ElementOrSelector, keyframes: DOMKeyframesDefinition, options?: DynamicAnimationOptions) => GroupPlaybackControls;
3846
3847interface ScrollOptions {
3848 source?: HTMLElement;
3849 container?: HTMLElement;
3850 target?: Element;
3851 axis?: "x" | "y";
3852 offset?: ScrollOffset;
3853}
3854type OnScrollProgress = (progress: number) => void;
3855type OnScrollWithInfo = (progress: number, info: ScrollInfo) => void;
3856type OnScroll = OnScrollProgress | OnScrollWithInfo;
3857interface AxisScrollInfo {
3858 current: number;
3859 offset: number[];
3860 progress: number;
3861 scrollLength: number;
3862 velocity: number;
3863 targetOffset: number;
3864 targetLength: number;
3865 containerLength: number;
3866 interpolatorOffsets?: number[];
3867 interpolate?: EasingFunction;
3868}
3869interface ScrollInfo {
3870 time: number;
3871 x: AxisScrollInfo;
3872 y: AxisScrollInfo;
3873}
3874type OnScrollInfo = (info: ScrollInfo) => void;
3875type SupportedEdgeUnit = "px" | "vw" | "vh" | "%";
3876type EdgeUnit = `${number}${SupportedEdgeUnit}`;
3877type NamedEdges = "start" | "end" | "center";
3878type EdgeString = NamedEdges | EdgeUnit | `${number}`;
3879type Edge = EdgeString | number;
3880type ProgressIntersection = [number, number];
3881type Intersection = `${Edge} ${Edge}`;
3882type ScrollOffset = Array<Edge | Intersection | ProgressIntersection>;
3883interface ScrollInfoOptions {
3884 container?: HTMLElement;
3885 target?: Element;
3886 axis?: "x" | "y";
3887 offset?: ScrollOffset;
3888}
3889
3890declare class ScrollTimeline implements ProgressTimeline {
3891 constructor(options: ScrollOptions);
3892 currentTime: null | {
3893 value: number;
3894 };
3895 cancel?: VoidFunction;
3896}
3897declare global {
3898 interface Window {
3899 ScrollTimeline: ScrollTimeline;
3900 }
3901}
3902declare function scroll(onScroll: OnScroll | GroupPlaybackControls, { axis, ...options }?: ScrollOptions): VoidFunction;
3903
3904declare function scrollInfo(onScroll: OnScrollInfo, { container, ...options }?: ScrollInfoOptions): () => void;
3905
3906type ViewChangeHandler = (entry: IntersectionObserverEntry) => void;
3907type MarginValue = `${number}${'px' | '%'}`;
3908type MarginType = MarginValue | `${MarginValue} ${MarginValue}` | `${MarginValue} ${MarginValue} ${MarginValue}` | `${MarginValue} ${MarginValue} ${MarginValue} ${MarginValue}`;
3909interface InViewOptions {
3910 root?: Element | Document;
3911 margin?: MarginType;
3912 amount?: "some" | "all" | number;
3913}
3914declare function inView(elementOrSelector: ElementOrSelector, onStart: (entry: IntersectionObserverEntry) => void | ViewChangeHandler, { root, margin: rootMargin, amount }?: InViewOptions): VoidFunction;
3915
3916declare const anticipate: (p: number) => number;
3917
3918declare const backOut: (t: number) => number;
3919declare const backIn: EasingFunction;
3920declare const backInOut: EasingFunction;
3921
3922declare const circIn: EasingFunction;
3923declare const circOut: EasingFunction;
3924declare const circInOut: EasingFunction;
3925
3926declare const easeIn: (t: number) => number;
3927declare const easeOut: (t: number) => number;
3928declare const easeInOut: (t: number) => number;
3929
3930declare function cubicBezier(mX1: number, mY1: number, mX2: number, mY2: number): (t: number) => number;
3931
3932type Direction = "start" | "end";
3933declare function steps(numSteps: number, direction?: Direction): EasingFunction;
3934
3935declare const mirrorEasing: EasingModifier;
3936
3937declare const reverseEasing: EasingModifier;
3938
3939declare function spring({ keyframes, restDelta, restSpeed, ...options }: ValueAnimationOptions<number>): KeyframeGenerator<number>;
3940
3941declare function inertia({ keyframes, velocity, power, timeConstant, bounceDamping, bounceStiffness, modifyTarget, min, max, restDelta, restSpeed, }: ValueAnimationOptions<number>): KeyframeGenerator<number>;
3942
3943declare function keyframes<T extends string | number>({ duration, keyframes: keyframeValues, times, ease, }: ValueAnimationOptions<T>): KeyframeGenerator<T>;
3944
3945type StaggerOrigin = "first" | "last" | "center" | number;
3946type StaggerOptions = {
3947 startDelay?: number;
3948 from?: StaggerOrigin;
3949 ease?: Easing;
3950};
3951declare function stagger(duration?: number, { startDelay, from, ease }?: StaggerOptions): DynamicOption<number>;
3952
3953/**
3954 * @public
3955 */
3956interface TransformOptions<T> {
3957 /**
3958 * Clamp values to within the given range. Defaults to `true`
3959 *
3960 * @public
3961 */
3962 clamp?: boolean;
3963 /**
3964 * Easing functions to use on the interpolations between each value in the input and output ranges.
3965 *
3966 * If provided as an array, the array must be one item shorter than the input and output ranges, as the easings apply to the transition **between** each.
3967 *
3968 * @public
3969 */
3970 ease?: EasingFunction | EasingFunction[];
3971 /**
3972 * Provide a function that can interpolate between any two values in the provided range.
3973 *
3974 * @public
3975 */
3976 mixer?: (from: T, to: T) => (v: number) => any;
3977}
3978/**
3979 * Transforms numbers into other values by mapping them from an input range to an output range.
3980 * Returns the type of the input provided.
3981 *
3982 * @remarks
3983 *
3984 * Given an input range of `[0, 200]` and an output range of
3985 * `[0, 1]`, this function will return a value between `0` and `1`.
3986 * The input range must be a linear series of numbers. The output range
3987 * can be any supported value type, such as numbers, colors, shadows, arrays, objects and more.
3988 * Every value in the output range must be of the same type and in the same format.
3989 *
3990 * ```jsx
3991 * import * as React from "react"
3992 * import { transform } from "framer-motion"
3993 *
3994 * export function MyComponent() {
3995 * const inputRange = [0, 200]
3996 * const outputRange = [0, 1]
3997 * const output = transform(100, inputRange, outputRange)
3998 *
3999 * // Returns 0.5
4000 * return <div>{output}</div>
4001 * }
4002 * ```
4003 *
4004 * @param inputValue - A number to transform between the input and output ranges.
4005 * @param inputRange - A linear series of numbers (either all increasing or decreasing).
4006 * @param outputRange - A series of numbers, colors, strings, or arrays/objects of those. Must be the same length as `inputRange`.
4007 * @param options - Clamp: Clamp values to within the given range. Defaults to `true`.
4008 *
4009 * @public
4010 */
4011declare function transform<T>(inputValue: number, inputRange: number[], outputRange: T[], options?: TransformOptions<T>): T;
4012/**
4013 *
4014 * Transforms numbers into other values by mapping them from an input range to an output range.
4015 *
4016 * Given an input range of `[0, 200]` and an output range of
4017 * `[0, 1]`, this function will return a value between `0` and `1`.
4018 * The input range must be a linear series of numbers. The output range
4019 * can be any supported value type, such as numbers, colors, shadows, arrays, objects and more.
4020 * Every value in the output range must be of the same type and in the same format.
4021 *
4022 * ```jsx
4023 * import * as React from "react"
4024 * import { Frame, transform } from "framer"
4025 *
4026 * export function MyComponent() {
4027 * const inputRange = [-200, -100, 100, 200]
4028 * const outputRange = [0, 1, 1, 0]
4029 * const convertRange = transform(inputRange, outputRange)
4030 * const output = convertRange(-150)
4031 *
4032 * // Returns 0.5
4033 * return <div>{output}</div>
4034 * }
4035 *
4036 * ```
4037 *
4038 * @param inputRange - A linear series of numbers (either all increasing or decreasing).
4039 * @param outputRange - A series of numbers, colors or strings. Must be the same length as `inputRange`.
4040 * @param options - Clamp: clamp values to within the given range. Defaults to `true`.
4041 *
4042 * @public
4043 */
4044declare function transform<T>(inputRange: number[], outputRange: T[], options?: TransformOptions<T>): (inputValue: number) => T;
4045
4046declare const clamp: (min: number, max: number, v: number) => number;
4047
4048type DelayedFunction = (overshoot: number) => void;
4049/**
4050 * Timeout defined in ms
4051 */
4052declare function delay(callback: DelayedFunction, timeout: number): () => void;
4053
4054declare const distance: (a: number, b: number) => number;
4055declare function distance2D(a: Point, b: Point): number;
4056
4057type DevMessage = (check: boolean, message: string) => void;
4058declare let warning: DevMessage;
4059declare let invariant: DevMessage;
4060
4061type Mix<T> = (v: number) => T;
4062type MixerFactory<T> = (from: T, to: T) => Mix<T>;
4063interface InterpolateOptions<T> {
4064 clamp?: boolean;
4065 ease?: EasingFunction | EasingFunction[];
4066 mixer?: MixerFactory<T>;
4067}
4068/**
4069 * Create a function that maps from a numerical input array to a generic output array.
4070 *
4071 * Accepts:
4072 * - Numbers
4073 * - Colors (hex, hsl, hsla, rgb, rgba)
4074 * - Complex (combinations of one or more numbers or strings)
4075 *
4076 * ```jsx
4077 * const mixColor = interpolate([0, 1], ['#fff', '#000'])
4078 *
4079 * mixColor(0.5) // 'rgba(128, 128, 128, 1)'
4080 * ```
4081 *
4082 * TODO Revist this approach once we've moved to data models for values,
4083 * probably not needed to pregenerate mixer functions.
4084 *
4085 * @public
4086 */
4087declare function interpolate<T>(input: number[], output: T[], { clamp: isClamp, ease, mixer }?: InterpolateOptions<T>): (v: number) => T;
4088
4089type Mixer<T> = (p: number) => T;
4090
4091declare function mix<T>(from: T, to: T): Mixer<T>;
4092declare function mix(from: number, to: number, p: number): number;
4093
4094declare const pipe: (...transformers: Function[]) => Function;
4095
4096declare const progress: (from: number, to: number, value: number) => number;
4097
4098declare const wrap: (min: number, max: number, v: number) => number;
4099
4100type Process = (data: FrameData) => void;
4101type Schedule = (process: Process, keepAlive?: boolean, immediate?: boolean) => Process;
4102interface Step {
4103 schedule: Schedule;
4104 cancel: (process: Process) => void;
4105 process: (data: FrameData) => void;
4106}
4107type StepId = "read" | "resolveKeyframes" | "update" | "preRender" | "render" | "postRender";
4108type Batcher = {
4109 [key in StepId]: Schedule;
4110};
4111type Steps = {
4112 [key in StepId]: Step;
4113};
4114interface FrameData {
4115 delta: number;
4116 timestamp: number;
4117 isProcessing: boolean;
4118}
4119
4120declare const frame: Batcher;
4121declare const cancelFrame: (process: Process) => void;
4122declare const frameData: FrameData;
4123declare const frameSteps: Steps;
4124
4125/**
4126 * @deprecated
4127 *
4128 * Import as `frame` instead.
4129 */
4130declare const sync: Batcher;
4131/**
4132 * @deprecated
4133 *
4134 * Use cancelFrame(callback) instead.
4135 */
4136declare const cancelSync: Record<string, (process: Process) => void>;
4137
4138declare const animations: FeaturePackages;
4139
4140interface MotionContextProps<Instance = unknown> {
4141 visualElement?: VisualElement<Instance>;
4142 initial?: false | string | string[];
4143 animate?: string | string[];
4144}
4145declare const MotionContext: React$1.Context<MotionContextProps<unknown>>;
4146
4147declare const createBox: () => Box;
4148
4149declare function calcLength(axis: Axis): number;
4150
4151declare function isDragActive(): boolean;
4152
4153type EventListenerWithPointInfo = (e: PointerEvent, info: EventInfo) => void;
4154declare const addPointerInfo: (handler: EventListenerWithPointInfo) => EventListener;
4155
4156declare function addPointerEvent(target: EventTarget, eventName: string, handler: EventListenerWithPointInfo, options?: AddEventListenerOptions): () => void;
4157
4158declare const isMotionValue: (value: any) => value is MotionValue<any>;
4159
4160declare const isBrowser: boolean;
4161
4162declare function useUnmountEffect(callback: () => void): void;
4163
4164declare const useIsomorphicLayoutEffect: typeof useEffect;
4165
4166declare function useForceUpdate(): [VoidFunction, number];
4167
4168/**
4169 * @public
4170 */
4171declare const domMin: FeatureBundle;
4172
4173/**
4174 * @public
4175 */
4176declare const domAnimation: FeatureBundle;
4177
4178/**
4179 * @public
4180 */
4181declare const domMax: FeatureBundle;
4182
4183/**
4184 * Creates a `MotionValue` to track the state and velocity of a value.
4185 *
4186 * Usually, these are created automatically. For advanced use-cases, like use with `useTransform`, you can create `MotionValue`s externally and pass them into the animated component via the `style` prop.
4187 *
4188 * ```jsx
4189 * export const MyComponent = () => {
4190 * const scale = useMotionValue(1)
4191 *
4192 * return <motion.div style={{ scale }} />
4193 * }
4194 * ```
4195 *
4196 * @param initial - The initial state.
4197 *
4198 * @public
4199 */
4200declare function useMotionValue<T>(initial: T): MotionValue<T>;
4201
4202/**
4203 * Combine multiple motion values into a new one using a string template literal.
4204 *
4205 * ```jsx
4206 * import {
4207 * motion,
4208 * useSpring,
4209 * useMotionValue,
4210 * useMotionTemplate
4211 * } from "framer-motion"
4212 *
4213 * function Component() {
4214 * const shadowX = useSpring(0)
4215 * const shadowY = useMotionValue(0)
4216 * const shadow = useMotionTemplate`drop-shadow(${shadowX}px ${shadowY}px 20px rgba(0,0,0,0.3))`
4217 *
4218 * return <motion.div style={{ filter: shadow }} />
4219 * }
4220 * ```
4221 *
4222 * @public
4223 */
4224declare function useMotionTemplate(fragments: TemplateStringsArray, ...values: Array<MotionValue | number | string>): MotionValue<string>;
4225
4226/**
4227 * If the provided value is a MotionValue, this returns the actual value, otherwise just the value itself
4228 *
4229 * TODO: Remove and move to library
4230 */
4231declare function resolveMotionValue(value?: string | number | CustomValueType | MotionValue): string | number;
4232
4233type InputRange = number[];
4234type SingleTransformer<I, O> = (input: I) => O;
4235type MultiTransformer<I, O> = (input: I[]) => O;
4236/**
4237 * Create a `MotionValue` that transforms the output of another `MotionValue` by mapping it from one range of values into another.
4238 *
4239 * @remarks
4240 *
4241 * Given an input range of `[-200, -100, 100, 200]` and an output range of
4242 * `[0, 1, 1, 0]`, the returned `MotionValue` will:
4243 *
4244 * - When provided a value between `-200` and `-100`, will return a value between `0` and `1`.
4245 * - When provided a value between `-100` and `100`, will return `1`.
4246 * - When provided a value between `100` and `200`, will return a value between `1` and `0`
4247 *
4248 *
4249 * The input range must be a linear series of numbers. The output range
4250 * can be any value type supported by Framer Motion: numbers, colors, shadows, etc.
4251 *
4252 * Every value in the output range must be of the same type and in the same format.
4253 *
4254 * ```jsx
4255 * export const MyComponent = () => {
4256 * const x = useMotionValue(0)
4257 * const xRange = [-200, -100, 100, 200]
4258 * const opacityRange = [0, 1, 1, 0]
4259 * const opacity = useTransform(x, xRange, opacityRange)
4260 *
4261 * return (
4262 * <motion.div
4263 * animate={{ x: 200 }}
4264 * style={{ opacity, x }}
4265 * />
4266 * )
4267 * }
4268 * ```
4269 *
4270 * @param inputValue - `MotionValue`
4271 * @param inputRange - A linear series of numbers (either all increasing or decreasing)
4272 * @param outputRange - A series of numbers, colors or strings. Must be the same length as `inputRange`.
4273 * @param options -
4274 *
4275 * - clamp: boolean. Clamp values to within the given range. Defaults to `true`
4276 * - ease: EasingFunction[]. Easing functions to use on the interpolations between each value in the input and output ranges. If provided as an array, the array must be one item shorter than the input and output ranges, as the easings apply to the transition between each.
4277 *
4278 * @returns `MotionValue`
4279 *
4280 * @public
4281 */
4282declare function useTransform<I, O>(value: MotionValue<number>, inputRange: InputRange, outputRange: O[], options?: TransformOptions<O>): MotionValue<O>;
4283/**
4284 * Create a `MotionValue` that transforms the output of another `MotionValue` through a function.
4285 * In this example, `y` will always be double `x`.
4286 *
4287 * ```jsx
4288 * export const MyComponent = () => {
4289 * const x = useMotionValue(10)
4290 * const y = useTransform(x, value => value * 2)
4291 *
4292 * return <motion.div style={{ x, y }} />
4293 * }
4294 * ```
4295 *
4296 * @param input - A `MotionValue` that will pass its latest value through `transform` to update the returned `MotionValue`.
4297 * @param transform - A function that accepts the latest value from `input` and returns a new value.
4298 * @returns `MotionValue`
4299 *
4300 * @public
4301 */
4302declare function useTransform<I, O>(input: MotionValue<I>, transformer: SingleTransformer<I, O>): MotionValue<O>;
4303/**
4304 * Pass an array of `MotionValue`s and a function to combine them. In this example, `z` will be the `x` multiplied by `y`.
4305 *
4306 * ```jsx
4307 * export const MyComponent = () => {
4308 * const x = useMotionValue(0)
4309 * const y = useMotionValue(0)
4310 * const z = useTransform([x, y], ([latestX, latestY]) => latestX * latestY)
4311 *
4312 * return <motion.div style={{ x, y, z }} />
4313 * }
4314 * ```
4315 *
4316 * @param input - An array of `MotionValue`s that will pass their latest values through `transform` to update the returned `MotionValue`.
4317 * @param transform - A function that accepts the latest values from `input` and returns a new value.
4318 * @returns `MotionValue`
4319 *
4320 * @public
4321 */
4322declare function useTransform<I, O>(input: MotionValue<string>[] | MotionValue<number>[] | MotionValue<string | number>[], transformer: MultiTransformer<I, O>): MotionValue<O>;
4323declare function useTransform<I, O>(transformer: () => O): MotionValue<O>;
4324
4325/**
4326 * Creates a `MotionValue` that, when `set`, will use a spring animation to animate to its new state.
4327 *
4328 * It can either work as a stand-alone `MotionValue` by initialising it with a value, or as a subscriber
4329 * to another `MotionValue`.
4330 *
4331 * @remarks
4332 *
4333 * ```jsx
4334 * const x = useSpring(0, { stiffness: 300 })
4335 * const y = useSpring(x, { damping: 10 })
4336 * ```
4337 *
4338 * @param inputValue - `MotionValue` or number. If provided a `MotionValue`, when the input `MotionValue` changes, the created `MotionValue` will spring towards that value.
4339 * @param springConfig - Configuration options for the spring.
4340 * @returns `MotionValue`
4341 *
4342 * @public
4343 */
4344declare function useSpring(source: MotionValue<string> | MotionValue<number> | number, config?: SpringOptions): MotionValue<number>;
4345
4346/**
4347 * Creates a `MotionValue` that updates when the velocity of the provided `MotionValue` changes.
4348 *
4349 * ```javascript
4350 * const x = useMotionValue(0)
4351 * const xVelocity = useVelocity(x)
4352 * const xAcceleration = useVelocity(xVelocity)
4353 * ```
4354 *
4355 * @public
4356 */
4357declare function useVelocity(value: MotionValue<number>): MotionValue<number>;
4358
4359interface UseScrollOptions extends Omit<ScrollInfoOptions, "container" | "target"> {
4360 container?: RefObject$1<HTMLElement>;
4361 target?: RefObject$1<HTMLElement>;
4362 layoutEffect?: boolean;
4363}
4364declare function useScroll({ container, target, layoutEffect, ...options }?: UseScrollOptions): {
4365 scrollX: MotionValue<number>;
4366 scrollY: MotionValue<number>;
4367 scrollXProgress: MotionValue<number>;
4368 scrollYProgress: MotionValue<number>;
4369};
4370
4371/**
4372 * @deprecated useElementScroll is deprecated. Convert to useScroll({ container: ref })
4373 */
4374declare function useElementScroll(ref: RefObject$1<HTMLElement>): {
4375 scrollX: MotionValue<number>;
4376 scrollY: MotionValue<number>;
4377 scrollXProgress: MotionValue<number>;
4378 scrollYProgress: MotionValue<number>;
4379};
4380
4381/**
4382 * @deprecated useViewportScroll is deprecated. Convert to useScroll()
4383 */
4384declare function useViewportScroll(): {
4385 scrollX: MotionValue<number>;
4386 scrollY: MotionValue<number>;
4387 scrollXProgress: MotionValue<number>;
4388 scrollYProgress: MotionValue<number>;
4389};
4390
4391declare function useTime(): MotionValue<number>;
4392
4393interface WillChange extends MotionValue {
4394 add(name: string): void;
4395}
4396
4397declare function useWillChange(): WillChange;
4398
4399declare function useMotionValueEvent<V, EventName extends keyof MotionValueEventCallbacks<V>>(value: MotionValue<V>, event: EventName, callback: MotionValueEventCallbacks<V>[EventName]): void;
4400
4401/**
4402 * A hook that returns `true` if we should be using reduced motion based on the current device's Reduced Motion setting.
4403 *
4404 * This can be used to implement changes to your UI based on Reduced Motion. For instance, replacing motion-sickness inducing
4405 * `x`/`y` animations with `opacity`, disabling the autoplay of background videos, or turning off parallax motion.
4406 *
4407 * It will actively respond to changes and re-render your components with the latest setting.
4408 *
4409 * ```jsx
4410 * export function Sidebar({ isOpen }) {
4411 * const shouldReduceMotion = useReducedMotion()
4412 * const closedX = shouldReduceMotion ? 0 : "-100%"
4413 *
4414 * return (
4415 * <motion.div animate={{
4416 * opacity: isOpen ? 1 : 0,
4417 * x: isOpen ? 0 : closedX
4418 * }} />
4419 * )
4420 * }
4421 * ```
4422 *
4423 * @return boolean
4424 *
4425 * @public
4426 */
4427declare function useReducedMotion(): boolean | null;
4428
4429declare function useReducedMotionConfig(): boolean | null;
4430
4431/**
4432 * @public
4433 */
4434declare function animationControls(): AnimationControls;
4435
4436declare function useAnimate<T extends Element = any>(): [AnimationScope<T>, {
4437 (sequence: AnimationSequence, options?: SequenceOptions | undefined): AnimationPlaybackControls;
4438 (value: string | MotionValue<string>, keyframes: string | GenericKeyframesTarget<string>, options?: ValueAnimationTransition<string> | undefined): AnimationPlaybackControls;
4439 (value: number | MotionValue<number>, keyframes: number | GenericKeyframesTarget<number>, options?: ValueAnimationTransition<number> | undefined): AnimationPlaybackControls;
4440 <V>(value: V | MotionValue<V>, keyframes: V | GenericKeyframesTarget<V>, options?: ValueAnimationTransition<V> | undefined): AnimationPlaybackControls;
4441 (element: ElementOrSelector, keyframes: DOMKeyframesDefinition, options?: DynamicAnimationOptions | undefined): AnimationPlaybackControls;
4442 <O extends {}>(object: O | O[], keyframes: ObjectTarget<O>, options?: DynamicAnimationOptions | undefined): AnimationPlaybackControls;
4443}];
4444
4445declare function useAnimateMini<T extends Element = any>(): [AnimationScope<T>, (elementOrSelector: ElementOrSelector, keyframes: DOMKeyframesDefinition, options?: DynamicAnimationOptions | undefined) => GroupPlaybackControls];
4446
4447/**
4448 * Creates `AnimationControls`, which can be used to manually start, stop
4449 * and sequence animations on one or more components.
4450 *
4451 * The returned `AnimationControls` should be passed to the `animate` property
4452 * of the components you want to animate.
4453 *
4454 * These components can then be animated with the `start` method.
4455 *
4456 * ```jsx
4457 * import * as React from 'react'
4458 * import { motion, useAnimation } from 'framer-motion'
4459 *
4460 * export function MyComponent(props) {
4461 * const controls = useAnimation()
4462 *
4463 * controls.start({
4464 * x: 100,
4465 * transition: { duration: 0.5 },
4466 * })
4467 *
4468 * return <motion.div animate={controls} />
4469 * }
4470 * ```
4471 *
4472 * @returns Animation controller with `start` and `stop` methods
4473 *
4474 * @public
4475 */
4476declare function useAnimationControls(): AnimationControls;
4477declare const useAnimation: typeof useAnimationControls;
4478
4479type FrameCallback = (timestamp: number, delta: number) => void;
4480declare function useAnimationFrame(callback: FrameCallback): void;
4481
4482declare function animateVisualElement(visualElement: VisualElement, definition: AnimationDefinition, options?: VisualElementAnimationOptions): Promise<void>;
4483
4484type Cycle = (i?: number) => void;
4485type CycleState<T> = [T, Cycle];
4486/**
4487 * Cycles through a series of visual properties. Can be used to toggle between or cycle through animations. It works similar to `useState` in React. It is provided an initial array of possible states, and returns an array of two arguments.
4488 *
4489 * An index value can be passed to the returned `cycle` function to cycle to a specific index.
4490 *
4491 * ```jsx
4492 * import * as React from "react"
4493 * import { motion, useCycle } from "framer-motion"
4494 *
4495 * export const MyComponent = () => {
4496 * const [x, cycleX] = useCycle(0, 50, 100)
4497 *
4498 * return (
4499 * <motion.div
4500 * animate={{ x: x }}
4501 * onTap={() => cycleX()}
4502 * />
4503 * )
4504 * }
4505 * ```
4506 *
4507 * @param items - items to cycle through
4508 * @returns [currentState, cycleState]
4509 *
4510 * @public
4511 */
4512declare function useCycle<T>(...items: T[]): CycleState<T>;
4513
4514/**
4515 * Check whether a prop name is a valid `MotionProp` key.
4516 *
4517 * @param key - Name of the property to check
4518 * @returns `true` is key is a valid `MotionProp`.
4519 *
4520 * @public
4521 */
4522declare function isValidMotionProp(key: string): boolean;
4523
4524type SafeToRemove = () => void;
4525type AlwaysPresent = [true, null];
4526type Present = [true];
4527type NotPresent = [false, SafeToRemove];
4528/**
4529 * When a component is the child of `AnimatePresence`, it can use `usePresence`
4530 * to access information about whether it's still present in the React tree.
4531 *
4532 * ```jsx
4533 * import { usePresence } from "framer-motion"
4534 *
4535 * export const Component = () => {
4536 * const [isPresent, safeToRemove] = usePresence()
4537 *
4538 * useEffect(() => {
4539 * !isPresent && setTimeout(safeToRemove, 1000)
4540 * }, [isPresent])
4541 *
4542 * return <div />
4543 * }
4544 * ```
4545 *
4546 * If `isPresent` is `false`, it means that a component has been removed the tree, but
4547 * `AnimatePresence` won't really remove it until `safeToRemove` has been called.
4548 *
4549 * @public
4550 */
4551declare function usePresence(): AlwaysPresent | Present | NotPresent;
4552/**
4553 * Similar to `usePresence`, except `useIsPresent` simply returns whether or not the component is present.
4554 * There is no `safeToRemove` function.
4555 *
4556 * ```jsx
4557 * import { useIsPresent } from "framer-motion"
4558 *
4559 * export const Component = () => {
4560 * const isPresent = useIsPresent()
4561 *
4562 * useEffect(() => {
4563 * !isPresent && console.log("I've been removed!")
4564 * }, [isPresent])
4565 *
4566 * return <div />
4567 * }
4568 * ```
4569 *
4570 * @public
4571 */
4572declare function useIsPresent(): boolean;
4573
4574interface UseInViewOptions extends Omit<InViewOptions, "root" | "amount"> {
4575 root?: RefObject$1<Element>;
4576 once?: boolean;
4577 amount?: "some" | "all" | number;
4578}
4579declare function useInView(ref: RefObject$1<Element>, { root, margin, amount, once }?: UseInViewOptions): boolean;
4580
4581/**
4582 * Attaches an event listener directly to the provided DOM element.
4583 *
4584 * Bypassing React's event system can be desirable, for instance when attaching non-passive
4585 * event handlers.
4586 *
4587 * ```jsx
4588 * const ref = useRef(null)
4589 *
4590 * useDomEvent(ref, 'wheel', onWheel, { passive: false })
4591 *
4592 * return <div ref={ref} />
4593 * ```
4594 *
4595 * @param ref - React.RefObject that's been provided to the element you want to bind the listener to.
4596 * @param eventName - Name of the event you want listen for.
4597 * @param handler - Function to fire when receiving the event.
4598 * @param options - Options to pass to `Event.addEventListener`.
4599 *
4600 * @public
4601 */
4602declare function useDomEvent(ref: RefObject$1<EventTarget>, eventName: string, handler?: EventListener | undefined, options?: AddEventListenerOptions): void;
4603
4604/**
4605 * Checks if a component is a `motion` component.
4606 */
4607declare function isMotionComponent(component: React.ComponentType | string): boolean;
4608
4609/**
4610 * Unwraps a `motion` component and returns either a string for `motion.div` or
4611 * the React component for `motion(Component)`.
4612 *
4613 * If the component is not a `motion` component it returns undefined.
4614 */
4615declare function unwrapMotionComponent(component: React.ComponentType | string): React.ComponentType | string | undefined;
4616
4617type ScaleCorrector = (latest: string | number, node: IProjectionNode) => string | number;
4618interface ScaleCorrectorDefinition {
4619 correct: ScaleCorrector;
4620 applyTo?: string[];
4621}
4622interface ScaleCorrectorMap {
4623 [key: string]: ScaleCorrectorDefinition;
4624}
4625
4626declare function addScaleCorrector(correctors: ScaleCorrectorMap): void;
4627
4628declare function useInstantTransition(): (callback: () => void) => void;
4629declare function disableInstantTransitions(): void;
4630
4631declare function useInstantLayoutTransition(): (cb?: (() => void) | undefined) => void;
4632
4633declare function useResetProjection(): () => void;
4634
4635/**
4636 * Build a CSS transform style from individual x/y/scale etc properties.
4637 *
4638 * This outputs with a default order of transforms/scales/rotations, this can be customised by
4639 * providing a transformTemplate function.
4640 */
4641declare function buildTransform(latestValues: ResolvedValues, transform: HTMLRenderState["transform"], transformTemplate?: MotionProps["transformTemplate"]): string;
4642
4643declare const visualElementStore: WeakMap<any, VisualElement<unknown, unknown, {}>>;
4644
4645interface ValueAnimationOptionsWithDefaults<T extends string | number> extends ValueAnimationOptionsWithRenderContext<T> {
4646 autoplay: boolean;
4647 delay: number;
4648 repeat: number;
4649 repeatDelay: number;
4650 repeatType: RepeatType;
4651}
4652declare abstract class BaseAnimation<T extends string | number, Resolved> implements AnimationPlaybackControls {
4653 protected options: ValueAnimationOptionsWithDefaults<T>;
4654 protected resolveFinishedPromise: VoidFunction;
4655 protected currentFinishedPromise: Promise<void>;
4656 protected isStopped: boolean;
4657 protected _resolved: Resolved & {
4658 keyframes: ResolvedKeyframes<T>;
4659 };
4660 protected hasAttemptedResolve: boolean;
4661 protected resolver: KeyframeResolver<T>;
4662 private createdAt;
4663 private resolvedAt;
4664 constructor({ autoplay, delay, type, repeat, repeatDelay, repeatType, ...options }: ValueAnimationOptions<T>);
4665 /**
4666 * This method uses the createdAt and resolvedAt to calculate the
4667 * animation startTime. *Ideally*, we would use the createdAt time as t=0
4668 * as the following frame would then be the first frame of the animation in
4669 * progress, which would feel snappier.
4670 *
4671 * However, if there's a delay (main thread work) between the creation of
4672 * the animation and the first commited frame, we prefer to use resolvedAt
4673 * to avoid a sudden jump into the animation.
4674 */
4675 calcStartTime(): number;
4676 protected abstract initPlayback(keyframes: ResolvedKeyframes<T>, finalKeyframe?: T): Resolved | false;
4677 abstract play(): void;
4678 abstract pause(): void;
4679 abstract stop(): void;
4680 abstract cancel(): void;
4681 abstract complete(): void;
4682 abstract get speed(): number;
4683 abstract set speed(newSpeed: number);
4684 abstract get time(): number;
4685 abstract set time(newTime: number);
4686 abstract get duration(): number;
4687 abstract get state(): AnimationPlayState;
4688 abstract get startTime(): number | null;
4689 /**
4690 * A getter for resolved data. If keyframes are not yet resolved, accessing
4691 * this.resolved will synchronously flush all pending keyframe resolvers.
4692 * This is a deoptimisation, but at its worst still batches read/writes.
4693 */
4694 get resolved(): (Resolved & {
4695 keyframes: ResolvedKeyframes<T>;
4696 finalKeyframe?: T;
4697 }) | undefined;
4698 /**
4699 * A method to be called when the keyframes resolver completes. This method
4700 * will check if its possible to run the animation and, if not, skip it.
4701 * Otherwise, it will call initPlayback on the implementing class.
4702 */
4703 protected onKeyframesResolved(keyframes: ResolvedKeyframes<T>, finalKeyframe?: T): void;
4704 onPostResolved(): void;
4705 /**
4706 * Allows the returned animation to be awaited or promise-chained. Currently
4707 * resolves when the animation finishes at all but in a future update could/should
4708 * reject if its cancels.
4709 */
4710 then(resolve: VoidFunction, reject?: VoidFunction): Promise<void>;
4711 protected updateFinishedPromise(): void;
4712}
4713
4714interface ResolvedData<T extends string | number> {
4715 generator: KeyframeGenerator<T>;
4716 mirroredGenerator: KeyframeGenerator<T> | undefined;
4717 mapPercentToKeyframes: ((v: number) => T) | undefined;
4718 /**
4719 * Duration of the animation as calculated by the generator.
4720 */
4721 calculatedDuration: number;
4722 /**
4723 * Duration of the animation plus repeatDelay.
4724 */
4725 resolvedDuration: number;
4726 /**
4727 * Total duration of the animation including repeats.
4728 */
4729 totalDuration: number;
4730}
4731/**
4732 * Animation that runs on the main thread. Designed to be WAAPI-spec in the subset of
4733 * features we expose publically. Mostly the compatibility is to ensure visual identity
4734 * between both WAAPI and main thread animations.
4735 */
4736declare class MainThreadAnimation<T extends string | number> extends BaseAnimation<T, ResolvedData<T>> {
4737 /**
4738 * The driver that's controlling the animation loop. Normally this is a requestAnimationFrame loop
4739 * but in tests we can pass in a synchronous loop.
4740 */
4741 private driver?;
4742 /**
4743 * The time at which the animation was paused.
4744 */
4745 private holdTime;
4746 /**
4747 * The time at which the animation was cancelled.
4748 */
4749 private cancelTime;
4750 /**
4751 * The current time of the animation.
4752 */
4753 private currentTime;
4754 /**
4755 * Playback speed as a factor. 0 would be stopped, -1 reverse and 2 double speed.
4756 */
4757 private playbackSpeed;
4758 /**
4759 * The state of the animation to apply when the animation is resolved. This
4760 * allows calls to the public API to control the animation before it is resolved,
4761 * without us having to resolve it first.
4762 */
4763 private pendingPlayState;
4764 /**
4765 * The time at which the animation was started.
4766 */
4767 startTime: number | null;
4768 constructor(options: ValueAnimationOptions<T>);
4769 protected initPlayback(keyframes: ResolvedKeyframes<T>): {
4770 generator: KeyframeGenerator<any>;
4771 mirroredGenerator: KeyframeGenerator<T> | undefined;
4772 mapPercentToKeyframes: ((v: number) => T) | undefined;
4773 calculatedDuration: number;
4774 resolvedDuration: number;
4775 totalDuration: number;
4776 };
4777 onPostResolved(): void;
4778 tick(timestamp: number, sample?: boolean): {
4779 done: boolean;
4780 value: T;
4781 };
4782 state: AnimationPlayState;
4783 get duration(): number;
4784 get time(): number;
4785 set time(newTime: number);
4786 get speed(): number;
4787 set speed(newSpeed: number);
4788 play(): void;
4789 pause(): void;
4790 /**
4791 * This method is bound to the instance to fix a pattern where
4792 * animation.stop is returned as a reference from a useEffect.
4793 */
4794 stop: () => void;
4795 complete(): void;
4796 finish(): void;
4797 cancel(): void;
4798 private teardown;
4799 private stopDriver;
4800 sample(time: number): AnimationState<T>;
4801}
4802declare function animateValue(options: ValueAnimationOptionsWithRenderContext<any>): MainThreadAnimation<any>;
4803
4804type Transformer = (v: any) => any;
4805type ValueType = {
4806 test: (v: any) => boolean;
4807 parse: (v: any) => any;
4808 transform?: Transformer;
4809 createTransformer?: (template: string) => Transformer;
4810 default?: any;
4811 getAnimatableNone?: (v: any) => any;
4812};
4813type RGBA = {
4814 red: number;
4815 green: number;
4816 blue: number;
4817 alpha: number;
4818};
4819type HSLA = {
4820 hue: number;
4821 saturation: number;
4822 lightness: number;
4823 alpha: number;
4824};
4825type Color = HSLA | RGBA;
4826
4827declare const color: {
4828 test: (v: any) => boolean;
4829 parse: (v: any) => RGBA | HSLA;
4830 transform: (v: HSLA | RGBA | string) => string;
4831};
4832
4833type CSSVariableName = `--${string}`;
4834type CSSVariableToken = `var(${CSSVariableName})`;
4835
4836declare function test(v: any): boolean;
4837type ComplexValues = Array<CSSVariableToken | string | number | Color>;
4838declare function parseComplexValue(v: string | number): ComplexValues;
4839declare function createTransformer(source: string | number): (v: Array<CSSVariableToken | Color | number | string>) => string;
4840declare function getAnimatableNone(v: string | number): string;
4841declare const complex: {
4842 test: typeof test;
4843 parse: typeof parseComplexValue;
4844 createTransformer: typeof createTransformer;
4845 getAnimatableNone: typeof getAnimatableNone;
4846};
4847
4848declare const px: {
4849 test: (v: string | number) => boolean;
4850 parse: typeof parseFloat;
4851 transform: (v: number | string) => string;
4852};
4853
4854declare const MotionGlobalConfig: {
4855 skipAnimations: boolean;
4856 useManualTiming: boolean;
4857};
4858
4859interface AcceleratedValueAnimationOptions<T extends string | number = number> extends ValueAnimationOptions<T> {
4860 name: string;
4861 motionValue: MotionValue<T>;
4862}
4863interface ResolvedAcceleratedAnimation {
4864 animation: Animation;
4865 duration: number;
4866 times: ValueAnimationOptions["times"];
4867 type: ValueAnimationOptions["type"];
4868 ease: ValueAnimationOptions["ease"];
4869 keyframes: string[] | number[];
4870}
4871declare class AcceleratedAnimation<T extends string | number> extends BaseAnimation<T, ResolvedAcceleratedAnimation> {
4872 protected options: ValueAnimationOptionsWithDefaults<T> & {
4873 name: string;
4874 motionValue: MotionValue<T>;
4875 };
4876 constructor(options: ValueAnimationOptionsWithRenderContext<T>);
4877 /**
4878 * An AnimationTimline to attach to the WAAPI animation once it's created.
4879 */
4880 private pendingTimeline;
4881 protected initPlayback(keyframes: ResolvedKeyframes<T>, finalKeyframe: T): false | {
4882 animation: Animation;
4883 duration: number;
4884 times: number[] | undefined;
4885 type: AnimationGeneratorType | undefined;
4886 ease: Easing | Easing[] | undefined;
4887 keyframes: number[] | string[];
4888 };
4889 get duration(): number;
4890 get time(): number;
4891 set time(newTime: number);
4892 get speed(): number;
4893 set speed(newSpeed: number);
4894 get state(): AnimationPlayState;
4895 get startTime(): number | null;
4896 /**
4897 * Replace the default DocumentTimeline with another AnimationTimeline.
4898 * Currently used for scroll animations.
4899 */
4900 attachTimeline(timeline: any): (any: void) => void;
4901 play(): void;
4902 pause(): void;
4903 stop(): void;
4904 complete(): void;
4905 cancel(): void;
4906 static supports(options: ValueAnimationOptionsWithRenderContext): options is AcceleratedValueAnimationOptions;
4907}
4908
4909interface NativeAnimationOptions {
4910 delay?: number;
4911 duration?: number;
4912 ease?: Easing | Easing[];
4913 times?: number[];
4914 repeat?: number;
4915 repeatType?: "loop" | "reverse" | "mirror";
4916}
4917
4918declare const optimizedAppearDataAttribute: "data-framer-appear-id";
4919
4920/**
4921 * Expose only the needed part of the VisualElement interface to
4922 * ensure React types don't end up in the generic DOM bundle.
4923 */
4924interface WithAppearProps {
4925 props: {
4926 [optimizedAppearDataAttribute]?: string;
4927 values?: {
4928 [key: string]: MotionValue<number> | MotionValue<string>;
4929 };
4930 };
4931}
4932type HandoffFunction = (storeId: string, valueName: string, frame: Batcher) => number | null;
4933/**
4934 * The window global object acts as a bridge between our inline script
4935 * triggering the optimized appear animations, and Framer Motion.
4936 */
4937declare global {
4938 interface Window {
4939 MotionHandoffAnimation?: HandoffFunction;
4940 MotionHandoffMarkAsComplete?: (elementId: string) => void;
4941 MotionHandoffIsComplete?: (elementId: string) => boolean;
4942 MotionHasOptimisedAnimation?: (elementId?: string, valueName?: string) => boolean;
4943 MotionCancelOptimisedAnimation?: (elementId?: string, valueName?: string, frame?: Batcher, canResume?: boolean) => void;
4944 MotionCheckAppearSync?: (visualElement: WithAppearProps, valueName: string, value: MotionValue) => VoidFunction | void;
4945 MotionIsMounted?: boolean;
4946 }
4947}
4948
4949declare function startOptimizedAppearAnimation(element: HTMLElement, name: string, keyframes: string[] | number[], options: NativeAnimationOptions, onReady?: (animation: Animation) => void): void;
4950
4951declare function findSpring({ duration, bounce, velocity, mass, }: SpringOptions): {
4952 stiffness: number;
4953 damping: number;
4954 duration: number;
4955};
4956
4957interface NodeGroup {
4958 add: (node: IProjectionNode) => void;
4959 remove: (node: IProjectionNode) => void;
4960 dirty: VoidFunction;
4961}
4962
4963interface LayoutGroupContextProps {
4964 id?: string;
4965 group?: NodeGroup;
4966 forceRender?: VoidFunction;
4967}
4968declare const LayoutGroupContext: React$1.Context<LayoutGroupContextProps>;
4969
4970type DOMMotionComponents = HTMLMotionComponents & SVGMotionComponents;
4971
4972/**
4973 * @public
4974 */
4975interface ScrollMotionValues {
4976 scrollX: MotionValue<number>;
4977 scrollY: MotionValue<number>;
4978 scrollXProgress: MotionValue<number>;
4979 scrollYProgress: MotionValue<number>;
4980}
4981
4982/**
4983 * Note: Still used by components generated by old versions of Framer
4984 *
4985 * @deprecated
4986 */
4987declare const DeprecatedLayoutGroupContext: React$1.Context<string | null>;
4988
4989/**
4990 * This is not an officially supported API and may be removed
4991 * on any version.
4992 */
4993declare function useAnimatedState(initialState: any): any[];
4994
4995interface ScaleMotionValues {
4996 scaleX: MotionValue<number>;
4997 scaleY: MotionValue<number>;
4998}
4999/**
5000 * Returns a `MotionValue` each for `scaleX` and `scaleY` that update with the inverse
5001 * of their respective parent scales.
5002 *
5003 * This is useful for undoing the distortion of content when scaling a parent component.
5004 *
5005 * By default, `useInvertedScale` will automatically fetch `scaleX` and `scaleY` from the nearest parent.
5006 * By passing other `MotionValue`s in as `useInvertedScale({ scaleX, scaleY })`, it will invert the output
5007 * of those instead.
5008 *
5009 * ```jsx
5010 * const MyComponent = () => {
5011 * const { scaleX, scaleY } = useInvertedScale()
5012 * return <motion.div style={{ scaleX, scaleY }} />
5013 * }
5014 * ```
5015 *
5016 * @deprecated
5017 */
5018declare function useInvertedScale(scale?: Partial<ScaleMotionValues>): ScaleMotionValues;
5019
5020declare const AnimateSharedLayout: React$1.FunctionComponent<React$1.PropsWithChildren<unknown>>;
5021
5022export { type AbsoluteKeyframe, AcceleratedAnimation, AnimatePresence, type AnimatePresenceProps, AnimateSharedLayout, type AnimationControls, type AnimationDefinition, type AnimationGeneratorType, type AnimationLifecycles, type AnimationOptionsWithValueOverrides, type AnimationPlaybackControls, type AnimationPlaybackLifecycles, type AnimationPlaybackOptions, type AnimationProps, type AnimationScope, type AnimationSequence, type AnimationType, type At, type Axis, type AxisDelta, type BezierDefinition, type BoundingBox, type Box, type CSSStyleDeclarationWithTransform, type CreateVisualElement, type CustomValueType, type Cycle, type CycleState, type DOMKeyframesDefinition, type DOMMotionComponents, type DOMSegment, type DOMSegmentWithTransition, type DecayOptions, type DelayedFunction, type Delta, DeprecatedLayoutGroupContext, type DevMessage, type Direction, DragControls, type DragElastic, type DragHandlers, type DraggableProps, type DurationSpringOptions, type DynamicAnimationOptions, type DynamicOption, type Easing, type EasingDefinition, type EasingFunction, type EasingModifier, type ElementOrSelector, type EventInfo, type FeatureBundle, type FeatureDefinition, type FeatureDefinitions, type FeaturePackage, type FeaturePackages, FlatTree, type FocusHandlers, type ForwardRefComponent, type GeneratorFactory, type HTMLMotionProps, type HoverHandlers, type HydratedFeatureDefinition, type HydratedFeatureDefinitions, type IProjectionNode, type Inertia, type InertiaOptions$1 as InertiaOptions, type InterpolateOptions, type KeyframeOptions, type Keyframes, type KeyframesTarget, LayoutGroup, LayoutGroupContext, type LayoutProps, type LazyFeatureBundle$1 as LazyFeatureBundle, LazyMotion, type LazyProps, type MixerFactory, type MotionAdvancedProps, MotionConfig, MotionConfigContext, type MotionConfigProps, MotionContext, MotionGlobalConfig, type MotionProps, type MotionStyle, type MotionTransform, MotionValue, type MotionValueSegment, type MotionValueSegmentWithTransition, type None, type ObjectSegment, type ObjectSegmentWithTransition, type ObjectTarget, type Orchestration, type PanHandlers, type PanInfo, type PassiveEffect, type Point, PresenceContext, type RenderComponent, namespace_d as Reorder, type Repeat, type RepeatType, type ResolveKeyframes, type ResolvedAnimationDefinition, type ResolvedAnimationDefinitions, type ResolvedKeyframesTarget, type ResolvedSingleTarget, type ResolvedValueTarget, type ResolvedValues, type SVGAttributesAsMotionValues, type SVGKeyframesDefinition, type SVGMotionProps, type SVGPathKeyframesDefinition, type SVGPathTransitions, type SVGTransitions, type ScrapeMotionValuesFromProps, type ScrollMotionValues, type Segment, type SequenceLabel, type SequenceLabelWithTime, type SequenceMap, type SequenceOptions, type SequenceTime, type SingleTarget, type Spring, type SpringOptions, type StyleKeyframesDefinition, type StyleTransitions, type Subscriber, SwitchLayoutGroupContext, type TapHandlers, type TapInfo, type Target, type TargetAndTransition, type TransformPoint, type Transition$1 as Transition, type Tween, type UnresolvedValueKeyframe, type UseInViewOptions, type UseScrollOptions, type ValueAnimationOptions, type ValueAnimationOptionsWithRenderContext, type ValueAnimationTransition, type ValueKeyframe, type ValueKeyframesDefinition, type ValueSequence, type ValueTarget, type ValueType, type VariableKeyframesDefinition, type VariableTransitions, type Variant, type VariantLabels, type Variants, type VelocityOptions, VisualElement, type VisualState, addPointerEvent, addPointerInfo, addScaleCorrector, animate, animateMini, animateValue, animateVisualElement, animationControls, animations, anticipate, backIn, backInOut, backOut, buildTransform, calcLength, cancelFrame, cancelSync, circIn, circInOut, circOut, clamp, color, complex, createBox, createRendererMotionComponent, createScopedAnimate, cubicBezier, delay, disableInstantTransitions, distance, distance2D, domAnimation, domMax, domMin, easeIn, easeInOut, easeOut, filterProps, findSpring, frame, frameData, frameSteps, inView, inertia, interpolate, invariant, isBrowser, isDragActive, isMotionComponent, isMotionValue, isValidMotionProp, keyframes, m, makeUseVisualState, mirrorEasing, mix, motion, motionValue, optimizedAppearDataAttribute, pipe, progress, px, resolveMotionValue, reverseEasing, scroll, scrollInfo, spring, stagger, startOptimizedAppearAnimation, steps, sync, transform, unwrapMotionComponent, useAnimate, useAnimateMini, useAnimation, useAnimationControls, useAnimationFrame, useCycle, useAnimatedState as useDeprecatedAnimatedState, useInvertedScale as useDeprecatedInvertedScale, useDomEvent, useDragControls, useElementScroll, useForceUpdate, useInView, useInstantLayoutTransition, useInstantTransition, useIsPresent, useIsomorphicLayoutEffect, useMotionTemplate, useMotionValue, useMotionValueEvent, usePresence, useReducedMotion, useReducedMotionConfig, useResetProjection, useScroll, useSpring, useTime, useTransform, useUnmountEffect, useVelocity, useViewportScroll, useWillChange, visualElementStore, warning, wrap };