motion-v 0.10.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -4875,7 +4875,7 @@ function stagger(duration = 0.1, { startDelay = 0, from = 0, ease: ease2 } = {})
4875
4875
  return startDelay + delay2;
4876
4876
  };
4877
4877
  }
4878
- function delay(callback, timeout) {
4878
+ function delay$1(callback, timeout) {
4879
4879
  const start = time.now();
4880
4880
  const checkElapsed = ({ timestamp }) => {
4881
4881
  const elapsed = timestamp - start;
@@ -4888,7 +4888,7 @@ function delay(callback, timeout) {
4888
4888
  return () => cancelFrame(checkElapsed);
4889
4889
  }
4890
4890
  function delayInSeconds(callback, timeout) {
4891
- return delay(callback, secondsToMilliseconds$1(timeout));
4891
+ return delay$1(callback, secondsToMilliseconds$1(timeout));
4892
4892
  }
4893
4893
  const distance = (a, b) => Math.abs(a - b);
4894
4894
  function distance2D(a, b) {
@@ -5012,7 +5012,7 @@ function shallowCompare(next, prev) {
5012
5012
  return true;
5013
5013
  }
5014
5014
  function getOptions(options, key) {
5015
- return options[key] ? { ...options, ...options[key] } : { ...options };
5015
+ return options[key] ? { ...options, ...options[key], [key]: void 0 } : { ...options };
5016
5016
  }
5017
5017
  function isCssVar(name) {
5018
5018
  return name == null ? void 0 : name.startsWith("--");
@@ -6422,22 +6422,22 @@ class LayoutFeature extends Feature {
6422
6422
  }
6423
6423
  didUpdate() {
6424
6424
  var _a, _b;
6425
- if (this.state.options.layout || this.state.options.layoutId)
6425
+ if (this.state.options.layout || this.state.options.layoutId || this.state.options.drag)
6426
6426
  (_b = (_a = this.state.visualElement.projection) == null ? void 0 : _a.root) == null ? void 0 : _b.didUpdate();
6427
6427
  }
6428
6428
  mount() {
6429
6429
  var _a;
6430
6430
  const options = this.state.options;
6431
6431
  const layoutGroup = this.state.options.layoutGroup;
6432
- if (options.layout || options.layoutId || options.drag) {
6432
+ if (options.layout || options.layoutId) {
6433
6433
  const projection = this.state.visualElement.projection;
6434
6434
  if (projection) {
6435
6435
  projection.promote();
6436
6436
  (_a = layoutGroup == null ? void 0 : layoutGroup.group) == null ? void 0 : _a.add(projection);
6437
6437
  }
6438
- this.didUpdate();
6439
6438
  globalProjectionState.hasEverUpdated = true;
6440
6439
  }
6440
+ this.didUpdate();
6441
6441
  }
6442
6442
  beforeUnmount() {
6443
6443
  const projection = this.state.visualElement.projection;
@@ -6452,11 +6452,16 @@ class LayoutFeature extends Feature {
6452
6452
  }
6453
6453
  }
6454
6454
  unmount() {
6455
+ var _a, _b;
6455
6456
  const layoutGroup = this.state.options.layoutGroup;
6456
6457
  const projection = this.state.visualElement.projection;
6457
- if ((layoutGroup == null ? void 0 : layoutGroup.group) && projection) {
6458
- layoutGroup.group.remove(projection);
6459
- } else {
6458
+ if (projection) {
6459
+ if (layoutGroup == null ? void 0 : layoutGroup.group) {
6460
+ layoutGroup.group.remove(projection);
6461
+ }
6462
+ if ((_b = (_a = projection.getStack()) == null ? void 0 : _a.lead) == null ? void 0 : _b.animationProgress) {
6463
+ return;
6464
+ }
6460
6465
  this.didUpdate();
6461
6466
  }
6462
6467
  }
@@ -6971,7 +6976,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
6971
6976
  attachResizeListener(instance, () => {
6972
6977
  this.root.updateBlockedByResize = true;
6973
6978
  cancelDelay && cancelDelay();
6974
- cancelDelay = delay(resizeUnblockUpdate, 250);
6979
+ cancelDelay = delay$1(resizeUnblockUpdate, 250);
6975
6980
  if (globalProjectionState.hasAnimatedSinceResize) {
6976
6981
  globalProjectionState.hasAnimatedSinceResize = false;
6977
6982
  this.nodes.forEach(finishAnimation);
@@ -8322,34 +8327,26 @@ class MotionState {
8322
8327
  unmount(unMountChildren = false) {
8323
8328
  const shouldDelay = this.options.layoutId && !mountedLayoutIds.has(this.options.layoutId);
8324
8329
  const unmount = () => {
8325
- var _a, _b, _c;
8326
- mountedStates.delete(this.element);
8327
- this.featureManager.unmount();
8328
- if (unMountChildren && !shouldDelay) {
8329
- frame.render(() => {
8330
- var _a2;
8331
- (_a2 = this.visualElement) == null ? void 0 : _a2.unmount();
8332
- });
8333
- } else {
8334
- (_a = this.visualElement) == null ? void 0 : _a.unmount();
8335
- }
8336
8330
  if (unMountChildren) {
8337
- const unmountChild = (child) => {
8338
- var _a2;
8339
- child.unmount(true);
8340
- (_a2 = child.children) == null ? void 0 : _a2.forEach(unmountChild);
8341
- };
8342
- Array.from(this.children).forEach(unmountChild);
8331
+ Array.from(this.children).reverse().forEach(this.unmountChild);
8332
+ }
8333
+ const unmountState = () => {
8334
+ var _a, _b, _c;
8335
+ (_b = (_a = this.parent) == null ? void 0 : _a.children) == null ? void 0 : _b.delete(this);
8336
+ mountedStates.delete(this.element);
8337
+ this.featureManager.unmount();
8338
+ (_c = this.visualElement) == null ? void 0 : _c.unmount();
8339
+ };
8340
+ if (shouldDelay) {
8341
+ Promise.resolve().then(unmountState);
8342
+ } else {
8343
+ unmountState();
8343
8344
  }
8344
- (_c = (_b = this.parent) == null ? void 0 : _b.children) == null ? void 0 : _c.delete(this);
8345
8345
  };
8346
- if (shouldDelay) {
8347
- Promise.resolve().then(() => {
8348
- unmount();
8349
- });
8350
- } else {
8351
- unmount();
8352
- }
8346
+ unmount();
8347
+ }
8348
+ unmountChild(child) {
8349
+ child.unmount(true);
8353
8350
  }
8354
8351
  // Called before updating, executes in parent-to-child order
8355
8352
  beforeUpdate() {
@@ -8376,7 +8373,7 @@ class MotionState {
8376
8373
  });
8377
8374
  if (isAnimate) {
8378
8375
  this.animateUpdates({
8379
- isFallback: !isActive
8376
+ isFallback: !isActive && name !== "exit" && this.visualElement.isControllingVariants
8380
8377
  });
8381
8378
  }
8382
8379
  }
@@ -8654,12 +8651,17 @@ function usePopLayout(props) {
8654
8651
  function addPopStyle(state2) {
8655
8652
  if (props.mode !== "popLayout")
8656
8653
  return;
8654
+ const parent = state2.element.offsetParent;
8655
+ const parentWidth = parent instanceof HTMLElement ? parent.offsetWidth || 0 : 0;
8657
8656
  const size = {
8658
8657
  height: state2.element.offsetHeight || 0,
8659
8658
  width: state2.element.offsetWidth || 0,
8660
8659
  top: state2.element.offsetTop,
8661
- left: state2.element.offsetLeft
8660
+ left: state2.element.offsetLeft,
8661
+ right: 0
8662
8662
  };
8663
+ size.right = parentWidth - size.width - size.left;
8664
+ const x = props.anchorX === "left" ? `left: ${size.left}` : `right: ${size.right}`;
8663
8665
  state2.element.dataset.motionPopId = state2.id;
8664
8666
  const style2 = document.createElement("style");
8665
8667
  if (config.value.nonce) {
@@ -8667,11 +8669,6 @@ function usePopLayout(props) {
8667
8669
  }
8668
8670
  styles.set(state2, style2);
8669
8671
  document.head.appendChild(style2);
8670
- style2.textContent = `
8671
- [data-motion-pop-id="${state2.id}"] {
8672
- animation: pop 0.3s ease-in-out;
8673
- }
8674
- `;
8675
8672
  if (style2.sheet) {
8676
8673
  style2.sheet.insertRule(`
8677
8674
  [data-motion-pop-id="${state2.id}"] {
@@ -8679,8 +8676,8 @@ function usePopLayout(props) {
8679
8676
  width: ${size.width}px !important;
8680
8677
  height: ${size.height}px !important;
8681
8678
  top: ${size.top}px !important;
8682
- left: ${size.left}px !important;
8683
- }
8679
+ ${x}px !important;
8680
+ }
8684
8681
  `);
8685
8682
  }
8686
8683
  }
@@ -8689,7 +8686,7 @@ function usePopLayout(props) {
8689
8686
  if (!style2)
8690
8687
  return;
8691
8688
  styles.delete(state2);
8692
- requestIdleCallback(() => {
8689
+ frame.render(() => {
8693
8690
  document.head.removeChild(style2);
8694
8691
  });
8695
8692
  }
@@ -8699,6 +8696,11 @@ function usePopLayout(props) {
8699
8696
  styles
8700
8697
  };
8701
8698
  }
8699
+ function delay(fn) {
8700
+ return Promise.resolve().then(() => {
8701
+ fn();
8702
+ });
8703
+ }
8702
8704
  const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
8703
8705
  ...{
8704
8706
  name: "AnimatePresence",
@@ -8712,7 +8714,8 @@ const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
8712
8714
  as: {},
8713
8715
  custom: {},
8714
8716
  onExitComplete: {},
8715
- unwrapElement: { type: Boolean, default: false }
8717
+ unwrapElement: { type: Boolean, default: false },
8718
+ anchorX: { default: "left" }
8716
8719
  },
8717
8720
  setup(__props) {
8718
8721
  const props = __props;
@@ -8724,28 +8727,30 @@ const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
8724
8727
  vue.onMounted(() => {
8725
8728
  presenceContext.initial = void 0;
8726
8729
  });
8730
+ const { addPopStyle, removePopStyle, styles } = usePopLayout(props);
8727
8731
  function enter(el) {
8728
8732
  const state2 = mountedStates.get(el);
8729
8733
  if (!state2) {
8730
8734
  return;
8731
8735
  }
8736
+ removePopStyle(state2);
8732
8737
  state2.isVShow = true;
8733
8738
  removeDoneCallback(el);
8734
- state2.setActive("exit", false);
8739
+ delay(() => {
8740
+ state2.setActive("exit", false);
8741
+ });
8735
8742
  }
8736
- const { addPopStyle, removePopStyle, styles } = usePopLayout(props);
8737
8743
  const exitDom = /* @__PURE__ */ new Map();
8738
8744
  vue.onUnmounted(() => {
8739
8745
  exitDom.clear();
8740
8746
  });
8741
8747
  function exit(el, done) {
8742
- let state2 = mountedStates.get(el);
8743
- if (!state2) {
8744
- if (!props.unwrapElement) {
8745
- return done();
8746
- }
8748
+ if (props.unwrapElement) {
8747
8749
  el = el.firstElementChild;
8748
- state2 = mountedStates.get(el);
8750
+ }
8751
+ const state2 = mountedStates.get(el);
8752
+ if (!state2) {
8753
+ return done();
8749
8754
  }
8750
8755
  exitDom.set(el, true);
8751
8756
  removeDoneCallback(el);
@@ -8765,19 +8770,19 @@ const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
8765
8770
  if (!styles.has(state2)) {
8766
8771
  state2.willUpdate("done");
8767
8772
  } else {
8768
- frame.render(() => {
8769
- removePopStyle(state2);
8770
- });
8773
+ removePopStyle(state2);
8771
8774
  }
8772
8775
  done();
8773
- if (!(el == null ? void 0 : el.isConnected)) {
8776
+ if (!el.isConnected) {
8774
8777
  state2.unmount(true);
8775
8778
  }
8776
8779
  }
8777
8780
  }
8778
8781
  doneCallbacks.set(el, doneCallback);
8779
8782
  el.addEventListener("motioncomplete", doneCallback);
8780
- state2.setActive("exit", true);
8783
+ delay(() => {
8784
+ state2.setActive("exit", true);
8785
+ });
8781
8786
  }
8782
8787
  const transitionProps = vue.computed(() => {
8783
8788
  if (props.multiple) {
@@ -9405,7 +9410,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
9405
9410
  __name: "LayoutGroup",
9406
9411
  props: {
9407
9412
  id: {},
9408
- inherit: { type: [Boolean, String] }
9413
+ inherit: { type: [Boolean, String], default: true }
9409
9414
  },
9410
9415
  setup(__props) {
9411
9416
  const props = __props;
@@ -9611,6 +9616,7 @@ exports.Reorder = Reorder;
9611
9616
  exports.ReorderGroup = ReorderGroup;
9612
9617
  exports.ReorderItem = ReorderItem;
9613
9618
  exports.RowValue = _sfc_main$1;
9619
+ exports.addScaleCorrector = addScaleCorrector;
9614
9620
  exports.animate = animate;
9615
9621
  exports.animateMini = animateMini;
9616
9622
  exports.anticipate = anticipate;
@@ -9650,6 +9656,7 @@ exports.mirrorEasing = mirrorEasing;
9650
9656
  exports.mix = mix;
9651
9657
  exports.motion = motion;
9652
9658
  exports.motionValue = motionValue;
9659
+ exports.mountedStates = mountedStates;
9653
9660
  exports.noop = noop;
9654
9661
  exports.pipe = pipe;
9655
9662
  exports.progress = progress$1;
@@ -10,9 +10,20 @@ declare function __VLS_template(): {
10
10
  attrs: Partial<{}>;
11
11
  };
12
12
  type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
13
- declare const __VLS_component: import('vue').DefineComponent<__VLS_TypePropsToOption<LayoutGroupProps>, {}, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_TypePropsToOption<LayoutGroupProps>>>, {}, {}>;
13
+ declare const __VLS_component: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<LayoutGroupProps>, {
14
+ inherit: boolean;
15
+ }>, {}, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<LayoutGroupProps>, {
16
+ inherit: boolean;
17
+ }>>>, {
18
+ inherit: boolean | "id" | "group";
19
+ }, {}>;
14
20
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
15
21
  export default _default;
22
+ type __VLS_WithDefaults<P, D> = {
23
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_PrettifyLocal<P[K] & {
24
+ default: D[K];
25
+ }> : P[K];
26
+ };
16
27
  type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
17
28
  type __VLS_TypePropsToOption<T> = {
18
29
  [K in keyof T]-?: {} extends Pick<T, K> ? {
@@ -27,3 +38,6 @@ type __VLS_WithTemplateSlots<T, S> = T & {
27
38
  $slots: S;
28
39
  };
29
40
  };
41
+ type __VLS_PrettifyLocal<T> = {
42
+ [K in keyof T]: T[K];
43
+ } & {};
@@ -4,7 +4,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
4
4
  __name: "LayoutGroup",
5
5
  props: {
6
6
  id: {},
7
- inherit: { type: [Boolean, String] }
7
+ inherit: { type: [Boolean, String], default: true }
8
8
  },
9
9
  setup(__props) {
10
10
  const props = __props;
@@ -12,16 +12,19 @@ declare const __VLS_component: import('vue').DefineComponent<__VLS_WithDefaults<
12
12
  initial: boolean;
13
13
  multiple: boolean;
14
14
  unwrapElement: boolean;
15
+ anchorX: string;
15
16
  }>, {}, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<AnimatePresenceProps>, {
16
17
  mode: string;
17
18
  initial: boolean;
18
19
  multiple: boolean;
19
20
  unwrapElement: boolean;
21
+ anchorX: string;
20
22
  }>>>, {
21
23
  initial: boolean;
22
24
  mode: "wait" | "popLayout" | "sync";
23
25
  multiple: boolean;
24
26
  unwrapElement: boolean;
27
+ anchorX: "left" | "right";
25
28
  }, {}>;
26
29
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
27
30
  export default _default;
@@ -2,7 +2,7 @@ import { defineComponent, onMounted, onUnmounted, computed, openBlock, createBlo
2
2
  import { mountedStates } from "../../state/motion-state.mjs";
3
3
  import { provideAnimatePresence, removeDoneCallback, doneCallbacks } from "../presence.mjs";
4
4
  import { usePopLayout } from "./use-pop-layout.mjs";
5
- import { frame } from "../../external/.pnpm/framer-motion@11.16.6/external/framer-motion/dist/es/frameloop/frame.mjs";
5
+ import { delay } from "../../utils/delay.mjs";
6
6
  const _sfc_main = /* @__PURE__ */ defineComponent({
7
7
  ...{
8
8
  name: "AnimatePresence",
@@ -16,7 +16,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
16
16
  as: {},
17
17
  custom: {},
18
18
  onExitComplete: {},
19
- unwrapElement: { type: Boolean, default: false }
19
+ unwrapElement: { type: Boolean, default: false },
20
+ anchorX: { default: "left" }
20
21
  },
21
22
  setup(__props) {
22
23
  const props = __props;
@@ -28,28 +29,30 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
28
29
  onMounted(() => {
29
30
  presenceContext.initial = void 0;
30
31
  });
32
+ const { addPopStyle, removePopStyle, styles } = usePopLayout(props);
31
33
  function enter(el) {
32
34
  const state = mountedStates.get(el);
33
35
  if (!state) {
34
36
  return;
35
37
  }
38
+ removePopStyle(state);
36
39
  state.isVShow = true;
37
40
  removeDoneCallback(el);
38
- state.setActive("exit", false);
41
+ delay(() => {
42
+ state.setActive("exit", false);
43
+ });
39
44
  }
40
- const { addPopStyle, removePopStyle, styles } = usePopLayout(props);
41
45
  const exitDom = /* @__PURE__ */ new Map();
42
46
  onUnmounted(() => {
43
47
  exitDom.clear();
44
48
  });
45
49
  function exit(el, done) {
46
- let state = mountedStates.get(el);
47
- if (!state) {
48
- if (!props.unwrapElement) {
49
- return done();
50
- }
50
+ if (props.unwrapElement) {
51
51
  el = el.firstElementChild;
52
- state = mountedStates.get(el);
52
+ }
53
+ const state = mountedStates.get(el);
54
+ if (!state) {
55
+ return done();
53
56
  }
54
57
  exitDom.set(el, true);
55
58
  removeDoneCallback(el);
@@ -69,19 +72,19 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
69
72
  if (!styles.has(state)) {
70
73
  state.willUpdate("done");
71
74
  } else {
72
- frame.render(() => {
73
- removePopStyle(state);
74
- });
75
+ removePopStyle(state);
75
76
  }
76
77
  done();
77
- if (!(el == null ? void 0 : el.isConnected)) {
78
+ if (!el.isConnected) {
78
79
  state.unmount(true);
79
80
  }
80
81
  }
81
82
  }
82
83
  doneCallbacks.set(el, doneCallback);
83
84
  el.addEventListener("motioncomplete", doneCallback);
84
- state.setActive("exit", true);
85
+ delay(() => {
86
+ state.setActive("exit", true);
87
+ });
85
88
  }
86
89
  const transitionProps = computed(() => {
87
90
  if (props.multiple) {
@@ -6,4 +6,5 @@ export interface AnimatePresenceProps {
6
6
  custom?: any;
7
7
  onExitComplete?: VoidFunction;
8
8
  unwrapElement?: boolean;
9
+ anchorX?: 'left' | 'right';
9
10
  }
@@ -1,16 +1,22 @@
1
1
  import { useMotionConfig } from "../motion-config/context.mjs";
2
+ import { frame } from "../../external/.pnpm/framer-motion@11.16.6/external/framer-motion/dist/es/frameloop/frame.mjs";
2
3
  function usePopLayout(props) {
3
4
  const styles = /* @__PURE__ */ new WeakMap();
4
5
  const config = useMotionConfig();
5
6
  function addPopStyle(state) {
6
7
  if (props.mode !== "popLayout")
7
8
  return;
9
+ const parent = state.element.offsetParent;
10
+ const parentWidth = parent instanceof HTMLElement ? parent.offsetWidth || 0 : 0;
8
11
  const size = {
9
12
  height: state.element.offsetHeight || 0,
10
13
  width: state.element.offsetWidth || 0,
11
14
  top: state.element.offsetTop,
12
- left: state.element.offsetLeft
15
+ left: state.element.offsetLeft,
16
+ right: 0
13
17
  };
18
+ size.right = parentWidth - size.width - size.left;
19
+ const x = props.anchorX === "left" ? `left: ${size.left}` : `right: ${size.right}`;
14
20
  state.element.dataset.motionPopId = state.id;
15
21
  const style = document.createElement("style");
16
22
  if (config.value.nonce) {
@@ -18,11 +24,6 @@ function usePopLayout(props) {
18
24
  }
19
25
  styles.set(state, style);
20
26
  document.head.appendChild(style);
21
- style.textContent = `
22
- [data-motion-pop-id="${state.id}"] {
23
- animation: pop 0.3s ease-in-out;
24
- }
25
- `;
26
27
  if (style.sheet) {
27
28
  style.sheet.insertRule(`
28
29
  [data-motion-pop-id="${state.id}"] {
@@ -30,8 +31,8 @@ function usePopLayout(props) {
30
31
  width: ${size.width}px !important;
31
32
  height: ${size.height}px !important;
32
33
  top: ${size.top}px !important;
33
- left: ${size.left}px !important;
34
- }
34
+ ${x}px !important;
35
+ }
35
36
  `);
36
37
  }
37
38
  }
@@ -40,7 +41,7 @@ function usePopLayout(props) {
40
41
  if (!style)
41
42
  return;
42
43
  styles.delete(state);
43
- requestIdleCallback(() => {
44
+ frame.render(() => {
44
45
  document.head.removeChild(style);
45
46
  });
46
47
  }
@@ -3,3 +3,4 @@ export * from './animate-presence';
3
3
  export * from './motion-config';
4
4
  export * from './reorder';
5
5
  export { default as RowValue } from './RowValue';
6
+ export { mountedStates } from '../state';
@@ -1,11 +1,14 @@
1
1
  import { DefineComponent, ExtractPropTypes, ExtractPublicPropTypes, IntrinsicElementAttributes } from 'vue';
2
2
  import { MotionProps } from './Motion';
3
+ import { MotionHTMLAttributes } from '../../types';
3
4
  type ComponentProps<T> = T extends DefineComponent<ExtractPropTypes<infer Props>, any, any> ? ExtractPublicPropTypes<Props> : never;
4
5
  type MotionComponentProps = {
5
6
  create: <T extends DefineComponent>(T: any) => DefineComponent<MotionProps<any, unknown> & ComponentProps<T>>;
6
7
  };
7
- interface MotionNameSpace extends Record<keyof IntrinsicElementAttributes, DefineComponent<MotionProps<keyof IntrinsicElementAttributes, unknown>>> {
8
+ type MotionNameSpace = {
9
+ [K in keyof IntrinsicElementAttributes]: DefineComponent<MotionProps<K, unknown> & MotionHTMLAttributes<K>>;
10
+ } & {
8
11
  create: MotionComponentProps['create'];
9
- }
12
+ };
10
13
  export declare const motion: MotionNameSpace;
11
14
  export {};
@@ -15,22 +15,22 @@ class LayoutFeature extends Feature {
15
15
  }
16
16
  didUpdate() {
17
17
  var _a, _b;
18
- if (this.state.options.layout || this.state.options.layoutId)
18
+ if (this.state.options.layout || this.state.options.layoutId || this.state.options.drag)
19
19
  (_b = (_a = this.state.visualElement.projection) == null ? void 0 : _a.root) == null ? void 0 : _b.didUpdate();
20
20
  }
21
21
  mount() {
22
22
  var _a;
23
23
  const options = this.state.options;
24
24
  const layoutGroup = this.state.options.layoutGroup;
25
- if (options.layout || options.layoutId || options.drag) {
25
+ if (options.layout || options.layoutId) {
26
26
  const projection = this.state.visualElement.projection;
27
27
  if (projection) {
28
28
  projection.promote();
29
29
  (_a = layoutGroup == null ? void 0 : layoutGroup.group) == null ? void 0 : _a.add(projection);
30
30
  }
31
- this.didUpdate();
32
31
  globalProjectionState.hasEverUpdated = true;
33
32
  }
33
+ this.didUpdate();
34
34
  }
35
35
  beforeUnmount() {
36
36
  const projection = this.state.visualElement.projection;
@@ -45,11 +45,16 @@ class LayoutFeature extends Feature {
45
45
  }
46
46
  }
47
47
  unmount() {
48
+ var _a, _b;
48
49
  const layoutGroup = this.state.options.layoutGroup;
49
50
  const projection = this.state.visualElement.projection;
50
- if ((layoutGroup == null ? void 0 : layoutGroup.group) && projection) {
51
- layoutGroup.group.remove(projection);
52
- } else {
51
+ if (projection) {
52
+ if (layoutGroup == null ? void 0 : layoutGroup.group) {
53
+ layoutGroup.group.remove(projection);
54
+ }
55
+ if ((_b = (_a = projection.getStack()) == null ? void 0 : _a.lead) == null ? void 0 : _b.animationProgress) {
56
+ return;
57
+ }
53
58
  this.didUpdate();
54
59
  }
55
60
  }
@@ -1,4 +1,5 @@
1
1
  export * from 'framer-motion/dom';
2
+ export { addScaleCorrector } from '../node_modules/framer-motion/dist/es/projection/styles/scale-correction.mjs';
2
3
  export { motionValue as useMotionValue } from 'framer-motion/dom';
3
4
  export * from './components';
4
5
  export { default as LayoutGroup } from './components/LayoutGroup';
package/dist/es/index.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { addScaleCorrector } from "./external/.pnpm/framer-motion@11.16.6/external/framer-motion/dist/es/projection/styles/scale-correction.mjs";
1
2
  import { default as default2 } from "./components/LayoutGroup.vue.mjs";
2
3
  import { useLayoutGroup } from "./components/use-layout-group.mjs";
3
4
  import { injectLayoutGroup, injectMotion, provideLayoutGroup, provideMotion } from "./components/context.mjs";
@@ -41,6 +42,7 @@ import { wrap } from "./external/.pnpm/framer-motion@11.16.6/external/framer-mot
41
42
  import { cancelSync, sync } from "./external/.pnpm/framer-motion@11.16.6/external/framer-motion/dist/es/frameloop/index-legacy.mjs";
42
43
  import { cancelFrame, frame, frameData, frameSteps } from "./external/.pnpm/framer-motion@11.16.6/external/framer-motion/dist/es/frameloop/frame.mjs";
43
44
  import { motion } from "./components/motion/NameSpace.mjs";
45
+ import { mountedStates } from "./state/motion-state.mjs";
44
46
  import { provideMotionConfig, useMotionConfig } from "./components/motion-config/context.mjs";
45
47
  import { Reorder, ReorderGroup, ReorderItem } from "./components/reorder/index.mjs";
46
48
  import { useComputed } from "./value/use-computed.mjs";
@@ -70,6 +72,7 @@ export {
70
72
  ReorderGroup,
71
73
  ReorderItem,
72
74
  default4 as RowValue,
75
+ addScaleCorrector,
73
76
  animate,
74
77
  animateMini,
75
78
  anticipate,
@@ -110,6 +113,7 @@ export {
110
113
  mix,
111
114
  motion,
112
115
  motionValue,
116
+ mountedStates,
113
117
  noop,
114
118
  pipe,
115
119
  progress,
@@ -29,6 +29,7 @@ export declare class MotionState {
29
29
  mount(element: HTMLElement, options: Options, notAnimate?: boolean): void;
30
30
  beforeUnmount(): void;
31
31
  unmount(unMountChildren?: boolean): void;
32
+ private unmountChild;
32
33
  beforeUpdate(): void;
33
34
  update(options: Options): void;
34
35
  setActive(name: StateType, isActive: boolean, isAnimate?: boolean): void;
@@ -124,34 +124,26 @@ class MotionState {
124
124
  unmount(unMountChildren = false) {
125
125
  const shouldDelay = this.options.layoutId && !mountedLayoutIds.has(this.options.layoutId);
126
126
  const unmount = () => {
127
- var _a, _b, _c;
128
- mountedStates.delete(this.element);
129
- this.featureManager.unmount();
130
- if (unMountChildren && !shouldDelay) {
131
- frame.render(() => {
132
- var _a2;
133
- (_a2 = this.visualElement) == null ? void 0 : _a2.unmount();
134
- });
135
- } else {
136
- (_a = this.visualElement) == null ? void 0 : _a.unmount();
137
- }
138
127
  if (unMountChildren) {
139
- const unmountChild = (child) => {
140
- var _a2;
141
- child.unmount(true);
142
- (_a2 = child.children) == null ? void 0 : _a2.forEach(unmountChild);
143
- };
144
- Array.from(this.children).forEach(unmountChild);
128
+ Array.from(this.children).reverse().forEach(this.unmountChild);
129
+ }
130
+ const unmountState = () => {
131
+ var _a, _b, _c;
132
+ (_b = (_a = this.parent) == null ? void 0 : _a.children) == null ? void 0 : _b.delete(this);
133
+ mountedStates.delete(this.element);
134
+ this.featureManager.unmount();
135
+ (_c = this.visualElement) == null ? void 0 : _c.unmount();
136
+ };
137
+ if (shouldDelay) {
138
+ Promise.resolve().then(unmountState);
139
+ } else {
140
+ unmountState();
145
141
  }
146
- (_c = (_b = this.parent) == null ? void 0 : _b.children) == null ? void 0 : _c.delete(this);
147
142
  };
148
- if (shouldDelay) {
149
- Promise.resolve().then(() => {
150
- unmount();
151
- });
152
- } else {
153
- unmount();
154
- }
143
+ unmount();
144
+ }
145
+ unmountChild(child) {
146
+ child.unmount(true);
155
147
  }
156
148
  // Called before updating, executes in parent-to-child order
157
149
  beforeUpdate() {
@@ -178,7 +170,7 @@ class MotionState {
178
170
  });
179
171
  if (isAnimate) {
180
172
  this.animateUpdates({
181
- isFallback: !isActive
173
+ isFallback: !isActive && name !== "exit" && this.visualElement.isControllingVariants
182
174
  });
183
175
  }
184
176
  }
@@ -24,7 +24,7 @@ function shallowCompare(next, prev) {
24
24
  return true;
25
25
  }
26
26
  function getOptions(options, key) {
27
- return options[key] ? { ...options, ...options[key] } : { ...options };
27
+ return options[key] ? { ...options, ...options[key], [key]: void 0 } : { ...options };
28
28
  }
29
29
  function isCssVar(name) {
30
30
  return name == null ? void 0 : name.startsWith("--");
@@ -1,6 +1,6 @@
1
1
  import { MotionValue } from 'framer-motion/dom';
2
- import { Options } from './state';
3
- import { AriaAttributes, Events, SVGAttributes } from 'vue';
2
+ import { ElementType, Options } from './state';
3
+ import { AriaAttributes, Events, IntrinsicElementAttributes, SVGAttributes } from 'vue';
4
4
  type EventHandlers<E> = {
5
5
  [K in keyof E]?: E[K] extends (...args: any) => any ? E[K] : (payload: E[K]) => void;
6
6
  };
@@ -88,4 +88,6 @@ export interface SVGAttributesWithMotionValues {
88
88
  export type SetMotionValueType<T, Keys extends keyof T> = {
89
89
  [K in keyof T]: K extends Keys ? SVGAttributesAsMotionValues : T[K];
90
90
  };
91
+ type IntrinsicElementAttributesAsMotionValues = SetMotionValueType<IntrinsicElementAttributes, keyof SVGAttributesWithMotionValues>;
92
+ export type MotionHTMLAttributes<C extends ElementType> = Omit<IntrinsicElementAttributesAsMotionValues[C], keyof Options | 'style' | 'as' | 'asChild'>;
91
93
  export {};
@@ -0,0 +1 @@
1
+ export declare function delay(fn: () => void): Promise<void>;
@@ -0,0 +1,8 @@
1
+ function delay(fn) {
2
+ return Promise.resolve().then(() => {
3
+ fn();
4
+ });
5
+ }
6
+ export {
7
+ delay
8
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "motion-v",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "MIT",