motion-v 0.13.1-alpha.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 -966
  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 +3 -7
  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 -242
  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,375 +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
- let shouldBuildPath = false;
4589
- for (const key in keyframes2) {
4590
- if (key in SVG_STYLE_TO_ATTRIBUTES) {
4591
- if (key === "pathLength") {
4592
- shouldBuildPath = true;
4593
- }
4594
- const value = keyframes2[key];
4595
- attributes[key] = isMotionValue(value) ? value.get() : value;
4596
- } else {
4597
- styleProps[key] = keyframes2[key];
4598
- }
4599
- }
4600
- if (shouldBuildPath) {
4601
- buildSVGPath(attributes, attributes.pathLength, attributes.pathSpacing, attributes.pathOffset);
4602
- }
4603
- return {
4604
- attributes,
4605
- style: styleProps
4606
- };
4607
- }
4608
- function renderSlotFragments(children) {
4609
- if (!children)
4610
- return [];
4611
- return children.flatMap((child) => {
4612
- if (child.type === vue.Fragment)
4613
- return renderSlotFragments(child.children);
4614
- return [child];
4615
- });
4616
- }
4617
- const Slot = vue.defineComponent({
4618
- name: "PrimitiveSlot",
4619
- inheritAttrs: false,
4620
- setup(_, { attrs, slots }) {
4621
- return () => {
4622
- var _a, _b;
4623
- if (!slots.default)
4624
- return null;
4625
- const childrens = renderSlotFragments(slots.default());
4626
- const firstNonCommentChildrenIndex = childrens.findIndex((child) => child.type !== vue.Comment);
4627
- if (firstNonCommentChildrenIndex === -1)
4628
- return childrens;
4629
- const firstNonCommentChildren = childrens[firstNonCommentChildrenIndex];
4630
- (_a = firstNonCommentChildren.props) == null ? true : delete _a.ref;
4631
- const mergedProps = firstNonCommentChildren.props ? vue.mergeProps(attrs, firstNonCommentChildren.props) : attrs;
4632
- if (attrs.class && ((_b = firstNonCommentChildren.props) == null ? void 0 : _b.class))
4633
- delete firstNonCommentChildren.props.class;
4634
- const cloned = vue.cloneVNode(firstNonCommentChildren, mergedProps);
4635
- for (const prop in mergedProps) {
4636
- if (prop.startsWith("on")) {
4637
- cloned.props || (cloned.props = {});
4638
- cloned.props[prop] = mergedProps[prop];
4639
- }
4640
- }
4641
- if (childrens.length === 1)
4642
- return cloned;
4643
- childrens[firstNonCommentChildrenIndex] = cloned;
4644
- return childrens;
4645
- };
4646
- }
4647
- });
4648
- const Primitive = vue.defineComponent({
4649
- name: "Primitive",
4650
- inheritAttrs: false,
4651
- props: {
4652
- asChild: {
4653
- type: Boolean,
4654
- default: false
4655
- },
4656
- as: {
4657
- type: [String, Object],
4658
- default: "div"
4659
- },
4660
- getProps: {
4661
- type: Function,
4662
- default: () => ({})
4663
- },
4664
- getAttrs: {
4665
- type: Function,
4666
- default: () => ({})
4667
- }
4668
- },
4669
- setup(props, { attrs, slots }) {
4670
- const asTag = props.asChild ? "template" : props.as;
4671
- const SELF_CLOSING_TAGS = ["area", "img", "input"];
4672
- return () => {
4673
- const motionProps = props.getProps();
4674
- const motionAttrs = props.getAttrs();
4675
- let allAttrs = { ...motionAttrs, ...attrs };
4676
- if (typeof asTag === "string" && SELF_CLOSING_TAGS.includes(asTag))
4677
- return vue.h(asTag, allAttrs);
4678
- if (asTag !== "template") {
4679
- if (motionProps.forwardMotionProps) {
4680
- allAttrs = { ...motionProps, ...allAttrs };
4681
- }
4682
- return vue.h(props.as, allAttrs, { default: slots.default });
4683
- }
4684
- return vue.h(Slot, allAttrs, { default: slots.default });
4685
- };
4686
- }
4687
- });
4688
- class Feature {
4689
- constructor(state2) {
4690
- this.state = state2;
4691
- }
4692
- beforeMount() {
4693
- }
4694
- mount() {
4695
- }
4696
- unmount() {
4697
- }
4698
- update() {
4699
- }
4700
- beforeUpdate() {
4701
- }
4702
- beforeUnmount() {
4703
- }
4704
- }
4705
- function handleHoverEvent$1(state2, event, lifecycle) {
4706
- const props = state2.options;
4707
- if (props.whileHover) {
4708
- state2.setActive("whileHover", lifecycle === "Start");
4709
- }
4710
- const eventName = `onHover${lifecycle}`;
4711
- const callback = props[eventName];
4712
- if (callback) {
4713
- motionDom.frame.postRender(() => callback(event, extractEventInfo$1(event)));
4714
- }
4715
- }
4716
- class HoverGesture extends Feature {
4717
- isActive() {
4718
- return Boolean(this.state.getOptions().whileHover);
4719
- }
4720
- constructor(state2) {
4721
- super(state2);
4722
- }
4723
- mount() {
4724
- const element = this.state.element;
4725
- if (!element)
4726
- return;
4727
- this.unmount = motionDom.hover(
4728
- element,
4729
- (el, startEvent) => {
4730
- handleHoverEvent$1(this.state, startEvent, "Start");
4731
- return (endEvent) => {
4732
- handleHoverEvent$1(this.state, endEvent, "End");
4733
- };
4734
- }
4735
- );
4736
- }
4737
- }
4738
- function extractEventInfo$1(event) {
4739
- return {
4740
- point: {
4741
- x: event.pageX,
4742
- y: event.pageY
4743
- }
4744
- };
4745
- }
4746
- function handlePressEvent(state2, event, lifecycle) {
4747
- const props = state2.options;
4748
- if (props.whilePress) {
4749
- state2.setActive("whilePress", lifecycle === "Start");
4750
- }
4751
- const eventName = `onPress${lifecycle === "End" ? "" : lifecycle}`;
4752
- const callback = props[eventName];
4753
- if (callback) {
4754
- motionDom.frame.postRender(() => callback(event, extractEventInfo$1(event)));
4755
- }
4756
- }
4757
- class PressGesture extends Feature {
4758
- isActive() {
4759
- const { whilePress, onPress, onPressCancel, onPressStart } = this.state.options;
4760
- return Boolean(whilePress || onPress || onPressCancel || onPressStart);
4761
- }
4762
- constructor(state2) {
4763
- super(state2);
4764
- }
4765
- mount() {
4766
- this.register();
4767
- }
4768
- update() {
4769
- const preProps = this.state.visualElement.prevProps;
4770
- if (preProps.whilePress !== this.state.options.whilePress) {
4771
- this.register();
4772
- }
4773
- }
4774
- register() {
4775
- this.unmount();
4776
- if (this.isActive()) {
4777
- const element = this.state.element;
4778
- if (!element)
4779
- return;
4780
- this.unmount = motionDom.press(
4781
- element,
4782
- (el, startEvent) => {
4783
- handlePressEvent(this.state, startEvent, "Start");
4784
- return (endEvent, { success }) => handlePressEvent(
4785
- this.state,
4786
- endEvent,
4787
- success ? "End" : "Cancel"
4788
- );
4789
- },
4790
- { useGlobalTarget: this.state.options.globalPressTarget }
4791
- );
4792
- }
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
+ );
4793
4584
  }
