@astryxdesign/core 0.7.11 → 0.7.12-canary.ccb4a6d

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 (533) hide show
  1. package/dist/AppShell/AppShellMobileContext.d.ts.map +1 -1
  2. package/dist/AppShell/AppShellMobileContext.js +4 -3
  3. package/dist/AppShell/useAppShellMainId.d.ts.map +1 -1
  4. package/dist/AppShell/useAppShellMainId.js +3 -2
  5. package/dist/Avatar/AvatarSizeContext.d.ts.map +1 -1
  6. package/dist/Avatar/AvatarSizeContext.js +2 -2
  7. package/dist/Avatar/AvatarStatusLabelContext.d.ts +2 -2
  8. package/dist/Avatar/AvatarStatusLabelContext.d.ts.map +1 -1
  9. package/dist/Avatar/AvatarStatusLabelContext.js +3 -3
  10. package/dist/AvatarGroup/AvatarGroupContext.d.ts.map +1 -1
  11. package/dist/AvatarGroup/AvatarGroupContext.js +2 -2
  12. package/dist/BottomSheet/BottomSheetHostContext.d.ts.map +1 -1
  13. package/dist/BottomSheet/BottomSheetHostContext.js +3 -2
  14. package/dist/BottomSheet/BottomSheetPanel.d.ts.map +1 -1
  15. package/dist/BottomSheet/BottomSheetPanel.js +48 -4
  16. package/dist/BottomSheet/BottomSheetSwitcherContext.d.ts.map +1 -1
  17. package/dist/BottomSheet/BottomSheetSwitcherContext.js +2 -2
  18. package/dist/BottomSheet/bottomSheetEscape.d.ts.map +1 -1
  19. package/dist/BottomSheet/bottomSheetEscape.js +2 -2
  20. package/dist/BottomSheet/bottomSheetStack.d.ts.map +1 -1
  21. package/dist/BottomSheet/bottomSheetStack.js +2 -13
  22. package/dist/BottomSheet/useSheetGestures.d.ts.map +1 -1
  23. package/dist/BottomSheet/useSheetGestures.js +25 -42
  24. package/dist/Breadcrumbs/Breadcrumbs.d.ts.map +1 -1
  25. package/dist/Breadcrumbs/Breadcrumbs.js +2 -2
  26. package/dist/Button/Button.d.ts.map +1 -1
  27. package/dist/Button/Button.js +12 -21
  28. package/dist/Button/buttonHitArea.d.ts.map +1 -1
  29. package/dist/Button/buttonHitArea.js +3 -3
  30. package/dist/ButtonGroup/ButtonGroup.d.ts.map +1 -1
  31. package/dist/ButtonGroup/ButtonGroup.js +13 -7
  32. package/dist/ButtonGroup/ButtonGroupContext.d.ts.map +1 -1
  33. package/dist/ButtonGroup/ButtonGroupContext.js +2 -2
  34. package/dist/Carousel/Carousel.d.ts.map +1 -1
  35. package/dist/Carousel/Carousel.js +24 -15
  36. package/dist/Chat/ChatContext.d.ts.map +1 -1
  37. package/dist/Chat/ChatContext.js +6 -5
  38. package/dist/Chat/useChatStreamScroll.d.ts.map +1 -1
  39. package/dist/Chat/useChatStreamScroll.js +7 -22
  40. package/dist/CheckboxInput/CheckboxRowPressContext.d.ts.map +1 -1
  41. package/dist/CheckboxInput/CheckboxRowPressContext.js +1 -1
  42. package/dist/CheckboxList/CheckboxListContext.d.ts.map +1 -1
  43. package/dist/CheckboxList/CheckboxListContext.js +1 -1
  44. package/dist/Collapsible/CollapsibleGroupContext.d.ts.map +1 -1
  45. package/dist/Collapsible/CollapsibleGroupContext.js +3 -3
  46. package/dist/CommandPalette/CommandPaletteContext.d.ts.map +1 -1
  47. package/dist/CommandPalette/CommandPaletteContext.js +4 -3
  48. package/dist/CommandPalette/busyStartSettle.d.ts.map +1 -1
  49. package/dist/CommandPalette/busyStartSettle.js +2 -2
  50. package/dist/DateInput/TouchDateField.d.ts.map +1 -1
  51. package/dist/DateInput/TouchDateField.js +41 -4
  52. package/dist/Dialog/DialogContext.d.ts.map +1 -1
  53. package/dist/Dialog/DialogContext.js +3 -2
  54. package/dist/DropdownMenu/DropdownMenuContext.d.ts.map +1 -1
  55. package/dist/DropdownMenu/DropdownMenuContext.js +6 -5
  56. package/dist/DropdownMenu/lazyMenuBottomSheet.d.ts.map +1 -1
  57. package/dist/DropdownMenu/lazyMenuBottomSheet.js +4 -15
  58. package/dist/DropdownMenu/menuRegionStops.d.ts.map +1 -1
  59. package/dist/DropdownMenu/menuRegionStops.js +2 -37
  60. package/dist/FormLayout/FormLayoutContext.d.ts.map +1 -1
  61. package/dist/FormLayout/FormLayoutContext.js +2 -2
  62. package/dist/Heading/Heading.d.ts.map +1 -1
  63. package/dist/Heading/Heading.js +19 -16
  64. package/dist/HoverCard/HoverCard.d.ts +1 -2
  65. package/dist/HoverCard/HoverCard.d.ts.map +1 -1
  66. package/dist/HoverCard/useHoverCard.d.ts +1 -2
  67. package/dist/HoverCard/useHoverCard.d.ts.map +1 -1
  68. package/dist/HoverCard/useHoverCard.js +5 -1
  69. package/dist/Icon/IconDefaultSizeContext.d.ts.map +1 -1
  70. package/dist/Icon/IconDefaultSizeContext.js +2 -2
  71. package/dist/InputGroup/InputGroupContext.d.ts.map +1 -1
  72. package/dist/InputGroup/InputGroupContext.js +2 -2
  73. package/dist/InputGroup/InputGroupInternalContext.d.ts.map +1 -1
  74. package/dist/InputGroup/InputGroupInternalContext.js +2 -2
  75. package/dist/InteractiveRoleContext/InteractiveRoleContext.d.ts.map +1 -1
  76. package/dist/InteractiveRoleContext/InteractiveRoleContext.js +5 -3
  77. package/dist/Item/ItemDescriptionContext.d.ts.map +1 -1
  78. package/dist/Item/ItemDescriptionContext.js +3 -3
  79. package/dist/Item/ItemListRowContext.d.ts.map +1 -1
  80. package/dist/Item/ItemListRowContext.js +3 -3
  81. package/dist/Item/ItemMarkerColumnsContext.d.ts +1 -1
  82. package/dist/Item/ItemMarkerColumnsContext.d.ts.map +1 -1
  83. package/dist/Item/ItemMarkerColumnsContext.js +2 -2
  84. package/dist/Layer/LayerContext.d.ts.map +1 -1
  85. package/dist/Layer/LayerContext.js +3 -2
  86. package/dist/Layer/LayerDepthContext.d.ts.map +1 -1
  87. package/dist/Layer/LayerDepthContext.js +3 -2
  88. package/dist/Layer/LayerTouch.d.ts +3 -2
  89. package/dist/Layer/LayerTouch.d.ts.map +1 -1
  90. package/dist/Layer/LayerTouch.js +3 -2
  91. package/dist/Layer/anchorName.d.ts.map +1 -1
  92. package/dist/Layer/anchorName.js +5 -1
  93. package/dist/Layer/inputHold.d.ts.map +1 -1
  94. package/dist/Layer/inputHold.js +115 -13
  95. package/dist/Layer/layerScopedContext.d.ts +5 -2
  96. package/dist/Layer/layerScopedContext.d.ts.map +1 -1
  97. package/dist/Layer/layerScopedContext.js +27 -10
  98. package/dist/Layer/layerSlideRules.d.ts +28 -26
  99. package/dist/Layer/layerSlideRules.d.ts.map +1 -1
  100. package/dist/Layer/layerSlideRules.js +41 -40
  101. package/dist/Layer/outsidePress.d.ts +21 -3
  102. package/dist/Layer/outsidePress.d.ts.map +1 -1
  103. package/dist/Layer/outsidePress.js +119 -29
  104. package/dist/Layer/settledBox.d.ts +9 -8
  105. package/dist/Layer/settledBox.d.ts.map +1 -1
  106. package/dist/Layer/settledBox.js +169 -49
  107. package/dist/Layer/toastHost.d.ts.map +1 -1
  108. package/dist/Layer/toastHost.js +3 -2
  109. package/dist/Layer/useLayer.d.ts.map +1 -1
  110. package/dist/Layer/useLayer.js +172 -60
  111. package/dist/Layer/useLayerKeyboardClearance.d.ts +14 -2
  112. package/dist/Layer/useLayerKeyboardClearance.d.ts.map +1 -1
  113. package/dist/Layer/useLayerKeyboardClearance.js +83 -12
  114. package/dist/Layer/useTouchTrigger.d.ts +21 -1
  115. package/dist/Layer/useTouchTrigger.d.ts.map +1 -1
  116. package/dist/Layer/useTouchTrigger.js +61 -37
  117. package/dist/Layout/Layout.d.ts +1 -1
  118. package/dist/Layout/Layout.d.ts.map +1 -1
  119. package/dist/Layout/Layout.js +10 -6
  120. package/dist/Layout/LayoutAreaContext.d.ts.map +1 -1
  121. package/dist/Layout/LayoutAreaContext.js +3 -3
  122. package/dist/Layout/LayoutContent.d.ts +6 -6
  123. package/dist/Layout/LayoutContent.js +9 -9
  124. package/dist/Layout/LayoutDividerContext.d.ts.map +1 -1
  125. package/dist/Layout/LayoutDividerContext.js +2 -2
  126. package/dist/Layout/LayoutSlotsContext.d.ts.map +1 -1
  127. package/dist/Layout/LayoutSlotsContext.js +2 -2
  128. package/dist/Link/LinkContext.d.ts +16 -0
  129. package/dist/Link/LinkContext.d.ts.map +1 -1
  130. package/dist/Link/LinkContext.js +3 -3
  131. package/dist/List/List.d.ts +12 -1
  132. package/dist/List/List.d.ts.map +1 -1
  133. package/dist/List/List.js +29 -10
  134. package/dist/List/ListContext.d.ts +18 -3
  135. package/dist/List/ListContext.d.ts.map +1 -1
  136. package/dist/List/ListContext.js +9 -6
  137. package/dist/List/ListItem.d.ts +13 -4
  138. package/dist/List/ListItem.d.ts.map +1 -1
  139. package/dist/List/ListItem.js +37 -10
  140. package/dist/List/listLayoutUpdates.d.ts +34 -0
  141. package/dist/List/listLayoutUpdates.d.ts.map +1 -0
  142. package/dist/List/listLayoutUpdates.js +539 -0
  143. package/dist/Markdown/Markdown.d.ts.map +1 -1
  144. package/dist/Markdown/Markdown.js +57 -10
  145. package/dist/Markdown/blockDirection.d.ts +26 -0
  146. package/dist/Markdown/blockDirection.d.ts.map +1 -0
  147. package/dist/Markdown/blockDirection.js +68 -0
  148. package/dist/Markdown/plugins/HeadingLinksRenderer.d.ts +3 -1
  149. package/dist/Markdown/plugins/HeadingLinksRenderer.d.ts.map +1 -1
  150. package/dist/Markdown/plugins/HeadingLinksRenderer.js +3 -1
  151. package/dist/MetadataList/MetadataListContext.d.ts.map +1 -1
  152. package/dist/MetadataList/MetadataListContext.js +2 -2
  153. package/dist/NavMenu/NavMenuContext.d.ts.map +1 -1
  154. package/dist/NavMenu/NavMenuContext.js +5 -4
  155. package/dist/Popover/Popover.d.ts.map +1 -1
  156. package/dist/Popover/Popover.js +9 -9
  157. package/dist/Popover/usePopover.d.ts.map +1 -1
  158. package/dist/Popover/usePopover.js +11 -8
  159. package/dist/RadioList/RadioList.d.ts.map +1 -1
  160. package/dist/RadioList/RadioList.js +2 -2
  161. package/dist/RadioList/RadioListReasonContext.d.ts.map +1 -1
  162. package/dist/RadioList/RadioListReasonContext.js +1 -1
  163. package/dist/SegmentedControl/SegmentedControlContext.d.ts.map +1 -1
  164. package/dist/SegmentedControl/SegmentedControlContext.js +2 -2
  165. package/dist/SelectableCard/selectableCardInput.d.ts.map +1 -1
  166. package/dist/SelectableCard/selectableCardInput.js +2 -2
  167. package/dist/Selector/SelectorRowLayoutContext.d.ts.map +1 -1
  168. package/dist/Selector/SelectorRowLayoutContext.js +2 -2
  169. package/dist/SideNav/SideNavCollapseButton.d.ts +4 -3
  170. package/dist/SideNav/SideNavCollapseButton.d.ts.map +1 -1
  171. package/dist/SideNav/SideNavCollapseContext.d.ts.map +1 -1
  172. package/dist/SideNav/SideNavCollapseContext.js +4 -3
  173. package/dist/SideNav/SideNavFocusTargetsContext.d.ts.map +1 -1
  174. package/dist/SideNav/SideNavFocusTargetsContext.js +2 -2
  175. package/dist/SideNav/SideNavItem.d.ts.map +1 -1
  176. package/dist/SideNav/SideNavItem.js +3 -2
  177. package/dist/SideNav/SideNavRenderContext.d.ts.map +1 -1
  178. package/dist/SideNav/SideNavRenderContext.js +4 -3
  179. package/dist/SideNav/railMotion.d.ts +40 -0
  180. package/dist/SideNav/railMotion.d.ts.map +1 -1
  181. package/dist/SideNav/railMotion.js +2 -2
  182. package/dist/SizeContext/SizeContext.d.ts.map +1 -1
  183. package/dist/SizeContext/SizeContext.js +2 -2
  184. package/dist/SnapPaging/SnapPaging.d.ts.map +1 -1
  185. package/dist/SnapPaging/SnapPaging.js +162 -36
  186. package/dist/SnapPaging/snapPagingValue.d.ts +29 -3
  187. package/dist/SnapPaging/snapPagingValue.d.ts.map +1 -1
  188. package/dist/SnapPaging/snapPagingValue.js +38 -6
  189. package/dist/Spinner/SpinnerOwnerContext.d.ts.map +1 -1
  190. package/dist/Spinner/SpinnerOwnerContext.js +2 -2
  191. package/dist/Stepper/StepperContext.d.ts.map +1 -1
  192. package/dist/Stepper/StepperContext.js +3 -3
  193. package/dist/Switch/useSwitchTouch.d.ts.map +1 -1
  194. package/dist/Switch/useSwitchTouch.js +8 -3
  195. package/dist/TabList/TabListContext.d.ts.map +1 -1
  196. package/dist/TabList/TabListContext.js +2 -2
  197. package/dist/Table/BaseTable.d.ts +3 -2
  198. package/dist/Table/BaseTable.d.ts.map +1 -1
  199. package/dist/Table/BaseTable.js +73 -16
  200. package/dist/Table/Table.d.ts.map +1 -1
  201. package/dist/Table/Table.js +3 -2
  202. package/dist/Table/TableContext.d.ts.map +1 -1
  203. package/dist/Table/TableContext.js +2 -2
  204. package/dist/Table/index.d.ts +1 -1
  205. package/dist/Table/index.d.ts.map +1 -1
  206. package/dist/Table/plugins/filtering/useTableFiltering.d.ts.map +1 -1
  207. package/dist/Table/plugins/filtering/useTableFiltering.js +4 -3
  208. package/dist/Table/plugins/rowExpansion/useTableRowExpansion.d.ts.map +1 -1
  209. package/dist/Table/plugins/rowExpansion/useTableRowExpansion.js +5 -3
  210. package/dist/Table/plugins/rowIndex/useTableRowIndex.d.ts +16 -18
  211. package/dist/Table/plugins/rowIndex/useTableRowIndex.d.ts.map +1 -1
  212. package/dist/Table/plugins/rowIndex/useTableRowIndex.js +48 -39
  213. package/dist/Table/plugins/selection/useTableSelection.d.ts.map +1 -1
  214. package/dist/Table/plugins/selection/useTableSelection.js +4 -2
  215. package/dist/Table/plugins/stickyColumns/useTableStickyColumns.d.ts.map +1 -1
  216. package/dist/Table/plugins/stickyColumns/useTableStickyColumns.js +1 -0
  217. package/dist/Table/plugins/tree/useTableTreeData.d.ts.map +1 -1
  218. package/dist/Table/plugins/tree/useTableTreeData.js +3 -2
  219. package/dist/Table/tableRowContextUsage.d.ts +21 -0
  220. package/dist/Table/tableRowContextUsage.d.ts.map +1 -0
  221. package/dist/Table/tableRowContextUsage.js +88 -0
  222. package/dist/Table/types.d.ts +58 -5
  223. package/dist/Table/types.d.ts.map +1 -1
  224. package/dist/Table/useBaseTablePlugins.d.ts.map +1 -1
  225. package/dist/Table/useBaseTablePlugins.js +5 -2
  226. package/dist/Text/Text.d.ts.map +1 -1
  227. package/dist/Text/Text.js +18 -14
  228. package/dist/Text/TruncationTooltip.d.ts +45 -0
  229. package/dist/Text/TruncationTooltip.d.ts.map +1 -0
  230. package/dist/Text/TruncationTooltip.js +123 -0
  231. package/dist/Text/textClampContext.d.ts.map +1 -1
  232. package/dist/Text/textClampContext.js +1 -1
  233. package/dist/TimeInput/TimeInput.d.ts.map +1 -1
  234. package/dist/TimeInput/TimeInput.js +4 -0
  235. package/dist/ToggleButton/ToggleButtonGroup.d.ts.map +1 -1
  236. package/dist/ToggleButton/ToggleButtonGroup.js +2 -2
  237. package/dist/Token/TokenNamingContext.d.ts.map +1 -1
  238. package/dist/Token/TokenNamingContext.js +2 -2
  239. package/dist/Tokenizer/TokenizerClearAllMessageContext.d.ts.map +1 -1
  240. package/dist/Tokenizer/TokenizerClearAllMessageContext.js +2 -2
  241. package/dist/Tokenizer/TokenizerItemRemovableContext.d.ts +12 -0
  242. package/dist/Tokenizer/TokenizerItemRemovableContext.d.ts.map +1 -1
  243. package/dist/Tokenizer/TokenizerItemRemovableContext.js +2 -2
  244. package/dist/Toolbar/Toolbar.d.ts.map +1 -1
  245. package/dist/Toolbar/Toolbar.js +12 -6
  246. package/dist/Tooltip/tooltipPresentInterest.d.ts +29 -0
  247. package/dist/Tooltip/tooltipPresentInterest.d.ts.map +1 -0
  248. package/dist/Tooltip/tooltipPresentInterest.js +29 -0
  249. package/dist/Tooltip/useTooltip.d.ts.map +1 -1
  250. package/dist/Tooltip/useTooltip.js +30 -4
  251. package/dist/TopNav/TopNavContext.d.ts.map +1 -1
  252. package/dist/TopNav/TopNavContext.js +2 -2
  253. package/dist/TopNav/TopNavMobileContentContext.d.ts +1 -1
  254. package/dist/TopNav/TopNavMobileContentContext.d.ts.map +1 -1
  255. package/dist/TopNav/TopNavMobileContentContext.js +4 -3
  256. package/dist/TopNav/TopNavRenderContext.d.ts.map +1 -1
  257. package/dist/TopNav/TopNavRenderContext.js +4 -3
  258. package/dist/Typeahead/busyIndicatorLane.d.ts.map +1 -1
  259. package/dist/Typeahead/busyIndicatorLane.js +3 -2
  260. package/dist/Typeahead/committedChoicesKey.d.ts.map +1 -1
  261. package/dist/Typeahead/committedChoicesKey.js +3 -2
  262. package/dist/Typeahead/trailingKeyDown.d.ts.map +1 -1
  263. package/dist/Typeahead/trailingKeyDown.js +3 -2
  264. package/dist/astryx.css +18 -8
  265. package/dist/gestures/GestureArena.d.ts +2 -0
  266. package/dist/gestures/GestureArena.d.ts.map +1 -1
  267. package/dist/gestures/GestureArena.js +8 -1
  268. package/dist/gestures/GestureRecognizer.d.ts +6 -0
  269. package/dist/gestures/GestureRecognizer.d.ts.map +1 -1
  270. package/dist/gestures/GestureRecognizer.js +9 -0
  271. package/dist/gestures/PressTracker.d.ts.map +1 -1
  272. package/dist/gestures/PressTracker.js +9 -4
  273. package/dist/hooks/focusableSelector.d.ts +13 -1
  274. package/dist/hooks/focusableSelector.d.ts.map +1 -1
  275. package/dist/hooks/focusableSelector.js +22 -2
  276. package/dist/hooks/longPressDetector.d.ts.map +1 -1
  277. package/dist/hooks/longPressDetector.js +1 -25
  278. package/dist/hooks/pressGroupContext.d.ts.map +1 -1
  279. package/dist/hooks/pressGroupContext.js +1 -1
  280. package/dist/hooks/useActionGroupTracking.d.ts +18 -1
  281. package/dist/hooks/useActionGroupTracking.d.ts.map +1 -1
  282. package/dist/hooks/useActionGroupTracking.js +13 -2
  283. package/dist/hooks/useAnnounce.d.ts.map +1 -1
  284. package/dist/hooks/useAnnounce.js +3 -2
  285. package/dist/hooks/useFocusTrap.d.ts +11 -0
  286. package/dist/hooks/useFocusTrap.d.ts.map +1 -1
  287. package/dist/hooks/useFocusTrap.js +47 -2
  288. package/dist/hooks/useListFocus.d.ts +7 -0
  289. package/dist/hooks/useListFocus.d.ts.map +1 -1
  290. package/dist/hooks/useListFocus.js +20 -3
  291. package/dist/hooks/usePager.d.ts.map +1 -1
  292. package/dist/hooks/usePager.js +26 -3
  293. package/dist/hooks/useScrollOverflow.d.ts +22 -0
  294. package/dist/hooks/useScrollOverflow.d.ts.map +1 -1
  295. package/dist/hooks/useScrollOverflow.js +67 -11
  296. package/dist/i18n/InternationalizationContext.d.ts +19 -0
  297. package/dist/i18n/InternationalizationContext.d.ts.map +1 -1
  298. package/dist/i18n/InternationalizationContext.js +3 -3
  299. package/dist/i18n/englishFallback.d.ts.map +1 -1
  300. package/dist/i18n/englishFallback.js +5 -1
  301. package/dist/i18n/firstStrongDirection.d.ts +7 -0
  302. package/dist/i18n/firstStrongDirection.d.ts.map +1 -0
  303. package/dist/i18n/firstStrongDirection.js +65 -0
  304. package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
  305. package/dist/i18n/generated-locales/en.generated.js +1 -0
  306. package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
  307. package/dist/i18n/generated-locales/pseudo.generated.js +1 -0
  308. package/dist/internal/scroll-anchoring.d.ts +16 -0
  309. package/dist/internal/scroll-anchoring.d.ts.map +1 -0
  310. package/dist/internal/scroll-anchoring.js +16 -0
  311. package/dist/internal/touch.d.ts +2 -0
  312. package/dist/internal/touch.d.ts.map +1 -1
  313. package/dist/internal/touch.js +4 -1
  314. package/dist/motion/animatedLayout.d.ts +8 -0
  315. package/dist/motion/animatedLayout.d.ts.map +1 -1
  316. package/dist/motion/animatedLayout.js +51 -3
  317. package/dist/motion/animator.d.ts +19 -2
  318. package/dist/motion/animator.d.ts.map +1 -1
  319. package/dist/motion/animator.js +72 -7
  320. package/dist/privateAttributes/itemKey.stylex.d.ts +5 -0
  321. package/dist/privateAttributes/itemKey.stylex.d.ts.map +1 -0
  322. package/dist/privateAttributes/itemKey.stylex.js +25 -0
  323. package/dist/privateAttributes/leaving.stylex.d.ts +5 -0
  324. package/dist/privateAttributes/leaving.stylex.d.ts.map +1 -0
  325. package/dist/privateAttributes/leaving.stylex.js +23 -0
  326. package/dist/privateAttributes/press.stylex.d.ts.map +1 -1
  327. package/dist/privateAttributes/press.stylex.js +13 -3
  328. package/dist/privateAttributes/scrollAnchoring.stylex.d.ts +7 -0
  329. package/dist/privateAttributes/scrollAnchoring.stylex.d.ts.map +1 -0
  330. package/dist/privateAttributes/scrollAnchoring.stylex.js +50 -0
  331. package/dist/privateAttributes/travelling.stylex.d.ts +27 -0
  332. package/dist/privateAttributes/travelling.stylex.d.ts.map +1 -0
  333. package/dist/privateAttributes/travelling.stylex.js +51 -0
  334. package/dist/theme/Theme.d.ts.map +1 -1
  335. package/dist/theme/Theme.js +95 -49
  336. package/dist/theme/syntax/SyntaxTheme.d.ts.map +1 -1
  337. package/dist/theme/syntax/SyntaxTheme.js +3 -2
  338. package/dist/theme/useTheme.d.ts.map +1 -1
  339. package/dist/theme/useTheme.js +3 -2
  340. package/dist/utils/calendarSystem.d.ts.map +1 -1
  341. package/dist/utils/calendarSystem.js +4 -1
  342. package/dist/utils/flatTree.d.ts +13 -0
  343. package/dist/utils/flatTree.d.ts.map +1 -1
  344. package/dist/utils/flatTree.js +28 -4
  345. package/dist/utils/inputAge.d.ts +22 -0
  346. package/dist/utils/inputAge.d.ts.map +1 -0
  347. package/dist/utils/inputAge.js +54 -0
  348. package/dist/utils/inputStream.d.ts +8 -0
  349. package/dist/utils/inputStream.d.ts.map +1 -1
  350. package/dist/utils/inputStream.js +53 -3
  351. package/dist/utils/moduleLoader.d.ts +23 -0
  352. package/dist/utils/moduleLoader.d.ts.map +1 -0
  353. package/dist/utils/moduleLoader.js +31 -0
  354. package/dist/utils/pressFeedback.d.ts.map +1 -1
  355. package/dist/utils/pressFeedback.js +13 -8
  356. package/dist/utils/selectionLock.d.ts.map +1 -1
  357. package/dist/utils/selectionLock.js +7 -14
  358. package/dist/utils/sharedContext.d.ts +18 -0
  359. package/dist/utils/sharedContext.d.ts.map +1 -0
  360. package/dist/utils/sharedContext.js +33 -0
  361. package/dist/utils/sharedRealm.d.ts +24 -0
  362. package/dist/utils/sharedRealm.d.ts.map +1 -0
  363. package/dist/utils/sharedRealm.js +38 -0
  364. package/locales/en.json +4 -0
  365. package/locales/pseudo.json +3 -0
  366. package/package.json +10 -5
  367. package/src/AppShell/AppShellMobileContext.tsx +8 -3
  368. package/src/AppShell/useAppShellMainId.ts +7 -2
  369. package/src/Avatar/AvatarSizeContext.ts +6 -2
  370. package/src/Avatar/AvatarStatusLabelContext.ts +8 -3
  371. package/src/AvatarGroup/AvatarGroupContext.ts +7 -4
  372. package/src/BottomSheet/BottomSheetHostContext.ts +7 -3
  373. package/src/BottomSheet/BottomSheetPanel.tsx +56 -7
  374. package/src/BottomSheet/BottomSheetSwitcherContext.ts +7 -2
  375. package/src/BottomSheet/bottomSheetEscape.ts +6 -2
  376. package/src/BottomSheet/bottomSheetStack.ts +6 -14
  377. package/src/BottomSheet/useSheetGestures.ts +28 -48
  378. package/src/Breadcrumbs/Breadcrumbs.tsx +6 -5
  379. package/src/Button/Button.doc.mjs +3 -3
  380. package/src/Button/Button.tsx +10 -22
  381. package/src/Button/buttonHitArea.ts +7 -4
  382. package/src/ButtonGroup/ButtonGroup.doc.mjs +3 -3
  383. package/src/ButtonGroup/ButtonGroup.tsx +27 -16
  384. package/src/ButtonGroup/ButtonGroupContext.ts +7 -4
  385. package/src/Carousel/Carousel.tsx +33 -15
  386. package/src/Chat/ChatContext.tsx +23 -7
  387. package/src/Chat/useChatStreamScroll.ts +7 -26
  388. package/src/CheckboxInput/CheckboxRowPressContext.ts +5 -1
  389. package/src/CheckboxList/CheckboxListContext.tsx +5 -1
  390. package/src/Collapsible/CollapsibleGroupContext.tsx +11 -3
  391. package/src/CommandPalette/CommandPaletteContext.ts +8 -3
  392. package/src/CommandPalette/busyStartSettle.ts +6 -2
  393. package/src/DateInput/TouchDateField.tsx +62 -4
  394. package/src/Dialog/DialogContext.ts +7 -2
  395. package/src/DropdownMenu/DropdownMenuContext.tsx +18 -5
  396. package/src/DropdownMenu/lazyMenuBottomSheet.ts +6 -18
  397. package/src/DropdownMenu/menuRegionStops.ts +1 -49
  398. package/src/FormLayout/FormLayoutContext.ts +3 -3
  399. package/src/Heading/Heading.tsx +34 -18
  400. package/src/HoverCard/HoverCard.doc.mjs +3 -3
  401. package/src/HoverCard/HoverCard.tsx +1 -2
  402. package/src/HoverCard/useHoverCard.tsx +6 -2
  403. package/src/Icon/IconDefaultSizeContext.ts +6 -2
  404. package/src/IconButton/IconButton.doc.mjs +2 -2
  405. package/src/InputGroup/InputGroupContext.ts +7 -4
  406. package/src/InputGroup/InputGroupInternalContext.ts +6 -2
  407. package/src/InteractiveRoleContext/InteractiveRoleContext.ts +8 -3
  408. package/src/Item/ItemDescriptionContext.tsx +7 -3
  409. package/src/Item/ItemListRowContext.tsx +7 -3
  410. package/src/Item/ItemMarkerColumnsContext.tsx +7 -2
  411. package/src/Layer/LayerContext.ts +7 -2
  412. package/src/Layer/LayerDepthContext.tsx +3 -2
  413. package/src/Layer/LayerTouch.ts +6 -2
  414. package/src/Layer/anchorName.ts +8 -4
  415. package/src/Layer/inputHold.ts +138 -21
  416. package/src/Layer/layerScopedContext.tsx +34 -7
  417. package/src/Layer/layerSlideRules.ts +43 -40
  418. package/src/Layer/outsidePress.ts +144 -28
  419. package/src/Layer/settledBox.ts +216 -54
  420. package/src/Layer/toastHost.tsx +6 -2
  421. package/src/Layer/useLayer.tsx +200 -69
  422. package/src/Layer/useLayerKeyboardClearance.ts +90 -12
  423. package/src/Layer/useTouchTrigger.ts +89 -40
  424. package/src/Layout/Layout.doc.mjs +17 -0
  425. package/src/Layout/Layout.tsx +13 -9
  426. package/src/Layout/LayoutAreaContext.ts +8 -9
  427. package/src/Layout/LayoutContent.doc.mjs +11 -0
  428. package/src/Layout/LayoutContent.tsx +9 -9
  429. package/src/Layout/LayoutDividerContext.ts +6 -2
  430. package/src/Layout/LayoutSlotsContext.ts +6 -3
  431. package/src/Link/LinkContext.ts +7 -3
  432. package/src/List/List.doc.mjs +5 -0
  433. package/src/List/List.tsx +53 -5
  434. package/src/List/ListContext.tsx +28 -6
  435. package/src/List/ListItem.doc.mjs +11 -0
  436. package/src/List/ListItem.tsx +51 -14
  437. package/src/List/listLayoutUpdates.ts +603 -0
  438. package/src/Markdown/Markdown.tsx +93 -5
  439. package/src/Markdown/blockDirection.ts +100 -0
  440. package/src/Markdown/plugins/HeadingLinksRenderer.tsx +4 -0
  441. package/src/MetadataList/MetadataListContext.tsx +6 -2
  442. package/src/NavMenu/NavMenuContext.tsx +14 -5
  443. package/src/Popover/Popover.tsx +23 -16
  444. package/src/Popover/usePopover.tsx +21 -7
  445. package/src/RadioList/RadioList.tsx +7 -4
  446. package/src/RadioList/RadioListReasonContext.ts +1 -1
  447. package/src/Section/Section.doc.mjs +22 -0
  448. package/src/SegmentedControl/SegmentedControlContext.ts +6 -2
  449. package/src/SelectableCard/selectableCardInput.ts +6 -2
  450. package/src/Selector/SelectorRowLayoutContext.ts +6 -2
  451. package/src/SideNav/SideNavCollapseButton.doc.mjs +5 -5
  452. package/src/SideNav/SideNavCollapseButton.tsx +4 -3
  453. package/src/SideNav/SideNavCollapseContext.ts +12 -7
  454. package/src/SideNav/SideNavFocusTargetsContext.ts +6 -2
  455. package/src/SideNav/SideNavItem.tsx +6 -2
  456. package/src/SideNav/SideNavRenderContext.ts +9 -8
  457. package/src/SideNav/railMotion.ts +6 -2
  458. package/src/SizeContext/SizeContext.ts +6 -2
  459. package/src/SnapPaging/SnapPaging.ts +164 -39
  460. package/src/SnapPaging/snapPagingValue.ts +59 -12
  461. package/src/Spinner/SpinnerOwnerContext.ts +6 -2
  462. package/src/Stepper/StepperContext.ts +12 -3
  463. package/src/Switch/useSwitchTouch.ts +7 -5
  464. package/src/TabList/TabListContext.ts +7 -2
  465. package/src/Table/BaseTable.tsx +143 -19
  466. package/src/Table/Table.tsx +4 -3
  467. package/src/Table/TableContext.ts +6 -2
  468. package/src/Table/index.ts +2 -0
  469. package/src/Table/plugins/filtering/useTableFiltering.tsx +11 -3
  470. package/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx +10 -3
  471. package/src/Table/plugins/rowIndex/useTableRowIndex.tsx +38 -29
  472. package/src/Table/plugins/selection/useTableSelection.tsx +7 -2
  473. package/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx +1 -0
  474. package/src/Table/plugins/tree/useTableTreeData.tsx +6 -2
  475. package/src/Table/tableRowContextUsage.ts +105 -0
  476. package/src/Table/types.ts +60 -2
  477. package/src/Table/useBaseTablePlugins.ts +5 -2
  478. package/src/Table/useTableRowIndex.doc.mjs +6 -7
  479. package/src/Text/Text.tsx +34 -18
  480. package/src/Text/TruncationTooltip.tsx +179 -0
  481. package/src/Text/textClampContext.ts +5 -1
  482. package/src/TimeInput/TimeInput.tsx +4 -0
  483. package/src/ToggleButton/ToggleButtonGroup.tsx +6 -2
  484. package/src/Token/TokenNamingContext.ts +6 -2
  485. package/src/Tokenizer/TokenizerClearAllMessageContext.ts +4 -4
  486. package/src/Tokenizer/TokenizerItemRemovableContext.ts +3 -3
  487. package/src/Toolbar/Toolbar.tsx +16 -9
  488. package/src/Tooltip/tooltipPresentInterest.ts +43 -0
  489. package/src/Tooltip/useTooltip.tsx +33 -0
  490. package/src/TopNav/TopNavContext.ts +6 -2
  491. package/src/TopNav/TopNavMobileContentContext.ts +8 -3
  492. package/src/TopNav/TopNavRenderContext.ts +8 -4
  493. package/src/Typeahead/busyIndicatorLane.tsx +7 -2
  494. package/src/Typeahead/committedChoicesKey.tsx +4 -3
  495. package/src/Typeahead/trailingKeyDown.tsx +7 -2
  496. package/src/gestures/GestureArena.ts +8 -1
  497. package/src/gestures/GestureRecognizer.ts +9 -0
  498. package/src/gestures/PressTracker.ts +13 -4
  499. package/src/hooks/focusableSelector.ts +29 -1
  500. package/src/hooks/longPressDetector.ts +1 -35
  501. package/src/hooks/pressGroupContext.ts +5 -1
  502. package/src/hooks/useActionGroupTracking.ts +29 -2
  503. package/src/hooks/useAnnounce.ts +8 -4
  504. package/src/hooks/useFocusTrap.ts +62 -2
  505. package/src/hooks/useListFocus.ts +34 -7
  506. package/src/hooks/usePager.ts +30 -3
  507. package/src/hooks/useScrollOverflow.ts +65 -7
  508. package/src/i18n/InternationalizationContext.ts +12 -8
  509. package/src/i18n/englishFallback.ts +7 -1
  510. package/src/i18n/firstStrongDirection.ts +69 -0
  511. package/src/i18n/generated-locales/en.generated.ts +1 -0
  512. package/src/i18n/generated-locales/pseudo.generated.ts +1 -0
  513. package/src/internal/scroll-anchoring.ts +16 -0
  514. package/src/internal/touch.ts +4 -0
  515. package/src/motion/animatedLayout.ts +44 -3
  516. package/src/motion/animator.ts +97 -9
  517. package/src/privateAttributes/itemKey.stylex.ts +25 -0
  518. package/src/privateAttributes/leaving.stylex.ts +23 -0
  519. package/src/privateAttributes/press.stylex.ts +19 -7
  520. package/src/privateAttributes/scrollAnchoring.stylex.ts +50 -0
  521. package/src/privateAttributes/travelling.stylex.ts +88 -0
  522. package/src/theme/Theme.tsx +124 -60
  523. package/src/theme/syntax/SyntaxTheme.tsx +7 -2
  524. package/src/theme/useTheme.ts +7 -8
  525. package/src/utils/calendarSystem.ts +7 -1
  526. package/src/utils/flatTree.ts +31 -4
  527. package/src/utils/inputAge.ts +66 -0
  528. package/src/utils/inputStream.ts +52 -3
  529. package/src/utils/moduleLoader.ts +47 -0
  530. package/src/utils/pressFeedback.ts +16 -7
  531. package/src/utils/selectionLock.ts +8 -18
  532. package/src/utils/sharedContext.ts +42 -0
  533. package/src/utils/sharedRealm.ts +42 -0
