motion-v 0.13.1 → 1.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/cjs/index.js +1000 -961
  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 +115 -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 +152 -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 +6 -5
  39. package/dist/es/state/motion-state.mjs +7 -12
  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
@@ -2,8 +2,8 @@
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
3
  const vue = require("vue");
4
4
  const core = require("@vueuse/core");
5
- const heyListen = require("hey-listen");
6
5
  const motionDom = require("motion-dom");
6
+ const heyListen = require("hey-listen");
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,463 @@ 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
+ const STATE_TYPES = ["initial", "animate", "whileInView", "whileHover", "whilePress", "whileDrag", "whileFocus", "exit"];
5865
+ class AnimationFeature extends Feature {
5866
+ constructor(state2) {
5867
+ super(state2);
5868
+ this.animateUpdates = ({
5869
+ controlActiveState,
5870
+ directAnimate,
5871
+ directTransition,
5872
+ controlDelay = 0,
5873
+ isFallback,
5874
+ isExit
5875
+ } = {}) => {
5876
+ const prevTarget = this.state.target;
5877
+ this.state.target = { ...this.state.baseTarget };
5878
+ let animationOptions = {};
5879
+ const transition = { ...this.state.options.transition };
5880
+ animationOptions = this.resolveStateAnimation({
5881
+ controlActiveState,
5882
+ directAnimate,
5883
+ directTransition
5884
+ });
5885
+ const factories = this.createAnimationFactories(prevTarget, animationOptions, controlDelay);
5886
+ const { getChildAnimations, childAnimations } = this.setupChildAnimations(animationOptions, controlActiveState, isFallback);
5887
+ return this.executeAnimations({
5888
+ factories,
5889
+ getChildAnimations,
5890
+ childAnimations,
5891
+ transition,
5892
+ controlActiveState,
5893
+ isExit
5894
+ });
5895
+ };
5896
+ this.state.animateUpdates = this.animateUpdates;
5897
+ }
5898
+ updateAnimationControlsSubscription() {
5899
+ const { animate: animate2 } = this.state.options;
5900
+ if (isAnimationControls(animate2)) {
5901
+ this.unmountControls = animate2.subscribe(this.state);
5902
+ }
5903
+ }
5904
+ executeAnimations({
5905
+ factories,
5906
+ getChildAnimations,
5907
+ transition,
5908
+ controlActiveState,
5909
+ isExit = false
5910
+ }) {
5911
+ const getAnimation = () => Promise.all(factories.map((factory) => factory()).filter(Boolean));
5912
+ const animationTarget2 = { ...this.state.target };
5913
+ const element = this.state.element;
5914
+ const finishAnimation2 = (animationPromise) => {
5915
+ var _a, _b;
5916
+ element.dispatchEvent(motionEvent("motionstart", animationTarget2));
5917
+ (_b = (_a = this.state.options).onAnimationStart) == null ? void 0 : _b.call(_a, animationTarget2);
5918
+ animationPromise.then(() => {
5919
+ var _a2, _b2;
5920
+ element.dispatchEvent(motionEvent("motioncomplete", animationTarget2, isExit));
5921
+ (_b2 = (_a2 = this.state.options).onAnimationComplete) == null ? void 0 : _b2.call(_a2, animationTarget2);
5922
+ }).catch(noop);
5923
+ };
5924
+ const getAnimationPromise = () => {
5925
+ const animationPromise = (transition == null ? void 0 : transition.when) ? (transition.when === "beforeChildren" ? getAnimation() : getChildAnimations()).then(() => transition.when === "beforeChildren" ? getChildAnimations() : getAnimation()) : Promise.all([getAnimation(), getChildAnimations()]);
5926
+ finishAnimation2(animationPromise);
5927
+ return animationPromise;
5928
+ };
5929
+ return controlActiveState ? getAnimationPromise : getAnimationPromise();
5930
+ }
5931
+ /**
5932
+ * Setup child animations
5933
+ */
5934
+ setupChildAnimations(transition, controlActiveState, isFallback) {
5935
+ var _a;
5936
+ if (!((_a = this.state.visualElement.variantChildren) == null ? void 0 : _a.size) || !controlActiveState)
5937
+ return { getChildAnimations: () => Promise.resolve(), childAnimations: [] };
5938
+ const { staggerChildren = 0, staggerDirection = 1, delayChildren = 0 } = transition || {};
5939
+ const maxStaggerDuration = (this.state.visualElement.variantChildren.size - 1) * staggerChildren;
5940
+ const generateStaggerDuration = staggerDirection === 1 ? (i = 0) => i * staggerChildren : (i = 0) => maxStaggerDuration - i * staggerChildren;
5941
+ const childAnimations = Array.from(this.state.visualElement.variantChildren).map((child, index) => {
5942
+ const childDelay = delayChildren + generateStaggerDuration(index);
5943
+ return child.state.animateUpdates({
5944
+ controlActiveState,
5945
+ controlDelay: isFallback ? 0 : childDelay
5946
+ });
5947
+ }).filter(Boolean);
5948
+ return {
5949
+ getChildAnimations: () => Promise.all(childAnimations.map((animation) => {
5950
+ return animation == null ? void 0 : animation();
5951
+ })),
5952
+ childAnimations
5953
+ };
5954
+ }
5955
+ createAnimationFactories(prevTarget, animationOptions, controlDelay) {
5956
+ const factories = [];
5957
+ Object.keys(this.state.target).forEach((key) => {
5958
+ var _a;
5959
+ if (!hasChanged(prevTarget[key], this.state.target[key]))
5960
+ return;
5961
+ (_a = this.state.baseTarget)[key] ?? (_a[key] = style.get(this.state.element, key));
5962
+ const keyValue = this.state.target[key] === "none" && core.isDef(transformResetValue[key]) ? transformResetValue[key] : this.state.target[key];
5963
+ factories.push(() => {
5964
+ var _a2;
5965
+ return animate(
5966
+ this.state.element,
5967
+ { [key]: keyValue },
5968
+ {
5969
+ ...(animationOptions == null ? void 0 : animationOptions[key]) || animationOptions,
5970
+ delay: (((_a2 = animationOptions == null ? void 0 : animationOptions[key]) == null ? void 0 : _a2.delay) || (animationOptions == null ? void 0 : animationOptions.delay) || 0) + controlDelay
5971
+ }
5972
+ );
5973
+ });
5974
+ });
5975
+ return factories;
5976
+ }
5977
+ resolveStateAnimation({
5978
+ controlActiveState,
5979
+ directAnimate,
5980
+ directTransition
5981
+ }) {
5982
+ let variantTransition = this.state.options.transition;
5983
+ let variant = {};
5984
+ const { variants, custom, transition, animatePresenceContext } = this.state.options;
5985
+ const customValue = core.isDef(custom) ? custom : animatePresenceContext == null ? void 0 : animatePresenceContext.custom;
5986
+ this.state.activeStates = { ...this.state.activeStates, ...controlActiveState };
5987
+ STATE_TYPES.forEach((name) => {
5988
+ if (!this.state.activeStates[name] || isAnimationControls(this.state.options[name]))
5989
+ return;
5990
+ const definition = this.state.options[name];
5991
+ let resolvedVariant = core.isDef(definition) ? resolveVariant(definition, variants, customValue) : void 0;
5992
+ if (this.state.visualElement.isVariantNode) {
5993
+ const controlVariant = resolveVariant(this.state.context[name], variants, customValue);
5994
+ resolvedVariant = controlVariant ? Object.assign(controlVariant || {}, resolvedVariant) : variant;
5995
+ }
5996
+ if (!resolvedVariant)
5997
+ return;
5998
+ if (name !== "initial")
5999
+ variantTransition = resolvedVariant.transition || this.state.options.transition || {};
6000
+ variant = Object.assign(variant, resolvedVariant);
6001
+ });
6002
+ if (directAnimate) {
6003
+ variant = resolveVariant(directAnimate, variants, customValue);
6004
+ variantTransition = variant.transition || directTransition || transition;
6005
+ }
6006
+ Object.entries(variant).forEach(([key, value]) => {
6007
+ if (key === "transition")
6008
+ return;
6009
+ this.state.target[key] = value;
6010
+ });
6011
+ return variantTransition;
6012
+ }
6013
+ /**
6014
+ * Subscribe any provided AnimationControls to the component's VisualElement
6015
+ */
6016
+ mount() {
6017
+ this.updateAnimationControlsSubscription();
6018
+ }
6019
+ update() {
6020
+ const { animate: animate2 } = this.state.options;
6021
+ const { animate: prevAnimate } = this.state.visualElement.prevProps || {};
6022
+ if (animate2 !== prevAnimate) {
6023
+ this.updateAnimationControlsSubscription();
6024
+ }
6025
+ }
6026
+ unmount() {
6027
+ var _a;
6028
+ (_a = this.unmountControls) == null ? void 0 : _a.call(this);
6029
+ }
6030
+ }
6031
+ class FocusGesture extends Feature {
6032
+ constructor() {
6033
+ super(...arguments);
6034
+ this.isActive = false;
6035
+ }
6036
+ onFocus() {
6037
+ let isFocusVisible = false;
6038
+ try {
6039
+ isFocusVisible = this.state.element.matches(":focus-visible");
6040
+ } catch (e) {
6041
+ isFocusVisible = true;
6042
+ }
6043
+ if (!isFocusVisible)
6044
+ return;
6045
+ this.state.setActive("whileFocus", true);
6046
+ this.isActive = true;
6047
+ }
6048
+ onBlur() {
6049
+ if (!this.isActive)
6050
+ return;
6051
+ this.state.setActive("whileFocus", false);
6052
+ this.isActive = false;
6053
+ }
6054
+ mount() {
6055
+ this.unmount = pipe(
6056
+ addDomEvent$1(this.state.element, "focus", () => this.onFocus()),
6057
+ addDomEvent$1(this.state.element, "blur", () => this.onBlur())
6058
+ );
6059
+ }
6060
+ }
6061
+ const compareByDepth = (a, b) => a.depth - b.depth;
6062
+ class FlatTree {
6063
+ constructor() {
6064
+ this.children = [];
6065
+ this.isDirty = false;
6066
+ }
6067
+ add(child) {
6068
+ addUniqueItem(this.children, child);
6069
+ this.isDirty = true;
6070
+ }
6071
+ remove(child) {
6072
+ removeItem(this.children, child);
6073
+ this.isDirty = true;
6074
+ }
6075
+ forEach(callback) {
6076
+ this.isDirty && this.children.sort(compareByDepth);
6077
+ this.isDirty = false;
6078
+ this.children.forEach(callback);
6079
+ }
6080
+ }
6081
+ function resolveMotionValue(value) {
6082
+ const unwrappedValue = isMotionValue$1(value) ? value.get() : value;
6083
+ return isCustomValue(unwrappedValue) ? unwrappedValue.toValue() : unwrappedValue;
6084
+ }
6085
+ const borders = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"];
6086
+ const numBorders = borders.length;
6087
+ const asNumber = (value) => typeof value === "string" ? parseFloat(value) : value;
6088
+ const isPx = (value) => typeof value === "number" || px$1.test(value);
6089
+ function mixValues(target, follow, lead, progress2, shouldCrossfadeOpacity, isOnlyMember) {
6090
+ if (shouldCrossfadeOpacity) {
6091
+ target.opacity = mixNumber$2(
6092
+ 0,
6093
+ // TODO Reinstate this if only child
6094
+ lead.opacity !== void 0 ? lead.opacity : 1,
6095
+ easeCrossfadeIn(progress2)
5879
6096
  );
5880
6097
  target.opacityExit = mixNumber$2(follow.opacity !== void 0 ? follow.opacity : 1, 0, easeCrossfadeOut(progress2));
5881
6098
  } else if (isOnlyMember) {
@@ -7299,258 +7516,41 @@ class ProjectionFeature extends Feature {
7299
7516
  }
7300
7517
  }
7301
7518
  }
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();
7519
+ });
7400
7520
  }
