motion-v 2.0.0-beta.1 → 2.0.0-beta.2
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.
|
@@ -35,6 +35,7 @@ export declare const ReorderGroup: <T, K, V>(__VLS_props: NonNullable<Awaited<ty
|
|
|
35
35
|
[k: string]: import('../..').VariantType | ((custom: K) => import('../..').VariantType);
|
|
36
36
|
};
|
|
37
37
|
custom?: K;
|
|
38
|
+
initial?: import('motion-dom').VariantLabels | import('../..').VariantType | boolean;
|
|
38
39
|
style?: Partial<{
|
|
39
40
|
[x: `--${string}`]: string | number | import('motion-dom').MotionValue<any>;
|
|
40
41
|
string?: string | number | import('motion-dom').MotionValue<any>;
|
|
@@ -731,7 +732,6 @@ export declare const ReorderGroup: <T, K, V>(__VLS_props: NonNullable<Awaited<ty
|
|
|
731
732
|
inView?: import('motion-dom').VariantLabels | import('../..').VariantType;
|
|
732
733
|
onHoverStart?: import('../../features/gestures/hover/types').HoverEvent;
|
|
733
734
|
onHoverEnd?: import('../../features/gestures/hover/types').HoverEvent;
|
|
734
|
-
initial?: import('motion-dom').VariantLabels | import('../..').VariantType | boolean;
|
|
735
735
|
exit?: import('motion-dom').VariantLabels | import('../..').VariantType;
|
|
736
736
|
onPress?: import('../../features/gestures/press/types').PressEvent;
|
|
737
737
|
onPressCancel?: import('../../features/gestures/press/types').PressEvent;
|
|
@@ -820,6 +820,7 @@ export declare const ReorderItem: <T extends import('../..').ElementType = "li",
|
|
|
820
820
|
[k: string]: import('../..').VariantType | ((custom: unknown) => import('../..').VariantType);
|
|
821
821
|
};
|
|
822
822
|
custom?: unknown;
|
|
823
|
+
initial?: import('motion-dom').VariantLabels | import('../..').VariantType | boolean;
|
|
823
824
|
style?: Partial<{
|
|
824
825
|
[x: `--${string}`]: string | number | import('motion-dom').MotionValue<any>;
|
|
825
826
|
string?: string | number | import('motion-dom').MotionValue<any>;
|
|
@@ -1516,7 +1517,6 @@ export declare const ReorderItem: <T extends import('../..').ElementType = "li",
|
|
|
1516
1517
|
inView?: import('motion-dom').VariantLabels | import('../..').VariantType;
|
|
1517
1518
|
onHoverStart?: import('../../features/gestures/hover/types').HoverEvent;
|
|
1518
1519
|
onHoverEnd?: import('../../features/gestures/hover/types').HoverEvent;
|
|
1519
|
-
initial?: import('motion-dom').VariantLabels | import('../..').VariantType | boolean;
|
|
1520
1520
|
exit?: import('motion-dom').VariantLabels | import('../..').VariantType;
|
|
1521
1521
|
onPress?: import('../../features/gestures/press/types').PressEvent;
|
|
1522
1522
|
onPressCancel?: import('../../features/gestures/press/types').PressEvent;
|
|
@@ -1608,6 +1608,7 @@ export declare const Reorder: {
|
|
|
1608
1608
|
[k: string]: import('../..').VariantType | ((custom: K) => import('../..').VariantType);
|
|
1609
1609
|
};
|
|
1610
1610
|
custom?: K;
|
|
1611
|
+
initial?: import('motion-dom').VariantLabels | import('../..').VariantType | boolean;
|
|
1611
1612
|
style?: Partial<{
|
|
1612
1613
|
[x: `--${string}`]: string | number | import('motion-dom').MotionValue<any>;
|
|
1613
1614
|
string?: string | number | import('motion-dom').MotionValue<any>;
|
|
@@ -2304,7 +2305,6 @@ export declare const Reorder: {
|
|
|
2304
2305
|
inView?: import('motion-dom').VariantLabels | import('../..').VariantType;
|
|
2305
2306
|
onHoverStart?: import('../../features/gestures/hover/types').HoverEvent;
|
|
2306
2307
|
onHoverEnd?: import('../../features/gestures/hover/types').HoverEvent;
|
|
2307
|
-
initial?: import('motion-dom').VariantLabels | import('../..').VariantType | boolean;
|
|
2308
2308
|
exit?: import('motion-dom').VariantLabels | import('../..').VariantType;
|
|
2309
2309
|
onPress?: import('../../features/gestures/press/types').PressEvent;
|
|
2310
2310
|
onPressCancel?: import('../../features/gestures/press/types').PressEvent;
|
|
@@ -2393,6 +2393,7 @@ export declare const Reorder: {
|
|
|
2393
2393
|
[k: string]: import('../..').VariantType | ((custom: unknown) => import('../..').VariantType);
|
|
2394
2394
|
};
|
|
2395
2395
|
custom?: unknown;
|
|
2396
|
+
initial?: import('motion-dom').VariantLabels | import('../..').VariantType | boolean;
|
|
2396
2397
|
style?: Partial<{
|
|
2397
2398
|
[x: `--${string}`]: string | number | import('motion-dom').MotionValue<any>;
|
|
2398
2399
|
string?: string | number | import('motion-dom').MotionValue<any>;
|
|
@@ -3089,7 +3090,6 @@ export declare const Reorder: {
|
|
|
3089
3090
|
inView?: import('motion-dom').VariantLabels | import('../..').VariantType;
|
|
3090
3091
|
onHoverStart?: import('../../features/gestures/hover/types').HoverEvent;
|
|
3091
3092
|
onHoverEnd?: import('../../features/gestures/hover/types').HoverEvent;
|
|
3092
|
-
initial?: import('motion-dom').VariantLabels | import('../..').VariantType | boolean;
|
|
3093
3093
|
exit?: import('motion-dom').VariantLabels | import('../..').VariantType;
|
|
3094
3094
|
onPress?: import('../../features/gestures/press/types').PressEvent;
|
|
3095
3095
|
onPressCancel?: import('../../features/gestures/press/types').PressEvent;
|
|
@@ -4,7 +4,7 @@ import { defaultConfig, motionConfigInjectionKey } from "../components/motion-co
|
|
|
4
4
|
import { animatePresenceInjectionKey } from "../components/animate-presence/presence.mjs";
|
|
5
5
|
import { createSVGStyles, createStyles } from "../state/style.mjs";
|
|
6
6
|
import { updateLazyFeatures } from "../features/lazy-features.mjs";
|
|
7
|
-
import { isSVGElement } from "../state/utils.mjs";
|
|
7
|
+
import { isSVGElement, resolveInitialValues } from "../state/utils.mjs";
|
|
8
8
|
import { MotionState, mountedStates } from "../state/motion-state.mjs";
|
|
9
9
|
import { createVisualElement } from "../state/create-visual-element.mjs";
|
|
10
10
|
import { domMax } from "../features/dom-max.mjs";
|
|
@@ -47,9 +47,9 @@ function computeStyles(values, tag, styleProp) {
|
|
|
47
47
|
}
|
|
48
48
|
function resolveSSRStyles(options) {
|
|
49
49
|
if (!options) return null;
|
|
50
|
-
const
|
|
51
|
-
if (Object.keys(
|
|
52
|
-
return computeStyles(
|
|
50
|
+
const latestValues = resolveInitialValues(options);
|
|
51
|
+
if (Object.keys(latestValues).length === 0) return null;
|
|
52
|
+
return computeStyles(latestValues, options.as || "div", options.style).styles;
|
|
53
53
|
}
|
|
54
54
|
function applyInitialStyles(el, state) {
|
|
55
55
|
const { styles, attrs } = computeStyles(state.latestValues, resolveTag(el), state.options.style);
|
|
@@ -134,7 +134,6 @@ function createMotionDirective(featureBundle, defaultOptions) {
|
|
|
134
134
|
updated(el, binding, vnode) {
|
|
135
135
|
const state = mountedStates.get(el);
|
|
136
136
|
if (!state) return;
|
|
137
|
-
cleanVNodeProps(el, vnode.props);
|
|
138
137
|
const provides = resolveProvides(vnode, binding);
|
|
139
138
|
const { options } = buildMotionOptions(mergeMotionProps(vnode, binding.value), provides, resolveTag(el));
|
|
140
139
|
state.update(options);
|
|
@@ -24,7 +24,6 @@ export declare class MotionState {
|
|
|
24
24
|
constructor(options: Options, parent?: MotionState);
|
|
25
25
|
private _context;
|
|
26
26
|
get context(): MotionStateContext;
|
|
27
|
-
private resolveInitialLatestValues;
|
|
28
27
|
/**
|
|
29
28
|
* Initialize features from options and global lazy features
|
|
30
29
|
* Features are stored by key to avoid duplicate instantiation
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { lazyFeatures } from "../features/lazy-features.mjs";
|
|
2
|
-
import { isSVGElement,
|
|
2
|
+
import { isSVGElement, resolveInitialValues } from "./utils.mjs";
|
|
3
3
|
import { motionGlobalConfig } from "../config.mjs";
|
|
4
4
|
import { frame, isVariantLabel } from "motion-dom";
|
|
5
5
|
import { invariant } from "hey-listen";
|
|
@@ -15,8 +15,7 @@ var MotionState = class {
|
|
|
15
15
|
this.options = options;
|
|
16
16
|
this.parent = parent;
|
|
17
17
|
parent?.children?.add(this);
|
|
18
|
-
|
|
19
|
-
this.resolveInitialLatestValues(initialVariantSource);
|
|
18
|
+
this.latestValues = resolveInitialValues(options, this.context);
|
|
20
19
|
this.type = isSVGElement(this.options.as) ? "svg" : "html";
|
|
21
20
|
}
|
|
22
21
|
get context() {
|
|
@@ -27,15 +26,6 @@ var MotionState = class {
|
|
|
27
26
|
} });
|
|
28
27
|
return this._context;
|
|
29
28
|
}
|
|
30
|
-
resolveInitialLatestValues(initialVariantSource) {
|
|
31
|
-
const custom = this.options.custom ?? this.options.presenceContext?.custom;
|
|
32
|
-
this.latestValues = initialVariantSource.reduce((acc, variant) => {
|
|
33
|
-
return {
|
|
34
|
-
...acc,
|
|
35
|
-
...resolveVariant$1(this.options[variant] || this.context[variant], this.options.variants, custom)
|
|
36
|
-
};
|
|
37
|
-
}, {});
|
|
38
|
-
}
|
|
39
29
|
updateFeatures() {
|
|
40
30
|
if (!this.visualElement) return;
|
|
41
31
|
for (const FeatureCtor of lazyFeatures) {
|
package/dist/es/state/utils.d.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import { AsTag, Options, VariantType } from '../types';
|
|
1
|
+
import { AsTag, MotionStateContext, Options, VariantType } from '../types';
|
|
2
2
|
export declare function resolveVariant(definition?: Options['animate'], variants?: Options['variants'], custom?: Options['custom']): VariantType | undefined;
|
|
3
|
+
/**
|
|
4
|
+
* Resolve initial latest values from variant sources.
|
|
5
|
+
* Shared by MotionState constructor and SSR style resolution.
|
|
6
|
+
*
|
|
7
|
+
* @param options - Motion options
|
|
8
|
+
* @param context - Optional parent context for variant inheritance (MotionState passes this)
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolveInitialValues(options: Options, context?: MotionStateContext): Record<string, any>;
|
|
3
11
|
export declare function shallowCompare(next: any[], prev: any[]): boolean;
|
|
4
12
|
export declare function isCssVar(name: string): boolean;
|
|
5
13
|
export declare const svgElements: readonly ["animate", "circle", "defs", "desc", "ellipse", "g", "image", "line", "filter", "marker", "mask", "metadata", "path", "pattern", "polygon", "polyline", "rect", "stop", "svg", "switch", "symbol", "text", "tspan", "use", "view", "clipPath", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "foreignObject", "linearGradient", "radialGradient", "textPath"];
|
package/dist/es/state/utils.mjs
CHANGED
|
@@ -21,6 +21,16 @@ function resolveVariant(definition, variants, custom) {
|
|
|
21
21
|
...transitionEnd
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
+
function resolveInitialValues(options, context) {
|
|
25
|
+
const sources = (options.initial === void 0 && options.variants ? context?.initial : options.initial) === false ? ["initial", "animate"] : ["initial"];
|
|
26
|
+
const custom = options.custom ?? options.presenceContext?.custom;
|
|
27
|
+
return sources.reduce((acc, variant) => {
|
|
28
|
+
return {
|
|
29
|
+
...acc,
|
|
30
|
+
...resolveVariant(options[variant] || context?.[variant], options.variants, custom)
|
|
31
|
+
};
|
|
32
|
+
}, {});
|
|
33
|
+
}
|
|
24
34
|
function shallowCompare(next, prev) {
|
|
25
35
|
const prevLength = prev?.length;
|
|
26
36
|
if (prevLength !== next.length) return false;
|
|
@@ -87,4 +97,4 @@ var svgElementSet = new Set([
|
|
|
87
97
|
function isSVGElement(as) {
|
|
88
98
|
return svgElementSet.has(as);
|
|
89
99
|
}
|
|
90
|
-
export { isSVGElement,
|
|
100
|
+
export { isSVGElement, resolveInitialValues, shallowCompare };
|