motion-dom 14.9.1 → 14.10.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.
@@ -1,3 +1,6 @@
1
+ import { secondsToMilliseconds } from 'motion-utils';
2
+ import { cancelFrame, frame } from '../../frameloop/frame.mjs';
3
+ import { time } from '../../frameloop/sync-time.mjs';
1
4
  import { bindToScope } from '../../scope/active.mjs';
2
5
  import { isHTMLElement } from '../../utils/is-html-element.mjs';
3
6
  import { isDragActive } from '../drag/state/is-active.mjs';
@@ -16,6 +19,18 @@ function isValidPressEvent(event) {
16
19
  return isPrimaryPointer(event) && !isDragActive();
17
20
  }
18
21
  const claimedPointerDownEvents = new WeakSet();
22
+ /**
23
+ * Max distance in px between consecutive presses of a `count` sequence.
24
+ * Android's `ViewConfiguration` double tap slop is 100dp.
25
+ */
26
+ const sequenceSlop = 100;
27
+ /**
28
+ * Max distance in px a pointer can move during a held press (`hold`
29
+ * pending, or `repeat`). Android's `ViewConfiguration` touch slop is 8dp.
30
+ */
31
+ const holdSlop = 8;
32
+ const exceeds = (a, b, max) => Math.hypot(a.clientX - b.clientX, a.clientY - b.clientY) > max;
33
+ const preventDefault = (event) => event.preventDefault();
19
34
  /**
20
35
  * Create a press gesture.
21
36
  *
@@ -33,22 +48,110 @@ const claimedPointerDownEvents = new WeakSet();
33
48
  * to be focusable for this to work, whereas a press gesture will
34
49
  * make an element focusable by default.
35
50
  *
51
+ * `onPressStart` fires on the first pointer or key down, and can return
52
+ * a function to call when the press ends, or an object of handlers for
53
+ * this press:
54
+ *
55
+ * ```js
56
+ * press(button, () => ({
57
+ * onHold: (progress) => {},
58
+ * onComplete: (event, { success }) => {},
59
+ * }), { hold: 0.5 })
60
+ * ```
61
+ *
36
62
  * @public
37
63
  */
