motion-v 0.4.1 → 0.5.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.
Files changed (30) hide show
  1. package/dist/cjs/index.js +294 -96
  2. package/dist/es/components/AnimatePresence.vue.mjs +13 -2
  3. package/dist/es/components/LayoutGroup.vue.mjs +3 -23
  4. package/dist/es/components/Motion.vue.mjs +16 -15
  5. package/dist/es/components/presence.mjs +5 -2
  6. package/dist/es/components/use-layout-group.mjs +34 -0
  7. package/dist/es/components/use-pop-layout.mjs +47 -0
  8. package/dist/es/components/utils.mjs +8 -0
  9. package/dist/es/constants/index.mjs +1 -1
  10. package/dist/es/features/gestures/hover.mjs +4 -0
  11. package/dist/es/features/gestures/in-view.mjs +4 -0
  12. package/dist/es/features/layout/layout.mjs +7 -4
  13. package/dist/es/state/animate-variants-children.mjs +72 -0
  14. package/dist/es/state/motion-state.mjs +74 -20
  15. package/dist/es/state/schedule.mjs +1 -1
  16. package/dist/src/components/AnimatePresence.d.ts +2 -7
  17. package/dist/src/components/LayoutGroup.d.ts +1 -5
  18. package/dist/src/components/Motion.d.ts +1 -3
  19. package/dist/src/components/presence.d.ts +2 -1
  20. package/dist/src/components/type.d.ts +5 -24
  21. package/dist/src/components/use-layout-group.d.ts +20 -0
  22. package/dist/src/components/use-pop-layout.d.ts +6 -0
  23. package/dist/src/components/utils.d.ts +1 -0
  24. package/dist/src/features/layout/types.d.ts +1 -1
  25. package/dist/src/index.d.ts +5 -3
  26. package/dist/src/state/animate-variants-children.d.ts +15 -0
  27. package/dist/src/state/motion-state.d.ts +8 -7
  28. package/dist/src/types/state.d.ts +11 -2
  29. package/package.json +4 -3
  30. /package/dist/es/external/.pnpm/{@vueuse_shared@12.0.0_typescript@5.5.4 → @vueuse_shared@12.0.0_typescript@5.7.2}/external/@vueuse/shared/index.mjs +0 -0