7401
7521
  update() {
7402
- const { animate: animate2 } = this.state.options;
7403
- const { animate: prevAnimate } = this.state.visualElement.prevProps || {};
7404
- if (animate2 !== prevAnimate) {
7405
- this.updateAnimationControlsSubscription();
7406
- }
7522
+ this.setOptions();
7407
7523
  }
7408
- unmount() {
7524
+ mount() {
7409
7525
  var _a;
7410
- (_a = this.unmountControls) == null ? void 0 : _a.call(this);
7526
+ (_a = this.state.visualElement.projection) == null ? void 0 : _a.mount(this.state.element);
7411
7527
  }
7412
7528
  }
7529
+ const domMax = [
7530
+ AnimationFeature,
7531
+ PressGesture,
7532
+ HoverGesture,
7533
+ InViewGesture,
7534
+ FocusGesture,
7535
+ ProjectionFeature,
7536
+ PanGesture,
7537
+ DragGesture,
7538
+ LayoutFeature
7539
+ ];
7540
+ const domAnimation = [
7541
+ AnimationFeature,
7542
+ PressGesture,
7543
+ HoverGesture,
7544
+ InViewGesture,
7545
+ FocusGesture
7546
+ // ProjectionFeature,
7547
+ // DragGesture,
7548
+ // LayoutFeature,
7549
+ // PanGesture,
7550
+ ];
7413
7551
  function createVisualElement(Component, options) {
7414
7552
  return isSVGElement(Component) ? new SVGVisualElement(options) : new HTMLVisualElement(options);
7415
7553
  }
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
7503
- }
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
7521
- });
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();
7553
- }
7554
7554
  function isVariantLabels(value) {
7555
7555
  return typeof value === "string" || value === false || Array.isArray(value);
7556
7556
  }
