@astryxdesign/core 0.7.17-canary.gffd1fc0 → 0.7.17

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 (950) hide show
  1. package/CHANGELOG.md +334 -0
  2. package/README.md +26 -9
  3. package/dist/AlertDialog/AlertDialog.d.ts +1 -1
  4. package/dist/AlertDialog/AlertDialog.d.ts.map +1 -1
  5. package/dist/AlertDialog/AlertDialog.js +6 -8
  6. package/dist/AppShell/AppShell.d.ts +7 -3
  7. package/dist/AppShell/AppShell.d.ts.map +1 -1
  8. package/dist/AppShell/AppShell.js +74 -36
  9. package/dist/AppShell/unreadWidthPoint.d.ts +29 -0
  10. package/dist/AppShell/unreadWidthPoint.d.ts.map +1 -0
  11. package/dist/AppShell/unreadWidthPoint.js +134 -0
  12. package/dist/AvatarGroup/AvatarGroupOverflow.d.ts +1 -1
  13. package/dist/AvatarGroup/AvatarGroupOverflow.d.ts.map +1 -1
  14. package/dist/AvatarGroup/AvatarGroupOverflow.js +5 -1
  15. package/dist/Badge/Badge.d.ts.map +1 -1
  16. package/dist/Badge/Badge.js +2 -2
  17. package/dist/Banner/Banner.d.ts +6 -4
  18. package/dist/Banner/Banner.d.ts.map +1 -1
  19. package/dist/Banner/Banner.js +32 -29
  20. package/dist/BottomSheet/BottomSheet.d.ts.map +1 -1
  21. package/dist/BottomSheet/BottomSheet.js +3 -1
  22. package/dist/BottomSheet/BottomSheetPanel.d.ts.map +1 -1
  23. package/dist/BottomSheet/BottomSheetPanel.js +11 -7
  24. package/dist/BottomSheet/BottomSheetSwitcher.d.ts.map +1 -1
  25. package/dist/BottomSheet/BottomSheetSwitcher.js +57 -2
  26. package/dist/BottomSheet/BottomSheetSwitcherContext.d.ts +5 -0
  27. package/dist/BottomSheet/BottomSheetSwitcherContext.d.ts.map +1 -1
  28. package/dist/BottomSheet/bottomSheetStack.d.ts.map +1 -1
  29. package/dist/BottomSheet/bottomSheetStack.js +6 -14
  30. package/dist/Breadcrumbs/BreadcrumbItem.d.ts.map +1 -1
  31. package/dist/Breadcrumbs/BreadcrumbItem.js +12 -1
  32. package/dist/Button/Button.d.ts.map +1 -1
  33. package/dist/Button/Button.js +45 -7
  34. package/dist/Calendar/Calendar.js +8 -2
  35. package/dist/Calendar/styles.d.ts +10 -6
  36. package/dist/Calendar/styles.d.ts.map +1 -1
  37. package/dist/Calendar/styles.js +7 -3
  38. package/dist/Card/Card.d.ts.map +1 -1
  39. package/dist/Card/Card.js +23 -4
  40. package/dist/Chat/ChatComposer.d.ts +1 -1
  41. package/dist/Chat/ChatComposer.d.ts.map +1 -1
  42. package/dist/Chat/ChatComposer.js +4 -4
  43. package/dist/Chat/ChatComposerDrawer.d.ts.map +1 -1
  44. package/dist/Chat/ChatComposerDrawer.js +8 -4
  45. package/dist/Chat/ChatDictationButton.d.ts.map +1 -1
  46. package/dist/Chat/ChatDictationButton.js +7 -0
  47. package/dist/Chat/ChatPastedTextToken.d.ts.map +1 -1
  48. package/dist/Chat/ChatPastedTextToken.js +3 -9
  49. package/dist/Chat/ChatSendButton.d.ts.map +1 -1
  50. package/dist/Chat/ChatSendButton.js +3 -0
  51. package/dist/Chat/ChatSystemMessage.d.ts.map +1 -1
  52. package/dist/Chat/ChatSystemMessage.js +1 -0
  53. package/dist/Chat/ChatToolCalls.d.ts.map +1 -1
  54. package/dist/Chat/ChatToolCalls.js +8 -0
  55. package/dist/Chat/pastedTextLabel.d.ts +4 -0
  56. package/dist/Chat/pastedTextLabel.d.ts.map +1 -0
  57. package/dist/Chat/pastedTextLabel.js +21 -0
  58. package/dist/Chat/useChatPasteAsToken.d.ts.map +1 -1
  59. package/dist/Chat/useChatPasteAsToken.js +8 -8
  60. package/dist/Chat/useTriggerMenu.d.ts.map +1 -1
  61. package/dist/Chat/useTriggerMenu.js +3 -3
  62. package/dist/CheckboxInput/CheckboxInput.d.ts +2 -1
  63. package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
  64. package/dist/CheckboxInput/CheckboxInput.js +69 -18
  65. package/dist/Citation/Citation.d.ts.map +1 -1
  66. package/dist/Citation/Citation.js +8 -1
  67. package/dist/Code/Code.d.ts.map +1 -1
  68. package/dist/Code/Code.js +5 -1
  69. package/dist/CodeBlock/CodeBlock.d.ts.map +1 -1
  70. package/dist/CodeBlock/CodeBlock.js +39 -12
  71. package/dist/CodeBlock/highlightRanges.d.ts.map +1 -1
  72. package/dist/CodeBlock/highlightRanges.js +6 -5
  73. package/dist/Collapsible/Collapsible.d.ts.map +1 -1
  74. package/dist/Collapsible/Collapsible.js +2 -0
  75. package/dist/CommandPalette/CommandPaletteItem.d.ts.map +1 -1
  76. package/dist/CommandPalette/CommandPaletteItem.js +1 -0
  77. package/dist/ComplexSelector/ComplexSelector.d.ts.map +1 -1
  78. package/dist/ComplexSelector/ComplexSelector.js +8 -1
  79. package/dist/ContextMenu/ContextMenu.d.ts.map +1 -1
  80. package/dist/ContextMenu/ContextMenu.js +32 -5
  81. package/dist/DateInput/MonthScroller.d.ts.map +1 -1
  82. package/dist/DateInput/MonthScroller.js +1 -0
  83. package/dist/DateInput/PickerWheel.d.ts.map +1 -1
  84. package/dist/DateInput/PickerWheel.js +3 -2
  85. package/dist/DateInput/TouchDateField.d.ts.map +1 -1
  86. package/dist/DateInput/TouchDateField.js +2 -1
  87. package/dist/DateInput/Wheel.d.ts.map +1 -1
  88. package/dist/DateInput/Wheel.js +8 -8
  89. package/dist/DateInput/usePointerDragScroll.d.ts.map +1 -1
  90. package/dist/DateInput/usePointerDragScroll.js +5 -2
  91. package/dist/DateRangeInput/DateRangeInput.d.ts.map +1 -1
  92. package/dist/DateRangeInput/DateRangeInput.js +7 -0
  93. package/dist/DateTimeInput/TouchDateTimeField.d.ts.map +1 -1
  94. package/dist/DateTimeInput/TouchDateTimeField.js +2 -1
  95. package/dist/DateTimeInput/nativePickerSegmentStyles.d.ts +2 -2
  96. package/dist/Dialog/Dialog.d.ts.map +1 -1
  97. package/dist/Dialog/Dialog.js +104 -18
  98. package/dist/Dialog/DialogContext.d.ts +5 -4
  99. package/dist/Dialog/DialogContext.d.ts.map +1 -1
  100. package/dist/Dialog/DialogHeader.d.ts.map +1 -1
  101. package/dist/Dialog/DialogHeader.js +38 -12
  102. package/dist/Drawer/DrawerHeader.d.ts.map +1 -1
  103. package/dist/Drawer/DrawerHeader.js +23 -8
  104. package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
  105. package/dist/DropdownMenu/DropdownMenu.js +23 -17
  106. package/dist/DropdownMenu/DropdownMenuCheckboxItem.d.ts.map +1 -1
  107. package/dist/DropdownMenu/DropdownMenuCheckboxItem.js +3 -3
  108. package/dist/DropdownMenu/DropdownMenuItem.d.ts.map +1 -1
  109. package/dist/DropdownMenu/DropdownMenuItem.js +3 -2
  110. package/dist/DropdownMenu/DropdownMenuRadioItem.d.ts.map +1 -1
  111. package/dist/DropdownMenu/DropdownMenuRadioItem.js +3 -3
  112. package/dist/DropdownMenu/DropdownMenuSubMenu.d.ts.map +1 -1
  113. package/dist/DropdownMenu/DropdownMenuSubMenu.js +19 -2
  114. package/dist/DropdownMenu/lazyMenuBottomSheet.d.ts +6 -3
  115. package/dist/DropdownMenu/lazyMenuBottomSheet.d.ts.map +1 -1
  116. package/dist/DropdownMenu/lazyMenuBottomSheet.js +31 -7
  117. package/dist/DropdownMenu/menuRowCorners.stylex.d.ts +24 -0
  118. package/dist/DropdownMenu/menuRowCorners.stylex.d.ts.map +1 -0
  119. package/dist/DropdownMenu/menuRowCorners.stylex.js +29 -0
  120. package/dist/EmptyState/EmptyState.d.ts.map +1 -1
  121. package/dist/EmptyState/EmptyState.js +2 -2
  122. package/dist/Field/FieldLabel.d.ts.map +1 -1
  123. package/dist/Field/FieldLabel.js +2 -2
  124. package/dist/Field/inputDisabledFocus.d.ts +4 -0
  125. package/dist/Field/inputDisabledFocus.d.ts.map +1 -1
  126. package/dist/Field/inputDisabledFocus.js +5 -0
  127. package/dist/Field/inputStyles.stylex.d.ts +31 -4
  128. package/dist/Field/inputStyles.stylex.d.ts.map +1 -1
  129. package/dist/Field/inputStyles.stylex.js +30 -5
  130. package/dist/Grid/Grid.d.ts +2 -1
  131. package/dist/Grid/Grid.d.ts.map +1 -1
  132. package/dist/Grid/Grid.js +5 -2
  133. package/dist/Heading/Heading.d.ts +1 -1
  134. package/dist/Heading/Heading.d.ts.map +1 -1
  135. package/dist/Heading/Heading.js +15 -1
  136. package/dist/Icon/Icon.d.ts +1 -1
  137. package/dist/Icon/Icon.d.ts.map +1 -1
  138. package/dist/Icon/Icon.js +32 -2
  139. package/dist/Indicator/CheckboxIndicator.d.ts.map +1 -1
  140. package/dist/Indicator/CheckboxIndicator.js +12 -6
  141. package/dist/Indicator/RadioIndicator.d.ts.map +1 -1
  142. package/dist/Indicator/RadioIndicator.js +18 -4
  143. package/dist/Indicator/indicatorRegistry.d.ts +3 -26
  144. package/dist/Indicator/indicatorRegistry.d.ts.map +1 -1
  145. package/dist/Indicator/indicatorRegistry.js +2 -11
  146. package/dist/Indicator/themeIndicators.d.ts +15 -0
  147. package/dist/Indicator/themeIndicators.d.ts.map +1 -0
  148. package/dist/Indicator/themeIndicators.js +21 -0
  149. package/dist/Indicator/types.d.ts +14 -0
  150. package/dist/Indicator/types.d.ts.map +1 -1
  151. package/dist/Indicator/useThemeIndicator.d.ts +3 -0
  152. package/dist/Indicator/useThemeIndicator.d.ts.map +1 -0
  153. package/dist/Indicator/useThemeIndicator.js +19 -0
  154. package/dist/Item/Item.d.ts +6 -2
  155. package/dist/Item/Item.d.ts.map +1 -1
  156. package/dist/Item/Item.js +30 -2
  157. package/dist/Kbd/Kbd.d.ts.map +1 -1
  158. package/dist/Kbd/Kbd.js +9 -2
  159. package/dist/Layer/layerExitCopy.d.ts.map +1 -1
  160. package/dist/Layer/layerExitCopy.js +1 -1
  161. package/dist/Layer/layerSlideRules.d.ts +23 -15
  162. package/dist/Layer/layerSlideRules.d.ts.map +1 -1
  163. package/dist/Layer/layerSlideRules.js +54 -54
  164. package/dist/Layer/useLayer.d.ts +41 -29
  165. package/dist/Layer/useLayer.d.ts.map +1 -1
  166. package/dist/Layer/useLayer.js +199 -126
  167. package/dist/Layer/useLayerKeyboardClearance.d.ts +5 -5
  168. package/dist/Layer/useLayerKeyboardClearance.d.ts.map +1 -1
  169. package/dist/Layer/useLayerKeyboardClearance.js +5 -5
  170. package/dist/Layout/LayoutContainerContext.d.ts +4 -0
  171. package/dist/Layout/LayoutContainerContext.d.ts.map +1 -0
  172. package/dist/Layout/LayoutContainerContext.js +20 -0
  173. package/dist/Layout/LayoutContainerScope.d.ts +15 -0
  174. package/dist/Layout/LayoutContainerScope.d.ts.map +1 -0
  175. package/dist/Layout/LayoutContainerScope.js +23 -0
  176. package/dist/Layout/LayoutContent.d.ts +2 -1
  177. package/dist/Layout/LayoutContent.d.ts.map +1 -1
  178. package/dist/Layout/LayoutContent.js +7 -2
  179. package/dist/Layout/LayoutFooter.d.ts.map +1 -1
  180. package/dist/Layout/LayoutFooter.js +5 -1
  181. package/dist/Layout/LayoutHeader.d.ts.map +1 -1
  182. package/dist/Layout/LayoutHeader.js +5 -1
  183. package/dist/Layout/containerCorners.stylex.d.ts +15 -7
  184. package/dist/Layout/containerCorners.stylex.d.ts.map +1 -1
  185. package/dist/Layout/containerCorners.stylex.js +16 -7
  186. package/dist/Lightbox/Lightbox.d.ts.map +1 -1
  187. package/dist/Lightbox/Lightbox.js +324 -6
  188. package/dist/Link/Link.d.ts.map +1 -1
  189. package/dist/Link/Link.js +1 -1
  190. package/dist/List/List.d.ts.map +1 -1
  191. package/dist/List/List.js +14 -6
  192. package/dist/List/ListContext.d.ts +38 -1
  193. package/dist/List/ListContext.d.ts.map +1 -1
  194. package/dist/List/ListContext.js +50 -2
  195. package/dist/List/ListItem.js +2 -2
  196. package/dist/Markdown/Markdown.d.ts.map +1 -1
  197. package/dist/Markdown/Markdown.js +85 -96
  198. package/dist/Markdown/plugins/HeadingLinksRenderer.d.ts.map +1 -1
  199. package/dist/Markdown/plugins/HeadingLinksRenderer.js +12 -5
  200. package/dist/Markdown/plugins/protocol.js +3 -3
  201. package/dist/MetadataList/MetadataListItem.d.ts.map +1 -1
  202. package/dist/MetadataList/MetadataListItem.js +11 -3
  203. package/dist/MobileNav/MobileNav.d.ts +1 -1
  204. package/dist/MobileNav/MobileNav.d.ts.map +1 -1
  205. package/dist/MobileNav/MobileNav.js +6 -3
  206. package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
  207. package/dist/MultiSelector/MultiSelector.js +33 -9
  208. package/dist/NavMenu/NavHeadingMenu.d.ts.map +1 -1
  209. package/dist/NavMenu/NavHeadingMenu.js +5 -2
  210. package/dist/NavMenu/NavHeadingMenuItem.d.ts.map +1 -1
  211. package/dist/NavMenu/NavHeadingMenuItem.js +1 -0
  212. package/dist/NavMenu/NavMenuContext.d.ts +7 -0
  213. package/dist/NavMenu/NavMenuContext.d.ts.map +1 -1
  214. package/dist/NavMenu/NavMenuContext.js +9 -0
  215. package/dist/NumberInput/NumberInput.d.ts.map +1 -1
  216. package/dist/NumberInput/NumberInput.js +8 -2
  217. package/dist/Outline/Outline.d.ts +7 -3
  218. package/dist/Outline/Outline.d.ts.map +1 -1
  219. package/dist/Outline/Outline.js +11 -3
  220. package/dist/Outline/useScrollSpy.d.ts +1 -1
  221. package/dist/Outline/useScrollSpy.d.ts.map +1 -1
  222. package/dist/Outline/useScrollSpy.js +6 -2
  223. package/dist/OverflowList/OverflowList.d.ts.map +1 -1
  224. package/dist/OverflowList/OverflowList.js +51 -25
  225. package/dist/Pagination/Pagination.d.ts.map +1 -1
  226. package/dist/Pagination/Pagination.js +33 -13
  227. package/dist/Popover/Popover.d.ts.map +1 -1
  228. package/dist/Popover/Popover.js +5 -1
  229. package/dist/Popover/popoverAnchor.d.ts +11 -0
  230. package/dist/Popover/popoverAnchor.d.ts.map +1 -0
  231. package/dist/Popover/popoverAnchor.js +33 -0
  232. package/dist/Popover/usePopover.d.ts +20 -3
  233. package/dist/Popover/usePopover.d.ts.map +1 -1
  234. package/dist/Popover/usePopover.js +110 -10
  235. package/dist/PowerSearch/PowerSearch.d.ts +1 -0
  236. package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
  237. package/dist/PowerSearch/PowerSearch.js +46 -9
  238. package/dist/PowerSearch/PowerSearchEditPopover.d.ts.map +1 -1
  239. package/dist/PowerSearch/PowerSearchEditPopover.js +1 -1
  240. package/dist/PowerSearch/PowerSearchFilterEditor.d.ts.map +1 -1
  241. package/dist/PowerSearch/PowerSearchFilterEditor.js +7 -1
  242. package/dist/PowerSearch/PowerSearchToken.d.ts.map +1 -1
  243. package/dist/PowerSearch/PowerSearchToken.js +7 -0
  244. package/dist/PowerSearch/PowerSearchValueEditor.d.ts +2 -4
  245. package/dist/PowerSearch/PowerSearchValueEditor.d.ts.map +1 -1
  246. package/dist/PowerSearch/PowerSearchValueEditor.js +6 -13
  247. package/dist/ProgressBar/ProgressBar.d.ts +5 -4
  248. package/dist/ProgressBar/ProgressBar.d.ts.map +1 -1
  249. package/dist/ProgressBar/ProgressBar.js +26 -26
  250. package/dist/RadioList/RadioList.d.ts.map +1 -1
  251. package/dist/RadioList/RadioList.js +51 -0
  252. package/dist/RadioList/RadioListItem.d.ts.map +1 -1
  253. package/dist/RadioList/RadioListItem.js +1 -1
  254. package/dist/Resizable/ResizeHandle.d.ts +1 -1
  255. package/dist/Resizable/ResizeHandle.d.ts.map +1 -1
  256. package/dist/Resizable/ResizeHandle.js +1 -1
  257. package/dist/Resizable/resizableModel.d.ts +45 -3
  258. package/dist/Resizable/resizableModel.d.ts.map +1 -1
  259. package/dist/Resizable/resizableModel.js +91 -3
  260. package/dist/Resizable/resizeGesture.d.ts +3 -0
  261. package/dist/Resizable/resizeGesture.d.ts.map +1 -1
  262. package/dist/Resizable/resizeGesture.js +6 -0
  263. package/dist/Resizable/useResizable.d.ts +1 -33
  264. package/dist/Resizable/useResizable.d.ts.map +1 -1
  265. package/dist/Resizable/useResizable.js +8 -72
  266. package/dist/SegmentedControl/SegmentedControlItem.d.ts.map +1 -1
  267. package/dist/SegmentedControl/SegmentedControlItem.js +1 -0
  268. package/dist/SegmentedControl/useSegmentedTouchTracking.d.ts +27 -5
  269. package/dist/SegmentedControl/useSegmentedTouchTracking.d.ts.map +1 -1
  270. package/dist/SegmentedControl/useSegmentedTouchTracking.js +70 -8
  271. package/dist/Selector/Selector.d.ts.map +1 -1
  272. package/dist/Selector/Selector.js +34 -14
  273. package/dist/Selector/hooks.d.ts +5 -0
  274. package/dist/Selector/hooks.d.ts.map +1 -1
  275. package/dist/Selector/hooks.js +72 -16
  276. package/dist/Selector/useSelectorPresentation.d.ts.map +1 -1
  277. package/dist/Selector/useSelectorPresentation.js +9 -3
  278. package/dist/SideNav/SideNavHeading.d.ts.map +1 -1
  279. package/dist/SideNav/SideNavHeading.js +18 -5
  280. package/dist/Slider/Slider.d.ts.map +1 -1
  281. package/dist/Slider/Slider.js +2 -2
  282. package/dist/Spinner/Spinner.d.ts.map +1 -1
  283. package/dist/Spinner/Spinner.js +47 -33
  284. package/dist/Stepper/Step.d.ts.map +1 -1
  285. package/dist/Stepper/Step.js +21 -12
  286. package/dist/Swipe/useSwipeAction.js +3 -3
  287. package/dist/Switch/Switch.d.ts.map +1 -1
  288. package/dist/Switch/Switch.js +64 -46
  289. package/dist/Switch/useSwitchTouch.d.ts +22 -1
  290. package/dist/Switch/useSwitchTouch.d.ts.map +1 -1
  291. package/dist/Switch/useSwitchTouch.js +54 -3
  292. package/dist/TabList/Tab.d.ts.map +1 -1
  293. package/dist/TabList/Tab.js +3 -3
  294. package/dist/Table/BaseTable.d.ts.map +1 -1
  295. package/dist/Table/BaseTable.js +37 -18
  296. package/dist/Table/Table.d.ts +4 -3
  297. package/dist/Table/Table.d.ts.map +1 -1
  298. package/dist/Table/Table.js +32 -14
  299. package/dist/Table/TableBody.d.ts.map +1 -1
  300. package/dist/Table/TableBody.js +5 -1
  301. package/dist/Table/TableCell.d.ts.map +1 -1
  302. package/dist/Table/TableCell.js +6 -0
  303. package/dist/Table/TableHeaderCell.d.ts +1 -1
  304. package/dist/Table/TableHeaderCell.d.ts.map +1 -1
  305. package/dist/Table/TableHeaderCell.js +42 -9
  306. package/dist/Table/TableRow.d.ts.map +1 -1
  307. package/dist/Table/TableRow.js +9 -1
  308. package/dist/Table/TableRowPlacementContext.d.ts +18 -0
  309. package/dist/Table/TableRowPlacementContext.d.ts.map +1 -0
  310. package/dist/Table/TableRowPlacementContext.js +41 -0
  311. package/dist/Table/TableSelectionToolbar.d.ts.map +1 -1
  312. package/dist/Table/TableSelectionToolbar.js +7 -0
  313. package/dist/Table/columnUtils.d.ts +5 -0
  314. package/dist/Table/columnUtils.d.ts.map +1 -1
  315. package/dist/Table/columnUtils.js +9 -1
  316. package/dist/Table/plugins/rowIndex/useTableRowIndex.d.ts.map +1 -1
  317. package/dist/Table/plugins/rowIndex/useTableRowIndex.js +2 -2
  318. package/dist/Table/plugins/sortable/useTableSortable.d.ts.map +1 -1
  319. package/dist/Table/plugins/sortable/useTableSortable.js +8 -3
  320. package/dist/Table/plugins/sortable/useTableSortableState.d.ts.map +1 -1
  321. package/dist/Table/plugins/sortable/useTableSortableState.js +10 -6
  322. package/dist/Table/plugins/stickyColumns/useTableStickyColumns.d.ts.map +1 -1
  323. package/dist/Table/plugins/stickyColumns/useTableStickyColumns.js +5 -1
  324. package/dist/Table/plugins/tree/useTableTreeData.d.ts.map +1 -1
  325. package/dist/Table/plugins/tree/useTableTreeData.js +76 -15
  326. package/dist/Table/table.stylex.d.ts +31 -5
  327. package/dist/Table/table.stylex.d.ts.map +1 -1
  328. package/dist/Table/table.stylex.js +33 -5
  329. package/dist/Table/types.d.ts +3 -1
  330. package/dist/Table/types.d.ts.map +1 -1
  331. package/dist/Text/TruncationTooltip.d.ts +35 -1
  332. package/dist/Text/TruncationTooltip.d.ts.map +1 -1
  333. package/dist/Text/TruncationTooltip.js +115 -0
  334. package/dist/Text/text.stylex.d.ts +2 -2
  335. package/dist/Text/useTruncation.d.ts.map +1 -1
  336. package/dist/Text/useTruncation.js +23 -4
  337. package/dist/TextArea/TextArea.d.ts.map +1 -1
  338. package/dist/TextArea/TextArea.js +15 -1
  339. package/dist/TextInput/TextInput.d.ts +9 -3
  340. package/dist/TextInput/TextInput.d.ts.map +1 -1
  341. package/dist/TextInput/TextInput.js +19 -18
  342. package/dist/Thumbnail/Thumbnail.d.ts.map +1 -1
  343. package/dist/Thumbnail/Thumbnail.js +13 -4
  344. package/dist/Timer/Timer.d.ts.map +1 -1
  345. package/dist/Timer/Timer.js +10 -7
  346. package/dist/Timestamp/Timestamp.d.ts.map +1 -1
  347. package/dist/Timestamp/Timestamp.js +55 -4
  348. package/dist/Toast/Toast.d.ts +1 -6
  349. package/dist/Toast/Toast.d.ts.map +1 -1
  350. package/dist/Toast/Toast.js +77 -44
  351. package/dist/Toast/ToastViewport.d.ts.map +1 -1
  352. package/dist/Toast/ToastViewport.js +48 -21
  353. package/dist/Toast/types.d.ts +8 -0
  354. package/dist/Toast/types.d.ts.map +1 -1
  355. package/dist/Toast/useToast.d.ts.map +1 -1
  356. package/dist/Toast/useToast.js +14 -7
  357. package/dist/ToggleButton/ToggleButton.d.ts.map +1 -1
  358. package/dist/ToggleButton/ToggleButton.js +14 -9
  359. package/dist/Token/Token.d.ts +1 -1
  360. package/dist/Token/Token.d.ts.map +1 -1
  361. package/dist/Token/Token.js +6 -2
  362. package/dist/Tokenizer/Tokenizer.d.ts +2 -2
  363. package/dist/Tokenizer/Tokenizer.d.ts.map +1 -1
  364. package/dist/Tokenizer/Tokenizer.js +102 -62
  365. package/dist/Toolbar/Toolbar.d.ts.map +1 -1
  366. package/dist/Toolbar/Toolbar.js +33 -5
  367. package/dist/Tooltip/Tooltip.d.ts +12 -1
  368. package/dist/Tooltip/Tooltip.d.ts.map +1 -1
  369. package/dist/Tooltip/Tooltip.js +31 -1
  370. package/dist/Tooltip/useTooltip.d.ts.map +1 -1
  371. package/dist/Tooltip/useTooltip.js +20 -1
  372. package/dist/TopNav/TopNav.d.ts.map +1 -1
  373. package/dist/TopNav/TopNav.js +24 -8
  374. package/dist/TopNav/TopNavContext.d.ts +13 -0
  375. package/dist/TopNav/TopNavContext.d.ts.map +1 -1
  376. package/dist/TopNav/TopNavContext.js +27 -1
  377. package/dist/TopNav/TopNavHeading.d.ts.map +1 -1
  378. package/dist/TopNav/TopNavHeading.js +21 -9
  379. package/dist/TopNav/TopNavMegaMenu.d.ts.map +1 -1
  380. package/dist/TopNav/TopNavMegaMenu.js +25 -17
  381. package/dist/TopNav/TopNavMegaMenuFeaturedCard.d.ts.map +1 -1
  382. package/dist/TopNav/TopNavMegaMenuFeaturedCard.js +13 -2
  383. package/dist/TopNav/TopNavMegaMenuItem.d.ts +9 -1
  384. package/dist/TopNav/TopNavMegaMenuItem.d.ts.map +1 -1
  385. package/dist/TopNav/TopNavMegaMenuItem.js +14 -2
  386. package/dist/TopNav/TopNavMenu.d.ts +8 -0
  387. package/dist/TopNav/TopNavMenu.d.ts.map +1 -1
  388. package/dist/TopNav/TopNavMenu.js +20 -5
  389. package/dist/TopNav/TopNavRenderContext.d.ts +13 -0
  390. package/dist/TopNav/TopNavRenderContext.d.ts.map +1 -1
  391. package/dist/TopNav/TopNavRenderContext.js +24 -9
  392. package/dist/TreeList/TreeList.d.ts.map +1 -1
  393. package/dist/TreeList/TreeList.js +7 -1
  394. package/dist/TreeList/TreeListItem.d.ts.map +1 -1
  395. package/dist/TreeList/TreeListItem.js +20 -2
  396. package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
  397. package/dist/Typeahead/BaseTypeahead.js +2 -1
  398. package/dist/Typeahead/Typeahead.d.ts.map +1 -1
  399. package/dist/Typeahead/Typeahead.js +24 -9
  400. package/dist/Typeahead/TypeaheadItem.d.ts.map +1 -1
  401. package/dist/Typeahead/TypeaheadItem.js +7 -0
  402. package/dist/astryx.css +215 -56
  403. package/dist/gestures/GestureHost.d.ts +7 -0
  404. package/dist/gestures/GestureHost.d.ts.map +1 -1
  405. package/dist/gestures/GestureHost.js +37 -0
  406. package/dist/hooks/anchoredHint.d.ts.map +1 -1
  407. package/dist/hooks/anchoredHint.js +0 -1
  408. package/dist/hooks/computeOverflow.d.ts.map +1 -1
  409. package/dist/hooks/computeOverflow.js +7 -0
  410. package/dist/hooks/focusableSelector.d.ts +16 -9
  411. package/dist/hooks/focusableSelector.d.ts.map +1 -1
  412. package/dist/hooks/focusableSelector.js +53 -2
  413. package/dist/hooks/scrollEdgeFade.d.ts +34 -0
  414. package/dist/hooks/scrollEdgeFade.d.ts.map +1 -0
  415. package/dist/hooks/scrollEdgeFade.js +173 -0
  416. package/dist/hooks/statusButtonPress.d.ts +15 -0
  417. package/dist/hooks/statusButtonPress.d.ts.map +1 -0
  418. package/dist/hooks/statusButtonPress.js +19 -0
  419. package/dist/hooks/useAnnounce.d.ts.map +1 -1
  420. package/dist/hooks/useAnnounce.js +2 -1
  421. package/dist/hooks/useFocusTrap.d.ts +26 -16
  422. package/dist/hooks/useFocusTrap.d.ts.map +1 -1
  423. package/dist/hooks/useFocusTrap.js +75 -112
  424. package/dist/hooks/useGroupPressTracking.d.ts +1 -1
  425. package/dist/hooks/useGroupPressTracking.js +1 -1
  426. package/dist/hooks/useOverflow.d.ts +25 -2
  427. package/dist/hooks/useOverflow.d.ts.map +1 -1
  428. package/dist/hooks/useOverflow.js +137 -8
  429. package/dist/hooks/useResolvedRequired.d.ts +27 -0
  430. package/dist/hooks/useResolvedRequired.d.ts.map +1 -1
  431. package/dist/hooks/useResolvedRequired.js +30 -1
  432. package/dist/hooks/useTreeFocus.d.ts.map +1 -1
  433. package/dist/hooks/useTreeFocus.js +4 -2
  434. package/dist/hooks/useTypeahead.d.ts.map +1 -1
  435. package/dist/hooks/useTypeahead.js +8 -8
  436. package/dist/i18n/InternationalizationContext.d.ts +13 -6
  437. package/dist/i18n/InternationalizationContext.d.ts.map +1 -1
  438. package/dist/i18n/InternationalizationContext.js +11 -6
  439. package/dist/i18n/InternationalizationProvider.d.ts.map +1 -1
  440. package/dist/i18n/InternationalizationProvider.js +7 -0
  441. package/dist/i18n/defaultTranslator.d.ts +17 -0
  442. package/dist/i18n/defaultTranslator.d.ts.map +1 -0
  443. package/dist/i18n/defaultTranslator.js +18 -0
  444. package/dist/i18n/firstStrongDirection.d.ts +3 -2
  445. package/dist/i18n/firstStrongDirection.d.ts.map +1 -1
  446. package/dist/i18n/firstStrongDirection.js +50 -12
  447. package/dist/i18n/generated-english/Chat/ChatPastedTextToken.generated.d.ts.map +1 -1
  448. package/dist/i18n/generated-english/Chat/ChatPastedTextToken.generated.js +1 -2
  449. package/dist/i18n/generated-english/Chat/pastedTextLabel.generated.d.ts +8 -0
  450. package/dist/i18n/generated-english/Chat/pastedTextLabel.generated.d.ts.map +1 -0
  451. package/dist/i18n/generated-english/Chat/pastedTextLabel.generated.js +12 -0
  452. package/dist/i18n/generated-english/Chat/useTriggerMenu.generated.d.ts.map +1 -1
  453. package/dist/i18n/generated-english/Chat/useTriggerMenu.generated.js +1 -0
  454. package/dist/i18n/generated-english/CodeBlock/CodeBlock.generated.d.ts.map +1 -1
  455. package/dist/i18n/generated-english/CodeBlock/CodeBlock.generated.js +2 -1
  456. package/dist/i18n/generated-english/Markdown/plugins/HeadingLinksRenderer.generated.d.ts.map +1 -1
  457. package/dist/i18n/generated-english/Markdown/plugins/HeadingLinksRenderer.generated.js +2 -1
  458. package/dist/i18n/generated-english/MultiSelector/MultiSelector.generated.d.ts.map +1 -1
  459. package/dist/i18n/generated-english/MultiSelector/MultiSelector.generated.js +1 -0
  460. package/dist/i18n/generated-english/Slider/Slider.generated.d.ts.map +1 -1
  461. package/dist/i18n/generated-english/Slider/Slider.generated.js +2 -1
  462. package/dist/i18n/generated-english/TextArea/TextArea.generated.d.ts.map +1 -1
  463. package/dist/i18n/generated-english/TextArea/TextArea.generated.js +1 -0
  464. package/dist/i18n/generated-english/TextInput/TextInput.generated.d.ts.map +1 -1
  465. package/dist/i18n/generated-english/TextInput/TextInput.generated.js +1 -0
  466. package/dist/i18n/generated-english/Timestamp/Timestamp.generated.d.ts.map +1 -1
  467. package/dist/i18n/generated-english/Timestamp/Timestamp.generated.js +2 -1
  468. package/dist/i18n/generated-english/Tokenizer/Tokenizer.generated.d.ts.map +1 -1
  469. package/dist/i18n/generated-english/Tokenizer/Tokenizer.generated.js +1 -0
  470. package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
  471. package/dist/i18n/generated-locales/en.generated.js +9 -0
  472. package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
  473. package/dist/i18n/generated-locales/pseudo.generated.js +9 -0
  474. package/dist/i18n/publicContext.d.ts.map +1 -1
  475. package/dist/i18n/publicContext.js +4 -2
  476. package/dist/i18n/translatingContext.d.ts +2 -0
  477. package/dist/i18n/translatingContext.d.ts.map +1 -0
  478. package/dist/i18n/translatingContext.js +25 -0
  479. package/dist/i18n/useComponentTranslator.d.ts.map +1 -1
  480. package/dist/i18n/useComponentTranslator.js +3 -2
  481. package/dist/i18n/useListFormatter.d.ts.map +1 -1
  482. package/dist/i18n/useListFormatter.js +3 -2
  483. package/dist/i18n/useTranslator.d.ts.map +1 -1
  484. package/dist/i18n/useTranslator.js +3 -2
  485. package/dist/internal/touch.d.ts +2 -0
  486. package/dist/internal/touch.d.ts.map +1 -1
  487. package/dist/internal/touch.js +5 -1
  488. package/dist/keyboard/keyboardHeight.d.ts +34 -3
  489. package/dist/keyboard/keyboardHeight.d.ts.map +1 -1
  490. package/dist/keyboard/keyboardHeight.js +101 -24
  491. package/dist/keyboard/keyboardTarget.d.ts +19 -16
  492. package/dist/keyboard/keyboardTarget.d.ts.map +1 -1
  493. package/dist/keyboard/keyboardTarget.js +529 -72
  494. package/dist/keyboard/useMobileKeyboard.d.ts.map +1 -1
  495. package/dist/keyboard/useMobileKeyboard.js +1 -8
  496. package/dist/palette/color.d.ts +23 -0
  497. package/dist/palette/color.d.ts.map +1 -0
  498. package/dist/palette/color.js +126 -0
  499. package/dist/palette/generator.d.ts +69 -0
  500. package/dist/palette/generator.d.ts.map +1 -0
  501. package/dist/palette/generator.js +778 -0
  502. package/dist/palette/index.d.ts +12 -0
  503. package/dist/palette/index.d.ts.map +1 -0
  504. package/dist/palette/index.js +13 -0
  505. package/dist/palette/mapping.d.ts +319 -0
  506. package/dist/palette/mapping.d.ts.map +1 -0
  507. package/dist/palette/mapping.js +1312 -0
  508. package/dist/palette/themePalette.d.ts +20 -0
  509. package/dist/palette/themePalette.d.ts.map +1 -0
  510. package/dist/palette/themePalette.js +145 -0
  511. package/dist/palette/types.d.ts +178 -0
  512. package/dist/palette/types.d.ts.map +1 -0
  513. package/dist/palette/types.js +1 -0
  514. package/dist/privateAttributes/mediaDarkPage.d.ts +5 -0
  515. package/dist/privateAttributes/mediaDarkPage.d.ts.map +1 -0
  516. package/dist/privateAttributes/mediaDarkPage.js +27 -0
  517. package/dist/privateAttributes/pressGroupItem.stylex.d.ts +2 -1
  518. package/dist/privateAttributes/pressGroupItem.stylex.d.ts.map +1 -1
  519. package/dist/privateAttributes/pressGroupItem.stylex.js +2 -1
  520. package/dist/privateAttributes/scheme.d.ts +10 -0
  521. package/dist/privateAttributes/scheme.d.ts.map +1 -0
  522. package/dist/privateAttributes/scheme.js +34 -0
  523. package/dist/privateAttributes/travelling.stylex.d.ts.map +1 -1
  524. package/dist/privateAttributes/travelling.stylex.js +2 -2
  525. package/dist/theme/MediaDarkPage.d.ts +18 -0
  526. package/dist/theme/MediaDarkPage.d.ts.map +1 -0
  527. package/dist/theme/MediaDarkPage.js +35 -0
  528. package/dist/theme/MediaTheme.d.ts.map +1 -1
  529. package/dist/theme/MediaTheme.js +9 -1
  530. package/dist/theme/Theme.d.ts.map +1 -1
  531. package/dist/theme/Theme.js +99 -31
  532. package/dist/theme/defineTheme.d.ts +31 -6
  533. package/dist/theme/defineTheme.d.ts.map +1 -1
  534. package/dist/theme/defineTheme.js +65 -29
  535. package/dist/theme/derivedVarRegistry.d.ts +19 -0
  536. package/dist/theme/derivedVarRegistry.d.ts.map +1 -1
  537. package/dist/theme/derivedVarRegistry.js +49 -4
  538. package/dist/theme/expandRadiusScale.d.ts +1 -2
  539. package/dist/theme/expandRadiusScale.d.ts.map +1 -1
  540. package/dist/theme/expandRadiusScale.js +1 -5
  541. package/dist/theme/generateThemeRules.d.ts +10 -3
  542. package/dist/theme/generateThemeRules.d.ts.map +1 -1
  543. package/dist/theme/generateThemeRules.js +310 -207
  544. package/dist/theme/index.d.ts +2 -1
  545. package/dist/theme/index.d.ts.map +1 -1
  546. package/dist/theme/index.js +2 -1
  547. package/dist/theme/invertedSurfaceSide.d.ts +17 -0
  548. package/dist/theme/invertedSurfaceSide.d.ts.map +1 -0
  549. package/dist/theme/invertedSurfaceSide.js +47 -0
  550. package/dist/theme/resolveThemeValues.d.ts +5 -2
  551. package/dist/theme/resolveThemeValues.d.ts.map +1 -1
  552. package/dist/theme/resolveThemeValues.js +7 -1
  553. package/dist/theme/statusRoleDefaults.d.ts +43 -0
  554. package/dist/theme/statusRoleDefaults.d.ts.map +1 -0
  555. package/dist/theme/statusRoleDefaults.js +196 -0
  556. package/dist/theme/statusRoleDerivation.d.ts +4 -0
  557. package/dist/theme/statusRoleDerivation.d.ts.map +1 -1
  558. package/dist/theme/statusRoleDerivation.js +3 -1
  559. package/dist/theme/syntax/SyntaxTheme.d.ts.map +1 -1
  560. package/dist/theme/syntax/SyntaxTheme.js +7 -0
  561. package/dist/theme/themeAdaptations.d.ts +24 -1
  562. package/dist/theme/themeAdaptations.d.ts.map +1 -1
  563. package/dist/theme/themeAdaptations.js +48 -5
  564. package/dist/theme/tokenDefaults.d.ts +3 -0
  565. package/dist/theme/tokenDefaults.d.ts.map +1 -0
  566. package/dist/theme/tokenDefaults.js +30 -0
  567. package/dist/theme/tokenValues.d.ts +26 -0
  568. package/dist/theme/tokenValues.d.ts.map +1 -0
  569. package/dist/theme/tokenValues.js +180 -0
  570. package/dist/theme/tokens.d.ts +3 -2
  571. package/dist/theme/tokens.d.ts.map +1 -1
  572. package/dist/theme/tokens.js +7 -161
  573. package/dist/theme/tokens.stylex.d.ts +4 -4
  574. package/dist/theme/tokens.stylex.d.ts.map +1 -1
  575. package/dist/theme/tokens.stylex.js +7 -5
  576. package/dist/theme/useTheme.d.ts +40 -3
  577. package/dist/theme/useTheme.d.ts.map +1 -1
  578. package/dist/theme/useTheme.js +137 -32
  579. package/dist/utils/devWarning.d.ts +17 -0
  580. package/dist/utils/devWarning.d.ts.map +1 -1
  581. package/dist/utils/devWarning.js +20 -0
  582. package/dist/utils/focusOutline.stylex.d.ts.map +1 -1
  583. package/dist/utils/focusOutline.stylex.js +7 -4
  584. package/dist/utils/focusReturn.d.ts +110 -0
  585. package/dist/utils/focusReturn.d.ts.map +1 -1
  586. package/dist/utils/focusReturn.js +418 -12
  587. package/dist/utils/hitArea.d.ts +28 -0
  588. package/dist/utils/hitArea.d.ts.map +1 -1
  589. package/dist/utils/hitArea.js +52 -18
  590. package/dist/utils/inputStream.d.ts +27 -0
  591. package/dist/utils/inputStream.d.ts.map +1 -1
  592. package/dist/utils/inputStream.js +72 -5
  593. package/dist/utils/nodeType.d.ts +2 -0
  594. package/dist/utils/nodeType.d.ts.map +1 -1
  595. package/dist/utils/nodeType.js +10 -0
  596. package/dist/utils/timeFormat.d.ts +14 -4
  597. package/dist/utils/timeFormat.d.ts.map +1 -1
  598. package/dist/utils/timeFormat.js +42 -4
  599. package/dist/utils/touchPresentation.d.ts +2 -2
  600. package/dist/utils/touchPresentation.d.ts.map +1 -1
  601. package/dist/utils/touchPresentation.js +10 -7
  602. package/dist/utils/touchPresentation.stylex.d.ts +4 -3
  603. package/dist/utils/touchPresentation.stylex.d.ts.map +1 -1
  604. package/dist/utils/touchPresentation.stylex.js +3 -3
  605. package/dist/utils/touchQueries.d.ts +3 -2
  606. package/dist/utils/touchQueries.d.ts.map +1 -1
  607. package/dist/utils/touchQueries.js +3 -2
  608. package/dist/utils/typeaheadMatch.d.ts +13 -0
  609. package/dist/utils/typeaheadMatch.d.ts.map +1 -1
  610. package/dist/utils/typeaheadMatch.js +15 -1
  611. package/dist/virtualization/useInlineListWindow.d.ts.map +1 -1
  612. package/dist/virtualization/useInlineListWindow.js +38 -22
  613. package/locales/en.json +36 -0
  614. package/locales/pseudo.json +27 -0
  615. package/package.json +10 -5
  616. package/scripts/agent-doc-state.mjs +71 -4
  617. package/src/AlertDialog/AlertDialog.doc.mjs +5 -1
  618. package/src/AlertDialog/AlertDialog.tsx +34 -7
  619. package/src/AppShell/AppShell.doc.mjs +22 -0
  620. package/src/AppShell/AppShell.tsx +112 -65
  621. package/src/AppShell/unreadWidthPoint.ts +162 -0
  622. package/src/AvatarGroup/AvatarGroupOverflow.tsx +6 -1
  623. package/src/Badge/Badge.tsx +5 -2
  624. package/src/Banner/Banner.doc.mjs +15 -0
  625. package/src/Banner/Banner.tsx +56 -45
  626. package/src/BottomSheet/BottomSheet.doc.mjs +6 -3
  627. package/src/BottomSheet/BottomSheet.tsx +3 -0
  628. package/src/BottomSheet/BottomSheetPanel.tsx +15 -7
  629. package/src/BottomSheet/BottomSheetSwitcher.tsx +73 -1
  630. package/src/BottomSheet/BottomSheetSwitcherContext.ts +5 -0
  631. package/src/BottomSheet/bottomSheetStack.ts +6 -14
  632. package/src/Breadcrumbs/BreadcrumbItem.tsx +14 -1
  633. package/src/Button/Button.doc.mjs +9 -3
  634. package/src/Button/Button.tsx +65 -11
  635. package/src/Calendar/Calendar.doc.mjs +16 -0
  636. package/src/Calendar/Calendar.tsx +32 -20
  637. package/src/Calendar/styles.ts +12 -3
  638. package/src/Card/Card.doc.mjs +2 -2
  639. package/src/Card/Card.tsx +22 -3
  640. package/src/Chat/Chat.doc.mjs +1 -1
  641. package/src/Chat/ChatComposer.doc.mjs +3 -3
  642. package/src/Chat/ChatComposer.tsx +11 -5
  643. package/src/Chat/ChatComposerDrawer.tsx +11 -7
  644. package/src/Chat/ChatDictationButton.tsx +12 -0
  645. package/src/Chat/ChatMessageBubble.tsx +2 -2
  646. package/src/Chat/ChatPastedTextToken.tsx +3 -9
  647. package/src/Chat/ChatSendButton.tsx +5 -0
  648. package/src/Chat/ChatSystemMessage.tsx +1 -0
  649. package/src/Chat/ChatToolCalls.tsx +16 -0
  650. package/src/Chat/pastedTextLabel.ts +23 -0
  651. package/src/Chat/useChatPasteAsToken.ts +9 -8
  652. package/src/Chat/useTriggerMenu.tsx +4 -1
  653. package/src/CheckboxInput/CheckboxInput.doc.mjs +20 -0
  654. package/src/CheckboxInput/CheckboxInput.tsx +83 -26
  655. package/src/CheckboxList/CheckboxList.doc.mjs +15 -0
  656. package/src/CheckboxList/CheckboxListItem.doc.mjs +3 -3
  657. package/src/Citation/Citation.tsx +16 -1
  658. package/src/Code/Code.tsx +3 -0
  659. package/src/CodeBlock/CodeBlock.doc.mjs +7 -0
  660. package/src/CodeBlock/CodeBlock.tsx +60 -13
  661. package/src/CodeBlock/highlightRanges.ts +7 -5
  662. package/src/Collapsible/Collapsible.tsx +2 -0
  663. package/src/CommandPalette/CommandPaletteItem.tsx +1 -0
  664. package/src/ComplexSelector/ComplexSelector.doc.mjs +30 -2
  665. package/src/ComplexSelector/ComplexSelector.tsx +19 -1
  666. package/src/ContextMenu/ContextMenu.doc.mjs +5 -1
  667. package/src/ContextMenu/ContextMenu.tsx +44 -5
  668. package/src/ContextMenu/ContextMenuItem.doc.mjs +55 -5
  669. package/src/DateInput/MonthScroller.tsx +1 -0
  670. package/src/DateInput/PickerWheel.tsx +1 -0
  671. package/src/DateInput/TouchDateField.tsx +2 -0
  672. package/src/DateInput/Wheel.tsx +1 -0
  673. package/src/DateInput/usePointerDragScroll.ts +6 -2
  674. package/src/DateRangeInput/DateRangeInput.tsx +16 -0
  675. package/src/DateTimeInput/TouchDateTimeField.tsx +2 -0
  676. package/src/Dialog/Dialog.doc.mjs +11 -1
  677. package/src/Dialog/Dialog.tsx +116 -19
  678. package/src/Dialog/DialogContext.ts +5 -4
  679. package/src/Dialog/DialogHeader.tsx +50 -12
  680. package/src/Drawer/DrawerHeader.tsx +31 -6
  681. package/src/DropdownMenu/DropdownMenu.doc.mjs +20 -1
  682. package/src/DropdownMenu/DropdownMenu.tsx +29 -22
  683. package/src/DropdownMenu/DropdownMenuCheckboxItem.doc.mjs +4 -4
  684. package/src/DropdownMenu/DropdownMenuCheckboxItem.tsx +3 -2
  685. package/src/DropdownMenu/DropdownMenuItem.doc.mjs +5 -5
  686. package/src/DropdownMenu/DropdownMenuItem.tsx +3 -1
  687. package/src/DropdownMenu/DropdownMenuRadioItem.doc.mjs +4 -4
  688. package/src/DropdownMenu/DropdownMenuRadioItem.tsx +3 -2
  689. package/src/DropdownMenu/DropdownMenuSubMenu.doc.mjs +3 -3
  690. package/src/DropdownMenu/DropdownMenuSubMenu.tsx +23 -1
  691. package/src/DropdownMenu/lazyMenuBottomSheet.ts +37 -9
  692. package/src/DropdownMenu/menuRowCorners.stylex.ts +40 -0
  693. package/src/EmptyState/EmptyState.tsx +2 -0
  694. package/src/Field/Field.doc.mjs +1 -1
  695. package/src/Field/FieldLabel.doc.mjs +3 -3
  696. package/src/Field/FieldLabel.tsx +9 -2
  697. package/src/Field/inputDisabledFocus.ts +18 -0
  698. package/src/Field/inputStyles.stylex.ts +52 -1
  699. package/src/Grid/Grid.doc.mjs +6 -3
  700. package/src/Grid/Grid.tsx +5 -2
  701. package/src/Heading/Heading.tsx +24 -1
  702. package/src/Icon/Icon.doc.mjs +1 -1
  703. package/src/Icon/Icon.tsx +40 -2
  704. package/src/Indicator/CheckboxIndicator.tsx +11 -6
  705. package/src/Indicator/Indicator.doc.mjs +1 -1
  706. package/src/Indicator/RadioIndicator.tsx +31 -4
  707. package/src/Indicator/indicatorRegistry.ts +7 -23
  708. package/src/Indicator/themeIndicators.ts +29 -0
  709. package/src/Indicator/types.ts +14 -0
  710. package/src/Indicator/useThemeIndicator.ts +24 -0
  711. package/src/Item/Item.doc.mjs +3 -3
  712. package/src/Item/Item.tsx +48 -7
  713. package/src/Kbd/Kbd.doc.mjs +6 -2
  714. package/src/Kbd/Kbd.tsx +16 -1
  715. package/src/Layer/layerExitCopy.ts +0 -1
  716. package/src/Layer/layerSlideRules.ts +62 -74
  717. package/src/Layer/useLayer.doc.mjs +2 -2
  718. package/src/Layer/useLayer.tsx +293 -137
  719. package/src/Layer/useLayerKeyboardClearance.ts +9 -12
  720. package/src/Layout/Layout.doc.mjs +3 -3
  721. package/src/Layout/LayoutContainerContext.ts +27 -0
  722. package/src/Layout/LayoutContainerScope.tsx +32 -0
  723. package/src/Layout/LayoutContent.tsx +5 -2
  724. package/src/Layout/LayoutFooter.tsx +3 -1
  725. package/src/Layout/LayoutHeader.tsx +3 -1
  726. package/src/Layout/containerCorners.stylex.ts +44 -7
  727. package/src/Lightbox/Lightbox.tsx +460 -8
  728. package/src/Link/Link.doc.mjs +18 -0
  729. package/src/Link/Link.tsx +3 -1
  730. package/src/List/List.tsx +14 -2
  731. package/src/List/ListContext.tsx +60 -1
  732. package/src/List/ListItem.doc.mjs +11 -9
  733. package/src/List/ListItem.tsx +4 -4
  734. package/src/Markdown/Markdown.doc.mjs +1 -1
  735. package/src/Markdown/Markdown.tsx +189 -190
  736. package/src/Markdown/plugins/HeadingLinksRenderer.tsx +14 -4
  737. package/src/Markdown/plugins/protocol.ts +3 -3
  738. package/src/MetadataList/MetadataListItem.tsx +18 -3
  739. package/src/MobileNav/MobileNav.doc.mjs +134 -52
  740. package/src/MobileNav/MobileNav.tsx +13 -9
  741. package/src/MultiSelector/MultiSelector.doc.mjs +2 -2
  742. package/src/MultiSelector/MultiSelector.tsx +51 -8
  743. package/src/NavMenu/NavHeadingMenu.tsx +5 -1
  744. package/src/NavMenu/NavHeadingMenuItem.tsx +1 -0
  745. package/src/NavMenu/NavMenu.doc.mjs +105 -2
  746. package/src/NavMenu/NavMenuContext.tsx +13 -0
  747. package/src/NumberInput/NumberInput.doc.mjs +12 -10
  748. package/src/NumberInput/NumberInput.tsx +19 -11
  749. package/src/Outline/Outline.doc.mjs +26 -8
  750. package/src/Outline/Outline.tsx +35 -5
  751. package/src/Outline/useScrollSpy.ts +8 -3
  752. package/src/OverflowList/OverflowList.doc.mjs +15 -0
  753. package/src/OverflowList/OverflowList.tsx +62 -26
  754. package/src/Pagination/Pagination.doc.mjs +12 -0
  755. package/src/Pagination/Pagination.tsx +40 -6
  756. package/src/Popover/Popover.doc.mjs +10 -0
  757. package/src/Popover/Popover.tsx +8 -4
  758. package/src/Popover/popoverAnchor.ts +47 -0
  759. package/src/Popover/usePopover.doc.mjs +16 -2
  760. package/src/Popover/usePopover.tsx +152 -16
  761. package/src/PowerSearch/PowerSearch.doc.mjs +8 -8
  762. package/src/PowerSearch/PowerSearch.tsx +65 -12
  763. package/src/PowerSearch/PowerSearchEditPopover.tsx +1 -0
  764. package/src/PowerSearch/PowerSearchFilterEditor.tsx +12 -0
  765. package/src/PowerSearch/PowerSearchToken.tsx +12 -0
  766. package/src/PowerSearch/PowerSearchValueEditor.tsx +14 -19
  767. package/src/ProgressBar/ProgressBar.doc.mjs +2 -2
  768. package/src/ProgressBar/ProgressBar.tsx +44 -30
  769. package/src/RadioList/RadioList.tsx +63 -0
  770. package/src/RadioList/RadioListItem.tsx +4 -1
  771. package/src/Resizable/ResizeHandle.tsx +2 -3
  772. package/src/Resizable/resizableModel.ts +105 -3
  773. package/src/Resizable/resizeGesture.ts +14 -0
  774. package/src/Resizable/useResizable.ts +14 -75
  775. package/src/SegmentedControl/SegmentedControlItem.tsx +1 -0
  776. package/src/SegmentedControl/useSegmentedTouchTracking.ts +76 -12
  777. package/src/Selector/Selector.doc.mjs +34 -7
  778. package/src/Selector/Selector.tsx +55 -25
  779. package/src/Selector/SelectorOption.doc.mjs +5 -5
  780. package/src/Selector/hooks.ts +92 -17
  781. package/src/Selector/useSelectorPresentation.ts +18 -3
  782. package/src/SideNav/SideNavHeading.tsx +15 -4
  783. package/src/SideNav/SideNavItem.doc.mjs +10 -10
  784. package/src/Slider/Slider.tsx +4 -1
  785. package/src/Spinner/Spinner.tsx +56 -41
  786. package/src/Stepper/Step.tsx +18 -3
  787. package/src/Stepper/Stepper.doc.mjs +14 -2
  788. package/src/Swipe/useSwipeAction.ts +3 -3
  789. package/src/Switch/Switch.doc.mjs +61 -5
  790. package/src/Switch/Switch.tsx +72 -35
  791. package/src/Switch/useSwitchTouch.ts +68 -3
  792. package/src/TabList/Tab.tsx +6 -0
  793. package/src/Table/BaseTable.tsx +73 -35
  794. package/src/Table/Table.doc.mjs +109 -5
  795. package/src/Table/Table.tsx +42 -17
  796. package/src/Table/TableBody.tsx +10 -1
  797. package/src/Table/TableCell.tsx +6 -0
  798. package/src/Table/TableHeaderCell.tsx +52 -7
  799. package/src/Table/TableRow.tsx +8 -1
  800. package/src/Table/TableRowPlacementContext.ts +58 -0
  801. package/src/Table/TableSelectionToolbar.tsx +12 -0
  802. package/src/Table/columnUtils.ts +9 -1
  803. package/src/Table/plugins/columnSettings/useTableColumnSettingsState.doc.mjs +1 -1
  804. package/src/Table/plugins/rowIndex/useTableRowIndex.tsx +1 -0
  805. package/src/Table/plugins/sortable/useTableSortable.tsx +15 -2
  806. package/src/Table/plugins/sortable/useTableSortableState.doc.mjs +5 -5
  807. package/src/Table/plugins/sortable/useTableSortableState.tsx +15 -8
  808. package/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx +8 -0
  809. package/src/Table/plugins/tree/useTableTreeData.tsx +90 -14
  810. package/src/Table/table.stylex.ts +44 -5
  811. package/src/Table/types.ts +3 -1
  812. package/src/Table/useTableColumnResize.doc.mjs +3 -3
  813. package/src/Table/useTableColumnSettings.doc.mjs +3 -3
  814. package/src/Table/useTableFilterState.doc.mjs +6 -3
  815. package/src/Table/useTableFiltering.doc.mjs +71 -4
  816. package/src/Table/useTableInfiniteScroll.doc.mjs +2 -2
  817. package/src/Table/useTablePagination.doc.mjs +24 -3
  818. package/src/Table/useTableSelection.doc.mjs +30 -6
  819. package/src/Table/useTableSelectionState.doc.mjs +30 -2
  820. package/src/Table/useTableSortable.doc.mjs +104 -17
  821. package/src/Table/useTableStickyColumns.doc.mjs +3 -3
  822. package/src/Table/useTableTreeData.doc.mjs +2 -2
  823. package/src/Text/Heading.doc.mjs +2 -2
  824. package/src/Text/Text.doc.mjs +1 -1
  825. package/src/Text/TruncationTooltip.tsx +168 -1
  826. package/src/Text/useTruncation.ts +20 -4
  827. package/src/TextArea/TextArea.doc.mjs +5 -5
  828. package/src/TextArea/TextArea.tsx +20 -1
  829. package/src/TextInput/TextInput.doc.mjs +5 -5
  830. package/src/TextInput/TextInput.tsx +23 -18
  831. package/src/Thumbnail/Thumbnail.tsx +2 -1
  832. package/src/Timer/Timer.tsx +21 -6
  833. package/src/Timestamp/Timestamp.tsx +67 -4
  834. package/src/Toast/Toast.doc.mjs +15 -5
  835. package/src/Toast/Toast.tsx +83 -62
  836. package/src/Toast/ToastViewport.tsx +62 -23
  837. package/src/Toast/types.ts +8 -0
  838. package/src/Toast/useToast.doc.mjs +80 -15
  839. package/src/Toast/useToast.tsx +18 -7
  840. package/src/ToggleButton/ToggleButton.doc.mjs +1 -1
  841. package/src/ToggleButton/ToggleButton.tsx +25 -2
  842. package/src/Token/Token.tsx +5 -1
  843. package/src/Tokenizer/Tokenizer.doc.mjs +15 -3
  844. package/src/Tokenizer/Tokenizer.tsx +130 -75
  845. package/src/Toolbar/Toolbar.tsx +55 -4
  846. package/src/Tooltip/Tooltip.tsx +34 -0
  847. package/src/Tooltip/useTooltip.tsx +26 -0
  848. package/src/TopNav/TopNav.doc.mjs +1 -1
  849. package/src/TopNav/TopNav.tsx +13 -3
  850. package/src/TopNav/TopNavContext.ts +31 -1
  851. package/src/TopNav/TopNavHeading.tsx +22 -9
  852. package/src/TopNav/TopNavMegaMenu.tsx +27 -18
  853. package/src/TopNav/TopNavMegaMenuFeaturedCard.tsx +14 -2
  854. package/src/TopNav/TopNavMegaMenuItem.doc.mjs +26 -5
  855. package/src/TopNav/TopNavMegaMenuItem.tsx +26 -2
  856. package/src/TopNav/TopNavMenu.doc.mjs +19 -8
  857. package/src/TopNav/TopNavMenu.tsx +34 -2
  858. package/src/TopNav/TopNavRenderContext.ts +30 -9
  859. package/src/TreeList/TreeList.tsx +12 -0
  860. package/src/TreeList/TreeListItem.tsx +26 -5
  861. package/src/Typeahead/BaseTypeahead.doc.mjs +6 -0
  862. package/src/Typeahead/BaseTypeahead.tsx +2 -0
  863. package/src/Typeahead/Typeahead.doc.mjs +15 -2
  864. package/src/Typeahead/Typeahead.tsx +37 -13
  865. package/src/Typeahead/TypeaheadItem.tsx +12 -0
  866. package/src/gestures/GestureHost.ts +34 -0
  867. package/src/gestures/README.md +9 -6
  868. package/src/hooks/anchoredHint.tsx +1 -2
  869. package/src/hooks/computeOverflow.ts +10 -0
  870. package/src/hooks/focusableSelector.ts +59 -2
  871. package/src/hooks/scrollEdgeFade.ts +129 -0
  872. package/src/hooks/statusButtonPress.ts +26 -0
  873. package/src/hooks/useAnnounce.ts +2 -1
  874. package/src/hooks/useFocusTrap.ts +110 -141
  875. package/src/hooks/useGroupPressTracking.ts +1 -1
  876. package/src/hooks/useOverflow.ts +227 -13
  877. package/src/hooks/useResolvedRequired.ts +50 -1
  878. package/src/hooks/useTreeFocus.ts +8 -4
  879. package/src/hooks/useTypeahead.ts +12 -10
  880. package/src/i18n/InternationalizationContext.ts +16 -7
  881. package/src/i18n/InternationalizationProvider.doc.mjs +1 -1
  882. package/src/i18n/InternationalizationProvider.tsx +12 -0
  883. package/src/i18n/defaultTranslator.ts +25 -0
  884. package/src/i18n/firstStrongDirection.ts +54 -13
  885. package/src/i18n/generated-english/Chat/ChatPastedTextToken.generated.ts +1 -2
  886. package/src/i18n/generated-english/Chat/pastedTextLabel.generated.ts +13 -0
  887. package/src/i18n/generated-english/Chat/useTriggerMenu.generated.ts +1 -0
  888. package/src/i18n/generated-english/CodeBlock/CodeBlock.generated.ts +2 -1
  889. package/src/i18n/generated-english/Markdown/plugins/HeadingLinksRenderer.generated.ts +2 -1
  890. package/src/i18n/generated-english/MultiSelector/MultiSelector.generated.ts +1 -0
  891. package/src/i18n/generated-english/Slider/Slider.generated.ts +2 -1
  892. package/src/i18n/generated-english/TextArea/TextArea.generated.ts +1 -0
  893. package/src/i18n/generated-english/TextInput/TextInput.generated.ts +1 -0
  894. package/src/i18n/generated-english/Timestamp/Timestamp.generated.ts +2 -1
  895. package/src/i18n/generated-english/Tokenizer/Tokenizer.generated.ts +1 -0
  896. package/src/i18n/generated-locales/en.generated.ts +11 -0
  897. package/src/i18n/generated-locales/pseudo.generated.ts +11 -0
  898. package/src/i18n/publicContext.ts +4 -2
  899. package/src/i18n/translatingContext.ts +28 -0
  900. package/src/i18n/useComponentTranslator.ts +3 -2
  901. package/src/i18n/useListFormatter.ts +3 -2
  902. package/src/i18n/useTranslator.ts +3 -2
  903. package/src/internal/touch.ts +7 -0
  904. package/src/keyboard/README.md +58 -16
  905. package/src/keyboard/keyboardHeight.ts +138 -26
  906. package/src/keyboard/keyboardTarget.ts +667 -71
  907. package/src/keyboard/useMobileKeyboard.ts +1 -7
  908. package/src/palette/color.ts +205 -0
  909. package/src/palette/generator.ts +1134 -0
  910. package/src/palette/index.ts +35 -0
  911. package/src/palette/mapping.ts +1630 -0
  912. package/src/palette/themePalette.ts +175 -0
  913. package/src/palette/types.ts +194 -0
  914. package/src/privateAttributes/mediaDarkPage.ts +27 -0
  915. package/src/privateAttributes/pressGroupItem.stylex.ts +2 -1
  916. package/src/privateAttributes/scheme.ts +37 -0
  917. package/src/privateAttributes/travelling.stylex.ts +6 -4
  918. package/src/reset.css +1 -1
  919. package/src/theme/MediaDarkPage.tsx +41 -0
  920. package/src/theme/MediaTheme.tsx +8 -1
  921. package/src/theme/Theme.doc.mjs +4 -4
  922. package/src/theme/Theme.tsx +140 -35
  923. package/src/theme/defineTheme.ts +103 -40
  924. package/src/theme/derivedVarRegistry.ts +61 -4
  925. package/src/theme/expandRadiusScale.ts +1 -5
  926. package/src/theme/generateThemeRules.ts +398 -342
  927. package/src/theme/index.ts +2 -4
  928. package/src/theme/invertedSurfaceSide.ts +65 -0
  929. package/src/theme/resolveThemeValues.ts +8 -2
  930. package/src/theme/statusRoleDefaults.ts +330 -0
  931. package/src/theme/statusRoleDerivation.ts +2 -1
  932. package/src/theme/syntax/SyntaxTheme.tsx +12 -0
  933. package/src/theme/themeAdaptations.ts +53 -5
  934. package/src/theme/tokenDefaults.ts +44 -0
  935. package/src/theme/tokenValues.ts +193 -0
  936. package/src/theme/tokens.stylex.ts +7 -5
  937. package/src/theme/tokens.ts +14 -176
  938. package/src/theme/useTheme.ts +164 -35
  939. package/src/utils/devWarning.ts +24 -0
  940. package/src/utils/focusOutline.stylex.ts +7 -4
  941. package/src/utils/focusReturn.ts +578 -16
  942. package/src/utils/hitArea.ts +70 -33
  943. package/src/utils/inputStream.ts +81 -5
  944. package/src/utils/nodeType.ts +10 -0
  945. package/src/utils/timeFormat.ts +54 -4
  946. package/src/utils/touchPresentation.stylex.ts +7 -6
  947. package/src/utils/touchPresentation.ts +10 -7
  948. package/src/utils/touchQueries.ts +3 -2
  949. package/src/utils/typeaheadMatch.ts +20 -1
  950. package/src/virtualization/useInlineListWindow.ts +57 -33
