@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.
Files changed (73) hide show
  1. package/CHANGELOG.md +171 -0
  2. package/LICENSE +15 -0
  3. package/README.md +5 -0
  4. package/dist/index.d.ts +144 -0
  5. package/lib/components/PresenceGroup.js +53 -0
  6. package/lib/components/PresenceGroup.js.map +1 -0
  7. package/lib/components/PresenceGroupItemProvider.js +25 -0
  8. package/lib/components/PresenceGroupItemProvider.js.map +1 -0
  9. package/lib/contexts/PresenceGroupChildContext.js +4 -0
  10. package/lib/contexts/PresenceGroupChildContext.js.map +1 -0
  11. package/lib/factories/createMotionComponent.js +41 -0
  12. package/lib/factories/createMotionComponent.js.map +1 -0
  13. package/lib/factories/createPresenceComponent.js +86 -0
  14. package/lib/factories/createPresenceComponent.js.map +1 -0
  15. package/lib/hooks/useIsReducedMotion.js +30 -0
  16. package/lib/hooks/useIsReducedMotion.js.map +1 -0
  17. package/lib/hooks/useMotionImperativeRef.js +22 -0
  18. package/lib/hooks/useMotionImperativeRef.js.map +1 -0
  19. package/lib/hooks/useMountedState.js +26 -0
  20. package/lib/hooks/useMountedState.js.map +1 -0
  21. package/lib/index.js +4 -0
  22. package/lib/index.js.map +1 -0
  23. package/lib/motions/motionTokens.js +40 -0
  24. package/lib/motions/motionTokens.js.map +1 -0
  25. package/lib/types.js +1 -0
  26. package/lib/types.js.map +1 -0
  27. package/lib/utils/animateAtoms.js +74 -0
  28. package/lib/utils/animateAtoms.js.map +1 -0
  29. package/lib/utils/getChildElement.js +18 -0
  30. package/lib/utils/getChildElement.js.map +1 -0
  31. package/lib/utils/groups/getChildMapping.js +20 -0
  32. package/lib/utils/groups/getChildMapping.js.map +1 -0
  33. package/lib/utils/groups/getNextChildMapping.js +30 -0
  34. package/lib/utils/groups/getNextChildMapping.js.map +1 -0
  35. package/lib/utils/groups/mergeChildMappings.js +39 -0
  36. package/lib/utils/groups/mergeChildMappings.js.map +1 -0
  37. package/lib/utils/groups/types.js +1 -0
  38. package/lib/utils/groups/types.js.map +1 -0
  39. package/lib-commonjs/components/PresenceGroup.js +64 -0
  40. package/lib-commonjs/components/PresenceGroup.js.map +1 -0
  41. package/lib-commonjs/components/PresenceGroupItemProvider.js +31 -0
  42. package/lib-commonjs/components/PresenceGroupItemProvider.js.map +1 -0
  43. package/lib-commonjs/contexts/PresenceGroupChildContext.js +13 -0
  44. package/lib-commonjs/contexts/PresenceGroupChildContext.js.map +1 -0
  45. package/lib-commonjs/factories/createMotionComponent.js +48 -0
  46. package/lib-commonjs/factories/createMotionComponent.js.map +1 -0
  47. package/lib-commonjs/factories/createPresenceComponent.js +96 -0
  48. package/lib-commonjs/factories/createPresenceComponent.js.map +1 -0
  49. package/lib-commonjs/hooks/useIsReducedMotion.js +40 -0
  50. package/lib-commonjs/hooks/useIsReducedMotion.js.map +1 -0
  51. package/lib-commonjs/hooks/useMotionImperativeRef.js +33 -0
  52. package/lib-commonjs/hooks/useMotionImperativeRef.js.map +1 -0
  53. package/lib-commonjs/hooks/useMountedState.js +34 -0
  54. package/lib-commonjs/hooks/useMountedState.js.map +1 -0
  55. package/lib-commonjs/index.js +34 -0
  56. package/lib-commonjs/index.js.map +1 -0
  57. package/lib-commonjs/motions/motionTokens.js +58 -0
  58. package/lib-commonjs/motions/motionTokens.js.map +1 -0
  59. package/lib-commonjs/types.js +4 -0
  60. package/lib-commonjs/types.js.map +1 -0
  61. package/lib-commonjs/utils/animateAtoms.js +84 -0
  62. package/lib-commonjs/utils/animateAtoms.js.map +1 -0
  63. package/lib-commonjs/utils/getChildElement.js +29 -0
  64. package/lib-commonjs/utils/getChildElement.js.map +1 -0
  65. package/lib-commonjs/utils/groups/getChildMapping.js +29 -0
  66. package/lib-commonjs/utils/groups/getChildMapping.js.map +1 -0
  67. package/lib-commonjs/utils/groups/getNextChildMapping.js +40 -0
  68. package/lib-commonjs/utils/groups/getNextChildMapping.js.map +1 -0
  69. package/lib-commonjs/utils/groups/mergeChildMappings.js +49 -0
  70. package/lib-commonjs/utils/groups/mergeChildMappings.js.map +1 -0
  71. package/lib-commonjs/utils/groups/types.js +6 -0
  72. package/lib-commonjs/utils/groups/types.js.map +1 -0
  73. package/package.json +60 -0
