motion-v 0.11.0-beta.5 β†’ 0.11.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.
Files changed (37) hide show
  1. package/README.md +90 -16
  2. package/dist/cjs/index.js +106 -45
  3. package/dist/es/components/animate-presence/AnimatePresence.d.ts +1 -1
  4. package/dist/es/components/hooks/use-motion-elm.mjs +9 -0
  5. package/dist/es/components/motion/Motion.d.ts +9 -1
  6. package/dist/es/components/motion/Motion.vue.mjs +38 -8
  7. package/dist/es/components/motion/utils.d.ts +0 -1
  8. package/dist/es/components/motion/utils.mjs +2 -7
  9. package/dist/es/components/motion-config/MotionConfig.d.ts +2 -2
  10. package/dist/es/components/motion-config/MotionConfig.vue.mjs +4 -2
  11. package/dist/es/components/motion-config/types.d.ts +2 -0
  12. package/dist/es/components/reorder/Group.vue.mjs +8 -4
  13. package/dist/es/components/reorder/Item.d.ts +6 -6
  14. package/dist/es/components/reorder/Item.vue.mjs +8 -4
  15. package/dist/es/features/gestures/focus/index.mjs +2 -2
  16. package/dist/es/features/gestures/focus/types.d.ts +7 -0
  17. package/dist/es/features/gestures/hover/index.mjs +2 -2
  18. package/dist/es/features/gestures/hover/types.d.ts +7 -0
  19. package/dist/es/features/gestures/in-view/index.mjs +2 -2
  20. package/dist/es/features/gestures/in-view/types.d.ts +7 -0
  21. package/dist/es/features/gestures/press/index.mjs +2 -2
  22. package/dist/es/features/gestures/press/types.d.ts +7 -0
  23. package/dist/es/index.mjs +2 -0
  24. package/dist/es/state/animate-updates.d.ts +1 -1
  25. package/dist/es/state/animate-updates.mjs +15 -11
  26. package/dist/es/state/motion-state.mjs +4 -4
  27. package/dist/es/state/utils/is-variant-labels.mjs +1 -1
  28. package/dist/es/types/state.d.ts +3 -2
  29. package/dist/es/utils/index.d.ts +1 -0
  30. package/dist/es/utils/use-dom-ref.d.ts +1 -1
  31. package/dist/es/utils/use-dom-ref.mjs +22 -0
  32. package/dist/resolver/index.cjs +25 -0
  33. package/dist/resolver/index.d.cts +5 -0
  34. package/dist/resolver/index.d.mts +5 -0
  35. package/dist/resolver/index.mjs +23 -0
  36. package/package.json +13 -3
  37. package/dist/es/shared/index.d.ts +0 -0
package/README.md CHANGED
@@ -1,31 +1,105 @@
1
+ <p align="center">
2
+ <img width="100" height="100" alt="Motion logo" src="https://user-images.githubusercontent.com/7850794/164965523-3eced4c4-6020-467e-acde-f11b7900ad62.png" />
3
+ </p>
1
4
  <h1 align="center">Motion for Vue</h1>
2
5
 