@@ -7570,7 +7570,7 @@ class MotionState {
7570
7570
  };
7571
7571
  this.currentProcess = null;
7572
7572
  this._context = null;
7573
- this.animateUpdates = animateUpdates;
7573
+ this.animateUpdates = noop;
7574
7574
  this.id = `motion-state-${id++}`;
7575
7575
  this.options = options;
7576
7576
  this.parent = parent;
@@ -7583,9 +7583,7 @@ class MotionState {
7583
7583
  parent: parent == null ? void 0 : parent.visualElement,
7584
7584
  props: {
7585
7585
  ...this.options,
7586
- whileHover: this.options.whileHover,
7587
- whileTap: this.options.whilePress,
7588
- whileInView: this.options.whileInView
7586
+ whileTap: this.options.whilePress
7589
7587
  },
7590
7588
  visualState: {
7591
7589
  renderState: {
@@ -7630,9 +7628,7 @@ class MotionState {
7630
7628
  updateOptions() {
7631
7629
  this.visualElement.update({
7632
7630
  ...this.options,
7633
- whileHover: this.options.hover,
7634
- whileTap: this.options.press,
7635
- whileInView: this.options.inView,
7631
+ whileTap: this.options.whilePress,
7636
7632
  reducedMotionConfig: this.options.motionConfig.reduceMotion
7637
7633
  }, {
7638
7634
  isPresent: !doneCallbacks.has(this.element)
@@ -7644,6 +7640,7 @@ class MotionState {
7644
7640
  }
7645
7641
  // Mount motion state to DOM element, handles parent-child relationships
7646
7642
  mount(element, options, notAnimate = false) {
7643
+ var _a;
7647
7644
  heyListen.invariant(
7648
7645
  Boolean(element),
7649
7646
  "Animation state must be mounted with valid Element"
@@ -7662,7 +7659,7 @@ class MotionState {
7662
7659
  if (this.visualElement.type === "svg") {
7663
7660
  this.visualElement.updateDimensions();
7664
7661
  }
7665
- this.startAnimation();
7662
+ (_a = this.startAnimation) == null ? void 0 : _a.call(this);
7666
7663
  }
7667
7664
  if (this.options.layoutId) {
7668
7665
  mountedLayoutIds.add(this.options.layoutId);
@@ -7750,9 +7747,6 @@ class MotionState {
7750
7747
  isMounted() {
7751
7748
  return Boolean(this.element);
7752
7749
  }
7753
- getOptions() {
7754
- return this.options;
7755
- }
7756
7750
  // Called before layout updates to prepare for changes
7757
7751
  willUpdate(label) {
7758
7752
  var _a;
@@ -7761,292 +7755,320 @@ class MotionState {
7761
7755
  }
7762
7756
  }
7763
7757
  }
7758
+ function useMotionState(props) {
7759
+ var _a;
7760
+ const parentState = injectMotion(null);
7761
+ const layoutGroup = injectLayoutGroup({});
7762
+ const config = useMotionConfig();
7763
+ const animatePresenceContext = injectAnimatePresence({});
7764
+ const lazyMotionContext = useLazyMotionContext({
7765
+ features: vue.ref([]),
7766
+ strict: false
7767
+ });
7768
+ if (process.env.NODE_ENV !== "production" && ((_a = props.features) == null ? void 0 : _a.length) && lazyMotionContext.strict) {
7769
+ const strictMessage = "You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";
7770
+ props.ignoreStrict ? heyListen.warning(false, strictMessage) : heyListen.invariant(false, strictMessage);
7771
+ }
7772
+ const attrs = vue.useAttrs();
7773
+ function getLayoutId() {
7774
+ if (layoutGroup.id && props.layoutId)
7775
+ return `${layoutGroup.id}-${props.layoutId}`;
7776
+ return props.layoutId || void 0;
7777
+ }
7778
+ function getProps() {
7779
+ return {
7780
+ ...props,
7781
+ lazyMotionContext,
7782
+ layoutId: getLayoutId(),
7783
+ transition: props.transition ?? config.value.transition,
7784
+ layoutGroup,
7785
+ motionConfig: config.value,
7786
+ inViewOptions: props.inViewOptions ?? config.value.inViewOptions,
7787
+ animatePresenceContext,
7788
+ initial: animatePresenceContext.initial === false ? animatePresenceContext.initial : props.initial === true ? void 0 : props.initial
7789
+ };
7790
+ }
7791
+ function getMotionProps() {
7792
+ return {
7793
+ ...attrs,
7794
+ ...getProps()
7795
+ };
7796
+ }
7797
+ const state2 = new MotionState(
7798
+ getMotionProps(),
7799
+ parentState
7800
+ );
7801
+ provideMotion(state2);
7802
+ function getAttrs() {
7803
+ const isSVG = state2.visualElement.type === "svg";
7804
+ const attrsProps = { ...attrs };
7805
+ Object.keys(attrs).forEach((key) => {
7806
+ if (isMotionValue(attrs[key]))
7807
+ attrsProps[key] = attrs[key].get();
7808
+ });
7809
+ let styleProps = {
7810
+ ...props.style,
7811
+ ...isSVG ? {} : state2.visualElement.latestValues
7812
+ };
7813
+ if (isSVG) {
7814
+ const { attributes, style: style2 } = convertSvgStyleToAttributes({
7815
+ ...state2.isMounted() ? state2.target : state2.baseTarget,
7816
+ ...styleProps
7817
+ });
7818
+ Object.assign(attrsProps, attributes);
7819
+ styleProps = style2;
7820
+ }
7821
+ if (props.drag && props.dragListener !== false) {
7822
+ Object.assign(styleProps, {
7823
+ userSelect: "none",
7824
+ WebkitUserSelect: "none",
7825
+ WebkitTouchCallout: "none",
7826
+ touchAction: props.drag === true ? "none" : `pan-${props.drag === "x" ? "y" : "x"}`
7827
+ });
7828
+ }
7829
+ attrsProps.style = createStyles(styleProps);
7830
+ return attrsProps;
7831
+ }
7832
+ const instance = vue.getCurrentInstance().proxy;
7833
+ vue.onBeforeMount(() => {
7834
+ state2.beforeMount();
7835
+ });
7836
+ vue.onMounted(() => {
7837
+ state2.mount(getMotionElement(instance.$el), getMotionProps(), checkMotionIsHidden(instance));
7838
+ });
7839
+ vue.onBeforeUnmount(() => state2.beforeUnmount());
7840
+ vue.onUnmounted(() => {
7841
+ const el = getMotionElement(instance.$el);
7842
+ if (!(el == null ? void 0 : el.isConnected)) {
7843
+ state2.unmount();
7844
+ }
7845
+ });
7846
+ vue.onBeforeUpdate(() => {
7847
+ state2.beforeUpdate();
7848
+ });
7849
+ vue.onUpdated(() => {
7850
+ state2.update(getMotionProps());
7851
+ });
7852
+ return {
7853
+ getProps,
7854
+ getAttrs,
7855
+ layoutGroup,
7856
+ state: state2
7857
+ };
7858
+ }
7859
+ const MotionComponentProps = {
7860
+ "ignoreStrict": { type: Boolean },
7861
+ "forwardMotionProps": { type: Boolean, default: false },
7862
+ "asChild": { type: Boolean, default: false },
7863
+ "hover": { type: [String, Array, Object] },
7864
+ "press": { type: [String, Array, Object] },
7865
+ "inView": { type: [String, Array, Object] },
7866
+ "focus": { type: [String, Array, Object] },
7867
+ "whileDrag": { type: [String, Array, Object] },
7868
+ "whileHover": { type: [String, Array, Object], default: ({ hover }) => {
7869
+ if (process.env.NODE_ENV === "development" && hover) {
7870
+ heyListen.warning(true, "hover is deprecated. Use whileHover instead.");
7871
+ }
7872
+ return hover;
7873
+ } },
7874
+ "whilePress": { type: [String, Array, Object], default: ({ press }) => {
7875
+ if (process.env.NODE_ENV === "development" && press) {
7876
+ heyListen.warning(true, "press is deprecated. Use whilePress instead.");
7877
+ }
7878
+ return press;
7879
+ } },
7880
+ "whileInView": { type: [String, Array, Object], default: ({ inView: inView2 }) => {
7881
+ if (process.env.NODE_ENV === "development" && inView2) {
7882
+ heyListen.warning(true, "inView is deprecated. Use whileInView instead.");
7883
+ }
7884
+ return inView2;
7885
+ } },
7886
+ "whileFocus": { type: [String, Array, Object], default: ({ focus }) => {
7887
+ if (process.env.NODE_ENV === "development" && focus) {
7888
+ heyListen.warning(true, "focus is deprecated. Use whileFocus instead.");
7889
+ }
7890
+ return focus;
7891
+ } },
7892
+ "custom": { type: [String, Number, Object, Array] },
7893
+ "initial": { type: [String, Array, Object, Boolean], default: void 0 },
7894
+ "animate": { type: [String, Array, Object], default: void 0 },
7895
+ "exit": { type: [String, Array, Object] },
7896
+ "variants": { type: Object },
7897
+ "inherit": { type: Boolean },
7898
+ "style": { type: Object },
7899
+ "transformTemplate": { type: Function },
7900
+ "transition": { type: Object },
7901
+ "layoutGroup": { type: Object },
7902
+ "motionConfig": { type: Object },
7903
+ "onAnimationComplete": { type: Function },
7904
+ "onUpdate": { type: Function },
7905
+ "layout": { type: [Boolean, String], default: false },
7906
+ "layoutId": { type: String, default: void 0 },
7907
+ "layoutScroll": { type: Boolean, default: false },
7908
+ "layoutRoot": { type: Boolean, default: false },
7909
+ "data-framer-portal-id": { type: String },
7910
+ "crossfade": { type: Boolean, default: true },
7911
+ "layoutDependency": { type: [String, Number, Object, Array] },
7912
+ "onBeforeLayoutMeasure": { type: Function },
7913
+ "onLayoutMeasure": { type: Function },
7914
+ "onLayoutAnimationStart": { type: Function },
7915
+ "onLayoutAnimationComplete": { type: Function },
7916
+ "globalPressTarget": { type: Boolean },
7917
+ "onPressStart": { type: Function },
7918
+ "onPress": { type: Function },
7919
+ "onPressCancel": { type: Function },
7920
+ "onHoverStart": { type: Function },
7921
+ "onHoverEnd": { type: Function },
7922
+ "inViewOptions": { type: Object },
7923
+ "onViewportEnter": { type: Function },
7924
+ "onViewportLeave": { type: Function },
7925
+ "drag": { type: [Boolean, String] },
7926
+ "dragSnapToOrigin": { type: Boolean },
7927
+ "dragDirectionLock": { type: Boolean },
7928
+ "dragPropagation": { type: Boolean },
7929
+ "dragConstraints": { type: [Boolean, Object] },
7930
+ "dragElastic": { type: [Boolean, Number, Object], default: 0.5 },
7931
+ "dragMomentum": { type: Boolean, default: true },
7932
+ "dragTransition": { type: Object },
7933
+ "dragListener": { type: Boolean, default: true },
7934
+ "dragControls": { type: Object },
7935
+ "onDragStart": { type: Function },
7936
+ "onDragEnd": { type: Function },
7937
+ "onDrag": { type: Function },
7938
+ "onDirectionLock": { type: Function },
7939
+ "onDragTransitionEnd": { type: Function },
7940
+ "onMeasureDragConstraints": { type: Function },
7941
+ "onPanSessionStart": { type: Function },
7942
+ "onPanStart": { type: Function },
7943
+ "onPan": { type: Function },
7944
+ "onPanEnd": { type: Function },
7945
+ "onFocus": { type: Function },
7946
+ "onBlur": { type: Function }
7947
+ };
7764
7948
  function checkMotionIsHidden(instance) {
7765
7949
  var _a;
7766
7950
  const isHidden = ((_a = getMotionElement(instance.$el)) == null ? void 0 : _a.style.display) === "none";
7767
7951
  const hasTransition = instance.$.vnode.transition;
7768
7952
  return hasTransition && isHidden;
7769
7953
  }
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));
7954
+ const componentMaxCache = /* @__PURE__ */ new Map();
7955
+ const componentMiniCache = /* @__PURE__ */ new Map();
7956
+ function renderSlotFragments(fragments) {
7957
+ if (!Array.isArray(fragments))
7958
+ return [fragments];
7959
+ const result = [];
7960
+ for (const item of fragments) {
7961
+ if (Array.isArray(item))
7962
+ result.push(...item);
7963
+ else
7964
+ result.push(item);
7965
+ }
7966
+ return result;
7778
7967
  }
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;
7968
+ const SELF_CLOSING_TAGS = ["area", "img", "input"];
7969
+ function handlePrimitiveAndSlot(asTag, allAttrs, slots) {
7970
+ var _a, _b;
7971
+ if (typeof asTag === "string" && SELF_CLOSING_TAGS.includes(asTag)) {
7972
+ return vue.h(asTag, allAttrs);
7973
+ }
7974
+ if (asTag === "template") {
7975
+ if (!slots.default)
7976
+ return null;
7977
+ const childrens = renderSlotFragments(slots.default());
7978
+ const firstNonCommentChildrenIndex = childrens.findIndex((child) => child.type !== vue.Comment);
7979
+ if (firstNonCommentChildrenIndex === -1)
7980
+ return childrens;
7981
+ const firstNonCommentChildren = childrens[firstNonCommentChildrenIndex];
7982
+ (_a = firstNonCommentChildren.props) == null ? true : delete _a.ref;
7983
+ const mergedProps = firstNonCommentChildren.props ? vue.mergeProps(allAttrs, firstNonCommentChildren.props) : allAttrs;
7984
+ if (allAttrs.class && ((_b = firstNonCommentChildren.props) == null ? void 0 : _b.class))
7985
+ delete firstNonCommentChildren.props.class;
7986
+ const cloned = vue.cloneVNode(firstNonCommentChildren, mergedProps);
7987
+ for (const prop in mergedProps) {
7988
+ if (prop.startsWith("on")) {
7989
+ cloned.props || (cloned.props = {});
7990
+ cloned.props[prop] = mergedProps[prop];
7991
+ }
7992
+ }
7993
+ if (childrens.length === 1)
7994
+ return cloned;
7995
+ childrens[firstNonCommentChildrenIndex] = cloned;
7996
+ return childrens;
7997
+ }
7998
+ return null;
7999
+ }
8000
+ function createMotionComponent(component, options = {}) {
8001
+ var _a;
8002
+ const isString = typeof component === "string";
8003
+ const name = isString ? component : component.name || "";
8004
+ const componentCache = ((_a = options.features) == null ? void 0 : _a.length) > 0 ? componentMaxCache : componentMiniCache;
8005
+ if (isString && (componentCache == null ? void 0 : componentCache.has(component))) {
8006
+ return componentCache.get(component);
8007
+ }
8008
+ const motionComponent = vue.defineComponent({
8009
+ inheritAttrs: false,
8010
+ props: {
8011
+ ...MotionComponentProps,
8012
+ features: {
8013
+ type: Object,
8014
+ default: () => options.features || []
8015
+ },
8016
+ as: { type: [String, Object], default: component || "div" }
7886
8017
  },
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();
8018
+ name: name ? `motion.${name}` : "Motion",
8019
+ setup(props, { slots }) {
8020
+ const { getProps, getAttrs, state: state2 } = useMotionState(props);
8021
+ function onVnodeUpdated() {
8022
+ const el = state2.element;
8023
+ const isComponent = typeof props.as === "object";
8024
+ if ((!isComponent || props.asChild) && el) {
8025
+ const { style: style2 } = getAttrs();
8026
+ for (const [key, val] of Object.entries(style2)) {
8027
+ el.style[key] = val;
8028
+ }
8029
+ }
7941
8030
  }
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
8031
+ return () => {
8032
+ const motionProps = getProps();
8033
+ const motionAttrs = getAttrs();
8034
+ const asTag = props.asChild ? "template" : props.as;
8035
+ const allAttrs = {
8036
+ ...options.forwardMotionProps || props.forwardMotionProps ? motionProps : {},
8037
+ ...motionAttrs,
8038
+ onVnodeUpdated
8039
+ };
8040
+ const primitiveOrSlotResult = handlePrimitiveAndSlot(asTag, allAttrs, slots);
8041
+ if (primitiveOrSlotResult !== null) {
8042
+ return primitiveOrSlotResult;
8043
+ }
8044
+ return vue.h(asTag, {
8045
+ ...allAttrs
8046
+ }, slots);
7959
8047
  };
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
8048
  }
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
- };
8049
+ });
8050
+ if (isString) {
8051
+ componentCache == null ? void 0 : componentCache.set(component, motionComponent);
8005
8052
  }
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
- }
8053
+ return motionComponent;
8054
+ }
8055
+ function createMotionComponentWithFeatures(features = []) {
8056
+ return new Proxy({}, {
8057
+ get(target, prop) {
8058
+ if (prop === "create") {
8059
+ return (component, options) => createMotionComponent(component, {
8060
+ ...options,
8061
+ features
8028
8062
  });
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
- }
8063
+ }
8064
+ return createMotionComponent(prop, {
8065
+ features
8044
8066
  });
8045
- componentCache.set(prop, motionComponent);
8046
8067
  }
8047
- return motionComponent;
8048
- }
8049
- });
8068
+ });
8069
+ }
8070
+ const motion = createMotionComponentWithFeatures(domMax);
8071
+ const Motion = motion.create("div");
8050
8072
  function usePopLayout(props) {
8051
8073
  const styles = /* @__PURE__ */ new WeakMap();
8052
8074
  const config = useMotionConfig();
@@ -8103,7 +8125,7 @@ function delay(fn) {
8103
8125
  fn();
8104
8126
  });
8105
8127
  }
8106
- const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
8128
+ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
8107
8129
  ...{
8108
8130
  name: "AnimatePresence",
8109
8131
  inheritAttrs: true
@@ -8221,33 +8243,6 @@ const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
8221
8243
  };
8222
8244
  }
