@bevelo/dnd 0.0.0-stage → 0.1.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 (65) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +48 -2
  3. package/dist/a11y-BOpF8vx8.d.cts +30 -0
  4. package/dist/a11y-Bbm_a0mw.d.ts +30 -0
  5. package/dist/index-DDuIvuzA.d.cts +258 -0
  6. package/dist/index-kH3SGg1R.d.ts +258 -0
  7. package/dist/index.cjs +413 -0
  8. package/dist/index.d.cts +139 -0
  9. package/dist/index.d.ts +139 -0
  10. package/dist/index.js +357 -0
  11. package/dist/live/animate-settle.cjs +20 -0
  12. package/dist/live/animate-settle.d.cts +14 -0
  13. package/dist/live/animate-settle.d.ts +14 -0
  14. package/dist/live/animate-settle.js +19 -0
  15. package/dist/live/flip.cjs +39 -0
  16. package/dist/live/flip.d.cts +9 -0
  17. package/dist/live/flip.d.ts +9 -0
  18. package/dist/live/flip.js +38 -0
  19. package/dist/live/index.cjs +22 -0
  20. package/dist/live/index.d.cts +4 -0
  21. package/dist/live/index.d.ts +4 -0
  22. package/dist/live/index.js +4 -0
  23. package/dist/live-BUYwbSUp.cjs +899 -0
  24. package/dist/live-Clc3aswx.js +840 -0
  25. package/dist/pure/a11y.cjs +85 -0
  26. package/dist/pure/a11y.d.cts +2 -0
  27. package/dist/pure/a11y.d.ts +2 -0
  28. package/dist/pure/a11y.js +81 -0
  29. package/dist/pure/apply.cjs +130 -0
  30. package/dist/pure/apply.d.cts +29 -0
  31. package/dist/pure/apply.d.ts +29 -0
  32. package/dist/pure/apply.js +127 -0
  33. package/dist/pure/reorder.cjs +121 -0
  34. package/dist/pure/reorder.d.cts +77 -0
  35. package/dist/pure/reorder.d.ts +77 -0
  36. package/dist/pure/reorder.js +117 -0
  37. package/dist/pure/sensors.cjs +243 -0
  38. package/dist/pure/sensors.d.cts +2 -0
  39. package/dist/pure/sensors.d.ts +2 -0
  40. package/dist/pure/sensors.js +240 -0
  41. package/dist/pure/spatial.cjs +121 -0
  42. package/dist/pure/spatial.d.cts +64 -0
  43. package/dist/pure/spatial.d.ts +64 -0
  44. package/dist/pure/spatial.js +119 -0
  45. package/dist/pure/state.cjs +15 -0
  46. package/dist/pure/state.d.cts +2 -0
  47. package/dist/pure/state.d.ts +2 -0
  48. package/dist/pure/state.js +1 -0
  49. package/dist/pure/tree.cjs +164 -0
  50. package/dist/pure/tree.d.cts +36 -0
  51. package/dist/pure/tree.d.ts +36 -0
  52. package/dist/pure/tree.js +161 -0
  53. package/dist/rows-B2C7Yf94.cjs +56 -0
  54. package/dist/rows-BIT_Rkhr.js +45 -0
  55. package/dist/sensors-C9RnMr6P.d.cts +212 -0
  56. package/dist/sensors-C9RnMr6P.d.ts +212 -0
  57. package/dist/settle-BiwZ0ZDt.js +235 -0
  58. package/dist/settle-COFsW7ul.cjs +282 -0
  59. package/dist/settle-Dl5Y9uOw.d.ts +59 -0
  60. package/dist/settle-DzdqbH4S.d.cts +59 -0
  61. package/dist/state-BEKGNZY1.d.cts +323 -0
  62. package/dist/state-BEKGNZY1.d.ts +323 -0
  63. package/dist/state-BK9W_RZn.cjs +672 -0
  64. package/dist/state-CYXS6GIb.js +595 -0
  65. package/package.json +89 -3