4794
4585
  }
4795
4586
  function handleHoverEvent(state2, entry, lifecycle) {
@@ -4805,17 +4596,17 @@ function handleHoverEvent(state2, entry, lifecycle) {
4805
4596
  }
4806
4597
  class InViewGesture extends Feature {
4807
4598
  isActive() {
4808
- return Boolean(this.state.getOptions().whileInView);
4599
+ return Boolean(this.state.options.whileInView);
4809
4600
  }
4810
4601
  constructor(state2) {
4811
4602
  super(state2);
4812
4603
  }
4813
4604
  startObserver() {
4814
4605
  const element = this.state.element;
4815
- if (!element)
4606
+ if (!element || !this.isActive())
4816
4607
  return;
4817
4608
  this.unmount();
4818
- const { once, ...viewOptions } = this.state.getOptions().inViewOptions || {};
4609
+ const { once, ...viewOptions } = this.state.options.inViewOptions || {};
4819
4610
  this.unmount = inView(
4820
4611
  element,
4821
4612
  (_, entry) => {
@@ -5154,6 +4945,15 @@ function createBox() {
5154
4945
  function eachAxis$1(callback) {
5155
4946
  return [callback("x"), callback("y")];
5156
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");
5157
4957
  function isWillChangeMotionValue(value) {
5158
4958
  return Boolean(isMotionValue(value) && value.add);
5159
4959
  }
@@ -5207,15 +5007,6 @@ function measurePageBox(element, rootProjectionNode2, transformPagePoint) {
5207
5007
  }
5208
5008
  return viewportBox;
5209
5009
  }
5210
- const doneCallbacks = /* @__PURE__ */ new WeakMap();
5211
- function removeDoneCallback(element) {
5212
- const prevDoneCallback = doneCallbacks.get(element);
5213
- if (prevDoneCallback) {
5214
- element.removeEventListener("motioncomplete", prevDoneCallback);
5215
- }
5216
- doneCallbacks.delete(element);
5217
- }
5218
- const [injectAnimatePresence, provideAnimatePresence] = createContext("AnimatePresenceContext");
5219
5010
  function isPresent(visualElement) {
5220
5011
  return !doneCallbacks.has(visualElement.current);
5221
5012
  }
@@ -5845,41 +5636,463 @@ class PanGesture extends Feature {
5845
5636
  this.session && this.session.end();
5846
5637
  }
5847
5638
  }
5848
- const compareByDepth = (a, b) => a.depth - b.depth;
5849
- class FlatTree {
5850
- constructor() {
5851
- this.children = [];
5852
- 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
+ });
5853
5661
  }
5854
- add(child) {
5855
- addUniqueItem(this.children, child);
5856
- this.isDirty = true;
5662
+ mount() {
5663
+ this.features.forEach((feature) => feature.mount());
5857
5664
  }
5858
- remove(child) {
5859
- removeItem(this.children, child);
5860
- 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
+ });
5861
5670
  }
5862
- forEach(callback) {
5863
- this.isDirty && this.children.sort(compareByDepth);
5864
- this.isDirty = false;
5865
- 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());
5866
5685
  }
5867
5686
  }
5868
- function resolveMotionValue(value) {
5869
- const unwrappedValue = isMotionValue$1(value) ? value.get() : value;
5870
- return isCustomValue(unwrappedValue) ? unwrappedValue.toValue() : unwrappedValue;
5687
+ function isAnimationControls(v) {
5688
+ return v !== null && typeof v === "object" && typeof v.start === "function";
5871
5689
  }
5872
- const borders = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"];
5873
- const numBorders = borders.length;
5874
- const asNumber = (value) => typeof value === "string" ? parseFloat(value) : value;
5875
- const isPx = (value) => typeof value === "number" || px$1.test(value);
5876
- function mixValues(target, follow, lead, progress2, shouldCrossfadeOpacity, isOnlyMember) {
5877
- if (shouldCrossfadeOpacity) {
5878
- target.opacity = mixNumber$2(
5879
- 0,
5880
- // TODO Reinstate this if only child
5881
- lead.opacity !== void 0 ? lead.opacity : 1,
5882
- 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)
5883
6096
  );
5884
6097
  target.opacityExit = mixNumber$2(follow.opacity !== void 0 ? follow.opacity : 1, 0, easeCrossfadeOut(progress2));
5885
6098
  } else if (isOnlyMember) {
@@ -7303,258 +7516,41 @@ class ProjectionFeature extends Feature {
7303
7516
  }
7304
7517
  }
7305
7518
  }
7306
- });
7307
- }
7308
- update() {
7309
- this.setOptions();
7310
- }
7311
- mount() {
7312
- var _a;
7313
- (_a = this.state.visualElement.projection) == null ? void 0 : _a.mount(this.state.element);
7314
- }
7315
- }
7316
- class FocusGesture extends Feature {
7317
- constructor() {
7318
- super(...arguments);
7319
- this.isActive = false;
7320
- }
7321
- onFocus() {
7322
- let isFocusVisible = false;
7323
- try {
7324
- isFocusVisible = this.state.element.matches(":focus-visible");
7325
- } catch (e) {
7326
- isFocusVisible = true;
7327
- }
7328
- if (!isFocusVisible)
7329
- return;
7330
- this.state.setActive("whileFocus", true);
7331
- this.isActive = true;
7332
- }
7333
- onBlur() {
7334
- if (!this.isActive)
7335
- return;
7336
- this.state.setActive("whileFocus", false);
7337
- this.isActive = false;
7338
- }
7339
- mount() {
7340
- this.unmount = pipe(
7341
- addDomEvent$1(this.state.element, "focus", () => this.onFocus()),
7342
- addDomEvent$1(this.state.element, "blur", () => this.onBlur())
7343
- );
7344
- }
7345
- }
7346
- class FeatureManager {
7347
- constructor(state2) {
7348
- this.features = [];
7349
- this.features = [
7350
- new HoverGesture(state2),
7351
- new PressGesture(state2),
7352
- new InViewGesture(state2),
7353
- new LayoutFeature(state2),
7354
- new ProjectionFeature(state2),
7355
- new PanGesture(state2),
7356
- new DragGesture(state2),
7357
- new FocusGesture(state2),
7358
- new AnimationFeature(state2)
7359
- ];
7360
- }
7361
- mount() {
7362
- this.features.forEach((feature) => feature.mount());
7363
- }
7364
- beforeMount() {
7365
- this.features.forEach((feature) => {
7366
- var _a;
7367
- return (_a = feature.beforeMount) == null ? void 0 : _a.call(feature);
7368
- });
7369
- }
7370
- unmount() {
7371
- this.features.forEach((feature) => feature.unmount());
7372
- }
7373
- update() {
7374
- this.features.forEach((feature) => {
7375
- var _a;
7376
- return (_a = feature.update) == null ? void 0 : _a.call(feature);
7377
- });
7378
- }
7379
- beforeUpdate() {
7380
- this.features.forEach((feature) => feature.beforeUpdate());
7381
- }
7382
- beforeUnmount() {
7383
- this.features.forEach((feature) => feature.beforeUnmount());
7384
- }
7385
- }
7386
- function isAnimationControls(v) {
7387
- return v !== null && typeof v === "object" && typeof v.start === "function";
7388
- }
7389
- class AnimationFeature extends Feature {
7390
- constructor(state2) {
7391
- super(state2);
7392
- }
7393
- updateAnimationControlsSubscription() {
7394
- const { animate: animate2 } = this.state.options;
7395
- if (isAnimationControls(animate2)) {
7396
- this.unmountControls = animate2.subscribe(this.state);
7397
- }
7398
- }
7399
- /**
7400
- * Subscribe any provided AnimationControls to the component's VisualElement
7401
- */
7402
- mount() {
7403
- this.updateAnimationControlsSubscription();
7519
+ });
7404
7520
  }