@@ -0,0 +1,22 @@
1
+ import * as React from 'react';
2
+ export function useMotionImperativeRef(imperativeRef) {
3
+ const animationRef = React.useRef();
4
+ React.useImperativeHandle(imperativeRef, ()=>({
5
+ setPlayState: (state)=>{
6
+ if (state === 'running') {
7
+ var _animationRef_current;
8
+ (_animationRef_current = animationRef.current) === null || _animationRef_current === void 0 ? void 0 : _animationRef_current.play();
9
+ }
10
+ if (state === 'paused') {
11
+ var _animationRef_current1;
12
+ (_animationRef_current1 = animationRef.current) === null || _animationRef_current1 === void 0 ? void 0 : _animationRef_current1.pause();
13
+ }
14
+ },
15
+ setPlaybackRate: (rate)=>{
16
+ if (animationRef.current) {
17
+ animationRef.current.playbackRate = rate;
18
+ }
19
+ }
20
+ }));
21
+ return animationRef;
22
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useMotionImperativeRef.ts"],"sourcesContent":["import * as React from 'react';\nimport type { AnimationHandle, MotionImperativeRef } from '../types';\n\nexport function useMotionImperativeRef(imperativeRef: React.Ref<MotionImperativeRef | undefined> | undefined) {\n const animationRef = React.useRef<AnimationHandle | undefined>();\n\n React.useImperativeHandle(imperativeRef, () => ({\n setPlayState: state => {\n if (state === 'running') {\n animationRef.current?.play();\n }\n\n if (state === 'paused') {\n animationRef.current?.pause();\n }\n },\n setPlaybackRate: rate => {\n if (animationRef.current) {\n animationRef.current.playbackRate = rate;\n }\n },\n }));\n\n return animationRef;\n}\n"],"names":["React","useMotionImperativeRef","imperativeRef","animationRef","useRef","useImperativeHandle","setPlayState","state","current","play","pause","setPlaybackRate","rate","playbackRate"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAG/B,OAAO,SAASC,uBAAuBC,aAAqE;IAC1G,MAAMC,eAAeH,MAAMI,MAAM;IAEjCJ,MAAMK,mBAAmB,CAACH,eAAe,IAAO,CAAA;YAC9CI,cAAcC,CAAAA;gBACZ,IAAIA,UAAU,WAAW;wBACvBJ;qBAAAA,wBAAAA,aAAaK,OAAO,cAApBL,4CAAAA,sBAAsBM,IAAI;gBAC5B;gBAEA,IAAIF,UAAU,UAAU;wBACtBJ;qBAAAA,yBAAAA,aAAaK,OAAO,cAApBL,6CAAAA,uBAAsBO,KAAK;gBAC7B;YACF;YACAC,iBAAiBC,CAAAA;gBACf,IAAIT,aAAaK,OAAO,EAAE;oBACxBL,aAAaK,OAAO,CAACK,YAAY,GAAGD;gBACtC;YACF;QACF,CAAA;IAEA,OAAOT;AACT"}
@@ -0,0 +1,26 @@
1
+ import { useForceUpdate } from '@fluentui/react-utilities';
2
+ import * as React from 'react';
3
+ /**
4
+ * This hook manages the mounted state of a component, based on the "visible" and "unmountOnExit" props.
5
+ * It simulates the behavior of getDerivedStateFromProps(), which is not available in functional components.
6
+ */ export function useMountedState(visible = false, unmountOnExit = false) {
7
+ const mountedRef = React.useRef(unmountOnExit ? visible : true);
8
+ const forceUpdate = useForceUpdate();
9
+ const setMounted = React.useCallback((newValue)=>{
10
+ if (mountedRef.current !== newValue) {
11
+ mountedRef.current = newValue;
12
+ forceUpdate();
13
+ }
14
+ }, [
15
+ forceUpdate
16
+ ]);
17
+ React.useEffect(()=>{
18
+ if (visible) {
19
+ mountedRef.current = visible;
20
+ }
21
+ });
22
+ return [
23
+ visible || mountedRef.current,
24
+ setMounted
25
+ ];
26
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useMountedState.ts"],"sourcesContent":["import { useForceUpdate } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\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 */\nexport function useMountedState(\n visible: boolean = false,\n unmountOnExit: boolean = false,\n): [boolean, (value: boolean) => void] {\n const mountedRef = React.useRef<boolean>(unmountOnExit ? visible : true);\n const forceUpdate = useForceUpdate();\n\n const setMounted = React.useCallback(\n (newValue: boolean) => {\n if (mountedRef.current !== newValue) {\n mountedRef.current = newValue;\n forceUpdate();\n }\n },\n [forceUpdate],\n );\n\n React.useEffect(() => {\n if (visible) {\n mountedRef.current = visible;\n }\n });\n\n return [visible || mountedRef.current, setMounted];\n}\n"],"names":["useForceUpdate","React","useMountedState","visible","unmountOnExit","mountedRef","useRef","forceUpdate","setMounted","useCallback","newValue","current","useEffect"],"mappings":"AAAA,SAASA,cAAc,QAAQ,4BAA4B;AAC3D,YAAYC,WAAW,QAAQ;AAE/B;;;CAGC,GACD,OAAO,SAASC,gBACdC,UAAmB,KAAK,EACxBC,gBAAyB,KAAK;IAE9B,MAAMC,aAAaJ,MAAMK,MAAM,CAAUF,gBAAgBD,UAAU;IACnE,MAAMI,cAAcP;IAEpB,MAAMQ,aAAaP,MAAMQ,WAAW,CAClC,CAACC;QACC,IAAIL,WAAWM,OAAO,KAAKD,UAAU;YACnCL,WAAWM,OAAO,GAAGD;YACrBH;QACF;IACF,GACA;QAACA;KAAY;IAGfN,MAAMW,SAAS,CAAC;QACd,IAAIT,SAAS;YACXE,WAAWM,OAAO,GAAGR;QACvB;IACF;IAEA,OAAO;QAACA,WAAWE,WAAWM,OAAO;QAAEH;KAAW;AACpD"}
package/lib/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { motionTokens, durations, curves } from './motions/motionTokens';
2
+ export { createMotionComponent } from './factories/createMotionComponent';
3
+ export { createPresenceComponent } from './factories/createPresenceComponent';
4
+ export { PresenceGroup } from './components/PresenceGroup';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export { motionTokens, durations, curves } from './motions/motionTokens';\n\nexport { createMotionComponent, type MotionComponentProps } from './factories/createMotionComponent';\nexport { createPresenceComponent, type PresenceComponentProps } from './factories/createPresenceComponent';\n\nexport { PresenceGroup } from './components/PresenceGroup';\n\nexport type { AtomMotion, AtomMotionFn, PresenceMotion, PresenceMotionFn, MotionImperativeRef } from './types';\n"],"names":["motionTokens","durations","curves","createMotionComponent","createPresenceComponent","PresenceGroup"],"mappings":"AAAA,SAASA,YAAY,EAAEC,SAAS,EAAEC,MAAM,QAAQ,yBAAyB;AAEzE,SAASC,qBAAqB,QAAmC,oCAAoC;AACrG,SAASC,uBAAuB,QAAqC,sCAAsC;AAE3G,SAASC,aAAa,QAAQ,6BAA6B"}
@@ -0,0 +1,40 @@
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
+ export const durations = {
5
+ durationUltraFast: 50,
6
+ durationFaster: 100,
7
+ durationFast: 150,
8
+ durationNormal: 200,
9
+ durationGentle: 250,
10
+ durationSlow: 300,
11
+ durationSlower: 400,
12
+ durationUltraSlow: 500
13
+ };
14
+ // Copied from packages/tokens/src/global/curves.ts
15
+ // Names and values are preserved exactly
16
+ export const curves = {
17
+ curveAccelerateMax: 'cubic-bezier(0.9,0.1,1,0.2)',
18
+ curveAccelerateMid: 'cubic-bezier(1,0,1,1)',
19
+ curveAccelerateMin: 'cubic-bezier(0.8,0,0.78,1)',
20
+ curveDecelerateMax: 'cubic-bezier(0.1,0.9,0.2,1)',
21
+ curveDecelerateMid: 'cubic-bezier(0,0,0,1)',
22
+ curveDecelerateMin: 'cubic-bezier(0.33,0,0.1,1)',
23
+ curveEasyEaseMax: 'cubic-bezier(0.8,0,0.2,1)',
24
+ curveEasyEase: 'cubic-bezier(0.33,0,0.67,1)',
25
+ curveLinear: 'cubic-bezier(0,0,1,1)'
26
+ };
27
+ // A merged flat lookup for convenience
28
+ export const motionTokens = {
29
+ ...durations,
30
+ ...curves
31
+ }; /*
32
+ TODO: enforce naming conventions when TypeScript 4.4 features are supported in Fluent:
33
+
34
+ type DurationKey = `duration${Capitalize<string>}`;
35
+ type CurveKey = `curve${Capitalize<string>}`;
36
+ type CurveValue = `cubic-bezier(${number},${number},${number},${number})`;
37
+
38
+ type DurationTokens = Record<DurationKey, number>;
39
+ type CurveTokens = Record<CurveKey, CurveValue>;
40
+ */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["motionTokens.ts"],"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} as const;\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} as const;\n\n// A merged flat lookup for convenience\nexport const motionTokens = {\n ...durations,\n ...curves,\n};\n\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","durationUltraFast","durationFaster","durationFast","durationNormal","durationGentle","durationSlow","durationSlower","durationUltraSlow","curves","curveAccelerateMax","curveAccelerateMid","curveAccelerateMin","curveDecelerateMax","curveDecelerateMid","curveDecelerateMin","curveEasyEaseMax","curveEasyEase","curveLinear","motionTokens"],"mappings":"AAAA,sDAAsD;AACtD,2EAA2E;AAC3E,+BAA+B;AAC/B,OAAO,MAAMA,YAAY;IACvBC,mBAAmB;IACnBC,gBAAgB;IAChBC,cAAc;IACdC,gBAAgB;IAChBC,gBAAgB;IAChBC,cAAc;IACdC,gBAAgB;IAChBC,mBAAmB;AACrB,EAAW;AAEX,mDAAmD;AACnD,yCAAyC;AACzC,OAAO,MAAMC,SAAS;IACpBC,oBAAoB;IACpBC,oBAAoB;IACpBC,oBAAoB;IACpBC,oBAAoB;IACpBC,oBAAoB;IACpBC,oBAAoB;IACpBC,kBAAkB;IAClBC,eAAe;IACfC,aAAa;AACf,EAAW;AAEX,uCAAuC;AACvC,OAAO,MAAMC,eAAe;IAC1B,GAAGnB,SAAS;IACZ,GAAGS,MAAM;AACX,EAAE,CAEF;;;;;;;;;AASA"}
package/lib/types.js ADDED
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["types.ts"],"sourcesContent":["export type AtomMotion = { keyframes: Keyframe[] } & KeyframeEffectOptions;\n\nexport type PresenceMotion = {\n enter: AtomMotion | AtomMotion[];\n exit: AtomMotion | AtomMotion[];\n};\n\nexport type AtomMotionFn = (params: { element: HTMLElement }) => AtomMotion | AtomMotion[];\nexport type PresenceMotionFn = (params: { element: HTMLElement }) => PresenceMotion;\n\n// ---\n\nexport type AnimationHandle = Pick<Animation, 'cancel' | 'finish' | 'pause' | 'play' | 'playbackRate'> & {\n onfinish: () => void;\n};\n\nexport type MotionImperativeRef = {\n /** Sets the playback rate of the animation, where 1 is normal speed. */\n setPlaybackRate: (rate: number) => void;\n\n /** Sets the state of the animation to running or paused. */\n setPlayState: (state: 'running' | 'paused') => void;\n};\n"],"names":[],"mappings":"AAAA,WAsBE"}
@@ -0,0 +1,74 @@
1
+ export function animateAtoms(element, value, options) {
2
+ // Heads up!
3
+ // Jest uses jsdom as the default environment, which doesn't support the Web Animations API. The same is true for
4
+ // older browsers that are out of browser support matrix. In these cases, the animation will be a no-op.
5
+ const SUPPORTS_WEB_ANIMATIONS = typeof element.animate === 'function';
6
+ const atoms = Array.isArray(value) ? value : [
7
+ value
8
+ ];
9
+ const { isReducedMotion } = options;
10
+ const animations = SUPPORTS_WEB_ANIMATIONS ? atoms.map((motion)=>{
11
+ const { keyframes, ...params } = motion;
12
+ const animation = element.animate(keyframes, {
13
+ fill: 'forwards',
14
+ ...params,
15
+ ...isReducedMotion && {
16
+ duration: 1
17
+ }
18
+ });
19
+ animation.persist();
20
+ return animation;
21
+ }) : [];
22
+ return {
23
+ set playbackRate (rate){
24
+ animations.forEach((animation)=>{
25
+ animation.playbackRate = rate;
26
+ });
27
+ },
28
+ set onfinish (callback){
29
+ // Heads up!
30
+ // Jest uses jsdom as the default environment, which doesn't support the Web Animations API. This no-op is
31
+ // necessary to avoid errors in tests.
32
+ //
33
+ // See https://github.com/microsoft/fluentui/issues/31593
34
+ // See https://github.com/jsdom/jsdom/issues/3429
35
+ if (process.env.NODE_ENV === 'test') {
36
+ if (animations.length === 0) {
37
+ callback();
38
+ return;
39
+ }
40
+ }
41
+ Promise.all(animations.map((animation)=>animation.finished)).then(()=>{
42
+ callback();
43
+ }).catch((err)=>{
44
+ var _element_ownerDocument_defaultView;
45
+ const DOMException = (_element_ownerDocument_defaultView = element.ownerDocument.defaultView) === null || _element_ownerDocument_defaultView === void 0 ? void 0 : _element_ownerDocument_defaultView.DOMException;
46
+ // Ignores "DOMException: The user aborted a request" that appears if animations are cancelled
47
+ if (DOMException && err instanceof DOMException) {
48
+ return;
49
+ }
50
+ throw err;
51
+ });
52
+ },
53
+ cancel: ()=>{
54
+ animations.forEach((animation)=>{
55
+ animation.cancel();
56
+ });
57
+ },
58
+ pause: ()=>{
59
+ animations.forEach((animation)=>{
60
+ animation.pause();
61
+ });
62
+ },
63
+ play: ()=>{
64
+ animations.forEach((animation)=>{
65
+ animation.play();
66
+ });
67
+ },
68
+ finish: ()=>{
69
+ animations.forEach((animation)=>{
70
+ animation.finish();
71
+ });
72
+ }
73
+ };
74
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["animateAtoms.ts"],"sourcesContent":["import type { AnimationHandle, AtomMotion } from '../types';\n\nexport function animateAtoms(\n element: HTMLElement,\n value: AtomMotion | AtomMotion[],\n options: {\n isReducedMotion: boolean;\n },\n): AnimationHandle {\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\n const atoms = Array.isArray(value) ? value : [value];\n const { isReducedMotion } = options;\n\n const animations = SUPPORTS_WEB_ANIMATIONS\n ? atoms.map(motion => {\n const { keyframes, ...params } = motion;\n const animation = element.animate(keyframes, {\n fill: 'forwards',\n\n ...params,\n ...(isReducedMotion && { duration: 1 }),\n });\n\n animation.persist();\n\n return animation;\n })\n : [];\n\n return {\n set playbackRate(rate: number) {\n animations.forEach(animation => {\n animation.playbackRate = rate;\n });\n },\n set onfinish(callback: () => void) {\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\n Promise.all(animations.map(animation => animation.finished))\n .then(() => {\n callback();\n })\n .catch((err: unknown) => {\n const DOMException = element.ownerDocument.defaultView?.DOMException;\n\n // Ignores \"DOMException: The user aborted a request\" that appears if animations are cancelled\n if (DOMException && err instanceof DOMException) {\n return;\n }\n\n throw err;\n });\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","DOMException","ownerDocument","defaultView","cancel","pause","play","finish"],"mappings":"AAEA,OAAO,SAASA,aACdC,OAAoB,EACpBC,KAAgC,EAChCC,OAEC;IAED,YAAY;IACZ,iHAAiH;IACjH,wGAAwG;IACxG,MAAMC,0BAA0B,OAAOH,QAAQI,OAAO,KAAK;IAE3D,MAAMC,QAAQC,MAAMC,OAAO,CAACN,SAASA,QAAQ;QAACA;KAAM;IACpD,MAAM,EAAEO,eAAe,EAAE,GAAGN;IAE5B,MAAMO,aAAaN,0BACfE,MAAMK,GAAG,CAACC,CAAAA;QACR,MAAM,EAAEC,SAAS,EAAE,GAAGC,QAAQ,GAAGF;QACjC,MAAMG,YAAYd,QAAQI,OAAO,CAACQ,WAAW;YAC3CG,MAAM;YAEN,GAAGF,MAAM;YACT,GAAIL,mBAAmB;gBAAEQ,UAAU;YAAE,CAAC;QACxC;QAEAF,UAAUG,OAAO;QAEjB,OAAOH;IACT,KACA,EAAE;IAEN,OAAO;QACL,IAAII,cAAaC,KAAc;YAC7BV,WAAWW,OAAO,CAACN,CAAAA;gBACjBA,UAAUI,YAAY,GAAGC;YAC3B;QACF;QACA,IAAIE,UAASC,SAAsB;YACjC,YAAY;YACZ,0GAA0G;YAC1G,sCAAsC;YACtC,EAAE;YACF,yDAAyD;YACzD,iDAAiD;YACjD,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,QAAQ;gBACnC,IAAIhB,WAAWiB,MAAM,KAAK,GAAG;oBAC3BJ;oBACA;gBACF;YACF;YAEAK,QAAQC,GAAG,CAACnB,WAAWC,GAAG,CAACI,CAAAA,YAAaA,UAAUe,QAAQ,GACvDC,IAAI,CAAC;gBACJR;YACF,GACCS,KAAK,CAAC,CAACC;oBACehC;gBAArB,MAAMiC,gBAAejC,qCAAAA,QAAQkC,aAAa,CAACC,WAAW,cAAjCnC,yDAAAA,mCAAmCiC,YAAY;gBAEpE,8FAA8F;gBAC9F,IAAIA,gBAAgBD,eAAeC,cAAc;oBAC/C;gBACF;gBAEA,MAAMD;YACR;QACJ;QAEAI,QAAQ;YACN3B,WAAWW,OAAO,CAACN,CAAAA;gBACjBA,UAAUsB,MAAM;YAClB;QACF;QACAC,OAAO;YACL5B,WAAWW,OAAO,CAACN,CAAAA;gBACjBA,UAAUuB,KAAK;YACjB;QACF;QACAC,MAAM;YACJ7B,WAAWW,OAAO,CAACN,CAAAA;gBACjBA,UAAUwB,IAAI;YAChB;QACF;QACAC,QAAQ;YACN9B,WAAWW,OAAO,CAACN,CAAAA;gBACjBA,UAAUyB,MAAM;YAClB;QACF;IACF;AACF"}
@@ -0,0 +1,18 @@
1
+ import * as React from 'react';
2
+ import * as ReactIs from 'react-is';
3
+ export function getChildElement(children) {
4
+ try {
5
+ const child = React.Children.only(children);
6
+ if (typeof child.type === 'string' || ReactIs.isForwardRef(child)) {
7
+ return child;
8
+ }
9
+ // We don't need to do anything here: we catch the exception from React to throw a more meaningful error
10
+ // eslint-disable-next-line no-empty
11
+ } catch {}
12
+ throw new Error([
13
+ '@fluentui/react-motion: Invalid child element.',
14
+ '\n',
15
+ 'Motion factories require a single child element to be passed. ',
16
+ '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().'
17
+ ].join(''));
18
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["getChildElement.ts"],"sourcesContent":["import * as React from 'react';\nimport * as ReactIs from 'react-is';\n\nexport function getChildElement(children: React.ReactElement) {\n try {\n const child = React.Children.only(children) as React.ReactElement & { ref: React.Ref<HTMLElement> };\n\n if (typeof child.type === 'string' || ReactIs.isForwardRef(child)) {\n return child as React.ReactElement & { ref: React.Ref<HTMLElement> };\n }\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\n throw new Error(\n [\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}\n"],"names":["React","ReactIs","getChildElement","children","child","Children","only","type","isForwardRef","Error","join"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,YAAYC,aAAa,WAAW;AAEpC,OAAO,SAASC,gBAAgBC,QAA4B;IAC1D,IAAI;QACF,MAAMC,QAAQJ,MAAMK,QAAQ,CAACC,IAAI,CAACH;QAElC,IAAI,OAAOC,MAAMG,IAAI,KAAK,YAAYN,QAAQO,YAAY,CAACJ,QAAQ;YACjE,OAAOA;QACT;IAEA,wGAAwG;IACxG,oCAAoC;IACtC,EAAE,OAAM,CAAC;IAET,MAAM,IAAIK,MACR;QACE;QACA;QACA;QACA;KACD,CAACC,IAAI,CAAC;AAEX"}
@@ -0,0 +1,20 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * Given `children`, return an object mapping key to child.
4
+ */ export function getChildMapping(children) {
5
+ const childMapping = {};
6
+ if (children) {
7
+ React.Children.toArray(children).forEach((child)=>{
8
+ if (React.isValidElement(child)) {
9
+ var _child_key;
10
+ childMapping[(_child_key = child.key) !== null && _child_key !== void 0 ? _child_key : ''] = {
11
+ appear: false,
12
+ element: child,
13
+ visible: true,
14
+ unmountOnExit: true
15
+ };
16
+ }
17
+ });
18
+ }
19
+ return childMapping;
20
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["getChildMapping.ts"],"sourcesContent":["import * as React from 'react';\nimport type { PresenceGroupChildMapping } from './types';\n\n/**\n * Given `children`, return an object mapping key to child.\n */\nexport function getChildMapping(children: React.ReactNode | undefined) {\n const childMapping: PresenceGroupChildMapping = {};\n\n if (children) {\n React.Children.toArray(children).forEach(child => {\n if (React.isValidElement(child)) {\n childMapping[child.key ?? ''] = {\n appear: false,\n element: child,\n visible: true,\n unmountOnExit: true,\n };\n }\n });\n }\n\n return childMapping;\n}\n"],"names":["React","getChildMapping","children","childMapping","Children","toArray","forEach","child","isValidElement","key","appear","element","visible","unmountOnExit"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAG/B;;CAEC,GACD,OAAO,SAASC,gBAAgBC,QAAqC;IACnE,MAAMC,eAA0C,CAAC;IAEjD,IAAID,UAAU;QACZF,MAAMI,QAAQ,CAACC,OAAO,CAACH,UAAUI,OAAO,CAACC,CAAAA;YACvC,IAAIP,MAAMQ,cAAc,CAACD,QAAQ;oBAClBA;gBAAbJ,YAAY,CAACI,CAAAA,aAAAA,MAAME,GAAG,cAATF,wBAAAA,aAAa,GAAG,GAAG;oBAC9BG,QAAQ;oBACRC,SAASJ;oBACTK,SAAS;oBACTC,eAAe;gBACjB;YACF;QACF;IACF;IAEA,OAAOV;AACT"}
@@ -0,0 +1,30 @@
1
+ import { mergeChildMappings } from './mergeChildMappings';
2
+ export function getNextChildMapping(prevChildMapping, nextChildMapping) {
3
+ const childrenMapping = mergeChildMappings(prevChildMapping, nextChildMapping);
4
+ Object.entries(childrenMapping).forEach(([key, childDefinition])=>{
5
+ const hasPrev = key in prevChildMapping;
6
+ const hasNext = key in nextChildMapping;
7
+ if (hasNext) {
8
+ // Case 1: item hasn't changed transition states
9
+ if (hasPrev) {
10
+ childrenMapping[key] = {
11
+ ...childDefinition
12
+ };
13
+ return;
14
+ }
15
+ // Case 2: item is new (entering)
16
+ childrenMapping[key] = {
17
+ ...childDefinition,
18
+ appear: true,
19
+ visible: true
20
+ };
21
+ return;
22
+ }
23
+ // Case 3: item is leaving
24
+ childrenMapping[key] = {
25
+ ...childDefinition,
26
+ visible: false
27
+ };
28
+ });
29
+ return childrenMapping;
30
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["getNextChildMapping.ts"],"sourcesContent":["import { mergeChildMappings } from './mergeChildMappings';\nimport type { PresenceGroupChildMapping } from './types';\n\nexport function getNextChildMapping(\n prevChildMapping: PresenceGroupChildMapping,\n nextChildMapping: PresenceGroupChildMapping,\n) {\n const childrenMapping = mergeChildMappings(prevChildMapping, nextChildMapping);\n\n Object.entries(childrenMapping).forEach(([key, childDefinition]) => {\n const hasPrev = key in prevChildMapping;\n const hasNext = key in nextChildMapping;\n\n if (hasNext) {\n // Case 1: item hasn't changed transition states\n if (hasPrev) {\n childrenMapping[key] = { ...childDefinition };\n return;\n }\n\n // Case 2: item is new (entering)\n childrenMapping[key] = {\n ...childDefinition,\n appear: true,\n visible: true,\n };\n return;\n }\n\n // Case 3: item is leaving\n childrenMapping[key] = {\n ...childDefinition,\n visible: false,\n };\n });\n\n return childrenMapping;\n}\n"],"names":["mergeChildMappings","getNextChildMapping","prevChildMapping","nextChildMapping","childrenMapping","Object","entries","forEach","key","childDefinition","hasPrev","hasNext","appear","visible"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,uBAAuB;AAG1D,OAAO,SAASC,oBACdC,gBAA2C,EAC3CC,gBAA2C;IAE3C,MAAMC,kBAAkBJ,mBAAmBE,kBAAkBC;IAE7DE,OAAOC,OAAO,CAACF,iBAAiBG,OAAO,CAAC,CAAC,CAACC,KAAKC,gBAAgB;QAC7D,MAAMC,UAAUF,OAAON;QACvB,MAAMS,UAAUH,OAAOL;QAEvB,IAAIQ,SAAS;YACX,gDAAgD;YAChD,IAAID,SAAS;gBACXN,eAAe,CAACI,IAAI,GAAG;oBAAE,GAAGC,eAAe;gBAAC;gBAC5C;YACF;YAEA,iCAAiC;YACjCL,eAAe,CAACI,IAAI,GAAG;gBACrB,GAAGC,eAAe;gBAClBG,QAAQ;gBACRC,SAAS;YACX;YACA;QACF;QAEA,0BAA0B;QAC1BT,eAAe,CAACI,IAAI,GAAG;YACrB,GAAGC,eAAe;YAClBI,SAAS;QACX;IACF;IAEA,OAAOT;AACT"}
@@ -0,0 +1,39 @@
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
+ */ export function mergeChildMappings(prevMapping, nextMapping) {
6
+ function getValueForKey(key) {
7
+ return key in nextMapping ? nextMapping[key] : prevMapping[key];
8
+ }
9
+ // For each key of `next`, the list of keys to insert before that key in
10
+ // the combined list
11
+ const nextKeysPending = {};
12
+ let pendingKeys = [];
13
+ // eslint-disable-next-line guard-for-in
14
+ for(const prevKey in prevMapping){
15
+ if (prevKey in nextMapping) {
16
+ if (pendingKeys.length) {
17
+ nextKeysPending[prevKey] = pendingKeys;
18
+ pendingKeys = [];
19
+ }
20
+ continue;
21
+ }
22
+ pendingKeys.push(prevKey);
23
+ }
24
+ const childMapping = {};
25
+ // eslint-disable-next-line guard-for-in
26
+ for(const nextKey in nextMapping){
27
+ if (nextKeysPending[nextKey]) {
28
+ for (const pendingNextKey of nextKeysPending[nextKey]){
29
+ childMapping[pendingNextKey] = getValueForKey(pendingNextKey);
30
+ }
31
+ }
32
+ childMapping[nextKey] = getValueForKey(nextKey);
33
+ }
34
+ // Finally, add the keys which didn't appear before any key in `next`
35
+ for (const pendingKey of pendingKeys){
36
+ childMapping[pendingKey] = getValueForKey(pendingKey);
37
+ }
38
+ return childMapping;
39
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["mergeChildMappings.ts"],"sourcesContent":["import type { PresenceGroupChildMapping } from './types';\n\n/**\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 */\nexport function mergeChildMappings(\n prevMapping: PresenceGroupChildMapping,\n nextMapping: PresenceGroupChildMapping,\n): PresenceGroupChildMapping {\n function getValueForKey(key: string) {\n return key in nextMapping ? nextMapping[key] : prevMapping[key];\n }\n\n // For each key of `next`, the list of keys to insert before that key in\n // the combined list\n const nextKeysPending: Record<string, string[]> = {};\n let pendingKeys: string[] = [];\n\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\n continue;\n }\n\n pendingKeys.push(prevKey);\n }\n\n const childMapping: PresenceGroupChildMapping = {};\n\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\n childMapping[nextKey] = getValueForKey(nextKey);\n }\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\n return childMapping;\n}\n"],"names":["mergeChildMappings","prevMapping","nextMapping","getValueForKey","key","nextKeysPending","pendingKeys","prevKey","length","push","childMapping","nextKey","pendingNextKey","pendingKey"],"mappings":"AAEA;;;;CAIC,GACD,OAAO,SAASA,mBACdC,WAAsC,EACtCC,WAAsC;IAEtC,SAASC,eAAeC,GAAW;QACjC,OAAOA,OAAOF,cAAcA,WAAW,CAACE,IAAI,GAAGH,WAAW,CAACG,IAAI;IACjE;IAEA,wEAAwE;IACxE,oBAAoB;IACpB,MAAMC,kBAA4C,CAAC;IACnD,IAAIC,cAAwB,EAAE;IAE9B,wCAAwC;IACxC,IAAK,MAAMC,WAAWN,YAAa;QACjC,IAAIM,WAAWL,aAAa;YAC1B,IAAII,YAAYE,MAAM,EAAE;gBACtBH,eAAe,CAACE,QAAQ,GAAGD;gBAC3BA,cAAc,EAAE;YAClB;YAEA;QACF;QAEAA,YAAYG,IAAI,CAACF;IACnB;IAEA,MAAMG,eAA0C,CAAC;IAEjD,wCAAwC;IACxC,IAAK,MAAMC,WAAWT,YAAa;QACjC,IAAIG,eAAe,CAACM,QAAQ,EAAE;YAC5B,KAAK,MAAMC,kBAAkBP,eAAe,CAACM,QAAQ,CAAE;gBACrDD,YAAY,CAACE,eAAe,GAAGT,eAAeS;YAChD;QACF;QAEAF,YAAY,CAACC,QAAQ,GAAGR,eAAeQ;IACzC;IAEA,qEAAqE;IACrE,KAAK,MAAME,cAAcP,YAAa;QACpCI,YAAY,CAACG,WAAW,GAAGV,eAAeU;IAC5C;IAEA,OAAOH;AACT"}
@@ -0,0 +1 @@
1
+ import * as React from 'react';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["types.ts"],"sourcesContent":["import * as React from 'react';\n\nexport type PresenceGroupChild = {\n element: React.ReactElement;\n\n appear: boolean;\n visible: boolean;\n unmountOnExit: boolean;\n};\n\nexport type PresenceGroupChildMapping = Record<string, PresenceGroupChild>;\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "PresenceGroup", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return PresenceGroup;
9
+ }
10
+ });
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _define_property = require("@swc/helpers/_/_define_property");
13
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
14
+ const _getNextChildMapping = require("../utils/groups/getNextChildMapping");
15
+ const _getChildMapping = require("../utils/groups/getChildMapping");
16
+ const _PresenceGroupItemProvider = require("./PresenceGroupItemProvider");
17
+ class PresenceGroup extends _react.Component {
18
+ static getDerivedStateFromProps(nextProps, { childMapping: prevChildMapping, firstRender }) {
19
+ const nextChildMapping = (0, _getChildMapping.getChildMapping)(nextProps.children);
20
+ return {
21
+ childMapping: firstRender ? nextChildMapping : (0, _getNextChildMapping.getNextChildMapping)(prevChildMapping, nextChildMapping),
22
+ firstRender: false
23
+ };
24
+ }
25
+ componentDidMount() {
26
+ this.mounted = true;
27
+ }
28
+ componentWillUnmount() {
29
+ this.mounted = false;
30
+ }
31
+ render() {
32
+ return /*#__PURE__*/ _react.createElement(_react.Fragment, null, Object.entries(this.state.childMapping).map(([childKey, childProps])=>/*#__PURE__*/ _react.createElement(_PresenceGroupItemProvider.PresenceGroupItemProvider, {
33
+ ...childProps,
34
+ childKey: childKey,
35
+ key: childKey,
36
+ onExit: this.handleExit
37
+ }, childProps.element)));
38
+ }
39
+ constructor(props, context){
40
+ super(props, context);
41
+ (0, _define_property._)(this, "mounted", false);
42
+ (0, _define_property._)(this, "handleExit", (childKey)=>{
43
+ const currentChildMapping = (0, _getChildMapping.getChildMapping)(this.props.children);
44
+ if (childKey in currentChildMapping) {
45
+ return;
46
+ }
47
+ if (this.mounted) {
48
+ this.setState((state)=>{
49
+ const childMapping = {
50
+ ...state.childMapping
51
+ };
52
+ delete childMapping[childKey];
53
+ return {
54
+ childMapping
55
+ };
56
+ });
57
+ }
58
+ });
59
+ this.state = {
60
+ childMapping: {},
61
+ firstRender: true
62
+ };
63
+ }
64
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["PresenceGroup.js"],"sourcesContent":["import { _ as _define_property } from \"@swc/helpers/_/_define_property\";\nimport * as React from 'react';\nimport { getNextChildMapping } from '../utils/groups/getNextChildMapping';\nimport { getChildMapping } from '../utils/groups/getChildMapping';\nimport { PresenceGroupItemProvider } from './PresenceGroupItemProvider';\n/* eslint-disable @typescript-eslint/explicit-member-accessibility */ /* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable @typescript-eslint/member-ordering */ export class PresenceGroup extends React.Component {\n static getDerivedStateFromProps(nextProps, { childMapping: prevChildMapping, firstRender }) {\n const nextChildMapping = getChildMapping(nextProps.children);\n return {\n childMapping: firstRender ? nextChildMapping : getNextChildMapping(prevChildMapping, nextChildMapping),\n firstRender: false\n };\n }\n componentDidMount() {\n this.mounted = true;\n }\n componentWillUnmount() {\n this.mounted = false;\n }\n render() {\n return /*#__PURE__*/ React.createElement(React.Fragment, null, Object.entries(this.state.childMapping).map(([childKey, childProps])=>/*#__PURE__*/ React.createElement(PresenceGroupItemProvider, {\n ...childProps,\n childKey: childKey,\n key: childKey,\n onExit: this.handleExit\n }, childProps.element)));\n }\n constructor(props, context){\n super(props, context);\n _define_property(this, \"mounted\", false);\n _define_property(this, \"handleExit\", (childKey)=>{\n const currentChildMapping = getChildMapping(this.props.children);\n if (childKey in currentChildMapping) {\n return;\n }\n if (this.mounted) {\n this.setState((state)=>{\n const childMapping = {\n ...state.childMapping\n };\n delete childMapping[childKey];\n return {\n childMapping\n };\n });\n }\n });\n this.state = {\n childMapping: {},\n firstRender: true\n };\n }\n}\n"],"names":["PresenceGroup","React","Component","getDerivedStateFromProps","nextProps","childMapping","prevChildMapping","firstRender","nextChildMapping","getChildMapping","children","getNextChildMapping","componentDidMount","mounted","componentWillUnmount","render","createElement","Fragment","Object","entries","state","map","childKey","childProps","PresenceGroupItemProvider","key","onExit","handleExit","element","constructor","props","context","_define_property","currentChildMapping","setState"],"mappings":";;;;+BAKqMA;;;eAAAA;;;;iCAL/J;iEACf;qCACa;iCACJ;2CACU;AACqJ,MAAMA,sBAAsBC,OAAMC,SAAS;IACtO,OAAOC,yBAAyBC,SAAS,EAAE,EAAEC,cAAcC,gBAAgB,EAAEC,WAAW,EAAE,EAAE;QACxF,MAAMC,mBAAmBC,IAAAA,gCAAe,EAACL,UAAUM,QAAQ;QAC3D,OAAO;YACHL,cAAcE,cAAcC,mBAAmBG,IAAAA,wCAAmB,EAACL,kBAAkBE;YACrFD,aAAa;QACjB;IACJ;IACAK,oBAAoB;QAChB,IAAI,CAACC,OAAO,GAAG;IACnB;IACAC,uBAAuB;QACnB,IAAI,CAACD,OAAO,GAAG;IACnB;IACAE,SAAS;QACL,OAAO,WAAW,GAAGd,OAAMe,aAAa,CAACf,OAAMgB,QAAQ,EAAE,MAAMC,OAAOC,OAAO,CAAC,IAAI,CAACC,KAAK,CAACf,YAAY,EAAEgB,GAAG,CAAC,CAAC,CAACC,UAAUC,WAAW,GAAG,WAAW,GAAGtB,OAAMe,aAAa,CAACQ,oDAAyB,EAAE;gBAC1L,GAAGD,UAAU;gBACbD,UAAUA;gBACVG,KAAKH;gBACLI,QAAQ,IAAI,CAACC,UAAU;YAC3B,GAAGJ,WAAWK,OAAO;IAC7B;IACAC,YAAYC,KAAK,EAAEC,OAAO,CAAC;QACvB,KAAK,CAACD,OAAOC;QACbC,IAAAA,kBAAgB,EAAC,IAAI,EAAE,WAAW;QAClCA,IAAAA,kBAAgB,EAAC,IAAI,EAAE,cAAc,CAACV;YAClC,MAAMW,sBAAsBxB,IAAAA,gCAAe,EAAC,IAAI,CAACqB,KAAK,CAACpB,QAAQ;YAC/D,IAAIY,YAAYW,qBAAqB;gBACjC;YACJ;YACA,IAAI,IAAI,CAACpB,OAAO,EAAE;gBACd,IAAI,CAACqB,QAAQ,CAAC,CAACd;oBACX,MAAMf,eAAe;wBACjB,GAAGe,MAAMf,YAAY;oBACzB;oBACA,OAAOA,YAAY,CAACiB,SAAS;oBAC7B,OAAO;wBACHjB;oBACJ;gBACJ;YACJ;QACJ;QACA,IAAI,CAACe,KAAK,GAAG;YACTf,cAAc,CAAC;YACfE,aAAa;QACjB;IACJ;AACJ"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "PresenceGroupItemProvider", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return PresenceGroupItemProvider;
9
+ }
10
+ });
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
13
+ const _PresenceGroupChildContext = require("../contexts/PresenceGroupChildContext");
14
+ const PresenceGroupItemProvider = (props)=>{
15
+ const { appear, childKey, onExit, visible, unmountOnExit } = props;
16
+ const contextValue = _react.useMemo(()=>({
17
+ appear,
18
+ visible,
19
+ onExit: ()=>onExit(childKey),
20
+ unmountOnExit
21
+ }), [
22
+ appear,
23
+ childKey,
24
+ onExit,
25
+ visible,
26
+ unmountOnExit
27
+ ]);
28
+ return /*#__PURE__*/ _react.createElement(_PresenceGroupChildContext.PresenceGroupChildContext.Provider, {
29
+ value: contextValue
30
+ }, props.children);
31
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["PresenceGroupItemProvider.js"],"sourcesContent":["import * as React from 'react';\nimport { PresenceGroupChildContext } from '../contexts/PresenceGroupChildContext';\n/**\n * @internal\n *\n * Provides context for a single child of a `PresenceGroup`. Exists only to make a stable context value for a child.\n * Not intended for direct use.\n */ export const PresenceGroupItemProvider = (props)=>{\n const { appear, childKey, onExit, visible, unmountOnExit } = props;\n const contextValue = React.useMemo(()=>({\n appear,\n visible,\n onExit: ()=>onExit(childKey),\n unmountOnExit\n }), [\n appear,\n childKey,\n onExit,\n visible,\n unmountOnExit\n ]);\n return /*#__PURE__*/ React.createElement(PresenceGroupChildContext.Provider, {\n value: contextValue\n }, props.children);\n};\n"],"names":["PresenceGroupItemProvider","props","appear","childKey","onExit","visible","unmountOnExit","contextValue","React","useMemo","createElement","PresenceGroupChildContext","Provider","value","children"],"mappings":";;;;+BAOiBA;;;eAAAA;;;;iEAPM;2CACmB;AAM/B,MAAMA,4BAA4B,CAACC;IAC1C,MAAM,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,OAAO,EAAEC,aAAa,EAAE,GAAGL;IAC7D,MAAMM,eAAeC,OAAMC,OAAO,CAAC,IAAK,CAAA;YAChCP;YACAG;YACAD,QAAQ,IAAIA,OAAOD;YACnBG;QACJ,CAAA,GAAI;QACJJ;QACAC;QACAC;QACAC;QACAC;KACH;IACD,OAAO,WAAW,GAAGE,OAAME,aAAa,CAACC,oDAAyB,CAACC,QAAQ,EAAE;QACzEC,OAAON;IACX,GAAGN,MAAMa,QAAQ;AACrB"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "PresenceGroupChildContext", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return PresenceGroupChildContext;
9
+ }
10
+ });
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
13
+ const PresenceGroupChildContext = /*#__PURE__*/ _react.createContext(undefined);
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["PresenceGroupChildContext.js"],"sourcesContent":["import * as React from 'react';\n/**\n * @internal\n */ export const PresenceGroupChildContext = React.createContext(undefined);\n"],"names":["PresenceGroupChildContext","React","createContext","undefined"],"mappings":";;;;+BAGiBA;;;eAAAA;;;;iEAHM;AAGZ,MAAMA,0CAA4BC,OAAMC,aAAa,CAACC"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "createMotionComponent", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return createMotionComponent;
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 _useIsReducedMotion = require("../hooks/useIsReducedMotion");
15
+ const _useMotionImperativeRef = require("../hooks/useMotionImperativeRef");
16
+ const _animateAtoms = require("../utils/animateAtoms");
17
+ const _getChildElement = require("../utils/getChildElement");
18
+ function createMotionComponent(value) {
19
+ const Atom = (props)=>{
20
+ const { children, imperativeRef } = props;
21
+ const child = (0, _getChildElement.getChildElement)(children);
22
+ const handleRef = (0, _useMotionImperativeRef.useMotionImperativeRef)(imperativeRef);
23
+ const elementRef = _react.useRef();
24
+ const isReducedMotion = (0, _useIsReducedMotion.useIsReducedMotion)();
25
+ (0, _reactutilities.useIsomorphicLayoutEffect)(()=>{
26
+ const element = elementRef.current;
27
+ if (element) {
28
+ const atoms = typeof value === 'function' ? value({
29
+ element
30
+ }) : value;
31
+ const handle = (0, _animateAtoms.animateAtoms)(element, atoms, {
32
+ isReducedMotion: isReducedMotion()
33
+ });
34
+ handleRef.current = handle;
35
+ return ()=>{
36
+ handle.cancel();
37
+ };
38
+ }
39
+ }, [
40
+ handleRef,
41
+ isReducedMotion
42
+ ]);
43
+ return /*#__PURE__*/ _react.cloneElement(children, {
44
+ ref: (0, _reactutilities.useMergedRefs)(elementRef, child.ref)
45
+ });
46
+ };
47
+ return Atom;
48
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["createMotionComponent.js"],"sourcesContent":["import { useIsomorphicLayoutEffect, useMergedRefs } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport { useIsReducedMotion } from '../hooks/useIsReducedMotion';\nimport { useMotionImperativeRef } from '../hooks/useMotionImperativeRef';\nimport { animateAtoms } from '../utils/animateAtoms';\nimport { getChildElement } from '../utils/getChildElement';\n/**\n * Creates a component that will animate the children using the provided motion.\n *\n * @param value - A motion definition.\n */ export function createMotionComponent(value) {\n const Atom = (props)=>{\n const { children, imperativeRef } = props;\n const child = getChildElement(children);\n const handleRef = useMotionImperativeRef(imperativeRef);\n const elementRef = React.useRef();\n const isReducedMotion = useIsReducedMotion();\n useIsomorphicLayoutEffect(()=>{\n const element = elementRef.current;\n if (element) {\n const atoms = typeof value === 'function' ? value({\n element\n }) : value;\n const handle = animateAtoms(element, atoms, {\n isReducedMotion: isReducedMotion()\n });\n handleRef.current = handle;\n return ()=>{\n handle.cancel();\n };\n }\n }, [\n handleRef,\n isReducedMotion\n ]);\n return React.cloneElement(children, {\n ref: useMergedRefs(elementRef, child.ref)\n });\n };\n return Atom;\n}\n"],"names":["createMotionComponent","value","Atom","props","children","imperativeRef","child","getChildElement","handleRef","useMotionImperativeRef","elementRef","React","useRef","isReducedMotion","useIsReducedMotion","useIsomorphicLayoutEffect","element","current","atoms","handle","animateAtoms","cancel","cloneElement","ref","useMergedRefs"],"mappings":";;;;+BAUoBA;;;eAAAA;;;;gCAVqC;iEAClC;oCACY;wCACI;8BACV;iCACG;AAKrB,SAASA,sBAAsBC,KAAK;IAC3C,MAAMC,OAAO,CAACC;QACV,MAAM,EAAEC,QAAQ,EAAEC,aAAa,EAAE,GAAGF;QACpC,MAAMG,QAAQC,IAAAA,gCAAe,EAACH;QAC9B,MAAMI,YAAYC,IAAAA,8CAAsB,EAACJ;QACzC,MAAMK,aAAaC,OAAMC,MAAM;QAC/B,MAAMC,kBAAkBC,IAAAA,sCAAkB;QAC1CC,IAAAA,yCAAyB,EAAC;YACtB,MAAMC,UAAUN,WAAWO,OAAO;YAClC,IAAID,SAAS;gBACT,MAAME,QAAQ,OAAOjB,UAAU,aAAaA,MAAM;oBAC9Ce;gBACJ,KAAKf;gBACL,MAAMkB,SAASC,IAAAA,0BAAY,EAACJ,SAASE,OAAO;oBACxCL,iBAAiBA;gBACrB;gBACAL,UAAUS,OAAO,GAAGE;gBACpB,OAAO;oBACHA,OAAOE,MAAM;gBACjB;YACJ;QACJ,GAAG;YACCb;YACAK;SACH;QACD,qBAAOF,OAAMW,YAAY,CAAClB,UAAU;YAChCmB,KAAKC,IAAAA,6BAAa,EAACd,YAAYJ,MAAMiB,GAAG;QAC5C;IACJ;IACA,OAAOrB;AACX"}