38
64
  function press(targetOrSelector, onPressStart, options = {}) {
39
65
  onPressStart = bindToScope(onPressStart);
40
66
  const [targets, eventOptions, cancelEvents] = setupGesture(targetOrSelector, options);
67
+ const sequences = new WeakMap();
41
68
  const startPress = (startEvent) => {
42
69
  const target = startEvent.currentTarget;
43
70
  if (!isValidPressEvent(startEvent))
44
71
  return;
45
72
  if (claimedPointerDownEvents.has(startEvent))
46
73
  return;
47
- isPressing.add(target);
48
74
  if (options.stopPropagation) {
49
75
  claimedPointerDownEvents.add(startEvent);
50
76
  }
51
- const onPressEnd = onPressStart(target, startEvent);
77
+ /**
78
+ * Options are read per press so they can be updated between presses.
79
+ */
80
+ const { count: presses = 1, countTimeout = 0.3, hold = 0, repeat, } = options;
81
+ const downTime = time.now();
82
+ const holdTime = secondsToMilliseconds(hold);
83
+ const timeout = secondsToMilliseconds(countTimeout);
84
+ let previous = sequences.get(target);
85
+ /**
86
+ * A press during a `count` sequence continues it. If it's too late
87
+ * or too far away, the sequence is cancelled and this press starts
88
+ * a new one.
89
+ */
90
+ if (previous?.expire(exceeds(previous.event, startEvent, sequenceSlop))) {
91
+ previous = undefined;
92
+ }
93
+ else if (previous) {
94
+ cancelFrame(previous.expire);
95
+ sequences.delete(target);
96
+ }
97
+ const count = previous ? previous.count + 1 : 1;
98
+ const isFinal = count >= presses;
99
+ const isHeld = isFinal && (hold || repeat);
100
+ let isActive = !hold;
101
+ let repeats = 0;
102
+ let handlers;
103
+ isPressing.add(target);
104
+ if (previous) {
105
+ handlers = previous.handlers;
106
+ }
107
+ else {
108
+ const result = onPressStart(target, startEvent);
109
+ handlers =
110
+ typeof result === "function"
111
+ ? { onComplete: result }
112
+ : result || {};
113
+ }
114
+ isFinal && isActive && handlers.onActive?.();
115
+ /**
116
+ * While held, `onHold` reports progress from 0 to 1 over `hold`,
117
+ * then over each `repeat`. Each cycle reports exactly 1 at its end,
118
+ * then 0 on the next frame.
119
+ */
120
+ const repeatTime = secondsToMilliseconds(repeat);
121
+ let length = holdTime || repeatTime;
122
+ let cycleEnd = downTime + length;
123
+ let isCycleStart = true;
124
+ const tick = () => {
125
+ if (eventOptions.signal.aborted)
126
+ return cancelFrame(tick);
127
+ let progress = Math.min(1 - (cycleEnd - time.now()) / length, 1);
128
+ /**
129
+ * The frame after a boundary reports 0, so each cycle visibly
130
+ * restarts. Boundaries are timed from `downTime`, so this
131
+ * doesn't delay the next one. If a long frame has already
132
+ * passed the next boundary, it reports 1 instead.
133
+ */
134
+ if (isCycleStart && progress < 1)
135
+ progress = 0;
136
+ isCycleStart = false;
137
+ handlers.onHold?.(progress);
138
+ if (progress < 1)
139
+ return;
140
+ if (isActive) {
141
+ handlers.onRepeat?.(++repeats);
142
+ }
143
+ else {
144
+ isActive = true;
145
+ handlers.onActive?.();
146
+ }
147
+ if (repeat) {
148
+ isCycleStart = true;
149
+ cycleEnd += length = repeatTime;
150
+ }
151
+ else {
152
+ cancelFrame(tick);
153
+ }
154
+ };
52
155
  /**
53
156
  * End listeners run in the capture phase so a descendant calling
54
157
  * stopPropagation() in its own pointerup handler can't prevent the
@@ -59,14 +162,55 @@ function press(targetOrSelector, onPressStart, options = {}) {
59
162
  const onPointerEnd = (endEvent, success) => {
60
163
  window.removeEventListener("pointerup", onPointerUp, endEventOptions);
61
164
  window.removeEventListener("pointercancel", onPointerCancel, endEventOptions);
62
- if (isPressing.has(target)) {
63
- isPressing.delete(target);
64
- }
65
- if (!isValidPressEvent(endEvent)) {
165
+ window.removeEventListener("pointermove", onPointerMove, endEventOptions);
166
+ target.removeEventListener("contextmenu", preventDefault);
167
+ cancelFrame(tick);
168
+ isPressing.delete(target);
169
+ if (!isPrimaryPointer(endEvent))
66
170
  return;
171
+ /**
172
+ * A press that ends while a drag is active is a cancel.
173
+ */
174
+ if (isDragActive())
175
+ success = false;
176
+ if (success && !isFinal) {
177
+ /**
178
+ * Wait for the next press of the sequence, and cancel the
179
+ * gesture if it doesn't arrive in time.
180
+ */
181
+ const end = time.now();
182
+ /**
183
+ * Cancels the sequence if it's `force`d, or the interval
184
+ * has passed. Runs every frame, where `force` is frame
185
+ * data, so it's checked with `=== true`.
186
+ */
187
+ const expire = (force) => {
188
+ const isAborted = eventOptions.signal.aborted;
189
+ if (isAborted ||
190
+ force === true ||
191
+ time.now() - end > timeout) {
192
+ cancelFrame(expire);
193
+ sequences.delete(target);
194
+ isAborted ||
195
+ handlers.onComplete?.(endEvent, { success: false });
196
+ return true;
197
+ }
198
+ };
199
+ sequences.set(target, {
200
+ count,
201
+ event: startEvent,
202
+ handlers,
203
+ expire,
204
+ });
205
+ frame.update(expire, true);
67
206
  }
68
- if (typeof onPressEnd === "function") {
69
- onPressEnd(endEvent, { success });
207
+ else {
208
+ /**
209
+ * Releasing before `hold` is reached is a cancel.
210
+ */
211
+ handlers.onComplete?.(endEvent, {
212
+ success: success && isActive,
213
+ });
70
214
  }
71
215
  };
72
216
  const onPointerUp = (upEvent) => {
@@ -78,8 +222,35 @@ function press(targetOrSelector, onPressStart, options = {}) {
78
222
  const onPointerCancel = (cancelEvent) => {
79
223
  onPointerEnd(cancelEvent, false);
80
224
  };
225
+ /**
226
+ * Moving during a pending long press, or a repeating press, cancels
227
+ * it, so scrolling on touch devices doesn't trigger it. A drag
228
+ * starting during a `count` sequence cancels it.
229
+ */
230
+ const onPointerMove = (moveEvent) => {
231
+ if (isPrimaryPointer(moveEvent) &&
232
+ (((repeat || !isActive) &&
233
+ exceeds(startEvent, moveEvent, holdSlop)) ||
234
+ (presses > 1 && isDragActive()))) {
235
+ onPointerCancel(moveEvent);
236
+ }
237
+ };
81
238
  window.addEventListener("pointerup", onPointerUp, endEventOptions);
82
239
  window.addEventListener("pointercancel", onPointerCancel, endEventOptions);
240
+ if (isHeld || presses > 1) {
241
+ window.addEventListener("pointermove", onPointerMove, endEventOptions);
242
+ }
243
+ if (isHeld) {
244
+ frame.update(tick, true);
245
+ /**
246
+ * Touch devices open a context menu or callout on long press,
247
+ * which would cancel the gesture.
248
+ */
249
+ target.addEventListener("contextmenu", preventDefault, {
250
+ ...eventOptions,
251
+ passive: false,
252
+ });
253
+ }
83
254
  };
84
255
  targets.forEach((target) => {
85
256
  const pointerDownTarget = options.useGlobalTarget ? window : target;
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../../../src/gestures/press/index.ts"],"sourcesContent":["import { bindToScope } from \"../../scope/active\"\nimport { isHTMLElement } from \"../../utils/is-html-element\"\nimport { ElementOrSelector } from \"../../utils/resolve-elements\"\nimport { isDragActive } from \"../drag/state/is-active\"\nimport { EventOptions } from \"../types\"\nimport { isNodeOrChild } from \"../utils/is-node-or-child\"\nimport { isPrimaryPointer } from \"../utils/is-primary-pointer\"\nimport { setupGesture } from \"../utils/setup\"\nimport { OnPressStartEvent } from \"./types\"\nimport { isElementKeyboardAccessible } from \"./utils/is-keyboard-accessible\"\nimport { enableKeyboardPress } from \"./utils/keyboard\"\nimport { isPressing } from \"./utils/state\"\n\n/**\n * Filter out events that are not primary pointer events, or are triggering\n * while a Motion gesture is active.\n */\nfunction isValidPressEvent(event: PointerEvent) {\n return isPrimaryPointer(event) && !isDragActive()\n}\n\nconst claimedPointerDownEvents = new WeakSet<Event>()\n\nexport interface PointerEventOptions extends EventOptions {\n useGlobalTarget?: boolean\n stopPropagation?: boolean\n}\n\n/**\n * Create a press gesture.\n *\n * Press is different to `\"pointerdown\"`, `\"pointerup\"` in that it\n * automatically filters out secondary pointer events like right\n * click and multitouch.\n *\n * It also adds accessibility support for keyboards, where\n * an element with a press gesture will receive focus and\n * trigger on Enter `\"keydown\"` and `\"keyup\"` events.\n *\n * This is different to a browser's `\"click\"` event, which does\n * respond to keyboards but only for the `\"click\"` itself, rather\n * than the press start and end/cancel. The element also needs\n * to be focusable for this to work, whereas a press gesture will\n * make an element focusable by default.\n *\n * @public\n */\nexport function press(\n targetOrSelector: ElementOrSelector,\n onPressStart: OnPressStartEvent,\n options: PointerEventOptions = {}\n): VoidFunction {\n onPressStart = bindToScope(onPressStart)\n\n const [targets, eventOptions, cancelEvents] = setupGesture(\n targetOrSelector,\n options\n )\n\n const startPress = (startEvent: PointerEvent) => {\n const target = startEvent.currentTarget as Element\n\n if (!isValidPressEvent(startEvent)) return\n if (claimedPointerDownEvents.has(startEvent)) return\n\n isPressing.add(target)\n\n if (options.stopPropagation) {\n claimedPointerDownEvents.add(startEvent)\n }\n\n const onPressEnd = onPressStart(target, startEvent)\n\n /**\n * End listeners run in the capture phase so a descendant calling\n * stopPropagation() in its own pointerup handler can't prevent the\n * press gesture from ending. This also keeps the gesture-end\n * ordering consistent with the drag gesture. See #2794.\n */\n const endEventOptions = { ...eventOptions, capture: true }\n\n const onPointerEnd = (endEvent: PointerEvent, success: boolean) => {\n window.removeEventListener(\n \"pointerup\",\n onPointerUp,\n endEventOptions\n )\n window.removeEventListener(\n \"pointercancel\",\n onPointerCancel,\n endEventOptions\n )\n\n if (isPressing.has(target)) {\n isPressing.delete(target)\n }\n\n if (!isValidPressEvent(endEvent)) {\n return\n }\n\n if (typeof onPressEnd === \"function\") {\n onPressEnd(endEvent, { success })\n }\n }\n\n const onPointerUp = (upEvent: PointerEvent) => {\n onPointerEnd(\n upEvent,\n (target as any) === window ||\n (target as any) === document ||\n options.useGlobalTarget ||\n isNodeOrChild(target, upEvent.target as Element)\n )\n }\n\n const onPointerCancel = (cancelEvent: PointerEvent) => {\n onPointerEnd(cancelEvent, false)\n }\n\n window.addEventListener(\"pointerup\", onPointerUp, endEventOptions)\n window.addEventListener(\n \"pointercancel\",\n onPointerCancel,\n endEventOptions\n )\n }\n\n targets.forEach((target: EventTarget) => {\n const pointerDownTarget = options.useGlobalTarget ? window : target\n pointerDownTarget.addEventListener(\n \"pointerdown\",\n startPress as EventListener,\n eventOptions\n )\n\n if (isHTMLElement(target)) {\n target.addEventListener(\n \"focus\",\n () => enableKeyboardPress(target, eventOptions),\n eventOptions\n )\n\n if (\n !isElementKeyboardAccessible(target) &&\n !target.hasAttribute(\"tabindex\")\n ) {\n target.tabIndex = 0\n }\n }\n })\n\n return cancelEvents\n}\n"],"names":[],"mappings":";;;;;;;;;;AAaA;;;AAGG;AACH,SAAS,iBAAiB,CAAC,KAAmB,EAAA;IAC1C,OAAO,gBAAgB,CA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AY;AACvB;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../../../src/gestures/press/index.ts"],"sourcesContent":["import { secondsToMilliseconds } from \"motion-utils\"\nimport { cancelFrame, frame } from \"../../frameloop/frame\"\nimport { time } from \"../../frameloop/sync-time\"\nimport { bindToScope } from \"../../scope/active\"\nimport { isHTMLElement } from \"../../utils/is-html-element\"\nimport { ElementOrSelector } from \"../../utils/resolve-elements\"\nimport { isDragActive } from \"../drag/state/is-active\"\nimport { EventOptions } from \"../types\"\nimport { isNodeOrChild } from \"../utils/is-node-or-child\"\nimport { isPrimaryPointer } from \"../utils/is-primary-pointer\"\nimport { setupGesture } from \"../utils/setup\"\nimport { OnPressStartEvent, PressHandlers, PressOptions } from \"./types\"\nimport { isElementKeyboardAccessible } from \"./utils/is-keyboard-accessible\"\nimport { enableKeyboardPress } from \"./utils/keyboard\"\nimport { isPressing } from \"./utils/state\"\n\n/**\n * Filter out events that are not primary pointer events, or are triggering\n * while a Motion gesture is active.\n */\nfunction isValidPressEvent(event: PointerEvent) {\n return isPrimaryPointer(event) && !isDragActive()\n}\n\nconst claimedPointerDownEvents = new WeakSet<Event>()\n\n/**\n * Max distance in px between consecutive presses of a `count` sequence.\n * Android's `ViewConfiguration` double tap slop is 100dp.\n */\nconst sequenceSlop = 100\n\n/**\n * Max distance in px a pointer can move during a held press (`hold`\n * pending, or `repeat`). Android's `ViewConfiguration` touch slop is 8dp.\n */\nconst holdSlop = 8\n\nconst exceeds = (a: PointerEvent, b: PointerEvent, max: number) =>\n Math.hypot(a.clientX - b.clientX, a.clientY - b.clientY) > max\n\nconst preventDefault = (event: Event) => event.preventDefault()\n\n/**\n * A `count` sequence waiting for its next press.\n */\ninterface PressSequence {\n count: number\n event: PointerEvent\n handlers: PressHandlers\n expire: (force?: unknown) => true | void\n}\n\nexport interface PointerEventOptions extends EventOptions, PressOptions {\n useGlobalTarget?: boolean\n stopPropagation?: boolean\n}\n\n/**\n * Create a press gesture.\n *\n * Press is different to `\"pointerdown\"`, `\"pointerup\"` in that it\n * automatically filters out secondary pointer events like right\n * click and multitouch.\n *\n * It also adds accessibility support for keyboards, where\n * an element with a press gesture will receive focus and\n * trigger on Enter `\"keydown\"` and `\"keyup\"` events.\n *\n * This is different to a browser's `\"click\"` event, which does\n * respond to keyboards but only for the `\"click\"` itself, rather\n * than the press start and end/cancel. The element also needs\n * to be focusable for this to work, whereas a press gesture will\n * make an element focusable by default.\n *\n * `onPressStart` fires on the first pointer or key down, and can return\n * a function to call when the press ends, or an object of handlers for\n * this press:\n *\n * ```js\n * press(button, () => ({\n * onHold: (progress) => {},\n * onComplete: (event, { success }) => {},\n * }), { hold: 0.5 })\n * ```\n *\n * @public\n */\nexport function press(\n targetOrSelector: ElementOrSelector,\n onPressStart: OnPressStartEvent,\n options: PointerEventOptions = {}\n): VoidFunction {\n onPressStart = bindToScope(onPressStart)\n\n const [targets, eventOptions, cancelEvents] = setupGesture(\n targetOrSelector,\n options\n )\n\n const sequences = new WeakMap<Element, PressSequence>()\n\n const startPress = (startEvent: PointerEvent) => {\n const target = startEvent.currentTarget as Element\n\n if (!isValidPressEvent(startEvent)) return\n if (claimedPointerDownEvents.has(startEvent)) return\n\n if (options.stopPropagation) {\n claimedPointerDownEvents.add(startEvent)\n }\n\n /**\n * Options are read per press so they can be updated between presses.\n */\n const {\n count: presses = 1,\n countTimeout = 0.3,\n hold = 0,\n repeat,\n } = options\n const downTime = time.now()\n const holdTime = secondsToMilliseconds(hold)\n const timeout = secondsToMilliseconds(countTimeout)\n let previous = sequences.get(target)\n\n /**\n * A press during a `count` sequence continues it. If it's too late\n * or too far away, the sequence is cancelled and this press starts\n * a new one.\n */\n if (\n previous?.expire(exceeds(previous.event, startEvent, sequenceSlop))\n ) {\n previous = undefined\n } else if (previous) {\n cancelFrame(previous.expire)\n sequences.delete(target)\n }\n\n const count = previous ? previous.count + 1 : 1\n const isFinal = count >= presses\n const isHeld = isFinal && (hold || repeat)\n let isActive = !hold\n let repeats = 0\n let handlers: PressHandlers\n\n isPressing.add(target)\n\n if (previous) {\n handlers = previous.handlers\n } else {\n const result = onPressStart(target, startEvent)\n handlers =\n typeof result === \"function\"\n ? { onComplete: result }\n : result || {}\n }\n\n isFinal && isActive && handlers.onActive?.()\n\n /**\n * While held, `onHold` reports progress from 0 to 1 over `hold`,\n * then over each `repeat`. Each cycle reports exactly 1 at its end,\n * then 0 on the next frame.\n */\n const repeatTime = secondsToMilliseconds(repeat!)\n let length = holdTime || repeatTime\n let cycleEnd = downTime + length\n let isCycleStart = true\n\n const tick = () => {\n if (eventOptions.signal!.aborted) return cancelFrame(tick)\n\n let progress = Math.min(1 - (cycleEnd - time.now()) / length, 1)\n\n /**\n * The frame after a boundary reports 0, so each cycle visibly\n * restarts. Boundaries are timed from `downTime`, so this\n * doesn't delay the next one. If a long frame has already\n * passed the next boundary, it reports 1 instead.\n */\n if (isCycleStart && progress < 1) progress = 0\n isCycleStart = false\n handlers.onHold?.(progress)\n\n if (progress < 1) return\n\n if (isActive) {\n handlers.onRepeat?.(++repeats)\n } else {\n isActive = true\n handlers.onActive?.()\n }\n\n if (repeat) {\n isCycleStart = true\n cycleEnd += length = repeatTime\n } else {\n cancelFrame(tick)\n }\n }\n\n /**\n * End listeners run in the capture phase so a descendant calling\n * stopPropagation() in its own pointerup handler can't prevent the\n * press gesture from ending. This also keeps the gesture-end\n * ordering consistent with the drag gesture. See #2794.\n */\n const endEventOptions = { ...eventOptions, capture: true }\n\n const onPointerEnd = (endEvent: PointerEvent, success: boolean) => {\n window.removeEventListener(\n \"pointerup\",\n onPointerUp,\n endEventOptions\n )\n window.removeEventListener(\n \"pointercancel\",\n onPointerCancel,\n endEventOptions\n )\n window.removeEventListener(\n \"pointermove\",\n onPointerMove,\n endEventOptions\n )\n target.removeEventListener(\"contextmenu\", preventDefault)\n cancelFrame(tick)\n isPressing.delete(target)\n\n if (!isPrimaryPointer(endEvent)) return\n\n /**\n * A press that ends while a drag is active is a cancel.\n */\n if (isDragActive()) success = false\n\n if (success && !isFinal) {\n /**\n * Wait for the next press of the sequence, and cancel the\n * gesture if it doesn't arrive in time.\n */\n const end = time.now()\n\n /**\n * Cancels the sequence if it's `force`d, or the interval\n * has passed. Runs every frame, where `force` is frame\n * data, so it's checked with `=== true`.\n */\n const expire = (force?: unknown) => {\n const isAborted = eventOptions.signal!.aborted\n if (\n isAborted ||\n force === true ||\n time.now() - end > timeout\n ) {\n cancelFrame(expire)\n sequences.delete(target)\n isAborted ||\n handlers.onComplete?.(endEvent, { success: false })\n return true\n }\n }\n sequences.set(target, {\n count,\n event: startEvent,\n handlers,\n expire,\n })\n frame.update(expire, true)\n } else {\n /**\n * Releasing before `hold` is reached is a cancel.\n */\n handlers.onComplete?.(endEvent, {\n success: success && isActive,\n })\n }\n }\n\n const onPointerUp = (upEvent: PointerEvent) => {\n onPointerEnd(\n upEvent,\n (target as any) === window ||\n (target as any) === document ||\n options.useGlobalTarget ||\n isNodeOrChild(target, upEvent.target as Element)\n )\n }\n\n const onPointerCancel = (cancelEvent: PointerEvent) => {\n onPointerEnd(cancelEvent, false)\n }\n\n /**\n * Moving during a pending long press, or a repeating press, cancels\n * it, so scrolling on touch devices doesn't trigger it. A drag\n * starting during a `count` sequence cancels it.\n */\n const onPointerMove = (moveEvent: PointerEvent) => {\n if (\n isPrimaryPointer(moveEvent) &&\n (((repeat || !isActive) &&\n exceeds(startEvent, moveEvent, holdSlop)) ||\n (presses > 1 && isDragActive()))\n ) {\n onPointerCancel(moveEvent)\n }\n }\n\n window.addEventListener(\"pointerup\", onPointerUp, endEventOptions)\n window.addEventListener(\n \"pointercancel\",\n onPointerCancel,\n endEventOptions\n )\n\n if (isHeld || presses > 1) {\n window.addEventListener(\n \"pointermove\",\n onPointerMove,\n endEventOptions\n )\n }\n\n if (isHeld) {\n frame.update(tick, true)\n /**\n * Touch devices open a context menu or callout on long press,\n * which would cancel the gesture.\n */\n target.addEventListener(\"contextmenu\", preventDefault, {\n ...eventOptions,\n passive: false,\n })\n }\n }\n\n targets.forEach((target: EventTarget) => {\n const pointerDownTarget = options.useGlobalTarget ? window : target\n pointerDownTarget.addEventListener(\n \"pointerdown\",\n startPress as EventListener,\n eventOptions\n )\n\n if (isHTMLElement(target)) {\n target.addEventListener(\n \"focus\",\n () => enableKeyboardPress(target, eventOptions),\n eventOptions\n )\n\n if (\n !isElementKeyboardAccessible(target) &&\n !target.hasAttribute(\"tabindex\")\n ) {\n target.tabIndex = 0\n }\n }\n })\n\n return cancelEvents\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAgBA;;;AAGG;AACH,SAAS,iBAAiB,CAAC,KAAmB,EAAA;IAC1C,OAAO,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE;AACrD;AAEA,MAAM,wBAAwB,GAAG,IAAI,OAAO,EAAS;AAErD;;;AAGG;AACH,MAAM,YAAY,GAAG,GAAG;AAExB;;;AAGG;AACH,MAAM,QAAQ,GAAG,CAAC;AAElB,MAAM,OAAO,GAAG,CAAC,CAAe,EAAE,CAAe,EAAE,GAAW,KAC1D,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,GAAG;AAElE,MAAM,cAAc,GAAG,CAAC,KAAY,KAAK,KAAK,CAAC,cAAc,EAAE;AAiB/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BG;AACG,SAAU,KAAK,CACjB,gBAAmC,EACnC,YAA+B,EAC/B,UAA+B,EAAE,EAAA;AAEjC,IAAA,YAAY,GAAG,WAAW,CAAC,YAAY,CAAC;AAExC,IAAA,MAAM,CAAC,OAAO,EAAE,YAAY,EAAE,YAAY,CAAC,GAAG,YAAY,CACtD,gBAAgB,EAChB,OAAO,CACV;AAED,IAAA,MAAM,SAAS,GAAG,IAAI,OAAO,EAA0B;AAEvD,IAAA,MAAM,UAAU,GAAG,CAAC,UAAwB,KAAI;AAC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AgB,CACnB,eAAe,EACf,eAAe,EACf,eAAe,CAClB;AAED,QAAA,IAAI,MAAM,IAAI,OAAO,GAAG,CAAC,EAAE;YACvB,MAAM,CAAC,gBAAgB,CACnB,aAAa,EACb,aAAa,EACb,eAAe,CAClB;QACL;QAEA,IAAI,MAAM,EAAE;AACR,YAAA,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC;AACxB;;;AAGG;AACH,YAAA,MAAM,CAAC,gBAAgB,CAAC,aAAa,EAAE,cAAc,EAAE;AACnD,gBAAA,GAAG,YAAY;AACf,gBAAA,OAAO,EAAE,KAAK;AACjB,aAAA,CAAC;QACN;AACJ,IAAA,CAAC;AAED,IAAA,OAAO,CAAC,OAAO,CAAC,CAAC,MAAmB,KAAI;AACpC,QAAA,MAAM,iBAAiB,GAAG,OAAO,CAAC,eAAe,GAAG,MAAM,GAAG,MAAM;QACnE,iBAAiB,CAAC,gBAAgB,CAC9B,aAAa,EACb,UAA2B,EAC3B,YAAY,CACf;AAED,QAAA,IAAI,aAAa,CAAC,MAAM,CAAC,EAAE;AACvB,YAAA,MAAM,CAAC,gBAAgB,CACnB,OAAO,EACP,MAAM,mBAAmB,CAAC,MAAM,EAAE,YAAY,CAAC,EAC/C,YAAY,CACf;AAED,YAAA,IACI,CAAC,2BAA2B,CAAC,MAAM,CAAC;AACpC,gBAAA,CAAC,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,EAClC;AACE,gBAAA,MAAM,CAAC,QAAQ,GAAG,CAAC;YACvB;QACJ;AACJ,IAAA,CAAC,CAAC;AAEF,IAAA,OAAO,YAAY;AACvB;;;;"}
@@ -21,7 +21,7 @@ const enableKeyboardPress = (element, eventOptions) => {
21
21
  */
22
22
  let isKeyPressing = false;
23
23
  const handleKeydown = filterEvents(() => {
24
- if (isPressing.has(element))
24
+ if (isKeyPressing || isPressing.has(element))
25
25
  return;
26
26
  isKeyPressing = true;
27
27
  firePointerEvent(element, "down");
@@ -1 +1 @@
1
- {"version":3,"file":"keyboard.mjs","sources":["../../../../../src/gestures/press/utils/keyboard.ts"],"sourcesContent":["import { isPressing } from \"./state\"\n\n/**\n * Filter out events that are not \"Enter\" keys.\n */\nfunction filterEvents(callback: (event: KeyboardEvent) => void) {\n return (event: KeyboardEvent) => {\n if (event.key !== \"Enter\") return\n callback(event)\n }\n}\n\nfunction firePointerEvent(target: EventTarget, type: \"down\" | \"up\" | \"cancel\") {\n target.dispatchEvent(\n new PointerEvent(\"pointer\" + type, { isPrimary: true, bubbles: true })\n )\n}\n\nexport const enableKeyboardPress = (\n element: HTMLElement,\n eventOptions: AddEventListenerOptions\n) => {\n /**\n * Listeners are scoped to this focus and all released on blur, rather\n * than added per Enter press, so they can't accumulate and fire\n * duplicate pointerup/pointercancel events. See #3935.\n */\n let isKeyPressing = false\n\n const handleKeydown = filterEvents(() => {\n if (isPressing.has(element)) return\n isKeyPressing = true\n firePointerEvent(element, \"down\")\n })\n\n const handleKeyup = filterEvents(() => {\n if (!isKeyPressing) return\n isKeyPressing = false\n firePointerEvent(element, \"up\")\n })\n\n element.addEventListener(\"keydown\", handleKeydown, eventOptions)\n element.addEventListener(\"keyup\", handleKeyup, eventOptions)\n\n /**\n * On blur, remove the key listeners and cancel any keyboard press.\n */\n element.addEventListener(\n \"blur\",\n () => {\n element.removeEventListener(\"keydown\", handleKeydown)\n element.removeEventListener(\"keyup\", handleKeyup)\n if (isKeyPressing) firePointerEvent(element, \"cancel\")\n },\n { ...eventOptions, once: true }\n )\n}\n"],"names":[],"mappings":";;AAEA;;AAEG;AACH,SAAS,YAAY,CAAC,QAAwC,EAAA;IAC1D,OAAO,CAAC,KAAoB,KAAI;AAC5B,QAAA,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO;YAAE;QAC3B,QAAQ,CAAC,KAAK,CAAC;AACnB,IAAA,CAAC;AACL;AAEA,SAAS,gBAAgB,CAAC,MAAmB,EAAE,IAA8B,EAAA;IACzE,MAAM,CAAC,aAAa,CAChB,IAAI,YAAY,CAAC,SAAS,GAAG,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CACzE;AACL;MAEa,mBAAmB,GAAG,CAC/B,OAAoB,EACpB,YAAqC,KACrC;AACA;;;;AAIG;IACH,IAAI,aAAa,GAAG,KAAK;AAEzB,IAAA,MAAM,aAAa,GAAG,YAAY,CAAC,MAAK;AACpC,QAAA,IAAI,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC;YAAE;QAC7B,aAAa,GAAG,IAAI;AACpB,QAAA,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC;AACrC,IAAA,CAAC,CAAC;AAEF,IAAA,MAAM,WAAW,GAAG,YAAY,CAAC,MAAK;AAClC,QAAA,IAAI,CAAC,aAAa;YAAE;QACpB,aAAa,GAAG,KAAK;AACrB,QAAA,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC;AACnC,IAAA,CAAC,CAAC;IAEF,OAAO,CAAC,gBAAgB,CAAC,SAAS,EAAE,aAAa,EAAE,YAAY,CAAC;IAChE,OAAO,CAAC,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,YAAY,CAAC;AAE5D;;AAEG;AACH,IAAA,OAAO,CAAC,gBAAgB,CACpB,MAAM,EACN,MAAK;AACD,QAAA,OAAO,CAAC,mBAAmB,CAAC,SAAS,EAAE,aAAa,CAAC;AACrD,QAAA,OAAO,CAAC,mBAAmB,CAAC,OAAO,EAAE,WAAW,CAAC;AACjD,QAAA,IAAI,aAAa;AAAE,YAAA,gBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC;IAC1D,CAAC,EACD,EAAE,GAAG,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,CAClC;AACL;;;;"}
1
+ {"version":3,"file":"keyboard.mjs","sources":["../../../../../src/gestures/press/utils/keyboard.ts"],"sourcesContent":["import { isPressing } from \"./state\"\n\n/**\n * Filter out events that are not \"Enter\" keys.\n */\nfunction filterEvents(callback: (event: KeyboardEvent) => void) {\n return (event: KeyboardEvent) => {\n if (event.key !== \"Enter\") return\n callback(event)\n }\n}\n\nfunction firePointerEvent(target: EventTarget, type: \"down\" | \"up\" | \"cancel\") {\n target.dispatchEvent(\n new PointerEvent(\"pointer\" + type, { isPrimary: true, bubbles: true })\n )\n}\n\nexport const enableKeyboardPress = (\n element: HTMLElement,\n eventOptions: AddEventListenerOptions\n) => {\n /**\n * Listeners are scoped to this focus and all released on blur, rather\n * than added per Enter press, so they can't accumulate and fire\n * duplicate pointerup/pointercancel events. See #3935.\n */\n let isKeyPressing = false\n\n const handleKeydown = filterEvents(() => {\n if (isKeyPressing || isPressing.has(element)) return\n isKeyPressing = true\n firePointerEvent(element, \"down\")\n })\n\n const handleKeyup = filterEvents(() => {\n if (!isKeyPressing) return\n isKeyPressing = false\n firePointerEvent(element, \"up\")\n })\n\n element.addEventListener(\"keydown\", handleKeydown, eventOptions)\n element.addEventListener(\"keyup\", handleKeyup, eventOptions)\n\n /**\n * On blur, remove the key listeners and cancel any keyboard press.\n */\n element.addEventListener(\n \"blur\",\n () => {\n element.removeEventListener(\"keydown\", handleKeydown)\n element.removeEventListener(\"keyup\", handleKeyup)\n if (isKeyPressing) firePointerEvent(element, \"cancel\")\n },\n { ...eventOptions, once: true }\n )\n}\n"],"names":[],"mappings":";;AAEA;;AAEG;AACH,SAAS,YAAY,CAAC,QAAwC,EAAA;IAC1D,OAAO,CAAC,KAAoB,KAAI;AAC5B,QAAA,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO;YAAE;QAC3B,QAAQ,CAAC,KAAK,CAAC;AACnB,IAAA,CAAC;AACL;AAEA,SAAS,gBAAgB,CAAC,MAAmB,EAAE,IAA8B,EAAA;IACzE,MAAM,CAAC,aAAa,CAChB,IAAI,YAAY,CAAC,SAAS,GAAG,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CACzE;AACL;MAEa,mBAAmB,GAAG,CAC/B,OAAoB,EACpB,YAAqC,KACrC;AACA;;;;AAIG;IACH,IAAI,aAAa,GAAG,KAAK;AAEzB,IAAA,MAAM,aAAa,GAAG,YAAY,CAAC,MAAK;AACpC,QAAA,IAAI,aAAa,IAAI,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC;YAAE;QAC9C,aAAa,GAAG,IAAI;AACpB,QAAA,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC;AACrC,IAAA,CAAC,CAAC;AAEF,IAAA,MAAM,WAAW,GAAG,YAAY,CAAC,MAAK;AAClC,QAAA,IAAI,CAAC,aAAa;YAAE;QACpB,aAAa,GAAG,KAAK;AACrB,QAAA,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC;AACnC,IAAA,CAAC,CAAC;IAEF,OAAO,CAAC,gBAAgB,CAAC,SAAS,EAAE,aAAa,EAAE,YAAY,CAAC;IAChE,OAAO,CAAC,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,YAAY,CAAC;AAE5D;;AAEG;AACH,IAAA,OAAO,CAAC,gBAAgB,CACpB,MAAM,EACN,MAAK;AACD,QAAA,OAAO,CAAC,mBAAmB,CAAC,SAAS,EAAE,aAAa,CAAC;AACrD,QAAA,OAAO,CAAC,mBAAmB,CAAC,OAAO,EAAE,WAAW,CAAC;AACjD,QAAA,IAAI,aAAa;AAAE,YAAA,gBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC;IAC1D,CAAC,EACD,EAAE,GAAG,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,CAClC;AACL;;;;"}
package/dist/index.d.ts CHANGED
@@ -582,6 +582,14 @@ interface DragControlOptions {
582
582
  * @public
583
583
  */
584
584
  snapToCursor?: boolean;
585
+ /**
586
+ * Start dragging straight away, rather than once the pointer has moved
587
+ * past `distanceThreshold`. For instance, to carry on a drag from
588
+ * another element.
589
+ *
590
+ * @public
591
+ */
592
+ immediate?: boolean;
585
593
  }
586
594
  type DragDirection = "x" | "y";
587
595
  declare class VisualElementDragControls {
@@ -625,7 +633,7 @@ declare class VisualElementDragControls {
625
633
  */
626
634
  private readProps;
627
635
  constructor(visualElement: VisualElement<HTMLElement>, readProps?: () => MotionNodeOptions);
628
- start(originEvent: PointerEvent, { snapToCursor, distanceThreshold }?: DragControlOptions): void;
636
+ start(originEvent: PointerEvent, options?: DragControlOptions): void;
629
637
  /**
630
638
  * @param dragAxes - The axes to animate on release, if not the `drag`
631
639
  * prop's, e.g. when drag was disabled mid-gesture.
@@ -704,6 +712,10 @@ interface DragConstraintsContext {
704
712
  */
705
713
  elastic: VisualElementDragControls["elastic"];
706
714
  getAxisMotionValue: VisualElementDragControls["getAxisMotionValue"];
715
+ /**
716
+ * The drag's options, e.g. `drag` for the axes it moves.
717
+ */
718
+ getProps: VisualElementDragControls["getProps"];
707
719
  }
708
720
  /**
709
721
  * Called when a drag starts, after the drag's origin and elastic are
@@ -711,6 +723,83 @@ interface DragConstraintsContext {
711
723
  */
712
724
  type DragConstraintsFunction = (controls: DragConstraintsContext) => DragPointConstraint;
713
725
 
726
+ interface PressGestureInfo {
727
+ success: boolean;
728
+ }
729
+ type OnPressEndEvent = (event: PointerEvent, info: PressGestureInfo) => void;
730
+ /**
731
+ * Handlers for a single press gesture, returned from the press start
732
+ * callback.
733
+ */
734
+ interface PressHandlers {
735
+ /**
736
+ * Called when the press gesture ends. `success` is `true` if it
737
+ * completed: released on the element, after `count` presses and once
738
+ * held for `hold` seconds. Otherwise it's `false`.
739
+ *
740
+ * Returning this function directly from the press start callback is
741
+ * equivalent.
742
+ */
743
+ onComplete?: OnPressEndEvent;
744
+ /**
745
+ * Called once per press gesture, when the press becomes active while
746
+ * still held: the final press of `count` is down, and held for `hold`
747
+ * seconds if set. Without `hold`, this is on the final press down.
748
+ * Not called if the gesture is cancelled before then.
749
+ */
750
+ onActive?: VoidFunction;
751
+ /**
752
+ * Called every frame while the final press is held, with progress
753
+ * from `0` to `1`: first over `hold`, then over each `repeat`.
754
+ * Each cycle starts at exactly `0` and ends at exactly `1`, before the
755
+ * press becomes active or `onRepeat` fires. Not called if neither
756
+ * `hold` nor `repeat` is set.
757
+ */
758
+ onHold?: (progress: number) => void;
759
+ /**
760
+ * Called every `repeat` seconds while the press is held, with the
761
+ * number of repeats so far.
762
+ */
763
+ onRepeat?: (count: number) => void;
764
+ }
765
+ /**
766
+ * Called when a press gesture starts, on the first pointer or key down.
767
+ * Can return a function to call when the press ends, or an object of
768
+ * `PressHandlers`.
769
+ */
770
+ type OnPressStartEvent = (element: Element, event: PointerEvent) => OnPressEndEvent | PressHandlers | void;
771
+ interface PressOptions {
772
+ /**
773
+ * The number of quick, consecutive presses needed for the press
774
+ * gesture to succeed. For example, `2` for a double press. The gesture
775
+ * starts on the first press, and is cancelled if a press is too late
776
+ * or too far away.
777
+ *
778
+ * @default 1
779
+ */
780
+ count?: number;
781
+ /**
782
+ * The maximum time, in seconds, between the end of one press and the
783
+ * start of the next for both to be counted.
784
+ *
785
+ * @default 0.3
786
+ */
787
+ countTimeout?: number;
788
+ /**
789
+ * The time, in seconds, the final press must be held for the press
790
+ * gesture to succeed (long press). Releasing earlier cancels it.
791
+ *
792
+ * @default 0
793
+ */
794
+ hold?: number;
795
+ /**
796
+ * While the final press is held, and once `hold` is reached, repeat
797
+ * it every `repeat` seconds. Each repeat calls the `onRepeat` handler
798
+ * returned from the press start callback.
799
+ */
800
+ repeat?: number;
801
+ }
802
+
714
803
  interface EventInfo {
715
804
  point: Point;
716
805
  }
@@ -1185,6 +1274,30 @@ interface MotionNodeTapHandlers {
1185
1274
  * Note: This is not supported publicly.
1186
1275
  */
1187
1276
  globalTapTarget?: boolean;
1277
+ /**
1278
+ * Options for the tap gesture, applied to `onTapStart`, `onTap`,
1279
+ * `onTapCancel` and `whileTap`. `onTapStart` and `whileTap` start on
1280
+ * the first press. `onTap` fires only when the gesture completes,
1281
+ * otherwise `onTapCancel` fires.
1282
+ *
1283
+ * ```jsx
1284
+ * // Double tap
1285
+ * <motion.div tap={{ count: 2 }} onTap={onDoubleTap} />
1286
+ *
1287
+ * // Long press
1288
+ * <motion.div tap={{ hold: 0.5 }} whileTap={{ scale: 0.9 }} onTap={onLongPress} />
1289
+ *
1290
+ * // Stepper: `onTap` fires every 0.1 seconds while held
1291
+ * <motion.button tap={{ repeat: 0.1 }} onTap={increment} />
1292
+ * ```
1293
+ *
1294
+ * - `count`: Quick, consecutive presses needed for `onTap`. Default `1`.
1295
+ * - `countTimeout`: Max seconds between presses. Default `0.3`.
1296
+ * - `hold`: Seconds a press must be held for `onTap`. Default `0`.
1297
+ * - `repeat`: While held, `onTap` fires every `repeat` seconds,
1298
+ * and `whileTap` stays active.
1299
+ */
1300
+ tap?: PressOptions;
1188
1301
  }
1189
1302
  /**
1190
1303
  * @deprecated - Use MotionNodeTapHandlers
@@ -4062,6 +4175,19 @@ interface DragOptions {
4062
4175
  * draggable. By default, only the innermost draggable element moves.
4063
4176
  */
4064
4177
  propagation?: boolean;
4178
+ /**
4179
+ * Motion values to write the drag to, instead of the element's
4180
+ * `x` and `y`. When either is set, the element itself doesn't move,
4181
+ * so drag can drive other values, like a dial's rotation.
4182
+ *
4183
+ * ```javascript
4184
+ * const x = motionValue(0)
4185
+ * x.on("change", (v) => (dial.style.rotate = v + "deg"))
4186
+ * drag(dial, { axis: "x", x })
4187
+ * ```
4188
+ */
4189
+ x?: MotionValue<number>;
4190
+ y?: MotionValue<number>;
4065
4191
  onStart?: DragHandler;
4066
4192
  onMove?: DragHandler;
4067
4193
  onEnd?: DragHandler;
@@ -4159,6 +4285,11 @@ interface PanSessionOptions {
4159
4285
  * smoothly during scroll.
4160
4286
  */
4161
4287
  element?: HTMLElement | null;
4288
+ /**
4289
+ * Start panning from `event` straight away, as if the pointer had moved
4290
+ * there, rather than waiting for it to move past `distanceThreshold`.
4291
+ */
4292
+ immediate?: boolean;
4162
4293
  }
4163
4294
  declare class PanSession {
4164
4295
  private history;
@@ -4194,7 +4325,7 @@ declare class PanSession {
4194
4325
  * Cleanup function for scroll listeners.
4195
4326
  */
4196
4327
  private removeScrollListeners?;
4197
- constructor(event: PointerEvent, handlers: Partial<PanSessionHandlers>, { transformPagePoint, contextWindow, dragSnapToOrigin, distanceThreshold, element, }?: PanSessionOptions);
4328
+ constructor(event: PointerEvent, handlers: Partial<PanSessionHandlers>, { transformPagePoint, contextWindow, dragSnapToOrigin, distanceThreshold, element, immediate, }?: PanSessionOptions);
4198
4329
  /**
4199
4330
  * Start tracking scroll on ancestors and window.
4200
4331
  */
@@ -4215,13 +4346,7 @@ declare class PanSession {
4215
4346
  end(): void;
4216
4347
  }
4217
4348
 
4218
- interface PressGestureInfo {
4219
- success: boolean;
4220
- }
4221
- type OnPressEndEvent = (event: PointerEvent, info: PressGestureInfo) => void;
4222
- type OnPressStartEvent = (element: Element, event: PointerEvent) => OnPressEndEvent | void;
4223
-
4224
- interface PointerEventOptions extends EventOptions {
4349
+ interface PointerEventOptions extends EventOptions, PressOptions {
4225
4350
  useGlobalTarget?: boolean;
4226
4351
  stopPropagation?: boolean;
4227
4352
  }
@@ -4242,6 +4367,17 @@ interface PointerEventOptions extends EventOptions {
4242
4367
  * to be focusable for this to work, whereas a press gesture will
4243
4368
  * make an element focusable by default.
4244
4369
  *
4370
+ * `onPressStart` fires on the first pointer or key down, and can return
4371
+ * a function to call when the press ends, or an object of handlers for
4372
+ * this press:
4373
+ *
4374
+ * ```js
4375
+ * press(button, () => ({
4376
+ * onHold: (progress) => {},
4377
+ * onComplete: (event, { success }) => {},
4378
+ * }), { hold: 0.5 })
4379
+ * ```
4380
+ *
4245
4381
  * @public
4246
4382
  */
4247
4383
  declare function press(targetOrSelector: ElementOrSelector, onPressStart: OnPressStartEvent, options?: PointerEventOptions): VoidFunction;
@@ -6253,4 +6389,4 @@ declare const sync: Batcher;
6253
6389
  */
6254
6390
  declare const cancelSync: Record<string, (process: Process) => void>;
6255
6391
 
6256
- export { type AccelerateConfig, type AcceptedAnimations, type ActiveStatsBuffer, type AddEffectValue, type AnimateEffect, type AnimationDefinition, type AnimationGeneratorName, type AnimationGeneratorType, type AnimationList, type AnimationOptions, type AnimationOrchestrationOptions, type AnimationPlaybackControls, type AnimationPlaybackControlsWithThen, type AnimationPlaybackLifecycles, type AnimationPlaybackOptions, type AnimationScope, type AnimationState$1 as AnimationState, type AnimationType, type AnimationTypeState, type AnyResolvedKeyframe, type ArcOptions, AsyncMotionValueAnimation, type Batcher, type CSSStyleDeclarationWithTransform, type CSSVariableName, type CSSVariableToken, type CancelProcess, type Color, type ComplexValueInfo, type ComplexValues, type DOMKeyframesDefinition, DOMKeyframesResolver, type DOMValueAnimationOptions, DOMVisualElement, type DOMVisualElementOptions, type DecayOptions, type DelayedFunction, DocumentProjectionNode, type DragConstraintsContext, type DragConstraintsFunction, type DragControlOptions, type DragElastic, type DragHandler, type DragOptions, type DragPointConstraint, type DraggableProps, type DurationSpringOptions, type DynamicOption, type Effect, type EffectKeyframes, type EffectOptions, type EffectRead, type EffectTest, type EffectTransition, type ElementOrSelector, type EventInfo, type EventListenerWithPointInfo, type EventOptions, Feature, type FeatureClass, FlatTree, type FollowValueOptions, type FrameData, type GeneratorFactory, type GeneratorFactoryFunction, GroupAnimation, GroupAnimationWithThen, type GroupedAnimations, type HSLA, HTMLProjectionNode, type HTMLRenderState, HTMLVisualElement, type HandoffFunction, type IProjectionNode, type InactiveStatsBuffer, type InertiaOptions, type InitialPromotionConfig, type InterpolateOptions, JSAnimation, type KeyframeGenerator, type KeyframeOptions, KeyframeResolver, LayoutAnimationBuilder, type LayoutEvents, type LayoutLifecycles, type LayoutProjectionMetrics, type LayoutProjectionStats, type LayoutUpdateData, type LayoutUpdateHandler, type LegacyAnimationControls, type MapInputRange, type Measurements, type MediaConditions, type Mixer, type MixerFactory, type MotionConfigContextProps, type MotionNodeAdvancedOptions, type MotionNodeAnimationOptions, type MotionNodeDragHandlers, type MotionNodeDraggableOptions, type MotionNodeEventOptions, type MotionNodeFocusHandlers, type MotionNodeHoverHandlers, type MotionNodeLayoutOptions, type MotionNodeOptions, type MotionNodePanHandlers, type MotionNodeTapHandlers, type MotionNodeViewportOptions, type MotionPath, type MotionScope, type MotionStyle, MotionValue, type MotionValueAnimation, type MotionValueEventCallbacks, type MotionValueOptions, MotionValueState, type MultiTransformer, NativeAnimation, NativeAnimationExtended, type NativeAnimationOptions, type NativeAnimationOptionsExtended, NativeAnimationWrapper, type NodeGroup, NodeStack, type NumberMap, ObjectVisualElement, type OnHoverEndEvent, type OnHoverStartEvent, type OnKeyframesResolved, type OnPressEndEvent, type OnPressStartEvent, type Owner, type PanHandler, type PanInfo, PanSession, type PassiveEffect, type PathInterpolator, type PathState, type Phase, type Point2D, type PointerEventOptions, type PresenceContextProps, type PressGestureInfo, type Process, type ProgressTimeline, type ProjectionEventName, type ProjectionNodeConfig, type ProjectionNodeOptions, type PropagateOptions, type RGBA, type ReducedMotionConfig, type RepeatType, type ResolvedConstraints, type ResolvedElastic, type ResolvedKeyframes, type ResolvedValueKeyframe, type ResolvedValues$1 as ResolvedValues, type SVGAttributes, type SVGForcedAttrKeyframesDefinition, type SVGForcedAttrProperties, type SVGForcedAttrTransitions, type SVGKeyframesDefinition, type SVGPathKeyframesDefinition, type SVGPathProperties, type SVGPathTransitions, type SVGRenderState, type SVGTransitions, SVGVisualElement, type ScaleCorrectionNode, type ScaleCorrector, type ScaleCorrectorDefinition, type ScaleCorrectorMap, type Schedule, type ScopeOptions, type ScopeSetup, type ScopeState, type ScrapeMotionValuesFromProps, type ScrollMeasurements, type SelectorCache, type SingleTransformer, type Spring, type SpringOptions, type StaggerOptions, type StaggerOrigin, type StartAnimation, type StatsRecording, type Step, type StepId, type Steps, type StyleKeyframesDefinition, type StyleSubject, type StyleTransitions, type Subscriber, type TapHandlers, type TapInfo, type Target, type TargetAndTransition, type TargetResolver, type TimelineWithFallback, type TransformInputRange, type TransformOptions, type TransformOrigin, type TransformProperties, type TransformTemplate, type Transformer, type Transition, type TransitionWithValueOverrides, type Tween, type UnresolvedKeyframes, type UnresolvedValueKeyframe, type UseRenderState, type ValueAnimationOptions, type ValueAnimationOptionsWithRenderContext, type ValueAnimationTransition, type ValueAnimationWithDynamicDelay, type ValueIndexes, type ValueKeyframe, type ValueKeyframesDefinition, type ValueTransformer, type ValueTransition, type ValueType, type ValueTypeMap, type VariableKeyframesDefinition, type VariableTransitions, type Variant, type VariantLabels, type Variants, type VelocityOptions, type ViewTransitionAnimationDefinition, ViewTransitionBuilder, type ViewTransitionOptions, type ViewTransitionTarget, type ViewTransitionTargetDefinition, type ViewportEventHandler, type ViewportOptions, VisualElement, type VisualElementAnimationOptions, VisualElementDragControls, type VisualElementEventCallbacks, type VisualElementOptions, type VisualState, type WillChange, type WithAppearProps, type WithDepth, type WithQuerySelectorAll, acceleratedValues, acquireProjectionNode, activeScope, addAttrValue, addBuilderToScope, addDomEvent, addEffect, addPointerEvent, addPointerInfo, addSVGValue, addScaleCorrector, addStyleValue, addToScope, addValueToWillChange, alpha, analyseComplexValue, animateEffectSubject, animateElement, animateLayout, animateMotionValue, animateSingleValue, animateTarget, animateValue, animateValues, animateVariant, animateView, animateVisualElement, animationMapKey, applyAxisDelta, applyBoxDelta, applyGeneratorOptions, applyPointDelta, applyPxDefaults, applyTreeDeltas, arc, aspectRatio, attachFollow, attachSpring, attrEffect, axisDeltaEquals, axisEquals, axisEqualsRounded, bindToScope, boxEquals, boxEqualsRounded, buildHTMLStyles, buildProjectionTransform, buildSVGAttrs, buildSVGPath, buildTransform, buildTransformer, calcAxisDelta, calcBoxDelta, calcChildStagger, calcGeneratorDuration, calcLength, calcRelativeAxis, calcRelativeAxisPosition, calcRelativeBox, calcRelativePosition, camelCaseAttributes, camelToDash, cancelFrame, cancelMicrotask, cancelSync, checkVariantsDidChange, cleanDirtyNodes, collectMotionValues, color, compareByDepth, complex, containsCSSVariable, convertBoundingBoxToBox, convertBoxToBoundingBox, convertOffsetToTimes, copyAxisDeltaInto, copyAxisInto, copyBoxInto, correctBorderRadius, correctBoxShadow, createAnimationState, createAxis, createAxisDelta, createBox, createDelta, createEffect, createGeneratorEasing, createProjectionNode, createRenderBatcher, cubicBezierAsString, defaultEasing, defaultOffset, defaultTransformValue, defaultValueTypes, degrees, delay, delayInSeconds, dimensionValueTypes, distance, distance2D, drag, eachAxis, elementDragControls, expectsResolvedDragConstraints, extractEventInfo, fillOffset, fillWildcards, findDimensionValueType, findEffect, findValueType, flushKeyframeResolvers, flushLayoutSnapshots, followValue, frame, frameData, frameSteps, generateLinearEasing, getAnimatableNone, getAnimationMap, getComputedStyle, getDefaultTransition, getDefaultValueType, getFeatureDefinitions, getFinalKeyframe, getMixer, getOptimisedAppearId, getOriginIndex, getValueAsType, getValueTransition, getVariableValue, getVariantContext, getViewAnimationLayerInfo, getViewAnimations, globalProjectionState, handOffElementState, has2DTranslate, hasComplexValues, hasReducedMotionListener, hasScale, hasTransform, hex, hover, hsla, hslaToRgba, inertia, initPrefersReducedMotion, interpolate, invisibleValues, isAnimationControls, isCSSVariableName, isCSSVariableToken, isControllingVariants, isDeltaZero, isDragActive, isDragging, isElementKeyboardAccessible, isElementTextInput, isForcedMotionValue, isGenerator, isHTMLElement, isKeyframesTarget, isMotionValue, isNear, isNodeOrChild, isPrimaryPointer, isSVGElement, isSVGSVGElement, isSVGTag, isTransitionDefined, isVariantLabel, isVariantNode, isWaapiSupportedEasing, isWillChangeMotionValue, keyframes, makeAnimationInstant, mapEasingToNativeEasing, mapValue, maxGeneratorDuration, measurePageBox, measureViewportBox, microtask, mix, mixArray, mixColor, mixComplex, mixImmediate, mixLinearColor, mixNumber, mixObject, mixValues, mixVisibility, motionValue, nodeGroup, number, numberValueTypes, optimizedAppearDataAttribute, optimizedAppearDataId, originProps, parseAnimateLayoutArgs, parseCSSVariable, parseValueFromTransform, percent, pixelsToPercent, positionalKeys, prefersReducedMotion, press, processFrame, progressPercentage, propEffect, propagateDirtyNodes, px, readSVGValue, readStyleValue, readTransformValue, recordStats, releaseElement, removeAxisDelta, removeAxisTransforms, removeBoxTransforms, removeEffect, removePointDelta, renderHTML, renderSVG, resize, resolveElements, resolveMotionValue, resolveTransition, resolveVariant, resolveVariantFromProps, rgbUnit, rgba, rootProjectionNode, round, sampleDelta, scale, scaleCorrectors, scalePoint, scopeMotion, scrapeMotionValuesFromProps$1 as scrapeHTMLMotionValuesFromProps, scrapeMotionValuesFromProps as scrapeSVGMotionValuesFromProps, setDragLock, setFeatureDefinitions, setStyle, setTarget, spring, springValue, stagger, startWaapiAnimation, statsBuffer, styleEffect, styleSubjectEffect, supportedWaapiEasing, supportsBrowserAnimation, supportsFlags, supportsLinearEasing, supportsPartialKeyframes, supportsScrollTimeline, supportsViewTimeline, supportsWaapi, svgEffect, svgSubjectEffect, sync, testValueType, time, toMediaQuery, transform, transformAxis, transformBox, transformBoxPoints, transformPropOrder, transformProps, transformValue, transformValueTypes, translateAxis, updateMotionValuesFromProps, variantPriorityOrder, variantProps, vh, visualElementStore, vw };
6392
+ export { type AccelerateConfig, type AcceptedAnimations, type ActiveStatsBuffer, type AddEffectValue, type AnimateEffect, type AnimationDefinition, type AnimationGeneratorName, type AnimationGeneratorType, type AnimationList, type AnimationOptions, type AnimationOrchestrationOptions, type AnimationPlaybackControls, type AnimationPlaybackControlsWithThen, type AnimationPlaybackLifecycles, type AnimationPlaybackOptions, type AnimationScope, type AnimationState$1 as AnimationState, type AnimationType, type AnimationTypeState, type AnyResolvedKeyframe, type ArcOptions, AsyncMotionValueAnimation, type Batcher, type CSSStyleDeclarationWithTransform, type CSSVariableName, type CSSVariableToken, type CancelProcess, type Color, type ComplexValueInfo, type ComplexValues, type DOMKeyframesDefinition, DOMKeyframesResolver, type DOMValueAnimationOptions, DOMVisualElement, type DOMVisualElementOptions, type DecayOptions, type DelayedFunction, DocumentProjectionNode, type DragConstraintsContext, type DragConstraintsFunction, type DragControlOptions, type DragElastic, type DragHandler, type DragOptions, type DragPointConstraint, type DraggableProps, type DurationSpringOptions, type DynamicOption, type Effect, type EffectKeyframes, type EffectOptions, type EffectRead, type EffectTest, type EffectTransition, type ElementOrSelector, type EventInfo, type EventListenerWithPointInfo, type EventOptions, Feature, type FeatureClass, FlatTree, type FollowValueOptions, type FrameData, type GeneratorFactory, type GeneratorFactoryFunction, GroupAnimation, GroupAnimationWithThen, type GroupedAnimations, type HSLA, HTMLProjectionNode, type HTMLRenderState, HTMLVisualElement, type HandoffFunction, type IProjectionNode, type InactiveStatsBuffer, type InertiaOptions, type InitialPromotionConfig, type InterpolateOptions, JSAnimation, type KeyframeGenerator, type KeyframeOptions, KeyframeResolver, LayoutAnimationBuilder, type LayoutEvents, type LayoutLifecycles, type LayoutProjectionMetrics, type LayoutProjectionStats, type LayoutUpdateData, type LayoutUpdateHandler, type LegacyAnimationControls, type MapInputRange, type Measurements, type MediaConditions, type Mixer, type MixerFactory, type MotionConfigContextProps, type MotionNodeAdvancedOptions, type MotionNodeAnimationOptions, type MotionNodeDragHandlers, type MotionNodeDraggableOptions, type MotionNodeEventOptions, type MotionNodeFocusHandlers, type MotionNodeHoverHandlers, type MotionNodeLayoutOptions, type MotionNodeOptions, type MotionNodePanHandlers, type MotionNodeTapHandlers, type MotionNodeViewportOptions, type MotionPath, type MotionScope, type MotionStyle, MotionValue, type MotionValueAnimation, type MotionValueEventCallbacks, type MotionValueOptions, MotionValueState, type MultiTransformer, NativeAnimation, NativeAnimationExtended, type NativeAnimationOptions, type NativeAnimationOptionsExtended, NativeAnimationWrapper, type NodeGroup, NodeStack, type NumberMap, ObjectVisualElement, type OnHoverEndEvent, type OnHoverStartEvent, type OnKeyframesResolved, type OnPressEndEvent, type OnPressStartEvent, type Owner, type PanHandler, type PanInfo, PanSession, type PassiveEffect, type PathInterpolator, type PathState, type Phase, type Point2D, type PointerEventOptions, type PresenceContextProps, type PressGestureInfo, type PressHandlers, type PressOptions, type Process, type ProgressTimeline, type ProjectionEventName, type ProjectionNodeConfig, type ProjectionNodeOptions, type PropagateOptions, type RGBA, type ReducedMotionConfig, type RepeatType, type ResolvedConstraints, type ResolvedElastic, type ResolvedKeyframes, type ResolvedValueKeyframe, type ResolvedValues$1 as ResolvedValues, type SVGAttributes, type SVGForcedAttrKeyframesDefinition, type SVGForcedAttrProperties, type SVGForcedAttrTransitions, type SVGKeyframesDefinition, type SVGPathKeyframesDefinition, type SVGPathProperties, type SVGPathTransitions, type SVGRenderState, type SVGTransitions, SVGVisualElement, type ScaleCorrectionNode, type ScaleCorrector, type ScaleCorrectorDefinition, type ScaleCorrectorMap, type Schedule, type ScopeOptions, type ScopeSetup, type ScopeState, type ScrapeMotionValuesFromProps, type ScrollMeasurements, type SelectorCache, type SingleTransformer, type Spring, type SpringOptions, type StaggerOptions, type StaggerOrigin, type StartAnimation, type StatsRecording, type Step, type StepId, type Steps, type StyleKeyframesDefinition, type StyleSubject, type StyleTransitions, type Subscriber, type TapHandlers, type TapInfo, type Target, type TargetAndTransition, type TargetResolver, type TimelineWithFallback, type TransformInputRange, type TransformOptions, type TransformOrigin, type TransformProperties, type TransformTemplate, type Transformer, type Transition, type TransitionWithValueOverrides, type Tween, type UnresolvedKeyframes, type UnresolvedValueKeyframe, type UseRenderState, type ValueAnimationOptions, type ValueAnimationOptionsWithRenderContext, type ValueAnimationTransition, type ValueAnimationWithDynamicDelay, type ValueIndexes, type ValueKeyframe, type ValueKeyframesDefinition, type ValueTransformer, type ValueTransition, type ValueType, type ValueTypeMap, type VariableKeyframesDefinition, type VariableTransitions, type Variant, type VariantLabels, type Variants, type VelocityOptions, type ViewTransitionAnimationDefinition, ViewTransitionBuilder, type ViewTransitionOptions, type ViewTransitionTarget, type ViewTransitionTargetDefinition, type ViewportEventHandler, type ViewportOptions, VisualElement, type VisualElementAnimationOptions, VisualElementDragControls, type VisualElementEventCallbacks, type VisualElementOptions, type VisualState, type WillChange, type WithAppearProps, type WithDepth, type WithQuerySelectorAll, acceleratedValues, acquireProjectionNode, activeScope, addAttrValue, addBuilderToScope, addDomEvent, addEffect, addPointerEvent, addPointerInfo, addSVGValue, addScaleCorrector, addStyleValue, addToScope, addValueToWillChange, alpha, analyseComplexValue, animateEffectSubject, animateElement, animateLayout, animateMotionValue, animateSingleValue, animateTarget, animateValue, animateValues, animateVariant, animateView, animateVisualElement, animationMapKey, applyAxisDelta, applyBoxDelta, applyGeneratorOptions, applyPointDelta, applyPxDefaults, applyTreeDeltas, arc, aspectRatio, attachFollow, attachSpring, attrEffect, axisDeltaEquals, axisEquals, axisEqualsRounded, bindToScope, boxEquals, boxEqualsRounded, buildHTMLStyles, buildProjectionTransform, buildSVGAttrs, buildSVGPath, buildTransform, buildTransformer, calcAxisDelta, calcBoxDelta, calcChildStagger, calcGeneratorDuration, calcLength, calcRelativeAxis, calcRelativeAxisPosition, calcRelativeBox, calcRelativePosition, camelCaseAttributes, camelToDash, cancelFrame, cancelMicrotask, cancelSync, checkVariantsDidChange, cleanDirtyNodes, collectMotionValues, color, compareByDepth, complex, containsCSSVariable, convertBoundingBoxToBox, convertBoxToBoundingBox, convertOffsetToTimes, copyAxisDeltaInto, copyAxisInto, copyBoxInto, correctBorderRadius, correctBoxShadow, createAnimationState, createAxis, createAxisDelta, createBox, createDelta, createEffect, createGeneratorEasing, createProjectionNode, createRenderBatcher, cubicBezierAsString, defaultEasing, defaultOffset, defaultTransformValue, defaultValueTypes, degrees, delay, delayInSeconds, dimensionValueTypes, distance, distance2D, drag, eachAxis, elementDragControls, expectsResolvedDragConstraints, extractEventInfo, fillOffset, fillWildcards, findDimensionValueType, findEffect, findValueType, flushKeyframeResolvers, flushLayoutSnapshots, followValue, frame, frameData, frameSteps, generateLinearEasing, getAnimatableNone, getAnimationMap, getComputedStyle, getDefaultTransition, getDefaultValueType, getFeatureDefinitions, getFinalKeyframe, getMixer, getOptimisedAppearId, getOriginIndex, getValueAsType, getValueTransition, getVariableValue, getVariantContext, getViewAnimationLayerInfo, getViewAnimations, globalProjectionState, handOffElementState, has2DTranslate, hasComplexValues, hasReducedMotionListener, hasScale, hasTransform, hex, hover, hsla, hslaToRgba, inertia, initPrefersReducedMotion, interpolate, invisibleValues, isAnimationControls, isCSSVariableName, isCSSVariableToken, isControllingVariants, isDeltaZero, isDragActive, isDragging, isElementKeyboardAccessible, isElementTextInput, isForcedMotionValue, isGenerator, isHTMLElement, isKeyframesTarget, isMotionValue, isNear, isNodeOrChild, isPrimaryPointer, isSVGElement, isSVGSVGElement, isSVGTag, isTransitionDefined, isVariantLabel, isVariantNode, isWaapiSupportedEasing, isWillChangeMotionValue, keyframes, makeAnimationInstant, mapEasingToNativeEasing, mapValue, maxGeneratorDuration, measurePageBox, measureViewportBox, microtask, mix, mixArray, mixColor, mixComplex, mixImmediate, mixLinearColor, mixNumber, mixObject, mixValues, mixVisibility, motionValue, nodeGroup, number, numberValueTypes, optimizedAppearDataAttribute, optimizedAppearDataId, originProps, parseAnimateLayoutArgs, parseCSSVariable, parseValueFromTransform, percent, pixelsToPercent, positionalKeys, prefersReducedMotion, press, processFrame, progressPercentage, propEffect, propagateDirtyNodes, px, readSVGValue, readStyleValue, readTransformValue, recordStats, releaseElement, removeAxisDelta, removeAxisTransforms, removeBoxTransforms, removeEffect, removePointDelta, renderHTML, renderSVG, resize, resolveElements, resolveMotionValue, resolveTransition, resolveVariant, resolveVariantFromProps, rgbUnit, rgba, rootProjectionNode, round, sampleDelta, scale, scaleCorrectors, scalePoint, scopeMotion, scrapeMotionValuesFromProps$1 as scrapeHTMLMotionValuesFromProps, scrapeMotionValuesFromProps as scrapeSVGMotionValuesFromProps, setDragLock, setFeatureDefinitions, setStyle, setTarget, spring, springValue, stagger, startWaapiAnimation, statsBuffer, styleEffect, styleSubjectEffect, supportedWaapiEasing, supportsBrowserAnimation, supportsFlags, supportsLinearEasing, supportsPartialKeyframes, supportsScrollTimeline, supportsViewTimeline, supportsWaapi, svgEffect, svgSubjectEffect, sync, testValueType, time, toMediaQuery, transform, transformAxis, transformBox, transformBoxPoints, transformPropOrder, transformProps, transformValue, transformValueTypes, translateAxis, updateMotionValuesFromProps, variantPriorityOrder, variantProps, vh, visualElementStore, vw };