first commit
This commit is contained in:
23
node_modules/framer-motion/dist/es/utils/delay.mjs
generated
vendored
Normal file
23
node_modules/framer-motion/dist/es/utils/delay.mjs
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import { time, frame, cancelFrame } from 'motion-dom';
|
||||
import { secondsToMilliseconds } from 'motion-utils';
|
||||
|
||||
/**
|
||||
* Timeout defined in ms
|
||||
*/
|
||||
function delay(callback, timeout) {
|
||||
const start = time.now();
|
||||
const checkElapsed = ({ timestamp }) => {
|
||||
const elapsed = timestamp - start;
|
||||
if (elapsed >= timeout) {
|
||||
cancelFrame(checkElapsed);
|
||||
callback(elapsed - timeout);
|
||||
}
|
||||
};
|
||||
frame.setup(checkElapsed, true);
|
||||
return () => cancelFrame(checkElapsed);
|
||||
}
|
||||
function delayInSeconds(callback, timeout) {
|
||||
return delay(callback, secondsToMilliseconds(timeout));
|
||||
}
|
||||
|
||||
export { delay, delayInSeconds };
|
||||
9
node_modules/framer-motion/dist/es/utils/distance.mjs
generated
vendored
Normal file
9
node_modules/framer-motion/dist/es/utils/distance.mjs
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
const distance = (a, b) => Math.abs(a - b);
|
||||
function distance2D(a, b) {
|
||||
// Multi-dimensional
|
||||
const xDelta = distance(a.x, b.x);
|
||||
const yDelta = distance(a.y, b.y);
|
||||
return Math.sqrt(xDelta ** 2 + yDelta ** 2);
|
||||
}
|
||||
|
||||
export { distance, distance2D };
|
||||
6
node_modules/framer-motion/dist/es/utils/get-context-window.mjs
generated
vendored
Normal file
6
node_modules/framer-motion/dist/es/utils/get-context-window.mjs
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
// Fixes https://github.com/motiondivision/motion/issues/2270
|
||||
const getContextWindow = ({ current }) => {
|
||||
return current ? current.ownerDocument.defaultView : null;
|
||||
};
|
||||
|
||||
export { getContextWindow };
|
||||
3
node_modules/framer-motion/dist/es/utils/is-browser.mjs
generated
vendored
Normal file
3
node_modules/framer-motion/dist/es/utils/is-browser.mjs
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
const isBrowser = typeof window !== "undefined";
|
||||
|
||||
export { isBrowser };
|
||||
7
node_modules/framer-motion/dist/es/utils/is-ref-object.mjs
generated
vendored
Normal file
7
node_modules/framer-motion/dist/es/utils/is-ref-object.mjs
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
function isRefObject(ref) {
|
||||
return (ref &&
|
||||
typeof ref === "object" &&
|
||||
Object.prototype.hasOwnProperty.call(ref, "current"));
|
||||
}
|
||||
|
||||
export { isRefObject };
|
||||
19
node_modules/framer-motion/dist/es/utils/reduced-motion/index.mjs
generated
vendored
Normal file
19
node_modules/framer-motion/dist/es/utils/reduced-motion/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import { isBrowser } from '../is-browser.mjs';
|
||||
import { hasReducedMotionListener, prefersReducedMotion } from './state.mjs';
|
||||
|
||||
function initPrefersReducedMotion() {
|
||||
hasReducedMotionListener.current = true;
|
||||
if (!isBrowser)
|
||||
return;
|
||||
if (window.matchMedia) {
|
||||
const motionMediaQuery = window.matchMedia("(prefers-reduced-motion)");
|
||||
const setReducedMotionPreferences = () => (prefersReducedMotion.current = motionMediaQuery.matches);
|
||||
motionMediaQuery.addEventListener("change", setReducedMotionPreferences);
|
||||
setReducedMotionPreferences();
|
||||
}
|
||||
else {
|
||||
prefersReducedMotion.current = false;
|
||||
}
|
||||
}
|
||||
|
||||
export { initPrefersReducedMotion };
|
||||
5
node_modules/framer-motion/dist/es/utils/reduced-motion/state.mjs
generated
vendored
Normal file
5
node_modules/framer-motion/dist/es/utils/reduced-motion/state.mjs
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
// Does this device prefer reduced motion? Returns `null` server-side.
|
||||
const prefersReducedMotion = { current: null };
|
||||
const hasReducedMotionListener = { current: false };
|
||||
|
||||
export { hasReducedMotionListener, prefersReducedMotion };
|
||||
20
node_modules/framer-motion/dist/es/utils/reduced-motion/use-reduced-motion-config.mjs
generated
vendored
Normal file
20
node_modules/framer-motion/dist/es/utils/reduced-motion/use-reduced-motion-config.mjs
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use client";
|
||||
import { useContext } from 'react';
|
||||
import { MotionConfigContext } from '../../context/MotionConfigContext.mjs';
|
||||
import { useReducedMotion } from './use-reduced-motion.mjs';
|
||||
|
||||
function useReducedMotionConfig() {
|
||||
const reducedMotionPreference = useReducedMotion();
|
||||
const { reducedMotion } = useContext(MotionConfigContext);
|
||||
if (reducedMotion === "never") {
|
||||
return false;
|
||||
}
|
||||
else if (reducedMotion === "always") {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return reducedMotionPreference;
|
||||
}
|
||||
}
|
||||
|
||||
export { useReducedMotionConfig };
|
||||
48
node_modules/framer-motion/dist/es/utils/reduced-motion/use-reduced-motion.mjs
generated
vendored
Normal file
48
node_modules/framer-motion/dist/es/utils/reduced-motion/use-reduced-motion.mjs
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
"use client";
|
||||
import { warnOnce } from 'motion-utils';
|
||||
import { useState } from 'react';
|
||||
import { initPrefersReducedMotion } from './index.mjs';
|
||||
import { hasReducedMotionListener, prefersReducedMotion } from './state.mjs';
|
||||
|
||||
/**
|
||||
* A hook that returns `true` if we should be using reduced motion based on the current device's Reduced Motion setting.
|
||||
*
|
||||
* This can be used to implement changes to your UI based on Reduced Motion. For instance, replacing motion-sickness inducing
|
||||
* `x`/`y` animations with `opacity`, disabling the autoplay of background videos, or turning off parallax motion.
|
||||
*
|
||||
* It will actively respond to changes and re-render your components with the latest setting.
|
||||
*
|
||||
* ```jsx
|
||||
* export function Sidebar({ isOpen }) {
|
||||
* const shouldReduceMotion = useReducedMotion()
|
||||
* const closedX = shouldReduceMotion ? 0 : "-100%"
|
||||
*
|
||||
* return (
|
||||
* <motion.div animate={{
|
||||
* opacity: isOpen ? 1 : 0,
|
||||
* x: isOpen ? 0 : closedX
|
||||
* }} />
|
||||
* )
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
function useReducedMotion() {
|
||||
/**
|
||||
* Lazy initialisation of prefersReducedMotion
|
||||
*/
|
||||
!hasReducedMotionListener.current && initPrefersReducedMotion();
|
||||
const [shouldReduceMotion] = useState(prefersReducedMotion.current);
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
warnOnce(shouldReduceMotion !== true, "You have Reduced Motion enabled on your device. Animations may not appear as expected.", "reduced-motion-disabled");
|
||||
}
|
||||
/**
|
||||
* TODO See if people miss automatically updating shouldReduceMotion setting
|
||||
*/
|
||||
return shouldReduceMotion;
|
||||
}
|
||||
|
||||
export { useReducedMotion };
|
||||
14
node_modules/framer-motion/dist/es/utils/shallow-compare.mjs
generated
vendored
Normal file
14
node_modules/framer-motion/dist/es/utils/shallow-compare.mjs
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
function shallowCompare(next, prev) {
|
||||
if (!Array.isArray(prev))
|
||||
return false;
|
||||
const prevLength = prev.length;
|
||||
if (prevLength !== next.length)
|
||||
return false;
|
||||
for (let i = 0; i < prevLength; i++) {
|
||||
if (prev[i] !== next[i])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
export { shallowCompare };
|
||||
22
node_modules/framer-motion/dist/es/utils/use-animation-frame.mjs
generated
vendored
Normal file
22
node_modules/framer-motion/dist/es/utils/use-animation-frame.mjs
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
"use client";
|
||||
import { frame, cancelFrame } from 'motion-dom';
|
||||
import { useRef, useContext, useEffect } from 'react';
|
||||
import { MotionConfigContext } from '../context/MotionConfigContext.mjs';
|
||||
|
||||
function useAnimationFrame(callback) {
|
||||
const initialTimestamp = useRef(0);
|
||||
const { isStatic } = useContext(MotionConfigContext);
|
||||
useEffect(() => {
|
||||
if (isStatic)
|
||||
return;
|
||||
const provideTimeSinceStart = ({ timestamp, delta }) => {
|
||||
if (!initialTimestamp.current)
|
||||
initialTimestamp.current = timestamp;
|
||||
callback(timestamp - initialTimestamp.current, delta);
|
||||
};
|
||||
frame.update(provideTimeSinceStart, true);
|
||||
return () => cancelFrame(provideTimeSinceStart);
|
||||
}, [callback]);
|
||||
}
|
||||
|
||||
export { useAnimationFrame };
|
||||
60
node_modules/framer-motion/dist/es/utils/use-composed-ref.mjs
generated
vendored
Normal file
60
node_modules/framer-motion/dist/es/utils/use-composed-ref.mjs
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
import * as React from 'react';
|
||||
|
||||
/**
|
||||
* Taken from https://github.com/radix-ui/primitives/blob/main/packages/react/compose-refs/src/compose-refs.tsx
|
||||
*/
|
||||
/**
|
||||
* Set a given ref to a given value
|
||||
* This utility takes care of different types of refs: callback refs and RefObject(s)
|
||||
*/
|
||||
function setRef(ref, value) {
|
||||
if (typeof ref === "function") {
|
||||
return ref(value);
|
||||
}
|
||||
else if (ref !== null && ref !== undefined) {
|
||||
ref.current = value;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A utility to compose multiple refs together
|
||||
* Accepts callback refs and RefObject(s)
|
||||
*/
|
||||
function composeRefs(...refs) {
|
||||
return (node) => {
|
||||
let hasCleanup = false;
|
||||
const cleanups = refs.map((ref) => {
|
||||
const cleanup = setRef(ref, node);
|
||||
if (!hasCleanup && typeof cleanup === "function") {
|
||||
hasCleanup = true;
|
||||
}
|
||||
return cleanup;
|
||||
});
|
||||
// React <19 will log an error to the console if a callback ref returns a
|
||||
// value. We don't use ref cleanups internally so this will only happen if a
|
||||
// user's ref callback returns a value, which we only expect if they are
|
||||
// using the cleanup functionality added in React 19.
|
||||
if (hasCleanup) {
|
||||
return () => {
|
||||
for (let i = 0; i < cleanups.length; i++) {
|
||||
const cleanup = cleanups[i];
|
||||
if (typeof cleanup === "function") {
|
||||
cleanup();
|
||||
}
|
||||
else {
|
||||
setRef(refs[i], null);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* A custom hook that composes multiple refs
|
||||
* Accepts callback refs and RefObject(s)
|
||||
*/
|
||||
function useComposedRefs(...refs) {
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
return React.useCallback(composeRefs(...refs), refs);
|
||||
}
|
||||
|
||||
export { useComposedRefs };
|
||||
19
node_modules/framer-motion/dist/es/utils/use-constant.mjs
generated
vendored
Normal file
19
node_modules/framer-motion/dist/es/utils/use-constant.mjs
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
"use client";
|
||||
import { useRef } from 'react';
|
||||
|
||||
/**
|
||||
* Creates a constant value over the lifecycle of a component.
|
||||
*
|
||||
* Even if `useMemo` is provided an empty array as its final argument, it doesn't offer
|
||||
* a guarantee that it won't re-run for performance reasons later on. By using `useConstant`
|
||||
* you can ensure that initialisers don't execute twice or more.
|
||||
*/
|
||||
function useConstant(init) {
|
||||
const ref = useRef(null);
|
||||
if (ref.current === null) {
|
||||
ref.current = init();
|
||||
}
|
||||
return ref.current;
|
||||
}
|
||||
|
||||
export { useConstant };
|
||||
48
node_modules/framer-motion/dist/es/utils/use-cycle.mjs
generated
vendored
Normal file
48
node_modules/framer-motion/dist/es/utils/use-cycle.mjs
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
"use client";
|
||||
import { wrap } from 'motion-utils';
|
||||
import { useRef, useState, useCallback } from 'react';
|
||||
|
||||
/**
|
||||
* Cycles through a series of visual properties. Can be used to toggle between or cycle through animations. It works similar to `useState` in React. It is provided an initial array of possible states, and returns an array of two arguments.
|
||||
*
|
||||
* An index value can be passed to the returned `cycle` function to cycle to a specific index.
|
||||
*
|
||||
* ```jsx
|
||||
* import * as React from "react"
|
||||
* import { motion, useCycle } from "framer-motion"
|
||||
*
|
||||
* export const MyComponent = () => {
|
||||
* const [x, cycleX] = useCycle(0, 50, 100)
|
||||
*
|
||||
* return (
|
||||
* <motion.div
|
||||
* animate={{ x: x }}
|
||||
* onTap={() => cycleX()}
|
||||
* />
|
||||
* )
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @param items - items to cycle through
|
||||
* @returns [currentState, cycleState]
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
function useCycle(...items) {
|
||||
const index = useRef(0);
|
||||
const [item, setItem] = useState(items[index.current]);
|
||||
const runCycle = useCallback((next) => {
|
||||
index.current =
|
||||
typeof next !== "number"
|
||||
? wrap(0, items.length, index.current + 1)
|
||||
: next;
|
||||
setItem(items[index.current]);
|
||||
},
|
||||
// The array will change on each call, but by putting items.length at
|
||||
// the front of this array, we guarantee the dependency comparison will match up
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
[items.length, ...items]);
|
||||
return [item, runCycle];
|
||||
}
|
||||
|
||||
export { useCycle };
|
||||
20
node_modules/framer-motion/dist/es/utils/use-force-update.mjs
generated
vendored
Normal file
20
node_modules/framer-motion/dist/es/utils/use-force-update.mjs
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use client";
|
||||
import { frame } from 'motion-dom';
|
||||
import { useState, useCallback } from 'react';
|
||||
import { useIsMounted } from './use-is-mounted.mjs';
|
||||
|
||||
function useForceUpdate() {
|
||||
const isMounted = useIsMounted();
|
||||
const [forcedRenderCount, setForcedRenderCount] = useState(0);
|
||||
const forceRender = useCallback(() => {
|
||||
isMounted.current && setForcedRenderCount(forcedRenderCount + 1);
|
||||
}, [forcedRenderCount]);
|
||||
/**
|
||||
* Defer this to the end of the next animation frame in case there are multiple
|
||||
* synchronous calls.
|
||||
*/
|
||||
const deferredForceRender = useCallback(() => frame.postRender(forceRender), [forceRender]);
|
||||
return [deferredForceRender, forcedRenderCount];
|
||||
}
|
||||
|
||||
export { useForceUpdate };
|
||||
24
node_modules/framer-motion/dist/es/utils/use-in-view.mjs
generated
vendored
Normal file
24
node_modules/framer-motion/dist/es/utils/use-in-view.mjs
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
"use client";
|
||||
import { useState, useEffect } from 'react';
|
||||
import { inView } from '../render/dom/viewport/index.mjs';
|
||||
|
||||
function useInView(ref, { root, margin, amount, once = false, initial = false, } = {}) {
|
||||
const [isInView, setInView] = useState(initial);
|
||||
useEffect(() => {
|
||||
if (!ref.current || (once && isInView))
|
||||
return;
|
||||
const onEnter = () => {
|
||||
setInView(true);
|
||||
return once ? undefined : () => setInView(false);
|
||||
};
|
||||
const options = {
|
||||
root: (root && root.current) || undefined,
|
||||
margin,
|
||||
amount,
|
||||
};
|
||||
return inView(ref.current, onEnter, options);
|
||||
}, [root, ref, margin, once, amount]);
|
||||
return isInView;
|
||||
}
|
||||
|
||||
export { useInView };
|
||||
42
node_modules/framer-motion/dist/es/utils/use-instant-transition.mjs
generated
vendored
Normal file
42
node_modules/framer-motion/dist/es/utils/use-instant-transition.mjs
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
"use client";
|
||||
import { frame } from 'motion-dom';
|
||||
import { MotionGlobalConfig } from 'motion-utils';
|
||||
import { useRef, useEffect } from 'react';
|
||||
import { useInstantLayoutTransition } from '../projection/use-instant-layout-transition.mjs';
|
||||
import { useForceUpdate } from './use-force-update.mjs';
|
||||
|
||||
function useInstantTransition() {
|
||||
const [forceUpdate, forcedRenderCount] = useForceUpdate();
|
||||
const startInstantLayoutTransition = useInstantLayoutTransition();
|
||||
const unlockOnFrameRef = useRef(-1);
|
||||
useEffect(() => {
|
||||
/**
|
||||
* Unblock after two animation frames, otherwise this will unblock too soon.
|
||||
*/
|
||||
frame.postRender(() => frame.postRender(() => {
|
||||
/**
|
||||
* If the callback has been called again after the effect
|
||||
* triggered this 2 frame delay, don't unblock animations. This
|
||||
* prevents the previous effect from unblocking the current
|
||||
* instant transition too soon. This becomes more likely when
|
||||
* used in conjunction with React.startTransition().
|
||||
*/
|
||||
if (forcedRenderCount !== unlockOnFrameRef.current)
|
||||
return;
|
||||
MotionGlobalConfig.instantAnimations = false;
|
||||
}));
|
||||
}, [forcedRenderCount]);
|
||||
return (callback) => {
|
||||
startInstantLayoutTransition(() => {
|
||||
MotionGlobalConfig.instantAnimations = true;
|
||||
forceUpdate();
|
||||
callback();
|
||||
unlockOnFrameRef.current = forcedRenderCount + 1;
|
||||
});
|
||||
};
|
||||
}
|
||||
function disableInstantTransitions() {
|
||||
MotionGlobalConfig.instantAnimations = false;
|
||||
}
|
||||
|
||||
export { disableInstantTransitions, useInstantTransition };
|
||||
16
node_modules/framer-motion/dist/es/utils/use-is-mounted.mjs
generated
vendored
Normal file
16
node_modules/framer-motion/dist/es/utils/use-is-mounted.mjs
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
"use client";
|
||||
import { useRef } from 'react';
|
||||
import { useIsomorphicLayoutEffect } from './use-isomorphic-effect.mjs';
|
||||
|
||||
function useIsMounted() {
|
||||
const isMounted = useRef(false);
|
||||
useIsomorphicLayoutEffect(() => {
|
||||
isMounted.current = true;
|
||||
return () => {
|
||||
isMounted.current = false;
|
||||
};
|
||||
}, []);
|
||||
return isMounted;
|
||||
}
|
||||
|
||||
export { useIsMounted };
|
||||
7
node_modules/framer-motion/dist/es/utils/use-isomorphic-effect.mjs
generated
vendored
Normal file
7
node_modules/framer-motion/dist/es/utils/use-isomorphic-effect.mjs
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
"use client";
|
||||
import { useLayoutEffect, useEffect } from 'react';
|
||||
import { isBrowser } from './is-browser.mjs';
|
||||
|
||||
const useIsomorphicLayoutEffect = isBrowser ? useLayoutEffect : useEffect;
|
||||
|
||||
export { useIsomorphicLayoutEffect };
|
||||
14
node_modules/framer-motion/dist/es/utils/use-motion-value-event.mjs
generated
vendored
Normal file
14
node_modules/framer-motion/dist/es/utils/use-motion-value-event.mjs
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
"use client";
|
||||
import { useInsertionEffect } from 'react';
|
||||
|
||||
function useMotionValueEvent(value, event, callback) {
|
||||
/**
|
||||
* useInsertionEffect will create subscriptions before any other
|
||||
* effects will run. Effects run upwards through the tree so it
|
||||
* can be that binding a useLayoutEffect higher up the tree can
|
||||
* miss changes from lower down the tree.
|
||||
*/
|
||||
useInsertionEffect(() => value.on(event, callback), [value, event, callback]);
|
||||
}
|
||||
|
||||
export { useMotionValueEvent };
|
||||
19
node_modules/framer-motion/dist/es/utils/use-page-in-view.mjs
generated
vendored
Normal file
19
node_modules/framer-motion/dist/es/utils/use-page-in-view.mjs
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
"use client";
|
||||
import { useState, useEffect } from 'react';
|
||||
|
||||
function usePageInView() {
|
||||
const [isInView, setIsInView] = useState(true);
|
||||
useEffect(() => {
|
||||
const handleVisibilityChange = () => setIsInView(!document.hidden);
|
||||
if (document.hidden) {
|
||||
handleVisibilityChange();
|
||||
}
|
||||
document.addEventListener("visibilitychange", handleVisibilityChange);
|
||||
return () => {
|
||||
document.removeEventListener("visibilitychange", handleVisibilityChange);
|
||||
};
|
||||
}, []);
|
||||
return isInView;
|
||||
}
|
||||
|
||||
export { usePageInView };
|
||||
8
node_modules/framer-motion/dist/es/utils/use-unmount-effect.mjs
generated
vendored
Normal file
8
node_modules/framer-motion/dist/es/utils/use-unmount-effect.mjs
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
"use client";
|
||||
import { useEffect } from 'react';
|
||||
|
||||
function useUnmountEffect(callback) {
|
||||
return useEffect(() => () => callback(), []);
|
||||
}
|
||||
|
||||
export { useUnmountEffect };
|
||||
Reference in New Issue
Block a user