package/dist/index.cjs ADDED
@@ -0,0 +1,413 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_state = require("./state-BK9W_RZn.cjs");
3
+ const require_pure_tree = require("./pure/tree.cjs");
4
+ const require_pure_apply = require("./pure/apply.cjs");
5
+ const require_pure_a11y = require("./pure/a11y.cjs");
6
+ const require_live = require("./live-BUYwbSUp.cjs");
7
+ const require_settle = require("./settle-COFsW7ul.cjs");
8
+ const require_live_flip = require("./live/flip.cjs");
9
+ const require_live_animate_settle = require("./live/animate-settle.cjs");
10
+ const require_pure_sensors = require("./pure/sensors.cjs");
11
+ const require_pure_reorder = require("./pure/reorder.cjs");
12
+ const require_pure_spatial = require("./pure/spatial.cjs");
13
+ // src/pure/clock.ts
14
+ /**
15
+ * The real clock, for the DOM binding and for applications.
16
+ *
17
+ * performance.now() is preferred because it does not jump when the system clock
18
+ * is corrected mid-drag; Date.now() is the fallback for hosts (older SSR
19
+ * runtimes) that define neither. Nothing above the binding layer calls this.
20
+ */
21
+ const systemClock = { now() {
22
+ if (typeof performance !== "undefined") return performance.now();
23
+ return Date.now();
24
+ } };
25
+ // src/live/measure.ts
26
+ /**
27
+ * Measures elements into plain rects. A DOMRect is a live object with mutation methods, so it
28
+ * is copied: a transform applied after measuring cannot change a rect a host still holds.
29
+ */
30
+ function measureRects(elements) {
31
+ const measured = [];
32
+ for (const source of elements) {
33
+ const { x, y, width, height } = source.element.getBoundingClientRect();
34
+ measured.push({
35
+ id: source.id,
36
+ rect: {
37
+ x,
38
+ y,
39
+ width,
40
+ height
41
+ }
42
+ });
43
+ }
44
+ return measured;
45
+ }
46
+ /**
47
+ * Reports fresh measurements whenever an element resizes or the page scrolls.
48
+ *
49
+ * Returns the unsubscribe; calling it twice is safe. The initial measurement is not reported
50
+ * here (measure once with measureRects before listening), because a synchronous first call
51
+ * would arrive before the caller had stored the disposer.
52
+ *
53
+ * Scroll is listened to in the capture phase on window: a scrollable ancestor does not bubble
54
+ * its scroll event, and one listener sees every container. ResizeObserver is read at call
55
+ * time and skipped when absent (jsdom, SSR).
56
+ */
57
+ function observeRects(elements, onChange) {
58
+ const sources = [...elements];
59
+ let disposed = false;
60
+ const report = () => {
61
+ if (!disposed) onChange(measureRects(sources));
62
+ };
63
+ const observer = typeof ResizeObserver === "undefined" ? void 0 : new ResizeObserver(report);
64
+ for (const source of sources) observer?.observe(source.element);
65
+ const view = sources[0]?.element.ownerDocument.defaultView ?? (typeof window === "undefined" ? void 0 : window);
66
+ view?.addEventListener("scroll", report, {
67
+ capture: true,
68
+ passive: true
69
+ });
70
+ view?.addEventListener("resize", report, { passive: true });
71
+ return () => {
72
+ if (disposed) return;
73
+ disposed = true;
74
+ observer?.disconnect();
75
+ view?.removeEventListener("scroll", report, { capture: true });
76
+ view?.removeEventListener("resize", report);
77
+ };
78
+ }
79
+ // src/pure/gestures.ts
80
+ const ALL_DIRECTIONS = [
81
+ "left",
82
+ "right",
83
+ "up",
84
+ "down"
85
+ ];
86
+ const DEFAULT_LONG_PRESS_MS = 300;
87
+ const DEFAULT_TAP_SLOP = 8;
88
+ const DEFAULT_SWIPE_DISTANCE = 24;
89
+ const DEFAULT_SWIPE_VELOCITY = .5;
90
+ /** The distance between two points; named so the pinch maths reads like prose. */
91
+ function spanBetween(a, b) {
92
+ return Math.hypot(b.x - a.x, b.y - a.y);
93
+ }
94
+ /** The point halfway between two pointers, which is what a pinch moves. */
95
+ function midpoint(a, b) {
96
+ return {
97
+ x: (a.x + b.x) / 2,
98
+ y: (a.y + b.y) / 2
99
+ };
100
+ }
101
+ /**
102
+ * The axis a delta mostly lies on. A tie goes horizontal: the caller asked for
103
+ * one direction and "right/left" is the axis most pointer gestures use.
104
+ */
105
+ function dominantDirection(delta) {
106
+ if (Math.abs(delta.x) >= Math.abs(delta.y)) return delta.x >= 0 ? "right" : "left";
107
+ return delta.y >= 0 ? "down" : "up";
108
+ }
109
+ /**
110
+ * Average velocity, delta over elapsed time. A zero-length interval reports no
111
+ * velocity instead of Infinity: a replay can contain two events with the same
112
+ * timestamp, and Infinity in a result would poison every comparison downstream.
113
+ */
114
+ function velocityOf(delta, durationMs) {
115
+ if (!(durationMs > 0)) return {
116
+ x: 0,
117
+ y: 0
118
+ };
119
+ return {
120
+ x: delta.x / durationMs,
121
+ y: delta.y / durationMs
122
+ };
123
+ }
124
+ /**
125
+ * Builds a recogniser.
126
+ *
127
+ * State is deliberately flat and small: positions of the pointers seen so far,
128
+ * the origin and time of the press, the furthest the primary pointer has been
129
+ * from it, the pinch (if one started) and whether the gesture already reported.
130
+ */
131
+ function createGestureRecognizer(options = {}) {
132
+ const longPressMs = options.longPressMs ?? DEFAULT_LONG_PRESS_MS;
133
+ const tapSlop = options.tapSlop ?? DEFAULT_TAP_SLOP;
134
+ const swipeDistance = options.swipeDistance ?? DEFAULT_SWIPE_DISTANCE;
135
+ const swipeVelocity = options.swipeVelocity ?? DEFAULT_SWIPE_VELOCITY;
136
+ const axes = options.axes ?? ALL_DIRECTIONS;
137
+ /** pointerId -> last known position, inserted in the order the pointers went down. */
138
+ let positions = /* @__PURE__ */ new Map();
139
+ /** The pointer that went down first; it owns a single-pointer gesture. */
140
+ let primaryId;
141
+ let start = {
142
+ x: 0,
143
+ y: 0
144
+ };
145
+ let startTime = 0;
146
+ /**
147
+ * The furthest the primary pointer has ever been from start. Classification
148
+ * uses this for "did it move at all", so a pointer that wanders far and
149
+ * returns is not mistaken for a still press; distance in the result stays the
150
+ * net displacement, which is the number a caller animates from.
151
+ */
152
+ let travelled = 0;
153
+ let pinch;
154
+ /** A result was already reported for the press in progress. */
155
+ let settled = false;
156
+ function clear() {
157
+ positions = /* @__PURE__ */ new Map();
158
+ primaryId = void 0;
159
+ start = {
160
+ x: 0,
161
+ y: 0
162
+ };
163
+ startTime = 0;
164
+ travelled = 0;
165
+ pinch = void 0;
166
+ settled = false;
167
+ }
168
+ /**
169
+ * Drops a pointer that lifted. When the last one is gone the gesture is over,
170
+ * so the whole state resets — including settled, which must not leak into the
171
+ * next press.
172
+ */
173
+ function release(pointerId) {
174
+ positions.delete(pointerId);
175
+ if (positions.size === 0) clear();
176
+ }
177
+ /** The single-pointer result, decided on up. */
178
+ function finishSingle(end, endTime) {
179
+ const durationMs = Math.max(0, endTime - startTime);
180
+ const delta = {
181
+ x: end.x - start.x,
182
+ y: end.y - start.y
183
+ };
184
+ const distance = spanBetween(start, end);
185
+ travelled = Math.max(travelled, distance);
186
+ const velocity = velocityOf(delta, durationMs);
187
+ if (travelled <= tapSlop) return {
188
+ kind: durationMs >= longPressMs ? "long-press" : "tap",
189
+ start,
190
+ end,
191
+ delta,
192
+ distance,
193
+ velocity,
194
+ durationMs
195
+ };
196
+ const speed = Math.hypot(velocity.x, velocity.y);
197
+ if (distance >= swipeDistance || speed > swipeVelocity) {
198
+ const direction = dominantDirection(delta);
199
+ if (!axes.includes(direction)) return void 0;
200
+ return {
201
+ kind: "swipe",
202
+ start,
203
+ end,
204
+ delta,
205
+ distance,
206
+ direction,
207
+ velocity,
208
+ durationMs
209
+ };
210
+ }
211
+ return {
212
+ kind: "drag",
213
+ start,
214
+ end,
215
+ delta,
216
+ distance,
217
+ velocity,
218
+ durationMs
219
+ };
220
+ }
221
+ /** The pinch result, decided when the first of the two pointers lifts. */
222
+ function finishPinch(active, endTime) {
223
+ const primary = primaryId === void 0 ? void 0 : positions.get(primaryId);
224
+ const secondary = positions.get(active.secondaryId);
225
+ if (primary === void 0 || secondary === void 0) return void 0;
226
+ const end = midpoint(primary, secondary);
227
+ const durationMs = Math.max(0, endTime - active.startTime);
228
+ const delta = {
229
+ x: end.x - active.startMid.x,
230
+ y: end.y - active.startMid.y
231
+ };
232
+ const distance = Math.hypot(delta.x, delta.y);
233
+ const velocity = velocityOf(delta, durationMs);
234
+ const span = spanBetween(primary, secondary);
235
+ const scale = active.initialSpan > 0 ? span / active.initialSpan : 1;
236
+ return {
237
+ kind: "pinch",
238
+ start: active.startMid,
239
+ end,
240
+ delta,
241
+ distance,
242
+ velocity,
243
+ scale,
244
+ durationMs
245
+ };
246
+ }
247
+ function handle(event) {
248
+ const at = {
249
+ x: event.x,
250
+ y: event.y
251
+ };
252
+ if (event.type === "cancel") {
253
+ clear();
254
+ return;
255
+ }
256
+ if (event.type === "down") {
257
+ const known = positions.has(event.pointerId);
258
+ positions.set(event.pointerId, at);
259
+ if (known) return void 0;
260
+ if (primaryId === void 0) {
261
+ clear();
262
+ positions.set(event.pointerId, at);
263
+ primaryId = event.pointerId;
264
+ start = at;
265
+ startTime = event.time;
266
+ return;
267
+ }
268
+ if (settled || pinch !== void 0) return void 0;
269
+ const primary = positions.get(primaryId);
270
+ if (primary === void 0) return void 0;
271
+ pinch = {
272
+ startMid: midpoint(primary, at),
273
+ startTime: event.time,
274
+ initialSpan: spanBetween(primary, at),
275
+ secondaryId: event.pointerId
276
+ };
277
+ return;
278
+ }
279
+ if (!positions.has(event.pointerId)) return void 0;
280
+ positions.set(event.pointerId, at);
281
+ if (event.type === "move") {
282
+ if (settled || pinch !== void 0) return void 0;
283
+ if (event.pointerId !== primaryId) return void 0;
284
+ travelled = Math.max(travelled, spanBetween(start, at));
285
+ const durationMs = Math.max(0, event.time - startTime);
286
+ if (durationMs >= longPressMs && travelled <= tapSlop) {
287
+ settled = true;
288
+ const delta = {
289
+ x: at.x - start.x,
290
+ y: at.y - start.y
291
+ };
292
+ return {
293
+ kind: "long-press",
294
+ start,
295
+ end: at,
296
+ delta,
297
+ distance: Math.hypot(delta.x, delta.y),
298
+ velocity: velocityOf(delta, durationMs),
299
+ durationMs
300
+ };
301
+ }
302
+ return;
303
+ }
304
+ if (pinch !== void 0) {
305
+ const endsPinch = event.pointerId === primaryId || event.pointerId === pinch.secondaryId;
306
+ const result = settled || !endsPinch ? void 0 : finishPinch(pinch, event.time);
307
+ if (result !== void 0) settled = true;
308
+ release(event.pointerId);
309
+ return result;
310
+ }
311
+ if (event.pointerId !== primaryId || settled) {
312
+ release(event.pointerId);
313
+ return;
314
+ }
315
+ const result = finishSingle(at, event.time);
316
+ if (result !== void 0) settled = true;
317
+ release(event.pointerId);
318
+ return result;
319
+ }
320
+ return {
321
+ handle,
322
+ active: () => positions.size > 0,
323
+ reset: clear
324
+ };
325
+ }
326
+ /**
327
+ * Recognises a whole event list at once — the seam tests and a replay use.
328
+ *
329
+ * This is the same recogniser run in a loop, so a recorded interaction cannot
330
+ * disagree with the incremental path a live binding uses.
331
+ */
332
+ function recognize(events, options = {}) {
333
+ const recognizer = createGestureRecognizer(options);
334
+ const results = [];
335
+ for (const event of events) {
336
+ const result = recognizer.handle(event);
337
+ if (result !== void 0) results.push(result);
338
+ }
339
+ return results;
340
+ }
341
+ // src/pure/transform.ts
342
+ /**
343
+ * The CSS transform to write for one offset.
344
+ *
345
+ * Translation first, then scale when either scale is named: an omitted scale means 1, so
346
+ * a transform that names only scaleX still carries both. A null or undefined transform has no
347
+ * string, which is what an absent inline transform is.
348
+ *
349
+ * Numbers are not rounded. A plan's offsets are fractional whenever the measured slots
350
+ * are, and rounding them here would be a second decision about where a row sits.
351
+ */
352
+ function transformCss(transform) {
353
+ if (transform === null || transform === void 0) return void 0;
354
+ const translate = "translate3d(" + transform.x + "px, " + transform.y + "px, 0)";
355
+ if (transform.scaleX === void 0 && transform.scaleY === void 0) return translate;
356
+ return translate + " scaleX(" + (transform.scaleX ?? 1) + ") scaleY(" + (transform.scaleY ?? 1) + ")";
357
+ }
358
+ exports.DRAG_HIDDEN = require_settle.DRAG_HIDDEN;
359
+ exports.DRAG_X = require_settle.DRAG_X;
360
+ exports.DRAG_Y = require_settle.DRAG_Y;
361
+ exports.animateSettle = require_live_animate_settle.animateSettle;
362
+ exports.announcement = require_pure_a11y.announcement;
363
+ exports.applyBoardDrop = require_pure_apply.applyBoardDrop;
364
+ exports.applyListDrop = require_pure_apply.applyListDrop;
365
+ exports.applyTreeDrop = require_pure_apply.applyTreeDrop;
366
+ exports.arrayMove = require_pure_reorder.arrayMove;
367
+ exports.autoscroll = require_live.autoscroll;
368
+ exports.boardZones = require_state.boardZones;
369
+ exports.carrySelection = require_state.carrySelection;
370
+ exports.clonePreview = require_live.clonePreview;
371
+ exports.createDnd = require_live.createDnd;
372
+ exports.createDragInputSensor = require_pure_sensors.createDragInputSensor;
373
+ exports.createGestureRecognizer = createGestureRecognizer;
374
+ exports.createKeyboardSensor = require_pure_sensors.createKeyboardSensor;
375
+ exports.createPointerSensor = require_pure_sensors.createPointerSensor;
376
+ exports.defaultMessages = require_pure_a11y.defaultMessages;
377
+ exports.dragReducer = require_state.dragReducer;
378
+ exports.dropIndexAt = require_pure_reorder.dropIndexAt;
379
+ exports.expandAfter = require_live.expandAfter;
380
+ exports.flipSettle = require_settle.flipSettle;
381
+ exports.handleAttributes = require_pure_a11y.handleAttributes;
382
+ exports.hitTest = require_state.hitTest;
383
+ exports.idle = require_state.idle;
384
+ exports.inPlacePreview = require_live.inPlacePreview;
385
+ exports.isDragged = require_state.isDragged;
386
+ exports.keyboardInstructions = require_pure_a11y.keyboardInstructions;
387
+ exports.measureRects = measureRects;
388
+ exports.moveWithin = require_pure_reorder.moveWithin;
389
+ exports.nearestInDirection = require_pure_spatial.nearestInDirection;
390
+ exports.noModifiers = require_state.noModifiers;
391
+ exports.observeRects = observeRects;
392
+ exports.observeZones = require_live.observeZones;
393
+ exports.operationFor = require_state.operationFor;
394
+ exports.operations = require_state.operations;
395
+ exports.outline = require_pure_tree.outline;
396
+ exports.overlayPreview = require_live.overlayPreview;
397
+ exports.placeholderOf = require_state.placeholderOf;
398
+ exports.projectTree = require_pure_tree.projectTree;
399
+ exports.recognize = recognize;
400
+ exports.reorder = require_pure_reorder.reorder;
401
+ exports.resultOf = require_state.resultOf;
402
+ exports.selection = require_live.selection;
403
+ exports.shiftOf = require_state.shiftOf;
404
+ exports.spatialMove = require_pure_spatial.spatialMove;
405
+ exports.springSettle = require_live_flip.springSettle;
406
+ exports.styleChannel = require_settle.styleChannel;
407
+ exports.subtreeEnd = require_pure_tree.subtreeEnd;
408
+ exports.systemClock = systemClock;
409
+ exports.transformCss = transformCss;
410
+ exports.treeZones = require_live.treeZones;
411
+ exports.varsChannel = require_settle.varsChannel;
412
+ exports.virtualZones = require_live.virtualZones;
413
+ exports.zoneFlags = require_state.zoneFlags;
@@ -0,0 +1,139 @@
1
+ import { A as ZoneBase, B as boardZones, C as Placement, D as TreeRules, E as StepDirection, F as noModifiers, H as operationFor, I as placeholderOf, L as resultOf, M as hitTest, N as idle, O as TreeZone, P as isDragged, R as shiftOf, S as Placeholder, T as Root, U as operations, V as carrySelection, _ as ItemTarget, a as DragLayout, b as Operation, c as DragState, d as DropResult, f as DropTarget, g as ItemHit, h as InputKind, i as DragInput, j as dragReducer, k as Zone, l as Dragging, m as Hit, n as Carry, o as DragPlugin, p as GapTarget, r as DragConfig, s as DragSource, t as AnyPlugin, u as DropPolicy, v as ListZone, w as Proposal, x as Outline, y as Modifiers, z as zoneFlags } from "./state-BEKGNZY1.cjs";
2
+ import { TreeProjection, TreeProjectionSource, outline, projectTree, subtreeEnd } from "./pure/tree.cjs";
3
+ import { ApplyOptions, TreeApplyOptions, applyBoardDrop, applyListDrop, applyTreeDrop } from "./pure/apply.cjs";
4
+ import { a as handleAttributes, i as defaultMessages, n as MessageContext, o as keyboardInstructions, r as announcement, t as DragMessages } from "./a11y-BOpF8vx8.cjs";
5
+ import { A as PreviewStrategy, C as DRAG_X, D as styleChannel, E as DragChannelFactory, M as inPlacePreview, N as overlayPreview, O as varsChannel, S as DRAG_HIDDEN, T as DragChannel, _ as ItemsShape, a as treeZones, b as ZoneSpec, c as DndOptions, d as DndZone, f as LiveDrag, g as AnyZoneSpec, h as createDnd, i as selection, j as clonePreview, k as Preview, l as DndPlugin, m as ZoneSpecOf, n as autoscroll, o as virtualZones, p as OperationsOf, r as observeZones, s as Dnd, t as expandAfter, u as DndPlugins, v as SourceShape, w as DRAG_Y, x as ZoneSpecBase, y as TreeSpec } from "./index-DDuIvuzA.cjs";
6
+ import { a as flipSettle, i as SettleStrategy, n as SettleDrop, r as SettleRun, t as SettleContext } from "./settle-DzdqbH4S.cjs";
7
+ import { springSettle } from "./live/flip.cjs";
8
+ import { AnimateSettleOptions, animateSettle } from "./live/animate-settle.cjs";
9
+ import { C as createPointerSensor, S as createKeyboardSensor, T as systemClock, _ as PointerSensorState, a as DragInputActivation, b as SensorResult, c as DragInputSensorOptions, d as IdlePointerState, f as KeyboardSensorEvent, g as PointerSensorOptions, h as PointerSensorEvent, i as DragEvent, l as DragInputSensorState, m as KeyboardSensorState, n as ActivePointerState, o as DragInputSensor, p as KeyboardSensorOptions, r as CancelReason, s as DragInputSensorEvent, t as ActiveKeyboardState, u as IdleKeyboardState, v as PressedPointerState, w as Clock, x as createDragInputSensor, y as SensorReducer } from "./sensors-C9RnMr6P.cjs";
10
+ import { ReorderMove, ReorderOffset, arrayMove, dropIndexAt, moveWithin, reorder } from "./pure/reorder.cjs";
11
+ import { Direction, NearestInDirectionOptions, SpatialCandidate, SpatialMoveOptions, nearestInDirection, spatialMove } from "./pure/spatial.cjs";
12
+ import { Point, Rect } from "@bevelo/runtime/geometry";
13
+ /** A DOM element plus the identity a host knows it by. */
14
+ interface MeasuredSource {
15
+ readonly id: string;
16
+ readonly element: Element;
17
+ }
18
+ /** One measured element: its id and its viewport box. */
19
+ interface MeasuredRect {
20
+ readonly id: string;
21
+ readonly rect: Rect;
22
+ }
23
+ /**
24
+ * Measures elements into plain rects. A DOMRect is a live object with mutation methods, so it
25
+ * is copied: a transform applied after measuring cannot change a rect a host still holds.
26
+ */
27
+ export declare function measureRects(elements: Iterable<MeasuredSource>): readonly MeasuredRect[];
28
+ /**
29
+ * Reports fresh measurements whenever an element resizes or the page scrolls.
30
+ *
31
+ * Returns the unsubscribe; calling it twice is safe. The initial measurement is not reported
32
+ * here (measure once with measureRects before listening), because a synchronous first call
33
+ * would arrive before the caller had stored the disposer.
34
+ *
35
+ * Scroll is listened to in the capture phase on window: a scrollable ancestor does not bubble
36
+ * its scroll event, and one listener sees every container. ResizeObserver is read at call
37
+ * time and skipped when absent (jsdom, SSR).
38
+ */
39
+ export declare function observeRects(elements: Iterable<MeasuredSource>, onChange: (items: readonly MeasuredRect[]) => void): () => void;
40
+ /** What a pointer did, as far as callers are concerned. */
41
+ type GestureKind = "tap" | "long-press" | "swipe" | "drag" | "pinch";
42
+ /** The dominant axis of a swipe, in viewport coordinates (y grows downwards). */
43
+ type SwipeDirection = "left" | "right" | "up" | "down";
44
+ /**
45
+ * One pointer sample. The binding forwards pointer events, and it may inject a
46
+ * synthetic move at the held point so a press can be recognised while it is
47
+ * still down.
48
+ *
49
+ * pointers is the host's count of pointers currently down. It is metadata: the
50
+ * recogniser counts the pointers it has seen go down itself, because only those
51
+ * have a position and a pinch cannot be measured from a count alone.
52
+ */
53
+ interface GestureEvent {
54
+ type: "down" | "move" | "up" | "cancel";
55
+ pointerId: number;
56
+ x: number;
57
+ y: number;
58
+ /** Milliseconds, from the host's clock. */
59
+ time: number;
60
+ /** How many pointers are currently down (2 means a pinch is possible). */
61
+ pointers?: number;
62
+ }
63
+ /**
64
+ * A recognised gesture, reported once it settles.
65
+ *
66
+ * distance is the straight-line distance from start to end (not the path
67
+ * travelled), and velocity is that same delta divided by durationMs. direction
68
+ * is set only for a swipe and scale only for a pinch; every other kind omits
69
+ * them rather than carrying undefined, so a presence check is meaningful.
70
+ */
71
+ interface GestureResult {
72
+ kind: GestureKind;
73
+ start: Point;
74
+ end: Point;
75
+ delta: Point;
76
+ distance: number;
77
+ direction?: SwipeDirection;
78
+ velocity: Point;
79
+ scale?: number;
80
+ durationMs: number;
81
+ }
82
+ /** Thresholds; the defaults live here once, and a caller may override any of them. */
83
+ interface GestureOptions {
84
+ /** A press shorter than this that does not move is a tap. Default 300. */
85
+ longPressMs?: number;
86
+ /** Distance a press may move and still be a tap. Default 8. */
87
+ tapSlop?: number;
88
+ /** Distance that makes a move a swipe/drag rather than a tap. Default 24. */
89
+ swipeDistance?: number;
90
+ /** Velocity (px/ms) that makes it a swipe even under swipeDistance. Default 0.5. */
91
+ swipeVelocity?: number;
92
+ /** Only report swipes whose direction is allowed. Default all four. */
93
+ axes?: readonly SwipeDirection[];
94
+ }
95
+ /** The recogniser as a component binding holds it: feed events, ask, reset. */
96
+ interface GestureRecognizer {
97
+ /** Returns a result when a gesture settles, undefined while it is still running. */
98
+ handle(event: GestureEvent): GestureResult | undefined;
99
+ /** True while a pointer is down. */
100
+ active(): boolean;
101
+ reset(): void;
102
+ }
103
+ /**
104
+ * Builds a recogniser.
105
+ *
106
+ * State is deliberately flat and small: positions of the pointers seen so far,
107
+ * the origin and time of the press, the furthest the primary pointer has been
108
+ * from it, the pinch (if one started) and whether the gesture already reported.
109
+ */
110
+ export declare function createGestureRecognizer(options?: GestureOptions): GestureRecognizer;
111
+ /**
112
+ * Recognises a whole event list at once — the seam tests and a replay use.
113
+ *
114
+ * This is the same recogniser run in a loop, so a recorded interaction cannot
115
+ * disagree with the incremental path a live binding uses.
116
+ */
117
+ export declare function recognize(events: readonly GestureEvent[], options?: GestureOptions): readonly GestureResult[];
118
+ /**
119
+ * A transform in the shape this engine's plan entries carry (x/y, plus an optional scale).
120
+ *
121
+ * The scale is optional because most plans never name one: a reorder moves rows, it does
122
+ * not resize them, and a transform with no scale writes the shorter string.
123
+ */
124
+ interface CssTransform extends Point {
125
+ readonly scaleX?: number;
126
+ readonly scaleY?: number;
127
+ }
128
+ /**
129
+ * The CSS transform to write for one offset.
130
+ *
131
+ * Translation first, then scale when either scale is named: an omitted scale means 1, so
132
+ * a transform that names only scaleX still carries both. A null or undefined transform has no
133
+ * string, which is what an absent inline transform is.
134
+ *
135
+ * Numbers are not rounded. A plan's offsets are fractional whenever the measured slots
136
+ * are, and rounding them here would be a second decision about where a row sits.
137
+ */
138
+ export declare function transformCss(transform: CssTransform | null | undefined): string | undefined;
139
+ export { type ActiveKeyboardState, type ActivePointerState, type AnimateSettleOptions, type AnyPlugin, type AnyZoneSpec, type ApplyOptions, type CancelReason, type Carry, type Clock, type CssTransform, DRAG_HIDDEN, DRAG_X, DRAG_Y, type Direction, type Dnd, type DndOptions, type DndPlugin, type DndPlugins, type DndZone, type DragChannel, type DragChannelFactory, type DragConfig, type DragEvent, type DragInput, type DragInputActivation, type DragInputSensor, type DragInputSensorEvent, type DragInputSensorOptions, type DragInputSensorState, type DragLayout, type DragMessages, type DragPlugin, type DragSource, type DragState, type Dragging, type DropPolicy, type DropResult, type DropTarget, type GapTarget, type GestureEvent, type GestureKind, type GestureOptions, type GestureRecognizer, type GestureResult, type Hit, type IdleKeyboardState, type IdlePointerState, type InputKind, type ItemHit, type ItemTarget, type ItemsShape, type KeyboardSensorEvent, type KeyboardSensorOptions, type KeyboardSensorState, type ListZone, type LiveDrag, type MeasuredRect, type MeasuredSource, type MessageContext, type Modifiers, type NearestInDirectionOptions, type Operation, type OperationsOf, type Outline, type Placeholder, type Placement, type PointerSensorEvent, type PointerSensorOptions, type PointerSensorState, type PressedPointerState, type Preview, type PreviewStrategy, type Proposal, type ReorderMove, type ReorderOffset, type Root, type SensorReducer, type SensorResult, type SettleContext, type SettleDrop, type SettleRun, type SettleStrategy, type SourceShape, type SpatialCandidate, type SpatialMoveOptions, type StepDirection, type SwipeDirection, type TreeApplyOptions, type TreeProjection, type TreeProjectionSource, type TreeRules, type TreeSpec, type TreeZone, type Zone, type ZoneBase, type ZoneSpec, type ZoneSpecBase, type ZoneSpecOf, animateSettle, announcement, applyBoardDrop, applyListDrop, applyTreeDrop, arrayMove, autoscroll, boardZones, carrySelection, clonePreview, createDnd, createDragInputSensor, createKeyboardSensor, createPointerSensor, defaultMessages, dragReducer, dropIndexAt, expandAfter, flipSettle, handleAttributes, hitTest, idle, inPlacePreview, isDragged, keyboardInstructions, moveWithin, nearestInDirection, noModifiers, observeZones, operationFor, operations, outline, overlayPreview, placeholderOf, projectTree, reorder, resultOf, selection, shiftOf, spatialMove, springSettle, styleChannel, subtreeEnd, systemClock, treeZones, varsChannel, virtualZones, zoneFlags };