@@ -1,7 +1,5 @@
1
- import { defineComponent, watch, renderSlot } from "vue";
2
- import { injectLayoutGroup, provideLayoutGroup, shouldInheritId, shouldInheritGroup } from "./context.mjs";
3
- import { nodeGroup } from "./group.mjs";
4
- import { useForceUpdate } from "./use-force-update.mjs";
1
+ import { defineComponent, renderSlot } from "vue";
2
+ import { useLayoutGroup } from "./use-layout-group.mjs";
5
3
  const _sfc_main = /* @__PURE__ */ defineComponent({
6
4
  __name: "LayoutGroup",
7
5
  props: {
@@ -10,25 +8,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
10
8
  },
11
9
  setup(__props) {
12
10
  const props = __props;
13
- const layoutGroup = injectLayoutGroup(null);
14
- const [forceRender, key] = useForceUpdate();
15
- function generateId() {
16
- const upstreamId = layoutGroup == null ? void 0 : layoutGroup.id;
17
- return shouldInheritId(props.inherit) && upstreamId ? props.id ? `${upstreamId}-${props.id}` : upstreamId : props.id;
18
- }
19
- function generateGroup() {
20
- return shouldInheritGroup(props.inherit) ? (layoutGroup == null ? void 0 : layoutGroup.group) || nodeGroup() : nodeGroup();
21
- }
22
- const memoizedContext = {
23
- id: generateId(),
24
- group: generateGroup(),
25
- forceRender,
26
- key
27
- };
28
- watch(key, () => {
29
- memoizedContext.id = generateId();
30
- });
31
- provideLayoutGroup(memoizedContext);
11
+ useLayoutGroup(props);
32
12
  return (_ctx, _cache) => {
33
13
  return renderSlot(_ctx.$slots, "default");
34
14
  };
@@ -3,8 +3,8 @@ import { injectMotion, injectLayoutGroup, provideMotion } from "./context.mjs";
3
3
  import { convertSvgStyleToAttributes, createStyles } from "../state/style.mjs";
4
4
  import { Primitive } from "./Primitive.mjs";
5
5
  import { MotionState } from "../state/motion-state.mjs";
6
- import { isSVGElement } from "../state/utils.mjs";
7
6
  import { injectAnimatePresence } from "./presence.mjs";
7
+ import { getMotionElement } from "./utils.mjs";
8
8
  import { isMotionValue } from "../utils/motion-value.mjs";
9
9
  const _sfc_main = /* @__PURE__ */ defineComponent({
10
10
  ...{
@@ -35,7 +35,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
35
35
  onPressEnd: { type: Function },
36
36
  onViewEnter: { type: Function },
37
37
  onViewLeave: { type: Function },
38
- layout: { type: Boolean },
38
+ layout: { type: [Boolean, String] },
39
39
  layoutId: {},
40
40
  layoutScroll: { type: Boolean },
41
41
  layoutRoot: { type: Boolean },
@@ -66,16 +66,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
66
66
  parentState
67
67
  );
68
68
  provideMotion(state);
69
- const instance = getCurrentInstance();
69
+ const instance = getCurrentInstance().proxy;
70
70
  onMounted(() => {
71
- state.mount(instance == null ? void 0 : instance.vnode.el);
72
- state.update({
71
+ state.mount(getMotionElement(instance.$el), {
73
72
  ...attrs,
74
- ...props
73
+ ...props,
74
+ initial: presenceInitial.value === false ? presenceInitial.value : props.initial === true ? void 0 : props.initial
75
75
  });
76
76
  });
77
77
  onUnmounted(() => {
78
- if (safeUnmount(instance == null ? void 0 : instance.vnode.el))
78
+ if (safeUnmount(getMotionElement(instance.$el)))
79
79
  state.unmount();
80
80
  });
81
81
  onUpdated(() => {
@@ -86,22 +86,23 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
86
86
  });
87
87
  });
88
88
  function getProps() {
89
+ const isSVG = state.visualElement.type === "svg";
89
90
  const attrsProps = { ...attrs };
90
91
  Object.keys(attrs).forEach((key) => {
91
92
  if (isMotionValue(attrs[key]))
92
93
  attrsProps[key] = attrs[key].get();
93
94
  });
94
95
  let styleProps = {
95
- ...props.style
96
+ ...props.style,
97
+ ...isSVG ? {} : state.visualElement.latestValues
96
98
  };
99
+ if (isSVG) {
100
+ const { attributes, style } = convertSvgStyleToAttributes(state.target);
101
+ Object.assign(attrsProps, attributes);
102
+ Object.assign(styleProps, style, props.style);
103
+ }
97
104
  if (!state.isMounted()) {
98
- if (isSVGElement(props.as)) {
99
- const { attributes, style } = convertSvgStyleToAttributes(state.getTarget());
100
- Object.assign(attrsProps, attributes);
101
- Object.assign(styleProps, style, props.style);
102
- } else {
103
- Object.assign(styleProps, state.getTarget(), props.style);
104
- }
105
+ Object.assign(styleProps, state.target, props.style);
105
106
  }
106
107
  styleProps = createStyles(styleProps);
107
108
  attrsProps.style = styleProps;
@@ -1,5 +1,7 @@
1
+ import { ref } from "vue";
1
2
  import { createContext } from "../utils/createContext.mjs";
2
- const doneCallbacks = /* @__PURE__ */ new Map();
3
+ const doneCallbacks = /* @__PURE__ */ new WeakMap();
4
+ const unPresenceDom = ref(/* @__PURE__ */ new WeakMap());
3
5
  function removeDoneCallback(element) {
4
6
  const prevDoneCallback = doneCallbacks.get(element);
5
7
  if (prevDoneCallback) {
@@ -12,5 +14,6 @@ export {
12
14
  doneCallbacks,
13
15
  injectAnimatePresence,
14
16
  provideAnimatePresence,
15
- removeDoneCallback
17
+ removeDoneCallback,
18
+ unPresenceDom
16
19
  };
@@ -0,0 +1,34 @@
1
+ import { watch } from "vue";
2
+ import { injectLayoutGroup, provideLayoutGroup } from "./context.mjs";
3
+ import { useForceUpdate } from "./use-force-update.mjs";
4
+ import { nodeGroup } from "./group.mjs";
5
+ function useLayoutGroup(props) {
6
+ const parentGroup = injectLayoutGroup(null);
7
+ const [forceRender, key] = useForceUpdate();
8
+ const context = {
9
+ id: getGroupId(props, parentGroup),
10
+ group: getGroup(props, parentGroup),
11
+ forceRender,
12
+ key
13
+ };
14
+ watch(key, () => {
15
+ context.id = getGroupId(props, parentGroup);
16
+ });
17
+ provideLayoutGroup(context);
18
+ return context;
19
+ }
20
+ function getGroupId(props, parentGroup) {
21
+ const shouldInherit = props.inherit === true || props.inherit === "id";
22
+ const parentId = parentGroup == null ? void 0 : parentGroup.id;
23
+ if (shouldInherit && parentId) {
24
+ return props.id ? `${parentId}-${props.id}` : parentId;
25
+ }
26
+ return props.id;
27
+ }
28
+ function getGroup(props, parentGroup) {
29
+ const shouldInherit = props.inherit === true || props.inherit === "group";
30
+ return shouldInherit ? (parentGroup == null ? void 0 : parentGroup.group) || nodeGroup() : nodeGroup();
31
+ }
32
+ export {
33
+ useLayoutGroup
34
+ };
@@ -0,0 +1,47 @@
1
+ function usePopLayout(props) {
2
+ const styles = /* @__PURE__ */ new WeakMap();
3
+ function addPopStyle(state) {
4
+ if (props.mode !== "popLayout")
5
+ return;
6
+ const size = {
7
+ height: state.element.offsetHeight || 0,
8
+ width: state.element.offsetWidth || 0,
9
+ top: state.element.offsetTop,
10
+ left: state.element.offsetLeft
11
+ };
12
+ state.element.dataset.motionPopId = state.id;
13
+ const style = document.createElement("style");
14
+ styles.set(state, style);
15
+ document.head.appendChild(style);
16
+ style.textContent = `
17
+ [data-motion-pop-id="${state.id}"] {
18
+ animation: pop 0.3s ease-in-out;
19
+ }
20
+ `;
21
+ if (style.sheet) {
22
+ style.sheet.insertRule(`
23
+ [data-motion-pop-id="${state.id}"] {
24
+ position: absolute !important;
25
+ width: ${size.width}px !important;
26
+ height: ${size.height}px !important;
27
+ top: ${size.top}px !important;
28
+ left: ${size.left}px !important;
29
+ }
30
+ `);
31
+ }
32
+ }
33
+ function removePopStyle(state) {
34
+ const style = styles.get(state);
35
+ if (style) {
36
+ styles.delete(state);
37
+ document.head.removeChild(style);
38
+ }
39
+ }
40
+ return {
41
+ addPopStyle,
42
+ removePopStyle
43
+ };
44
+ }
45
+ export {
46
+ usePopLayout
47
+ };
@@ -0,0 +1,8 @@
1
+ function getMotionElement(el) {
2
+ if ((el == null ? void 0 : el.nodeType) === 3 || (el == null ? void 0 : el.nodeType) === 8)
3
+ return getMotionElement(el.nextSibling);
4
+ return el;
5
+ }
6
+ export {
7
+ getMotionElement
8
+ };
@@ -1,7 +1,7 @@
1
1
  const components = {
2
2
  motion: [
3
3
  "Motion",
4
- "MotionPresence",
4
+ "AnimatePresence",
5
5
  "LayoutGroup"
6
6
  ]
7
7
  };
@@ -20,7 +20,11 @@ class HoverGesture extends BaseGesture {
20
20
  this.state.setActive("hover", true);
21
21
  });
22
22
  const onLeave = mouseEvent(element, "hoverend", () => {
23
+ var _a;
23
24
  this.state.setActive("hover", false);
25
+ (_a = this.state.visualElement.variantChildren) == null ? void 0 : _a.forEach((child) => {
26
+ child.state.setActive("hover", false);
27
+ });
24
28
  });
25
29
  element.addEventListener("pointerenter", onEnter);
26
30
  element.addEventListener("pointerleave", onLeave);
@@ -12,7 +12,11 @@ class InViewGesture extends BaseGesture {
12
12
  const element = this.state.element;
13
13
  const { once, ...viewOptions } = ((_a = this.state.getOptions()) == null ? void 0 : _a.inViewOptions) || {};
14
14
  return inView(element, (enterEntry) => {
15
+ var _a2;
15
16
  this.state.setActive("inView", true);
17
+ (_a2 = this.state.visualElement.variantChildren) == null ? void 0 : _a2.forEach((child) => {
18
+ child.state.setActive("inView", true);
19
+ });
16
20
  dispatchPointerEvent(element, "viewenter", enterEntry);
17
21
  if (!once) {
18
22
  return (leaveEntry) => {
@@ -40,11 +40,8 @@ class LayoutFeature extends Feature {
40
40
  (_a = visualElement.projection) == null ? void 0 : _a.root.didUpdate();
41
41
  });
42
42
  onBeforeUnmount(() => {
43
- var _a;
44
43
  if (visualElement.projection) {
45
- visualElement.projection.unmount();
46
- if ((_a = this.layoutGroup) == null ? void 0 : _a.group)
47
- this.layoutGroup.group.remove(visualElement.projection);
44
+ visualElement.projection.willUpdate();
48
45
  }
49
46
  });
50
47
  }
@@ -67,6 +64,12 @@ class LayoutFeature extends Feature {
67
64
  }
68
65
  }
69
66
  unmount() {
67
+ var _a;
68
+ if (this.state.visualElement.projection) {
69
+ this.state.visualElement.projection.unmount();
70
+ if ((_a = this.layoutGroup) == null ? void 0 : _a.group)
71
+ this.layoutGroup.group.remove(this.state.visualElement.projection);
72
+ }
70
73
  }
71
74
  }
72
75
  export {
@@ -0,0 +1,72 @@
1
+ import { style } from "./style.mjs";
2
+ import { transformResetValue } from "./transform.mjs";
3
+ import { resolveVariant, hasChanged, getOptions } from "./utils.mjs";
4
+ import { animate } from "../external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/animation/animate/index.mjs";
5
+ function animateVariantsChildren(state, activeState) {
6
+ const variantChildren = state.visualElement.variantChildren;
7
+ if (!(variantChildren == null ? void 0 : variantChildren.size)) {
8
+ return {
9
+ animations: [],
10
+ getAnimations: () => Promise.resolve()
11
+ };
12
+ }
13
+ const animationFactories = [];
14
+ Array.from(variantChildren).forEach((child, index) => {
15
+ var _a;
16
+ const prevTarget = child.state.target;
17
+ const childState = child.state;
18
+ childState.target = {};
19
+ for (const name in activeState) {
20
+ childState.activeStates[name] = true;
21
+ const { definition, transition } = activeState[name];
22
+ const { staggerChildren = 0, staggerDirection = 1, delayChildren = 0 } = transition;
23
+ const maxStaggerDuration = (variantChildren.size - 1) * staggerChildren;
24
+ const generateStaggerDuration = staggerDirection === 1 ? (i = 0) => i * staggerChildren : (i = 0) => maxStaggerDuration - i * staggerChildren;
25
+ const variant = resolveVariant(
26
+ definition,
27
+ child.props.variants,
28
+ child.props.custom
29
+ );
30
+ const animationOptions = {};
31
+ const allTarget = { ...prevTarget, ...variant };
32
+ for (const key in allTarget) {
33
+ if (key === "transition")
34
+ continue;
35
+ childState.target[key] = allTarget[key];
36
+ if (childState.target[key] === void 0) {
37
+ childState.target[key] = childState.baseTarget[key];
38
+ }
39
+ if (hasChanged(prevTarget[key], childState.target[key])) {
40
+ (_a = childState.baseTarget)[key] ?? (_a[key] = style.get(child.current, key));
41
+ animationOptions[key] = getOptions(
42
+ Object.assign({}, transition, allTarget.transition, child.props.transition),
43
+ key
44
+ );
45
+ const keyValue = childState.target[key] === "none" ? transformResetValue[key] : childState.target[key];
46
+ animationFactories.push(
47
+ () => {
48
+ var _a2;
49
+ return animate(
50
+ child.current,
51
+ {
52
+ [key]: keyValue
53
+ },
54
+ {
55
+ ...animationOptions[key] || {},
56
+ delay: (((_a2 = animationOptions[key]) == null ? void 0 : _a2.delay) || 0) + delayChildren + generateStaggerDuration(index)
57
+ }
58
+ );
59
+ }
60
+ );
61
+ }
62
+ }
63
+ }
64
+ });
65
+ return {
66
+ animations: animationFactories,
67
+ getAnimations: () => Promise.all(animationFactories.map((factory) => factory()))
68
+ };
69
+ }
70
+ export {
71
+ animateVariantsChildren
72
+ };
@@ -7,18 +7,22 @@ import { transformResetValue } from "./transform.mjs";
7
7
  import { scheduleAnimation, unscheduleAnimation } from "./schedule.mjs";
8
8
  import { motionEvent } from "./event.mjs";
9
9
  import { createVisualElement } from "./create-visual-element.mjs";
10
+ import { animateVariantsChildren } from "./animate-variants-children.mjs";
10
11
  import { animate } from "../external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/animation/animate/index.mjs";
11
- import { isDef } from "../external/.pnpm/@vueuse_shared@12.0.0_typescript@5.5.4/external/@vueuse/shared/index.mjs";
12
+ import { isDef } from "../external/.pnpm/@vueuse_shared@12.0.0_typescript@5.7.2/external/@vueuse/shared/index.mjs";
12
13
  const STATE_TYPES = ["initial", "animate", "inView", "hover", "press", "exit", "drag"];
13
14
  const mountedStates = /* @__PURE__ */ new WeakMap();
15
+ let id = 0;
14
16
  class MotionState {
15
17
  constructor(options, parent) {
16
18
  this.element = null;
19
+ this.isFirstAnimate = true;
17
20
  this.activeStates = {
18
21
  initial: true,
19
22
  animate: true
20
23
  };
21
24
  this._context = null;
25
+ this.id = `motion-state-${id++}`;
22
26
  this.options = options;
23
27
  this.parent = parent;
24
28
  this.depth = (parent == null ? void 0 : parent.depth) + 1 || 0;
@@ -26,7 +30,10 @@ class MotionState {
26
30
  presenceContext: null,
27
31
  parent: parent == null ? void 0 : parent.visualElement,
28
32
  props: {
29
- ...this.options
33
+ ...this.options,
34
+ whileHover: this.options.hover,
35
+ whileTap: this.options.press,
36
+ whileInView: this.options.inView
30
37
  },
31
38
  visualState: {
32
39
  renderState: {
@@ -62,19 +69,29 @@ class MotionState {
62
69
  get initial() {
63
70
  return isDef(this.options.initial) ? this.options.initial : this.context.initial;
64
71
  }
65
- mount(element) {
72
+ updateOptions() {
66
73
  var _a;
74
+ this.visualElement.update({
75
+ ...this.options,
76
+ whileHover: this.options.hover,
77
+ whileTap: this.options.press,
78
+ whileInView: this.options.inView
79
+ }, (_a = this.parent) == null ? void 0 : _a.context);
80
+ }
81
+ mount(element, options) {
67
82
  invariant(
68
83
  Boolean(element),
69
84
  "Animation state must be mounted with valid Element"
70
85
  );
71
86
  this.element = element;
87
+ this.options = options;
72
88
  mountedStates.set(element, this);
73
89
  if (!visualElementStore.get(element)) {
74
90
  this.visualElement.mount(element);
75
91
  visualElementStore.set(element, this.visualElement);
76
92
  }
77
- this.visualElement.update(this.options, (_a = this.parent) == null ? void 0 : _a.context);
93
+ this.visualElement.state = this;
94
+ this.updateOptions();
78
95
  if (typeof this.initial === "object") {
79
96
  for (const key in this.initial) {
80
97
  this.visualElement.setStaticValue(key, this.initial[key]);
@@ -85,6 +102,7 @@ class MotionState {
85
102
  }
86
103
  }
87
104
  this.featureManager.mount();
105
+ scheduleAnimation(this);
88
106
  }
89
107
  unmount() {
90
108
  var _a;
@@ -94,14 +112,13 @@ class MotionState {
94
112
  this.featureManager.unmount();
95
113
  }
96
114
  update(options) {
97
- var _a;
98
115
  this.options = options;
99
- this.visualElement.update(this.options, (_a = this.parent) == null ? void 0 : _a.context);
116
+ this.updateOptions();
100
117
  this.featureManager.update();
101
118
  scheduleAnimation(this);
102
119
  }
103
120
  setActive(name, isActive) {
104
- if (!this.element)
121
+ if (!this.element || this.activeStates[name] === isActive)
105
122
  return;
106
123
  this.activeStates[name] = isActive;
107
124
  scheduleAnimation(this);
@@ -109,15 +126,31 @@ class MotionState {
109
126
  *animateUpdates() {
110
127
  const prevTarget = this.target;
111
128
  this.target = {};
129
+ const activeState = {};
112
130
  const animationOptions = {};
131
+ let transition;
113
132
  for (const name of STATE_TYPES) {
133
+ if (name === "initial") {
134
+ if (!this.isFirstAnimate) {
135
+ continue;
136
+ }
137
+ this.isFirstAnimate = false;
138
+ }
114
139
  if (!this.activeStates[name])
115
140
  continue;
141
+ const definition = isDef(this.options[name]) ? this.options[name] : this.context[name];
116
142
  const variant = resolveVariant(
117
- isDef(this.options[name]) ? this.options[name] : this.context[name],
143
+ definition,
118
144
  this.options.variants,
119
145
  this.options.custom
120
146
  );
147
+ transition = Object.assign({}, this.options.transition, variant == null ? void 0 : variant.transition);
148
+ if (typeof definition === "string") {
149
+ activeState[name] = {
150
+ definition,
151
+ transition
152
+ };
153
+ }
121
154
  if (!variant)
122
155
  continue;
123
156
  const allTarget = { ...prevTarget, ...variant };
@@ -126,7 +159,7 @@ class MotionState {
126
159
  continue;
127
160
  this.target[key] = variant[key];
128
161
  animationOptions[key] = getOptions(
129
- variant.transition ?? this.options.transition ?? {},
162
+ transition,
130
163
  key
131
164
  );
132
165
  }
@@ -143,12 +176,13 @@ class MotionState {
143
176
  }
144
177
  if (hasChanged(prevTarget[key], this.target[key])) {
145
178
  (_a = this.baseTarget)[key] ?? (_a[key] = style.get(this.element, key));
179
+ const keyValue = this.target[key] === "none" ? transformResetValue[key] : this.target[key];
146
180
  animationFactories.push(
147
181
  () => {
148
182
  return animate(
149
183
  this.element,
150
184
  {
151
- [key]: this.target[key] === "none" ? transformResetValue[key] : this.target[key]
185
+ [key]: keyValue
152
186
  },
153
187
  animationOptions[key] || {}
154
188
  );
@@ -156,14 +190,40 @@ class MotionState {
156
190
  );
157
191
  }
158
192
  });
193
+ let getChildAnimations = () => Promise.resolve();
194
+ let childAnimations = [];
195
+ if (Object.keys(activeState).length) {
196
+ const { getAnimations, animations: animations2 } = animateVariantsChildren(this, activeState);
197
+ getChildAnimations = getAnimations;
198
+ childAnimations = animations2;
199
+ }
159
200
  yield;
160
- const animations = animationFactories.map((factory) => factory()).filter(Boolean);
161
- if (!animations.length)
201
+ let animations;
202
+ const getAnimation = () => {
203
+ animations = animationFactories.map((factory) => factory()).filter(Boolean);
204
+ return Promise.all(animations);
205
+ };
206
+ const { when } = transition;
207
+ let animationPromise;
208
+ if (when) {
209
+ const [first, last] = when === "beforeChildren" ? [getAnimation, getChildAnimations] : [getChildAnimations, getAnimation];
210
+ animationPromise = first().then(() => last());
211
+ } else {
212
+ animationPromise = Promise.all([getAnimation(), getChildAnimations()]);
213
+ }
214
+ const isExit = this.activeStates.exit;
215
+ if (!(animations == null ? void 0 : animations.length) && !childAnimations.length) {
216
+ if (isExit) {
217
+ this.element.dispatchEvent(motionEvent("motionstart", this.target));
218
+ this.element.dispatchEvent(motionEvent("motioncomplete", {
219
+ ...this.target
220
+ }, isExit));
221
+ }
162
222
  return;
223
+ }
163
224
  const animationTarget = this.target;
164
225
  this.element.dispatchEvent(motionEvent("motionstart", animationTarget));
165
- const isExit = this.activeStates.exit;
166
- Promise.all(animations).then(() => {
226
+ animationPromise.then(() => {
167
227
  this.element.dispatchEvent(motionEvent("motioncomplete", {
168
228
  ...animationTarget
169
229
  }, isExit));
@@ -172,15 +232,9 @@ class MotionState {
172
232
  isMounted() {
173
233
  return Boolean(this.element);
174
234
  }
175
- getDepth() {
176
- return this.depth;
177
- }
178
235
  getOptions() {
179
236
  return this.options;
180
237
  }
181
- getTarget() {
182
- return this.target;
183
- }
184
238
  }
185
239
  export {
186
240
  MotionState,
@@ -22,7 +22,7 @@ function unscheduleAnimation(state) {
22
22
  scheduled && removeItem(scheduled, state);
23
23
  }
24
24
  function compareByDepth(a, b) {
25
- return a.getDepth() - b.getDepth();
25
+ return a.depth - b.depth;
26
26
  }
27
27
  export {
28
28
  scheduleAnimation,
@@ -1,9 +1,4 @@
1
- export interface AnimatePresenceProps {
2
- mode?: 'wait' | 'sync';
3
- initial?: boolean;
4
- multiple?: boolean;
5
- as?: string;
6
- }
1
+ import { AnimatePresenceProps } from './type';
7
2
  declare function __VLS_template(): {
8
3
  slots: {
9
4
  default?(_: {}): any;
@@ -21,7 +16,7 @@ declare const __VLS_component: import('vue').DefineComponent<__VLS_WithDefaults<
21
16
  initial: boolean;
22
17
  multiple: boolean;
23
18
  }>>>, {
24
- mode: "wait" | "sync";
19
+ mode: "wait" | "popLayout" | "sync";
25
20
  initial: boolean;
26
21
  multiple: boolean;
27
22
  }, {}>;
@@ -1,8 +1,4 @@
1
- import { InheritOption } from './context';
2
- export interface LayoutGroupProps {
3
- id?: string;
4
- inherit?: InheritOption;
5
- }
1
+ import { LayoutGroupProps } from './use-layout-group';
6
2
  declare function __VLS_template(): {
7
3
  slots: {
8
4
  default?(_: {}): any;
@@ -12,9 +12,7 @@ declare const _default: <T extends ElementType = "div", K = unknown>(__VLS_props
12
12
  default?(_: {}): any;
13
13
  };
14
14
  emit: {};
15
- }>) => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
16
- [key: string]: any;
17
- }> & {
15
+ }>) => import('vue').VNode & {
18
16
  __ctx?: Awaited<typeof __VLS_setup>;
19
17
  };
20
18
  export default _default;
@@ -1,5 +1,6 @@
1
1
  import { Ref } from 'vue';
2
- export declare const doneCallbacks: Map<Element, VoidFunction>;
2
+ export declare const doneCallbacks: WeakMap<Element, VoidFunction>;
3
+ export declare const unPresenceDom: Ref<WeakMap<Element, boolean> & Omit<WeakMap<Element, boolean>, keyof WeakMap<any, any>>>;
3
4
  export declare function removeDoneCallback(element: Element): void;
4
5
  export interface PresenceContext {
5
6
  initial: Ref<boolean>;
@@ -1,25 +1,6 @@
1
- interface SVGRenderState {
2
- style: Record<string, any>;
3
- transform: Record<string, any>;
4
- transformOrigin: {
5
- originX?: string | number;
6
- originY?: string | number;
7
- originZ?: string | number;
8
- };
9
- attrs: Record<string, any>;
10
- dimensions?: {
11
- x: number;
12
- y: number;
13
- width: number;
14
- height: number;
15
- };
16
- }
17
- interface SVGProps {
18
- attrX?: number;
19
- attrY?: number;
20
- attrScale?: number;
21
- pathLength?: number;
22
- pathSpacing?: number;
23
- pathOffset?: number;
24
- [key: string]: any;
1
+ export interface AnimatePresenceProps {
2
+ mode?: 'wait' | 'popLayout' | 'sync';
3
+ initial?: boolean;
4
+ multiple?: boolean;
5
+ as?: string;
25
6
  }
@@ -0,0 +1,20 @@
1
+ import { LayoutGroupState } from './context';
2
+ /**
3
+ * Props for configuring layout group behavior
4
+ */
5
+ export interface LayoutGroupProps {
6
+ /** Optional ID for the layout group */
7
+ id?: string;
8
+ /**
9
+ * Controls inheritance of parent group properties:
10
+ * - true: Inherit both id and group
11
+ * - 'id': Only inherit id
12
+ * - 'group': Only inherit group
13
+ */
14
+ inherit?: boolean | 'id' | 'group';
15
+ }
16
+ /**
17
+ * Hook to create and manage a layout group
18
+ * Handles group inheritance, force updates, and context management
19
+ */
20
+ export declare function useLayoutGroup(props: LayoutGroupProps): LayoutGroupState;