motion-v 0.13.1 → 1.0.0-alpha.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.
Files changed (61) hide show
  1. package/dist/cjs/index.js +1055 -1009
  2. package/dist/es/components/index.d.ts +2 -0
  3. package/dist/es/components/lazy-motion/context.d.ts +7 -0
  4. package/dist/es/components/lazy-motion/context.mjs +6 -0
  5. package/dist/es/components/lazy-motion/index.d.ts +26 -0
  6. package/dist/es/components/lazy-motion/index.mjs +36 -0
  7. package/dist/es/components/motion/index.d.ts +179 -2
  8. package/dist/es/components/motion/index.mjs +8 -0
  9. package/dist/es/components/motion/m.d.ts +178 -0
  10. package/dist/es/components/motion/m.mjs +7 -0
  11. package/dist/es/components/motion/props.d.ts +227 -0
  12. package/dist/es/components/motion/props.mjs +93 -0
  13. package/dist/es/components/motion/{Motion.d.ts → types.d.ts} +12 -9
  14. package/dist/es/components/motion/use-motion-state.d.ts +790 -0
  15. package/dist/es/components/motion/use-motion-state.mjs +116 -0
  16. package/dist/es/components/motion/utils.d.ts +20 -5
  17. package/dist/es/components/motion/utils.mjs +122 -1
  18. package/dist/es/components/reorder/Group.vue.mjs +5 -2
  19. package/dist/es/components/reorder/Item.vue.mjs +5 -2
  20. package/dist/es/components/reorder/index.d.ts +12 -0
  21. package/dist/es/features/animation/animation.d.ts +32 -0
  22. package/dist/es/features/animation/animation.mjs +186 -5
  23. package/dist/es/features/animation/types.d.ts +17 -0
  24. package/dist/es/features/dom-animation.d.ts +2 -0
  25. package/dist/es/features/dom-animation.mjs +19 -0
  26. package/dist/es/features/dom-max.d.ts +2 -0
  27. package/dist/es/features/dom-max.mjs +23 -0
  28. package/dist/es/features/feature-manager.mjs +20 -20
  29. package/dist/es/features/gestures/drag/VisualElementDragControls.d.ts +1 -1
  30. package/dist/es/features/gestures/hover/index.d.ts +2 -0
  31. package/dist/es/features/gestures/hover/index.mjs +13 -2
  32. package/dist/es/features/gestures/in-view/index.mjs +3 -3
  33. package/dist/es/features/gestures/index.d.ts +0 -1
  34. package/dist/es/features/gestures/press/index.mjs +17 -19
  35. package/dist/es/features/index.d.ts +2 -0
  36. package/dist/es/index.d.ts +1 -0
  37. package/dist/es/index.mjs +17 -9
  38. package/dist/es/state/motion-state.d.ts +8 -6
  39. package/dist/es/state/motion-state.mjs +13 -45
  40. package/dist/es/state/style.mjs +2 -2
  41. package/dist/es/state/transform.d.ts +0 -1
  42. package/dist/es/state/transform.mjs +0 -1
  43. package/dist/es/types/state.d.ts +1 -0
  44. package/dist/nuxt/index.cjs +3 -1
  45. package/dist/nuxt/index.mjs +3 -1
  46. package/dist/resolver/index.cjs +3 -1
  47. package/dist/resolver/index.mjs +3 -1
  48. package/package.json +1 -1
  49. package/dist/es/components/motion/Motion.vue.mjs +0 -241
  50. package/dist/es/components/motion/Motion.vue2.mjs +0 -4
  51. package/dist/es/components/motion/NameSpace.d.ts +0 -15
  52. package/dist/es/components/motion/NameSpace.mjs +0 -48
  53. package/dist/es/components/motion/Primitive.d.ts +0 -57
  54. package/dist/es/components/motion/Primitive.mjs +0 -45
  55. package/dist/es/components/motion/Slot.d.ts +0 -5
  56. package/dist/es/components/motion/Slot.mjs +0 -36
  57. package/dist/es/components/motion/renderSlotFragments.mjs +0 -13
  58. package/dist/es/features/gestures/base.d.ts +0 -8
  59. package/dist/es/state/animate-updates.d.ts +0 -20
  60. package/dist/es/state/animate-updates.mjs +0 -147
  61. package/dist/es/utils/noop.d.ts +0 -1
package/dist/cjs/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
3
  const vue = require("vue");
4
- const core = require("@vueuse/core");
5
4
  const heyListen = require("hey-listen");
6
5
  const motionDom = require("motion-dom");
6
+ const core = require("@vueuse/core");
7
7
  function addUniqueItem(arr, item) {
8
8
  if (arr.indexOf(item) === -1)
9
9
  arr.push(item);
@@ -4207,6 +4207,11 @@ function transform(...args) {
4207
4207
  });
4208
4208
  return useImmediate ? interpolator(inputValue) : interpolator;
4209
4209
  }