@@ -6,31 +6,41 @@
6
6
  * rideKeyboard and the shared animator
7
7
  * @output The keyboard targets: their registry, followKeyboard for a docked
8
8
  * or scrolling target, and keepFieldAboveKeyboard, a covered field's path.
9
- * Also followsKeyboard, the touch gate, and deliverTap, a tap's delivery
9
+ * Also followsKeyboard, the touch gate, and deliverTap, a tap's delivery.
10
+ * Each scroll a reveal makes goes back when the keyboard goes
10
11
  * @position Keyboard module, internal to core. useMobileKeyboard calls it.
11
12
  *
12
13
  * SYNC: When modified, update /packages/core/src/keyboard/README.md
13
14
  */
14
15
 
15
16
  import {animatorFor, type Animator} from '../motion/animator';
17
+ import {reducedMotionFade} from '../motion/reducedMotion';
16
18
  import {isCoarsePointer} from '../utils/coarsePointer';
17
- import {subscribeInput} from '../utils/inputStream';
19
+ import {getTouches, subscribeInput} from '../utils/inputStream';
18
20
  import {layoutViewportHeight} from '../utils/layoutViewport';
19
21
  import {nearestScroller, scrollingAncestor} from '../utils/scrollingAncestor';
20
22
  import {sharedWeakMap, sharedWeakSet} from '../utils/sharedRealm';