3
- A animation library designed for Vue 3, Powered by [Motion](https://www.framer.com/motion/).
6
+ <br>
4
7
 
5
- ## Features
8
+ <p align="center">
9
+ <a href="https://www.npmjs.com/package/motion-v" target="_blank">
10
+ <img src="https://img.shields.io/npm/v/motion-v.svg?style=flat-square" />
11
+ </a>
12
+ <a href="https://www.npmjs.com/package/motion-v" target="_blank">
13
+ <img src="https://img.shields.io/npm/dm/motion-v.svg?style=flat-square" />
14
+ </a>
15
+ <a href="https://twitter.com/motiondotdev" target="_blank">
16
+ <img src="https://img.shields.io/twitter/follow/framer.svg?style=social&label=Follow" />
17
+ </a>
18
+ </p>
6
19
 
7
- - 🎨 Declarative Animation API
8
- - πŸ”„ Gesture Animation Support
9
- - 🎯 Full TypeScript Support
10
- - ⚑️ High Performance Animation
11
- - 🎭 Variants Animation System
12
- - πŸ‘€ Viewport Animation Trigger
13
- - πŸšͺ Enter/Exit Animation Support
20
+ <br>
21
+ <hr>
22
+ <br>
14
23
 
15
- ## 🏎️ Quick start
16
- Install `motion-v`:
17
- ```bash
24
+ Motion for Vue is an open source, production-ready library that’s designed for all creative developers.
25
+
26
+ It's the only animation library with a hybrid engine, combining the power of JavaScript animations with the performance of native browser APIs.
27
+
28
+ It looks like this:
29
+
30
+ ```jsx
31
+ <motion.div :animate="{ x: 100 }" />
32
+ ```
33
+
34
+ It does all this:
35
+
36
+ - Springs
37
+ - Keyframes
38
+ - Layout animations
39
+ - Shared layout animations
40
+ - Gestures (drag/tap/hover)
41
+ - Scroll animations
42
+ - SVG paths
43
+ - Exit animations
44
+ - Server-side rendering
45
+ - Independent transforms
46
+ - Orchestrate animations across components
47
+ - CSS variables
48
+
49
+ ...and a whole lot more.
50
+
51
+ ## Get started
52
+
53
+ ### πŸ‡ Quick start
54
+
55
+ Install `motion-v` via your package manager:
56
+
57
+ ```
18
58
  npm install motion-v
19
59
  ```
20
- ## Basic Usage
60
+
61
+ Then import the `motion` component:
62
+
21
63
  ```vue
22
64
  <script setup>
23
- import { Motion } from 'motion-v'
65
+ import { motion } from 'motion-v'
24
66
  </script>
25
67
 
26
68
  <template>
27
- <Motion :animate="{ x: 100 }" />
69
+ <motion.div :animate="{ x: 100 }" />
28
70
  </template>
29
71
  ```
30
72
 
31
- Read the full [docs](https://motion.seacoly.me/).
73
+ ### πŸ’Ž Contribute
74
+
75
+ - Want to contribute to Motion? Our [contributing guide](https://github.com/motiondivision/motion-vue/blob/master/CONTRIBUTING.md) has you covered.
76
+
77
+ ### πŸ‘©πŸ»β€βš–οΈ License
78
+
79
+ - Motion for Vue is MIT licensed.
80
+
81
+ ## ✨ Sponsors
82
+
83
+ Motion is sustainable thanks to the kind support of its sponsors.
84
+
85
+ ### Partners
86
+
87
+ #### Framer
88
+
89
+ Motion powers Framer animations, the web builder for creative pros. Design and ship your dream site. Zero code, maximum speed.
90
+
91
+ <a href="https://www.framer.com?utm_source=motion-readme">
92
+ <img alt="Framer" src="https://github.com/user-attachments/assets/0404c7a1-c29d-4785-89ae-aae315f3c759" width="300px" height="200px">
93
+ </a>
94
+
95
+ ### Platinum
96
+
97
+ <a href="https://syntax.fm"><img alt="Syntax.fm" src="https://github.com/user-attachments/assets/ab852bfe-b36c-490b-b98d-4061158c4863" width="300px" height="200px"></a> <a href="https://tailwindcss.com"><img alt="Tailwind" src="https://github.com/user-attachments/assets/c0496f09-b8ee-4bc4-85ab-83a071bbbdec" width="300px" height="200px"></a> <a href="https://emilkowal.ski"><img alt="Emil Kowalski" src="https://github.com/user-attachments/assets/29f56b1a-37fb-4695-a6a6-151f6c24864f" width="300px" height="200px"></a> <a href="https://linear.app"><img alt="Linear" src="https://github.com/user-attachments/assets/a93710bb-d8ed-40e3-b0fb-1c5b3e2b16bb" width="300px" height="200px"></a>
98
+
99
+ ### Gold
100
+
101
+ <a href="https://vercel.com"><img alt="Vercel" src="https://github.com/user-attachments/assets/23cb1e37-fa67-49ad-8f77-7f4b8eaba325" width="225px" height="150px"></a> <a href="https://liveblocks.io"><img alt="Liveblocks" src="https://github.com/user-attachments/assets/31436a47-951e-4eab-9a68-bdd54ccf9444" width="225px" height="150px"></a> <a href="https://lu.ma"><img alt="Luma" src="https://github.com/user-attachments/assets/4fae0c9d-de0f-4042-9cd6-e07885d028a9" width="225px" height="150px"></a>
102
+
103
+ ### Silver
104
+
105
+ <a href="https://www.frontend.fyi/?utm_source=motion"><img alt="Frontend.fyi" src="https://github.com/user-attachments/assets/07d23aa5-69db-44a0-849d-90177e6fc817" width="150px" height="100px"></a> <a href="https://statamic.com"><img alt="Statamic" src="https://github.com/user-attachments/assets/5d28f090-bdd9-4b31-b134-fb2b94ca636f" width="150px" height="100px"></a> <a href="https://firecrawl.dev"><img alt="Firecrawl" src="https://github.com/user-attachments/assets/cba90e54-1329-4353-8fba-85beef4d2ee9" width="150px" height="100px"></a> <a href="https://puzzmo.com"><img alt="Puzzmo" src="https://github.com/user-attachments/assets/aa2d5586-e5e2-43b9-8446-db456e4b0758" width="150px" height="100px"></a> <a href="https://buildui.com"><img alt="Build UI" src="https://github.com/user-attachments/assets/024bfcd5-50e8-4b3d-a115-d5c6d6030d1c" width="150px" height="100px"></a> <a href="https://hover.dev"><img alt="Hover" src="https://github.com/user-attachments/assets/4715b555-d2ac-4cb7-9f35-d36d708827b3" width="150px" height="100px"></a>
package/dist/cjs/index.js CHANGED
@@ -4984,6 +4984,28 @@ function millisecondsToSeconds(milliseconds) {
4984
4984
  function getContextWindow({ current }) {
4985
4985
  return current ? current.ownerDocument.defaultView : null;
4986
4986
  }
4987
+ function getMotionElement(el) {
4988
+ if ((el == null ? void 0 : el.nodeType) === 3 || (el == null ? void 0 : el.nodeType) === 8)
4989
+ return getMotionElement(el.nextSibling);
4990
+ return el;
4991
+ }
4992
+ function useDomRef() {
4993
+ const dom = vue.ref(null);
4994
+ const domProxy = new Proxy(dom, {
4995
+ get(target, key) {
4996
+ if (typeof key === "string" || typeof key === "symbol") {
4997
+ return Reflect.get(target, key);
4998
+ }
4999
+ return void 0;
5000
+ },
5001
+ set(target, key, value) {
5002
+ if (key === "value")
5003
+ return Reflect.set(target, key, getMotionElement((value == null ? void 0 : value.$el) || value));
5004
+ return true;
5005
+ }
5006
+ });
5007
+ return domProxy;
5008
+ }
4987
5009
  const [injectMotion, provideMotion] = createContext("Motion");
4988
5010
  const [injectLayoutGroup, provideLayoutGroup] = createContext("LayoutGroup");
4989
5011
  function resolveVariant(definition, variants, custom) {
@@ -5364,8 +5386,8 @@ class Feature {
5364
5386
  }
5365
5387
  function handleHoverEvent$1(state2, event, lifecycle) {
5366
5388
  const props = state2.options;
5367
- if (props.hover) {
5368
- state2.setActive("hover", lifecycle === "Start");
5389
+ if (props.whileHover) {
5390
+ state2.setActive("whileHover", lifecycle === "Start");
5369
5391
  }
5370
5392
  const eventName = `onHover${lifecycle}`;
5371
5393
  const callback = props[eventName];
@@ -5405,8 +5427,8 @@ function extractEventInfo$1(event) {
5405
5427
  }
5406
5428
  function handlePressEvent(state2, event, lifecycle) {
5407
5429
  const props = state2.options;
5408
- if (props.press) {
5409
- state2.setActive("press", lifecycle === "Start");
5430
+ if (props.whilePress) {
5431
+ state2.setActive("whilePress", lifecycle === "Start");
5410
5432
  }
5411
5433
  const eventName = `onPress${lifecycle === "End" ? "" : lifecycle}`;
5412
5434
  const callback = props[eventName];
@@ -5441,8 +5463,8 @@ class PressGesture extends Feature {
5441
5463
  }
5442
5464
  function handleHoverEvent(state2, entry, lifecycle) {
5443
5465
  const props = state2.options;
5444
- if (props.inView) {
5445
- state2.setActive("inView", lifecycle === "Enter");
5466
+ if (props.whileInView) {
5467
+ state2.setActive("whileInView", lifecycle === "Enter");
5446
5468
  }
5447
5469
  const eventName = `onViewport${lifecycle}`;
5448
5470
  const callback = props[eventName];
@@ -8003,13 +8025,13 @@ class FocusGesture extends Feature {
8003
8025
  }
8004
8026
  if (!isFocusVisible)
8005
8027
  return;
8006
- this.state.setActive("focus", true);
8028
+ this.state.setActive("whileFocus", true);
8007
8029
  this.isActive = true;
8008
8030
  }
8009
8031
  onBlur() {
8010
8032
  if (!this.isActive)
8011
8033
  return;
8012
- this.state.setActive("focus", false);
8034
+ this.state.setActive("whileFocus", false);
8013
8035
  this.isActive = false;
8014
8036
  }
8015
8037
  mount() {
@@ -8097,7 +8119,7 @@ function createVisualElement(Component, options) {
8097
8119
  function motionEvent(name, target, isExit) {
8098
8120
  return new CustomEvent(name, { detail: { target, isExit } });
8099
8121
  }
8100
- const STATE_TYPES = ["initial", "animate", "inView", "hover", "press", "whileDrag", "focus", "exit"];
8122
+ const STATE_TYPES = ["initial", "animate", "whileInView", "whileHover", "whilePress", "whileDrag", "whileFocus", "exit"];
8101
8123
  function animateUpdates({
8102
8124
  controlActiveState = void 0,
8103
8125
  controlDelay = 0,
@@ -8107,31 +8129,34 @@ function animateUpdates({
8107
8129
  } = {}) {
8108
8130
  const prevTarget = this.target;
8109
8131
  this.target = { ...this.baseTarget };
8110
- const animationOptions = {};
8132
+ let animationOptions = {};
8111
8133
  const transition = { ...this.options.transition };
8112
8134
  if (directAnimate)
8113
- resolveDirectAnimation.call(this, directAnimate, directTransition, animationOptions);
8135
+ animationOptions = resolveDirectAnimation.call(this, directAnimate, directTransition, animationOptions);
8114
8136
  else
8115
- resolveStateAnimation.call(this, controlActiveState, animationOptions);
8137
+ animationOptions = resolveStateAnimation.call(this, controlActiveState, transition);
8116
8138
  const factories = createAnimationFactories.call(this, prevTarget, animationOptions, controlDelay);
8117
- const { getChildAnimations, childAnimations } = setupChildAnimations.call(this, transition, controlActiveState, isFallback);
8139
+ const { getChildAnimations, childAnimations } = setupChildAnimations.call(this, transition, this.activeStates, isFallback);
8118
8140
  return executeAnimations.call(this, factories, getChildAnimations, childAnimations, transition, controlActiveState);
8119
8141
  }
8120
- function resolveDirectAnimation(directAnimate, directTransition, animationOptions) {
8142
+ function resolveDirectAnimation(directAnimate, directTransition) {
8121
8143
  const variant = resolveVariant(directAnimate, this.options.variants, this.options.custom);
8122
8144
  if (!variant)
8123
- return;
8145
+ return {};
8124
8146
  const transition = { ...this.options.transition, ...directTransition || variant.transition };
8147
+ const animationOptions = {};
8125
8148
  Object.entries(variant).forEach(([key, value]) => {
8126
8149
  if (key === "transition")
8127
8150
  return;
8128
8151
  this.target[key] = value;
8129
8152
  animationOptions[key] = getOptions(transition, key);
8130
8153
  });
8154
+ return animationOptions;
8131
8155
  }
8132
- function resolveStateAnimation(controlActiveState, animationOptions) {
8156
+ function resolveStateAnimation(controlActiveState, transition) {
8133
8157
  if (controlActiveState)
8134
8158
  this.activeStates = { ...this.activeStates, ...controlActiveState };
8159
+ const transitionOptions = {};
8135
8160
  STATE_TYPES.forEach((name) => {
8136
8161
  if (!this.activeStates[name] || isAnimationControls(this.options[name]))
8137
8162
  return;
@@ -8139,14 +8164,15 @@ function resolveStateAnimation(controlActiveState, animationOptions) {
8139
8164
  const variant = resolveVariant(definition, this.options.variants, this.options.custom);
8140
8165
  if (!variant)
8141
8166
  return;
8142
- const transition = { ...this.options.transition, ...variant.transition };
8167
+ Object.assign(transition, variant.transition);
8143
8168
  Object.entries(variant).forEach(([key, value]) => {
8144
8169
  if (key === "transition")
8145
8170
  return;
8146
8171
  this.target[key] = value;
8147
- animationOptions[key] = getOptions(transition, key);
8172
+ transitionOptions[key] = getOptions(transition, key);
8148
8173
  });
8149
8174
  });
8175
+ return transitionOptions;
8150
8176
  }
8151
8177
  function createAnimationFactories(prevTarget, animationOptions, controlDelay) {
8152
8178
  const factories = [];
@@ -8170,7 +8196,7 @@ function createAnimationFactories(prevTarget, animationOptions, controlDelay) {
8170
8196
  }
8171
8197
  function setupChildAnimations(transition, controlActiveState, isFallback) {
8172
8198
  var _a;
8173
- if (!((_a = this.visualElement.variantChildren) == null ? void 0 : _a.size) || controlActiveState)
8199
+ if (!((_a = this.visualElement.variantChildren) == null ? void 0 : _a.size) || !controlActiveState)
8174
8200
  return { getChildAnimations: () => Promise.resolve(), childAnimations: [] };
8175
8201
  const { staggerChildren = 0, staggerDirection = 1, delayChildren = 0 } = transition || {};
8176
8202
  const maxStaggerDuration = (this.visualElement.variantChildren.size - 1) * staggerChildren;
@@ -8217,7 +8243,7 @@ function executeAnimations(factories, getChildAnimations, childAnimations, trans
8217
8243
  return controlActiveState ? getAnimationPromise : getAnimationPromise();
8218
8244
  }
8219
8245
  function isVariantLabels(value) {
8220
- return typeof value === "string" || Array.isArray(value);
8246
+ return typeof value === "string" || value === false || Array.isArray(value);
8221
8247
  }
8222
8248
  const mountedStates = /* @__PURE__ */ new WeakMap();
8223
8249
  let id = 0;
@@ -8240,16 +8266,16 @@ class MotionState {
8240
8266
  this.parent = parent;
8241
8267
  (_a = parent == null ? void 0 : parent.children) == null ? void 0 : _a.add(this);
8242
8268
  this.depth = (parent == null ? void 0 : parent.depth) + 1 || 0;
8243
- const initialVariantSource = options.initial === false ? "animate" : "initial";
8269
+ const initialVariantSource = this.context.initial === false ? "animate" : "initial";
8244
8270
  this.initTarget(initialVariantSource);
8245
8271
  this.visualElement = createVisualElement(this.options.as, {
8246
8272
  presenceContext: null,
8247
8273
  parent: parent == null ? void 0 : parent.visualElement,
8248
8274
  props: {
8249
8275
  ...this.options,
8250
- whileHover: this.options.hover,
8251
- whileTap: this.options.press,
8252
- whileInView: this.options.inView
8276
+ whileHover: this.options.whileHover,
8277
+ whileTap: this.options.whilePress,
8278
+ whileInView: this.options.whileInView
8253
8279
  },
8254
8280
  visualState: {
8255
8281
  renderState: {
@@ -8400,11 +8426,6 @@ class MotionState {
8400
8426
  }
8401
8427
  }
8402
8428
  }
8403
- function getMotionElement(el) {
8404
- if ((el == null ? void 0 : el.nodeType) === 3 || (el == null ? void 0 : el.nodeType) === 8)
8405
- return getMotionElement(el.nextSibling);
8406
- return el;
8407
- }
8408
8429
  function checkMotionIsHidden(instance) {
8409
8430
  var _a;
8410
8431
  const isHidden = ((_a = getMotionElement(instance.$el)) == null ? void 0 : _a.style.display) === "none";
@@ -8429,7 +8450,15 @@ const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
8429
8450
  props: /* @__PURE__ */ vue.mergeDefaults({
8430
8451
  as: {},
8431
8452
  asChild: { type: Boolean },
8453
+ hover: {},
8454
+ press: {},
8455
+ inView: {},
8456
+ focus: {},
8432
8457
  whileDrag: {},
8458
+ whileHover: {},
8459
+ whilePress: {},
8460
+ whileInView: {},
8461
+ whileFocus: {},
8433
8462
  custom: {},
8434
8463
  initial: { type: [String, Array, Object, Boolean] },
8435
8464
  animate: {},
@@ -8453,15 +8482,12 @@ const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
8453
8482
  onLayoutAnimationStart: { type: Function },
8454
8483
  onLayoutAnimationComplete: { type: Function },
8455
8484
  globalPressTarget: { type: Boolean },
8456
- press: {},
8457
8485
  onPressStart: { type: Function },
8458
8486
  onPress: { type: Function },
8459
8487
  onPressCancel: { type: Function },
8460
- hover: {},
8461
8488
  onHoverStart: { type: Function },
8462
8489
  onHoverEnd: { type: Function },
8463
8490
  inViewOptions: {},
8464
- inView: {},
8465
8491
  onViewportEnter: { type: Function },
8466
8492
  onViewportLeave: { type: Function },
8467
8493
  drag: { type: [Boolean, String] },
@@ -8484,7 +8510,6 @@ const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
8484
8510
  onPanStart: { type: Function },
8485
8511
  onPan: { type: Function },
8486
8512
  onPanEnd: { type: Function },
8487
- focus: {},
8488
8513
  onFocus: { type: Function },
8489
8514
  onBlur: { type: Function }
8490
8515
  }, {
@@ -8502,7 +8527,31 @@ const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
8502
8527
  dragElastic: 0.5,
8503
8528
  dragMomentum: true,
8504
8529
  whileDrag: void 0,
8505
- crossfade: true
8530
+ crossfade: true,
8531
+ whileHover: ({ hover: hover2 }) => {
8532
+ if (process.env.NODE_ENV === "development" && hover2) {
8533
+ vue.warn("hover is deprecated. Use whileHover instead.");
8534
+ }
8535
+ return hover2;
8536
+ },
8537
+ whilePress: ({ press: press2 }) => {
8538
+ if (process.env.NODE_ENV === "development" && press2) {
8539
+ vue.warn("press is deprecated. Use whilePress instead.");
8540
+ }
8541
+ return press2;
8542
+ },
8543
+ whileInView: ({ inView: inView2 }) => {
8544
+ if (process.env.NODE_ENV === "development" && inView2) {
8545
+ vue.warn("inView is deprecated. Use whileInView instead.");
8546
+ }
8547
+ return inView2;
8548
+ },
8549
+ whileFocus: ({ focus }) => {
8550
+ if (process.env.NODE_ENV === "development" && focus) {
8551
+ vue.warn("focus is deprecated. Use whileFocus instead.");
8552
+ }
8553
+ return focus;
8554
+ }
8506
8555
  }),
8507
8556
  setup(__props) {
8508
8557
  const props = __props;
@@ -8524,6 +8573,7 @@ const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
8524
8573
  transition: props.transition ?? config.value.transition,
8525
8574
  layoutGroup,
8526
8575
  motionConfig: config.value,
8576
+ inViewOptions: props.inViewOptions ?? config.value.inViewOptions,
8527
8577
  initial: animatePresenceContext.initial === false ? animatePresenceContext.initial : props.initial === true ? void 0 : props.initial
8528
8578
  };
8529
8579
  }
@@ -8564,7 +8614,7 @@ const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
8564
8614
  ...isSVG ? {} : state2.visualElement.latestValues
8565
8615
  };
8566
8616
  if (isSVG) {
8567
- const { attributes, style: style2 } = convertSvgStyleToAttributes(state2.target);
8617
+ const { attributes, style: style2 } = convertSvgStyleToAttributes(state2.isMounted() ? state2.target : state2.baseTarget);
8568
8618
  Object.assign(attrsProps, attributes);
8569
8619
  Object.assign(styleProps, style2);
8570
8620
  }
@@ -8822,7 +8872,8 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
8822
8872
  props: {
8823
8873
  transition: {},
8824
8874
  reduceMotion: { default: defaultConfig.reduceMotion },
8825
- nonce: {}
8875
+ nonce: {},
8876
+ inViewOptions: {}
8826
8877
  },
8827
8878
  setup(__props) {
8828
8879
  const props = __props;
@@ -8830,7 +8881,8 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
8830
8881
  const config = vue.computed(() => ({
8831
8882
  transition: props.transition ?? parentConfig.value.transition,
8832
8883
  reduceMotion: props.reduceMotion ?? parentConfig.value.reduceMotion,
8833
- nonce: props.nonce ?? parentConfig.value.nonce
8884
+ nonce: props.nonce ?? parentConfig.value.nonce,
8885
+ inViewOptions: props.inViewOptions ?? parentConfig.value.inViewOptions
8834
8886
  }));
8835
8887
  provideMotionConfig(config);
8836
8888
  return (_ctx, _cache) => {
@@ -8887,7 +8939,15 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
8887
8939
  values: {},
8888
8940
  as: { default: "ul" },
8889
8941
  asChild: { type: Boolean },
8942
+ hover: {},
8943
+ press: {},
8944
+ inView: {},
8945
+ focus: {},
8890
8946
  whileDrag: {},
8947
+ whileHover: {},
8948
+ whilePress: {},
8949
+ whileInView: {},
8950
+ whileFocus: {},
8891
8951
  custom: {},
8892
8952
  initial: { type: [String, Array, Object, Boolean] },
8893
8953
  animate: {},
@@ -8911,15 +8971,12 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
8911
8971
  onLayoutAnimationStart: {},
8912
8972
  onLayoutAnimationComplete: {},
8913
8973
  globalPressTarget: { type: Boolean },
8914
- press: {},
8915
8974
  onPressStart: {},
8916
8975
  onPress: {},
8917
8976
  onPressCancel: {},
8918
- hover: {},
8919
8977
  onHoverStart: {},
8920
8978
  onHoverEnd: {},
8921
8979
  inViewOptions: {},
8922
- inView: {},
8923
8980
  onViewportEnter: {},
8924
8981
  onViewportLeave: {},
8925
8982
  drag: { type: [Boolean, String] },
@@ -8942,7 +8999,6 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
8942
8999
  onPanStart: {},
8943
9000
  onPan: {},
8944
9001
  onPanEnd: {},
8945
- focus: {},
8946
9002
  onFocus: {},
8947
9003
  onBlur: {}
8948
9004
  },
@@ -9211,7 +9267,15 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
9211
9267
  layout: { type: [Boolean, String], default: true },
9212
9268
  as: { default: "li" },
9213
9269
  asChild: { type: Boolean },
9270
+ hover: { default: void 0 },
9271
+ press: {},
9272
+ inView: { default: void 0 },
9273
+ focus: {},
9214
9274
  whileDrag: { default: void 0 },
9275
+ whileHover: {},
9276
+ whilePress: {},
9277
+ whileInView: {},
9278
+ whileFocus: {},
9215
9279
  custom: {},
9216
9280
  initial: { type: [String, Array, Object, Boolean], default: void 0 },
9217
9281
  animate: { default: void 0 },
@@ -9234,15 +9298,12 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
9234
9298
  onLayoutAnimationStart: {},
9235
9299
  onLayoutAnimationComplete: {},
9236
9300
  globalPressTarget: { type: Boolean },
9237
- press: {},
9238
9301
  onPressStart: {},
9239
9302
  onPress: {},
9240
9303
  onPressCancel: {},
9241
- hover: { default: void 0 },
9242
9304
  onHoverStart: {},
9243
9305
  onHoverEnd: {},
9244
9306
  inViewOptions: {},
9245
- inView: { default: void 0 },
9246
9307
  onViewportEnter: {},
9247
9308
  onViewportLeave: {},
9248
9309
  drag: { type: [Boolean, String] },
@@ -9265,7 +9326,6 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
9265
9326
  onPanStart: {},
9266
9327
  onPan: {},
9267
9328
  onPanEnd: {},
9268
- focus: {},
9269
9329
  onFocus: {},
9270
9330
  onBlur: {}
9271
9331
  },
@@ -9686,6 +9746,7 @@ exports.useAnimationControls = useAnimationControls;
9686
9746
  exports.useAnimationFrame = useAnimationFrame;
9687
9747
  exports.useCombineMotionValues = useCombineMotionValues;
9688
9748
  exports.useComputed = useComputed;
9749
+ exports.useDomRef = useDomRef;
9689
9750
  exports.useDragControls = useDragControls;
9690
9751
  exports.useInView = useInView;
9691
9752
  exports.useLayoutGroup = useLayoutGroup;
@@ -20,8 +20,8 @@ declare const __VLS_component: import('vue').DefineComponent<__VLS_WithDefaults<
20
20
  unwrapElement: boolean;
21
21
  anchorX: string;
22
22
  }>>>, {
23
- initial: boolean;
24
23
  mode: "wait" | "popLayout" | "sync";
24
+ initial: boolean;
25
25
  multiple: boolean;
26
26
  unwrapElement: boolean;
27
27
  anchorX: "left" | "right";
@@ -0,0 +1,9 @@
1
+ import "vue";
2
+ function getMotionElement(el) {
3
+ if ((el == null ? void 0 : el.nodeType) === 3 || (el == null ? void 0 : el.nodeType) === 8)
4
+ return getMotionElement(el.nextSibling);
5
+ return el;
6
+ }
7
+ export {
8
+ getMotionElement
9
+ };
@@ -3,10 +3,18 @@ import { ElementType, Options, SVGAttributesWithMotionValues, SetMotionValueType
3
3
  export interface MotionProps<T extends ElementType = 'div', K = unknown> extends Options<K> {
4
4
  as?: T;
5
5
  asChild?: boolean;
6
+ hover?: Options['hover'];
7
+ press?: Options['press'];
8
+ inView?: Options['inView'];
9
+ focus?: Options['focus'];
6
10
  whileDrag?: Options['whileDrag'];
11
+ whileHover?: Options['whileHover'];
12
+ whilePress?: Options['whilePress'];
13
+ whileInView?: Options['whileInView'];
14
+ whileFocus?: Options['whileFocus'];
7
15
  }
8
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<{
9
- 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
+ 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], keyof Options<any> | "asChild"> & MotionProps<T, K>)> & import('vue').PublicProps;
10
18
  expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
11
19
  attrs: any;
12
20
  slots: {
@@ -1,11 +1,12 @@
1
- import { defineComponent, mergeDefaults, useAttrs, getCurrentInstance, onBeforeMount, onMounted, onBeforeUnmount, onUnmounted, onBeforeUpdate, onUpdated, ref, openBlock, createBlock, unref, withCtx, renderSlot } from "vue";
1
+ import { defineComponent, mergeDefaults, warn, useAttrs, getCurrentInstance, onBeforeMount, onMounted, onBeforeUnmount, onUnmounted, onBeforeUpdate, onUpdated, ref, openBlock, createBlock, unref, withCtx, renderSlot } from "vue";
2
2
  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
6
  import { injectAnimatePresence } from "../presence.mjs";
7
- import { getMotionElement, checkMotionIsHidden } from "./utils.mjs";
7
+ import { checkMotionIsHidden } from "./utils.mjs";
8
8
  import { useMotionConfig } from "../motion-config/context.mjs";
9
+ import { getMotionElement } from "../hooks/use-motion-elm.mjs";
9
10
  import { isMotionValue } from "../../utils/motion-value.mjs";
10
11
  const _sfc_main = /* @__PURE__ */ defineComponent({
11
12
  ...{
@@ -16,7 +17,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
16
17
  props: /* @__PURE__ */ mergeDefaults({
17
18
  as: {},
18
19
  asChild: { type: Boolean },
20
+ hover: {},
21
+ press: {},
22
+ inView: {},
23
+ focus: {},
19
24
  whileDrag: {},
25
+ whileHover: {},
26
+ whilePress: {},
27
+ whileInView: {},
28
+ whileFocus: {},
20
29
  custom: {},
21
30
  initial: { type: [String, Array, Object, Boolean] },
22
31
  animate: {},
@@ -40,15 +49,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
40
49
  onLayoutAnimationStart: { type: Function },
41
50
  onLayoutAnimationComplete: { type: Function },
42
51
  globalPressTarget: { type: Boolean },
43
- press: {},
44
52
  onPressStart: { type: Function },
45
53
  onPress: { type: Function },
46
54
  onPressCancel: { type: Function },
47
- hover: {},
48
55
  onHoverStart: { type: Function },
49
56
  onHoverEnd: { type: Function },
50
57
  inViewOptions: {},
51
- inView: {},
52
58
  onViewportEnter: { type: Function },
53
59
  onViewportLeave: { type: Function },
54
60
  drag: { type: [Boolean, String] },
@@ -71,7 +77,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
71
77
  onPanStart: { type: Function },
72
78
  onPan: { type: Function },
73
79
  onPanEnd: { type: Function },
74
- focus: {},
75
80
  onFocus: { type: Function },
76
81
  onBlur: { type: Function }
77
82
  }, {
@@ -89,7 +94,31 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
89
94
  dragElastic: 0.5,
90
95
  dragMomentum: true,
91
96
  whileDrag: void 0,
92
- crossfade: true
97
+ crossfade: true,
98
+ whileHover: ({ hover }) => {
99
+ if (process.env.NODE_ENV === "development" && hover) {
100
+ warn("hover is deprecated. Use whileHover instead.");
101
+ }
102
+ return hover;
103
+ },
104
+ whilePress: ({ press }) => {
105
+ if (process.env.NODE_ENV === "development" && press) {
106
+ warn("press is deprecated. Use whilePress instead.");
107
+ }
108
+ return press;
109
+ },
110
+ whileInView: ({ inView }) => {
111
+ if (process.env.NODE_ENV === "development" && inView) {
112
+ warn("inView is deprecated. Use whileInView instead.");
113
+ }
114
+ return inView;
115
+ },
116
+ whileFocus: ({ focus }) => {
117
+ if (process.env.NODE_ENV === "development" && focus) {
118
+ warn("focus is deprecated. Use whileFocus instead.");
119
+ }
120
+ return focus;
121
+ }
93
122
  }),
94
123
  setup(__props) {
95
124
  const props = __props;
@@ -111,6 +140,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
111
140
  transition: props.transition ?? config.value.transition,
112
141
  layoutGroup,
113
142
  motionConfig: config.value,
143
+ inViewOptions: props.inViewOptions ?? config.value.inViewOptions,
114
144
  initial: animatePresenceContext.initial === false ? animatePresenceContext.initial : props.initial === true ? void 0 : props.initial
115
145
  };
116
146
  }
@@ -151,7 +181,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
151
181
  ...isSVG ? {} : state.visualElement.latestValues
152
182
  };
153
183
  if (isSVG) {
154
- const { attributes, style } = convertSvgStyleToAttributes(state.target);
184
+ const { attributes, style } = convertSvgStyleToAttributes(state.isMounted() ? state.target : state.baseTarget);
155
185
  Object.assign(attrsProps, attributes);
156
186
  Object.assign(styleProps, style);
157
187
  }
@@ -1,5 +1,4 @@
1
1
  import { ComponentPublicInstance } from 'vue';
2
- export declare function getMotionElement(el: HTMLElement): HTMLElement;
3
2
  /**
4
3
  * ζ£€ζŸ₯ζ˜―ε¦ζ˜―ιšθ—ηš„ motion ε…ƒη΄ 
5
4
  * @param instance
@@ -1,8 +1,4 @@
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
- }
1
+ import { getMotionElement } from "../hooks/use-motion-elm.mjs";
6
2
  function checkMotionIsHidden(instance) {
7
3
  var _a;
8
4
  const isHidden = ((_a = getMotionElement(instance.$el)) == null ? void 0 : _a.style.display) === "none";
@@ -10,6 +6,5 @@ function checkMotionIsHidden(instance) {
10
6
  return hasTransition && isHidden;
11
7
  }
12
8
  export {
13
- checkMotionIsHidden,
14
- getMotionElement
9
+ checkMotionIsHidden
15
10
  };
@@ -7,9 +7,9 @@ declare function __VLS_template(): {
7
7
  };
8
8
  type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
9
9
  declare const __VLS_component: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<import('./types').MotionConfigState>, {
10
- reduceMotion: "user" | "never" | "always";
10
+ reduceMotion: "always" | "user" | "never";
11
11
  }>, {}, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<import('./types').MotionConfigState>, {
12
- reduceMotion: "user" | "never" | "always";
12
+ reduceMotion: "always" | "user" | "never";
13
13
  }>>>, {
14
14
  reduceMotion: "user" | "never" | "always";
15
15
  }, {}>;
@@ -9,7 +9,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
9
9
  props: {
10
10
  transition: {},
11
11
  reduceMotion: { default: defaultConfig.reduceMotion },
12
- nonce: {}
12
+ nonce: {},
13
+ inViewOptions: {}
13
14
  },
14
15
  setup(__props) {
15
16
  const props = __props;
@@ -17,7 +18,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
17
18
  const config = computed(() => ({
18
19
  transition: props.transition ?? parentConfig.value.transition,
19
20
  reduceMotion: props.reduceMotion ?? parentConfig.value.reduceMotion,
20
- nonce: props.nonce ?? parentConfig.value.nonce
21
+ nonce: props.nonce ?? parentConfig.value.nonce,
22
+ inViewOptions: props.inViewOptions ?? parentConfig.value.inViewOptions
21
23
  }));
22
24
  provideMotionConfig(config);
23
25
  return (_ctx, _cache) => {
@@ -9,6 +9,8 @@ export interface MotionConfigState {
9
9
  reduceMotion?: 'user' | 'never' | 'always';
10
10
  /** Custom nonce for CSP compliance with inline styles */
11
11
  nonce?: string;
12
+ /** Options for the inView prop */
13
+ inViewOptions?: Options['inViewOptions'];
12
14
  }
13
15
  /** Props interface matching the config state */
14
16
  export type MotionConfigProps = MotionConfigState;
@@ -15,7 +15,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
15
15
  values: {},
16
16
  as: { default: "ul" },
17
17
  asChild: { type: Boolean },
18
+ hover: {},
19
+ press: {},
20
+ inView: {},
21
+ focus: {},
18
22
  whileDrag: {},
23
+ whileHover: {},
24
+ whilePress: {},
25
+ whileInView: {},
26
+ whileFocus: {},
19
27
  custom: {},
20
28
  initial: { type: [String, Array, Object, Boolean] },
21
29
  animate: {},
@@ -39,15 +47,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
39
47
  onLayoutAnimationStart: {},
40
48
  onLayoutAnimationComplete: {},
41
49
  globalPressTarget: { type: Boolean },
42
- press: {},
43
50
  onPressStart: {},
44
51
  onPress: {},
45
52
  onPressCancel: {},
46
- hover: {},
47
53
  onHoverStart: {},
48
54
  onHoverEnd: {},
49
55
  inViewOptions: {},
50
- inView: {},
51
56
  onViewportEnter: {},
52
57
  onViewportLeave: {},
53
58
  drag: { type: [Boolean, String] },
@@ -70,7 +75,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
70
75
  onPanStart: {},
71
76
  onPan: {},
72
77
  onPanEnd: {},
73
- focus: {},
74
78
  onFocus: {},
75
79
  onBlur: {}
76
80
  },
@@ -46,20 +46,20 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<__
46
46
  whileDrag: any;
47
47
  crossfade: boolean;
48
48
  }>>>, {
49
+ as: keyof import('vue').IntrinsicElementAttributes;
50
+ initial: import('../../types').VariantLabels | import('../../types').Variant | boolean;
51
+ animate: import('../../types').VariantLabels | import('../../types').Variant | import('../../animation/types').AnimationControls;
49
52
  layout: true | "position";
50
53
  layoutId: string;
51
54
  layoutScroll: boolean;
52
55
  layoutRoot: boolean;
53
56
  crossfade: boolean;
54
- initial: import('../../types').VariantLabels | import('../../types').Variant | boolean;
55
- animate: import('../../types').VariantLabels | import('../../types').Variant | import('../../animation/types').AnimationControls;
56
- inView: import('../../types').VariantLabels | import('../../types').Variant;
57
- hover: import('../../types').VariantLabels | import('../../types').Variant;
58
- whileDrag: import('../../types').Options["whileDrag"];
57
+ hover: import('../../types').Options["hover"];
58
+ inView: import('../../types').Options["inView"];
59
59
  dragElastic: number;
60
60
  dragMomentum: boolean;
61
61
  dragListener: boolean;
62
- as: keyof import('vue').IntrinsicElementAttributes;
62
+ whileDrag: import('../../types').Options["whileDrag"];
63
63
  }, {}>, {
64
64
  default?(_: {}): any;
65
65
  }>;
@@ -15,7 +15,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
15
15
  layout: { type: [Boolean, String], default: true },
16
16
  as: { default: "li" },
17
17
  asChild: { type: Boolean },
18
+ hover: { default: void 0 },
19
+ press: {},
20
+ inView: { default: void 0 },
21
+ focus: {},
18
22
  whileDrag: { default: void 0 },
23
+ whileHover: {},
24
+ whilePress: {},
25
+ whileInView: {},
26
+ whileFocus: {},
19
27
  custom: {},
20
28
  initial: { type: [String, Array, Object, Boolean], default: void 0 },
21
29
  animate: { default: void 0 },
@@ -38,15 +46,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
38
46
  onLayoutAnimationStart: {},
39
47
  onLayoutAnimationComplete: {},
40
48
  globalPressTarget: { type: Boolean },
41
- press: {},
42
49
  onPressStart: {},
43
50
  onPress: {},
44
51
  onPressCancel: {},
45
- hover: { default: void 0 },
46
52
  onHoverStart: {},
47
53
  onHoverEnd: {},
48
54
  inViewOptions: {},
49
- inView: { default: void 0 },
50
55
  onViewportEnter: {},
51
56
  onViewportLeave: {},
52
57
  drag: { type: [Boolean, String] },
@@ -69,7 +74,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
69
74
  onPanStart: {},
70
75
  onPan: {},
71
76
  onPanEnd: {},
72
- focus: {},
73
77
  onFocus: {},
74
78
  onBlur: {}
75
79
  },
@@ -15,13 +15,13 @@ class FocusGesture extends Feature {
15
15
  }
16
16
  if (!isFocusVisible)
17
17
  return;
18
- this.state.setActive("focus", true);
18
+ this.state.setActive("whileFocus", true);
19
19
  this.isActive = true;
20
20
  }
21
21
  onBlur() {
22
22
  if (!this.isActive)
23
23
  return;
24
- this.state.setActive("focus", false);
24
+ this.state.setActive("whileFocus", false);
25
25
  this.isActive = false;
26
26
  }
27
27
  mount() {
@@ -1,6 +1,13 @@
1
1
  import { Variant, VariantLabels } from '../../../types';
2
2
  export type FocusProps = {
3
+ /**
4
+ * @deprecated Use `whileFocus` instead.
5
+ */
3
6
  focus?: VariantLabels | Variant;
7
+ /**
8
+ * Variant to apply when the element is focused.
9
+ */
10
+ whileFocus?: VariantLabels | Variant;
4
11
  onFocus?: (e: FocusEvent) => void;
5
12
  onBlur?: (e: FocusEvent) => void;
6
13
  };
@@ -5,8 +5,8 @@ import { frame } from "../../../external/.pnpm/framer-motion@11.16.6/external/fr
5
5
  import { extractEventInfo } from "../press/index.mjs";
6
6
  function handleHoverEvent(state, event, lifecycle) {
7
7
  const props = state.options;
8
- if (props.hover) {
9
- state.setActive("hover", lifecycle === "Start");
8
+ if (props.whileHover) {
9
+ state.setActive("whileHover", lifecycle === "Start");
10
10
  }
11
11
  const eventName = `onHover${lifecycle}`;
12
12
  const callback = props[eventName];
@@ -2,7 +2,14 @@ import { Variant, VariantLabels } from '../../../types';
2
2
  import { EventInfo } from 'framer-motion';
3
3
  export type HoverEvent = (event: MouseEvent, info: EventInfo) => void;
4
4
  export interface HoverProps {
5
+ /**
6
+ * @deprecated Use `whileHover` instead.
7
+ */
5
8
  hover?: VariantLabels | Variant;
9
+ /**
10
+ * Variant to apply when the element is hovered.
11
+ */
12
+ whileHover?: VariantLabels | Variant;
6
13
  onHoverStart?: HoverEvent;
7
14
  onHoverEnd?: HoverEvent;
8
15
  }
@@ -3,8 +3,8 @@ import { inView } from "../../../external/.pnpm/framer-motion@11.16.6/external/f
3
3
  import { frame } from "../../../external/.pnpm/framer-motion@11.16.6/external/framer-motion/dist/es/frameloop/frame.mjs";
4
4
  function handleHoverEvent(state, entry, lifecycle) {
5
5
  const props = state.options;
6
- if (props.inView) {
7
- state.setActive("inView", lifecycle === "Enter");
6
+ if (props.whileInView) {
7
+ state.setActive("whileInView", lifecycle === "Enter");
8
8
  }
9
9
  const eventName = `onViewport${lifecycle}`;
10
10
  const callback = props[eventName];
@@ -11,7 +11,14 @@ export interface InViewProps {
11
11
  inViewOptions?: InViewOptions & {
12
12
  once?: boolean;
13
13
  };
14
+ /**
15
+ * @deprecated Use `whileInView` instead.
16
+ */
14
17
  inView?: VariantLabels | Variant;
18
+ /**
19
+ * Variant to apply when the element is in view.
20
+ */
21
+ whileInView?: VariantLabels | Variant;
15
22
  onViewportEnter?: ViewportEventHandler;
16
23
  onViewportLeave?: ViewportEventHandler;
17
24
  }
@@ -12,8 +12,8 @@ function extractEventInfo(event) {
12
12
  }
13
13
  function handlePressEvent(state, event, lifecycle) {
14
14
  const props = state.options;
15
- if (props.press) {
16
- state.setActive("press", lifecycle === "Start");
15
+ if (props.whilePress) {
16
+ state.setActive("whilePress", lifecycle === "Start");
17
17
  }
18
18
  const eventName = `onPress${lifecycle === "End" ? "" : lifecycle}`;
19
19
  const callback = props[eventName];
@@ -6,7 +6,14 @@ export interface PressProps {
6
6
  * If `true`, the press gesture will attach its start listener to window.
7
7
  */
8
8
  globalPressTarget?: boolean;
9
+ /**
10
+ * @deprecated Use `whilePress` instead.
11
+ */
9
12
  press?: VariantLabels | Variant;
13
+ /**
14
+ * Variant to apply when the element is pressed.
15
+ */
16
+ whilePress?: VariantLabels | Variant;
10
17
  onPressStart?: PressEvent;
11
18
  onPress?: PressEvent;
12
19
  onPressCancel?: PressEvent;
package/dist/es/index.mjs CHANGED
@@ -62,6 +62,7 @@ import { useInView } from "./utils/use-in-view.mjs";
62
62
  import { useAnimationFrame } from "./utils/use-animation-frame.mjs";
63
63
  import { millisecondsToSeconds, secondsToMilliseconds } from "./utils/time-conversion.mjs";
64
64
  import { getContextWindow } from "./utils/get-context-window.mjs";
65
+ import { useDomRef } from "./utils/use-dom-ref.mjs";
65
66
  export {
66
67
  default5 as AnimatePresence,
67
68
  default2 as LayoutGroup,
@@ -135,6 +136,7 @@ export {
135
136
  useAnimationFrame,
136
137
  useCombineMotionValues,
137
138
  useComputed,
139
+ useDomRef,
138
140
  useDragControls,
139
141
  useInView,
140
142
  useLayoutGroup,
@@ -1,6 +1,6 @@
1
1
  import { $Transition, Options } from '../types';
2
2
  import { MotionState } from './motion-state';
3
- declare const STATE_TYPES: readonly ["initial", "animate", "inView", "hover", "press", "whileDrag", "focus", "exit"];
3
+ declare const STATE_TYPES: readonly ["initial", "animate", "whileInView", "whileHover", "whilePress", "whileDrag", "whileFocus", "exit"];
4
4
  export type StateType = typeof STATE_TYPES[number];
5
5
  /**
6
6
  * ζ ΈεΏƒεŠ¨η”»ζ›΄ζ–°ε‡½ζ•°,ε€„η†ζ‰€ζœ‰εŠ¨η”»ηŠΆζ€ε˜εŒ–ε’Œζ‰§θ‘Œ
@@ -7,7 +7,7 @@ import { isAnimationControls } from "../animation/utils.mjs";
7
7
  import { animate } from "../external/.pnpm/framer-motion@11.16.6/external/framer-motion/dist/es/animation/animate/index.mjs";
8
8
  import { noop } from "../external/.pnpm/motion-utils@11.16.0/external/motion-utils/dist/es/noop.mjs";
9
9
  import "../external/.pnpm/motion-utils@11.16.0/external/motion-utils/dist/es/errors.mjs";
10
- const STATE_TYPES = ["initial", "animate", "inView", "hover", "press", "whileDrag", "focus", "exit"];
10
+ const STATE_TYPES = ["initial", "animate", "whileInView", "whileHover", "whilePress", "whileDrag", "whileFocus", "exit"];
11
11
  function animateUpdates({
12
12
  controlActiveState = void 0,
13
13
  controlDelay = 0,
@@ -17,31 +17,34 @@ function animateUpdates({
17
17
  } = {}) {
18
18
  const prevTarget = this.target;
19
19
  this.target = { ...this.baseTarget };
20
- const animationOptions = {};
20
+ let animationOptions = {};
21
21
  const transition = { ...this.options.transition };
22
22
  if (directAnimate)
23
- resolveDirectAnimation.call(this, directAnimate, directTransition, animationOptions);
23
+ animationOptions = resolveDirectAnimation.call(this, directAnimate, directTransition, animationOptions);
24
24
  else
25
- resolveStateAnimation.call(this, controlActiveState, animationOptions);
25
+ animationOptions = resolveStateAnimation.call(this, controlActiveState, transition);
26
26
  const factories = createAnimationFactories.call(this, prevTarget, animationOptions, controlDelay);
27
- const { getChildAnimations, childAnimations } = setupChildAnimations.call(this, transition, controlActiveState, isFallback);
27
+ const { getChildAnimations, childAnimations } = setupChildAnimations.call(this, transition, this.activeStates, isFallback);
28
28
  return executeAnimations.call(this, factories, getChildAnimations, childAnimations, transition, controlActiveState);
29
29
  }
30
- function resolveDirectAnimation(directAnimate, directTransition, animationOptions) {
30
+ function resolveDirectAnimation(directAnimate, directTransition) {
31
31
  const variant = resolveVariant(directAnimate, this.options.variants, this.options.custom);
32
32
  if (!variant)
33
- return;
33
+ return {};
34
34
  const transition = { ...this.options.transition, ...directTransition || variant.transition };
35
+ const animationOptions = {};
35
36
  Object.entries(variant).forEach(([key, value]) => {
36
37
  if (key === "transition")
37
38
  return;
38
39
  this.target[key] = value;
39
40
  animationOptions[key] = getOptions(transition, key);
40
41
  });
42
+ return animationOptions;
41
43
  }
42
- function resolveStateAnimation(controlActiveState, animationOptions) {
44
+ function resolveStateAnimation(controlActiveState, transition) {
43
45
  if (controlActiveState)
44
46
  this.activeStates = { ...this.activeStates, ...controlActiveState };
47
+ const transitionOptions = {};
45
48
  STATE_TYPES.forEach((name) => {
46
49
  if (!this.activeStates[name] || isAnimationControls(this.options[name]))
47
50
  return;
@@ -49,14 +52,15 @@ function resolveStateAnimation(controlActiveState, animationOptions) {
49
52
  const variant = resolveVariant(definition, this.options.variants, this.options.custom);
50
53
  if (!variant)
51
54
  return;
52
- const transition = { ...this.options.transition, ...variant.transition };
55
+ Object.assign(transition, variant.transition);
53
56
  Object.entries(variant).forEach(([key, value]) => {
54
57
  if (key === "transition")
55
58
  return;
56
59
  this.target[key] = value;
57
- animationOptions[key] = getOptions(transition, key);
60
+ transitionOptions[key] = getOptions(transition, key);
58
61
  });
59
62
  });
63
+ return transitionOptions;
60
64
  }
61
65
  function createAnimationFactories(prevTarget, animationOptions, controlDelay) {
62
66
  const factories = [];
@@ -80,7 +84,7 @@ function createAnimationFactories(prevTarget, animationOptions, controlDelay) {
80
84
  }
81
85
  function setupChildAnimations(transition, controlActiveState, isFallback) {
82
86
  var _a;
83
- if (!((_a = this.visualElement.variantChildren) == null ? void 0 : _a.size) || controlActiveState)
87
+ if (!((_a = this.visualElement.variantChildren) == null ? void 0 : _a.size) || !controlActiveState)
84
88
  return { getChildAnimations: () => Promise.resolve(), childAnimations: [] };
85
89
  const { staggerChildren = 0, staggerDirection = 1, delayChildren = 0 } = transition || {};
86
90
  const maxStaggerDuration = (this.visualElement.variantChildren.size - 1) * staggerChildren;
@@ -28,16 +28,16 @@ class MotionState {
28
28
  this.parent = parent;
29
29
  (_a = parent == null ? void 0 : parent.children) == null ? void 0 : _a.add(this);
30
30
  this.depth = (parent == null ? void 0 : parent.depth) + 1 || 0;
31
- const initialVariantSource = options.initial === false ? "animate" : "initial";
31
+ const initialVariantSource = this.context.initial === false ? "animate" : "initial";
32
32
  this.initTarget(initialVariantSource);
33
33
  this.visualElement = createVisualElement(this.options.as, {
34
34
  presenceContext: null,
35
35
  parent: parent == null ? void 0 : parent.visualElement,
36
36
  props: {
37
37
  ...this.options,
38
- whileHover: this.options.hover,
39
- whileTap: this.options.press,
40
- whileInView: this.options.inView
38
+ whileHover: this.options.whileHover,
39
+ whileTap: this.options.whilePress,
40
+ whileInView: this.options.whileInView
41
41
  },
42
42
  visualState: {
43
43
  renderState: {
@@ -1,5 +1,5 @@
1
1
  function isVariantLabels(value) {
2
- return typeof value === "string" || Array.isArray(value);
2
+ return typeof value === "string" || value === false || Array.isArray(value);
3
3
  }
4
4
  export {
5
5
  isVariantLabels
@@ -32,8 +32,9 @@ export interface DragOptions {
32
32
  constraints?: false | Partial<BoundingBox>;
33
33
  dragSnapToOrigin?: boolean;
34
34
  }
35
+ type TransformPropertiesWithoutTransition = Omit<TransformProperties, 'transition'>;
35
36
  export type MotionStyle = Partial<{
36
- [K in keyof (Variant & TransformProperties)]: (Variant & TransformProperties)[K] | MotionValue;
37
+ [K in keyof (Variant & TransformPropertiesWithoutTransition)]: string | number | undefined | MotionValue;
37
38
  }>;
38
39
  export type ElementType = keyof IntrinsicElementAttributes;
39
40
  export interface Options<T = any> extends LayoutOptions, PressProps, HoverProps, InViewProps, DragProps, PanProps, FocusProps {
@@ -56,7 +57,7 @@ export interface Options<T = any> extends LayoutOptions, PressProps, HoverProps,
56
57
  onUpdate?: (latest: ResolvedValues) => void;
57
58
  }
58
59
  export interface MotionStateContext {
59
- initial?: VariantLabels;
60
+ initial?: VariantLabels | boolean;
60
61
  animate?: VariantLabels;
61
62
  inView?: VariantLabels;
62
63
  hover?: VariantLabels;
@@ -4,3 +4,4 @@ export * from './use-in-view';
4
4
  export * from './use-animation-frame';
5
5
  export * from './time-conversion';
6
6
  export * from './get-context-window';
7
+ export * from './use-dom-ref';
@@ -1 +1 @@
1
- export declare function useDomRef<T extends Element = any>(): import('vue').Ref<import('vue').UnwrapRef<T>>;
1
+ export declare function useDomRef(): import('vue').Ref<any>;
@@ -0,0 +1,22 @@
1
+ import { getMotionElement } from "../components/hooks/use-motion-elm.mjs";
2
+ import { ref } from "vue";
3
+ function useDomRef() {
4
+ const dom = ref(null);
5
+ const domProxy = new Proxy(dom, {
6
+ get(target, key) {
7
+ if (typeof key === "string" || typeof key === "symbol") {
8
+ return Reflect.get(target, key);
9
+ }
10
+ return void 0;
11
+ },
12
+ set(target, key, value) {
13
+ if (key === "value")
14
+ return Reflect.set(target, key, getMotionElement((value == null ? void 0 : value.$el) || value));
15
+ return true;
16
+ }
17
+ });
18
+ return domProxy;
19
+ }
20
+ export {
21
+ useDomRef
22
+ };
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ const components = /* @__PURE__ */ new Set([
4
+ "Motion",
5
+ "AnimatePresence",
6
+ "LayoutGroup",
7
+ "MotionConfig",
8
+ "ReorderGroup",
9
+ "ReorderItem"
10
+ ]);
11
+ function index() {
12
+ return {
13
+ type: "component",
14
+ resolve: (name) => {
15
+ if (components.has(name)) {
16
+ return {
17
+ name,
18
+ from: "motion-v"
19
+ };
20
+ }
21
+ }
22
+ };
23
+ }
24
+
25
+ module.exports = index;
@@ -0,0 +1,5 @@
1
+ import { ComponentResolver } from 'unplugin-vue-components';
2
+
3
+ declare function export_default(): ComponentResolver;
4
+
5
+ export { export_default as default };
@@ -0,0 +1,5 @@
1
+ import { ComponentResolver } from 'unplugin-vue-components';
2
+
3
+ declare function export_default(): ComponentResolver;
4
+
5
+ export { export_default as default };
@@ -0,0 +1,23 @@
1
+ const components = /* @__PURE__ */ new Set([
2
+ "Motion",
3
+ "AnimatePresence",
4
+ "LayoutGroup",
5
+ "MotionConfig",
6
+ "ReorderGroup",
7
+ "ReorderItem"
8
+ ]);
9
+ function index() {
10
+ return {
11
+ type: "component",
12
+ resolve: (name) => {
13
+ if (components.has(name)) {
14
+ return {
15
+ name,
16
+ from: "motion-v"
17
+ };
18
+ }
19
+ }
20
+ };
21
+ }
22
+
23
+ export { index as default };
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "motion-v",
3
- "version": "0.11.0-beta.5",
3
+ "version": "0.11.0",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "MIT",
7
- "homepage": "https://github.com/unovue/motion-vue",
7
+ "homepage": "https://github.com/motiondivision/motion-vue",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "https://github.com/unovue/motion-vue.git"
10
+ "url": "https://github.com/motiondivision/motion-vue.git"
11
11
  },
12
12
  "keywords": [
13
13
  "vue",
@@ -30,6 +30,16 @@
30
30
  "types": "./dist/nuxt/index.d.cts",
31
31
  "default": "./dist/nuxt/index.cjs"
32
32
  }
33
+ },
34
+ "./resolver": {
35
+ "import": {
36
+ "types": "./dist/resolver/index.d.mts",
37
+ "default": "./dist/resolver/index.mjs"
38
+ },
39
+ "require": {
40
+ "types": "./dist/resolver/index.d.cts",
41
+ "default": "./dist/resolver/index.cjs"
42
+ }
33
43
  }
34
44
  },
35
45
  "main": "./dist/cjs/index.js",
File without changes