@@ -18,22 +18,26 @@
18
18
  * gutter on both alignment-axis edges, and the clearance facing the anchor
19
19
  * with the gutter on the far edge of the side it lands on.
20
20
  *
21
- * A layer that must never settle over its anchor (spec:AST-059 FR4, Tooltip)
22
- * has a second fallback list, for when its settled box covers its anchor:
23
- * content taller than the room above and below its trigger. `beside` lands on a
21
+ * An above or below layer that must never settle over its anchor
22
+ * (spec:AST-059 FR4, Tooltip) uses one combined fallback list from the start,
23
+ * and no option in it overlaps the anchor. `beside` lands on a
24
24
  * side across the alignment axis, spanning the whole block axis, at the
25
25
  * content's own inline size, so it fits only where the layer fits without
26
26
  * squeezing. `fit` lands above or below sized to the room on that side, so
27
27
  * overflow scrolls inside the layer, and is never smaller than half of the room
28
28
  * the trigger leaves on the block axis, so it fits only on the side with more
29
- * room; the list tries both only after the layer's own position, `beside` and
30
- * the opposite side at the layer's own size, so only content taller than the
29
+ * room; the list tries both only after the layer's own position, the opposite
30
+ * side at the layer's own size and `beside`, so only content taller than the
31
31
  * room on both sides is sized to a room. No option is sized to whatever room
