motion-v 0.13.0-beta.4 → 0.13.1-alpha.0

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
@@ -4537,15 +4537,12 @@ const SVG_STYLE_TO_ATTRIBUTES = {
4537
4537
  cy: true,
4538
4538
  r: true,
4539
4539
  d: true,
4540
- x: true,
4541
- y: true,
4542
4540
  x1: true,
4543
4541
  y1: true,
4544
4542
  x2: true,
4545
4543
  y2: true,
4546
4544
  points: true,
4547
4545
  pathLength: true,
4548
- transform: true,
4549
4546
  viewBox: true,
4550
4547
  width: true,
4551
4548
  height: true,
@@ -4642,6 +4639,10 @@ const Primitive = vue.defineComponent({
4642
4639
  getProps: {
4643
4640
  type: Function,
4644
4641
  default: () => ({})
4642
+ },
4643
+ getAttrs: {
4644
+ type: Function,
4645
+ default: () => ({})
4645
4646
  }
4646
4647
  },
4647
4648
  setup(props, { attrs, slots }) {
@@ -4649,10 +4650,14 @@ const Primitive = vue.defineComponent({
4649
4650
  const SELF_CLOSING_TAGS = ["area", "img", "input"];
4650
4651
  return () => {
4651
4652
  const motionProps = props.getProps();
4652
- const allAttrs = { ...motionProps, ...attrs };
4653
+ const motionAttrs = props.getAttrs();
4654
+ let allAttrs = { ...motionAttrs, ...attrs };
4653
4655
  if (typeof asTag === "string" && SELF_CLOSING_TAGS.includes(asTag))
4654
4656
  return vue.h(asTag, allAttrs);
4655
4657
  if (asTag !== "template") {
4658
+ if (motionProps.forwardMotionProps) {
4659
+ allAttrs = { ...motionProps, ...allAttrs };
4660
+ }
4656
4661
  return vue.h(props.as, allAttrs, { default: slots.default });
4657
4662
  }
4658
4663
  return vue.h(Slot, allAttrs, { default: slots.default });
@@ -7431,7 +7436,8 @@ function animateUpdates({
7431
7436
  });
7432
7437
  }
7433
7438
  function resolveDirectAnimation(directAnimate, directTransition) {
7434
- const variant = resolveVariant(directAnimate, this.options.variants, this.options.custom);
7439
+ var _a;
7440
+ const variant = resolveVariant(directAnimate, this.options.variants, this.options.custom || ((_a = this.options.animatePresenceContext) == null ? void 0 : _a.custom));
7435
7441
  if (!variant)
7436
7442
  return {};
7437
7443
  const transition = variant.transition || directTransition || this.options.transition || {};
@@ -7779,11 +7785,13 @@ const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
7779
7785
  whilePress: {},
7780
7786
  whileInView: {},
7781
7787
  whileFocus: {},
7788
+ forwardMotionProps: { type: Boolean },
7782
7789
  custom: {},
7783
7790
  initial: { type: [String, Array, Object, Boolean] },
7784
7791
  animate: {},
7785
7792
  exit: {},
7786
7793
  variants: {},
7794
+ inherit: { type: Boolean },
7787
7795
  style: {},
7788
7796
  transformTemplate: { type: Function },
7789
7797
  transition: {},
@@ -7797,6 +7805,7 @@ const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
7797
7805
  layoutRoot: { type: Boolean },
7798
7806
  "data-framer-portal-id": {},
7799
7807
  crossfade: { type: Boolean },
7808
+ layoutDependency: {},
7800
7809
  onBeforeLayoutMeasure: { type: Function },
7801
7810
  onLayoutMeasure: { type: Function },
7802
7811
  onLayoutAnimationStart: { type: Function },
@@ -7885,18 +7894,24 @@ const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
7885
7894
  return `${layoutGroup.id}-${props.layoutId}`;
7886
7895
  return props.layoutId || void 0;
7887
7896
  }
7888
- function getMotionProps() {
7897
+ function getProps() {
7889
7898
  return {
7890
- ...attrs,
7891
7899
  ...props,
7892
7900
  layoutId: getLayoutId(),
7893
7901
  transition: props.transition ?? config.value.transition,
7894
7902
  layoutGroup,
7895
7903
  motionConfig: config.value,
7896
7904
  inViewOptions: props.inViewOptions ?? config.value.inViewOptions,
7905
+ animatePresenceContext,
7897
7906
  initial: animatePresenceContext.initial === false ? animatePresenceContext.initial : props.initial === true ? void 0 : props.initial
7898
7907
  };
7899
7908
  }
7909
+ function getMotionProps() {
7910
+ return {
7911
+ ...attrs,
7912
+ ...getProps()
7913
+ };
7914
+ }
7900
7915
  const state2 = new MotionState(
7901
7916
  getMotionProps(),
7902
7917
  parentState
@@ -7922,7 +7937,7 @@ const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
7922
7937
  vue.onUpdated(() => {
7923
7938
  state2.update(getMotionProps());
7924
7939
  });
7925
- function getProps() {
7940
+ function getAttrs() {
7926
7941
  const isSVG = state2.visualElement.type === "svg";
7927
7942
  const attrsProps = { ...attrs };
7928
7943
  Object.keys(attrs).forEach((key) => {
@@ -7934,9 +7949,12 @@ const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
7934
7949
  ...isSVG ? {} : state2.visualElement.latestValues
7935
7950
  };
7936
7951
  if (isSVG) {
7937
- const { attributes, style: style2 } = convertSvgStyleToAttributes(state2.isMounted() ? state2.target : state2.baseTarget);
7952
+ const { attributes, style: style2 } = convertSvgStyleToAttributes({
7953
+ ...state2.isMounted() ? state2.target : state2.baseTarget,
7954
+ ...styleProps
7955
+ });
7938
7956
  Object.assign(attrsProps, attributes);
7939
- Object.assign(styleProps, style2);
7957
+ styleProps = style2;
7940
7958
  }
7941
7959
  if (props.drag && props.dragListener !== false) {
7942
7960
  Object.assign(styleProps, {
@@ -7946,10 +7964,7 @@ const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
7946
7964
  touchAction: props.drag === true ? "none" : `pan-${props.drag === "x" ? "y" : "x"}`
7947
7965
  });
7948
7966
  }
7949
- styleProps = createStyles({
7950
- ...styleProps,
7951
- ...props.style
7952
- });
7967
+ styleProps = createStyles(styleProps);
7953
7968
  attrsProps.style = styleProps;
7954
7969
  return attrsProps;
7955
7970
  }
@@ -7967,6 +7982,7 @@ const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
7967
7982
  ref_key: "PrimitiveRef",
7968
7983
  ref: PrimitiveRef,
7969
7984
  "get-props": getProps,
7985
+ "get-attrs": getAttrs,
7970
7986
  as: _ctx.as,
7971
7987
  "as-child": _ctx.asChild,
7972
7988
  "data-motion-group": ((_a = vue.unref(layoutGroup).key) == null ? void 0 : _a.value) || void 0,
@@ -7987,7 +8003,7 @@ const motion = new Proxy(_sfc_main$6, {
7987
8003
  return target[prop];
7988
8004
  let motionComponent = componentCache.get(prop);
7989
8005
  if (prop === "create") {
7990
- return (component) => {
8006
+ return (component, { forwardMotionProps = false } = {}) => {
7991
8007
  return vue.defineComponent({
7992
8008
  inheritAttrs: false,
7993
8009
  name: `motion.${component.$name}`,
@@ -7995,6 +8011,7 @@ const motion = new Proxy(_sfc_main$6, {
7995
8011
  return () => {
7996
8012
  return vue.h(_sfc_main$6, {
7997
8013
  ...attrs,
8014
+ forwardMotionProps,
7998
8015
  as: component,
7999
8016
  asChild: false
8000
8017
  }, slots);
@@ -8090,7 +8107,6 @@ const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
8090
8107
  as: {},
8091
8108
  custom: {},
8092
8109
  onExitComplete: {},
8093
- unwrapElement: { type: [Boolean, Function], default: false },
8094
8110
  anchorX: { default: "left" }
8095
8111
  },
8096
8112
  setup(__props) {
@@ -8104,6 +8120,16 @@ const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
8104
8120
  presenceContext.initial = void 0;
8105
8121
  });
8106
8122
  const { addPopStyle, removePopStyle, styles } = usePopLayout(props);
8123
+ function findMotionElement(el) {
8124
+ let current = el;
8125
+ while (current) {
8126
+ if (mountedStates.get(current)) {
8127
+ return current;
8128
+ }
8129
+ current = current.firstElementChild;
8130
+ }
8131
+ return null;
8132
+ }
8107
8133
  function enter(el) {
8108
8134
  const state2 = mountedStates.get(el);
8109
8135
  if (!state2) {
@@ -8121,29 +8147,28 @@ const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
8121
8147
  exitDom.clear();
8122
8148
  });
8123
8149
  function exit(el, done) {
8124
- if (props.unwrapElement) {
8125
- if (typeof props.unwrapElement === "function") {
8126
- el = props.unwrapElement(el) || el;
8127
- } else {
8128
- el = el.firstElementChild || el;
8150
+ var _a;
8151
+ const motionEl = findMotionElement(el);
8152
+ const state2 = mountedStates.get(motionEl);
8153
+ if (!motionEl || !state2) {
8154
+ done();
8155
+ if (exitDom.size === 0) {
8156
+ (_a = props.onExitComplete) == null ? void 0 : _a.call(props);
8129
8157
  }
8158
+ return;
8130
8159
  }
8131
- const state2 = mountedStates.get(el);
8132
- if (!state2) {
8133
- return done();
8134
- }
8135
- exitDom.set(el, true);
8136
- removeDoneCallback(el);
8160
+ exitDom.set(motionEl, true);
8161
+ removeDoneCallback(motionEl);
8137
8162
  addPopStyle(state2);
8138
8163
  function doneCallback(e) {
8139
- var _a, _b;
8140
- if ((_a = e == null ? void 0 : e.detail) == null ? void 0 : _a.isExit) {
8164
+ var _a2, _b;
8165
+ if ((_a2 = e == null ? void 0 : e.detail) == null ? void 0 : _a2.isExit) {
8141
8166
  const projection = state2.visualElement.projection;
8142
8167
  if ((projection == null ? void 0 : projection.animationProgress) > 0 && !state2.isSafeToRemove && !state2.isVShow) {
8143
8168
  return;
8144
8169
  }
8145
- removeDoneCallback(el);
8146
- exitDom.delete(el);
8170
+ removeDoneCallback(motionEl);
8171
+ exitDom.delete(motionEl);
8147
8172
  if (exitDom.size === 0) {
8148
8173
  (_b = props.onExitComplete) == null ? void 0 : _b.call(props);
8149
8174
  }
@@ -8153,15 +8178,15 @@ const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
8153
8178
  removePopStyle(state2);
8154
8179
  }
8155
8180
  done();
8156
- if (!el.isConnected) {
8181
+ if (!motionEl.isConnected) {
8157
8182
  state2.unmount(true);
8158
8183
  }
8159
8184
  }
8160
8185
  }
8161
8186
  delay(() => {
8162
8187
  state2.setActive("exit", true);
8163
- doneCallbacks.set(el, doneCallback);
8164
- el.addEventListener("motioncomplete", doneCallback);
8188
+ doneCallbacks.set(motionEl, doneCallback);
8189
+ motionEl.addEventListener("motioncomplete", doneCallback);
8165
8190
  });
8166
8191
  }
8167
8192
  const transitionProps = vue.computed(() => {
@@ -8273,11 +8298,13 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
8273
8298
  whilePress: {},
8274
8299
  whileInView: {},
8275
8300
  whileFocus: {},
8301
+ forwardMotionProps: { type: Boolean },
8276
8302
  custom: {},
8277
8303
  initial: { type: [String, Array, Object, Boolean] },
8278
8304
  animate: {},
8279
8305
  exit: {},
8280
8306
  variants: {},
8307
+ inherit: { type: Boolean },
8281
8308
  style: {},
8282
8309
  transformTemplate: {},
8283
8310
  transition: {},
@@ -8291,6 +8318,7 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
8291
8318
  layoutRoot: { type: Boolean },
8292
8319
  "data-framer-portal-id": {},
8293
8320
  crossfade: { type: Boolean },
8321
+ layoutDependency: {},
8294
8322
  onBeforeLayoutMeasure: {},
8295
8323
  onLayoutMeasure: {},
8296
8324
  onLayoutAnimationStart: {},
@@ -8365,9 +8393,10 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
8365
8393
  });
8366
8394
  const attrs = vue.useAttrs();
8367
8395
  function bindProps() {
8396
+ const { axis: axis2, values, "onUpdate:values": onUpdateValues, ...rest } = props;
8368
8397
  return {
8369
8398
  ...attrs,
8370
- ...props
8399
+ ...rest
8371
8400
  };
8372
8401
  }
8373
8402
  return (_ctx, _cache) => {
@@ -8614,11 +8643,13 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
8614
8643
  whilePress: {},
8615
8644
  whileInView: {},
8616
8645
  whileFocus: {},
8646
+ forwardMotionProps: { type: Boolean },
8617
8647
  custom: {},
8618
8648
  initial: { type: [String, Array, Object, Boolean], default: void 0 },
8619
8649
  animate: { default: void 0 },
8620
8650
  exit: {},
8621
8651
  variants: {},
8652
+ inherit: { type: Boolean },
8622
8653
  style: {},
8623
8654
  transformTemplate: {},
8624
8655
  transition: {},
@@ -8631,6 +8662,7 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
8631
8662
  layoutRoot: { type: Boolean, default: false },
8632
8663
  "data-framer-portal-id": {},
8633
8664
  crossfade: { type: Boolean, default: true },
8665
+ layoutDependency: {},
8634
8666
  onBeforeLayoutMeasure: {},
8635
8667
  onLayoutMeasure: {},
8636
8668
  onLayoutAnimationStart: {},
@@ -8683,9 +8715,10 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
8683
8715
  const { axis, registerItem, updateOrder } = context || {};
8684
8716
  const attrs = vue.useAttrs();
8685
8717
  function bindProps() {
8718
+ const { value, ...rest } = props;
8686
8719
  return {
8687
8720
  ...attrs,
8688
- ...props,
8721
+ ...rest,
8689
8722
  style: {
8690
8723
  ...style2.value,
8691
8724
  x: point2.x,
@@ -10,17 +10,14 @@ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
10
10
  declare const __VLS_component: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<AnimatePresenceProps>, {
11
11
  mode: string;
12
12
  initial: boolean;
13
- unwrapElement: boolean;
14
13
  anchorX: string;
15
14
  }>, {}, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<AnimatePresenceProps>, {
16
15
  mode: string;
17
16
  initial: boolean;
18
- unwrapElement: boolean;
19
17
  anchorX: string;
20
18
  }>>>, {
21
19
  initial: boolean;
22
20
  mode: "wait" | "popLayout" | "sync";
23
- unwrapElement: boolean | ((el: HTMLElement) => HTMLElement);
24
21
  anchorX: "left" | "right";
25
22
  }, {}>;
26
23
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
@@ -15,7 +15,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
15
15
  as: {},
16
16
  custom: {},
17
17
  onExitComplete: {},
18
- unwrapElement: { type: [Boolean, Function], default: false },
19
18
  anchorX: { default: "left" }
20
19
  },
21
20
  setup(__props) {
@@ -29,6 +28,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
29
28
  presenceContext.initial = void 0;
30
29
  });
31
30
  const { addPopStyle, removePopStyle, styles } = usePopLayout(props);
31
+ function findMotionElement(el) {
32
+ let current = el;
33
+ while (current) {
34
+ if (mountedStates.get(current)) {
35
+ return current;
36
+ }
37
+ current = current.firstElementChild;
38
+ }
39
+ return null;
40
+ }
32
41
  function enter(el) {
33
42
  const state = mountedStates.get(el);
34
43
  if (!state) {
@@ -46,29 +55,28 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
46
55
  exitDom.clear();
47
56
  });
48
57
  function exit(el, done) {
49
- if (props.unwrapElement) {
50
- if (typeof props.unwrapElement === "function") {
51
- el = props.unwrapElement(el) || el;
52
- } else {
53
- el = el.firstElementChild || el;
58
+ var _a;
59
+ const motionEl = findMotionElement(el);
60
+ const state = mountedStates.get(motionEl);
61
+ if (!motionEl || !state) {
62
+ done();
63
+ if (exitDom.size === 0) {
64
+ (_a = props.onExitComplete) == null ? void 0 : _a.call(props);
54
65
  }
66
+ return;
55
67
  }
56
- const state = mountedStates.get(el);
57
- if (!state) {
58
- return done();
59
- }
60
- exitDom.set(el, true);
61
- removeDoneCallback(el);
68
+ exitDom.set(motionEl, true);
69
+ removeDoneCallback(motionEl);
62
70
  addPopStyle(state);
63
71
  function doneCallback(e) {
64
- var _a, _b;
65
- if ((_a = e == null ? void 0 : e.detail) == null ? void 0 : _a.isExit) {
72
+ var _a2, _b;
73
+ if ((_a2 = e == null ? void 0 : e.detail) == null ? void 0 : _a2.isExit) {
66
74
  const projection = state.visualElement.projection;
67
75
  if ((projection == null ? void 0 : projection.animationProgress) > 0 && !state.isSafeToRemove && !state.isVShow) {
68
76
  return;
69
77
  }
70
- removeDoneCallback(el);
71
- exitDom.delete(el);
78
+ removeDoneCallback(motionEl);
79
+ exitDom.delete(motionEl);
72
80
  if (exitDom.size === 0) {
73
81
  (_b = props.onExitComplete) == null ? void 0 : _b.call(props);
74
82
  }
@@ -78,15 +86,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
78
86
  removePopStyle(state);
79
87
  }
80
88
  done();
81
- if (!el.isConnected) {
89
+ if (!motionEl.isConnected) {
82
90
  state.unmount(true);
83
91
  }
84
92
  }
85
93
  }
86
94
  delay(() => {
87
95
  state.setActive("exit", true);
88
- doneCallbacks.set(el, doneCallback);
89
- el.addEventListener("motioncomplete", doneCallback);
96
+ doneCallbacks.set(motionEl, doneCallback);
97
+ motionEl.addEventListener("motioncomplete", doneCallback);
90
98
  });
91
99
  }
92
100
  const transitionProps = computed(() => {
@@ -4,6 +4,5 @@ export interface AnimatePresenceProps {
4
4
  as?: string;
5
5
  custom?: any;
6
6
  onExitComplete?: VoidFunction;
7
- unwrapElement?: boolean | ((el: HTMLElement) => HTMLElement);
8
7
  anchorX?: 'left' | 'right';
9
8
  }
@@ -1,6 +1,6 @@
1
1
  import { IntrinsicElementAttributes } from 'vue';
2
- import { ElementType, Options, SVGAttributesWithMotionValues, SetMotionValueType } from '../../types';
3
- export interface MotionProps<T extends ElementType = 'div', K = unknown> extends Options<K> {
2
+ import { AsTag, ComponentProps, Options, SVGAttributesWithMotionValues, SetMotionValueType } from '../../types';
3
+ export interface MotionProps<T extends AsTag = 'div', K = unknown> extends Options<K> {
4
4
  as?: T;
5
5
  asChild?: boolean;
6
6
  hover?: Options['hover'];
@@ -12,9 +12,10 @@ export interface MotionProps<T extends ElementType = 'div', K = unknown> extends
12
12
  whilePress?: Options['whilePress'];
13
13
  whileInView?: Options['whileInView'];
14
14
  whileFocus?: Options['whileFocus'];
15
+ forwardMotionProps?: boolean;
15
16
  }
16
- declare const _default: <T extends ElementType = "div", K = unknown>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
17
- props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & Readonly<import('vue').ExtractPropTypes<{}>>, never>, never> & (Omit<SetMotionValueType<IntrinsicElementAttributes, keyof SVGAttributesWithMotionValues>[T], "asChild" | keyof Options<any>> & MotionProps<T, K>)> & import('vue').PublicProps;
17
+ declare const _default: <T extends AsTag = "div", K = unknown>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
18
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & Readonly<import('vue').ExtractPropTypes<{}>>, never>, never> & (Omit<T extends keyof IntrinsicElementAttributes ? SetMotionValueType<IntrinsicElementAttributes, keyof SVGAttributesWithMotionValues>[T] : ComponentProps<T>, "asChild" | keyof Options<any>> & MotionProps<T, K>)> & import('vue').PublicProps;
18
19
  expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
19
20
  attrs: any;
20
21
  slots: {
@@ -26,11 +26,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
26
26
  whilePress: {},
27
27
  whileInView: {},
28
28
  whileFocus: {},
29
+ forwardMotionProps: { type: Boolean },
29
30
  custom: {},
30
31
  initial: { type: [String, Array, Object, Boolean] },
31
32
  animate: {},
32
33
  exit: {},
33
34
  variants: {},
35
+ inherit: { type: Boolean },
34
36
  style: {},
35
37
  transformTemplate: { type: Function },
36
38
  transition: {},
@@ -44,6 +46,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
44
46
  layoutRoot: { type: Boolean },
45
47
  "data-framer-portal-id": {},
46
48
  crossfade: { type: Boolean },
49
+ layoutDependency: {},
47
50
  onBeforeLayoutMeasure: { type: Function },
48
51
  onLayoutMeasure: { type: Function },
49
52
  onLayoutAnimationStart: { type: Function },
@@ -132,18 +135,24 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
132
135
  return `${layoutGroup.id}-${props.layoutId}`;
133
136
  return props.layoutId || void 0;
134
137
  }
135
- function getMotionProps() {
138
+ function getProps() {
136
139
  return {
137
- ...attrs,
138
140
  ...props,
139
141
  layoutId: getLayoutId(),
140
142
  transition: props.transition ?? config.value.transition,
141
143
  layoutGroup,
142
144
  motionConfig: config.value,
143
145
  inViewOptions: props.inViewOptions ?? config.value.inViewOptions,
146
+ animatePresenceContext,
144
147
  initial: animatePresenceContext.initial === false ? animatePresenceContext.initial : props.initial === true ? void 0 : props.initial
145
148
  };
146
149
  }
150
+ function getMotionProps() {
151
+ return {
152
+ ...attrs,
153
+ ...getProps()
154
+ };
155
+ }
147
156
  const state = new MotionState(
148
157
  getMotionProps(),
149
158
  parentState
@@ -169,7 +178,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
169
178
  onUpdated(() => {
170
179
  state.update(getMotionProps());
171
180
  });
172
- function getProps() {
181
+ function getAttrs() {
173
182
  const isSVG = state.visualElement.type === "svg";
174
183
  const attrsProps = { ...attrs };
175
184
  Object.keys(attrs).forEach((key) => {
@@ -181,9 +190,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
181
190
  ...isSVG ? {} : state.visualElement.latestValues
182
191
  };
183
192
  if (isSVG) {
184
- const { attributes, style } = convertSvgStyleToAttributes(state.isMounted() ? state.target : state.baseTarget);
193
+ const { attributes, style } = convertSvgStyleToAttributes({
194
+ ...state.isMounted() ? state.target : state.baseTarget,
195
+ ...styleProps
196
+ });
185
197
  Object.assign(attrsProps, attributes);
186
- Object.assign(styleProps, style);
198
+ styleProps = style;
187
199
  }
188
200
  if (props.drag && props.dragListener !== false) {
189
201
  Object.assign(styleProps, {
@@ -193,10 +205,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
193
205
  touchAction: props.drag === true ? "none" : `pan-${props.drag === "x" ? "y" : "x"}`
194
206
  });
195
207
  }
196
- styleProps = createStyles({
197
- ...styleProps,
198
- ...props.style
199
- });
208
+ styleProps = createStyles(styleProps);
200
209
  attrsProps.style = styleProps;
201
210
  return attrsProps;
202
211
  }
@@ -214,6 +223,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
214
223
  ref_key: "PrimitiveRef",
215
224
  ref: PrimitiveRef,
216
225
  "get-props": getProps,
226
+ "get-attrs": getAttrs,
217
227
  as: _ctx.as,
218
228
  "as-child": _ctx.asChild,
219
229
  "data-motion-group": ((_a = unref(layoutGroup).key) == null ? void 0 : _a.value) || void 0,
@@ -1,9 +1,10 @@
1
- import { DefineComponent, ExtractPropTypes, ExtractPublicPropTypes, IntrinsicElementAttributes } from 'vue';
1
+ import { DefineComponent, IntrinsicElementAttributes } from 'vue';
2
2
  import { MotionProps } from './Motion';
3
- import { MotionHTMLAttributes } from '../../types';
4
- type ComponentProps<T> = T extends DefineComponent<ExtractPropTypes<infer Props>, any, any> ? ExtractPublicPropTypes<Props> : never;
3
+ import { ComponentProps, MotionHTMLAttributes } from '../../types';
5
4
  type MotionComponentProps = {
6
- create: <T extends DefineComponent>(T: any) => DefineComponent<MotionProps<any, unknown> & ComponentProps<T>>;
5
+ create: <T extends DefineComponent>(T: any, options?: {
6
+ forwardMotionProps?: boolean;
7
+ }) => DefineComponent<MotionProps<any, unknown> & ComponentProps<T>>;
7
8
  };
8
9
  type MotionNameSpace = {
9
10
  [K in keyof IntrinsicElementAttributes]: DefineComponent<MotionProps<K, unknown> & MotionHTMLAttributes<K>>;
@@ -7,7 +7,7 @@ const motion = new Proxy(_sfc_main, {
7
7
  return target[prop];
8
8
  let motionComponent = componentCache.get(prop);
9
9
  if (prop === "create") {
10
- return (component) => {
10
+ return (component, { forwardMotionProps = false } = {}) => {
11
11
  return defineComponent({
12
12
  inheritAttrs: false,
13
13
  name: `motion.${component.$name}`,
@@ -15,6 +15,7 @@ const motion = new Proxy(_sfc_main, {
15
15
  return () => {
16
16
  return h(_sfc_main, {
17
17
  ...attrs,
18
+ forwardMotionProps,
18
19
  as: component,
19
20
  asChild: false
20
21
  }, slots);
@@ -1,5 +1,5 @@
1
- import { Component, IntrinsicElementAttributes, PropType } from 'vue';
2
- export type AsTag = keyof IntrinsicElementAttributes | ({} & string);
1
+ import { Component, PropType } from 'vue';
2
+ import { AsTag } from '../../types';
3
3
  export interface PrimitiveProps {
4
4
  /**
5
5
  * Change the default rendered element for the one passed as a child, merging their props and behavior.
@@ -26,6 +26,10 @@ export declare const Primitive: import('vue').DefineComponent<{
26
26
  type: FunctionConstructor;
27
27
  default: () => {};
28
28
  };
29
+ getAttrs: {
30
+ type: FunctionConstructor;
31
+ default: () => {};
32
+ };
29
33
  }, () => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
30
34
  [key: string]: any;
31
35
  }>, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
@@ -41,8 +45,13 @@ export declare const Primitive: import('vue').DefineComponent<{
41
45
  type: FunctionConstructor;
42
46
  default: () => {};
43
47
  };
48
+ getAttrs: {
49
+ type: FunctionConstructor;
50
+ default: () => {};
51
+ };
44
52
  }>>, {
45
53
  as: AsTag;
46
54
  asChild: boolean;
47
55
  getProps: Function;
56
+ getAttrs: Function;
48
57
  }, {}>;
@@ -15,6 +15,10 @@ const Primitive = defineComponent({
15
15
  getProps: {
16
16
  type: Function,
17
17
  default: () => ({})
18
+ },
19
+ getAttrs: {
20
+ type: Function,
21
+ default: () => ({})
18
22
  }
19
23
  },
20
24
  setup(props, { attrs, slots }) {
@@ -22,10 +26,14 @@ const Primitive = defineComponent({
22
26
  const SELF_CLOSING_TAGS = ["area", "img", "input"];
23
27
  return () => {
24
28
  const motionProps = props.getProps();
25
- const allAttrs = { ...motionProps, ...attrs };
29
+ const motionAttrs = props.getAttrs();
30
+ let allAttrs = { ...motionAttrs, ...attrs };
26
31
  if (typeof asTag === "string" && SELF_CLOSING_TAGS.includes(asTag))
27
32
  return h(asTag, allAttrs);
28
33
  if (asTag !== "template") {
34
+ if (motionProps.forwardMotionProps) {
35
+ allAttrs = { ...motionProps, ...allAttrs };
36
+ }
29
37
  return h(props.as, allAttrs, { default: slots.default });
30
38
  }
31
39
  return h(Slot, allAttrs, { default: slots.default });