7405
7521
  update() {
7406
- const { animate: animate2 } = this.state.options;
7407
- const { animate: prevAnimate } = this.state.visualElement.prevProps || {};
7408
- if (animate2 !== prevAnimate) {
7409
- this.updateAnimationControlsSubscription();
7410
- }
7522
+ this.setOptions();
7411
7523
  }
7412
- unmount() {
7524
+ mount() {
7413
7525
  var _a;
7414
- (_a = this.unmountControls) == null ? void 0 : _a.call(this);
7526
+ (_a = this.state.visualElement.projection) == null ? void 0 : _a.mount(this.state.element);
7415
7527
  }
7416
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
+ ];
7417
7551
  function createVisualElement(Component, options) {
7418
7552
  return isSVGElement(Component) ? new SVGVisualElement(options) : new HTMLVisualElement(options);
7419
7553
  }
7420
- function motionEvent(name, target, isExit) {
7421
- return new CustomEvent(name, { detail: { target, isExit } });
7422
- }
7423
- const STATE_TYPES = ["initial", "animate", "whileInView", "whileHover", "whilePress", "whileDrag", "whileFocus", "exit"];
7424
- function animateUpdates({
7425
- controlActiveState = void 0,
7426
- controlDelay = 0,
7427
- directAnimate,
7428
- directTransition,
7429
- isFallback = false,
7430
- isExit = false
7431
- } = {}) {
7432
- const prevTarget = this.target;
7433
- this.target = { ...this.baseTarget };
7434
- let animationOptions = {};
7435
- const transition = { ...this.options.transition };
7436
- if (directAnimate)
7437
- animationOptions = resolveDirectAnimation.call(this, directAnimate, directTransition, animationOptions);
7438
- else
7439
- animationOptions = resolveStateAnimation.call(this, controlActiveState);
7440
- const factories = createAnimationFactories.call(this, prevTarget, animationOptions, controlDelay);
7441
- const { getChildAnimations, childAnimations } = setupChildAnimations.call(this, animationOptions, this.activeStates, isFallback);
7442
- return executeAnimations.call(this, {
7443
- factories,
7444
- getChildAnimations,
7445
- childAnimations,
7446
- transition,
7447
- controlActiveState,
7448
- isExit
7449
- });
7450
- }
7451
- function resolveDirectAnimation(directAnimate, directTransition) {
7452
- var _a;
7453
- const variant = resolveVariant(directAnimate, this.options.variants, this.options.custom || ((_a = this.options.animatePresenceContext) == null ? void 0 : _a.custom));
7454
- if (!variant)
7455
- return {};
7456
- const transition = variant.transition || directTransition || this.options.transition || {};
7457
- Object.entries(variant).forEach(([key, value]) => {
7458
- if (key === "transition")
7459
- return;
7460
- this.target[key] = value;
7461
- });
7462
- return transition;
7463
- }
7464
- function resolveStateAnimation(controlActiveState) {
7465
- if (controlActiveState)
7466
- this.activeStates = { ...this.activeStates, ...controlActiveState };
7467
- let variantTransition = this.options.transition;
7468
- let variant = {};
7469
- STATE_TYPES.forEach((name) => {
7470
- if (!this.activeStates[name] || isAnimationControls(this.options[name]))
7471
- return;
7472
- const definition = this.options[name];
7473
- let resolvedVariant = core.isDef(definition) ? resolveVariant(definition, this.options.variants, this.options.custom) : void 0;
7474
- if (this.visualElement.isVariantNode) {
7475
- const controlVariant = resolveVariant(this.context[name], this.options.variants, this.options.custom);
7476
- resolvedVariant = controlVariant ? Object.assign(controlVariant || {}, resolvedVariant) : variant;
7477
- }
7478
- if (!resolvedVariant)
7479
- return;
7480
- if (name !== "initial")
7481
- variantTransition = resolvedVariant.transition || this.options.transition || {};
7482
- variant = Object.assign(variant, resolvedVariant);
7483
- });
7484
- Object.entries(variant).forEach(([key, value]) => {
7485
- if (key === "transition")
7486
- return;
7487
- this.target[key] = value;
7488
- });
7489
- return variantTransition;
7490
- }
7491
- function createAnimationFactories(prevTarget, animationOptions, controlDelay) {
7492
- const factories = [];
7493
- Object.keys(this.target).forEach((key) => {
7494
- var _a;
7495
- if (!hasChanged(prevTarget[key], this.target[key]))
7496
- return;
7497
- (_a = this.baseTarget)[key] ?? (_a[key] = style.get(this.element, key));
7498
- const keyValue = this.target[key] === "none" && core.isDef(transformResetValue[key]) ? transformResetValue[key] : this.target[key];
7499
- factories.push(() => {
7500
- var _a2;
7501
- return animate(
7502
- this.element,
7503
- { [key]: keyValue },
7504
- {
7505
- ...(animationOptions == null ? void 0 : animationOptions[key]) || animationOptions,
7506
- delay: (((_a2 = animationOptions == null ? void 0 : animationOptions[key]) == null ? void 0 : _a2.delay) || (animationOptions == null ? void 0 : animationOptions.delay) || 0) + controlDelay
7507
- }
7508
- );
7509
- });
7510
- });
7511
- return factories;
7512
- }
7513
- function setupChildAnimations(transition, controlActiveState, isFallback) {
7514
- var _a;
7515
- if (!((_a = this.visualElement.variantChildren) == null ? void 0 : _a.size) || !controlActiveState)
7516
- return { getChildAnimations: () => Promise.resolve(), childAnimations: [] };
7517
- const { staggerChildren = 0, staggerDirection = 1, delayChildren = 0 } = transition || {};
7518
- const maxStaggerDuration = (this.visualElement.variantChildren.size - 1) * staggerChildren;
7519
- const generateStaggerDuration = staggerDirection === 1 ? (i = 0) => i * staggerChildren : (i = 0) => maxStaggerDuration - i * staggerChildren;
7520
- const childAnimations = Array.from(this.visualElement.variantChildren).map((child, index) => {
7521
- const childDelay = delayChildren + generateStaggerDuration(index);
7522
- return child.state.animateUpdates({
7523
- controlActiveState,
7524
- controlDelay: isFallback ? 0 : childDelay
7525
- });
7526
- }).filter(Boolean);
7527
- return {
7528
- getChildAnimations: () => Promise.all(childAnimations.map((animation) => {
7529
- return animation == null ? void 0 : animation();
7530
- })),
7531
- childAnimations
7532
- };
7533
- }
7534
- function executeAnimations({
7535
- factories,
7536
- getChildAnimations,
7537
- childAnimations,
7538
- transition,
7539
- controlActiveState,
7540
- isExit = false
7541
- }) {
7542
- const getAnimation = () => Promise.all(factories.map((factory) => factory()).filter(Boolean));
7543
- const animationTarget2 = { ...this.target };
7544
- const element = this.element;
7545
- const finishAnimation2 = (animationPromise) => {
7546
- element.dispatchEvent(motionEvent("motionstart", animationTarget2));
7547
- animationPromise.then(() => {
7548
- element.dispatchEvent(motionEvent("motioncomplete", animationTarget2, isExit));
7549
- }).catch(noop);
7550
- };
7551
- const getAnimationPromise = () => {
7552
- const animationPromise = (transition == null ? void 0 : transition.when) ? (transition.when === "beforeChildren" ? getAnimation() : getChildAnimations()).then(() => transition.when === "beforeChildren" ? getChildAnimations() : getAnimation()) : Promise.all([getAnimation(), getChildAnimations()]);
7553
- finishAnimation2(animationPromise);
7554
- return animationPromise;
7555
- };
7556
- return controlActiveState ? getAnimationPromise : getAnimationPromise();
7557
- }
7558
7554
  function isVariantLabels(value) {
7559
7555
  return typeof value === "string" || value === false || Array.isArray(value);
7560
7556
  }
