@astryxdesign/core 0.7.8 → 0.7.9-canary.07992bb

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 (403) hide show
  1. package/dist/AppShell/observeMainOverflow.d.ts.map +1 -1
  2. package/dist/AppShell/observeMainOverflow.js +9 -6
  3. package/dist/BottomSheet/BottomSheet.d.ts.map +1 -1
  4. package/dist/BottomSheet/BottomSheet.js +5 -0
  5. package/dist/BottomSheet/BottomSheetPanel.d.ts.map +1 -1
  6. package/dist/BottomSheet/BottomSheetPanel.js +40 -8
  7. package/dist/BottomSheet/useSheetGestures.d.ts.map +1 -1
  8. package/dist/BottomSheet/useSheetGestures.js +61 -21
  9. package/dist/Calendar/Calendar.d.ts +14 -2
  10. package/dist/Calendar/Calendar.d.ts.map +1 -1
  11. package/dist/Calendar/Calendar.js +63 -74
  12. package/dist/Calendar/getInitialFocusDate.d.ts +4 -1
  13. package/dist/Calendar/getInitialFocusDate.d.ts.map +1 -1
  14. package/dist/Calendar/getInitialFocusDate.js +7 -5
  15. package/dist/Calendar/hooks/useCalendarDays.d.ts +19 -2
  16. package/dist/Calendar/hooks/useCalendarDays.d.ts.map +1 -1
  17. package/dist/Calendar/hooks/useCalendarDays.js +57 -64
  18. package/dist/Calendar/hooks/useCalendarNavigation.d.ts +28 -3
  19. package/dist/Calendar/hooks/useCalendarNavigation.d.ts.map +1 -1
  20. package/dist/Calendar/hooks/useCalendarNavigation.js +33 -22
  21. package/dist/Calendar/styles.d.ts +1 -1
  22. package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
  23. package/dist/CheckboxInput/CheckboxInput.js +54 -11
  24. package/dist/ClickableCard/ClickableCard.d.ts +1 -1
  25. package/dist/ClickableCard/ClickableCard.d.ts.map +1 -1
  26. package/dist/ClickableCard/ClickableCard.js +5 -1
  27. package/dist/DateInput/DateInput.d.ts.map +1 -1
  28. package/dist/DateInput/DateInput.js +4 -1
  29. package/dist/DateInput/PickerWheel.d.ts.map +1 -1
  30. package/dist/DateInput/PickerWheel.js +7 -1
  31. package/dist/DateRangeInput/DateRangeInput.d.ts.map +1 -1
  32. package/dist/DateRangeInput/DateRangeInput.js +5 -2
  33. package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
  34. package/dist/DateTimeInput/DateTimeInput.js +4 -1
  35. package/dist/Dialog/Dialog.d.ts +2 -1
  36. package/dist/Dialog/Dialog.d.ts.map +1 -1
  37. package/dist/Dialog/Dialog.js +12 -1
  38. package/dist/Drawer/useDrawerDialogPresence.d.ts +2 -1
  39. package/dist/Drawer/useDrawerDialogPresence.d.ts.map +1 -1
  40. package/dist/Drawer/useDrawerDialogPresence.js +11 -2
  41. package/dist/DropdownMenu/DropdownMenu.d.ts +9 -1
  42. package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
  43. package/dist/DropdownMenu/DropdownMenu.js +9 -4
  44. package/dist/DropdownMenu/DropdownMenuCheckboxItem.d.ts.map +1 -1
  45. package/dist/DropdownMenu/DropdownMenuCheckboxItem.js +3 -2
  46. package/dist/DropdownMenu/DropdownMenuItem.d.ts.map +1 -1
  47. package/dist/DropdownMenu/DropdownMenuItem.js +3 -2
  48. package/dist/DropdownMenu/DropdownMenuRadioItem.d.ts.map +1 -1
  49. package/dist/DropdownMenu/DropdownMenuRadioItem.js +3 -2
  50. package/dist/DropdownMenu/DropdownMenuSubMenu.d.ts.map +1 -1
  51. package/dist/DropdownMenu/DropdownMenuSubMenu.js +3 -2
  52. package/dist/Field/inputDisabledFocus.d.ts +4 -4
  53. package/dist/Field/inputStyles.stylex.d.ts +1 -1
  54. package/dist/FileInput/FileInput.d.ts.map +1 -1
  55. package/dist/FileInput/FileInput.js +16 -2
  56. package/dist/HoverCard/useHoverCard.d.ts +3 -1
  57. package/dist/HoverCard/useHoverCard.d.ts.map +1 -1
  58. package/dist/Icon/Icon.d.ts +1 -1
  59. package/dist/InfoTip/InfoTip.d.ts +1 -0
  60. package/dist/InfoTip/InfoTip.d.ts.map +1 -1
  61. package/dist/InfoTip/InfoTip.js +1 -0
  62. package/dist/InputGroup/InputGroup.d.ts +4 -3
  63. package/dist/InputGroup/InputGroup.d.ts.map +1 -1
  64. package/dist/InputGroup/InputGroup.js +2 -2
  65. package/dist/InputGroup/groupStyles.d.ts +1 -1
  66. package/dist/InputGroup/groupStyles.d.ts.map +1 -1
  67. package/dist/InputGroup/groupStyles.js +1 -1
  68. package/dist/Item/Item.d.ts +2 -1
  69. package/dist/Item/Item.d.ts.map +1 -1
  70. package/dist/Item/Item.js +29 -6
  71. package/dist/Layer/holdEntranceInput.d.ts +24 -0
  72. package/dist/Layer/holdEntranceInput.d.ts.map +1 -0
  73. package/dist/Layer/holdEntranceInput.js +65 -0
  74. package/dist/Layer/inputHold.d.ts +49 -0
  75. package/dist/Layer/inputHold.d.ts.map +1 -0
  76. package/dist/Layer/inputHold.js +636 -0
  77. package/dist/Layer/preserveAnimations.d.ts +1 -5
  78. package/dist/Layer/preserveAnimations.d.ts.map +1 -1
  79. package/dist/Layer/preserveAnimations.js +12 -214
  80. package/dist/Layer/useLayer.d.ts +3 -1
  81. package/dist/Layer/useLayer.d.ts.map +1 -1
  82. package/dist/Layer/useLayer.js +64 -4
  83. package/dist/Layout/LayoutContent.d.ts +3 -1
  84. package/dist/Layout/LayoutContent.d.ts.map +1 -1
  85. package/dist/Layout/LayoutContent.js +12 -4
  86. package/dist/Layout/LayoutPanel.d.ts +4 -1
  87. package/dist/Layout/LayoutPanel.d.ts.map +1 -1
  88. package/dist/Layout/LayoutPanel.js +13 -4
  89. package/dist/Lightbox/Lightbox.d.ts.map +1 -1
  90. package/dist/Lightbox/Lightbox.js +4 -0
  91. package/dist/MetadataList/MetadataList.js +1 -1
  92. package/dist/MobileNav/MobileNav.d.ts +11 -1
  93. package/dist/MobileNav/MobileNav.d.ts.map +1 -1
  94. package/dist/MobileNav/MobileNav.js +39 -1
  95. package/dist/MoreMenu/MoreMenu.d.ts +5 -3
  96. package/dist/MoreMenu/MoreMenu.d.ts.map +1 -1
  97. package/dist/NumberInput/NumberInput.d.ts +4 -2
  98. package/dist/NumberInput/NumberInput.d.ts.map +1 -1
  99. package/dist/NumberInput/NumberInput.js +244 -11
  100. package/dist/Popover/usePopover.d.ts +1 -0
  101. package/dist/Popover/usePopover.d.ts.map +1 -1
  102. package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
  103. package/dist/PowerSearch/PowerSearch.js +12 -5
  104. package/dist/PowerSearch/PowerSearchBottomSheet.d.ts.map +1 -1
  105. package/dist/PowerSearch/PowerSearchBottomSheet.js +4 -2
  106. package/dist/PowerSearch/PowerSearchToken.d.ts.map +1 -1
  107. package/dist/PowerSearch/PowerSearchToken.js +3 -1
  108. package/dist/PowerSearch/formatFilterValue.d.ts +9 -3
  109. package/dist/PowerSearch/formatFilterValue.d.ts.map +1 -1
  110. package/dist/PowerSearch/formatFilterValue.js +14 -11
  111. package/dist/PowerSearch/formatTokenValue.d.ts +6 -2
  112. package/dist/PowerSearch/formatTokenValue.d.ts.map +1 -1
  113. package/dist/PowerSearch/formatTokenValue.js +6 -3
  114. package/dist/RadioList/RadioListItem.d.ts.map +1 -1
  115. package/dist/RadioList/RadioListItem.js +22 -4
  116. package/dist/SelectableCard/SelectableCard.d.ts +1 -1
  117. package/dist/SelectableCard/SelectableCard.d.ts.map +1 -1
  118. package/dist/SelectableCard/SelectableCard.js +5 -1
  119. package/dist/Spinner/Spinner.d.ts.map +1 -1
  120. package/dist/Spinner/Spinner.js +14 -71
  121. package/dist/Spinner/index.d.ts +1 -1
  122. package/dist/Spinner/index.d.ts.map +1 -1
  123. package/dist/Spinner/spinnerRotor.d.ts +28 -0
  124. package/dist/Spinner/spinnerRotor.d.ts.map +1 -0
  125. package/dist/Spinner/spinnerRotor.js +98 -0
  126. package/dist/Stack/StackItem.d.ts +8 -4
  127. package/dist/Stack/StackItem.d.ts.map +1 -1
  128. package/dist/Stack/StackItem.js +17 -4
  129. package/dist/Switch/Switch.d.ts.map +1 -1
  130. package/dist/Switch/Switch.js +13 -10
  131. package/dist/Table/plugins/sortable/useTableSortable.js +1 -1
  132. package/dist/Timestamp/Timestamp.d.ts.map +1 -1
  133. package/dist/Timestamp/Timestamp.js +14 -8
  134. package/dist/Timestamp/formatInstant.d.ts +10 -1
  135. package/dist/Timestamp/formatInstant.d.ts.map +1 -1
  136. package/dist/Timestamp/formatInstant.js +13 -27
  137. package/dist/Timestamp/tooltipEntries.d.ts +5 -3
  138. package/dist/Timestamp/tooltipEntries.d.ts.map +1 -1
  139. package/dist/Timestamp/tooltipEntries.js +6 -4
  140. package/dist/Token/Token.d.ts.map +1 -1
  141. package/dist/Token/Token.js +9 -0
  142. package/dist/Token/TokenLink.d.ts +1 -1
  143. package/dist/Token/TokenLink.d.ts.map +1 -1
  144. package/dist/Token/TokenLink.js +4 -1
  145. package/dist/Tokenizer/Tokenizer.d.ts +14 -10
  146. package/dist/Tokenizer/Tokenizer.d.ts.map +1 -1
  147. package/dist/Tokenizer/Tokenizer.js +189 -89
  148. package/dist/Tooltip/useTooltip.d.ts +3 -1
  149. package/dist/Tooltip/useTooltip.d.ts.map +1 -1
  150. package/dist/Tooltip/useTooltip.js +162 -59
  151. package/dist/TreeList/TreeListItem.d.ts +2 -1
  152. package/dist/TreeList/TreeListItem.d.ts.map +1 -1
  153. package/dist/TreeList/TreeListItem.js +27 -3
  154. package/dist/astryx.css +45 -18
  155. package/dist/gestures/GestureHost.d.ts +2 -2
  156. package/dist/gestures/GestureHost.d.ts.map +1 -1
  157. package/dist/gestures/GestureHost.js +21 -6
  158. package/dist/gestures/PanGestureRecognizer.d.ts +11 -1
  159. package/dist/gestures/PanGestureRecognizer.d.ts.map +1 -1
  160. package/dist/gestures/PanGestureRecognizer.js +15 -1
  161. package/dist/gestures/ScreenEdgePanGestureRecognizer.d.ts +6 -1
  162. package/dist/gestures/ScreenEdgePanGestureRecognizer.d.ts.map +1 -1
  163. package/dist/gestures/nativeScroll.d.ts +3 -6
  164. package/dist/gestures/nativeScroll.d.ts.map +1 -1
  165. package/dist/gestures/nativeScroll.js +7 -52
  166. package/dist/gestures/wheelSegmenter.d.ts +68 -1
  167. package/dist/gestures/wheelSegmenter.d.ts.map +1 -1
  168. package/dist/gestures/wheelSegmenter.js +199 -10
  169. package/dist/hooks/StackItemScrollRegion.d.ts +31 -0
  170. package/dist/hooks/StackItemScrollRegion.d.ts.map +1 -0
  171. package/dist/hooks/StackItemScrollRegion.js +40 -0
  172. package/dist/hooks/menuPressGesture.d.ts +133 -21
  173. package/dist/hooks/menuPressGesture.d.ts.map +1 -1
  174. package/dist/hooks/menuPressGesture.js +155 -30
  175. package/dist/hooks/menuPressValues.d.ts +16 -0
  176. package/dist/hooks/menuPressValues.d.ts.map +1 -0
  177. package/dist/hooks/menuPressValues.js +18 -0
  178. package/dist/hooks/useClickableContainer.d.ts +27 -5
  179. package/dist/hooks/useClickableContainer.d.ts.map +1 -1
  180. package/dist/hooks/useClickableContainer.js +41 -5
  181. package/dist/hooks/useFocusTrap.d.ts +10 -0
  182. package/dist/hooks/useFocusTrap.d.ts.map +1 -1
  183. package/dist/hooks/useFocusTrap.js +225 -132
  184. package/dist/hooks/useMenuPress.d.ts +34 -1
  185. package/dist/hooks/useMenuPress.d.ts.map +1 -1
  186. package/dist/hooks/useMenuPress.js +93 -5
  187. package/dist/hooks/usePressFeedback.d.ts +6 -6
  188. package/dist/hooks/usePressFeedback.js +6 -6
  189. package/dist/hooks/useScrollRegionProps.d.ts +35 -0
  190. package/dist/hooks/useScrollRegionProps.d.ts.map +1 -0
  191. package/dist/hooks/useScrollRegionProps.js +51 -0
  192. package/dist/i18n/InternationalizationContext.d.ts +6 -0
  193. package/dist/i18n/InternationalizationContext.d.ts.map +1 -1
  194. package/dist/i18n/InternationalizationProvider.d.ts +21 -3
  195. package/dist/i18n/InternationalizationProvider.d.ts.map +1 -1
  196. package/dist/i18n/InternationalizationProvider.js +8 -3
  197. package/dist/i18n/generated-english/hooks/useScrollRegionProps.generated.d.ts +8 -0
  198. package/dist/i18n/generated-english/hooks/useScrollRegionProps.generated.d.ts.map +1 -0
  199. package/dist/i18n/generated-english/hooks/useScrollRegionProps.generated.js +12 -0
  200. package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
  201. package/dist/i18n/generated-locales/en.generated.js +1 -0
  202. package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
  203. package/dist/i18n/generated-locales/pseudo.generated.js +1 -0
  204. package/dist/i18n/index.d.ts +2 -0
  205. package/dist/i18n/index.d.ts.map +1 -1
  206. package/dist/i18n/index.js +1 -0
  207. package/dist/i18n/useCalendarSystem.d.ts +19 -0
  208. package/dist/i18n/useCalendarSystem.d.ts.map +1 -0
  209. package/dist/i18n/useCalendarSystem.js +61 -0
  210. package/dist/internal/spinner-rotor.d.ts +16 -0
  211. package/dist/internal/spinner-rotor.d.ts.map +1 -0
  212. package/dist/internal/spinner-rotor.js +16 -0
  213. package/dist/internal/touch.d.ts +14 -1
  214. package/dist/internal/touch.d.ts.map +1 -1
  215. package/dist/internal/touch.js +20 -2
  216. package/dist/motion/carryAnimations.d.ts +58 -0
  217. package/dist/motion/carryAnimations.d.ts.map +1 -0
  218. package/dist/motion/carryAnimations.js +305 -0
  219. package/dist/motion/transientCopy.d.ts +4 -2
  220. package/dist/motion/transientCopy.d.ts.map +1 -1
  221. package/dist/motion/transientCopy.js +34 -5
  222. package/dist/motion/uikit/gestures.d.ts +41 -0
  223. package/dist/motion/uikit/gestures.d.ts.map +1 -1
  224. package/dist/motion/uikit/gestures.js +25 -0
  225. package/dist/motion/uikit/index.d.ts +1 -1
  226. package/dist/motion/uikit/index.d.ts.map +1 -1
  227. package/dist/motion/uikit/index.js +1 -1
  228. package/dist/motion/uikit/timing.d.ts +14 -10
  229. package/dist/motion/uikit/timing.d.ts.map +1 -1
  230. package/dist/motion/uikit/timing.js +7 -5
  231. package/dist/privateAttributes/menuPressLit.stylex.d.ts +52 -0
  232. package/dist/privateAttributes/menuPressLit.stylex.d.ts.map +1 -0
  233. package/dist/privateAttributes/menuPressLit.stylex.js +99 -0
  234. package/dist/privateAttributes/press.stylex.d.ts +139 -0
  235. package/dist/privateAttributes/press.stylex.d.ts.map +1 -0
  236. package/dist/privateAttributes/press.stylex.js +97 -0
  237. package/dist/theme/themeMotion.d.ts +3 -2
  238. package/dist/theme/themeMotion.d.ts.map +1 -1
  239. package/dist/theme/themeMotion.js +3 -2
  240. package/dist/theme/tokens.stylex.d.ts +2 -2
  241. package/dist/theme/tokens.stylex.js +1 -1
  242. package/dist/utils/calendarSystem.d.ts +114 -0
  243. package/dist/utils/calendarSystem.d.ts.map +1 -0
  244. package/dist/utils/calendarSystem.js +386 -0
  245. package/dist/utils/flatTree.d.ts +6 -3
  246. package/dist/utils/flatTree.d.ts.map +1 -1
  247. package/dist/utils/flatTree.js +13 -3
  248. package/dist/utils/hitArea.d.ts.map +1 -1
  249. package/dist/utils/hitArea.js +82 -5
  250. package/dist/utils/inputStream.d.ts +14 -1
  251. package/dist/utils/inputStream.d.ts.map +1 -1
  252. package/dist/utils/inputStream.js +40 -9
  253. package/dist/utils/interactionOverlay.stylex.d.ts +5 -9
  254. package/dist/utils/interactionOverlay.stylex.d.ts.map +1 -1
  255. package/dist/utils/interactionOverlay.stylex.js +29 -31
  256. package/dist/utils/plainDate.d.ts +23 -7
  257. package/dist/utils/plainDate.d.ts.map +1 -1
  258. package/dist/utils/plainDate.js +57 -18
  259. package/dist/utils/pressFeedback.d.ts +10 -2
  260. package/dist/utils/pressFeedback.d.ts.map +1 -1
  261. package/dist/utils/pressFeedback.js +40 -15
  262. package/dist/utils/pressGesture.d.ts +12 -6
  263. package/dist/utils/pressGesture.d.ts.map +1 -1
  264. package/dist/utils/pressGesture.js +26 -8
  265. package/dist/utils/scrollView.d.ts +25 -0
  266. package/dist/utils/scrollView.d.ts.map +1 -0
  267. package/dist/utils/scrollView.js +108 -0
  268. package/dist/utils/selectionLock.d.ts.map +1 -1
  269. package/dist/utils/selectionLock.js +1 -10
  270. package/dist/utils/touchHitArea.stylex.d.ts +35 -0
  271. package/dist/utils/touchHitArea.stylex.d.ts.map +1 -0
  272. package/dist/utils/touchHitArea.stylex.js +32 -0
  273. package/dist/utils/triggerFocus.d.ts +5 -0
  274. package/dist/utils/triggerFocus.d.ts.map +1 -1
  275. package/dist/utils/triggerFocus.js +9 -2
  276. package/locales/en.json +4 -0
  277. package/locales/pseudo.json +3 -0
  278. package/package.json +10 -4
  279. package/src/AppShell/observeMainOverflow.ts +9 -6
  280. package/src/BottomSheet/BottomSheet.tsx +5 -0
  281. package/src/BottomSheet/BottomSheetPanel.tsx +64 -7
  282. package/src/BottomSheet/useSheetGestures.ts +83 -20
  283. package/src/Calendar/Calendar.doc.mjs +76 -6
  284. package/src/Calendar/Calendar.tsx +123 -104
  285. package/src/Calendar/getInitialFocusDate.ts +22 -8
  286. package/src/Calendar/hooks/useCalendarDays.ts +89 -63
  287. package/src/Calendar/hooks/useCalendarNavigation.ts +68 -26
  288. package/src/CheckboxInput/CheckboxInput.doc.mjs +3 -2
  289. package/src/CheckboxInput/CheckboxInput.tsx +71 -9
  290. package/src/ClickableCard/ClickableCard.tsx +8 -1
  291. package/src/DateInput/DateInput.tsx +2 -0
  292. package/src/DateInput/PickerWheel.tsx +7 -2
  293. package/src/DateRangeInput/DateRangeInput.tsx +3 -1
  294. package/src/DateTimeInput/DateTimeInput.tsx +2 -0
  295. package/src/Dialog/Dialog.doc.mjs +1 -1
  296. package/src/Dialog/Dialog.tsx +12 -1
  297. package/src/Drawer/Drawer.doc.mjs +1 -1
  298. package/src/Drawer/useDrawerDialogPresence.ts +9 -2
  299. package/src/DropdownMenu/DropdownMenu.doc.mjs +1 -2
  300. package/src/DropdownMenu/DropdownMenu.tsx +29 -5
  301. package/src/DropdownMenu/DropdownMenuCheckboxItem.tsx +5 -1
  302. package/src/DropdownMenu/DropdownMenuItem.tsx +8 -4
  303. package/src/DropdownMenu/DropdownMenuRadioItem.tsx +5 -1
  304. package/src/DropdownMenu/DropdownMenuSubMenu.tsx +5 -1
  305. package/src/FileInput/FileInput.tsx +16 -2
  306. package/src/HoverCard/useHoverCard.tsx +3 -1
  307. package/src/InfoTip/InfoTip.doc.mjs +26 -2
  308. package/src/InfoTip/InfoTip.tsx +1 -0
  309. package/src/InputGroup/InputGroup.doc.mjs +4 -3
  310. package/src/InputGroup/InputGroup.tsx +4 -3
  311. package/src/InputGroup/groupStyles.ts +3 -1
  312. package/src/Item/Item.tsx +51 -9
  313. package/src/Layer/holdEntranceInput.ts +84 -0
  314. package/src/Layer/inputHold.ts +734 -0
  315. package/src/Layer/preserveAnimations.ts +12 -275
  316. package/src/Layer/useLayer.tsx +77 -4
  317. package/src/Layout/LayoutContent.doc.mjs +6 -3
  318. package/src/Layout/LayoutContent.tsx +10 -4
  319. package/src/Layout/LayoutPanel.doc.mjs +6 -3
  320. package/src/Layout/LayoutPanel.tsx +11 -4
  321. package/src/Lightbox/Lightbox.tsx +4 -0
  322. package/src/MetadataList/MetadataList.tsx +1 -1
  323. package/src/MobileNav/MobileNav.doc.mjs +3 -3
  324. package/src/MobileNav/MobileNav.tsx +39 -1
  325. package/src/MoreMenu/MoreMenu.doc.mjs +2 -4
  326. package/src/MoreMenu/MoreMenu.tsx +5 -3
  327. package/src/NumberInput/NumberInput.doc.mjs +1 -1
  328. package/src/NumberInput/NumberInput.tsx +259 -11
  329. package/src/Popover/usePopover.tsx +1 -0
  330. package/src/PowerSearch/PowerSearch.doc.mjs +3 -3
  331. package/src/PowerSearch/PowerSearch.tsx +20 -3
  332. package/src/PowerSearch/PowerSearchBottomSheet.tsx +4 -1
  333. package/src/PowerSearch/PowerSearchToken.tsx +3 -0
  334. package/src/PowerSearch/formatFilterValue.ts +21 -11
  335. package/src/PowerSearch/formatTokenValue.ts +7 -1
  336. package/src/RadioList/RadioListItem.doc.mjs +3 -2
  337. package/src/RadioList/RadioListItem.tsx +25 -7
  338. package/src/SelectableCard/SelectableCard.tsx +8 -1
  339. package/src/Spinner/Spinner.tsx +7 -89
  340. package/src/Spinner/index.ts +1 -5
  341. package/src/Spinner/spinnerRotor.ts +113 -0
  342. package/src/Stack/Stack.doc.mjs +1 -1
  343. package/src/Stack/StackItem.tsx +27 -13
  344. package/src/Switch/Switch.tsx +7 -6
  345. package/src/Table/plugins/sortable/useTableSortable.tsx +1 -1
  346. package/src/Timestamp/Timestamp.doc.mjs +3 -3
  347. package/src/Timestamp/Timestamp.tsx +13 -8
  348. package/src/Timestamp/formatInstant.ts +49 -28
  349. package/src/Timestamp/tooltipEntries.ts +7 -3
  350. package/src/Token/Token.tsx +18 -1
  351. package/src/Token/TokenLink.tsx +7 -1
  352. package/src/Tokenizer/Tokenizer.doc.mjs +3 -3
  353. package/src/Tokenizer/Tokenizer.tsx +252 -115
  354. package/src/Tooltip/useTooltip.tsx +178 -80
  355. package/src/TreeList/TreeListItem.tsx +36 -2
  356. package/src/gestures/GestureHost.ts +21 -5
  357. package/src/gestures/PanGestureRecognizer.ts +19 -2
  358. package/src/gestures/README.md +14 -5
  359. package/src/gestures/ScreenEdgePanGestureRecognizer.ts +6 -1
  360. package/src/gestures/nativeScroll.ts +12 -68
  361. package/src/gestures/wheelSegmenter.ts +243 -10
  362. package/src/hooks/StackItemScrollRegion.tsx +57 -0
  363. package/src/hooks/menuPressGesture.ts +244 -38
  364. package/src/hooks/menuPressValues.ts +18 -0
  365. package/src/hooks/useClickableContainer.doc.mjs +8 -2
  366. package/src/hooks/useClickableContainer.ts +72 -6
  367. package/src/hooks/useFocusTrap.ts +268 -151
  368. package/src/hooks/useMenuPress.ts +118 -11
  369. package/src/hooks/usePressFeedback.doc.mjs +3 -3
  370. package/src/hooks/usePressFeedback.ts +6 -6
  371. package/src/hooks/useScrollRegionProps.ts +76 -0
  372. package/src/i18n/InternationalizationContext.ts +6 -0
  373. package/src/i18n/InternationalizationProvider.doc.mjs +29 -1
  374. package/src/i18n/InternationalizationProvider.tsx +33 -3
  375. package/src/i18n/generated-english/hooks/useScrollRegionProps.generated.ts +13 -0
  376. package/src/i18n/generated-locales/en.generated.ts +1 -0
  377. package/src/i18n/generated-locales/pseudo.generated.ts +1 -0
  378. package/src/i18n/index.ts +2 -0
  379. package/src/i18n/useCalendarSystem.ts +95 -0
  380. package/src/internal/spinner-rotor.ts +20 -0
  381. package/src/internal/touch.ts +34 -1
  382. package/src/motion/MEASUREMENTS.md +11 -0
  383. package/src/motion/carryAnimations.ts +389 -0
  384. package/src/motion/transientCopy.ts +45 -5
  385. package/src/motion/uikit/gestures.ts +22 -0
  386. package/src/motion/uikit/index.ts +1 -0
  387. package/src/motion/uikit/timing.ts +7 -5
  388. package/src/privateAttributes/menuPressLit.stylex.ts +104 -0
  389. package/src/privateAttributes/press.stylex.ts +243 -0
  390. package/src/theme/themeMotion.ts +3 -2
  391. package/src/theme/tokens.stylex.ts +1 -1
  392. package/src/utils/calendarSystem.ts +548 -0
  393. package/src/utils/flatTree.ts +15 -3
  394. package/src/utils/hitArea.ts +107 -5
  395. package/src/utils/inputStream.ts +47 -10
  396. package/src/utils/interactionOverlay.stylex.ts +19 -22
  397. package/src/utils/plainDate.ts +84 -19
  398. package/src/utils/pressFeedback.ts +46 -14
  399. package/src/utils/pressGesture.ts +35 -9
  400. package/src/utils/scrollView.ts +135 -0
  401. package/src/utils/selectionLock.ts +5 -10
  402. package/src/utils/touchHitArea.stylex.ts +41 -0
  403. package/src/utils/triggerFocus.ts +17 -4
