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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (454) hide show
  1. package/dist/AppShell/AppShell.d.ts.map +1 -1
  2. package/dist/AppShell/AppShell.js +183 -5
  3. package/dist/AppShell/observeMainOverflow.d.ts +9 -0
  4. package/dist/AppShell/observeMainOverflow.d.ts.map +1 -0
  5. package/dist/AppShell/observeMainOverflow.js +125 -0
  6. package/dist/Carousel/Carousel.d.ts +3 -1
  7. package/dist/Carousel/Carousel.d.ts.map +1 -1
  8. package/dist/Carousel/Carousel.js +12 -3
  9. package/dist/ComplexSelector/ComplexSelector.d.ts.map +1 -1
  10. package/dist/ComplexSelector/ComplexSelector.js +41 -4
  11. package/dist/DateInput/Wheel.d.ts.map +1 -1
  12. package/dist/DateInput/Wheel.js +11 -7
  13. package/dist/DateInput/usePointerDragScroll.d.ts +10 -1
  14. package/dist/DateInput/usePointerDragScroll.d.ts.map +1 -1
  15. package/dist/DateInput/usePointerDragScroll.js +25 -9
  16. package/dist/DateInput/useScrollSettle.d.ts +3 -1
  17. package/dist/DateInput/useScrollSettle.d.ts.map +1 -1
  18. package/dist/DateInput/useScrollSettle.js +37 -8
  19. package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
  20. package/dist/DropdownMenu/DropdownMenu.js +28 -19
  21. package/dist/Item/Item.d.ts.map +1 -1
  22. package/dist/Item/Item.js +19 -6
  23. package/dist/Layer/useLayer.d.ts.map +1 -1
  24. package/dist/Layer/useLayer.js +27 -6
  25. package/dist/Link/Link.d.ts.map +1 -1
  26. package/dist/Link/Link.js +8 -3
  27. package/dist/Markdown/plugins/headingLinks.a11y.chromium.spec.js +1 -1
  28. package/dist/NavMenu/NavHeadingMenuItem.d.ts.map +1 -1
  29. package/dist/NavMenu/NavHeadingMenuItem.js +5 -29
  30. package/dist/NumberInput/NumberInput.d.ts.map +1 -1
  31. package/dist/NumberInput/NumberInput.js +23 -2
  32. package/dist/Outline/Outline.d.ts.map +1 -1
  33. package/dist/Outline/Outline.js +27 -0
  34. package/dist/Popover/Popover.d.ts.map +1 -1
  35. package/dist/Popover/Popover.js +32 -12
  36. package/dist/Popover/usePopover.d.ts.map +1 -1
  37. package/dist/Popover/usePopover.js +10 -3
  38. package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
  39. package/dist/PowerSearch/PowerSearch.js +37 -30
  40. package/dist/RadioList/RadioListItem.d.ts.map +1 -1
  41. package/dist/RadioList/RadioListItem.js +11 -3
  42. package/dist/SideNav/SideNavItem.d.ts +2 -2
  43. package/dist/SideNav/SideNavItem.d.ts.map +1 -1
  44. package/dist/SideNav/SideNavItem.js +18 -7
  45. package/dist/Skeleton/Skeleton.d.ts.map +1 -1
  46. package/dist/Skeleton/Skeleton.js +1 -1
  47. package/dist/Spinner/Spinner.d.ts.map +1 -1
  48. package/dist/Spinner/Spinner.js +1 -1
  49. package/dist/Stepper/Step.d.ts.map +1 -1
  50. package/dist/Stepper/Step.js +26 -6
  51. package/dist/Switch/Switch.d.ts.map +1 -1
  52. package/dist/Switch/Switch.js +10 -3
  53. package/dist/Table/Table.d.ts.map +1 -1
  54. package/dist/Table/Table.js +36 -10
  55. package/dist/Table/plugins/sortable/useTableSortable.d.ts.map +1 -1
  56. package/dist/Table/plugins/sortable/useTableSortable.js +46 -58
  57. package/dist/Toast/ToastViewport.d.ts.map +1 -1
  58. package/dist/Toast/ToastViewport.js +19 -3
  59. package/dist/ToggleButton/ToggleButtonGroup.d.ts +7 -1
  60. package/dist/ToggleButton/ToggleButtonGroup.d.ts.map +1 -1
  61. package/dist/ToggleButton/ToggleButtonGroup.js +16 -2
  62. package/dist/Token/Token.d.ts.map +1 -1
  63. package/dist/Token/Token.js +37 -5
  64. package/dist/Token/TokenLink.d.ts.map +1 -1
  65. package/dist/Token/TokenLink.js +14 -2
  66. package/dist/Tokenizer/Tokenizer.d.ts.map +1 -1
  67. package/dist/Tokenizer/Tokenizer.js +15 -4
  68. package/dist/Tokenizer/TokenizerClearAllMessageContext.d.ts +2 -0
  69. package/dist/Tokenizer/TokenizerClearAllMessageContext.d.ts.map +1 -0
  70. package/dist/Tokenizer/TokenizerClearAllMessageContext.js +17 -0
  71. package/dist/TreeList/TreeListItem.d.ts.map +1 -1
  72. package/dist/TreeList/TreeListItem.js +27 -4
  73. package/dist/Typeahead/BaseTypeahead.d.ts +4 -4
  74. package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
  75. package/dist/Typeahead/BaseTypeahead.js +43 -7
  76. package/dist/astryx.css +10 -3
  77. package/dist/gestures/GestureArena.d.ts +26 -1
  78. package/dist/gestures/GestureArena.d.ts.map +1 -1
  79. package/dist/gestures/GestureArena.js +71 -9
  80. package/dist/gestures/GestureHost.d.ts +2 -3
  81. package/dist/gestures/GestureHost.d.ts.map +1 -1
  82. package/dist/gestures/GestureHost.js +7 -7
  83. package/dist/gestures/GestureRecognizer.d.ts +3 -1
  84. package/dist/gestures/GestureRecognizer.d.ts.map +1 -1
  85. package/dist/gestures/GestureRecognizer.js +3 -1
  86. package/dist/gestures/PressTracker.d.ts +112 -0
  87. package/dist/gestures/PressTracker.d.ts.map +1 -0
  88. package/dist/gestures/PressTracker.js +267 -0
  89. package/dist/gestures/index.d.ts +37 -0
  90. package/dist/gestures/index.d.ts.map +1 -0
  91. package/dist/gestures/index.js +25 -0
  92. package/dist/gestures/useGestureRecognizer.d.ts +56 -0
  93. package/dist/gestures/useGestureRecognizer.d.ts.map +1 -0
  94. package/dist/gestures/useGestureRecognizer.js +226 -0
  95. package/dist/hooks/scrollKeyboardDelegation.d.ts.map +1 -1
  96. package/dist/hooks/scrollKeyboardDelegation.js +7 -3
  97. package/dist/hooks/useScrollOverflow.d.ts +2 -1
  98. package/dist/hooks/useScrollOverflow.d.ts.map +1 -1
  99. package/dist/hooks/useScrollOverflow.js +56 -10
  100. package/dist/i18n/generated-locales/af-ZA.generated.d.ts.map +1 -1
  101. package/dist/i18n/generated-locales/af-ZA.generated.js +0 -5
  102. package/dist/i18n/generated-locales/ar-SA.generated.d.ts.map +1 -1
  103. package/dist/i18n/generated-locales/ar-SA.generated.js +0 -5
  104. package/dist/i18n/generated-locales/ca-ES.generated.d.ts.map +1 -1
  105. package/dist/i18n/generated-locales/ca-ES.generated.js +0 -5
  106. package/dist/i18n/generated-locales/cs-CZ.generated.d.ts.map +1 -1
  107. package/dist/i18n/generated-locales/cs-CZ.generated.js +0 -5
  108. package/dist/i18n/generated-locales/da-DK.generated.d.ts.map +1 -1
  109. package/dist/i18n/generated-locales/da-DK.generated.js +0 -5
  110. package/dist/i18n/generated-locales/de-DE.generated.d.ts.map +1 -1
  111. package/dist/i18n/generated-locales/de-DE.generated.js +0 -5
  112. package/dist/i18n/generated-locales/el-GR.generated.d.ts.map +1 -1
  113. package/dist/i18n/generated-locales/el-GR.generated.js +0 -5
  114. package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
  115. package/dist/i18n/generated-locales/en.generated.js +3 -5
  116. package/dist/i18n/generated-locales/es-ES.generated.d.ts.map +1 -1
  117. package/dist/i18n/generated-locales/es-ES.generated.js +0 -5
  118. package/dist/i18n/generated-locales/fi-FI.generated.d.ts.map +1 -1
  119. package/dist/i18n/generated-locales/fi-FI.generated.js +0 -5
  120. package/dist/i18n/generated-locales/fr-FR.generated.d.ts.map +1 -1
  121. package/dist/i18n/generated-locales/fr-FR.generated.js +0 -5
  122. package/dist/i18n/generated-locales/he-IL.generated.d.ts.map +1 -1
  123. package/dist/i18n/generated-locales/he-IL.generated.js +0 -5
  124. package/dist/i18n/generated-locales/hu-HU.generated.d.ts.map +1 -1
  125. package/dist/i18n/generated-locales/hu-HU.generated.js +0 -5
  126. package/dist/i18n/generated-locales/it-IT.generated.d.ts.map +1 -1
  127. package/dist/i18n/generated-locales/it-IT.generated.js +0 -5
  128. package/dist/i18n/generated-locales/ja-JP.generated.d.ts.map +1 -1
  129. package/dist/i18n/generated-locales/ja-JP.generated.js +0 -5
  130. package/dist/i18n/generated-locales/ko-KR.generated.d.ts.map +1 -1
  131. package/dist/i18n/generated-locales/ko-KR.generated.js +0 -5
  132. package/dist/i18n/generated-locales/nl-NL.generated.d.ts.map +1 -1
  133. package/dist/i18n/generated-locales/nl-NL.generated.js +0 -5
  134. package/dist/i18n/generated-locales/no-NO.generated.d.ts.map +1 -1
  135. package/dist/i18n/generated-locales/no-NO.generated.js +0 -5
  136. package/dist/i18n/generated-locales/pl-PL.generated.d.ts.map +1 -1
  137. package/dist/i18n/generated-locales/pl-PL.generated.js +0 -5
  138. package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
  139. package/dist/i18n/generated-locales/pseudo.generated.js +3 -5
  140. package/dist/i18n/generated-locales/pt-BR.generated.d.ts.map +1 -1
  141. package/dist/i18n/generated-locales/pt-BR.generated.js +0 -5
  142. package/dist/i18n/generated-locales/pt-PT.generated.d.ts.map +1 -1
  143. package/dist/i18n/generated-locales/pt-PT.generated.js +0 -5
  144. package/dist/i18n/generated-locales/ro-RO.generated.d.ts.map +1 -1
  145. package/dist/i18n/generated-locales/ro-RO.generated.js +0 -5
  146. package/dist/i18n/generated-locales/ru-RU.generated.d.ts.map +1 -1
  147. package/dist/i18n/generated-locales/ru-RU.generated.js +0 -5
  148. package/dist/i18n/generated-locales/sr-SP.generated.d.ts.map +1 -1
  149. package/dist/i18n/generated-locales/sr-SP.generated.js +0 -5
  150. package/dist/i18n/generated-locales/sv-SE.generated.d.ts.map +1 -1
  151. package/dist/i18n/generated-locales/sv-SE.generated.js +0 -5
  152. package/dist/i18n/generated-locales/tr-TR.generated.d.ts.map +1 -1
  153. package/dist/i18n/generated-locales/tr-TR.generated.js +0 -5
  154. package/dist/i18n/generated-locales/uk-UA.generated.d.ts.map +1 -1
  155. package/dist/i18n/generated-locales/uk-UA.generated.js +0 -5
  156. package/dist/i18n/generated-locales/vi-VN.generated.d.ts.map +1 -1
  157. package/dist/i18n/generated-locales/vi-VN.generated.js +0 -5
  158. package/dist/i18n/generated-locales/zh-CN.generated.d.ts.map +1 -1
  159. package/dist/i18n/generated-locales/zh-CN.generated.js +0 -5
  160. package/dist/i18n/generated-locales/zh-TW.generated.d.ts.map +1 -1
  161. package/dist/i18n/generated-locales/zh-TW.generated.js +0 -5
  162. package/dist/motion/animator.d.ts +76 -7
  163. package/dist/motion/animator.d.ts.map +1 -1
  164. package/dist/motion/animator.js +589 -99
  165. package/dist/motion/coast.d.ts +4 -1
  166. package/dist/motion/coast.d.ts.map +1 -1
  167. package/dist/motion/coast.js +4 -2
  168. package/dist/motion/reducedMotion.d.ts.map +1 -1
  169. package/dist/motion/reducedMotion.js +6 -2
  170. package/dist/motion/reducedMotionPlan.d.ts +7 -0
  171. package/dist/motion/reducedMotionPlan.d.ts.map +1 -1
  172. package/dist/motion/reducedMotionPlan.js +14 -1
  173. package/dist/motion/resolveMotion.d.ts +42 -0
  174. package/dist/motion/resolveMotion.d.ts.map +1 -0
  175. package/dist/motion/resolveMotion.js +43 -0
  176. package/dist/motion/roleValue.d.ts +2 -1
  177. package/dist/motion/roleValue.d.ts.map +1 -1
  178. package/dist/motion/roleValue.js +2 -1
  179. package/dist/motion/uikit/timing.d.ts +7 -1
  180. package/dist/motion/uikit/timing.d.ts.map +1 -1
  181. package/dist/motion/uikit/timing.js +19 -1
  182. package/dist/theme/defineTheme.d.ts +19 -5
  183. package/dist/theme/defineTheme.d.ts.map +1 -1
  184. package/dist/theme/defineTheme.js +63 -3
  185. package/dist/theme/index.d.ts +1 -0
  186. package/dist/theme/index.d.ts.map +1 -1
  187. package/dist/theme/motionKnobs.d.ts +56 -0
  188. package/dist/theme/motionKnobs.d.ts.map +1 -0
  189. package/dist/theme/motionKnobs.js +48 -0
  190. package/dist/theme/resolveThemeValues.d.ts +11 -4
  191. package/dist/theme/resolveThemeValues.d.ts.map +1 -1
  192. package/dist/theme/resolveThemeValues.js +40 -4
  193. package/dist/theme/themeAdaptations.d.ts +7 -3
  194. package/dist/theme/themeAdaptations.d.ts.map +1 -1
  195. package/dist/theme/themeAdaptations.js +36 -7
  196. package/dist/theme/themeMotion.d.ts +96 -0
  197. package/dist/theme/themeMotion.d.ts.map +1 -0
  198. package/dist/theme/themeMotion.js +177 -0
  199. package/dist/theme/tokenReferences.d.ts +31 -0
  200. package/dist/theme/tokenReferences.d.ts.map +1 -0
  201. package/dist/theme/tokenReferences.js +132 -0
  202. package/dist/theme/tokens.d.ts +1 -0
  203. package/dist/theme/tokens.d.ts.map +1 -1
  204. package/dist/theme/tokens.js +9 -129
  205. package/dist/theme/tokens.stylex.d.ts +12 -0
  206. package/dist/theme/tokens.stylex.d.ts.map +1 -1
  207. package/dist/theme/tokens.stylex.js +12 -0
  208. package/dist/utils/focusOutline.stylex.d.ts +6 -0
  209. package/dist/utils/focusOutline.stylex.d.ts.map +1 -1
  210. package/dist/utils/focusOutline.stylex.js +7 -0
  211. package/dist/utils/interactionOverlay.stylex.d.ts.map +1 -1
  212. package/dist/utils/interactionOverlay.stylex.js +17 -8
  213. package/dist/utils/pressFeedback.d.ts.map +1 -1
  214. package/dist/utils/pressFeedback.js +20 -1
  215. package/dist/utils/sharedMutationObserver.d.ts +19 -11
  216. package/dist/utils/sharedMutationObserver.d.ts.map +1 -1
  217. package/dist/utils/sharedMutationObserver.js +66 -26
  218. package/dist/utils/touchPresentation.d.ts +2 -2
  219. package/dist/utils/touchPresentation.d.ts.map +1 -1
  220. package/dist/utils/touchPresentation.js +8 -5
  221. package/dist/utils/touchQueries.d.ts +13 -0
  222. package/dist/utils/touchQueries.d.ts.map +1 -0
  223. package/dist/utils/touchQueries.js +15 -0
  224. package/dist/utils/useFocusAcrossSwap.d.ts +19 -0
  225. package/dist/utils/useFocusAcrossSwap.d.ts.map +1 -0
  226. package/dist/utils/useFocusAcrossSwap.js +41 -0
  227. package/locales/af-ZA.json +0 -21
  228. package/locales/ar-SA.json +0 -21
  229. package/locales/ca-ES.json +0 -21
  230. package/locales/cs-CZ.json +0 -21
  231. package/locales/da-DK.json +0 -21
  232. package/locales/de-DE.json +0 -21
  233. package/locales/el-GR.json +0 -21
  234. package/locales/en.json +12 -20
  235. package/locales/es-ES.json +0 -21
  236. package/locales/fi-FI.json +0 -21
  237. package/locales/fr-FR.json +0 -21
  238. package/locales/he-IL.json +0 -21
  239. package/locales/hu-HU.json +0 -21
  240. package/locales/it-IT.json +0 -21
  241. package/locales/ja-JP.json +0 -21
  242. package/locales/ko-KR.json +0 -21
  243. package/locales/nl-NL.json +0 -21
  244. package/locales/no-NO.json +0 -21
  245. package/locales/pl-PL.json +0 -21
  246. package/locales/pseudo.json +8 -14
  247. package/locales/pt-BR.json +0 -21
  248. package/locales/pt-PT.json +0 -21
  249. package/locales/ro-RO.json +0 -21
  250. package/locales/ru-RU.json +0 -21
  251. package/locales/sr-SP.json +0 -21
  252. package/locales/sv-SE.json +0 -21
  253. package/locales/tr-TR.json +0 -21
  254. package/locales/uk-UA.json +0 -21
  255. package/locales/vi-VN.json +0 -21
  256. package/locales/zh-CN.json +0 -21
  257. package/locales/zh-TW.json +0 -21
  258. package/package.json +4 -4
  259. package/src/AppShell/AppShell.doc.mjs +1 -1
  260. package/src/AppShell/AppShell.spec.md +9 -12
  261. package/src/AppShell/AppShell.test.tsx +164 -2
  262. package/src/AppShell/AppShell.tsx +225 -5
  263. package/src/AppShell/__tests__/AppShellMainKeyboard.a11y.browser.spec.ts +534 -0
  264. package/src/AppShell/observeMainOverflow.test.ts +173 -0
  265. package/src/AppShell/observeMainOverflow.ts +143 -0
  266. package/src/Carousel/Carousel.doc.mjs +1 -1
  267. package/src/Carousel/Carousel.spec.md +9 -9
  268. package/src/Carousel/Carousel.test.tsx +124 -3
  269. package/src/Carousel/Carousel.tsx +10 -2
  270. package/src/Carousel/__tests__/Carousel.a11y.known-failures.ts +1 -16
  271. package/src/Chat/ChatComposer.spec.md +75 -59
  272. package/src/Chat/ChatComposerTokenElement.spec.md +45 -33
  273. package/src/Chat/ChatDictationButton.spec.md +126 -81
  274. package/src/Chat/ChatLayout.spec.md +41 -36
  275. package/src/Chat/ChatLayoutScrollButton.spec.md +87 -103
  276. package/src/Chat/ChatSendButton.spec.md +78 -67
  277. package/src/CodeBlock/__tests__/CodeBlockCopyClearance.a11y.chromium.spec.ts +38 -3
  278. package/src/ComplexSelector/ComplexSelector.test.tsx +111 -0
  279. package/src/ComplexSelector/ComplexSelector.tsx +41 -4
  280. package/src/ContextMenu/ContextMenu.spec.md +84 -56
  281. package/src/ContextMenu/ContextMenuItem.spec.md +132 -0
  282. package/src/DateInput/DateInputTouch.test.tsx +44 -0
  283. package/src/DateInput/Wheel.tsx +9 -6
  284. package/src/DateInput/usePointerDragScroll.ts +34 -10
  285. package/src/DateInput/useScrollSettle.ts +38 -7
  286. package/src/DropdownMenu/DropdownMenu.spec.md +198 -218
  287. package/src/DropdownMenu/DropdownMenu.test.tsx +117 -0
  288. package/src/DropdownMenu/DropdownMenu.tsx +33 -18
  289. package/src/DropdownMenu/DropdownMenuCheckboxItem.spec.md +192 -0
  290. package/src/DropdownMenu/DropdownMenuDivider.spec.md +25 -31
  291. package/src/DropdownMenu/DropdownMenuGroup.spec.md +145 -0
  292. package/src/DropdownMenu/DropdownMenuItem.spec.md +48 -42
  293. package/src/DropdownMenu/DropdownMenuRadioGroup.spec.md +34 -37
  294. package/src/DropdownMenu/DropdownMenuRadioItem.spec.md +54 -53
  295. package/src/DropdownMenu/DropdownMenuSubMenu.spec.md +47 -41
  296. package/src/EmptyState/EmptyState.spec.md +35 -29
  297. package/src/Item/Item.test.tsx +60 -0
  298. package/src/Item/Item.tsx +14 -7
  299. package/src/Layer/useLayer.test.tsx +78 -3
  300. package/src/Layer/useLayer.tsx +27 -6
  301. package/src/Link/Link.spec.md +3 -2
  302. package/src/Link/Link.tsx +11 -0
  303. package/src/Link/__tests__/Link.truncation.a11y.chromium.spec.ts +58 -0
  304. package/src/Markdown/plugins/headingLinks.a11y.chromium.spec.ts +1 -1
  305. package/src/NavMenu/NavHeadingMenuItem.tsx +5 -39
  306. package/src/NumberInput/NumberInput.test.tsx +68 -7
  307. package/src/NumberInput/NumberInput.tsx +31 -1
  308. package/src/Outline/Outline.spec.md +165 -69
  309. package/src/Outline/Outline.test.tsx +67 -2
  310. package/src/Outline/Outline.tsx +23 -0
  311. package/src/Outline/modules/parseOutlineFromMarkdown.spec.md +3 -4
  312. package/src/OverflowList/OverflowList.spec.md +102 -55
  313. package/src/Pagination/Pagination.spec.md +158 -84
  314. package/src/Popover/Popover.test.tsx +84 -0
  315. package/src/Popover/Popover.tsx +34 -14
  316. package/src/Popover/__tests__/PopoverSecondDocument.a11y.chromium.spec.ts +70 -8
  317. package/src/Popover/usePopover.tsx +10 -3
  318. package/src/PowerSearch/PowerSearch.test.tsx +24 -0
  319. package/src/PowerSearch/PowerSearch.tsx +42 -31
  320. package/src/RadioList/RadioList.spec.md +1 -1
  321. package/src/RadioList/RadioList.test.tsx +84 -0
  322. package/src/RadioList/RadioListItem.tsx +11 -2
  323. package/src/Resizable/Resizable.spec.md +144 -124
  324. package/src/SideNav/SideNav.test.tsx +124 -4
  325. package/src/SideNav/SideNavItem.spec.md +14 -24
  326. package/src/SideNav/SideNavItem.tsx +27 -10
  327. package/src/Skeleton/Skeleton.tsx +3 -1
  328. package/src/Spinner/Spinner.tsx +3 -1
  329. package/src/Stepper/Step.spec.md +36 -42
  330. package/src/Stepper/Step.tsx +33 -6
  331. package/src/Stepper/Stepper.doc.mjs +1 -1
  332. package/src/Stepper/Stepper.test.tsx +69 -7
  333. package/src/Switch/Switch.spec.md +1 -1
  334. package/src/Switch/Switch.test.tsx +66 -1
  335. package/src/Switch/Switch.tsx +11 -3
  336. package/src/Table/Table.spec.md +1 -1
  337. package/src/Table/Table.test.tsx +32 -0
  338. package/src/Table/Table.tsx +43 -11
  339. package/src/Table/__tests__/Table.a11y.states.ts +1 -5
  340. package/src/Table/plugins/sortable/useTableSortable.test.tsx +73 -144
  341. package/src/Table/plugins/sortable/useTableSortable.tsx +44 -73
  342. package/src/Table/plugins/sortable/useTableSortableState.test.tsx +9 -21
  343. package/src/TimeInput/TimeInput.spec.md +13 -13
  344. package/src/Toast/Toast.spec.md +2 -5
  345. package/src/Toast/ToastViewport.test.tsx +79 -0
  346. package/src/Toast/ToastViewport.tsx +21 -3
  347. package/src/ToggleButton/ToggleButton.test.tsx +27 -0
  348. package/src/ToggleButton/ToggleButtonGroup.tsx +20 -1
  349. package/src/Token/Token.doc.mjs +2 -2
  350. package/src/Token/Token.spec.md +41 -51
  351. package/src/Token/Token.test.tsx +67 -0
  352. package/src/Token/Token.tsx +60 -5
  353. package/src/Token/TokenLink.tsx +21 -7
  354. package/src/Tokenizer/Tokenizer.spec.md +13 -1
  355. package/src/Tokenizer/Tokenizer.test.tsx +27 -0
  356. package/src/Tokenizer/Tokenizer.tsx +24 -10
  357. package/src/Tokenizer/TokenizerBottomSheet.test.tsx +8 -0
  358. package/src/Tokenizer/TokenizerClearAllMessageContext.ts +21 -0
  359. package/src/TreeList/TreeList.test.tsx +26 -0
  360. package/src/TreeList/TreeListItem.tsx +26 -4
  361. package/src/Typeahead/BaseTypeahead.doc.mjs +3 -3
  362. package/src/Typeahead/BaseTypeahead.spec.md +45 -45
  363. package/src/Typeahead/BaseTypeahead.tsx +48 -9
  364. package/src/Typeahead/Typeahead.test.tsx +120 -0
  365. package/src/__tests__/internalModulesNotExperimental.test.ts +88 -0
  366. package/src/__tests__/pressState.ts +8 -4
  367. package/src/gestures/GestureArena.ts +76 -11
  368. package/src/gestures/GestureHost.ts +6 -7
  369. package/src/gestures/GestureRecognizer.ts +3 -1
  370. package/src/gestures/PressTracker.ts +386 -0
  371. package/src/gestures/README.md +420 -0
  372. package/src/gestures/__tests__/GestureHost.test.ts +50 -1
  373. package/src/gestures/__tests__/PressTracker.test.ts +275 -0
  374. package/src/gestures/__tests__/arena.test.ts +35 -0
  375. package/src/gestures/__tests__/harness.ts +31 -2
  376. package/src/gestures/__tests__/pressTrackerFactory.test.ts +59 -0
  377. package/src/gestures/__tests__/useGestureRecognizer.test.tsx +570 -0
  378. package/src/gestures/index.ts +79 -0
  379. package/src/gestures/useGestureRecognizer.ts +305 -0
  380. package/src/hooks/scrollKeyboardDelegation.test.ts +33 -0
  381. package/src/hooks/scrollKeyboardDelegation.ts +9 -3
  382. package/src/hooks/useScrollOverflow.doc.mjs +1 -1
  383. package/src/hooks/useScrollOverflow.test.tsx +102 -1
  384. package/src/hooks/useScrollOverflow.ts +59 -10
  385. package/src/i18n/generated-locales/af-ZA.generated.ts +0 -7
  386. package/src/i18n/generated-locales/ar-SA.generated.ts +0 -6
  387. package/src/i18n/generated-locales/ca-ES.generated.ts +0 -7
  388. package/src/i18n/generated-locales/cs-CZ.generated.ts +0 -6
  389. package/src/i18n/generated-locales/da-DK.generated.ts +0 -6
  390. package/src/i18n/generated-locales/de-DE.generated.ts +0 -6
  391. package/src/i18n/generated-locales/el-GR.generated.ts +0 -7
  392. package/src/i18n/generated-locales/en.generated.ts +3 -6
  393. package/src/i18n/generated-locales/es-ES.generated.ts +0 -7
  394. package/src/i18n/generated-locales/fi-FI.generated.ts +0 -6
  395. package/src/i18n/generated-locales/fr-FR.generated.ts +0 -7
  396. package/src/i18n/generated-locales/he-IL.generated.ts +0 -6
  397. package/src/i18n/generated-locales/hu-HU.generated.ts +0 -6
  398. package/src/i18n/generated-locales/it-IT.generated.ts +0 -7
  399. package/src/i18n/generated-locales/ja-JP.generated.ts +0 -6
  400. package/src/i18n/generated-locales/ko-KR.generated.ts +0 -6
  401. package/src/i18n/generated-locales/nl-NL.generated.ts +0 -6
  402. package/src/i18n/generated-locales/no-NO.generated.ts +0 -6
  403. package/src/i18n/generated-locales/pl-PL.generated.ts +0 -7
  404. package/src/i18n/generated-locales/pseudo.generated.ts +3 -6
  405. package/src/i18n/generated-locales/pt-BR.generated.ts +0 -7
  406. package/src/i18n/generated-locales/pt-PT.generated.ts +0 -7
  407. package/src/i18n/generated-locales/ro-RO.generated.ts +0 -6
  408. package/src/i18n/generated-locales/ru-RU.generated.ts +0 -7
  409. package/src/i18n/generated-locales/sr-SP.generated.ts +0 -6
  410. package/src/i18n/generated-locales/sv-SE.generated.ts +0 -6
  411. package/src/i18n/generated-locales/tr-TR.generated.ts +0 -7
  412. package/src/i18n/generated-locales/uk-UA.generated.ts +0 -7
  413. package/src/i18n/generated-locales/vi-VN.generated.ts +0 -6
  414. package/src/i18n/generated-locales/zh-CN.generated.ts +0 -6
  415. package/src/i18n/generated-locales/zh-TW.generated.ts +0 -6
  416. package/src/motion/MEASUREMENTS.md +2 -1
  417. package/src/motion/README.md +102 -32
  418. package/src/motion/__tests__/animator.interaction.browser.spec.ts +843 -0
  419. package/src/motion/__tests__/motionBundle.ts +14 -0
  420. package/src/motion/animator.test.ts +978 -33
  421. package/src/motion/animator.ts +790 -104
  422. package/src/motion/coast.ts +10 -3
  423. package/src/motion/reducedMotion.ts +12 -2
  424. package/src/motion/reducedMotionPlan.test.ts +26 -0
  425. package/src/motion/reducedMotionPlan.ts +20 -1
  426. package/src/motion/resolveMotion.test.ts +123 -0
  427. package/src/motion/resolveMotion.ts +68 -0
  428. package/src/motion/roleValue.ts +2 -1
  429. package/src/motion/roles.test.ts +21 -4
  430. package/src/motion/uikit/tableImports.test.ts +293 -0
  431. package/src/motion/uikit/timing.ts +15 -1
  432. package/src/motion/uikit/values.test.ts +23 -12
  433. package/src/theme/Theme.doc.mjs +1 -1
  434. package/src/theme/defineTheme.ts +116 -7
  435. package/src/theme/expandMotionScale.test.ts +1 -1
  436. package/src/theme/index.ts +5 -0
  437. package/src/theme/motionKnobs.ts +82 -0
  438. package/src/theme/resolveThemeValues.ts +68 -6
  439. package/src/theme/themeAdaptations.ts +52 -12
  440. package/src/theme/themeMotion.test.ts +620 -0
  441. package/src/theme/themeMotion.ts +221 -0
  442. package/src/theme/tokenReferences.ts +149 -0
  443. package/src/theme/tokens.stylex.ts +10 -0
  444. package/src/theme/tokens.ts +15 -158
  445. package/src/utils/focusOutline.stylex.ts +28 -0
  446. package/src/utils/interactionOverlay.stylex.ts +12 -3
  447. package/src/utils/pressFeedback.test.ts +138 -0
  448. package/src/utils/pressFeedback.ts +34 -11
  449. package/src/utils/pressGesture.test.ts +9 -0
  450. package/src/utils/sharedMutationObserver.test.ts +54 -1
  451. package/src/utils/sharedMutationObserver.ts +87 -29
  452. package/src/utils/touchPresentation.ts +8 -5
  453. package/src/utils/touchQueries.ts +15 -0
  454. package/src/utils/useFocusAcrossSwap.ts +55 -0