@@ -7574,7 +7570,7 @@ class MotionState {
7574
7570
  };
7575
7571
  this.currentProcess = null;
7576
7572
  this._context = null;
7577
- this.animateUpdates = animateUpdates;
7573
+ this.animateUpdates = noop;
7578
7574
  this.id = `motion-state-${id++}`;
7579
7575
  this.options = options;
7580
7576
  this.parent = parent;
@@ -7587,9 +7583,7 @@ class MotionState {
7587
7583
  parent: parent == null ? void 0 : parent.visualElement,
7588
7584
  props: {
7589
7585
  ...this.options,
7590
- whileHover: this.options.whileHover,
7591
- whileTap: this.options.whilePress,
7592
- whileInView: this.options.whileInView
7586
+ whileTap: this.options.whilePress
7593
7587
  },
7594
7588
  visualState: {
7595
7589
  renderState: {
@@ -7634,9 +7628,7 @@ class MotionState {
7634
7628
  updateOptions() {
7635
7629
  this.visualElement.update({
7636
7630
  ...this.options,
7637
- whileHover: this.options.hover,
7638
- whileTap: this.options.press,
7639
- whileInView: this.options.inView,
7631
+ whileTap: this.options.whilePress,
7640
7632
  reducedMotionConfig: this.options.motionConfig.reduceMotion
7641
7633
  }, {
7642
7634
  isPresent: !doneCallbacks.has(this.element)
@@ -7648,6 +7640,7 @@ class MotionState {
7648
7640
  }
7649
7641
  // Mount motion state to DOM element, handles parent-child relationships
7650
7642
  mount(element, options, notAnimate = false) {
7643
+ var _a;
7651
7644
  heyListen.invariant(
7652
7645
  Boolean(element),
7653
7646
  "Animation state must be mounted with valid Element"
@@ -7666,7 +7659,7 @@ class MotionState {
7666
7659
  if (this.visualElement.type === "svg") {
7667
7660
  this.visualElement.updateDimensions();
7668
7661
  }
7669
- this.startAnimation();
7662
+ (_a = this.startAnimation) == null ? void 0 : _a.call(this);
7670
7663
  }
7671
7664
  if (this.options.layoutId) {
7672
7665
  mountedLayoutIds.add(this.options.layoutId);
@@ -7754,9 +7747,6 @@ class MotionState {
7754
7747
  isMounted() {
7755
7748
  return Boolean(this.element);
7756
7749
  }
7757
- getOptions() {
7758
- return this.options;
7759
- }
7760
7750
  // Called before layout updates to prepare for changes
7761
7751
  willUpdate(label) {
7762
7752
  var _a;
@@ -7765,293 +7755,320 @@ class MotionState {
7765
7755
  }
7766
7756
  }
7767
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
+ };
7768
7948
  function checkMotionIsHidden(instance) {
7769
7949
  var _a;
7770
7950
  const isHidden = ((_a = getMotionElement(instance.$el)) == null ? void 0 : _a.style.display) === "none";
7771
7951
  const hasTransition = instance.$.vnode.transition;
7772
7952
  return hasTransition && isHidden;
7773
7953
  }
7774
- const defaultConfig = {
7775
- reduceMotion: "never",
7776
- transition: void 0,
7777
- nonce: void 0
7778
- };
7779
- const [injectMotionConfig, provideMotionConfig] = createContext("MotionConfig");
7780
- function useMotionConfig() {
7781
- 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;
7782
7967
  }
7783
- const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
7784
- ...{
7785
- name: "Motion",
7786
- inheritAttrs: false
7787
- },
7788
- __name: "Motion",
7789
- props: /* @__PURE__ */ vue.mergeDefaults({
7790
- as: {},
7791
- asChild: { type: Boolean },
7792
- hover: {},
7793
- press: {},
7794
- inView: {},
7795
- focus: {},
7796
- whileDrag: {},
7797
- whileHover: {},
7798
- whilePress: {},
7799
- whileInView: {},
7800
- whileFocus: {},
7801
- forwardMotionProps: { type: Boolean },
7802
- custom: {},
7803
- initial: { type: [String, Array, Object, Boolean] },
7804
- animate: {},
7805
- exit: {},
7806
- variants: {},
7807
- inherit: { type: Boolean },
7808
- style: {},
7809
- transformTemplate: { type: Function },
7810
- transition: {},
7811
- layoutGroup: {},
7812
- motionConfig: {},
7813
- onAnimationComplete: { type: Function },
7814
- onUpdate: { type: Function },
7815
- layout: { type: [Boolean, String] },
7816
- layoutId: {},
7817
- layoutScroll: { type: Boolean },
7818
- layoutRoot: { type: Boolean },
7819
- "data-framer-portal-id": {},
7820
- crossfade: { type: Boolean },
7821
- layoutDependency: {},
7822
- onBeforeLayoutMeasure: { type: Function },
7823
- onLayoutMeasure: { type: Function },
7824
- onLayoutAnimationStart: { type: Function },
7825
- onLayoutAnimationComplete: { type: Function },
7826
- globalPressTarget: { type: Boolean },
7827
- onPressStart: { type: Function },
7828
- onPress: { type: Function },
7829
- onPressCancel: { type: Function },
7830
- onHoverStart: { type: Function },
7831
- onHoverEnd: { type: Function },
7832
- inViewOptions: {},
7833
- onViewportEnter: { type: Function },
7834
- onViewportLeave: { type: Function },
7835
- drag: { type: [Boolean, String] },
7836
- dragSnapToOrigin: { type: Boolean },
7837
- dragDirectionLock: { type: Boolean },
7838
- dragPropagation: { type: Boolean },
7839
- dragConstraints: { type: [Boolean, Object] },
7840
- dragElastic: { type: [Boolean, Number, Object] },
7841
- dragMomentum: { type: Boolean },
7842
- dragTransition: {},
7843
- dragListener: { type: Boolean },
7844
- dragControls: {},
7845
- onDragStart: { type: Function },
7846
- onDragEnd: { type: Function },
7847
- onDrag: { type: Function },
7848
- onDirectionLock: { type: Function },
7849
- onDragTransitionEnd: { type: Function },
7850
- onMeasureDragConstraints: { type: Function },
7851
- onPanSessionStart: { type: Function },
7852
- onPanStart: { type: Function },
7853
- onPan: { type: Function },
7854
- onPanEnd: { type: Function },
7855
- onFocus: { type: Function },
7856
- onBlur: { type: Function }
7857
- }, {
7858
- as: "div",
7859
- asChild: false,
7860
- initial: void 0,
7861
- animate: void 0,
7862
- hover: void 0,
7863
- inView: void 0,
7864
- layout: false,
7865
- layoutId: void 0,
7866
- layoutScroll: false,
7867
- layoutRoot: false,
7868
- dragListener: true,
7869
- dragElastic: 0.5,
7870
- dragMomentum: true,
7871
- whileDrag: void 0,
7872
- crossfade: true,
7873
- whileHover: ({ hover }) => {
7874
- if (process.env.NODE_ENV === "development" && hover) {
7875
- vue.warn("hover is deprecated. Use whileHover instead.");
7876
- }
7877
- return hover;
7878
- },
7879
- whilePress: ({ press }) => {
7880
- if (process.env.NODE_ENV === "development" && press) {
7881
- vue.warn("press is deprecated. Use whilePress instead.");
7882
- }
7883
- return press;
7884
- },
7885
- whileInView: ({ inView: inView2 }) => {
7886
- if (process.env.NODE_ENV === "development" && inView2) {
7887
- vue.warn("inView is deprecated. Use whileInView instead.");
7888
- }
7889
- 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" }
7890
8017
  },
7891
- whileFocus: ({ focus }) => {
7892
- if (process.env.NODE_ENV === "development" && focus) {
7893
- vue.warn("focus is deprecated. Use whileFocus instead.");
7894
- }
7895
- return focus;
7896
- }
7897
- }),
7898
- setup(__props) {
7899
- const props = __props;
7900
- const animatePresenceContext = injectAnimatePresence({});
7901
- const parentState = injectMotion(null);
7902
- const attrs = vue.useAttrs();
7903
- const layoutGroup = injectLayoutGroup({});
7904
- const config = useMotionConfig();
7905
- function getLayoutId() {
7906
- if (layoutGroup.id && props.layoutId)
7907
- return `${layoutGroup.id}-${props.layoutId}`;
7908
- return props.layoutId || void 0;
7909
- }
7910
- function getProps() {
7911
- return {
7912
- ...props,
7913
- layoutId: getLayoutId(),
7914
- transition: props.transition ?? config.value.transition,
7915
- layoutGroup,
7916
- motionConfig: config.value,
7917
- inViewOptions: props.inViewOptions ?? config.value.inViewOptions,
7918
- animatePresenceContext,
7919
- initial: animatePresenceContext.initial === false ? animatePresenceContext.initial : props.initial === true ? void 0 : props.initial
7920
- };
7921
- }
7922
- function getMotionProps() {
7923
- return {
7924
- ...attrs,
7925
- ...getProps()
7926
- };
7927
- }
7928
- const state2 = new MotionState(
7929
- getMotionProps(),
7930
- parentState
7931
- );
7932
- provideMotion(state2);
7933
- const instance = vue.getCurrentInstance().proxy;
7934
- vue.onBeforeMount(() => {
7935
- state2.beforeMount();
7936
- });
7937
- vue.onMounted(() => {
7938
- state2.mount(getMotionElement(instance.$el), getMotionProps(), checkMotionIsHidden(instance));
7939
- });
7940
- vue.onBeforeUnmount(() => state2.beforeUnmount());
7941
- vue.onUnmounted(() => {
7942
- const el = getMotionElement(instance.$el);
7943
- if (!(el == null ? void 0 : el.isConnected)) {
7944
- 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
+ }
7945
8030
  }
7946
- });
7947
- vue.onBeforeUpdate(() => {
7948
- state2.beforeUpdate();
7949
- });
7950
- vue.onUpdated(() => {
7951
- state2.update(getMotionProps());
7952
- });
7953
- function getAttrs() {
7954
- const isSVG = state2.visualElement.type === "svg";
7955
- const attrsProps = { ...attrs };
7956
- Object.keys(attrs).forEach((key) => {
7957
- if (isMotionValue(attrs[key]))
7958
- attrsProps[key] = attrs[key].get();
7959
- });
7960
- let styleProps = {
7961
- ...props.style,
7962
- ...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);
7963
8047
  };
7964
- if (isSVG) {
7965
- const { attributes, style: style2 } = convertSvgStyleToAttributes({
7966
- ...state2.isMounted() ? state2.target : state2.baseTarget,
7967
- ...styleProps
7968
- });
7969
- Object.assign(attrsProps, attributes);
7970
- styleProps = style2;
7971
- }
7972
- if (props.drag && props.dragListener !== false) {
7973
- Object.assign(styleProps, {
7974
- userSelect: "none",
7975
- WebkitUserSelect: "none",
7976
- WebkitTouchCallout: "none",
7977
- touchAction: props.drag === true ? "none" : `pan-${props.drag === "x" ? "y" : "x"}`
7978
- });
7979
- }
7980
- styleProps = createStyles(styleProps);
7981
- attrsProps.style = styleProps;
7982
- return attrsProps;
7983
- }
7984
- const PrimitiveRef = vue.ref();
7985
- function onMotionComplete(e) {
7986
- var _a, _b;
7987
- if (props.asChild) {
7988
- (_a = PrimitiveRef.value) == null ? void 0 : _a.$forceUpdate();
7989
- }
7990
- (_b = attrs.onMotioncomplete) == null ? void 0 : _b.call(attrs, e);
7991
8048
  }
7992
- return (_ctx, _cache) => {
7993
- var _a;
7994
- return vue.openBlock(), vue.createBlock(vue.unref(Primitive), {
7995
- ref_key: "PrimitiveRef",
7996
- ref: PrimitiveRef,
7997
- "get-props": getProps,
7998
- "get-attrs": getAttrs,
7999
- as: _ctx.as,
8000
- "as-child": _ctx.asChild,
8001
- "data-motion-group": ((_a = vue.unref(layoutGroup).key) == null ? void 0 : _a.value) || void 0,
8002
- onMotioncomplete: onMotionComplete
8003
- }, {
8004
- default: vue.withCtx(() => [
8005
- vue.renderSlot(_ctx.$slots, "default")
8006
- ]),
8007
- _: 3
8008
- }, 8, ["as", "as-child", "data-motion-group"]);
8009
- };
8049
+ });
8050
+ if (isString) {
8051
+ componentCache == null ? void 0 : componentCache.set(component, motionComponent);
8010
8052
  }
8011
- });
8012
- const componentCache = /* @__PURE__ */ new Map();
8013
- const motion = new Proxy(_sfc_main$6, {
8014
- get(target, prop) {
8015
- if (typeof prop === "symbol")
8016
- return target[prop];
8017
- let motionComponent = componentCache.get(prop);
8018
- if (prop === "create") {
8019
- return (component, { forwardMotionProps = false } = {}) => {
8020
- return vue.defineComponent({
8021
- inheritAttrs: false,
8022
- name: `motion.${component.$name}`,
8023
- setup(_, { attrs, slots }) {
8024
- return () => {
8025
- return vue.h(_sfc_main$6, {
8026
- ...attrs,
8027
- forwardMotionProps,
8028
- as: component,
8029
- asChild: false
8030
- }, slots);
8031
- };
8032
- }
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
8033
8062
  });
8034
- };
8035
- }
8036
- if (!motionComponent) {
8037
- motionComponent = vue.defineComponent({
8038
- inheritAttrs: false,
8039
- name: `motion.${prop}`,
8040
- setup(_, { attrs, slots }) {
8041
- return () => {
8042
- return vue.h(_sfc_main$6, {
8043
- ...attrs,
8044
- as: prop,
8045
- asChild: false
8046
- }, slots);
8047
- };
8048
- }
8063
+ }
8064
+ return createMotionComponent(prop, {
8065
+ features
8049
8066
  });
8050
- componentCache.set(prop, motionComponent);
8051
8067
  }
8052
- return motionComponent;
8053
- }
8054
- });
8068
+ });
8069
+ }
8070
+ const motion = createMotionComponentWithFeatures(domMax);
8071
+ const Motion = motion.create("div");
8055
8072
  function usePopLayout(props) {
8056
8073
  const styles = /* @__PURE__ */ new WeakMap();
8057
8074
  const config = useMotionConfig();
@@ -8108,7 +8125,7 @@ function delay(fn) {
8108
8125
  fn();
8109
8126
  });
8110
8127
  }
8111
- const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
8128
+ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
8112
8129
  ...{
8113
8130
  name: "AnimatePresence",
8114
8131
  inheritAttrs: true
@@ -8226,33 +8243,6 @@ const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
8226
8243
  };
8227
8244
  }
8228
8245
  });
