framer-motion 12.24.7 → 12.24.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,912 @@
1
+ /// <reference types="react" />
2
+ import * as motion_dom from 'motion-dom';
3
+ import { Transition, MotionNodeOptions, MotionValue, TransformProperties, SVGPathProperties, JSAnimation, ValueTransition, TargetAndTransition, AnyResolvedKeyframe, KeyframeResolver, AnimationDefinition, Batcher, DOMKeyframesResolver } from 'motion-dom';
4
+ export { frame, frameData, mix, recordStats, statsBuffer } from 'motion-dom';
5
+ import * as motion_utils from 'motion-utils';
6
+ import { TransformPoint, Box, Point, Delta, Axis } from 'motion-utils';
7
+ import * as React$1 from 'react';
8
+ import { CSSProperties } from 'react';
9
+
10
+ type ReducedMotionConfig = "always" | "never" | "user";
11
+ /**
12
+ * @public
13
+ */
14
+ interface MotionConfigContext {
15
+ /**
16
+ * Internal, exported only for usage in Framer
17
+ */
18
+ transformPagePoint: TransformPoint;
19
+ /**
20
+ * Internal. Determines whether this is a static context ie the Framer canvas. If so,
21
+ * it'll disable all dynamic functionality.
22
+ */
23
+ isStatic: boolean;
24
+ /**
25
+ * Defines a new default transition for the entire tree.
26
+ *
27
+ * @public
28
+ */
29
+ transition?: Transition;
30
+ /**
31
+ * If true, will respect the device prefersReducedMotion setting by switching
32
+ * transform animations off.
33
+ *
34
+ * @public
35
+ */
36
+ reducedMotion?: ReducedMotionConfig;
37
+ /**
38
+ * A custom `nonce` attribute used when wanting to enforce a Content Security Policy (CSP).
39
+ * For more details see:
40
+ * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/style-src#unsafe_inline_styles
41
+ *
42
+ * @public
43
+ */
44
+ nonce?: string;
45
+ }
46
+ /**
47
+ * @public
48
+ */
49
+ declare const MotionConfigContext: React$1.Context<MotionConfigContext>;
50
+
51
+ /**
52
+ * Either a string, or array of strings, that reference variants defined via the `variants` prop.
53
+ * @public
54
+ */
55
+ type VariantLabels = string | string[];
56
+
57
+ type MotionValueString = MotionValue<string>;
58
+ type MotionValueNumber = MotionValue<number>;
59
+ type MotionValueAny = MotionValue<any>;
60
+ type AnyMotionValue = MotionValueNumber | MotionValueString | MotionValueAny;
61
+ type MotionValueHelper<T> = T | AnyMotionValue;
62
+ type MakeMotionHelper<T> = {
63
+ [K in keyof T]: MotionValueHelper<T[K]>;
64
+ };
65
+ type MakeCustomValueTypeHelper<T> = MakeMotionHelper<T>;
66
+ type MakeMotion<T> = MakeCustomValueTypeHelper<T>;
67
+ type MotionCSS = MakeMotion<Omit<CSSProperties, "rotate" | "scale" | "perspective" | "x" | "y" | "z">>;
68
+ /**
69
+ * @public
70
+ */
71
+ type MotionTransform = MakeMotion<TransformProperties>;
72
+ type MotionSVGProps = MakeMotion<SVGPathProperties>;
73
+ /**
74
+ * @public
75
+ */
76
+ interface MotionStyle extends MotionCSS, MotionTransform, MotionSVGProps {
77
+ }
78
+ /**
79
+ * Props for `motion` components.
80
+ *
81
+ * @public
82
+ */
83
+ interface MotionProps extends MotionNodeOptions {
84
+ /**
85
+ *
86
+ * The React DOM `style` prop, enhanced with support for `MotionValue`s and separate `transform` values.
87
+ *
88
+ * ```jsx
89
+ * export const MyComponent = () => {
90
+ * const x = useMotionValue(0)
91
+ *
92
+ * return <motion.div style={{ x, opacity: 1, scale: 0.5 }} />
93
+ * }
94
+ * ```
95
+ */
96
+ style?: MotionStyle;
97
+ children?: React.ReactNode | MotionValueNumber | MotionValueString;
98
+ }
99
+
100
+ /**
101
+ * @public
102
+ */
103
+ interface PresenceContextProps {
104
+ id: string;
105
+ isPresent: boolean;
106
+ register: (id: string | number) => () => void;
107
+ onExitComplete?: (id: string | number) => void;
108
+ initial?: false | VariantLabels;
109
+ custom?: any;
110
+ }
111
+
112
+ interface VisualState<Instance, RenderState> {
113
+ renderState: RenderState;
114
+ latestValues: ResolvedValues;
115
+ onMount?: (instance: Instance) => void;
116
+ }
117
+
118
+ interface TransformOrigin {
119
+ originX?: number | string;
120
+ originY?: number | string;
121
+ originZ?: number | string;
122
+ }
123
+ interface HTMLRenderState {
124
+ /**
125
+ * A mutable record of transforms we want to apply directly to the rendered Element
126
+ * every frame. We use a mutable data structure to reduce GC during animations.
127
+ */
128
+ transform: ResolvedValues;
129
+ /**
130
+ * A mutable record of transform origins we want to apply directly to the rendered Element
131
+ * every frame. We use a mutable data structure to reduce GC during animations.
132
+ */
133
+ transformOrigin: TransformOrigin;
134
+ /**
135
+ * A mutable record of styles we want to apply directly to the rendered Element
136
+ * every frame. We use a mutable data structure to reduce GC during animations.
137
+ */
138
+ style: ResolvedValues;
139
+ /**
140
+ * A mutable record of CSS variables we want to apply directly to the rendered Element
141
+ * every frame. We use a mutable data structure to reduce GC during animations.
142
+ */
143
+ vars: ResolvedValues;
144
+ }
145
+
146
+ interface DOMVisualElementOptions {
147
+ /**
148
+ * If `true`, this element will be included in the projection tree.
149
+ *
150
+ * Default: `true`
151
+ *
152
+ * @public
153
+ */
154
+ allowProjection?: boolean;
155
+ /**
156
+ * Allow this element to be GPU-accelerated. We currently enable this by
157
+ * adding a `translateZ(0)`.
158
+ *
159
+ * @public
160
+ */
161
+ enableHardwareAcceleration?: boolean;
162
+ }
163
+
164
+ type InitialPromotionConfig = {
165
+ /**
166
+ * The initial transition to use when the elements in this group mount (and automatically promoted).
167
+ * Subsequent updates should provide a transition in the promote method.
168
+ */
169
+ transition?: Transition;
170
+ /**
171
+ * If the follow tree should preserve its opacity when the lead is promoted on mount
172
+ */
173
+ shouldPreserveFollowOpacity?: (member: IProjectionNode) => boolean;
174
+ };
175
+
176
+ interface WithDepth {
177
+ depth: number;
178
+ }
179
+
180
+ declare class FlatTree {
181
+ private children;
182
+ private isDirty;
183
+ add(child: WithDepth): void;
184
+ remove(child: WithDepth): void;
185
+ forEach(callback: (child: WithDepth) => void): void;
186
+ }
187
+
188
+ declare class NodeStack {
189
+ lead?: IProjectionNode;
190
+ prevLead?: IProjectionNode;
191
+ members: IProjectionNode[];
192
+ add(node: IProjectionNode): void;
193
+ remove(node: IProjectionNode): void;
194
+ relegate(node: IProjectionNode): boolean;
195
+ promote(node: IProjectionNode, preserveFollowOpacity?: boolean): void;
196
+ exitAnimationComplete(): void;
197
+ scheduleRender(): void;
198
+ /**
199
+ * Clear any leads that have been removed this render to prevent them from being
200
+ * used in future animations and to prevent memory leaks
201
+ */
202
+ removeLeadSnapshot(): void;
203
+ }
204
+
205
+ interface Measurements {
206
+ animationId: number;
207
+ measuredBox: Box;
208
+ layoutBox: Box;
209
+ latestValues: ResolvedValues;
210
+ source: number;
211
+ }
212
+ type Phase = "snapshot" | "measure";
213
+ interface ScrollMeasurements {
214
+ animationId: number;
215
+ phase: Phase;
216
+ offset: Point;
217
+ isRoot: boolean;
218
+ wasRoot: boolean;
219
+ }
220
+ type LayoutEvents = "willUpdate" | "didUpdate" | "beforeMeasure" | "measure" | "projectionUpdate" | "animationStart" | "animationComplete";
221
+ interface IProjectionNode<I = unknown> {
222
+ linkedParentVersion: number;
223
+ layoutVersion: number;
224
+ id: number;
225
+ animationId: number;
226
+ animationCommitId: number;
227
+ parent?: IProjectionNode;
228
+ relativeParent?: IProjectionNode;
229
+ root?: IProjectionNode;
230
+ children: Set<IProjectionNode>;
231
+ path: IProjectionNode[];
232
+ nodes?: FlatTree;
233
+ depth: number;
234
+ instance: I | undefined;
235
+ mount: (node: I, isLayoutDirty?: boolean) => void;
236
+ unmount: () => void;
237
+ options: ProjectionNodeOptions;
238
+ setOptions(options: ProjectionNodeOptions): void;
239
+ layout?: Measurements;
240
+ snapshot?: Measurements;
241
+ target?: Box;
242
+ relativeTarget?: Box;
243
+ relativeTargetOrigin?: Box;
244
+ targetDelta?: Delta;
245
+ targetWithTransforms?: Box;
246
+ scroll?: ScrollMeasurements;
247
+ treeScale?: Point;
248
+ projectionDelta?: Delta;
249
+ projectionDeltaWithTransform?: Delta;
250
+ latestValues: ResolvedValues;
251
+ isLayoutDirty: boolean;
252
+ isProjectionDirty: boolean;
253
+ isSharedProjectionDirty: boolean;
254
+ isTransformDirty: boolean;
255
+ resolvedRelativeTargetAt?: number;
256
+ shouldResetTransform: boolean;
257
+ prevTransformTemplateValue: string | undefined;
258
+ isUpdateBlocked(): boolean;
259
+ updateManuallyBlocked: boolean;
260
+ updateBlockedByResize: boolean;
261
+ blockUpdate(): void;
262
+ unblockUpdate(): void;
263
+ isUpdating: boolean;
264
+ needsReset: boolean;
265
+ startUpdate(): void;
266
+ willUpdate(notifyListeners?: boolean): void;
267
+ didUpdate(): void;
268
+ measure(removeTransform?: boolean): Measurements;
269
+ measurePageBox(): Box;
270
+ updateLayout(): void;
271
+ updateSnapshot(): void;
272
+ clearSnapshot(): void;
273
+ updateScroll(phase?: Phase): void;
274
+ scheduleUpdateProjection(): void;
275
+ scheduleCheckAfterUnmount(): void;
276
+ checkUpdateFailed(): void;
277
+ sharedNodes: Map<string, NodeStack>;
278
+ registerSharedNode(id: string, node: IProjectionNode): void;
279
+ getStack(): NodeStack | undefined;
280
+ isVisible: boolean;
281
+ hide(): void;
282
+ show(): void;
283
+ scheduleRender(notifyAll?: boolean): void;
284
+ getClosestProjectingParent(): IProjectionNode | undefined;
285
+ setTargetDelta(delta: Delta): void;
286
+ resetTransform(): void;
287
+ resetSkewAndRotation(): void;
288
+ applyTransform(box: Box, transformOnly?: boolean): Box;
289
+ resolveTargetDelta(force?: boolean): void;
290
+ calcProjection(): void;
291
+ applyProjectionStyles(targetStyle: CSSStyleDeclaration, styleProp?: MotionStyle): void;
292
+ clearMeasurements(): void;
293
+ resetTree(): void;
294
+ isProjecting(): boolean;
295
+ animationValues?: ResolvedValues;
296
+ currentAnimation?: JSAnimation<number>;
297
+ isTreeAnimating?: boolean;
298
+ isAnimationBlocked?: boolean;
299
+ isTreeAnimationBlocked: () => boolean;
300
+ setAnimationOrigin(delta: Delta): void;
301
+ startAnimation(transition: ValueTransition): void;
302
+ finishAnimation(): void;
303
+ hasCheckedOptimisedAppear: boolean;
304
+ isLead(): boolean;
305
+ promote(options?: {
306
+ needsReset?: boolean;
307
+ transition?: Transition;
308
+ preserveFollowOpacity?: boolean;
309
+ }): void;
310
+ relegate(): boolean;
311
+ resumeFrom?: IProjectionNode;
312
+ resumingFrom?: IProjectionNode;
313
+ isPresent?: boolean;
314
+ addEventListener(name: LayoutEvents, handler: any): VoidFunction;
315
+ notifyListeners(name: LayoutEvents, ...args: any): void;
316
+ hasListeners(name: LayoutEvents): boolean;
317
+ hasTreeAnimated: boolean;
318
+ preserveOpacity?: boolean;
319
+ }
320
+ interface ProjectionNodeOptions {
321
+ animate?: boolean;
322
+ layoutScroll?: boolean;
323
+ layoutRoot?: boolean;
324
+ alwaysMeasureLayout?: boolean;
325
+ onExitComplete?: VoidFunction;
326
+ animationType?: "size" | "position" | "both" | "preserve-aspect";
327
+ layoutId?: string;
328
+ layout?: boolean | string;
329
+ visualElement?: VisualElement;
330
+ crossfade?: boolean;
331
+ transition?: Transition;
332
+ initialPromotionConfig?: InitialPromotionConfig;
333
+ }
334
+
335
+ type AnimationType = "animate" | "whileHover" | "whileTap" | "whileDrag" | "whileFocus" | "whileInView" | "exit";
336
+
337
+ type VisualElementAnimationOptions = {
338
+ delay?: number;
339
+ transitionOverride?: Transition;
340
+ custom?: any;
341
+ type?: AnimationType;
342
+ };
343
+
344
+ interface AnimationState {
345
+ animateChanges: (type?: AnimationType) => Promise<any>;
346
+ setActive: (type: AnimationType, isActive: boolean, options?: VisualElementAnimationOptions) => Promise<any>;
347
+ setAnimateFunction: (fn: any) => void;
348
+ getState: () => {
349
+ [key: string]: AnimationTypeState;
350
+ };
351
+ reset: () => void;
352
+ }
353
+ interface AnimationTypeState {
354
+ isActive: boolean;
355
+ protectedKeys: {
356
+ [key: string]: true;
357
+ };
358
+ needsAnimating: {
359
+ [key: string]: boolean;
360
+ };
361
+ prevResolvedValues: {
362
+ [key: string]: any;
363
+ };
364
+ prevProp?: VariantLabels | TargetAndTransition;
365
+ }
366
+
367
+ /**
368
+ * A VisualElement is an imperative abstraction around UI elements such as
369
+ * HTMLElement, SVGElement, Three.Object3D etc.
370
+ */
371
+ declare abstract class VisualElement<Instance = unknown, RenderState = unknown, Options extends {} = {}> {
372
+ /**
373
+ * VisualElements are arranged in trees mirroring that of the React tree.
374
+ * Each type of VisualElement has a unique name, to detect when we're crossing
375
+ * type boundaries within that tree.
376
+ */
377
+ abstract type: string;
378
+ /**
379
+ * An `Array.sort` compatible function that will compare two Instances and
380
+ * compare their respective positions within the tree.
381
+ */
382
+ abstract sortInstanceNodePosition(a: Instance, b: Instance): number;
383
+ /**
384
+ * Measure the viewport-relative bounding box of the Instance.
385
+ */
386
+ abstract measureInstanceViewportBox(instance: Instance, props: MotionProps & Partial<MotionConfigContext>): Box;
387
+ /**
388
+ * When a value has been removed from all animation props we need to
389
+ * pick a target to animate back to. For instance, for HTMLElements
390
+ * we can look in the style prop.
391
+ */
392
+ abstract getBaseTargetFromProps(props: MotionProps, key: string): AnyResolvedKeyframe | undefined | MotionValue;
393
+ /**
394
+ * When we first animate to a value we need to animate it *from* a value.
395
+ * Often this have been specified via the initial prop but it might be
396
+ * that the value needs to be read from the Instance.
397
+ */
398
+ abstract readValueFromInstance(instance: Instance, key: string, options: Options): AnyResolvedKeyframe | null | undefined;
399
+ /**
400
+ * When a value has been removed from the VisualElement we use this to remove
401
+ * it from the inherting class' unique render state.
402
+ */
403
+ abstract removeValueFromRenderState(key: string, renderState: RenderState): void;
404
+ /**
405
+ * Run before a React or VisualElement render, builds the latest motion
406
+ * values into an Instance-specific format. For example, HTMLVisualElement
407
+ * will use this step to build `style` and `var` values.
408
+ */
409
+ abstract build(renderState: RenderState, latestValues: ResolvedValues, props: MotionProps): void;
410
+ /**
411
+ * Apply the built values to the Instance. For example, HTMLElements will have
412
+ * styles applied via `setProperty` and the style attribute, whereas SVGElements
413
+ * will have values applied to attributes.
414
+ */
415
+ abstract renderInstance(instance: Instance, renderState: RenderState, styleProp?: MotionStyle, projection?: IProjectionNode): void;
416
+ /**
417
+ * This method is called when a transform property is bound to a motion value.
418
+ * It's currently used to measure SVG elements when a new transform property is bound.
419
+ */
420
+ onBindTransform?(): void;
421
+ /**
422
+ * If the component child is provided as a motion value, handle subscriptions
423
+ * with the renderer-specific VisualElement.
424
+ */
425
+ handleChildMotionValue?(): void;
426
+ /**
427
+ * This method takes React props and returns found MotionValues. For example, HTML
428
+ * MotionValues will be found within the style prop, whereas for Three.js within attribute arrays.
429
+ *
430
+ * This isn't an abstract method as it needs calling in the constructor, but it is
431
+ * intended to be one.
432
+ */
433
+ scrapeMotionValuesFromProps(_props: MotionProps, _prevProps: MotionProps, _visualElement: VisualElement): {
434
+ [key: string]: MotionValue | AnyResolvedKeyframe;
435
+ };
436
+ /**
437
+ * A reference to the current underlying Instance, e.g. a HTMLElement
438
+ * or Three.Mesh etc.
439
+ */
440
+ current: Instance | null;
441
+ /**
442
+ * A reference to the parent VisualElement (if exists).
443
+ */
444
+ parent: VisualElement | undefined;
445
+ /**
446
+ * A set containing references to this VisualElement's children.
447
+ */
448
+ children: Set<VisualElement<unknown, unknown, {}>>;
449
+ /**
450
+ * A set containing the latest children of this VisualElement. This is flushed
451
+ * at the start of every commit. We use it to calculate the stagger delay
452
+ * for newly-added children.
453
+ */
454
+ enteringChildren?: Set<VisualElement>;
455
+ /**
456
+ * The depth of this VisualElement within the overall VisualElement tree.
457
+ */
458
+ depth: number;
459
+ /**
460
+ * The current render state of this VisualElement. Defined by inherting VisualElements.
461
+ */
462
+ renderState: RenderState;
463
+ /**
464
+ * An object containing the latest static values for each of this VisualElement's
465
+ * MotionValues.
466
+ */
467
+ latestValues: ResolvedValues;
468
+ /**
469
+ * Determine what role this visual element should take in the variant tree.
470
+ */
471
+ isVariantNode: boolean;
472
+ isControllingVariants: boolean;
473
+ /**
474
+ * If this component is part of the variant tree, it should track
475
+ * any children that are also part of the tree. This is essentially
476
+ * a shadow tree to simplify logic around how to stagger over children.
477
+ */
478
+ variantChildren?: Set<VisualElement>;
479
+ /**
480
+ * Decides whether this VisualElement should animate in reduced motion
481
+ * mode.
482
+ *
483
+ * TODO: This is currently set on every individual VisualElement but feels
484
+ * like it could be set globally.
485
+ */
486
+ shouldReduceMotion: boolean | null;
487
+ /**
488
+ * Normally, if a component is controlled by a parent's variants, it can
489
+ * rely on that ancestor to trigger animations further down the tree.
490
+ * However, if a component is created after its parent is mounted, the parent
491
+ * won't trigger that mount animation so the child needs to.
492
+ *
493
+ * TODO: This might be better replaced with a method isParentMounted
494
+ */
495
+ manuallyAnimateOnMount: boolean;
496
+ /**
497
+ * This can be set by AnimatePresence to force components that mount
498
+ * at the same time as it to mount as if they have initial={false} set.
499
+ */
500
+ blockInitialAnimation: boolean;
501
+ /**
502
+ * A reference to this VisualElement's projection node, used in layout animations.
503
+ */
504
+ projection?: IProjectionNode;
505
+ /**
506
+ * A map of all motion values attached to this visual element. Motion
507
+ * values are source of truth for any given animated value. A motion
508
+ * value might be provided externally by the component via props.
509
+ */
510
+ values: Map<string, MotionValue<any>>;
511
+ /**
512
+ * The AnimationState, this is hydrated by the animation Feature.
513
+ */
514
+ animationState?: AnimationState;
515
+ KeyframeResolver: typeof KeyframeResolver;
516
+ /**
517
+ * The options used to create this VisualElement. The Options type is defined
518
+ * by the inheriting VisualElement and is passed straight through to the render functions.
519
+ */
520
+ readonly options: Options;
521
+ /**
522
+ * A reference to the latest props provided to the VisualElement's host React component.
523
+ */
524
+ props: MotionProps;
525
+ prevProps?: MotionProps;
526
+ presenceContext: PresenceContextProps | null;
527
+ prevPresenceContext?: PresenceContextProps | null;
528
+ /**
529
+ * Cleanup functions for active features (hover/tap/exit etc)
530
+ */
531
+ private features;
532
+ /**
533
+ * A map of every subscription that binds the provided or generated
534
+ * motion values onChange listeners to this visual element.
535
+ */
536
+ private valueSubscriptions;
537
+ /**
538
+ * A reference to the ReducedMotionConfig passed to the VisualElement's host React component.
539
+ */
540
+ private reducedMotionConfig;
541
+ /**
542
+ * On mount, this will be hydrated with a callback to disconnect
543
+ * this visual element from its parent on unmount.
544
+ */
545
+ private removeFromVariantTree;
546
+ /**
547
+ * A reference to the previously-provided motion values as returned
548
+ * from scrapeMotionValuesFromProps. We use the keys in here to determine
549
+ * if any motion values need to be removed after props are updated.
550
+ */
551
+ private prevMotionValues;
552
+ /**
553
+ * When values are removed from all animation props we need to search
554
+ * for a fallback value to animate to. These values are tracked in baseTarget.
555
+ */
556
+ private baseTarget;
557
+ /**
558
+ * Create an object of the values we initially animated from (if initial prop present).
559
+ */
560
+ private initialValues;
561
+ /**
562
+ * An object containing a SubscriptionManager for each active event.
563
+ */
564
+ private events;
565
+ /**
566
+ * An object containing an unsubscribe function for each prop event subscription.
567
+ * For example, every "Update" event can have multiple subscribers via
568
+ * VisualElement.on(), but only one of those can be defined via the onUpdate prop.
569
+ */
570
+ private propEventSubscriptions;
571
+ constructor({ parent, props, presenceContext, reducedMotionConfig, blockInitialAnimation, visualState, }: VisualElementOptions<Instance, RenderState>, options?: Options);
572
+ mount(instance: Instance): void;
573
+ unmount(): void;
574
+ addChild(child: VisualElement): void;
575
+ removeChild(child: VisualElement): void;
576
+ private bindToMotionValue;
577
+ sortNodePosition(other: VisualElement<Instance>): number;
578
+ updateFeatures(): void;
579
+ notifyUpdate: () => void;
580
+ triggerBuild(): void;
581
+ render: () => void;
582
+ private renderScheduledAt;
583
+ scheduleRender: () => void;
584
+ /**
585
+ * Measure the current viewport box with or without transforms.
586
+ * Only measures axis-aligned boxes, rotate and skew must be manually
587
+ * removed with a re-render to work.
588
+ */
589
+ measureViewportBox(): Box;
590
+ getStaticValue(key: string): AnyResolvedKeyframe;
591
+ setStaticValue(key: string, value: AnyResolvedKeyframe): void;
592
+ /**
593
+ * Update the provided props. Ensure any newly-added motion values are
594
+ * added to our map, old ones removed, and listeners updated.
595
+ */
596
+ update(props: MotionProps, presenceContext: PresenceContextProps | null): void;
597
+ getProps(): MotionProps;
598
+ /**
599
+ * Returns the variant definition with a given name.
600
+ */
601
+ getVariant(name: string): motion_dom.Variant | undefined;
602
+ /**
603
+ * Returns the defined default transition on this component.
604
+ */
605
+ getDefaultTransition(): motion_dom.Transition<any> | undefined;
606
+ getTransformPagePoint(): any;
607
+ getClosestVariantNode(): VisualElement | undefined;
608
+ /**
609
+ * Add a child visual element to our set of children.
610
+ */
611
+ addVariantChild(child: VisualElement): (() => boolean) | undefined;
612
+ /**
613
+ * Add a motion value and bind it to this visual element.
614
+ */
615
+ addValue(key: string, value: MotionValue): void;
616
+ /**
617
+ * Remove a motion value and unbind any active subscriptions.
618
+ */
619
+ removeValue(key: string): void;
620
+ /**
621
+ * Check whether we have a motion value for this key
622
+ */
623
+ hasValue(key: string): boolean;
624
+ /**
625
+ * Get a motion value for this key. If called with a default
626
+ * value, we'll create one if none exists.
627
+ */
628
+ getValue(key: string): MotionValue | undefined;
629
+ getValue(key: string, defaultValue: AnyResolvedKeyframe | null): MotionValue;
630
+ /**
631
+ * If we're trying to animate to a previously unencountered value,
632
+ * we need to check for it in our state and as a last resort read it
633
+ * directly from the instance (which might have performance implications).
634
+ */
635
+ readValue(key: string, target?: AnyResolvedKeyframe | null): any;
636
+ /**
637
+ * Set the base target to later animate back to. This is currently
638
+ * only hydrated on creation and when we first read a value.
639
+ */
640
+ setBaseTarget(key: string, value: AnyResolvedKeyframe): void;
641
+ /**
642
+ * Find the base target for a value thats been removed from all animation
643
+ * props.
644
+ */
645
+ getBaseTarget(key: string): ResolvedValues[string] | undefined | null;
646
+ on<EventName extends keyof VisualElementEventCallbacks>(eventName: EventName, callback: VisualElementEventCallbacks[EventName]): VoidFunction;
647
+ notify<EventName extends keyof VisualElementEventCallbacks>(eventName: EventName, ...args: any): void;
648
+ scheduleRenderMicrotask(): void;
649
+ }
650
+
651
+ interface VisualElementOptions<Instance, RenderState = any> {
652
+ visualState: VisualState<Instance, RenderState>;
653
+ parent?: VisualElement<unknown>;
654
+ variantParent?: VisualElement<unknown>;
655
+ presenceContext: PresenceContextProps | null;
656
+ props: MotionProps;
657
+ blockInitialAnimation?: boolean;
658
+ reducedMotionConfig?: ReducedMotionConfig;
659
+ /**
660
+ * Explicit override for SVG detection. When true, uses SVG rendering;
661
+ * when false, uses HTML rendering. If undefined, auto-detects.
662
+ */
663
+ isSVG?: boolean;
664
+ }
665
+ /**
666
+ * A generic set of string/number values
667
+ */
668
+ interface ResolvedValues {
669
+ [key: string]: AnyResolvedKeyframe;
670
+ }
671
+ interface VisualElementEventCallbacks {
672
+ BeforeLayoutMeasure: () => void;
673
+ LayoutMeasure: (layout: Box, prevLayout?: Box) => void;
674
+ LayoutUpdate: (layout: Axis, prevLayout: Axis) => void;
675
+ Update: (latest: ResolvedValues) => void;
676
+ AnimationStart: (definition: AnimationDefinition) => void;
677
+ AnimationComplete: (definition: AnimationDefinition) => void;
678
+ LayoutAnimationStart: () => void;
679
+ LayoutAnimationComplete: () => void;
680
+ SetAxisTarget: () => void;
681
+ Unmount: () => void;
682
+ }
683
+
684
+ declare function calcBoxDelta(delta: Delta, source: Box, target: Box, origin?: ResolvedValues): void;
685
+
686
+ interface NodeGroup {
687
+ add: (node: IProjectionNode) => void;
688
+ remove: (node: IProjectionNode) => void;
689
+ dirty: VoidFunction;
690
+ }
691
+ declare function nodeGroup(): NodeGroup;
692
+
693
+ type ScaleCorrector = (latest: AnyResolvedKeyframe, node: IProjectionNode) => AnyResolvedKeyframe;
694
+ interface ScaleCorrectorDefinition {
695
+ correct: ScaleCorrector;
696
+ applyTo?: string[];
697
+ isCSSVariable?: boolean;
698
+ }
699
+ interface ScaleCorrectorMap {
700
+ [key: string]: ScaleCorrectorDefinition;
701
+ }
702
+
703
+ declare function addScaleCorrector(correctors: ScaleCorrectorMap): void;
704
+
705
+ /**
706
+ * Build a CSS transform style from individual x/y/scale etc properties.
707
+ *
708
+ * This outputs with a default order of transforms/scales/rotations, this can be customised by
709
+ * providing a transformTemplate function.
710
+ */
711
+ declare function buildTransform(latestValues: ResolvedValues, transform: HTMLRenderState["transform"], transformTemplate?: MotionProps["transformTemplate"]): string;
712
+
713
+ declare const optimizedAppearDataAttribute: "data-framer-appear-id";
714
+
715
+ /**
716
+ * Expose only the needed part of the VisualElement interface to
717
+ * ensure React types don't end up in the generic DOM bundle.
718
+ */
719
+ interface WithAppearProps {
720
+ props: {
721
+ [optimizedAppearDataAttribute]?: string;
722
+ values?: {
723
+ [key: string]: MotionValue<number> | MotionValue<string>;
724
+ };
725
+ };
726
+ }
727
+ type HandoffFunction = (storeId: string, valueName: string, frame: Batcher) => number | null;
728
+ /**
729
+ * The window global object acts as a bridge between our inline script
730
+ * triggering the optimized appear animations, and Motion.
731
+ */
732
+ declare global {
733
+ interface Window {
734
+ MotionHandoffAnimation?: HandoffFunction;
735
+ MotionHandoffMarkAsComplete?: (elementId: string) => void;
736
+ MotionHandoffIsComplete?: (elementId: string) => boolean;
737
+ MotionHasOptimisedAnimation?: (elementId?: string, valueName?: string) => boolean;
738
+ MotionCancelOptimisedAnimation?: (elementId?: string, valueName?: string, frame?: Batcher, canResume?: boolean) => void;
739
+ MotionCheckAppearSync?: (visualElement: WithAppearProps, valueName: string, value: MotionValue) => VoidFunction | void;
740
+ MotionIsMounted?: boolean;
741
+ }
742
+ }
743
+
744
+ declare const HTMLProjectionNode: {
745
+ new (latestValues?: ResolvedValues, parent?: IProjectionNode<unknown> | undefined): {
746
+ id: number;
747
+ animationId: number;
748
+ animationCommitId: number;
749
+ instance: HTMLElement | undefined;
750
+ root: IProjectionNode<unknown>;
751
+ parent?: IProjectionNode<unknown> | undefined;
752
+ path: IProjectionNode<unknown>[];
753
+ children: Set<IProjectionNode<unknown>>;
754
+ options: ProjectionNodeOptions;
755
+ snapshot: Measurements | undefined;
756
+ layout: Measurements | undefined;
757
+ targetLayout?: motion_utils.Box | undefined;
758
+ layoutCorrected: motion_utils.Box;
759
+ targetDelta?: motion_utils.Delta | undefined;
760
+ target?: motion_utils.Box | undefined;
761
+ relativeTarget?: motion_utils.Box | undefined;
762
+ relativeTargetOrigin?: motion_utils.Box | undefined;
763
+ relativeParent?: IProjectionNode<unknown> | undefined;
764
+ isTreeAnimating: boolean;
765
+ isAnimationBlocked: boolean;
766
+ attemptToResolveRelativeTarget?: boolean | undefined;
767
+ targetWithTransforms?: motion_utils.Box | undefined;
768
+ prevProjectionDelta?: motion_utils.Delta | undefined;
769
+ projectionDelta?: motion_utils.Delta | undefined;
770
+ projectionDeltaWithTransform?: motion_utils.Delta | undefined;
771
+ scroll?: ScrollMeasurements | undefined;
772
+ isLayoutDirty: boolean;
773
+ isProjectionDirty: boolean;
774
+ isSharedProjectionDirty: boolean;
775
+ isTransformDirty: boolean;
776
+ updateManuallyBlocked: boolean;
777
+ updateBlockedByResize: boolean;
778
+ isUpdating: boolean;
779
+ isSVG: boolean;
780
+ needsReset: boolean;
781
+ shouldResetTransform: boolean;
782
+ hasCheckedOptimisedAppear: boolean;
783
+ treeScale: motion_utils.Point;
784
+ resumeFrom?: IProjectionNode<unknown> | undefined;
785
+ resumingFrom?: IProjectionNode<unknown> | undefined;
786
+ latestValues: ResolvedValues;
787
+ eventHandlers: Map<LayoutEvents, motion_utils.SubscriptionManager<any>>;
788
+ nodes?: FlatTree | undefined;
789
+ depth: number;
790
+ prevTransformTemplateValue: string | undefined;
791
+ preserveOpacity?: boolean | undefined;
792
+ hasTreeAnimated: boolean;
793
+ layoutVersion: number;
794
+ addEventListener(name: LayoutEvents, handler: any): VoidFunction;
795
+ notifyListeners(name: LayoutEvents, ...args: any): void;
796
+ hasListeners(name: LayoutEvents): boolean;
797
+ mount(instance: HTMLElement): void;
798
+ unmount(): void;
799
+ blockUpdate(): void;
800
+ unblockUpdate(): void;
801
+ isUpdateBlocked(): boolean;
802
+ isTreeAnimationBlocked(): boolean;
803
+ startUpdate(): void;
804
+ getTransformTemplate(): motion_dom.TransformTemplate | undefined;
805
+ willUpdate(shouldNotifyListeners?: boolean): void;
806
+ updateScheduled: boolean;
807
+ update(): void;
808
+ scheduleUpdate: () => void;
809
+ didUpdate(): void;
810
+ clearAllSnapshots(): void;
811
+ projectionUpdateScheduled: boolean;
812
+ scheduleUpdateProjection(): void;
813
+ scheduleCheckAfterUnmount(): void;
814
+ checkUpdateFailed: () => void;
815
+ updateProjection: () => void;
816
+ updateSnapshot(): void;
817
+ updateLayout(): void;
818
+ updateScroll(phase?: Phase): void;
819
+ resetTransform(): void;
820
+ measure(removeTransform?: boolean): {
821
+ animationId: number;
822
+ measuredBox: motion_utils.Box;
823
+ layoutBox: motion_utils.Box;
824
+ latestValues: {};
825
+ source: number;
826
+ };
827
+ measurePageBox(): motion_utils.Box;
828
+ removeElementScroll(box: motion_utils.Box): motion_utils.Box;
829
+ applyTransform(box: motion_utils.Box, transformOnly?: boolean): motion_utils.Box;
830
+ removeTransform(box: motion_utils.Box): motion_utils.Box;
831
+ setTargetDelta(delta: motion_utils.Delta): void;
832
+ setOptions(options: ProjectionNodeOptions): void;
833
+ clearMeasurements(): void;
834
+ forceRelativeParentToResolveTarget(): void;
835
+ resolvedRelativeTargetAt: number;
836
+ resolveTargetDelta(forceRecalculation?: boolean): void;
837
+ getClosestProjectingParent(): IProjectionNode<unknown> | undefined;
838
+ isProjecting(): boolean;
839
+ linkedParentVersion: number;
840
+ createRelativeTarget(relativeParent: IProjectionNode<unknown>, layout: motion_utils.Box, parentLayout: motion_utils.Box): void;
841
+ removeRelativeTarget(): void;
842
+ hasProjected: boolean;
843
+ calcProjection(): void;
844
+ isVisible: boolean;
845
+ hide(): void;
846
+ show(): void;
847
+ scheduleRender(notifyAll?: boolean): void;
848
+ createProjectionDeltas(): void;
849
+ animationValues?: ResolvedValues | undefined;
850
+ pendingAnimation?: motion_dom.Process | undefined;
851
+ currentAnimation?: motion_dom.JSAnimation<number> | undefined;
852
+ mixTargetDelta: (progress: number) => void;
853
+ animationProgress: number;
854
+ setAnimationOrigin(delta: motion_utils.Delta, hasOnlyRelativeTargetChanged?: boolean): void;
855
+ motionValue?: motion_dom.MotionValue<number> | undefined;
856
+ startAnimation(options: motion_dom.ValueAnimationOptions<number>): void;
857
+ completeAnimation(): void;
858
+ finishAnimation(): void;
859
+ applyTransformsToTarget(): void;
860
+ sharedNodes: Map<string, NodeStack>;
861
+ registerSharedNode(layoutId: string, node: IProjectionNode<unknown>): void;
862
+ isLead(): boolean;
863
+ getLead(): IProjectionNode<unknown> | any;
864
+ getPrevLead(): IProjectionNode<unknown> | undefined;
865
+ getStack(): NodeStack | undefined;
866
+ promote({ needsReset, transition, preserveFollowOpacity, }?: {
867
+ needsReset?: boolean | undefined;
868
+ transition?: motion_dom.Transition | undefined;
869
+ preserveFollowOpacity?: boolean | undefined;
870
+ }): void;
871
+ relegate(): boolean;
872
+ resetSkewAndRotation(): void;
873
+ applyProjectionStyles(targetStyle: any, styleProp?: MotionStyle | undefined): void;
874
+ clearSnapshot(): void;
875
+ resetTree(): void;
876
+ };
877
+ };
878
+
879
+ /**
880
+ * We always correct borderRadius as a percentage rather than pixels to reduce paints.
881
+ * For example, if you are projecting a box that is 100px wide with a 10px borderRadius
882
+ * into a box that is 200px wide with a 20px borderRadius, that is actually a 10%
883
+ * borderRadius in both states. If we animate between the two in pixels that will trigger
884
+ * a paint each time. If we animate between the two in percentage we'll avoid a paint.
885
+ */
886
+ declare const correctBorderRadius: ScaleCorrectorDefinition;
887
+
888
+ declare const correctBoxShadow: ScaleCorrectorDefinition;
889
+
890
+ declare abstract class DOMVisualElement<Instance extends HTMLElement | SVGElement = HTMLElement, State extends HTMLRenderState = HTMLRenderState, Options extends DOMVisualElementOptions = DOMVisualElementOptions> extends VisualElement<Instance, State, Options> {
891
+ sortInstanceNodePosition(a: Instance, b: Instance): number;
892
+ getBaseTargetFromProps(props: MotionProps, key: string): AnyResolvedKeyframe | MotionValue<any> | undefined;
893
+ removeValueFromRenderState(key: string, { vars, style }: HTMLRenderState): void;
894
+ KeyframeResolver: typeof DOMKeyframesResolver;
895
+ childSubscription?: VoidFunction;
896
+ handleChildMotionValue(): void;
897
+ }
898
+
899
+ declare function renderHTML(element: HTMLElement, { style, vars }: HTMLRenderState, styleProp?: MotionStyle, projection?: IProjectionNode): void;
900
+
901
+ declare class HTMLVisualElement extends DOMVisualElement<HTMLElement, HTMLRenderState, DOMVisualElementOptions> {
902
+ type: string;
903
+ readValueFromInstance(instance: HTMLElement, key: string): AnyResolvedKeyframe | null | undefined;
904
+ measureInstanceViewportBox(instance: HTMLElement, { transformPagePoint }: MotionProps & Partial<MotionConfigContext>): Box;
905
+ build(renderState: HTMLRenderState, latestValues: ResolvedValues, props: MotionProps): void;
906
+ scrapeMotionValuesFromProps(props: MotionProps, prevProps: MotionProps, visualElement: VisualElement): {
907
+ [key: string]: any;
908
+ };
909
+ renderInstance: typeof renderHTML;
910
+ }
911
+
912
+ export { HTMLProjectionNode, HTMLVisualElement, addScaleCorrector, buildTransform, calcBoxDelta, correctBorderRadius, correctBoxShadow, nodeGroup };