@@ -0,0 +1,305 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ /**
6
+ * @file useGestureRecognizer.ts
7
+ * @input An element ref, a recognizer factory and a gesture listener; or an
8
+ * element ref and press tracker options
9
+ * @output Exports useGestureRecognizer and usePressTracker
10
+ * @position React face of packages/core/src/gestures
11
+ *
12
+ * The recognizer is created once and keeps its identity for the life of the
13
+ * component, so relationships set up at creation (`requireToFail`,
14
+ * `recognizeSimultaneouslyWith`) hold. The listener is read through a ref:
15
+ * passing a new function each render re-attaches nothing, and a gesture
16
+ * costs no React render at all — the listener runs inside the input event
17
+ * and writes to the DOM itself. The recognizer attaches in a layout effect,
18
+ * so its `touch-action` is in place before the browser can see a finger.
19
+ *
20
+ * SYNC: When modified, update useGestureRecognizer.test.tsx and README.md.
21
+ */
22
+
23
+ import {useEffect, useMemo, useRef, useState, type RefObject} from 'react';
24
+ import {useIsomorphicLayoutEffect} from '../hooks/useIsomorphicLayoutEffect';
25
+ import {getGestureHost} from './GestureHost';
26
+ import type {GestureRecognizer} from './GestureRecognizer';
27
+ import {
28
+ createPressTracker,
29
+ vetoesSingleTap,
30
+ type PressTracker,
31
+ type PressTrackerOptions,
32
+ } from './PressTracker';
33
+
34
+ export interface UseGestureRecognizerOptions {
35
+ /**
36
+ * Live toggle; turning it off mid-gesture cancels the gesture. That cancel
37
+ * does not call `onGesture`: it comes from the render that turned the
38
+ * recognizer off, and the code that turned it off already knows.
39
+ * @default true
40
+ */
41
+ isEnabled?: boolean;
42
+ /** Let the host set touch-action (and long-press callout) styles. @default true */
43
+ manageStyle?: boolean;
44
+ }
45
+
46
+ /**
47
+ * How many Effects are driving the gesture system right now (an `isEnabled`
48
+ * sync, a detach, a press tracker's release or host update). While one runs
49
+ * no hook calls its caller back (react-component-runtime INV2, INV3): the
50
+ * recognizer it stops is cancelled silently, and what that stop unblocks (a
51
+ * recognizer that required it to fail) resolves in the arena's next pass, a
52
+ * microtask later, where its listener reports as usual
53
+ * (`deferringResolution`).
54
+ */
55
+ let effectDepth = 0;
56
+
57
+ /** Runs `drive` as an Effect's work on the gesture system (see effectDepth). */
58
+ function driveFromEffect(drive: () => void): void {
59
+ effectDepth += 1;
60
+ try {
61
+ drive();
62
+ } finally {
63
+ effectDepth -= 1;
64
+ }
65
+ }
66
+
67
+ /**
68
+ * Runs `body`, which stops `recognizer` from an Effect, with its arena leaving
69
+ * what the stop unblocks to a pass a microtask later
70
+ * (GestureArena.deferResolution): a recognizer that required the stopped one
71
+ * to fail recognizes there, outside the Effect, and its listener reports as
72
+ * usual. A recognizer that has met no touch has no arena, and nothing waits on
73
+ * it.
74
+ */
75
+ function deferringResolution(
76
+ recognizer: GestureRecognizer,
77
+ body: () => void,
78
+ ): void {
79
+ const arena = recognizer.arena;
80
+ if (arena == null) {
81
+ body();
82
+ return;
83
+ }
84
+ arena.deferResolution(body);
85
+ }
86
+
87
+ /**
88
+ * Attach a recognizer to the element behind `ref`.
89
+ *
90
+ * @example
91
+ * ```
92
+ * const pan = useGestureRecognizer(
93
+ * ref,
94
+ * () => new PanGestureRecognizer({direction: 'vertical'}),
95
+ * recognizer => {
96
+ * ref.current.style.transform = `translateY(${recognizer.translation().y}px)`;
97
+ * },
98
+ * );
99
+ * ```
100
+ */
101
+ export function useGestureRecognizer<R extends GestureRecognizer>(
102
+ ref: RefObject<Element | null>,
103
+ create: () => R,
104
+ onGesture?: (recognizer: R) => void,
105
+ options: UseGestureRecognizerOptions = {},
106
+ ): R {
107
+ const [recognizer] = useState(create);
108
+ const onGestureRef = useRef(onGesture);
109
+ useIsomorphicLayoutEffect(() => {
110
+ onGestureRef.current = onGesture;
111
+ });
112
+ const {isEnabled = true, manageStyle = true} = options;
113
+
114
+ // Syncs the recognizer's target-action listeners with the caller's
115
+ // callback (read through a ref, so a new function re-subscribes nothing).
116
+ useEffect(
117
+ () =>
118
+ recognizer.addListener(current => {
119
+ if (effectDepth === 0) {
120
+ onGestureRef.current?.(current);
121
+ }
122
+ }),
123
+ [recognizer],
124
+ );
125
+
126
+ // Syncs the recognizer's `isEnabled` (UIKit's). It runs first, so disabling
127
+ // cancels a gesture in flight before its attachment goes, and that cancel,
128
+ // with whatever it settles in the arena, reaches no caller callback.
129
+ useIsomorphicLayoutEffect(() => {
130
+ driveFromEffect(() =>
131
+ deferringResolution(recognizer, () => recognizer.setEnabled(isEnabled)),
132
+ );
133
+ }, [recognizer, isEnabled]);
134
+
135
+ // Syncs the document's gesture host with the element behind `ref`: attached
136
+ // while enabled, re-attached when the node is replaced. A disabled gesture
137
+ // is not attached at all: no listener and no `touch-action` of its own on
138
+ // the element (spec:AST-094 FR24). Detaching (an unmount, a replaced node)
139
+ // cancels a gesture in flight, and that cancel, run in an Effect, reaches
140
+ // no caller callback (react-component-runtime INV2).
141
+ useNodeAttachment(
142
+ ref,
143
+ element => {
144
+ if (!isEnabled) {
145
+ return null;
146
+ }
147
+ const detach = getGestureHost(element.ownerDocument).attach(
148
+ element,
149
+ recognizer,
150
+ {manageStyle},
151
+ );
152
+ return () =>
153
+ driveFromEffect(() => deferringResolution(recognizer, detach));
154
+ },
155
+ [recognizer, manageStyle, isEnabled],
156
+ );
157
+
158
+ return recognizer;
159
+ }
160
+
161
+ export type UsePressTrackerOptions = Omit<
162
+ PressTrackerOptions,
163
+ 'getBounds' | 'view'
164
+ >;
165
+
166
+ /**
167
+ * Track presses on the element behind `ref` with UIControl semantics. The
168
+ * callbacks are read through a ref, like a recognizer's listener. Releasing
169
+ * the element (unmount, or a replaced node) ends any press without calling
170
+ * them: that release runs in an Effect, which never calls a caller's
171
+ * callback (react-component-runtime INV2, INV3).
172
+ */
173
+ export function usePressTracker(
174
+ ref: RefObject<Element | null>,
175
+ options: UsePressTrackerOptions = {},
176
+ ): PressTracker {
177
+ const optionsRef = useRef(options);
178
+ useIsomorphicLayoutEffect(() => {
179
+ optionsRef.current = options;
180
+ });
181
+ const {trackingExpansion, highlightDelay, cancelTravel, quickTapFlash} =
182
+ options;
183
+ // The tracker reads these four when it is built: a change rebuilds it (the
184
+ // attachment below moves to the new one and disposes the old), and the new
185
+ // values apply from the next touch. The callbacks, the brake included, are
186
+ // read through the ref on every touch.
187
+ const tracker = useMemo(
188
+ () =>
189
+ createPressTracker({
190
+ getBounds: () => ref.current?.getBoundingClientRect() ?? null,
191
+ get view() {
192
+ return ref.current;
193
+ },
194
+ onControlEvent: (event, touch) => {
195
+ if (effectDepth === 0) {
196
+ optionsRef.current.onControlEvent?.(event, touch);
197
+ }
198
+ },
199
+ onHighlightChange: isHighlighted => {
200
+ if (effectDepth === 0) {
201
+ optionsRef.current.onHighlightChange?.(isHighlighted);
202
+ }
203
+ },
204
+ trackingExpansion,
205
+ highlightDelay,
206
+ cancelTravel,
207
+ quickTapFlash,
208
+ // The caller's veto, read on every touch, else the tracker's own.
209
+ vetoesAncestorRecognizer: recognizer =>
210
+ (optionsRef.current.vetoesAncestorRecognizer ?? vetoesSingleTap)(
211
+ recognizer,
212
+ ),
213
+ isEnabled: () => optionsRef.current.isEnabled?.() ?? true,
214
+ // A finger that brakes a scroll it set moving presses nothing
215
+ // (GestureHost.isScrollBraking), unless the caller decides; the tracker
216
+ // asks only for a finger (spec:AST-094 FR11).
217
+ isBraking: touch => {
218
+ const element = ref.current;
219
+ return (
220
+ optionsRef.current.isBraking?.(touch) ??
221
+ (element != null &&
222
+ getGestureHost(element.ownerDocument).isScrollBraking(element))
223
+ );
224
+ },
225
+ }),
226
+ [ref, trackingExpansion, highlightDelay, cancelTravel, quickTapFlash],
227
+ );
228
+
229
+ // Syncs the document's gesture host with the element behind `ref`: the
230
+ // tracker is its press consumer, moved when the node is replaced, and a
231
+ // press in progress ends with it.
232
+ useNodeAttachment(
233
+ ref,
234
+ element => {
235
+ const detach = getGestureHost(element.ownerDocument).attachConsumer(
236
+ element,
237
+ tracker,
238
+ );
239
+ return () =>
240
+ driveFromEffect(() => {
241
+ detach();
242
+ tracker.dispose();
243
+ });
244
+ },
245
+ [tracker],
246
+ );
247
+
248
+ // Syncs the host's listeners with the tracker's enabled state, which can
249
+ // change with any render: the host listens only while an enabled control
250
+ // is attached (spec:AST-094 FR24).
251
+ useIsomorphicLayoutEffect(() => {
252
+ const element = ref.current;
253
+ if (element != null) {
254
+ driveFromEffect(() =>
255
+ getGestureHost(element.ownerDocument).update(element),
256
+ );
257
+ }
258
+ });
259
+
260
+ return tracker;
261
+ }
262
+
263
+ /**
264
+ * Keeps `attach` applied to the element behind `ref`: checked after every
265
+ * render, so a replaced node (a re-keyed or swapped element) is detached and
266
+ * the new one attached, a removed one detached, and a change in `deps`
267
+ * re-attaches (`architecture:react-component-runtime` INV6). Costs no render.
268
+ * `attach` returns its detach, or null for nothing attached.
269
+ */
270
+ function useNodeAttachment<T extends Element>(
271
+ ref: RefObject<T | null>,
272
+ attach: (element: T) => (() => void) | null,
273
+ deps: ReadonlyArray<unknown>,
274
+ ): void {
275
+ const attachedRef = useRef<{
276
+ element: T;
277
+ deps: ReadonlyArray<unknown>;
278
+ detach: (() => void) | null;
279
+ } | null>(null);
280
+ // Syncs the attachment with the DOM node the caller's ref holds after
281
+ // this commit.
282
+ useIsomorphicLayoutEffect(() => {
283
+ const element = ref.current;
284
+ const current = attachedRef.current;
285
+ if (
286
+ current != null &&
287
+ current.element === element &&
288
+ current.deps.length === deps.length &&
289
+ current.deps.every((dep, index) => Object.is(dep, deps[index]))
290
+ ) {
291
+ return;
292
+ }
293
+ current?.detach?.();
294
+ attachedRef.current =
295
+ element == null ? null : {element, deps, detach: attach(element)};
296
+ });
297
+ // Detaches at unmount.
298
+ useIsomorphicLayoutEffect(
299
+ () => () => {
300
+ attachedRef.current?.detach?.();
301
+ attachedRef.current = null;
302
+ },
303
+ [],
304
+ );
305
+ }
@@ -153,3 +153,36 @@ describe('scroll keyboard delegation', () => {
153
153
  expect(document.activeElement).toBe(viewport);
154
154
  });