8223
8245
  });
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
8246
  const [useReorderContext, reorderContextProvider] = createContext("ReorderContext");
8252
8247
  function compareMin(a, b) {
8253
8248
  return a.layout.min - b.layout.min;
@@ -8307,6 +8302,8 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
8307
8302
  whileInView: {},
8308
8303
  whileFocus: {},
8309
8304
  forwardMotionProps: { type: Boolean },
8305
+ features: {},
8306
+ ignoreStrict: { type: Boolean },
8310
8307
  custom: {},
8311
8308
  initial: { type: [String, Array, Object, Boolean] },
8312
8309
  animate: {},
@@ -8320,6 +8317,7 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
8320
8317
  motionConfig: {},
8321
8318
  onAnimationComplete: {},
8322
8319
  onUpdate: {},
8320
+ onAnimationStart: {},
8323
8321
  layout: { type: [Boolean, String] },
8324
8322
  layoutId: {},
8325
8323
  layoutScroll: { type: Boolean },
@@ -8408,7 +8406,7 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
8408
8406
  };
8409
8407
  }
8410
8408
  return (_ctx, _cache) => {
8411
- return vue.openBlock(), vue.createBlock(vue.unref(_sfc_main$6), vue.normalizeProps(vue.guardReactiveProps(bindProps())), {
8409
+ return vue.openBlock(), vue.createBlock(vue.unref(Motion), vue.normalizeProps(vue.guardReactiveProps(bindProps())), {
8412
8410
  default: vue.withCtx(() => [
8413
8411
  vue.renderSlot(_ctx.$slots, "default"),
8414
8412
  vue.createTextVNode(" " + vue.toDisplayString(warning2()), 1)
@@ -8652,6 +8650,8 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
8652
8650
  whileInView: {},
8653
8651
  whileFocus: {},
8654
8652
  forwardMotionProps: { type: Boolean },
8653
+ features: {},
8654
+ ignoreStrict: { type: Boolean },
8655
8655
  custom: {},
8656
8656
  initial: { type: [String, Array, Object, Boolean], default: void 0 },
8657
8657
  animate: { default: void 0 },
@@ -8665,6 +8665,7 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
8665
8665
  motionConfig: {},
8666
8666
  onAnimationComplete: {},
8667
8667
  onUpdate: {},
8668
+ onAnimationStart: {},
8668
8669
  layoutId: { default: void 0 },
8669
8670
  layoutScroll: { type: Boolean, default: false },
8670
8671
  layoutRoot: { type: Boolean, default: false },
@@ -8743,7 +8744,7 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
8743
8744
  });
8744
8745
  const isDragging = vue.ref(false);
8745
8746
  return (_ctx, _cache) => {
8746
- return vue.openBlock(), vue.createBlock(vue.unref(_sfc_main$6), vue.mergeProps(bindProps(), {
8747
+ return vue.openBlock(), vue.createBlock(vue.unref(Motion), vue.mergeProps(bindProps(), {
8747
8748
  drag: drag.value,
8748
8749
  "drag-snap-to-origin": true,
8749
8750
  onDrag: _cache[0] || (_cache[0] = (event, gesturePoint) => {
@@ -8794,6 +8795,39 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
8794
8795
  };
8795
8796
  }
8796
8797
  });
8798
+ const LazyMotion = vue.defineComponent({
8799
+ name: "LazyMotion",
8800
+ inheritAttrs: false,
8801
+ props: {
8802
+ features: {
8803
+ type: [Object, Function],
8804
+ default: () => []
8805
+ },
8806
+ strict: {
8807
+ type: Boolean,
8808
+ default: false
8809
+ }
8810
+ },
8811
+ setup(props, { slots }) {
8812
+ const features = vue.ref(Array.isArray(props.features) ? props.features : []);
8813
+ if (!Array.isArray(props.features)) {
8814
+ const featuresPromise = typeof props.features === "function" ? props.features() : props.features;
8815
+ featuresPromise.then((feats) => {
8816
+ features.value = feats;
8817
+ });
8818
+ }
8819
+ lazyMotionContextProvider({
8820
+ features,
8821
+ strict: props.strict
8822
+ });
8823
+ return () => {
8824
+ var _a;
8825
+ return (_a = slots.default) == null ? void 0 : _a.call(slots);
8826
+ };
8827
+ }
8828
+ });
8829
+ const m = createMotionComponentWithFeatures();
8830
+ const M = m.create("div");
8797
8831
  function useForceUpdate() {
8798
8832
  const key = vue.ref(0);
8799
8833
  function forceUpdate() {
@@ -9077,10 +9111,12 @@ Object.defineProperty(exports, "useMotionValue", {
9077
9111
  enumerable: true,
9078
9112
  get: () => motionDom.motionValue
9079
9113
  });
9080
- exports.AnimatePresence = _sfc_main$5;
9114
+ exports.AnimatePresence = _sfc_main$4;
9081
9115
  exports.LayoutGroup = _sfc_main;
9082
- exports.Motion = _sfc_main$6;
9083
- exports.MotionConfig = _sfc_main$4;
9116
+ exports.LazyMotion = LazyMotion;
9117
+ exports.M = M;
9118
+ exports.Motion = Motion;
9119
+ exports.MotionConfig = _sfc_main$5;
9084
9120
  exports.Reorder = Reorder;
9085
9121
  exports.ReorderGroup = ReorderGroup;
9086
9122
  exports.ReorderItem = ReorderItem;
@@ -9102,6 +9138,8 @@ exports.cubicBezier = cubicBezier;
9102
9138
  exports.delay = delayInSeconds;
9103
9139
  exports.distance = distance;
9104
9140
  exports.distance2D = distance2D;
9141
+ exports.domAnimation = domAnimation;
9142
+ exports.domMax = domMax;
9105
9143
  exports.easeIn = easeIn;
9106
9144
  exports.easeInOut = easeInOut;
9107
9145
  exports.easeOut = easeOut;
@@ -9113,6 +9151,7 @@ exports.injectMotion = injectMotion;
9113
9151
  exports.interpolate = interpolate;
9114
9152
  exports.isMotionValue = isMotionValue;
9115
9153
  exports.keyframes = keyframes;
9154
+ exports.m = m;
9116
9155
  exports.millisecondsToSeconds = millisecondsToSeconds;
9117
9156
  exports.mirrorEasing = mirrorEasing;
9118
9157
  exports.mix = mix;