@fluentui/react-motion 9.72.9-experimental.component-base-hooks.20260122-49fc330360.0 → 9.74.3-experimental.esm.20260709-49ee7a20cf.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/CHANGELOG.md +83 -7
  2. package/README.md +60 -2
  3. package/dist/index.d.cts +368 -0
  4. package/dist/index.d.ts +85 -5
  5. package/lib/components/MotionRefForwarder.js +35 -0
  6. package/lib/components/MotionRefForwarder.js.map +1 -0
  7. package/lib/components/PresenceGroup.js +4 -4
  8. package/lib/components/PresenceGroup.js.map +1 -1
  9. package/lib/components/PresenceGroupItemProvider.js +4 -4
  10. package/lib/components/PresenceGroupItemProvider.js.map +1 -1
  11. package/lib/contexts/MotionBehaviourContext.js +1 -1
  12. package/lib/contexts/PresenceGroupChildContext.js +1 -1
  13. package/lib/factories/createMotionComponent.js +51 -18
  14. package/lib/factories/createMotionComponent.js.map +1 -1
  15. package/lib/factories/createMotionComponentVariant.js +3 -3
  16. package/lib/factories/createMotionComponentVariant.js.map +1 -1
  17. package/lib/factories/createPresenceComponent.js +13 -12
  18. package/lib/factories/createPresenceComponent.js.map +1 -1
  19. package/lib/factories/createPresenceComponentVariant.js +3 -3
  20. package/lib/factories/createPresenceComponentVariant.js.map +1 -1
  21. package/lib/hooks/useAnimateAtoms.js +2 -3
  22. package/lib/hooks/useAnimateAtoms.js.map +1 -1
  23. package/lib/hooks/useIsReducedMotion.js +3 -3
  24. package/lib/hooks/useMotionImperativeRef.js +1 -1
  25. package/lib/hooks/useMountedState.js +3 -2
  26. package/lib/hooks/useMountedState.js.map +1 -1
  27. package/lib/index.js +11 -9
  28. package/lib/index.js.map +1 -1
  29. package/lib/slots/motionSlot.js +39 -0
  30. package/lib/slots/motionSlot.js.map +1 -0
  31. package/lib/slots/presenceMotionSlot.js +2 -2
  32. package/lib/slots/presenceMotionSlot.js.map +1 -1
  33. package/lib/utils/groups/getChildMapping.js +1 -1
  34. package/lib/utils/groups/getNextChildMapping.js +1 -1
  35. package/lib/utils/groups/getNextChildMapping.js.map +1 -1
  36. package/lib/utils/useChildElement.js +2 -2
  37. package/lib-commonjs/components/MotionRefForwarder.cjs +40 -0
  38. package/lib-commonjs/components/MotionRefForwarder.cjs.map +1 -0
  39. package/lib-commonjs/components/{PresenceGroup.js → PresenceGroup.cjs} +3 -3
  40. package/lib-commonjs/components/{PresenceGroupItemProvider.js → PresenceGroupItemProvider.cjs} +1 -1
  41. package/lib-commonjs/components/{PresenceGroupItemProvider.js.map → PresenceGroupItemProvider.cjs.map} +1 -1
  42. package/lib-commonjs/factories/{createMotionComponent.js → createMotionComponent.cjs} +46 -15
  43. package/lib-commonjs/factories/createMotionComponent.cjs.map +1 -0
  44. package/lib-commonjs/factories/{createMotionComponentVariant.js → createMotionComponentVariant.cjs} +1 -1
  45. package/lib-commonjs/factories/createMotionComponentVariant.cjs.map +1 -0
  46. package/lib-commonjs/factories/{createPresenceComponent.js → createPresenceComponent.cjs} +8 -9
  47. package/lib-commonjs/factories/createPresenceComponent.cjs.map +1 -0
  48. package/lib-commonjs/factories/{createPresenceComponentVariant.js → createPresenceComponentVariant.cjs} +1 -1
  49. package/lib-commonjs/factories/createPresenceComponentVariant.cjs.map +1 -0
  50. package/lib-commonjs/hooks/{useAnimateAtoms.js → useAnimateAtoms.cjs} +1 -2
  51. package/lib-commonjs/hooks/{useAnimateAtoms.js.map → useAnimateAtoms.cjs.map} +1 -1
  52. package/lib-commonjs/hooks/{useMountedState.js → useMountedState.cjs} +1 -0
  53. package/lib-commonjs/hooks/{useMountedState.js.map → useMountedState.cjs.map} +1 -1
  54. package/lib-commonjs/{index.js → index.cjs} +23 -9
  55. package/lib-commonjs/index.cjs.map +1 -0
  56. package/lib-commonjs/slots/motionSlot.cjs +50 -0
  57. package/lib-commonjs/slots/motionSlot.cjs.map +1 -0
  58. package/lib-commonjs/slots/presenceMotionSlot.cjs.map +1 -0
  59. package/lib-commonjs/utils/groups/{getNextChildMapping.js → getNextChildMapping.cjs} +1 -1
  60. package/package.json +15 -9
  61. package/lib-commonjs/factories/createMotionComponent.js.map +0 -1
  62. package/lib-commonjs/factories/createMotionComponentVariant.js.map +0 -1
  63. package/lib-commonjs/factories/createPresenceComponent.js.map +0 -1
  64. package/lib-commonjs/factories/createPresenceComponentVariant.js.map +0 -1
  65. package/lib-commonjs/index.js.map +0 -1
  66. package/lib-commonjs/slots/presenceMotionSlot.js.map +0 -1
  67. /package/lib-commonjs/components/{PresenceGroup.js.map → PresenceGroup.cjs.map} +0 -0
  68. /package/lib-commonjs/contexts/{MotionBehaviourContext.js → MotionBehaviourContext.cjs} +0 -0
  69. /package/lib-commonjs/contexts/{MotionBehaviourContext.js.map → MotionBehaviourContext.cjs.map} +0 -0
  70. /package/lib-commonjs/contexts/{PresenceGroupChildContext.js → PresenceGroupChildContext.cjs} +0 -0
  71. /package/lib-commonjs/contexts/{PresenceGroupChildContext.js.map → PresenceGroupChildContext.cjs.map} +0 -0
  72. /package/lib-commonjs/hooks/{useIsReducedMotion.js → useIsReducedMotion.cjs} +0 -0
  73. /package/lib-commonjs/hooks/{useIsReducedMotion.js.map → useIsReducedMotion.cjs.map} +0 -0
  74. /package/lib-commonjs/hooks/{useMotionImperativeRef.js → useMotionImperativeRef.cjs} +0 -0
  75. /package/lib-commonjs/hooks/{useMotionImperativeRef.js.map → useMotionImperativeRef.cjs.map} +0 -0
  76. /package/lib-commonjs/motions/{motionTokens.js → motionTokens.cjs} +0 -0
  77. /package/lib-commonjs/motions/{motionTokens.js.map → motionTokens.cjs.map} +0 -0
  78. /package/lib-commonjs/slots/{presenceMotionSlot.js → presenceMotionSlot.cjs} +0 -0
  79. /package/lib-commonjs/{types.js → types.cjs} +0 -0
  80. /package/lib-commonjs/{types.js.map → types.cjs.map} +0 -0
  81. /package/lib-commonjs/utils/groups/{getChildMapping.js → getChildMapping.cjs} +0 -0
  82. /package/lib-commonjs/utils/groups/{getChildMapping.js.map → getChildMapping.cjs.map} +0 -0
  83. /package/lib-commonjs/utils/groups/{getNextChildMapping.js.map → getNextChildMapping.cjs.map} +0 -0
  84. /package/lib-commonjs/utils/groups/{mergeChildMappings.js → mergeChildMappings.cjs} +0 -0
  85. /package/lib-commonjs/utils/groups/{mergeChildMappings.js.map → mergeChildMappings.cjs.map} +0 -0
  86. /package/lib-commonjs/utils/groups/{types.js → types.cjs} +0 -0
  87. /package/lib-commonjs/utils/groups/{types.js.map → types.cjs.map} +0 -0
  88. /package/lib-commonjs/utils/{isAnimationRunning.js → isAnimationRunning.cjs} +0 -0
  89. /package/lib-commonjs/utils/{isAnimationRunning.js.map → isAnimationRunning.cjs.map} +0 -0
  90. /package/lib-commonjs/utils/{useChildElement.js → useChildElement.cjs} +0 -0
  91. /package/lib-commonjs/utils/{useChildElement.js.map → useChildElement.cjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,19 +1,95 @@
1
1
  # Change Log - @fluentui/react-motion
2
2
 
3
- This log was last generated on Thu, 22 Jan 2026 16:12:40 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 09 Jul 2026 17:34:11 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
- ## [9.72.9-experimental.component-base-hooks.20260122-49fc330360.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-motion_v9.72.9-experimental.component-base-hooks.20260122-49fc330360.0)
7
+ ## [9.74.3-experimental.esm.20260709-49ee7a20cf.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-motion_v9.74.3-experimental.esm.20260709-49ee7a20cf.0)
8
8
 
9
- Thu, 22 Jan 2026 16:12:40 GMT
10
- [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-motion_v9.11.5..@fluentui/react-motion_v9.72.9-experimental.component-base-hooks.20260122-49fc330360.0)
9
+ Thu, 09 Jul 2026 17:34:11 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-motion_v9.16.1..@fluentui/react-motion_v9.74.3-experimental.esm.20260709-49ee7a20cf.0)
11
11
 
