@fluentui/react-motion 0.0.0-nightly-20240607-0405.1
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 +171 -0
- package/LICENSE +15 -0
- package/README.md +5 -0
- package/dist/index.d.ts +144 -0
- package/lib/components/PresenceGroup.js +53 -0
- package/lib/components/PresenceGroup.js.map +1 -0
- package/lib/components/PresenceGroupItemProvider.js +25 -0
- package/lib/components/PresenceGroupItemProvider.js.map +1 -0
- package/lib/contexts/PresenceGroupChildContext.js +4 -0
- package/lib/contexts/PresenceGroupChildContext.js.map +1 -0
- package/lib/factories/createMotionComponent.js +41 -0
- package/lib/factories/createMotionComponent.js.map +1 -0
- package/lib/factories/createPresenceComponent.js +86 -0
- package/lib/factories/createPresenceComponent.js.map +1 -0
- package/lib/hooks/useIsReducedMotion.js +30 -0
- package/lib/hooks/useIsReducedMotion.js.map +1 -0
- package/lib/hooks/useMotionImperativeRef.js +22 -0
- package/lib/hooks/useMotionImperativeRef.js.map +1 -0
- package/lib/hooks/useMountedState.js +26 -0
- package/lib/hooks/useMountedState.js.map +1 -0
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -0
- package/lib/motions/motionTokens.js +40 -0
- package/lib/motions/motionTokens.js.map +1 -0
- package/lib/types.js +1 -0
- package/lib/types.js.map +1 -0
- package/lib/utils/animateAtoms.js +74 -0
- package/lib/utils/animateAtoms.js.map +1 -0
- package/lib/utils/getChildElement.js +18 -0
- package/lib/utils/getChildElement.js.map +1 -0
- package/lib/utils/groups/getChildMapping.js +20 -0
- package/lib/utils/groups/getChildMapping.js.map +1 -0
- package/lib/utils/groups/getNextChildMapping.js +30 -0
- package/lib/utils/groups/getNextChildMapping.js.map +1 -0
- package/lib/utils/groups/mergeChildMappings.js +39 -0
- package/lib/utils/groups/mergeChildMappings.js.map +1 -0
- package/lib/utils/groups/types.js +1 -0
- package/lib/utils/groups/types.js.map +1 -0
- package/lib-commonjs/components/PresenceGroup.js +64 -0
- package/lib-commonjs/components/PresenceGroup.js.map +1 -0
- package/lib-commonjs/components/PresenceGroupItemProvider.js +31 -0
- package/lib-commonjs/components/PresenceGroupItemProvider.js.map +1 -0
- package/lib-commonjs/contexts/PresenceGroupChildContext.js +13 -0
- package/lib-commonjs/contexts/PresenceGroupChildContext.js.map +1 -0
- package/lib-commonjs/factories/createMotionComponent.js +48 -0
- package/lib-commonjs/factories/createMotionComponent.js.map +1 -0
- package/lib-commonjs/factories/createPresenceComponent.js +96 -0
- package/lib-commonjs/factories/createPresenceComponent.js.map +1 -0
- package/lib-commonjs/hooks/useIsReducedMotion.js +40 -0
- package/lib-commonjs/hooks/useIsReducedMotion.js.map +1 -0
- package/lib-commonjs/hooks/useMotionImperativeRef.js +33 -0
- package/lib-commonjs/hooks/useMotionImperativeRef.js.map +1 -0
- package/lib-commonjs/hooks/useMountedState.js +34 -0
- package/lib-commonjs/hooks/useMountedState.js.map +1 -0
- package/lib-commonjs/index.js +34 -0
- package/lib-commonjs/index.js.map +1 -0
- package/lib-commonjs/motions/motionTokens.js +58 -0
- package/lib-commonjs/motions/motionTokens.js.map +1 -0
- package/lib-commonjs/types.js +4 -0
- package/lib-commonjs/types.js.map +1 -0
- package/lib-commonjs/utils/animateAtoms.js +84 -0
- package/lib-commonjs/utils/animateAtoms.js.map +1 -0
- package/lib-commonjs/utils/getChildElement.js +29 -0
- package/lib-commonjs/utils/getChildElement.js.map +1 -0
- package/lib-commonjs/utils/groups/getChildMapping.js +29 -0
- package/lib-commonjs/utils/groups/getChildMapping.js.map +1 -0
- package/lib-commonjs/utils/groups/getNextChildMapping.js +40 -0
- package/lib-commonjs/utils/groups/getNextChildMapping.js.map +1 -0
- package/lib-commonjs/utils/groups/mergeChildMappings.js +49 -0
- package/lib-commonjs/utils/groups/mergeChildMappings.js.map +1 -0
- package/lib-commonjs/utils/groups/types.js +6 -0
- package/lib-commonjs/utils/groups/types.js.map +1 -0
- package/package.json +60 -0
@@ -0,0 +1,96 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "createPresenceComponent", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return createPresenceComponent;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
|
+
const _reactutilities = require("@fluentui/react-utilities");
|
13
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
14
|
+
const _PresenceGroupChildContext = require("../contexts/PresenceGroupChildContext");
|
15
|
+
const _useIsReducedMotion = require("../hooks/useIsReducedMotion");
|
16
|
+
const _useMotionImperativeRef = require("../hooks/useMotionImperativeRef");
|
17
|
+
const _useMountedState = require("../hooks/useMountedState");
|
18
|
+
const _animateAtoms = require("../utils/animateAtoms");
|
19
|
+
const _getChildElement = require("../utils/getChildElement");
|
20
|
+
function shouldSkipAnimation(appear, isFirstMount, visible) {
|
21
|
+
return !appear && isFirstMount && visible;
|
22
|
+
}
|
23
|
+
function createPresenceComponent(value) {
|
24
|
+
const Presence = (props)=>{
|
25
|
+
const itemContext = _react.useContext(_PresenceGroupChildContext.PresenceGroupChildContext);
|
26
|
+
const { appear, children, imperativeRef, onMotionFinish, visible, unmountOnExit } = {
|
27
|
+
...itemContext,
|
28
|
+
...props
|
29
|
+
};
|
30
|
+
const [mounted, setMounted] = (0, _useMountedState.useMountedState)(visible, unmountOnExit);
|
31
|
+
const child = (0, _getChildElement.getChildElement)(children);
|
32
|
+
const handleRef = (0, _useMotionImperativeRef.useMotionImperativeRef)(imperativeRef);
|
33
|
+
const elementRef = _react.useRef();
|
34
|
+
const ref = (0, _reactutilities.useMergedRefs)(elementRef, child.ref);
|
35
|
+
const optionsRef = _react.useRef({});
|
36
|
+
const isFirstMount = (0, _reactutilities.useFirstMount)();
|
37
|
+
const isReducedMotion = (0, _useIsReducedMotion.useIsReducedMotion)();
|
38
|
+
const onEnterFinish = (0, _reactutilities.useEventCallback)(()=>{
|
39
|
+
onMotionFinish === null || onMotionFinish === void 0 ? void 0 : onMotionFinish(null, {
|
40
|
+
direction: 'enter'
|
41
|
+
});
|
42
|
+
});
|
43
|
+
const onExitFinish = (0, _reactutilities.useEventCallback)(()=>{
|
44
|
+
onMotionFinish === null || onMotionFinish === void 0 ? void 0 : onMotionFinish(null, {
|
45
|
+
direction: 'exit'
|
46
|
+
});
|
47
|
+
if (unmountOnExit) {
|
48
|
+
setMounted(false);
|
49
|
+
itemContext === null || itemContext === void 0 ? void 0 : itemContext.onExit();
|
50
|
+
}
|
51
|
+
});
|
52
|
+
(0, _reactutilities.useIsomorphicLayoutEffect)(()=>{
|
53
|
+
optionsRef.current = {
|
54
|
+
appear
|
55
|
+
};
|
56
|
+
});
|
57
|
+
(0, _reactutilities.useIsomorphicLayoutEffect)(()=>{
|
58
|
+
const element = elementRef.current;
|
59
|
+
if (!element || shouldSkipAnimation(optionsRef.current.appear, isFirstMount, visible)) {
|
60
|
+
return;
|
61
|
+
}
|
62
|
+
const presenceMotion = typeof value === 'function' ? value({
|
63
|
+
element
|
64
|
+
}) : value;
|
65
|
+
const atoms = visible ? presenceMotion.enter : presenceMotion.exit;
|
66
|
+
const handle = (0, _animateAtoms.animateAtoms)(element, atoms, {
|
67
|
+
isReducedMotion: isReducedMotion()
|
68
|
+
});
|
69
|
+
if (!visible && isFirstMount) {
|
70
|
+
// Heads up!
|
71
|
+
// .finish() is used there to skip animation on first mount, but apply animation styles immediately
|
72
|
+
handle.finish();
|
73
|
+
return;
|
74
|
+
}
|
75
|
+
handleRef.current = handle;
|
76
|
+
handle.onfinish = visible ? onEnterFinish : onExitFinish;
|
77
|
+
return ()=>{
|
78
|
+
handle.cancel();
|
79
|
+
};
|
80
|
+
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
81
|
+
[
|
82
|
+
handleRef,
|
83
|
+
isReducedMotion,
|
84
|
+
onEnterFinish,
|
85
|
+
onExitFinish,
|
86
|
+
visible
|
87
|
+
]);
|
88
|
+
if (mounted) {
|
89
|
+
return /*#__PURE__*/ _react.cloneElement(child, {
|
90
|
+
ref
|
91
|
+
});
|
92
|
+
}
|
93
|
+
return null;
|
94
|
+
};
|
95
|
+
return Presence;
|
96
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["createPresenceComponent.js"],"sourcesContent":["import { useEventCallback, useFirstMount, useIsomorphicLayoutEffect, useMergedRefs } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport { PresenceGroupChildContext } from '../contexts/PresenceGroupChildContext';\nimport { useIsReducedMotion } from '../hooks/useIsReducedMotion';\nimport { useMotionImperativeRef } from '../hooks/useMotionImperativeRef';\nimport { useMountedState } from '../hooks/useMountedState';\nimport { animateAtoms } from '../utils/animateAtoms';\nimport { getChildElement } from '../utils/getChildElement';\nfunction shouldSkipAnimation(appear, isFirstMount, visible) {\n return !appear && isFirstMount && visible;\n}\nexport function createPresenceComponent(value) {\n const Presence = (props)=>{\n const itemContext = React.useContext(PresenceGroupChildContext);\n const { appear, children, imperativeRef, onMotionFinish, visible, unmountOnExit } = {\n ...itemContext,\n ...props\n };\n const [mounted, setMounted] = useMountedState(visible, unmountOnExit);\n const child = getChildElement(children);\n const handleRef = useMotionImperativeRef(imperativeRef);\n const elementRef = React.useRef();\n const ref = useMergedRefs(elementRef, child.ref);\n const optionsRef = React.useRef({});\n const isFirstMount = useFirstMount();\n const isReducedMotion = useIsReducedMotion();\n const onEnterFinish = useEventCallback(()=>{\n onMotionFinish === null || onMotionFinish === void 0 ? void 0 : onMotionFinish(null, {\n direction: 'enter'\n });\n });\n const onExitFinish = useEventCallback(()=>{\n onMotionFinish === null || onMotionFinish === void 0 ? void 0 : onMotionFinish(null, {\n direction: 'exit'\n });\n if (unmountOnExit) {\n setMounted(false);\n itemContext === null || itemContext === void 0 ? void 0 : itemContext.onExit();\n }\n });\n useIsomorphicLayoutEffect(()=>{\n optionsRef.current = {\n appear\n };\n });\n useIsomorphicLayoutEffect(()=>{\n const element = elementRef.current;\n if (!element || shouldSkipAnimation(optionsRef.current.appear, isFirstMount, visible)) {\n return;\n }\n const presenceMotion = typeof value === 'function' ? value({\n element\n }) : value;\n const atoms = visible ? presenceMotion.enter : presenceMotion.exit;\n const handle = animateAtoms(element, atoms, {\n isReducedMotion: isReducedMotion()\n });\n if (!visible && isFirstMount) {\n // Heads up!\n // .finish() is used there to skip animation on first mount, but apply animation styles immediately\n handle.finish();\n return;\n }\n handleRef.current = handle;\n handle.onfinish = visible ? onEnterFinish : onExitFinish;\n return ()=>{\n handle.cancel();\n };\n }, // Excluding `isFirstMount` from deps to prevent re-triggering the animation on subsequent renders\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n handleRef,\n isReducedMotion,\n onEnterFinish,\n onExitFinish,\n visible\n ]);\n if (mounted) {\n return React.cloneElement(child, {\n ref\n });\n }\n return null;\n };\n return Presence;\n}\n"],"names":["createPresenceComponent","shouldSkipAnimation","appear","isFirstMount","visible","value","Presence","props","itemContext","React","useContext","PresenceGroupChildContext","children","imperativeRef","onMotionFinish","unmountOnExit","mounted","setMounted","useMountedState","child","getChildElement","handleRef","useMotionImperativeRef","elementRef","useRef","ref","useMergedRefs","optionsRef","useFirstMount","isReducedMotion","useIsReducedMotion","onEnterFinish","useEventCallback","direction","onExitFinish","onExit","useIsomorphicLayoutEffect","current","element","presenceMotion","atoms","enter","exit","handle","animateAtoms","finish","onfinish","cancel","cloneElement"],"mappings":";;;;+BAWgBA;;;eAAAA;;;;gCAX0E;iEACnE;2CACmB;oCACP;wCACI;iCACP;8BACH;iCACG;AAChC,SAASC,oBAAoBC,MAAM,EAAEC,YAAY,EAAEC,OAAO;IACtD,OAAO,CAACF,UAAUC,gBAAgBC;AACtC;AACO,SAASJ,wBAAwBK,KAAK;IACzC,MAAMC,WAAW,CAACC;QACd,MAAMC,cAAcC,OAAMC,UAAU,CAACC,oDAAyB;QAC9D,MAAM,EAAET,MAAM,EAAEU,QAAQ,EAAEC,aAAa,EAAEC,cAAc,EAAEV,OAAO,EAAEW,aAAa,EAAE,GAAG;YAChF,GAAGP,WAAW;YACd,GAAGD,KAAK;QACZ;QACA,MAAM,CAACS,SAASC,WAAW,GAAGC,IAAAA,gCAAe,EAACd,SAASW;QACvD,MAAMI,QAAQC,IAAAA,gCAAe,EAACR;QAC9B,MAAMS,YAAYC,IAAAA,8CAAsB,EAACT;QACzC,MAAMU,aAAad,OAAMe,MAAM;QAC/B,MAAMC,MAAMC,IAAAA,6BAAa,EAACH,YAAYJ,MAAMM,GAAG;QAC/C,MAAME,aAAalB,OAAMe,MAAM,CAAC,CAAC;QACjC,MAAMrB,eAAeyB,IAAAA,6BAAa;QAClC,MAAMC,kBAAkBC,IAAAA,sCAAkB;QAC1C,MAAMC,gBAAgBC,IAAAA,gCAAgB,EAAC;YACnClB,mBAAmB,QAAQA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAe,MAAM;gBACjFmB,WAAW;YACf;QACJ;QACA,MAAMC,eAAeF,IAAAA,gCAAgB,EAAC;YAClClB,mBAAmB,QAAQA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAe,MAAM;gBACjFmB,WAAW;YACf;YACA,IAAIlB,eAAe;gBACfE,WAAW;gBACXT,gBAAgB,QAAQA,gBAAgB,KAAK,IAAI,KAAK,IAAIA,YAAY2B,MAAM;YAChF;QACJ;QACAC,IAAAA,yCAAyB,EAAC;YACtBT,WAAWU,OAAO,GAAG;gBACjBnC;YACJ;QACJ;QACAkC,IAAAA,yCAAyB,EAAC;YACtB,MAAME,UAAUf,WAAWc,OAAO;YAClC,IAAI,CAACC,WAAWrC,oBAAoB0B,WAAWU,OAAO,CAACnC,MAAM,EAAEC,cAAcC,UAAU;gBACnF;YACJ;YACA,MAAMmC,iBAAiB,OAAOlC,UAAU,aAAaA,MAAM;gBACvDiC;YACJ,KAAKjC;YACL,MAAMmC,QAAQpC,UAAUmC,eAAeE,KAAK,GAAGF,eAAeG,IAAI;YAClE,MAAMC,SAASC,IAAAA,0BAAY,EAACN,SAASE,OAAO;gBACxCX,iBAAiBA;YACrB;YACA,IAAI,CAACzB,WAAWD,cAAc;gBAC1B,YAAY;gBACZ,mGAAmG;gBACnGwC,OAAOE,MAAM;gBACb;YACJ;YACAxB,UAAUgB,OAAO,GAAGM;YACpBA,OAAOG,QAAQ,GAAG1C,UAAU2B,gBAAgBG;YAC5C,OAAO;gBACHS,OAAOI,MAAM;YACjB;QACJ,GACA,uDAAuD;QACvD;YACI1B;YACAQ;YACAE;YACAG;YACA9B;SACH;QACD,IAAIY,SAAS;YACT,qBAAOP,OAAMuC,YAAY,CAAC7B,OAAO;gBAC7BM;YACJ;QACJ;QACA,OAAO;IACX;IACA,OAAOnB;AACX"}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "useIsReducedMotion", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return useIsReducedMotion;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
13
|
+
const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
|
14
|
+
const REDUCED_MEDIA_QUERY = 'screen and (prefers-reduced-motion: reduce)';
|
15
|
+
function useIsReducedMotion() {
|
16
|
+
const { targetDocument } = (0, _reactsharedcontexts.useFluent_unstable)();
|
17
|
+
var _targetDocument_defaultView;
|
18
|
+
const targetWindow = (_targetDocument_defaultView = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView) !== null && _targetDocument_defaultView !== void 0 ? _targetDocument_defaultView : null;
|
19
|
+
const queryValue = _react.useRef(false);
|
20
|
+
const isEnabled = _react.useCallback(()=>queryValue.current, []);
|
21
|
+
_react.useEffect(()=>{
|
22
|
+
if (targetWindow === null || typeof targetWindow.matchMedia !== 'function') {
|
23
|
+
return;
|
24
|
+
}
|
25
|
+
const queryMatch = targetWindow.matchMedia(REDUCED_MEDIA_QUERY);
|
26
|
+
if (queryMatch.matches) {
|
27
|
+
queryValue.current = true;
|
28
|
+
}
|
29
|
+
const matchListener = (e)=>{
|
30
|
+
queryValue.current = e.matches;
|
31
|
+
};
|
32
|
+
queryMatch.addEventListener('change', matchListener);
|
33
|
+
return ()=>{
|
34
|
+
queryMatch.removeEventListener('change', matchListener);
|
35
|
+
};
|
36
|
+
}, [
|
37
|
+
targetWindow
|
38
|
+
]);
|
39
|
+
return isEnabled;
|
40
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["useIsReducedMotion.js"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nconst REDUCED_MEDIA_QUERY = 'screen and (prefers-reduced-motion: reduce)';\n// TODO: find a better approach there as each hook creates a separate subscription\nexport function useIsReducedMotion() {\n const { targetDocument } = useFluent();\n var _targetDocument_defaultView;\n const targetWindow = (_targetDocument_defaultView = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView) !== null && _targetDocument_defaultView !== void 0 ? _targetDocument_defaultView : null;\n const queryValue = React.useRef(false);\n const isEnabled = React.useCallback(()=>queryValue.current, []);\n React.useEffect(()=>{\n if (targetWindow === null || typeof targetWindow.matchMedia !== 'function') {\n return;\n }\n const queryMatch = targetWindow.matchMedia(REDUCED_MEDIA_QUERY);\n if (queryMatch.matches) {\n queryValue.current = true;\n }\n const matchListener = (e)=>{\n queryValue.current = e.matches;\n };\n queryMatch.addEventListener('change', matchListener);\n return ()=>{\n queryMatch.removeEventListener('change', matchListener);\n };\n }, [\n targetWindow\n ]);\n return isEnabled;\n}\n"],"names":["useIsReducedMotion","REDUCED_MEDIA_QUERY","targetDocument","useFluent","_targetDocument_defaultView","targetWindow","defaultView","queryValue","React","useRef","isEnabled","useCallback","current","useEffect","matchMedia","queryMatch","matches","matchListener","e","addEventListener","removeEventListener"],"mappings":";;;;+BAIgBA;;;eAAAA;;;;iEAJO;qCACyB;AAChD,MAAMC,sBAAsB;AAErB,SAASD;IACZ,MAAM,EAAEE,cAAc,EAAE,GAAGC,IAAAA,uCAAS;IACpC,IAAIC;IACJ,MAAMC,eAAe,AAACD,CAAAA,8BAA8BF,mBAAmB,QAAQA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeI,WAAW,AAAD,MAAO,QAAQF,gCAAgC,KAAK,IAAIA,8BAA8B;IACnO,MAAMG,aAAaC,OAAMC,MAAM,CAAC;IAChC,MAAMC,YAAYF,OAAMG,WAAW,CAAC,IAAIJ,WAAWK,OAAO,EAAE,EAAE;IAC9DJ,OAAMK,SAAS,CAAC;QACZ,IAAIR,iBAAiB,QAAQ,OAAOA,aAAaS,UAAU,KAAK,YAAY;YACxE;QACJ;QACA,MAAMC,aAAaV,aAAaS,UAAU,CAACb;QAC3C,IAAIc,WAAWC,OAAO,EAAE;YACpBT,WAAWK,OAAO,GAAG;QACzB;QACA,MAAMK,gBAAgB,CAACC;YACnBX,WAAWK,OAAO,GAAGM,EAAEF,OAAO;QAClC;QACAD,WAAWI,gBAAgB,CAAC,UAAUF;QACtC,OAAO;YACHF,WAAWK,mBAAmB,CAAC,UAAUH;QAC7C;IACJ,GAAG;QACCZ;KACH;IACD,OAAOK;AACX"}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "useMotionImperativeRef", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return useMotionImperativeRef;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
13
|
+
function useMotionImperativeRef(imperativeRef) {
|
14
|
+
const animationRef = _react.useRef();
|
15
|
+
_react.useImperativeHandle(imperativeRef, ()=>({
|
16
|
+
setPlayState: (state)=>{
|
17
|
+
if (state === 'running') {
|
18
|
+
var _animationRef_current;
|
19
|
+
(_animationRef_current = animationRef.current) === null || _animationRef_current === void 0 ? void 0 : _animationRef_current.play();
|
20
|
+
}
|
21
|
+
if (state === 'paused') {
|
22
|
+
var _animationRef_current1;
|
23
|
+
(_animationRef_current1 = animationRef.current) === null || _animationRef_current1 === void 0 ? void 0 : _animationRef_current1.pause();
|
24
|
+
}
|
25
|
+
},
|
26
|
+
setPlaybackRate: (rate)=>{
|
27
|
+
if (animationRef.current) {
|
28
|
+
animationRef.current.playbackRate = rate;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}));
|
32
|
+
return animationRef;
|
33
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["useMotionImperativeRef.js"],"sourcesContent":["import * as React from 'react';\nexport function useMotionImperativeRef(imperativeRef) {\n const animationRef = React.useRef();\n React.useImperativeHandle(imperativeRef, ()=>({\n setPlayState: (state)=>{\n if (state === 'running') {\n var _animationRef_current;\n (_animationRef_current = animationRef.current) === null || _animationRef_current === void 0 ? void 0 : _animationRef_current.play();\n }\n if (state === 'paused') {\n var _animationRef_current1;\n (_animationRef_current1 = animationRef.current) === null || _animationRef_current1 === void 0 ? void 0 : _animationRef_current1.pause();\n }\n },\n setPlaybackRate: (rate)=>{\n if (animationRef.current) {\n animationRef.current.playbackRate = rate;\n }\n }\n }));\n return animationRef;\n}\n"],"names":["useMotionImperativeRef","imperativeRef","animationRef","React","useRef","useImperativeHandle","setPlayState","state","_animationRef_current","current","play","_animationRef_current1","pause","setPlaybackRate","rate","playbackRate"],"mappings":";;;;+BACgBA;;;eAAAA;;;;iEADO;AAChB,SAASA,uBAAuBC,aAAa;IAChD,MAAMC,eAAeC,OAAMC,MAAM;IACjCD,OAAME,mBAAmB,CAACJ,eAAe,IAAK,CAAA;YACtCK,cAAc,CAACC;gBACX,IAAIA,UAAU,WAAW;oBACrB,IAAIC;oBACHA,CAAAA,wBAAwBN,aAAaO,OAAO,AAAD,MAAO,QAAQD,0BAA0B,KAAK,IAAI,KAAK,IAAIA,sBAAsBE,IAAI;gBACrI;gBACA,IAAIH,UAAU,UAAU;oBACpB,IAAII;oBACHA,CAAAA,yBAAyBT,aAAaO,OAAO,AAAD,MAAO,QAAQE,2BAA2B,KAAK,IAAI,KAAK,IAAIA,uBAAuBC,KAAK;gBACzI;YACJ;YACAC,iBAAiB,CAACC;gBACd,IAAIZ,aAAaO,OAAO,EAAE;oBACtBP,aAAaO,OAAO,CAACM,YAAY,GAAGD;gBACxC;YACJ;QACJ,CAAA;IACJ,OAAOZ;AACX"}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "useMountedState", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return useMountedState;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
|
+
const _reactutilities = require("@fluentui/react-utilities");
|
13
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
14
|
+
function useMountedState(visible = false, unmountOnExit = false) {
|
15
|
+
const mountedRef = _react.useRef(unmountOnExit ? visible : true);
|
16
|
+
const forceUpdate = (0, _reactutilities.useForceUpdate)();
|
17
|
+
const setMounted = _react.useCallback((newValue)=>{
|
18
|
+
if (mountedRef.current !== newValue) {
|
19
|
+
mountedRef.current = newValue;
|
20
|
+
forceUpdate();
|
21
|
+
}
|
22
|
+
}, [
|
23
|
+
forceUpdate
|
24
|
+
]);
|
25
|
+
_react.useEffect(()=>{
|
26
|
+
if (visible) {
|
27
|
+
mountedRef.current = visible;
|
28
|
+
}
|
29
|
+
});
|
30
|
+
return [
|
31
|
+
visible || mountedRef.current,
|
32
|
+
setMounted
|
33
|
+
];
|
34
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["useMountedState.js"],"sourcesContent":["import { useForceUpdate } from '@fluentui/react-utilities';\nimport * as React from 'react';\n/**\n * This hook manages the mounted state of a component, based on the \"visible\" and \"unmountOnExit\" props.\n * It simulates the behavior of getDerivedStateFromProps(), which is not available in functional components.\n */ export function useMountedState(visible = false, unmountOnExit = false) {\n const mountedRef = React.useRef(unmountOnExit ? visible : true);\n const forceUpdate = useForceUpdate();\n const setMounted = React.useCallback((newValue)=>{\n if (mountedRef.current !== newValue) {\n mountedRef.current = newValue;\n forceUpdate();\n }\n }, [\n forceUpdate\n ]);\n React.useEffect(()=>{\n if (visible) {\n mountedRef.current = visible;\n }\n });\n return [\n visible || mountedRef.current,\n setMounted\n ];\n}\n"],"names":["useMountedState","visible","unmountOnExit","mountedRef","React","useRef","forceUpdate","useForceUpdate","setMounted","useCallback","newValue","current","useEffect"],"mappings":";;;;+BAKoBA;;;eAAAA;;;;gCALW;iEACR;AAIZ,SAASA,gBAAgBC,UAAU,KAAK,EAAEC,gBAAgB,KAAK;IACtE,MAAMC,aAAaC,OAAMC,MAAM,CAACH,gBAAgBD,UAAU;IAC1D,MAAMK,cAAcC,IAAAA,8BAAc;IAClC,MAAMC,aAAaJ,OAAMK,WAAW,CAAC,CAACC;QAClC,IAAIP,WAAWQ,OAAO,KAAKD,UAAU;YACjCP,WAAWQ,OAAO,GAAGD;YACrBJ;QACJ;IACJ,GAAG;QACCA;KACH;IACDF,OAAMQ,SAAS,CAAC;QACZ,IAAIX,SAAS;YACTE,WAAWQ,OAAO,GAAGV;QACzB;IACJ;IACA,OAAO;QACHA,WAAWE,WAAWQ,OAAO;QAC7BH;KACH;AACL"}
|
@@ -0,0 +1,34 @@
|
|
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
|
+
motionTokens: function() {
|
13
|
+
return _motionTokens.motionTokens;
|
14
|
+
},
|
15
|
+
durations: function() {
|
16
|
+
return _motionTokens.durations;
|
17
|
+
},
|
18
|
+
curves: function() {
|
19
|
+
return _motionTokens.curves;
|
20
|
+
},
|
21
|
+
createMotionComponent: function() {
|
22
|
+
return _createMotionComponent.createMotionComponent;
|
23
|
+
},
|
24
|
+
createPresenceComponent: function() {
|
25
|
+
return _createPresenceComponent.createPresenceComponent;
|
26
|
+
},
|
27
|
+
PresenceGroup: function() {
|
28
|
+
return _PresenceGroup.PresenceGroup;
|
29
|
+
}
|
30
|
+
});
|
31
|
+
const _motionTokens = require("./motions/motionTokens");
|
32
|
+
const _createMotionComponent = require("./factories/createMotionComponent");
|
33
|
+
const _createPresenceComponent = require("./factories/createPresenceComponent");
|
34
|
+
const _PresenceGroup = require("./components/PresenceGroup");
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["index.js"],"sourcesContent":["export { motionTokens, durations, curves } from './motions/motionTokens';\nexport { createMotionComponent } from './factories/createMotionComponent';\nexport { createPresenceComponent } from './factories/createPresenceComponent';\nexport { PresenceGroup } from './components/PresenceGroup';\n"],"names":["motionTokens","durations","curves","createMotionComponent","createPresenceComponent","PresenceGroup"],"mappings":";;;;;;;;;;;IAASA,YAAY;eAAZA,0BAAY;;IAAEC,SAAS;eAATA,uBAAS;;IAAEC,MAAM;eAANA,oBAAM;;IAC/BC,qBAAqB;eAArBA,4CAAqB;;IACrBC,uBAAuB;eAAvBA,gDAAuB;;IACvBC,aAAa;eAAbA,4BAAa;;;8BAH0B;uCACV;yCACE;+BACV"}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
// Copied from packages/tokens/src/global/durations.ts
|
2
|
+
// Values are numeric in milliseconds for ease of use in Web Animations API
|
3
|
+
// (rather than parsing '__ms')
|
4
|
+
"use strict";
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
6
|
+
value: true
|
7
|
+
});
|
8
|
+
function _export(target, all) {
|
9
|
+
for(var name in all)Object.defineProperty(target, name, {
|
10
|
+
enumerable: true,
|
11
|
+
get: all[name]
|
12
|
+
});
|
13
|
+
}
|
14
|
+
_export(exports, {
|
15
|
+
durations: function() {
|
16
|
+
return durations;
|
17
|
+
},
|
18
|
+
curves: function() {
|
19
|
+
return curves;
|
20
|
+
},
|
21
|
+
motionTokens: function() {
|
22
|
+
return motionTokens;
|
23
|
+
}
|
24
|
+
});
|
25
|
+
const durations = {
|
26
|
+
durationUltraFast: 50,
|
27
|
+
durationFaster: 100,
|
28
|
+
durationFast: 150,
|
29
|
+
durationNormal: 200,
|
30
|
+
durationGentle: 250,
|
31
|
+
durationSlow: 300,
|
32
|
+
durationSlower: 400,
|
33
|
+
durationUltraSlow: 500
|
34
|
+
};
|
35
|
+
const curves = {
|
36
|
+
curveAccelerateMax: 'cubic-bezier(0.9,0.1,1,0.2)',
|
37
|
+
curveAccelerateMid: 'cubic-bezier(1,0,1,1)',
|
38
|
+
curveAccelerateMin: 'cubic-bezier(0.8,0,0.78,1)',
|
39
|
+
curveDecelerateMax: 'cubic-bezier(0.1,0.9,0.2,1)',
|
40
|
+
curveDecelerateMid: 'cubic-bezier(0,0,0,1)',
|
41
|
+
curveDecelerateMin: 'cubic-bezier(0.33,0,0.1,1)',
|
42
|
+
curveEasyEaseMax: 'cubic-bezier(0.8,0,0.2,1)',
|
43
|
+
curveEasyEase: 'cubic-bezier(0.33,0,0.67,1)',
|
44
|
+
curveLinear: 'cubic-bezier(0,0,1,1)'
|
45
|
+
};
|
46
|
+
const motionTokens = {
|
47
|
+
...durations,
|
48
|
+
...curves
|
49
|
+
}; /*
|
50
|
+
TODO: enforce naming conventions when TypeScript 4.4 features are supported in Fluent:
|
51
|
+
|
52
|
+
type DurationKey = `duration${Capitalize<string>}`;
|
53
|
+
type CurveKey = `curve${Capitalize<string>}`;
|
54
|
+
type CurveValue = `cubic-bezier(${number},${number},${number},${number})`;
|
55
|
+
|
56
|
+
type DurationTokens = Record<DurationKey, number>;
|
57
|
+
type CurveTokens = Record<CurveKey, CurveValue>;
|
58
|
+
*/
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["motionTokens.js"],"sourcesContent":["// Copied from packages/tokens/src/global/durations.ts\n// Values are numeric in milliseconds for ease of use in Web Animations API\n// (rather than parsing '__ms')\nexport const durations = {\n durationUltraFast: 50,\n durationFaster: 100,\n durationFast: 150,\n durationNormal: 200,\n durationGentle: 250,\n durationSlow: 300,\n durationSlower: 400,\n durationUltraSlow: 500\n};\n// Copied from packages/tokens/src/global/curves.ts\n// Names and values are preserved exactly\nexport const curves = {\n curveAccelerateMax: 'cubic-bezier(0.9,0.1,1,0.2)',\n curveAccelerateMid: 'cubic-bezier(1,0,1,1)',\n curveAccelerateMin: 'cubic-bezier(0.8,0,0.78,1)',\n curveDecelerateMax: 'cubic-bezier(0.1,0.9,0.2,1)',\n curveDecelerateMid: 'cubic-bezier(0,0,0,1)',\n curveDecelerateMin: 'cubic-bezier(0.33,0,0.1,1)',\n curveEasyEaseMax: 'cubic-bezier(0.8,0,0.2,1)',\n curveEasyEase: 'cubic-bezier(0.33,0,0.67,1)',\n curveLinear: 'cubic-bezier(0,0,1,1)'\n};\n// A merged flat lookup for convenience\nexport const motionTokens = {\n ...durations,\n ...curves\n}; /*\nTODO: enforce naming conventions when TypeScript 4.4 features are supported in Fluent:\n\ntype DurationKey = `duration${Capitalize<string>}`;\ntype CurveKey = `curve${Capitalize<string>}`;\ntype CurveValue = `cubic-bezier(${number},${number},${number},${number})`;\n\ntype DurationTokens = Record<DurationKey, number>;\ntype CurveTokens = Record<CurveKey, CurveValue>;\n*/ \n"],"names":["durations","curves","motionTokens","durationUltraFast","durationFaster","durationFast","durationNormal","durationGentle","durationSlow","durationSlower","durationUltraSlow","curveAccelerateMax","curveAccelerateMid","curveAccelerateMin","curveDecelerateMax","curveDecelerateMid","curveDecelerateMin","curveEasyEaseMax","curveEasyEase","curveLinear"],"mappings":"AAAA,sDAAsD;AACtD,2EAA2E;AAC3E,+BAA+B;;;;;;;;;;;;IAClBA,SAAS;eAATA;;IAYAC,MAAM;eAANA;;IAYAC,YAAY;eAAZA;;;AAxBN,MAAMF,YAAY;IACrBG,mBAAmB;IACnBC,gBAAgB;IAChBC,cAAc;IACdC,gBAAgB;IAChBC,gBAAgB;IAChBC,cAAc;IACdC,gBAAgB;IAChBC,mBAAmB;AACvB;AAGO,MAAMT,SAAS;IAClBU,oBAAoB;IACpBC,oBAAoB;IACpBC,oBAAoB;IACpBC,oBAAoB;IACpBC,oBAAoB;IACpBC,oBAAoB;IACpBC,kBAAkB;IAClBC,eAAe;IACfC,aAAa;AACjB;AAEO,MAAMjB,eAAe;IACxB,GAAGF,SAAS;IACZ,GAAGC,MAAM;AACb,GAAG;;;;;;;;;AASH"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
@@ -0,0 +1,84 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "animateAtoms", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return animateAtoms;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
function animateAtoms(element, value, options) {
|
12
|
+
// Heads up!
|
13
|
+
// Jest uses jsdom as the default environment, which doesn't support the Web Animations API. The same is true for
|
14
|
+
// older browsers that are out of browser support matrix. In these cases, the animation will be a no-op.
|
15
|
+
const SUPPORTS_WEB_ANIMATIONS = typeof element.animate === 'function';
|
16
|
+
const atoms = Array.isArray(value) ? value : [
|
17
|
+
value
|
18
|
+
];
|
19
|
+
const { isReducedMotion } = options;
|
20
|
+
const animations = SUPPORTS_WEB_ANIMATIONS ? atoms.map((motion)=>{
|
21
|
+
const { keyframes, ...params } = motion;
|
22
|
+
const animation = element.animate(keyframes, {
|
23
|
+
fill: 'forwards',
|
24
|
+
...params,
|
25
|
+
...isReducedMotion && {
|
26
|
+
duration: 1
|
27
|
+
}
|
28
|
+
});
|
29
|
+
animation.persist();
|
30
|
+
return animation;
|
31
|
+
}) : [];
|
32
|
+
return {
|
33
|
+
set playbackRate (rate){
|
34
|
+
animations.forEach((animation)=>{
|
35
|
+
animation.playbackRate = rate;
|
36
|
+
});
|
37
|
+
},
|
38
|
+
set onfinish (callback){
|
39
|
+
// Heads up!
|
40
|
+
// Jest uses jsdom as the default environment, which doesn't support the Web Animations API. This no-op is
|
41
|
+
// necessary to avoid errors in tests.
|
42
|
+
//
|
43
|
+
// See https://github.com/microsoft/fluentui/issues/31593
|
44
|
+
// See https://github.com/jsdom/jsdom/issues/3429
|
45
|
+
if (process.env.NODE_ENV === 'test') {
|
46
|
+
if (animations.length === 0) {
|
47
|
+
callback();
|
48
|
+
return;
|
49
|
+
}
|
50
|
+
}
|
51
|
+
Promise.all(animations.map((animation)=>animation.finished)).then(()=>{
|
52
|
+
callback();
|
53
|
+
}).catch((err)=>{
|
54
|
+
var _element_ownerDocument_defaultView;
|
55
|
+
const DOMException = (_element_ownerDocument_defaultView = element.ownerDocument.defaultView) === null || _element_ownerDocument_defaultView === void 0 ? void 0 : _element_ownerDocument_defaultView.DOMException;
|
56
|
+
// Ignores "DOMException: The user aborted a request" that appears if animations are cancelled
|
57
|
+
if (DOMException && err instanceof DOMException) {
|
58
|
+
return;
|
59
|
+
}
|
60
|
+
throw err;
|
61
|
+
});
|
62
|
+
},
|
63
|
+
cancel: ()=>{
|
64
|
+
animations.forEach((animation)=>{
|
65
|
+
animation.cancel();
|
66
|
+
});
|
67
|
+
},
|
68
|
+
pause: ()=>{
|
69
|
+
animations.forEach((animation)=>{
|
70
|
+
animation.pause();
|
71
|
+
});
|
72
|
+
},
|
73
|
+
play: ()=>{
|
74
|
+
animations.forEach((animation)=>{
|
75
|
+
animation.play();
|
76
|
+
});
|
77
|
+
},
|
78
|
+
finish: ()=>{
|
79
|
+
animations.forEach((animation)=>{
|
80
|
+
animation.finish();
|
81
|
+
});
|
82
|
+
}
|
83
|
+
};
|
84
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["animateAtoms.js"],"sourcesContent":["export function animateAtoms(element, value, options) {\n // Heads up!\n // Jest uses jsdom as the default environment, which doesn't support the Web Animations API. The same is true for\n // older browsers that are out of browser support matrix. In these cases, the animation will be a no-op.\n const SUPPORTS_WEB_ANIMATIONS = typeof element.animate === 'function';\n const atoms = Array.isArray(value) ? value : [\n value\n ];\n const { isReducedMotion } = options;\n const animations = SUPPORTS_WEB_ANIMATIONS ? atoms.map((motion)=>{\n const { keyframes, ...params } = motion;\n const animation = element.animate(keyframes, {\n fill: 'forwards',\n ...params,\n ...isReducedMotion && {\n duration: 1\n }\n });\n animation.persist();\n return animation;\n }) : [];\n return {\n set playbackRate (rate){\n animations.forEach((animation)=>{\n animation.playbackRate = rate;\n });\n },\n set onfinish (callback){\n // Heads up!\n // Jest uses jsdom as the default environment, which doesn't support the Web Animations API. This no-op is\n // necessary to avoid errors in tests.\n //\n // See https://github.com/microsoft/fluentui/issues/31593\n // See https://github.com/jsdom/jsdom/issues/3429\n if (process.env.NODE_ENV === 'test') {\n if (animations.length === 0) {\n callback();\n return;\n }\n }\n Promise.all(animations.map((animation)=>animation.finished)).then(()=>{\n callback();\n }).catch((err)=>{\n var _element_ownerDocument_defaultView;\n const DOMException = (_element_ownerDocument_defaultView = element.ownerDocument.defaultView) === null || _element_ownerDocument_defaultView === void 0 ? void 0 : _element_ownerDocument_defaultView.DOMException;\n // Ignores \"DOMException: The user aborted a request\" that appears if animations are cancelled\n if (DOMException && err instanceof DOMException) {\n return;\n }\n throw err;\n });\n },\n cancel: ()=>{\n animations.forEach((animation)=>{\n animation.cancel();\n });\n },\n pause: ()=>{\n animations.forEach((animation)=>{\n animation.pause();\n });\n },\n play: ()=>{\n animations.forEach((animation)=>{\n animation.play();\n });\n },\n finish: ()=>{\n animations.forEach((animation)=>{\n animation.finish();\n });\n }\n };\n}\n"],"names":["animateAtoms","element","value","options","SUPPORTS_WEB_ANIMATIONS","animate","atoms","Array","isArray","isReducedMotion","animations","map","motion","keyframes","params","animation","fill","duration","persist","playbackRate","rate","forEach","onfinish","callback","process","env","NODE_ENV","length","Promise","all","finished","then","catch","err","_element_ownerDocument_defaultView","DOMException","ownerDocument","defaultView","cancel","pause","play","finish"],"mappings":";;;;+BAAgBA;;;eAAAA;;;AAAT,SAASA,aAAaC,OAAO,EAAEC,KAAK,EAAEC,OAAO;IAChD,YAAY;IACZ,iHAAiH;IACjH,wGAAwG;IACxG,MAAMC,0BAA0B,OAAOH,QAAQI,OAAO,KAAK;IAC3D,MAAMC,QAAQC,MAAMC,OAAO,CAACN,SAASA,QAAQ;QACzCA;KACH;IACD,MAAM,EAAEO,eAAe,EAAE,GAAGN;IAC5B,MAAMO,aAAaN,0BAA0BE,MAAMK,GAAG,CAAC,CAACC;QACpD,MAAM,EAAEC,SAAS,EAAE,GAAGC,QAAQ,GAAGF;QACjC,MAAMG,YAAYd,QAAQI,OAAO,CAACQ,WAAW;YACzCG,MAAM;YACN,GAAGF,MAAM;YACT,GAAGL,mBAAmB;gBAClBQ,UAAU;YACd,CAAC;QACL;QACAF,UAAUG,OAAO;QACjB,OAAOH;IACX,KAAK,EAAE;IACP,OAAO;QACH,IAAII,cAAcC,KAAK;YACnBV,WAAWW,OAAO,CAAC,CAACN;gBAChBA,UAAUI,YAAY,GAAGC;YAC7B;QACJ;QACA,IAAIE,UAAUC,SAAS;YACnB,YAAY;YACZ,0GAA0G;YAC1G,sCAAsC;YACtC,EAAE;YACF,yDAAyD;YACzD,iDAAiD;YACjD,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,QAAQ;gBACjC,IAAIhB,WAAWiB,MAAM,KAAK,GAAG;oBACzBJ;oBACA;gBACJ;YACJ;YACAK,QAAQC,GAAG,CAACnB,WAAWC,GAAG,CAAC,CAACI,YAAYA,UAAUe,QAAQ,GAAGC,IAAI,CAAC;gBAC9DR;YACJ,GAAGS,KAAK,CAAC,CAACC;gBACN,IAAIC;gBACJ,MAAMC,eAAe,AAACD,CAAAA,qCAAqCjC,QAAQmC,aAAa,CAACC,WAAW,AAAD,MAAO,QAAQH,uCAAuC,KAAK,IAAI,KAAK,IAAIA,mCAAmCC,YAAY;gBAClN,8FAA8F;gBAC9F,IAAIA,gBAAgBF,eAAeE,cAAc;oBAC7C;gBACJ;gBACA,MAAMF;YACV;QACJ;QACAK,QAAQ;YACJ5B,WAAWW,OAAO,CAAC,CAACN;gBAChBA,UAAUuB,MAAM;YACpB;QACJ;QACAC,OAAO;YACH7B,WAAWW,OAAO,CAAC,CAACN;gBAChBA,UAAUwB,KAAK;YACnB;QACJ;QACAC,MAAM;YACF9B,WAAWW,OAAO,CAAC,CAACN;gBAChBA,UAAUyB,IAAI;YAClB;QACJ;QACAC,QAAQ;YACJ/B,WAAWW,OAAO,CAAC,CAACN;gBAChBA,UAAU0B,MAAM;YACpB;QACJ;IACJ;AACJ"}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "getChildElement", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return getChildElement;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
13
|
+
const _reactis = /*#__PURE__*/ _interop_require_wildcard._(require("react-is"));
|
14
|
+
function getChildElement(children) {
|
15
|
+
try {
|
16
|
+
const child = _react.Children.only(children);
|
17
|
+
if (typeof child.type === 'string' || _reactis.isForwardRef(child)) {
|
18
|
+
return child;
|
19
|
+
}
|
20
|
+
// We don't need to do anything here: we catch the exception from React to throw a more meaningful error
|
21
|
+
// eslint-disable-next-line no-empty
|
22
|
+
} catch {}
|
23
|
+
throw new Error([
|
24
|
+
'@fluentui/react-motion: Invalid child element.',
|
25
|
+
'\n',
|
26
|
+
'Motion factories require a single child element to be passed. ',
|
27
|
+
'That element element should support ref forwarding i.e. it should be either an intrinsic element (e.g. div) or a component that uses React.forwardRef().'
|
28
|
+
].join(''));
|
29
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["getChildElement.js"],"sourcesContent":["import * as React from 'react';\nimport * as ReactIs from 'react-is';\nexport function getChildElement(children) {\n try {\n const child = React.Children.only(children);\n if (typeof child.type === 'string' || ReactIs.isForwardRef(child)) {\n return child;\n }\n // We don't need to do anything here: we catch the exception from React to throw a more meaningful error\n // eslint-disable-next-line no-empty\n } catch {}\n throw new Error([\n '@fluentui/react-motion: Invalid child element.',\n '\\n',\n 'Motion factories require a single child element to be passed. ',\n 'That element element should support ref forwarding i.e. it should be either an intrinsic element (e.g. div) or a component that uses React.forwardRef().'\n ].join(''));\n}\n"],"names":["getChildElement","children","child","React","Children","only","type","ReactIs","isForwardRef","Error","join"],"mappings":";;;;+BAEgBA;;;eAAAA;;;;iEAFO;mEACE;AAClB,SAASA,gBAAgBC,QAAQ;IACpC,IAAI;QACA,MAAMC,QAAQC,OAAMC,QAAQ,CAACC,IAAI,CAACJ;QAClC,IAAI,OAAOC,MAAMI,IAAI,KAAK,YAAYC,SAAQC,YAAY,CAACN,QAAQ;YAC/D,OAAOA;QACX;IACJ,wGAAwG;IACxG,oCAAoC;IACpC,EAAE,OAAO,CAAC;IACV,MAAM,IAAIO,MAAM;QACZ;QACA;QACA;QACA;KACH,CAACC,IAAI,CAAC;AACX"}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "getChildMapping", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return getChildMapping;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
13
|
+
function getChildMapping(children) {
|
14
|
+
const childMapping = {};
|
15
|
+
if (children) {
|
16
|
+
_react.Children.toArray(children).forEach((child)=>{
|
17
|
+
if (/*#__PURE__*/ _react.isValidElement(child)) {
|
18
|
+
var _child_key;
|
19
|
+
childMapping[(_child_key = child.key) !== null && _child_key !== void 0 ? _child_key : ''] = {
|
20
|
+
appear: false,
|
21
|
+
element: child,
|
22
|
+
visible: true,
|
23
|
+
unmountOnExit: true
|
24
|
+
};
|
25
|
+
}
|
26
|
+
});
|
27
|
+
}
|
28
|
+
return childMapping;
|
29
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["getChildMapping.js"],"sourcesContent":["import * as React from 'react';\n/**\n * Given `children`, return an object mapping key to child.\n */ export function getChildMapping(children) {\n const childMapping = {};\n if (children) {\n React.Children.toArray(children).forEach((child)=>{\n if (React.isValidElement(child)) {\n var _child_key;\n childMapping[(_child_key = child.key) !== null && _child_key !== void 0 ? _child_key : ''] = {\n appear: false,\n element: child,\n visible: true,\n unmountOnExit: true\n };\n }\n });\n }\n return childMapping;\n}\n"],"names":["getChildMapping","children","childMapping","React","Children","toArray","forEach","child","isValidElement","_child_key","key","appear","element","visible","unmountOnExit"],"mappings":";;;;+BAGoBA;;;eAAAA;;;;iEAHG;AAGZ,SAASA,gBAAgBC,QAAQ;IACxC,MAAMC,eAAe,CAAC;IACtB,IAAID,UAAU;QACVE,OAAMC,QAAQ,CAACC,OAAO,CAACJ,UAAUK,OAAO,CAAC,CAACC;YACtC,kBAAIJ,OAAMK,cAAc,CAACD,QAAQ;gBAC7B,IAAIE;gBACJP,YAAY,CAAC,AAACO,CAAAA,aAAaF,MAAMG,GAAG,AAAD,MAAO,QAAQD,eAAe,KAAK,IAAIA,aAAa,GAAG,GAAG;oBACzFE,QAAQ;oBACRC,SAASL;oBACTM,SAAS;oBACTC,eAAe;gBACnB;YACJ;QACJ;IACJ;IACA,OAAOZ;AACX"}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "getNextChildMapping", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return getNextChildMapping;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
const _mergeChildMappings = require("./mergeChildMappings");
|
12
|
+
function getNextChildMapping(prevChildMapping, nextChildMapping) {
|
13
|
+
const childrenMapping = (0, _mergeChildMappings.mergeChildMappings)(prevChildMapping, nextChildMapping);
|
14
|
+
Object.entries(childrenMapping).forEach(([key, childDefinition])=>{
|
15
|
+
const hasPrev = key in prevChildMapping;
|
16
|
+
const hasNext = key in nextChildMapping;
|
17
|
+
if (hasNext) {
|
18
|
+
// Case 1: item hasn't changed transition states
|
19
|
+
if (hasPrev) {
|
20
|
+
childrenMapping[key] = {
|
21
|
+
...childDefinition
|
22
|
+
};
|
23
|
+
return;
|
24
|
+
}
|
25
|
+
// Case 2: item is new (entering)
|
26
|
+
childrenMapping[key] = {
|
27
|
+
...childDefinition,
|
28
|
+
appear: true,
|
29
|
+
visible: true
|
30
|
+
};
|
31
|
+
return;
|
32
|
+
}
|
33
|
+
// Case 3: item is leaving
|
34
|
+
childrenMapping[key] = {
|
35
|
+
...childDefinition,
|
36
|
+
visible: false
|
37
|
+
};
|
38
|
+
});
|
39
|
+
return childrenMapping;
|
40
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["getNextChildMapping.js"],"sourcesContent":["import { mergeChildMappings } from './mergeChildMappings';\nexport function getNextChildMapping(prevChildMapping, nextChildMapping) {\n const childrenMapping = mergeChildMappings(prevChildMapping, nextChildMapping);\n Object.entries(childrenMapping).forEach(([key, childDefinition])=>{\n const hasPrev = key in prevChildMapping;\n const hasNext = key in nextChildMapping;\n if (hasNext) {\n // Case 1: item hasn't changed transition states\n if (hasPrev) {\n childrenMapping[key] = {\n ...childDefinition\n };\n return;\n }\n // Case 2: item is new (entering)\n childrenMapping[key] = {\n ...childDefinition,\n appear: true,\n visible: true\n };\n return;\n }\n // Case 3: item is leaving\n childrenMapping[key] = {\n ...childDefinition,\n visible: false\n };\n });\n return childrenMapping;\n}\n"],"names":["getNextChildMapping","prevChildMapping","nextChildMapping","childrenMapping","mergeChildMappings","Object","entries","forEach","key","childDefinition","hasPrev","hasNext","appear","visible"],"mappings":";;;;+BACgBA;;;eAAAA;;;oCADmB;AAC5B,SAASA,oBAAoBC,gBAAgB,EAAEC,gBAAgB;IAClE,MAAMC,kBAAkBC,IAAAA,sCAAkB,EAACH,kBAAkBC;IAC7DG,OAAOC,OAAO,CAACH,iBAAiBI,OAAO,CAAC,CAAC,CAACC,KAAKC,gBAAgB;QAC3D,MAAMC,UAAUF,OAAOP;QACvB,MAAMU,UAAUH,OAAON;QACvB,IAAIS,SAAS;YACT,gDAAgD;YAChD,IAAID,SAAS;gBACTP,eAAe,CAACK,IAAI,GAAG;oBACnB,GAAGC,eAAe;gBACtB;gBACA;YACJ;YACA,iCAAiC;YACjCN,eAAe,CAACK,IAAI,GAAG;gBACnB,GAAGC,eAAe;gBAClBG,QAAQ;gBACRC,SAAS;YACb;YACA;QACJ;QACA,0BAA0B;QAC1BV,eAAe,CAACK,IAAI,GAAG;YACnB,GAAGC,eAAe;YAClBI,SAAS;QACb;IACJ;IACA,OAAOV;AACX"}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
/**
|
2
|
+
* When you're adding or removing children some may be added or removed in the same render pass. We want to show *both*
|
3
|
+
* since we want to simultaneously animate elements in and out. This function takes a previous set of keys and a new set
|
4
|
+
* of keys and merges them with its best guess of the correct ordering.
|
5
|
+
*/ "use strict";
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
7
|
+
value: true
|
8
|
+
});
|
9
|
+
Object.defineProperty(exports, "mergeChildMappings", {
|
10
|
+
enumerable: true,
|
11
|
+
get: function() {
|
12
|
+
return mergeChildMappings;
|
13
|
+
}
|
14
|
+
});
|
15
|
+
function mergeChildMappings(prevMapping, nextMapping) {
|
16
|
+
function getValueForKey(key) {
|
17
|
+
return key in nextMapping ? nextMapping[key] : prevMapping[key];
|
18
|
+
}
|
19
|
+
// For each key of `next`, the list of keys to insert before that key in
|
20
|
+
// the combined list
|
21
|
+
const nextKeysPending = {};
|
22
|
+
let pendingKeys = [];
|
23
|
+
// eslint-disable-next-line guard-for-in
|
24
|
+
for(const prevKey in prevMapping){
|
25
|
+
if (prevKey in nextMapping) {
|
26
|
+
if (pendingKeys.length) {
|
27
|
+
nextKeysPending[prevKey] = pendingKeys;
|
28
|
+
pendingKeys = [];
|
29
|
+
}
|
30
|
+
continue;
|
31
|
+
}
|
32
|
+
pendingKeys.push(prevKey);
|
33
|
+
}
|
34
|
+
const childMapping = {};
|
35
|
+
// eslint-disable-next-line guard-for-in
|
36
|
+
for(const nextKey in nextMapping){
|
37
|
+
if (nextKeysPending[nextKey]) {
|
38
|
+
for (const pendingNextKey of nextKeysPending[nextKey]){
|
39
|
+
childMapping[pendingNextKey] = getValueForKey(pendingNextKey);
|
40
|
+
}
|
41
|
+
}
|
42
|
+
childMapping[nextKey] = getValueForKey(nextKey);
|
43
|
+
}
|
44
|
+
// Finally, add the keys which didn't appear before any key in `next`
|
45
|
+
for (const pendingKey of pendingKeys){
|
46
|
+
childMapping[pendingKey] = getValueForKey(pendingKey);
|
47
|
+
}
|
48
|
+
return childMapping;
|
49
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["mergeChildMappings.js"],"sourcesContent":["/**\n * When you're adding or removing children some may be added or removed in the same render pass. We want to show *both*\n * since we want to simultaneously animate elements in and out. This function takes a previous set of keys and a new set\n * of keys and merges them with its best guess of the correct ordering.\n */ export function mergeChildMappings(prevMapping, nextMapping) {\n function getValueForKey(key) {\n return key in nextMapping ? nextMapping[key] : prevMapping[key];\n }\n // For each key of `next`, the list of keys to insert before that key in\n // the combined list\n const nextKeysPending = {};\n let pendingKeys = [];\n // eslint-disable-next-line guard-for-in\n for(const prevKey in prevMapping){\n if (prevKey in nextMapping) {\n if (pendingKeys.length) {\n nextKeysPending[prevKey] = pendingKeys;\n pendingKeys = [];\n }\n continue;\n }\n pendingKeys.push(prevKey);\n }\n const childMapping = {};\n // eslint-disable-next-line guard-for-in\n for(const nextKey in nextMapping){\n if (nextKeysPending[nextKey]) {\n for (const pendingNextKey of nextKeysPending[nextKey]){\n childMapping[pendingNextKey] = getValueForKey(pendingNextKey);\n }\n }\n childMapping[nextKey] = getValueForKey(nextKey);\n }\n // Finally, add the keys which didn't appear before any key in `next`\n for (const pendingKey of pendingKeys){\n childMapping[pendingKey] = getValueForKey(pendingKey);\n }\n return childMapping;\n}\n"],"names":["mergeChildMappings","prevMapping","nextMapping","getValueForKey","key","nextKeysPending","pendingKeys","prevKey","length","push","childMapping","nextKey","pendingNextKey","pendingKey"],"mappings":"AAAA;;;;CAIC;;;;+BAAmBA;;;eAAAA;;;AAAT,SAASA,mBAAmBC,WAAW,EAAEC,WAAW;IAC3D,SAASC,eAAeC,GAAG;QACvB,OAAOA,OAAOF,cAAcA,WAAW,CAACE,IAAI,GAAGH,WAAW,CAACG,IAAI;IACnE;IACA,wEAAwE;IACxE,oBAAoB;IACpB,MAAMC,kBAAkB,CAAC;IACzB,IAAIC,cAAc,EAAE;IACpB,wCAAwC;IACxC,IAAI,MAAMC,WAAWN,YAAY;QAC7B,IAAIM,WAAWL,aAAa;YACxB,IAAII,YAAYE,MAAM,EAAE;gBACpBH,eAAe,CAACE,QAAQ,GAAGD;gBAC3BA,cAAc,EAAE;YACpB;YACA;QACJ;QACAA,YAAYG,IAAI,CAACF;IACrB;IACA,MAAMG,eAAe,CAAC;IACtB,wCAAwC;IACxC,IAAI,MAAMC,WAAWT,YAAY;QAC7B,IAAIG,eAAe,CAACM,QAAQ,EAAE;YAC1B,KAAK,MAAMC,kBAAkBP,eAAe,CAACM,QAAQ,CAAC;gBAClDD,YAAY,CAACE,eAAe,GAAGT,eAAeS;YAClD;QACJ;QACAF,YAAY,CAACC,QAAQ,GAAGR,eAAeQ;IAC3C;IACA,qEAAqE;IACrE,KAAK,MAAME,cAAcP,YAAY;QACjCI,YAAY,CAACG,WAAW,GAAGV,eAAeU;IAC9C;IACA,OAAOH;AACX"}
|