@@ -5,7 +5,8 @@
5
5
  /**
6
6
  * @file useFocusTrap.ts
7
7
  * @input Uses React useCallback, useEffect, useRef
8
- * @output Exports useFocusTrap, the deprecated Escape-state shim, and an
8
+ * @output Exports useFocusTrap, the internal focus-region Tab containment it
9
+ * composes, the deprecated Escape-state shim, and an
9
10
  * internal compatibility-signal hook
10
11
  * @position Core hook; used by dialogs, modals, date pickers
11
12
  *
@@ -63,6 +64,19 @@ export function useFocusTrapEscapeCompatibilitySignal(isActive: boolean): void {
63
64
  }, [isActive]);
64
65
  }
65
66
 
67
+ /**
68
+ * Whether an element is shown as a popover. jsdom and browsers without the
69
+ * Popover API do not recognize `:popover-open`, and nothing is popover-open
70
+ * there.
71
+ */
72
+ function isPopoverOpen(el: Element): boolean {
73
+ try {
74
+ return el.matches(':popover-open');
75
+ } catch {
76
+ return false;
77
+ }
78
+ }
79
+
66
80
  /**
67
81
  * Whether an element is currently perceivable/focusable — excludes ones hidden
68
82
  * via `display:none`/`visibility:hidden` or inside an `inert`/`hidden` subtree,
@@ -77,6 +91,18 @@ function isVisiblyFocusable(el: HTMLElement): boolean {
77
91
  if (el.hidden || el.closest('[hidden]')) {
78
92
  return false;
79
93
  }
94
+ // A closed <dialog> renders nothing, so nothing inside it can take focus.
95
+ // A dialog shown with showPopover() (a non-modal sheet or drawer) never
96
+ // sets `open`, so it counts as shown while it is popover-open.
97
+ for (
98
+ let dialog = el.closest('dialog');
99
+ dialog != null;
100
+ dialog = dialog.parentElement?.closest('dialog') ?? null
101
+ ) {
102
+ if (!dialog.open && !isPopoverOpen(dialog)) {
103
+ return false;
104
+ }
105
+ }
80
106
  // closest() matches the element itself as well as any ancestor.
81
107
  if (el.closest('[aria-hidden="true"]')) {
82
108
  return false;
@@ -125,6 +151,15 @@ function isHTMLElement(node: Node | null): node is HTMLElement {
125
151
  return view != null && node instanceof view.HTMLElement;
126
152
  }
127
153
 
154
+ /**
155
+ * Whether node `a` comes before node `b` in document order.
156
+ */
157
+ function precedes(a: Node, b: Node): boolean {
158
+ return (
159
+ (a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING) !== 0
160
+ );
161
+ }
162
+
128
163
  /**
129
164
  * Attempt to focus an element. Returns true if focus was successful.
130
165
  */
