motion-v 1.0.0-alpha.4 → 1.0.0-beta.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 (91) hide show
  1. package/dist/cjs/index.js +1062 -265
  2. package/dist/es/components/animate-presence/AnimatePresence.d.ts +1 -1
  3. package/dist/es/components/animate-presence/use-pop-layout.mjs +2 -1
  4. package/dist/es/components/motion/props.d.ts +0 -6
  5. package/dist/es/components/motion/props.mjs +1 -3
  6. package/dist/es/components/motion/use-motion-state.d.ts +41 -41
  7. package/dist/es/components/motion/use-motion-state.mjs +5 -3
  8. package/dist/es/components/motion/utils.mjs +4 -2
  9. package/dist/es/components/reorder/index.d.ts +160 -160
  10. package/dist/es/components/reorder/utils.mjs +2 -1
  11. package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/animate/index.mjs +2 -1
  12. package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/animate/resolve-subjects.mjs +2 -1
  13. package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/animate/single-value.mjs +2 -1
  14. package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/animators/AcceleratedAnimation.mjs +4 -1
  15. package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/animators/BaseAnimation.mjs +2 -1
  16. package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/animators/MainThreadAnimation.mjs +2 -3
  17. package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/animators/drivers/driver-frameloop.mjs +3 -1
  18. package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/animators/utils/can-animate.mjs +1 -1
  19. package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/animators/waapi/NativeAnimation.mjs +4 -1
  20. package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/animators/waapi/animate-elements.mjs +2 -1
  21. package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/animators/waapi/animate-style.mjs +2 -1
  22. package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/animators/waapi/index.mjs +2 -9
  23. package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/generators/spring/index.mjs +2 -1
  24. package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/interfaces/motion-value.mjs +3 -1
  25. package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/interfaces/visual-element-target.mjs +3 -1
  26. package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/sequence/create.mjs +2 -1
  27. package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/easing/utils/map.mjs +1 -1
  28. package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/projection/node/create-projection-node.mjs +4 -24
  29. package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/render/VisualElement.mjs +3 -1
  30. package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/render/dom/resize/handle-element.mjs +2 -1
  31. package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/render/dom/scroll/index.mjs +1 -1
  32. package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/render/dom/scroll/observe.mjs +2 -1
  33. package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/render/dom/scroll/track.mjs +2 -1
  34. package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/render/dom/viewport/index.mjs +2 -1
  35. package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/render/svg/SVGVisualElement.mjs +2 -1
  36. package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/render/utils/KeyframesResolver.mjs +2 -1
  37. package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/render/utils/motion-values.mjs +1 -1
  38. package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/render/utils/setters.mjs +2 -1
  39. package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/utils/delay.mjs +2 -1
  40. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/animation/controls/BaseGroup.mjs +79 -0
  41. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/animation/controls/Group.mjs +9 -0
  42. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/animation/generators/utils/calc-duration.mjs +15 -0
  43. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/animation/generators/utils/create-generator-easing.mjs +17 -0
  44. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/animation/generators/utils/is-generator.mjs +6 -0
  45. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/animation/utils/get-value-transition.mjs +6 -0
  46. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/animation/waapi/NativeAnimationControls.mjs +81 -0
  47. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/animation/waapi/utils/attach-timeline.mjs +7 -0
  48. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/animation/waapi/utils/easing.mjs +37 -0
  49. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/animation/waapi/utils/linear.mjs +13 -0
  50. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/frameloop/batcher.mjs +64 -0
  51. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/frameloop/frame.mjs +10 -0
  52. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/frameloop/microtask.mjs +6 -0
  53. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/frameloop/order.mjs +17 -0
  54. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/frameloop/render-step.mjs +70 -0
  55. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/frameloop/sync-time.mjs +22 -0
  56. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/gestures/drag/state/is-active.mjs +11 -0
  57. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/gestures/hover.mjs +30 -0
  58. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/gestures/press/index.mjs +74 -0
  59. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/gestures/press/utils/is-keyboard-accessible.mjs +13 -0
  60. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/gestures/press/utils/keyboard.mjs +32 -0
  61. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/gestures/press/utils/state.mjs +4 -0
  62. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/gestures/utils/capture-pointer.mjs +12 -0
  63. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/gestures/utils/is-node-or-child.mjs +12 -0
  64. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/gestures/utils/is-primary-pointer.mjs +10 -0
  65. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/gestures/utils/setup.mjs +15 -0
  66. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/stats/buffer.mjs +7 -0
  67. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/utils/is-bezier-definition.mjs +4 -0
  68. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/utils/resolve-elements.mjs +17 -0
  69. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/utils/supports/flags.mjs +6 -0
  70. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/utils/supports/linear-easing.mjs +12 -0
  71. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/utils/supports/memo.mjs +13 -0
  72. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/utils/supports/scroll-timeline.mjs +6 -0
  73. package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/value/index.mjs +277 -0
  74. package/dist/es/external/.pnpm/motion-utils@12.5.0/external/motion-utils/dist/es/global-config.mjs +7 -0
  75. package/dist/es/features/gestures/drag/VisualElementDragControls.mjs +2 -1
  76. package/dist/es/features/gestures/hover/index.mjs +3 -1
  77. package/dist/es/features/gestures/in-view/index.mjs +2 -1
  78. package/dist/es/features/gestures/pan/PanSession.mjs +2 -1
  79. package/dist/es/features/gestures/pan/index.mjs +1 -1
  80. package/dist/es/features/gestures/press/index.mjs +3 -1
  81. package/dist/es/index.mjs +6 -1
  82. package/dist/es/state/motion-state.mjs +1 -1
  83. package/dist/es/state/style.mjs +3 -0
  84. package/dist/es/utils/use-animation-frame.mjs +2 -1
  85. package/dist/es/value/use-combine-values.mjs +3 -1
  86. package/dist/es/value/use-computed.mjs +2 -1
  87. package/dist/es/value/use-scroll.mjs +2 -1
  88. package/dist/es/value/use-spring.mjs +3 -1
  89. package/dist/es/value/use-time.mjs +2 -1
  90. package/dist/es/value/use-velocity.mjs +3 -1
  91. package/package.json +1 -1
