@fluentui/react-motion 9.16.1 → 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.
- package/CHANGELOG.md +13 -2
- package/dist/index.d.cts +368 -0
- package/lib/components/MotionRefForwarder.js +1 -1
- package/lib/components/PresenceGroup.js +4 -4
- package/lib/components/PresenceGroup.js.map +1 -1
- package/lib/components/PresenceGroupItemProvider.js +2 -2
- package/lib/components/PresenceGroupItemProvider.js.map +1 -1
- package/lib/contexts/MotionBehaviourContext.js +1 -1
- package/lib/contexts/PresenceGroupChildContext.js +1 -1
- package/lib/factories/createMotionComponent.js +7 -7
- package/lib/factories/createMotionComponent.js.map +1 -1
- package/lib/factories/createMotionComponentVariant.js +1 -1
- package/lib/factories/createMotionComponentVariant.js.map +1 -1
- package/lib/factories/createPresenceComponent.js +10 -10
- package/lib/factories/createPresenceComponent.js.map +1 -1
- package/lib/factories/createPresenceComponentVariant.js +1 -1
- package/lib/factories/createPresenceComponentVariant.js.map +1 -1
- package/lib/hooks/useAnimateAtoms.js +2 -2
- package/lib/hooks/useAnimateAtoms.js.map +1 -1
- package/lib/hooks/useIsReducedMotion.js +3 -3
- package/lib/hooks/useMotionImperativeRef.js +1 -1
- package/lib/hooks/useMountedState.js +2 -2
- package/lib/index.js +11 -11
- package/lib/index.js.map +1 -1
- package/lib/slots/motionSlot.js +2 -2
- package/lib/slots/presenceMotionSlot.js +2 -2
- package/lib/utils/groups/getChildMapping.js +1 -1
- package/lib/utils/groups/getNextChildMapping.js +1 -1
- package/lib/utils/groups/getNextChildMapping.js.map +1 -1
- package/lib/utils/useChildElement.js +2 -2
- package/lib-commonjs/components/{PresenceGroup.js → PresenceGroup.cjs} +3 -3
- package/lib-commonjs/components/{PresenceGroupItemProvider.js → PresenceGroupItemProvider.cjs} +1 -1
- package/lib-commonjs/factories/{createMotionComponent.js → createMotionComponent.cjs} +5 -5
- package/lib-commonjs/factories/{createMotionComponentVariant.js → createMotionComponentVariant.cjs} +1 -1
- package/lib-commonjs/factories/{createPresenceComponent.js → createPresenceComponent.cjs} +8 -8
- package/lib-commonjs/factories/{createPresenceComponentVariant.js → createPresenceComponentVariant.cjs} +1 -1
- package/lib-commonjs/hooks/{useAnimateAtoms.js → useAnimateAtoms.cjs} +1 -1
- package/lib-commonjs/{index.js → index.cjs} +11 -11
- package/lib-commonjs/utils/groups/{getNextChildMapping.js → getNextChildMapping.cjs} +1 -1
- package/package.json +15 -14
- /package/lib-commonjs/components/{MotionRefForwarder.js → MotionRefForwarder.cjs} +0 -0
- /package/lib-commonjs/components/{MotionRefForwarder.js.map → MotionRefForwarder.cjs.map} +0 -0
- /package/lib-commonjs/components/{PresenceGroup.js.map → PresenceGroup.cjs.map} +0 -0
- /package/lib-commonjs/components/{PresenceGroupItemProvider.js.map → PresenceGroupItemProvider.cjs.map} +0 -0
- /package/lib-commonjs/contexts/{MotionBehaviourContext.js → MotionBehaviourContext.cjs} +0 -0
- /package/lib-commonjs/contexts/{MotionBehaviourContext.js.map → MotionBehaviourContext.cjs.map} +0 -0
- /package/lib-commonjs/contexts/{PresenceGroupChildContext.js → PresenceGroupChildContext.cjs} +0 -0
- /package/lib-commonjs/contexts/{PresenceGroupChildContext.js.map → PresenceGroupChildContext.cjs.map} +0 -0
- /package/lib-commonjs/factories/{createMotionComponent.js.map → createMotionComponent.cjs.map} +0 -0
- /package/lib-commonjs/factories/{createMotionComponentVariant.js.map → createMotionComponentVariant.cjs.map} +0 -0
- /package/lib-commonjs/factories/{createPresenceComponent.js.map → createPresenceComponent.cjs.map} +0 -0
- /package/lib-commonjs/factories/{createPresenceComponentVariant.js.map → createPresenceComponentVariant.cjs.map} +0 -0
- /package/lib-commonjs/hooks/{useAnimateAtoms.js.map → useAnimateAtoms.cjs.map} +0 -0
- /package/lib-commonjs/hooks/{useIsReducedMotion.js → useIsReducedMotion.cjs} +0 -0
- /package/lib-commonjs/hooks/{useIsReducedMotion.js.map → useIsReducedMotion.cjs.map} +0 -0
- /package/lib-commonjs/hooks/{useMotionImperativeRef.js → useMotionImperativeRef.cjs} +0 -0
- /package/lib-commonjs/hooks/{useMotionImperativeRef.js.map → useMotionImperativeRef.cjs.map} +0 -0
- /package/lib-commonjs/hooks/{useMountedState.js → useMountedState.cjs} +0 -0
- /package/lib-commonjs/hooks/{useMountedState.js.map → useMountedState.cjs.map} +0 -0
- /package/lib-commonjs/{index.js.map → index.cjs.map} +0 -0
- /package/lib-commonjs/motions/{motionTokens.js → motionTokens.cjs} +0 -0
- /package/lib-commonjs/motions/{motionTokens.js.map → motionTokens.cjs.map} +0 -0
- /package/lib-commonjs/slots/{motionSlot.js → motionSlot.cjs} +0 -0
- /package/lib-commonjs/slots/{motionSlot.js.map → motionSlot.cjs.map} +0 -0
- /package/lib-commonjs/slots/{presenceMotionSlot.js → presenceMotionSlot.cjs} +0 -0
- /package/lib-commonjs/slots/{presenceMotionSlot.js.map → presenceMotionSlot.cjs.map} +0 -0
- /package/lib-commonjs/{types.js → types.cjs} +0 -0
- /package/lib-commonjs/{types.js.map → types.cjs.map} +0 -0
- /package/lib-commonjs/utils/groups/{getChildMapping.js → getChildMapping.cjs} +0 -0
- /package/lib-commonjs/utils/groups/{getChildMapping.js.map → getChildMapping.cjs.map} +0 -0
- /package/lib-commonjs/utils/groups/{getNextChildMapping.js.map → getNextChildMapping.cjs.map} +0 -0
- /package/lib-commonjs/utils/groups/{mergeChildMappings.js → mergeChildMappings.cjs} +0 -0
- /package/lib-commonjs/utils/groups/{mergeChildMappings.js.map → mergeChildMappings.cjs.map} +0 -0
- /package/lib-commonjs/utils/groups/{types.js → types.cjs} +0 -0
- /package/lib-commonjs/utils/groups/{types.js.map → types.cjs.map} +0 -0
- /package/lib-commonjs/utils/{isAnimationRunning.js → isAnimationRunning.cjs} +0 -0
- /package/lib-commonjs/utils/{isAnimationRunning.js.map → isAnimationRunning.cjs.map} +0 -0
- /package/lib-commonjs/utils/{useChildElement.js → useChildElement.cjs} +0 -0
- /package/lib-commonjs/utils/{useChildElement.js.map → useChildElement.cjs.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
# Change Log - @fluentui/react-motion
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
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.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
|
+
|
|
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
|
+
|
|
12
|
+
### Changes
|
|
13
|
+
|
|
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
|
+
|
|
7
18
|
## [9.16.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-motion_v9.16.1)
|
|
8
19
|
|
|
9
|
-
Wed, 24 Jun 2026 11:
|
|
20
|
+
Wed, 24 Jun 2026 11:09:49 GMT
|
|
10
21
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-motion_v9.16.0..@fluentui/react-motion_v9.16.1)
|
|
11
22
|
|
|
12
23
|
### Patches
|
package/dist/index.d.cts
ADDED
|
@@ -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 { }
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
3
|
-
import * as React from
|
|
4
|
-
import { getNextChildMapping } from
|
|
5
|
-
import { getChildMapping } from
|
|
6
|
-
import { PresenceGroupItemProvider } from
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { getNextChildMapping } from "../utils/groups/getNextChildMapping.js";
|
|
5
|
+
import { getChildMapping } from "../utils/groups/getChildMapping.js";
|
|
6
|
+
import { PresenceGroupItemProvider } from "./PresenceGroupItemProvider.js";
|
|
7
7
|
/* eslint-disable @typescript-eslint/explicit-member-accessibility */ /* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable @typescript-eslint/member-ordering */ export class PresenceGroup extends React.Component {
|
|
8
8
|
static getDerivedStateFromProps(nextProps, { childMapping: prevChildMapping, firstRender }) {
|
|
9
9
|
const nextChildMapping = getChildMapping(nextProps.children);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/PresenceGroup.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport { getNextChildMapping } from '../utils/groups/getNextChildMapping';\nimport { getChildMapping } from '../utils/groups/getChildMapping';\nimport type { PresenceGroupChildMapping } from '../utils/groups/types';\nimport { PresenceGroupItemProvider } from './PresenceGroupItemProvider';\n\ntype PresenceGroupProps = {\n children: React.ReactNode;\n};\n\ntype PresenceGroupState = {\n childMapping: PresenceGroupChildMapping;\n firstRender: boolean;\n};\n\n/* eslint-disable @typescript-eslint/explicit-member-accessibility */\n/* eslint-disable @typescript-eslint/naming-convention */\n/* eslint-disable @typescript-eslint/member-ordering */\n\nexport class PresenceGroup extends React.Component<PresenceGroupProps, PresenceGroupState> {\n private mounted: boolean = false;\n\n static getDerivedStateFromProps(\n nextProps: PresenceGroupProps,\n { childMapping: prevChildMapping, firstRender }: PresenceGroupState,\n ): PresenceGroupState {\n const nextChildMapping = getChildMapping(nextProps.children);\n\n return {\n childMapping: firstRender ? nextChildMapping : getNextChildMapping(prevChildMapping, nextChildMapping),\n firstRender: false,\n };\n }\n\n constructor(props: PresenceGroupProps, context?: unknown) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - React.Component constructor has only one argument in React 19\n super(props, context);\n\n this.state = {\n childMapping: {},\n firstRender: true,\n };\n }\n\n private handleExit = (childKey: string): void => {\n const currentChildMapping = getChildMapping(this.props.children);\n\n if (childKey in currentChildMapping) {\n return;\n }\n\n if (this.mounted) {\n this.setState(state => {\n const childMapping = { ...state.childMapping };\n delete childMapping[childKey];\n\n return { childMapping };\n });\n }\n };\n\n componentDidMount(): void {\n this.mounted = true;\n }\n\n componentWillUnmount(): void {\n this.mounted = false;\n }\n render(): JSXElement {\n return (\n <>\n {Object.entries(this.state.childMapping).map(([childKey, childProps]) => (\n <PresenceGroupItemProvider {...childProps} childKey={childKey} key={childKey} onExit={this.handleExit}>\n {childProps.element}\n </PresenceGroupItemProvider>\n ))}\n </>\n );\n }\n}\n"],"names":["React","getNextChildMapping","getChildMapping","PresenceGroupItemProvider","PresenceGroup","Component","getDerivedStateFromProps","nextProps","childMapping","prevChildMapping","firstRender","nextChildMapping","children","componentDidMount","mounted","componentWillUnmount","render","Object","entries","state","map","childKey","childProps","key","onExit","handleExit","element","constructor","props","context","currentChildMapping","setState"],"mappings":"AAAA;;AAEA,YAAYA,WAAW,QAAQ;AAE/B,SAASC,mBAAmB,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../src/components/PresenceGroup.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport { getNextChildMapping } from '../utils/groups/getNextChildMapping';\nimport { getChildMapping } from '../utils/groups/getChildMapping';\nimport type { PresenceGroupChildMapping } from '../utils/groups/types';\nimport { PresenceGroupItemProvider } from './PresenceGroupItemProvider';\n\ntype PresenceGroupProps = {\n children: React.ReactNode;\n};\n\ntype PresenceGroupState = {\n childMapping: PresenceGroupChildMapping;\n firstRender: boolean;\n};\n\n/* eslint-disable @typescript-eslint/explicit-member-accessibility */\n/* eslint-disable @typescript-eslint/naming-convention */\n/* eslint-disable @typescript-eslint/member-ordering */\n\nexport class PresenceGroup extends React.Component<PresenceGroupProps, PresenceGroupState> {\n private mounted: boolean = false;\n\n static getDerivedStateFromProps(\n nextProps: PresenceGroupProps,\n { childMapping: prevChildMapping, firstRender }: PresenceGroupState,\n ): PresenceGroupState {\n const nextChildMapping = getChildMapping(nextProps.children);\n\n return {\n childMapping: firstRender ? nextChildMapping : getNextChildMapping(prevChildMapping, nextChildMapping),\n firstRender: false,\n };\n }\n\n constructor(props: PresenceGroupProps, context?: unknown) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - React.Component constructor has only one argument in React 19\n super(props, context);\n\n this.state = {\n childMapping: {},\n firstRender: true,\n };\n }\n\n private handleExit = (childKey: string): void => {\n const currentChildMapping = getChildMapping(this.props.children);\n\n if (childKey in currentChildMapping) {\n return;\n }\n\n if (this.mounted) {\n this.setState(state => {\n const childMapping = { ...state.childMapping };\n delete childMapping[childKey];\n\n return { childMapping };\n });\n }\n };\n\n componentDidMount(): void {\n this.mounted = true;\n }\n\n componentWillUnmount(): void {\n this.mounted = false;\n }\n render(): JSXElement {\n return (\n <>\n {Object.entries(this.state.childMapping).map(([childKey, childProps]) => (\n <PresenceGroupItemProvider {...childProps} childKey={childKey} key={childKey} onExit={this.handleExit}>\n {childProps.element}\n </PresenceGroupItemProvider>\n ))}\n </>\n );\n }\n}\n"],"names":["React","getNextChildMapping","getChildMapping","PresenceGroupItemProvider","PresenceGroup","Component","getDerivedStateFromProps","nextProps","childMapping","prevChildMapping","firstRender","nextChildMapping","children","componentDidMount","mounted","componentWillUnmount","render","Object","entries","state","map","childKey","childProps","key","onExit","handleExit","element","constructor","props","context","currentChildMapping","setState"],"mappings":"AAAA;;AAEA,YAAYA,WAAW,QAAQ;AAE/B,SAASC,mBAAmB,QAAQ,yCAAsC;AAC1E,SAASC,eAAe,QAAQ,qCAAkC;AAElE,SAASC,yBAAyB,QAAQ,iCAA8B;AAWxE,mEAAmE,GACnE,uDAAuD,GACvD,qDAAqD,GAErD,OAAO,MAAMC,sBAAsBJ,MAAMK,SAAS;IAGhD,OAAOC,yBACLC,SAA6B,EAC7B,EAAEC,cAAcC,gBAAgB,EAAEC,WAAW,EAAsB,EAC/C;QACpB,MAAMC,mBAAmBT,gBAAgBK,UAAUK,QAAQ;QAE3D,OAAO;YACLJ,cAAcE,cAAcC,mBAAmBV,oBAAoBQ,kBAAkBE;YACrFD,aAAa;QACf;IACF;IA8BAG,oBAA0B;QACxB,IAAI,CAACC,OAAO,GAAG;IACjB;IAEAC,uBAA6B;QAC3B,IAAI,CAACD,OAAO,GAAG;IACjB;IACAE,SAAqB;QACnB,qBACE,0CACGC,OAAOC,OAAO,CAAC,IAAI,CAACC,KAAK,CAACX,YAAY,EAAEY,GAAG,CAAC,CAAC,CAACC,UAAUC,WAAW,iBAClE,oBAACnB;gBAA2B,GAAGmB,UAAU;gBAAED,UAAUA;gBAAUE,KAAKF;gBAAUG,QAAQ,IAAI,CAACC,UAAU;eAClGH,WAAWI,OAAO;IAK7B;IA7CAC,YAAYC,KAAyB,EAAEC,OAAiB,CAAE;QACxD,6DAA6D;QAC7D,6EAA6E;QAC7E,KAAK,CAACD,OAAOC,UAjBf,uBAAQf,WAAmB,QAyB3B,uBAAQW,cAAa,CAACJ;YACpB,MAAMS,sBAAsB5B,gBAAgB,IAAI,CAAC0B,KAAK,CAAChB,QAAQ;YAE/D,IAAIS,YAAYS,qBAAqB;gBACnC;YACF;YAEA,IAAI,IAAI,CAAChB,OAAO,EAAE;gBAChB,IAAI,CAACiB,QAAQ,CAACZ,CAAAA;oBACZ,MAAMX,eAAe;wBAAE,GAAGW,MAAMX,YAAY;oBAAC;oBAC7C,OAAOA,YAAY,CAACa,SAAS;oBAE7B,OAAO;wBAAEb;oBAAa;gBACxB;YACF;QACF;QArBE,IAAI,CAACW,KAAK,GAAG;YACXX,cAAc,CAAC;YACfE,aAAa;QACf;IACF;AAqCF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import * as React from
|
|
3
|
-
import { PresenceGroupChildContext } from
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { PresenceGroupChildContext } from "../contexts/PresenceGroupChildContext.js";
|
|
4
4
|
/**
|
|
5
5
|
* Provides context for a single child of a `PresenceGroup`. Exists only to make a stable context value for a child.
|
|
6
6
|
* Not intended for direct use.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/PresenceGroupItemProvider.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport { PresenceGroupChildContext } from '../contexts/PresenceGroupChildContext';\nimport type { PresenceGroupChildContextValue } from '../contexts/PresenceGroupChildContext';\n\ntype PresenceGroupItemProviderProps = Omit<PresenceGroupChildContextValue, 'onExit'> & {\n children: JSXElement;\n childKey: string;\n // That's an internal callback, so we don't need to enforce the type here\n // eslint-disable-next-line @nx/workspace-consistent-callback-type\n onExit: (childKey: string) => void;\n};\n\n/**\n * Provides context for a single child of a `PresenceGroup`. Exists only to make a stable context value for a child.\n * Not intended for direct use.\n *\n * @internal\n */\nexport const PresenceGroupItemProvider: React.FC<PresenceGroupItemProviderProps> = props => {\n const { appear, childKey, onExit, visible, unmountOnExit } = props;\n const contextValue = React.useMemo(\n () => ({\n appear,\n visible,\n onExit: () => onExit(childKey),\n unmountOnExit,\n }),\n [appear, childKey, onExit, visible, unmountOnExit],\n );\n\n return <PresenceGroupChildContext.Provider value={contextValue}>{props.children}</PresenceGroupChildContext.Provider>;\n};\n"],"names":["React","PresenceGroupChildContext","PresenceGroupItemProvider","props","appear","childKey","onExit","visible","unmountOnExit","contextValue","useMemo","Provider","value","children"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAG/B,SAASC,yBAAyB,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../src/components/PresenceGroupItemProvider.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport { PresenceGroupChildContext } from '../contexts/PresenceGroupChildContext';\nimport type { PresenceGroupChildContextValue } from '../contexts/PresenceGroupChildContext';\n\ntype PresenceGroupItemProviderProps = Omit<PresenceGroupChildContextValue, 'onExit'> & {\n children: JSXElement;\n childKey: string;\n // That's an internal callback, so we don't need to enforce the type here\n // eslint-disable-next-line @nx/workspace-consistent-callback-type\n onExit: (childKey: string) => void;\n};\n\n/**\n * Provides context for a single child of a `PresenceGroup`. Exists only to make a stable context value for a child.\n * Not intended for direct use.\n *\n * @internal\n */\nexport const PresenceGroupItemProvider: React.FC<PresenceGroupItemProviderProps> = props => {\n const { appear, childKey, onExit, visible, unmountOnExit } = props;\n const contextValue = React.useMemo(\n () => ({\n appear,\n visible,\n onExit: () => onExit(childKey),\n unmountOnExit,\n }),\n [appear, childKey, onExit, visible, unmountOnExit],\n );\n\n return <PresenceGroupChildContext.Provider value={contextValue}>{props.children}</PresenceGroupChildContext.Provider>;\n};\n"],"names":["React","PresenceGroupChildContext","PresenceGroupItemProvider","props","appear","childKey","onExit","visible","unmountOnExit","contextValue","useMemo","Provider","value","children"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAG/B,SAASC,yBAAyB,QAAQ,2CAAwC;AAWlF;;;;;CAKC,GACD,OAAO,MAAMC,4BAAsEC,CAAAA;IACjF,MAAM,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,OAAO,EAAEC,aAAa,EAAE,GAAGL;IAC7D,MAAMM,eAAeT,MAAMU,OAAO,CAChC,IAAO,CAAA;YACLN;YACAG;YACAD,QAAQ,IAAMA,OAAOD;YACrBG;QACF,CAAA,GACA;QAACJ;QAAQC;QAAUC;QAAQC;QAASC;KAAc;IAGpD,qBAAO,oBAACP,0BAA0BU,QAAQ;QAACC,OAAOH;OAAeN,MAAMU,QAAQ;AACjF,EAAE"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { useEventCallback, useIsomorphicLayoutEffect } from
|
|
3
|
-
import * as React from
|
|
4
|
-
import { useAnimateAtoms } from
|
|
5
|
-
import { useMotionImperativeRef } from
|
|
6
|
-
import { useIsReducedMotion } from
|
|
7
|
-
import { useChildElement } from
|
|
8
|
-
import { useMotionBehaviourContext } from
|
|
2
|
+
import { useEventCallback, useIsomorphicLayoutEffect } from "@fluentui/react-utilities";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { useAnimateAtoms } from "../hooks/useAnimateAtoms.js";
|
|
5
|
+
import { useMotionImperativeRef } from "../hooks/useMotionImperativeRef.js";
|
|
6
|
+
import { useIsReducedMotion } from "../hooks/useIsReducedMotion.js";
|
|
7
|
+
import { useChildElement } from "../utils/useChildElement.js";
|
|
8
|
+
import { useMotionBehaviourContext } from "../contexts/MotionBehaviourContext.js";
|
|
9
9
|
/**
|
|
10
10
|
* A private symbol to store the motion definition on the component for variants.
|
|
11
11
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/factories/createMotionComponent.ts"],"sourcesContent":["'use client';\n\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport { useEventCallback, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { useAnimateAtoms } from '../hooks/useAnimateAtoms';\nimport { useMotionImperativeRef } from '../hooks/useMotionImperativeRef';\nimport { useIsReducedMotion } from '../hooks/useIsReducedMotion';\nimport { useChildElement } from '../utils/useChildElement';\nimport type { AtomMotion, AtomMotionFn, MotionParam, MotionImperativeRef, AnimationHandle } from '../types';\nimport { useMotionBehaviourContext } from '../contexts/MotionBehaviourContext';\n\n/**\n * A private symbol to store the motion definition on the component for variants.\n *\n * @internal\n */\nexport const MOTION_DEFINITION = Symbol('MOTION_DEFINITION');\n\nexport type MotionComponentProps = {\n children: JSXElement;\n\n /** Provides imperative controls for the animation. */\n imperativeRef?: React.Ref<MotionImperativeRef | undefined>;\n\n /**\n * Callback that is called when the whole motion finishes.\n *\n * A motion definition can contain multiple animations and therefore multiple \"finish\" events. The callback is\n * triggered once all animations have finished with \"null\" instead of an event object to avoid ambiguity.\n */\n // eslint-disable-next-line @nx/workspace-consistent-callback-type -- EventHandler<T> does not support \"null\"\n onMotionFinish?: (ev: null) => void;\n\n /**\n * Callback that is called when the whole motion is cancelled.\n *\n * A motion definition can contain multiple animations and therefore multiple \"cancel\" events. The callback is\n * triggered once all animations have been cancelled with \"null\" instead of an event object to avoid ambiguity.\n */\n // eslint-disable-next-line @nx/workspace-consistent-callback-type -- EventHandler<T> does not support \"null\"\n onMotionCancel?: (ev: null) => void;\n\n /**\n * Callback that is called when the whole motion starts.\n *\n * A motion definition can contain multiple animations and therefore multiple \"start\" events. The callback is\n * triggered when the first animation is started. There is no official \"start\" event with the Web Animations API.\n * so the callback is triggered with \"null\".\n */\n // eslint-disable-next-line @nx/workspace-consistent-callback-type -- EventHandler<T> does not support \"null\"\n onMotionStart?: (ev: null) => void;\n\n /**\n * When this value changes, the animation replays from the start on the same DOM element,\n * cancelling any in-progress animation, without remounting the component or its children.\n *\n * **Why not just use a React `key`?** Changing a React `key` forces a full unmount and\n * remount of the subtree: DOM nodes are destroyed and recreated, focus is lost, and any\n * child state is reset. `replayKey` avoids all of that — only the animation effect reruns\n * while the DOM and component state remain intact.\n *\n * Use this when you want to retrigger a motion in response to a state change (e.g. a user\n * action or a data update) while preserving DOM continuity. It is the declarative equivalent\n * of calling `imperativeRef.current.play()` but driven by a prop rather than a ref call.\n *\n * @example\n * ```tsx\n * // Replay a Fade.In each time the user clicks \"Refresh\"\n * const [replayKey, setReplayKey] = React.useState(0);\n * <Fade.In replayKey={replayKey}>\n * <div>Content</div>\n * </Fade.In>\n * <button onClick={() => setReplayKey(k => k + 1)}>Refresh</button>\n * ```\n */\n replayKey?: string | number;\n};\n\nexport type MotionComponent<MotionParams extends Record<string, MotionParam> = {}> = React.FC<\n MotionComponentProps & MotionParams\n> & {\n [MOTION_DEFINITION]: AtomMotionFn<MotionParams>;\n};\n\n/**\n * Creates a component that will animate the children using the provided motion.\n *\n * @param value - A motion definition.\n */\nexport function createMotionComponent<MotionParams extends Record<string, MotionParam> = {}>(\n value: AtomMotion | AtomMotion[] | AtomMotionFn<MotionParams>,\n): MotionComponent<MotionParams> {\n const Atom: React.FC<MotionComponentProps & MotionParams> = props => {\n const {\n children,\n imperativeRef,\n onMotionFinish: onMotionFinishProp,\n onMotionStart: onMotionStartProp,\n onMotionCancel: onMotionCancelProp,\n replayKey,\n ..._rest\n } = props;\n const params = _rest as Exclude<typeof props, MotionComponentProps>;\n const [child, childRef] = useChildElement(children);\n\n const handleRef = useMotionImperativeRef(imperativeRef);\n const isInitialRender = React.useRef(true);\n const skipMotions = useMotionBehaviourContext() === 'skip';\n const optionsRef = React.useRef<{ skipMotions: boolean; params: MotionParams }>({\n skipMotions,\n params,\n });\n\n const animateAtoms = useAnimateAtoms();\n const isReducedMotion = useIsReducedMotion();\n\n const onMotionStart = useEventCallback(() => {\n onMotionStartProp?.(null);\n });\n\n const onMotionFinish = useEventCallback(() => {\n onMotionFinishProp?.(null);\n });\n\n const onMotionCancel = useEventCallback(() => {\n onMotionCancelProp?.(null);\n });\n\n // Stable callback (all deps are refs or useEventCallback) that activates a handle for a new playback cycle.\n //\n // TODO: consider moving the cancel+play+rewire sequence into a handle.replay() method on AnimationHandle,\n // keeping pure animation sequencing on the handle and React callbacks here in the component.\n const activateAnimationHandle = React.useCallback(\n (handle: AnimationHandle) => {\n onMotionStart();\n handle.setMotionEndCallbacks(onMotionFinish, onMotionCancel);\n if (optionsRef.current.skipMotions) {\n handle.finish();\n }\n },\n [onMotionStart, onMotionFinish, onMotionCancel],\n );\n\n useIsomorphicLayoutEffect(() => {\n // Heads up!\n // We store the params in a ref to avoid re-rendering the component when the params change.\n optionsRef.current = { skipMotions, params };\n });\n\n useIsomorphicLayoutEffect(() => {\n const element = childRef.current;\n\n if (element) {\n const atoms = typeof value === 'function' ? value({ element, ...optionsRef.current.params }) : value;\n\n const handle = animateAtoms(element, atoms, { isReducedMotion: isReducedMotion() });\n handleRef.current = handle;\n activateAnimationHandle(handle);\n\n return () => {\n handle.cancel();\n };\n }\n }, [animateAtoms, childRef, handleRef, isReducedMotion, activateAnimationHandle]);\n\n // Skips initial mount; on replayKey changes, reuses existing Animation objects via cancel+play\n // rather than recreating them, preserving DOM continuity.\n useIsomorphicLayoutEffect(() => {\n if (isInitialRender.current) {\n return;\n }\n\n const handle = handleRef.current;\n if (handle) {\n handle.cancel();\n handle.play();\n activateAnimationHandle(handle);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps -- replayKey is intentionally the only trigger; other deps are stable refs/callbacks\n }, [replayKey]);\n\n useIsomorphicLayoutEffect(() => {\n isInitialRender.current = false;\n\n return () => {\n isInitialRender.current = true;\n };\n }, []);\n\n return child;\n };\n\n return Object.assign(Atom, {\n // Heads up!\n // Always normalize it to a function to simplify types\n [MOTION_DEFINITION]: typeof value === 'function' ? value : () => value,\n });\n}\n"],"names":["useEventCallback","useIsomorphicLayoutEffect","React","useAnimateAtoms","useMotionImperativeRef","useIsReducedMotion","useChildElement","useMotionBehaviourContext","MOTION_DEFINITION","Symbol","createMotionComponent","value","Atom","props","children","imperativeRef","onMotionFinish","onMotionFinishProp","onMotionStart","onMotionStartProp","onMotionCancel","onMotionCancelProp","replayKey","_rest","params","child","childRef","handleRef","isInitialRender","useRef","skipMotions","optionsRef","animateAtoms","isReducedMotion","activateAnimationHandle","useCallback","handle","setMotionEndCallbacks","current","finish","element","atoms","cancel","play","Object","assign"],"mappings":"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"}
|
|
1
|
+
{"version":3,"sources":["../src/factories/createMotionComponent.ts"],"sourcesContent":["'use client';\n\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport { useEventCallback, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { useAnimateAtoms } from '../hooks/useAnimateAtoms';\nimport { useMotionImperativeRef } from '../hooks/useMotionImperativeRef';\nimport { useIsReducedMotion } from '../hooks/useIsReducedMotion';\nimport { useChildElement } from '../utils/useChildElement';\nimport type { AtomMotion, AtomMotionFn, MotionParam, MotionImperativeRef, AnimationHandle } from '../types';\nimport { useMotionBehaviourContext } from '../contexts/MotionBehaviourContext';\n\n/**\n * A private symbol to store the motion definition on the component for variants.\n *\n * @internal\n */\nexport const MOTION_DEFINITION = Symbol('MOTION_DEFINITION');\n\nexport type MotionComponentProps = {\n children: JSXElement;\n\n /** Provides imperative controls for the animation. */\n imperativeRef?: React.Ref<MotionImperativeRef | undefined>;\n\n /**\n * Callback that is called when the whole motion finishes.\n *\n * A motion definition can contain multiple animations and therefore multiple \"finish\" events. The callback is\n * triggered once all animations have finished with \"null\" instead of an event object to avoid ambiguity.\n */\n // eslint-disable-next-line @nx/workspace-consistent-callback-type -- EventHandler<T> does not support \"null\"\n onMotionFinish?: (ev: null) => void;\n\n /**\n * Callback that is called when the whole motion is cancelled.\n *\n * A motion definition can contain multiple animations and therefore multiple \"cancel\" events. The callback is\n * triggered once all animations have been cancelled with \"null\" instead of an event object to avoid ambiguity.\n */\n // eslint-disable-next-line @nx/workspace-consistent-callback-type -- EventHandler<T> does not support \"null\"\n onMotionCancel?: (ev: null) => void;\n\n /**\n * Callback that is called when the whole motion starts.\n *\n * A motion definition can contain multiple animations and therefore multiple \"start\" events. The callback is\n * triggered when the first animation is started. There is no official \"start\" event with the Web Animations API.\n * so the callback is triggered with \"null\".\n */\n // eslint-disable-next-line @nx/workspace-consistent-callback-type -- EventHandler<T> does not support \"null\"\n onMotionStart?: (ev: null) => void;\n\n /**\n * When this value changes, the animation replays from the start on the same DOM element,\n * cancelling any in-progress animation, without remounting the component or its children.\n *\n * **Why not just use a React `key`?** Changing a React `key` forces a full unmount and\n * remount of the subtree: DOM nodes are destroyed and recreated, focus is lost, and any\n * child state is reset. `replayKey` avoids all of that — only the animation effect reruns\n * while the DOM and component state remain intact.\n *\n * Use this when you want to retrigger a motion in response to a state change (e.g. a user\n * action or a data update) while preserving DOM continuity. It is the declarative equivalent\n * of calling `imperativeRef.current.play()` but driven by a prop rather than a ref call.\n *\n * @example\n * ```tsx\n * // Replay a Fade.In each time the user clicks \"Refresh\"\n * const [replayKey, setReplayKey] = React.useState(0);\n * <Fade.In replayKey={replayKey}>\n * <div>Content</div>\n * </Fade.In>\n * <button onClick={() => setReplayKey(k => k + 1)}>Refresh</button>\n * ```\n */\n replayKey?: string | number;\n};\n\nexport type MotionComponent<MotionParams extends Record<string, MotionParam> = {}> = React.FC<\n MotionComponentProps & MotionParams\n> & {\n [MOTION_DEFINITION]: AtomMotionFn<MotionParams>;\n};\n\n/**\n * Creates a component that will animate the children using the provided motion.\n *\n * @param value - A motion definition.\n */\nexport function createMotionComponent<MotionParams extends Record<string, MotionParam> = {}>(\n value: AtomMotion | AtomMotion[] | AtomMotionFn<MotionParams>,\n): MotionComponent<MotionParams> {\n const Atom: React.FC<MotionComponentProps & MotionParams> = props => {\n const {\n children,\n imperativeRef,\n onMotionFinish: onMotionFinishProp,\n onMotionStart: onMotionStartProp,\n onMotionCancel: onMotionCancelProp,\n replayKey,\n ..._rest\n } = props;\n const params = _rest as Exclude<typeof props, MotionComponentProps>;\n const [child, childRef] = useChildElement(children);\n\n const handleRef = useMotionImperativeRef(imperativeRef);\n const isInitialRender = React.useRef(true);\n const skipMotions = useMotionBehaviourContext() === 'skip';\n const optionsRef = React.useRef<{ skipMotions: boolean; params: MotionParams }>({\n skipMotions,\n params,\n });\n\n const animateAtoms = useAnimateAtoms();\n const isReducedMotion = useIsReducedMotion();\n\n const onMotionStart = useEventCallback(() => {\n onMotionStartProp?.(null);\n });\n\n const onMotionFinish = useEventCallback(() => {\n onMotionFinishProp?.(null);\n });\n\n const onMotionCancel = useEventCallback(() => {\n onMotionCancelProp?.(null);\n });\n\n // Stable callback (all deps are refs or useEventCallback) that activates a handle for a new playback cycle.\n //\n // TODO: consider moving the cancel+play+rewire sequence into a handle.replay() method on AnimationHandle,\n // keeping pure animation sequencing on the handle and React callbacks here in the component.\n const activateAnimationHandle = React.useCallback(\n (handle: AnimationHandle) => {\n onMotionStart();\n handle.setMotionEndCallbacks(onMotionFinish, onMotionCancel);\n if (optionsRef.current.skipMotions) {\n handle.finish();\n }\n },\n [onMotionStart, onMotionFinish, onMotionCancel],\n );\n\n useIsomorphicLayoutEffect(() => {\n // Heads up!\n // We store the params in a ref to avoid re-rendering the component when the params change.\n optionsRef.current = { skipMotions, params };\n });\n\n useIsomorphicLayoutEffect(() => {\n const element = childRef.current;\n\n if (element) {\n const atoms = typeof value === 'function' ? value({ element, ...optionsRef.current.params }) : value;\n\n const handle = animateAtoms(element, atoms, { isReducedMotion: isReducedMotion() });\n handleRef.current = handle;\n activateAnimationHandle(handle);\n\n return () => {\n handle.cancel();\n };\n }\n }, [animateAtoms, childRef, handleRef, isReducedMotion, activateAnimationHandle]);\n\n // Skips initial mount; on replayKey changes, reuses existing Animation objects via cancel+play\n // rather than recreating them, preserving DOM continuity.\n useIsomorphicLayoutEffect(() => {\n if (isInitialRender.current) {\n return;\n }\n\n const handle = handleRef.current;\n if (handle) {\n handle.cancel();\n handle.play();\n activateAnimationHandle(handle);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps -- replayKey is intentionally the only trigger; other deps are stable refs/callbacks\n }, [replayKey]);\n\n useIsomorphicLayoutEffect(() => {\n isInitialRender.current = false;\n\n return () => {\n isInitialRender.current = true;\n };\n }, []);\n\n return child;\n };\n\n return Object.assign(Atom, {\n // Heads up!\n // Always normalize it to a function to simplify types\n [MOTION_DEFINITION]: typeof value === 'function' ? value : () => value,\n });\n}\n"],"names":["useEventCallback","useIsomorphicLayoutEffect","React","useAnimateAtoms","useMotionImperativeRef","useIsReducedMotion","useChildElement","useMotionBehaviourContext","MOTION_DEFINITION","Symbol","createMotionComponent","value","Atom","props","children","imperativeRef","onMotionFinish","onMotionFinishProp","onMotionStart","onMotionStartProp","onMotionCancel","onMotionCancelProp","replayKey","_rest","params","child","childRef","handleRef","isInitialRender","useRef","skipMotions","optionsRef","animateAtoms","isReducedMotion","activateAnimationHandle","useCallback","handle","setMotionEndCallbacks","current","finish","element","atoms","cancel","play","Object","assign"],"mappings":"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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MOTION_DEFINITION, createMotionComponent } from
|
|
1
|
+
import { MOTION_DEFINITION, createMotionComponent } from "./createMotionComponent.js";
|
|
2
2
|
/**
|
|
3
3
|
* Create a variant function that wraps a motion function to customize it.
|
|
4
4
|
* The new motion function has the supplied variant params as defaults,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/factories/createMotionComponentVariant.ts"],"sourcesContent":["import type { MotionParam, AtomMotionFn } from '../types';\nimport type { MotionComponent } from './createMotionComponent';\nimport { MOTION_DEFINITION, createMotionComponent } from './createMotionComponent';\n\n/**\n * Create a variant function that wraps a motion function to customize it.\n * The new motion function has the supplied variant params as defaults,\n * but these can still be overridden by runtime params when the new function is called.\n *\n * @internal\n */\nexport function createMotionFnVariant<MotionParams extends Record<string, MotionParam> = {}>(\n motionFn: AtomMotionFn<MotionParams>,\n variantParams: Partial<MotionParams>,\n): typeof motionFn {\n const variantFn: typeof motionFn = runtimeParams => motionFn({ ...variantParams, ...runtimeParams });\n return variantFn;\n}\n\n/**\n * Create a new motion component based on another motion component,\n * using the provided variant parameters as defaults.\n *\n * @param component - A component created by `createMotionComponent`.\n * @param variantParams - An object containing the variant parameters to be used as defaults.\n * The variant parameters should match the type of the component's motion parameters.\n * @returns A new motion component that uses the provided variant parameters as defaults.\n * The new component can still accept runtime parameters that override the defaults.\n */\nexport function createMotionComponentVariant<MotionParams extends Record<string, MotionParam> = {}>(\n component: MotionComponent<MotionParams>,\n variantParams: Partial<MotionParams>,\n): MotionComponent<MotionParams> {\n const originalFn = component[MOTION_DEFINITION];\n // The variant params become new defaults, but they can still be overridden by runtime params.\n const variantFn = createMotionFnVariant(originalFn, variantParams);\n return createMotionComponent(variantFn);\n}\n"],"names":["MOTION_DEFINITION","createMotionComponent","createMotionFnVariant","motionFn","variantParams","variantFn","runtimeParams","createMotionComponentVariant","component","originalFn"],"mappings":"AAEA,SAASA,iBAAiB,EAAEC,qBAAqB,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../src/factories/createMotionComponentVariant.ts"],"sourcesContent":["import type { MotionParam, AtomMotionFn } from '../types';\nimport type { MotionComponent } from './createMotionComponent';\nimport { MOTION_DEFINITION, createMotionComponent } from './createMotionComponent';\n\n/**\n * Create a variant function that wraps a motion function to customize it.\n * The new motion function has the supplied variant params as defaults,\n * but these can still be overridden by runtime params when the new function is called.\n *\n * @internal\n */\nexport function createMotionFnVariant<MotionParams extends Record<string, MotionParam> = {}>(\n motionFn: AtomMotionFn<MotionParams>,\n variantParams: Partial<MotionParams>,\n): typeof motionFn {\n const variantFn: typeof motionFn = runtimeParams => motionFn({ ...variantParams, ...runtimeParams });\n return variantFn;\n}\n\n/**\n * Create a new motion component based on another motion component,\n * using the provided variant parameters as defaults.\n *\n * @param component - A component created by `createMotionComponent`.\n * @param variantParams - An object containing the variant parameters to be used as defaults.\n * The variant parameters should match the type of the component's motion parameters.\n * @returns A new motion component that uses the provided variant parameters as defaults.\n * The new component can still accept runtime parameters that override the defaults.\n */\nexport function createMotionComponentVariant<MotionParams extends Record<string, MotionParam> = {}>(\n component: MotionComponent<MotionParams>,\n variantParams: Partial<MotionParams>,\n): MotionComponent<MotionParams> {\n const originalFn = component[MOTION_DEFINITION];\n // The variant params become new defaults, but they can still be overridden by runtime params.\n const variantFn = createMotionFnVariant(originalFn, variantParams);\n return createMotionComponent(variantFn);\n}\n"],"names":["MOTION_DEFINITION","createMotionComponent","createMotionFnVariant","motionFn","variantParams","variantFn","runtimeParams","createMotionComponentVariant","component","originalFn"],"mappings":"AAEA,SAASA,iBAAiB,EAAEC,qBAAqB,QAAQ,6BAA0B;AAEnF;;;;;;CAMC,GACD,OAAO,SAASC,sBACdC,QAAoC,EACpCC,aAAoC;IAEpC,MAAMC,YAA6BC,CAAAA,gBAAiBH,SAAS;YAAE,GAAGC,aAAa;YAAE,GAAGE,aAAa;QAAC;IAClG,OAAOD;AACT;AAEA;;;;;;;;;CASC,GACD,OAAO,SAASE,6BACdC,SAAwC,EACxCJ,aAAoC;IAEpC,MAAMK,aAAaD,SAAS,CAACR,kBAAkB;IAC/C,8FAA8F;IAC9F,MAAMK,YAAYH,sBAAsBO,YAAYL;IACpD,OAAOH,sBAAsBI;AAC/B"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { useEventCallback, useFirstMount, useIsomorphicLayoutEffect } from
|
|
3
|
-
import * as React from
|
|
4
|
-
import { PresenceGroupChildContext } from
|
|
5
|
-
import { useAnimateAtoms } from
|
|
6
|
-
import { useMotionImperativeRef } from
|
|
7
|
-
import { useMountedState } from
|
|
8
|
-
import { useIsReducedMotion } from
|
|
9
|
-
import { useChildElement } from
|
|
10
|
-
import { useMotionBehaviourContext } from
|
|
11
|
-
import { createMotionComponent } from
|
|
2
|
+
import { useEventCallback, useFirstMount, useIsomorphicLayoutEffect } from "@fluentui/react-utilities";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { PresenceGroupChildContext } from "../contexts/PresenceGroupChildContext.js";
|
|
5
|
+
import { useAnimateAtoms } from "../hooks/useAnimateAtoms.js";
|
|
6
|
+
import { useMotionImperativeRef } from "../hooks/useMotionImperativeRef.js";
|
|
7
|
+
import { useMountedState } from "../hooks/useMountedState.js";
|
|
8
|
+
import { useIsReducedMotion } from "../hooks/useIsReducedMotion.js";
|
|
9
|
+
import { useChildElement } from "../utils/useChildElement.js";
|
|
10
|
+
import { useMotionBehaviourContext } from "../contexts/MotionBehaviourContext.js";
|
|
11
|
+
import { createMotionComponent } from "./createMotionComponent.js";
|
|
12
12
|
/**
|
|
13
13
|
* A private symbol to store the motion definition on the component for variants.
|
|
14
14
|
*
|