@astryxdesign/core 0.7.6-canary.ec128c4 → 0.7.6-canary.f73623d

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 (454) hide show
  1. package/dist/AppShell/AppShell.d.ts.map +1 -1
  2. package/dist/AppShell/AppShell.js +183 -5
  3. package/dist/AppShell/observeMainOverflow.d.ts +9 -0
  4. package/dist/AppShell/observeMainOverflow.d.ts.map +1 -0
  5. package/dist/AppShell/observeMainOverflow.js +125 -0
  6. package/dist/Carousel/Carousel.d.ts +3 -1
  7. package/dist/Carousel/Carousel.d.ts.map +1 -1
  8. package/dist/Carousel/Carousel.js +12 -3
  9. package/dist/ComplexSelector/ComplexSelector.d.ts.map +1 -1
  10. package/dist/ComplexSelector/ComplexSelector.js +41 -4
  11. package/dist/DateInput/Wheel.d.ts.map +1 -1
  12. package/dist/DateInput/Wheel.js +11 -7
  13. package/dist/DateInput/usePointerDragScroll.d.ts +10 -1
  14. package/dist/DateInput/usePointerDragScroll.d.ts.map +1 -1
  15. package/dist/DateInput/usePointerDragScroll.js +25 -9
  16. package/dist/DateInput/useScrollSettle.d.ts +3 -1
  17. package/dist/DateInput/useScrollSettle.d.ts.map +1 -1
  18. package/dist/DateInput/useScrollSettle.js +37 -8
  19. package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
  20. package/dist/DropdownMenu/DropdownMenu.js +28 -19
  21. package/dist/Item/Item.d.ts.map +1 -1
  22. package/dist/Item/Item.js +19 -6
  23. package/dist/Layer/useLayer.d.ts.map +1 -1
  24. package/dist/Layer/useLayer.js +27 -6
  25. package/dist/Link/Link.d.ts.map +1 -1
  26. package/dist/Link/Link.js +8 -3
  27. package/dist/Markdown/plugins/headingLinks.a11y.chromium.spec.js +1 -1
  28. package/dist/NavMenu/NavHeadingMenuItem.d.ts.map +1 -1
  29. package/dist/NavMenu/NavHeadingMenuItem.js +5 -29
  30. package/dist/NumberInput/NumberInput.d.ts.map +1 -1
  31. package/dist/NumberInput/NumberInput.js +23 -2
  32. package/dist/Outline/Outline.d.ts.map +1 -1
  33. package/dist/Outline/Outline.js +27 -0
  34. package/dist/Popover/Popover.d.ts.map +1 -1
  35. package/dist/Popover/Popover.js +32 -12
  36. package/dist/Popover/usePopover.d.ts.map +1 -1
  37. package/dist/Popover/usePopover.js +10 -3
  38. package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
  39. package/dist/PowerSearch/PowerSearch.js +37 -30
  40. package/dist/RadioList/RadioListItem.d.ts.map +1 -1
  41. package/dist/RadioList/RadioListItem.js +11 -3
  42. package/dist/SideNav/SideNavItem.d.ts +2 -2
  43. package/dist/SideNav/SideNavItem.d.ts.map +1 -1
  44. package/dist/SideNav/SideNavItem.js +18 -7
  45. package/dist/Skeleton/Skeleton.d.ts.map +1 -1
  46. package/dist/Skeleton/Skeleton.js +1 -1
  47. package/dist/Spinner/Spinner.d.ts.map +1 -1
  48. package/dist/Spinner/Spinner.js +1 -1
  49. package/dist/Stepper/Step.d.ts.map +1 -1
  50. package/dist/Stepper/Step.js +26 -6
  51. package/dist/Switch/Switch.d.ts.map +1 -1
  52. package/dist/Switch/Switch.js +10 -3
  53. package/dist/Table/Table.d.ts.map +1 -1
  54. package/dist/Table/Table.js +36 -10
  55. package/dist/Table/plugins/sortable/useTableSortable.d.ts.map +1 -1
  56. package/dist/Table/plugins/sortable/useTableSortable.js +46 -58
  57. package/dist/Toast/ToastViewport.d.ts.map +1 -1
  58. package/dist/Toast/ToastViewport.js +19 -3
  59. package/dist/ToggleButton/ToggleButtonGroup.d.ts +7 -1
  60. package/dist/ToggleButton/ToggleButtonGroup.d.ts.map +1 -1
  61. package/dist/ToggleButton/ToggleButtonGroup.js +16 -2
  62. package/dist/Token/Token.d.ts.map +1 -1
  63. package/dist/Token/Token.js +37 -5
  64. package/dist/Token/TokenLink.d.ts.map +1 -1
  65. package/dist/Token/TokenLink.js +14 -2
  66. package/dist/Tokenizer/Tokenizer.d.ts.map +1 -1
  67. package/dist/Tokenizer/Tokenizer.js +15 -4
  68. package/dist/Tokenizer/TokenizerClearAllMessageContext.d.ts +2 -0
  69. package/dist/Tokenizer/TokenizerClearAllMessageContext.d.ts.map +1 -0
  70. package/dist/Tokenizer/TokenizerClearAllMessageContext.js +17 -0
  71. package/dist/TreeList/TreeListItem.d.ts.map +1 -1
  72. package/dist/TreeList/TreeListItem.js +27 -4
  73. package/dist/Typeahead/BaseTypeahead.d.ts +4 -4
  74. package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
  75. package/dist/Typeahead/BaseTypeahead.js +43 -7
  76. package/dist/astryx.css +10 -3
  77. package/dist/gestures/GestureArena.d.ts +26 -1
  78. package/dist/gestures/GestureArena.d.ts.map +1 -1
  79. package/dist/gestures/GestureArena.js +71 -9
  80. package/dist/gestures/GestureHost.d.ts +2 -3
  81. package/dist/gestures/GestureHost.d.ts.map +1 -1
  82. package/dist/gestures/GestureHost.js +7 -7
  83. package/dist/gestures/GestureRecognizer.d.ts +3 -1
  84. package/dist/gestures/GestureRecognizer.d.ts.map +1 -1
  85. package/dist/gestures/GestureRecognizer.js +3 -1
  86. package/dist/gestures/PressTracker.d.ts +112 -0
  87. package/dist/gestures/PressTracker.d.ts.map +1 -0
  88. package/dist/gestures/PressTracker.js +267 -0
  89. package/dist/gestures/index.d.ts +37 -0
  90. package/dist/gestures/index.d.ts.map +1 -0
  91. package/dist/gestures/index.js +25 -0
  92. package/dist/gestures/useGestureRecognizer.d.ts +56 -0
  93. package/dist/gestures/useGestureRecognizer.d.ts.map +1 -0
  94. package/dist/gestures/useGestureRecognizer.js +226 -0
  95. package/dist/hooks/scrollKeyboardDelegation.d.ts.map +1 -1
  96. package/dist/hooks/scrollKeyboardDelegation.js +7 -3
  97. package/dist/hooks/useScrollOverflow.d.ts +2 -1
  98. package/dist/hooks/useScrollOverflow.d.ts.map +1 -1
  99. package/dist/hooks/useScrollOverflow.js +56 -10
  100. package/dist/i18n/generated-locales/af-ZA.generated.d.ts.map +1 -1
  101. package/dist/i18n/generated-locales/af-ZA.generated.js +0 -5
  102. package/dist/i18n/generated-locales/ar-SA.generated.d.ts.map +1 -1
  103. package/dist/i18n/generated-locales/ar-SA.generated.js +0 -5
  104. package/dist/i18n/generated-locales/ca-ES.generated.d.ts.map +1 -1
  105. package/dist/i18n/generated-locales/ca-ES.generated.js +0 -5
  106. package/dist/i18n/generated-locales/cs-CZ.generated.d.ts.map +1 -1
  107. package/dist/i18n/generated-locales/cs-CZ.generated.js +0 -5
  108. package/dist/i18n/generated-locales/da-DK.generated.d.ts.map +1 -1
  109. package/dist/i18n/generated-locales/da-DK.generated.js +0 -5
  110. package/dist/i18n/generated-locales/de-DE.generated.d.ts.map +1 -1
  111. package/dist/i18n/generated-locales/de-DE.generated.js +0 -5
  112. package/dist/i18n/generated-locales/el-GR.generated.d.ts.map +1 -1
  113. package/dist/i18n/generated-locales/el-GR.generated.js +0 -5
  114. package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
  115. package/dist/i18n/generated-locales/en.generated.js +3 -5
  116. package/dist/i18n/generated-locales/es-ES.generated.d.ts.map +1 -1
  117. package/dist/i18n/generated-locales/es-ES.generated.js +0 -5
  118. package/dist/i18n/generated-locales/fi-FI.generated.d.ts.map +1 -1
  119. package/dist/i18n/generated-locales/fi-FI.generated.js +0 -5
  120. package/dist/i18n/generated-locales/fr-FR.generated.d.ts.map +1 -1
  121. package/dist/i18n/generated-locales/fr-FR.generated.js +0 -5
  122. package/dist/i18n/generated-locales/he-IL.generated.d.ts.map +1 -1
  123. package/dist/i18n/generated-locales/he-IL.generated.js +0 -5
  124. package/dist/i18n/generated-locales/hu-HU.generated.d.ts.map +1 -1
  125. package/dist/i18n/generated-locales/hu-HU.generated.js +0 -5
  126. package/dist/i18n/generated-locales/it-IT.generated.d.ts.map +1 -1
  127. package/dist/i18n/generated-locales/it-IT.generated.js +0 -5
  128. package/dist/i18n/generated-locales/ja-JP.generated.d.ts.map +1 -1
  129. package/dist/i18n/generated-locales/ja-JP.generated.js +0 -5
  130. package/dist/i18n/generated-locales/ko-KR.generated.d.ts.map +1 -1
  131. package/dist/i18n/generated-locales/ko-KR.generated.js +0 -5
  132. package/dist/i18n/generated-locales/nl-NL.generated.d.ts.map +1 -1
  133. package/dist/i18n/generated-locales/nl-NL.generated.js +0 -5
  134. package/dist/i18n/generated-locales/no-NO.generated.d.ts.map +1 -1
  135. package/dist/i18n/generated-locales/no-NO.generated.js +0 -5
  136. package/dist/i18n/generated-locales/pl-PL.generated.d.ts.map +1 -1
  137. package/dist/i18n/generated-locales/pl-PL.generated.js +0 -5
  138. package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
  139. package/dist/i18n/generated-locales/pseudo.generated.js +3 -5
  140. package/dist/i18n/generated-locales/pt-BR.generated.d.ts.map +1 -1
  141. package/dist/i18n/generated-locales/pt-BR.generated.js +0 -5
  142. package/dist/i18n/generated-locales/pt-PT.generated.d.ts.map +1 -1
  143. package/dist/i18n/generated-locales/pt-PT.generated.js +0 -5
  144. package/dist/i18n/generated-locales/ro-RO.generated.d.ts.map +1 -1
  145. package/dist/i18n/generated-locales/ro-RO.generated.js +0 -5
  146. package/dist/i18n/generated-locales/ru-RU.generated.d.ts.map +1 -1
  147. package/dist/i18n/generated-locales/ru-RU.generated.js +0 -5
  148. package/dist/i18n/generated-locales/sr-SP.generated.d.ts.map +1 -1
  149. package/dist/i18n/generated-locales/sr-SP.generated.js +0 -5
  150. package/dist/i18n/generated-locales/sv-SE.generated.d.ts.map +1 -1
  151. package/dist/i18n/generated-locales/sv-SE.generated.js +0 -5
  152. package/dist/i18n/generated-locales/tr-TR.generated.d.ts.map +1 -1
  153. package/dist/i18n/generated-locales/tr-TR.generated.js +0 -5
  154. package/dist/i18n/generated-locales/uk-UA.generated.d.ts.map +1 -1
  155. package/dist/i18n/generated-locales/uk-UA.generated.js +0 -5
  156. package/dist/i18n/generated-locales/vi-VN.generated.d.ts.map +1 -1
  157. package/dist/i18n/generated-locales/vi-VN.generated.js +0 -5
  158. package/dist/i18n/generated-locales/zh-CN.generated.d.ts.map +1 -1
  159. package/dist/i18n/generated-locales/zh-CN.generated.js +0 -5
  160. package/dist/i18n/generated-locales/zh-TW.generated.d.ts.map +1 -1
  161. package/dist/i18n/generated-locales/zh-TW.generated.js +0 -5
  162. package/dist/motion/animator.d.ts +76 -7
  163. package/dist/motion/animator.d.ts.map +1 -1
  164. package/dist/motion/animator.js +589 -99
  165. package/dist/motion/coast.d.ts +4 -1
  166. package/dist/motion/coast.d.ts.map +1 -1
  167. package/dist/motion/coast.js +4 -2
  168. package/dist/motion/reducedMotion.d.ts.map +1 -1
  169. package/dist/motion/reducedMotion.js +6 -2
  170. package/dist/motion/reducedMotionPlan.d.ts +7 -0
  171. package/dist/motion/reducedMotionPlan.d.ts.map +1 -1
  172. package/dist/motion/reducedMotionPlan.js +14 -1
  173. package/dist/motion/resolveMotion.d.ts +42 -0
  174. package/dist/motion/resolveMotion.d.ts.map +1 -0
  175. package/dist/motion/resolveMotion.js +43 -0
  176. package/dist/motion/roleValue.d.ts +2 -1
  177. package/dist/motion/roleValue.d.ts.map +1 -1
  178. package/dist/motion/roleValue.js +2 -1
  179. package/dist/motion/uikit/timing.d.ts +7 -1
  180. package/dist/motion/uikit/timing.d.ts.map +1 -1
  181. package/dist/motion/uikit/timing.js +19 -1
  182. package/dist/theme/defineTheme.d.ts +19 -5
  183. package/dist/theme/defineTheme.d.ts.map +1 -1
  184. package/dist/theme/defineTheme.js +63 -3
  185. package/dist/theme/index.d.ts +1 -0
  186. package/dist/theme/index.d.ts.map +1 -1
  187. package/dist/theme/motionKnobs.d.ts +56 -0
  188. package/dist/theme/motionKnobs.d.ts.map +1 -0
  189. package/dist/theme/motionKnobs.js +48 -0
  190. package/dist/theme/resolveThemeValues.d.ts +11 -4
  191. package/dist/theme/resolveThemeValues.d.ts.map +1 -1
  192. package/dist/theme/resolveThemeValues.js +40 -4
  193. package/dist/theme/themeAdaptations.d.ts +7 -3
  194. package/dist/theme/themeAdaptations.d.ts.map +1 -1
  195. package/dist/theme/themeAdaptations.js +36 -7
  196. package/dist/theme/themeMotion.d.ts +96 -0
  197. package/dist/theme/themeMotion.d.ts.map +1 -0
  198. package/dist/theme/themeMotion.js +177 -0
  199. package/dist/theme/tokenReferences.d.ts +31 -0
  200. package/dist/theme/tokenReferences.d.ts.map +1 -0
  201. package/dist/theme/tokenReferences.js +132 -0
  202. package/dist/theme/tokens.d.ts +1 -0
  203. package/dist/theme/tokens.d.ts.map +1 -1
  204. package/dist/theme/tokens.js +9 -129
  205. package/dist/theme/tokens.stylex.d.ts +12 -0
  206. package/dist/theme/tokens.stylex.d.ts.map +1 -1
  207. package/dist/theme/tokens.stylex.js +12 -0
  208. package/dist/utils/focusOutline.stylex.d.ts +6 -0
  209. package/dist/utils/focusOutline.stylex.d.ts.map +1 -1
  210. package/dist/utils/focusOutline.stylex.js +7 -0
  211. package/dist/utils/interactionOverlay.stylex.d.ts.map +1 -1
  212. package/dist/utils/interactionOverlay.stylex.js +17 -8
  213. package/dist/utils/pressFeedback.d.ts.map +1 -1
  214. package/dist/utils/pressFeedback.js +20 -1
  215. package/dist/utils/sharedMutationObserver.d.ts +19 -11
  216. package/dist/utils/sharedMutationObserver.d.ts.map +1 -1
  217. package/dist/utils/sharedMutationObserver.js +66 -26
  218. package/dist/utils/touchPresentation.d.ts +2 -2
  219. package/dist/utils/touchPresentation.d.ts.map +1 -1
  220. package/dist/utils/touchPresentation.js +8 -5
  221. package/dist/utils/touchQueries.d.ts +13 -0
  222. package/dist/utils/touchQueries.d.ts.map +1 -0
  223. package/dist/utils/touchQueries.js +15 -0
  224. package/dist/utils/useFocusAcrossSwap.d.ts +19 -0
  225. package/dist/utils/useFocusAcrossSwap.d.ts.map +1 -0
  226. package/dist/utils/useFocusAcrossSwap.js +41 -0
  227. package/locales/af-ZA.json +0 -21
  228. package/locales/ar-SA.json +0 -21
  229. package/locales/ca-ES.json +0 -21
  230. package/locales/cs-CZ.json +0 -21
  231. package/locales/da-DK.json +0 -21
  232. package/locales/de-DE.json +0 -21
  233. package/locales/el-GR.json +0 -21
  234. package/locales/en.json +12 -20
  235. package/locales/es-ES.json +0 -21
  236. package/locales/fi-FI.json +0 -21
  237. package/locales/fr-FR.json +0 -21
  238. package/locales/he-IL.json +0 -21
  239. package/locales/hu-HU.json +0 -21
  240. package/locales/it-IT.json +0 -21
  241. package/locales/ja-JP.json +0 -21
  242. package/locales/ko-KR.json +0 -21
  243. package/locales/nl-NL.json +0 -21
  244. package/locales/no-NO.json +0 -21
  245. package/locales/pl-PL.json +0 -21
  246. package/locales/pseudo.json +8 -14
  247. package/locales/pt-BR.json +0 -21
  248. package/locales/pt-PT.json +0 -21
  249. package/locales/ro-RO.json +0 -21
  250. package/locales/ru-RU.json +0 -21
  251. package/locales/sr-SP.json +0 -21
  252. package/locales/sv-SE.json +0 -21
  253. package/locales/tr-TR.json +0 -21
  254. package/locales/uk-UA.json +0 -21
  255. package/locales/vi-VN.json +0 -21
  256. package/locales/zh-CN.json +0 -21
  257. package/locales/zh-TW.json +0 -21
  258. package/package.json +4 -4
  259. package/src/AppShell/AppShell.doc.mjs +1 -1
  260. package/src/AppShell/AppShell.spec.md +9 -12
  261. package/src/AppShell/AppShell.test.tsx +164 -2
  262. package/src/AppShell/AppShell.tsx +225 -5
  263. package/src/AppShell/__tests__/AppShellMainKeyboard.a11y.browser.spec.ts +534 -0
  264. package/src/AppShell/observeMainOverflow.test.ts +173 -0
  265. package/src/AppShell/observeMainOverflow.ts +143 -0
  266. package/src/Carousel/Carousel.doc.mjs +1 -1
  267. package/src/Carousel/Carousel.spec.md +9 -9
  268. package/src/Carousel/Carousel.test.tsx +124 -3
  269. package/src/Carousel/Carousel.tsx +10 -2
  270. package/src/Carousel/__tests__/Carousel.a11y.known-failures.ts +1 -16
  271. package/src/Chat/ChatComposer.spec.md +75 -59
  272. package/src/Chat/ChatComposerTokenElement.spec.md +45 -33
  273. package/src/Chat/ChatDictationButton.spec.md +126 -81
  274. package/src/Chat/ChatLayout.spec.md +41 -36
  275. package/src/Chat/ChatLayoutScrollButton.spec.md +87 -103
  276. package/src/Chat/ChatSendButton.spec.md +78 -67
  277. package/src/CodeBlock/__tests__/CodeBlockCopyClearance.a11y.chromium.spec.ts +38 -3
  278. package/src/ComplexSelector/ComplexSelector.test.tsx +111 -0
  279. package/src/ComplexSelector/ComplexSelector.tsx +41 -4
  280. package/src/ContextMenu/ContextMenu.spec.md +84 -56
  281. package/src/ContextMenu/ContextMenuItem.spec.md +132 -0
  282. package/src/DateInput/DateInputTouch.test.tsx +44 -0
  283. package/src/DateInput/Wheel.tsx +9 -6
  284. package/src/DateInput/usePointerDragScroll.ts +34 -10
  285. package/src/DateInput/useScrollSettle.ts +38 -7
  286. package/src/DropdownMenu/DropdownMenu.spec.md +198 -218
  287. package/src/DropdownMenu/DropdownMenu.test.tsx +117 -0
  288. package/src/DropdownMenu/DropdownMenu.tsx +33 -18
  289. package/src/DropdownMenu/DropdownMenuCheckboxItem.spec.md +192 -0
  290. package/src/DropdownMenu/DropdownMenuDivider.spec.md +25 -31
  291. package/src/DropdownMenu/DropdownMenuGroup.spec.md +145 -0
  292. package/src/DropdownMenu/DropdownMenuItem.spec.md +48 -42
  293. package/src/DropdownMenu/DropdownMenuRadioGroup.spec.md +34 -37
  294. package/src/DropdownMenu/DropdownMenuRadioItem.spec.md +54 -53
  295. package/src/DropdownMenu/DropdownMenuSubMenu.spec.md +47 -41
  296. package/src/EmptyState/EmptyState.spec.md +35 -29
  297. package/src/Item/Item.test.tsx +60 -0
  298. package/src/Item/Item.tsx +14 -7
  299. package/src/Layer/useLayer.test.tsx +78 -3
  300. package/src/Layer/useLayer.tsx +27 -6
  301. package/src/Link/Link.spec.md +3 -2
  302. package/src/Link/Link.tsx +11 -0
  303. package/src/Link/__tests__/Link.truncation.a11y.chromium.spec.ts +58 -0
  304. package/src/Markdown/plugins/headingLinks.a11y.chromium.spec.ts +1 -1
  305. package/src/NavMenu/NavHeadingMenuItem.tsx +5 -39
  306. package/src/NumberInput/NumberInput.test.tsx +68 -7
  307. package/src/NumberInput/NumberInput.tsx +31 -1
  308. package/src/Outline/Outline.spec.md +165 -69
  309. package/src/Outline/Outline.test.tsx +67 -2
  310. package/src/Outline/Outline.tsx +23 -0
  311. package/src/Outline/modules/parseOutlineFromMarkdown.spec.md +3 -4
  312. package/src/OverflowList/OverflowList.spec.md +102 -55
  313. package/src/Pagination/Pagination.spec.md +158 -84
  314. package/src/Popover/Popover.test.tsx +84 -0
  315. package/src/Popover/Popover.tsx +34 -14
  316. package/src/Popover/__tests__/PopoverSecondDocument.a11y.chromium.spec.ts +70 -8
  317. package/src/Popover/usePopover.tsx +10 -3
  318. package/src/PowerSearch/PowerSearch.test.tsx +24 -0
  319. package/src/PowerSearch/PowerSearch.tsx +42 -31
  320. package/src/RadioList/RadioList.spec.md +1 -1
  321. package/src/RadioList/RadioList.test.tsx +84 -0
  322. package/src/RadioList/RadioListItem.tsx +11 -2
  323. package/src/Resizable/Resizable.spec.md +144 -124
  324. package/src/SideNav/SideNav.test.tsx +124 -4
  325. package/src/SideNav/SideNavItem.spec.md +14 -24
  326. package/src/SideNav/SideNavItem.tsx +27 -10
  327. package/src/Skeleton/Skeleton.tsx +3 -1
  328. package/src/Spinner/Spinner.tsx +3 -1
  329. package/src/Stepper/Step.spec.md +36 -42
  330. package/src/Stepper/Step.tsx +33 -6
  331. package/src/Stepper/Stepper.doc.mjs +1 -1
  332. package/src/Stepper/Stepper.test.tsx +69 -7
  333. package/src/Switch/Switch.spec.md +1 -1
  334. package/src/Switch/Switch.test.tsx +66 -1
  335. package/src/Switch/Switch.tsx +11 -3
  336. package/src/Table/Table.spec.md +1 -1
  337. package/src/Table/Table.test.tsx +32 -0
  338. package/src/Table/Table.tsx +43 -11
  339. package/src/Table/__tests__/Table.a11y.states.ts +1 -5
  340. package/src/Table/plugins/sortable/useTableSortable.test.tsx +73 -144
  341. package/src/Table/plugins/sortable/useTableSortable.tsx +44 -73
  342. package/src/Table/plugins/sortable/useTableSortableState.test.tsx +9 -21
  343. package/src/TimeInput/TimeInput.spec.md +13 -13
  344. package/src/Toast/Toast.spec.md +2 -5
  345. package/src/Toast/ToastViewport.test.tsx +79 -0
  346. package/src/Toast/ToastViewport.tsx +21 -3
  347. package/src/ToggleButton/ToggleButton.test.tsx +27 -0
  348. package/src/ToggleButton/ToggleButtonGroup.tsx +20 -1
  349. package/src/Token/Token.doc.mjs +2 -2
  350. package/src/Token/Token.spec.md +41 -51
  351. package/src/Token/Token.test.tsx +67 -0
  352. package/src/Token/Token.tsx +60 -5
  353. package/src/Token/TokenLink.tsx +21 -7
  354. package/src/Tokenizer/Tokenizer.spec.md +13 -1
  355. package/src/Tokenizer/Tokenizer.test.tsx +27 -0
  356. package/src/Tokenizer/Tokenizer.tsx +24 -10
  357. package/src/Tokenizer/TokenizerBottomSheet.test.tsx +8 -0
  358. package/src/Tokenizer/TokenizerClearAllMessageContext.ts +21 -0
  359. package/src/TreeList/TreeList.test.tsx +26 -0
  360. package/src/TreeList/TreeListItem.tsx +26 -4
  361. package/src/Typeahead/BaseTypeahead.doc.mjs +3 -3
  362. package/src/Typeahead/BaseTypeahead.spec.md +45 -45
  363. package/src/Typeahead/BaseTypeahead.tsx +48 -9
  364. package/src/Typeahead/Typeahead.test.tsx +120 -0
  365. package/src/__tests__/internalModulesNotExperimental.test.ts +88 -0
  366. package/src/__tests__/pressState.ts +8 -4
  367. package/src/gestures/GestureArena.ts +76 -11
  368. package/src/gestures/GestureHost.ts +6 -7
  369. package/src/gestures/GestureRecognizer.ts +3 -1
  370. package/src/gestures/PressTracker.ts +386 -0
  371. package/src/gestures/README.md +420 -0
  372. package/src/gestures/__tests__/GestureHost.test.ts +50 -1
  373. package/src/gestures/__tests__/PressTracker.test.ts +275 -0
  374. package/src/gestures/__tests__/arena.test.ts +35 -0
  375. package/src/gestures/__tests__/harness.ts +31 -2
  376. package/src/gestures/__tests__/pressTrackerFactory.test.ts +59 -0
  377. package/src/gestures/__tests__/useGestureRecognizer.test.tsx +570 -0
  378. package/src/gestures/index.ts +79 -0
  379. package/src/gestures/useGestureRecognizer.ts +305 -0
  380. package/src/hooks/scrollKeyboardDelegation.test.ts +33 -0
  381. package/src/hooks/scrollKeyboardDelegation.ts +9 -3
  382. package/src/hooks/useScrollOverflow.doc.mjs +1 -1
  383. package/src/hooks/useScrollOverflow.test.tsx +102 -1
  384. package/src/hooks/useScrollOverflow.ts +59 -10
  385. package/src/i18n/generated-locales/af-ZA.generated.ts +0 -7
  386. package/src/i18n/generated-locales/ar-SA.generated.ts +0 -6
  387. package/src/i18n/generated-locales/ca-ES.generated.ts +0 -7
  388. package/src/i18n/generated-locales/cs-CZ.generated.ts +0 -6
  389. package/src/i18n/generated-locales/da-DK.generated.ts +0 -6
  390. package/src/i18n/generated-locales/de-DE.generated.ts +0 -6
  391. package/src/i18n/generated-locales/el-GR.generated.ts +0 -7
  392. package/src/i18n/generated-locales/en.generated.ts +3 -6
  393. package/src/i18n/generated-locales/es-ES.generated.ts +0 -7
  394. package/src/i18n/generated-locales/fi-FI.generated.ts +0 -6
  395. package/src/i18n/generated-locales/fr-FR.generated.ts +0 -7
  396. package/src/i18n/generated-locales/he-IL.generated.ts +0 -6
  397. package/src/i18n/generated-locales/hu-HU.generated.ts +0 -6
  398. package/src/i18n/generated-locales/it-IT.generated.ts +0 -7
  399. package/src/i18n/generated-locales/ja-JP.generated.ts +0 -6
  400. package/src/i18n/generated-locales/ko-KR.generated.ts +0 -6
  401. package/src/i18n/generated-locales/nl-NL.generated.ts +0 -6
  402. package/src/i18n/generated-locales/no-NO.generated.ts +0 -6
  403. package/src/i18n/generated-locales/pl-PL.generated.ts +0 -7
  404. package/src/i18n/generated-locales/pseudo.generated.ts +3 -6
  405. package/src/i18n/generated-locales/pt-BR.generated.ts +0 -7
  406. package/src/i18n/generated-locales/pt-PT.generated.ts +0 -7
  407. package/src/i18n/generated-locales/ro-RO.generated.ts +0 -6
  408. package/src/i18n/generated-locales/ru-RU.generated.ts +0 -7
  409. package/src/i18n/generated-locales/sr-SP.generated.ts +0 -6
  410. package/src/i18n/generated-locales/sv-SE.generated.ts +0 -6
  411. package/src/i18n/generated-locales/tr-TR.generated.ts +0 -7
  412. package/src/i18n/generated-locales/uk-UA.generated.ts +0 -7
  413. package/src/i18n/generated-locales/vi-VN.generated.ts +0 -6
  414. package/src/i18n/generated-locales/zh-CN.generated.ts +0 -6
  415. package/src/i18n/generated-locales/zh-TW.generated.ts +0 -6
  416. package/src/motion/MEASUREMENTS.md +2 -1
  417. package/src/motion/README.md +102 -32
  418. package/src/motion/__tests__/animator.interaction.browser.spec.ts +843 -0
  419. package/src/motion/__tests__/motionBundle.ts +14 -0
  420. package/src/motion/animator.test.ts +978 -33
  421. package/src/motion/animator.ts +790 -104
  422. package/src/motion/coast.ts +10 -3
  423. package/src/motion/reducedMotion.ts +12 -2
  424. package/src/motion/reducedMotionPlan.test.ts +26 -0
  425. package/src/motion/reducedMotionPlan.ts +20 -1
  426. package/src/motion/resolveMotion.test.ts +123 -0
  427. package/src/motion/resolveMotion.ts +68 -0
  428. package/src/motion/roleValue.ts +2 -1
  429. package/src/motion/roles.test.ts +21 -4
  430. package/src/motion/uikit/tableImports.test.ts +293 -0
  431. package/src/motion/uikit/timing.ts +15 -1
  432. package/src/motion/uikit/values.test.ts +23 -12
  433. package/src/theme/Theme.doc.mjs +1 -1
  434. package/src/theme/defineTheme.ts +116 -7
  435. package/src/theme/expandMotionScale.test.ts +1 -1
  436. package/src/theme/index.ts +5 -0
  437. package/src/theme/motionKnobs.ts +82 -0
  438. package/src/theme/resolveThemeValues.ts +68 -6
  439. package/src/theme/themeAdaptations.ts +52 -12
  440. package/src/theme/themeMotion.test.ts +620 -0
  441. package/src/theme/themeMotion.ts +221 -0
  442. package/src/theme/tokenReferences.ts +149 -0
  443. package/src/theme/tokens.stylex.ts +10 -0
  444. package/src/theme/tokens.ts +15 -158
  445. package/src/utils/focusOutline.stylex.ts +28 -0
  446. package/src/utils/interactionOverlay.stylex.ts +12 -3
  447. package/src/utils/pressFeedback.test.ts +138 -0
  448. package/src/utils/pressFeedback.ts +34 -11
  449. package/src/utils/pressGesture.test.ts +9 -0
  450. package/src/utils/sharedMutationObserver.test.ts +54 -1
  451. package/src/utils/sharedMutationObserver.ts +87 -29
  452. package/src/utils/touchPresentation.ts +8 -5
  453. package/src/utils/touchQueries.ts +15 -0
  454. package/src/utils/useFocusAcrossSwap.ts +55 -0