32
32
  * is left: a browser keeps a layer on the option it last used for as long as
33
33
  * that option still fits, so such an option would hold an open layer on a side
34
34
  * shrunk to a sliver after its anchor moved. Chromium applies a position
35
35
  * option's width and height properties but not their min/max forms, so the
36
- * sizes are `inline-size` and `block-size`.
36
+ * sizes are `inline-size` and `block-size`. Inside a scrolling panel, Chromium
37
+ * does not choose an option again while the panel scrolls, and it shifts a box
38
+ * that runs out of room back into the room, onto the anchor. So the layer and
39
+ * every option align `unsafe` toward the anchor on the placement axis: a box
40
+ * that runs out of room overflows away from the anchor instead.
37
41
  *
38
42
  * The rules are static — the anchor clearance travels through a custom
39
43
  * property — so one style sheet per document carries all of them. It is
@@ -141,6 +145,18 @@ const PLACEMENTS: ReadonlyArray<LayerPlacement> = [
141
145
  ];
142
146
  const ALIGNMENTS: ReadonlyArray<LayerAlignment> = ['start', 'center', 'end'];
143
147
 
148
+ /**
149
+ * The placement-axis alignment of a layer that keeps its anchor clear, on
150
+ * `side` of its anchor: `unsafe`, toward the anchor, so a box that runs out of
151
+ * room overflows away from the anchor rather than being shifted onto it.
152
+ * `flip-block` swaps it with the side.
153
+ */
154
+ export function anchorClearAlignment(side: LayerPlacement): string {
155
+ return side === 'above' || side === 'start'
156
+ ? 'unsafe self-end'
157
+ : 'unsafe self-start';
158
+ }
159
+
144
160
  /** The name of the `beside` option that lands on `side`, across the block axis. */
