@fluentui/react-motion 9.16.1 → 9.74.3-experimental.esm.20260709-49ee7a20cf.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -2
- package/dist/index.d.cts +368 -0
- package/lib/components/MotionRefForwarder.js +1 -1
- package/lib/components/PresenceGroup.js +4 -4
- package/lib/components/PresenceGroup.js.map +1 -1
- package/lib/components/PresenceGroupItemProvider.js +2 -2
- package/lib/components/PresenceGroupItemProvider.js.map +1 -1
- package/lib/contexts/MotionBehaviourContext.js +1 -1
- package/lib/contexts/PresenceGroupChildContext.js +1 -1
- package/lib/factories/createMotionComponent.js +7 -7
- package/lib/factories/createMotionComponent.js.map +1 -1
- package/lib/factories/createMotionComponentVariant.js +1 -1
- package/lib/factories/createMotionComponentVariant.js.map +1 -1
- package/lib/factories/createPresenceComponent.js +10 -10
- package/lib/factories/createPresenceComponent.js.map +1 -1
- package/lib/factories/createPresenceComponentVariant.js +1 -1
- package/lib/factories/createPresenceComponentVariant.js.map +1 -1
- package/lib/hooks/useAnimateAtoms.js +2 -2
- package/lib/hooks/useAnimateAtoms.js.map +1 -1
- package/lib/hooks/useIsReducedMotion.js +3 -3
- package/lib/hooks/useMotionImperativeRef.js +1 -1
- package/lib/hooks/useMountedState.js +2 -2
- package/lib/index.js +11 -11
- package/lib/index.js.map +1 -1
- package/lib/slots/motionSlot.js +2 -2
- package/lib/slots/presenceMotionSlot.js +2 -2
- package/lib/utils/groups/getChildMapping.js +1 -1
- package/lib/utils/groups/getNextChildMapping.js +1 -1
- package/lib/utils/groups/getNextChildMapping.js.map +1 -1
- package/lib/utils/useChildElement.js +2 -2
- package/lib-commonjs/components/{PresenceGroup.js → PresenceGroup.cjs} +3 -3
- package/lib-commonjs/components/{PresenceGroupItemProvider.js → PresenceGroupItemProvider.cjs} +1 -1
- package/lib-commonjs/factories/{createMotionComponent.js → createMotionComponent.cjs} +5 -5
- package/lib-commonjs/factories/{createMotionComponentVariant.js → createMotionComponentVariant.cjs} +1 -1
- package/lib-commonjs/factories/{createPresenceComponent.js → createPresenceComponent.cjs} +8 -8
- package/lib-commonjs/factories/{createPresenceComponentVariant.js → createPresenceComponentVariant.cjs} +1 -1
- package/lib-commonjs/hooks/{useAnimateAtoms.js → useAnimateAtoms.cjs} +1 -1
- package/lib-commonjs/{index.js → index.cjs} +11 -11
- package/lib-commonjs/utils/groups/{getNextChildMapping.js → getNextChildMapping.cjs} +1 -1
- package/package.json +15 -14
- /package/lib-commonjs/components/{MotionRefForwarder.js → MotionRefForwarder.cjs} +0 -0
- /package/lib-commonjs/components/{MotionRefForwarder.js.map → MotionRefForwarder.cjs.map} +0 -0
- /package/lib-commonjs/components/{PresenceGroup.js.map → PresenceGroup.cjs.map} +0 -0
- /package/lib-commonjs/components/{PresenceGroupItemProvider.js.map → PresenceGroupItemProvider.cjs.map} +0 -0
- /package/lib-commonjs/contexts/{MotionBehaviourContext.js → MotionBehaviourContext.cjs} +0 -0
- /package/lib-commonjs/contexts/{MotionBehaviourContext.js.map → MotionBehaviourContext.cjs.map} +0 -0
- /package/lib-commonjs/contexts/{PresenceGroupChildContext.js → PresenceGroupChildContext.cjs} +0 -0
- /package/lib-commonjs/contexts/{PresenceGroupChildContext.js.map → PresenceGroupChildContext.cjs.map} +0 -0
- /package/lib-commonjs/factories/{createMotionComponent.js.map → createMotionComponent.cjs.map} +0 -0
- /package/lib-commonjs/factories/{createMotionComponentVariant.js.map → createMotionComponentVariant.cjs.map} +0 -0
- /package/lib-commonjs/factories/{createPresenceComponent.js.map → createPresenceComponent.cjs.map} +0 -0
- /package/lib-commonjs/factories/{createPresenceComponentVariant.js.map → createPresenceComponentVariant.cjs.map} +0 -0
- /package/lib-commonjs/hooks/{useAnimateAtoms.js.map → useAnimateAtoms.cjs.map} +0 -0
- /package/lib-commonjs/hooks/{useIsReducedMotion.js → useIsReducedMotion.cjs} +0 -0
- /package/lib-commonjs/hooks/{useIsReducedMotion.js.map → useIsReducedMotion.cjs.map} +0 -0
- /package/lib-commonjs/hooks/{useMotionImperativeRef.js → useMotionImperativeRef.cjs} +0 -0
- /package/lib-commonjs/hooks/{useMotionImperativeRef.js.map → useMotionImperativeRef.cjs.map} +0 -0
- /package/lib-commonjs/hooks/{useMountedState.js → useMountedState.cjs} +0 -0
- /package/lib-commonjs/hooks/{useMountedState.js.map → useMountedState.cjs.map} +0 -0
- /package/lib-commonjs/{index.js.map → index.cjs.map} +0 -0
- /package/lib-commonjs/motions/{motionTokens.js → motionTokens.cjs} +0 -0
- /package/lib-commonjs/motions/{motionTokens.js.map → motionTokens.cjs.map} +0 -0
- /package/lib-commonjs/slots/{motionSlot.js → motionSlot.cjs} +0 -0
- /package/lib-commonjs/slots/{motionSlot.js.map → motionSlot.cjs.map} +0 -0
- /package/lib-commonjs/slots/{presenceMotionSlot.js → presenceMotionSlot.cjs} +0 -0
- /package/lib-commonjs/slots/{presenceMotionSlot.js.map → presenceMotionSlot.cjs.map} +0 -0
- /package/lib-commonjs/{types.js → types.cjs} +0 -0
- /package/lib-commonjs/{types.js.map → types.cjs.map} +0 -0
- /package/lib-commonjs/utils/groups/{getChildMapping.js → getChildMapping.cjs} +0 -0
- /package/lib-commonjs/utils/groups/{getChildMapping.js.map → getChildMapping.cjs.map} +0 -0
- /package/lib-commonjs/utils/groups/{getNextChildMapping.js.map → getNextChildMapping.cjs.map} +0 -0
- /package/lib-commonjs/utils/groups/{mergeChildMappings.js → mergeChildMappings.cjs} +0 -0
- /package/lib-commonjs/utils/groups/{mergeChildMappings.js.map → mergeChildMappings.cjs.map} +0 -0
- /package/lib-commonjs/utils/groups/{types.js → types.cjs} +0 -0
- /package/lib-commonjs/utils/groups/{types.js.map → types.cjs.map} +0 -0
- /package/lib-commonjs/utils/{isAnimationRunning.js → isAnimationRunning.cjs} +0 -0
- /package/lib-commonjs/utils/{isAnimationRunning.js.map → isAnimationRunning.cjs.map} +0 -0
- /package/lib-commonjs/utils/{useChildElement.js → useChildElement.cjs} +0 -0
- /package/lib-commonjs/utils/{useChildElement.js.map → useChildElement.cjs.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/factories/createPresenceComponent.ts"],"sourcesContent":["'use client';\n\nimport { useEventCallback, useFirstMount, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { PresenceGroupChildContext } from '../contexts/PresenceGroupChildContext';\nimport { useAnimateAtoms } from '../hooks/useAnimateAtoms';\nimport { useMotionImperativeRef } from '../hooks/useMotionImperativeRef';\nimport { useMountedState } from '../hooks/useMountedState';\nimport { useIsReducedMotion } from '../hooks/useIsReducedMotion';\nimport { useChildElement } from '../utils/useChildElement';\nimport type {\n MotionParam,\n PresenceMotion,\n MotionImperativeRef,\n PresenceMotionFn,\n PresenceDirection,\n AnimationHandle,\n} from '../types';\nimport { useMotionBehaviourContext } from '../contexts/MotionBehaviourContext';\nimport type { MotionComponent } from './createMotionComponent';\nimport { createMotionComponent } from './createMotionComponent';\n\n/**\n * A private symbol to store the motion definition on the component for variants.\n *\n * @internal\n */\nexport const PRESENCE_MOTION_DEFINITION = Symbol('PRESENCE_MOTION_DEFINITION');\n\nexport type PresenceComponentProps = {\n /**\n * By default, the child component won't execute the \"enter\" motion when it initially mounts, regardless of the value\n * of \"visible\". If you desire this behavior, ensure both \"appear\" and \"visible\" are set to \"true\".\n */\n appear?: boolean;\n\n /** A React element that will be cloned and will have motion effects applied to it. */\n children: JSXElement;\n\n /** Provides imperative controls for the animation. */\n imperativeRef?: React.Ref<MotionImperativeRef | undefined>;\n\n /**\n * Callback that is called when the whole motion finishes.\n *\n * A motion definition can contain multiple animations and therefore multiple \"finish\" events. The callback is\n * triggered once all animations have finished with \"null\" instead of an event object to avoid ambiguity.\n */\n // eslint-disable-next-line @nx/workspace-consistent-callback-type -- EventHandler<T> does not support \"null\"\n onMotionFinish?: (ev: null, data: { direction: PresenceDirection }) => void;\n\n /**\n * Callback that is called when the whole motion is cancelled. When a motion is cancelled it does not\n * emit a finish event but a specific cancel event\n *\n * A motion definition can contain multiple animations and therefore multiple \"finish\" events. The callback is\n * triggered once all animations have finished with \"null\" instead of an event object to avoid ambiguity.\n */\n // eslint-disable-next-line @nx/workspace-consistent-callback-type -- EventHandler<T> does not support \"null\"\n onMotionCancel?: (ev: null, data: { direction: PresenceDirection }) => void;\n\n /**\n * Callback that is called when the whole motion starts.\n *\n * A motion definition can contain multiple animations and therefore multiple \"start\" events. The callback is\n * triggered when the first animation is started. There is no official \"start\" event with the Web Animations API.\n * so the callback is triggered with \"null\".\n */\n // eslint-disable-next-line @nx/workspace-consistent-callback-type -- EventHandler<T> does not support \"null\"\n onMotionStart?: (ev: null, data: { direction: PresenceDirection }) => void;\n\n /** Defines whether a component is visible; triggers the \"enter\" or \"exit\" motions. */\n visible?: boolean;\n\n /**\n * By default, the child component remains mounted after it reaches the \"finished\" state. Set \"unmountOnExit\" if\n * you prefer to unmount the component after it finishes exiting.\n */\n unmountOnExit?: boolean;\n};\n\nexport type PresenceComponent<MotionParams extends Record<string, MotionParam> = {}> = React.FC<\n PresenceComponentProps & MotionParams\n> & {\n (props: PresenceComponentProps & MotionParams): JSXElement | null;\n [PRESENCE_MOTION_DEFINITION]: PresenceMotionFn<MotionParams>;\n In: MotionComponent<MotionParams>;\n Out: MotionComponent<MotionParams>;\n};\n\nconst INTERRUPTABLE_MOTION_SYMBOL = Symbol.for('interruptablePresence');\n\nexport function createPresenceComponent<MotionParams extends Record<string, MotionParam> = {}>(\n value: PresenceMotion | PresenceMotionFn<MotionParams>,\n): PresenceComponent<MotionParams> {\n return Object.assign(\n (props: PresenceComponentProps & MotionParams) => {\n const itemContext = React.useContext(PresenceGroupChildContext);\n const merged = { ...itemContext, ...props };\n const skipMotions = useMotionBehaviourContext() === 'skip';\n\n const {\n appear,\n children,\n imperativeRef,\n onExit,\n onMotionFinish,\n onMotionStart,\n onMotionCancel,\n visible,\n unmountOnExit,\n ..._rest\n } = merged;\n const params = _rest as Exclude<typeof merged, PresenceComponentProps | typeof itemContext>;\n\n const [mounted, setMounted] = useMountedState(visible, unmountOnExit);\n const [child, childRef] = useChildElement(children, mounted);\n\n const handleRef = useMotionImperativeRef(imperativeRef);\n const optionsRef = React.useRef<{ appear?: boolean; params: MotionParams; skipMotions: boolean }>({\n appear,\n params,\n skipMotions,\n });\n\n const animateAtoms = useAnimateAtoms();\n const isFirstMount = useFirstMount();\n const isReducedMotion = useIsReducedMotion();\n\n const handleMotionStart = useEventCallback((direction: PresenceDirection) => {\n onMotionStart?.(null, { direction });\n });\n const handleMotionFinish = useEventCallback((direction: PresenceDirection) => {\n onMotionFinish?.(null, { direction });\n\n if (direction === 'exit' && unmountOnExit) {\n setMounted(false);\n onExit?.();\n }\n });\n\n const handleMotionCancel = useEventCallback((direction: PresenceDirection) => {\n onMotionCancel?.(null, { direction });\n });\n\n useIsomorphicLayoutEffect(() => {\n // Heads up!\n // We store the params in a ref to avoid re-rendering the component when the params change.\n optionsRef.current = { appear, params, skipMotions };\n });\n\n useIsomorphicLayoutEffect(\n () => {\n const element = childRef.current;\n\n if (!element) {\n return;\n }\n\n let handle: AnimationHandle | undefined;\n\n function cleanup() {\n if (!handle) {\n return;\n }\n\n // Heads up!\n //\n // If the animation is interruptible & is running, we don't want to cancel it as it will be reversed in\n // the next effect.\n if (IS_EXPERIMENTAL_INTERRUPTIBLE_MOTION && handle.isRunning()) {\n return;\n }\n\n handle.cancel();\n handleRef.current = undefined;\n }\n\n const presenceMotion =\n typeof value === 'function' ? value({ element, ...optionsRef.current.params }) : (value as PresenceMotion);\n const IS_EXPERIMENTAL_INTERRUPTIBLE_MOTION = (\n presenceMotion as PresenceMotion & { [INTERRUPTABLE_MOTION_SYMBOL]?: boolean }\n )[INTERRUPTABLE_MOTION_SYMBOL];\n\n if (IS_EXPERIMENTAL_INTERRUPTIBLE_MOTION) {\n handle = handleRef.current;\n\n if (handle && handle.isRunning()) {\n handle.reverse();\n\n return cleanup;\n }\n }\n\n const atoms = visible ? presenceMotion.enter : presenceMotion.exit;\n const direction: PresenceDirection = visible ? 'enter' : 'exit';\n\n // Heads up!\n // Initial styles are applied when the component is mounted for the first time and \"appear\" is set to \"false\" (otherwise animations are triggered)\n const applyInitialStyles = !optionsRef.current.appear && isFirstMount;\n const skipAnimationByConfig = optionsRef.current.skipMotions;\n\n if (!applyInitialStyles) {\n handleMotionStart(direction);\n }\n\n handle = animateAtoms(element, atoms, { isReducedMotion: isReducedMotion() });\n\n if (applyInitialStyles) {\n // Heads up!\n // .finish() is used in this case to skip animation and apply animation styles immediately\n handle.finish();\n\n return cleanup;\n }\n\n handleRef.current = handle;\n handle.setMotionEndCallbacks(\n () => handleMotionFinish(direction),\n () => handleMotionCancel(direction),\n );\n\n if (skipAnimationByConfig) {\n handle.finish();\n }\n\n return cleanup;\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 animateAtoms,\n childRef,\n handleRef,\n isReducedMotion,\n handleMotionFinish,\n handleMotionStart,\n handleMotionCancel,\n visible,\n ],\n );\n\n React.useEffect(() => {\n // Heads up!\n //\n // Dispose the handle when unmounting the component to clean up retained references. Doing it in a separate\n // effect to ensure that the component is unmounted.\n\n if (unmountOnExit && !mounted) {\n handleRef.current?.dispose();\n }\n }, [handleRef, unmountOnExit, mounted]);\n\n if (mounted) {\n return child;\n }\n\n return null;\n },\n {\n // Heads up!\n // Always normalize it to a function to simplify types\n [PRESENCE_MOTION_DEFINITION]: typeof value === 'function' ? value : () => value,\n },\n {\n // Wrap `enter` in its own motion component as a static method, e.g. <Fade.In>\n In: createMotionComponent(\n // If we have a motion function, wrap it to forward the runtime params and pick `enter`.\n // Otherwise, pass the `enter` motion object directly.\n typeof value === 'function' ? (...args: Parameters<typeof value>) => value(...args).enter : value.enter,\n ),\n\n // Wrap `exit` in its own motion component as a static method, e.g. <Fade.Out>\n Out: createMotionComponent(\n // If we have a motion function, wrap it to forward the runtime params and pick `exit`.\n // Otherwise, pass the `exit` motion object directly.\n typeof value === 'function' ? (...args: Parameters<typeof value>) => value(...args).exit : value.exit,\n ),\n },\n );\n}\n"],"names":["useEventCallback","useFirstMount","useIsomorphicLayoutEffect","React","PresenceGroupChildContext","useAnimateAtoms","useMotionImperativeRef","useMountedState","useIsReducedMotion","useChildElement","useMotionBehaviourContext","createMotionComponent","PRESENCE_MOTION_DEFINITION","Symbol","INTERRUPTABLE_MOTION_SYMBOL","for","createPresenceComponent","value","Object","assign","props","itemContext","useContext","merged","skipMotions","appear","children","imperativeRef","onExit","onMotionFinish","onMotionStart","onMotionCancel","visible","unmountOnExit","_rest","params","mounted","setMounted","child","childRef","handleRef","optionsRef","useRef","animateAtoms","isFirstMount","isReducedMotion","handleMotionStart","direction","handleMotionFinish","handleMotionCancel","current","element","handle","cleanup","IS_EXPERIMENTAL_INTERRUPTIBLE_MOTION","isRunning","cancel","undefined","presenceMotion","reverse","atoms","enter","exit","applyInitialStyles","skipAnimationByConfig","finish","setMotionEndCallbacks","useEffect","dispose","In","args","Out"],"mappings":"AAAA;AAEA,SAASA,gBAAgB,EAAEC,aAAa,EAAEC,yBAAyB,QAAQ,4BAA4B;AAEvG,YAAYC,WAAW,QAAQ;AAE/B,SAASC,yBAAyB,QAAQ,wCAAwC;AAClF,SAASC,eAAe,QAAQ,2BAA2B;AAC3D,SAASC,sBAAsB,QAAQ,kCAAkC;AACzE,SAASC,eAAe,QAAQ,2BAA2B;AAC3D,SAASC,kBAAkB,QAAQ,8BAA8B;AACjE,SAASC,eAAe,QAAQ,2BAA2B;AAS3D,SAASC,yBAAyB,QAAQ,qCAAqC;AAE/E,SAASC,qBAAqB,QAAQ,0BAA0B;AAEhE;;;;CAIC,GACD,OAAO,MAAMC,6BAA6BC,OAAO,8BAA8B;AA+D/E,MAAMC,8BAA8BD,OAAOE,GAAG,CAAC;AAE/C,OAAO,SAASC,wBACdC,KAA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AGH7B,MAAMgE,SAAS,CAAC;YACd,YAAY;YACZ,EAAE;YACF,2GAA2G;YAC3G,oDAAoD;YAEpD,IAAIlC,iBAAiB,CAACG,SAAS;oBAC7BI;iBAAAA,qBAAAA,UAAUU,OAAO,cAAjBV,yCAAAA,mBAAmB4B,OAAO;YAC5B;QACF,GAAG;YAAC5B;YAAWP;YAAeG;SAAQ;QAEtC,IAAIA,SAAS;YACX,OAAOE;QACT;QAEA,OAAO;IACT,GACA;QACE,YAAY;QACZ,sDAAsD;QACtD,CAAC1B,2BAA2B,EAAE,OAAOK,UAAU,aAAaA,QAAQ,IAAMA;IAC5E,GACA;QACE,8EAA8E;QAC9EoD,IAAI1D,sBACF,wFAAwF;QACxF,sDAAsD;QACtD,OAAOM,UAAU,aAAa,CAAC,GAAGqD,OAAmCrD,SAASqD,MAAMT,KAAK,GAAG5C,MAAM4C,KAAK;QAGzG,8EAA8E;QAC9EU,KAAK5D,sBACH,uFAAuF;QACvF,qDAAqD;QACrD,OAAOM,UAAU,aAAa,CAAC,GAAGqD,OAAmCrD,SAASqD,MAAMR,IAAI,GAAG7C,MAAM6C,IAAI;IAEzG;AAEJ"}
|
|
1
|
+
{"version":3,"sources":["../src/factories/createPresenceComponent.ts"],"sourcesContent":["'use client';\n\nimport { useEventCallback, useFirstMount, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { PresenceGroupChildContext } from '../contexts/PresenceGroupChildContext';\nimport { useAnimateAtoms } from '../hooks/useAnimateAtoms';\nimport { useMotionImperativeRef } from '../hooks/useMotionImperativeRef';\nimport { useMountedState } from '../hooks/useMountedState';\nimport { useIsReducedMotion } from '../hooks/useIsReducedMotion';\nimport { useChildElement } from '../utils/useChildElement';\nimport type {\n MotionParam,\n PresenceMotion,\n MotionImperativeRef,\n PresenceMotionFn,\n PresenceDirection,\n AnimationHandle,\n} from '../types';\nimport { useMotionBehaviourContext } from '../contexts/MotionBehaviourContext';\nimport type { MotionComponent } from './createMotionComponent';\nimport { createMotionComponent } from './createMotionComponent';\n\n/**\n * A private symbol to store the motion definition on the component for variants.\n *\n * @internal\n */\nexport const PRESENCE_MOTION_DEFINITION = Symbol('PRESENCE_MOTION_DEFINITION');\n\nexport type PresenceComponentProps = {\n /**\n * By default, the child component won't execute the \"enter\" motion when it initially mounts, regardless of the value\n * of \"visible\". If you desire this behavior, ensure both \"appear\" and \"visible\" are set to \"true\".\n */\n appear?: boolean;\n\n /** A React element that will be cloned and will have motion effects applied to it. */\n children: JSXElement;\n\n /** Provides imperative controls for the animation. */\n imperativeRef?: React.Ref<MotionImperativeRef | undefined>;\n\n /**\n * Callback that is called when the whole motion finishes.\n *\n * A motion definition can contain multiple animations and therefore multiple \"finish\" events. The callback is\n * triggered once all animations have finished with \"null\" instead of an event object to avoid ambiguity.\n */\n // eslint-disable-next-line @nx/workspace-consistent-callback-type -- EventHandler<T> does not support \"null\"\n onMotionFinish?: (ev: null, data: { direction: PresenceDirection }) => void;\n\n /**\n * Callback that is called when the whole motion is cancelled. When a motion is cancelled it does not\n * emit a finish event but a specific cancel event\n *\n * A motion definition can contain multiple animations and therefore multiple \"finish\" events. The callback is\n * triggered once all animations have finished with \"null\" instead of an event object to avoid ambiguity.\n */\n // eslint-disable-next-line @nx/workspace-consistent-callback-type -- EventHandler<T> does not support \"null\"\n onMotionCancel?: (ev: null, data: { direction: PresenceDirection }) => void;\n\n /**\n * Callback that is called when the whole motion starts.\n *\n * A motion definition can contain multiple animations and therefore multiple \"start\" events. The callback is\n * triggered when the first animation is started. There is no official \"start\" event with the Web Animations API.\n * so the callback is triggered with \"null\".\n */\n // eslint-disable-next-line @nx/workspace-consistent-callback-type -- EventHandler<T> does not support \"null\"\n onMotionStart?: (ev: null, data: { direction: PresenceDirection }) => void;\n\n /** Defines whether a component is visible; triggers the \"enter\" or \"exit\" motions. */\n visible?: boolean;\n\n /**\n * By default, the child component remains mounted after it reaches the \"finished\" state. Set \"unmountOnExit\" if\n * you prefer to unmount the component after it finishes exiting.\n */\n unmountOnExit?: boolean;\n};\n\nexport type PresenceComponent<MotionParams extends Record<string, MotionParam> = {}> = React.FC<\n PresenceComponentProps & MotionParams\n> & {\n (props: PresenceComponentProps & MotionParams): JSXElement | null;\n [PRESENCE_MOTION_DEFINITION]: PresenceMotionFn<MotionParams>;\n In: MotionComponent<MotionParams>;\n Out: MotionComponent<MotionParams>;\n};\n\nconst INTERRUPTABLE_MOTION_SYMBOL = Symbol.for('interruptablePresence');\n\nexport function createPresenceComponent<MotionParams extends Record<string, MotionParam> = {}>(\n value: PresenceMotion | PresenceMotionFn<MotionParams>,\n): PresenceComponent<MotionParams> {\n return Object.assign(\n (props: PresenceComponentProps & MotionParams) => {\n const itemContext = React.useContext(PresenceGroupChildContext);\n const merged = { ...itemContext, ...props };\n const skipMotions = useMotionBehaviourContext() === 'skip';\n\n const {\n appear,\n children,\n imperativeRef,\n onExit,\n onMotionFinish,\n onMotionStart,\n onMotionCancel,\n visible,\n unmountOnExit,\n ..._rest\n } = merged;\n const params = _rest as Exclude<typeof merged, PresenceComponentProps | typeof itemContext>;\n\n const [mounted, setMounted] = useMountedState(visible, unmountOnExit);\n const [child, childRef] = useChildElement(children, mounted);\n\n const handleRef = useMotionImperativeRef(imperativeRef);\n const optionsRef = React.useRef<{ appear?: boolean; params: MotionParams; skipMotions: boolean }>({\n appear,\n params,\n skipMotions,\n });\n\n const animateAtoms = useAnimateAtoms();\n const isFirstMount = useFirstMount();\n const isReducedMotion = useIsReducedMotion();\n\n const handleMotionStart = useEventCallback((direction: PresenceDirection) => {\n onMotionStart?.(null, { direction });\n });\n const handleMotionFinish = useEventCallback((direction: PresenceDirection) => {\n onMotionFinish?.(null, { direction });\n\n if (direction === 'exit' && unmountOnExit) {\n setMounted(false);\n onExit?.();\n }\n });\n\n const handleMotionCancel = useEventCallback((direction: PresenceDirection) => {\n onMotionCancel?.(null, { direction });\n });\n\n useIsomorphicLayoutEffect(() => {\n // Heads up!\n // We store the params in a ref to avoid re-rendering the component when the params change.\n optionsRef.current = { appear, params, skipMotions };\n });\n\n useIsomorphicLayoutEffect(\n () => {\n const element = childRef.current;\n\n if (!element) {\n return;\n }\n\n let handle: AnimationHandle | undefined;\n\n function cleanup() {\n if (!handle) {\n return;\n }\n\n // Heads up!\n //\n // If the animation is interruptible & is running, we don't want to cancel it as it will be reversed in\n // the next effect.\n if (IS_EXPERIMENTAL_INTERRUPTIBLE_MOTION && handle.isRunning()) {\n return;\n }\n\n handle.cancel();\n handleRef.current = undefined;\n }\n\n const presenceMotion =\n typeof value === 'function' ? value({ element, ...optionsRef.current.params }) : (value as PresenceMotion);\n const IS_EXPERIMENTAL_INTERRUPTIBLE_MOTION = (\n presenceMotion as PresenceMotion & { [INTERRUPTABLE_MOTION_SYMBOL]?: boolean }\n )[INTERRUPTABLE_MOTION_SYMBOL];\n\n if (IS_EXPERIMENTAL_INTERRUPTIBLE_MOTION) {\n handle = handleRef.current;\n\n if (handle && handle.isRunning()) {\n handle.reverse();\n\n return cleanup;\n }\n }\n\n const atoms = visible ? presenceMotion.enter : presenceMotion.exit;\n const direction: PresenceDirection = visible ? 'enter' : 'exit';\n\n // Heads up!\n // Initial styles are applied when the component is mounted for the first time and \"appear\" is set to \"false\" (otherwise animations are triggered)\n const applyInitialStyles = !optionsRef.current.appear && isFirstMount;\n const skipAnimationByConfig = optionsRef.current.skipMotions;\n\n if (!applyInitialStyles) {\n handleMotionStart(direction);\n }\n\n handle = animateAtoms(element, atoms, { isReducedMotion: isReducedMotion() });\n\n if (applyInitialStyles) {\n // Heads up!\n // .finish() is used in this case to skip animation and apply animation styles immediately\n handle.finish();\n\n return cleanup;\n }\n\n handleRef.current = handle;\n handle.setMotionEndCallbacks(\n () => handleMotionFinish(direction),\n () => handleMotionCancel(direction),\n );\n\n if (skipAnimationByConfig) {\n handle.finish();\n }\n\n return cleanup;\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 animateAtoms,\n childRef,\n handleRef,\n isReducedMotion,\n handleMotionFinish,\n handleMotionStart,\n handleMotionCancel,\n visible,\n ],\n );\n\n React.useEffect(() => {\n // Heads up!\n //\n // Dispose the handle when unmounting the component to clean up retained references. Doing it in a separate\n // effect to ensure that the component is unmounted.\n\n if (unmountOnExit && !mounted) {\n handleRef.current?.dispose();\n }\n }, [handleRef, unmountOnExit, mounted]);\n\n if (mounted) {\n return child;\n }\n\n return null;\n },\n {\n // Heads up!\n // Always normalize it to a function to simplify types\n [PRESENCE_MOTION_DEFINITION]: typeof value === 'function' ? value : () => value,\n },\n {\n // Wrap `enter` in its own motion component as a static method, e.g. <Fade.In>\n In: createMotionComponent(\n // If we have a motion function, wrap it to forward the runtime params and pick `enter`.\n // Otherwise, pass the `enter` motion object directly.\n typeof value === 'function' ? (...args: Parameters<typeof value>) => value(...args).enter : value.enter,\n ),\n\n // Wrap `exit` in its own motion component as a static method, e.g. <Fade.Out>\n Out: createMotionComponent(\n // If we have a motion function, wrap it to forward the runtime params and pick `exit`.\n // Otherwise, pass the `exit` motion object directly.\n typeof value === 'function' ? (...args: Parameters<typeof value>) => value(...args).exit : value.exit,\n ),\n },\n );\n}\n"],"names":["useEventCallback","useFirstMount","useIsomorphicLayoutEffect","React","PresenceGroupChildContext","useAnimateAtoms","useMotionImperativeRef","useMountedState","useIsReducedMotion","useChildElement","useMotionBehaviourContext","createMotionComponent","PRESENCE_MOTION_DEFINITION","Symbol","INTERRUPTABLE_MOTION_SYMBOL","for","createPresenceComponent","value","Object","assign","props","itemContext","useContext","merged","skipMotions","appear","children","imperativeRef","onExit","onMotionFinish","onMotionStart","onMotionCancel","visible","unmountOnExit","_rest","params","mounted","setMounted","child","childRef","handleRef","optionsRef","useRef","animateAtoms","isFirstMount","isReducedMotion","handleMotionStart","direction","handleMotionFinish","handleMotionCancel","current","element","handle","cleanup","IS_EXPERIMENTAL_INTERRUPTIBLE_MOTION","isRunning","cancel","undefined","presenceMotion","reverse","atoms","enter","exit","applyInitialStyles","skipAnimationByConfig","finish","setMotionEndCallbacks","useEffect","dispose","In","args","Out"],"mappings":"AAAA;AAEA,SAASA,gBAAgB,EAAEC,aAAa,EAAEC,yBAAyB,QAAQ,4BAA4B;AAEvG,YAAYC,WAAW,QAAQ;AAE/B,SAASC,yBAAyB,QAAQ,2CAAwC;AAClF,SAASC,eAAe,QAAQ,8BAA2B;AAC3D,SAASC,sBAAsB,QAAQ,qCAAkC;AACzE,SAASC,eAAe,QAAQ,8BAA2B;AAC3D,SAASC,kBAAkB,QAAQ,iCAA8B;AACjE,SAASC,eAAe,QAAQ,8BAA2B;AAS3D,SAASC,yBAAyB,QAAQ,wCAAqC;AAE/E,SAASC,qBAAqB,QAAQ,6BAA0B;AAEhE;;;;CAIC,GACD,OAAO,MAAMC,6BAA6BC,OAAO,8BAA8B;AA+D/E,MAAMC,8BAA8BD,OAAOE,GAAG,CAAC;AAE/C,OAAO,SAASC,wBACdC,KAAsD;IAEtD,OAAOC,OAAOC,MAAM,CAClB,CAACC;QACC,MAAMC,cAAclB,MAAMmB,UAAU,CAAClB;QACrC,MAAMmB,SAAS;YAAE,GAAGF,WAAW;YAAE,GAAGD,KAAK;QAAC;QAC1C,MAAMI,cAAcd,gCAAgC;QAEpD,MAAM,EACJe,MAAM,EACNC,QAAQ,EACRC,aAAa,EACbC,MAAM,EACNC,cAAc,EACdC,aAAa,EACbC,cAAc,EACdC,OAAO,EACPC,aAAa,EACb,GAAGC,OACJ,GAAGX;QACJ,MAAMY,SAASD;QAEf,MAAM,CAACE,SAASC,WAAW,GAAG9B,gBAAgByB,SAASC;QACvD,MAAM,CAACK,OAAOC,SAAS,GAAG9B,gBAAgBiB,UAAUU;QAEpD,MAAMI,YAAYlC,uBAAuBqB;QACzC,MAAMc,aAAatC,MAAMuC,MAAM,CAAmE;YAChGjB;YACAU;YACAX;QACF;QAEA,MAAMmB,eAAetC;QACrB,MAAMuC,eAAe3C;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DAAqD;QACrD,OAAOM,UAAU,aAAa,CAAC,GAAGqD,OAAmCrD,SAASqD,MAAMR,IAAI,GAAG7C,MAAM6C,IAAI;IAEzG;AAEJ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PRESENCE_MOTION_DEFINITION, createPresenceComponent } from
|
|
1
|
+
import { PRESENCE_MOTION_DEFINITION, createPresenceComponent } from "./createPresenceComponent.js";
|
|
2
2
|
/**
|
|
3
3
|
* Create a variant function that wraps a presence function to customize it.
|
|
4
4
|
* The new presence function has the supplied variant params as defaults,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/factories/createPresenceComponentVariant.ts"],"sourcesContent":["import type { MotionParam, PresenceMotionFn } from '../types';\nimport type { PresenceComponent } from './createPresenceComponent';\nimport { PRESENCE_MOTION_DEFINITION, createPresenceComponent } from './createPresenceComponent';\n\n/**\n * Create a variant function that wraps a presence function to customize it.\n * The new presence function has the supplied variant params as defaults,\n * but these can still be overridden by runtime params when the new function is called.\n *\n * @internal\n */\nexport function createPresenceFnVariant<MotionParams extends Record<string, MotionParam> = {}>(\n presenceFn: PresenceMotionFn<MotionParams>,\n variantParams: Partial<MotionParams>,\n): typeof presenceFn {\n const variantFn: typeof presenceFn = runtimeParams => presenceFn({ ...variantParams, ...runtimeParams });\n return variantFn;\n}\n\n/**\n * Create a new presence component based on another presence component,\n * using the provided variant parameters as defaults.\n *\n * @param component - A component created by `createPresenceComponent`.\n * @param variantParams - An object containing the variant parameters to be used as defaults.\n * The variant parameters should match the type of the component's motion parameters.\n * @returns A new presence component that uses the provided variant parameters as defaults.\n * The new component can still accept runtime parameters that override the defaults.\n */\nexport function createPresenceComponentVariant<MotionParams extends Record<string, MotionParam> = {}>(\n component: PresenceComponent<MotionParams>,\n variantParams: Partial<MotionParams>,\n): PresenceComponent<MotionParams> {\n const originalFn = component[PRESENCE_MOTION_DEFINITION];\n // The variant params become new defaults, but they can still be overridden by runtime params.\n const variantFn = createPresenceFnVariant(originalFn, variantParams);\n return createPresenceComponent(variantFn);\n}\n"],"names":["PRESENCE_MOTION_DEFINITION","createPresenceComponent","createPresenceFnVariant","presenceFn","variantParams","variantFn","runtimeParams","createPresenceComponentVariant","component","originalFn"],"mappings":"AAEA,SAASA,0BAA0B,EAAEC,uBAAuB,QAAQ
|
|
1
|
+
{"version":3,"sources":["../src/factories/createPresenceComponentVariant.ts"],"sourcesContent":["import type { MotionParam, PresenceMotionFn } from '../types';\nimport type { PresenceComponent } from './createPresenceComponent';\nimport { PRESENCE_MOTION_DEFINITION, createPresenceComponent } from './createPresenceComponent';\n\n/**\n * Create a variant function that wraps a presence function to customize it.\n * The new presence function has the supplied variant params as defaults,\n * but these can still be overridden by runtime params when the new function is called.\n *\n * @internal\n */\nexport function createPresenceFnVariant<MotionParams extends Record<string, MotionParam> = {}>(\n presenceFn: PresenceMotionFn<MotionParams>,\n variantParams: Partial<MotionParams>,\n): typeof presenceFn {\n const variantFn: typeof presenceFn = runtimeParams => presenceFn({ ...variantParams, ...runtimeParams });\n return variantFn;\n}\n\n/**\n * Create a new presence component based on another presence component,\n * using the provided variant parameters as defaults.\n *\n * @param component - A component created by `createPresenceComponent`.\n * @param variantParams - An object containing the variant parameters to be used as defaults.\n * The variant parameters should match the type of the component's motion parameters.\n * @returns A new presence component that uses the provided variant parameters as defaults.\n * The new component can still accept runtime parameters that override the defaults.\n */\nexport function createPresenceComponentVariant<MotionParams extends Record<string, MotionParam> = {}>(\n component: PresenceComponent<MotionParams>,\n variantParams: Partial<MotionParams>,\n): PresenceComponent<MotionParams> {\n const originalFn = component[PRESENCE_MOTION_DEFINITION];\n // The variant params become new defaults, but they can still be overridden by runtime params.\n const variantFn = createPresenceFnVariant(originalFn, variantParams);\n return createPresenceComponent(variantFn);\n}\n"],"names":["PRESENCE_MOTION_DEFINITION","createPresenceComponent","createPresenceFnVariant","presenceFn","variantParams","variantFn","runtimeParams","createPresenceComponentVariant","component","originalFn"],"mappings":"AAEA,SAASA,0BAA0B,EAAEC,uBAAuB,QAAQ,+BAA4B;AAEhG;;;;;;CAMC,GACD,OAAO,SAASC,wBACdC,UAA0C,EAC1CC,aAAoC;IAEpC,MAAMC,YAA+BC,CAAAA,gBAAiBH,WAAW;YAAE,GAAGC,aAAa;YAAE,GAAGE,aAAa;QAAC;IACtG,OAAOD;AACT;AAEA;;;;;;;;;CASC,GACD,OAAO,SAASE,+BACdC,SAA0C,EAC1CJ,aAAoC;IAEpC,MAAMK,aAAaD,SAAS,CAACR,2BAA2B;IACxD,8FAA8F;IAC9F,MAAMK,YAAYH,wBAAwBO,YAAYL;IACtD,OAAOH,wBAAwBI;AACjC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import * as React from
|
|
3
|
-
import { isAnimationRunning } from
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { isAnimationRunning } from "../utils/isAnimationRunning.js";
|
|
4
4
|
export const DEFAULT_ANIMATION_OPTIONS = {
|
|
5
5
|
fill: 'forwards'
|
|
6
6
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/useAnimateAtoms.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\nimport { isAnimationRunning } from '../utils/isAnimationRunning';\nimport type { AnimationHandle, AtomMotion } from '../types';\n\nexport const DEFAULT_ANIMATION_OPTIONS: KeyframeEffectOptions = {\n fill: 'forwards',\n};\n\n// A motion atom's default reduced motion is a simple 1 ms duration.\n// But an atom can define a custom reduced motion, overriding keyframes and/or params like duration, easing, iterations, etc.\nconst DEFAULT_REDUCED_MOTION_ATOM: NonNullable<AtomMotion['reducedMotion']> = {\n duration: 1,\n};\n\n/**\n * Creates an animation handle that controls multiple animations.\n * Is used to avoid leaking \"element\" references from the hook.\n *\n * @param animations\n */\nfunction createHandle(animations: Animation[]): AnimationHandle {\n return {\n set playbackRate(rate: number) {\n animations.forEach(animation => {\n animation.playbackRate = rate;\n });\n },\n setMotionEndCallbacks(onfinish: () => void, oncancel: () => void) {\n // Heads up!\n // This could use \"Animation:finished\", but it's causing a memory leak in Chromium.\n // See: https://issues.chromium.org/u/2/issues/383016426\n const promises = animations.map(animation => {\n return new Promise<void>((resolve, reject) => {\n animation.onfinish = () => resolve();\n animation.oncancel = () => reject();\n });\n });\n\n Promise.all(promises)\n .then(() => {\n onfinish();\n })\n .catch(() => {\n oncancel();\n });\n },\n isRunning() {\n return animations.some(animation => isAnimationRunning(animation));\n },\n\n dispose: () => {\n animations.length = 0;\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 reverse: () => {\n // Heads up!\n //\n // This is used for the interruptible motion. If the animation is running, we need to reverse it.\n //\n // TODO: what do with animations that have \"delay\"?\n // TODO: what do with animations that have different \"durations\"?\n\n animations.forEach(animation => {\n animation.reverse();\n });\n },\n };\n}\n\nfunction useAnimateAtomsInSupportedEnvironment() {\n // eslint-disable-next-line @nx/workspace-no-restricted-globals\n const SUPPORTS_PERSIST = typeof window !== 'undefined' && typeof window.Animation?.prototype.persist === 'function';\n\n return React.useCallback(\n (\n element: HTMLElement,\n value: AtomMotion | AtomMotion[],\n options: {\n isReducedMotion: boolean;\n },\n ): AnimationHandle => {\n const atoms = Array.isArray(value) ? value : [value];\n const { isReducedMotion } = options;\n\n const animations = atoms\n .map(motion => {\n // Grab the custom reduced motion definition if it exists, or fall back to the default reduced motion.\n const { keyframes: motionKeyframes, reducedMotion = DEFAULT_REDUCED_MOTION_ATOM, ...params } = motion;\n // Grab the reduced motion keyframes if they exist, or fall back to the regular keyframes.\n const { keyframes: reducedMotionKeyframes = motionKeyframes, ...reducedMotionParams } = reducedMotion;\n\n const animationKeyframes: Keyframe[] = isReducedMotion ? reducedMotionKeyframes : motionKeyframes;\n const animationParams: KeyframeEffectOptions = {\n ...DEFAULT_ANIMATION_OPTIONS,\n ...params,\n\n // Use reduced motion overrides (e.g. duration, easing) when reduced motion is enabled\n ...(isReducedMotion && reducedMotionParams),\n };\n\n try {\n // Firefox can throw an error when calling `element.animate()`.\n // See: https://github.com/microsoft/fluentui/issues/33902\n const animation = element.animate(animationKeyframes, animationParams);\n\n if (SUPPORTS_PERSIST) {\n // Chromium browsers can return null when calling `element.animate()`.\n // See: https://github.com/microsoft/fluentui/issues/33902\n animation?.persist();\n } else {\n const resultKeyframe = animationKeyframes[animationKeyframes.length - 1];\n Object.assign(element.style ?? {}, resultKeyframe);\n }\n\n return animation;\n } catch (e) {\n return null;\n }\n })\n .filter(animation => !!animation) as Animation[];\n\n return createHandle(animations);\n },\n [SUPPORTS_PERSIST],\n );\n}\n\n/**\n * In test environments, this hook is used to delay the execution of a callback until the next render. This is necessary\n * to ensure that the callback is not executed synchronously, which would cause the test to fail.\n *\n * @see https://github.com/microsoft/fluentui/issues/31701\n */\nfunction useAnimateAtomsInTestEnvironment() {\n const [count, setCount] = React.useState(0);\n const callbackRef = React.useRef<() => void>(undefined);\n\n const realAnimateAtoms = useAnimateAtomsInSupportedEnvironment();\n\n React.useEffect(() => {\n if (count > 0) {\n callbackRef.current?.();\n }\n }, [count]);\n\n return React.useCallback(\n (\n element: HTMLElement,\n value: AtomMotion | AtomMotion[],\n options: {\n isReducedMotion: boolean;\n },\n ): AnimationHandle => {\n const ELEMENT_SUPPORTS_WEB_ANIMATIONS = typeof element.animate === 'function';\n\n // Heads up!\n // If the environment supports Web Animations API, we can use the native implementation.\n if (ELEMENT_SUPPORTS_WEB_ANIMATIONS) {\n return realAnimateAtoms(element, value, options);\n }\n\n return {\n setMotionEndCallbacks(onfinish: () => void) {\n callbackRef.current = onfinish;\n setCount(v => v + 1);\n },\n\n set playbackRate(rate: number) {\n /* no-op */\n },\n isRunning() {\n return false;\n },\n\n dispose() {\n /* no-op */\n },\n\n cancel() {\n /* no-op */\n },\n pause() {\n /* no-op */\n },\n play() {\n /* no-op */\n },\n finish() {\n /* no-op */\n },\n reverse() {\n /* no-op */\n },\n };\n },\n [realAnimateAtoms],\n );\n}\n\n/**\n * @internal\n */\nexport function useAnimateAtoms(): (\n element: HTMLElement,\n value: AtomMotion | AtomMotion[],\n options: { isReducedMotion: boolean },\n) => AnimationHandle {\n if (process.env.NODE_ENV === 'test') {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return useAnimateAtomsInTestEnvironment();\n }\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return useAnimateAtomsInSupportedEnvironment();\n}\n"],"names":["React","isAnimationRunning","DEFAULT_ANIMATION_OPTIONS","fill","DEFAULT_REDUCED_MOTION_ATOM","duration","createHandle","animations","playbackRate","rate","forEach","animation","setMotionEndCallbacks","onfinish","oncancel","promises","map","Promise","resolve","reject","all","then","catch","isRunning","some","dispose","length","cancel","pause","play","finish","reverse","useAnimateAtomsInSupportedEnvironment","window","SUPPORTS_PERSIST","Animation","prototype","persist","useCallback","element","value","options","atoms","Array","isArray","isReducedMotion","motion","keyframes","motionKeyframes","reducedMotion","params","reducedMotionKeyframes","reducedMotionParams","animationKeyframes","animationParams","animate","resultKeyframe","Object","assign","style","e","filter","useAnimateAtomsInTestEnvironment","count","setCount","useState","callbackRef","useRef","undefined","realAnimateAtoms","useEffect","current","ELEMENT_SUPPORTS_WEB_ANIMATIONS","v","useAnimateAtoms","process","env","NODE_ENV"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAE/B,SAASC,kBAAkB,QAAQ,8BAA8B;AAGjE,OAAO,MAAMC,4BAAmD;IAC9DC,MAAM;AACR,EAAE;AAEF,oEAAoE;AACpE,6HAA6H;AAC7H,MAAMC,8BAAwE;IAC5EC,UAAU;AACZ;AAEA;;;;;CAKC,GACD,SAASC,aAAaC,UAAuB;IAC3C,OAAO;QACL,IAAIC,cAAaC,KAAc;YAC7BF,WAAWG,OAAO,CAACC,CAAAA;gBACjBA,UAAUH,YA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AG;gBACbG;aAAAA,uBAAAA,YAAYK,OAAO,cAAnBL,2CAAAA,0BAAAA;QACF;IACF,GAAG;QAACH;KAAM;IAEV,OAAO/D,MAAMsC,WAAW,CACtB,CACEC,SACAC,OACAC;QAIA,MAAM+B,kCAAkC,OAAOjC,QAAQgB,OAAO,KAAK;QAEnE,YAAY;QACZ,wFAAwF;QACxF,IAAIiB,iCAAiC;YACnC,OAAOH,iBAAiB9B,SAASC,OAAOC;QAC1C;QAEA,OAAO;YACL7B,uBAAsBC,QAAoB;gBACxCqD,YAAYK,OAAO,GAAG1D;gBACtBmD,SAASS,CAAAA,IAAKA,IAAI;YACpB;YAEA,IAAIjE,cAAaC,KAAc;YAC7B,SAAS,GACX;YACAc;gBACE,OAAO;YACT;YAEAE;YACE,SAAS,GACX;YAEAE;YACE,SAAS,GACX;YACAC;YACE,SAAS,GACX;YACAC;YACE,SAAS,GACX;YACAC;YACE,SAAS,GACX;YACAC;YACE,SAAS,GACX;QACF;IACF,GACA;QAACsC;KAAiB;AAEtB;AAEA;;CAEC,GACD,OAAO,SAASK;IAKd,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,QAAQ;QACnC,sDAAsD;QACtD,OAAOf;IACT;IAEA,sDAAsD;IACtD,OAAO9B;AACT"}
|
|
1
|
+
{"version":3,"sources":["../src/hooks/useAnimateAtoms.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\nimport { isAnimationRunning } from '../utils/isAnimationRunning';\nimport type { AnimationHandle, AtomMotion } from '../types';\n\nexport const DEFAULT_ANIMATION_OPTIONS: KeyframeEffectOptions = {\n fill: 'forwards',\n};\n\n// A motion atom's default reduced motion is a simple 1 ms duration.\n// But an atom can define a custom reduced motion, overriding keyframes and/or params like duration, easing, iterations, etc.\nconst DEFAULT_REDUCED_MOTION_ATOM: NonNullable<AtomMotion['reducedMotion']> = {\n duration: 1,\n};\n\n/**\n * Creates an animation handle that controls multiple animations.\n * Is used to avoid leaking \"element\" references from the hook.\n *\n * @param animations\n */\nfunction createHandle(animations: Animation[]): AnimationHandle {\n return {\n set playbackRate(rate: number) {\n animations.forEach(animation => {\n animation.playbackRate = rate;\n });\n },\n setMotionEndCallbacks(onfinish: () => void, oncancel: () => void) {\n // Heads up!\n // This could use \"Animation:finished\", but it's causing a memory leak in Chromium.\n // See: https://issues.chromium.org/u/2/issues/383016426\n const promises = animations.map(animation => {\n return new Promise<void>((resolve, reject) => {\n animation.onfinish = () => resolve();\n animation.oncancel = () => reject();\n });\n });\n\n Promise.all(promises)\n .then(() => {\n onfinish();\n })\n .catch(() => {\n oncancel();\n });\n },\n isRunning() {\n return animations.some(animation => isAnimationRunning(animation));\n },\n\n dispose: () => {\n animations.length = 0;\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 reverse: () => {\n // Heads up!\n //\n // This is used for the interruptible motion. If the animation is running, we need to reverse it.\n //\n // TODO: what do with animations that have \"delay\"?\n // TODO: what do with animations that have different \"durations\"?\n\n animations.forEach(animation => {\n animation.reverse();\n });\n },\n };\n}\n\nfunction useAnimateAtomsInSupportedEnvironment() {\n // eslint-disable-next-line @nx/workspace-no-restricted-globals\n const SUPPORTS_PERSIST = typeof window !== 'undefined' && typeof window.Animation?.prototype.persist === 'function';\n\n return React.useCallback(\n (\n element: HTMLElement,\n value: AtomMotion | AtomMotion[],\n options: {\n isReducedMotion: boolean;\n },\n ): AnimationHandle => {\n const atoms = Array.isArray(value) ? value : [value];\n const { isReducedMotion } = options;\n\n const animations = atoms\n .map(motion => {\n // Grab the custom reduced motion definition if it exists, or fall back to the default reduced motion.\n const { keyframes: motionKeyframes, reducedMotion = DEFAULT_REDUCED_MOTION_ATOM, ...params } = motion;\n // Grab the reduced motion keyframes if they exist, or fall back to the regular keyframes.\n const { keyframes: reducedMotionKeyframes = motionKeyframes, ...reducedMotionParams } = reducedMotion;\n\n const animationKeyframes: Keyframe[] = isReducedMotion ? reducedMotionKeyframes : motionKeyframes;\n const animationParams: KeyframeEffectOptions = {\n ...DEFAULT_ANIMATION_OPTIONS,\n ...params,\n\n // Use reduced motion overrides (e.g. duration, easing) when reduced motion is enabled\n ...(isReducedMotion && reducedMotionParams),\n };\n\n try {\n // Firefox can throw an error when calling `element.animate()`.\n // See: https://github.com/microsoft/fluentui/issues/33902\n const animation = element.animate(animationKeyframes, animationParams);\n\n if (SUPPORTS_PERSIST) {\n // Chromium browsers can return null when calling `element.animate()`.\n // See: https://github.com/microsoft/fluentui/issues/33902\n animation?.persist();\n } else {\n const resultKeyframe = animationKeyframes[animationKeyframes.length - 1];\n Object.assign(element.style ?? {}, resultKeyframe);\n }\n\n return animation;\n } catch (e) {\n return null;\n }\n })\n .filter(animation => !!animation) as Animation[];\n\n return createHandle(animations);\n },\n [SUPPORTS_PERSIST],\n );\n}\n\n/**\n * In test environments, this hook is used to delay the execution of a callback until the next render. This is necessary\n * to ensure that the callback is not executed synchronously, which would cause the test to fail.\n *\n * @see https://github.com/microsoft/fluentui/issues/31701\n */\nfunction useAnimateAtomsInTestEnvironment() {\n const [count, setCount] = React.useState(0);\n const callbackRef = React.useRef<() => void>(undefined);\n\n const realAnimateAtoms = useAnimateAtomsInSupportedEnvironment();\n\n React.useEffect(() => {\n if (count > 0) {\n callbackRef.current?.();\n }\n }, [count]);\n\n return React.useCallback(\n (\n element: HTMLElement,\n value: AtomMotion | AtomMotion[],\n options: {\n isReducedMotion: boolean;\n },\n ): AnimationHandle => {\n const ELEMENT_SUPPORTS_WEB_ANIMATIONS = typeof element.animate === 'function';\n\n // Heads up!\n // If the environment supports Web Animations API, we can use the native implementation.\n if (ELEMENT_SUPPORTS_WEB_ANIMATIONS) {\n return realAnimateAtoms(element, value, options);\n }\n\n return {\n setMotionEndCallbacks(onfinish: () => void) {\n callbackRef.current = onfinish;\n setCount(v => v + 1);\n },\n\n set playbackRate(rate: number) {\n /* no-op */\n },\n isRunning() {\n return false;\n },\n\n dispose() {\n /* no-op */\n },\n\n cancel() {\n /* no-op */\n },\n pause() {\n /* no-op */\n },\n play() {\n /* no-op */\n },\n finish() {\n /* no-op */\n },\n reverse() {\n /* no-op */\n },\n };\n },\n [realAnimateAtoms],\n );\n}\n\n/**\n * @internal\n */\nexport function useAnimateAtoms(): (\n element: HTMLElement,\n value: AtomMotion | AtomMotion[],\n options: { isReducedMotion: boolean },\n) => AnimationHandle {\n if (process.env.NODE_ENV === 'test') {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return useAnimateAtomsInTestEnvironment();\n }\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return useAnimateAtomsInSupportedEnvironment();\n}\n"],"names":["React","isAnimationRunning","DEFAULT_ANIMATION_OPTIONS","fill","DEFAULT_REDUCED_MOTION_ATOM","duration","createHandle","animations","playbackRate","rate","forEach","animation","setMotionEndCallbacks","onfinish","oncancel","promises","map","Promise","resolve","reject","all","then","catch","isRunning","some","dispose","length","cancel","pause","play","finish","reverse","useAnimateAtomsInSupportedEnvironment","window","SUPPORTS_PERSIST","Animation","prototype","persist","useCallback","element","value","options","atoms","Array","isArray","isReducedMotion","motion","keyframes","motionKeyframes","reducedMotion","params","reducedMotionKeyframes","reducedMotionParams","animationKeyframes","animationParams","animate","resultKeyframe","Object","assign","style","e","filter","useAnimateAtomsInTestEnvironment","count","setCount","useState","callbackRef","useRef","undefined","realAnimateAtoms","useEffect","current","ELEMENT_SUPPORTS_WEB_ANIMATIONS","v","useAnimateAtoms","process","env","NODE_ENV"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAE/B,SAASC,kBAAkB,QAAQ,iCAA8B;AAGjE,OAAO,MAAMC,4BAAmD;IAC9DC,MAAM;AACR,EAAE;AAEF,oEAAoE;AACpE,6HAA6H;AAC7H,MAAMC,8BAAwE;IAC5EC,UAAU;AACZ;AAEA;;;;;CA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;IACzC,MAAMC,cAAclE,MAAMmE,MAAM,CAAaC;IAE7C,MAAMC,mBAAmBrC;IAEzBhC,MAAMsE,SAAS,CAAC;QACd,IAAIP,QAAQ,GAAG;gBACbG;aAAAA,uBAAAA,YAAYK,OAAO,cAAnBL,2CAAAA,0BAAAA;QACF;IACF,GAAG;QAACH;KAAM;IAEV,OAAO/D,MAAMsC,WAAW,CACtB,CACEC,SACAC,OACAC;QAIA,MAAM+B,kCAAkC,OAAOjC,QAAQgB,OAAO,KAAK;QAEnE,YAAY;QACZ,wFAAwF;QACxF,IAAIiB,iCAAiC;YACnC,OAAOH,iBAAiB9B,SAASC,OAAOC;QAC1C;QAEA,OAAO;YACL7B,uBAAsBC,QAAoB;gBACxCqD,YAAYK,OAAO,GAAG1D;gBACtBmD,SAASS,CAAAA,IAAKA,IAAI;YACpB;YAEA,IAAIjE,cAAaC,KAAc;YAC7B,SAAS,GACX;YACAc;gBACE,OAAO;YACT;YAEAE;YACE,SAAS,GACX;YAEAE;YACE,SAAS,GACX;YACAC;YACE,SAAS,GACX;YACAC;YACE,SAAS,GACX;YACAC;YACE,SAAS,GACX;YACAC;YACE,SAAS,GACX;QACF;IACF,GACA;QAACsC;KAAiB;AAEtB;AAEA;;CAEC,GACD,OAAO,SAASK;IAKd,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,QAAQ;QACnC,sDAAsD;QACtD,OAAOf;IACT;IAEA,sDAAsD;IACtD,OAAO9B;AACT"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { useFluent_unstable as useFluent } from
|
|
3
|
-
import { useIsomorphicLayoutEffect } from
|
|
4
|
-
import * as React from
|
|
2
|
+
import { useFluent_unstable as useFluent } from "@fluentui/react-shared-contexts";
|
|
3
|
+
import { useIsomorphicLayoutEffect } from "@fluentui/react-utilities";
|
|
4
|
+
import * as React from "react";
|
|
5
5
|
const REDUCED_MEDIA_QUERY = 'screen and (prefers-reduced-motion: reduce)';
|
|
6
6
|
// TODO: find a better approach there as each hook creates a separate subscription
|
|
7
7
|
export function useIsReducedMotion() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { useForceUpdate } from
|
|
3
|
-
import * as React from
|
|
2
|
+
import { useForceUpdate } from "@fluentui/react-utilities";
|
|
3
|
+
import * as React from "react";
|
|
4
4
|
/**
|
|
5
5
|
* This hook manages the mounted state of a component, based on the "visible" and "unmountOnExit" props.
|
|
6
6
|
* It simulates the behavior of getDerivedStateFromProps(), which is not available in functional components.
|
package/lib/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { motionTokens, durations, curves } from
|
|
2
|
-
export { createMotionComponent } from
|
|
3
|
-
export { createMotionComponentVariant } from
|
|
4
|
-
export { createPresenceComponent } from
|
|
5
|
-
export { createPresenceComponentVariant } from
|
|
6
|
-
export { PresenceGroup } from
|
|
7
|
-
export { MotionRefForwarder, MotionRefForwarderReset, useMotionForwardedRef } from
|
|
8
|
-
export { motionSlot } from
|
|
9
|
-
export { presenceMotionSlot } from
|
|
10
|
-
export { PresenceGroupChildProvider, usePresenceGroupChildContext } from
|
|
11
|
-
export { MotionBehaviourProvider } from
|
|
1
|
+
export { motionTokens, durations, curves } from "./motions/motionTokens.js";
|
|
2
|
+
export { createMotionComponent } from "./factories/createMotionComponent.js";
|
|
3
|
+
export { createMotionComponentVariant } from "./factories/createMotionComponentVariant.js";
|
|
4
|
+
export { createPresenceComponent } from "./factories/createPresenceComponent.js";
|
|
5
|
+
export { createPresenceComponentVariant } from "./factories/createPresenceComponentVariant.js";
|
|
6
|
+
export { PresenceGroup } from "./components/PresenceGroup.js";
|
|
7
|
+
export { MotionRefForwarder, MotionRefForwarderReset, useMotionForwardedRef } from "./components/MotionRefForwarder.js";
|
|
8
|
+
export { motionSlot } from "./slots/motionSlot.js";
|
|
9
|
+
export { presenceMotionSlot } from "./slots/presenceMotionSlot.js";
|
|
10
|
+
export { PresenceGroupChildProvider, usePresenceGroupChildContext } from "./contexts/PresenceGroupChildContext.js";
|
|
11
|
+
export { MotionBehaviourProvider } from "./contexts/MotionBehaviourContext.js";
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { motionTokens, durations, curves } from './motions/motionTokens';\n\nexport {\n createMotionComponent,\n type MotionComponentProps,\n type MotionComponent,\n} from './factories/createMotionComponent';\nexport { createMotionComponentVariant } from './factories/createMotionComponentVariant';\nexport {\n createPresenceComponent,\n type PresenceComponentProps,\n type PresenceComponent,\n} from './factories/createPresenceComponent';\nexport { createPresenceComponentVariant } from './factories/createPresenceComponentVariant';\n\nexport { PresenceGroup } from './components/PresenceGroup';\nexport { MotionRefForwarder, MotionRefForwarderReset, useMotionForwardedRef } from './components/MotionRefForwarder';\n\nexport { motionSlot, type MotionSlotProps } from './slots/motionSlot';\nexport { presenceMotionSlot, type PresenceMotionSlotProps } from './slots/presenceMotionSlot';\n\nexport {\n PresenceGroupChildProvider,\n usePresenceGroupChildContext,\n type PresenceGroupChildContextValue,\n} from './contexts/PresenceGroupChildContext';\n\nexport type {\n AtomMotion,\n AtomMotionFn,\n PresenceMotion,\n PresenceMotionFn,\n PresenceDirection,\n MotionImperativeRef,\n MotionParam,\n} from './types';\n\nexport { MotionBehaviourProvider } from './contexts/MotionBehaviourContext';\n"],"names":["motionTokens","durations","curves","createMotionComponent","createMotionComponentVariant","createPresenceComponent","createPresenceComponentVariant","PresenceGroup","MotionRefForwarder","MotionRefForwarderReset","useMotionForwardedRef","motionSlot","presenceMotionSlot","PresenceGroupChildProvider","usePresenceGroupChildContext","MotionBehaviourProvider"],"mappings":"AAAA,SAASA,YAAY,EAAEC,SAAS,EAAEC,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { motionTokens, durations, curves } from './motions/motionTokens';\n\nexport {\n createMotionComponent,\n type MotionComponentProps,\n type MotionComponent,\n} from './factories/createMotionComponent';\nexport { createMotionComponentVariant } from './factories/createMotionComponentVariant';\nexport {\n createPresenceComponent,\n type PresenceComponentProps,\n type PresenceComponent,\n} from './factories/createPresenceComponent';\nexport { createPresenceComponentVariant } from './factories/createPresenceComponentVariant';\n\nexport { PresenceGroup } from './components/PresenceGroup';\nexport { MotionRefForwarder, MotionRefForwarderReset, useMotionForwardedRef } from './components/MotionRefForwarder';\n\nexport { motionSlot, type MotionSlotProps } from './slots/motionSlot';\nexport { presenceMotionSlot, type PresenceMotionSlotProps } from './slots/presenceMotionSlot';\n\nexport {\n PresenceGroupChildProvider,\n usePresenceGroupChildContext,\n type PresenceGroupChildContextValue,\n} from './contexts/PresenceGroupChildContext';\n\nexport type {\n AtomMotion,\n AtomMotionFn,\n PresenceMotion,\n PresenceMotionFn,\n PresenceDirection,\n MotionImperativeRef,\n MotionParam,\n} from './types';\n\nexport { MotionBehaviourProvider } from './contexts/MotionBehaviourContext';\n"],"names":["motionTokens","durations","curves","createMotionComponent","createMotionComponentVariant","createPresenceComponent","createPresenceComponentVariant","PresenceGroup","MotionRefForwarder","MotionRefForwarderReset","useMotionForwardedRef","motionSlot","presenceMotionSlot","PresenceGroupChildProvider","usePresenceGroupChildContext","MotionBehaviourProvider"],"mappings":"AAAA,SAASA,YAAY,EAAEC,SAAS,EAAEC,MAAM,QAAQ,4BAAyB;AAEzE,SACEC,qBAAqB,QAGhB,uCAAoC;AAC3C,SAASC,4BAA4B,QAAQ,8CAA2C;AACxF,SACEC,uBAAuB,QAGlB,yCAAsC;AAC7C,SAASC,8BAA8B,QAAQ,gDAA6C;AAE5F,SAASC,aAAa,QAAQ,gCAA6B;AAC3D,SAASC,kBAAkB,EAAEC,uBAAuB,EAAEC,qBAAqB,QAAQ,qCAAkC;AAErH,SAASC,UAAU,QAA8B,wBAAqB;AACtE,SAASC,kBAAkB,QAAsC,gCAA6B;AAE9F,SACEC,0BAA0B,EAC1BC,4BAA4B,QAEvB,0CAAuC;AAY9C,SAASC,uBAAuB,QAAQ,uCAAoC"}
|
package/lib/slots/motionSlot.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import { SLOT_ELEMENT_TYPE_SYMBOL, SLOT_RENDER_FUNCTION_SYMBOL } from
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { SLOT_ELEMENT_TYPE_SYMBOL, SLOT_RENDER_FUNCTION_SYMBOL } from "@fluentui/react-utilities";
|
|
3
3
|
export function motionSlot(motion, options) {
|
|
4
4
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
5
5
|
const { as, children, ...rest } = motion !== null && motion !== void 0 ? motion : {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import { SLOT_ELEMENT_TYPE_SYMBOL, SLOT_RENDER_FUNCTION_SYMBOL } from
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { SLOT_ELEMENT_TYPE_SYMBOL, SLOT_RENDER_FUNCTION_SYMBOL } from "@fluentui/react-utilities";
|
|
3
3
|
export function presenceMotionSlot(motion, options) {
|
|
4
4
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
5
5
|
const { as, children, ...rest } = motion !== null && motion !== void 0 ? motion : {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mergeChildMappings } from
|
|
1
|
+
import { mergeChildMappings } from "./mergeChildMappings.js";
|
|
2
2
|
export function getNextChildMapping(prevChildMapping, nextChildMapping) {
|
|
3
3
|
const childrenMapping = mergeChildMappings(prevChildMapping, nextChildMapping);
|
|
4
4
|
Object.entries(childrenMapping).forEach(([key, childDefinition])=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/groups/getNextChildMapping.ts"],"sourcesContent":["import { mergeChildMappings } from './mergeChildMappings';\nimport type { PresenceGroupChildMapping } from './types';\n\nexport function getNextChildMapping(\n prevChildMapping: PresenceGroupChildMapping,\n nextChildMapping: PresenceGroupChildMapping,\n): PresenceGroupChildMapping {\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,
|
|
1
|
+
{"version":3,"sources":["../src/utils/groups/getNextChildMapping.ts"],"sourcesContent":["import { mergeChildMappings } from './mergeChildMappings';\nimport type { PresenceGroupChildMapping } from './types';\n\nexport function getNextChildMapping(\n prevChildMapping: PresenceGroupChildMapping,\n nextChildMapping: PresenceGroupChildMapping,\n): PresenceGroupChildMapping {\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,0BAAuB;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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import * as React from
|
|
3
|
-
import { getReactElementRef, useMergedRefs } from
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { getReactElementRef, useMergedRefs } from "@fluentui/react-utilities";
|
|
4
4
|
const CHILD_ERROR_MESSAGE = [
|
|
5
5
|
'@fluentui/react-motion: Invalid child element.',
|
|
6
6
|
'\n',
|
|
@@ -12,9 +12,9 @@ Object.defineProperty(exports, "PresenceGroup", {
|
|
|
12
12
|
const _define_property = require("@swc/helpers/_/_define_property");
|
|
13
13
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
14
14
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
15
|
-
const _getNextChildMapping = require("../utils/groups/getNextChildMapping");
|
|
16
|
-
const _getChildMapping = require("../utils/groups/getChildMapping");
|
|
17
|
-
const _PresenceGroupItemProvider = require("./PresenceGroupItemProvider");
|
|
15
|
+
const _getNextChildMapping = require("../utils/groups/getNextChildMapping.cjs");
|
|
16
|
+
const _getChildMapping = require("../utils/groups/getChildMapping.cjs");
|
|
17
|
+
const _PresenceGroupItemProvider = require("./PresenceGroupItemProvider.cjs");
|
|
18
18
|
class PresenceGroup extends _react.Component {
|
|
19
19
|
static getDerivedStateFromProps(nextProps, { childMapping: prevChildMapping, firstRender }) {
|
|
20
20
|
const nextChildMapping = (0, _getChildMapping.getChildMapping)(nextProps.children);
|
package/lib-commonjs/components/{PresenceGroupItemProvider.js → PresenceGroupItemProvider.cjs}
RENAMED
|
@@ -11,7 +11,7 @@ Object.defineProperty(exports, "PresenceGroupItemProvider", {
|
|
|
11
11
|
});
|
|
12
12
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
13
13
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
14
|
-
const _PresenceGroupChildContext = require("../contexts/PresenceGroupChildContext");
|
|
14
|
+
const _PresenceGroupChildContext = require("../contexts/PresenceGroupChildContext.cjs");
|
|
15
15
|
const PresenceGroupItemProvider = (props)=>{
|
|
16
16
|
const { appear, childKey, onExit, visible, unmountOnExit } = props;
|
|
17
17
|
const contextValue = _react.useMemo(()=>({
|
|
@@ -20,11 +20,11 @@ _export(exports, {
|
|
|
20
20
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
21
21
|
const _reactutilities = require("@fluentui/react-utilities");
|
|
22
22
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
23
|
-
const _useAnimateAtoms = require("../hooks/useAnimateAtoms");
|
|
24
|
-
const _useMotionImperativeRef = require("../hooks/useMotionImperativeRef");
|
|
25
|
-
const _useIsReducedMotion = require("../hooks/useIsReducedMotion");
|
|
26
|
-
const _useChildElement = require("../utils/useChildElement");
|
|
27
|
-
const _MotionBehaviourContext = require("../contexts/MotionBehaviourContext");
|
|
23
|
+
const _useAnimateAtoms = require("../hooks/useAnimateAtoms.cjs");
|
|
24
|
+
const _useMotionImperativeRef = require("../hooks/useMotionImperativeRef.cjs");
|
|
25
|
+
const _useIsReducedMotion = require("../hooks/useIsReducedMotion.cjs");
|
|
26
|
+
const _useChildElement = require("../utils/useChildElement.cjs");
|
|
27
|
+
const _MotionBehaviourContext = require("../contexts/MotionBehaviourContext.cjs");
|
|
28
28
|
const MOTION_DEFINITION = Symbol('MOTION_DEFINITION');
|
|
29
29
|
function createMotionComponent(value) {
|
|
30
30
|
const Atom = (props)=>{
|
package/lib-commonjs/factories/{createMotionComponentVariant.js → createMotionComponentVariant.cjs}
RENAMED
|
@@ -16,7 +16,7 @@ _export(exports, {
|
|
|
16
16
|
return createMotionFnVariant;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
-
const _createMotionComponent = require("./createMotionComponent");
|
|
19
|
+
const _createMotionComponent = require("./createMotionComponent.cjs");
|
|
20
20
|
function createMotionFnVariant(motionFn, variantParams) {
|
|
21
21
|
const variantFn = (runtimeParams)=>motionFn({
|
|
22
22
|
...variantParams,
|
|
@@ -20,14 +20,14 @@ _export(exports, {
|
|
|
20
20
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
21
21
|
const _reactutilities = require("@fluentui/react-utilities");
|
|
22
22
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
23
|
-
const _PresenceGroupChildContext = require("../contexts/PresenceGroupChildContext");
|
|
24
|
-
const _useAnimateAtoms = require("../hooks/useAnimateAtoms");
|
|
25
|
-
const _useMotionImperativeRef = require("../hooks/useMotionImperativeRef");
|
|
26
|
-
const _useMountedState = require("../hooks/useMountedState");
|
|
27
|
-
const _useIsReducedMotion = require("../hooks/useIsReducedMotion");
|
|
28
|
-
const _useChildElement = require("../utils/useChildElement");
|
|
29
|
-
const _MotionBehaviourContext = require("../contexts/MotionBehaviourContext");
|
|
30
|
-
const _createMotionComponent = require("./createMotionComponent");
|
|
23
|
+
const _PresenceGroupChildContext = require("../contexts/PresenceGroupChildContext.cjs");
|
|
24
|
+
const _useAnimateAtoms = require("../hooks/useAnimateAtoms.cjs");
|
|
25
|
+
const _useMotionImperativeRef = require("../hooks/useMotionImperativeRef.cjs");
|
|
26
|
+
const _useMountedState = require("../hooks/useMountedState.cjs");
|
|
27
|
+
const _useIsReducedMotion = require("../hooks/useIsReducedMotion.cjs");
|
|
28
|
+
const _useChildElement = require("../utils/useChildElement.cjs");
|
|
29
|
+
const _MotionBehaviourContext = require("../contexts/MotionBehaviourContext.cjs");
|
|
30
|
+
const _createMotionComponent = require("./createMotionComponent.cjs");
|
|
31
31
|
const PRESENCE_MOTION_DEFINITION = Symbol('PRESENCE_MOTION_DEFINITION');
|
|
32
32
|
const INTERRUPTABLE_MOTION_SYMBOL = Symbol.for('interruptablePresence');
|
|
33
33
|
function createPresenceComponent(value) {
|
|
@@ -16,7 +16,7 @@ _export(exports, {
|
|
|
16
16
|
return createPresenceFnVariant;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
-
const _createPresenceComponent = require("./createPresenceComponent");
|
|
19
|
+
const _createPresenceComponent = require("./createPresenceComponent.cjs");
|
|
20
20
|
function createPresenceFnVariant(presenceFn, variantParams) {
|
|
21
21
|
const variantFn = (runtimeParams)=>presenceFn({
|
|
22
22
|
...variantParams,
|
|
@@ -19,7 +19,7 @@ _export(exports, {
|
|
|
19
19
|
});
|
|
20
20
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
21
21
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
22
|
-
const _isAnimationRunning = require("../utils/isAnimationRunning");
|
|
22
|
+
const _isAnimationRunning = require("../utils/isAnimationRunning.cjs");
|
|
23
23
|
const DEFAULT_ANIMATION_OPTIONS = {
|
|
24
24
|
fill: 'forwards'
|
|
25
25
|
};
|
|
@@ -58,14 +58,14 @@ _export(exports, {
|
|
|
58
58
|
return _PresenceGroupChildContext.usePresenceGroupChildContext;
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
|
-
const _motionTokens = require("./motions/motionTokens");
|
|
62
|
-
const _createMotionComponent = require("./factories/createMotionComponent");
|
|
63
|
-
const _createMotionComponentVariant = require("./factories/createMotionComponentVariant");
|
|
64
|
-
const _createPresenceComponent = require("./factories/createPresenceComponent");
|
|
65
|
-
const _createPresenceComponentVariant = require("./factories/createPresenceComponentVariant");
|
|
66
|
-
const _PresenceGroup = require("./components/PresenceGroup");
|
|
67
|
-
const _MotionRefForwarder = require("./components/MotionRefForwarder");
|
|
68
|
-
const _motionSlot = require("./slots/motionSlot");
|
|
69
|
-
const _presenceMotionSlot = require("./slots/presenceMotionSlot");
|
|
70
|
-
const _PresenceGroupChildContext = require("./contexts/PresenceGroupChildContext");
|
|
71
|
-
const _MotionBehaviourContext = require("./contexts/MotionBehaviourContext");
|
|
61
|
+
const _motionTokens = require("./motions/motionTokens.cjs");
|
|
62
|
+
const _createMotionComponent = require("./factories/createMotionComponent.cjs");
|
|
63
|
+
const _createMotionComponentVariant = require("./factories/createMotionComponentVariant.cjs");
|
|
64
|
+
const _createPresenceComponent = require("./factories/createPresenceComponent.cjs");
|
|
65
|
+
const _createPresenceComponentVariant = require("./factories/createPresenceComponentVariant.cjs");
|
|
66
|
+
const _PresenceGroup = require("./components/PresenceGroup.cjs");
|
|
67
|
+
const _MotionRefForwarder = require("./components/MotionRefForwarder.cjs");
|
|
68
|
+
const _motionSlot = require("./slots/motionSlot.cjs");
|
|
69
|
+
const _presenceMotionSlot = require("./slots/presenceMotionSlot.cjs");
|
|
70
|
+
const _PresenceGroupChildContext = require("./contexts/PresenceGroupChildContext.cjs");
|
|
71
|
+
const _MotionBehaviourContext = require("./contexts/MotionBehaviourContext.cjs");
|
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "getNextChildMapping", {
|
|
|
8
8
|
return getNextChildMapping;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _mergeChildMappings = require("./mergeChildMappings");
|
|
11
|
+
const _mergeChildMappings = require("./mergeChildMappings.cjs");
|
|
12
12
|
function getNextChildMapping(prevChildMapping, nextChildMapping) {
|
|
13
13
|
const childrenMapping = (0, _mergeChildMappings.mergeChildMappings)(prevChildMapping, nextChildMapping);
|
|
14
14
|
Object.entries(childrenMapping).forEach(([key, childDefinition])=>{
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui/react-motion",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.74.3-experimental.esm.20260709-49ee7a20cf.0",
|
|
4
4
|
"description": "A package with utilities & motion definitions using Web Animations API",
|
|
5
|
-
"main": "lib-commonjs/index.
|
|
5
|
+
"main": "lib-commonjs/index.cjs",
|
|
6
6
|
"module": "lib/index.js",
|
|
7
7
|
"typings": "./dist/index.d.ts",
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"files": [
|
|
10
10
|
"*.md",
|
|
11
11
|
"dist/*.d.ts",
|
|
12
|
+
"dist/*.d.cts",
|
|
12
13
|
"lib",
|
|
13
14
|
"lib-commonjs"
|
|
14
15
|
],
|
|
@@ -18,8 +19,8 @@
|
|
|
18
19
|
},
|
|
19
20
|
"license": "MIT",
|
|
20
21
|
"dependencies": {
|
|
21
|
-
"@fluentui/react-shared-contexts": "
|
|
22
|
-
"@fluentui/react-utilities": "
|
|
22
|
+
"@fluentui/react-shared-contexts": "9.74.3-experimental.esm.20260709-49ee7a20cf.0",
|
|
23
|
+
"@fluentui/react-utilities": "9.74.3-experimental.esm.20260709-49ee7a20cf.0",
|
|
23
24
|
"@swc/helpers": "^0.5.1"
|
|
24
25
|
},
|
|
25
26
|
"peerDependencies": {
|
|
@@ -30,17 +31,17 @@
|
|
|
30
31
|
},
|
|
31
32
|
"exports": {
|
|
32
33
|
".": {
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
"import": {
|
|
35
|
+
"types": "./dist/index.d.ts",
|
|
36
|
+
"default": "./lib/index.js"
|
|
37
|
+
},
|
|
38
|
+
"require": {
|
|
39
|
+
"types": "./dist/index.d.cts",
|
|
40
|
+
"default": "./lib-commonjs/index.cjs"
|
|
41
|
+
}
|
|
37
42
|
},
|
|
38
43
|
"./package.json": "./package.json"
|
|
39
44
|
},
|
|
40
|
-
"beachball": {
|
|
41
|
-
|
|
42
|
-
"major",
|
|
43
|
-
"prerelease"
|
|
44
|
-
]
|
|
45
|
-
}
|
|
45
|
+
"beachball": {},
|
|
46
|
+
"type": "module"
|
|
46
47
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/lib-commonjs/contexts/{MotionBehaviourContext.js.map → MotionBehaviourContext.cjs.map}
RENAMED
|
File without changes
|
/package/lib-commonjs/contexts/{PresenceGroupChildContext.js → PresenceGroupChildContext.cjs}
RENAMED
|
File without changes
|
|
File without changes
|
/package/lib-commonjs/factories/{createMotionComponent.js.map → createMotionComponent.cjs.map}
RENAMED
|
File without changes
|
|
File without changes
|
/package/lib-commonjs/factories/{createPresenceComponent.js.map → createPresenceComponent.cjs.map}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/lib-commonjs/hooks/{useMotionImperativeRef.js.map → useMotionImperativeRef.cjs.map}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/lib-commonjs/utils/groups/{getNextChildMapping.js.map → getNextChildMapping.cjs.map}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|