@@ -137,6 +172,18 @@ function attemptFocus(element: HTMLElement): boolean {
137
172
  return element.ownerDocument.activeElement === element;
138
173
  }
139
174
 
175
+ /**
176
+ * Wrap focus to `target` for a Tab press, and cancel the press only when the
177
+ * target took focus. A target the browser refuses (inert behind a modal
178
+ * layered over this region) leaves the press to the browser instead of
179
+ * stranding focus where it was.
180
+ */
181
+ function wrapFocus(event: KeyboardEvent, target: HTMLElement): void {
182
+ if (attemptFocus(target)) {
183
+ event.preventDefault();
184
+ }
185
+ }
186
+
140
187
  /**
141
188
  * Focus the first focusable descendant of a container.
142
189
  * Returns true if a focusable element was found and focused.
@@ -165,6 +212,223 @@ function focusLastDescendant(container: HTMLElement): boolean {
165
212
  return false;
166
213
  }
167
214
 
215
+ // Containers of the focus regions currently active, in every document. A Tab
216
+ // is answered by the innermost region that holds focus, so regions that nest
217
+ // in the DOM never fight over one key press.
218
+ const activeRegionContainers = new Set<HTMLElement>();
219
+
220
+ function hasInnerRegionHolding(
221
+ container: HTMLElement,
222
+ active: Element,
223
+ ): boolean {
224
+ // An open <dialog> nested in the region that holds focus is its own focus
225
+ // context (a modal step over a covered sheet): it answers Tab, not us.
226
+ const dialog = active.closest('dialog[open]');
227
+ if (dialog != null && dialog !== container && container.contains(dialog)) {
228
+ return true;
229
+ }
230
+ for (const other of activeRegionContainers) {
231
+ if (
232
+ other !== container &&
233
+ container.contains(other) &&
234
+ other.contains(active)
235
+ ) {
236
+ return true;
237
+ }
238
+ }
239
+ return false;
240
+ }
241
+
242
+ /**
243
+ * Tab containment for a focus region: Tab and Shift+Tab pressed inside wrap at
244
+ * either end, and a Tab that starts outside is left to the page. When regions
245
+ * nest, the innermost one holding focus answers.
246
+ *
247
+ * `useFocusTrap` composes this. Dialog, BottomSheet and Lightbox call it
248
+ * directly, because their native lifecycle already owns focus entry and
249
+ * return. Internal: not re-exported from `hooks`.
250
+ */
251
+ export function useFocusRegionContainment(
252
+ containerRef: React.RefObject<HTMLElement | null>,
253
+ isActive: boolean,
254
+ ): void {
255
+ const lastFocusRef = useRef<Element | null>(null);
256
+ // Track if focus change was triggered by keyboard (Tab key)
257
+ const isKeyboardNavigationRef = useRef(false);
258
+
259
+ useEffect(() => {
260
+ const container = containerRef.current;
261
+ if (!isActive || container == null) {
262
+ return;
263
+ }
264
+ activeRegionContainers.add(container);
265
+ return () => {
266
+ activeRegionContainers.delete(container);
267
+ };
268
+ }, [containerRef, isActive]);
269
+
270
+ /**
271
+ * Handle focus events - redirect focus back into container if it escapes.
272
+ * Only redirects for keyboard navigation, not mouse clicks.
273
+ */
274
+ useEffect(() => {
275
+ if (!isActive) {
276
+ return;
277
+ }
278
+
279
+ const doc = trapDocument(containerRef.current);
280
+
281
+ const handleFocus = (event: FocusEvent) => {
282
+ const container = containerRef.current;
283
+ if (!container) {
284
+ return;
285
+ }
286
+
287
+ const target = event.target as Node;
288
+
289
+ if (container.contains(target)) {
290
+ // Focus is inside the container - track it
291
+ lastFocusRef.current = target as Element;
292
+ } else if (isKeyboardNavigationRef.current) {
293
+ // Focus escaped via keyboard - redirect it back
294
+ const focusedFirst = focusFirstDescendant(container);
295
+
296
+ // If we're back at the same element (Shift+Tab from first element),
297
+ // try focusing the last element instead
298
+ if (focusedFirst && lastFocusRef.current === doc.activeElement) {
299
+ focusLastDescendant(container);
300
+ } else if (
301
+ !focusedFirst &&
302
+ isHTMLElement(lastFocusRef.current) &&
303
+ container.contains(lastFocusRef.current)
304
+ ) {
305
+ // A modal surface may intentionally have no tabbable controls and
306
+ // place initial focus on a tabIndex={-1} heading or panel. Preserve
307
+ // that programmatic focus target instead of letting Tab escape.
308
+ attemptFocus(lastFocusRef.current);
309
+ }
310
+
311
+ lastFocusRef.current = doc.activeElement;
312
+ }
313
+ // If focus escaped via mouse click, don't redirect - let light dismiss handle it
314
+
315
+ // Reset keyboard navigation flag
316
+ isKeyboardNavigationRef.current = false;
317
+ };
318
+
319
+ // Use capture phase to intercept focus before it settles
320
+ doc.addEventListener('focus', handleFocus, true);
321
+
322
+ return () => {
323
+ doc.removeEventListener('focus', handleFocus, true);
324
+ };
325
+ }, [containerRef, isActive]);
326
+
327
+ /**
328
+ * Handle Tab key to wrap focus at boundaries. Also tracks that keyboard
329
+ * navigation is occurring.
330
+ *
331
+ * No Escape here, and no IME guard: the shared layer dismissal stack owns
332
+ * that press, and each surface that applies a region decides its own
333
+ * dismissal (`useFocusTrap` through its `onEscape`).
334
+ */
335
+ useEffect(() => {
336
+ if (!isActive) {
337
+ return;
338
+ }
339
+
340
+ const doc = trapDocument(containerRef.current);
341
+
342
+ const handleKeyDown = (event: KeyboardEvent) => {
343
+ const container = containerRef.current;
344
+ if (!container) {
345
+ return;
346
+ }
347
+
348
+ if (event.key === 'Tab') {
349
+ if (event.defaultPrevented) {
350
+ // A control that handles Tab itself (an editor that indents) keeps
351
+ // focus where it is.
352
+ return;
353
+ }
354
+ const active = doc.activeElement;
355
+ // Any focused node counts, not only HTML elements: an SVG control
356
+ // inside the container is still inside.
357
+ if (active == null || !container.contains(active)) {
358
+ // The trap contains focus that is inside it; it does not pull in a
359
+ // Tab pressed elsewhere on the page. A layer can be open while focus
360
+ // legitimately sits outside it — a listbox popup anchored to its own
361
+ // input, a non-modal popover beside the content it annotates — and
362
+ // capturing that Tab would take the rest of the page away from
363
+ // keyboard users.
364
+ return;
365
+ }
366
+
367
+ if (hasInnerRegionHolding(container, active)) {
368
+ // A region nested in this one (a Dialog opened from a Dialog, a
369
+ // Popover inside a Drawer) holds focus; that region answers Tab.
370
+ return;
371
+ }
372
+
373
+ // Mark that keyboard navigation is leaving from inside the trap, so a
374
+ // focus that lands outside is redirected back in.
375
+ isKeyboardNavigationRef.current = true;
376
+
377
+ const focusable = getFocusableElements(container);
378
+ if (focusable.length === 0) {
379
+ // There is nowhere to advance to. Keep focus on the current
380
+ // programmatic target (for example a dialog panel with tabIndex=-1)
381
+ // rather than allowing the browser to move into background content.
382
+ event.preventDefault();
383
+ lastFocusRef.current = active;
384
+ isKeyboardNavigationRef.current = false;
385
+ return;
386
+ }
387
+
388
+ const first = focusable[0];
389
+ const last = focusable[focusable.length - 1];
390
+
391
+ if (doc.activeElement === container) {
392
+ // Programmatic initial focus can sit on the trap container itself
393
+ // (for example a dialog panel with no content controls). Move into
394
+ // the tabbable cycle instead of letting Tab escape to the page.
395
+ wrapFocus(event, event.shiftKey ? last : first);
396
+ return;
397
+ }
398
+
399
+ // Programmatic focus can also sit on an element that is not a Tab stop
400
+ // (a dialog title with tabIndex -1). Its place in document order
401
+ // decides the edge: nothing tabbable before it means Shift+Tab is
402
+ // leaving the region, nothing after it means Tab is.
403
+ const isProgrammaticStop = !(focusable as Element[]).includes(active);
404
+ if (event.shiftKey) {
405
+ // Shift+Tab: if on (or before) the first element, wrap to last
406
+ if (
407
+ active === first ||
408
+ (isProgrammaticStop && precedes(active, first))
409
+ ) {
410
+ wrapFocus(event, last);
411
+ }
412
+ } else {
413
+ // Tab: if on (or after) the last element, wrap to first
414
+ if (
415
+ active === last ||
416
+ (isProgrammaticStop && precedes(last, active))
417
+ ) {
418
+ wrapFocus(event, first);
419
+ }
420
+ }
421
+ }
422
+ };
423
+
424
+ doc.addEventListener('keydown', handleKeyDown);
425
+
426
+ return () => {
427
+ doc.removeEventListener('keydown', handleKeyDown);
428
+ };
429
+ }, [containerRef, isActive]);
430
+ }
431
+
168
432
  /**
169
433
  * Configuration for focus trap behavior
170
434
  */