8229
- const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
8230
- ...{
8231
- name: "MotionConfig",
8232
- inheritAttrs: false
8233
- },
8234
- __name: "MotionConfig",
8235
- props: {
8236
- transition: {},
8237
- reduceMotion: { default: defaultConfig.reduceMotion },
8238
- nonce: {},
8239
- inViewOptions: {}
8240
- },
8241
- setup(__props) {
8242
- const props = __props;
8243
- const parentConfig = useMotionConfig();
8244
- const config = vue.computed(() => ({
8245
- transition: props.transition ?? parentConfig.value.transition,
8246
- reduceMotion: props.reduceMotion ?? parentConfig.value.reduceMotion,
8247
- nonce: props.nonce ?? parentConfig.value.nonce,
8248
- inViewOptions: props.inViewOptions ?? parentConfig.value.inViewOptions
8249
- }));
8250
- provideMotionConfig(config);
8251
- return (_ctx, _cache) => {
8252
- return vue.renderSlot(_ctx.$slots, "default");
8253
- };
8254
- }
8255
- });
8256
8246
  const [useReorderContext, reorderContextProvider] = createContext("ReorderContext");
8257
8247
  function compareMin(a, b) {
8258
8248
  return a.layout.min - b.layout.min;
@@ -8312,6 +8302,8 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
8312
8302
  whileInView: {},
8313
8303
  whileFocus: {},
8314
8304
  forwardMotionProps: { type: Boolean },
8305
+ features: {},
8306
+ ignoreStrict: { type: Boolean },
8315
8307
  custom: {},
8316
8308
  initial: { type: [String, Array, Object, Boolean] },
8317
8309
  animate: {},
@@ -8325,6 +8317,7 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
8325
8317
  motionConfig: {},
8326
8318
  onAnimationComplete: {},
8327
8319
  onUpdate: {},
8320
+ onAnimationStart: {},
8328
8321
  layout: { type: [Boolean, String] },
8329
8322
  layoutId: {},
8330
8323
  layoutScroll: { type: Boolean },
@@ -8413,7 +8406,7 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
8413
8406
  };
