@fluentui/react-motion-components-preview 0.13.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.
- package/CHANGELOG.md +11 -2
- package/dist/index.d.ts +117 -0
- package/lib/choreography/Stagger/Stagger.js +189 -0
- package/lib/choreography/Stagger/Stagger.js.map +1 -0
- package/lib/choreography/Stagger/index.js +1 -0
- package/lib/choreography/Stagger/index.js.map +1 -0
- package/lib/choreography/Stagger/stagger-types.js +1 -0
- package/lib/choreography/Stagger/stagger-types.js.map +1 -0
- package/lib/choreography/Stagger/useStaggerItemsVisibility.js +176 -0
- package/lib/choreography/Stagger/useStaggerItemsVisibility.js.map +1 -0
- package/lib/choreography/Stagger/utils/constants.js +5 -0
- package/lib/choreography/Stagger/utils/constants.js.map +1 -0
- package/lib/choreography/Stagger/utils/getStaggerChildMapping.js +29 -0
- package/lib/choreography/Stagger/utils/getStaggerChildMapping.js.map +1 -0
- package/lib/choreography/Stagger/utils/index.js +4 -0
- package/lib/choreography/Stagger/utils/index.js.map +1 -0
- package/lib/choreography/Stagger/utils/motionComponentDetection.js +83 -0
- package/lib/choreography/Stagger/utils/motionComponentDetection.js.map +1 -0
- package/lib/choreography/Stagger/utils/stagger-calculations.js +71 -0
- package/lib/choreography/Stagger/utils/stagger-calculations.js.map +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib-commonjs/choreography/Stagger/Stagger.js +137 -0
- package/lib-commonjs/choreography/Stagger/Stagger.js.map +1 -0
- package/lib-commonjs/choreography/Stagger/index.js +11 -0
- package/lib-commonjs/choreography/Stagger/index.js.map +1 -0
- package/lib-commonjs/choreography/Stagger/stagger-types.js +6 -0
- package/lib-commonjs/choreography/Stagger/stagger-types.js.map +1 -0
- package/lib-commonjs/choreography/Stagger/useStaggerItemsVisibility.js +161 -0
- package/lib-commonjs/choreography/Stagger/useStaggerItemsVisibility.js.map +1 -0
- package/lib-commonjs/choreography/Stagger/utils/constants.js +23 -0
- package/lib-commonjs/choreography/Stagger/utils/constants.js.map +1 -0
- package/lib-commonjs/choreography/Stagger/utils/getStaggerChildMapping.js +27 -0
- package/lib-commonjs/choreography/Stagger/utils/getStaggerChildMapping.js.map +1 -0
- package/lib-commonjs/choreography/Stagger/utils/index.js +37 -0
- package/lib-commonjs/choreography/Stagger/utils/index.js.map +1 -0
- package/lib-commonjs/choreography/Stagger/utils/motionComponentDetection.js +48 -0
- package/lib-commonjs/choreography/Stagger/utils/motionComponentDetection.js.map +1 -0
- package/lib-commonjs/choreography/Stagger/utils/stagger-calculations.js +76 -0
- package/lib-commonjs/choreography/Stagger/utils/stagger-calculations.js.map +1 -0
- package/lib-commonjs/index.js +4 -0
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +2 -1
|
@@ -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;eAA5BA;;;2BAzC0C;AAcnD,SAASD,wBAAwB,EACtCE,SAAS,EACTC,YAAYC,6BAAkB,EAC9BC,eAAeC,gCAAqB,EAGc;IAClD,IAAIJ,aAAa,GAAG;QAClB,OAAO;IACT;IACA,IAAIA,aAAa,GAAG;QAClB,OAAOK,KAAKC,GAAG,CAAC,GAAGH;IACrB;IACA,MAAMI,kBAAkBN,YAAaD,CAAAA,YAAY,CAAA;IACjD,OAAOK,KAAKC,GAAG,CAAC,GAAGC,kBAAkBJ;AACvC;AAYO,SAASJ,6BAA6B,EAC3CC,SAAS,EACTQ,OAAO,EACPP,YAAYC,6BAAkB,EAC9BC,eAAeC,gCAAqB,EACpCK,YAAY,OAAO,EACnBC,WAAW,KAAK,EACmB;IAInC,sCAAsC;IACtC,IAAIV,aAAa,GAAG;QAClB,OAAO;YAAEW,iBAAiB,EAAE;YAAEC,eAAe;QAAE;IACjD;IAEA,MAAMA,gBAAgBd,wBAAwB;QAAEE;QAAWC;QAAWE;IAAa;IAEnF,qDAAqD;IACrD,IAAIU;IACJ,IAAIZ,aAAa,GAAG;QAClB,kEAAkE;QAClEY,iBAAiBb;IACnB,OAAO;QACL,4FAA4F;QAC5F,IAAIQ,YAAY,GAAG;YACjB,2FAA2F;YAC3FK,iBAAiBJ,cAAc,UAAU,IAAI;QAC/C,OAAO;YACL,8DAA8D;YAC9D,MAAMK,uBAAuBT,KAAKU,KAAK,CAACP,UAAUP,aAAa;YAC/DY,iBAAiBR,KAAKW,GAAG,CAAChB,WAAWc;QACvC;IACF;IAEA,MAAMH,kBAAkBM,MAAMC,IAAI,CAAC;QAAEC,QAAQnB;IAAU,GAAG,CAACoB,GAAGC;QAC5D,sEAAsE;QACtE,MAAMC,YAAYD,MAAMR;QACxB,MAAMU,UAAUF,OAAOrB,YAAYa;QAEnC,IAAIW,cAAcd,WAAWa,UAAUD;QAEvC,qCAAqC;QACrC,IAAIb,cAAc,QAAQ;YACxBe,cAAc,CAACA;QACjB;QAEA,OAAOA;IACT;IAEA,OAAO;QAAEb;QAAiBC;IAAc;AAC1C"}
|
package/lib-commonjs/index.js
CHANGED
|
@@ -54,6 +54,9 @@ _export(exports, {
|
|
|
54
54
|
SlideSnappy: function() {
|
|
55
55
|
return _Slide.SlideSnappy;
|
|
56
56
|
},
|
|
57
|
+
Stagger: function() {
|
|
58
|
+
return _Stagger.Stagger;
|
|
59
|
+
},
|
|
57
60
|
blurAtom: function() {
|
|
58
61
|
return _bluratom.blurAtom;
|
|
59
62
|
},
|
|
@@ -76,6 +79,7 @@ const _Scale = require("./components/Scale");
|
|
|
76
79
|
const _Slide = require("./components/Slide");
|
|
77
80
|
const _Blur = require("./components/Blur");
|
|
78
81
|
const _Rotate = require("./components/Rotate");
|
|
82
|
+
const _Stagger = require("./choreography/Stagger");
|
|
79
83
|
const _bluratom = require("./atoms/blur-atom");
|
|
80
84
|
const _fadeatom = require("./atoms/fade-atom");
|
|
81
85
|
const _rotateatom = require("./atoms/rotate-atom");
|
|
@@ -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\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","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;;
|
|
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.
|
|
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": {
|