@@ -255,9 +519,9 @@ export function useFocusTrapInternal<T extends HTMLElement = HTMLElement>(
255
519
  getRestoreTargetRef.current = getRestoreTarget;
256
520
 
257
521
  const containerRef = useRef<T | null>(null);
258
- const lastFocusRef = useRef<Element | null>(null);
259
- // Track if focus change was triggered by keyboard (Tab key)
260
- const isKeyboardNavigationRef = useRef(false);
522
+
523
+ // Tab and Shift+Tab wrap inside the container while the trap is active.
524
+ useFocusRegionContainment(containerRef, isActive);
261
525
 
262
526
  // Join the shared layer dismissal stack. The trap no longer listens for
263
527
  // Escape itself: the stack owns one listener and routes each press to the
@@ -365,153 +629,6 @@ export function useFocusTrapInternal<T extends HTMLElement = HTMLElement>(
365
629
  };
366
630
  }, [isActive]);
367
631
 
368
- /**
369
- * Handle focus events - redirect focus back into container if it escapes.
370
- * Only redirects for keyboard navigation, not mouse clicks.
371
- */
372
- useEffect(() => {
373
- if (!isActive) {
374
- return;
375
- }
376
-
377
- const doc = trapDocument(containerRef.current);
378
-
379
- const handleFocus = (event: FocusEvent) => {
380
- const container = containerRef.current;
381
- if (!container) {
382
- return;
383
- }
384
-
385
- const target = event.target as Node;
386
-
387
- if (container.contains(target)) {
388
- // Focus is inside the container - track it
389
- lastFocusRef.current = target as Element;
390
- } else if (isKeyboardNavigationRef.current) {
391
- // Focus escaped via keyboard - redirect it back
392
- const focusedFirst = focusFirstDescendant(container);
393
-
394
- // If we're back at the same element (Shift+Tab from first element),
395
- // try focusing the last element instead
396
- if (focusedFirst && lastFocusRef.current === doc.activeElement) {
397
- focusLastDescendant(container);
398
- } else if (
399
- !focusedFirst &&
400
- isHTMLElement(lastFocusRef.current) &&
401
- container.contains(lastFocusRef.current)
402
- ) {
403
- // A modal surface may intentionally have no tabbable controls and
404
- // place initial focus on a tabIndex={-1} heading or panel. Preserve
405
- // that programmatic focus target instead of letting Tab escape.
406
- attemptFocus(lastFocusRef.current);
407
- }
408
-
409
- lastFocusRef.current = doc.activeElement;
410
- }
411
- // If focus escaped via mouse click, don't redirect - let light dismiss handle it
412
-
413
- // Reset keyboard navigation flag
414
- isKeyboardNavigationRef.current = false;
415
- };
416
-
417
- // Use capture phase to intercept focus before it settles
418
- doc.addEventListener('focus', handleFocus, true);
419
-
420
- return () => {
421
- doc.removeEventListener('focus', handleFocus, true);
422
- };
423
- }, [isActive]);
424
-
425
- /**
426
- * Handle Tab key to wrap focus at boundaries. Also tracks that keyboard
427
- * navigation is occurring.
428
- *
429
- * No Escape here, and no IME guard: the shared stack owns the press, claims
430
- * a composing Escape so no close request follows, and dismisses the trap
431
- * through `onEscape` above. The trap renders no element of its own, so it
432
- * has no `cancel` to answer either.
433
- */
434
- useEffect(() => {
435
- if (!isActive) {
436
- return;
437
- }
438
-
439
- const doc = trapDocument(containerRef.current);
440
-
441
- const handleKeyDown = (event: KeyboardEvent) => {
442
- const container = containerRef.current;
443
- if (!container) {
444
- return;
445
- }
446
-
447
- if (event.key === 'Tab') {
448
- const active = doc.activeElement;
449
- // Any focused node counts, not only HTML elements: an SVG control
450
- // inside the container is still inside.
451
- if (active == null || !container.contains(active)) {
452
- // The trap contains focus that is inside it; it does not pull in a
453
- // Tab pressed elsewhere on the page. A layer can be open while focus
454
- // legitimately sits outside it — a listbox popup anchored to its own
455
- // input, a non-modal popover beside the content it annotates — and
456
- // capturing that Tab would take the rest of the page away from
457
- // keyboard users.
458
- return;
459
- }
460
-
461
- // Mark that keyboard navigation is leaving from inside the trap, so a
462
- // focus that lands outside is redirected back in.
463
- isKeyboardNavigationRef.current = true;
464
-
465
- const focusable = getFocusableElements(container);
466
- if (focusable.length === 0) {
467
- // There is nowhere to advance to. Keep focus on the current
468
- // programmatic target (for example a dialog panel with tabIndex=-1)
469
- // rather than allowing the browser to move into background content.
470
- event.preventDefault();
471
- lastFocusRef.current = active;
472
- isKeyboardNavigationRef.current = false;
473
- return;
474
- }
475
-
476
- const first = focusable[0];
477
- const last = focusable[focusable.length - 1];
478
-
479
- if (doc.activeElement === container) {
480
- // Programmatic initial focus can sit on the trap container itself
481
- // (for example a dialog panel with no content controls). Move into
482
- // the tabbable cycle instead of letting Tab escape to the page.
483
- event.preventDefault();
484
- if (event.shiftKey) {
485
- last.focus();
486
- } else {
487
- first.focus();
488
- }
489
- return;
490
- }
491
-
492
- if (event.shiftKey) {
493
- // Shift+Tab: if on first element, wrap to last
494
- if (doc.activeElement === first) {
495
- event.preventDefault();
496
- last.focus();
497
- }
498
- } else {
499
- // Tab: if on last element, wrap to first
500
- if (doc.activeElement === last) {
501
- event.preventDefault();
502
- first.focus();
503
- }
504
- }
505
- }
506
- };
507
-
508
- doc.addEventListener('keydown', handleKeyDown);
509
-
510
- return () => {
511
- doc.removeEventListener('keydown', handleKeyDown);
512
- };
513
- }, [isActive, onEscape]);
514
-
515
632
  return {
516
633
  containerRef,
517
634
  focusFirst,
@@ -6,7 +6,8 @@
6
6
  * @file useMenuPress.ts
7
7
  * @input The menu root, its trigger, the enabled-row selector, and callbacks
8
8
  * for opening, highlighting, activating and dismissing
9
- * @output useMenuPress, the marker attributes, and the activation mark
9
+ * @output useMenuPress, the marker attributes, the activation mark, and the
10
+ * internal useDropdownMenuPress entry with its touch model
10
11
  * @position Core hook for DropdownMenu, ContextMenu, DropdownMenuSubMenu,
11
12
  * Selector and MenuBottomSheetActionList. The transition table lives in
12
13
  * menuPressGesture.ts.
@@ -29,10 +30,10 @@ import {
29
30
  import {currentGesture} from '../Layer/gestureCounter';
30
31
  import {
31
32
  IDLE_MENU_PRESS,
32
- menuPressStep,
33
- type MenuPressEffect,
34
- type MenuPressEvent,
35
- type MenuPressGesture,
33
+ menuPressTransition,
34
+ type MenuPressOutcome,
35
+ type MenuPressInput,
36
+ type MenuPressState,
36
37
  type MenuPressPointerType,
37
38
  } from './menuPressGesture';
38
39
  import {MENU_PRESS_MARKER} from './menuPressMarker';
@@ -45,6 +46,12 @@ import {edgeAutoscroll} from '../utils/edgeAutoscroll';
45
46
  import {focusForLastInput} from '../utils/focusReturn';
46
47
  import {useInteractionModalityTrackingFor} from '../utils/interactionModality';
47
48
  import {LONG_PRESS_DURATION_MS} from '../motion/uikit/longPress';
49
+ import {
50
+ clearMenuPressLit,
51
+ holdMenuPressPaint,
52
+ markMenuPressLit,
53
+ releaseMenuPressPaint,
54
+ } from '../privateAttributes/menuPressLit.stylex';
48
55
  import {
49
56
  __resetClickGuardForTest,
50
57
  armClickGuard,
@@ -235,6 +242,44 @@ interface ResolvedPoint {
235
242
  isOnTrigger: boolean;
236
243
  }
237
244
 
245
+ /**
246
+ * DropdownMenu's options for the press model: everything the public hook
247
+ * takes, plus its touch model. DropdownMenu reaches the touch model through
248
+ * its `presentation`, so the public hook has no such option.
249
+ *
250
+ * @internal
251
+ */
252
+ export interface DropdownMenuPressOptions extends UseMenuPressOptions {
253
+ /**
254
+ * How the finger that opened the menu from the trigger picks.
255
+ * `'pointer'`: its opening press follows the settle rule. `'uikit'`: it
256
+ * picks only after UIMenu's handoff distance, so the row that appeared
257
+ * under it never acts on a still lift. A mouse is unaffected.
258
+ * @default 'pointer'
259
+ */
260
+ touchModel?: 'pointer' | 'uikit';
261
+ }
262
+
263
+ /**
264
+ * What core's own menus get from {@link useDropdownMenuPress}: the public
265
+ * return. Not exported from the hooks entry point.
266
+ *
267
+ * @internal
268
+ */
269
+ export type DropdownMenuPressReturn = UseMenuPressReturn;
270
+
271
+ /**
272
+ * Where a pointer is, for a finger's handoff distance. Positions reach the
273
+ * machine only under `touchModel: 'uikit'`. Without them, it keeps the settle
274
+ * rule.
275
+ */
276
+ function handoffPosition(
277
+ event: PointerEvent,
278
+ hasHandoff: boolean,
279
+ ): {x?: number; y?: number} {
280
+ return hasHandoff ? {x: event.clientX, y: event.clientY} : {};
281
+ }
282
+
238
283
  /**
239
284
  * The press model for a menu: the row under the release acts, the highlight
240
285
  * follows a held pointer, and a mouse opens the menu on press.
@@ -271,13 +316,30 @@ interface ResolvedPoint {
271
316
  * ```
272
317
  */
273
318
  export function useMenuPress(options: UseMenuPressOptions): UseMenuPressReturn {
319
+ // The touch model is DropdownMenu's alone; an untyped caller's
320
+ // `touchModel` does not reach the model.
321
+ const {touchModel: _touchModel, ...publicOptions} =
322
+ options as DropdownMenuPressOptions;
323
+ return useDropdownMenuPress({...publicOptions, touchModel: 'pointer'});
324
+ }
325
+
326
+ /**
327
+ * The press model with DropdownMenu's touch model
328
+ * ({@link DropdownMenuPressOptions.touchModel}). Not exported from the hooks
329
+ * entry point.
330
+ *
331
+ * @internal
332
+ */
333
+ export function useDropdownMenuPress(
334
+ options: DropdownMenuPressOptions,
335
+ ): DropdownMenuPressReturn {
274
336
  const optionsRef = useRef(options);
275
337
  optionsRef.current = options;
276
338
  // The highlight, and the hover focus of the rows in this menu, follow the
277
339
  // last input, which this tracks for the menu's own document.
278
340
  useInteractionModalityTrackingFor(options.menuRef);
279
341
 
280
- const gestureRef = useRef<MenuPressGesture<HTMLElement>>(IDLE_MENU_PRESS);
342
+ const gestureRef = useRef<MenuPressState<HTMLElement>>(IDLE_MENU_PRESS);
281
343
  const pointerIdRef = useRef<number | null>(null);
282
344
  const detachRef = useRef<(() => void) | null>(null);
283
345
  // `useLongPress` detects the held finger, as in ContextMenu, so the hold
@@ -374,8 +436,18 @@ export function useMenuPress(options: UseMenuPressOptions): UseMenuPressReturn {
374
436
  autoscrollRef.current = null;
375
437
  }, [autoscroll]);
376
438
 
439
+ const litRowRef = useRef<HTMLElement | null>(null);
440
+ const heldMenuRef = useRef<HTMLElement | null>(null);
377
441
  const endGesture = useCallback(() => {
378
442
  longPressApiRef.current?.cancel();
443
+ if (litRowRef.current != null) {
444
+ clearMenuPressLit(litRowRef.current);
445
+ litRowRef.current = null;
446
+ }
447
+ if (heldMenuRef.current != null) {
448
+ releaseMenuPressPaint(heldMenuRef.current);
449
+ heldMenuRef.current = null;
450
+ }
379
451
  touchMovePreventerRef.current?.();
380
452
  touchMovePreventerRef.current = null;
381
453
  stopAutoscroll();
@@ -388,7 +460,34 @@ export function useMenuPress(options: UseMenuPressOptions): UseMenuPressReturn {
388
460
 
389
461
  const highlight = useCallback(
390
462
  (row: HTMLElement | null) => {
463
+ // A held finger or pen marks the row it lights, for the row's pressed
464
+ // paint. A held mouse keeps the hover tint, as on a desktop.
465
+ const gesture = gestureRef.current;
466
+ const isHeld =
467
+ gesture.phase !== 'idle' && gesture.pointerType !== 'mouse';
468
+ const lit = isHeld ? row : null;
469
+ if (litRowRef.current !== lit) {
470
+ if (litRowRef.current != null) {
471
+ clearMenuPressLit(litRowRef.current);
472
+ }
473
+ litRowRef.current = lit;
474
+ if (lit != null) {
475
+ markMenuPressLit(lit);
476
+ }
477
+ }
391
478
  const {onHighlight, menuRef} = optionsRef.current;
479
+ // The row the press began on stays :active where a pointer hovers, so
480
+ // the menu holds every row but the lit one off that paint.
481
+ const held = isHeld ? menuRef.current : null;
482
+ if (heldMenuRef.current !== held) {
483
+ if (heldMenuRef.current != null) {
484
+ releaseMenuPressPaint(heldMenuRef.current);
485
+ }
486
+ heldMenuRef.current = held;
487
+ if (held != null) {
488
+ holdMenuPressPaint(held);
489
+ }
490
+ }
392
491
  if (onHighlight != null) {
393
492
  onHighlight(row);
394
493
  return;
@@ -449,13 +548,13 @@ export function useMenuPress(options: UseMenuPressOptions): UseMenuPressReturn {
449
548
 
450
549
  // Declared before `step` so the mutual recursion through refs type-checks.
451
550
  const stepRef = useRef<
452
- (event: MenuPressEvent<HTMLElement>, native?: PointerEvent) => void
551
+ (event: MenuPressInput<HTMLElement>, native?: PointerEvent) => void
453
552
  >(() => {});
454
553
 
455
554
  const applyEffect = useCallback(
456
555
  (
457
- effect: MenuPressEffect<HTMLElement>,
458
- gesture: MenuPressGesture<HTMLElement>,
556
+ effect: MenuPressOutcome<HTMLElement>,
557
+ gesture: MenuPressState<HTMLElement>,
459
558
  native: PointerEvent | undefined,
460
559
  ) => {
461
560
  const doc = getDocument();
@@ -511,8 +610,8 @@ export function useMenuPress(options: UseMenuPressOptions): UseMenuPressReturn {
511
610
  );
512
611
 
513
612
  const step = useCallback(
514
- (event: MenuPressEvent<HTMLElement>, native?: PointerEvent) => {
515
- const result = menuPressStep(gestureRef.current, event);
613
+ (event: MenuPressInput<HTMLElement>, native?: PointerEvent) => {
614
+ const result = menuPressTransition(gestureRef.current, event);
516
615
  gestureRef.current = result.gesture;
517
616
  applyEffect(result.effect, result.gesture, native);
518
617
  },
@@ -619,6 +718,10 @@ export function useMenuPress(options: UseMenuPressOptions): UseMenuPressReturn {
619
718
  row: point.row,
620
719
  isInMenu: point.isInMenu,
621
720
  time: Date.now(),
721
+ ...handoffPosition(
722
+ event,
723
+ optionsRef.current.touchModel === 'uikit',
724
+ ),
622
725
  },
623
726
  event,
624
727
  );
@@ -636,6 +739,10 @@ export function useMenuPress(options: UseMenuPressOptions): UseMenuPressReturn {
636
739
  isInMenu: point.isInMenu,
637
740
  isOnTrigger: point.isOnTrigger,
638
741
  time: Date.now(),
742
+ ...handoffPosition(
743
+ event,
744
+ optionsRef.current.touchModel === 'uikit',
745
+ ),
639
746
  },
640
747
  event,
641
748
  );