8414
8407
  }
8415
8408
  return (_ctx, _cache) => {
8416
- 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())), {
8417
8410
  default: vue.withCtx(() => [
8418
8411
  vue.renderSlot(_ctx.$slots, "default"),
8419
8412
  vue.createTextVNode(" " + vue.toDisplayString(warning2()), 1)
@@ -8657,6 +8650,8 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
8657
8650
  whileInView: {},
8658
8651
  whileFocus: {},
8659
8652
  forwardMotionProps: { type: Boolean },
8653
+ features: {},
8654
+ ignoreStrict: { type: Boolean },
8660
8655
  custom: {},
8661
8656
  initial: { type: [String, Array, Object, Boolean], default: void 0 },
8662
8657
  animate: { default: void 0 },
@@ -8670,6 +8665,7 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
8670
8665
  motionConfig: {},
8671
8666
  onAnimationComplete: {},
8672
8667
  onUpdate: {},
8668
+ onAnimationStart: {},
8673
8669
  layoutId: { default: void 0 },
8674
8670
  layoutScroll: { type: Boolean, default: false },
8675
8671
  layoutRoot: { type: Boolean, default: false },
@@ -8748,7 +8744,7 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
8748
8744
  });
8749
8745
  const isDragging = vue.ref(false);
8750
8746
  return (_ctx, _cache) => {
8751
- 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(), {
8752
8748
  drag: drag.value,
8753
8749
  "drag-snap-to-origin": true,
8754
8750
  onDrag: _cache[0] || (_cache[0] = (event, gesturePoint) => {
@@ -8799,6 +8795,39 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
8799
8795
  };
8800
8796
  }
8801
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");
8802
8831
  function useForceUpdate() {
8803
8832
  const key = vue.ref(0);
8804
8833
  function forceUpdate() {
@@ -9082,10 +9111,12 @@ Object.defineProperty(exports, "useMotionValue", {
9082
9111
  enumerable: true,
9083
9112
  get: () => motionDom.motionValue
9084
9113
  });
9085
- exports.AnimatePresence = _sfc_main$5;
9114
+ exports.AnimatePresence = _sfc_main$4;
9086
9115
  exports.LayoutGroup = _sfc_main;
9087
- exports.Motion = _sfc_main$6;
9088
- exports.MotionConfig = _sfc_main$4;
9116
+ exports.LazyMotion = LazyMotion;
9117
+ exports.M = M;
9118
+ exports.Motion = Motion;
9119
+ exports.MotionConfig = _sfc_main$5;
9089
9120
  exports.Reorder = Reorder;
9090
9121
  exports.ReorderGroup = ReorderGroup;
9091
9122
  exports.ReorderItem = ReorderItem;
@@ -9107,6 +9138,8 @@ exports.cubicBezier = cubicBezier;
9107
9138
  exports.delay = delayInSeconds;
9108
9139
  exports.distance = distance;
9109
9140
  exports.distance2D = distance2D;
9141
+ exports.domAnimation = domAnimation;
9142
+ exports.domMax = domMax;
9110
9143
  exports.easeIn = easeIn;
9111
9144
  exports.easeInOut = easeInOut;
9112
9145
  exports.easeOut = easeOut;
@@ -9118,6 +9151,7 @@ exports.injectMotion = injectMotion;
9118
9151
  exports.interpolate = interpolate;
9119
9152
  exports.isMotionValue = isMotionValue;
9120
9153
  exports.keyframes = keyframes;
9154
+ exports.m = m;
9121
9155
  exports.millisecondsToSeconds = millisecondsToSeconds;
9122
9156
  exports.mirrorEasing = mirrorEasing;
9123
9157
  exports.mix = mix;