155
155
  });
156
+
157
+ describe('a viewport that is its own content box', () => {
158
+ function attachToItself(markup: string) {
159
+ detach?.();
160
+ viewport.innerHTML = markup;
161
+ const query = viewport.querySelectorAll.bind(viewport);
162
+ vi.spyOn(viewport, 'querySelectorAll').mockImplementation(selector => {
163
+ const result = query(selector);
164
+ return selector === FOCUSABLE_SELECTOR
165
+ ? ([...result].sort((a, b) =>
166
+ a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING
167
+ ? -1
168
+ : 1,
169
+ ) as unknown as NodeListOf<Element>)
170
+ : result;
171
+ });
172
+ detach = attachScrollKeyboardDelegation(viewport, viewport);
173
+ }
174
+
175
+ it('delegates Tab entry to its first link or button, never to itself', () => {
176
+ attachToItself(
177
+ '<p>Text</p><a href="#first">First link</a><button>Later</button>',
178
+ );
179
+ enter();
180
+ expect(document.activeElement).toBe(viewport.querySelector('a'));
181
+ });
182
+
183
+ it('keeps the stop on itself when nothing inside is focusable', () => {
184
+ attachToItself('<p>Only text</p>');
185
+ enter();
186
+ expect(document.activeElement).toBe(viewport);
187
+ });
188
+ });
@@ -2,9 +2,11 @@
2
2
 
