@wardic/dom 1.1.0 → 1.1.2

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 (253) hide show
  1. package/dist/DomProjectionSystem.js +3 -3
  2. package/dist/DomProjectionSystem.js.map +1 -1
  3. package/dist/FlushGate.d.ts +6 -6
  4. package/dist/FlushGate.d.ts.map +1 -1
  5. package/dist/FlushGate.js +7 -5
  6. package/dist/FlushGate.js.map +1 -1
  7. package/dist/ReorderController.js +3 -3
  8. package/dist/ReorderController.js.map +1 -1
  9. package/dist/Report.d.ts +1 -1
  10. package/dist/Report.d.ts.map +1 -1
  11. package/dist/Report.js +3 -2
  12. package/dist/Report.js.map +1 -1
  13. package/dist/Style.d.ts +2 -1
  14. package/dist/Style.d.ts.map +1 -1
  15. package/dist/Style.js +3 -1
  16. package/dist/Style.js.map +1 -1
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.js +1 -1
  19. package/dist/internal/batch-handoff.d.ts +25 -0
  20. package/dist/internal/batch-handoff.d.ts.map +1 -0
  21. package/dist/internal/batch-handoff.js +64 -0
  22. package/dist/internal/batch-handoff.js.map +1 -0
  23. package/dist/internal/gate-environment.d.ts +4 -0
  24. package/dist/internal/gate-environment.d.ts.map +1 -0
  25. package/dist/internal/gate-environment.js +21 -0
  26. package/dist/internal/gate-environment.js.map +1 -0
  27. package/dist/internal/projection.js +14 -14
  28. package/dist/internal/projection.js.map +1 -1
  29. package/dist/internal/reorder.d.ts +2 -2
  30. package/dist/internal/reorder.d.ts.map +1 -1
  31. package/dist/internal/reorder.js +2 -2
  32. package/dist/internal/reorder.js.map +1 -1
  33. package/dist/internal/starting-style.d.ts +0 -83
  34. package/dist/internal/starting-style.d.ts.map +1 -1
  35. package/dist/internal/starting-style.js +16 -143
  36. package/dist/internal/starting-style.js.map +1 -1
  37. package/dist/unstable/AppearAnimations.d.ts +191 -0
  38. package/dist/unstable/AppearAnimations.d.ts.map +1 -0
  39. package/dist/unstable/AppearAnimations.js +561 -0
  40. package/dist/unstable/AppearAnimations.js.map +1 -0
  41. package/dist/unstable/BatchMembers.d.ts +513 -0
  42. package/dist/unstable/BatchMembers.d.ts.map +1 -0
  43. package/dist/unstable/BatchMembers.js +2490 -0
  44. package/dist/unstable/BatchMembers.js.map +1 -0
  45. package/dist/unstable/DomValues.d.ts +25 -0
  46. package/dist/unstable/DomValues.d.ts.map +1 -0
  47. package/dist/unstable/DomValues.js +45 -0
  48. package/dist/unstable/DomValues.js.map +1 -0
  49. package/dist/unstable/DragConstraints.d.ts +48 -0
  50. package/dist/unstable/DragConstraints.d.ts.map +1 -0
  51. package/dist/unstable/DragConstraints.js +49 -0
  52. package/dist/unstable/DragConstraints.js.map +1 -0
  53. package/dist/unstable/DragControls.d.ts +50 -0
  54. package/dist/unstable/DragControls.d.ts.map +1 -0
  55. package/dist/unstable/DragControls.js +55 -0
  56. package/dist/unstable/DragControls.js.map +1 -0
  57. package/dist/unstable/DragDefaults.d.ts +34 -0
  58. package/dist/unstable/DragDefaults.d.ts.map +1 -0
  59. package/dist/unstable/DragDefaults.js +47 -0
  60. package/dist/unstable/DragDefaults.js.map +1 -0
  61. package/dist/unstable/DragTrack.d.ts +236 -0
  62. package/dist/unstable/DragTrack.d.ts.map +1 -0
  63. package/dist/unstable/DragTrack.js +646 -0
  64. package/dist/unstable/DragTrack.js.map +1 -0
  65. package/dist/unstable/DragTransition.d.ts +22 -0
  66. package/dist/unstable/DragTransition.d.ts.map +1 -0
  67. package/dist/unstable/DragTransition.js +31 -0
  68. package/dist/unstable/DragTransition.js.map +1 -0
  69. package/dist/unstable/ElementSetup.d.ts +144 -0
  70. package/dist/unstable/ElementSetup.d.ts.map +1 -0
  71. package/dist/unstable/ElementSetup.js +297 -0
  72. package/dist/unstable/ElementSetup.js.map +1 -0
  73. package/dist/unstable/Feature.d.ts +221 -0
  74. package/dist/unstable/Feature.d.ts.map +1 -0
  75. package/dist/unstable/Feature.js +281 -0
  76. package/dist/unstable/Feature.js.map +1 -0
  77. package/dist/unstable/GestureFeatures.d.ts +30 -0
  78. package/dist/unstable/GestureFeatures.d.ts.map +1 -0
  79. package/dist/unstable/GestureFeatures.js +32 -0
  80. package/dist/unstable/GestureFeatures.js.map +1 -0
  81. package/dist/unstable/GestureInfo.d.ts +61 -0
  82. package/dist/unstable/GestureInfo.d.ts.map +1 -0
  83. package/dist/unstable/GestureInfo.js +23 -0
  84. package/dist/unstable/GestureInfo.js.map +1 -0
  85. package/dist/unstable/Imperative.d.ts +214 -0
  86. package/dist/unstable/Imperative.d.ts.map +1 -0
  87. package/dist/unstable/Imperative.js +768 -0
  88. package/dist/unstable/Imperative.js.map +1 -0
  89. package/dist/unstable/Instant.d.ts +46 -0
  90. package/dist/unstable/Instant.d.ts.map +1 -0
  91. package/dist/unstable/Instant.js +49 -0
  92. package/dist/unstable/Instant.js.map +1 -0
  93. package/dist/unstable/LayoutGroup.d.ts +14 -0
  94. package/dist/unstable/LayoutGroup.d.ts.map +1 -0
  95. package/dist/unstable/LayoutGroup.js +31 -0
  96. package/dist/unstable/LayoutGroup.js.map +1 -0
  97. package/dist/unstable/LayoutMember.d.ts +127 -0
  98. package/dist/unstable/LayoutMember.d.ts.map +1 -0
  99. package/dist/unstable/LayoutMember.js +176 -0
  100. package/dist/unstable/LayoutMember.js.map +1 -0
  101. package/dist/unstable/LiveStyle.d.ts +171 -0
  102. package/dist/unstable/LiveStyle.d.ts.map +1 -0
  103. package/dist/unstable/LiveStyle.js +329 -0
  104. package/dist/unstable/LiveStyle.js.map +1 -0
  105. package/dist/unstable/MemberHold.d.ts +3 -0
  106. package/dist/unstable/MemberHold.d.ts.map +1 -0
  107. package/dist/unstable/MemberHold.js +223 -0
  108. package/dist/unstable/MemberHold.js.map +1 -0
  109. package/dist/unstable/OwnerScope.d.ts +16 -0
  110. package/dist/unstable/OwnerScope.d.ts.map +1 -0
  111. package/dist/unstable/OwnerScope.js +35 -0
  112. package/dist/unstable/OwnerScope.js.map +1 -0
  113. package/dist/unstable/PresenceController.d.ts +128 -0
  114. package/dist/unstable/PresenceController.d.ts.map +1 -0
  115. package/dist/unstable/PresenceController.js +1427 -0
  116. package/dist/unstable/PresenceController.js.map +1 -0
  117. package/dist/unstable/Press.d.ts +26 -0
  118. package/dist/unstable/Press.d.ts.map +1 -0
  119. package/dist/unstable/Press.js +19 -0
  120. package/dist/unstable/Press.js.map +1 -0
  121. package/dist/unstable/ServerInterpolators.d.ts +17 -0
  122. package/dist/unstable/ServerInterpolators.d.ts.map +1 -0
  123. package/dist/unstable/ServerInterpolators.js +20 -0
  124. package/dist/unstable/ServerInterpolators.js.map +1 -0
  125. package/dist/unstable/WardConfig.d.ts +567 -0
  126. package/dist/unstable/WardConfig.d.ts.map +1 -0
  127. package/dist/unstable/WardConfig.js +2 -0
  128. package/dist/unstable/WardConfig.js.map +1 -0
  129. package/dist/unstable/features/All.d.ts +24 -0
  130. package/dist/unstable/features/All.d.ts.map +1 -0
  131. package/dist/unstable/features/All.js +20 -0
  132. package/dist/unstable/features/All.js.map +1 -0
  133. package/dist/unstable/features/Colors.d.ts +12 -0
  134. package/dist/unstable/features/Colors.d.ts.map +1 -0
  135. package/dist/unstable/features/Colors.js +38 -0
  136. package/dist/unstable/features/Colors.js.map +1 -0
  137. package/dist/unstable/features/DomAnimation.d.ts +16 -0
  138. package/dist/unstable/features/DomAnimation.d.ts.map +1 -0
  139. package/dist/unstable/features/DomAnimation.js +19 -0
  140. package/dist/unstable/features/DomAnimation.js.map +1 -0
  141. package/dist/unstable/features/DomMax.d.ts +12 -0
  142. package/dist/unstable/features/DomMax.d.ts.map +1 -0
  143. package/dist/unstable/features/DomMax.js +14 -0
  144. package/dist/unstable/features/DomMax.js.map +1 -0
  145. package/dist/unstable/features/Drag.d.ts +5 -0
  146. package/dist/unstable/features/Drag.d.ts.map +1 -0
  147. package/dist/unstable/features/Drag.js +32 -0
  148. package/dist/unstable/features/Drag.js.map +1 -0
  149. package/dist/unstable/features/Focus.d.ts +5 -0
  150. package/dist/unstable/features/Focus.d.ts.map +1 -0
  151. package/dist/unstable/features/Focus.js +20 -0
  152. package/dist/unstable/features/Focus.js.map +1 -0
  153. package/dist/unstable/features/Hover.d.ts +5 -0
  154. package/dist/unstable/features/Hover.d.ts.map +1 -0
  155. package/dist/unstable/features/Hover.js +20 -0
  156. package/dist/unstable/features/Hover.js.map +1 -0
  157. package/dist/unstable/features/InView.d.ts +5 -0
  158. package/dist/unstable/features/InView.d.ts.map +1 -0
  159. package/dist/unstable/features/InView.js +20 -0
  160. package/dist/unstable/features/InView.js.map +1 -0
  161. package/dist/unstable/features/Input.d.ts +28 -0
  162. package/dist/unstable/features/Input.d.ts.map +1 -0
  163. package/dist/unstable/features/Input.js +31 -0
  164. package/dist/unstable/features/Input.js.map +1 -0
  165. package/dist/unstable/features/Keys.d.ts +95 -0
  166. package/dist/unstable/features/Keys.d.ts.map +1 -0
  167. package/dist/unstable/features/Keys.js +44 -0
  168. package/dist/unstable/features/Keys.js.map +1 -0
  169. package/dist/unstable/features/Layout.d.ts +43 -0
  170. package/dist/unstable/features/Layout.d.ts.map +1 -0
  171. package/dist/unstable/features/Layout.js +44 -0
  172. package/dist/unstable/features/Layout.js.map +1 -0
  173. package/dist/unstable/features/Pan.d.ts +5 -0
  174. package/dist/unstable/features/Pan.d.ts.map +1 -0
  175. package/dist/unstable/features/Pan.js +20 -0
  176. package/dist/unstable/features/Pan.js.map +1 -0
  177. package/dist/unstable/features/Press.d.ts +13 -0
  178. package/dist/unstable/features/Press.d.ts.map +1 -0
  179. package/dist/unstable/features/Press.js +10 -0
  180. package/dist/unstable/features/Press.js.map +1 -0
  181. package/dist/unstable/features/Scroll.d.ts +20 -0
  182. package/dist/unstable/features/Scroll.d.ts.map +1 -0
  183. package/dist/unstable/features/Scroll.js +34 -0
  184. package/dist/unstable/features/Scroll.js.map +1 -0
  185. package/dist/unstable/features/TimelineKeys.d.ts +7 -0
  186. package/dist/unstable/features/TimelineKeys.d.ts.map +1 -0
  187. package/dist/unstable/features/TimelineKeys.js +103 -0
  188. package/dist/unstable/features/TimelineKeys.js.map +1 -0
  189. package/package.json +4 -3
  190. package/src/DomProjectionSystem.ts +3 -3
  191. package/src/FlushGate.ts +11 -9
  192. package/src/ReorderController.ts +3 -3
  193. package/src/Report.ts +3 -7
  194. package/src/Style.ts +4 -1
  195. package/src/index.ts +1 -1
  196. package/src/internal/batch-handoff.ts +75 -0
  197. package/src/internal/gate-environment.ts +21 -0
  198. package/src/internal/projection.ts +14 -14
  199. package/src/internal/reorder.ts +4 -4
  200. package/src/internal/starting-style.ts +5 -204
  201. package/src/unstable/AppearAnimations.ts +837 -0
  202. package/src/unstable/BatchMembers.ts +3085 -0
  203. package/src/unstable/DomValues.ts +53 -0
  204. package/src/unstable/DragConstraints.ts +107 -0
  205. package/src/unstable/DragControls.ts +98 -0
  206. package/src/unstable/DragDefaults.ts +57 -0
  207. package/src/unstable/DragTrack.ts +959 -0
  208. package/src/unstable/DragTransition.ts +46 -0
  209. package/src/unstable/ElementSetup.ts +411 -0
  210. package/src/unstable/Feature.ts +494 -0
  211. package/src/unstable/GestureFeatures.ts +38 -0
  212. package/src/unstable/GestureInfo.ts +85 -0
  213. package/src/unstable/Imperative.ts +1037 -0
  214. package/src/unstable/Instant.ts +93 -0
  215. package/src/unstable/LayoutGroup.ts +36 -0
  216. package/src/unstable/LayoutMember.ts +319 -0
  217. package/src/unstable/LiveStyle.ts +497 -0
  218. package/src/unstable/MemberHold.ts +211 -0
  219. package/src/unstable/OwnerScope.ts +35 -0
  220. package/src/unstable/PresenceController.ts +1747 -0
  221. package/src/unstable/Press.ts +43 -0
  222. package/src/unstable/ServerInterpolators.ts +39 -0
  223. package/src/unstable/WardConfig.ts +704 -0
  224. package/src/unstable/features/All.ts +39 -0
  225. package/src/unstable/features/Colors.ts +40 -0
  226. package/src/unstable/features/DomAnimation.ts +19 -0
  227. package/src/unstable/features/DomMax.ts +14 -0
  228. package/src/unstable/features/Drag.ts +34 -0
  229. package/src/unstable/features/Focus.ts +21 -0
  230. package/src/unstable/features/Hover.ts +21 -0
  231. package/src/unstable/features/InView.ts +21 -0
  232. package/src/unstable/features/Input.ts +37 -0
  233. package/src/unstable/features/Keys.ts +124 -0
  234. package/src/unstable/features/Layout.ts +75 -0
  235. package/src/unstable/features/Pan.ts +21 -0
  236. package/src/unstable/features/Press.ts +21 -0
  237. package/src/unstable/features/Scroll.ts +35 -0
  238. package/src/unstable/features/TimelineKeys.ts +115 -0
  239. package/dist/internal/gate.d.ts +0 -199
  240. package/dist/internal/gate.d.ts.map +0 -1
  241. package/dist/internal/gate.js +0 -570
  242. package/dist/internal/gate.js.map +0 -1
  243. package/dist/internal/report.d.ts +0 -30
  244. package/dist/internal/report.d.ts.map +0 -1
  245. package/dist/internal/report.js +0 -60
  246. package/dist/internal/report.js.map +0 -1
  247. package/dist/internal/runner.d.ts +0 -22
  248. package/dist/internal/runner.d.ts.map +0 -1
  249. package/dist/internal/runner.js +0 -62
  250. package/dist/internal/runner.js.map +0 -1
  251. package/src/internal/gate.ts +0 -706
  252. package/src/internal/report.ts +0 -69
  253. package/src/internal/runner.ts +0 -78
