@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
@@ -0,0 +1,77 @@
1
+ import { Point, Rect } from "@bevelo/runtime/geometry";
2
+ /**
3
+ * One item's travel between two slots. `from` and `to` are indices in the list
4
+ * as it is being rendered; `dx`/`dy` are the offset to add to the item's
5
+ * current rect to put it on its destination slot's centre. The moved item and
6
+ * each displaced neighbour get one, so a renderer can apply them all with a
7
+ * single loop and a CSS transform.
8
+ */
9
+ export interface ReorderOffset {
10
+ readonly from: number;
11
+ readonly to: number;
12
+ readonly dx: number;
13
+ readonly dy: number;
14
+ }
15
+ /**
16
+ * The visual half of one move: the item that travels the longest distance and
17
+ * the neighbours that shift one slot to close the gap. The relative order of
18
+ * `displaced` follows the list, not the direction of travel.
19
+ */
20
+ export interface ReorderMove {
21
+ readonly moved: ReorderOffset;
22
+ readonly displaced: readonly ReorderOffset[];
23
+ }
24
+ /**
25
+ * The order after moving the item at `from` to `to`.
26
+ *
27
+ * Pure and stable: the input array is never touched, and the moved item keeps
28
+ * its relative order against everything else. Out-of-range indices and a move
29
+ * onto the item's own slot both return a copy of the input unchanged — the
30
+ * answer a caller can use without a branch, matching `applySort`'s treatment
31
+ * of an unknown id.
32
+ */
33
+ export declare function reorder<T>(items: readonly T[], from: number, to: number): T[];
34
+ /**
35
+ * The order after moving one item, with relative indices allowed.
36
+ *
37
+ * `arrayMove` is `reorder` with one extra rule: a negative `to`
38
+ * counts back from the end, so -1 is the last slot, and a `to` equal to the
39
+ * length appends (the slot after the last one a host reads from the list). Both
40
+ * are normalised to an index and handed to `reorder`, so there is one
41
+ * implementation of the move and one contract for its edges: an index that names
42
+ * a slot in the list moves the item, and an index that names nothing returns a
43
+ * copy unchanged, rather than splicing `undefined` into the list.
44
+ */
45
+ export declare function arrayMove<T>(items: readonly T[], from: number, to: number): T[];
46
+ /**
47
+ * The offsets that animate a move inside one list.
48
+ *
49
+ * The moved item travels from its own slot's centre to the destination slot's
50
+ * centre. Every slot it passes is filled by its neighbour shifting one place
51
+ * towards the vacated slot: moving down, the rows after it move up; moving up,
52
+ * the rows before it move down. Because the offsets are centres rather than
53
+ * rect origins, they also carry a perpendicular component when the rects are
54
+ * laid out in a grid.
55
+ *
56
+ * Returns undefined for an out-of-range move (nothing sensible to animate), and
57
+ * a zero-length move for `from === to` (the caller may skip work, but the answer
58
+ * is still usable). Broken (NaN) rects give NaN offsets rather than throwing:
59
+ * this runs inside a pointer handler.
60
+ */
61
+ export declare function moveWithin(rects: readonly Rect[], from: number, to: number): ReorderMove | undefined;
62
+ /**
63
+ * The slot a point would drop into, by the midpoint rule: an item owns the half
64
+ * of its rect before its centre, so the index is the number of rects whose
65
+ * centre the point has passed. That is the insertion index in the list as it is
66
+ * rendered (before the dragged item is removed); a same-list caller adjusts for
67
+ * the removal the same way `applyBoardMove` does.
68
+ *
69
+ * A point exactly on a midpoint counts as past it, which is the tie-break a
70
+ * pointer expects: dropping on the line between two items goes after the first
71
+ * one. The axis names the coordinate that orders the rects — horizontal for a
72
+ * rail, vertical for a column. Broken rects are skipped rather than allowed to
73
+ * decide where an item lands, and a non-finite point has no slot to report and
74
+ * returns 0 (the insertion that cannot put the item on the wrong side of a
75
+ * valid midpoint).
76
+ */
77
+ export declare function dropIndexAt(rects: readonly Rect[], point: Point, axis: "vertical" | "horizontal"): number;
@@ -0,0 +1,77 @@
1
+ import { Point, Rect } from "@bevelo/runtime/geometry";
2
+ /**
3
+ * One item's travel between two slots. `from` and `to` are indices in the list
4
+ * as it is being rendered; `dx`/`dy` are the offset to add to the item's
5
+ * current rect to put it on its destination slot's centre. The moved item and
6
+ * each displaced neighbour get one, so a renderer can apply them all with a
7
+ * single loop and a CSS transform.
8
+ */
9
+ export interface ReorderOffset {
10
+ readonly from: number;
11
+ readonly to: number;
12
+ readonly dx: number;
13
+ readonly dy: number;
14
+ }
15
+ /**
16
+ * The visual half of one move: the item that travels the longest distance and
17
+ * the neighbours that shift one slot to close the gap. The relative order of
18
+ * `displaced` follows the list, not the direction of travel.
19
+ */
20
+ export interface ReorderMove {
21
+ readonly moved: ReorderOffset;
22
+ readonly displaced: readonly ReorderOffset[];
23
+ }
24
+ /**
25
+ * The order after moving the item at `from` to `to`.
26
+ *
27
+ * Pure and stable: the input array is never touched, and the moved item keeps
28
+ * its relative order against everything else. Out-of-range indices and a move
29
+ * onto the item's own slot both return a copy of the input unchanged — the
30
+ * answer a caller can use without a branch, matching `applySort`'s treatment
31
+ * of an unknown id.
32
+ */
33
+ export declare function reorder<T>(items: readonly T[], from: number, to: number): T[];
34
+ /**
35
+ * The order after moving one item, with relative indices allowed.
36
+ *
37
+ * `arrayMove` is `reorder` with one extra rule: a negative `to`
38
+ * counts back from the end, so -1 is the last slot, and a `to` equal to the
39
+ * length appends (the slot after the last one a host reads from the list). Both
40
+ * are normalised to an index and handed to `reorder`, so there is one
41
+ * implementation of the move and one contract for its edges: an index that names
42
+ * a slot in the list moves the item, and an index that names nothing returns a
43
+ * copy unchanged, rather than splicing `undefined` into the list.
44
+ */
45
+ export declare function arrayMove<T>(items: readonly T[], from: number, to: number): T[];
46
+ /**
47
+ * The offsets that animate a move inside one list.
48
+ *
49
+ * The moved item travels from its own slot's centre to the destination slot's
50
+ * centre. Every slot it passes is filled by its neighbour shifting one place
51
+ * towards the vacated slot: moving down, the rows after it move up; moving up,
52
+ * the rows before it move down. Because the offsets are centres rather than
53
+ * rect origins, they also carry a perpendicular component when the rects are
54
+ * laid out in a grid.
55
+ *
56
+ * Returns undefined for an out-of-range move (nothing sensible to animate), and
57
+ * a zero-length move for `from === to` (the caller may skip work, but the answer
58
+ * is still usable). Broken (NaN) rects give NaN offsets rather than throwing:
59
+ * this runs inside a pointer handler.
60
+ */
61
+ export declare function moveWithin(rects: readonly Rect[], from: number, to: number): ReorderMove | undefined;
62
+ /**
63
+ * The slot a point would drop into, by the midpoint rule: an item owns the half
64
+ * of its rect before its centre, so the index is the number of rects whose
65
+ * centre the point has passed. That is the insertion index in the list as it is
66
+ * rendered (before the dragged item is removed); a same-list caller adjusts for
67
+ * the removal the same way `applyBoardMove` does.
68
+ *
69
+ * A point exactly on a midpoint counts as past it, which is the tie-break a
70
+ * pointer expects: dropping on the line between two items goes after the first
71
+ * one. The axis names the coordinate that orders the rects — horizontal for a
72
+ * rail, vertical for a column. Broken rects are skipped rather than allowed to
73
+ * decide where an item lands, and a non-finite point has no slot to report and
74
+ * returns 0 (the insertion that cannot put the item on the wrong side of a
75
+ * valid midpoint).
76
+ */
77
+ export declare function dropIndexAt(rects: readonly Rect[], point: Point, axis: "vertical" | "horizontal"): number;
@@ -0,0 +1,117 @@
1
+ import { center } from "@bevelo/runtime/geometry";
2
+ // src/pure/reorder.ts
3
+ /**
4
+ * The order after moving the item at `from` to `to`.
5
+ *
6
+ * Pure and stable: the input array is never touched, and the moved item keeps
7
+ * its relative order against everything else. Out-of-range indices and a move
8
+ * onto the item's own slot both return a copy of the input unchanged — the
9
+ * answer a caller can use without a branch, matching `applySort`'s treatment
10
+ * of an unknown id.
11
+ */
12
+ function reorder(items, from, to) {
13
+ const next = [...items];
14
+ if (!Number.isInteger(from) || !Number.isInteger(to)) return next;
15
+ if (from < 0 || from >= items.length || to < 0 || to >= items.length || from === to) return next;
16
+ const [moved] = next.splice(from, 1);
17
+ if (moved === void 0) return [...items];
18
+ next.splice(to, 0, moved);
19
+ return next;
20
+ }
21
+ /**
22
+ * The order after moving one item, with relative indices allowed.
23
+ *
24
+ * `arrayMove` is `reorder` with one extra rule: a negative `to`
25
+ * counts back from the end, so -1 is the last slot, and a `to` equal to the
26
+ * length appends (the slot after the last one a host reads from the list). Both
27
+ * are normalised to an index and handed to `reorder`, so there is one
28
+ * implementation of the move and one contract for its edges: an index that names
29
+ * a slot in the list moves the item, and an index that names nothing returns a
30
+ * copy unchanged, rather than splicing `undefined` into the list.
31
+ */
32
+ function arrayMove(items, from, to) {
33
+ const target = to < 0 ? items.length + to : to;
34
+ if (!Number.isInteger(from) || !Number.isInteger(target)) return [...items];
35
+ if (target === items.length) return reorder(items, from, items.length - 1);
36
+ return reorder(items, from, target);
37
+ }
38
+ /**
39
+ * The offsets that animate a move inside one list.
40
+ *
41
+ * The moved item travels from its own slot's centre to the destination slot's
42
+ * centre. Every slot it passes is filled by its neighbour shifting one place
43
+ * towards the vacated slot: moving down, the rows after it move up; moving up,
44
+ * the rows before it move down. Because the offsets are centres rather than
45
+ * rect origins, they also carry a perpendicular component when the rects are
46
+ * laid out in a grid.
47
+ *
48
+ * Returns undefined for an out-of-range move (nothing sensible to animate), and
49
+ * a zero-length move for `from === to` (the caller may skip work, but the answer
50
+ * is still usable). Broken (NaN) rects give NaN offsets rather than throwing:
51
+ * this runs inside a pointer handler.
52
+ */
53
+ function moveWithin(rects, from, to) {
54
+ if (!Number.isInteger(from) || !Number.isInteger(to)) return void 0;
55
+ if (from < 0 || from >= rects.length || to < 0 || to >= rects.length) return void 0;
56
+ const origin = rects[from];
57
+ const destination = rects[to];
58
+ if (origin === void 0 || destination === void 0) return void 0;
59
+ const moved = offsetBetween(origin, destination, from, to);
60
+ if (from === to) return {
61
+ moved,
62
+ displaced: []
63
+ };
64
+ const displaced = [];
65
+ if (from < to) for (let index = from + 1; index <= to; index += 1) {
66
+ const rect = rects[index];
67
+ const target = rects[index - 1];
68
+ if (rect !== void 0 && target !== void 0) displaced.push(offsetBetween(rect, target, index, index - 1));
69
+ }
70
+ else for (let index = to; index < from; index += 1) {
71
+ const rect = rects[index];
72
+ const target = rects[index + 1];
73
+ if (rect !== void 0 && target !== void 0) displaced.push(offsetBetween(rect, target, index, index + 1));
74
+ }
75
+ return {
76
+ moved,
77
+ displaced
78
+ };
79
+ }
80
+ /** The centre-to-centre offset from one slot's rect to another's. */
81
+ function offsetBetween(from, to, fromIndex, toIndex) {
82
+ const start = center(from);
83
+ const end = center(to);
84
+ return {
85
+ from: fromIndex,
86
+ to: toIndex,
87
+ dx: end.x - start.x,
88
+ dy: end.y - start.y
89
+ };
90
+ }
91
+ /**
92
+ * The slot a point would drop into, by the midpoint rule: an item owns the half
93
+ * of its rect before its centre, so the index is the number of rects whose
94
+ * centre the point has passed. That is the insertion index in the list as it is
95
+ * rendered (before the dragged item is removed); a same-list caller adjusts for
96
+ * the removal the same way `applyBoardMove` does.
97
+ *
98
+ * A point exactly on a midpoint counts as past it, which is the tie-break a
99
+ * pointer expects: dropping on the line between two items goes after the first
100
+ * one. The axis names the coordinate that orders the rects — horizontal for a
101
+ * rail, vertical for a column. Broken rects are skipped rather than allowed to
102
+ * decide where an item lands, and a non-finite point has no slot to report and
103
+ * returns 0 (the insertion that cannot put the item on the wrong side of a
104
+ * valid midpoint).
105
+ */
106
+ function dropIndexAt(rects, point, axis) {
107
+ const coordinate = axis === "vertical" ? point.y : point.x;
108
+ if (!Number.isFinite(coordinate)) return 0;
109
+ let index = 0;
110
+ for (const rect of rects) {
111
+ const midpoint = axis === "vertical" ? center(rect).y : center(rect).x;
112
+ if (!Number.isFinite(midpoint)) continue;
113
+ if (midpoint <= coordinate) index += 1;
114
+ }
115
+ return index;
116
+ }
117
+ export { arrayMove, dropIndexAt, moveWithin, reorder };
@@ -0,0 +1,243 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ // src/pure/sensors.ts
3
+ const IDLE_POINTER = { phase: "idle" };
4
+ /**
5
+ * A drag that starts after N pixels of travel or a long press.
6
+ *
7
+ * The threshold is deliberately checked on pointermove rather than on
8
+ * pointerdown: starting on the press would swallow every click, and the whole
9
+ * point of the pending state is that a click and a drag can share a press.
10
+ *
11
+ * Events from a pointer other than the one that pressed are ignored, because a
12
+ * second finger must not steer the drag the first one started.
13
+ */
14
+ function createPointerSensor(options) {
15
+ const { activationDistance = 4, delayMs = 0, delayTolerance, clock } = options;
16
+ return (state, event) => {
17
+ const current = state ?? IDLE_POINTER;
18
+ if (current.phase === "idle") {
19
+ if (event.type !== "pointerdown") return { state: current };
20
+ const now = clock.now();
21
+ return {
22
+ state: {
23
+ phase: "pressed",
24
+ id: event.id,
25
+ pointerId: event.pointerId,
26
+ origin: event.at,
27
+ pressedAt: now
28
+ },
29
+ emit: [{
30
+ type: "start",
31
+ id: event.id,
32
+ atTime: now
33
+ }]
34
+ };
35
+ }
36
+ if (current.phase === "pressed") {
37
+ if (event.type === "pointerdown") return { state: current };
38
+ if (event.pointerId !== current.pointerId) return { state: current };
39
+ if (event.type === "pointerup") return {
40
+ state: IDLE_POINTER,
41
+ emit: [{
42
+ type: "cancel",
43
+ reason: "released"
44
+ }]
45
+ };
46
+ if (event.type === "pointercancel") return {
47
+ state: IDLE_POINTER,
48
+ emit: [{
49
+ type: "cancel",
50
+ reason: "pointercancel"
51
+ }]
52
+ };
53
+ const now = clock.now();
54
+ const elapsed = now - current.pressedAt;
55
+ const distance = Math.hypot(event.at.x - current.origin.x, event.at.y - current.origin.y);
56
+ const held = delayMs > 0 && elapsed >= delayMs;
57
+ if (delayMs > 0 && delayTolerance !== void 0 && !held && distance > delayTolerance) return {
58
+ state: IDLE_POINTER,
59
+ emit: [{
60
+ type: "cancel",
61
+ reason: "tolerance"
62
+ }]
63
+ };
64
+ if (held || distance >= activationDistance) return {
65
+ state: {
66
+ phase: "active",
67
+ id: current.id,
68
+ pointerId: current.pointerId,
69
+ last: current.origin,
70
+ startedAt: now
71
+ },
72
+ emit: [{ type: "activate" }]
73
+ };
74
+ return { state: current };
75
+ }
76
+ if (event.type === "pointerdown") return { state: current };
77
+ if (event.pointerId !== current.pointerId) return { state: current };
78
+ if (event.type === "pointerup") return {
79
+ state: IDLE_POINTER,
80
+ emit: [{ type: "drop" }]
81
+ };
82
+ if (event.type === "pointercancel") return {
83
+ state: IDLE_POINTER,
84
+ emit: [{
85
+ type: "cancel",
86
+ reason: "pointercancel"
87
+ }]
88
+ };
89
+ const by = {
90
+ x: event.at.x - current.last.x,
91
+ y: event.at.y - current.last.y
92
+ };
93
+ return {
94
+ state: {
95
+ ...current,
96
+ last: event.at
97
+ },
98
+ emit: [{
99
+ type: "move",
100
+ by,
101
+ pointer: event.at
102
+ }]
103
+ };
104
+ };
105
+ }
106
+ const IDLE_KEYBOARD = { phase: "idle" };
107
+ /** Space arrives as " " in modern browsers and as "Spacebar" or "Space" in older ones. */
108
+ const ACTIVATE_KEYS = /* @__PURE__ */ new Set([
109
+ " ",
110
+ "Spacebar",
111
+ "Space",
112
+ "Enter"
113
+ ]);
114
+ const CANCEL_KEYS = /* @__PURE__ */ new Set(["Escape", "Esc"]);
115
+ /**
116
+ * A keyboard drag: Space or Enter lifts the focused item, arrows move it, Space
117
+ * or Enter drops it and Escape cancels.
118
+ *
119
+ * The sensor emits exactly the events the pointer sensor emits, so the machine
120
+ * (and its sorting) runs unchanged for both input methods. Shift picks the large
121
+ * step, because the key set is arrows/space/enter/escape and there is
122
+ * no other way to ask for a bigger jump.
123
+ */
124
+ function createKeyboardSensor(options) {
125
+ const { step = 20, stepLarge = 40, clock } = options;
126
+ const read = (value) => typeof value === "function" ? value() : value;
127
+ return (state, event) => {
128
+ const current = state ?? IDLE_KEYBOARD;
129
+ if (current.phase === "idle") {
130
+ if (!ACTIVATE_KEYS.has(event.key) || event.id === void 0) return { state: current };
131
+ const now = clock.now();
132
+ return {
133
+ state: {
134
+ phase: "active",
135
+ id: event.id,
136
+ startedAt: now
137
+ },
138
+ emit: [{
139
+ type: "start",
140
+ id: event.id,
141
+ atTime: now
142
+ }, { type: "activate" }]
143
+ };
144
+ }
145
+ if (CANCEL_KEYS.has(event.key)) return {
146
+ state: IDLE_KEYBOARD,
147
+ emit: [{
148
+ type: "cancel",
149
+ reason: "escape"
150
+ }]
151
+ };
152
+ if (ACTIVATE_KEYS.has(event.key)) return {
153
+ state: IDLE_KEYBOARD,
154
+ emit: [{ type: "drop" }]
155
+ };
156
+ const size = event.shiftKey === true ? read(stepLarge) : read(step);
157
+ const by = keyDelta(event.key, size);
158
+ if (by === void 0) return { state: current };
159
+ return {
160
+ state: current,
161
+ emit: [{
162
+ type: "move",
163
+ by
164
+ }]
165
+ };
166
+ };
167
+ }
168
+ /** The movement one arrow key asks for, or undefined for a key we do not handle. */
169
+ function keyDelta(key, step) {
170
+ switch (key) {
171
+ case "ArrowUp": return {
172
+ x: 0,
173
+ y: -step
174
+ };
175
+ case "ArrowDown": return {
176
+ x: 0,
177
+ y: step
178
+ };
179
+ case "ArrowLeft": return {
180
+ x: -step,
181
+ y: 0
182
+ };
183
+ case "ArrowRight": return {
184
+ x: step,
185
+ y: 0
186
+ };
187
+ default: return;
188
+ }
189
+ }
190
+ /**
191
+ * Composes the pointer and keyboard sensors behind one reducer.
192
+ *
193
+ * The composition is small, but it is the part every strict drag primitive would
194
+ * otherwise copy: sensor state is channel-independent, device time is an input
195
+ * rather than a platform read, and activation options are re-read without
196
+ * resetting sensor state in the middle of a gesture.
197
+ */
198
+ function createDragInputSensor(options) {
199
+ let atTime = 0;
200
+ const clock = { now: () => atTime };
201
+ const pointer = (state, event) => {
202
+ const activation = options.activation();
203
+ return createPointerSensor({
204
+ activationDistance: activation.distance,
205
+ delayMs: activation.delayMs,
206
+ ...activation.delayTolerance === void 0 ? {} : { delayTolerance: activation.delayTolerance },
207
+ clock
208
+ })(state, event);
209
+ };
210
+ const keyboard = createKeyboardSensor({
211
+ step: options.keyboardStep,
212
+ stepLarge: options.keyboardStepLarge ?? (() => options.keyboardStep() * 2),
213
+ clock
214
+ });
215
+ return {
216
+ setTime(next) {
217
+ atTime = next;
218
+ },
219
+ reducer(state, input) {
220
+ if (input.channel === "pointer") {
221
+ const result = pointer(state?.pointer, input.event);
222
+ return {
223
+ state: {
224
+ ...state ?? {},
225
+ pointer: result.state
226
+ },
227
+ ...result.emit === void 0 ? {} : { emit: result.emit }
228
+ };
229
+ }
230
+ const result = keyboard(state?.keyboard, input.event);
231
+ return {
232
+ state: {
233
+ ...state ?? {},
234
+ keyboard: result.state
235
+ },
236
+ ...result.emit === void 0 ? {} : { emit: result.emit }
237
+ };
238
+ }
239
+ };
240
+ }
241
+ exports.createDragInputSensor = createDragInputSensor;
242
+ exports.createKeyboardSensor = createKeyboardSensor;
243
+ exports.createPointerSensor = createPointerSensor;
@@ -0,0 +1,2 @@
1
+ import { C as createPointerSensor, S as createKeyboardSensor, _ 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, x as createDragInputSensor, y as SensorReducer } from "../sensors-C9RnMr6P.cjs";
2
+ export { ActiveKeyboardState, ActivePointerState, CancelReason, DragEvent, DragInputActivation, DragInputSensor, DragInputSensorEvent, DragInputSensorOptions, DragInputSensorState, IdleKeyboardState, IdlePointerState, KeyboardSensorEvent, KeyboardSensorOptions, KeyboardSensorState, PointerSensorEvent, PointerSensorOptions, PointerSensorState, PressedPointerState, SensorReducer, SensorResult, createDragInputSensor, createKeyboardSensor, createPointerSensor };
@@ -0,0 +1,2 @@
1
+ import { C as createPointerSensor, S as createKeyboardSensor, _ 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, x as createDragInputSensor, y as SensorReducer } from "../sensors-C9RnMr6P.js";
2
+ export { ActiveKeyboardState, ActivePointerState, CancelReason, DragEvent, DragInputActivation, DragInputSensor, DragInputSensorEvent, DragInputSensorOptions, DragInputSensorState, IdleKeyboardState, IdlePointerState, KeyboardSensorEvent, KeyboardSensorOptions, KeyboardSensorState, PointerSensorEvent, PointerSensorOptions, PointerSensorState, PressedPointerState, SensorReducer, SensorResult, createDragInputSensor, createKeyboardSensor, createPointerSensor };