@@ -177,9 +177,11 @@ export function declaresPressPaint(el: Element): boolean {
177
177
  );
178
178
  }
179
179
 
180
- /** `.2s`, `200ms`, `0.2s` → 200. */
180
+ /** `.2s`, `200ms`, `0.2s` → 200; a scaled clock reads its base, at tempo 1. */
181
181
  export function durationToMs(value: string): number {
182
- const match = value.trim().match(/^([\d.]+)(ms|s)$/);
182
+ // The press release scales its base clock by the theme's tempo, capped under
183
+ // Reduce Motion: `calc(<ms> * …)`, `min(<ms>, …)` (`spec:AST-108` FR4).
184
+ const match = value.trim().match(/^(?:(?:calc|min)\(\s*)?([\d.]+)(ms|s)\b/);
183
185
  if (match == null) {
184
186
  return Number.NaN;
185
187
  }
@@ -203,10 +205,12 @@ export function hasReleaseFade(el: Element): boolean {
203
205
  const onArmAnimates = rulesWithSelector(el, '[data-astryx-press="on"]').some(
204
206
  rule => rule.includes('animation'),
205
207
  );
208
+ // One duration and its Reduce Motion cap: both the machine's clock.
206
209
  return (
207
210
  named &&
208
- durations.length === 1 &&
209
- durations[0] === PRESS_FADE_MS &&
211
+ durations.length >= 1 &&
212
+ durations.length <= 2 &&
213
+ durations.every(duration => duration === PRESS_FADE_MS) &&
210
214
  !onArmAnimates
211
215
  );
212
216
  }
@@ -119,10 +119,15 @@ interface Timer {
119
119
  callback: () => void;
120
120
  }
121
121
 
122
+ /**
123
+ * The arena that decides which recognizer gets a touch.
124
+ */
122
125
  export class GestureArena {
123
126
  readonly environment: GestureEnvironment;
124
127
  private readonly clock: GestureClock;
125
128
  private readonly options: GestureArenaOptions;
129
+ /** The touches whose move the arena is delivering right now. */
130
+ private movingIds: ReadonlySet<number> = new Set();
126
131
  private readonly records = new Map<number, TouchRecord>();
127
132
  /** Recognizers involved in the current interaction, in resolution order. */
128
133
  private active: GestureRecognizer[] = [];
@@ -134,6 +139,10 @@ export class GestureArena {
134
139
  /** The latest time processed: input never moves the clock backwards. */
135
140
  private latestTime = Number.NEGATIVE_INFINITY;
136
141
  private depth = 0;
142
+ /** Open `deferResolution` calls: what their stops unblock waits. */
143
+ private deferDepth = 0;
144
+ /** A deferred stop left recognitions, held touches or resets to settle. */
145
+ private owesResolution = false;
137
146
 
138
147
  constructor(options: GestureArenaOptions = {}) {
139
148
  this.options = options;
@@ -308,8 +317,14 @@ export class GestureArena {
308
317
  return;
309
318
  }
310
319
  const context = this.context();
311
- for (const recognizer of [...this.active]) {
312
- recognizer.deliverMoved(changed, context);
320
+ const previous = this.movingIds;
321
+ this.movingIds = new Set(changed.map(touch => touch.id));
322
+ try {
323
+ for (const recognizer of [...this.active]) {
324
+ recognizer.deliverMoved(changed, context);
325
+ }
326
+ } finally {
327
+ this.movingIds = previous;
313
328
  }
314
329
  for (const touch of changed) {
315
330
  const record = this.records.get(touch.id);
@@ -456,13 +471,43 @@ export class GestureArena {
456
471
  }
457
472
  }
458
473
 
474
+ /**
475
+ * Runs `body`, code outside input that stops recognizers (an Effect that
476
+ * turns one off or detaches it), without resolving what those stops
477
+ * unblock: the recognitions waiting on them, the touches they held from a
478
+ * view, the resets. A pass a microtask later resolves all of it, at the
479
+ * last event's time, so the listeners and consumers it reaches hear it
480
+ * outside the caller's frame and read the recognized state
481
+ * (react-component-runtime INV2).
482
+ */
483
+ deferResolution(body: () => void): void {
484
+ this.deferDepth += 1;
485
+ try {
486
+ body();
487
+ } finally {
488
+ this.deferDepth -= 1;
489
+ }
490
+ if (this.deferDepth === 0 && this.owesResolution) {
491
+ queueMicrotask(() => {
492
+ if (this.owesResolution && this.deferDepth === 0) {
493
+ this.run(this.lastEventTime(), () => {});
494
+ }
495
+ });
496
+ }
497
+ }
498
+
499
+ /** The last event's time, or now before any event. */
500
+ private lastEventTime(): number {
501
+ return Number.isFinite(this.latestTime)
502
+ ? this.latestTime
503
+ : this.clock.now();
504
+ }
505
+
459
506
  /** Cancel an active recognizer, or fail a possible one. */
460
507
  stop(recognizer: GestureRecognizer): void {
461
508
  // A cancel from code between events happens at the last event's time:
462
509
  // wall time would run deadlines ahead of input still queued (FR16).
463
- const time =
464
- this.currentTime ??
465
- (Number.isFinite(this.latestTime) ? this.latestTime : this.clock.now());
510
+ const time = this.currentTime ?? this.lastEventTime();
466
511
  this.run(time, () => {
467
512
  if (isActive(recognizer.state)) {
468
513
  this.apply(recognizer, 'cancelled');
@@ -569,6 +614,11 @@ export class GestureArena {
569
614
  }
570
615
  recognizer.pending = null;
571
616
  this.apply(recognizer, 'failed');
617
+ if (this.deferDepth > 0) {
618
+ // Inside `deferResolution`, the next pass settles.
619
+ this.owesResolution = true;
620
+ return;
621
+ }
572
622
  this.reviewPending();
573
623
  }
574
624
 
@@ -576,12 +626,19 @@ export class GestureArena {
576
626
  * A recognition that claimed its touches and then fails or is cancelled (a
577
627
  * waiting recognition that fails, a gesture a second finger or the app
578
628
  * cancels) gives them back to the browser unless another recognition owns
579
- * them, so a finger still resting there can pinch-zoom the page.
629
+ * them, so a finger still resting there can pinch-zoom the page. A gesture
630
+ * that cancels itself on a finger's move (a long press past its tolerance)
631
+ * keeps that finger until it lifts: the drag goes on, and the page never
632
+ * takes it over midway (`spec:AST-094` FR14), as UIKit's scroll view never
633
+ * takes a touch another recognizer had.
580
634
  */
581
- private releaseClaim(recognizer: GestureRecognizer): void {
635
+ private releaseClaim(
636
+ recognizer: GestureRecognizer,
637
+ keep: ReadonlySet<number> = new Set(),
638
+ ): void {
582
639
  for (const touch of recognizer.trackedTouches) {
583
640
  const record = this.records.get(touch.id);
584
- if (record == null || !record.isClaimed) {
641
+ if (record == null || !record.isClaimed || keep.has(touch.id)) {
585
642
  continue;
586
643
  }
587
644
  // A recognized discrete gesture (`ended`, a swipe) still owns its
@@ -612,7 +669,9 @@ export class GestureArena {
612
669
  if (isTerminal(next)) {
613
670
  this.clearTimer(recognizer);
614
671
  }
615
- if (next === 'cancelled' || next === 'failed') {
672
+ if (next === 'cancelled') {
673
+ this.releaseClaim(recognizer, this.movingIds);
674
+ } else if (next === 'failed') {
616
675
  this.releaseClaim(recognizer);
617
676
  }
618
677
  }
@@ -870,9 +929,15 @@ export class GestureArena {
870
929
  this.currentTime = this.clampTime(time);
871
930
  body();
872
931
  // Re-entrant calls settle with the outermost one: settling mid-delivery
873
- // would reset recognizers that have not heard the event yet.
932
+ // would reset recognizers that have not heard the event yet. Inside
933
+ // `deferResolution`, the next pass settles.
874
934
  if (this.depth === 1) {
875
- this.settle();
935
+ if (this.deferDepth > 0) {
936
+ this.owesResolution = true;
937
+ } else {
938
+ this.owesResolution = false;
939
+ this.settle();
940
+ }
876
941
  }
877
942
  } finally {
878
943
  this.depth -= 1;
@@ -217,10 +217,6 @@ function claimsWhileMoving(recognizer: GestureRecognizer): boolean {
217
217
  return recognizer.acceptsTouchInput && recognizer.kind !== 'tap';
218
218
  }
219
219
 
220
- /**
221
- * Run `task` in the next frame, before it paints: a read there styles what
222
- * the frame must style anyway, and its writes are what the frame shows.
223
- */
224
220
  /**
225
221
  * A CSS-wide keyword, which names no touch-action of its own: the value in
226
222
  * force resolves it (`initial` and `unset` to `auto`, `inherit` to the
@@ -238,6 +234,10 @@ const CSS_WIDE_KEYWORDS: ReadonlySet<string> = new Set([
238
234
  'revert-layer',
239
235
  ]);
240
236
 
237
+ /**
238
+ * Run `task` in the next frame, before it paints: a read there styles what
239
+ * the frame must style anyway, and its writes are what the frame shows.
240
+ */
241
241
  function inNextFrame(view: Window | null, task: () => void): void {
242
242
  if (view != null && typeof view.requestAnimationFrame === 'function') {
243
243
  view.requestAnimationFrame(task);
@@ -328,7 +328,6 @@ export class GestureHost {
328
328
  private readonly touchIds = new Map<number, number>();
329
329
  /** Touch.identifier → the element the finger landed on. */
330
330
  private readonly touchTargets = new Map<number, EventTarget>();
331
- /** Finger targets with listeners of their own, and how many fingers each. */
332
331
  /**
333
332
  * Finger targets with listeners of their own: how many fingers each, and
334
333
  * how many of those a recognizer could claim while they move (only those
@@ -374,20 +373,20 @@ export class GestureHost {
374
373
  private readonly claimedLifts: PlacedContact[] = [];
375
374
  /** Fingers still waiting for their pointerdown, by arena id. */
376
375
  private readonly unpairedTouches = new Map<number, PlacedContact>();
377
- /** The last position fed per contact, so one channel's echo is dropped. */
378
376
  /** The elements each held contact turned selection off on. */
379
377
  private readonly heldSelectionBy = new Map<number, HTMLElement[]>();
380
378
  private readonly isPrimaryPointerCoarse: () => boolean;
381
379
  private readonly coarseQuery: MediaQueryList | null;
382
380
  private isWatchingPointer = false;
383
381
  private readonly onPointerKindChange = (): void => this.refreshAll();
382
+ /** The last position fed per contact, so one channel's echo is dropped. */
384
383
  private readonly lastFed = new Map<number, TouchSample>();
385
384
  /** When a finger was last down or lifted, and where it landed. */
386
385
  private lastTouch: {readonly target: Node; readonly time: number} | null =
387
386
  null;
388
- /** The last scroll a finger drove, and when. */
389
387
  /** Scrollers a recognizer is scrolling itself this frame (ownScroll). */
390
388
  private readonly ownedScrolls = new Set<Node>();
389
+ /** The last scroll a finger drove, and when. */
391
390
  private lastScroll: {readonly scroller: Node; readonly time: number} | null =
392
391
  null;
393
392
  private nextId = 1;
@@ -118,7 +118,9 @@ export function isActive(state: GestureState): boolean {
118
118
  return state === 'began' || state === 'changed';
119
119
  }
120
120
 
121
- /** The browser behaviors `touch-action` can keep or remove. */
121
+ /**
122
+ * The browser behaviors `touch-action` can keep or remove.
123
+ */
122
124
  export interface NativeTouchBehavior {
123
125
  readonly panX: boolean;
124
126
  readonly panY: boolean;
@@ -0,0 +1,386 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file PressTracker.ts
5
+ * @input Touches the arena delivers to a pressable view (TouchConsumer)
6
+ * @output Exports createPressTracker and its PressTracker interface
7
+ * (UIControl's touch tracking, built by a factory per
8
+ * architecture:react-component-runtime INV13), its options, the
9
+ * control event type, and PRESS_PROFILES (a control's and a table cell's
10
+ * tracking and release clock)
11
+ * @position View-level consumer of packages/core/src/gestures: what a
12
+ * UIControl does with the touches no gesture recognizer took
13
+ *
14
+ * UIControl semantics, event for event:
15
+ *
16
+ * - `touchDown` when the finger lands; the highlight comes on in the same
17
+ * frame, unless the control sits in a scroller, where it waits
18
+ * `contentTouchDelay` (UIScrollView.delaysContentTouches) so a flick
19
+ * paints nothing.
20
+ * - `touchDragInside` / `touchDragOutside` on every move, `touchDragExit` /
21
+ * `touchDragEnter` when the finger crosses the control's bounds EXPANDED
22
+ * by `trackingExpansion` (a fingertip dragged a little off a button is
23
+ * still on it). The highlight follows inside / outside.
24
+ * - `touchUpInside` / `touchUpOutside` at the lift. A tap quicker than the
25
+ * scroller delay shows the highlight at the lift for `quickTapFlash`.
26
+ * - `touchCancel` when a recognizer took the touch (`cancelsTouchesInView`)
27
+ * or the browser took it to scroll: the highlight goes at once, with no
28
+ * release, one frame before the content moves.
29
+ *
30
+ * Two profiles (PRESS_PROFILES) cover what UIKit does:
31
+ *
32
+ * - `control` (a button, a switch): as above.
33
+ * - `cell` (a table or collection row): the highlight waits the
34
+ * content-touch delay inside a scroll view and comes on at once outside one
35
+ * (`spec:AST-094` FR11), travel past the pan hysteresis cancels the press
36
+ * for good (the scroll view took the touch), and a quicker tap highlights
37
+ * at the lift straight into the release, with no flash.
38
+ *
39
+ * And UIControl's iOS 6 rule: a single-finger single tap recognizer on an
40
+ * ANCESTOR does not beat the control's own action for a touch on it (the
41
+ * default veto; `vetoesAncestorRecognizer` replaces it, as a slider vetoes a
42
+ * pan along its track).
43
+ *
44
+ * The bounds are read once, when the finger lands; nothing reads layout
45
+ * during the press. Activation stays the browser's click, which the arena
46
+ * swallows for a touch a recognizer took.
47
+ */
48
+
49
+ import {UIKIT_GESTURES} from '../motion/uikit/gestures';
50
+ import {timing} from '../motion/uikit/timing';
51
+ import {travel} from './geometry';
52
+ import type {GestureRecognizer} from './GestureRecognizer';
53
+ import type {TapGestureRecognizer} from './TapGestureRecognizer';
54
+ import type {GestureTouch, TouchConsumer} from './types';
55
+
56
+ export type ControlEvent =
57
+ | 'touchDown'
58
+ | 'touchDragInside'
59
+ | 'touchDragOutside'
60
+ | 'touchDragEnter'
61
+ | 'touchDragExit'
62
+ | 'touchUpInside'
63
+ | 'touchUpOutside'
64
+ | 'touchCancel';
65
+
66
+ export interface PressBounds {
67
+ readonly left: number;
68
+ readonly top: number;
69
+ readonly right: number;
70
+ readonly bottom: number;
71
+ }
72
+
73
+ export interface PressTrackerOptions {
74
+ /** The control's bounds in client px, read when a finger lands. */
75
+ getBounds: () => PressBounds | null;
76
+ /** The view the tracker belongs to; recognizers on it are not ancestors. */
77
+ view?: unknown;
78
+ onControlEvent?: (event: ControlEvent, touch: GestureTouch) => void;
79
+ onHighlightChange?: (isHighlighted: boolean) => void;
80
+ trackingExpansion?: number;
81
+ /**
82
+ * When the highlight waits `contentTouchDelay`: inside a scroller (a
83
+ * control or a cell), always, or never. @default 'inScrollers'
84
+ */
85
+ highlightDelay?: PressHighlightDelay;
86
+ /**
87
+ * Travel (px) past which the press is cancelled for good, with no
88
+ * re-highlight on the way back (a cell whose scroll view took the touch).
89
+ * Unset, the finger is tracked in and out of the expanded bounds.
90
+ */
91
+ cancelTravel?: number;
92
+ /**
93
+ * How long a tap quicker than the delay shows the highlight at the lift,
94
+ * ms; 0 highlights and releases at once. @default the quick-tap flash
95
+ */
96
+ quickTapFlash?: number;
97
+ /** Which ancestor recognizers the control's own action beats. */
98
+ vetoesAncestorRecognizer?: (recognizer: GestureRecognizer) => boolean;
99
+ /** @default () => true */
100
+ isEnabled?: () => boolean;
101
+ /**
102
+ * Whether this finger is braking a scroll it set moving (see
103
+ * GestureHost.isScrollBraking): a native list highlights nothing for one,
104
+ * and the control does not track it at all. Asked only for a finger: a
105
+ * mouse or a pen never brakes (`spec:AST-094` FR11).
106
+ */
107
+ isBraking?: (touch: GestureTouch) => boolean;
108
+ }
109
+
110
+ const PRESS = UIKIT_GESTURES.press;
111
+
112
+ export type PressHighlightDelay = 'inScrollers' | 'always' | 'never';
113
+
114
+ /**
115
+ * How a kind of pressable tracks a finger and how long its release takes.
116
+ */
117
+ export interface PressProfile {
118
+ readonly highlightDelay: PressHighlightDelay;
119
+ readonly cancelTravel?: number;
120
+ readonly quickTapFlash: number;
121
+ /** The release (`fading`) clock a painter uses, ms. */
122
+ readonly releaseMs: number;
123
+ }
124
+
125
+ export const PRESS_PROFILES = {
126
+ /** UIControl: same-frame highlight outside scrollers, 70 pt tracking. */
127
+ control: {
128
+ highlightDelay: 'inScrollers',
129
+ quickTapFlash: PRESS.quickTapFlash.value,
130
+ // The shared press styles release every surface on the deselect clock
131
+ // until a control runs its own release (UIButton's 250 ms), so a
132
+ // painter's `fading` never outlasts the fade it shows.
133
+ releaseMs: timing.press.highlightOutMs,
134
+ },
135
+ /**
136
+ * A table or collection cell: inside a scroll view it highlights after the
137
+ * content-touch delay, outside one at once (AST-094 FR11: the delay applies
138
+ * only inside scroll views); cancelled by the scroll.
139
+ */
140
+ cell: {
141
+ highlightDelay: 'inScrollers',
142
+ cancelTravel: UIKIT_GESTURES.pan.hysteresis.value,
143
+ quickTapFlash: 0,
144
+ releaseMs: timing.press.highlightOutMs,
145
+ },
146
+ } as const satisfies Record<string, PressProfile>;
147
+
148
+ export type PressProfileName = keyof typeof PRESS_PROFILES;
149
+
150
+ /**
151
+ * UIButton's rule, the tracker's default ancestor veto: an ancestor's
152
+ * single-finger single tap. A tap is told apart by its `kind`
153
+ * (`architecture:react-component-runtime` INV13).
154
+ */
155
+ export function vetoesSingleTap(recognizer: GestureRecognizer): boolean {
156
+ if (recognizer.kind !== 'tap') {
157
+ return false;
158
+ }
159
+ const tap = recognizer as TapGestureRecognizer;
160
+ return tap.numberOfTapsRequired === 1 && tap.numberOfTouchesRequired === 1;
161
+ }
162
+
163
+ /**
164
+ * A control's touch tracking, the gesture host's consumer for one element
165
+ * (UIControl's `beginTracking` / `continueTracking` / `endTracking`): it
166
+ * reports control events and the highlight. Built by
167
+ * {@link createPressTracker}.
168
+ */
169
+ export interface PressTracker extends TouchConsumer {
170
+ /** Whether the control paints its pressed highlight now. */
171
+ readonly isHighlighted: boolean;
172
+ /** Whether a touch is being tracked. */
173
+ readonly isTracking: boolean;
174
+ /** Whether the tracked touch is inside the bounds plus the expansion. */
175
+ readonly isTouchInside: boolean;
176
+ /**
177
+ * How far past its bounds a tracked touch still counts as inside, px; its
178
+ * hook keeps it in step with the option.
179
+ */
180
+ trackingExpansion: number;
181
+ /**
182
+ * Whether the control takes touches now: a disabled one gives the host no
183
+ * reason to listen (`spec:AST-094` FR24).
184
+ */
185
+ isEnabled(): boolean;
186
+ allowsAncestorRecognizer(recognizer: unknown): boolean;
187
+ /** Drop any highlight and timers (the control unmounted or was disabled). */
188
+ dispose(): void;
189
+ }
190
+
191
+ /** Track a control's touches (see {@link PressTracker}). */
192
+ export function createPressTracker(options: PressTrackerOptions): PressTracker {
193
+ let touchId: number | null = null;
194
+ let bounds: PressBounds | null = null;
195
+ let highlightTimer: ReturnType<typeof setTimeout> | null = null;
196
+ let flashTimer: ReturnType<typeof setTimeout> | null = null;
197
+ /** A pending highlight whose finger travelled: it will never paint. */
198
+ let isPendingDead = false;
199
+
200
+ const state = {
201
+ isHighlighted: false,
202
+ isTracking: false,
203
+ isTouchInside: false,
204
+ };
205
+ const contains = (touch: GestureTouch): boolean => {
206
+ if (bounds == null) {
207
+ return true;
208
+ }
209
+ const margin = tracker.trackingExpansion;
210
+ return (
211
+ touch.x >= bounds.left - margin &&
212
+ touch.x <= bounds.right + margin &&
213
+ touch.y >= bounds.top - margin &&
214
+ touch.y <= bounds.bottom + margin
215
+ );
216
+ };
217
+
218
+ const emit = (event: ControlEvent, touch: GestureTouch): void => {
219
+ options.onControlEvent?.(event, touch);
220
+ };
221
+
222
+ const setHighlighted = (value: boolean): void => {
223
+ if (state.isHighlighted === value) {
224
+ return;
225
+ }
226
+ state.isHighlighted = value;
227
+ options.onHighlightChange?.(value);
228
+ };
229
+
230
+ const clearHighlightTimer = (): void => {
231
+ if (highlightTimer != null) {
232
+ clearTimeout(highlightTimer);
233
+ highlightTimer = null;
234
+ }
235
+ };
236
+
237
+ const clearFlash = (): void => {
238
+ if (flashTimer != null) {
239
+ clearTimeout(flashTimer);
240
+ flashTimer = null;
241
+ }
242
+ };
243
+
244
+ const finish = (): void => {
245
+ touchId = null;
246
+ state.isTracking = false;
247
+ state.isTouchInside = false;
248
+ bounds = null;
249
+ };
250
+
251
+ const touchCancelled = (touch: GestureTouch): void => {
252
+ if (touch.id !== touchId) {
253
+ return;
254
+ }
255
+ clearHighlightTimer();
256
+ emit('touchCancel', touch);
257
+ setHighlighted(false);
258
+ finish();
259
+ };
260
+
261
+ const tracker: PressTracker = {
262
+ get isHighlighted() {
263
+ return state.isHighlighted;
264
+ },
265
+ get isTracking() {
266
+ return state.isTracking;
267
+ },
268
+ get isTouchInside() {
269
+ return state.isTouchInside;
270
+ },
271
+ trackingExpansion:
272
+ options.trackingExpansion ??
273
+ UIKIT_GESTURES.control.trackingExpansion.value,
274
+
275
+ isEnabled(): boolean {
276
+ return options.isEnabled?.() !== false;
277
+ },
278
+
279
+ touchBegan(touch: GestureTouch): void {
280
+ if (
281
+ touchId != null ||
282
+ options.isEnabled?.() === false ||
283
+ // The scroll brake is a finger's (`spec:AST-094` FR11, DEC-21).
284
+ (touch.pointerType === 'touch' && options.isBraking?.(touch) === true)
285
+ ) {
286
+ return;
287
+ }
288
+ clearFlash();
289
+ touchId = touch.id;
290
+ bounds = options.getBounds();
291
+ state.isTracking = true;
292
+ state.isTouchInside = true;
293
+ isPendingDead = false;
294
+ emit('touchDown', touch);
295
+ const delay = options.highlightDelay ?? 'inScrollers';
296
+ const delays =
297
+ touch.pointerType === 'touch' &&
298
+ (delay === 'always' ||
299
+ (delay === 'inScrollers' && touch.scroll?.isInsideScroller === true));
300
+ if (delays) {
301
+ highlightTimer = setTimeout(() => {
302
+ highlightTimer = null;
303
+ if (state.isTouchInside) {
304
+ setHighlighted(true);
305
+ }
306
+ }, PRESS.contentTouchDelay.value);
307
+ } else {
308
+ setHighlighted(true);
309
+ }
310
+ },
311
+
312
+ touchMoved(touch: GestureTouch): void {
313
+ if (touch.id !== touchId) {
314
+ return;
315
+ }
316
+ const cancelTravel = options.cancelTravel;
317
+ if (cancelTravel != null && travel(touch) > cancelTravel) {
318
+ // A cell's scroll view took the touch: the press is over.
319
+ touchCancelled(touch);
320
+ return;
321
+ }
322
+ if (highlightTimer != null && travel(touch) > PRESS.slop.value) {
323
+ // A finger travelling before the delay ran out is scrolling: the
324
+ // press it began never paints, as a flick on a list paints nothing.
325
+ clearTimeout(highlightTimer);
326
+ highlightTimer = null;
327
+ isPendingDead = true;
328
+ }
329
+ const inside = contains(touch);
330
+ if (inside !== state.isTouchInside) {
331
+ state.isTouchInside = inside;
332
+ emit(inside ? 'touchDragEnter' : 'touchDragExit', touch);
333
+ if (highlightTimer == null && !isPendingDead) {
334
+ setHighlighted(inside);
335
+ }
336
+ }
337
+ emit(inside ? 'touchDragInside' : 'touchDragOutside', touch);
338
+ },
339
+
340
+ touchEnded(touch: GestureTouch): void {
341
+ if (touch.id !== touchId) {
342
+ return;
343
+ }
344
+ const inside = contains(touch);
345
+ const wasPending = highlightTimer != null;
346
+ clearHighlightTimer();
347
+ emit(inside ? 'touchUpInside' : 'touchUpOutside', touch);
348
+ const flash = options.quickTapFlash ?? PRESS.quickTapFlash.value;
349
+ if (wasPending && inside) {
350
+ // Quicker than the delay: the highlight shows at the lift, for the
351
+ // flash, or (a cell) straight into the release.
352
+ setHighlighted(true);
353
+ if (flash > 0) {
354
+ flashTimer = setTimeout(() => {
355
+ flashTimer = null;
356
+ setHighlighted(false);
357
+ }, flash);
358
+ } else {
359
+ setHighlighted(false);
360
+ }
361
+ } else {
362
+ setHighlighted(false);
363
+ }
364
+ finish();
365
+ },
366
+
367
+ touchCancelled,
368
+
369
+ allowsAncestorRecognizer(recognizer: unknown): boolean {
370
+ const candidate = recognizer as GestureRecognizer;
371
+ if (candidate.view != null && candidate.view === options.view) {
372
+ return true;
373
+ }
374
+ const vetoes = options.vetoesAncestorRecognizer ?? vetoesSingleTap;
375
+ return !vetoes(candidate);
376
+ },
377
+
378
+ dispose(): void {
379
+ clearHighlightTimer();
380
+ clearFlash();
381
+ setHighlighted(false);
382
+ finish();
383
+ },
384
+ };
385
+ return tracker;
386
+ }