@@ -0,0 +1,81 @@
1
+ import "../../../../../../../motion-utils@12.5.0/external/motion-utils/dist/es/errors.mjs";
2
+ import { noop } from "../../../../../../../motion-utils@12.5.0/external/motion-utils/dist/es/noop.mjs";
3
+ import { millisecondsToSeconds, secondsToMilliseconds } from "../../../../../../../motion-utils@12.5.0/external/motion-utils/dist/es/time-conversion.mjs";
4
+ import { attachTimeline } from "./utils/attach-timeline.mjs";
5
+ class NativeAnimationControls {
6
+ constructor(animation) {
7
+ this.animation = animation;
8
+ }
9
+ get duration() {
10
+ var _a, _b, _c;
11
+ const durationInMs = ((_b = (_a = this.animation) === null || _a === void 0 ? void 0 : _a.effect) === null || _b === void 0 ? void 0 : _b.getComputedTiming().duration) || ((_c = this.options) === null || _c === void 0 ? void 0 : _c.duration) || 300;
12
+ return millisecondsToSeconds(Number(durationInMs));
13
+ }
14
+ get time() {
15
+ var _a;
16
+ if (this.animation) {
17
+ return millisecondsToSeconds(((_a = this.animation) === null || _a === void 0 ? void 0 : _a.currentTime) || 0);
18
+ }
19
+ return 0;
20
+ }
21
+ set time(newTime) {
22
+ if (this.animation) {
23
+ this.animation.currentTime = secondsToMilliseconds(newTime);
24
+ }
25
+ }
26
+ get speed() {
27
+ return this.animation ? this.animation.playbackRate : 1;
28
+ }
29
+ set speed(newSpeed) {
30
+ if (this.animation) {
31
+ this.animation.playbackRate = newSpeed;
32
+ }
33
+ }
34
+ get state() {
35
+ return this.animation ? this.animation.playState : "finished";
36
+ }
37
+ get startTime() {
38
+ return this.animation ? this.animation.startTime : null;
39
+ }
40
+ get finished() {
41
+ return this.animation ? this.animation.finished : Promise.resolve();
42
+ }
43
+ play() {
44
+ this.animation && this.animation.play();
45
+ }
46
+ pause() {
47
+ this.animation && this.animation.pause();
48
+ }
49
+ stop() {
50
+ if (!this.animation || this.state === "idle" || this.state === "finished") {
51
+ return;
52
+ }
53
+ if (this.animation.commitStyles) {
54
+ this.animation.commitStyles();
55
+ }
56
+ this.cancel();
57
+ }
58
+ flatten() {
59
+ var _a, _b;
60
+ if (!this.animation || !((_a = this.options) === null || _a === void 0 ? void 0 : _a.allowFlatten))
61
+ return;
62
+ (_b = this.animation.effect) === null || _b === void 0 ? void 0 : _b.updateTiming({ easing: "linear" });
63
+ }
64
+ attachTimeline(timeline) {
65
+ if (this.animation)
66
+ attachTimeline(this.animation, timeline);
67
+ return noop;
68
+ }
69
+ complete() {
70
+ this.animation && this.animation.finish();
71
+ }
72
+ cancel() {
73
+ try {
74
+ this.animation && this.animation.cancel();
75
+ } catch (e) {
76
+ }
77
+ }
78
+ }
79
+ export {
80
+ NativeAnimationControls
81
+ };
@@ -0,0 +1,7 @@
1
+ function attachTimeline(animation, timeline) {
2
+ animation.timeline = timeline;
3
+ animation.onfinish = null;
4
+ }
5
+ export {
6
+ attachTimeline
7
+ };
@@ -0,0 +1,37 @@
1
+ import { isBezierDefinition } from "../../../utils/is-bezier-definition.mjs";
2
+ import { supportsLinearEasing } from "../../../utils/supports/linear-easing.mjs";
3
+ import { generateLinearEasing } from "./linear.mjs";
4
+ function isWaapiSupportedEasing(easing) {
5
+ return Boolean(typeof easing === "function" && supportsLinearEasing() || !easing || typeof easing === "string" && (easing in supportedWaapiEasing || supportsLinearEasing()) || isBezierDefinition(easing) || Array.isArray(easing) && easing.every(isWaapiSupportedEasing));
6
+ }
7
+ const cubicBezierAsString = ([a, b, c, d]) => `cubic-bezier(${a}, ${b}, ${c}, ${d})`;
8
+ const supportedWaapiEasing = {
9
+ linear: "linear",
10
+ ease: "ease",
11
+ easeIn: "ease-in",
12
+ easeOut: "ease-out",
13
+ easeInOut: "ease-in-out",
14
+ circIn: /* @__PURE__ */ cubicBezierAsString([0, 0.65, 0.55, 1]),
15
+ circOut: /* @__PURE__ */ cubicBezierAsString([0.55, 0, 1, 0.45]),
16
+ backIn: /* @__PURE__ */ cubicBezierAsString([0.31, 0.01, 0.66, -0.59]),
17
+ backOut: /* @__PURE__ */ cubicBezierAsString([0.33, 1.53, 0.69, 0.99])
18
+ };
19
+ function mapEasingToNativeEasing(easing, duration) {
20
+ if (!easing) {
21
+ return void 0;
22
+ } else if (typeof easing === "function" && supportsLinearEasing()) {
23
+ return generateLinearEasing(easing, duration);
24
+ } else if (isBezierDefinition(easing)) {
25
+ return cubicBezierAsString(easing);
26
+ } else if (Array.isArray(easing)) {
27
+ return easing.map((segmentEasing) => mapEasingToNativeEasing(segmentEasing, duration) || supportedWaapiEasing.easeOut);
28
+ } else {
29
+ return supportedWaapiEasing[easing];
30
+ }
31
+ }
32
+ export {
33
+ cubicBezierAsString,
34
+ isWaapiSupportedEasing,
35
+ mapEasingToNativeEasing,
36
+ supportedWaapiEasing
37
+ };
@@ -0,0 +1,13 @@
1
+ import "../../../../../../../../motion-utils@12.5.0/external/motion-utils/dist/es/errors.mjs";
2
+ import { progress } from "../../../../../../../../motion-utils@12.5.0/external/motion-utils/dist/es/progress.mjs";
3
+ const generateLinearEasing = (easing, duration, resolution = 10) => {
4
+ let points = "";
5
+ const numPoints = Math.max(Math.round(duration / resolution), 2);
6
+ for (let i = 0; i < numPoints; i++) {
7
+ points += easing(progress(0, numPoints - 1, i)) + ", ";
8
+ }
9
+ return `linear(${points.substring(0, points.length - 2)})`;
10
+ };
11
+ export {
12
+ generateLinearEasing
13
+ };
@@ -0,0 +1,64 @@
1
+ import "../../../../../../motion-utils@12.5.0/external/motion-utils/dist/es/errors.mjs";
2
+ import { stepsOrder } from "./order.mjs";
3
+ import { createRenderStep } from "./render-step.mjs";
4
+ const maxElapsed = 40;
5
+ function createRenderBatcher(scheduleNextBatch, allowKeepAlive) {
6
+ let runNextFrame = false;
7
+ let useDefaultElapsed = true;
8
+ const state = {
9
+ delta: 0,
10
+ timestamp: 0,
11
+ isProcessing: false
12
+ };
13
+ const flagRunNextFrame = () => runNextFrame = true;
14
+ const steps = stepsOrder.reduce((acc, key) => {
15
+ acc[key] = createRenderStep(flagRunNextFrame, allowKeepAlive ? key : void 0);
16
+ return acc;
17
+ }, {});
18
+ const { read, resolveKeyframes, update, preRender, render, postRender } = steps;
19
+ const processBatch = () => {
20
+ const timestamp = performance.now();
21
+ runNextFrame = false;
22
+ {
23
+ state.delta = useDefaultElapsed ? 1e3 / 60 : Math.max(Math.min(timestamp - state.timestamp, maxElapsed), 1);
24
+ }
25
+ state.timestamp = timestamp;
26
+ state.isProcessing = true;
27
+ read.process(state);
28
+ resolveKeyframes.process(state);
29
+ update.process(state);
30
+ preRender.process(state);
31
+ render.process(state);
32
+ postRender.process(state);
33
+ state.isProcessing = false;
34
+ if (runNextFrame && allowKeepAlive) {
35
+ useDefaultElapsed = false;
36
+ scheduleNextBatch(processBatch);
37
+ }
38
+ };
39
+ const wake = () => {
40
+ runNextFrame = true;
41
+ useDefaultElapsed = true;
42
+ if (!state.isProcessing) {
43
+ scheduleNextBatch(processBatch);
44
+ }
45
+ };
46
+ const schedule = stepsOrder.reduce((acc, key) => {
47
+ const step = steps[key];
48
+ acc[key] = (process, keepAlive = false, immediate = false) => {
49
+ if (!runNextFrame)
50
+ wake();
51
+ return step.schedule(process, keepAlive, immediate);
52
+ };
53
+ return acc;
54
+ }, {});
55
+ const cancel = (process) => {
56
+ for (let i = 0; i < stepsOrder.length; i++) {
57
+ steps[stepsOrder[i]].cancel(process);
58
+ }
59
+ };
60
+ return { schedule, cancel, state, steps };
61
+ }
62
+ export {
63
+ createRenderBatcher
64
+ };
@@ -0,0 +1,10 @@
1
+ import "../../../../../../motion-utils@12.5.0/external/motion-utils/dist/es/errors.mjs";
2
+ import { noop } from "../../../../../../motion-utils@12.5.0/external/motion-utils/dist/es/noop.mjs";
3
+ import { createRenderBatcher } from "./batcher.mjs";
4
+ const { schedule: frame, cancel: cancelFrame, state: frameData, steps: frameSteps } = /* @__PURE__ */ createRenderBatcher(typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame : noop, true);
5
+ export {
6
+ cancelFrame,
7
+ frame,
8
+ frameData,
9
+ frameSteps
10
+ };
@@ -0,0 +1,6 @@
1
+ import { createRenderBatcher } from "./batcher.mjs";
2
+ const { schedule: microtask, cancel: cancelMicrotask } = /* @__PURE__ */ createRenderBatcher(queueMicrotask, false);
3
+ export {
4
+ cancelMicrotask,
5
+ microtask
6
+ };
@@ -0,0 +1,17 @@
1
+ const stepsOrder = [
2
+ "read",
3
+ // Read
4
+ "resolveKeyframes",
5
+ // Write/Read/Write/Read
6
+ "update",
7
+ // Compute
8
+ "preRender",
9
+ // Compute
10
+ "render",
11
+ // Write
12
+ "postRender"
13
+ // Compute
14
+ ];
15
+ export {
16
+ stepsOrder
17
+ };
@@ -0,0 +1,70 @@
1
+ import { statsBuffer } from "../stats/buffer.mjs";
2
+ function createRenderStep(runNextFrame, stepName) {
3
+ let thisFrame = /* @__PURE__ */ new Set();
4
+ let nextFrame = /* @__PURE__ */ new Set();
5
+ let isProcessing = false;
6
+ let flushNextFrame = false;
7
+ const toKeepAlive = /* @__PURE__ */ new WeakSet();
8
+ let latestFrameData = {
9
+ delta: 0,
10
+ timestamp: 0,
11
+ isProcessing: false
12
+ };
13
+ let numCalls = 0;
14
+ function triggerCallback(callback) {
15
+ if (toKeepAlive.has(callback)) {
16
+ step.schedule(callback);
17
+ runNextFrame();
18
+ }
19
+ numCalls++;
20
+ callback(latestFrameData);
21
+ }
22
+ const step = {
23
+ /**
24
+ * Schedule a process to run on the next frame.
25
+ */
26
+ schedule: (callback, keepAlive = false, immediate = false) => {
27
+ const addToCurrentFrame = immediate && isProcessing;
28
+ const queue = addToCurrentFrame ? thisFrame : nextFrame;
29
+ if (keepAlive)
30
+ toKeepAlive.add(callback);
31
+ if (!queue.has(callback))
32
+ queue.add(callback);
33
+ return callback;
34
+ },
35
+ /**
36
+ * Cancel the provided callback from running on the next frame.
37
+ */
38
+ cancel: (callback) => {
39
+ nextFrame.delete(callback);
40
+ toKeepAlive.delete(callback);
41
+ },
42
+ /**
43
+ * Execute all schedule callbacks.
44
+ */
45
+ process: (frameData) => {
46
+ latestFrameData = frameData;
47
+ if (isProcessing) {
48
+ flushNextFrame = true;
49
+ return;
50
+ }
51
+ isProcessing = true;
52
+ [thisFrame, nextFrame] = [nextFrame, thisFrame];
53
+ thisFrame.forEach(triggerCallback);
54
+ if (stepName && statsBuffer.value) {
55
+ statsBuffer.value.frameloop[stepName].push(numCalls);
56
+ }
57
+ numCalls = 0;
58
+ thisFrame.clear();
59
+ isProcessing = false;
60
+ if (flushNextFrame) {
61
+ flushNextFrame = false;
62
+ step.process(frameData);
63
+ }
64
+ }
65
+ };
66
+ return step;
67
+ }
68
+ export {
69
+ createRenderStep
70
+ };
@@ -0,0 +1,22 @@
1
+ import "../../../../../../motion-utils@12.5.0/external/motion-utils/dist/es/errors.mjs";
2
+ import { MotionGlobalConfig } from "../../../../../../motion-utils@12.5.0/external/motion-utils/dist/es/global-config.mjs";
3
+ import { frameData } from "./frame.mjs";
4
+ let now;
5
+ function clearTime() {
6
+ now = void 0;
7
+ }
8
+ const time = {
9
+ now: () => {
10
+ if (now === void 0) {
11
+ time.set(frameData.isProcessing || MotionGlobalConfig.useManualTiming ? frameData.timestamp : performance.now());
12
+ }
13
+ return now;
14
+ },
15
+ set: (newTime) => {
16
+ now = newTime;
17
+ queueMicrotask(clearTime);
18
+ }
19
+ };
20
+ export {
21
+ time
22
+ };
@@ -0,0 +1,11 @@
1
+ const isDragging = {
2
+ x: false,
3
+ y: false
4
+ };
5
+ function isDragActive() {
6
+ return isDragging.y;
7
+ }
8
+ export {
9
+ isDragActive,
10
+ isDragging
11
+ };
@@ -0,0 +1,30 @@
1
+ import { isDragActive } from "./drag/state/is-active.mjs";
2
+ import { setupGesture } from "./utils/setup.mjs";
3
+ function isValidHover(event) {
4
+ return !(event.pointerType === "touch" || isDragActive());
5
+ }
6
+ function hover(elementOrSelector, onHoverStart, options = {}) {
7
+ const [elements, eventOptions, cancel] = setupGesture(elementOrSelector, options);
8
+ const onPointerEnter = (enterEvent) => {
9
+ if (!isValidHover(enterEvent))
10
+ return;
11
+ const { target } = enterEvent;
12
+ const onHoverEnd = onHoverStart(target, enterEvent);
13
+ if (typeof onHoverEnd !== "function" || !target)
14
+ return;
15
+ const onPointerLeave = (leaveEvent) => {
16
+ if (!isValidHover(leaveEvent))
17
+ return;
18
+ onHoverEnd(leaveEvent);
19
+ target.removeEventListener("pointerleave", onPointerLeave);
20
+ };
21
+ target.addEventListener("pointerleave", onPointerLeave, eventOptions);
22
+ };
23
+ elements.forEach((element) => {
24
+ element.addEventListener("pointerenter", onPointerEnter, eventOptions);
25
+ });
26
+ return cancel;
27
+ }
28
+ export {
29
+ hover
30
+ };
@@ -0,0 +1,74 @@
1
+ import { isDragActive } from "../drag/state/is-active.mjs";
2
+ import { capturePointer } from "../utils/capture-pointer.mjs";
3
+ import { isNodeOrChild } from "../utils/is-node-or-child.mjs";
4
+ import { isPrimaryPointer } from "../utils/is-primary-pointer.mjs";
5
+ import { setupGesture } from "../utils/setup.mjs";
6
+ import { isElementKeyboardAccessible } from "./utils/is-keyboard-accessible.mjs";
7
+ import { enableKeyboardPress } from "./utils/keyboard.mjs";
8
+ import { isPressing } from "./utils/state.mjs";
9
+ function isValidPressEvent(event) {
10
+ return isPrimaryPointer(event) && !isDragActive();
11
+ }
12
+ function press(targetOrSelector, onPressStart, options = {}) {
13
+ const [targets, eventOptions, cancelEvents] = setupGesture(targetOrSelector, options);
14
+ const startPress = (startEvent) => {
15
+ const target = startEvent.currentTarget;
16
+ if (!target || !isValidPressEvent(startEvent) || isPressing.has(target))
17
+ return;
18
+ isPressing.add(target);
19
+ capturePointer(startEvent, "set");
20
+ const onPressEnd = onPressStart(target, startEvent);
21
+ const onPointerEnd = (endEvent, success) => {
22
+ target.removeEventListener("pointerup", onPointerUp);
23
+ target.removeEventListener("pointercancel", onPointerCancel);
24
+ capturePointer(endEvent, "release");
25
+ if (!isValidPressEvent(endEvent) || !isPressing.has(target)) {
26
+ return;
27
+ }
28
+ isPressing.delete(target);
29
+ if (typeof onPressEnd === "function") {
30
+ onPressEnd(endEvent, { success });
31
+ }
32
+ };
33
+ const onPointerUp = (upEvent) => {
34
+ const isOutside = !upEvent.isTrusted ? false : checkOutside(upEvent, target instanceof Element ? target.getBoundingClientRect() : {
35
+ left: 0,
36
+ top: 0,
37
+ right: window.innerWidth,
38
+ bottom: window.innerHeight
39
+ });
40
+ if (isOutside) {
41
+ onPointerEnd(upEvent, false);
42
+ } else {
43
+ onPointerEnd(upEvent, !(target instanceof Element) || isNodeOrChild(target, upEvent.target));
44
+ }
45
+ };
46
+ const onPointerCancel = (cancelEvent) => {
47
+ onPointerEnd(cancelEvent, false);
48
+ };
49
+ target.addEventListener("pointerup", onPointerUp, eventOptions);
50
+ target.addEventListener("pointercancel", onPointerCancel, eventOptions);
51
+ target.addEventListener("lostpointercapture", onPointerCancel, eventOptions);
52
+ };
53
+ targets.forEach((target) => {
54
+ target = options.useGlobalTarget ? window : target;
55
+ let canAddKeyboardAccessibility = false;
56
+ if (target instanceof HTMLElement) {
57
+ canAddKeyboardAccessibility = true;
58
+ if (!isElementKeyboardAccessible(target) && target.getAttribute("tabindex") === null) {
59
+ target.tabIndex = 0;
60
+ }
61
+ }
62
+ target.addEventListener("pointerdown", startPress, eventOptions);
63
+ if (canAddKeyboardAccessibility) {
64
+ target.addEventListener("focus", (event) => enableKeyboardPress(event, eventOptions), eventOptions);
65
+ }
66
+ });
67
+ return cancelEvents;
68
+ }
69
+ function checkOutside(event, rect) {
70
+ return event.clientX < rect.left || event.clientX > rect.right || event.clientY < rect.top || event.clientY > rect.bottom;
71
+ }
72
+ export {
73
+ press
74
+ };
@@ -0,0 +1,13 @@
1
+ const focusableElements = /* @__PURE__ */ new Set([
2
+ "BUTTON",
3
+ "INPUT",
4
+ "SELECT",
5
+ "TEXTAREA",
6
+ "A"
7
+ ]);
8
+ function isElementKeyboardAccessible(element) {
9
+ return focusableElements.has(element.tagName) || element.tabIndex !== -1;
10
+ }
11
+ export {
12
+ isElementKeyboardAccessible
13
+ };
@@ -0,0 +1,32 @@
1
+ import { isPressing } from "./state.mjs";
2
+ function filterEvents(callback) {
3
+ return (event) => {
4
+ if (event.key !== "Enter")
5
+ return;
6
+ callback(event);
7
+ };
8
+ }
9
+ function firePointerEvent(target, type) {
10
+ target.dispatchEvent(new PointerEvent("pointer" + type, { isPrimary: true, bubbles: true }));
11
+ }
12
+ const enableKeyboardPress = (focusEvent, eventOptions) => {
13
+ const element = focusEvent.currentTarget;
14
+ if (!element)
15
+ return;
16
+ const handleKeydown = filterEvents(() => {
17
+ if (isPressing.has(element))
18
+ return;
19
+ firePointerEvent(element, "down");
20
+ const handleKeyup = filterEvents(() => {
21
+ firePointerEvent(element, "up");
22
+ });
23
+ const handleBlur = () => firePointerEvent(element, "cancel");
24
+ element.addEventListener("keyup", handleKeyup, eventOptions);
25
+ element.addEventListener("blur", handleBlur, eventOptions);
26
+ });
27
+ element.addEventListener("keydown", handleKeydown, eventOptions);
28
+ element.addEventListener("blur", () => element.removeEventListener("keydown", handleKeydown), eventOptions);
29
+ };
30
+ export {
31
+ enableKeyboardPress
32
+ };
@@ -0,0 +1,4 @@
1
+ const isPressing = /* @__PURE__ */ new WeakSet();
2
+ export {
3
+ isPressing
4
+ };
@@ -0,0 +1,12 @@
1
+ function capturePointer(event, action) {
2
+ const actionName = `${action}PointerCapture`;
3
+ if (event.target instanceof Element && actionName in event.target && event.pointerId !== void 0) {
4
+ try {
5
+ event.target[actionName](event.pointerId);
6
+ } catch (e) {
7
+ }
8
+ }
9
+ }
10
+ export {
11
+ capturePointer
12
+ };
@@ -0,0 +1,12 @@
1
+ const isNodeOrChild = (parent, child) => {
2
+ if (!child) {
3
+ return false;
4
+ } else if (parent === child) {
5
+ return true;
6
+ } else {
7
+ return isNodeOrChild(parent, child.parentElement);
8
+ }
9
+ };
10
+ export {
11
+ isNodeOrChild
12
+ };
@@ -0,0 +1,10 @@
1
+ const isPrimaryPointer = (event) => {
2
+ if (event.pointerType === "mouse") {
3
+ return typeof event.button !== "number" || event.button <= 0;
4
+ } else {
5
+ return event.isPrimary !== false;
6
+ }
7
+ };
8
+ export {
9
+ isPrimaryPointer
10
+ };
@@ -0,0 +1,15 @@
1
+ import { resolveElements } from "../../utils/resolve-elements.mjs";
2
+ function setupGesture(elementOrSelector, options) {
3
+ const elements = resolveElements(elementOrSelector);
4
+ const gestureAbortController = new AbortController();
5
+ const eventOptions = {
6
+ passive: true,
7
+ ...options,
8
+ signal: gestureAbortController.signal
9
+ };
10
+ const cancel = () => gestureAbortController.abort();
11
+ return [elements, eventOptions, cancel];
12
+ }
13
+ export {
14
+ setupGesture
15
+ };
@@ -0,0 +1,7 @@
1
+ const statsBuffer = {
2
+ value: null,
3
+ addProjectionMetrics: null
4
+ };
5
+ export {
6
+ statsBuffer
7
+ };
@@ -0,0 +1,4 @@
1
+ const isBezierDefinition = (easing) => Array.isArray(easing) && typeof easing[0] === "number";
2
+ export {
3
+ isBezierDefinition
4
+ };
@@ -0,0 +1,17 @@
1
+ function resolveElements(elementOrSelector, scope, selectorCache) {
2
+ var _a;
3
+ if (elementOrSelector instanceof EventTarget) {
4
+ return [elementOrSelector];
5
+ } else if (typeof elementOrSelector === "string") {
6
+ let root = document;
7
+ if (scope) {
8
+ root = scope.current;
9
+ }
10
+ const elements = (_a = selectorCache === null || selectorCache === void 0 ? void 0 : selectorCache[elementOrSelector]) !== null && _a !== void 0 ? _a : root.querySelectorAll(elementOrSelector);
11
+ return elements ? Array.from(elements) : [];
12
+ }
13
+ return Array.from(elementOrSelector);
14
+ }
15
+ export {
16
+ resolveElements
17
+ };
@@ -0,0 +1,6 @@
1
+ const supportsFlags = {
2
+ linearEasing: void 0
3
+ };
4
+ export {
5
+ supportsFlags
6
+ };
@@ -0,0 +1,12 @@
1
+ import { memoSupports } from "./memo.mjs";
2
+ const supportsLinearEasing = /* @__PURE__ */ memoSupports(() => {
3
+ try {
4
+ document.createElement("div").animate({ opacity: 0 }, { easing: "linear(0, 1)" });
5
+ } catch (e) {
6
+ return false;
7
+ }
8
+ return true;
9
+ }, "linearEasing");
10
+ export {
11
+ supportsLinearEasing
12
+ };
@@ -0,0 +1,13 @@
1
+ import "../../../../../../../motion-utils@12.5.0/external/motion-utils/dist/es/errors.mjs";
2
+ import { memo } from "../../../../../../../motion-utils@12.5.0/external/motion-utils/dist/es/memo.mjs";
3
+ import { supportsFlags } from "./flags.mjs";
4
+ function memoSupports(callback, supportsFlag) {
5
+ const memoized = memo(callback);
6
+ return () => {
7
+ var _a;
8
+ return (_a = supportsFlags[supportsFlag]) !== null && _a !== void 0 ? _a : memoized();
9
+ };
10
+ }
11
+ export {
12
+ memoSupports
13
+ };
@@ -0,0 +1,6 @@
1
+ import "../../../../../../../motion-utils@12.5.0/external/motion-utils/dist/es/errors.mjs";
2
+ import { memo } from "../../../../../../../motion-utils@12.5.0/external/motion-utils/dist/es/memo.mjs";
3
+ const supportsScrollTimeline = /* @__PURE__ */ memo(() => window.ScrollTimeline !== void 0);
4
+ export {
5
+ supportsScrollTimeline
6
+ };