@fluentui/react-motion-components-preview 0.12.0 → 0.14.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 (43) hide show
  1. package/CHANGELOG.md +20 -2
  2. package/dist/index.d.ts +230 -0
  3. package/lib/choreography/Stagger/Stagger.js +189 -0
  4. package/lib/choreography/Stagger/Stagger.js.map +1 -0
  5. package/lib/choreography/Stagger/index.js +1 -0
  6. package/lib/choreography/Stagger/index.js.map +1 -0
  7. package/lib/choreography/Stagger/stagger-types.js +1 -0
  8. package/lib/choreography/Stagger/stagger-types.js.map +1 -0
  9. package/lib/choreography/Stagger/useStaggerItemsVisibility.js +176 -0
  10. package/lib/choreography/Stagger/useStaggerItemsVisibility.js.map +1 -0
  11. package/lib/choreography/Stagger/utils/constants.js +5 -0
  12. package/lib/choreography/Stagger/utils/constants.js.map +1 -0
  13. package/lib/choreography/Stagger/utils/getStaggerChildMapping.js +29 -0
  14. package/lib/choreography/Stagger/utils/getStaggerChildMapping.js.map +1 -0
  15. package/lib/choreography/Stagger/utils/index.js +4 -0
  16. package/lib/choreography/Stagger/utils/index.js.map +1 -0
  17. package/lib/choreography/Stagger/utils/motionComponentDetection.js +83 -0
  18. package/lib/choreography/Stagger/utils/motionComponentDetection.js.map +1 -0
  19. package/lib/choreography/Stagger/utils/stagger-calculations.js +71 -0
  20. package/lib/choreography/Stagger/utils/stagger-calculations.js.map +1 -0
  21. package/lib/index.js +7 -0
  22. package/lib/index.js.map +1 -1
  23. package/lib-commonjs/choreography/Stagger/Stagger.js +137 -0
  24. package/lib-commonjs/choreography/Stagger/Stagger.js.map +1 -0
  25. package/lib-commonjs/choreography/Stagger/index.js +11 -0
  26. package/lib-commonjs/choreography/Stagger/index.js.map +1 -0
  27. package/lib-commonjs/choreography/Stagger/stagger-types.js +6 -0
  28. package/lib-commonjs/choreography/Stagger/stagger-types.js.map +1 -0
  29. package/lib-commonjs/choreography/Stagger/useStaggerItemsVisibility.js +161 -0
  30. package/lib-commonjs/choreography/Stagger/useStaggerItemsVisibility.js.map +1 -0
  31. package/lib-commonjs/choreography/Stagger/utils/constants.js +23 -0
  32. package/lib-commonjs/choreography/Stagger/utils/constants.js.map +1 -0
  33. package/lib-commonjs/choreography/Stagger/utils/getStaggerChildMapping.js +27 -0
  34. package/lib-commonjs/choreography/Stagger/utils/getStaggerChildMapping.js.map +1 -0
  35. package/lib-commonjs/choreography/Stagger/utils/index.js +37 -0
  36. package/lib-commonjs/choreography/Stagger/utils/index.js.map +1 -0
  37. package/lib-commonjs/choreography/Stagger/utils/motionComponentDetection.js +48 -0
  38. package/lib-commonjs/choreography/Stagger/utils/motionComponentDetection.js.map +1 -0
  39. package/lib-commonjs/choreography/Stagger/utils/stagger-calculations.js +76 -0
  40. package/lib-commonjs/choreography/Stagger/utils/stagger-calculations.js.map +1 -0
  41. package/lib-commonjs/index.js +25 -0
  42. package/lib-commonjs/index.js.map +1 -1
  43. package/package.json +2 -1
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "Stagger", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _Stagger.Stagger;
9
+ }
10
+ });
11
+ const _Stagger = require("./Stagger");
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/choreography/Stagger/index.ts"],"sourcesContent":["export { Stagger } from './Stagger';\nexport type { StaggerProps } from './stagger-types';\n"],"names":["Stagger"],"mappings":";;;;+BAASA;;;eAAAA,gBAAO;;;yBAAQ"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
6
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/choreography/Stagger/stagger-types.ts"],"sourcesContent":["import { PresenceComponentProps, PresenceDirection } from '@fluentui/react-motion';\nimport * as React from 'react';\n\n/**\n * Defines how Stagger manages its children's visibility/mounting.\n * - 'visibleProp': Children are components with a `visible` prop (e.g. motion components)\n * - 'visibilityStyle': Children remain in DOM with inline style `visibility: hidden | visible`\n * - 'unmount': Children are mounted/unmounted from DOM based on visibility\n */\nexport type StaggerHideMode = 'visibleProp' | 'visibilityStyle' | 'unmount';\n\n/**\n * Defines how Stagger implements the timing of staggered animations.\n * - 'timing': Manages visibility over time using JavaScript timing (current behavior)\n * - 'delayProp': Passes delay props to motion components to use native Web Animations API delays\n */\nexport type StaggerDelayMode = 'timing' | 'delayProp';\n\n/**\n * Props for the Stagger component that manages staggered entrance and exit animations.\n */\nexport interface StaggerProps {\n /** React elements to animate. Elements are cloned with animation props. */\n children: React.ReactNode;\n\n /**\n * Controls children animation direction. When `true`, the group is animating \"enter\" (items shown).\n * When `false`, the group is animating \"exit\" (items hidden).\n */\n visible?: PresenceComponentProps['visible'];\n\n /** Whether to reverse the stagger sequence (last item animates first). Defaults to `false`. */\n reversed?: boolean;\n\n /**\n * Milliseconds between each child's animation start.\n * Defaults to the package's default delay (see `DEFAULT_ITEM_DELAY`).\n */\n itemDelay?: number;\n\n /**\n * Milliseconds each child's animation lasts. Only used with `delayMode=\"timing\"`.\n * Defaults to the package's default duration (see `DEFAULT_ITEM_DURATION`).\n */\n itemDuration?: number;\n\n /** How children's visibility/mounting is managed. Auto-detects if not specified. */\n hideMode?: StaggerHideMode;\n\n /** How staggering timing is implemented. Defaults to 'timing'. */\n delayMode?: StaggerDelayMode;\n\n /** Callback invoked when the staggered animation sequence completes. */\n onMotionFinish?: () => void;\n}\n\nexport interface StaggerOneWayProps extends Omit<StaggerProps, 'visible' | 'hideMode' | 'delayMode'> {\n /** Animation direction: 'enter' or 'exit'. */\n direction: PresenceDirection;\n\n /** How children's visibility/mounting is managed. Required - provided by wrapper components. */\n hideMode: StaggerHideMode;\n\n /** How staggering timing is implemented. Required - provided by wrapper components. */\n delayMode: StaggerDelayMode;\n}\n"],"names":[],"mappings":";;;;;iEACuB"}
@@ -0,0 +1,161 @@
1
+ 'use client';
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "useStaggerItemsVisibility", {
7
+ enumerable: true,
8
+ get: function() {
9
+ return useStaggerItemsVisibility;
10
+ }
11
+ });
12
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
13
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
14
+ const _reactutilities = require("@fluentui/react-utilities");
15
+ const _utils = require("./utils");
16
+ function useStaggerItemsVisibility({ childMapping, itemDelay, itemDuration = _utils.DEFAULT_ITEM_DURATION, direction, reversed = false, onMotionFinish, hideMode = 'visibleProp' }) {
17
+ const [requestAnimationFrame, cancelAnimationFrame] = (0, _reactutilities.useAnimationFrame)();
18
+ // Stabilize the callback reference to avoid re-triggering effects on every render
19
+ const handleMotionFinish = (0, _reactutilities.useEventCallback)(onMotionFinish !== null && onMotionFinish !== void 0 ? onMotionFinish : ()=>{
20
+ return;
21
+ });
22
+ // Track animation state independently of child changes
23
+ const [animationKey, setAnimationKey] = _react.useState(0);
24
+ const prevDirection = _react.useRef(direction);
25
+ // Only trigger new animation when direction actually changes, not when children change
26
+ _react.useEffect(()=>{
27
+ if (prevDirection.current !== direction) {
28
+ setAnimationKey((prev)=>prev + 1);
29
+ prevDirection.current = direction;
30
+ }
31
+ }, [
32
+ direction
33
+ ]);
34
+ // State: visibility mapping for all items by key
35
+ const [itemsVisibility, setItemsVisibility] = _react.useState(()=>{
36
+ const initial = {};
37
+ // All hide modes start in final state: visible for 'enter', hidden for 'exit'
38
+ const initialState = direction === 'enter';
39
+ Object.keys(childMapping).forEach((key)=>{
40
+ initial[key] = initialState;
41
+ });
42
+ return initial;
43
+ });
44
+ // Update visibility mapping when childMapping changes
45
+ _react.useEffect(()=>{
46
+ setItemsVisibility((prev)=>{
47
+ const next = {};
48
+ const targetState = direction === 'enter';
49
+ // Add or update items from new mapping
50
+ Object.keys(childMapping).forEach((key)=>{
51
+ if (key in prev) {
52
+ // Existing item - preserve its visibility state
53
+ next[key] = prev[key];
54
+ } else {
55
+ // New item - set to target state
56
+ next[key] = targetState;
57
+ }
58
+ });
59
+ // Note: Items that were in prev but not in childMapping are automatically removed
60
+ // because we only iterate over keys in childMapping
61
+ return next;
62
+ });
63
+ }, [
64
+ childMapping,
65
+ direction
66
+ ]);
67
+ // Refs: animation timing and control
68
+ const startTimeRef = _react.useRef(null);
69
+ const frameRef = _react.useRef(null);
70
+ const finishedRef = _react.useRef(false);
71
+ const isFirstRender = _react.useRef(true);
72
+ // Use ref to avoid re-running the animation when child mapping changes
73
+ const childMappingRef = _react.useRef(childMapping);
74
+ // Update childMapping ref whenever it changes
75
+ _react.useEffect(()=>{
76
+ childMappingRef.current = childMapping;
77
+ }, [
78
+ childMapping
79
+ ]);
80
+ // Use ref for reversed to avoid re-running animation when it changes
81
+ const reversedRef = _react.useRef(reversed);
82
+ // Update reversed ref whenever it changes
83
+ _react.useEffect(()=>{
84
+ reversedRef.current = reversed;
85
+ }, [
86
+ reversed
87
+ ]);
88
+ // ====== ANIMATION EFFECT ======
89
+ _react.useEffect(()=>{
90
+ let cancelled = false;
91
+ startTimeRef.current = null;
92
+ finishedRef.current = false;
93
+ // All hide modes skip animation on first render - items are already in their final state
94
+ if (isFirstRender.current) {
95
+ isFirstRender.current = false;
96
+ // Items are already in their final state from useState, no animation needed
97
+ handleMotionFinish();
98
+ return; // No cleanup needed for first render
99
+ }
100
+ // For animations after first render, start from the opposite of the final state
101
+ // - Enter animation: start hidden (false), animate to visible (true)
102
+ // - Exit animation: start visible (true), animate to hidden (false)
103
+ const startState = direction === 'exit';
104
+ // Use childMappingRef.current to avoid adding childMapping to dependencies
105
+ const initialVisibility = {};
106
+ Object.keys(childMappingRef.current).forEach((key)=>{
107
+ initialVisibility[key] = startState;
108
+ });
109
+ setItemsVisibility(initialVisibility);
110
+ // Animation loop: update visibility on each frame until complete
111
+ const tick = (now)=>{
112
+ if (cancelled) {
113
+ return;
114
+ }
115
+ if (startTimeRef.current === null) {
116
+ startTimeRef.current = now;
117
+ }
118
+ const elapsed = now - startTimeRef.current;
119
+ const childKeys = Object.keys(childMappingRef.current);
120
+ const itemCount = childKeys.length;
121
+ const result = (0, _utils.staggerItemsVisibilityAtTime)({
122
+ itemCount,
123
+ elapsed,
124
+ itemDelay,
125
+ itemDuration,
126
+ direction,
127
+ reversed: reversedRef.current
128
+ });
129
+ // Convert boolean array to keyed object
130
+ const nextVisibility = {};
131
+ childKeys.forEach((key, idx)=>{
132
+ nextVisibility[key] = result.itemsVisibility[idx];
133
+ });
134
+ setItemsVisibility(nextVisibility);
135
+ if (elapsed < result.totalDuration) {
136
+ frameRef.current = requestAnimationFrame(tick);
137
+ } else if (!finishedRef.current) {
138
+ finishedRef.current = true;
139
+ handleMotionFinish();
140
+ }
141
+ };
142
+ frameRef.current = requestAnimationFrame(tick);
143
+ return ()=>{
144
+ cancelled = true;
145
+ if (frameRef.current) {
146
+ cancelAnimationFrame();
147
+ }
148
+ };
149
+ }, [
150
+ animationKey,
151
+ itemDelay,
152
+ itemDuration,
153
+ direction,
154
+ requestAnimationFrame,
155
+ cancelAnimationFrame,
156
+ handleMotionFinish
157
+ ]);
158
+ return {
159
+ itemsVisibility
160
+ };
161
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/choreography/Stagger/useStaggerItemsVisibility.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useAnimationFrame, useEventCallback } from '@fluentui/react-utilities';\nimport type { StaggerProps } from './stagger-types';\nimport {\n staggerItemsVisibilityAtTime,\n type StaggerItemsVisibilityAtTimeParams,\n DEFAULT_ITEM_DURATION,\n type StaggerChildMapping,\n} from './utils';\n\nexport interface UseStaggerItemsVisibilityParams\n extends Pick<StaggerProps, 'onMotionFinish'>,\n Omit<StaggerItemsVisibilityAtTimeParams, 'elapsed' | 'itemCount'> {\n hideMode: StaggerProps['hideMode'];\n childMapping: StaggerChildMapping;\n}\n\n/**\n * Hook that tracks the visibility of a staggered sequence of items as time progresses.\n *\n * Behavior summary for all hide modes:\n * - On the first render, items are placed in their final state (enter => visible, exit => hidden)\n * and no animation runs.\n * - On subsequent renders when direction changes, items animate from the opposite state\n * to the final state over the stagger timeline.\n * - Changes to the `reversed` prop do not trigger re-animation; they only affect the order\n * during the next direction change animation.\n *\n * This hook uses child key mapping instead of item count to track individual items.\n * This allows it to correctly handle:\n * - Items being added and removed simultaneously (when count stays the same)\n * - Items being reordered\n * - Individual item identity across renders\n *\n * @param childMapping - Mapping of child keys to elements and indices\n * @param itemDelay - Milliseconds between the start of each item's animation\n * @param itemDuration - Milliseconds each item's animation lasts\n * @param direction - 'enter' (show items) or 'exit' (hide items)\n * @param reversed - Whether to reverse the stagger order (last item first)\n * @param onMotionFinish - Callback fired when the full stagger sequence completes\n * @param hideMode - How children's visibility is managed: 'visibleProp', 'visibilityStyle', or 'unmount'\n *\n * @returns An object with `itemsVisibility: Record<string, boolean>` indicating which items are currently visible by key\n */\nexport function useStaggerItemsVisibility({\n childMapping,\n itemDelay,\n itemDuration = DEFAULT_ITEM_DURATION,\n direction,\n reversed = false,\n onMotionFinish,\n hideMode = 'visibleProp',\n}: UseStaggerItemsVisibilityParams): { itemsVisibility: Record<string, boolean> } {\n const [requestAnimationFrame, cancelAnimationFrame] = useAnimationFrame();\n\n // Stabilize the callback reference to avoid re-triggering effects on every render\n const handleMotionFinish = useEventCallback(\n onMotionFinish ??\n (() => {\n return;\n }),\n );\n\n // Track animation state independently of child changes\n const [animationKey, setAnimationKey] = React.useState(0);\n const prevDirection = React.useRef(direction);\n\n // Only trigger new animation when direction actually changes, not when children change\n React.useEffect(() => {\n if (prevDirection.current !== direction) {\n setAnimationKey(prev => prev + 1);\n prevDirection.current = direction;\n }\n }, [direction]);\n\n // State: visibility mapping for all items by key\n const [itemsVisibility, setItemsVisibility] = React.useState<Record<string, boolean>>(() => {\n const initial: Record<string, boolean> = {};\n // All hide modes start in final state: visible for 'enter', hidden for 'exit'\n const initialState = direction === 'enter';\n Object.keys(childMapping).forEach(key => {\n initial[key] = initialState;\n });\n return initial;\n });\n\n // Update visibility mapping when childMapping changes\n React.useEffect(() => {\n setItemsVisibility(prev => {\n const next: Record<string, boolean> = {};\n const targetState = direction === 'enter';\n\n // Add or update items from new mapping\n Object.keys(childMapping).forEach(key => {\n if (key in prev) {\n // Existing item - preserve its visibility state\n next[key] = prev[key];\n } else {\n // New item - set to target state\n next[key] = targetState;\n }\n });\n\n // Note: Items that were in prev but not in childMapping are automatically removed\n // because we only iterate over keys in childMapping\n\n return next;\n });\n }, [childMapping, direction]);\n\n // Refs: animation timing and control\n const startTimeRef = React.useRef<number | null>(null);\n const frameRef = React.useRef<number | null>(null);\n const finishedRef = React.useRef(false);\n const isFirstRender = React.useRef(true);\n\n // Use ref to avoid re-running the animation when child mapping changes\n const childMappingRef = React.useRef(childMapping);\n\n // Update childMapping ref whenever it changes\n React.useEffect(() => {\n childMappingRef.current = childMapping;\n }, [childMapping]);\n\n // Use ref for reversed to avoid re-running animation when it changes\n const reversedRef = React.useRef(reversed);\n\n // Update reversed ref whenever it changes\n React.useEffect(() => {\n reversedRef.current = reversed;\n }, [reversed]);\n\n // ====== ANIMATION EFFECT ======\n\n React.useEffect(() => {\n let cancelled = false;\n startTimeRef.current = null;\n finishedRef.current = false;\n\n // All hide modes skip animation on first render - items are already in their final state\n if (isFirstRender.current) {\n isFirstRender.current = false;\n // Items are already in their final state from useState, no animation needed\n handleMotionFinish();\n return; // No cleanup needed for first render\n }\n\n // For animations after first render, start from the opposite of the final state\n // - Enter animation: start hidden (false), animate to visible (true)\n // - Exit animation: start visible (true), animate to hidden (false)\n const startState = direction === 'exit';\n // Use childMappingRef.current to avoid adding childMapping to dependencies\n const initialVisibility: Record<string, boolean> = {};\n Object.keys(childMappingRef.current).forEach(key => {\n initialVisibility[key] = startState;\n });\n setItemsVisibility(initialVisibility);\n\n // Animation loop: update visibility on each frame until complete\n const tick = (now: number) => {\n if (cancelled) {\n return;\n }\n if (startTimeRef.current === null) {\n startTimeRef.current = now;\n }\n const elapsed = now - (startTimeRef.current as number);\n\n const childKeys = Object.keys(childMappingRef.current);\n const itemCount = childKeys.length;\n\n const result = staggerItemsVisibilityAtTime({\n itemCount,\n elapsed,\n itemDelay,\n itemDuration,\n direction,\n reversed: reversedRef.current,\n });\n\n // Convert boolean array to keyed object\n const nextVisibility: Record<string, boolean> = {};\n childKeys.forEach((key, idx) => {\n nextVisibility[key] = result.itemsVisibility[idx];\n });\n\n setItemsVisibility(nextVisibility);\n\n if (elapsed < result.totalDuration) {\n frameRef.current = requestAnimationFrame(tick);\n } else if (!finishedRef.current) {\n finishedRef.current = true;\n handleMotionFinish();\n }\n };\n\n frameRef.current = requestAnimationFrame(tick);\n return () => {\n cancelled = true;\n if (frameRef.current) {\n cancelAnimationFrame();\n }\n };\n }, [\n animationKey,\n itemDelay,\n itemDuration,\n direction,\n requestAnimationFrame,\n cancelAnimationFrame,\n handleMotionFinish,\n ]);\n\n return { itemsVisibility };\n}\n"],"names":["useStaggerItemsVisibility","childMapping","itemDelay","itemDuration","DEFAULT_ITEM_DURATION","direction","reversed","onMotionFinish","hideMode","requestAnimationFrame","cancelAnimationFrame","useAnimationFrame","handleMotionFinish","useEventCallback","animationKey","setAnimationKey","React","useState","prevDirection","useRef","useEffect","current","prev","itemsVisibility","setItemsVisibility","initial","initialState","Object","keys","forEach","key","next","targetState","startTimeRef","frameRef","finishedRef","isFirstRender","childMappingRef","reversedRef","cancelled","startState","initialVisibility","tick","now","elapsed","childKeys","itemCount","length","result","staggerItemsVisibilityAtTime","nextVisibility","idx","totalDuration"],"mappings":"AAAA;;;;;+BA8CgBA;;;eAAAA;;;;iEA5CO;gCAC6B;uBAO7C;AAoCA,SAASA,0BAA0B,EACxCC,YAAY,EACZC,SAAS,EACTC,eAAeC,4BAAqB,EACpCC,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AMyB,YAAYD,UAAUE,MAAM;YAElC,MAAMC,SAASC,IAAAA,mCAA4B,EAAC;gBAC1CH;gBACAF;gBACA1C;gBACAC;gBACAE;gBACAC,UAAUgC,YAAYjB,OAAO;YAC/B;YAEA,wCAAwC;YACxC,MAAM6B,iBAA0C,CAAC;YACjDL,UAAUhB,OAAO,CAAC,CAACC,KAAKqB;gBACtBD,cAAc,CAACpB,IAAI,GAAGkB,OAAOzB,eAAe,CAAC4B,IAAI;YACnD;YAEA3B,mBAAmB0B;YAEnB,IAAIN,UAAUI,OAAOI,aAAa,EAAE;gBAClClB,SAASb,OAAO,GAAGZ,sBAAsBiC;YAC3C,OAAO,IAAI,CAACP,YAAYd,OAAO,EAAE;gBAC/Bc,YAAYd,OAAO,GAAG;gBACtBT;YACF;QACF;QAEAsB,SAASb,OAAO,GAAGZ,sBAAsBiC;QACzC,OAAO;YACLH,YAAY;YACZ,IAAIL,SAASb,OAAO,EAAE;gBACpBX;YACF;QACF;IACF,GAAG;QACDI;QACAZ;QACAC;QACAE;QACAI;QACAC;QACAE;KACD;IAED,OAAO;QAAEW;IAAgB;AAC3B"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Default timing constants for stagger animations (milliseconds).
3
+ */ "use strict";
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ function _export(target, all) {
8
+ for(var name in all)Object.defineProperty(target, name, {
9
+ enumerable: true,
10
+ get: all[name]
11
+ });
12
+ }
13
+ _export(exports, {
14
+ DEFAULT_ITEM_DELAY: function() {
15
+ return DEFAULT_ITEM_DELAY;
16
+ },
17
+ DEFAULT_ITEM_DURATION: function() {
18
+ return DEFAULT_ITEM_DURATION;
19
+ }
20
+ });
21
+ const _reactmotion = require("@fluentui/react-motion");
22
+ const DEFAULT_ITEM_DELAY = _reactmotion.motionTokens.durationFaster;
23
+ const DEFAULT_ITEM_DURATION = _reactmotion.motionTokens.durationNormal;
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/choreography/Stagger/utils/constants.ts"],"sourcesContent":["/**\n * Default timing constants for stagger animations (milliseconds).\n */\n\nimport { motionTokens } from '@fluentui/react-motion';\n\n/** Default delay in milliseconds between each item's animation start */\nexport const DEFAULT_ITEM_DELAY = motionTokens.durationFaster;\n\n/** Default duration in milliseconds for each item's animation */\nexport const DEFAULT_ITEM_DURATION = motionTokens.durationNormal;\n"],"names":["DEFAULT_ITEM_DELAY","DEFAULT_ITEM_DURATION","motionTokens","durationFaster","durationNormal"],"mappings":"AAAA;;CAEC;;;;;;;;;;;IAKYA,kBAAkB;eAAlBA;;IAGAC,qBAAqB;eAArBA;;;6BANgB;AAGtB,MAAMD,qBAAqBE,yBAAY,CAACC,cAAc;AAGtD,MAAMF,wBAAwBC,yBAAY,CAACE,cAAc"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "getStaggerChildMapping", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return getStaggerChildMapping;
9
+ }
10
+ });
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
13
+ function getStaggerChildMapping(children) {
14
+ const childMapping = {};
15
+ if (children) {
16
+ _react.Children.toArray(children).forEach((child, index)=>{
17
+ if (_react.isValidElement(child)) {
18
+ var _child_key;
19
+ childMapping[(_child_key = child.key) !== null && _child_key !== void 0 ? _child_key : ''] = {
20
+ element: child,
21
+ index
22
+ };
23
+ }
24
+ });
25
+ }
26
+ return childMapping;
27
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/choreography/Stagger/utils/getStaggerChildMapping.ts"],"sourcesContent":["import * as React from 'react';\n\nexport type StaggerChildMapping = Record<string, { element: React.ReactElement; index: number }>;\n\n/**\n * Given `children`, return an object mapping key to child element and its index.\n * This allows tracking individual items by identity (via React keys) rather than by position.\n *\n * Uses React.Children.toArray() which:\n * - Automatically provides stable indices (0, 1, 2, ...)\n * - Handles key normalization (e.g., 'a' → '.$a') consistently\n * - Flattens fragments automatically\n * - Generates keys for elements without explicit keys (e.g., '.0', '.1', '.2')\n *\n * @param children - React children to map\n * @returns Object mapping child keys to { element, index }\n */\n// TODO: consider unifying with getChildMapping from react-motion package by making it generic\nexport function getStaggerChildMapping(children: React.ReactNode | undefined): StaggerChildMapping {\n const childMapping: StaggerChildMapping = {};\n\n if (children) {\n React.Children.toArray(children).forEach((child, index) => {\n if (React.isValidElement(child)) {\n childMapping[child.key ?? ''] = {\n element: child,\n index,\n };\n }\n });\n }\n\n return childMapping;\n}\n"],"names":["getStaggerChildMapping","children","childMapping","React","Children","toArray","forEach","child","index","isValidElement","key","element"],"mappings":";;;;+BAkBgBA;;;eAAAA;;;;iEAlBO;AAkBhB,SAASA,uBAAuBC,QAAqC;IAC1E,MAAMC,eAAoC,CAAC;IAE3C,IAAID,UAAU;QACZE,OAAMC,QAAQ,CAACC,OAAO,CAACJ,UAAUK,OAAO,CAAC,CAACC,OAAOC;YAC/C,IAAIL,OAAMM,cAAc,CAACF,QAAQ;oBAClBA;gBAAbL,YAAY,CAACK,CAAAA,aAAAA,MAAMG,GAAG,cAATH,wBAAAA,aAAa,GAAG,GAAG;oBAC9BI,SAASJ;oBACTC;gBACF;YACF;QACF;IACF;IAEA,OAAON;AACT"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ DEFAULT_ITEM_DELAY: function() {
13
+ return _constants.DEFAULT_ITEM_DELAY;
14
+ },
15
+ DEFAULT_ITEM_DURATION: function() {
16
+ return _constants.DEFAULT_ITEM_DURATION;
17
+ },
18
+ acceptsDelayProps: function() {
19
+ return _motionComponentDetection.acceptsDelayProps;
20
+ },
21
+ acceptsVisibleProp: function() {
22
+ return _motionComponentDetection.acceptsVisibleProp;
23
+ },
24
+ getStaggerChildMapping: function() {
25
+ return _getStaggerChildMapping.getStaggerChildMapping;
26
+ },
27
+ getStaggerTotalDuration: function() {
28
+ return _staggercalculations.getStaggerTotalDuration;
29
+ },
30
+ staggerItemsVisibilityAtTime: function() {
31
+ return _staggercalculations.staggerItemsVisibilityAtTime;
32
+ }
33
+ });
34
+ const _constants = require("./constants");
35
+ const _staggercalculations = require("./stagger-calculations");
36
+ const _motionComponentDetection = require("./motionComponentDetection");
37
+ const _getStaggerChildMapping = require("./getStaggerChildMapping");
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/choreography/Stagger/utils/index.ts"],"sourcesContent":["export { DEFAULT_ITEM_DELAY, DEFAULT_ITEM_DURATION } from './constants';\nexport { getStaggerTotalDuration, staggerItemsVisibilityAtTime } from './stagger-calculations';\nexport type { StaggerItemsVisibilityAtTimeParams } from './stagger-calculations';\nexport { acceptsVisibleProp, acceptsDelayProps } from './motionComponentDetection';\nexport { getStaggerChildMapping } from './getStaggerChildMapping';\nexport type { StaggerChildMapping } from './getStaggerChildMapping';\n"],"names":["DEFAULT_ITEM_DELAY","DEFAULT_ITEM_DURATION","acceptsDelayProps","acceptsVisibleProp","getStaggerChildMapping","getStaggerTotalDuration","staggerItemsVisibilityAtTime"],"mappings":";;;;;;;;;;;IAASA,kBAAkB;eAAlBA,6BAAkB;;IAAEC,qBAAqB;eAArBA,gCAAqB;;IAGrBC,iBAAiB;eAAjBA,2CAAiB;;IAArCC,kBAAkB;eAAlBA,4CAAkB;;IAClBC,sBAAsB;eAAtBA,8CAAsB;;IAHtBC,uBAAuB;eAAvBA,4CAAuB;;IAAEC,4BAA4B;eAA5BA,iDAA4B;;;2BADJ;qCACY;0CAEhB;wCACf"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ acceptsDelayProps: function() {
13
+ return acceptsDelayProps;
14
+ },
15
+ acceptsVisibleProp: function() {
16
+ return acceptsVisibleProp;
17
+ },
18
+ isMotionComponent: function() {
19
+ return isMotionComponent;
20
+ },
21
+ isPresenceComponent: function() {
22
+ return isPresenceComponent;
23
+ }
24
+ });
25
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
26
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
27
+ function isMotionComponent(element) {
28
+ if (!(element === null || element === void 0 ? void 0 : element.type) || typeof element.type !== 'function') {
29
+ return false;
30
+ }
31
+ // Check if the component has the MOTION_DEFINITION symbol (internal to createMotionComponent)
32
+ const symbols = Object.getOwnPropertySymbols(element.type);
33
+ return symbols.some((sym)=>sym.description === 'MOTION_DEFINITION');
34
+ }
35
+ function isPresenceComponent(element) {
36
+ if (!(element === null || element === void 0 ? void 0 : element.type) || typeof element.type !== 'function') {
37
+ return false;
38
+ }
39
+ // Check if the component has the PRESENCE_MOTION_DEFINITION symbol (internal to createPresenceComponent)
40
+ const symbols = Object.getOwnPropertySymbols(element.type);
41
+ return symbols.some((sym)=>sym.description === 'PRESENCE_MOTION_DEFINITION');
42
+ }
43
+ function acceptsDelayProps(element) {
44
+ return isPresenceComponent(element) || isMotionComponent(element);
45
+ }
46
+ function acceptsVisibleProp(element) {
47
+ return isPresenceComponent(element);
48
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/choreography/Stagger/utils/motionComponentDetection.ts"],"sourcesContent":["import * as React from 'react';\n\n/**\n * Checks if a React element has all of the specified props explicitly provided.\n *\n * @param element - React element to inspect\n * @param props - Array of prop names to verify presence on the element\n * @returns true if all props exist on element.props, false otherwise\n *\n * @internal - Exported for testing purposes\n */\n\n/**\n * Checks if a React element is a motion component created by createMotionComponent.\n * Motion components are detected by the presence of the MOTION_DEFINITION symbol on the component.\n *\n * @param element - React element to inspect\n * @returns true when the element's type contains the MOTION_DEFINITION symbol\n *\n * **Note:** This is a heuristic detection. Motion components may or may not support\n * specific props like `delay` or `visible` depending on their implementation.\n *\n * @internal - Exported for testing purposes\n */\nexport function isMotionComponent(element: React.ReactElement): boolean {\n if (!element?.type || typeof element.type !== 'function') {\n return false;\n }\n\n // Check if the component has the MOTION_DEFINITION symbol (internal to createMotionComponent)\n const symbols = Object.getOwnPropertySymbols(element.type);\n return symbols.some(sym => sym.description === 'MOTION_DEFINITION');\n}\n\n/**\n * Checks if a React element is a presence motion component by looking for the PRESENCE_MOTION_DEFINITION symbol.\n * This symbol is added internally by createPresenceComponent and provides reliable detection.\n *\n * @param element - React element to inspect\n * @returns true when the element's type contains the PRESENCE_MOTION_DEFINITION symbol\n *\n * **Presence components** (like Fade, Scale, Slide) are guaranteed to support both `visible` and `delay` props.\n *\n * @internal - Exported for testing purposes\n */\nexport function isPresenceComponent(element: React.ReactElement): boolean {\n if (!element?.type || typeof element.type !== 'function') {\n return false;\n }\n\n // Check if the component has the PRESENCE_MOTION_DEFINITION symbol (internal to createPresenceComponent)\n const symbols = Object.getOwnPropertySymbols(element.type);\n return symbols.some(sym => sym.description === 'PRESENCE_MOTION_DEFINITION');\n}\n\n/**\n * Checks if a React element accepts both `delay` and `exitDelay` props.\n * This uses a best-effort heuristic to detect components that support both delay props.\n *\n * @param element - React element to inspect\n * @returns true when the element likely supports both delay and exitDelay props\n *\n * **Auto-detection includes:**\n * - Presence components (Fade, Scale, etc.) - guaranteed to support both delay and exitDelay\n * - Motion components (.In/.Out variants, custom motion components) - may support both delay props\n * - Elements with explicit delay and exitDelay props already set\n *\n * **When to override:** If auto-detection is incorrect, use explicit `delayMode` prop on Stagger.\n * For example, custom motion components that don't support both props should use `delayMode=\"timing\"`.\n *\n * @internal - Exported for testing purposes\n */\nexport function acceptsDelayProps(element: React.ReactElement): boolean {\n return isPresenceComponent(element) || isMotionComponent(element);\n}\n\n/**\n * Checks if a React element accepts a `visible` prop.\n * This uses a best-effort heuristic to detect components that support visible props.\n *\n * @param element - React element to inspect\n * @returns true when the element likely supports a `visible` prop\n *\n * **Auto-detection includes:**\n * - Presence components (Fade, Scale, etc.) - guaranteed to support visible\n * - Elements with explicit visible props already set\n *\n * **When to override:** If auto-detection is incorrect, use explicit `hideMode` prop on Stagger.\n * For example, custom components that don't support visible should use `hideMode=\"visibilityStyle\"` or `hideMode=\"unmount\"`.\n *\n * @internal - Exported for testing purposes\n */\nexport function acceptsVisibleProp(element: React.ReactElement): boolean {\n return isPresenceComponent(element);\n}\n"],"names":["acceptsDelayProps","acceptsVisibleProp","isMotionComponent","isPresenceComponent","element","type","symbols","Object","getOwnPropertySymbols","some","sym","description"],"mappings":";;;;;;;;;;;IAwEgBA,iBAAiB;eAAjBA;;IAoBAC,kBAAkB;eAAlBA;;IApEAC,iBAAiB;eAAjBA;;IAqBAC,mBAAmB;eAAnBA;;;;iEA7CO;AAwBhB,SAASD,kBAAkBE,OAA2B;IAC3D,IAAI,EAACA,oBAAAA,8BAAAA,QAASC,IAAI,KAAI,OAAOD,QAAQC,IAAI,KAAK,YAAY;QACxD,OAAO;IACT;IAEA,8FAA8F;IAC9F,MAAMC,UAAUC,OAAOC,qBAAqB,CAACJ,QAAQC,IAAI;IACzD,OAAOC,QAAQG,IAAI,CAACC,CAAAA,MAAOA,IAAIC,WAAW,KAAK;AACjD;AAaO,SAASR,oBAAoBC,OAA2B;IAC7D,IAAI,EAACA,oBAAAA,8BAAAA,QAASC,IAAI,KAAI,OAAOD,QAAQC,IAAI,KAAK,YAAY;QACxD,OAAO;IACT;IAEA,yGAAyG;IACzG,MAAMC,UAAUC,OAAOC,qBAAqB,CAACJ,QAAQC,IAAI;IACzD,OAAOC,QAAQG,IAAI,CAACC,CAAAA,MAAOA,IAAIC,WAAW,KAAK;AACjD;AAmBO,SAASX,kBAAkBI,OAA2B;IAC3D,OAAOD,oBAAoBC,YAAYF,kBAAkBE;AAC3D;AAkBO,SAASH,mBAAmBG,OAA2B;IAC5D,OAAOD,oBAAoBC;AAC7B"}
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ getStaggerTotalDuration: function() {
13
+ return getStaggerTotalDuration;
14
+ },
15
+ staggerItemsVisibilityAtTime: function() {
16
+ return staggerItemsVisibilityAtTime;
17
+ }
18
+ });
19
+ const _constants = require("./constants");
20
+ function getStaggerTotalDuration({ itemCount, itemDelay = _constants.DEFAULT_ITEM_DELAY, itemDuration = _constants.DEFAULT_ITEM_DURATION }) {
21
+ if (itemCount <= 0) {
22
+ return 0;
23
+ }
24
+ if (itemCount <= 1) {
25
+ return Math.max(0, itemDuration);
26
+ }
27
+ const staggerDuration = itemDelay * (itemCount - 1);
28
+ return Math.max(0, staggerDuration + itemDuration);
29
+ }
30
+ function staggerItemsVisibilityAtTime({ itemCount, elapsed, itemDelay = _constants.DEFAULT_ITEM_DELAY, itemDuration = _constants.DEFAULT_ITEM_DURATION, direction = 'enter', reversed = false }) {
31
+ // If no items, return the empty state
32
+ if (itemCount <= 0) {
33
+ return {
34
+ itemsVisibility: [],
35
+ totalDuration: 0
36
+ };
37
+ }
38
+ const totalDuration = getStaggerTotalDuration({
39
+ itemCount,
40
+ itemDelay,
41
+ itemDuration
42
+ });
43
+ // Calculate progression through the stagger sequence
44
+ let completedSteps;
45
+ if (itemDelay <= 0) {
46
+ // When itemDelay is 0 or negative, all steps complete immediately
47
+ completedSteps = itemCount;
48
+ } else {
49
+ // Both enter and exit should start their first item immediately, but handle t=0 differently
50
+ if (elapsed === 0) {
51
+ // At exactly t=0, for enter we want first item visible, for exit we want all items visible
52
+ completedSteps = direction === 'enter' ? 1 : 0;
53
+ } else {
54
+ // After t=0, both directions should progress at the same rate
55
+ const stepsFromElapsedTime = Math.floor(elapsed / itemDelay) + 1;
56
+ completedSteps = Math.min(itemCount, stepsFromElapsedTime);
57
+ }
58
+ }
59
+ const itemsVisibility = Array.from({
60
+ length: itemCount
61
+ }, (_, idx)=>{
62
+ // Calculate based on progression through the sequence (enter pattern)
63
+ const fromStart = idx < completedSteps;
64
+ const fromEnd = idx >= itemCount - completedSteps;
65
+ let itemVisible = reversed ? fromEnd : fromStart;
66
+ // For exit, invert the enter pattern
67
+ if (direction === 'exit') {
68
+ itemVisible = !itemVisible;
69
+ }
70
+ return itemVisible;
71
+ });
72
+ return {
73
+ itemsVisibility,
74
+ totalDuration
75
+ };
76
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/choreography/Stagger/utils/stagger-calculations.ts"],"sourcesContent":["import type { StaggerProps } from '../stagger-types';\nimport { DEFAULT_ITEM_DELAY, DEFAULT_ITEM_DURATION } from './constants';\n\n/**\n * Calculate the total stagger duration — from the moment the stagger begins\n * until the final item's animation completes.\n *\n * Uses the formula:\n * max(0, itemDelay * (itemCount - 1) + itemDuration)\n *\n * @param params.itemCount Total number of items to stagger\n * @param params.itemDelay Milliseconds between the start of each item (default: DEFAULT_ITEM_DELAY)\n * @param params.itemDuration Milliseconds each item's animation lasts (default: DEFAULT_ITEM_DURATION)\n * @returns Total duration in milliseconds (never negative)\n */\nexport function getStaggerTotalDuration({\n itemCount,\n itemDelay = DEFAULT_ITEM_DELAY,\n itemDuration = DEFAULT_ITEM_DURATION,\n}: {\n itemCount: number;\n} & Pick<StaggerProps, 'itemDelay' | 'itemDuration'>): number {\n if (itemCount <= 0) {\n return 0;\n }\n if (itemCount <= 1) {\n return Math.max(0, itemDuration);\n }\n const staggerDuration = itemDelay * (itemCount - 1);\n return Math.max(0, staggerDuration + itemDuration);\n}\n\nexport interface StaggerItemsVisibilityAtTimeParams\n extends Pick<StaggerProps, 'itemDelay' | 'itemDuration' | 'reversed'> {\n itemCount: number;\n elapsed: number;\n direction?: 'enter' | 'exit';\n}\n\n/**\n * Returns visibility flags plus timing metrics for a stagger sequence.\n */\nexport function staggerItemsVisibilityAtTime({\n itemCount,\n elapsed,\n itemDelay = DEFAULT_ITEM_DELAY,\n itemDuration = DEFAULT_ITEM_DURATION,\n direction = 'enter',\n reversed = false,\n}: StaggerItemsVisibilityAtTimeParams): {\n itemsVisibility: boolean[];\n totalDuration: number;\n} {\n // If no items, return the empty state\n if (itemCount <= 0) {\n return { itemsVisibility: [], totalDuration: 0 };\n }\n\n const totalDuration = getStaggerTotalDuration({ itemCount, itemDelay, itemDuration });\n\n // Calculate progression through the stagger sequence\n let completedSteps: number;\n if (itemDelay <= 0) {\n // When itemDelay is 0 or negative, all steps complete immediately\n completedSteps = itemCount;\n } else {\n // Both enter and exit should start their first item immediately, but handle t=0 differently\n if (elapsed === 0) {\n // At exactly t=0, for enter we want first item visible, for exit we want all items visible\n completedSteps = direction === 'enter' ? 1 : 0;\n } else {\n // After t=0, both directions should progress at the same rate\n const stepsFromElapsedTime = Math.floor(elapsed / itemDelay) + 1;\n completedSteps = Math.min(itemCount, stepsFromElapsedTime);\n }\n }\n\n const itemsVisibility = Array.from({ length: itemCount }, (_, idx) => {\n // Calculate based on progression through the sequence (enter pattern)\n const fromStart = idx < completedSteps;\n const fromEnd = idx >= itemCount - completedSteps;\n\n let itemVisible = reversed ? fromEnd : fromStart;\n\n // For exit, invert the enter pattern\n if (direction === 'exit') {\n itemVisible = !itemVisible;\n }\n\n return itemVisible;\n });\n\n return { itemsVisibility, totalDuration };\n}\n"],"names":["getStaggerTotalDuration","staggerItemsVisibilityAtTime","itemCount","itemDelay","DEFAULT_ITEM_DELAY","itemDuration","DEFAULT_ITEM_DURATION","Math","max","staggerDuration","elapsed","direction","reversed","itemsVisibility","totalDuration","completedSteps","stepsFromElapsedTime","floor","min","Array","from","length","_","idx","fromStart","fromEnd","itemVisible"],"mappings":";;;;;;;;;;;IAegBA,uBAAuB;eAAvBA;;IA2BAC,4BAA4B;e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IACT;IAEA,OAAO;QAAEb;QAAiBC;IAAc;AAC1C"}
@@ -53,6 +53,24 @@ _export(exports, {
53
53
  },
54
54
  SlideSnappy: function() {
55
55
  return _Slide.SlideSnappy;
56
+ },
57
+ Stagger: function() {
58
+ return _Stagger.Stagger;
59
+ },
60
+ blurAtom: function() {
61
+ return _bluratom.blurAtom;
62
+ },
63
+ fadeAtom: function() {
64
+ return _fadeatom.fadeAtom;
65
+ },
66
+ rotateAtom: function() {
67
+ return _rotateatom.rotateAtom;
68
+ },
69
+ scaleAtom: function() {
70
+ return _scaleatom.scaleAtom;
71
+ },
72
+ slideAtom: function() {
73
+ return _slideatom.slideAtom;
56
74
  }
57
75
  });
58
76
  const _Collapse = require("./components/Collapse");
@@ -61,3 +79,10 @@ const _Scale = require("./components/Scale");
61
79
  const _Slide = require("./components/Slide");
62
80
  const _Blur = require("./components/Blur");
63
81
  const _Rotate = require("./components/Rotate");
82
+ const _Stagger = require("./choreography/Stagger");
83
+ const _bluratom = require("./atoms/blur-atom");
84
+ const _fadeatom = require("./atoms/fade-atom");
85
+ const _rotateatom = require("./atoms/rotate-atom");
86
+ const _scaleatom = require("./atoms/scale-atom");
87
+ const _slideatom = require("./atoms/slide-atom");
88
+ // TODO: consider whether to export some or all collapse atoms
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {\n Collapse,\n CollapseSnappy,\n CollapseRelaxed,\n CollapseDelayed,\n type CollapseParams,\n type CollapseDurations,\n} from './components/Collapse';\nexport { Fade, FadeSnappy, FadeRelaxed, type FadeParams } from './components/Fade';\nexport { Scale, ScaleSnappy, ScaleRelaxed, type ScaleParams } from './components/Scale';\nexport { Slide, SlideSnappy, SlideRelaxed, type SlideParams } from './components/Slide';\nexport { Blur, type BlurParams } from './components/Blur';\nexport { Rotate, type RotateParams } from './components/Rotate';\n"],"names":["Blur","Collapse","CollapseDelayed","CollapseRelaxed","CollapseSnappy","Fade","FadeRelaxed","FadeSnappy","Rotate","Scale","ScaleRelaxed","ScaleSnappy","Slide","SlideRelaxed","SlideSnappy"],"mappings":";;;;;;;;;;;IAWSA,IAAI;eAAJA,UAAI;;IAVXC,QAAQ;eAARA,kBAAQ;;IAGRC,eAAe;eAAfA,yBAAe;;IADfC,eAAe;eAAfA,yBAAe;;IADfC,cAAc;eAAdA,wBAAc;;IAMPC,IAAI;eAAJA,UAAI;;IAAcC,WAAW;eAAXA,iBAAW;;IAAvBC,UAAU;eAAVA,gBAAU;;IAIhBC,MAAM;eAANA,cAAM;;IAHNC,KAAK;eAALA,YAAK;;IAAeC,YAAY;eAAZA,mBAAY;;IAAzBC,WAAW;eAAXA,kBAAW;;IAClBC,KAAK;eAALA,YAAK;;IAAeC,YAAY;eAAZA,mBAAY;;IAAzBC,WAAW;eAAXA,kBAAW;;;0BAHpB;sBACwD;uBACI;uBACA;sBAC7B;wBACI"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {\n Collapse,\n CollapseSnappy,\n CollapseRelaxed,\n CollapseDelayed,\n type CollapseParams,\n type CollapseDurations,\n} from './components/Collapse';\nexport { Fade, FadeSnappy, FadeRelaxed, type FadeParams } from './components/Fade';\nexport { Scale, ScaleSnappy, ScaleRelaxed, type ScaleParams } from './components/Scale';\nexport { Slide, SlideSnappy, SlideRelaxed, type SlideParams } from './components/Slide';\nexport { Blur, type BlurParams } from './components/Blur';\nexport { Rotate, type RotateParams } from './components/Rotate';\nexport { Stagger, type StaggerProps } from './choreography/Stagger';\n\n// Motion Atoms\nexport { blurAtom } from './atoms/blur-atom';\nexport { fadeAtom } from './atoms/fade-atom';\nexport { rotateAtom } from './atoms/rotate-atom';\nexport { scaleAtom } from './atoms/scale-atom';\nexport { slideAtom } from './atoms/slide-atom';\n// TODO: consider whether to export some or all collapse atoms\n"],"names":["Blur","Collapse","CollapseDelayed","CollapseRelaxed","CollapseSnappy","Fade","FadeRelaxed","FadeSnappy","Rotate","Scale","ScaleRelaxed","ScaleSnappy","Slide","SlideRelaxed","SlideSnappy","Stagger","blurAtom","fadeAtom","rotateAtom","scaleAtom","slideAtom"],"mappings":";;;;;;;;;;;IAWSA,IAAI;eAAJA,UAAI;;IAVXC,QAAQ;eAARA,kBAAQ;;IAGRC,eAAe;eAAfA,yBAAe;;IADfC,eAAe;eAAfA,yBAAe;;IADfC,cAAc;eAAdA,wBAAc;;IAMPC,IAAI;eAAJA,UAAI;;IAAcC,WAAW;eAAXA,iBAAW;;IAAvBC,UAAU;eAAVA,gBAAU;;IAIhBC,MAAM;eAANA,cAAM;;IAHNC,KAAK;eAALA,YAAK;;IAAeC,YAAY;eAAZA,mBAAY;;IAAzBC,WAAW;eAAXA,kBAAW;;IAClBC,KAAK;eAALA,YAAK;;IAAeC,YAAY;eAAZA,mBAAY;;IAAzBC,WAAW;eAAXA,kBAAW;;IAGlBC,OAAO;eAAPA,gBAAO;;IAGPC,QAAQ;eAARA,kBAAQ;;IACRC,QAAQ;eAARA,kBAAQ;;IACRC,UAAU;eAAVA,sBAAU;;IACVC,SAAS;eAATA,oBAAS;;IACTC,SAAS;eAATA,oBAAS;;;0BAbX;sBACwD;uBACI;uBACA;sBAC7B;wBACI;yBACC;0BAGlB;0BACA;4BACE;2BACD;2BACA;CAC1B,8DAA8D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-motion-components-preview",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
4
  "description": "A preview package for Fluent UI motion components, providing a collection of components",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -25,6 +25,7 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@fluentui/react-motion": "*",
28
+ "@fluentui/react-utilities": "*",
28
29
  "@swc/helpers": "^0.5.1"
29
30
  },
30
31
  "peerDependencies": {