Mission Control Dashboard - Initial implementation
This commit is contained in:
386
node_modules/motion-dom/dist/es/render/utils/animation-state.mjs
generated
vendored
Normal file
386
node_modules/motion-dom/dist/es/render/utils/animation-state.mjs
generated
vendored
Normal file
@@ -0,0 +1,386 @@
|
||||
import { animateVisualElement } from '../../animation/interfaces/visual-element.mjs';
|
||||
import { calcChildStagger } from '../../animation/utils/calc-child-stagger.mjs';
|
||||
import { getVariantContext } from './get-variant-context.mjs';
|
||||
import { isAnimationControls } from './is-animation-controls.mjs';
|
||||
import { isKeyframesTarget } from './is-keyframes-target.mjs';
|
||||
import { isVariantLabel } from './is-variant-label.mjs';
|
||||
import { resolveVariant } from './resolve-dynamic-variants.mjs';
|
||||
import { shallowCompare } from './shallow-compare.mjs';
|
||||
import { variantPriorityOrder } from './variant-props.mjs';
|
||||
|
||||
const reversePriorityOrder = [...variantPriorityOrder].reverse();
|
||||
const numAnimationTypes = variantPriorityOrder.length;
|
||||
function createAnimateFunction(visualElement) {
|
||||
return (animations) => {
|
||||
return Promise.all(animations.map(({ animation, options }) => animateVisualElement(visualElement, animation, options)));
|
||||
};
|
||||
}
|
||||
function createAnimationState(visualElement) {
|
||||
let animate = createAnimateFunction(visualElement);
|
||||
let state = createState();
|
||||
let isInitialRender = true;
|
||||
/**
|
||||
* Track whether the animation state has been reset (e.g. via StrictMode
|
||||
* double-invocation or Suspense unmount/remount). On the first
|
||||
* animateChanges() call after a reset we need to behave like the initial
|
||||
* render for variant-inheritance checks, even though isInitialRender is
|
||||
* already false.
|
||||
*/
|
||||
let wasReset = false;
|
||||
/**
|
||||
* This function will be used to reduce the animation definitions for
|
||||
* each active animation type into an object of resolved values for it.
|
||||
*/
|
||||
const buildResolvedTypeValues = (type) => (acc, definition) => {
|
||||
const resolved = resolveVariant(visualElement, definition, type === "exit"
|
||||
? visualElement.presenceContext?.custom
|
||||
: undefined);
|
||||
if (resolved) {
|
||||
const { transition, transitionEnd, ...target } = resolved;
|
||||
acc = { ...acc, ...target, ...transitionEnd };
|
||||
}
|
||||
return acc;
|
||||
};
|
||||
/**
|
||||
* This just allows us to inject mocked animation functions
|
||||
* @internal
|
||||
*/
|
||||
function setAnimateFunction(makeAnimator) {
|
||||
animate = makeAnimator(visualElement);
|
||||
}
|
||||
/**
|
||||
* When we receive new props, we need to:
|
||||
* 1. Create a list of protected keys for each type. This is a directory of
|
||||
* value keys that are currently being "handled" by types of a higher priority
|
||||
* so that whenever an animation is played of a given type, these values are
|
||||
* protected from being animated.
|
||||
* 2. Determine if an animation type needs animating.
|
||||
* 3. Determine if any values have been removed from a type and figure out
|
||||
* what to animate those to.
|
||||
*/
|
||||
function animateChanges(changedActiveType) {
|
||||
const { props } = visualElement;
|
||||
const context = getVariantContext(visualElement.parent) || {};
|
||||
/**
|
||||
* A list of animations that we'll build into as we iterate through the animation
|
||||
* types. This will get executed at the end of the function.
|
||||
*/
|
||||
const animations = [];
|
||||
/**
|
||||
* Keep track of which values have been removed. Then, as we hit lower priority
|
||||
* animation types, we can check if they contain removed values and animate to that.
|
||||
*/
|
||||
const removedKeys = new Set();
|
||||
/**
|
||||
* A dictionary of all encountered keys. This is an object to let us build into and
|
||||
* copy it without iteration. Each time we hit an animation type we set its protected
|
||||
* keys - the keys its not allowed to animate - to the latest version of this object.
|
||||
*/
|
||||
let encounteredKeys = {};
|
||||
/**
|
||||
* If a variant has been removed at a given index, and this component is controlling
|
||||
* variant animations, we want to ensure lower-priority variants are forced to animate.
|
||||
*/
|
||||
let removedVariantIndex = Infinity;
|
||||
/**
|
||||
* Iterate through all animation types in reverse priority order. For each, we want to
|
||||
* detect which values it's handling and whether or not they've changed (and therefore
|
||||
* need to be animated). If any values have been removed, we want to detect those in
|
||||
* lower priority props and flag for animation.
|
||||
*/
|
||||
for (let i = 0; i < numAnimationTypes; i++) {
|
||||
const type = reversePriorityOrder[i];
|
||||
const typeState = state[type];
|
||||
const prop = props[type] !== undefined
|
||||
? props[type]
|
||||
: context[type];
|
||||
const propIsVariant = isVariantLabel(prop);
|
||||
/**
|
||||
* If this type has *just* changed isActive status, set activeDelta
|
||||
* to that status. Otherwise set to null.
|
||||
*/
|
||||
const activeDelta = type === changedActiveType ? typeState.isActive : null;
|
||||
if (activeDelta === false)
|
||||
removedVariantIndex = i;
|
||||
/**
|
||||
* If this prop is an inherited variant, rather than been set directly on the
|
||||
* component itself, we want to make sure we allow the parent to trigger animations.
|
||||
*
|
||||
* TODO: Can probably change this to a !isControllingVariants check
|
||||
*/
|
||||
let isInherited = prop === context[type] &&
|
||||
prop !== props[type] &&
|
||||
propIsVariant;
|
||||
if (isInherited &&
|
||||
(isInitialRender || wasReset) &&
|
||||
visualElement.manuallyAnimateOnMount) {
|
||||
isInherited = false;
|
||||
}
|
||||
/**
|
||||
* Set all encountered keys so far as the protected keys for this type. This will
|
||||
* be any key that has been animated or otherwise handled by active, higher-priortiy types.
|
||||
*/
|
||||
typeState.protectedKeys = { ...encounteredKeys };
|
||||
// Check if we can skip analysing this prop early
|
||||
if (
|
||||
// If it isn't active and hasn't *just* been set as inactive
|
||||
(!typeState.isActive && activeDelta === null) ||
|
||||
// If we didn't and don't have any defined prop for this animation type
|
||||
(!prop && !typeState.prevProp) ||
|
||||
// Or if the prop doesn't define an animation
|
||||
isAnimationControls(prop) ||
|
||||
typeof prop === "boolean") {
|
||||
continue;
|
||||
}
|
||||
/**
|
||||
* If exit is already active and wasn't just activated, skip
|
||||
* re-processing to prevent interrupting running exit animations.
|
||||
* Re-resolving exit with a changed custom value can start new
|
||||
* value animations that stop the originals, leaving the exit
|
||||
* animation promise unresolved and the component stuck in the DOM.
|
||||
*/
|
||||
if (type === "exit" && typeState.isActive && activeDelta !== true) {
|
||||
if (typeState.prevResolvedValues) {
|
||||
encounteredKeys = {
|
||||
...encounteredKeys,
|
||||
...typeState.prevResolvedValues,
|
||||
};
|
||||
}
|
||||
continue;
|
||||
}
|
||||
/**
|
||||
* As we go look through the values defined on this type, if we detect
|
||||
* a changed value or a value that was removed in a higher priority, we set
|
||||
* this to true and add this prop to the animation list.
|
||||
*/
|
||||
const variantDidChange = checkVariantsDidChange(typeState.prevProp, prop);
|
||||
let shouldAnimateType = variantDidChange ||
|
||||
// If we're making this variant active, we want to always make it active
|
||||
(type === changedActiveType &&
|
||||
typeState.isActive &&
|
||||
!isInherited &&
|
||||
propIsVariant) ||
|
||||
// If we removed a higher-priority variant (i is in reverse order)
|
||||
(i > removedVariantIndex && propIsVariant);
|
||||
let handledRemovedValues = false;
|
||||
/**
|
||||
* As animations can be set as variant lists, variants or target objects, we
|
||||
* coerce everything to an array if it isn't one already
|
||||
*/
|
||||
const definitionList = Array.isArray(prop) ? prop : [prop];
|
||||
/**
|
||||
* Build an object of all the resolved values. We'll use this in the subsequent
|
||||
* animateChanges calls to determine whether a value has changed.
|
||||
*/
|
||||
let resolvedValues = definitionList.reduce(buildResolvedTypeValues(type), {});
|
||||
if (activeDelta === false)
|
||||
resolvedValues = {};
|
||||
/**
|
||||
* Now we need to loop through all the keys in the prev prop and this prop,
|
||||
* and decide:
|
||||
* 1. If the value has changed, and needs animating
|
||||
* 2. If it has been removed, and needs adding to the removedKeys set
|
||||
* 3. If it has been removed in a higher priority type and needs animating
|
||||
* 4. If it hasn't been removed in a higher priority but hasn't changed, and
|
||||
* needs adding to the type's protectedKeys list.
|
||||
*/
|
||||
const { prevResolvedValues = {} } = typeState;
|
||||
const allKeys = {
|
||||
...prevResolvedValues,
|
||||
...resolvedValues,
|
||||
};
|
||||
const markToAnimate = (key) => {
|
||||
shouldAnimateType = true;
|
||||
if (removedKeys.has(key)) {
|
||||
handledRemovedValues = true;
|
||||
removedKeys.delete(key);
|
||||
}
|
||||
typeState.needsAnimating[key] = true;
|
||||
const motionValue = visualElement.getValue(key);
|
||||
if (motionValue)
|
||||
motionValue.liveStyle = false;
|
||||
};
|
||||
for (const key in allKeys) {
|
||||
const next = resolvedValues[key];
|
||||
const prev = prevResolvedValues[key];
|
||||
// If we've already handled this we can just skip ahead
|
||||
if (encounteredKeys.hasOwnProperty(key))
|
||||
continue;
|
||||
/**
|
||||
* If the value has changed, we probably want to animate it.
|
||||
*/
|
||||
let valueHasChanged = false;
|
||||
if (isKeyframesTarget(next) && isKeyframesTarget(prev)) {
|
||||
valueHasChanged = !shallowCompare(next, prev);
|
||||
}
|
||||
else {
|
||||
valueHasChanged = next !== prev;
|
||||
}
|
||||
if (valueHasChanged) {
|
||||
if (next !== undefined && next !== null) {
|
||||
// If next is defined and doesn't equal prev, it needs animating
|
||||
markToAnimate(key);
|
||||
}
|
||||
else {
|
||||
// If it's undefined, it's been removed.
|
||||
removedKeys.add(key);
|
||||
}
|
||||
}
|
||||
else if (next !== undefined && removedKeys.has(key)) {
|
||||
/**
|
||||
* If next hasn't changed and it isn't undefined, we want to check if it's
|
||||
* been removed by a higher priority
|
||||
*/
|
||||
markToAnimate(key);
|
||||
}
|
||||
else {
|
||||
/**
|
||||
* If it hasn't changed, we add it to the list of protected values
|
||||
* to ensure it doesn't get animated.
|
||||
*/
|
||||
typeState.protectedKeys[key] = true;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Update the typeState so next time animateChanges is called we can compare the
|
||||
* latest prop and resolvedValues to these.
|
||||
*/
|
||||
typeState.prevProp = prop;
|
||||
typeState.prevResolvedValues = resolvedValues;
|
||||
if (typeState.isActive) {
|
||||
encounteredKeys = { ...encounteredKeys, ...resolvedValues };
|
||||
}
|
||||
if ((isInitialRender || wasReset) &&
|
||||
visualElement.blockInitialAnimation) {
|
||||
shouldAnimateType = false;
|
||||
}
|
||||
/**
|
||||
* If this is an inherited prop we want to skip this animation
|
||||
* unless the inherited variants haven't changed on this render.
|
||||
*/
|
||||
const willAnimateViaParent = isInherited && variantDidChange;
|
||||
const needsAnimating = !willAnimateViaParent || handledRemovedValues;
|
||||
if (shouldAnimateType && needsAnimating) {
|
||||
animations.push(...definitionList.map((animation) => {
|
||||
const options = { type };
|
||||
/**
|
||||
* If we're performing the initial animation, but we're not
|
||||
* rendering at the same time as the variant-controlling parent,
|
||||
* we want to use the parent's transition to calculate the stagger.
|
||||
*/
|
||||
if (typeof animation === "string" &&
|
||||
(isInitialRender || wasReset) &&
|
||||
!willAnimateViaParent &&
|
||||
visualElement.manuallyAnimateOnMount &&
|
||||
visualElement.parent) {
|
||||
const { parent } = visualElement;
|
||||
const parentVariant = resolveVariant(parent, animation);
|
||||
if (parent.enteringChildren && parentVariant) {
|
||||
const { delayChildren } = parentVariant.transition || {};
|
||||
options.delay = calcChildStagger(parent.enteringChildren, visualElement, delayChildren);
|
||||
}
|
||||
}
|
||||
return {
|
||||
animation: animation,
|
||||
options,
|
||||
};
|
||||
}));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* If there are some removed value that haven't been dealt with,
|
||||
* we need to create a new animation that falls back either to the value
|
||||
* defined in the style prop, or the last read value.
|
||||
*/
|
||||
if (removedKeys.size) {
|
||||
const fallbackAnimation = {};
|
||||
/**
|
||||
* If the initial prop contains a transition we can use that, otherwise
|
||||
* allow the animation function to use the visual element's default.
|
||||
*/
|
||||
if (typeof props.initial !== "boolean") {
|
||||
const initialTransition = resolveVariant(visualElement, Array.isArray(props.initial)
|
||||
? props.initial[0]
|
||||
: props.initial);
|
||||
if (initialTransition && initialTransition.transition) {
|
||||
fallbackAnimation.transition = initialTransition.transition;
|
||||
}
|
||||
}
|
||||
removedKeys.forEach((key) => {
|
||||
const fallbackTarget = visualElement.getBaseTarget(key);
|
||||
const motionValue = visualElement.getValue(key);
|
||||
if (motionValue)
|
||||
motionValue.liveStyle = true;
|
||||
// @ts-expect-error - @mattgperry to figure if we should do something here
|
||||
fallbackAnimation[key] = fallbackTarget ?? null;
|
||||
});
|
||||
animations.push({ animation: fallbackAnimation });
|
||||
}
|
||||
let shouldAnimate = Boolean(animations.length);
|
||||
if (isInitialRender &&
|
||||
(props.initial === false || props.initial === props.animate) &&
|
||||
!visualElement.manuallyAnimateOnMount) {
|
||||
shouldAnimate = false;
|
||||
}
|
||||
isInitialRender = false;
|
||||
wasReset = false;
|
||||
return shouldAnimate ? animate(animations) : Promise.resolve();
|
||||
}
|
||||
/**
|
||||
* Change whether a certain animation type is active.
|
||||
*/
|
||||
function setActive(type, isActive) {
|
||||
// If the active state hasn't changed, we can safely do nothing here
|
||||
if (state[type].isActive === isActive)
|
||||
return Promise.resolve();
|
||||
// Propagate active change to children
|
||||
visualElement.variantChildren?.forEach((child) => child.animationState?.setActive(type, isActive));
|
||||
state[type].isActive = isActive;
|
||||
const animations = animateChanges(type);
|
||||
for (const key in state) {
|
||||
state[key].protectedKeys = {};
|
||||
}
|
||||
return animations;
|
||||
}
|
||||
return {
|
||||
animateChanges,
|
||||
setActive,
|
||||
setAnimateFunction,
|
||||
getState: () => state,
|
||||
reset: () => {
|
||||
state = createState();
|
||||
wasReset = true;
|
||||
},
|
||||
};
|
||||
}
|
||||
function checkVariantsDidChange(prev, next) {
|
||||
if (typeof next === "string") {
|
||||
return next !== prev;
|
||||
}
|
||||
else if (Array.isArray(next)) {
|
||||
return !shallowCompare(next, prev);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function createTypeState(isActive = false) {
|
||||
return {
|
||||
isActive,
|
||||
protectedKeys: {},
|
||||
needsAnimating: {},
|
||||
prevResolvedValues: {},
|
||||
};
|
||||
}
|
||||
function createState() {
|
||||
return {
|
||||
animate: createTypeState(true),
|
||||
whileInView: createTypeState(),
|
||||
whileHover: createTypeState(),
|
||||
whileTap: createTypeState(),
|
||||
whileDrag: createTypeState(),
|
||||
whileFocus: createTypeState(),
|
||||
exit: createTypeState(),
|
||||
};
|
||||
}
|
||||
|
||||
export { checkVariantsDidChange, createAnimationState };
|
||||
//# sourceMappingURL=animation-state.mjs.map
|
||||
1
node_modules/motion-dom/dist/es/render/utils/animation-state.mjs.map
generated
vendored
Normal file
1
node_modules/motion-dom/dist/es/render/utils/animation-state.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
33
node_modules/motion-dom/dist/es/render/utils/get-variant-context.mjs
generated
vendored
Normal file
33
node_modules/motion-dom/dist/es/render/utils/get-variant-context.mjs
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
import { isVariantLabel } from './is-variant-label.mjs';
|
||||
import { variantProps } from './variant-props.mjs';
|
||||
|
||||
const numVariantProps = variantProps.length;
|
||||
/**
|
||||
* Get variant context from a visual element's parent chain.
|
||||
* Uses `any` type for visualElement to avoid circular dependencies.
|
||||
*/
|
||||
function getVariantContext(visualElement) {
|
||||
if (!visualElement)
|
||||
return undefined;
|
||||
if (!visualElement.isControllingVariants) {
|
||||
const context = visualElement.parent
|
||||
? getVariantContext(visualElement.parent) || {}
|
||||
: {};
|
||||
if (visualElement.props.initial !== undefined) {
|
||||
context.initial = visualElement.props.initial;
|
||||
}
|
||||
return context;
|
||||
}
|
||||
const context = {};
|
||||
for (let i = 0; i < numVariantProps; i++) {
|
||||
const name = variantProps[i];
|
||||
const prop = visualElement.props[name];
|
||||
if (isVariantLabel(prop) || prop === false) {
|
||||
context[name] = prop;
|
||||
}
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
export { getVariantContext };
|
||||
//# sourceMappingURL=get-variant-context.mjs.map
|
||||
1
node_modules/motion-dom/dist/es/render/utils/get-variant-context.mjs.map
generated
vendored
Normal file
1
node_modules/motion-dom/dist/es/render/utils/get-variant-context.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"get-variant-context.mjs","sources":["../../../../src/render/utils/get-variant-context.ts"],"sourcesContent":["import { isVariantLabel } from \"./is-variant-label\"\nimport { variantProps } from \"./variant-props\"\n\nconst numVariantProps = variantProps.length\n\ntype VariantStateContext = {\n initial?: string | string[]\n animate?: string | string[]\n exit?: string | string[]\n whileHover?: string | string[]\n whileDrag?: string | string[]\n whileFocus?: string | string[]\n whileTap?: string | string[]\n}\n\n/**\n * Get variant context from a visual element's parent chain.\n * Uses `any` type for visualElement to avoid circular dependencies.\n */\nexport function getVariantContext(\n visualElement?: any\n): undefined | VariantStateContext {\n if (!visualElement) return undefined\n\n if (!visualElement.isControllingVariants) {\n const context = visualElement.parent\n ? getVariantContext(visualElement.parent) || {}\n : {}\n if (visualElement.props.initial !== undefined) {\n context.initial = visualElement.props.initial as any\n }\n return context\n }\n\n const context: VariantStateContext = {}\n for (let i = 0; i < numVariantProps; i++) {\n const name = variantProps[i] as keyof typeof context\n const prop = visualElement.props[name]\n\n if (isVariantLabel(prop) || prop === false) {\n ;(context as any)[name] = prop\n }\n }\n\n return context\n}\n"],"names":[],"mappings":";;;AAGA,MAAM,eAAe,GAAG,YAAY,CAAC,MAAM;AAY3C;;;AAGG;AACG,SAAU,iBAAiB,CAC7B,aAAmB,EAAA;AAEnB,IAAA,IAAI,CAAC,aAAa;AAAE,QAAA,OAAO,SAAS;AAEpC,IAAA,IAAI,CAAC,aAAa,CAAC,qBAAqB,EAAE;AACtC,QAAA,MAAM,OAAO,GAAG,aAAa,CAAC;cACxB,iBAAiB,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI;cAC3C,EAAE;QACR,IAAI,aAAa,CAAC,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE;YAC3C,OAAO,CAAC,OAAO,GAAG,aAAa,CAAC,KAAK,CAAC,OAAc;QACxD;AACA,QAAA,OAAO,OAAO;IAClB;IAEA,MAAM,OAAO,GAAwB,EAAE;AACvC,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,eAAe,EAAE,CAAC,EAAE,EAAE;AACtC,QAAA,MAAM,IAAI,GAAG,YAAY,CAAC,CAAC,CAAyB;QACpD,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC;QAEtC,IAAI,cAAc,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,KAAK,EAAE;AACtC,YAAA,OAAe,CAAC,IAAI,CAAC,GAAG,IAAI;QAClC;IACJ;AAEA,IAAA,OAAO,OAAO;AAClB;;;;"}
|
||||
8
node_modules/motion-dom/dist/es/render/utils/is-animation-controls.mjs
generated
vendored
Normal file
8
node_modules/motion-dom/dist/es/render/utils/is-animation-controls.mjs
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
function isAnimationControls(v) {
|
||||
return (v !== null &&
|
||||
typeof v === "object" &&
|
||||
typeof v.start === "function");
|
||||
}
|
||||
|
||||
export { isAnimationControls };
|
||||
//# sourceMappingURL=is-animation-controls.mjs.map
|
||||
1
node_modules/motion-dom/dist/es/render/utils/is-animation-controls.mjs.map
generated
vendored
Normal file
1
node_modules/motion-dom/dist/es/render/utils/is-animation-controls.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"is-animation-controls.mjs","sources":["../../../../src/render/utils/is-animation-controls.ts"],"sourcesContent":["import type { LegacyAnimationControls } from \"../../node/types\"\n\nexport function isAnimationControls(v?: unknown): v is LegacyAnimationControls {\n return (\n v !== null &&\n typeof v === \"object\" &&\n typeof (v as LegacyAnimationControls).start === \"function\"\n )\n}\n"],"names":[],"mappings":"AAEM,SAAU,mBAAmB,CAAC,CAAW,EAAA;IAC3C,QACI,CAAC,KAAK,IAAI;QACV,OAAO,CAAC,KAAK,QAAQ;AACrB,QAAA,OAAQ,CAA6B,CAAC,KAAK,KAAK,UAAU;AAElE;;;;"}
|
||||
14
node_modules/motion-dom/dist/es/render/utils/is-controlling-variants.mjs
generated
vendored
Normal file
14
node_modules/motion-dom/dist/es/render/utils/is-controlling-variants.mjs
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import { isAnimationControls } from './is-animation-controls.mjs';
|
||||
import { isVariantLabel } from './is-variant-label.mjs';
|
||||
import { variantProps } from './variant-props.mjs';
|
||||
|
||||
function isControllingVariants(props) {
|
||||
return (isAnimationControls(props.animate) ||
|
||||
variantProps.some((name) => isVariantLabel(props[name])));
|
||||
}
|
||||
function isVariantNode(props) {
|
||||
return Boolean(isControllingVariants(props) || props.variants);
|
||||
}
|
||||
|
||||
export { isControllingVariants, isVariantNode };
|
||||
//# sourceMappingURL=is-controlling-variants.mjs.map
|
||||
1
node_modules/motion-dom/dist/es/render/utils/is-controlling-variants.mjs.map
generated
vendored
Normal file
1
node_modules/motion-dom/dist/es/render/utils/is-controlling-variants.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"is-controlling-variants.mjs","sources":["../../../../src/render/utils/is-controlling-variants.ts"],"sourcesContent":["import type { MotionNodeOptions } from \"../../node/types\"\nimport { isAnimationControls } from \"./is-animation-controls\"\nimport { isVariantLabel } from \"./is-variant-label\"\nimport { variantProps } from \"./variant-props\"\n\nexport function isControllingVariants(props: MotionNodeOptions) {\n return (\n isAnimationControls(props.animate) ||\n variantProps.some((name) =>\n isVariantLabel(props[name as keyof typeof props])\n )\n )\n}\n\nexport function isVariantNode(props: MotionNodeOptions) {\n return Boolean(isControllingVariants(props) || props.variants)\n}\n"],"names":[],"mappings":";;;;AAKM,SAAU,qBAAqB,CAAC,KAAwB,EAAA;AAC1D,IAAA,QACI,mBAAmB,CAAC,KAAK,CAAC,OAAO,CAAC;AAClC,QAAA,YAAY,CAAC,IAAI,CAAC,CAAC,IAAI,KACnB,cAAc,CAAC,KAAK,CAAC,IAA0B,CAAC,CAAC,CACpD;AAET;AAEM,SAAU,aAAa,CAAC,KAAwB,EAAA;IAClD,OAAO,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC;AAClE;;;;"}
|
||||
13
node_modules/motion-dom/dist/es/render/utils/is-forced-motion-value.mjs
generated
vendored
Normal file
13
node_modules/motion-dom/dist/es/render/utils/is-forced-motion-value.mjs
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import { transformProps } from './keys-transform.mjs';
|
||||
import { scaleCorrectors } from '../../projection/styles/scale-correction.mjs';
|
||||
export { addScaleCorrector } from '../../projection/styles/scale-correction.mjs';
|
||||
|
||||
function isForcedMotionValue(key, { layout, layoutId }) {
|
||||
return (transformProps.has(key) ||
|
||||
key.startsWith("origin") ||
|
||||
((layout || layoutId !== undefined) &&
|
||||
(!!scaleCorrectors[key] || key === "opacity")));
|
||||
}
|
||||
|
||||
export { isForcedMotionValue, scaleCorrectors };
|
||||
//# sourceMappingURL=is-forced-motion-value.mjs.map
|
||||
1
node_modules/motion-dom/dist/es/render/utils/is-forced-motion-value.mjs.map
generated
vendored
Normal file
1
node_modules/motion-dom/dist/es/render/utils/is-forced-motion-value.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"is-forced-motion-value.mjs","sources":["../../../../src/render/utils/is-forced-motion-value.ts"],"sourcesContent":["import { transformProps } from \"./keys-transform\"\nimport type { MotionNodeOptions } from \"../../node/types\"\nimport {\n scaleCorrectors,\n addScaleCorrector,\n} from \"../../projection/styles/scale-correction\"\n\nexport { scaleCorrectors, addScaleCorrector }\n\nexport function isForcedMotionValue(\n key: string,\n { layout, layoutId }: MotionNodeOptions\n) {\n return (\n transformProps.has(key) ||\n key.startsWith(\"origin\") ||\n ((layout || layoutId !== undefined) &&\n (!!scaleCorrectors[key] || key === \"opacity\"))\n )\n}\n"],"names":[],"mappings":";;;;AASM,SAAU,mBAAmB,CAC/B,GAAW,EACX,EAAE,MAAM,EAAE,QAAQ,EAAqB,EAAA;AAEvC,IAAA,QACI,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC;AACvB,QAAA,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC;AACxB,SAAC,CAAC,MAAM,IAAI,QAAQ,KAAK,SAAS;AAC9B,aAAC,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,GAAG,KAAK,SAAS,CAAC,CAAC;AAE1D;;;;"}
|
||||
6
node_modules/motion-dom/dist/es/render/utils/is-keyframes-target.mjs
generated
vendored
Normal file
6
node_modules/motion-dom/dist/es/render/utils/is-keyframes-target.mjs
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
const isKeyframesTarget = (v) => {
|
||||
return Array.isArray(v);
|
||||
};
|
||||
|
||||
export { isKeyframesTarget };
|
||||
//# sourceMappingURL=is-keyframes-target.mjs.map
|
||||
1
node_modules/motion-dom/dist/es/render/utils/is-keyframes-target.mjs.map
generated
vendored
Normal file
1
node_modules/motion-dom/dist/es/render/utils/is-keyframes-target.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"is-keyframes-target.mjs","sources":["../../../../src/render/utils/is-keyframes-target.ts"],"sourcesContent":["import type { UnresolvedValueKeyframe, ValueKeyframesDefinition } from \"../../animation/types\"\n\nexport const isKeyframesTarget = (\n v: ValueKeyframesDefinition\n): v is UnresolvedValueKeyframe[] => {\n return Array.isArray(v)\n}\n"],"names":[],"mappings":"AAEO,MAAM,iBAAiB,GAAG,CAC7B,CAA2B,KACK;AAChC,IAAA,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AAC3B;;;;"}
|
||||
9
node_modules/motion-dom/dist/es/render/utils/is-variant-label.mjs
generated
vendored
Normal file
9
node_modules/motion-dom/dist/es/render/utils/is-variant-label.mjs
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Decides if the supplied variable is variant label
|
||||
*/
|
||||
function isVariantLabel(v) {
|
||||
return typeof v === "string" || Array.isArray(v);
|
||||
}
|
||||
|
||||
export { isVariantLabel };
|
||||
//# sourceMappingURL=is-variant-label.mjs.map
|
||||
1
node_modules/motion-dom/dist/es/render/utils/is-variant-label.mjs.map
generated
vendored
Normal file
1
node_modules/motion-dom/dist/es/render/utils/is-variant-label.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"is-variant-label.mjs","sources":["../../../../src/render/utils/is-variant-label.ts"],"sourcesContent":["/**\n * Decides if the supplied variable is variant label\n */\nexport function isVariantLabel(v: unknown): v is string | string[] {\n return typeof v === \"string\" || Array.isArray(v)\n}\n"],"names":[],"mappings":"AAAA;;AAEG;AACG,SAAU,cAAc,CAAC,CAAU,EAAA;IACrC,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AACpD;;;;"}
|
||||
14
node_modules/motion-dom/dist/es/render/utils/keys-position.mjs
generated
vendored
Normal file
14
node_modules/motion-dom/dist/es/render/utils/keys-position.mjs
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import { transformPropOrder } from './keys-transform.mjs';
|
||||
|
||||
const positionalKeys = new Set([
|
||||
"width",
|
||||
"height",
|
||||
"top",
|
||||
"left",
|
||||
"right",
|
||||
"bottom",
|
||||
...transformPropOrder,
|
||||
]);
|
||||
|
||||
export { positionalKeys };
|
||||
//# sourceMappingURL=keys-position.mjs.map
|
||||
1
node_modules/motion-dom/dist/es/render/utils/keys-position.mjs.map
generated
vendored
Normal file
1
node_modules/motion-dom/dist/es/render/utils/keys-position.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"keys-position.mjs","sources":["../../../../src/render/utils/keys-position.ts"],"sourcesContent":["import { transformPropOrder } from \"./keys-transform\"\n\nexport const positionalKeys = new Set([\n \"width\",\n \"height\",\n \"top\",\n \"left\",\n \"right\",\n \"bottom\",\n ...transformPropOrder,\n])\n"],"names":[],"mappings":";;AAEO,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAClC,OAAO;IACP,QAAQ;IACR,KAAK;IACL,MAAM;IACN,OAAO;IACP,QAAQ;AACR,IAAA,GAAG,kBAAkB;AACxB,CAAA;;;;"}
|
||||
29
node_modules/motion-dom/dist/es/render/utils/keys-transform.mjs
generated
vendored
Normal file
29
node_modules/motion-dom/dist/es/render/utils/keys-transform.mjs
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Generate a list of every possible transform key.
|
||||
*/
|
||||
const transformPropOrder = [
|
||||
"transformPerspective",
|
||||
"x",
|
||||
"y",
|
||||
"z",
|
||||
"translateX",
|
||||
"translateY",
|
||||
"translateZ",
|
||||
"scale",
|
||||
"scaleX",
|
||||
"scaleY",
|
||||
"rotate",
|
||||
"rotateX",
|
||||
"rotateY",
|
||||
"rotateZ",
|
||||
"skew",
|
||||
"skewX",
|
||||
"skewY",
|
||||
];
|
||||
/**
|
||||
* A quick lookup for transform props.
|
||||
*/
|
||||
const transformProps = /*@__PURE__*/ (() => new Set(transformPropOrder))();
|
||||
|
||||
export { transformPropOrder, transformProps };
|
||||
//# sourceMappingURL=keys-transform.mjs.map
|
||||
1
node_modules/motion-dom/dist/es/render/utils/keys-transform.mjs.map
generated
vendored
Normal file
1
node_modules/motion-dom/dist/es/render/utils/keys-transform.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"keys-transform.mjs","sources":["../../../../src/render/utils/keys-transform.ts"],"sourcesContent":["/**\n * Generate a list of every possible transform key.\n */\nexport const transformPropOrder = [\n \"transformPerspective\",\n \"x\",\n \"y\",\n \"z\",\n \"translateX\",\n \"translateY\",\n \"translateZ\",\n \"scale\",\n \"scaleX\",\n \"scaleY\",\n \"rotate\",\n \"rotateX\",\n \"rotateY\",\n \"rotateZ\",\n \"skew\",\n \"skewX\",\n \"skewY\",\n]\n\n/**\n * A quick lookup for transform props.\n */\nexport const transformProps = /*@__PURE__*/ (() =>\n new Set(transformPropOrder))()\n"],"names":[],"mappings":"AAAA;;AAEG;AACI,MAAM,kBAAkB,GAAG;IAC9B,sBAAsB;IACtB,GAAG;IACH,GAAG;IACH,GAAG;IACH,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,SAAS;IACT,SAAS;IACT,MAAM;IACN,OAAO;IACP,OAAO;;AAGX;;AAEG;AACI,MAAM,cAAc,iBAAiB,CAAC,MACzC,IAAI,GAAG,CAAC,kBAAkB,CAAC;;;;"}
|
||||
56
node_modules/motion-dom/dist/es/render/utils/motion-values.mjs
generated
vendored
Normal file
56
node_modules/motion-dom/dist/es/render/utils/motion-values.mjs
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
import { motionValue } from '../../value/index.mjs';
|
||||
import { isMotionValue } from '../../value/utils/is-motion-value.mjs';
|
||||
|
||||
/**
|
||||
* Updates motion values from props changes.
|
||||
* Uses `any` type for element to avoid circular dependencies with VisualElement.
|
||||
*/
|
||||
function updateMotionValuesFromProps(element, next, prev) {
|
||||
for (const key in next) {
|
||||
const nextValue = next[key];
|
||||
const prevValue = prev[key];
|
||||
if (isMotionValue(nextValue)) {
|
||||
/**
|
||||
* If this is a motion value found in props or style, we want to add it
|
||||
* to our visual element's motion value map.
|
||||
*/
|
||||
element.addValue(key, nextValue);
|
||||
}
|
||||
else if (isMotionValue(prevValue)) {
|
||||
/**
|
||||
* If we're swapping from a motion value to a static value,
|
||||
* create a new motion value from that
|
||||
*/
|
||||
element.addValue(key, motionValue(nextValue, { owner: element }));
|
||||
}
|
||||
else if (prevValue !== nextValue) {
|
||||
/**
|
||||
* If this is a flat value that has changed, update the motion value
|
||||
* or create one if it doesn't exist. We only want to do this if we're
|
||||
* not handling the value with our animation state.
|
||||
*/
|
||||
if (element.hasValue(key)) {
|
||||
const existingValue = element.getValue(key);
|
||||
if (existingValue.liveStyle === true) {
|
||||
existingValue.jump(nextValue);
|
||||
}
|
||||
else if (!existingValue.hasAnimated) {
|
||||
existingValue.set(nextValue);
|
||||
}
|
||||
}
|
||||
else {
|
||||
const latestValue = element.getStaticValue(key);
|
||||
element.addValue(key, motionValue(latestValue !== undefined ? latestValue : nextValue, { owner: element }));
|
||||
}
|
||||
}
|
||||
}
|
||||
// Handle removed values
|
||||
for (const key in prev) {
|
||||
if (next[key] === undefined)
|
||||
element.removeValue(key);
|
||||
}
|
||||
return next;
|
||||
}
|
||||
|
||||
export { updateMotionValuesFromProps };
|
||||
//# sourceMappingURL=motion-values.mjs.map
|
||||
1
node_modules/motion-dom/dist/es/render/utils/motion-values.mjs.map
generated
vendored
Normal file
1
node_modules/motion-dom/dist/es/render/utils/motion-values.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"motion-values.mjs","sources":["../../../../src/render/utils/motion-values.ts"],"sourcesContent":["import { motionValue } from \"../../value\"\nimport { isMotionValue } from \"../../value/utils/is-motion-value\"\n\ntype MotionStyleLike = Record<string, any>\n\n/**\n * Updates motion values from props changes.\n * Uses `any` type for element to avoid circular dependencies with VisualElement.\n */\nexport function updateMotionValuesFromProps(\n element: any,\n next: MotionStyleLike,\n prev: MotionStyleLike\n) {\n for (const key in next) {\n const nextValue = next[key]\n const prevValue = prev[key]\n\n if (isMotionValue(nextValue)) {\n /**\n * If this is a motion value found in props or style, we want to add it\n * to our visual element's motion value map.\n */\n element.addValue(key, nextValue)\n } else if (isMotionValue(prevValue)) {\n /**\n * If we're swapping from a motion value to a static value,\n * create a new motion value from that\n */\n element.addValue(key, motionValue(nextValue, { owner: element }))\n } else if (prevValue !== nextValue) {\n /**\n * If this is a flat value that has changed, update the motion value\n * or create one if it doesn't exist. We only want to do this if we're\n * not handling the value with our animation state.\n */\n if (element.hasValue(key)) {\n const existingValue = element.getValue(key)!\n\n if (existingValue.liveStyle === true) {\n existingValue.jump(nextValue)\n } else if (!existingValue.hasAnimated) {\n existingValue.set(nextValue)\n }\n } else {\n const latestValue = element.getStaticValue(key)\n element.addValue(\n key,\n motionValue(\n latestValue !== undefined ? latestValue : nextValue,\n { owner: element }\n )\n )\n }\n }\n }\n\n // Handle removed values\n for (const key in prev) {\n if (next[key] === undefined) element.removeValue(key)\n }\n\n return next\n}\n"],"names":[],"mappings":";;;AAKA;;;AAGG;SACa,2BAA2B,CACvC,OAAY,EACZ,IAAqB,EACrB,IAAqB,EAAA;AAErB,IAAA,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;AACpB,QAAA,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC;AAC3B,QAAA,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC;AAE3B,QAAA,IAAI,aAAa,CAAC,SAAS,CAAC,EAAE;AAC1B;;;AAGG;AACH,YAAA,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;QACpC;AAAO,aAAA,IAAI,aAAa,CAAC,SAAS,CAAC,EAAE;AACjC;;;AAGG;AACH,YAAA,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;QACrE;AAAO,aAAA,IAAI,SAAS,KAAK,SAAS,EAAE;AAChC;;;;AAIG;AACH,YAAA,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;gBACvB,MAAM,aAAa,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAE;AAE5C,gBAAA,IAAI,aAAa,CAAC,SAAS,KAAK,IAAI,EAAE;AAClC,oBAAA,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC;gBACjC;AAAO,qBAAA,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE;AACnC,oBAAA,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC;gBAChC;YACJ;iBAAO;gBACH,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC;gBAC/C,OAAO,CAAC,QAAQ,CACZ,GAAG,EACH,WAAW,CACP,WAAW,KAAK,SAAS,GAAG,WAAW,GAAG,SAAS,EACnD,EAAE,KAAK,EAAE,OAAO,EAAE,CACrB,CACJ;YACL;QACJ;IACJ;;AAGA,IAAA,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;AACpB,QAAA,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,SAAS;AAAE,YAAA,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC;IACzD;AAEA,IAAA,OAAO,IAAI;AACf;;;;"}
|
||||
20
node_modules/motion-dom/dist/es/render/utils/reduced-motion/index.mjs
generated
vendored
Normal file
20
node_modules/motion-dom/dist/es/render/utils/reduced-motion/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
import { hasReducedMotionListener, prefersReducedMotion } from './state.mjs';
|
||||
|
||||
const isBrowser = typeof window !== "undefined";
|
||||
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 { hasReducedMotionListener, initPrefersReducedMotion, prefersReducedMotion };
|
||||
//# sourceMappingURL=index.mjs.map
|
||||
1
node_modules/motion-dom/dist/es/render/utils/reduced-motion/index.mjs.map
generated
vendored
Normal file
1
node_modules/motion-dom/dist/es/render/utils/reduced-motion/index.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.mjs","sources":["../../../../../src/render/utils/reduced-motion/index.ts"],"sourcesContent":["import { hasReducedMotionListener, prefersReducedMotion } from \"./state\"\n\nconst isBrowser = typeof window !== \"undefined\"\n\nexport function initPrefersReducedMotion() {\n hasReducedMotionListener.current = true\n if (!isBrowser) return\n\n if (window.matchMedia) {\n const motionMediaQuery = window.matchMedia(\"(prefers-reduced-motion)\")\n\n const setReducedMotionPreferences = () =>\n (prefersReducedMotion.current = motionMediaQuery.matches)\n\n motionMediaQuery.addEventListener(\"change\", setReducedMotionPreferences)\n\n setReducedMotionPreferences()\n } else {\n prefersReducedMotion.current = false\n }\n}\n\nexport { prefersReducedMotion, hasReducedMotionListener }\n"],"names":[],"mappings":";;AAEA,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW;SAE/B,wBAAwB,GAAA;AACpC,IAAA,wBAAwB,CAAC,OAAO,GAAG,IAAI;AACvC,IAAA,IAAI,CAAC,SAAS;QAAE;AAEhB,IAAA,IAAI,MAAM,CAAC,UAAU,EAAE;QACnB,MAAM,gBAAgB,GAAG,MAAM,CAAC,UAAU,CAAC,0BAA0B,CAAC;AAEtE,QAAA,MAAM,2BAA2B,GAAG,OAC/B,oBAAoB,CAAC,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC;AAE7D,QAAA,gBAAgB,CAAC,gBAAgB,CAAC,QAAQ,EAAE,2BAA2B,CAAC;AAExE,QAAA,2BAA2B,EAAE;IACjC;SAAO;AACH,QAAA,oBAAoB,CAAC,OAAO,GAAG,KAAK;IACxC;AACJ;;;;"}
|
||||
6
node_modules/motion-dom/dist/es/render/utils/reduced-motion/state.mjs
generated
vendored
Normal file
6
node_modules/motion-dom/dist/es/render/utils/reduced-motion/state.mjs
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
// Does this device prefer reduced motion? Returns `null` server-side.
|
||||
const prefersReducedMotion = { current: null };
|
||||
const hasReducedMotionListener = { current: false };
|
||||
|
||||
export { hasReducedMotionListener, prefersReducedMotion };
|
||||
//# sourceMappingURL=state.mjs.map
|
||||
1
node_modules/motion-dom/dist/es/render/utils/reduced-motion/state.mjs.map
generated
vendored
Normal file
1
node_modules/motion-dom/dist/es/render/utils/reduced-motion/state.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"state.mjs","sources":["../../../../../src/render/utils/reduced-motion/state.ts"],"sourcesContent":["interface ReducedMotionState {\n current: boolean | null\n}\n\n// Does this device prefer reduced motion? Returns `null` server-side.\nexport const prefersReducedMotion: ReducedMotionState = { current: null }\n\nexport const hasReducedMotionListener = { current: false }\n"],"names":[],"mappings":"AAIA;MACa,oBAAoB,GAAuB,EAAE,OAAO,EAAE,IAAI;MAE1D,wBAAwB,GAAG,EAAE,OAAO,EAAE,KAAK;;;;"}
|
||||
9
node_modules/motion-dom/dist/es/render/utils/resolve-dynamic-variants.mjs
generated
vendored
Normal file
9
node_modules/motion-dom/dist/es/render/utils/resolve-dynamic-variants.mjs
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { resolveVariantFromProps } from './resolve-variants.mjs';
|
||||
|
||||
function resolveVariant(visualElement, definition, custom) {
|
||||
const props = visualElement.getProps();
|
||||
return resolveVariantFromProps(props, definition, custom !== undefined ? custom : props.custom, visualElement);
|
||||
}
|
||||
|
||||
export { resolveVariant };
|
||||
//# sourceMappingURL=resolve-dynamic-variants.mjs.map
|
||||
1
node_modules/motion-dom/dist/es/render/utils/resolve-dynamic-variants.mjs.map
generated
vendored
Normal file
1
node_modules/motion-dom/dist/es/render/utils/resolve-dynamic-variants.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"resolve-dynamic-variants.mjs","sources":["../../../../src/render/utils/resolve-dynamic-variants.ts"],"sourcesContent":["import type {\n AnimationDefinition,\n TargetAndTransition,\n TargetResolver,\n} from \"../../node/types\"\nimport { resolveVariantFromProps } from \"./resolve-variants\"\n\n/**\n * Resolves a variant if it's a variant resolver.\n * Uses `any` type for visualElement to avoid circular dependencies.\n */\nexport function resolveVariant(\n visualElement: any,\n definition?: TargetAndTransition | TargetResolver,\n custom?: any\n): TargetAndTransition\nexport function resolveVariant(\n visualElement: any,\n definition?: AnimationDefinition,\n custom?: any\n): TargetAndTransition | undefined\nexport function resolveVariant(\n visualElement: any,\n definition?: AnimationDefinition,\n custom?: any\n) {\n const props = visualElement.getProps()\n return resolveVariantFromProps(\n props,\n definition,\n custom !== undefined ? custom : props.custom,\n visualElement\n )\n}\n"],"names":[],"mappings":";;SAqBgB,cAAc,CAC1B,aAAkB,EAClB,UAAgC,EAChC,MAAY,EAAA;AAEZ,IAAA,MAAM,KAAK,GAAG,aAAa,CAAC,QAAQ,EAAE;IACtC,OAAO,uBAAuB,CAC1B,KAAK,EACL,UAAU,EACV,MAAM,KAAK,SAAS,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM,EAC5C,aAAa,CAChB;AACL;;;;"}
|
||||
37
node_modules/motion-dom/dist/es/render/utils/resolve-variants.mjs
generated
vendored
Normal file
37
node_modules/motion-dom/dist/es/render/utils/resolve-variants.mjs
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
function getValueState(visualElement) {
|
||||
const state = [{}, {}];
|
||||
visualElement?.values.forEach((value, key) => {
|
||||
state[0][key] = value.get();
|
||||
state[1][key] = value.getVelocity();
|
||||
});
|
||||
return state;
|
||||
}
|
||||
function resolveVariantFromProps(props, definition, custom, visualElement) {
|
||||
/**
|
||||
* If the variant definition is a function, resolve.
|
||||
*/
|
||||
if (typeof definition === "function") {
|
||||
const [current, velocity] = getValueState(visualElement);
|
||||
definition = definition(custom !== undefined ? custom : props.custom, current, velocity);
|
||||
}
|
||||
/**
|
||||
* If the variant definition is a variant label, or
|
||||
* the function returned a variant label, resolve.
|
||||
*/
|
||||
if (typeof definition === "string") {
|
||||
definition = props.variants && props.variants[definition];
|
||||
}
|
||||
/**
|
||||
* At this point we've resolved both functions and variant labels,
|
||||
* but the resolved variant label might itself have been a function.
|
||||
* If so, resolve. This can only have returned a valid target object.
|
||||
*/
|
||||
if (typeof definition === "function") {
|
||||
const [current, velocity] = getValueState(visualElement);
|
||||
definition = definition(custom !== undefined ? custom : props.custom, current, velocity);
|
||||
}
|
||||
return definition;
|
||||
}
|
||||
|
||||
export { resolveVariantFromProps };
|
||||
//# sourceMappingURL=resolve-variants.mjs.map
|
||||
1
node_modules/motion-dom/dist/es/render/utils/resolve-variants.mjs.map
generated
vendored
Normal file
1
node_modules/motion-dom/dist/es/render/utils/resolve-variants.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"resolve-variants.mjs","sources":["../../../../src/render/utils/resolve-variants.ts"],"sourcesContent":["import type {\n AnimationDefinition,\n MotionNodeOptions,\n TargetAndTransition,\n TargetResolver,\n} from \"../../node/types\"\nimport type { ResolvedValues } from \"../types\"\n\nfunction getValueState(visualElement?: any): [ResolvedValues, ResolvedValues] {\n const state: [ResolvedValues, ResolvedValues] = [{}, {}]\n\n visualElement?.values.forEach((value: any, key: string) => {\n state[0][key] = value.get()\n state[1][key] = value.getVelocity()\n })\n\n return state\n}\n\nexport function resolveVariantFromProps(\n props: MotionNodeOptions,\n definition: TargetAndTransition | TargetResolver,\n custom?: any,\n visualElement?: any\n): TargetAndTransition\nexport function resolveVariantFromProps(\n props: MotionNodeOptions,\n definition?: AnimationDefinition,\n custom?: any,\n visualElement?: any\n): undefined | TargetAndTransition\nexport function resolveVariantFromProps(\n props: MotionNodeOptions,\n definition?: AnimationDefinition,\n custom?: any,\n visualElement?: any\n) {\n /**\n * If the variant definition is a function, resolve.\n */\n if (typeof definition === \"function\") {\n const [current, velocity] = getValueState(visualElement)\n definition = definition(\n custom !== undefined ? custom : props.custom,\n current,\n velocity\n )\n }\n\n /**\n * If the variant definition is a variant label, or\n * the function returned a variant label, resolve.\n */\n if (typeof definition === \"string\") {\n definition = props.variants && props.variants[definition]\n }\n\n /**\n * At this point we've resolved both functions and variant labels,\n * but the resolved variant label might itself have been a function.\n * If so, resolve. This can only have returned a valid target object.\n */\n if (typeof definition === \"function\") {\n const [current, velocity] = getValueState(visualElement)\n definition = definition(\n custom !== undefined ? custom : props.custom,\n current,\n velocity\n )\n }\n\n return definition\n}\n"],"names":[],"mappings":"AAQA,SAAS,aAAa,CAAC,aAAmB,EAAA;AACtC,IAAA,MAAM,KAAK,GAAqC,CAAC,EAAE,EAAE,EAAE,CAAC;IAExD,aAAa,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,KAAU,EAAE,GAAW,KAAI;QACtD,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE;QAC3B,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,WAAW,EAAE;AACvC,IAAA,CAAC,CAAC;AAEF,IAAA,OAAO,KAAK;AAChB;AAcM,SAAU,uBAAuB,CACnC,KAAwB,EACxB,UAAgC,EAChC,MAAY,EACZ,aAAmB,EAAA;AAEnB;;AAEG;AACH,IAAA,IAAI,OAAO,UAAU,KAAK,UAAU,EAAE;QAClC,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,aAAa,CAAC,aAAa,CAAC;QACxD,UAAU,GAAG,UAAU,CACnB,MAAM,KAAK,SAAS,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM,EAC5C,OAAO,EACP,QAAQ,CACX;IACL;AAEA;;;AAGG;AACH,IAAA,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;QAChC,UAAU,GAAG,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC;IAC7D;AAEA;;;;AAIG;AACH,IAAA,IAAI,OAAO,UAAU,KAAK,UAAU,EAAE;QAClC,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,aAAa,CAAC,aAAa,CAAC;QACxD,UAAU,GAAG,UAAU,CACnB,MAAM,KAAK,SAAS,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM,EAC5C,OAAO,EACP,QAAQ,CACX;IACL;AAEA,IAAA,OAAO,UAAU;AACrB;;;;"}
|
||||
32
node_modules/motion-dom/dist/es/render/utils/setters.mjs
generated
vendored
Normal file
32
node_modules/motion-dom/dist/es/render/utils/setters.mjs
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
import { motionValue } from '../../value/index.mjs';
|
||||
import { resolveVariant } from './resolve-dynamic-variants.mjs';
|
||||
import { isKeyframesTarget } from './is-keyframes-target.mjs';
|
||||
|
||||
/**
|
||||
* Set VisualElement's MotionValue, creating a new MotionValue for it if
|
||||
* it doesn't exist.
|
||||
*/
|
||||
function setMotionValue(visualElement, key, value) {
|
||||
if (visualElement.hasValue(key)) {
|
||||
visualElement.getValue(key).set(value);
|
||||
}
|
||||
else {
|
||||
visualElement.addValue(key, motionValue(value));
|
||||
}
|
||||
}
|
||||
function resolveFinalValueInKeyframes(v) {
|
||||
// TODO maybe throw if v.length - 1 is placeholder token?
|
||||
return isKeyframesTarget(v) ? v[v.length - 1] || 0 : v;
|
||||
}
|
||||
function setTarget(visualElement, definition) {
|
||||
const resolved = resolveVariant(visualElement, definition);
|
||||
let { transitionEnd = {}, transition = {}, ...target } = resolved || {};
|
||||
target = { ...target, ...transitionEnd };
|
||||
for (const key in target) {
|
||||
const value = resolveFinalValueInKeyframes(target[key]);
|
||||
setMotionValue(visualElement, key, value);
|
||||
}
|
||||
}
|
||||
|
||||
export { setTarget };
|
||||
//# sourceMappingURL=setters.mjs.map
|
||||
1
node_modules/motion-dom/dist/es/render/utils/setters.mjs.map
generated
vendored
Normal file
1
node_modules/motion-dom/dist/es/render/utils/setters.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"setters.mjs","sources":["../../../../src/render/utils/setters.ts"],"sourcesContent":["import { motionValue } from \"../../value\"\nimport { resolveVariant } from \"./resolve-dynamic-variants\"\nimport { isKeyframesTarget } from \"./is-keyframes-target\"\nimport type { AnimationDefinition } from \"../../node/types\"\nimport type {\n AnyResolvedKeyframe,\n UnresolvedValueKeyframe,\n ValueKeyframesDefinition,\n} from \"../../animation/types\"\nimport type { VisualElement } from \"../VisualElement\"\n\n/**\n * Set VisualElement's MotionValue, creating a new MotionValue for it if\n * it doesn't exist.\n */\nfunction setMotionValue(\n visualElement: VisualElement,\n key: string,\n value: AnyResolvedKeyframe\n) {\n if (visualElement.hasValue(key)) {\n visualElement.getValue(key)!.set(value)\n } else {\n visualElement.addValue(key, motionValue(value))\n }\n}\n\nfunction resolveFinalValueInKeyframes(\n v: ValueKeyframesDefinition\n): UnresolvedValueKeyframe {\n // TODO maybe throw if v.length - 1 is placeholder token?\n return isKeyframesTarget(v) ? v[v.length - 1] || 0 : v\n}\n\nexport function setTarget(\n visualElement: VisualElement,\n definition: AnimationDefinition\n) {\n const resolved = resolveVariant(visualElement, definition)\n let { transitionEnd = {}, transition = {}, ...target } = resolved || {}\n\n target = { ...target, ...transitionEnd }\n\n for (const key in target) {\n const value = resolveFinalValueInKeyframes(\n target[key as keyof typeof target] as any\n )\n setMotionValue(visualElement, key, value as AnyResolvedKeyframe)\n }\n}\n"],"names":[],"mappings":";;;;AAWA;;;AAGG;AACH,SAAS,cAAc,CACnB,aAA4B,EAC5B,GAAW,EACX,KAA0B,EAAA;AAE1B,IAAA,IAAI,aAAa,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QAC7B,aAAa,CAAC,QAAQ,CAAC,GAAG,CAAE,CAAC,GAAG,CAAC,KAAK,CAAC;IAC3C;SAAO;QACH,aAAa,CAAC,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;IACnD;AACJ;AAEA,SAAS,4BAA4B,CACjC,CAA2B,EAAA;;IAG3B,OAAO,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;AAC1D;AAEM,SAAU,SAAS,CACrB,aAA4B,EAC5B,UAA+B,EAAA;IAE/B,MAAM,QAAQ,GAAG,cAAc,CAAC,aAAa,EAAE,UAAU,CAAC;AAC1D,IAAA,IAAI,EAAE,aAAa,GAAG,EAAE,EAAE,UAAU,GAAG,EAAE,EAAE,GAAG,MAAM,EAAE,GAAG,QAAQ,IAAI,EAAE;IAEvE,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,GAAG,aAAa,EAAE;AAExC,IAAA,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE;QACtB,MAAM,KAAK,GAAG,4BAA4B,CACtC,MAAM,CAAC,GAA0B,CAAQ,CAC5C;AACD,QAAA,cAAc,CAAC,aAAa,EAAE,GAAG,EAAE,KAA4B,CAAC;IACpE;AACJ;;;;"}
|
||||
15
node_modules/motion-dom/dist/es/render/utils/shallow-compare.mjs
generated
vendored
Normal file
15
node_modules/motion-dom/dist/es/render/utils/shallow-compare.mjs
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
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 };
|
||||
//# sourceMappingURL=shallow-compare.mjs.map
|
||||
1
node_modules/motion-dom/dist/es/render/utils/shallow-compare.mjs.map
generated
vendored
Normal file
1
node_modules/motion-dom/dist/es/render/utils/shallow-compare.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"shallow-compare.mjs","sources":["../../../../src/render/utils/shallow-compare.ts"],"sourcesContent":["export function shallowCompare(next: any[], prev: any[] | null) {\n if (!Array.isArray(prev)) return false\n\n const prevLength = prev.length\n\n if (prevLength !== next.length) return false\n\n for (let i = 0; i < prevLength; i++) {\n if (prev[i] !== next[i]) return false\n }\n\n return true\n}\n"],"names":[],"mappings":"AAAM,SAAU,cAAc,CAAC,IAAW,EAAE,IAAkB,EAAA;AAC1D,IAAA,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;AAAE,QAAA,OAAO,KAAK;AAEtC,IAAA,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM;AAE9B,IAAA,IAAI,UAAU,KAAK,IAAI,CAAC,MAAM;AAAE,QAAA,OAAO,KAAK;AAE5C,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,EAAE,CAAC,EAAE,EAAE;QACjC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC;AAAE,YAAA,OAAO,KAAK;IACzC;AAEA,IAAA,OAAO,IAAI;AACf;;;;"}
|
||||
13
node_modules/motion-dom/dist/es/render/utils/variant-props.mjs
generated
vendored
Normal file
13
node_modules/motion-dom/dist/es/render/utils/variant-props.mjs
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
const variantPriorityOrder = [
|
||||
"animate",
|
||||
"whileInView",
|
||||
"whileFocus",
|
||||
"whileHover",
|
||||
"whileTap",
|
||||
"whileDrag",
|
||||
"exit",
|
||||
];
|
||||
const variantProps = ["initial", ...variantPriorityOrder];
|
||||
|
||||
export { variantPriorityOrder, variantProps };
|
||||
//# sourceMappingURL=variant-props.mjs.map
|
||||
1
node_modules/motion-dom/dist/es/render/utils/variant-props.mjs.map
generated
vendored
Normal file
1
node_modules/motion-dom/dist/es/render/utils/variant-props.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"variant-props.mjs","sources":["../../../../src/render/utils/variant-props.ts"],"sourcesContent":["import type { AnimationType } from \"../types\"\n\nexport const variantPriorityOrder: AnimationType[] = [\n \"animate\",\n \"whileInView\",\n \"whileFocus\",\n \"whileHover\",\n \"whileTap\",\n \"whileDrag\",\n \"exit\",\n]\n\nexport const variantProps = [\"initial\", ...variantPriorityOrder]\n"],"names":[],"mappings":"AAEO,MAAM,oBAAoB,GAAoB;IACjD,SAAS;IACT,aAAa;IACb,YAAY;IACZ,YAAY;IACZ,UAAU;IACV,WAAW;IACX,MAAM;;AAGH,MAAM,YAAY,GAAG,CAAC,SAAS,EAAE,GAAG,oBAAoB;;;;"}
|
||||
Reference in New Issue
Block a user