4210
+ function getMotionElement(el) {
4211
+ if ((el == null ? void 0 : el.nodeType) === 3 || (el == null ? void 0 : el.nodeType) === 8)
4212
+ return getMotionElement(el.nextSibling);
4213
+ return el;
4214
+ }
4210
4215
  function createContext(providerComponentName, contextName) {
4211
4216
  const symbolDescription = typeof providerComponentName === "string" && !contextName ? `${providerComponentName}Context` : contextName;
4212
4217
  const injectionKey = Symbol(symbolDescription);
@@ -4276,11 +4281,6 @@ function millisecondsToSeconds(milliseconds) {
4276
4281
  function getContextWindow({ current }) {
4277
4282
  return current ? current.ownerDocument.defaultView : null;
4278
4283
  }
4279
- function getMotionElement(el) {
4280
- if ((el == null ? void 0 : el.nodeType) === 3 || (el == null ? void 0 : el.nodeType) === 8)
4281
- return getMotionElement(el.nextSibling);
4282
- return el;
4283
- }
4284
4284
  function useDomRef() {
4285
4285
  const dom = vue.ref(null);
4286
4286
  const domProxy = new Proxy(dom, {
@@ -4300,6 +4300,52 @@ function useDomRef() {
4300
4300
  }
4301
4301
  const [injectMotion, provideMotion] = createContext("Motion");
4302
4302
  const [injectLayoutGroup, provideLayoutGroup] = createContext("LayoutGroup");
4303
+ const [useLazyMotionContext, lazyMotionContextProvider] = createContext("LazyMotionContext");
4304
+ const defaultConfig = {
4305
+ reduceMotion: "never",
4306
+ transition: void 0,
4307
+ nonce: void 0
4308
+ };
4309
+ const [injectMotionConfig, provideMotionConfig] = createContext("MotionConfig");
4310
+ function useMotionConfig() {
4311
+ return injectMotionConfig(vue.computed(() => defaultConfig));
4312
+ }
4313
+ const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
4314
+ ...{
4315
+ name: "MotionConfig",
4316
+ inheritAttrs: false
4317
+ },
4318
+ __name: "MotionConfig",
4319
+ props: {
4320
+ transition: {},
4321
+ reduceMotion: { default: defaultConfig.reduceMotion },
4322
+ nonce: {},
4323
+ inViewOptions: {}
4324
+ },
4325
+ setup(__props) {
4326
+ const props = __props;
4327
+ const parentConfig = useMotionConfig();
4328
+ const config = vue.computed(() => ({
4329
+ transition: props.transition ?? parentConfig.value.transition,
4330
+ reduceMotion: props.reduceMotion ?? parentConfig.value.reduceMotion,
4331
+ nonce: props.nonce ?? parentConfig.value.nonce,
4332
+ inViewOptions: props.inViewOptions ?? parentConfig.value.inViewOptions
4333
+ }));
4334
+ provideMotionConfig(config);
4335
+ return (_ctx, _cache) => {
4336
+ return vue.renderSlot(_ctx.$slots, "default");
4337
+ };
4338
+ }
4339
+ });
4340
+ const doneCallbacks = /* @__PURE__ */ new WeakMap();
4341
+ function removeDoneCallback(element) {
4342
+ const prevDoneCallback = doneCallbacks.get(element);
4343
+ if (prevDoneCallback) {
4344
+ element.removeEventListener("motioncomplete", prevDoneCallback);
4345
+ }
4346
+ doneCallbacks.delete(element);
4347
+ }
4348
+ const [injectAnimatePresence, provideAnimatePresence] = createContext("AnimatePresenceContext");
4303
4349
  function resolveVariant(definition, variants, custom) {
4304
4350
  if (Array.isArray(definition)) {
4305
4351
  return definition.reduce((acc, item) => {
@@ -4421,371 +4467,120 @@ function isAnimateChanged(oldOptions, newOptions) {
4421
4467
  }
4422
4468
  return oldAnimate !== newAnimate;
4423
4469
  }
4424
- const rotation = {
4425
- syntax: "<angle>",
4426
- initialValue: "0deg",
4427
- toDefaultUnit: (v) => `${v}deg`
4428
- };
4429
- const baseTransformProperties = {
4430
- translate: {
4431
- syntax: "<length-percentage>",
4432
- initialValue: "0px",
4433
- toDefaultUnit: (v) => `${v}px`
4434
- },
4435
- rotate: rotation,
4436
- scale: {
4437
- syntax: "<number>",
4438
- initialValue: 1,
4439
- toDefaultUnit: noopReturn
4440
- },
4441
- skew: rotation
4442
- };
4443
- const order = ["translate", "scale", "rotate", "skew"];
4444
- const axes = ["", "X", "Y", "Z"];
4445
- const transformDefinitions = /* @__PURE__ */ new Map();
4446
- const transforms = ["transformPerspective", "x", "y", "z", "translateX", "translateY", "translateZ", "scale", "scaleX", "scaleY", "rotate", "rotateX", "rotateY", "rotateZ", "skew", "skewX", "skewY"];
4447
- order.forEach((name) => {
4448
- axes.forEach((axis) => {
4449
- transforms.push(name + axis);
4450
- transformDefinitions.set(
4451
- name + axis,
4452
- baseTransformProperties[name]
4453
- );
4454
- });
4455
- });
4456
- const transformLookup = new Set(transforms);
4457
- const isTransform = (name) => transformLookup.has(name);
4458
- const transformAlias = {
4459
- x: "translateX",
4460
- y: "translateY",
4461
- z: "translateZ"
4462
- };
4463
- function compareTransformOrder([a], [b]) {
4464
- return transforms.indexOf(a) - transforms.indexOf(b);
4470
+ class Feature {
4471
+ constructor(state2) {
4472
+ this.state = state2;
4473
+ }
4474
+ beforeMount() {
4475
+ }
4476
+ mount() {
4477
+ }
4478
+ unmount() {
4479
+ }
4480
+ update() {
4481
+ }
4482
+ beforeUpdate() {
4483
+ }
4484
+ beforeUnmount() {
4485
+ }
4465
4486
  }
4466
- function transformListToString(template, [name, value]) {
4467
- return `${template} ${name}(${value})`;
4487
+ function handleHoverEvent$1(state2, event, lifecycle) {
4488
+ const props = state2.options;
4489
+ if (props.whileHover) {
4490
+ state2.setActive("whileHover", lifecycle === "Start");
4491
+ }
4492
+ const eventName = `onHover${lifecycle}`;
4493
+ const callback = props[eventName];
4494
+ if (callback) {
4495
+ motionDom.frame.postRender(() => callback(event, extractEventInfo$1(event)));
4496
+ }
4468
4497
  }
4469
- function buildTransformTemplate(transforms2) {
4470
- return transforms2.sort(compareTransformOrder).reduce(transformListToString, "").trim();
4498
+ class HoverGesture extends Feature {
4499
+ isActive() {
4500
+ const { whileHover, onHoverStart, onHoverEnd } = this.state.options;
4501
+ return Boolean(whileHover || onHoverStart || onHoverEnd);
4502
+ }
4503
+ constructor(state2) {
4504
+ super(state2);
4505
+ }
4506
+ mount() {
4507
+ this.register();
4508
+ }
4509
+ update() {
4510
+ const { whileHover, onHoverStart, onHoverEnd } = this.state.visualElement.prevProps;
4511
+ if (!(whileHover || onHoverStart || onHoverEnd)) {
4512
+ this.register();
4513
+ }
4514
+ }
4515
+ register() {
4516
+ const element = this.state.element;
4517
+ if (!element || !this.isActive())
4518
+ return;
4519
+ this.unmount();
4520
+ this.unmount = motionDom.hover(
4521
+ element,
4522
+ (el, startEvent) => {
4523
+ handleHoverEvent$1(this.state, startEvent, "Start");
4524
+ return (endEvent) => {
4525
+ handleHoverEvent$1(this.state, endEvent, "End");
4526
+ };
4527
+ }
4528
+ );
4529
+ }
4471
4530
  }
4472
- const transformResetValue = {
4473
- translate: [0, 0],
4474
- rotate: 0,
4475
- scale: 1,
4476
- skew: 0,
4477
- x: 0,
4478
- y: 0,
4479
- z: 0
4480
- };
4481
- function createUnitType(unit) {
4531
+ function extractEventInfo$1(event) {
4482
4532
  return {
4483
- test: (v) => typeof v === "string" && v.endsWith(unit) && v.split(" ").length === 1,
4484
- parse: parseFloat,
4485
- transform: (v) => `${v}${unit}`
4533
+ point: {
4534
+ x: event.pageX,
4535
+ y: event.pageY
4536
+ }
4486
4537
  };
4487
4538
  }
4488
- const percent = /* @__PURE__ */ createUnitType("%");
4489
- const px = /* @__PURE__ */ createUnitType("px");
4490
- const style = {
4491
- get: (element, name) => {
4492
- let value = isCssVar(name) ? element.style.getPropertyValue(name) : getComputedStyle(element)[name];
4493
- if (!value && value !== "0") {
4494
- const definition = transformDefinitions.get(name);
4495
- if (definition)
4496
- value = definition.initialValue;
4497
- }
4498
- return value;
4499
- },
4500
- set: (element, name, value) => {
4501
- if (isCssVar(name)) {
4502
- element.style.setProperty(name, value);
4503
- } else {
4504
- element.style[name] = value;
4505
- }
4539
+ function handlePressEvent(state2, event, lifecycle) {
4540
+ const props = state2.options;
4541
+ if (props.whilePress) {
4542
+ state2.setActive("whilePress", lifecycle === "Start");
4506
4543
  }
4507
- };
4508
- function createStyles(keyframes2) {
4509
- var _a;
4510
- const initialKeyframes = {};
4511
- const transforms2 = [];
4512
- for (let key in keyframes2) {
4513
- let value = keyframes2[key];
4514
- value = isMotionValue(value) ? value.get() : value;
4515
- if (isTransform(key)) {
4516
- if (key in transformAlias) {
4517
- key = transformAlias[key];
4518
- }
4519
- }
4520
- let initialKeyframe = Array.isArray(value) ? value[0] : value;
4521
- const definition = transformDefinitions.get(key);
4522
- if (definition) {
4523
- initialKeyframe = isNumber(value) ? (_a = definition.toDefaultUnit) == null ? void 0 : _a.call(definition, value) : value;
4524
- transforms2.push([key, initialKeyframe]);
4525
- } else {
4526
- initialKeyframes[key] = initialKeyframe;
4544
+ const eventName = `onPress${lifecycle === "End" ? "" : lifecycle}`;
4545
+ const callback = props[eventName];
4546
+ if (callback) {
4547
+ motionDom.frame.postRender(() => callback(event, extractEventInfo$1(event)));
4548
+ }
4549
+ }
4550
+ class PressGesture extends Feature {
4551
+ isActive() {
4552
+ const { whilePress, onPress, onPressCancel, onPressStart } = this.state.options;
4553
+ return Boolean(whilePress || onPress || onPressCancel || onPressStart);
4554
+ }
4555
+ constructor(state2) {
4556
+ super(state2);
4557
+ }
4558
+ mount() {
4559
+ this.register();
4560
+ }
4561
+ update() {
4562
+ const { whilePress, onPress, onPressCancel, onPressStart } = this.state.options;
4563
+ if (!(whilePress || onPress || onPressCancel || onPressStart)) {
4564
+ this.register();
4527
4565
  }
4528
4566
  }
4529
- if (transforms2.length) {
4530
- initialKeyframes.transform = buildTransformTemplate(transforms2);
4531
- }
4532
- return initialKeyframes;
4533
- }
4534
- const SVG_STYLE_TO_ATTRIBUTES = {
4535
- fill: true,
4536
- stroke: true,
4537
- strokeWidth: true,
4538
- opacity: true,
4539
- fillOpacity: true,
4540
- strokeOpacity: true,
4541
- strokeLinecap: true,
4542
- strokeLinejoin: true,
4543
- strokeDasharray: true,
4544
- strokeDashoffset: true,
4545
- cx: true,
4546
- cy: true,
4547
- r: true,
4548
- d: true,
4549
- x1: true,
4550
- y1: true,
4551
- x2: true,
4552
- y2: true,
4553
- points: true,
4554
- pathLength: true,
4555
- viewBox: true,
4556
- width: true,
4557
- height: true,
4558
- preserveAspectRatio: true,
4559
- clipPath: true,
4560
- filter: true,
4561
- mask: true,
4562
- stopColor: true,
4563
- stopOpacity: true,
4564
- gradientTransform: true,
4565
- gradientUnits: true,
4566
- spreadMethod: true,
4567
- markerEnd: true,
4568
- markerMid: true,
4569
- markerStart: true,
4570
- textAnchor: true,
4571
- dominantBaseline: true,
4572
- fontFamily: true,
4573
- fontSize: true,
4574
- fontWeight: true,
4575
- letterSpacing: true,
4576
- vectorEffect: true
4577
- };
4578
- function buildSVGPath(attrs, length, spacing = 1, offset = 0) {
4579
- attrs.pathLength = 1;
4580
- attrs["stroke-dashoffset"] = px.transform(-offset);
4581
- const pathLength = px.transform(length);
4582
- const pathSpacing = px.transform(spacing);
4583
- attrs["stroke-dasharray"] = `${pathLength} ${pathSpacing}`;
4584
- }
4585
- function convertSvgStyleToAttributes(keyframes2) {
4586
- const attributes = {};
4587
- const styleProps = {};
4588
- for (const key in keyframes2) {
4589
- if (key in SVG_STYLE_TO_ATTRIBUTES) {
4590
- const value = keyframes2[key];
4591
- attributes[key] = isMotionValue(value) ? value.get() : value;
4592
- } else {
4593
- styleProps[key] = keyframes2[key];
4594
- }
4595
- }
4596
- if (attributes.pathLength) {
4597
- buildSVGPath(attributes, attributes.pathLength, attributes.pathSpacing, attributes.pathOffset);
4598
- }
4599
- return {
4600
- attributes,
4601
- style: styleProps
4602
- };
4603
- }
4604
- function renderSlotFragments(children) {
4605
- if (!children)
4606
- return [];
4607
- return children.flatMap((child) => {
4608
- if (child.type === vue.Fragment)
4609
- return renderSlotFragments(child.children);
4610
- return [child];
4611
- });
4612
- }
4613
- const Slot = vue.defineComponent({
4614
- name: "PrimitiveSlot",
4615
- inheritAttrs: false,
4616
- setup(_, { attrs, slots }) {
4617
- return () => {
4618
- var _a, _b;
4619
- if (!slots.default)
4620
- return null;
4621
- const childrens = renderSlotFragments(slots.default());
4622
- const firstNonCommentChildrenIndex = childrens.findIndex((child) => child.type !== vue.Comment);
4623
- if (firstNonCommentChildrenIndex === -1)
4624
- return childrens;
4625
- const firstNonCommentChildren = childrens[firstNonCommentChildrenIndex];
4626
- (_a = firstNonCommentChildren.props) == null ? true : delete _a.ref;
4627
- const mergedProps = firstNonCommentChildren.props ? vue.mergeProps(attrs, firstNonCommentChildren.props) : attrs;
4628
- if (attrs.class && ((_b = firstNonCommentChildren.props) == null ? void 0 : _b.class))
4629
- delete firstNonCommentChildren.props.class;
4630
- const cloned = vue.cloneVNode(firstNonCommentChildren, mergedProps);
4631
- for (const prop in mergedProps) {
4632
- if (prop.startsWith("on")) {
4633
- cloned.props || (cloned.props = {});
4634
- cloned.props[prop] = mergedProps[prop];
4635
- }
4636
- }
4637
- if (childrens.length === 1)
4638
- return cloned;
4639
- childrens[firstNonCommentChildrenIndex] = cloned;
4640
- return childrens;
4641
- };
4642
- }
4643
- });
4644
- const Primitive = vue.defineComponent({
4645
- name: "Primitive",
4646
- inheritAttrs: false,
4647
- props: {
4648
- asChild: {
4649
- type: Boolean,
4650
- default: false
4651
- },
4652
- as: {
4653
- type: [String, Object],
4654
- default: "div"
4655
- },
4656
- getProps: {
4657
- type: Function,
4658
- default: () => ({})
4659
- },
4660
- getAttrs: {
4661
- type: Function,
4662
- default: () => ({})
4663
- }
4664
- },
4665
- setup(props, { attrs, slots }) {
4666
- const asTag = props.asChild ? "template" : props.as;
4667
- const SELF_CLOSING_TAGS = ["area", "img", "input"];
4668
- return () => {
4669
- const motionProps = props.getProps();
4670
- const motionAttrs = props.getAttrs();
4671
- let allAttrs = { ...motionAttrs, ...attrs };
4672
- if (typeof asTag === "string" && SELF_CLOSING_TAGS.includes(asTag))
4673
- return vue.h(asTag, allAttrs);
4674
- if (asTag !== "template") {
4675
- if (motionProps.forwardMotionProps) {
4676
- allAttrs = { ...motionProps, ...allAttrs };
4677
- }
4678
- return vue.h(props.as, allAttrs, { default: slots.default });
4679
- }
4680
- return vue.h(Slot, allAttrs, { default: slots.default });
4681
- };
4682
- }
4683
- });
4684
- class Feature {
4685
- constructor(state2) {
4686
- this.state = state2;
4687
- }
4688
- beforeMount() {
4689
- }
4690
- mount() {
4691
- }
4692
- unmount() {
4693
- }
4694
- update() {
4695
- }
4696
- beforeUpdate() {
4697
- }
4698
- beforeUnmount() {
4699
- }
4700
- }
4701
- function handleHoverEvent$1(state2, event, lifecycle) {
4702
- const props = state2.options;
4703
- if (props.whileHover) {
4704
- state2.setActive("whileHover", lifecycle === "Start");
4705
- }
4706
- const eventName = `onHover${lifecycle}`;
4707
- const callback = props[eventName];
4708
- if (callback) {
4709
- motionDom.frame.postRender(() => callback(event, extractEventInfo$1(event)));
4710
- }
4711
- }
4712
- class HoverGesture extends Feature {
4713
- isActive() {
4714
- return Boolean(this.state.getOptions().whileHover);
4715
- }
4716
- constructor(state2) {
4717
- super(state2);
4718
- }
4719
- mount() {
4720
- const element = this.state.element;
4721
- if (!element)
4722
- return;
4723
- this.unmount = motionDom.hover(
4724
- element,
4725
- (el, startEvent) => {
4726
- handleHoverEvent$1(this.state, startEvent, "Start");
4727
- return (endEvent) => {
4728
- handleHoverEvent$1(this.state, endEvent, "End");
4729
- };
4730
- }
4731
- );
4732
- }
4733
- }
4734
- function extractEventInfo$1(event) {
4735
- return {
4736
- point: {
4737
- x: event.pageX,
4738
- y: event.pageY
4739
- }
4740
- };
4741
- }
4742
- function handlePressEvent(state2, event, lifecycle) {
4743
- const props = state2.options;
4744
- if (props.whilePress) {
4745
- state2.setActive("whilePress", lifecycle === "Start");
4746
- }
4747
- const eventName = `onPress${lifecycle === "End" ? "" : lifecycle}`;
4748
- const callback = props[eventName];
4749
- if (callback) {
4750
- motionDom.frame.postRender(() => callback(event, extractEventInfo$1(event)));
4751
- }
4752
- }
4753
- class PressGesture extends Feature {
4754
- isActive() {
4755
- const { whilePress, onPress, onPressCancel, onPressStart } = this.state.options;
4756
- return Boolean(whilePress || onPress || onPressCancel || onPressStart);
4757
- }
4758
- constructor(state2) {
4759
- super(state2);
4760
- }
4761
- mount() {
4762
- this.register();
4763
- }
4764
- update() {
4765
- const preProps = this.state.visualElement.prevProps;
4766
- if (preProps.whilePress !== this.state.options.whilePress) {
4767
- this.register();
4768
- }
4769
- }
4770
- register() {
4771
- this.unmount();
4772
- if (this.isActive()) {
4773
- const element = this.state.element;
4774
- if (!element)
4775
- return;
4776
- this.unmount = motionDom.press(
4777
- element,
4778
- (el, startEvent) => {
4779
- handlePressEvent(this.state, startEvent, "Start");
4780
- return (endEvent, { success }) => handlePressEvent(
4781
- this.state,
4782
- endEvent,
4783
- success ? "End" : "Cancel"
4784
- );
4785
- },
4786
- { useGlobalTarget: this.state.options.globalPressTarget }
4787
- );
4788
- }
4567
+ register() {
4568
+ const element = this.state.element;
4569
+ if (!element || !this.isActive())
4570
+ return;
4571
+ this.unmount();
4572
+ this.unmount = motionDom.press(
4573
+ element,
4574
+ (el, startEvent) => {
4575
+ handlePressEvent(this.state, startEvent, "Start");
4576
+ return (endEvent, { success }) => handlePressEvent(
4577
+ this.state,
4578
+ endEvent,
4579
+ success ? "End" : "Cancel"
4580
+ );
4581
+ },
4582
+ { useGlobalTarget: this.state.options.globalPressTarget }
4583
+ );
4789
4584
  }
4790
4585
  }
4791
4586
  function handleHoverEvent(state2, entry, lifecycle) {
@@ -4801,17 +4596,17 @@ function handleHoverEvent(state2, entry, lifecycle) {
4801
4596
  }
4802
4597
  class InViewGesture extends Feature {
4803
4598
  isActive() {
4804
- return Boolean(this.state.getOptions().whileInView);
4599
+ return Boolean(this.state.options.whileInView);
4805
4600
  }
4806
4601
  constructor(state2) {
4807
4602
  super(state2);
4808
4603
  }
4809
4604
  startObserver() {
4810
4605
  const element = this.state.element;
4811
- if (!element)
4606
+ if (!element || !this.isActive())
4812
4607
  return;
4813
4608
  this.unmount();
4814
- const { once, ...viewOptions } = this.state.getOptions().inViewOptions || {};
4609
+ const { once, ...viewOptions } = this.state.options.inViewOptions || {};
4815
4610
  this.unmount = inView(
4816
4611
  element,
4817
4612
  (_, entry) => {
@@ -5150,6 +4945,15 @@ function createBox() {
5150
4945
  function eachAxis$1(callback) {
5151
4946
  return [callback("x"), callback("y")];
5152
4947
  }
4948
+ function createUnitType(unit) {
4949
+ return {
4950
+ test: (v) => typeof v === "string" && v.endsWith(unit) && v.split(" ").length === 1,
4951
+ parse: parseFloat,
4952
+ transform: (v) => `${v}${unit}`
4953
+ };
4954
+ }
4955
+ const percent = /* @__PURE__ */ createUnitType("%");
4956
+ const px = /* @__PURE__ */ createUnitType("px");
5153
4957
  function isWillChangeMotionValue(value) {
5154
4958
  return Boolean(isMotionValue(value) && value.add);
5155
4959
  }
@@ -5203,15 +5007,6 @@ function measurePageBox(element, rootProjectionNode2, transformPagePoint) {
5203
5007
  }
5204
5008
  return viewportBox;
5205
5009
  }
5206
- const doneCallbacks = /* @__PURE__ */ new WeakMap();
5207
- function removeDoneCallback(element) {
5208
- const prevDoneCallback = doneCallbacks.get(element);
5209
- if (prevDoneCallback) {
5210
- element.removeEventListener("motioncomplete", prevDoneCallback);
5211
- }
5212
- doneCallbacks.delete(element);
5213
- }
5214
- const [injectAnimatePresence, provideAnimatePresence] = createContext("AnimatePresenceContext");
5215
5010
  function isPresent(visualElement) {
5216
5011
  return !doneCallbacks.has(visualElement.current);
5217
5012
  }
@@ -5841,41 +5636,497 @@ class PanGesture extends Feature {
5841
5636
  this.session && this.session.end();
5842
5637
  }
5843
5638
  }
5844
- const compareByDepth = (a, b) => a.depth - b.depth;
5845
- class FlatTree {
5846
- constructor() {
5847
- this.children = [];
5848
- this.isDirty = false;
5639
+ class FeatureManager {
5640
+ constructor(state2) {
5641
+ this.features = [];
5642
+ const { features = [], lazyMotionContext } = state2.options;
5643
+ const allFeatures = features.concat(lazyMotionContext.features.value);
5644
+ this.features = allFeatures.map((Feature2) => new Feature2(state2));
5645
+ const featureInstances = this.features;
5646
+ vue.watch(lazyMotionContext.features, (features2) => {
5647
+ features2.forEach((feature) => {
5648
+ if (!allFeatures.includes(feature)) {
5649
+ allFeatures.push(feature);
5650
+ const featureInstance = new feature(state2);
5651
+ featureInstances.push(featureInstance);
5652
+ if (state2.isMounted()) {
5653
+ featureInstance.beforeMount();
5654
+ featureInstance.mount();
5655
+ }
5656
+ }
5657
+ });
5658
+ }, {
5659
+ flush: "pre"
5660
+ });
5849
5661
  }
5850
- add(child) {
5851
- addUniqueItem(this.children, child);
5852
- this.isDirty = true;
5662
+ mount() {
5663
+ this.features.forEach((feature) => feature.mount());
5853
5664
  }
5854
- remove(child) {
5855
- removeItem(this.children, child);
5856
- this.isDirty = true;
5665
+ beforeMount() {
5666
+ this.features.forEach((feature) => {
5667
+ var _a;
5668
+ return (_a = feature.beforeMount) == null ? void 0 : _a.call(feature);
5669
+ });
5857
5670
  }
5858
- forEach(callback) {
5859
- this.isDirty && this.children.sort(compareByDepth);
5860
- this.isDirty = false;
5861
- this.children.forEach(callback);
5671
+ unmount() {
5672
+ this.features.forEach((feature) => feature.unmount());
5673
+ }
5674
+ update() {
5675
+ this.features.forEach((feature) => {
5676
+ var _a;
5677
+ return (_a = feature.update) == null ? void 0 : _a.call(feature);
5678
+ });
5679
+ }
5680
+ beforeUpdate() {
5681
+ this.features.forEach((feature) => feature.beforeUpdate());
5682
+ }
5683
+ beforeUnmount() {
5684
+ this.features.forEach((feature) => feature.beforeUnmount());
5862
5685
  }
5863
5686
  }
5864
- function resolveMotionValue(value) {
5865
- const unwrappedValue = isMotionValue$1(value) ? value.get() : value;
5866
- return isCustomValue(unwrappedValue) ? unwrappedValue.toValue() : unwrappedValue;
5687
+ function isAnimationControls(v) {
5688
+ return v !== null && typeof v === "object" && typeof v.start === "function";
5867
5689
  }
5868
- const borders = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"];
5869
- const numBorders = borders.length;
5870
- const asNumber = (value) => typeof value === "string" ? parseFloat(value) : value;
5871
- const isPx = (value) => typeof value === "number" || px$1.test(value);
5872
- function mixValues(target, follow, lead, progress2, shouldCrossfadeOpacity, isOnlyMember) {
5873
- if (shouldCrossfadeOpacity) {
5874
- target.opacity = mixNumber$2(
5875
- 0,
5876
- // TODO Reinstate this if only child
5877
- lead.opacity !== void 0 ? lead.opacity : 1,
5878
- easeCrossfadeIn(progress2)
5690
+ function motionEvent(name, target, isExit) {
5691
+ return new CustomEvent(name, { detail: { target, isExit } });
5692
+ }
5693
+ const rotation = {
5694
+ syntax: "<angle>",
5695
+ initialValue: "0deg",
5696
+ toDefaultUnit: (v) => `${v}deg`
5697
+ };
5698
+ const baseTransformProperties = {
5699
+ translate: {
5700
+ syntax: "<length-percentage>",
5701
+ initialValue: "0px",
5702
+ toDefaultUnit: (v) => `${v}px`
5703
+ },
5704
+ rotate: rotation,
5705
+ scale: {
5706
+ syntax: "<number>",
5707
+ initialValue: 1,
5708
+ toDefaultUnit: noopReturn
5709
+ },
5710
+ skew: rotation
5711
+ };
5712
+ const order = ["translate", "scale", "rotate", "skew"];
5713
+ const axes = ["", "X", "Y", "Z"];
5714
+ const transformDefinitions = /* @__PURE__ */ new Map();
5715
+ const transforms = ["transformPerspective", "x", "y", "z", "translateX", "translateY", "translateZ", "scale", "scaleX", "scaleY", "rotate", "rotateX", "rotateY", "rotateZ", "skew", "skewX", "skewY"];
5716
+ order.forEach((name) => {
5717
+ axes.forEach((axis) => {
5718
+ transforms.push(name + axis);
5719
+ transformDefinitions.set(
5720
+ name + axis,
5721
+ baseTransformProperties[name]
5722
+ );
5723
+ });
5724
+ });
5725
+ const transformLookup = new Set(transforms);
5726
+ const isTransform = (name) => transformLookup.has(name);
5727
+ const transformAlias = {
5728
+ x: "translateX",
5729
+ y: "translateY",
5730
+ z: "translateZ"
5731
+ };
5732
+ function compareTransformOrder([a], [b]) {
5733
+ return transforms.indexOf(a) - transforms.indexOf(b);
5734
+ }
5735
+ function transformListToString(template, [name, value]) {
5736
+ return `${template} ${name}(${value})`;
5737
+ }
5738
+ function buildTransformTemplate(transforms2) {
5739
+ return transforms2.sort(compareTransformOrder).reduce(transformListToString, "").trim();
5740
+ }
5741
+ const transformResetValue = {
5742
+ translate: [0, 0],
5743
+ rotate: 0,
5744
+ scale: 1,
5745
+ skew: 0,
5746
+ x: 0,
5747
+ y: 0,
5748
+ z: 0
5749
+ };
5750
+ const style = {
5751
+ get: (element, name) => {
5752
+ let value = isCssVar(name) ? element.style.getPropertyValue(name) : getComputedStyle(element)[name];
5753
+ if (!value && value !== "0") {
5754
+ const definition = transformDefinitions.get(name);
5755
+ if (definition)
5756
+ value = definition.initialValue;
5757
+ }
5758
+ return value;
5759
+ },
5760
+ set: (element, name, value) => {
5761
+ if (isCssVar(name)) {
5762
+ element.style.setProperty(name, value);
5763
+ } else {
5764
+ element.style[name] = value;
5765
+ }
5766
+ }
5767
+ };
5768
+ function createStyles(keyframes2) {
5769
+ var _a;
5770
+ const initialKeyframes = {};
5771
+ const transforms2 = [];
5772
+ for (let key in keyframes2) {
5773
+ let value = keyframes2[key];
5774
+ value = isMotionValue(value) ? value.get() : value;
5775
+ if (isTransform(key)) {
5776
+ if (key in transformAlias) {
5777
+ key = transformAlias[key];
5778
+ }
5779
+ }
5780
+ let initialKeyframe = Array.isArray(value) ? value[0] : value;
5781
+ const definition = transformDefinitions.get(key);
5782
+ if (definition) {
5783
+ initialKeyframe = isNumber(value) ? (_a = definition.toDefaultUnit) == null ? void 0 : _a.call(definition, value) : value;
5784
+ transforms2.push([key, initialKeyframe]);
5785
+ } else {
5786
+ initialKeyframes[key] = initialKeyframe;
5787
+ }
5788
+ }
5789
+ if (transforms2.length) {
5790
+ initialKeyframes.transform = buildTransformTemplate(transforms2);
5791
+ }
5792
+ return initialKeyframes;
5793
+ }
5794
+ const SVG_STYLE_TO_ATTRIBUTES = {
5795
+ fill: true,
5796
+ stroke: true,
5797
+ strokeWidth: true,
5798
+ opacity: true,
5799
+ fillOpacity: true,
5800
+ strokeOpacity: true,
5801
+ strokeLinecap: true,
5802
+ strokeLinejoin: true,
5803
+ strokeDasharray: true,
5804
+ strokeDashoffset: true,
5805
+ cx: true,
5806
+ cy: true,
5807
+ r: true,
5808
+ d: true,
5809
+ x1: true,
5810
+ y1: true,
5811
+ x2: true,
5812
+ y2: true,
5813
+ points: true,
5814
+ pathLength: true,
5815
+ viewBox: true,
5816
+ width: true,
5817
+ height: true,
5818
+ preserveAspectRatio: true,
5819
+ clipPath: true,
5820
+ filter: true,
5821
+ mask: true,
5822
+ stopColor: true,
5823
+ stopOpacity: true,
5824
+ gradientTransform: true,
5825
+ gradientUnits: true,
5826
+ spreadMethod: true,
5827
+ markerEnd: true,
5828
+ markerMid: true,
5829
+ markerStart: true,
5830
+ textAnchor: true,
5831
+ dominantBaseline: true,
5832
+ fontFamily: true,
5833
+ fontSize: true,
5834
+ fontWeight: true,
5835
+ letterSpacing: true,
5836
+ vectorEffect: true
5837
+ };
5838
+ function buildSVGPath(attrs, length, spacing = 1, offset = 0) {
5839
+ attrs.pathLength = 1;
5840
+ attrs["stroke-dashoffset"] = px.transform(-offset);
5841
+ const pathLength = px.transform(length);
5842
+ const pathSpacing = px.transform(spacing);
5843
+ attrs["stroke-dasharray"] = `${pathLength} ${pathSpacing}`;
5844
+ }
5845
+ function convertSvgStyleToAttributes(keyframes2) {
5846
+ const attributes = {};
5847
+ const styleProps = {};
5848
+ for (const key in keyframes2) {
5849
+ if (key in SVG_STYLE_TO_ATTRIBUTES) {
5850
+ const value = keyframes2[key];
5851
+ attributes[key] = isMotionValue(value) ? value.get() : value;
5852
+ } else {
5853
+ styleProps[key] = keyframes2[key];
5854
+ }
5855
+ }
5856
+ if (attributes.pathLength) {
5857
+ buildSVGPath(attributes, attributes.pathLength, attributes.pathSpacing, attributes.pathOffset);
5858
+ }
5859
+ return {
5860
+ attributes,
5861
+ style: styleProps
5862
+ };
5863
+ }
5864
+ function createVisualElement(Component, options) {
5865
+ return isSVGElement(Component) ? new SVGVisualElement(options) : new HTMLVisualElement(options);
5866
+ }
5867
+ const STATE_TYPES = ["initial", "animate", "whileInView", "whileHover", "whilePress", "whileDrag", "whileFocus", "exit"];
5868
+ class AnimationFeature extends Feature {
5869
+ constructor(state2) {
5870
+ var _a;
5871
+ super(state2);
5872
+ this.animateUpdates = ({
5873
+ controlActiveState,
5874
+ directAnimate,
5875
+ directTransition,
5876
+ controlDelay = 0,
5877
+ isFallback,
5878
+ isExit
5879
+ } = {}) => {
5880
+ const prevTarget = this.state.target;
5881
+ this.state.target = { ...this.state.baseTarget };
5882
+ let animationOptions = {};
5883
+ const transition = { ...this.state.options.transition };
5884
+ animationOptions = this.resolveStateAnimation({
5885
+ controlActiveState,
5886
+ directAnimate,
5887
+ directTransition
5888
+ });
5889
+ const factories = this.createAnimationFactories(prevTarget, animationOptions, controlDelay);
5890
+ const { getChildAnimations, childAnimations } = this.setupChildAnimations(animationOptions, controlActiveState, isFallback);
5891
+ return this.executeAnimations({
5892
+ factories,
5893
+ getChildAnimations,
5894
+ childAnimations,
5895
+ transition,
5896
+ controlActiveState,
5897
+ isExit
5898
+ });
5899
+ };
5900
+ this.state.visualElement = createVisualElement(this.state.options.as, {
5901
+ presenceContext: null,
5902
+ parent: (_a = this.state.parent) == null ? void 0 : _a.visualElement,
5903
+ props: {
5904
+ ...this.state.options,
5905
+ whileTap: this.state.options.whilePress
5906
+ },
5907
+ visualState: {
5908
+ renderState: {
5909
+ transform: {},
5910
+ transformOrigin: {},
5911
+ style: {},
5912
+ vars: {},
5913
+ attrs: {}
5914
+ },
5915
+ latestValues: {
5916
+ ...this.state.baseTarget
5917
+ }
5918
+ },
5919
+ reducedMotionConfig: this.state.options.motionConfig.reduceMotion
5920
+ });
5921
+ this.state.animateUpdates = this.animateUpdates;
5922
+ if (this.state.isMounted())
5923
+ this.state.startAnimation();
5924
+ }
5925
+ updateAnimationControlsSubscription() {
5926
+ const { animate: animate2 } = this.state.options;
5927
+ if (isAnimationControls(animate2)) {
5928
+ this.unmountControls = animate2.subscribe(this.state);
5929
+ }
5930
+ }
5931
+ executeAnimations({
5932
+ factories,
5933
+ getChildAnimations,
5934
+ transition,
5935
+ controlActiveState,
5936
+ isExit = false
5937
+ }) {
5938
+ const getAnimation = () => Promise.all(factories.map((factory) => factory()).filter(Boolean));
5939
+ const animationTarget2 = { ...this.state.target };
5940
+ const element = this.state.element;
5941
+ const finishAnimation2 = (animationPromise) => {
5942
+ var _a, _b;
5943
+ element.dispatchEvent(motionEvent("motionstart", animationTarget2));
5944
+ (_b = (_a = this.state.options).onAnimationStart) == null ? void 0 : _b.call(_a, animationTarget2);
5945
+ animationPromise.then(() => {
5946
+ var _a2, _b2;
5947
+ element.dispatchEvent(motionEvent("motioncomplete", animationTarget2, isExit));
5948
+ (_b2 = (_a2 = this.state.options).onAnimationComplete) == null ? void 0 : _b2.call(_a2, animationTarget2);
5949
+ }).catch(noop);
5950
+ };
5951
+ const getAnimationPromise = () => {
5952
+ const animationPromise = (transition == null ? void 0 : transition.when) ? (transition.when === "beforeChildren" ? getAnimation() : getChildAnimations()).then(() => transition.when === "beforeChildren" ? getChildAnimations() : getAnimation()) : Promise.all([getAnimation(), getChildAnimations()]);
5953
+ finishAnimation2(animationPromise);
5954
+ return animationPromise;
5955
+ };
5956
+ return controlActiveState ? getAnimationPromise : getAnimationPromise();
5957
+ }
5958
+ /**
5959
+ * Setup child animations
5960
+ */
5961
+ setupChildAnimations(transition, controlActiveState, isFallback) {
5962
+ var _a;
5963
+ if (!((_a = this.state.visualElement.variantChildren) == null ? void 0 : _a.size) || !controlActiveState)
5964
+ return { getChildAnimations: () => Promise.resolve(), childAnimations: [] };
5965
+ const { staggerChildren = 0, staggerDirection = 1, delayChildren = 0 } = transition || {};
5966
+ const maxStaggerDuration = (this.state.visualElement.variantChildren.size - 1) * staggerChildren;
5967
+ const generateStaggerDuration = staggerDirection === 1 ? (i = 0) => i * staggerChildren : (i = 0) => maxStaggerDuration - i * staggerChildren;
5968
+ const childAnimations = Array.from(this.state.visualElement.variantChildren).map((child, index) => {
5969
+ const childDelay = delayChildren + generateStaggerDuration(index);
5970
+ return child.state.animateUpdates({
5971
+ controlActiveState,
5972
+ controlDelay: isFallback ? 0 : childDelay
5973
+ });
5974
+ }).filter(Boolean);
5975
+ return {
5976
+ getChildAnimations: () => Promise.all(childAnimations.map((animation) => {
5977
+ return animation == null ? void 0 : animation();
5978
+ })),
5979
+ childAnimations
5980
+ };
5981
+ }
5982
+ createAnimationFactories(prevTarget, animationOptions, controlDelay) {
5983
+ const factories = [];
5984
+ Object.keys(this.state.target).forEach((key) => {
5985
+ var _a;
5986
+ if (!hasChanged(prevTarget[key], this.state.target[key]))
5987
+ return;
5988
+ (_a = this.state.baseTarget)[key] ?? (_a[key] = style.get(this.state.element, key));
5989
+ const keyValue = this.state.target[key] === "none" && core.isDef(transformResetValue[key]) ? transformResetValue[key] : this.state.target[key];
5990
+ factories.push(() => {
5991
+ var _a2;
5992
+ return animate(
5993
+ this.state.element,
5994
+ { [key]: keyValue },
5995
+ {
5996
+ ...(animationOptions == null ? void 0 : animationOptions[key]) || animationOptions,
5997
+ delay: (((_a2 = animationOptions == null ? void 0 : animationOptions[key]) == null ? void 0 : _a2.delay) || (animationOptions == null ? void 0 : animationOptions.delay) || 0) + controlDelay
5998
+ }
5999
+ );
6000
+ });
6001
+ });
6002
+ return factories;
6003
+ }
6004
+ resolveStateAnimation({
6005
+ controlActiveState,
6006
+ directAnimate,
6007
+ directTransition
6008
+ }) {
6009
+ let variantTransition = this.state.options.transition;
6010
+ let variant = {};
6011
+ const { variants, custom, transition, animatePresenceContext } = this.state.options;
6012
+ const customValue = core.isDef(custom) ? custom : animatePresenceContext == null ? void 0 : animatePresenceContext.custom;
6013
+ this.state.activeStates = { ...this.state.activeStates, ...controlActiveState };
6014
+ STATE_TYPES.forEach((name) => {
6015
+ if (!this.state.activeStates[name] || isAnimationControls(this.state.options[name]))
6016
+ return;
6017
+ const definition = this.state.options[name];
6018
+ let resolvedVariant = core.isDef(definition) ? resolveVariant(definition, variants, customValue) : void 0;
6019
+ if (this.state.visualElement.isVariantNode) {
6020
+ const controlVariant = resolveVariant(this.state.context[name], variants, customValue);
6021
+ resolvedVariant = controlVariant ? Object.assign(controlVariant || {}, resolvedVariant) : variant;
6022
+ }
6023
+ if (!resolvedVariant)
6024
+ return;
6025
+ if (name !== "initial")
6026
+ variantTransition = resolvedVariant.transition || this.state.options.transition || {};
6027
+ variant = Object.assign(variant, resolvedVariant);
6028
+ });
6029
+ if (directAnimate) {
6030
+ variant = resolveVariant(directAnimate, variants, customValue);
6031
+ variantTransition = variant.transition || directTransition || transition;
6032
+ }
6033
+ Object.entries(variant).forEach(([key, value]) => {
6034
+ if (key === "transition")
6035
+ return;
6036
+ this.state.target[key] = value;
6037
+ });
6038
+ return variantTransition;
6039
+ }
6040
+ /**
6041
+ * Subscribe any provided AnimationControls to the component's VisualElement
6042
+ */
6043
+ mount() {
6044
+ const { element } = this.state;
6045
+ mountedStates.set(element, this.state);
6046
+ if (!visualElementStore.get(element)) {
6047
+ this.state.visualElement.mount(element);
6048
+ visualElementStore.set(element, this.state.visualElement);
6049
+ }
6050
+ this.state.visualElement.state = this.state;
6051
+ this.updateAnimationControlsSubscription();
6052
+ }
6053
+ update() {
6054
+ const { animate: animate2 } = this.state.options;
6055
+ const { animate: prevAnimate } = this.state.visualElement.prevProps || {};
6056
+ if (animate2 !== prevAnimate) {
6057
+ this.updateAnimationControlsSubscription();
6058
+ }
6059
+ }
6060
+ unmount() {
6061
+ var _a;
6062
+ (_a = this.unmountControls) == null ? void 0 : _a.call(this);
6063
+ }
6064
+ }
6065
+ class FocusGesture extends Feature {
6066
+ constructor() {
6067
+ super(...arguments);
6068
+ this.isActive = false;
6069
+ }
6070
+ onFocus() {
6071
+ let isFocusVisible = false;
6072
+ try {
6073
+ isFocusVisible = this.state.element.matches(":focus-visible");
6074
+ } catch (e) {
6075
+ isFocusVisible = true;
6076
+ }
6077
+ if (!isFocusVisible)
6078
+ return;
6079
+ this.state.setActive("whileFocus", true);
6080
+ this.isActive = true;
6081
+ }
6082
+ onBlur() {
6083
+ if (!this.isActive)
6084
+ return;
6085
+ this.state.setActive("whileFocus", false);
6086
+ this.isActive = false;
6087
+ }
6088
+ mount() {
6089
+ this.unmount = pipe(
6090
+ addDomEvent$1(this.state.element, "focus", () => this.onFocus()),
6091
+ addDomEvent$1(this.state.element, "blur", () => this.onBlur())
6092
+ );
6093
+ }
6094
+ }
6095
+ const compareByDepth = (a, b) => a.depth - b.depth;
6096
+ class FlatTree {
6097
+ constructor() {
6098
+ this.children = [];
6099
+ this.isDirty = false;
6100
+ }
6101
+ add(child) {
6102
+ addUniqueItem(this.children, child);
6103
+ this.isDirty = true;
6104
+ }
6105
+ remove(child) {
6106
+ removeItem(this.children, child);
6107
+ this.isDirty = true;
6108
+ }
6109
+ forEach(callback) {
6110
+ this.isDirty && this.children.sort(compareByDepth);
6111
+ this.isDirty = false;
6112
+ this.children.forEach(callback);
6113
+ }
6114
+ }
6115
+ function resolveMotionValue(value) {
6116
+ const unwrappedValue = isMotionValue$1(value) ? value.get() : value;
6117
+ return isCustomValue(unwrappedValue) ? unwrappedValue.toValue() : unwrappedValue;
6118
+ }
6119
+ const borders = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"];
6120
+ const numBorders = borders.length;
6121
+ const asNumber = (value) => typeof value === "string" ? parseFloat(value) : value;
6122
+ const isPx = (value) => typeof value === "number" || px$1.test(value);
6123
+ function mixValues(target, follow, lead, progress2, shouldCrossfadeOpacity, isOnlyMember) {
6124
+ if (shouldCrossfadeOpacity) {
6125
+ target.opacity = mixNumber$2(
6126
+ 0,
6127
+ // TODO Reinstate this if only child
6128
+ lead.opacity !== void 0 ? lead.opacity : 1,
6129
+ easeCrossfadeIn(progress2)
5879
6130
  );
5880
6131
  target.opacityExit = mixNumber$2(follow.opacity !== void 0 ? follow.opacity : 1, 0, easeCrossfadeOut(progress2));
5881
6132
  } else if (isOnlyMember) {
@@ -7287,270 +7538,50 @@ class ProjectionFeature extends Feature {
7287
7538
  crossfade: options.crossfade,
7288
7539
  onExitComplete: () => {
7289
7540
  var _a;
7290
- if (!((_a = this.state.visualElement.projection) == null ? void 0 : _a.isPresent)) {
7291
- const done = doneCallbacks.get(this.state.element);
7292
- this.state.isSafeToRemove = true;
7293
- if (done) {
7294
- done({
7295
- detail: {
7296
- isExit: true
7297
- }
7298
- }, true);
7299
- }
7300
- }
7301
- }
7302
- });
7303
- }
7304
- update() {
7305
- this.setOptions();
7306
- }
7307
- mount() {
7308
- var _a;
7309
- (_a = this.state.visualElement.projection) == null ? void 0 : _a.mount(this.state.element);
7310
- }
7311
- }
7312
- class FocusGesture extends Feature {
7313
- constructor() {
7314
- super(...arguments);
7315
- this.isActive = false;
7316
- }
7317
- onFocus() {
7318
- let isFocusVisible = false;
7319
- try {
7320
- isFocusVisible = this.state.element.matches(":focus-visible");
7321
- } catch (e) {
7322
- isFocusVisible = true;
7323
- }
7324
- if (!isFocusVisible)
7325
- return;
7326
- this.state.setActive("whileFocus", true);
7327
- this.isActive = true;
7328
- }
7329
- onBlur() {
7330
- if (!this.isActive)
7331
- return;
7332
- this.state.setActive("whileFocus", false);
7333
- this.isActive = false;
7334
- }
7335
- mount() {
7336
- this.unmount = pipe(
7337
- addDomEvent$1(this.state.element, "focus", () => this.onFocus()),
7338
- addDomEvent$1(this.state.element, "blur", () => this.onBlur())
7339
- );
7340
- }
7341
- }
7342
- class FeatureManager {
7343
- constructor(state2) {
7344
- this.features = [];
7345
- this.features = [
7346
- new HoverGesture(state2),
7347
- new PressGesture(state2),
7348
- new InViewGesture(state2),
7349
- new LayoutFeature(state2),
7350
- new ProjectionFeature(state2),
7351
- new PanGesture(state2),
7352
- new DragGesture(state2),
7353
- new FocusGesture(state2),
7354
- new AnimationFeature(state2)
7355
- ];
7356
- }
7357
- mount() {
7358
- this.features.forEach((feature) => feature.mount());
7359
- }
7360
- beforeMount() {
7361
- this.features.forEach((feature) => {
7362
- var _a;
7363
- return (_a = feature.beforeMount) == null ? void 0 : _a.call(feature);
7364
- });
7365
- }
7366
- unmount() {
7367
- this.features.forEach((feature) => feature.unmount());
7368
- }
7369
- update() {
7370
- this.features.forEach((feature) => {
7371
- var _a;
7372
- return (_a = feature.update) == null ? void 0 : _a.call(feature);
7373
- });
7374
- }
7375
- beforeUpdate() {
7376
- this.features.forEach((feature) => feature.beforeUpdate());
7377
- }
7378
- beforeUnmount() {
7379
- this.features.forEach((feature) => feature.beforeUnmount());
7380
- }
7381
- }
7382
- function isAnimationControls(v) {
7383
- return v !== null && typeof v === "object" && typeof v.start === "function";
7384
- }
7385
- class AnimationFeature extends Feature {
7386
- constructor(state2) {
7387
- super(state2);
7388
- }
7389
- updateAnimationControlsSubscription() {
7390
- const { animate: animate2 } = this.state.options;
7391
- if (isAnimationControls(animate2)) {
7392
- this.unmountControls = animate2.subscribe(this.state);
7393
- }
7394
- }
7395
- /**
7396
- * Subscribe any provided AnimationControls to the component's VisualElement
7397
- */
7398
- mount() {
7399
- this.updateAnimationControlsSubscription();
7400
- }
7401
- update() {
7402
- const { animate: animate2 } = this.state.options;
7403
- const { animate: prevAnimate } = this.state.visualElement.prevProps || {};
7404
- if (animate2 !== prevAnimate) {
7405
- this.updateAnimationControlsSubscription();
7406
- }
7407
- }
7408
- unmount() {
7409
- var _a;
7410
- (_a = this.unmountControls) == null ? void 0 : _a.call(this);
7411
- }
7412
- }
7413
- function createVisualElement(Component, options) {
7414
- return isSVGElement(Component) ? new SVGVisualElement(options) : new HTMLVisualElement(options);
7415
- }
7416
- function motionEvent(name, target, isExit) {
7417
- return new CustomEvent(name, { detail: { target, isExit } });
7418
- }
7419
- const STATE_TYPES = ["initial", "animate", "whileInView", "whileHover", "whilePress", "whileDrag", "whileFocus", "exit"];
7420
- function animateUpdates({
7421
- controlActiveState = void 0,
7422
- controlDelay = 0,
7423
- directAnimate,
7424
- directTransition,
7425
- isFallback = false,
7426
- isExit = false
7427
- } = {}) {
7428
- const prevTarget = this.target;
7429
- this.target = { ...this.baseTarget };
7430
- let animationOptions = {};
7431
- const transition = { ...this.options.transition };
7432
- if (directAnimate)
7433
- animationOptions = resolveDirectAnimation.call(this, directAnimate, directTransition, animationOptions);
7434
- else
7435
- animationOptions = resolveStateAnimation.call(this, controlActiveState);
7436
- const factories = createAnimationFactories.call(this, prevTarget, animationOptions, controlDelay);
7437
- const { getChildAnimations, childAnimations } = setupChildAnimations.call(this, animationOptions, this.activeStates, isFallback);
7438
- return executeAnimations.call(this, {
7439
- factories,
7440
- getChildAnimations,
7441
- childAnimations,
7442
- transition,
7443
- controlActiveState,
7444
- isExit
7445
- });
7446
- }
7447
- function resolveDirectAnimation(directAnimate, directTransition) {
7448
- var _a;
7449
- const variant = resolveVariant(directAnimate, this.options.variants, this.options.custom || ((_a = this.options.animatePresenceContext) == null ? void 0 : _a.custom));
7450
- if (!variant)
7451
- return {};
7452
- const transition = variant.transition || directTransition || this.options.transition || {};
7453
- Object.entries(variant).forEach(([key, value]) => {
7454
- if (key === "transition")
7455
- return;
7456
- this.target[key] = value;
7457
- });
7458
- return transition;
7459
- }
7460
- function resolveStateAnimation(controlActiveState) {
7461
- if (controlActiveState)
7462
- this.activeStates = { ...this.activeStates, ...controlActiveState };
7463
- let variantTransition = this.options.transition;
7464
- let variant = {};
7465
- STATE_TYPES.forEach((name) => {
7466
- if (!this.activeStates[name] || isAnimationControls(this.options[name]))
7467
- return;
7468
- const definition = this.options[name];
7469
- let resolvedVariant = core.isDef(definition) ? resolveVariant(definition, this.options.variants, this.options.custom) : void 0;
7470
- if (this.visualElement.isVariantNode) {
7471
- const controlVariant = resolveVariant(this.context[name], this.options.variants, this.options.custom);
7472
- resolvedVariant = controlVariant ? Object.assign(controlVariant || {}, resolvedVariant) : variant;
7473
- }
7474
- if (!resolvedVariant)
7475
- return;
7476
- if (name !== "initial")
7477
- variantTransition = resolvedVariant.transition || this.options.transition || {};
7478
- variant = Object.assign(variant, resolvedVariant);
7479
- });
7480
- Object.entries(variant).forEach(([key, value]) => {
7481
- if (key === "transition")
7482
- return;
7483
- this.target[key] = value;
7484
- });
7485
- return variantTransition;
7486
- }
7487
- function createAnimationFactories(prevTarget, animationOptions, controlDelay) {
7488
- const factories = [];
7489
- Object.keys(this.target).forEach((key) => {
7490
- var _a;
7491
- if (!hasChanged(prevTarget[key], this.target[key]))
7492
- return;
7493
- (_a = this.baseTarget)[key] ?? (_a[key] = style.get(this.element, key));
7494
- const keyValue = this.target[key] === "none" && core.isDef(transformResetValue[key]) ? transformResetValue[key] : this.target[key];
7495
- factories.push(() => {
7496
- var _a2;
7497
- return animate(
7498
- this.element,
7499
- { [key]: keyValue },
7500
- {
7501
- ...(animationOptions == null ? void 0 : animationOptions[key]) || animationOptions,
7502
- delay: (((_a2 = animationOptions == null ? void 0 : animationOptions[key]) == null ? void 0 : _a2.delay) || (animationOptions == null ? void 0 : animationOptions.delay) || 0) + controlDelay
7541
+ if (!((_a = this.state.visualElement.projection) == null ? void 0 : _a.isPresent)) {
7542
+ const done = doneCallbacks.get(this.state.element);
7543
+ this.state.isSafeToRemove = true;
7544
+ if (done) {
7545
+ done({
7546
+ detail: {
7547
+ isExit: true
7548
+ }
7549
+ }, true);
7550
+ }
7503
7551
  }
7504
- );
7505
- });
7506
- });
7507
- return factories;
7508
- }
7509
- function setupChildAnimations(transition, controlActiveState, isFallback) {
7510
- var _a;
7511
- if (!((_a = this.visualElement.variantChildren) == null ? void 0 : _a.size) || !controlActiveState)
7512
- return { getChildAnimations: () => Promise.resolve(), childAnimations: [] };
7513
- const { staggerChildren = 0, staggerDirection = 1, delayChildren = 0 } = transition || {};
7514
- const maxStaggerDuration = (this.visualElement.variantChildren.size - 1) * staggerChildren;
7515
- const generateStaggerDuration = staggerDirection === 1 ? (i = 0) => i * staggerChildren : (i = 0) => maxStaggerDuration - i * staggerChildren;
7516
- const childAnimations = Array.from(this.visualElement.variantChildren).map((child, index) => {
7517
- const childDelay = delayChildren + generateStaggerDuration(index);
7518
- return child.state.animateUpdates({
7519
- controlActiveState,
7520
- controlDelay: isFallback ? 0 : childDelay
7552
+ }
7521
7553
  });
7522
- }).filter(Boolean);
7523
- return {
7524
- getChildAnimations: () => Promise.all(childAnimations.map((animation) => {
7525
- return animation == null ? void 0 : animation();
7526
- })),
7527
- childAnimations
7528
- };
7529
- }
7530
- function executeAnimations({
7531
- factories,
7532
- getChildAnimations,
7533
- childAnimations,
7534
- transition,
7535
- controlActiveState,
7536
- isExit = false
7537
- }) {
7538
- const getAnimation = () => Promise.all(factories.map((factory) => factory()).filter(Boolean));
7539
- const animationTarget2 = { ...this.target };
7540
- const element = this.element;
7541
- const finishAnimation2 = (animationPromise) => {
7542
- element.dispatchEvent(motionEvent("motionstart", animationTarget2));
7543
- animationPromise.then(() => {
7544
- element.dispatchEvent(motionEvent("motioncomplete", animationTarget2, isExit));
7545
- }).catch(noop);
7546
- };
7547
- const getAnimationPromise = () => {
7548
- const animationPromise = (transition == null ? void 0 : transition.when) ? (transition.when === "beforeChildren" ? getAnimation() : getChildAnimations()).then(() => transition.when === "beforeChildren" ? getChildAnimations() : getAnimation()) : Promise.all([getAnimation(), getChildAnimations()]);
7549
- finishAnimation2(animationPromise);
7550
- return animationPromise;
7551
- };
7552
- return controlActiveState ? getAnimationPromise : getAnimationPromise();
7554
+ }
7555
+ update() {
7556
+ this.setOptions();
7557
+ }
7558
+ mount() {
7559
+ var _a;
7560
+ (_a = this.state.visualElement.projection) == null ? void 0 : _a.mount(this.state.element);
7561
+ }
7553
7562
  }
7563
+ const domMax = [
7564
+ AnimationFeature,
7565
+ PressGesture,
7566
+ HoverGesture,
7567
+ InViewGesture,
7568
+ FocusGesture,
7569
+ ProjectionFeature,
7570
+ PanGesture,
7571
+ DragGesture,
7572
+ LayoutFeature
7573
+ ];
7574
+ const domAnimation = [
7575
+ AnimationFeature,
7576
+ PressGesture,
7577
+ HoverGesture,
7578
+ InViewGesture,
7579
+ FocusGesture
7580
+ // ProjectionFeature,
7581
+ // DragGesture,
7582
+ // LayoutFeature,
7583
+ // PanGesture,
7584
+ ];
7554
7585
  function isVariantLabels(value) {
7555
7586
  return typeof value === "string" || value === false || Array.isArray(value);
7556
7587
  }
@@ -7570,7 +7601,7 @@ class MotionState {
7570
7601
  };
7571
7602
  this.currentProcess = null;
7572
7603
  this._context = null;
7573
- this.animateUpdates = animateUpdates;
7604
+ this.animateUpdates = noop;
7574
7605
  this.id = `motion-state-${id++}`;
7575
7606
  this.options = options;
7576
7607
  this.parent = parent;
@@ -7578,30 +7609,8 @@ class MotionState {
7578
7609
  this.depth = (parent == null ? void 0 : parent.depth) + 1 || 0;
7579
7610
  const initialVariantSource = this.context.initial === false ? ["initial", "animate"] : ["initial"];
7580
7611
  this.initTarget(initialVariantSource);
7581
- this.visualElement = createVisualElement(this.options.as, {
7582
- presenceContext: null,
7583
- parent: parent == null ? void 0 : parent.visualElement,
7584
- props: {
7585
- ...this.options,
7586
- whileHover: this.options.whileHover,
7587
- whileTap: this.options.whilePress,
7588
- whileInView: this.options.whileInView
7589
- },
7590
- visualState: {
7591
- renderState: {
7592
- transform: {},
7593
- transformOrigin: {},
7594
- style: {},
7595
- vars: {},
7596
- attrs: {}
7597
- },
7598
- latestValues: {
7599
- ...this.baseTarget
7600
- }
7601
- },
7602
- reducedMotionConfig: options.motionConfig.reduceMotion
7603
- });
7604
7612
  this.featureManager = new FeatureManager(this);
7613
+ this.type = isSVGElement(this.options.as) ? "svg" : "html";
7605
7614
  }
7606
7615
  // Get animation context, falling back to parent context for inheritance
7607
7616
  get context() {
@@ -7628,11 +7637,10 @@ class MotionState {
7628
7637
  }
7629
7638
  // Update visual element with new options
7630
7639
  updateOptions() {
7631
- this.visualElement.update({
7640
+ var _a;
7641
+ (_a = this.visualElement) == null ? void 0 : _a.update({
7632
7642
  ...this.options,
7633
- whileHover: this.options.hover,
7634
- whileTap: this.options.press,
7635
- whileInView: this.options.inView,
7643
+ whileTap: this.options.whilePress,
7636
7644
  reducedMotionConfig: this.options.motionConfig.reduceMotion
7637
7645
  }, {
7638
7646
  isPresent: !doneCallbacks.has(this.element)
@@ -7644,25 +7652,20 @@ class MotionState {
7644
7652
  }
7645
7653
  // Mount motion state to DOM element, handles parent-child relationships
7646
7654
  mount(element, options, notAnimate = false) {
7655
+ var _a;
7647
7656
  heyListen.invariant(
7648
7657
  Boolean(element),
7649
7658
  "Animation state must be mounted with valid Element"
7650
7659
  );
7651
7660
  this.element = element;
7652
7661
  this.options = options;
7653
- mountedStates.set(element, this);
7654
- if (!visualElementStore.get(element)) {
7655
- this.visualElement.mount(element);
7656
- visualElementStore.set(element, this.visualElement);
7657
- }
7658
- this.visualElement.state = this;
7659
7662
  this.updateOptions();
7660
7663
  this.featureManager.mount();
7661
7664
  if (!notAnimate && this.options.animate) {
7662
- if (this.visualElement.type === "svg") {
7665
+ if (this.type === "svg") {
7663
7666
  this.visualElement.updateDimensions();
7664
7667
  }
7665
- this.startAnimation();
7668
+ (_a = this.startAnimation) == null ? void 0 : _a.call(this);
7666
7669
  }
7667
7670
  if (this.options.layoutId) {
7668
7671
  mountedLayoutIds.add(this.options.layoutId);
@@ -7672,10 +7675,10 @@ class MotionState {
7672
7675
  }
7673
7676
  }
7674
7677
  clearAnimation() {
7675
- var _a;
7678
+ var _a, _b;
7676
7679
  this.currentProcess && motionDom.cancelFrame(this.currentProcess);
7677
7680
  this.currentProcess = null;
7678
- (_a = this.visualElement.variantChildren) == null ? void 0 : _a.forEach((child) => {
7681
+ (_b = (_a = this.visualElement) == null ? void 0 : _a.variantChildren) == null ? void 0 : _b.forEach((child) => {
7679
7682
  child.state.clearAnimation();
7680
7683
  });
7681
7684
  }
@@ -7750,9 +7753,6 @@ class MotionState {
7750
7753
  isMounted() {
7751
7754
  return Boolean(this.element);
7752
7755
  }
7753
- getOptions() {
7754
- return this.options;
7755
- }
7756
7756
  // Called before layout updates to prepare for changes
7757
7757
  willUpdate(label) {
7758
7758
  var _a;
@@ -7761,292 +7761,321 @@ class MotionState {
7761
7761
  }
7762
7762
  }
7763
7763
  }
7764
+ function useMotionState(props) {
7765
+ var _a;
7766
+ const parentState = injectMotion(null);
7767
+ const layoutGroup = injectLayoutGroup({});
7768
+ const config = useMotionConfig();
7769
+ const animatePresenceContext = injectAnimatePresence({});
7770
+ const lazyMotionContext = useLazyMotionContext({
7771
+ features: vue.ref([]),
7772
+ strict: false
7773
+ });
7774
+ if (process.env.NODE_ENV !== "production" && ((_a = props.features) == null ? void 0 : _a.length) && lazyMotionContext.strict) {
7775
+ const strictMessage = "You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";
7776
+ props.ignoreStrict ? heyListen.warning(false, strictMessage) : heyListen.invariant(false, strictMessage);
7777
+ }
7778
+ const attrs = vue.useAttrs();
7779
+ function getLayoutId() {
7780
+ if (layoutGroup.id && props.layoutId)
7781
+ return `${layoutGroup.id}-${props.layoutId}`;
7782
+ return props.layoutId || void 0;
7783
+ }
7784
+ function getProps() {
7785
+ return {
7786
+ ...props,
7787
+ lazyMotionContext,
7788
+ layoutId: getLayoutId(),
7789
+ transition: props.transition ?? config.value.transition,
7790
+ layoutGroup,
7791
+ motionConfig: config.value,
7792
+ inViewOptions: props.inViewOptions ?? config.value.inViewOptions,
7793
+ animatePresenceContext,
7794
+ initial: animatePresenceContext.initial === false ? animatePresenceContext.initial : props.initial === true ? void 0 : props.initial
7795
+ };
7796
+ }
7797
+ function getMotionProps() {
7798
+ return {
7799
+ ...attrs,
7800
+ ...getProps()
7801
+ };
7802
+ }
7803
+ const state2 = new MotionState(
7804
+ getMotionProps(),
7805
+ parentState
7806
+ );
7807
+ provideMotion(state2);
7808
+ function getAttrs() {
7809
+ var _a2;
7810
+ const isSVG = state2.type === "svg";
7811
+ const attrsProps = { ...attrs };
7812
+ Object.keys(attrs).forEach((key) => {
7813
+ if (isMotionValue(attrs[key]))
7814
+ attrsProps[key] = attrs[key].get();
7815
+ });
7816
+ let styleProps = {
7817
+ ...props.style,
7818
+ ...isSVG ? {} : ((_a2 = state2.visualElement) == null ? void 0 : _a2.latestValues) || state2.baseTarget
7819
+ };
7820
+ if (isSVG) {
7821
+ const { attributes, style: style2 } = convertSvgStyleToAttributes({
7822
+ ...state2.isMounted() ? state2.target : state2.baseTarget,
7823
+ ...styleProps
7824
+ });
7825
+ Object.assign(attrsProps, attributes);
7826
+ styleProps = style2;
7827
+ }
7828
+ if (props.drag && props.dragListener !== false) {
7829
+ Object.assign(styleProps, {
7830
+ userSelect: "none",
7831
+ WebkitUserSelect: "none",
7832
+ WebkitTouchCallout: "none",
7833
+ touchAction: props.drag === true ? "none" : `pan-${props.drag === "x" ? "y" : "x"}`
7834
+ });
7835
+ }
7836
+ attrsProps.style = createStyles(styleProps);
7837
+ return attrsProps;
7838
+ }
7839
+ const instance = vue.getCurrentInstance().proxy;
7840
+ vue.onBeforeMount(() => {
7841
+ state2.beforeMount();
7842
+ });
7843
+ vue.onMounted(() => {
7844
+ state2.mount(getMotionElement(instance.$el), getMotionProps(), checkMotionIsHidden(instance));
7845
+ });
7846
+ vue.onBeforeUnmount(() => state2.beforeUnmount());
7847
+ vue.onUnmounted(() => {
7848
+ const el = getMotionElement(instance.$el);
7849
+ if (!(el == null ? void 0 : el.isConnected)) {
7850
+ state2.unmount();
7851
+ }
7852
+ });
7853
+ vue.onBeforeUpdate(() => {
7854
+ state2.beforeUpdate();
7855
+ });
7856
+ vue.onUpdated(() => {
7857
+ state2.update(getMotionProps());
7858
+ });
7859
+ return {
7860
+ getProps,
7861
+ getAttrs,
7862
+ layoutGroup,
7863
+ state: state2
7864
+ };
7865
+ }
7866
+ const MotionComponentProps = {
7867
+ "ignoreStrict": { type: Boolean },
7868
+ "forwardMotionProps": { type: Boolean, default: false },
7869
+ "asChild": { type: Boolean, default: false },
7870
+ "hover": { type: [String, Array, Object] },
7871
+ "press": { type: [String, Array, Object] },
7872
+ "inView": { type: [String, Array, Object] },
7873
+ "focus": { type: [String, Array, Object] },
7874
+ "whileDrag": { type: [String, Array, Object] },
7875
+ "whileHover": { type: [String, Array, Object], default: ({ hover }) => {
7876
+ if (process.env.NODE_ENV === "development" && hover) {
7877
+ heyListen.warning(true, "hover is deprecated. Use whileHover instead.");
7878
+ }
7879
+ return hover;
7880
+ } },
7881
+ "whilePress": { type: [String, Array, Object], default: ({ press }) => {
7882
+ if (process.env.NODE_ENV === "development" && press) {
7883
+ heyListen.warning(true, "press is deprecated. Use whilePress instead.");
7884
+ }
7885
+ return press;
7886
+ } },
7887
+ "whileInView": { type: [String, Array, Object], default: ({ inView: inView2 }) => {
7888
+ if (process.env.NODE_ENV === "development" && inView2) {
7889
+ heyListen.warning(true, "inView is deprecated. Use whileInView instead.");
7890
+ }
7891
+ return inView2;
7892
+ } },
7893
+ "whileFocus": { type: [String, Array, Object], default: ({ focus }) => {
7894
+ if (process.env.NODE_ENV === "development" && focus) {
7895
+ heyListen.warning(true, "focus is deprecated. Use whileFocus instead.");
7896
+ }
7897
+ return focus;
7898
+ } },
7899
+ "custom": { type: [String, Number, Object, Array] },
7900
+ "initial": { type: [String, Array, Object, Boolean], default: void 0 },
7901
+ "animate": { type: [String, Array, Object], default: void 0 },
7902
+ "exit": { type: [String, Array, Object] },
7903
+ "variants": { type: Object },
7904
+ "inherit": { type: Boolean },
7905
+ "style": { type: Object },
7906
+ "transformTemplate": { type: Function },
7907
+ "transition": { type: Object },
7908
+ "layoutGroup": { type: Object },
7909
+ "motionConfig": { type: Object },
7910
+ "onAnimationComplete": { type: Function },
7911
+ "onUpdate": { type: Function },
7912
+ "layout": { type: [Boolean, String], default: false },
7913
+ "layoutId": { type: String, default: void 0 },
7914
+ "layoutScroll": { type: Boolean, default: false },
7915
+ "layoutRoot": { type: Boolean, default: false },
7916
+ "data-framer-portal-id": { type: String },
7917
+ "crossfade": { type: Boolean, default: true },
7918
+ "layoutDependency": { type: [String, Number, Object, Array] },
7919
+ "onBeforeLayoutMeasure": { type: Function },
7920
+ "onLayoutMeasure": { type: Function },
7921
+ "onLayoutAnimationStart": { type: Function },
7922
+ "onLayoutAnimationComplete": { type: Function },
7923
+ "globalPressTarget": { type: Boolean },
7924
+ "onPressStart": { type: Function },
7925
+ "onPress": { type: Function },
7926
+ "onPressCancel": { type: Function },
7927
+ "onHoverStart": { type: Function },
7928
+ "onHoverEnd": { type: Function },
7929
+ "inViewOptions": { type: Object },
7930
+ "onViewportEnter": { type: Function },
7931
+ "onViewportLeave": { type: Function },
7932
+ "drag": { type: [Boolean, String] },
7933
+ "dragSnapToOrigin": { type: Boolean },
7934
+ "dragDirectionLock": { type: Boolean },
7935
+ "dragPropagation": { type: Boolean },
7936
+ "dragConstraints": { type: [Boolean, Object] },
7937
+ "dragElastic": { type: [Boolean, Number, Object], default: 0.5 },
7938
+ "dragMomentum": { type: Boolean, default: true },
7939
+ "dragTransition": { type: Object },
7940
+ "dragListener": { type: Boolean, default: true },
7941
+ "dragControls": { type: Object },
7942
+ "onDragStart": { type: Function },
7943
+ "onDragEnd": { type: Function },
7944
+ "onDrag": { type: Function },
7945
+ "onDirectionLock": { type: Function },
7946
+ "onDragTransitionEnd": { type: Function },
7947
+ "onMeasureDragConstraints": { type: Function },
7948
+ "onPanSessionStart": { type: Function },
7949
+ "onPanStart": { type: Function },
7950
+ "onPan": { type: Function },
7951
+ "onPanEnd": { type: Function },
7952
+ "onFocus": { type: Function },
7953
+ "onBlur": { type: Function }
7954
+ };
7764
7955
  function checkMotionIsHidden(instance) {
7765
7956
  var _a;
7766
7957
  const isHidden = ((_a = getMotionElement(instance.$el)) == null ? void 0 : _a.style.display) === "none";
7767
7958
  const hasTransition = instance.$.vnode.transition;
7768
7959
  return hasTransition && isHidden;
7769
7960
  }
7770
- const defaultConfig = {
7771
- reduceMotion: "never",
7772
- transition: void 0,
7773
- nonce: void 0
7774
- };
7775
- const [injectMotionConfig, provideMotionConfig] = createContext("MotionConfig");
7776
- function useMotionConfig() {
7777
- return injectMotionConfig(vue.computed(() => defaultConfig));
7961
+ const componentMaxCache = /* @__PURE__ */ new Map();
7962
+ const componentMiniCache = /* @__PURE__ */ new Map();
7963
+ function renderSlotFragments(fragments) {
7964
+ if (!Array.isArray(fragments))
7965
+ return [fragments];
7966
+ const result = [];
7967
+ for (const item of fragments) {
7968
+ if (Array.isArray(item))
7969
+ result.push(...item);
7970
+ else
7971
+ result.push(item);
7972
+ }
7973
+ return result;
7778
7974
  }
7779
- const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
7780
- ...{
7781
- name: "Motion",
7782
- inheritAttrs: false
7783
- },
7784
- __name: "Motion",
7785
- props: /* @__PURE__ */ vue.mergeDefaults({
7786
- as: {},
7787
- asChild: { type: Boolean },
7788
- hover: {},
7789
- press: {},
7790
- inView: {},
7791
- focus: {},
7792
- whileDrag: {},
7793
- whileHover: {},
7794
- whilePress: {},
7795
- whileInView: {},
7796
- whileFocus: {},
7797
- forwardMotionProps: { type: Boolean },
7798
- custom: {},
7799
- initial: { type: [String, Array, Object, Boolean] },
7800
- animate: {},
7801
- exit: {},
7802
- variants: {},
7803
- inherit: { type: Boolean },
7804
- style: {},
7805
- transformTemplate: { type: Function },
7806
- transition: {},
7807
- layoutGroup: {},
7808
- motionConfig: {},
7809
- onAnimationComplete: { type: Function },
7810
- onUpdate: { type: Function },
7811
- layout: { type: [Boolean, String] },
7812
- layoutId: {},
7813
- layoutScroll: { type: Boolean },
7814
- layoutRoot: { type: Boolean },
7815
- "data-framer-portal-id": {},
7816
- crossfade: { type: Boolean },
7817
- layoutDependency: {},
7818
- onBeforeLayoutMeasure: { type: Function },
7819
- onLayoutMeasure: { type: Function },
7820
- onLayoutAnimationStart: { type: Function },
7821
- onLayoutAnimationComplete: { type: Function },
7822
- globalPressTarget: { type: Boolean },
7823
- onPressStart: { type: Function },
7824
- onPress: { type: Function },
7825
- onPressCancel: { type: Function },
7826
- onHoverStart: { type: Function },
7827
- onHoverEnd: { type: Function },
7828
- inViewOptions: {},
7829
- onViewportEnter: { type: Function },
7830
- onViewportLeave: { type: Function },
7831
- drag: { type: [Boolean, String] },
7832
- dragSnapToOrigin: { type: Boolean },
7833
- dragDirectionLock: { type: Boolean },
7834
- dragPropagation: { type: Boolean },
7835
- dragConstraints: { type: [Boolean, Object] },
7836
- dragElastic: { type: [Boolean, Number, Object] },
7837
- dragMomentum: { type: Boolean },
7838
- dragTransition: {},
7839
- dragListener: { type: Boolean },
7840
- dragControls: {},
7841
- onDragStart: { type: Function },
7842
- onDragEnd: { type: Function },
7843
- onDrag: { type: Function },
7844
- onDirectionLock: { type: Function },
7845
- onDragTransitionEnd: { type: Function },
7846
- onMeasureDragConstraints: { type: Function },
7847
- onPanSessionStart: { type: Function },
7848
- onPanStart: { type: Function },
7849
- onPan: { type: Function },
7850
- onPanEnd: { type: Function },
7851
- onFocus: { type: Function },
7852
- onBlur: { type: Function }
7853
- }, {
7854
- as: "div",
7855
- asChild: false,
7856
- initial: void 0,
7857
- animate: void 0,
7858
- hover: void 0,
7859
- inView: void 0,
7860
- layout: false,
7861
- layoutId: void 0,
7862
- layoutScroll: false,
7863
- layoutRoot: false,
7864
- dragListener: true,
7865
- dragElastic: 0.5,
7866
- dragMomentum: true,
7867
- whileDrag: void 0,
7868
- crossfade: true,
7869
- whileHover: ({ hover }) => {
7870
- if (process.env.NODE_ENV === "development" && hover) {
7871
- vue.warn("hover is deprecated. Use whileHover instead.");
7872
- }
7873
- return hover;
7874
- },
7875
- whilePress: ({ press }) => {
7876
- if (process.env.NODE_ENV === "development" && press) {
7877
- vue.warn("press is deprecated. Use whilePress instead.");
7878
- }
7879
- return press;
7880
- },
7881
- whileInView: ({ inView: inView2 }) => {
7882
- if (process.env.NODE_ENV === "development" && inView2) {
7883
- vue.warn("inView is deprecated. Use whileInView instead.");
7884
- }
7885
- return inView2;
7975
+ const SELF_CLOSING_TAGS = ["area", "img", "input"];
7976
+ function handlePrimitiveAndSlot(asTag, allAttrs, slots) {
7977
+ var _a, _b;
7978
+ if (typeof asTag === "string" && SELF_CLOSING_TAGS.includes(asTag)) {
7979
+ return vue.h(asTag, allAttrs);
7980
+ }
7981
+ if (asTag === "template") {
7982
+ if (!slots.default)
7983
+ return null;
7984
+ const childrens = renderSlotFragments(slots.default());
7985
+ const firstNonCommentChildrenIndex = childrens.findIndex((child) => child.type !== vue.Comment);
7986
+ if (firstNonCommentChildrenIndex === -1)
7987
+ return childrens;
7988
+ const firstNonCommentChildren = childrens[firstNonCommentChildrenIndex];
7989
+ (_a = firstNonCommentChildren.props) == null ? true : delete _a.ref;
7990
+ const mergedProps = firstNonCommentChildren.props ? vue.mergeProps(allAttrs, firstNonCommentChildren.props) : allAttrs;
7991
+ if (allAttrs.class && ((_b = firstNonCommentChildren.props) == null ? void 0 : _b.class))
7992
+ delete firstNonCommentChildren.props.class;
7993
+ const cloned = vue.cloneVNode(firstNonCommentChildren, mergedProps);
7994
+ for (const prop in mergedProps) {
7995
+ if (prop.startsWith("on")) {
7996
+ cloned.props || (cloned.props = {});
7997
+ cloned.props[prop] = mergedProps[prop];
7998
+ }
7999
+ }
8000
+ if (childrens.length === 1)
8001
+ return cloned;
8002
+ childrens[firstNonCommentChildrenIndex] = cloned;
8003
+ return childrens;
8004
+ }
8005
+ return null;
8006
+ }
8007
+ function createMotionComponent(component, options = {}) {
8008
+ var _a;
8009
+ const isString = typeof component === "string";
8010
+ const name = isString ? component : component.name || "";
8011
+ const componentCache = ((_a = options.features) == null ? void 0 : _a.length) > 0 ? componentMaxCache : componentMiniCache;
8012
+ if (isString && (componentCache == null ? void 0 : componentCache.has(component))) {
8013
+ return componentCache.get(component);
8014
+ }
8015
+ const motionComponent = vue.defineComponent({
8016
+ inheritAttrs: false,
8017
+ props: {
8018
+ ...MotionComponentProps,
8019
+ features: {
8020
+ type: Object,
8021
+ default: () => options.features || []
8022
+ },
8023
+ as: { type: [String, Object], default: component || "div" }
7886
8024
  },
7887
- whileFocus: ({ focus }) => {
7888
- if (process.env.NODE_ENV === "development" && focus) {
7889
- vue.warn("focus is deprecated. Use whileFocus instead.");
7890
- }
7891
- return focus;
7892
- }
7893
- }),
7894
- setup(__props) {
7895
- const props = __props;
7896
- const animatePresenceContext = injectAnimatePresence({});
7897
- const parentState = injectMotion(null);
7898
- const attrs = vue.useAttrs();
7899
- const layoutGroup = injectLayoutGroup({});
7900
- const config = useMotionConfig();
7901
- function getLayoutId() {
7902
- if (layoutGroup.id && props.layoutId)
7903
- return `${layoutGroup.id}-${props.layoutId}`;
7904
- return props.layoutId || void 0;
7905
- }
7906
- function getProps() {
7907
- return {
7908
- ...props,
7909
- layoutId: getLayoutId(),
7910
- transition: props.transition ?? config.value.transition,
7911
- layoutGroup,
7912
- motionConfig: config.value,
7913
- inViewOptions: props.inViewOptions ?? config.value.inViewOptions,
7914
- animatePresenceContext,
7915
- initial: animatePresenceContext.initial === false ? animatePresenceContext.initial : props.initial === true ? void 0 : props.initial
7916
- };
7917
- }
7918
- function getMotionProps() {
7919
- return {
7920
- ...attrs,
7921
- ...getProps()
7922
- };
7923
- }
7924
- const state2 = new MotionState(
7925
- getMotionProps(),
7926
- parentState
7927
- );
7928
- provideMotion(state2);
7929
- const instance = vue.getCurrentInstance().proxy;
7930
- vue.onBeforeMount(() => {
7931
- state2.beforeMount();
7932
- });
7933
- vue.onMounted(() => {
7934
- state2.mount(getMotionElement(instance.$el), getMotionProps(), checkMotionIsHidden(instance));
7935
- });
7936
- vue.onBeforeUnmount(() => state2.beforeUnmount());
7937
- vue.onUnmounted(() => {
7938
- const el = getMotionElement(instance.$el);
7939
- if (!(el == null ? void 0 : el.isConnected)) {
7940
- state2.unmount();
8025
+ name: name ? `motion.${name}` : "Motion",
8026
+ setup(props, { slots }) {
8027
+ const { getProps, getAttrs, state: state2 } = useMotionState(props);
8028
+ function onVnodeUpdated() {
8029
+ const el = state2.element;
8030
+ const isComponent = typeof props.as === "object";
8031
+ if ((!isComponent || props.asChild) && el) {
8032
+ const { style: style2 } = getAttrs();
8033
+ for (const [key, val] of Object.entries(style2)) {
8034
+ el.style[key] = val;
8035
+ }
8036
+ }
7941
8037
  }
7942
- });
7943
- vue.onBeforeUpdate(() => {
7944
- state2.beforeUpdate();
7945
- });
7946
- vue.onUpdated(() => {
7947
- state2.update(getMotionProps());
7948
- });
7949
- function getAttrs() {
7950
- const isSVG = state2.visualElement.type === "svg";
7951
- const attrsProps = { ...attrs };
7952
- Object.keys(attrs).forEach((key) => {
7953
- if (isMotionValue(attrs[key]))
7954
- attrsProps[key] = attrs[key].get();
7955
- });
7956
- let styleProps = {
7957
- ...props.style,
7958
- ...isSVG ? {} : state2.visualElement.latestValues
8038
+ return () => {
8039
+ const motionProps = getProps();
8040
+ const motionAttrs = getAttrs();
8041
+ const asTag = props.asChild ? "template" : props.as;
8042
+ const allAttrs = {
8043
+ ...options.forwardMotionProps || props.forwardMotionProps ? motionProps : {},
8044
+ ...motionAttrs,
8045
+ onVnodeUpdated
8046
+ };
8047
+ const primitiveOrSlotResult = handlePrimitiveAndSlot(asTag, allAttrs, slots);
8048
+ if (primitiveOrSlotResult !== null) {
8049
+ return primitiveOrSlotResult;
8050
+ }
8051
+ return vue.h(asTag, {
8052
+ ...allAttrs
8053
+ }, slots);
7959
8054
  };
7960
- if (isSVG) {
7961
- const { attributes, style: style2 } = convertSvgStyleToAttributes({
7962
- ...state2.isMounted() ? state2.target : state2.baseTarget,
7963
- ...styleProps
7964
- });
7965
- Object.assign(attrsProps, attributes);
7966
- styleProps = style2;
7967
- }
7968
- if (props.drag && props.dragListener !== false) {
7969
- Object.assign(styleProps, {
7970
- userSelect: "none",
7971
- WebkitUserSelect: "none",
7972
- WebkitTouchCallout: "none",
7973
- touchAction: props.drag === true ? "none" : `pan-${props.drag === "x" ? "y" : "x"}`
7974
- });
7975
- }
7976
- attrsProps.style = createStyles(styleProps);
7977
- return attrsProps;
7978
- }
7979
- const PrimitiveRef = vue.ref();
7980
- function onMotionComplete(e) {
7981
- var _a, _b;
7982
- if (props.asChild) {
7983
- (_a = PrimitiveRef.value) == null ? void 0 : _a.$forceUpdate();
7984
- }
7985
- (_b = attrs.onMotioncomplete) == null ? void 0 : _b.call(attrs, e);
7986
8055
  }
7987
- return (_ctx, _cache) => {
7988
- var _a;
7989
- return vue.openBlock(), vue.createBlock(vue.unref(Primitive), {
7990
- ref_key: "PrimitiveRef",
7991
- ref: PrimitiveRef,
7992
- "get-props": getProps,
7993
- "get-attrs": getAttrs,
7994
- as: _ctx.as,
7995
- "as-child": _ctx.asChild,
7996
- "data-motion-group": ((_a = vue.unref(layoutGroup).key) == null ? void 0 : _a.value) || void 0,
7997
- onMotioncomplete: onMotionComplete
7998
- }, {
7999
- default: vue.withCtx(() => [
8000
- vue.renderSlot(_ctx.$slots, "default")
8001
- ]),
8002
- _: 3
8003
- }, 8, ["as", "as-child", "data-motion-group"]);
8004
- };
8056
+ });
8057
+ if (isString) {
8058
+ componentCache == null ? void 0 : componentCache.set(component, motionComponent);
8005
8059
  }
8006
- });
8007
- const componentCache = /* @__PURE__ */ new Map();
8008
- const motion = new Proxy(_sfc_main$6, {
8009
- get(target, prop) {
8010
- if (typeof prop === "symbol")
8011
- return target[prop];
8012
- let motionComponent = componentCache.get(prop);
8013
- if (prop === "create") {
8014
- return (component, { forwardMotionProps = false } = {}) => {
8015
- return vue.defineComponent({
8016
- inheritAttrs: false,
8017
- name: `motion.${component.$name}`,
8018
- setup(_, { attrs, slots }) {
8019
- return () => {
8020
- return vue.h(_sfc_main$6, {
8021
- ...attrs,
8022
- forwardMotionProps,
8023
- as: component,
8024
- asChild: false
8025
- }, slots);
8026
- };
8027
- }
8060
+ return motionComponent;
8061
+ }
8062
+ function createMotionComponentWithFeatures(features = []) {
8063
+ return new Proxy({}, {
8064
+ get(target, prop) {
8065
+ if (prop === "create") {
8066
+ return (component, options) => createMotionComponent(component, {
8067
+ ...options,
8068
+ features
8028
8069
  });
8029
- };
8030
- }
8031
- if (!motionComponent) {
8032
- motionComponent = vue.defineComponent({
8033
- inheritAttrs: false,
8034
- name: `motion.${prop}`,
8035
- setup(_, { attrs, slots }) {
8036
- return () => {
8037
- return vue.h(_sfc_main$6, {
8038
- ...attrs,
8039
- as: prop,
8040
- asChild: false
8041
- }, slots);
8042
- };
8043
- }
8070
+ }
8071
+ return createMotionComponent(prop, {
8072
+ features
8044
8073
  });
8045
- componentCache.set(prop, motionComponent);
8046
8074
  }
8047
- return motionComponent;
8048
- }
8049
- });
8075
+ });
8076
+ }
8077
+ const motion = createMotionComponentWithFeatures(domMax);
8078
+ const Motion = motion.create("div");
8050
8079
  function usePopLayout(props) {
8051
8080
  const styles = /* @__PURE__ */ new WeakMap();
8052
8081
  const config = useMotionConfig();
@@ -8103,7 +8132,7 @@ function delay(fn) {
8103
8132
  fn();
8104
8133
  });
8105
8134
  }
8106
- const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
8135
+ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
8107
8136
  ...{
8108
8137
  name: "AnimatePresence",
8109
8138
  inheritAttrs: true
@@ -8221,33 +8250,6 @@ const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
8221
8250
  };
8222
8251
  }
8223
8252
  });
8224
- const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
8225
- ...{
8226
- name: "MotionConfig",
8227
- inheritAttrs: false
8228
- },
8229
- __name: "MotionConfig",
8230
- props: {
8231
- transition: {},
8232
- reduceMotion: { default: defaultConfig.reduceMotion },
8233
- nonce: {},
8234
- inViewOptions: {}
8235
- },
8236
- setup(__props) {
8237
- const props = __props;
8238
- const parentConfig = useMotionConfig();
8239
- const config = vue.computed(() => ({
8240
- transition: props.transition ?? parentConfig.value.transition,
8241
- reduceMotion: props.reduceMotion ?? parentConfig.value.reduceMotion,
8242
- nonce: props.nonce ?? parentConfig.value.nonce,
8243
- inViewOptions: props.inViewOptions ?? parentConfig.value.inViewOptions
8244
- }));
8245
- provideMotionConfig(config);
8246
- return (_ctx, _cache) => {
8247
- return vue.renderSlot(_ctx.$slots, "default");
8248
- };
8249
- }
8250
- });
8251
8253
  const [useReorderContext, reorderContextProvider] = createContext("ReorderContext");
8252
8254
  function compareMin(a, b) {
8253
8255
  return a.layout.min - b.layout.min;
@@ -8307,6 +8309,8 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
8307
8309
  whileInView: {},
8308
8310
  whileFocus: {},
8309
8311
  forwardMotionProps: { type: Boolean },
8312
+ features: {},
8313
+ ignoreStrict: { type: Boolean },
8310
8314
  custom: {},
8311
8315
  initial: { type: [String, Array, Object, Boolean] },
8312
8316
  animate: {},
@@ -8320,6 +8324,7 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
8320
8324
  motionConfig: {},
8321
8325
  onAnimationComplete: {},
8322
8326
  onUpdate: {},
8327
+ onAnimationStart: {},
8323
8328
  layout: { type: [Boolean, String] },
8324
8329
  layoutId: {},
8325
8330
  layoutScroll: { type: Boolean },
@@ -8408,7 +8413,7 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
8408
8413
  };
8409
8414
  }
8410
8415
  return (_ctx, _cache) => {
8411
- return vue.openBlock(), vue.createBlock(vue.unref(_sfc_main$6), vue.normalizeProps(vue.guardReactiveProps(bindProps())), {
8416
+ return vue.openBlock(), vue.createBlock(vue.unref(Motion), vue.normalizeProps(vue.guardReactiveProps(bindProps())), {
8412
8417
  default: vue.withCtx(() => [
8413
8418
  vue.renderSlot(_ctx.$slots, "default"),
8414
8419
  vue.createTextVNode(" " + vue.toDisplayString(warning2()), 1)
@@ -8652,6 +8657,8 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
8652
8657
  whileInView: {},
8653
8658
  whileFocus: {},
8654
8659
  forwardMotionProps: { type: Boolean },
8660
+ features: {},
8661
+ ignoreStrict: { type: Boolean },
8655
8662
  custom: {},
8656
8663
  initial: { type: [String, Array, Object, Boolean], default: void 0 },
8657
8664
  animate: { default: void 0 },
@@ -8665,6 +8672,7 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
8665
8672
  motionConfig: {},
8666
8673
  onAnimationComplete: {},
8667
8674
  onUpdate: {},
8675
+ onAnimationStart: {},
8668
8676
  layoutId: { default: void 0 },
8669
8677
  layoutScroll: { type: Boolean, default: false },
8670
8678
  layoutRoot: { type: Boolean, default: false },
@@ -8743,7 +8751,7 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
8743
8751
  });
8744
8752
  const isDragging = vue.ref(false);
8745
8753
  return (_ctx, _cache) => {
8746
- return vue.openBlock(), vue.createBlock(vue.unref(_sfc_main$6), vue.mergeProps(bindProps(), {
8754
+ return vue.openBlock(), vue.createBlock(vue.unref(Motion), vue.mergeProps(bindProps(), {
8747
8755
  drag: drag.value,
8748
8756
  "drag-snap-to-origin": true,
8749
8757
  onDrag: _cache[0] || (_cache[0] = (event, gesturePoint) => {
@@ -8794,6 +8802,39 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
8794
8802
  };
8795
8803
  }
8796
8804
  });
8805
+ const LazyMotion = vue.defineComponent({
8806
+ name: "LazyMotion",
8807
+ inheritAttrs: false,
8808
+ props: {
8809
+ features: {
8810
+ type: [Object, Function],
8811
+ default: () => []
8812
+ },
8813
+ strict: {
8814
+ type: Boolean,
8815
+ default: false
8816
+ }
8817
+ },
8818
+ setup(props, { slots }) {
8819
+ const features = vue.ref(Array.isArray(props.features) ? props.features : []);
8820
+ if (!Array.isArray(props.features)) {
8821
+ const featuresPromise = typeof props.features === "function" ? props.features() : props.features;
8822
+ featuresPromise.then((feats) => {
8823
+ features.value = feats;
8824
+ });
8825
+ }
8826
+ lazyMotionContextProvider({
8827
+ features,
8828
+ strict: props.strict
8829
+ });
8830
+ return () => {
8831
+ var _a;
8832
+ return (_a = slots.default) == null ? void 0 : _a.call(slots);
8833
+ };
8834
+ }
8835
+ });
8836
+ const m = createMotionComponentWithFeatures();
8837
+ const M = m.create("div");
8797
8838
  function useForceUpdate() {
8798
8839
  const key = vue.ref(0);
8799
8840
  function forceUpdate() {
@@ -9077,10 +9118,12 @@ Object.defineProperty(exports, "useMotionValue", {
9077
9118
  enumerable: true,
9078
9119
  get: () => motionDom.motionValue
9079
9120
  });
9080
- exports.AnimatePresence = _sfc_main$5;
9121
+ exports.AnimatePresence = _sfc_main$4;
9081
9122
  exports.LayoutGroup = _sfc_main;
9082
- exports.Motion = _sfc_main$6;
9083
- exports.MotionConfig = _sfc_main$4;
9123
+ exports.LazyMotion = LazyMotion;
9124
+ exports.M = M;
9125
+ exports.Motion = Motion;
9126
+ exports.MotionConfig = _sfc_main$5;
9084
9127
  exports.Reorder = Reorder;
9085
9128
  exports.ReorderGroup = ReorderGroup;
9086
9129
  exports.ReorderItem = ReorderItem;
@@ -9102,6 +9145,8 @@ exports.cubicBezier = cubicBezier;
9102
9145
  exports.delay = delayInSeconds;
9103
9146
  exports.distance = distance;
9104
9147
  exports.distance2D = distance2D;
9148
+ exports.domAnimation = domAnimation;
9149
+ exports.domMax = domMax;
9105
9150
  exports.easeIn = easeIn;
9106
9151
  exports.easeInOut = easeInOut;
9107
9152
  exports.easeOut = easeOut;
@@ -9113,6 +9158,7 @@ exports.injectMotion = injectMotion;
9113
9158
  exports.interpolate = interpolate;
9114
9159
  exports.isMotionValue = isMotionValue;
9115
9160
  exports.keyframes = keyframes;
9161
+ exports.m = m;
9116
9162
  exports.millisecondsToSeconds = millisecondsToSeconds;
9117
9163
  exports.mirrorEasing = mirrorEasing;
9118
9164
  exports.mix = mix;