23
+ import {isIosWebKit} from '../utils/touchQueries';
21
24
  import {
22
25
  KEYBOARD_EPSILON,
23
26
  claimTapFocus,
24
27
  findTextEntryControl,
25
28
  focusAtPoint,
26
29
  getKeyboardHeight,
30
+ isFingerOnScreen,
27
31
  isKeyboardMeasurable,
28
32
  isTextEntryControl,
33
+ panVisualViewportTo,
29
34
  refuseFocusReveal,
30
35
  subscribeKeyboardHeight,
31
36
  watchRevealPan,
32
37
  } from './keyboardHeight';
33
- import {getKeyboardLayoutGuide, keyboardProfileOf} from './keyboardLayoutGuide';
38
+ import {
39
+ bringsUpKeyboard,
40
+ getKeyboardLayoutGuide,
41
+ hidesField,
42
+ keyboardProfileOf,
43
+ } from './keyboardLayoutGuide';
34
44
  import type {KeyboardTransition} from './keyboardModel';
35
45
  import {distanceIntoBand} from './revealBand';
36
46
  import {rideKeyboard} from './rideKeyboard';
@@ -47,6 +57,14 @@ export type KeyboardMove = 'reveal' | 'ride';
47
57
  */
48
58
  export const FIELD_OFFSET = 10;