145
161
  export function besideRuleName(side: 'start' | 'end'): string {
146
162
  return `--astryx-layer-beside-${side}`;
@@ -158,10 +174,12 @@ export function fitRuleName(side: 'above' | 'below'): string {
158
174
  /**
159
175
  * `beside`: the slide's geometry on an inline side, at the content's own
160
176
  * inline size. A content-sized layer would otherwise wrap to whatever sliver
161
- * of room the trigger leaves and always fit.
177
+ * of room the trigger leaves and always fit. On the block axis it drops the
178
+ * layer's own alignment toward its anchor, so it centres on the trigger and
179
+ * slides into view.
162
180
  */
163
181
  function besideRule(side: 'start' | 'end'): string {
164
- return `@position-try ${besideRuleName(side)}{position-area:${areaFor(side)};${placementMargins(side)}${alignmentMargins(side)}inline-size:max-content;}`;
182
+ return `@position-try ${besideRuleName(side)}{position-area:${areaFor(side)};${placementMargins(side)}${alignmentMargins(side)}inline-size:max-content;align-self:normal;justify-self:${anchorClearAlignment(side)};}`;
165
183
  }
166
184
 
167
185
  /** The block size of the room on one block side: the area minus its margins. */
@@ -193,42 +211,30 @@ function fitRule(side: 'above' | 'below'): string {
193
211
  size('100vh', layerViewportInset.gutterBlockFallback),
194
212
  size('100dvb', layerViewportInset.gutterBlock),
195
213
  );
196
- return `@position-try ${fitRuleName(side)}{position-area:${areaFor(side)};${placementMargins(side)}${alignmentMargins(side)}${blockSize}}`;
214
+ return `@position-try ${fitRuleName(side)}{position-area:${areaFor(side)};${placementMargins(side)}${alignmentMargins(side)}${blockSize}align-self:${anchorClearAlignment(side)};}`;
197
215
  }
198
216
 
199
217
  /**
200
- * The fallback list of a layer that must never settle over its anchor, once
201
- * the standard list has failed it (FR4). After the layer's own position (the
202
- * preferred block side, at its own size): beside the trigger on the inline
203
- * end, then the inline start, then the opposite block side at its own size,
204
- * and only then the preferred block side and the opposite one sized to the
205
- * room there, each only while it is the roomier side. Every option before the
206
- * last two keeps the layer at its own size, so a layer whose content fits
207
- * somewhere is never stretched to a room; the last two are for content taller
208
- * than the room on both sides. Chromium tries no more than five options, so
209
- * this replaces the standard list rather than extending it. Side placements
210
- * already slide along the block axis at full height, so they have none.
218
+ * The one combined fallback list of an above or below layer that must never
219
+ * settle over its anchor (FR4). After the layer's own position (the preferred
220
+ * block side, at its own size): the opposite block side at its own size, then
221
+ * beside the trigger on the inline end, then the inline start, and only then
222
+ * the preferred block side and the opposite one sized to the room there, each
223
+ * only while it is the roomier side. Every option before the last two keeps
224
+ * the layer at its own size, so a layer whose content fits somewhere is never
225
+ * stretched to a room; the last two are for content taller than the room on
226
+ * both sides. Chromium tries no more than five options, so this replaces the
227
+ * standard list rather than extending it. Side placements already slide along
228
+ * the block axis at full height, so they have none.
211
229
  */
212
230
  export function getAnchorClearFallbacks(placement: LayerPlacement): string {
213
231
  if (placement !== 'above' && placement !== 'below') {
214
232
  return '';
215
233
  }
216
234
  const opposite = placement === 'above' ? 'below' : 'above';
217
- return `${besideRuleName('end')}, ${besideRuleName('start')}, flip-block, ${fitRuleName(placement)}, ${fitRuleName(opposite)}`;
235
+ return `flip-block, ${besideRuleName('end')}, ${besideRuleName('start')}, ${fitRuleName(placement)}, ${fitRuleName(opposite)}`;
218
236
  }
219
237
 
220
- /** The custom property a layer writes its anchor-clear fallback list to. */
221
- export const LAYER_CLEAR_FALLBACKS_PROPERTY = '--_astryx-layer-clear-fallbacks';
222
-
223
- /** The custom property its `position-try-fallbacks` reads first. */
224
- export const LAYER_TRY_FALLBACKS_PROPERTY = '--_astryx-layer-try-fallbacks';
225
-
226
- /**
227
- * The attribute the runtime sets on a layer whose settled box covered its
228
- * anchor; it switches the layer to its anchor-clear list.
229
- */
230
- export const LAYER_CLEARS_ANCHOR_ATTRIBUTE = 'data-astryx-clears-anchor';
231
-
232
238
  /**
233
239
  * The attribute the runtime sets on a layer that keeps its anchor clear while
234
240
  * its content overflows the box it was given; only then does it scroll, so a
@@ -237,12 +243,9 @@ export const LAYER_CLEARS_ANCHOR_ATTRIBUTE = 'data-astryx-clears-anchor';
237
243
  */
238
244
  export const LAYER_SCROLLS_ATTRIBUTE = 'data-astryx-layer-scrolls';
239
245
 
240
- /**
241
- * Switches a layer that set the attribute to its anchor-clear list, and lets
242
- * a layer whose content overflows scroll it.
243
- */
244
- function clearSwitchCss(): string {
245
- return `[${LAYER_CLEARS_ANCHOR_ATTRIBUTE}]{${LAYER_TRY_FALLBACKS_PROPERTY}:var(${LAYER_CLEAR_FALLBACKS_PROPERTY});}[${LAYER_SCROLLS_ATTRIBUTE}]{overflow-y:auto;overscroll-behavior-block:contain;}`;
246
+ /** Lets a layer whose content overflows scroll it. */
247
+ function scrollsCss(): string {
248
+ return `[${LAYER_SCROLLS_ATTRIBUTE}]{overflow-y:auto;overscroll-behavior-block:contain;}`;
246
249
  }
247
250
 
248
251
  /**
@@ -261,7 +264,7 @@ export function slideRulesCss(): string {
261
264
  besideRule('start'),
262
265
  fitRule('above'),
263
266
  fitRule('below'),
264
- clearSwitchCss(),
267
+ scrollsCss(),
265
268
  ].join('');
266
269
  }
267
270
 
@@ -4,27 +4,38 @@
4
4
 
5
5
  /**
6
6
  * @file outsidePress.ts
7
- * @input Listens for pointerdown, pointerup and pointercancel on a document
8
- * @output Exports watchOutsidePress and useOutsidePress, which owns one watch
9
- * for a component: start on show, stop on hide, stop on unmount;
10
- * noteOutsideDismissal and outsideDismissalCount, a per-document count of
11
- * layers that an outside press or focus move closed; and the
12
- * inside tests a text field's owner runs: isPressInsideOwnedLayer for a
13
- * press, isFocusInsideOwnedLayer for a blur
14
- * @position Internal to Layer; the outside-press dismissal for a manual
15
- * popover whose owner decides what counts as inside (a combobox's field
16
- * and its list). Not exported from the package.
17
- *
18
- * A press closes the layer only when it starts and ends outside, as native
19
- * light dismiss does: a pointerdown outside is remembered, the pointerup that
20
- * follows closes the layer if it is outside too, and a pointercancel (the
21
- * browser took the gesture for a scroll or a pinch) forgets it. Inside is
22
- * judged on the event's composed path, so a field or list inside an open
23
- * shadow root, which the document sees as its shadow host, is still inside.
7
+ * @input Pointer presses on a document and on the shadow roots around a
8
+ * given root; with closesOnPan, pan moves from core's input stream
9
+ * @output watchOutsidePress, and useOutsidePress, one watch per component.
10
+ * noteOutsideDismissal and outsideDismissalCount keep a per-document count
11
+ * of layers that an outside press or focus move closed. The inside tests
12
+ * are isPressInsideOwnedLayer and isFocusInsideOwnedLayer
13
+ * @position Internal to Layer: the outside-press dismissal for a manual
14
+ * popover whose owner decides what counts as inside. Not exported.
24
15
  */
25
16
 
26
17
  import {useCallback, useEffect, useMemo, useRef} from 'react';
27
- import {isElement, isNode, isShadowRoot} from '../utils/nodeType';
18
+ import {UIKIT_PAN} from '../motion/uikit/gestures';
19
+ import {shadowHostOf, shadowRootsOutward} from '../utils/flatTree';
20
+ import {subscribeInput} from '../utils/inputStream';
21
+ import {isElement, isNode} from '../utils/nodeType';
22
+
23
+ export interface OutsidePressOptions {
24
+ /** The pointer types the watch follows; every type when omitted. */
25
+ readonly pointerTypes?: ReadonlyArray<string>;
26
+ /**
27
+ * A press outside also closes the layer as it begins to pan, or when the
28
+ * browser takes it. While one press outside is followed, other pointers are
29
+ * ignored. A new primary pointer starts a new press.
30
+ */
31
+ readonly closesOnPan?: boolean;
32
+ /**
33
+ * The shadow root the layer renders in. The document sees a press inside a
34
+ * closed root as a press on its host. So each root from this one out to the
35
+ * document judges presses too, and an inner root's judgment stands.
36
+ */
37
+ readonly root?: Node | null;
38
+ }
28
39
 
29
40
  // A modal host's backdrop press reads this. A press that closed a layer above
30
41
  // the host is that layer's, so the host stays open.
@@ -47,39 +58,144 @@ export function outsideDismissalCount(doc: Document): number {
47
58
  * @param owner - The element that owns the layer (the field); its document is
48
59
  * watched.
49
60
  * @param isInside - Whether a press with this composed path is inside.
50
- * @param onOutside - Called once for each press that starts and ends outside.
61
+ * @param onOutside - Called once for each press that starts and ends outside,
62
+ * as native light dismiss does. With `closesOnPan`, also when that press
63
+ * pans or is cancelled.
51
64
  * @returns Stops watching.
52
65
  */
53
66
  export function watchOutsidePress(
54
67
  owner: Element,
55
68
  isInside: (path: ReadonlyArray<EventTarget>) => boolean,
56
69
  onOutside: () => void,
70
+ {pointerTypes, closesOnPan = false, root = null}: OutsidePressOptions = {},
57
71
  ): () => void {
58
72
  const doc = owner.ownerDocument;
73
+ const shadows = root == null ? [] : shadowRootsOutward(root);
59
74
  let startedOutside = false;
75
+ let panStart: {id: number; x: number; y: number} | null = null;
76
+ const follows = (event: PointerEvent) =>
77
+ pointerTypes == null || pointerTypes.includes(event.pointerType);
78
+ const close = () => {
79
+ startedOutside = false;
80
+ panStart = null;
81
+ noteOutsideDismissal(doc);
82
+ onOutside();
83
+ };
60
84
 
61
85
  // Capture phase, so a press whose target stops propagation is still seen.
86
+ // An inner root's listener runs after the outer ones', so its judgment
87
+ // stands.
62
88
  const handleDown = (event: PointerEvent) => {
89
+ if (!follows(event)) {
90
+ return;
91
+ }
92
+ if (
93
+ closesOnPan &&
94
+ panStart != null &&
95
+ panStart.id !== event.pointerId &&
96
+ !event.isPrimary
97
+ ) {
98
+ return;
99
+ }
63
100
  startedOutside = !isInside(event.composedPath());
101
+ if (closesOnPan) {
102
+ panStart = startedOutside
103
+ ? {id: event.pointerId, x: event.clientX, y: event.clientY}
104
+ : null;
105
+ }
106
+ };
107
+ const handleMove = (event: PointerEvent) => {
108
+ if (
109
+ panStart?.id === event.pointerId &&
110
+ Math.max(
111
+ Math.abs(event.clientX - panStart.x),
112
+ Math.abs(event.clientY - panStart.y),
113
+ ) >= UIKIT_PAN.hysteresis.value
114
+ ) {
115
+ close();
116
+ }
64
117
  };
65
- const handleUp = (event: PointerEvent) => {
118
+ const judgeUp = (event: PointerEvent) => {
119
+ if (!follows(event) || (closesOnPan && panStart?.id !== event.pointerId)) {
120
+ return;
121
+ }
66
122
  const wasOutside = startedOutside;
67
123
  startedOutside = false;
124
+ panStart = null;
68
125
  if (wasOutside && !isInside(event.composedPath())) {
69
126
  noteOutsideDismissal(doc);
70
127
  onOutside();
71
128
  }
72
129
  };
73
- const handleCancel = () => {
74
- startedOutside = false;
130
+ // The document and each root see a lift inside a deeper closed root as a
131
+ // lift on that root's host. So each of them judges, in the capture phase,
132
+ // only a lift whose path does not hold the host below it. The innermost root
133
+ // judges every lift it sees. A host judges a lift on itself, which no root
134
+ // sees.
135
+ let judgedLift: Event | null = null;
136
+ const judgeUpUnlessBelow =
137
+ (hostBelow: Element | null) => (event: PointerEvent) => {
138
+ if (
139
+ event === judgedLift ||
140
+ (hostBelow != null && event.composedPath().includes(hostBelow))
141
+ ) {
142
+ return;
143
+ }
144
+ judgedLift = event;
145
+ judgeUp(event);
146
+ };
147
+ const handleUp = judgeUpUnlessBelow(shadows.at(-1)?.host ?? null);
148
+ const liftJudges = shadows.map(({root: shadow, host}, index) => ({
149
+ shadow,
150
+ host,
151
+ handleRootUp: judgeUpUnlessBelow(
152
+ index === 0 ? null : shadows[index - 1].host,
153
+ ) as EventListener,
154
+ handleHostUp: judgeUpUnlessBelow(null) as EventListener,
155
+ }));
156
+ const handleCancel = (event: PointerEvent) => {
157
+ if (!follows(event)) {
158
+ return;
159
+ }
160
+ if (closesOnPan && panStart?.id === event.pointerId) {
161
+ close();
162
+ } else if (!closesOnPan) {
163
+ startedOutside = false;
164
+ }
75
165
  };
76
166
 
77
- doc.addEventListener('pointerdown', handleDown, true);
167
+ const judges: EventTarget[] = [
168
+ doc,
169
+ ...shadows.map(({root: shadow}) => shadow),
170
+ ];
171
+ for (const target of judges) {
172
+ target.addEventListener('pointerdown', handleDown as EventListener, true);
173
+ }
174
+ const view = doc.defaultView;
175
+ const stopMoves =
176
+ closesOnPan && view != null
177
+ ? subscribeInput(view, 'pointermove', handleMove)
178
+ : null;
78
179
  doc.addEventListener('pointerup', handleUp, true);
180
+ for (const {shadow, host, handleRootUp, handleHostUp} of liftJudges) {
181
+ shadow.addEventListener('pointerup', handleRootUp, true);
182
+ host.addEventListener('pointerup', handleHostUp);
183
+ }
79
184
  doc.addEventListener('pointercancel', handleCancel, true);
80
185
  return () => {
81
- doc.removeEventListener('pointerdown', handleDown, true);
186
+ for (const target of judges) {
187
+ target.removeEventListener(
188
+ 'pointerdown',
189
+ handleDown as EventListener,
190
+ true,
191
+ );
192
+ }
193
+ stopMoves?.();
82
194
  doc.removeEventListener('pointerup', handleUp, true);
195
+ for (const {shadow, host, handleRootUp, handleHostUp} of liftJudges) {
196
+ shadow.removeEventListener('pointerup', handleRootUp, true);
197
+ host.removeEventListener('pointerup', handleHostUp);
198
+ }
83
199
  doc.removeEventListener('pointercancel', handleCancel, true);
84
200
  };
85
201
  }
@@ -90,6 +206,7 @@ export interface OutsidePressWatch {
90
206
  owner: Element,
91
207
  isInside: (path: ReadonlyArray<EventTarget>) => boolean,
92
208
  onOutside: () => void,
209
+ options?: OutsidePressOptions,
93
210
  ) => void;
94
211
  /** Stop watching; does nothing when no watch is running. */
95
212
  stop: () => void;
@@ -108,9 +225,9 @@ export function useOutsidePress(): OutsidePressWatch {
108
225
  stopRef.current = null;
109
226
  }, []);
110
227
  const start = useCallback<OutsidePressWatch['start']>(
111
- (owner, isInside, onOutside) => {
228
+ (owner, isInside, onOutside, options) => {
112
229
  stopRef.current?.();
113
- stopRef.current = watchOutsidePress(owner, isInside, onOutside);
230
+ stopRef.current = watchOutsidePress(owner, isInside, onOutside, options);
114
231
  },
115
232
  [],
116
233
  );
@@ -124,8 +241,7 @@ function isWithinLayer(node: Node, layerId: string): boolean {
124
241
  for (
125
242
  let current: Node | null = node;
126
243
  current != null;
127
- current =
128
- current.parentNode ?? (isShadowRoot(current) ? current.host : null)
244
+ current = current.parentNode ?? shadowHostOf(current)
129
245
  ) {
130
246
  if (isElement(current) && current.id === layerId) {
131
247
  return true;