3
3
  /**
4
4
  * @file scrollKeyboardDelegation.ts
5
- * @input A named, overflowing viewport and its real content box
5
+ * @input A named, overflowing viewport and its real content box (the viewport
6
+ * itself when it has no separate content box)
6
7
  * @output Focus-time delegation with native forward and reverse Tab traversal
7
- * @position Private useScrollableArea keyboard behavior; no DOM observers or scrolling
8
+ * @position Private keyboard behavior of useScrollableArea and of AppShell's main
9
+ * region; no DOM observers or scrolling
8
10
  */
9
11
 
10
12
  import {FOCUSABLE_SELECTOR} from './focusableSelector';
@@ -58,8 +60,12 @@ function firstDelegationTarget(
58
60
  content: HTMLElement,
59
61
  ): HTMLElement | null {
60
62
  const candidates = content.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR);
63
+ // A viewport that is its own content box is the stop being entered, never
64
+ // the target it delegates to.
61
65
  let first =
62
- content.matches(FOCUSABLE_SELECTOR) && isSequential(content)
66
+ content !== viewport &&
67
+ content.matches(FOCUSABLE_SELECTOR) &&
68
+ isSequential(content)
63
69
  ? content
64
70
  : null;
65
71
  for (const candidate of candidates) {
@@ -30,7 +30,7 @@ export const docs = {
30
30
  ],
31
31
  usage: {
32
32
  description:
33
- 'Tracks scroll overflow state for a horizontally scrollable container. Returns a ref callback and state booleans that update as the user scrolls or the container resizes. Uses scroll event listeners and ResizeObserver for reactive updates. Tolerance of 1px is applied to avoid sub-pixel false positives.',
33
+ 'Tracks scroll overflow state for a horizontally scrollable container. Returns a ref callback and state booleans that update as the user scrolls, the container resizes, or its content changes (a child added, removed or resized, or a new gap or padding). Uses scroll event listeners, ResizeObserver and MutationObserver for reactive updates. Tolerance of 1px is applied to avoid sub-pixel false positives.',
34
34
  bestPractices: [
35
35
  { guidance: true, description: 'Use to show/hide scroll navigation buttons or fade edges on carousels and horizontal lists.' },
36
36
  { guidance: true, description: 'Apply the scrollRef to a container with overflow-x: auto or overflow-x: scroll.' },
@@ -3,7 +3,8 @@
3
3
  /**
4
4
  * @file useScrollOverflow.test.tsx
5
5
  * @input Uses vitest, @testing-library/react, useScrollOverflow
6
- * @output Unit tests for the hook's measurement and its rendered-only gate
6
+ * @output Unit tests for the hook's measurement, what it observes (the
7
+ * container's scroll and size, and its content), and its rendered-only gate
7
8
  * @position Testing; jsdom lays nothing out, so the scroll box is faked and
8
9
  * `checkVisibility` is stubbed per element.
9
10
  */
@@ -18,7 +19,10 @@ import {useScrollOverflow} from './useScrollOverflow';
18
19
  let deliverResize: ((entries: ResizeObserverEntry[]) => void) | null = null;
19
20
 
20
21
  class FakeResizeObserver implements ResizeObserver {
22
+ /** The shared observer, so a test can read what it observes. */
23
+ static last: FakeResizeObserver | null = null;
21
24
  constructor(callback: ResizeObserverCallback) {
25
+ FakeResizeObserver.last = this;
22
26
  deliverResize = entries => callback(entries, this);
23
27
  }
24
28
  observe = vi.fn();
@@ -69,7 +73,9 @@ beforeEach(() => {
69
73
 
70
74
  afterEach(() => {
71
75
  vi.unstubAllGlobals();
76
+ vi.restoreAllMocks();
72
77
  deliverResize = null;
78
+ FakeResizeObserver.last = null;
73
79
  });
74
80
 
75
81
  describe('useScrollOverflow', () => {
@@ -200,6 +206,101 @@ describe('useScrollOverflow', () => {
200
206
  unmount();
201
207
  });
202
208
 
209
+ // The overflow is the content's width against the container's: it changes
210
+ // when the content does, with the container keeping its size.
211
+ it('measures again when a child is added or removed, though the container keeps its size', async () => {
212
+ const el = document.createElement('div');
213
+ fakeScrollBox(el, {scrollWidth: 300, clientWidth: 300});
214
+ stubRendered(el, true);
215
+ const {result, unmount} = renderHook(() => useScrollOverflow());
216
+ act(() => {
217
+ result.current.scrollRef(el);
218
+ });
219
+ expect(result.current.hasOverflow).toBe(false);
220
+
221
+ const child = document.createElement('div');
222
+ fakeScrollBox(el, {scrollWidth: 600, clientWidth: 300});
223
+ await act(async () => {
224
+ el.append(child);
225
+ });
226
+ expect(result.current.hasOverflow).toBe(true);
227
+
228
+ fakeScrollBox(el, {scrollWidth: 300, clientWidth: 300});
229
+ await act(async () => {
230
+ child.remove();
231
+ });
232
+ expect(result.current.hasOverflow).toBe(false);
233
+ unmount();
234
+ });
235
+
236
+ it('measures again when a child resizes, though the container keeps its size', () => {
237
+ const el = document.createElement('div');
238
+ const child = document.createElement('div');
239
+ el.append(child);
240
+ fakeScrollBox(el, {scrollWidth: 300, clientWidth: 300});
241
+ stubRendered(el, true);
242
+ const {result, unmount} = renderHook(() => useScrollOverflow());
243
+ act(() => {
244
+ result.current.scrollRef(el);
245
+ });
246
+ expect(result.current.hasOverflow).toBe(false);
247
+
248
+ // The child's content grows past the container.
249
+ fakeScrollBox(el, {scrollWidth: 600, clientWidth: 300});
250
+ act(() => {
251
+ deliverResize?.([resizeEntry(child)]);
252
+ });
253
+ expect(result.current.hasOverflow).toBe(true);
254
+ unmount();
255
+ });
256
+
257
+ it("measures again when the container's class or style changes, as a new gap does", async () => {
258
+ const el = document.createElement('div');
259
+ fakeScrollBox(el, {scrollWidth: 300, clientWidth: 300});
260
+ stubRendered(el, true);
261
+ const {result, unmount} = renderHook(() => useScrollOverflow());
262
+ act(() => {
263
+ result.current.scrollRef(el);
264
+ });
265
+ expect(result.current.hasOverflow).toBe(false);
266
+
267
+ fakeScrollBox(el, {scrollWidth: 340, clientWidth: 300});
268
+ await act(async () => {
269
+ el.className = 'wider-gap';
270
+ });
271
+ expect(result.current.hasOverflow).toBe(true);
272
+
273
+ fakeScrollBox(el, {scrollWidth: 300, clientWidth: 300});
274
+ await act(async () => {
275
+ el.style.columnGap = '0px';
276
+ });
277
+ expect(result.current.hasOverflow).toBe(false);
278
+ unmount();
279
+ });
280
+
281
+ it('stops observing the content when the container detaches', () => {
282
+ const el = document.createElement('div');
283
+ const child = document.createElement('div');
284
+ el.append(child);
285
+ fakeScrollBox(el, {scrollWidth: 300, clientWidth: 300});
286
+ stubRendered(el, true);
287
+ const disconnect = vi.spyOn(MutationObserver.prototype, 'disconnect');
288
+ const {result, unmount} = renderHook(() => useScrollOverflow());
289
+ act(() => {
290
+ result.current.scrollRef(el);
291
+ });
292
+ const observer = FakeResizeObserver.last;
293
+ expect(observer?.observe).toHaveBeenCalledWith(child);
294
+
295
+ act(() => {
296
+ result.current.scrollRef(null);
297
+ });
298
+ expect(disconnect).toHaveBeenCalled();
299
+ expect(observer?.unobserve).toHaveBeenCalledWith(child);
300
+ expect(observer?.unobserve).toHaveBeenCalledWith(el);
301
+ unmount();
302
+ });
303
+
203
304
  it('follows a scroll on a rendered container', () => {
204
305
  const el = document.createElement('div');
205
306
  fakeScrollBox(el, {scrollWidth: 600, clientWidth: 300});
@@ -10,12 +10,15 @@
10
10
  * state
11
11
  *
12
12
  * Observes a scroll container and reports whether content overflows at the
13
- * start, end, or both edges. Updates on every scroll, and on a resize while
14
- * the container is rendered: a layout read on an element the browser is not
13
+ * start, end, or both edges. Updates on every scroll, and while the container
14
+ * is rendered on what else changes the overflow with or without the
15
+ * container resizing: its own size, a child's size (a slide's content
16
+ * growing), a child added or removed, and its class or style (a new gap or
17
+ * padding). A layout read on an element the browser is not
15
18
  * rendering (an ancestor with `display: none`, or a `content-visibility:
16
19
  * hidden` subtree) either answers zeros or makes the browser lay out that
17
- * whole hidden subtree for the answer, so a resize observation delivered for
18
- * a hidden container, and the measurement at registration inside one, are
20
+ * whole hidden subtree for the answer, so an observation delivered for a
21
+ * hidden container, and the measurement at registration inside one, are
19
22
  * skipped; the hook keeps its last state until the resize observation that
20
23
  * follows the reveal (one frame after it paints). A scroll is measured
21
24
  * whether or not the container is rendered: a scroll of a hidden container
@@ -52,11 +55,57 @@ function isRendered(el: HTMLElement): boolean {
52
55
  return typeof el.checkVisibility !== 'function' || el.checkVisibility();
53
56
  }
54
57
 
58
+ /**
59
+ * Observes what changes `el`'s overflow besides its scroll: its own size,
60
+ * each child's size, the children added or removed, and its class or style.
61
+ * Returns the teardown, which ends every observation.
62
+ */
63
+ function observeContent(el: HTMLElement, measure: () => void): () => void {
64
+ const unobserveContainer = observeResize(el, measure);
65
+ const unobserveChildren = new Map<Element, () => void>();
66
+ const followChildren = () => {
67
+ const children = new Set(el.children);
68
+ for (const [child, unobserve] of unobserveChildren) {
69
+ if (!children.has(child)) {
70
+ unobserve();
71
+ unobserveChildren.delete(child);
72
+ }
73
+ }
74
+ for (const child of children) {
75
+ if (!unobserveChildren.has(child)) {
76
+ unobserveChildren.set(child, observeResize(child, measure));
77
+ }
78
+ }
79
+ };
80
+ followChildren();
81
+ const mutations =
82
+ typeof MutationObserver === 'function'
83
+ ? new MutationObserver(() => {
84
+ followChildren();
85
+ measure();
86
+ })
87
+ : null;
88
+ mutations?.observe(el, {
89
+ childList: true,
90
+ attributes: true,
91
+ attributeFilter: ['class', 'style'],
92
+ });
93
+ return () => {
94
+ mutations?.disconnect();
95
+ for (const unobserve of unobserveChildren.values()) {
96
+ unobserve();
97
+ }
98
+ unobserveChildren.clear();
99
+ unobserveContainer();
100
+ };
101
+ }
102
+
55
103
  /**
56
104
  * Tracks scroll overflow state for a horizontally scrollable container.
57
105
  *
58
106
  * Returns a ref callback to attach to the scroll container and a state
59
- * object that updates as the user scrolls or the container resizes.
107
+ * object that updates as the user scrolls, the container resizes, or its
108
+ * content changes.
60
109
  *
61
110
  * @example
62
111
  * ```
@@ -95,10 +144,10 @@ export function useScrollOverflow() {
95
144
  });
96
145
  }, []);
97
146
 
98
- // Registration and resize: only a rendered container. A hidden one has no
99
- // edges to report, and reading its layout would make the browser render
100
- // the hidden subtree it sits in; the resize observation that follows the
101
- // reveal measures again.
147
+ // Registration, resize and content changes: only a rendered container. A
148
+ // hidden one has no edges to report, and reading its layout would make the
149
+ // browser render the hidden subtree it sits in; the resize observation that
150
+ // follows the reveal measures again.
102
151
  const measure = useCallback(() => {
103
152
  const el = elRef.current;
104
153
  if (el && isRendered(el)) {
@@ -129,7 +178,7 @@ export function useScrollOverflow() {
129
178
 
130
179
  if (el) {
131
180
  el.addEventListener('scroll', measureOnScroll, {passive: true});
132
- unobserveRef.current = observeResize(el, measure);
181
+ unobserveRef.current = observeContent(el, measure);
133
182
  }
134
183
  },
135
184
  [measure, measureOnScroll],
@@ -189,13 +189,6 @@ const runtimeCatalog: Readonly<Record<string, string>> = {
189
189
  '@astryx.table.sort.ascending': 'Sorteer opgaande',
190
190
  '@astryx.table.sort.descending': 'Sorteer afgaande',
191
191
  '@astryx.table.sort.clear': 'Vee sortering uit',
192
- '@astryx.table.sort.direction.ascending': 'opgaande',
193
- '@astryx.table.sort.direction.descending': 'afgaande',
194
- '@astryx.table.sort.sortBy': 'Sorteer volgens {label}',
195
- '@astryx.table.sort.sortedBy':
196
- 'Sorteer volgens {label}, gesorteer {direction}',
197
- '@astryx.table.sort.sortedByWithPriority':
198
- 'Sorteer volgens {label}, gesorteer {direction}, prioriteit {rank, number} van {total, number}',
199
192
  '@astryx.toast.dismiss': 'Maak kennisgewing toe',
200
193
  '@astryx.toast.viewport': 'Kennisgewings',
201
194
  '@astryx.tokenizer.clearAll': 'Vee alles uit',
@@ -188,12 +188,6 @@ const runtimeCatalog: Readonly<Record<string, string>> = {
188
188
  '@astryx.table.sort.ascending': 'ترتيب تصاعدي',
189
189
  '@astryx.table.sort.descending': 'ترتيب تنازلي',
190
190
  '@astryx.table.sort.clear': 'مسح الترتيب',
191
- '@astryx.table.sort.direction.ascending': 'تصاعدي',
192
- '@astryx.table.sort.direction.descending': 'تنازلي',
193
- '@astryx.table.sort.sortBy': 'الترتيب حسب {label}',
194
- '@astryx.table.sort.sortedBy': 'الترتيب حسب {label}، مُرتَّب {direction}',
195
- '@astryx.table.sort.sortedByWithPriority':
196
- 'الترتيب حسب {label}، مُرتَّب {direction}، الأولوية {rank, number} من {total, number}',
197
191
  '@astryx.toast.dismiss': 'تجاهل الإشعار',
198
192
  '@astryx.toast.viewport': 'الإشعارات',
199
193
  '@astryx.tokenizer.clearAll': 'مسح الكل',
@@ -195,13 +195,6 @@ const runtimeCatalog: Readonly<Record<string, string>> = {
195
195
  '@astryx.table.sort.ascending': 'Ordena ascendentment',
196
196
  '@astryx.table.sort.descending': 'Ordena descendentment',
197
197
  '@astryx.table.sort.clear': 'Esborra l’ordenació',
198
- '@astryx.table.sort.direction.ascending': 'ascendent',
199
- '@astryx.table.sort.direction.descending': 'descendent',
200
- '@astryx.table.sort.sortBy': 'Ordena per {label}',
201
- '@astryx.table.sort.sortedBy':
202
- 'Ordena per {label}, ordenat de manera {direction}',
203
- '@astryx.table.sort.sortedByWithPriority':
204
- 'Ordena per {label}, ordenat de manera {direction}, prioritat {rank, number} de {total, number}',
205
198
  '@astryx.toast.dismiss': 'Descarta la notificació',
206
199
  '@astryx.toast.viewport': 'Notificacions',
207
200
  '@astryx.tokenizer.clearAll': 'Esborra-ho tot',
@@ -189,12 +189,6 @@ const runtimeCatalog: Readonly<Record<string, string>> = {
189
189
  '@astryx.table.sort.ascending': 'Seřadit vzestupně',
190
190
  '@astryx.table.sort.descending': 'Seřadit sestupně',
191
191
  '@astryx.table.sort.clear': 'Vymazat řazení',
192
- '@astryx.table.sort.direction.ascending': 'vzestupně',
193
- '@astryx.table.sort.direction.descending': 'sestupně',
194
- '@astryx.table.sort.sortBy': 'Seřadit podle {label}',
195
- '@astryx.table.sort.sortedBy': 'Seřadit podle {label}, seřazeno {direction}',
196
- '@astryx.table.sort.sortedByWithPriority':
197
- 'Seřadit podle {label}, seřazeno {direction}, priorita {rank, number} z {total, number}',
198
192
  '@astryx.toast.dismiss': 'Zavřít oznámení',
199
193
  '@astryx.toast.viewport': 'Oznámení',
200
194
  '@astryx.tokenizer.clearAll': 'Vymazat vše',