foldkit-primitives 0.15.4 → 0.16.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 (422) hide show
  1. package/dist/device/fullscreen.d.ts +28 -0
  2. package/dist/device/fullscreen.d.ts.map +1 -0
  3. package/dist/device/fullscreen.js +69 -0
  4. package/dist/device/fullscreen.js.map +1 -0
  5. package/dist/device/geolocation.d.ts +56 -0
  6. package/dist/device/geolocation.d.ts.map +1 -0
  7. package/dist/device/geolocation.js +87 -0
  8. package/dist/device/geolocation.js.map +1 -0
  9. package/dist/device/index.d.ts +5 -0
  10. package/dist/device/index.js +6 -0
  11. package/dist/device/media-devices.d.ts +88 -0
  12. package/dist/device/media-devices.d.ts.map +1 -0
  13. package/dist/device/media-devices.js +117 -0
  14. package/dist/device/media-devices.js.map +1 -0
  15. package/dist/device/media-stream.d.ts +93 -0
  16. package/dist/device/media-stream.d.ts.map +1 -0
  17. package/dist/device/media-stream.js +106 -0
  18. package/dist/device/media-stream.js.map +1 -0
  19. package/dist/device/permissions.d.ts +106 -0
  20. package/dist/device/permissions.d.ts.map +1 -0
  21. package/dist/device/permissions.js +143 -0
  22. package/dist/device/permissions.js.map +1 -0
  23. package/dist/dom/autofocus.d.ts +15 -0
  24. package/dist/dom/autofocus.d.ts.map +1 -0
  25. package/dist/dom/autofocus.js +22 -0
  26. package/dist/dom/autofocus.js.map +1 -0
  27. package/dist/dom/clipboard.d.ts +30 -0
  28. package/dist/dom/clipboard.d.ts.map +1 -0
  29. package/dist/dom/clipboard.js +50 -0
  30. package/dist/dom/clipboard.js.map +1 -0
  31. package/dist/dom/editable-text.d.ts +72 -0
  32. package/dist/dom/editable-text.d.ts.map +1 -0
  33. package/dist/dom/editable-text.js +232 -0
  34. package/dist/dom/editable-text.js.map +1 -0
  35. package/dist/dom/fluid-hover.d.ts +93 -0
  36. package/dist/dom/fluid-hover.d.ts.map +1 -0
  37. package/dist/dom/fluid-hover.js +294 -0
  38. package/dist/dom/fluid-hover.js.map +1 -0
  39. package/dist/dom/focus-scope.d.ts +21 -0
  40. package/dist/dom/focus-scope.d.ts.map +1 -0
  41. package/dist/dom/focus-scope.js +93 -0
  42. package/dist/dom/focus-scope.js.map +1 -0
  43. package/dist/dom/follow-tab-stop.d.ts +11 -0
  44. package/dist/dom/follow-tab-stop.d.ts.map +1 -0
  45. package/dist/dom/follow-tab-stop.js +54 -0
  46. package/dist/dom/follow-tab-stop.js.map +1 -0
  47. package/dist/dom/image-decode.d.ts +27 -0
  48. package/dist/dom/image-decode.d.ts.map +1 -0
  49. package/dist/dom/image-decode.js +50 -0
  50. package/dist/dom/image-decode.js.map +1 -0
  51. package/dist/dom/index.d.ts +24 -0
  52. package/dist/dom/index.js +25 -0
  53. package/dist/dom/input-mask.d.ts +35 -0
  54. package/dist/dom/input-mask.d.ts.map +1 -0
  55. package/dist/dom/input-mask.js +90 -0
  56. package/dist/dom/input-mask.js.map +1 -0
  57. package/dist/dom/keep-in-view.d.ts +16 -0
  58. package/dist/dom/keep-in-view.d.ts.map +1 -0
  59. package/dist/dom/keep-in-view.js +38 -0
  60. package/dist/dom/keep-in-view.js.map +1 -0
  61. package/dist/dom/keyboard-inset.d.ts +29 -0
  62. package/dist/dom/keyboard-inset.d.ts.map +1 -0
  63. package/dist/dom/keyboard-inset.js +45 -0
  64. package/dist/dom/keyboard-inset.js.map +1 -0
  65. package/dist/dom/layers.d.ts +6 -0
  66. package/dist/dom/layers.d.ts.map +1 -0
  67. package/dist/dom/layers.js +35 -0
  68. package/dist/dom/layers.js.map +1 -0
  69. package/dist/dom/measure.d.ts +42 -0
  70. package/dist/dom/measure.d.ts.map +1 -0
  71. package/dist/dom/measure.js +123 -0
  72. package/dist/dom/measure.js.map +1 -0
  73. package/dist/dom/move.d.ts +45 -0
  74. package/dist/dom/move.d.ts.map +1 -0
  75. package/dist/dom/move.js +96 -0
  76. package/dist/dom/move.js.map +1 -0
  77. package/dist/dom/pointed-links.d.ts +13 -0
  78. package/dist/dom/pointed-links.d.ts.map +1 -0
  79. package/dist/dom/pointed-links.js +59 -0
  80. package/dist/dom/pointed-links.js.map +1 -0
  81. package/dist/dom/pointer-drag.d.ts +132 -0
  82. package/dist/dom/pointer-drag.d.ts.map +1 -0
  83. package/dist/dom/pointer-drag.js +307 -0
  84. package/dist/dom/pointer-drag.js.map +1 -0
  85. package/dist/dom/pointer-position.d.ts +133 -0
  86. package/dist/dom/pointer-position.d.ts.map +1 -0
  87. package/dist/dom/pointer-position.js +173 -0
  88. package/dist/dom/pointer-position.js.map +1 -0
  89. package/dist/dom/script-loader.d.ts +12 -0
  90. package/dist/dom/script-loader.d.ts.map +1 -0
  91. package/dist/dom/script-loader.js +54 -0
  92. package/dist/dom/script-loader.js.map +1 -0
  93. package/dist/dom/scroll-bars.d.ts +52 -0
  94. package/dist/dom/scroll-bars.d.ts.map +1 -0
  95. package/dist/dom/scroll-bars.js +259 -0
  96. package/dist/dom/scroll-bars.js.map +1 -0
  97. package/dist/dom/scroll-settle.d.ts +33 -0
  98. package/dist/dom/scroll-settle.d.ts.map +1 -0
  99. package/dist/dom/scroll-settle.js +84 -0
  100. package/dist/dom/scroll-settle.js.map +1 -0
  101. package/dist/dom/scroll.d.ts +21 -0
  102. package/dist/dom/scroll.d.ts.map +1 -0
  103. package/dist/dom/scroll.js +141 -0
  104. package/dist/dom/scroll.js.map +1 -0
  105. package/dist/dom/share.d.ts +19 -0
  106. package/dist/dom/share.d.ts.map +1 -0
  107. package/dist/dom/share.js +41 -0
  108. package/dist/dom/share.js.map +1 -0
  109. package/dist/dom/swipe.d.ts +121 -0
  110. package/dist/dom/swipe.d.ts.map +1 -0
  111. package/dist/dom/swipe.js +291 -0
  112. package/dist/dom/swipe.js.map +1 -0
  113. package/dist/dom/targets.d.ts +45 -0
  114. package/dist/dom/targets.d.ts.map +1 -0
  115. package/dist/dom/targets.js +70 -0
  116. package/dist/dom/targets.js.map +1 -0
  117. package/dist/dom/track-box.d.ts +61 -0
  118. package/dist/dom/track-box.d.ts.map +1 -0
  119. package/dist/dom/track-box.js +131 -0
  120. package/dist/dom/track-box.js.map +1 -0
  121. package/dist/events/active-element.d.ts +15 -0
  122. package/dist/events/active-element.d.ts.map +1 -0
  123. package/dist/events/active-element.js +33 -0
  124. package/dist/events/active-element.js.map +1 -0
  125. package/dist/events/hotkeys.d.ts +22 -0
  126. package/dist/events/hotkeys.d.ts.map +1 -0
  127. package/dist/events/hotkeys.js +56 -0
  128. package/dist/events/hotkeys.js.map +1 -0
  129. package/dist/events/idle.d.ts +29 -0
  130. package/dist/events/idle.d.ts.map +1 -0
  131. package/dist/events/idle.js +51 -0
  132. package/dist/events/idle.js.map +1 -0
  133. package/dist/events/index.d.ts +9 -0
  134. package/dist/events/index.js +10 -0
  135. package/dist/{input-modality-l7InESYh.d.mts → events/input-modality.d.ts} +9 -10
  136. package/dist/events/input-modality.d.ts.map +1 -0
  137. package/dist/{input-modality-XwQOFLip.mjs → events/input-modality.js} +2 -2
  138. package/dist/events/input-modality.js.map +1 -0
  139. package/dist/events/keyboard.d.ts +30 -0
  140. package/dist/events/keyboard.d.ts.map +1 -0
  141. package/dist/events/keyboard.js +55 -0
  142. package/dist/events/keyboard.js.map +1 -0
  143. package/dist/events/pointer.d.ts +15 -0
  144. package/dist/events/pointer.d.ts.map +1 -0
  145. package/dist/events/pointer.js +28 -0
  146. package/dist/events/pointer.js.map +1 -0
  147. package/dist/events/scroll.d.ts +16 -0
  148. package/dist/events/scroll.d.ts.map +1 -0
  149. package/dist/events/scroll.js +29 -0
  150. package/dist/events/scroll.js.map +1 -0
  151. package/dist/events/visibility.d.ts +25 -0
  152. package/dist/events/visibility.d.ts.map +1 -0
  153. package/dist/events/visibility.js +28 -0
  154. package/dist/events/visibility.js.map +1 -0
  155. package/dist/events/window-size.d.ts +30 -0
  156. package/dist/events/window-size.d.ts.map +1 -0
  157. package/dist/events/window-size.js +63 -0
  158. package/dist/events/window-size.js.map +1 -0
  159. package/dist/index.d.ts +9 -0
  160. package/dist/index.js +10 -0
  161. package/dist/interaction/bundle-behavior.d.ts +37 -0
  162. package/dist/interaction/bundle-behavior.d.ts.map +1 -0
  163. package/dist/interaction/bundle-behavior.js +34 -0
  164. package/dist/interaction/bundle-behavior.js.map +1 -0
  165. package/dist/interaction/dismiss-layer.d.ts +100 -0
  166. package/dist/interaction/dismiss-layer.d.ts.map +1 -0
  167. package/dist/interaction/dismiss-layer.js +140 -0
  168. package/dist/interaction/dismiss-layer.js.map +1 -0
  169. package/dist/interaction/editable-text.d.ts +13 -0
  170. package/dist/interaction/editable-text.d.ts.map +1 -0
  171. package/dist/interaction/editable-text.js +17 -0
  172. package/dist/interaction/editable-text.js.map +1 -0
  173. package/dist/interaction/focus-scope.d.ts +21 -0
  174. package/dist/interaction/focus-scope.d.ts.map +1 -0
  175. package/dist/interaction/focus-scope.js +25 -0
  176. package/dist/interaction/focus-scope.js.map +1 -0
  177. package/dist/interaction/focus-visible.d.ts +9 -0
  178. package/dist/interaction/focus-visible.d.ts.map +1 -0
  179. package/dist/interaction/focus-visible.js +10 -0
  180. package/dist/interaction/focus-visible.js.map +1 -0
  181. package/dist/interaction/grid-navigation.d.ts +73 -0
  182. package/dist/interaction/grid-navigation.d.ts.map +1 -0
  183. package/dist/interaction/grid-navigation.js +137 -0
  184. package/dist/interaction/grid-navigation.js.map +1 -0
  185. package/dist/interaction/index.d.ts +21 -0
  186. package/dist/interaction/index.js +21 -0
  187. package/dist/interaction/layers.d.ts +12 -0
  188. package/dist/interaction/layers.d.ts.map +1 -0
  189. package/dist/interaction/layers.js +14 -0
  190. package/dist/interaction/layers.js.map +1 -0
  191. package/dist/interaction/list-navigation.d.ts +105 -0
  192. package/dist/interaction/list-navigation.d.ts.map +1 -0
  193. package/dist/interaction/list-navigation.js +168 -0
  194. package/dist/interaction/list-navigation.js.map +1 -0
  195. package/dist/interaction/live-announce.d.ts +70 -0
  196. package/dist/interaction/live-announce.d.ts.map +1 -0
  197. package/dist/interaction/live-announce.js +115 -0
  198. package/dist/interaction/live-announce.js.map +1 -0
  199. package/dist/interaction/long-press.d.ts +102 -0
  200. package/dist/interaction/long-press.d.ts.map +1 -0
  201. package/dist/interaction/long-press.js +115 -0
  202. package/dist/interaction/long-press.js.map +1 -0
  203. package/dist/interaction/move.d.ts +10 -0
  204. package/dist/interaction/move.d.ts.map +1 -0
  205. package/dist/interaction/move.js +17 -0
  206. package/dist/interaction/move.js.map +1 -0
  207. package/dist/interaction/overlay.d.ts +45 -0
  208. package/dist/interaction/overlay.d.ts.map +1 -0
  209. package/dist/interaction/overlay.js +57 -0
  210. package/dist/interaction/overlay.js.map +1 -0
  211. package/dist/interaction/placing.d.ts +86 -0
  212. package/dist/interaction/placing.d.ts.map +1 -0
  213. package/dist/interaction/placing.js +239 -0
  214. package/dist/interaction/placing.js.map +1 -0
  215. package/dist/interaction/pointer-drag.d.ts +23 -0
  216. package/dist/interaction/pointer-drag.d.ts.map +1 -0
  217. package/dist/interaction/pointer-drag.js +21 -0
  218. package/dist/interaction/pointer-drag.js.map +1 -0
  219. package/dist/interaction/press.d.ts +152 -0
  220. package/dist/interaction/press.d.ts.map +1 -0
  221. package/dist/interaction/press.js +229 -0
  222. package/dist/interaction/press.js.map +1 -0
  223. package/dist/interaction/roving-tabindex.d.ts +85 -0
  224. package/dist/interaction/roving-tabindex.d.ts.map +1 -0
  225. package/dist/interaction/roving-tabindex.js +142 -0
  226. package/dist/interaction/roving-tabindex.js.map +1 -0
  227. package/dist/interaction/selection.d.ts +72 -0
  228. package/dist/interaction/selection.d.ts.map +1 -0
  229. package/dist/interaction/selection.js +129 -0
  230. package/dist/interaction/selection.js.map +1 -0
  231. package/dist/interaction/targets.d.ts +15 -0
  232. package/dist/interaction/targets.d.ts.map +1 -0
  233. package/dist/interaction/targets.js +20 -0
  234. package/dist/interaction/targets.js.map +1 -0
  235. package/dist/interaction/tree-navigation.d.ts +111 -0
  236. package/dist/interaction/tree-navigation.d.ts.map +1 -0
  237. package/dist/interaction/tree-navigation.js +207 -0
  238. package/dist/interaction/tree-navigation.js.map +1 -0
  239. package/dist/interaction/typeahead.d.ts +73 -0
  240. package/dist/interaction/typeahead.d.ts.map +1 -0
  241. package/dist/interaction/typeahead.js +113 -0
  242. package/dist/interaction/typeahead.js.map +1 -0
  243. package/dist/internal.d.ts +16 -0
  244. package/dist/internal.d.ts.map +1 -0
  245. package/dist/{internal-C4gHodLc.mjs → internal.js} +7 -5
  246. package/dist/internal.js.map +1 -0
  247. package/dist/media/breakpoints.d.ts +37 -0
  248. package/dist/media/breakpoints.d.ts.map +1 -0
  249. package/dist/media/breakpoints.js +64 -0
  250. package/dist/media/breakpoints.js.map +1 -0
  251. package/dist/media/index.d.ts +3 -0
  252. package/dist/media/index.js +4 -0
  253. package/dist/media/mediaquery.d.ts +40 -0
  254. package/dist/media/mediaquery.d.ts.map +1 -0
  255. package/dist/media/mediaquery.js +42 -0
  256. package/dist/media/mediaquery.js.map +1 -0
  257. package/dist/media/platform.d.ts +30 -0
  258. package/dist/media/platform.d.ts.map +1 -0
  259. package/dist/media/platform.js +50 -0
  260. package/dist/media/platform.js.map +1 -0
  261. package/dist/motion/index.d.ts +5 -0
  262. package/dist/motion/index.js +5 -0
  263. package/dist/motion/motion.d.ts +16 -0
  264. package/dist/motion/motion.d.ts.map +1 -0
  265. package/dist/motion/motion.js +25 -0
  266. package/dist/motion/motion.js.map +1 -0
  267. package/dist/motion/presence.d.ts +37 -0
  268. package/dist/motion/presence.d.ts.map +1 -0
  269. package/dist/motion/presence.js +65 -0
  270. package/dist/motion/presence.js.map +1 -0
  271. package/dist/motion/spring.d.ts +50 -0
  272. package/dist/motion/spring.d.ts.map +1 -0
  273. package/dist/motion/spring.js +92 -0
  274. package/dist/motion/spring.js.map +1 -0
  275. package/dist/motion/tween.d.ts +44 -0
  276. package/dist/motion/tween.d.ts.map +1 -0
  277. package/dist/motion/tween.js +65 -0
  278. package/dist/motion/tween.js.map +1 -0
  279. package/dist/net/broadcast.d.ts +39 -0
  280. package/dist/net/broadcast.d.ts.map +1 -0
  281. package/dist/net/broadcast.js +73 -0
  282. package/dist/net/broadcast.js.map +1 -0
  283. package/dist/net/index.d.ts +5 -0
  284. package/dist/net/index.js +6 -0
  285. package/dist/net/online.d.ts +24 -0
  286. package/dist/net/online.d.ts.map +1 -0
  287. package/dist/net/online.js +26 -0
  288. package/dist/net/online.js.map +1 -0
  289. package/dist/net/sharedHost.d.ts +64 -0
  290. package/dist/net/sharedHost.d.ts.map +1 -0
  291. package/dist/net/sharedHost.js +124 -0
  292. package/dist/net/sharedHost.js.map +1 -0
  293. package/dist/net/sse.d.ts +115 -0
  294. package/dist/net/sse.d.ts.map +1 -0
  295. package/dist/net/sse.js +138 -0
  296. package/dist/net/sse.js.map +1 -0
  297. package/dist/net/websocket.d.ts +172 -0
  298. package/dist/net/websocket.d.ts.map +1 -0
  299. package/dist/net/websocket.js +199 -0
  300. package/dist/net/websocket.js.map +1 -0
  301. package/dist/observers/bounds.d.ts +24 -0
  302. package/dist/observers/bounds.d.ts.map +1 -0
  303. package/dist/observers/bounds.js +51 -0
  304. package/dist/observers/bounds.js.map +1 -0
  305. package/dist/observers/index.d.ts +4 -0
  306. package/dist/observers/index.js +5 -0
  307. package/dist/observers/intersection.d.ts +18 -0
  308. package/dist/observers/intersection.d.ts.map +1 -0
  309. package/dist/observers/intersection.js +33 -0
  310. package/dist/observers/intersection.js.map +1 -0
  311. package/dist/observers/mutation.d.ts +25 -0
  312. package/dist/observers/mutation.d.ts.map +1 -0
  313. package/dist/observers/mutation.js +53 -0
  314. package/dist/observers/mutation.js.map +1 -0
  315. package/dist/observers/resize.d.ts +18 -0
  316. package/dist/observers/resize.d.ts.map +1 -0
  317. package/dist/observers/resize.js +33 -0
  318. package/dist/observers/resize.js.map +1 -0
  319. package/dist/state/history.d.ts +115 -0
  320. package/dist/state/history.d.ts.map +1 -0
  321. package/dist/state/history.js +167 -0
  322. package/dist/state/history.js.map +1 -0
  323. package/dist/state/index.d.ts +6 -0
  324. package/dist/state/index.js +7 -0
  325. package/dist/state/locale.d.ts +27 -0
  326. package/dist/state/locale.d.ts.map +1 -0
  327. package/dist/state/locale.js +25 -0
  328. package/dist/state/locale.js.map +1 -0
  329. package/dist/state/pagination.d.ts +53 -0
  330. package/dist/state/pagination.d.ts.map +1 -0
  331. package/dist/state/pagination.js +72 -0
  332. package/dist/state/pagination.js.map +1 -0
  333. package/dist/state/range.d.ts +9 -0
  334. package/dist/state/range.d.ts.map +1 -0
  335. package/dist/state/range.js +18 -0
  336. package/dist/state/range.js.map +1 -0
  337. package/dist/state/selection.d.ts +47 -0
  338. package/dist/state/selection.d.ts.map +1 -0
  339. package/dist/state/selection.js +39 -0
  340. package/dist/state/selection.js.map +1 -0
  341. package/dist/state/virtual.d.ts +201 -0
  342. package/dist/state/virtual.d.ts.map +1 -0
  343. package/dist/state/{index.mjs → virtual.js} +10 -306
  344. package/dist/state/virtual.js.map +1 -0
  345. package/dist/time/debounce.d.ts +43 -0
  346. package/dist/time/debounce.d.ts.map +1 -0
  347. package/dist/time/debounce.js +65 -0
  348. package/dist/time/debounce.js.map +1 -0
  349. package/dist/time/index.d.ts +6 -0
  350. package/dist/time/index.js +7 -0
  351. package/dist/time/interval.d.ts +37 -0
  352. package/dist/time/interval.d.ts.map +1 -0
  353. package/dist/time/interval.js +52 -0
  354. package/dist/time/interval.js.map +1 -0
  355. package/dist/time/relative.d.ts +8 -0
  356. package/dist/time/relative.d.ts.map +1 -0
  357. package/dist/time/relative.js +27 -0
  358. package/dist/time/relative.js.map +1 -0
  359. package/dist/time/throttle.d.ts +38 -0
  360. package/dist/time/throttle.d.ts.map +1 -0
  361. package/dist/time/throttle.js +39 -0
  362. package/dist/time/throttle.js.map +1 -0
  363. package/dist/time/ticks.d.ts +21 -0
  364. package/dist/time/ticks.d.ts.map +1 -0
  365. package/dist/time/ticks.js +30 -0
  366. package/dist/time/ticks.js.map +1 -0
  367. package/dist/time/timer.d.ts +32 -0
  368. package/dist/time/timer.d.ts.map +1 -0
  369. package/dist/time/timer.js +50 -0
  370. package/dist/time/timer.js.map +1 -0
  371. package/package.json +31 -31
  372. package/dist/device/index.d.mts +0 -335
  373. package/dist/device/index.d.mts.map +0 -1
  374. package/dist/device/index.mjs +0 -493
  375. package/dist/device/index.mjs.map +0 -1
  376. package/dist/dom/index.d.mts +0 -714
  377. package/dist/dom/index.d.mts.map +0 -1
  378. package/dist/dom/index.mjs +0 -1840
  379. package/dist/dom/index.mjs.map +0 -1
  380. package/dist/editable-text-Bg7vil7h.d.mts +0 -307
  381. package/dist/editable-text-Bg7vil7h.d.mts.map +0 -1
  382. package/dist/events/index.d.mts +0 -168
  383. package/dist/events/index.d.mts.map +0 -1
  384. package/dist/events/index.mjs +0 -307
  385. package/dist/events/index.mjs.map +0 -1
  386. package/dist/follow-tab-stop-DM5EI4Ci.mjs +0 -856
  387. package/dist/follow-tab-stop-DM5EI4Ci.mjs.map +0 -1
  388. package/dist/index-Bomdwb7e.d.mts +0 -142
  389. package/dist/index-Bomdwb7e.d.mts.map +0 -1
  390. package/dist/index.d.mts +0 -12
  391. package/dist/index.mjs +0 -12
  392. package/dist/input-modality-XwQOFLip.mjs.map +0 -1
  393. package/dist/input-modality-l7InESYh.d.mts.map +0 -1
  394. package/dist/interaction/index.d.mts +0 -1193
  395. package/dist/interaction/index.d.mts.map +0 -1
  396. package/dist/interaction/index.mjs +0 -1992
  397. package/dist/interaction/index.mjs.map +0 -1
  398. package/dist/internal-C4gHodLc.mjs.map +0 -1
  399. package/dist/media/index.d.mts +0 -103
  400. package/dist/media/index.d.mts.map +0 -1
  401. package/dist/media/index.mjs +0 -146
  402. package/dist/media/index.mjs.map +0 -1
  403. package/dist/motion/index.d.mts +0 -2
  404. package/dist/motion/index.mjs +0 -1
  405. package/dist/motion-BmlJCjn6.mjs +0 -236
  406. package/dist/motion-BmlJCjn6.mjs.map +0 -1
  407. package/dist/net/index.d.mts +0 -338
  408. package/dist/net/index.d.mts.map +0 -1
  409. package/dist/net/index.mjs +0 -530
  410. package/dist/net/index.mjs.map +0 -1
  411. package/dist/observers/index.d.mts +0 -76
  412. package/dist/observers/index.d.mts.map +0 -1
  413. package/dist/observers/index.mjs +0 -155
  414. package/dist/observers/index.mjs.map +0 -1
  415. package/dist/rolldown-runtime-D8jQpDG7.mjs +0 -12
  416. package/dist/state/index.d.mts +0 -432
  417. package/dist/state/index.d.mts.map +0 -1
  418. package/dist/state/index.mjs.map +0 -1
  419. package/dist/time/index.d.mts +0 -167
  420. package/dist/time/index.d.mts.map +0 -1
  421. package/dist/time/index.mjs +0 -236
  422. package/dist/time/index.mjs.map +0 -1