49
59
 
60
+ /**
61
+ * Chrome on Android pans the page itself if the keyboard still covers the
62
+ * focused field about 100 to 170 ms after the report. A field a fraction of a
63
+ * pixel under the keyboard's top still counts as covered. So a show sets the
64
+ * field this far above that top at once, CSS px, and only the rest rides.
65
+ */
66
+ export const FIELD_CLEARANCE_AT_REPORT = 4;
67
+
50
68
  // Targets that keep their own fields above the keyboard. A field inside one
51
69
  // moves nothing itself, so nothing moves twice.
52
70
  const targets = sharedWeakSet<Element>('keyboard/keyboard-target/targets', 1);
@@ -328,61 +346,143 @@ function liftFor(
328
346
  return animator.get('y') < 0 ? targetCovered : 0;
329
347
  }
330
348
 
331
- // Scrolls `scroller` by `distance` px, up or down, at once. A smooth scroll
332
- // would leave the field covered when Chrome checks it.
333
- function scrollBy(scroller: Element, distance: number, win: Window): void {
349
+ function scrollBy(
350
+ scroller: Element,
351
+ distance: number,
352
+ win: Window,
353
+ behavior: ScrollBehavior = 'instant',
354
+ ): void {
355
+ // An explicit 'instant' also overrides a scroller's own smooth
356
+ // `scroll-behavior`.
334
357
  const doc = scroller.ownerDocument;
335
358
  if (scroller === (doc.scrollingElement ?? doc.documentElement)) {
336
- win.scrollBy({top: distance, behavior: 'instant'});
359
+ win.scrollBy({top: distance, behavior});
360
+ } else if (typeof scroller.scrollBy === 'function') {
361
+ scroller.scrollBy({top: distance, behavior});
337
362
  } else {
338
363
  scroller.scrollTop += distance;
339
364
  }
340
365
  }
341
366
 
342
- // How far `field` sits outside the band it must be in. The band is inside its
343
- // scroller's box and the viewport, and `offset` above the keyboard while one
344
- // shows. A move not yet written shifts the field and its scroller by `shift`.
345
- function revealDistance(
346
- field: Element,
367
+ function scrollRangeOf(scroller: Element, win: Window): number {
368
+ const doc = scroller.ownerDocument;
369
+ const view =
370
+ scroller === (doc.scrollingElement ?? doc.documentElement)
371
+ ? layoutViewportHeight(win)
372
+ : scroller.clientHeight;
373
+ return Math.max(0, scroller.scrollHeight - view);
374
+ }
375
+
376
+ // Whether a reveal for a keyboard rises on the browser's smooth scroll. On
377
+ // iOS, the browser runs no reveal after Core takes the focus. Its first report
378
+ // comes as the keyboard starts to slide, so the field rises beside it. Chrome
379
+ // on Android checks the field in the resize's own commit, where a smooth
380
+ // scroll would leave it covered. There, and under Reduce Motion, the field
381
+ // moves at once.
382
+ function risesSmoothly(field: Element): boolean {
383
+ return (
384
+ isIosWebKit(field.ownerDocument.defaultView) &&
385
+ reducedMotionFade(field) == null
386
+ );
387
+ }
388
+
389
+ // The band a field must be in. It is inside its scroller's box and the
390
+ // viewport, and `offset` above the keyboard while one shows. A move not yet
391
+ // written shifts the scroller by `shift`.
392
+ function bandOf(
347
393
  scroller: Element,
348
394
  height: number,
349
395
  offset: number,
350
396
  win: Window,
351
397
  shift = 0,
352
- ): number {
353
- const doc = field.ownerDocument;
398
+ ): {top: number; bottom: number} {
399
+ const doc = scroller.ownerDocument;
354
400
  const keyboardTop = layoutViewportHeight(win) - height;
355
- let safeTop = 0;
356
- let safeBottom =
357
- height > KEYBOARD_EPSILON ? keyboardTop - offset : keyboardTop;
401
+ let top = 0;
402
+ let bottom = height > KEYBOARD_EPSILON ? keyboardTop - offset : keyboardTop;
358
403
  if (scroller !== (doc.scrollingElement ?? doc.documentElement)) {
359
404
  const box = scroller.getBoundingClientRect();
360
- safeTop = Math.max(safeTop, box.top + shift);
361
- safeBottom = Math.min(safeBottom, box.bottom + shift);
405
+ top = Math.max(top, box.top + shift);
406
+ bottom = Math.min(bottom, box.bottom + shift);
362
407
  }
408
+ return {top, bottom};
409
+ }
410
+
411
+ // How far `field` sits outside its band (see bandOf). A move not yet written
412
+ // shifts the field and its scroller by `shift`.
413
+ function revealDistance(
414
+ field: Element,
415
+ scroller: Element,
416
+ height: number,
417
+ offset: number,
418
+ win: Window,
419
+ shift = 0,
420
+ ): number {
421
+ const band = bandOf(scroller, height, offset, win, shift);
363
422
  const box = field.getBoundingClientRect();
364
423
  return distanceIntoBand(
365
424
  box.top + shift,
366
425
  box.bottom + shift,
367
- safeTop,
368
- safeBottom,
426
+ band.top,
427
+ band.bottom,
428
+ );
429
+ }
430
+
431
+ // Whether `field` lies wholly in its band. A band too short for the field
432
+ // holds none of it, as when a scroll area sits under the keyboard. A scroll of
433
+ // `scroller` not yet drawn moves the field by `fieldShift`.
434
+ function sitsInBand(
435
+ field: Element,
436
+ scroller: Element,
437
+ height: number,
438
+ offset: number,
439
+ win: Window,
440
+ fieldShift = 0,
441
+ ): boolean {
442
+ const band = bandOf(scroller, height, offset, win);
443
+ const box = field.getBoundingClientRect();
444
+ return (
445
+ box.top + fieldShift >= band.top - KEYBOARD_EPSILON &&
446
+ box.bottom + fieldShift <= band.bottom + KEYBOARD_EPSILON
369
447
  );
370
448
  }
371
449
 
372
450
  // Scrolls `field` into its band with its nearest scroller, the document
373
451
  // included. Nothing else moves: a scroller that cannot scroll far enough
374
- // leaves the rest of the field covered.
452
+ // leaves the rest of the field covered. A scroll for a keyboard goes back
453
+ // when the keyboard goes. Only a scroll that places the field rises (see
454
+ // risesSmoothly), unless `canRise` is false. Returns the part of the scroll
455
+ // not yet drawn.
375
456
  function reveal(
376
457
  field: Element,
377
458
  scroller: Element,
378
459
  height: number,
379
460
  offset: number,
380
461
  win: Window,
381
- ): void {
462
+ canRise = true,
463
+ ): number {
382
464
  const distance = revealDistance(field, scroller, height, offset, win);
383
- if (Math.abs(distance) > KEYBOARD_EPSILON) {
384
- scrollBy(scroller, distance, win);
465
+ if (Math.abs(distance) <= KEYBOARD_EPSILON) {
466
+ return 0;
385
467
  }
468
+ const now = scrollTopOf(scroller, win);
469
+ const target = Math.min(
470
+ Math.max(now + distance, 0),
471
+ scrollRangeOf(scroller, win),
472
+ );
473
+ const rises =
474
+ canRise &&
475
+ height > KEYBOARD_EPSILON &&
476
+ Math.abs(target - now - distance) <= KEYBOARD_EPSILON &&
477
+ sitsInBand(field, scroller, height, offset, win, -distance) &&
478
+ risesSmoothly(field);
479
+ // A rise still on its way extends Core's own scroll.
480
+ const before = keyboardScrollTarget(scroller, win) ?? now;
481
+ scrollBy(scroller, distance, win, rises ? 'smooth' : 'instant');
482
+ if (height > KEYBOARD_EPSILON) {
483
+ noteKeyboardScroll(scroller, before, win, rises ? target : undefined);
484
+ }
485
+ return rises ? target - scrollTopOf(scroller, win) : 0;
386
486
  }
387
487
 
388
488
  // Focuses the tapped field without the browser's reveal, then raises the
@@ -426,28 +526,86 @@ export function deliverTap(
426
526
  * Puts back a pan the browser makes on its own after a keyboard report. This
427
527
  * happens, for example, after a focus no claim saw: a script's `focus()` while
428
528
  * nothing has focus. The field sits in place already, so the pan only displaces
429
- * the page. Feed `report` each keyboard height the module reports; `owns`
430
- * says whether a focused element is one this watch keeps in place.
529
+ * the page. A pan made at the last height goes back at the next height's
530
+ * report. The caller's own pan is the new rest once reported (`expectPan`):
531
+ * its report comes after the call returns.
532
+ * Feed `report` each keyboard height the module reports; `owns` says whether a
533
+ * focused element is one this watch keeps in place. `documentScrollIsReveal`
534
+ * is watchRevealPan's option of that name.
431
535
  */
432
536
  export function watchPans(
433
537
  win: Window,
434
538
  owns: (focused: Element) => boolean,
435
- ): {report(height: number): void; stop(): void} {
436
- const watch = watchRevealPan(win, {owns});
539
+ documentScrollIsReveal = false,
540
+ ): {
541
+ report(height: number): void;
542
+ expectPan(top: number): void;
543
+ stop(): void;
544
+ } {
545
+ const watch = watchRevealPan(win, {owns, documentScrollIsReveal});
437
546
  let lastHeight = getKeyboardHeight(win);
547
+ let ownPanTop: number | null = null;
438
548
  return {
439
549
  report(height: number): void {
550
+ const top = win.visualViewport?.offsetTop ?? 0;
440
551
  if (height !== lastHeight) {
552
+ if (
553
+ ownPanTop == null &&
554
+ lastHeight > KEYBOARD_EPSILON &&
555
+ watch.isRevealPan(height)
556
+ ) {
557
+ watch.putBack();
558
+ }
441
559
  lastHeight = height;
442
560
  watch.report();
561
+ } else if (
562
+ ownPanTop != null &&
563
+ Math.abs(top - ownPanTop) <= KEYBOARD_EPSILON
564
+ ) {
565
+ ownPanTop = null;
566
+ watch.report();
443
567
  } else if (watch.isRevealPan(height)) {
444
568
  watch.putBack();
445
569
  }
446
570
  },
571
+ expectPan(top: number): void {
572
+ ownPanTop = top;
573
+ },
447
574
  stop: () => watch.stop(),
448
575
  };
449
576
  }
450
577
 
578
+ type PanWatch = ReturnType<typeof watchPans>;
579
+
580
+ // Pans the visual viewport until `field` sits `offset` above the keyboard,
581
+ // within the keyboard's room and never past the field's top. Returns whether
582
+ // the field is clear. In Safari a document scroll reaches that room first.
583
+ function panIntoView(
584
+ field: Element,
585
+ offset: number,
586
+ win: Window,
587
+ pans: PanWatch,
588
+ ): boolean {
589
+ const viewport = win.visualViewport;
590
+ if (viewport == null) {
591
+ return false;
592
+ }
593
+ const box = field.getBoundingClientRect();
594
+ const need = box.bottom + offset - (viewport.offsetTop + viewport.height);
595
+ if (need <= KEYBOARD_EPSILON) {
596
+ return true;
597
+ }
598
+ const room = layoutViewportHeight(win) - viewport.offsetTop - viewport.height;
599
+ const pan = Math.min(need, room, box.top - viewport.offsetTop);
600
+ if (pan <= KEYBOARD_EPSILON) {
601
+ return false;
602
+ }
603
+ const top = viewport.offsetTop + pan;
604
+ pans.expectPan(top);
605
+ panVisualViewportTo(win, top);
606
+ return pan >= need - KEYBOARD_EPSILON;
607
+ }
608
+
451
609
  function focusedFieldIn(target: Element): HTMLElement | null {
452
610
  const active = target.ownerDocument.activeElement;
453
611
  return active != null &&
@@ -496,6 +654,7 @@ export function followKeyboard(
496
654
  return () => {};
497
655
  }
498
656
  const unregister = registerKeyboardTarget(target);
657
+ const stopScrollBack = claimKeyboardScrollBack(win);
499
658
  const stopClaim = refuseFocusReveal(doc, {
500
659
  claim: destination =>
501
660
  destination instanceof win.HTMLElement &&
@@ -528,10 +687,16 @@ export function followKeyboard(
528
687
  stopMoving(true);
529
688
  stopTaps();
530
689
  stopClaim();
690
+ stopScrollBack();
531
691
  unregister();
532
692
  };
533
693
  }
534
694
 
695
+ // Who reveals a field its scroller cannot place. 'document': the document,
696
+ // then a pan. 'fixed': the same, with a scroll that moves nothing undone.
697
+ // 'keep': nobody, since the scroller holds every field it reveals.
698
+ type UnplacedField = 'document' | 'fixed' | 'keep';
699
+
535
700
  // Reveals the focused field `field()` returns through `scroller` when the
536
701
  // keyboard's height changes, now, and when focus moves into `region` with the
537
702
  // keyboard already up. Returns the call that stops it.
@@ -541,27 +706,90 @@ function revealWithKeyboard(
541
706
  scroller: Element,
542
707
  offset: number,
543
708
  win: Window,
709
+ unplaced: UnplacedField = 'keep',
544
710
  ): () => void {
711
+ // Unless `unplaced` is 'keep', a field its scroller leaves covered is
712
+ // revealed by the document, then by a pan where the document cannot reach.
713
+ const doc = scroller.ownerDocument;
714
+ const root = doc.scrollingElement ?? doc.documentElement;
715
+ let isPlaced = true;
716
+ // A long press focuses with the finger still down. The show's first reveal
717
+ // runs all the same.
718
+ let hasRevealed = false;
719
+ // The input stream's touch-start count at the last reveal. The press that
720
+ // focused the field started before it, so it holds no report. Gboard can
721
+ // report a 48 px keyboard first, then its full height, while that press is
722
+ // still down.
723
+ let startsAtReveal = 0;
545
724
  const revealNow = (height: number) => {
546
725
  const focused = field();
547
- if (focused != null) {
548
- reveal(focused, scroller, height, offset, win);
726
+ if (focused == null) {
727
+ return;
728
+ }
729
+ hasRevealed = height > KEYBOARD_EPSILON;
730
+ startsAtReveal = getTouches(win).starts;
731
+ const rising = reveal(focused, scroller, height, offset, win);
732
+ if (unplaced === 'keep') {
733
+ return;
734
+ }
735
+ isPlaced =
736
+ rising !== 0 || sitsInBand(focused, scroller, height, offset, win);
737
+ if (isPlaced || height <= KEYBOARD_EPSILON) {
738
+ return;
549
739
  }
740
+ if (unplaced === 'document') {
741
+ if (
742
+ scroller !== root &&
743
+ reveal(focused, root, height, offset, win) !== 0
744
+ ) {
745
+ isPlaced = true;
746
+ return;
747
+ }
748
+ } else {
749
+ // Safari runs no reveal after Core takes the focus. Its document scroll
750
+ // moves a fixed container too, as a visual-viewport offset while its
751
+ // keyboard shows. Where the scroll moves nothing, Core scrolls back.
752
+ const top = focused.getBoundingClientRect().top;
753
+ const scrollY = win.scrollY;
754
+ reveal(focused, root, height, offset, win, false);
755
+ if (
756
+ Math.abs(focused.getBoundingClientRect().top - top) <= KEYBOARD_EPSILON
757
+ ) {
758
+ const scrolled = win.scrollY - scrollY;
759
+ if (scrolled !== 0) {
760
+ const before = win.scrollY;
761
+ win.scrollBy({top: -scrolled, behavior: 'instant'});
762
+ noteKeyboardScroll(root, before, win);
763
+ }
764
+ }
765
+ }
766
+ // Chrome scrolls the document only within its range. The pan takes the
767
+ // rest at once, so Chrome's own pan finds the field clear.
768
+ isPlaced = panIntoView(focused, offset, win, pans);
550
769
  };
551
- const pans = watchPans(win, focused => focused === field());
552
- // A report within a pixel of the last height comes from a pan, a scroll or
553
- // a zoom's rounding. The field stays where the person put it.
770
+ const pans = watchPans(win, focused => focused === field() && isPlaced);
771
+ // A report within a pixel of the last height is a pan, a scroll or a
772
+ // zoom's rounding, so the field stays. After the show's first reveal, a
773
+ // report during a press that began after that reveal moves nothing, as
774
+ // when Firefox's toolbar hides in a drag.
554
775
  let lastHeight = getKeyboardHeight(win);
776
+ const isLaterPressDown = () =>
777
+ isFingerOnScreen(win) && getTouches(win).starts !== startsAtReveal;
555
778
  const stopReports = subscribeKeyboardHeight(win, event => {
556
779
  if (event.type === 'viewport') {
557
780
  if (Math.abs(event.height - lastHeight) > KEYBOARD_EPSILON) {
558
781
  lastHeight = event.height;
559
- revealNow(event.height);
782
+ if (!hasRevealed || !isLaterPressDown()) {
783
+ revealNow(event.height);
784
+ }
560
785
  }
561
786
  pans.report(event.height);
562
787
  }
563
788
  });
564
- const onFocusIn = () => revealNow(getKeyboardHeight(win));
789
+ const onFocusIn = () => {
790
+ stopKeyboardScrollBack(win);
791
+ revealNow(getKeyboardHeight(win));
792
+ };
565
793
  region.addEventListener('focusin', onFocusIn);
566
794
  revealNow(getKeyboardHeight(win));
567
795
  return () => {
@@ -625,6 +853,27 @@ function fieldLift(
625
853
  return Math.min(need, overlap);
626
854
  }
627
855
 
856
+ // The move that sets the focused field in `target` FIELD_CLEARANCE_AT_REPORT
857
+ // px above a keyboard `height` px tall, or null with no field to clear.
858
+ function clearanceAtReport(
859
+ target: HTMLElement,
860
+ animator: Animator,
861
+ height: number,
862
+ win: Window,
863
+ ): number | null {
864
+ const field = focusedFieldIn(target);
865
+ if (field == null) {
866
+ return null;
867
+ }
868
+ const need = coveredBy(
869
+ restingBottom(field, animator),
870
+ height,
871
+ FIELD_CLEARANCE_AT_REPORT,
872
+ win,
873
+ );
874
+ return need > 0 ? -need : null;
875
+ }
876
+
628
877
  // The ride that moves each target. A new ride on the same target takes over,
629
878
  // whether the old one still rides or waits for the keyboard to go. So two never
630
879
  // move one target, and the one taken over never moves it again.
@@ -655,7 +904,13 @@ function rideWithKeyboard(
655
904
  let state: 'riding' | 'waiting' | 'ended' = 'riding';
656
905
  let stopReports: (() => void) | null = null;
657
906
  let stopGuide: (() => void) | null = null;
658
- const pans = watchPans(win, focused => target.contains(focused));
907
+ // The guide runs only in Chrome, whose own reveal of a field in the target
908
+ // also scrolls the page behind it.
909
+ const pans = watchPans(
910
+ win,
911
+ focused => target.contains(focused),
912
+ guide != null,
913
+ );
659
914
  let frame = 0;
660
915
  let pendingSlide: KeyboardTransition | null = null;
661
916
  const end = () => {
@@ -712,6 +967,15 @@ function rideWithKeyboard(
712
967
  if (transition == null) {
713
968
  animator.set({y});
714
969
  } else {
970
+ // On a show, the field is set just above the keyboard's top at once,
971
+ // so Chrome's own pan finds it clear. Only the rest rides.
972
+ const atReport =
973
+ transition.kind === 'show'
974
+ ? clearanceAtReport(target, animator, height, win)
975
+ : null;
976
+ if (atReport != null && y < atReport && atReport < animator.get('y')) {
977
+ animator.set({y: atReport});
978
+ }
715
979
  rideKeyboard(animator, {y}, transition);
716
980
  }
717
981
  }
@@ -739,15 +1003,18 @@ function rideWithKeyboard(
739
1003
  place(next?.to ?? guide?.inset ?? getKeyboardHeight(win), next);
740
1004
  });
741
1005
  };
742
- if (guide != null) {
743
- stopGuide = guide.subscribe(placeOnNextFrame);
744
- } else {
745
- stopReports = subscribeKeyboardHeight(win, event => {
746
- if (event.type === 'viewport') {
1006
+ // Every viewport report feeds the pan watch, so a pan the browser still
1007
+ // makes is put back. Without the guide, the report also places the target.
1008
+ stopReports = subscribeKeyboardHeight(win, event => {
1009
+ if (event.type === 'viewport') {
1010
+ if (guide == null) {
747
1011
  placeOnNextFrame(null);
748
- pans.report(event.height);
749
1012
  }
750
- });
1013
+ pans.report(event.height);
1014
+ }
1015
+ });
1016
+ if (guide != null) {
1017
+ stopGuide = guide.subscribe(placeOnNextFrame);
751
1018
  }
752
1019
  // A field gaining focus with the keyboard up places the target. A blur to
753
1020
  // nothing waits for the keyboard's own report or slide, so the target rides
@@ -777,61 +1044,87 @@ export interface KeepFieldAboveKeyboardOptions {
777
1044
  offset?: number;
778
1045
  }
779
1046
 
1047
+ // Whether `scroller`, in a fixed container the app positions, can bring
1048
+ // `field` into its band. It must scroll the field up to the scroller's own
1049
+ // top, since a scroller does not gain the range it lacks at its end yet. With
1050
+ // the keyboard up, its box must also leave the field room above the keyboard.
1051
+ function canBringUp(
1052
+ field: Element,
1053
+ scroller: Element,
1054
+ offset: number,
1055
+ win: Window,
1056
+ ): boolean {
1057
+ const range =
1058
+ scroller.scrollHeight - scroller.clientHeight - scroller.scrollTop;
1059
+ const box = field.getBoundingClientRect();
1060
+ if (
1061
+ range <
1062
+ box.top - scroller.getBoundingClientRect().top - KEYBOARD_EPSILON
1063
+ ) {
1064
+ return false;
1065
+ }
1066
+ const height = getKeyboardHeight(win);
1067
+ if (height <= KEYBOARD_EPSILON) {
1068
+ return true;
1069
+ }
1070
+ const band = bandOf(scroller, height, offset, win);
1071
+ return band.bottom - band.top >= box.height - KEYBOARD_EPSILON;
1072
+ }
1073
+
780
1074
  // The placement of `field` when it gains focus. A docked container rides.
781
- // Page content, or a fixed container the app positions, reveals the field
782
- // through a scroller. Null keeps the browser's reveal: inside a keyboard
783
- // target, or with no such scroller.
1075
+ // Page content reveals the field through its nearest scroller. A fixed
1076
+ // container the app positions reveals it through a scroller in it that can
1077
+ // bring it up. Null keeps the browser's reveal: inside a keyboard target, on a
1078
+ // page with nothing to scroll, or with no such scroller.
784
1079
  function placementOf(
785
1080
  field: HTMLElement,
786
- ): {ride: HTMLElement} | {reveal: Element} | null {
1081
+ offset: number,
1082
+ win: Window,
1083
+ ): {ride: HTMLElement} | {reveal: Element; unplaced: UnplacedField} | null {
787
1084
  if (isInsideKeyboardTarget(field)) {
788
1085
  return null;
789
1086
  }
790
1087
  const container = fixedContainerOf(field);
791
1088
  if (container === 'floating' || container === 'fills-viewport') {
792
- return revealWithin(field, nearestFixedAncestor(field));
1089
+ return revealWithin(field, nearestFixedAncestor(field), offset, win);
793
1090
  }
794
1091
  if (container == null) {
795
1092
  // A page with nothing to scroll keeps the browser's own reveal: a claim
796
- // there would leave the field under the keyboard.
1093
+ // there would leave the field under the keyboard in Safari.
797
1094
  const scroller = nearestScroller(field);
1095
+ // In the page, the document reveals a field its scroll area cannot place.
798
1096
  return scroller.scrollHeight > scroller.clientHeight
799
- ? {reveal: scroller}
1097
+ ? {reveal: scroller, unplaced: 'document'}
800
1098
  : null;
801
1099
  }
802
1100
  // A bar the app positions with its own `translate` does not ride: the ride
803
1101
  // would replace that translate.
804
1102
  const view = field.ownerDocument.defaultView;
805
1103
  return view != null && hasOwnTranslate(container.docked, view)
806
- ? revealWithin(field, container.docked)
1104
+ ? revealWithin(field, container.docked, offset, win)
807
1105
  : {ride: container.docked};
808
1106
  }
809
1107
 
810
1108
  // A reveal by the scroller between `field` and the fixed `container` the app
811
- // positions, or null when no scroller sits between them.
1109
+ // positions, or null when no scroller there can bring the field up.
812
1110
  function revealWithin(
813
1111
  field: HTMLElement,
814
1112
  container: HTMLElement | null,
815
- ): {reveal: Element} | null {
1113
+ offset: number,
1114
+ win: Window,
1115
+ ): {reveal: Element; unplaced: UnplacedField} | null {
816
1116
  const scroller =
817
1117
  container == null ? null : scrollingAncestor(field, container);
818
- return scroller == null ? null : {reveal: scroller};
1118
+ return scroller == null || !canBringUp(field, scroller, offset, win)
1119
+ ? null
1120
+ : {reveal: scroller, unplaced: 'fixed'};
819
1121
  }
820
1122
 
821
1123
  /**
822
- * A field's own path until the returned call. When the field gains focus, it
823
- * decides where it is. Docked at the viewport's bottom, its fixed container
824
- * moves up by the part of it the keyboard still covers. In scrolling content,
825
- * its nearest scroller, the document included, brings it into view, above the
826
- * keyboard while one shows. A docked container taller than the room above the
827
- * keyboard never rides its whole overlap. Its scroller there brings the field
828
- * up instead, and with none it rides only as far as the field needs. A fixed
829
- * container the app positions fills the viewport, floats above the bottom edge,
830
- * or sets its own `translate`. In one, a scroller between the field and the
831
- * container brings it up. A focus move or a tap into the field arrives without
832
- * the browser's reveal there, so the page never pans for it. Inside a keyboard
833
- * target, or in such a container with no scroller around the field, the path
834
- * does nothing and the browser's own reveal stays.
1124
+ * Keeps `field` above the on-screen keyboard until the returned call. On focus,
1125
+ * `placementOf` decides who moves it. A claimed focus move or tap arrives
1126
+ * without the browser's reveal. Where no placement fits, the browser's own
1127
+ * reveal stays.
835
1128
  *
836
1129
  * @example
837
1130
  * ```
@@ -847,14 +1140,19 @@ export function keepFieldAboveKeyboard(
847
1140
  if (!followsKeyboard(win)) {
848
1141
  return () => {};
849
1142
  }
1143
+ const stopScrollBack = claimKeyboardScrollBack(win);
850
1144
  const stopClaim = refuseFocusReveal(doc, {
851
1145
  claim: destination =>
852
- destination === field && placementOf(field) != null ? field : null,
1146
+ destination === field && placementOf(field, offset, win) != null
1147
+ ? field
1148
+ : null,
853
1149
  });
854
1150
  // A first tap moves focus from nothing, so no blur claims it.
855
1151
  const stopTaps = claimTapFocus(field, {
856
1152
  claim: () =>
857
- doc.activeElement !== field && placementOf(field) != null ? field : null,
1153
+ doc.activeElement !== field && placementOf(field, offset, win) != null
1154
+ ? field
1155
+ : null,
858
1156
  deliver: deliverTap,
859
1157
  });
860
1158
  let stopSession: ((isFinal?: boolean) => void) | null = null;
@@ -866,10 +1164,11 @@ export function keepFieldAboveKeyboard(
866
1164
  if (stopSession != null) {
867
1165
  return;
868
1166
  }
869
- const placement = placementOf(field);
1167
+ const placement = placementOf(field, offset, win);
870
1168
  if (placement == null) {
871
1169
  return;
872
1170
  }
1171
+ stopKeyboardScrollBack(win);
873
1172
  stopSession =
874
1173
  'ride' in placement
875
1174
  ? rideWithKeyboard(placement.ride, offset, win, false)
@@ -879,6 +1178,7 @@ export function keepFieldAboveKeyboard(
879
1178
  placement.reveal,
880
1179
  offset,
881
1180
  win,
1181
+ placement.unplaced,
882
1182
  );
883
1183
  };
884
1184
  const onBlur = () => {
@@ -888,6 +1188,11 @@ export function keepFieldAboveKeyboard(
888
1188
  };
889
1189
  field.addEventListener('focus', onFocus);
890
1190
  field.addEventListener('blur', onBlur);
1191
+ // A field that has focus before this path attaches, as with `hasAutoFocus`,
1192
+ // gets no later focus event. Its session starts here.
1193
+ if (doc.activeElement === field) {
1194
+ onFocus();
1195
+ }
891
1196
  return () => {
892
1197
  field.removeEventListener('focus', onFocus);
893
1198
  field.removeEventListener('blur', onBlur);
@@ -897,5 +1202,296 @@ export function keepFieldAboveKeyboard(
897
1202
  stoppedSession = null;
898
1203
  stopTaps();
899
1204
  stopClaim();
1205
+ stopScrollBack();
900
1206
  };
901
1207
  }
1208
+
1209
+ // The scroll back: each scroll Core makes for the keyboard goes back when the
1210
+ // keyboard goes.
1211
+
1212
+ interface AddedScroll {
1213
+ /** Where the scroller was before Core's first scroll. */
1214
+ from: number;
1215
+ /** Where Core left it, or null once anyone else scrolled it. */
1216
+ at: number | null;
1217
+ /** Whether the scroll back runs from the blur, so the report moves nothing. */
1218
+ isBack: boolean;
1219
+ }
1220
+
1221
+ // Every copy of Core shares these stores, so one scroll back runs per page.
1222
+ const addedScrolls = sharedWeakMap<Window, Map<Element, AddedScroll>>(
1223
+ 'keyboard/keyboard-target/scroll-back-added-scrolls',
1224
+ 1,
1225
+ );
1226
+ const stopsOf = sharedWeakMap<Window, () => void>(
1227
+ 'keyboard/keyboard-target/scroll-back-stops',
1228
+ 1,
1229
+ );
1230
+ const foldWaitsOf = sharedWeakMap<Window, () => void>(
1231
+ 'keyboard/keyboard-target/scroll-back-fold-waits',
1232
+ 1,
1233
+ );
1234
+ const claimants = sharedWeakMap<Window, number>(
1235
+ 'keyboard/keyboard-target/scroll-back-claimants',
1236
+ 1,
1237
+ );
1238
+
1239
+ /**
1240
+ * Counts a field that keeps itself above `win`'s keyboard until the returned
1241
+ * call. Once no such field is left, nothing is put back: its page is gone.
1242
+ */
1243
+ function claimKeyboardScrollBack(win: Window): () => void {
1244
+ claimants.set(win, (claimants.get(win) ?? 0) + 1);
1245
+ let isClaimed = true;
1246
+ return () => {
1247
+ if (!isClaimed) {
1248
+ return;
1249
+ }
1250
+ isClaimed = false;
1251
+ const left = (claimants.get(win) ?? 1) - 1;
1252
+ claimants.set(win, left);
1253
+ if (left === 0) {
1254
+ stopsOf.get(win)?.();
1255
+ foldWaitsOf.get(win)?.();
1256
+ }
1257
+ };
1258
+ }
1259
+
1260
+ function isRoot(scroller: Element): boolean {
1261
+ const doc = scroller.ownerDocument;
1262
+ return scroller === (doc.scrollingElement ?? doc.documentElement);
1263
+ }
1264
+
1265
+ /** How far `scroller` is scrolled; for the root, the document's scroll. */
1266
+ function scrollTopOf(scroller: Element, win: Window): number {
1267
+ return isRoot(scroller) ? win.scrollY : scroller.scrollTop;
1268
+ }
1269
+
1270
+ function scrollTopTo(
1271
+ scroller: Element,
1272
+ top: number,
1273
+ behavior: ScrollBehavior,
1274
+ win: Window,
1275
+ ): void {
1276
+ if (isRoot(scroller)) {
1277
+ win.scrollTo({top, behavior});
1278
+ } else if (typeof scroller.scrollTo === 'function') {
1279
+ scroller.scrollTo({top, behavior});
1280
+ } else {
1281
+ scroller.scrollTop = top;
1282
+ }
1283
+ }
1284
+
1285
+ /**
1286
+ * Records that Core scrolled `scroller` from `before` to `after`, to keep a
1287
+ * field above the keyboard. `after` is where a smooth scroll is headed, and
1288
+ * where the scroller is now for any other. When the keyboard goes, the
1289
+ * scroller goes back to where it was before Core's first scroll. A scroller
1290
+ * anyone else scrolls meanwhile keeps that scroll.
1291
+ */
1292
+ function noteKeyboardScroll(
1293
+ scroller: Element,
1294
+ before: number,
1295
+ win: Window,
1296
+ after = scrollTopOf(scroller, win),
1297
+ ): void {
1298
+ const now = after;
1299
+ const added = addedScrolls.get(win)?.get(scroller);
1300
+ if (added == null) {
1301
+ if (Math.abs(now - before) >= 0.5) {
1302
+ const scrolls = addedScrolls.get(win) ?? watchKeyboardGo(win);
1303
+ scrolls.set(scroller, {from: before, at: now, isBack: false});
1304
+ }
1305
+ } else if (
1306
+ added.at != null &&
1307
+ Math.abs(before - added.at) <= KEYBOARD_EPSILON
1308
+ ) {
1309
+ added.at = now;
1310
+ } else {
1311
+ added.at = null;
1312
+ }
1313
+ }
1314
+
1315
+ /**
1316
+ * Where Core's own scroll of `scroller` is headed, while the scroller lies on
1317
+ * its way there, as during a smooth rise. Null for a scroller Core did not
1318
+ * scroll, or one moved off that way.
1319
+ */
1320
+ function keyboardScrollTarget(scroller: Element, win: Window): number | null {
1321
+ const added = addedScrolls.get(win)?.get(scroller);
1322
+ if (added?.at == null) {
1323
+ return null;
1324
+ }
1325
+ const now = scrollTopOf(scroller, win);
1326
+ const low = Math.min(added.from, added.at) - KEYBOARD_EPSILON;
1327
+ const high = Math.max(added.from, added.at) + KEYBOARD_EPSILON;
1328
+ return now >= low && now <= high ? added.at : null;
1329
+ }
1330
+
1331
+ // The scroll back starts at the keyboard's report that it has gone. Safari on
1332
+ // iOS sends that report about half a second after the blur that closes the
1333
+ // keyboard, once the keyboard is down. There the scroll back starts at that
1334
+ // blur, beside the keyboard's slide, and the report ends the watch.
1335
+ function watchKeyboardGo(win: Window): Map<Element, AddedScroll> {
1336
+ const scrolls = new Map<Element, AddedScroll>();
1337
+ const stopReports = subscribeKeyboardHeight(win, event => {
1338
+ if (event.type === 'viewport' && event.height <= KEYBOARD_EPSILON) {
1339
+ end();
1340
+ scrollBack(win, scrolls);
1341
+ }
1342
+ });
1343
+ let settle: number | null = null;
1344
+ const stopBlurs = isIosWebKit(win.document.defaultView) ? watchBlurs() : [];
1345
+ function watchBlurs(): (() => void)[] {
1346
+ return [
1347
+ // Heard so the stream counts the fingers on the screen.
1348
+ subscribeInput(win, 'touchstart', () => {}),
1349
+ subscribeInput(win, 'touchend', () => {}),
1350
+ subscribeInput(win, 'touchcancel', () => {}),
1351
+ subscribeInput(win, 'focusout', () => {
1352
+ if (settle != null) {
1353
+ win.clearTimeout(settle);
1354
+ }
1355
+ // Focus lands after the event. A field, or a frame or a shadow root
1356
+ // that may hold one, then keeps the keyboard up. A finger on the
1357
+ // screen can be a tap that brings it back, so the report decides.
1358
+ settle = win.setTimeout(() => {
1359
+ settle = null;
1360
+ const active = win.document.activeElement;
1361
+ if (
1362
+ getTouches(win).fingers === 0 &&
1363
+ (active == null ||
1364
+ (!bringsUpKeyboard(active) && !hidesField(active)))
1365
+ ) {
1366
+ scrollBackAtBlur(win, scrolls);
1367
+ }
1368
+ }, 0);
1369
+ }),
1370
+ ];
1371
+ }
1372
+ function end() {
1373
+ stopReports();
1374
+ for (const stop of stopBlurs) {
1375
+ stop();
1376
+ }
1377
+ if (settle != null) {
1378
+ win.clearTimeout(settle);
1379
+ settle = null;
1380
+ }
1381
+ addedScrolls.delete(win);
1382
+ stopsOf.delete(win);
1383
+ }
1384
+ addedScrolls.set(win, scrolls);
1385
+ stopsOf.set(win, end);
1386
+ return scrolls;
1387
+ }
1388
+
1389
+ // Each scroller Core left where it put it heads back now, on the browser's
1390
+ // own smooth scroll. A focus that brings the keyboard back stops it first
1391
+ // (stopKeyboardScrollBack). Under Reduce Motion, the scroll waits for the
1392
+ // report and lands at once.
1393
+ function scrollBackAtBlur(
1394
+ win: Window,
1395
+ scrolls: Map<Element, AddedScroll>,
1396
+ ): void {
1397
+ for (const [scroller, added] of scrolls) {
1398
+ if (
1399
+ added.at == null ||
1400
+ reducedMotionFade(scroller) != null ||
1401
+ Math.abs(scrollTopOf(scroller, win) - added.at) > KEYBOARD_EPSILON
1402
+ ) {
1403
+ continue;
1404
+ }
1405
+ added.at = added.from;
1406
+ added.isBack = true;
1407
+ scrollTopTo(scroller, added.from, 'smooth', win);
1408
+ }
1409
+ }
1410
+
1411
+ /**
1412
+ * Stops a scroll back that runs from the blur, where each scroller is now. A
1413
+ * field that gains focus during the keyboard's slide calls it before its
1414
+ * reveal, so the reveal goes on from there as Core's own scroll. The instant
1415
+ * scroll also ends a scroll back that a touch held, which Safari would run
1416
+ * after the field is placed.
1417
+ */
1418
+ function stopKeyboardScrollBack(win: Window): void {
1419
+ for (const [scroller, added] of addedScrolls.get(win) ?? []) {
1420
+ if (!added.isBack) {
1421
+ continue;
1422
+ }
1423
+ const top = scrollTopOf(scroller, win);
1424
+ scrollTopTo(scroller, top, 'instant', win);
1425
+ added.at = top;
1426
+ added.isBack = false;
1427
+ }
1428
+ }
1429
+
1430
+ // The browser's own smooth scroll carries the scroll back. iOS Safari applies
1431
+ // a scripted scroll a frame late, so a scroll set each frame jitters there. A
1432
+ // touch stops that scroll, so a person's scroll stands. Under Reduce Motion, or
1433
+ // in a theme that reduces motion for everyone, the scroll lands at once.
1434
+ function scrollBack(win: Window, scrolls: Map<Element, AddedScroll>): void {
1435
+ for (const [scroller, {from, at, isBack}] of scrolls) {
1436
+ if (at == null || isBack || !scroller.isConnected) {
1437
+ continue;
1438
+ }
1439
+ const top = scrollTopOf(scroller, win);
1440
+ if (Math.abs(top - at) <= KEYBOARD_EPSILON) {
1441
+ scrollTopTo(scroller, from, scrollBackBehavior(scroller), win);
1442
+ } else if (isRoot(scroller) && Math.abs(top - from) <= KEYBOARD_EPSILON) {
1443
+ awaitFoldedReveal(win, scroller, from, at);
1444
+ }
1445
+ }
1446
+ scrolls.clear();
1447
+ }
1448
+
1449
+ function scrollBackBehavior(scroller: Element): ScrollBehavior {
1450
+ return reducedMotionFade(scroller) == null ? 'smooth' : 'instant';
1451
+ }
1452
+
1453
+ // Firefox for Android can carry the reveal's document scroll as a visual-
1454
+ // viewport offset. It then shows the document where it was before the
1455
+ // reveal, and turns the offset back into a document scroll after the hide
1456
+ // report. The scroll back waits for that one document scroll.
1457
+ const FOLD_WAIT_MS = 1000;
1458
+
1459
+ // The first document scroll decides: one that lands where Core left the
1460
+ // document is the browser's own, and the scroll back follows it. A touch, a
1461
+ // keyboard that comes back, the field's page going, or the wait's end puts
1462
+ // nothing back.
1463
+ function awaitFoldedReveal(
1464
+ win: Window,
1465
+ scroller: Element,
1466
+ from: number,
1467
+ at: number,
1468
+ ): void {
1469
+ const doc = win.document;
1470
+ const stopScroll = subscribeInput(win, 'scroll', event => {
1471
+ if (event.target !== doc && event.target !== win) {
1472
+ return;
1473
+ }
1474
+ stop();
1475
+ if (Math.abs(scrollTopOf(scroller, win) - at) <= KEYBOARD_EPSILON) {
1476
+ scrollTopTo(scroller, from, scrollBackBehavior(scroller), win);
1477
+ }
1478
+ });
1479
+ const stopTouch = subscribeInput(win, 'touchstart', () => stop());
1480
+ const stopKeyboard = subscribeKeyboardHeight(win, event => {
1481
+ if (event.type === 'viewport' && event.height > KEYBOARD_EPSILON) {
1482
+ stop();
1483
+ }
1484
+ });
1485
+ const timer = win.setTimeout(stop, FOLD_WAIT_MS);
1486
+ foldWaitsOf.get(win)?.();
1487
+ foldWaitsOf.set(win, stop);
1488
+ function stop() {
1489
+ win.clearTimeout(timer);
1490
+ stopScroll();
1491
+ stopTouch();
1492
+ stopKeyboard();
1493
+ if (foldWaitsOf.get(win) === stop) {
1494
+ foldWaitsOf.delete(win);
1495
+ }
1496
+ }
1497
+ }