@@ -0,0 +1,47 @@
1
+ /**
2
+ * A drag element's defaults (ADR-0019 *Amendment (Reorder)*): the drag axis its binding runs its spine
3
+ * with, the styles and attribute a drag element takes, and their write at mount for an element whose
4
+ * props don't carry them.
5
+ *
6
+ * Unstable, for Wardic's own packages: public, with no semver promise.
7
+ *
8
+ * @module
9
+ */
10
+ // Unstable: ADR-0071, decision 5. #672 (Q11, PR2-Q3): solid's `drag-defaults.ts`, out of `spine.ts` since
11
+ // PR 2, moved to dom for every DOM binding's drag elements.
12
+ import * as Style from "../Style.js";
13
+ import * as Arr from "effect/Array";
14
+ import * as Option from "effect/Option";
15
+ import * as Rec from "effect/Record";
16
+ import * as UndefinedOr from "effect/UndefinedOr";
17
+ /** A plain element's drag internals: none. */
18
+ const NO_DRAG_INTERNALS = {};
19
+ /**
20
+ * The drag axis a spine runs with: its static `drag` config, else `true` for a
21
+ * `<Reorder>` item (its gesture's axis comes from `dragAxis`), else none.
22
+ */
23
+ export const dragAxisOf = (config, internal = NO_DRAG_INTERNALS) => Option.getOrUndefined(Option.orElse(Option.filter(Option.fromUndefinedOr(config.drag), (drag) => drag !== false), () => Option.map(Option.fromUndefinedOr(internal.dragAxis), () => true)));
24
+ /**
25
+ * A drag element's defaults (ADR-0019 *Amendment (Reorder)*): its axis's, unless its own presses don't
26
+ * drag it (`dragListener={false}`, #431), as Motion's come with its listener.
27
+ */
28
+ export const dragDefaultsOf = (config, internal = NO_DRAG_INTERNALS) => {
29
+ if (config.dragListener === false)
30
+ return undefined;
31
+ return UndefinedOr.map(dragAxisOf(config, internal), Style.dragDefaults);
32
+ };
33
+ /**
34
+ * Set each of a drag element's defaults its inline style doesn't already set, and
35
+ * `draggable="false"` unless it has the attribute, at mount: for an element whose props don't carry
36
+ * them, a directive's (`use:wardic`, `use:w`) and a `wardic.create(Component)` wrap's, whose
37
+ * component may not pass them on.
38
+ */
39
+ export const applyDragDefaults = (element, defaults) => {
40
+ Arr.forEach(Rec.keys(defaults), (key) => {
41
+ if (element.style.getPropertyValue(key) === "")
42
+ element.style.setProperty(key, UndefinedOr.getOrThrow(defaults[key]));
43
+ });
44
+ if (!element.hasAttribute("draggable"))
45
+ element.setAttribute("draggable", Style.DRAG_DEFAULT_ATTRIBUTES.draggable);
46
+ };
47
+ //# sourceMappingURL=DragDefaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DragDefaults.js","sourceRoot":"","sources":["../../src/unstable/DragDefaults.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,0GAA0G;AAC1G,4DAA4D;AAC5D,OAAO,KAAK,KAAK,MAAM,aAAa,CAAA;AACpC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AACnC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,GAAG,MAAM,eAAe,CAAA;AACpC,OAAO,KA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C,CAAC,CAAA;IACF,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,WAAW,CAAC;QAAE,OAAO,CAAC,YAAY,CAAC,WAAW,EAAE,KAAK,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAA;AACpH,CAAC,CAAA"}
@@ -0,0 +1,236 @@
1
+ /**
2
+ * The binding-orchestrated drag track (ADR-0004 response half), for every DOM binding: each binding
3
+ * runs it through `driveDragTrack`, handing it a `watch` for its element's watch Scope, a `fork` for
4
+ * its responses and a `setDragging` for its `dragging` state.
5
+ *
6
+ * DESIGN (locked via grilling, subtask 22c): on a drag-enabled element `x`/`y`
7
+ * are DIRECT-SET by the pointer (1:1, NOT sprung) while the spring spine keeps
8
+ * driving every OTHER key + `whileDrag`. Ownership of `x`/`y` is DYNAMIC: the
9
+ * drag owns them while held AND during the release tail; once the release
10
+ * settles, ownership returns to the spring (so a later `animate.x`/`y` or a
11
+ * layout/Reorder FLIP can take over from the rested position). A Retarget that
12
+ * changes `x` or `y` during the release takes them over sooner (#340, ADR-0016
13
+ * *Amendment (#340)*), as a newer animation of Motion's value does: the release
14
+ * stops where it is, tells no end, and the spring goes on from there, at the
15
+ * release's velocity ({@link DragTrack.takeRelease}).
16
+ *
17
+ * This module is the RESPONSE half (binding orchestration). Core ships the
18
+ * RECOGNITION (`drag()`, kept to its axis and holding its **Drag claim**), the
19
+ * constraint (`Drag.constrain`) and the inertia PRIMITIVE (`inertia`, `inertiaVec`); the
20
+ * constraints on the element's x/y, the release driver, the gate writes, and the
21
+ * snapshot sync are response concerns and live here (ADR-0004, ADR-0016 *Amendment (#140)*).
22
+ *
23
+ * STRUCTURE (ADR-0032, ADR-0055 *Amendment (#379)*): input is handled inside its event, by two
24
+ * watches in the element's watch Scope, with no fiber of the track's own at rest:
25
+ * - the drag's samples (`DragRecognizer.watchDrag`): a gesture's bookkeeping, then the direct-set,
26
+ * or at the "end" the release;
27
+ * - bare pointer-downs from the Primary pointer ("grabs", `InputFeed.watch`), which stop a
28
+ * running release, so a re-grab mid-release stops the tail where it is, and the ends of its
29
+ * presses, which let a projection node's release go on after a press that didn't drag.
30
+ * Each response is an Effect, run by `fork` on the provider runtime: its fiber starts at once and
31
+ * runs to its end inside the event (stopping a release interrupts a parked fiber in the caller's
32
+ * stack), and a release it starts, in a `FiberHandle`, is forked from it, keeping the runtime's
33
+ * scheduler, so it is on the Frame loop before its task ends. The next sample or grab interrupts it,
34
+ * which removes it from the loop at once. A response that fails is reported, and the next event's
35
+ * runs (ADR-0055 *Amendment (#379)*, Q4).
36
+ *
37
+ * **Drag controls** (#431, Motion's `useDragControls`) given to the element start its drag from a
38
+ * pointer pressed elsewhere: the track hands it to the element's pointer feed
39
+ * (`InputSource.adoptPointer`), whose adopted down the recognizer starts from as from a press on the
40
+ * element, and its grab stops a running release. `snapToCursor` moves the element's centre under the
41
+ * pointer there and then; `distanceThreshold` is that gesture's threshold. Their `stop` ends the drag
42
+ * as a release would; `cancel` ends it where it is, with no release and no `onDragEnd`. With
43
+ * `listen: false` (Motion's `dragListener={false}`) the element's own presses neither drag it nor stop
44
+ * its release. The track subscribes to the controls while its watch Scope is open, so an element an
45
+ * `<AnimatePresence>` is taking out (disposed) starts none, as Motion's doesn't.
46
+ *
47
+ * The samples subscribe before the grabs, so one event's samples reach the track
48
+ * before its grab: a Stale gesture's "end" (ADR-0019, rule B) starts its release and
49
+ * the grab of the same down stops it before its first frame, on every Environment.
50
+ * The track's state is a plain `MutableRef`: each response runs to completion, and a
51
+ * release is stopped before the next response changes the state.
52
+ *
53
+ * Unstable, for Wardic's own packages: public, with no semver promise.
54
+ *
55
+ * @module
56
+ */
57
+ import * as Drag from "@wardic/core/Drag";
58
+ import * as InputFeed from "@wardic/core/InputFeed";
59
+ import * as InputSource from "@wardic/core/InputSource";
60
+ import type * as Values from "@wardic/core/Values";
61
+ import type * as FlushGate from "../FlushGate.ts";
62
+ import type * as ProjectionSystem from "../ProjectionSystem.ts";
63
+ import * as Effect from "effect/Effect";
64
+ import type * as Scope from "effect/Scope";
65
+ import type * as DragConstraints from "./DragConstraints.ts";
66
+ import type * as WardicServices from "@wardic/core/unstable/WardicServices";
67
+ import type * as WardConfig from "./WardConfig.ts";
68
+ import * as DragControls from "./DragControls.ts";
69
+ /**
70
+ * The element's values as its drag reads and writes them: `values` and `velocities` by key, when `x`
71
+ * and `y` last moved, and the clock's time. The drag goes on from where the element is, and leaves it
72
+ * where the drag left it, its speed with it.
73
+ */
74
+ export interface DragSnapshot {
75
+ values: Values.Values;
76
+ velocities: Record<string, number>;
77
+ /** When the drag last moved `x` and `y`: their velocity holds 30 ms from then. */
78
+ drawnAt: Record<string, number>;
79
+ /** The time now, on the element's provider's Clock. */
80
+ readonly now: () => number;
81
+ }
82
+ /** A drag's config, read once as it starts: the `drag` props of a Wardic element. */
83
+ export interface DragTrackConfig {
84
+ /** `true` = free; `"x"`/`"y"` = axis-locked. */
85
+ readonly axis: boolean | "x" | "y";
86
+ /**
87
+ * `true`: the drag takes no **Drag claim** and is never refused, so a draggable ancestor can
88
+ * drag with it (Motion's `dragPropagation`). Default `false`.
89
+ */
90
+ readonly propagation?: boolean | undefined;
91
+ /**
92
+ * Optional numeric constraints (per axis) on the element's x/y, whichever gesture moved it there
93
+ * (Motion's): the drag keeps it within them, and a Fling springs back
94
+ * to an edge it would cross. A projection node's x/y is its drag offset.
95
+ */
96
+ readonly constraints?: Drag.Bounds | undefined;
97
+ /** Rubber-band resistance past `constraints`: 0 a hard clamp. Default {@link DragTransition.DEFAULT_DRAG_ELASTIC}. */
98
+ readonly elastic?: number | undefined;
99
+ /** Fling on release (default true); `false` releases with no velocity. */
100
+ readonly momentum?: boolean | undefined;
101
+ /** Spring back to the origin on release: both edges at 0. */
102
+ readonly snapToOrigin?: boolean | undefined;
103
+ /**
104
+ * Motion's `dragDirectionLock`: each gesture starts once it passes 10 px on one
105
+ * axis, and drags, claims and releases on that axis alone (`DragRecognizer.drag`'s `lock`).
106
+ */
107
+ readonly directionLock?: boolean | undefined;
108
+ /** What the release runs on: the element's drag transition, resolved ({@link DragTransition.dragTransitionOf}). */
109
+ readonly transition: ProjectionSystem.DragTransition;
110
+ /**
111
+ * Motion's `dragListener`: `false`, the element's own presses start no drag and stop no
112
+ * release; only its **Drag controls**' starts do. Default `true`.
113
+ */
114
+ readonly listen?: boolean | undefined;
115
+ }
116
+ /** What the track's watches and responses run with: the provider's services and the gestures' input (#511). */
117
+ export type TrackServices = WardicServices.WardicServices | InputSource.InputSource;
118
+ /** Options for {@link driveDragTrack}. */
119
+ export interface DragTrackOptions {
120
+ /**
121
+ * Runs the track in the element's watch Scope: its watches subscribed now, with no
122
+ * fiber, until the element goes and the Scope closes, which stops a running release. A throw from a
123
+ * watch's fold goes to the `onDefect` it's given (#209: each binding owns the Scope).
124
+ */
125
+ readonly watch: (track: (onDefect: InputFeed.OnDefect) => Effect.Effect<void, never, Scope.Scope | TrackServices>) => void;
126
+ /**
127
+ * Runs a response forked on the provider runtime: its fiber starts at once and runs to its
128
+ * end inside the event. A release it forks keeps the runtime's scheduler, a host's if it gave one,
129
+ * not a `runSync`'s sync one, which would resume
130
+ * the release's yields on a microtask.
131
+ */
132
+ readonly fork: (response: Effect.Effect<void, never, TrackServices>) => void;
133
+ /** The provider-owned flush gate; the drag writes `x`/`y` into `id`. */
134
+ readonly gate: FlushGate.Shape;
135
+ /** The element's gate id (shared with the spine, so writes merge). */
136
+ readonly id: string;
137
+ /** The live element the drag recognizer attaches to. */
138
+ readonly element: HTMLElement;
139
+ /** The spine's Snapshot object (shared — see {@link DragSnapshot}). */
140
+ readonly snapshot: DragSnapshot;
141
+ /** Merge a value-map into the presence snapshot (mirrors the spine's recordFrame). */
142
+ readonly recordFrame: (value: Values.Values) => void;
143
+ /** Flip the reactive `dragging` signal the spine reads for `whileDrag` + key stripping. */
144
+ readonly setDragging: (dragging: boolean) => void;
145
+ /**
146
+ * Told before the drag reads where the element rests, or writes `x`/`y`: a Batch member's element
147
+ * takes its transform from its Batch then (#665's PR 4), so the drag starts where the Batch drew it,
148
+ * and is the only one drawing it. Omitted, nothing is told.
149
+ */
150
+ readonly claim?: (() => void) | undefined;
151
+ /** The static drag config (read once at setup). */
152
+ readonly config: DragTrackConfig;
153
+ /**
154
+ * When the element is a projection node, the drag feeds the projection
155
+ * instead of writing raw `x`/`y`, which stay the element's own, drawn on top:
156
+ * grab → `dragStart`, each sample → `dragMove(offset)`, release →
157
+ * `dragEnd(velocity)` (its Release offset — the free tail is skipped), a press →
158
+ * `stopRelease`, a press that ends with no drag → `resumeRelease`. Absent ⇒ free drag.
159
+ */
160
+ readonly projection?: ProjectionSystem.DragHandle | undefined;
161
+ /**
162
+ * The gesture's axis, read at each gesture's "start" and held until its "end"
163
+ * (`true` = free), in place of `config.axis`: the axis it moves on and claims
164
+ * (internal: a `<Reorder>` item, whose group decides the axis per gesture, D5).
165
+ */
166
+ readonly axisAt?: (() => boolean | "x" | "y") | undefined;
167
+ /**
168
+ * Each sample, after its projection write: after `dragMove` for "start" and
169
+ * "move", after `dragEnd` for "end", so a reader of the handle's `dragOffset()`
170
+ * sees this sample (internal: a `<Reorder>` item's group).
171
+ */
172
+ readonly onSample?: ((sample: Drag.Sample) => void) | undefined;
173
+ /**
174
+ * The release came to rest on its own (Motion's `onDragTransitionEnd`): its Fling or its
175
+ * spring back finished, or it was dropped where it rests. Told after the gate's flush of the rest
176
+ * value. Not for one a grab stopped. A free drag's only: a layout node's release is its Release
177
+ * offset, which the projection tells.
178
+ */
179
+ readonly onReleaseEnd?: (() => void) | undefined;
180
+ /**
181
+ * Whether its animations are skipped (its nearest `WardicConfig`'s `skipAnimations`), read at
182
+ * each release: a skipped one lands at once where it would come to rest. Omitted, never.
183
+ */
184
+ readonly skipAnimations?: (() => boolean) | undefined;
185
+ /**
186
+ * An element constraint (Motion's `dragConstraints={ref}`): the container whose box
187
+ * the element's must stay inside, in place of `config.constraints`. It's measured at each drag's
188
+ * start, and again when the element or the container resizes; a resize that changes the bounds
189
+ * moves an element at rest (or releasing, which it stops) to keep its place within them (Motion's
190
+ * `scalePositionWithinConstraints`). A container not there at a drag's start leaves it unconstrained.
191
+ */
192
+ readonly container?: DragConstraints.DragContainer | undefined;
193
+ /**
194
+ * The **Drag controls** given to the element (Motion's `dragControls`): the track subscribes to
195
+ * them while its watch Scope is open.
196
+ */
197
+ readonly controls?: DragControls.WardicDragControls | undefined;
198
+ /**
199
+ * Where the drag's points are (its nearest `WardicConfig`'s `transformPagePoint`): read at
200
+ * each down, and applied to its every point and to the box its snap to the cursor measures.
201
+ * Omitted, as they are.
202
+ */
203
+ readonly mapPoint?: (() => WardConfig.WardicTransformPoint | undefined) | undefined;
204
+ }
205
+ /** A running drag track, for the spine's Retargets (#340). */
206
+ export interface DragTrack {
207
+ /**
208
+ * Take `x`/`y` from a free drag's running release (#340) for a Retarget that gives `retargeted`
209
+ * new targets, as a newer animation of Motion's value stops the one running: the release stops
210
+ * where it is and tells no end, and `dragging` is handed back at the end of the task (not in the
211
+ * caller's Retarget, which reads it). `false`, and nothing done, when no release runs, a gesture
212
+ * is on, or none of `retargeted` is an axis the release runs on (Motion's runs one per axis).
213
+ */
214
+ readonly takeRelease: (retargeted: {
215
+ readonly x: boolean;
216
+ readonly y: boolean;
217
+ }) => boolean;
218
+ }
219
+ /**
220
+ * Run the drag track for one element. Recognize `drag(element)` on its axis (read at
221
+ * each gesture's start for a `<Reorder>` item) with its **Drag claim** (none with
222
+ * `propagation`), then consume it, kept within its constraints, and the element's bare
223
+ * pointer-down grabs, each in place as it arrives (ADR-0032; the module doc). A drag
224
+ * refused its claim emits nothing, so a draggable ancestor of the element that claimed
225
+ * neither follows the pointer nor turns `whileDrag` on; its grab still stops its running
226
+ * release (ADR-0019, *Amendment (#29)*). The track runs in the element's watch Scope
227
+ * (`opts.watch`, #379), with no fiber at rest: closing it stops the watches (dropping the
228
+ * shared feed's count) and any in-flight release. A response that fails, or a release, is
229
+ * reported, and the track goes on.
230
+ *
231
+ * The drag config is read ONCE at setup (the caller passes a static
232
+ * {@link DragTrackConfig} — drag config is a document, not reactive); only the
233
+ * `dragging` signal the spine reads is reactive.
234
+ */
235
+ export declare const driveDragTrack: (opts: DragTrackOptions) => DragTrack;
236
+ //# sourceMappingURL=DragTrack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DragTrack.d.ts","sourceRoot":"","sources":["../../src/unstable/DragTrack.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAEH,OAAO,KAAK,IAAI,MAAM,mBAAmB,CAAA;AAGzC,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAA;AACnD,OAAO,KAAK,WAAW,MAAM,0BAA0B,CAAA;AAGvD,OAAO,KAAK,KAAK,MAAM,MAAM,qBAAqB,CAAA;AAIlD,OAAO,KAAK,KAAK,SAAS,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,KAAK,gBAAgB,MAAM,wBAAwB,CAAA;AAK/D,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAQvC,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAA;AAG1C,OAAO,KAAK,KAAK,eAAe,MAAM,sBAAsB,CAAA;AAC5D,OAAO,KAAK,KAAK,cAAc,MAAM,sCAAsC,CAAA;AAC3E,OAAO,KAAK,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAClD,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AAKjD;;;;GAIG;AAGH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAA;IACrB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAClC,kFAAkF;IAClF,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,uDAAuD;IACvD,QAAQ,CAAC,GAAG,EAAE,MAAM,MAAM,CAAA;CAC3B;AAED,qFAAqF;AACrF,MAAM,WAAW,eAAe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