@@ -0,0 +1,132 @@
1
+ import { Schema } from "effect";
2
+ import * as Mount from "foldkit/mount";
3
+ export declare const DragZone: Schema.Literals<readonly ["before", "inside", "after"]>;
4
+ export type DragZone = typeof DragZone.Type;
5
+ /**
6
+ * A marked descendant under the pointer, and the zone of it the pointer is in.
7
+ * `part` is the value of the `part` attribute on the element found, such as
8
+ * the empty Region of a node a drop goes into; a place with one is `inside`.
9
+ */
10
+ export declare const DragPlace: Schema.Struct<{
11
+ readonly id: Schema.String;
12
+ readonly zone: Schema.Literals<readonly ["before", "inside", "after"]>;
13
+ readonly part: Schema.optionalKey<Schema.String>;
14
+ }>;
15
+ export type DragPlace = typeof DragPlace.Type;
16
+ export declare const DragStarted: Schema.TaggedStruct<"DragStarted", {
17
+ /** The marked descendant being dragged. */
18
+ readonly id: Schema.String;
19
+ }>;
20
+ export type DragStarted = typeof DragStarted.Type;
21
+ export declare const DraggedOver: Schema.TaggedStruct<"DraggedOver", {
22
+ /** Where the pointer is, or `null` over nothing marked, or over what is dragged. */
23
+ readonly over: Schema.NullOr<Schema.Struct<{
24
+ readonly id: Schema.String;
25
+ readonly zone: Schema.Literals<readonly ["before", "inside", "after"]>;
26
+ readonly part: Schema.optionalKey<Schema.String>;
27
+ }>>;
28
+ /**
29
+ * For a drag onto `targets`: whether the pointer is inside the region they
30
+ * are in, so `over: null` with `region: true` is its empty space (an empty
31
+ * page, the space below the last node). Absent for a drag among its own.
32
+ */
33
+ readonly region: Schema.optionalKey<Schema.Boolean>;
34
+ }>;
35
+ export type DraggedOver = typeof DraggedOver.Type;
36
+ export declare const DragDropped: Schema.TaggedStruct<"DragDropped", {
37
+ readonly id: Schema.String;
38
+ readonly over: Schema.NullOr<Schema.Struct<{
39
+ readonly id: Schema.String;
40
+ readonly zone: Schema.Literals<readonly ["before", "inside", "after"]>;
41
+ readonly part: Schema.optionalKey<Schema.String>;
42
+ }>>;
43
+ /** As `DraggedOver`'s: released inside the `targets` region. */
44
+ readonly region: Schema.optionalKey<Schema.Boolean>;
45
+ }>;
46
+ export type DragDropped = typeof DragDropped.Type;
47
+ export declare const DragCancelled: Schema.TaggedStruct<"DragCancelled", {
48
+ readonly id: Schema.String;
49
+ }>;
50
+ export type DragCancelled = typeof DragCancelled.Type;
51
+ export type DragFact = DragStarted | DraggedOver | DragDropped | DragCancelled;
52
+ /** How far, in CSS pixels, a press moves before it is a drag rather than a click. */
53
+ export declare const DRAG_THRESHOLD = 4;
54
+ /**
55
+ * How long a finger is held still before its press is a drag. A touch that moves first is a
56
+ * scroll, so a list of draggable rows still scrolls under a finger.
57
+ */
58
+ export declare const HOLD_TO_DRAG_MS = 400;
59
+ /** How far, in CSS pixels, a held finger may wander before the hold is a scroll. */
60
+ export declare const HOLD_SLOP = 8;
61
+ interface Box {
62
+ readonly top: number;
63
+ readonly height: number;
64
+ }
65
+ /** The zone of a box a vertical position falls in, by thirds. */
66
+ export declare const zoneOf: (box: Box, y: number) => DragZone;
67
+ /**
68
+ * An element's box. An element drawn as `display: contents` has none, so its
69
+ * first child's stands for it, as an editor's node wrapper's does.
70
+ */
71
+ export declare const boxOf: (element: Element) => Box;
72
+ /**
73
+ * Dragging one marked descendant of an element onto another, as a Mount. A
74
+ * descendant is marked by an attribute whose value is its id, as `Targets`
75
+ * marks them; a press on one that then moves past a threshold starts a drag (a
76
+ * finger's, held still for `HOLD_TO_DRAG_MS`, as a touch that moves first scrolls), and
77
+ * the pointer's place over another marked descendant is reported with the
78
+ * zone of it the pointer is in: its first third (`before`), its middle
79
+ * (`inside`), or its last third (`after`). Releasing drops, and Escape or a
80
+ * cancelled pointer ends the drag with nothing dropped.
81
+ *
82
+ * It writes no roles, no `tabindex` and no key handling, so the marked
83
+ * elements can be anything: a tree's rows, a canvas's nodes. The keyboard's way
84
+ * to do what a drag does is the parent's to give. Geometry is measured when the
85
+ * pointer moves and never kept; what a drop means is the parent's `update`.
86
+ */
87
+ export declare const PointerDrag: Mount.MountDefinitionWithArgs<"PointerDrag", {
88
+ /** The attribute that marks a descendant, holding its id. */
89
+ attribute: Schema.String;
90
+ /**
91
+ * Where a drag may land, when not on the element's own marked descendants:
92
+ * the elements marked by `attribute` inside the one `within` selects, such
93
+ * as a palette's Blocks dragged onto a page. A drop's `over` is then one of
94
+ * those; what is dragged is still one of the element's own. `within` is
95
+ * looked for nearest first, under the element's closest ancestor that holds
96
+ * a match, so two editors on one page each drop onto their own.
97
+ */
98
+ targets: Schema.optionalKey<Schema.Struct<{
99
+ readonly attribute: Schema.String;
100
+ readonly within: Schema.String;
101
+ }>>;
102
+ /**
103
+ * An attribute that names a part of what a drop lands on, on an element
104
+ * also marked as one: a place over it carries the part and is `inside`.
105
+ */
106
+ part: Schema.optionalKey<Schema.String>;
107
+ }, {
108
+ readonly _tag: "DragStarted";
109
+ readonly id: string;
110
+ } | {
111
+ readonly _tag: "DraggedOver";
112
+ readonly over: {
113
+ readonly id: string;
114
+ readonly zone: "after" | "before" | "inside";
115
+ readonly part?: string;
116
+ } | null;
117
+ readonly region?: boolean;
118
+ } | {
119
+ readonly _tag: "DragDropped";
120
+ readonly id: string;
121
+ readonly over: {
122
+ readonly id: string;
123
+ readonly zone: "after" | "before" | "inside";
124
+ readonly part?: string;
125
+ } | null;
126
+ readonly region?: boolean;
127
+ } | {
128
+ readonly _tag: "DragCancelled";
129
+ readonly id: string;
130
+ }>;
131
+ export {};
132
+ //# sourceMappingURL=pointer-drag.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pointer-drag.d.ts","names":[],"sources":["../../src/dom/pointer-drag.ts"],"mappings":";;qBAIa,UAAQ,OAAA;YACT,kBAAkB,SAAS;;;;;;qBAO1B,WAAS,OAAA;;;;;YAKV,mBAAmB,UAAU;qBAE5B,aAAW,OAAA;;;;YAIZ,qBAAqB,YAAY;qBAEhC,aAAW,OAAA;;;;;;;;;;;;;;YAUZ,qBAAqB,YAAY;qBAEhC,aAAW,OAAA;;;;;;;;;;YAMZ,qBAAqB,YAAY;qBAEhC,eAAa,OAAA;;;YACd,uBAAuB,cAAc;YAErC,WAAW,cAAc,cAAc,cAAc;;qBAGpD;;;;;qBAMA;;qBAGA;UAEH;WACC;WACA;;;qBAIE,SAAM,KAAS,KAAG,cAAc;;;;;qBAUhC,QAAK,SAAa,YAAU;;;;;;;;;;;;;;;;qBAgC5B,aAAW,MAAA"}
@@ -0,0 +1,307 @@
1
+ import { Effect, Queue, Schema, Stream } from "effect";
2
+ import * as Mount from "foldkit/mount";
3
+ import { targetOf } from "./targets.js";
4
+ // src/dom/pointer-drag.ts
5
+ const DragZone = Schema.Literals([
6
+ "before",
7
+ "inside",
8
+ "after"
9
+ ]);
10
+ /**
11
+ * A marked descendant under the pointer, and the zone of it the pointer is in.
12
+ * `part` is the value of the `part` attribute on the element found, such as
13
+ * the empty Region of a node a drop goes into; a place with one is `inside`.
14
+ */
15
+ const DragPlace = Schema.Struct({
16
+ id: Schema.String,
17
+ zone: DragZone,
18
+ part: Schema.optionalKey(Schema.String)
19
+ });
20
+ const DragStarted = Schema.TaggedStruct("DragStarted", {
21
+ /** The marked descendant being dragged. */
22
+ id: Schema.String });
23
+ const DraggedOver = Schema.TaggedStruct("DraggedOver", {
24
+ /** Where the pointer is, or `null` over nothing marked, or over what is dragged. */
25
+ over: Schema.NullOr(DragPlace),
26
+ /**
27
+ * For a drag onto `targets`: whether the pointer is inside the region they
28
+ * are in, so `over: null` with `region: true` is its empty space (an empty
29
+ * page, the space below the last node). Absent for a drag among its own.
30
+ */
31
+ region: Schema.optionalKey(Schema.Boolean)
32
+ });
33
+ const DragDropped = Schema.TaggedStruct("DragDropped", {
34
+ id: Schema.String,
35
+ over: Schema.NullOr(DragPlace),
36
+ /** As `DraggedOver`'s: released inside the `targets` region. */
37
+ region: Schema.optionalKey(Schema.Boolean)
38
+ });
39
+ const DragCancelled = Schema.TaggedStruct("DragCancelled", { id: Schema.String });
40
+ /** How far, in CSS pixels, a press moves before it is a drag rather than a click. */
41
+ const DRAG_THRESHOLD = 4;
42
+ /**
43
+ * How long a finger is held still before its press is a drag. A touch that moves first is a
44
+ * scroll, so a list of draggable rows still scrolls under a finger.
45
+ */
46
+ const HOLD_TO_DRAG_MS = 400;
47
+ /** How far, in CSS pixels, a held finger may wander before the hold is a scroll. */
48
+ const HOLD_SLOP = 8;
49
+ /** The zone of a box a vertical position falls in, by thirds. */
50
+ const zoneOf = (box, y) => {
51
+ if (box.height <= 0) return "inside";
52
+ const at = (y - box.top) / box.height;
53
+ return at < 1 / 3 ? "before" : at > 2 / 3 ? "after" : "inside";
54
+ };
55
+ /**
56
+ * An element's box. An element drawn as `display: contents` has none, so its
57
+ * first child's stands for it, as an editor's node wrapper's does.
58
+ */
59
+ const boxOf = (element) => {
60
+ const own = element.getBoundingClientRect();
61
+ if (own.width > 0 || own.height > 0) return own;
62
+ const child = element.firstElementChild;
63
+ return child === null ? own : boxOf(child);
64
+ };
65
+ /**
66
+ * Dragging one marked descendant of an element onto another, as a Mount. A
67
+ * descendant is marked by an attribute whose value is its id, as `Targets`
68
+ * marks them; a press on one that then moves past a threshold starts a drag (a
69
+ * finger's, held still for `HOLD_TO_DRAG_MS`, as a touch that moves first scrolls), and
70
+ * the pointer's place over another marked descendant is reported with the
71
+ * zone of it the pointer is in: its first third (`before`), its middle
72
+ * (`inside`), or its last third (`after`). Releasing drops, and Escape or a
73
+ * cancelled pointer ends the drag with nothing dropped.
74
+ *
75
+ * It writes no roles, no `tabindex` and no key handling, so the marked
76
+ * elements can be anything: a tree's rows, a canvas's nodes. The keyboard's way
77
+ * to do what a drag does is the parent's to give. Geometry is measured when the
78
+ * pointer moves and never kept; what a drop means is the parent's `update`.
79
+ */
80
+ const PointerDrag = Mount.defineStream("PointerDrag", {
81
+ messages: [
82
+ DragStarted,
83
+ DraggedOver,
84
+ DragDropped,
85
+ DragCancelled
86
+ ],
87
+ args: {
88
+ /** The attribute that marks a descendant, holding its id. */
89
+ attribute: Schema.String,
90
+ /**
91
+ * Where a drag may land, when not on the element's own marked descendants:
92
+ * the elements marked by `attribute` inside the one `within` selects, such
93
+ * as a palette's Blocks dragged onto a page. A drop's `over` is then one of
94
+ * those; what is dragged is still one of the element's own. `within` is
95
+ * looked for nearest first, under the element's closest ancestor that holds
96
+ * a match, so two editors on one page each drop onto their own.
97
+ */
98
+ targets: Schema.optionalKey(Schema.Struct({
99
+ attribute: Schema.String,
100
+ within: Schema.String
101
+ })),
102
+ /**
103
+ * An attribute that names a part of what a drop lands on, on an element
104
+ * also marked as one: a place over it carries the part and is `inside`.
105
+ */
106
+ part: Schema.optionalKey(Schema.String)
107
+ },
108
+ execute: ({ element, attribute, targets, part }) => Stream.callback((queue) => Effect.acquireRelease(Effect.sync(() => {
109
+ const owner = element.ownerDocument;
110
+ const landsOn = targets?.attribute ?? attribute;
111
+ const regionOf = (within) => {
112
+ for (let at = element.parentElement; at !== null; at = at.parentElement) {
113
+ const found = at.querySelector(within);
114
+ if (found !== null) return found;
115
+ }
116
+ return null;
117
+ };
118
+ const find = (from) => {
119
+ if (!(from instanceof Element)) return {
120
+ marked: null,
121
+ inRegion: false
122
+ };
123
+ const region = targets === void 0 ? element : regionOf(targets.within);
124
+ const marked = from.closest(`[${landsOn}]`);
125
+ return {
126
+ marked: marked !== null && region !== null && region.contains(marked) ? marked : null,
127
+ inRegion: targets !== void 0 && region !== null && region.contains(from)
128
+ };
129
+ };
130
+ let pressed = null;
131
+ let holding;
132
+ const begin = (id) => {
133
+ dragging = id;
134
+ owner.getSelection()?.removeAllRanges();
135
+ Queue.offerUnsafe(queue, DragStarted.make({ id }));
136
+ };
137
+ let dragging = null;
138
+ let over = null;
139
+ let inRegion = false;
140
+ let swallowClick = false;
141
+ const placeAt = (event) => {
142
+ const under = typeof owner.elementFromPoint === "function" && event.clientX !== void 0 ? owner.elementFromPoint(event.clientX, event.clientY ?? 0) : null;
143
+ const { marked, inRegion: region } = find(under ?? event.target);
144
+ const id = marked?.getAttribute(landsOn) ?? null;
145
+ const named = part === void 0 ? null : marked?.getAttribute(part) ?? null;
146
+ return {
147
+ place: marked === null || id === null || targets === void 0 && id === dragging ? null : named === null ? {
148
+ id,
149
+ zone: zoneOf(boxOf(marked), event.clientY ?? 0)
150
+ } : {
151
+ id,
152
+ zone: "inside",
153
+ part: named
154
+ },
155
+ region
156
+ };
157
+ };
158
+ /** The region flag a fact carries: only for a drag onto `targets`. */
159
+ const withRegion = (region) => targets === void 0 ? {} : { region };
160
+ const ours = (event) => pressed !== null && (pressed.pointer === void 0 || event.pointerId === pressed.pointer);
161
+ const end = (dropped, at, inside = false) => {
162
+ clearTimeout(holding);
163
+ holding = void 0;
164
+ const id = dragging;
165
+ if (id !== null && at?.clientX !== void 0 && at.clientY !== void 0) {
166
+ const { place, region } = placeAt(at);
167
+ over = place;
168
+ inRegion = region;
169
+ }
170
+ pressed = null;
171
+ dragging = null;
172
+ const last = over;
173
+ const lastRegion = inRegion;
174
+ over = null;
175
+ inRegion = false;
176
+ release();
177
+ if (id === null) return;
178
+ swallowClick = dropped && inside;
179
+ Queue.offerUnsafe(queue, dropped ? DragDropped.make({
180
+ id,
181
+ over: last,
182
+ ...withRegion(lastRegion)
183
+ }) : DragCancelled.make({ id }));
184
+ };
185
+ const onDocument = [
186
+ ["pointermove", (event) => {
187
+ const positioned = event;
188
+ if (!ours(positioned) || pressed === null) return;
189
+ if (positioned.buttons !== void 0 && (positioned.buttons & 1) === 0) return end(false);
190
+ if (dragging === null) {
191
+ const moved = Math.hypot((positioned.clientX ?? 0) - pressed.x, (positioned.clientY ?? 0) - pressed.y);
192
+ if (pressed.touch) return moved < 8 ? void 0 : end(false);
193
+ if (moved < 4) return;
194
+ begin(pressed.id);
195
+ }
196
+ const { place, region } = placeAt(positioned);
197
+ if (place?.id === over?.id && place?.zone === over?.zone && place?.part === over?.part && region === inRegion) return;
198
+ over = place;
199
+ inRegion = region;
200
+ Queue.offerUnsafe(queue, DraggedOver.make({
201
+ over: place,
202
+ ...withRegion(region)
203
+ }));
204
+ }],
205
+ ["pointerup", (event) => {
206
+ if (!ours(event)) return;
207
+ if (dragging === null) end(false);
208
+ else end(true, event, event.target instanceof Node && element.contains(event.target));
209
+ }],
210
+ ["pointercancel", (event) => {
211
+ if (ours(event)) end(false);
212
+ }]
213
+ ];
214
+ const onEscape = (event) => {
215
+ if (pressed === null || event.key !== "Escape") return;
216
+ event.preventDefault();
217
+ event.stopPropagation();
218
+ end(false);
219
+ };
220
+ const heldStill = (event) => {
221
+ if (dragging !== null) event.preventDefault();
222
+ };
223
+ const noMenu = (event) => {
224
+ if (pressed?.touch === true) event.preventDefault();
225
+ };
226
+ let listening = false;
227
+ const listen = () => {
228
+ if (listening) return;
229
+ listening = true;
230
+ for (const [type, listener] of onDocument) owner.addEventListener(type, listener);
231
+ owner.addEventListener("keydown", onEscape, true);
232
+ owner.addEventListener("touchmove", heldStill, { passive: false });
233
+ owner.addEventListener("contextmenu", noMenu);
234
+ };
235
+ const release = () => {
236
+ if (!listening) return;
237
+ listening = false;
238
+ for (const [type, listener] of onDocument) owner.removeEventListener(type, listener);
239
+ owner.removeEventListener("keydown", onEscape, true);
240
+ owner.removeEventListener("touchmove", heldStill);
241
+ owner.removeEventListener("contextmenu", noMenu);
242
+ };
243
+ const onElement = [
244
+ [
245
+ "pointerdown",
246
+ (event) => {
247
+ const positioned = event;
248
+ swallowClick = false;
249
+ if (pressed !== null) return;
250
+ if ((positioned.button ?? 0) !== 0) return;
251
+ if (event.target instanceof Element && event.target.closest("[contenteditable]:not([contenteditable=\"false\"])") !== null) return;
252
+ const id = targetOf(element, event.target, attribute);
253
+ if (id === null) return;
254
+ const touch = positioned.pointerType === "touch";
255
+ pressed = {
256
+ id,
257
+ pointer: positioned.pointerId,
258
+ x: positioned.clientX ?? 0,
259
+ y: positioned.clientY ?? 0,
260
+ touch
261
+ };
262
+ listen();
263
+ if (touch) holding = setTimeout(() => {
264
+ holding = void 0;
265
+ if (pressed !== null && dragging === null) begin(pressed.id);
266
+ }, 400);
267
+ },
268
+ false
269
+ ],
270
+ [
271
+ "click",
272
+ (event) => {
273
+ if (!swallowClick) return;
274
+ swallowClick = false;
275
+ event.preventDefault();
276
+ event.stopImmediatePropagation();
277
+ },
278
+ true
279
+ ],
280
+ [
281
+ "dragstart",
282
+ (event) => event.preventDefault(),
283
+ false
284
+ ]
285
+ ];
286
+ for (const [type, listener, capture] of onElement) element.addEventListener(type, listener, capture);
287
+ const callout = element instanceof HTMLElement ? element.style.getPropertyValue("-webkit-touch-callout") : void 0;
288
+ if (element instanceof HTMLElement) element.style.setProperty("-webkit-touch-callout", "none");
289
+ const stop = () => {
290
+ clearTimeout(holding);
291
+ release();
292
+ if (!(element instanceof HTMLElement)) return;
293
+ if (callout === void 0 || callout === "") element.style.removeProperty("-webkit-touch-callout");
294
+ else element.style.setProperty("-webkit-touch-callout", callout);
295
+ };
296
+ return {
297
+ onElement,
298
+ stop
299
+ };
300
+ }), ({ onElement, stop }) => Effect.sync(() => {
301
+ for (const [type, listener, capture] of onElement) element.removeEventListener(type, listener, capture);
302
+ stop();
303
+ })))
304
+ });
305
+ export { DRAG_THRESHOLD, DragCancelled, DragDropped, DragPlace, DragStarted, DragZone, DraggedOver, HOLD_SLOP, HOLD_TO_DRAG_MS, PointerDrag, boxOf, zoneOf };
306
+
307
+ //# sourceMappingURL=pointer-drag.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pointer-drag.js","names":[],"sources":["../../src/dom/pointer-drag.ts"],"sourcesContent":["import { Effect, Queue, Schema, Stream } from 'effect'\nimport * as Mount from 'foldkit/mount'\nimport { targetOf } from './targets.js'\n\nexport const DragZone = Schema.Literals(['before', 'inside', 'after'])\nexport type DragZone = typeof DragZone.Type\n\n/**\n * A marked descendant under the pointer, and the zone of it the pointer is in.\n * `part` is the value of the `part` attribute on the element found, such as\n * the empty Region of a node a drop goes into; a place with one is `inside`.\n */\nexport const DragPlace = Schema.Struct({\n id: Schema.String,\n zone: DragZone,\n part: Schema.optionalKey(Schema.String),\n})\nexport type DragPlace = typeof DragPlace.Type\n\nexport const DragStarted = Schema.TaggedStruct('DragStarted', {\n /** The marked descendant being dragged. */\n id: Schema.String,\n})\nexport type DragStarted = typeof DragStarted.Type\n\nexport const DraggedOver = Schema.TaggedStruct('DraggedOver', {\n /** Where the pointer is, or `null` over nothing marked, or over what is dragged. */\n over: Schema.NullOr(DragPlace),\n /**\n * For a drag onto `targets`: whether the pointer is inside the region they\n * are in, so `over: null` with `region: true` is its empty space (an empty\n * page, the space below the last node). Absent for a drag among its own.\n */\n region: Schema.optionalKey(Schema.Boolean),\n})\nexport type DraggedOver = typeof DraggedOver.Type\n\nexport const DragDropped = Schema.TaggedStruct('DragDropped', {\n id: Schema.String,\n over: Schema.NullOr(DragPlace),\n /** As `DraggedOver`'s: released inside the `targets` region. */\n region: Schema.optionalKey(Schema.Boolean),\n})\nexport type DragDropped = typeof DragDropped.Type\n\nexport const DragCancelled = Schema.TaggedStruct('DragCancelled', { id: Schema.String })\nexport type DragCancelled = typeof DragCancelled.Type\n\nexport type DragFact = DragStarted | DraggedOver | DragDropped | DragCancelled\n\n/** How far, in CSS pixels, a press moves before it is a drag rather than a click. */\nexport const DRAG_THRESHOLD = 4\n\n/**\n * How long a finger is held still before its press is a drag. A touch that moves first is a\n * scroll, so a list of draggable rows still scrolls under a finger.\n */\nexport const HOLD_TO_DRAG_MS = 400\n\n/** How far, in CSS pixels, a held finger may wander before the hold is a scroll. */\nexport const HOLD_SLOP = 8\n\ninterface Box {\n readonly top: number\n readonly height: number\n}\n\n/** The zone of a box a vertical position falls in, by thirds. */\nexport const zoneOf = (box: Box, y: number): DragZone => {\n if (box.height <= 0) return 'inside'\n const at = (y - box.top) / box.height\n return at < 1 / 3 ? 'before' : at > 2 / 3 ? 'after' : 'inside'\n}\n\n/**\n * An element's box. An element drawn as `display: contents` has none, so its\n * first child's stands for it, as an editor's node wrapper's does.\n */\nexport const boxOf = (element: Element): Box => {\n const own = element.getBoundingClientRect()\n if (own.width > 0 || own.height > 0) return own\n const child = element.firstElementChild\n return child === null ? own : boxOf(child)\n}\n\ntype Positioned = Event & {\n readonly clientX?: number\n readonly clientY?: number\n readonly button?: number\n readonly buttons?: number\n readonly pointerId?: number\n readonly pointerType?: string\n readonly key?: string\n}\n\n/**\n * Dragging one marked descendant of an element onto another, as a Mount. A\n * descendant is marked by an attribute whose value is its id, as `Targets`\n * marks them; a press on one that then moves past a threshold starts a drag (a\n * finger's, held still for `HOLD_TO_DRAG_MS`, as a touch that moves first scrolls), and\n * the pointer's place over another marked descendant is reported with the\n * zone of it the pointer is in: its first third (`before`), its middle\n * (`inside`), or its last third (`after`). Releasing drops, and Escape or a\n * cancelled pointer ends the drag with nothing dropped.\n *\n * It writes no roles, no `tabindex` and no key handling, so the marked\n * elements can be anything: a tree's rows, a canvas's nodes. The keyboard's way\n * to do what a drag does is the parent's to give. Geometry is measured when the\n * pointer moves and never kept; what a drop means is the parent's `update`.\n */\nexport const PointerDrag = Mount.defineStream('PointerDrag', {\n messages: [DragStarted, DraggedOver, DragDropped, DragCancelled],\n args: {\n /** The attribute that marks a descendant, holding its id. */\n attribute: Schema.String,\n /**\n * Where a drag may land, when not on the element's own marked descendants:\n * the elements marked by `attribute` inside the one `within` selects, such\n * as a palette's Blocks dragged onto a page. A drop's `over` is then one of\n * those; what is dragged is still one of the element's own. `within` is\n * looked for nearest first, under the element's closest ancestor that holds\n * a match, so two editors on one page each drop onto their own.\n */\n targets: Schema.optionalKey(Schema.Struct({ attribute: Schema.String, within: Schema.String })),\n /**\n * An attribute that names a part of what a drop lands on, on an element\n * also marked as one: a place over it carries the part and is `inside`.\n */\n part: Schema.optionalKey(Schema.String),\n },\n execute: ({ element, attribute, targets, part }) =>\n Stream.callback<DragFact>(queue =>\n Effect.acquireRelease(\n Effect.sync(() => {\n const owner = element.ownerDocument\n // What a drop lands on: the element's own marked descendants, or those of `targets`.\n const landsOn = targets?.attribute ?? attribute\n // Looked for at each move, so a redraw that replaced it is followed.\n const regionOf = (within: string): Element | null => {\n for (let at = element.parentElement; at !== null; at = at.parentElement) {\n const found = at.querySelector(within)\n if (found !== null) return found\n }\n return null\n }\n const find = (from: EventTarget | null) => {\n if (!(from instanceof Element)) return { marked: null, inRegion: false }\n const region = targets === undefined ? element : regionOf(targets.within)\n const marked = from.closest(`[${landsOn}]`)\n return {\n marked: marked !== null && region !== null && region.contains(marked) ? marked : null,\n // Only a drag onto `targets` tells its region's empty space from elsewhere.\n inRegion: targets !== undefined && region !== null && region.contains(from),\n }\n }\n // A press not yet a drag, or a drag under way: one pointer's, the first down.\n let pressed: {\n readonly id: string\n readonly pointer: number | undefined\n readonly x: number\n readonly y: number\n /** A finger's: a drag once held still, a scroll if it moves first. */\n readonly touch: boolean\n } | null = null\n let holding: ReturnType<typeof setTimeout> | undefined\n const begin = (id: string) => {\n dragging = id\n owner.getSelection()?.removeAllRanges()\n Queue.offerUnsafe(queue, DragStarted.make({ id }))\n }\n let dragging: string | null = null\n let over: DragPlace | null = null\n let inRegion = false\n // The click that ends a drag is not a press on what it ends over.\n let swallowClick = false\n\n const placeAt = (event: Positioned) => {\n // Touch and pen capture the pointer to where it went down, so the\n // event's target is the dragged element: ask what is under it instead.\n const under =\n typeof owner.elementFromPoint === 'function' && event.clientX !== undefined\n ? owner.elementFromPoint(event.clientX, event.clientY ?? 0)\n : null\n const { marked, inRegion: region } = find(under ?? event.target)\n const id = marked?.getAttribute(landsOn) ?? null\n // Over itself is over nothing, where what is dragged is among what it lands on.\n const named = part === undefined ? null : (marked?.getAttribute(part) ?? null)\n const place: DragPlace | null =\n marked === null || id === null || (targets === undefined && id === dragging)\n ? null\n : named === null\n ? { id, zone: zoneOf(boxOf(marked), event.clientY ?? 0) }\n : { id, zone: 'inside', part: named }\n return { place, region }\n }\n /** The region flag a fact carries: only for a drag onto `targets`. */\n const withRegion = (region: boolean) => (targets === undefined ? {} : { region })\n const ours = (event: Positioned) =>\n pressed !== null &&\n (pressed.pointer === undefined || event.pointerId === pressed.pointer)\n // `inside`: the release was on the container, so its click will reach it.\n // The release is hit-tested again: the layout may have moved since\n // the last move (a scroll, a row that shifted), and the drop says\n // where the pointer was let go, not where it was last seen. A\n // release with no position of its own keeps the last move's answer.\n const end = (dropped: boolean, at?: Positioned, inside = false) => {\n clearTimeout(holding)\n holding = undefined\n const id = dragging\n if (id !== null && at?.clientX !== undefined && at.clientY !== undefined) {\n const { place, region } = placeAt(at)\n over = place\n inRegion = region\n }\n pressed = null\n dragging = null\n const last = over\n const lastRegion = inRegion\n over = null\n inRegion = false\n release()\n if (id === null) return\n swallowClick = dropped && inside\n Queue.offerUnsafe(\n queue,\n dropped\n ? DragDropped.make({ id, over: last, ...withRegion(lastRegion) })\n : DragCancelled.make({ id }),\n )\n }\n\n const onDocument: ReadonlyArray<readonly [string, (event: Event) => void]> = [\n [\n 'pointermove',\n event => {\n const positioned = event as Positioned\n if (!ours(positioned) || pressed === null) return\n // Released where no pointerup reached us, such as over a frame.\n if (positioned.buttons !== undefined && (positioned.buttons & 1) === 0)\n return end(false)\n if (dragging === null) {\n const moved = Math.hypot(\n (positioned.clientX ?? 0) - pressed.x,\n (positioned.clientY ?? 0) - pressed.y,\n )\n // A finger that moves before its hold is up is scrolling, not dragging.\n if (pressed.touch) return moved < HOLD_SLOP ? undefined : end(false)\n if (moved < DRAG_THRESHOLD) return\n begin(pressed.id)\n }\n const { place, region } = placeAt(positioned)\n if (\n place?.id === over?.id &&\n place?.zone === over?.zone &&\n place?.part === over?.part &&\n region === inRegion\n )\n return\n over = place\n inRegion = region\n Queue.offerUnsafe(queue, DraggedOver.make({ over: place, ...withRegion(region) }))\n },\n ],\n [\n 'pointerup',\n event => {\n if (!ours(event as Positioned)) return\n if (dragging === null) end(false)\n else\n end(\n true,\n event as Positioned,\n event.target instanceof Node && element.contains(event.target),\n )\n },\n ],\n [\n 'pointercancel',\n event => {\n if (ours(event as Positioned)) end(false)\n },\n ],\n ]\n // Heard on the way down, and kept there: an Escape that ends a drag is the\n // drag's, not also the focused element's (a canvas that would deselect).\n const onEscape = (event: Event) => {\n if (pressed === null || (event as Positioned).key !== 'Escape') return\n event.preventDefault()\n event.stopPropagation()\n end(false)\n }\n // Once a finger's drag is under way, the browser must not take its moves for a scroll,\n // and a held finger opens no menu of its own (Android's `contextmenu`). Not passive:\n // only a listener that may cancel can keep the page still.\n const heldStill = (event: Event) => {\n if (dragging !== null) event.preventDefault()\n }\n const noMenu = (event: Event) => {\n if (pressed?.touch === true) event.preventDefault()\n }\n // The document is listened to only while a press is under way.\n let listening = false\n const listen = () => {\n if (listening) return\n listening = true\n for (const [type, listener] of onDocument) owner.addEventListener(type, listener)\n owner.addEventListener('keydown', onEscape, true)\n owner.addEventListener('touchmove', heldStill, { passive: false })\n owner.addEventListener('contextmenu', noMenu)\n }\n const release = () => {\n if (!listening) return\n listening = false\n for (const [type, listener] of onDocument) owner.removeEventListener(type, listener)\n owner.removeEventListener('keydown', onEscape, true)\n owner.removeEventListener('touchmove', heldStill)\n owner.removeEventListener('contextmenu', noMenu)\n }\n\n const onElement: ReadonlyArray<readonly [string, (event: Event) => void, boolean]> = [\n [\n 'pointerdown',\n event => {\n const positioned = event as Positioned\n // Any press is past the drop a swallowed click was waiting for.\n swallowClick = false\n // A second pointer while one is down is not a new drag.\n if (pressed !== null) return\n if ((positioned.button ?? 0) !== 0) return\n // A press in text being edited selects text: it is no drag.\n if (\n event.target instanceof Element &&\n event.target.closest('[contenteditable]:not([contenteditable=\"false\"])') !== null\n )\n return\n const id = targetOf(element, event.target, attribute)\n if (id === null) return\n const touch = positioned.pointerType === 'touch'\n pressed = {\n id,\n pointer: positioned.pointerId,\n x: positioned.clientX ?? 0,\n y: positioned.clientY ?? 0,\n touch,\n }\n listen()\n if (touch) {\n holding = setTimeout(() => {\n holding = undefined\n if (pressed !== null && dragging === null) begin(pressed.id)\n }, HOLD_TO_DRAG_MS)\n }\n },\n false,\n ],\n [\n 'click',\n event => {\n if (!swallowClick) return\n swallowClick = false\n event.preventDefault()\n event.stopImmediatePropagation()\n },\n true,\n ],\n // A link or an image would start the browser's own drag instead.\n ['dragstart', event => event.preventDefault(), false],\n ]\n for (const [type, listener, capture] of onElement)\n element.addEventListener(type, listener, capture)\n // No callout of iOS's own over a finger held to drag, on anything inside (inherited).\n const callout =\n element instanceof HTMLElement\n ? element.style.getPropertyValue('-webkit-touch-callout')\n : undefined\n if (element instanceof HTMLElement) {\n element.style.setProperty('-webkit-touch-callout', 'none')\n }\n // Ended mid-hold: the hold must not start a drag after it.\n const stop = () => {\n clearTimeout(holding)\n release()\n if (!(element instanceof HTMLElement)) return\n if (callout === undefined || callout === '') {\n element.style.removeProperty('-webkit-touch-callout')\n } else element.style.setProperty('-webkit-touch-callout', callout)\n }\n return { onElement, stop }\n }),\n ({ onElement, stop }) =>\n Effect.sync(() => {\n for (const [type, listener, capture] of onElement)\n element.removeEventListener(type, listener, capture)\n stop()\n }),\n ),\n ),\n})\n"],"mappings":";;;;AAIA,MAAa,WAAW,OAAO,SAAS;CAAC;CAAU;CAAU;AAAO,CAAC;;;;;;AAQrE,MAAa,YAAY,OAAO,OAAO;CACrC,IAAI,OAAO;CACX,MAAM;CACN,MAAM,OAAO,YAAY,OAAO,MAAM;AACxC,CAAC;AAGD,MAAa,cAAc,OAAO,aAAa,eAAe;;AAE5D,IAAI,OAAO,OACb,CAAC;AAGD,MAAa,cAAc,OAAO,aAAa,eAAe;;CAE5D,MAAM,OAAO,OAAO,SAAS;;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;EACrD,KAAK;CACP,CAAC,CACL,CACF;AACJ,CAAC"}
@@ -0,0 +1,133 @@
1
+ import { Schema } from "effect";
2
+ import * as Mount from "foldkit/mount";
3
+ /**
4
+ * A place in an element's padding box, in CSS pixels from its top left
5
+ * corner, and the pointer's pressure there (0 to 1; a mouse reads 0.5 while
6
+ * a button is down). A captured pointer can be outside the box, so `x` and
7
+ * `y` can be negative or past its size.
8
+ */
9
+ export declare const PointerPoint: Schema.Struct<{
10
+ readonly x: Schema.Number;
11
+ readonly y: Schema.Number;
12
+ readonly pressure: Schema.Number;
13
+ }>;
14
+ export type PointerPoint = typeof PointerPoint.Type;
15
+ export declare const PointerPressed: Schema.TaggedStruct<"PointerPressed", {
16
+ readonly width: Schema.Number;
17
+ readonly height: Schema.Number;
18
+ readonly point: Schema.Struct<{
19
+ readonly x: Schema.Number;
20
+ readonly y: Schema.Number;
21
+ readonly pressure: Schema.Number;
22
+ }>;
23
+ /** `mouse`, `pen` or `touch`, as the browser names it. */
24
+ readonly pointerType: Schema.String;
25
+ }>;
26
+ export type PointerPressed = typeof PointerPressed.Type;
27
+ export declare const PointerMoved: Schema.TaggedStruct<"PointerMoved", {
28
+ readonly width: Schema.Number;
29
+ readonly height: Schema.Number;
30
+ /** Where the pointer is now. */
31
+ readonly point: Schema.Struct<{
32
+ readonly x: Schema.Number;
33
+ readonly y: Schema.Number;
34
+ readonly pressure: Schema.Number;
35
+ }>;
36
+ /**
37
+ * Every place it passed since the last move, ending with `point`: the
38
+ * browser's coalesced events, so a fast stroke keeps its curve. Just
39
+ * `point` where the browser coalesces none.
40
+ */
41
+ readonly points: Schema.$Array<Schema.Struct<{
42
+ readonly x: Schema.Number;
43
+ readonly y: Schema.Number;
44
+ readonly pressure: Schema.Number;
45
+ }>>;
46
+ }>;
47
+ export type PointerMoved = typeof PointerMoved.Type;
48
+ export declare const PointerReleased: Schema.TaggedStruct<"PointerReleased", {
49
+ /** `false` when the pointer was cancelled, lost its capture, or pressed again unreleased. */
50
+ readonly completed: Schema.Boolean;
51
+ }>;
52
+ export type PointerReleased = typeof PointerReleased.Type;
53
+ export type PointerFact = PointerPressed | PointerMoved | PointerReleased;
54
+ interface Sides {
55
+ readonly top: number;
56
+ readonly right: number;
57
+ readonly bottom: number;
58
+ readonly left: number;
59
+ }
60
+ export interface Rect {
61
+ readonly left: number;
62
+ readonly top: number;
63
+ readonly width: number;
64
+ readonly height: number;
65
+ }
66
+ /**
67
+ * The padding box of an element whose border box is `rect`: inside its
68
+ * border, padding included. An absolutely positioned child (a thumb, a
69
+ * stroke) is laid out against it, so a place read here is where that child
70
+ * sits, whatever padding a stylist adds.
71
+ */
72
+ export declare const paddingBoxOf: (layout: {
73
+ readonly rect: Rect;
74
+ readonly border: Sides;
75
+ }) => Rect;
76
+ /**
77
+ * An element's padding box now, in the viewport, as `PointerPosition`
78
+ * measures it: for a size kept beside its places, which a `ResizeObserver`'s
79
+ * content box does not match once the element has padding. Read from the
80
+ * bounding rectangle and the computed border, since `clientWidth` and
81
+ * `clientLeft` round to whole pixels.
82
+ */
83
+ export declare const measurePaddingBox: (element: Element) => Rect;
84
+ /**
85
+ * Where one pointer is inside an element, as a Mount, for a surface the
86
+ * pointer draws on or points into (a color area, a dial, a signature pad): a
87
+ * primary press, each move until the release, and the release, each with
88
+ * the place in the element's padding box and the box's size. The box is
89
+ * measured at each event, so an element that moved or resized is followed.
90
+ * Coordinates are raw, left to right and top down whatever the direction:
91
+ * what a place means (a share, an angle, a reading direction) is the parent's.
92
+ *
93
+ * The pointer is captured from press to release, so a drag that leaves the
94
+ * element is still heard, and the moves and the release are listened to only
95
+ * meanwhile. A press keeps the browser's own focus and text selection away,
96
+ * and a second pointer while one is down is ignored.
97
+ */
98
+ export declare const PointerPosition: Mount.MountDefinitionWithArgs<"PointerPosition", {
99
+ /**
100
+ * A descendant to focus on a press, found by this selector (a thumb), so
101
+ * the keys go on from where the pointer left it.
102
+ */
103
+ focus: Schema.optionalKey<Schema.String>;
104
+ }, {
105
+ readonly _tag: "PointerPressed";
106
+ readonly width: number;
107
+ readonly height: number;
108
+ readonly point: {
109
+ readonly x: number;
110
+ readonly y: number;
111
+ readonly pressure: number;
112
+ };
113
+ readonly pointerType: string;
114
+ } | {
115
+ readonly _tag: "PointerMoved";
116
+ readonly width: number;
117
+ readonly height: number;
118
+ readonly point: {
119
+ readonly x: number;
120
+ readonly y: number;
121
+ readonly pressure: number;
122
+ };
123
+ readonly points: readonly {
124
+ readonly x: number;
125
+ readonly y: number;
126
+ readonly pressure: number;
127
+ }[];
128
+ } | {
129
+ readonly _tag: "PointerReleased";
130
+ readonly completed: boolean;
131
+ }>;
132
+ export {};
133
+ //# sourceMappingURL=pointer-position.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pointer-position.d.ts","names":[],"sources":["../../src/dom/pointer-position.ts"],"mappings":";;;;;;;;qBASa,cAAY,OAAA;;;;;YAKb,sBAAsB,aAAa;qBAKlC,gBAAc,OAAA;;;;;;;;;;;YAMf,wBAAwB,eAAe;qBAEtC,cAAY,OAAA;;;;;;;;;;;;;;;;;;;;YAWb,sBAAsB,aAAa;qBAElC,iBAAe,OAAA;;;;YAIhB,yBAAyB,gBAAgB;YAEzC,cAAc,iBAAiB,eAAe;UAEhD;WACC;WACA;WACA;WACA;;iBAGM;WACN;WACA;WACA;WACA;;;;;;;;qBASE,eAAY;WAAuB,MAAM;WAAe,QAAQ;MAAU;;;;;;;;qBAwB1E,oBAAiB,SAAa,YAAU;;;;;;;;;;;;;;;qBA0BxC,iBAAe,MAAA"}