12
12
  ### Changes
13
13
 
14
- - Release 9.72.9-experimental.component-base-hooks.20260122-49fc330360 ([commit](https://github.com/microsoft/fluentui/commit/not available) by fluentui-internal@service.microsoft.com)
15
- - Bump @fluentui/react-shared-contexts to v9.72.9-experimental.component-base-hooks.20260122-49fc330360.0 ([commit](https://github.com/microsoft/fluentui/commit/373001c3e19d022ef1fcf745ea96375cf4f3aff1) by beachball)
16
- - Bump @fluentui/react-utilities to v9.72.9-experimental.component-base-hooks.20260122-49fc330360.0 ([commit](https://github.com/microsoft/fluentui/commit/373001c3e19d022ef1fcf745ea96375cf4f3aff1) by beachball)
14
+ - Release 9.74.3-experimental.esm.20260709-49ee7a20cf ([commit](https://github.com/microsoft/fluentui/commit/not available) by fluentui-internal@service.microsoft.com)
15
+ - Bump @fluentui/react-shared-contexts to v9.74.3-experimental.esm.20260709-49ee7a20cf.0 ([commit](https://github.com/microsoft/fluentui/commit/175a26e0c520dd90a54578d1185a3b0b6c446e15) by beachball)
16
+ - Bump @fluentui/react-utilities to v9.74.3-experimental.esm.20260709-49ee7a20cf.0 ([commit](https://github.com/microsoft/fluentui/commit/175a26e0c520dd90a54578d1185a3b0b6c446e15) by beachball)
17
+
18
+ ## [9.16.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-motion_v9.16.1)
19
+
20
+ Wed, 24 Jun 2026 11:09:49 GMT
21
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-motion_v9.16.0..@fluentui/react-motion_v9.16.1)
22
+
23
+ ### Patches
24
+
25
+ - fix: remove redundant use no memo directives, and add justification to valid ones ([PR #36224](https://github.com/microsoft/fluentui/pull/36224) by martinhochel@microsoft.com)
26
+ - Bump @fluentui/react-utilities to v9.26.5 ([commit](https://github.com/microsoft/fluentui/commit/a4b871ca80c1f16f35ab4229def4fe02be7f30ea) by beachball)
27
+
28
+ ## [9.16.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-motion_v9.16.0)
29
+
30
+ Tue, 26 May 2026 09:39:25 GMT
31
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-motion_v9.15.0..@fluentui/react-motion_v9.16.0)
32
+
33
+ ### Minor changes
34
+
35
+ - feat(react-motion): add replayKey prop to replay motion without remounting ([PR #36108](https://github.com/microsoft/fluentui/pull/36108) by robertpenner@microsoft.com)
36
+ - Bump @fluentui/react-utilities to v9.26.4 ([PR #36246](https://github.com/microsoft/fluentui/pull/36246) by beachball)
37
+
38
+ ## [9.15.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-motion_v9.15.0)
39
+
40
+ Thu, 23 Apr 2026 14:21:02 GMT
41
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-motion_v9.14.0..@fluentui/react-motion_v9.15.0)
42
+
43
+ ### Minor changes
44
+
45
+ - feat: expose motion params as direct props on motion slot types ([PR #36011](https://github.com/microsoft/fluentui/pull/36011) by robertpenner@microsoft.com)
46
+ - fix(react-motion): apply MotionComponent type to presence definition ([PR #35952](https://github.com/microsoft/fluentui/pull/35952) by robertpenner@microsoft.com)
47
+ - Bump @fluentui/react-utilities to v9.26.3 ([PR #36035](https://github.com/microsoft/fluentui/pull/36035) by beachball)
48
+
49
+ ## [9.14.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-motion_v9.14.0)
50
+
51
+ Mon, 30 Mar 2026 14:37:40 GMT
52
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-motion_v9.13.0..@fluentui/react-motion_v9.14.0)
53
+
54
+ ### Minor changes
55
+
56
+ - feat: add motionSlot() as parallel to presenceMotionSlot() ([PR #35888](https://github.com/microsoft/fluentui/pull/35888) by robertpenner@microsoft.com)
57
+ - feat: add motionSlot() as parallel to presenceMotionSlot() ([PR #35883](https://github.com/microsoft/fluentui/pull/35883) by robertpenner@microsoft.com)
58
+
59
+ ## [9.13.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-motion_v9.13.0)
60
+
61
+ Tue, 03 Mar 2026 09:43:40 GMT
62
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-motion_v9.12.0..@fluentui/react-motion_v9.13.0)
63
+
64
+ ### Minor changes
65
+
66
+ - fix: make children optional in MotionRefForwarder to resolve type issue ([PR #35763](https://github.com/microsoft/fluentui/pull/35763) by robertpenner@microsoft.com)
67
+
68
+ ### Patches
69
+
70
+ - fix: add MotionRefForwarderReset to prevent context leaking to descendants ([PR #35807](https://github.com/microsoft/fluentui/pull/35807) by olfedias@microsoft.com)
71
+
72
+ ## [9.12.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-motion_v9.12.0)
73
+
74
+ Wed, 25 Feb 2026 13:32:23 GMT
75
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-motion_v9.11.6..@fluentui/react-motion_v9.12.0)
76
+
77
+ ### Minor changes
78
+
79
+ - feat: export MotionRefForwarder and useMotionForwardedRef for shared motion ref forwarding ([PR #35774](https://github.com/microsoft/fluentui/pull/35774) by robertpenner@microsoft.com)
80
+ - Bump @fluentui/react-shared-contexts to v9.26.2 ([PR #35782](https://github.com/microsoft/fluentui/pull/35782) by beachball)
81
+ - Bump @fluentui/react-utilities to v9.26.2 ([PR #35782](https://github.com/microsoft/fluentui/pull/35782) by beachball)
82
+
83
+ ## [9.11.6](https://github.com/microsoft/fluentui/tree/@fluentui/react-motion_v9.11.6)
84
+
85
+ Thu, 22 Jan 2026 17:06:32 GMT
86
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-motion_v9.11.5..@fluentui/react-motion_v9.11.6)
87
+
88
+ ### Patches
89
+
90
+ - fix: cleanup animation handle on unmounted component ([PR #35617](https://github.com/microsoft/fluentui/pull/35617) by olfedias@microsoft.com)
91
+ - Bump @fluentui/react-shared-contexts to v9.26.1 ([PR #35574](https://github.com/microsoft/fluentui/pull/35574) by beachball)
92
+ - Bump @fluentui/react-utilities to v9.26.1 ([PR #35574](https://github.com/microsoft/fluentui/pull/35574) by beachball)
17
93
 
18
94
  ## [9.11.5](https://github.com/microsoft/fluentui/tree/@fluentui/react-motion_v9.11.5)
19
95
 
package/README.md CHANGED
@@ -1,5 +1,63 @@
1
1
  # @fluentui/react-motion
2
2
 
3
- **React Motions components for [Fluent UI React](https://react.fluentui.dev/)**
3
+ **React Motion components for [Fluent UI React](https://react.fluentui.dev/)**
4
4
 
5
- These are not production-ready components and **should never be used in product**. This space is useful for testing new components whose APIs might change before final release.
5
+ A lightweight, performant animation library for React that brings Fluent UI experiences to life using the Web Animations API (WAAPI).
6
+
7
+ ## Features
8
+
9
+ - ⚡ **Performance** — Animations run on the compositor thread for smooth 60fps motion
10
+ - 📦 **Lightweight** — ~3KB gzipped, leverages native browser capabilities
11
+ - 🎯 **Simple by default** — Common UI animations with minimal code
12
+ - 🔧 **Powerful on demand** — Full customization with keyframes, timing, and callbacks
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @fluentui/react-motion
18
+ # or
19
+ yarn add @fluentui/react-motion
20
+ ```
21
+
22
+ ## Quick Start
23
+
24
+ ```tsx
25
+ import { createPresenceComponent, motionTokens } from '@fluentui/react-motion';
26
+
27
+ // Create a custom fade presence component
28
+ const Fade = createPresenceComponent({
29
+ enter: {
30
+ keyframes: [{ opacity: 0 }, { opacity: 1 }],
31
+ duration: motionTokens.durationNormal,
32
+ },
33
+ exit: {
34
+ keyframes: [{ opacity: 1 }, { opacity: 0 }],
35
+ duration: motionTokens.durationFast,
36
+ },
37
+ });
38
+
39
+ // Use it in your app
40
+ function App() {
41
+ const [visible, setVisible] = useState(true);
42
+
43
+ return (
44
+ <Fade visible={visible}>
45
+ <div>Animated content</div>
46
+ </Fade>
47
+ );
48
+ }
49
+ ```
50
+
51
+ ## Documentation
52
+
53
+ 📚 **[Full documentation](https://react.fluentui.dev/?path=/docs/motion-introduction--docs)**
54
+
55
+ - [Introduction](https://react.fluentui.dev/?path=/docs/motion-introduction--docs) — Overview and key concepts
56
+ - [createPresenceComponent](https://react.fluentui.dev/?path=/docs/motion-apis-createpresencecomponent--docs) — Two-way enter/exit animations
57
+ - [createMotionComponent](https://react.fluentui.dev/?path=/docs/motion-apis-createmotioncomponent--docs) — One-way animations
58
+ - [Motion Tokens](https://react.fluentui.dev/?path=/docs/motion-tokens--docs) — Duration and easing values
59
+ - [Migration Guide](https://react.fluentui.dev/?path=/docs/motion-migration--docs) — Coming from Framer Motion, GSAP, etc.
60
+
61
+ ## Pre-built Components
62
+
63
+ For ready-to-use motion components (Fade, Scale, Slide, Collapse, etc.), see **[@fluentui/react-motion-components-preview](https://www.npmjs.com/package/@fluentui/react-motion-components-preview)**.
@@ -0,0 +1,368 @@
1
+ import type { JSXElement } from '@fluentui/react-utilities';
2
+ import type { JSXIntrinsicElementKeys } from '@fluentui/react-utilities';
3
+ import * as React_2 from 'react';
4
+ import type { SlotComponentType } from '@fluentui/react-utilities';
5
+ import type { SlotRenderFunction } from '@fluentui/react-utilities';
6
+
7
+ declare type AtomCore = {
8
+ keyframes: Keyframe[];
9
+ } & KeyframeEffectOptions;
10
+
11
+ export declare type AtomMotion = AtomCore & {
12
+ /**
13
+ * Allows to specify a reduced motion version of the animation. If provided, the settings will be used when the
14
+ * user has enabled the reduced motion setting in the operating system (i.e `prefers-reduced-motion` media query is
15
+ * active). If not provided, the duration of the animation will be overridden to be 1ms.
16
+ *
17
+ * Note, if `keyframes` are provided, they will be used instead of the regular `keyframes`.
18
+ */
19
+ reducedMotion?: Partial<AtomCore>;
20
+ };
21
+
22
+ export declare type AtomMotionFn<MotionParams extends Record<string, MotionParam> = {}> = (params: {
23
+ element: HTMLElement;
24
+ } & MotionParams) => AtomMotion | AtomMotion[];
25
+
26
+ /**
27
+ * Creates a component that will animate the children using the provided motion.
28
+ *
29
+ * @param value - A motion definition.
30
+ */
31
+ export declare function createMotionComponent<MotionParams extends Record<string, MotionParam> = {}>(value: AtomMotion | AtomMotion[] | AtomMotionFn<MotionParams>): MotionComponent<MotionParams>;
32
+
33
+ /**
34
+ * Create a new motion component based on another motion component,
35
+ * using the provided variant parameters as defaults.
36
+ *
37
+ * @param component - A component created by `createMotionComponent`.
38
+ * @param variantParams - An object containing the variant parameters to be used as defaults.
39
+ * The variant parameters should match the type of the component's motion parameters.
40
+ * @returns A new motion component that uses the provided variant parameters as defaults.
41
+ * The new component can still accept runtime parameters that override the defaults.
42
+ */
43
+ export declare function createMotionComponentVariant<MotionParams extends Record<string, MotionParam> = {}>(component: MotionComponent<MotionParams>, variantParams: Partial<MotionParams>): MotionComponent<MotionParams>;
44
+
45
+ export declare function createPresenceComponent<MotionParams extends Record<string, MotionParam> = {}>(value: PresenceMotion | PresenceMotionFn<MotionParams>): PresenceComponent<MotionParams>;
46
+
47
+ /**
48
+ * Create a new presence component based on another presence component,
49
+ * using the provided variant parameters as defaults.
50
+ *
51
+ * @param component - A component created by `createPresenceComponent`.
52
+ * @param variantParams - An object containing the variant parameters to be used as defaults.
53
+ * The variant parameters should match the type of the component's motion parameters.
54
+ * @returns A new presence component that uses the provided variant parameters as defaults.
55
+ * The new component can still accept runtime parameters that override the defaults.
56
+ */
57
+ export declare function createPresenceComponentVariant<MotionParams extends Record<string, MotionParam> = {}>(component: PresenceComponent<MotionParams>, variantParams: Partial<MotionParams>): PresenceComponent<MotionParams>;
58
+
59
+ export declare const curves: {
60
+ readonly curveAccelerateMax: "cubic-bezier(0.9,0.1,1,0.2)";
61
+ readonly curveAccelerateMid: "cubic-bezier(1,0,1,1)";
62
+ readonly curveAccelerateMin: "cubic-bezier(0.8,0,0.78,1)";
63
+ readonly curveDecelerateMax: "cubic-bezier(0.1,0.9,0.2,1)";
64
+ readonly curveDecelerateMid: "cubic-bezier(0,0,0,1)";
65
+ readonly curveDecelerateMin: "cubic-bezier(0.33,0,0.1,1)";
66
+ readonly curveEasyEaseMax: "cubic-bezier(0.8,0,0.2,1)";
67
+ readonly curveEasyEase: "cubic-bezier(0.33,0,0.67,1)";
68
+ readonly curveLinear: "cubic-bezier(0,0,1,1)";
69
+ };
70
+
71
+ export declare const durations: {
72
+ readonly durationUltraFast: 50;
73
+ readonly durationFaster: 100;
74
+ readonly durationFast: 150;
75
+ readonly durationNormal: 200;
76
+ readonly durationGentle: 250;
77
+ readonly durationSlow: 300;
78
+ readonly durationSlower: 400;
79
+ readonly durationUltraSlow: 500;
80
+ };
81
+
82
+ /**
83
+ * A private symbol to store the motion definition on the component for variants.
84
+ *
85
+ * @internal
86
+ */
87
+ declare const MOTION_DEFINITION: unique symbol;
88
+
89
+ export declare const MotionBehaviourProvider: React_2.Provider<MotionBehaviourType | undefined>;
90
+
91
+ /**
92
+ * Specifies the behaviour of child motion component under @see MotionBehaviourProvider.
93
+ */
94
+ declare type MotionBehaviourType = 'skip' | 'default';
95
+
96
+ export declare type MotionComponent<MotionParams extends Record<string, MotionParam> = {}> = React_2.FC<MotionComponentProps & MotionParams> & {
97
+ [MOTION_DEFINITION]: AtomMotionFn<MotionParams>;
98
+ };
99
+
100
+ export declare type MotionComponentProps = {
101
+ children: JSXElement;
102
+ /** Provides imperative controls for the animation. */
103
+ imperativeRef?: React_2.Ref<MotionImperativeRef | undefined>;
104
+ /**
105
+ * Callback that is called when the whole motion finishes.
106
+ *
107
+ * A motion definition can contain multiple animations and therefore multiple "finish" events. The callback is
108
+ * triggered once all animations have finished with "null" instead of an event object to avoid ambiguity.
109
+ */
110
+ onMotionFinish?: (ev: null) => void;
111
+ /**
112
+ * Callback that is called when the whole motion is cancelled.
113
+ *
114
+ * A motion definition can contain multiple animations and therefore multiple "cancel" events. The callback is
115
+ * triggered once all animations have been cancelled with "null" instead of an event object to avoid ambiguity.
116
+ */
117
+ onMotionCancel?: (ev: null) => void;
118
+ /**
119
+ * Callback that is called when the whole motion starts.
120
+ *
121
+ * A motion definition can contain multiple animations and therefore multiple "start" events. The callback is
122
+ * triggered when the first animation is started. There is no official "start" event with the Web Animations API.
123
+ * so the callback is triggered with "null".
124
+ */
125
+ onMotionStart?: (ev: null) => void;
126
+ /**
127
+ * When this value changes, the animation replays from the start on the same DOM element,
128
+ * cancelling any in-progress animation, without remounting the component or its children.
129
+ *
130
+ * **Why not just use a React `key`?** Changing a React `key` forces a full unmount and
131
+ * remount of the subtree: DOM nodes are destroyed and recreated, focus is lost, and any
132
+ * child state is reset. `replayKey` avoids all of that — only the animation effect reruns
133
+ * while the DOM and component state remain intact.
134
+ *
135
+ * Use this when you want to retrigger a motion in response to a state change (e.g. a user
136
+ * action or a data update) while preserving DOM continuity. It is the declarative equivalent
137
+ * of calling `imperativeRef.current.play()` but driven by a prop rather than a ref call.
138
+ *
139
+ * @example
140
+ * ```tsx
141
+ * // Replay a Fade.In each time the user clicks "Refresh"
142
+ * const [replayKey, setReplayKey] = React.useState(0);
143
+ * <Fade.In replayKey={replayKey}>
144
+ * <div>Content</div>
145
+ * </Fade.In>
146
+ * <button onClick={() => setReplayKey(k => k + 1)}>Refresh</button>
147
+ * ```
148
+ */
149
+ replayKey?: string | number;
150
+ };
151
+
152
+ export declare type MotionImperativeRef = {
153
+ /** Sets the playback rate of the animation, where 1 is normal speed. */
154
+ setPlaybackRate: (rate: number) => void;
155
+ /** Sets the state of the animation to running or paused. */
156
+ setPlayState: (state: 'running' | 'paused') => void;
157
+ };
158
+
159
+ /**
160
+ * A motion param should be a primitive value that can be serialized to JSON and could be potentially used a plain
161
+ * dependency for React hooks.
162
+ */
163
+ export declare type MotionParam = boolean | number | string;
164
+
165
+ /**
166
+ * A component that forwards a ref to its children via a React context.
167
+ * This is used to pass a motion component's ref through to the actual surface element,
168
+ * since motion components wrap their children and the ref needs to reach the inner element.
169
+ *
170
+ * @internal
171
+ */
172
+ export declare const MotionRefForwarder: React_2.ForwardRefExoticComponent<{
173
+ children?: React_2.ReactElement;
174
+ } & React_2.RefAttributes<HTMLElement>>;
175
+
176
+ /**
177
+ * Resets the MotionRefForwarder context to `undefined` for its children.
178
+ * Render this in components that consume `useMotionForwardedRef()` and render
179
+ * arbitrary user content, to prevent the context from leaking to descendants.
180
+ *
181
+ * @internal
182
+ */
183
+ export declare const MotionRefForwarderReset: React_2.FC<{
184
+ children: React_2.ReactElement;
185
+ }>;
186
+
187
+ export declare function motionSlot<MotionParams extends Record<string, MotionParam> = {}>(motion: MotionSlotProps<MotionParams> | null | undefined, options: {
188
+ elementType: React_2.FC<MotionComponentProps & MotionParams>;
189
+ defaultProps: MotionSlotRenderProps & MotionParams;
190
+ }): SlotComponentType<MotionSlotRenderProps & MotionParams>;
191
+
192
+ export declare type MotionSlotProps<MotionParams extends Record<string, MotionParam> = {}> = Pick<MotionComponentProps, 'imperativeRef' | 'onMotionFinish' | 'onMotionStart' | 'onMotionCancel'> & Partial<MotionParams> & {
193
+ /**
194
+ * @deprecated Do not use. Motion Slots do not support intrinsic elements.
195
+ *
196
+ * If you want to override the animation, use the children render function instead.
197
+ */
198
+ as?: JSXIntrinsicElementKeys;
199
+ children?: SlotRenderFunction<MotionSlotRenderProps & MotionParams & {
200
+ children: JSXElement;
201
+ }>;
202
+ };
203
+
204
+ /**
205
+ * @internal
206
+ */
207
+ declare type MotionSlotRenderProps = Pick<MotionComponentProps, 'onMotionFinish' | 'onMotionStart' | 'onMotionCancel'>;
208
+
209
+ export declare const motionTokens: {
210
+ curveAccelerateMax: "cubic-bezier(0.9,0.1,1,0.2)";
211
+ curveAccelerateMid: "cubic-bezier(1,0,1,1)";
212
+ curveAccelerateMin: "cubic-bezier(0.8,0,0.78,1)";
213
+ curveDecelerateMax: "cubic-bezier(0.1,0.9,0.2,1)";
214
+ curveDecelerateMid: "cubic-bezier(0,0,0,1)";
215
+ curveDecelerateMin: "cubic-bezier(0.33,0,0.1,1)";
216
+ curveEasyEaseMax: "cubic-bezier(0.8,0,0.2,1)";
217
+ curveEasyEase: "cubic-bezier(0.33,0,0.67,1)";
218
+ curveLinear: "cubic-bezier(0,0,1,1)";
219
+ durationUltraFast: 50;
220
+ durationFaster: 100;
221
+ durationFast: 150;
222
+ durationNormal: 200;
223
+ durationGentle: 250;
224
+ durationSlow: 300;
225
+ durationSlower: 400;
226
+ durationUltraSlow: 500;
227
+ };
228
+
229
+ /**
230
+ * A private symbol to store the motion definition on the component for variants.
231
+ *
232
+ * @internal
233
+ */
234
+ declare const PRESENCE_MOTION_DEFINITION: unique symbol;
235
+
236
+ export declare type PresenceComponent<MotionParams extends Record<string, MotionParam> = {}> = React_2.FC<PresenceComponentProps & MotionParams> & {
237
+ (props: PresenceComponentProps & MotionParams): JSXElement | null;
238
+ [PRESENCE_MOTION_DEFINITION]: PresenceMotionFn<MotionParams>;
239
+ In: MotionComponent<MotionParams>;
240
+ Out: MotionComponent<MotionParams>;
241
+ };
242
+
243
+ export declare type PresenceComponentProps = {
244
+ /**
245
+ * By default, the child component won't execute the "enter" motion when it initially mounts, regardless of the value
246
+ * of "visible". If you desire this behavior, ensure both "appear" and "visible" are set to "true".
247
+ */
248
+ appear?: boolean;
249
+ /** A React element that will be cloned and will have motion effects applied to it. */
250
+ children: JSXElement;
251
+ /** Provides imperative controls for the animation. */
252
+ imperativeRef?: React_2.Ref<MotionImperativeRef | undefined>;
253
+ /**
254
+ * Callback that is called when the whole motion finishes.
255
+ *
256
+ * A motion definition can contain multiple animations and therefore multiple "finish" events. The callback is
257
+ * triggered once all animations have finished with "null" instead of an event object to avoid ambiguity.
258
+ */
259
+ onMotionFinish?: (ev: null, data: {
260
+ direction: PresenceDirection;
261
+ }) => void;
262
+ /**
263
+ * Callback that is called when the whole motion is cancelled. When a motion is cancelled it does not
264
+ * emit a finish event but a specific cancel event
265
+ *
266
+ * A motion definition can contain multiple animations and therefore multiple "finish" events. The callback is
267
+ * triggered once all animations have finished with "null" instead of an event object to avoid ambiguity.
268
+ */
269
+ onMotionCancel?: (ev: null, data: {
270
+ direction: PresenceDirection;
271
+ }) => void;
272
+ /**
273
+ * Callback that is called when the whole motion starts.
274
+ *
275
+ * A motion definition can contain multiple animations and therefore multiple "start" events. The callback is
276
+ * triggered when the first animation is started. There is no official "start" event with the Web Animations API.
277
+ * so the callback is triggered with "null".
278
+ */
279
+ onMotionStart?: (ev: null, data: {
280
+ direction: PresenceDirection;
281
+ }) => void;
282
+ /** Defines whether a component is visible; triggers the "enter" or "exit" motions. */
283
+ visible?: boolean;
284
+ /**
285
+ * By default, the child component remains mounted after it reaches the "finished" state. Set "unmountOnExit" if
286
+ * you prefer to unmount the component after it finishes exiting.
287
+ */
288
+ unmountOnExit?: boolean;
289
+ };
290
+
291
+ export declare type PresenceDirection = 'enter' | 'exit';
292
+
293
+ export declare class PresenceGroup extends React_2.Component<PresenceGroupProps, PresenceGroupState> {
294
+ private mounted;
295
+ static getDerivedStateFromProps(nextProps: PresenceGroupProps, { childMapping: prevChildMapping, firstRender }: PresenceGroupState): PresenceGroupState;
296
+ constructor(props: PresenceGroupProps, context?: unknown);
297
+ private handleExit;
298
+ componentDidMount(): void;
299
+ componentWillUnmount(): void;
300
+ render(): JSXElement;
301
+ }
302
+
303
+ declare type PresenceGroupChild = {
304
+ element: JSXElement;
305
+ appear: boolean;
306
+ visible: boolean;
307
+ unmountOnExit: boolean;
308
+ };
309
+
310
+ export declare type PresenceGroupChildContextValue = {
311
+ appear: boolean;
312
+ visible: boolean;
313
+ unmountOnExit: boolean;
314
+ onExit: () => void;
315
+ };
316
+
317
+ declare type PresenceGroupChildMapping = Record<string, PresenceGroupChild>;
318
+
319
+ export declare const PresenceGroupChildProvider: React_2.Provider<PresenceGroupChildContextValue | undefined>;
320
+
321
+ declare type PresenceGroupProps = {
322
+ children: React_2.ReactNode;
323
+ };
324
+
325
+ declare type PresenceGroupState = {
326
+ childMapping: PresenceGroupChildMapping;
327
+ firstRender: boolean;
328
+ };
329
+
330
+ export declare type PresenceMotion = Record<PresenceDirection, AtomMotion | AtomMotion[]>;
331
+
332
+ export declare type PresenceMotionFn<MotionParams extends Record<string, MotionParam> = {}> = (params: {
333
+ element: HTMLElement;
334
+ } & MotionParams) => PresenceMotion;
335
+
336
+ export declare function presenceMotionSlot<MotionParams extends Record<string, MotionParam> = {}>(motion: PresenceMotionSlotProps<MotionParams> | null | undefined, options: {
337
+ elementType: React_2.FC<PresenceComponentProps & MotionParams>;
338
+ defaultProps: PresenceMotionSlotRenderProps & MotionParams;
339
+ }): SlotComponentType<PresenceMotionSlotRenderProps & MotionParams>;
340
+
341
+ export declare type PresenceMotionSlotProps<MotionParams extends Record<string, MotionParam> = {}> = Pick<PresenceComponentProps, 'imperativeRef' | 'onMotionFinish' | 'onMotionStart'> & Partial<MotionParams> & {
342
+ /**
343
+ * @deprecated Do not use. Presence Motion Slots do not support intrinsic elements.
344
+ *
345
+ * If you want to override the animation, use the children render function instead.
346
+ */
347
+ as?: JSXIntrinsicElementKeys;
348
+ children?: SlotRenderFunction<PresenceMotionSlotRenderProps & MotionParams & {
349
+ children: JSXElement;
350
+ }>;
351
+ };
352
+
353
+ /**
354
+ * @internal
355
+ */
356
+ declare type PresenceMotionSlotRenderProps = Pick<PresenceComponentProps, 'appear' | 'onMotionFinish' | 'onMotionStart' | 'unmountOnExit' | 'visible'>;
357
+
358
+ /**
359
+ * A hook that reads the ref forwarded by `MotionRefForwarder` from context.
360
+ * Used in child components to merge the motion ref into the root slot ref.
361
+ *
362
+ * @internal
363
+ */
364
+ export declare function useMotionForwardedRef(): React_2.Ref<HTMLElement> | undefined;
365
+
366
+ export declare const usePresenceGroupChildContext: () => PresenceGroupChildContextValue | undefined;
367
+
368
+ export { }
package/dist/index.d.ts CHANGED
@@ -80,7 +80,9 @@ export declare const durations: {
80
80
  };
81
81
 
82
82
  /**
83
- * @internal A private symbol to store the motion definition on the component for variants.
83
+ * A private symbol to store the motion definition on the component for variants.
84
+ *
85
+ * @internal
84
86
  */
85
87
  declare const MOTION_DEFINITION: unique symbol;
86
88
 
@@ -121,6 +123,30 @@ export declare type MotionComponentProps = {
121
123
  * so the callback is triggered with "null".
122
124
  */
123
125
  onMotionStart?: (ev: null) => void;
126
+ /**
127
+ * When this value changes, the animation replays from the start on the same DOM element,
128
+ * cancelling any in-progress animation, without remounting the component or its children.
129
+ *
130
+ * **Why not just use a React `key`?** Changing a React `key` forces a full unmount and
131
+ * remount of the subtree: DOM nodes are destroyed and recreated, focus is lost, and any
132
+ * child state is reset. `replayKey` avoids all of that — only the animation effect reruns
133
+ * while the DOM and component state remain intact.
134
+ *
135
+ * Use this when you want to retrigger a motion in response to a state change (e.g. a user
136
+ * action or a data update) while preserving DOM continuity. It is the declarative equivalent
137
+ * of calling `imperativeRef.current.play()` but driven by a prop rather than a ref call.
138
+ *
139
+ * @example
140
+ * ```tsx
141
+ * // Replay a Fade.In each time the user clicks "Refresh"
142
+ * const [replayKey, setReplayKey] = React.useState(0);
143
+ * <Fade.In replayKey={replayKey}>
144
+ * <div>Content</div>
145
+ * </Fade.In>
146
+ * <button onClick={() => setReplayKey(k => k + 1)}>Refresh</button>
147
+ * ```
148
+ */
149
+ replayKey?: string | number;
124
150
  };
125
151
 
126
152
  export declare type MotionImperativeRef = {
@@ -136,6 +162,50 @@ export declare type MotionImperativeRef = {
136
162
  */
137
163
  export declare type MotionParam = boolean | number | string;
138
164
 
165
+ /**
166
+ * A component that forwards a ref to its children via a React context.
167
+ * This is used to pass a motion component's ref through to the actual surface element,
168
+ * since motion components wrap their children and the ref needs to reach the inner element.
169
+ *
170
+ * @internal
171
+ */
172
+ export declare const MotionRefForwarder: React_2.ForwardRefExoticComponent<{
173
+ children?: React_2.ReactElement;
174
+ } & React_2.RefAttributes<HTMLElement>>;
175
+
176
+ /**
177
+ * Resets the MotionRefForwarder context to `undefined` for its children.
178
+ * Render this in components that consume `useMotionForwardedRef()` and render
179
+ * arbitrary user content, to prevent the context from leaking to descendants.
180
+ *
181
+ * @internal
182
+ */
183
+ export declare const MotionRefForwarderReset: React_2.FC<{
184
+ children: React_2.ReactElement;
185
+ }>;
186
+
187
+ export declare function motionSlot<MotionParams extends Record<string, MotionParam> = {}>(motion: MotionSlotProps<MotionParams> | null | undefined, options: {
188
+ elementType: React_2.FC<MotionComponentProps & MotionParams>;
189
+ defaultProps: MotionSlotRenderProps & MotionParams;
190
+ }): SlotComponentType<MotionSlotRenderProps & MotionParams>;
191
+
192
+ export declare type MotionSlotProps<MotionParams extends Record<string, MotionParam> = {}> = Pick<MotionComponentProps, 'imperativeRef' | 'onMotionFinish' | 'onMotionStart' | 'onMotionCancel'> & Partial<MotionParams> & {
193
+ /**
194
+ * @deprecated Do not use. Motion Slots do not support intrinsic elements.
195
+ *
196
+ * If you want to override the animation, use the children render function instead.
197
+ */
198
+ as?: JSXIntrinsicElementKeys;
199
+ children?: SlotRenderFunction<MotionSlotRenderProps & MotionParams & {
200
+ children: JSXElement;
201
+ }>;
202
+ };
203
+
204
+ /**
205
+ * @internal
206
+ */
207
+ declare type MotionSlotRenderProps = Pick<MotionComponentProps, 'onMotionFinish' | 'onMotionStart' | 'onMotionCancel'>;
208
+
139
209
  export declare const motionTokens: {
140
210
  curveAccelerateMax: "cubic-bezier(0.9,0.1,1,0.2)";
141
211
  curveAccelerateMid: "cubic-bezier(1,0,1,1)";
@@ -157,15 +227,17 @@ export declare const motionTokens: {
157
227
  };
158
228
 
159
229
  /**
160
- * @internal A private symbol to store the motion definition on the component for variants.
230
+ * A private symbol to store the motion definition on the component for variants.
231
+ *
232
+ * @internal
161
233
  */
162
234
  declare const PRESENCE_MOTION_DEFINITION: unique symbol;
163
235
 
164
236
  export declare type PresenceComponent<MotionParams extends Record<string, MotionParam> = {}> = React_2.FC<PresenceComponentProps & MotionParams> & {
165
237
  (props: PresenceComponentProps & MotionParams): JSXElement | null;
166
238
  [PRESENCE_MOTION_DEFINITION]: PresenceMotionFn<MotionParams>;
167
- In: React_2.FC<MotionComponentProps & MotionParams>;
168
- Out: React_2.FC<MotionComponentProps & MotionParams>;
239
+ In: MotionComponent<MotionParams>;
240
+ Out: MotionComponent<MotionParams>;
169
241
  };
170
242
 
171
243
  export declare type PresenceComponentProps = {
@@ -266,7 +338,7 @@ export declare function presenceMotionSlot<MotionParams extends Record<string, M
266
338
  defaultProps: PresenceMotionSlotRenderProps & MotionParams;
267
339
  }): SlotComponentType<PresenceMotionSlotRenderProps & MotionParams>;
268
340
 
269
- export declare type PresenceMotionSlotProps<MotionParams extends Record<string, MotionParam> = {}> = Pick<PresenceComponentProps, 'imperativeRef' | 'onMotionFinish' | 'onMotionStart'> & {
341
+ export declare type PresenceMotionSlotProps<MotionParams extends Record<string, MotionParam> = {}> = Pick<PresenceComponentProps, 'imperativeRef' | 'onMotionFinish' | 'onMotionStart'> & Partial<MotionParams> & {
270
342
  /**
271
343
  * @deprecated Do not use. Presence Motion Slots do not support intrinsic elements.
272
344
  *
@@ -283,6 +355,14 @@ export declare type PresenceMotionSlotProps<MotionParams extends Record<string,
283
355
  */
284
356
  declare type PresenceMotionSlotRenderProps = Pick<PresenceComponentProps, 'appear' | 'onMotionFinish' | 'onMotionStart' | 'unmountOnExit' | 'visible'>;
285
357
 
358
+ /**
359
+ * A hook that reads the ref forwarded by `MotionRefForwarder` from context.
360
+ * Used in child components to merge the motion ref into the root slot ref.
361
+ *
362
+ * @internal
363
+ */
364
+ export declare function useMotionForwardedRef(): React_2.Ref<HTMLElement> | undefined;
365
+
286
366
  export declare const usePresenceGroupChildContext: () => PresenceGroupChildContextValue | undefined;
287
367
 
288
368
  export { }