@astryxdesign/core 0.7.17 → 0.7.18-canary.g32556bb

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 (473) hide show
  1. package/dist/AlertDialog/AlertDialog.d.ts.map +1 -1
  2. package/dist/AlertDialog/AlertDialog.js +7 -0
  3. package/dist/AppShell/AppShell.d.ts.map +1 -1
  4. package/dist/AppShell/AppShell.js +5 -3
  5. package/dist/AppShell/observeMainOverflow.d.ts +5 -0
  6. package/dist/AppShell/observeMainOverflow.d.ts.map +1 -1
  7. package/dist/AppShell/observeMainOverflow.js +39 -9
  8. package/dist/BottomSheet/BottomSheet.d.ts.map +1 -1
  9. package/dist/BottomSheet/BottomSheet.js +8 -0
  10. package/dist/BottomSheet/useSheetGestures.d.ts +8 -0
  11. package/dist/BottomSheet/useSheetGestures.d.ts.map +1 -1
  12. package/dist/BottomSheet/useSheetGestures.js +16 -1
  13. package/dist/Button/Button.d.ts.map +1 -1
  14. package/dist/Button/Button.js +3 -16
  15. package/dist/Card/Card.d.ts.map +1 -1
  16. package/dist/Card/Card.js +5 -1
  17. package/dist/Citation/Citation.d.ts.map +1 -1
  18. package/dist/Citation/Citation.js +2 -2
  19. package/dist/ClickableCard/ClickableCard.d.ts.map +1 -1
  20. package/dist/ClickableCard/ClickableCard.js +7 -2
  21. package/dist/DateInput/DateInput.d.ts +0 -3
  22. package/dist/DateInput/DateInput.d.ts.map +1 -1
  23. package/dist/DateInput/DateInput.js +3 -5
  24. package/dist/DateInput/NativeDateField.d.ts.map +1 -1
  25. package/dist/DateInput/NativeDateField.js +3 -5
  26. package/dist/DateInput/TouchDateField.d.ts.map +1 -1
  27. package/dist/DateInput/TouchDateField.js +2 -4
  28. package/dist/DateInput/useTypedDate.d.ts.map +1 -1
  29. package/dist/DateInput/useTypedDate.js +9 -6
  30. package/dist/DateRangeInput/DateRangeInput.d.ts.map +1 -1
  31. package/dist/DateRangeInput/DateRangeInput.js +13 -9
  32. package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
  33. package/dist/DateTimeInput/DateTimeInput.js +3 -15
  34. package/dist/DateTimeInput/TouchDateTimeField.d.ts.map +1 -1
  35. package/dist/DateTimeInput/TouchDateTimeField.js +2 -14
  36. package/dist/Dialog/Dialog.d.ts.map +1 -1
  37. package/dist/Dialog/Dialog.js +7 -1
  38. package/dist/Drawer/Drawer.d.ts.map +1 -1
  39. package/dist/Drawer/Drawer.js +7 -0
  40. package/dist/Field/Field.d.ts.map +1 -1
  41. package/dist/Field/Field.js +2 -1
  42. package/dist/Field/FieldLabel.d.ts.map +1 -1
  43. package/dist/Field/FieldLabel.js +9 -2
  44. package/dist/Field/InputClearButton.d.ts.map +1 -1
  45. package/dist/Field/InputClearButton.js +23 -0
  46. package/dist/Field/inputStyles.stylex.d.ts +22 -6
  47. package/dist/Field/inputStyles.stylex.d.ts.map +1 -1
  48. package/dist/Field/inputStyles.stylex.js +32 -0
  49. package/dist/FieldStatus/FieldStatus.d.ts.map +1 -1
  50. package/dist/FieldStatus/FieldStatus.js +7 -2
  51. package/dist/FileInput/FileInput.d.ts.map +1 -1
  52. package/dist/FileInput/FileInput.js +4 -4
  53. package/dist/InputGroup/InputGroup.d.ts.map +1 -1
  54. package/dist/InputGroup/InputGroup.js +6 -16
  55. package/dist/InputGroup/InputGroupText.d.ts.map +1 -1
  56. package/dist/InputGroup/InputGroupText.js +2 -8
  57. package/dist/Item/Item.d.ts.map +1 -1
  58. package/dist/Item/Item.js +8 -2
  59. package/dist/Kbd/Kbd.d.ts +3 -2
  60. package/dist/Kbd/Kbd.d.ts.map +1 -1
  61. package/dist/Kbd/Kbd.js +3 -2
  62. package/dist/Layer/gestureCounter.d.ts +5 -0
  63. package/dist/Layer/gestureCounter.d.ts.map +1 -1
  64. package/dist/Layer/gestureCounter.js +40 -4
  65. package/dist/Layer/inputHold.d.ts +13 -0
  66. package/dist/Layer/inputHold.d.ts.map +1 -1
  67. package/dist/Layer/inputHold.js +203 -14
  68. package/dist/Layer/layerHost.d.ts +3 -2
  69. package/dist/Layer/layerHost.d.ts.map +1 -1
  70. package/dist/Layer/layerHost.js +3 -2
  71. package/dist/Layer/outsidePanClaim.d.ts +17 -0
  72. package/dist/Layer/outsidePanClaim.d.ts.map +1 -1
  73. package/dist/Layer/outsidePanClaim.js +36 -8
  74. package/dist/Layer/outsidePress.d.ts +7 -1
  75. package/dist/Layer/outsidePress.d.ts.map +1 -1
  76. package/dist/Layer/outsidePress.js +9 -2
  77. package/dist/Layer/useLayer.d.ts +21 -5
  78. package/dist/Layer/useLayer.d.ts.map +1 -1
  79. package/dist/Layer/useLayer.js +63 -40
  80. package/dist/Lightbox/Lightbox.d.ts.map +1 -1
  81. package/dist/Lightbox/Lightbox.js +7 -0
  82. package/dist/MetadataList/MetadataList.d.ts +1 -1
  83. package/dist/MetadataList/MetadataList.d.ts.map +1 -1
  84. package/dist/MetadataList/MetadataList.js +8 -0
  85. package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
  86. package/dist/MultiSelector/MultiSelector.js +37 -17
  87. package/dist/NavIcon/NavIcon.d.ts +2 -2
  88. package/dist/NavIcon/NavIcon.d.ts.map +1 -1
  89. package/dist/NavIcon/NavIcon.js +2 -2
  90. package/dist/NavMenu/NavHeadingMenuItem.d.ts.map +1 -1
  91. package/dist/NavMenu/NavHeadingMenuItem.js +4 -3
  92. package/dist/NumberInput/NumberInput.d.ts +13 -5
  93. package/dist/NumberInput/NumberInput.d.ts.map +1 -1
  94. package/dist/NumberInput/NumberInput.js +6 -17
  95. package/dist/NumberInput/numberParser.d.ts +9 -2
  96. package/dist/NumberInput/numberParser.d.ts.map +1 -1
  97. package/dist/NumberInput/numberParser.js +15 -2
  98. package/dist/Overlay/OverlayScrim.d.ts.map +1 -1
  99. package/dist/Overlay/OverlayScrim.js +13 -4
  100. package/dist/Overlay/useOverlay.d.ts +1 -1
  101. package/dist/Pagination/Pagination.d.ts +3 -2
  102. package/dist/Pagination/Pagination.d.ts.map +1 -1
  103. package/dist/Pagination/Pagination.js +9 -2
  104. package/dist/Popover/usePopover.d.ts +37 -6
  105. package/dist/Popover/usePopover.d.ts.map +1 -1
  106. package/dist/Popover/usePopover.js +103 -20
  107. package/dist/PowerSearch/PowerSearch.d.ts +4 -1
  108. package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
  109. package/dist/PowerSearch/PowerSearch.js +3 -4
  110. package/dist/PowerSearch/PowerSearchBottomSheet.d.ts +1 -2
  111. package/dist/PowerSearch/PowerSearchBottomSheet.d.ts.map +1 -1
  112. package/dist/PowerSearch/PowerSearchBottomSheet.js +173 -185
  113. package/dist/PowerSearch/PowerSearchValueEditor.d.ts +0 -12
  114. package/dist/PowerSearch/PowerSearchValueEditor.d.ts.map +1 -1
  115. package/dist/PowerSearch/PowerSearchValueEditor.js +1 -51
  116. package/dist/PowerSearch/formatFilterValue.d.ts.map +1 -1
  117. package/dist/PowerSearch/formatFilterValue.js +6 -8
  118. package/dist/PowerSearch/formatTokenValue.d.ts +5 -10
  119. package/dist/PowerSearch/formatTokenValue.d.ts.map +1 -1
  120. package/dist/PowerSearch/formatTokenValue.js +21 -38
  121. package/dist/PowerSearch/relativeDateOptions.d.ts +30 -0
  122. package/dist/PowerSearch/relativeDateOptions.d.ts.map +1 -0
  123. package/dist/PowerSearch/relativeDateOptions.js +74 -0
  124. package/dist/ProgressBar/ProgressBar.d.ts +1 -1
  125. package/dist/ProgressBar/ProgressBar.d.ts.map +1 -1
  126. package/dist/ProgressBar/ProgressBar.js +20 -14
  127. package/dist/Resizable/createResizable.d.ts.map +1 -1
  128. package/dist/Resizable/createResizable.js +38 -4
  129. package/dist/SegmentedControl/SegmentedControlItem.d.ts.map +1 -1
  130. package/dist/SegmentedControl/SegmentedControlItem.js +5 -3
  131. package/dist/SelectableCard/SelectableCard.d.ts.map +1 -1
  132. package/dist/SelectableCard/SelectableCard.js +6 -2
  133. package/dist/Selector/Selector.d.ts.map +1 -1
  134. package/dist/Selector/Selector.js +2 -1
  135. package/dist/SideNav/SideNavItem.d.ts.map +1 -1
  136. package/dist/SideNav/SideNavItem.js +1 -1
  137. package/dist/Slider/Slider.d.ts.map +1 -1
  138. package/dist/Slider/Slider.js +53 -8
  139. package/dist/Stepper/Step.d.ts.map +1 -1
  140. package/dist/Stepper/Step.js +2 -2
  141. package/dist/TabList/Tab.d.ts.map +1 -1
  142. package/dist/TabList/Tab.js +2 -0
  143. package/dist/TabList/TabMenu.d.ts.map +1 -1
  144. package/dist/TabList/TabMenu.js +2 -0
  145. package/dist/Table/BaseTable.d.ts.map +1 -1
  146. package/dist/Table/BaseTable.js +30 -8
  147. package/dist/Table/Table.d.ts +9 -4
  148. package/dist/Table/Table.d.ts.map +1 -1
  149. package/dist/Table/Table.js +9 -4
  150. package/dist/Table/TableCell.d.ts.map +1 -1
  151. package/dist/Table/TableCell.js +2 -2
  152. package/dist/Table/TableHeaderCell.d.ts.map +1 -1
  153. package/dist/Table/TableHeaderCell.js +3 -7
  154. package/dist/Table/TableRow.d.ts.map +1 -1
  155. package/dist/Table/TableRow.js +10 -1
  156. package/dist/Table/plugins/rowExpansion/useTableRowExpansion.d.ts +11 -3
  157. package/dist/Table/plugins/rowExpansion/useTableRowExpansion.d.ts.map +1 -1
  158. package/dist/Table/plugins/rowExpansion/useTableRowExpansion.js +203 -51
  159. package/dist/Table/plugins/rowIndex/useTableRowIndex.d.ts.map +1 -1
  160. package/dist/Table/plugins/rowIndex/useTableRowIndex.js +4 -1
  161. package/dist/Table/plugins/rowStatus/useTableRowStatus.d.ts.map +1 -1
  162. package/dist/Table/plugins/rowStatus/useTableRowStatus.js +2 -0
  163. package/dist/Table/plugins/sortable/useTableSortable.d.ts.map +1 -1
  164. package/dist/Table/plugins/sortable/useTableSortable.js +18 -1
  165. package/dist/Table/plugins/stickyColumns/useTableStickyColumns.d.ts.map +1 -1
  166. package/dist/Table/plugins/stickyColumns/useTableStickyColumns.js +34 -24
  167. package/dist/Table/tableColumnAdmission.d.ts +7 -0
  168. package/dist/Table/tableColumnAdmission.d.ts.map +1 -1
  169. package/dist/Table/tableColumnAdmission.js +15 -0
  170. package/dist/Table/types.d.ts +5 -5
  171. package/dist/Text/Text.d.ts.map +1 -1
  172. package/dist/Text/Text.js +13 -8
  173. package/dist/Text/TruncationTooltip.d.ts +7 -39
  174. package/dist/Text/TruncationTooltip.d.ts.map +1 -1
  175. package/dist/Text/TruncationTooltip.js +47 -128
  176. package/dist/Text/cutText.d.ts +22 -0
  177. package/dist/Text/cutText.d.ts.map +1 -0
  178. package/dist/Text/cutText.js +92 -0
  179. package/dist/Text/cutTextOnKeyboardFocus.d.ts +41 -0
  180. package/dist/Text/cutTextOnKeyboardFocus.d.ts.map +1 -0
  181. package/dist/Text/cutTextOnKeyboardFocus.js +112 -0
  182. package/dist/Text/textClampContext.d.ts +1 -0
  183. package/dist/Text/textClampContext.d.ts.map +1 -1
  184. package/dist/Text/textClampContext.js +10 -5
  185. package/dist/Text/useTruncation.d.ts +23 -1
  186. package/dist/Text/useTruncation.d.ts.map +1 -1
  187. package/dist/Text/useTruncation.js +74 -28
  188. package/dist/TextInput/TextInput.d.ts +6 -6
  189. package/dist/Thumbnail/Thumbnail.js +4 -1
  190. package/dist/TimeInput/TimeInput.d.ts +0 -3
  191. package/dist/TimeInput/TimeInput.d.ts.map +1 -1
  192. package/dist/TimeInput/TimeInput.js +3 -5
  193. package/dist/TimeInput/TouchTimeField.d.ts.map +1 -1
  194. package/dist/TimeInput/TouchTimeField.js +3 -5
  195. package/dist/Timestamp/Timestamp.d.ts.map +1 -1
  196. package/dist/Timestamp/Timestamp.js +22 -16
  197. package/dist/Timestamp/TimestampHoverCard.d.ts +6 -3
  198. package/dist/Timestamp/TimestampHoverCard.d.ts.map +1 -1
  199. package/dist/Timestamp/TimestampHoverCard.js +30 -19
  200. package/dist/Timestamp/formatInstant.d.ts.map +1 -1
  201. package/dist/Timestamp/formatInstant.js +3 -3
  202. package/dist/Timestamp/tooltipEntries.d.ts.map +1 -1
  203. package/dist/Timestamp/tooltipEntries.js +4 -2
  204. package/dist/Toast/Toast.d.ts.map +1 -1
  205. package/dist/Toast/Toast.js +62 -31
  206. package/dist/Toast/ToastViewport.d.ts.map +1 -1
  207. package/dist/Toast/ToastViewport.js +35 -13
  208. package/dist/Toast/useToast.d.ts.map +1 -1
  209. package/dist/Toast/useToast.js +35 -14
  210. package/dist/Toolbar/Toolbar.d.ts.map +1 -1
  211. package/dist/Toolbar/Toolbar.js +20 -3
  212. package/dist/Tooltip/useTooltip.d.ts.map +1 -1
  213. package/dist/Tooltip/useTooltip.js +3 -3
  214. package/dist/astryx.css +41 -10
  215. package/dist/hooks/useAnnounceRenderedText.d.ts +10 -3
  216. package/dist/hooks/useAnnounceRenderedText.d.ts.map +1 -1
  217. package/dist/hooks/useAnnounceRenderedText.js +11 -3
  218. package/dist/hooks/useFocusTrap.d.ts +12 -0
  219. package/dist/hooks/useFocusTrap.d.ts.map +1 -1
  220. package/dist/hooks/useFocusTrap.js +13 -6
  221. package/dist/hooks/useHotkeys.d.ts +9 -1
  222. package/dist/hooks/useHotkeys.d.ts.map +1 -1
  223. package/dist/hooks/useHotkeys.js +52 -2
  224. package/dist/hooks/useInputStatusIcon.d.ts.map +1 -1
  225. package/dist/hooks/useInputStatusIcon.js +2 -1
  226. package/dist/hooks/useKeyboardHint.d.ts.map +1 -1
  227. package/dist/hooks/useKeyboardHint.js +4 -3
  228. package/dist/i18n/generated-english/DateRangeInput/DateRangeInput.generated.d.ts.map +1 -1
  229. package/dist/i18n/generated-english/DateRangeInput/DateRangeInput.generated.js +2 -0
  230. package/dist/i18n/generated-english/MultiSelector/MultiSelector.generated.d.ts.map +1 -1
  231. package/dist/i18n/generated-english/MultiSelector/MultiSelector.generated.js +1 -0
  232. package/dist/i18n/generated-english/PowerSearch/PowerSearchValueEditor.generated.d.ts.map +1 -1
  233. package/dist/i18n/generated-english/PowerSearch/PowerSearchValueEditor.generated.js +0 -6
  234. package/dist/i18n/generated-english/PowerSearch/relativeDateOptions.generated.d.ts +8 -0
  235. package/dist/i18n/generated-english/PowerSearch/relativeDateOptions.generated.d.ts.map +1 -0
  236. package/dist/i18n/generated-english/PowerSearch/relativeDateOptions.generated.js +17 -0
  237. package/dist/i18n/generated-english/Slider/Slider.generated.d.ts.map +1 -1
  238. package/dist/i18n/generated-english/Slider/Slider.generated.js +1 -0
  239. package/dist/i18n/generated-english/Thumbnail/Thumbnail.generated.d.ts.map +1 -1
  240. package/dist/i18n/generated-english/Thumbnail/Thumbnail.generated.js +1 -0
  241. package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
  242. package/dist/i18n/generated-locales/en.generated.js +5 -0
  243. package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
  244. package/dist/i18n/generated-locales/pseudo.generated.js +5 -0
  245. package/dist/i18n/getLocaleDirection.d.ts +0 -16
  246. package/dist/i18n/getLocaleDirection.d.ts.map +1 -1
  247. package/dist/i18n/getLocaleDirection.js +16 -6
  248. package/dist/i18n/listFormat.d.ts +34 -0
  249. package/dist/i18n/listFormat.d.ts.map +1 -0
  250. package/dist/i18n/listFormat.js +45 -0
  251. package/dist/i18n/useListFormatter.d.ts +7 -3
  252. package/dist/i18n/useListFormatter.d.ts.map +1 -1
  253. package/dist/i18n/useListFormatter.js +16 -13
  254. package/dist/internal/module-loader.d.ts +15 -0
  255. package/dist/internal/module-loader.d.ts.map +1 -0
  256. package/dist/internal/module-loader.js +15 -0
  257. package/dist/motion/animatedLayout.d.ts +6 -0
  258. package/dist/motion/animatedLayout.d.ts.map +1 -1
  259. package/dist/motion/animatedLayout.js +201 -27
  260. package/dist/palette/color.d.ts +16 -0
  261. package/dist/palette/color.d.ts.map +1 -1
  262. package/dist/palette/color.js +37 -1
  263. package/dist/palette/derive-look.d.ts +235 -0
  264. package/dist/palette/derive-look.d.ts.map +1 -0
  265. package/dist/palette/derive-look.js +879 -0
  266. package/dist/palette/editor-look.d.ts +41 -0
  267. package/dist/palette/editor-look.d.ts.map +1 -0
  268. package/dist/palette/editor-look.js +401 -0
  269. package/dist/palette/mapping.d.ts +99 -6
  270. package/dist/palette/mapping.d.ts.map +1 -1
  271. package/dist/palette/mapping.js +68 -11
  272. package/dist/theme/tokens.d.ts +1 -1
  273. package/dist/theme/tokens.d.ts.map +1 -1
  274. package/dist/theme/tokens.js +1 -1
  275. package/dist/utils/characters.d.ts.map +1 -1
  276. package/dist/utils/characters.js +7 -0
  277. package/dist/utils/devWarning.d.ts +18 -0
  278. package/dist/utils/devWarning.d.ts.map +1 -1
  279. package/dist/utils/devWarning.js +30 -0
  280. package/dist/utils/focusReturn.d.ts +2 -0
  281. package/dist/utils/focusReturn.d.ts.map +1 -1
  282. package/dist/utils/focusReturn.js +3 -8
  283. package/dist/utils/hitArea.d.ts +4 -1
  284. package/dist/utils/hitArea.d.ts.map +1 -1
  285. package/dist/utils/hitArea.js +72 -9
  286. package/dist/utils/mergeProps.d.ts.map +1 -1
  287. package/dist/utils/mergeProps.js +53 -38
  288. package/dist/utils/scrollView.d.ts +2 -2
  289. package/dist/utils/scrollView.d.ts.map +1 -1
  290. package/dist/utils/scrollView.js +3 -3
  291. package/dist/utils/textDirection.d.ts +29 -5
  292. package/dist/utils/textDirection.d.ts.map +1 -1
  293. package/dist/utils/textDirection.js +56 -4
  294. package/dist/utils/themeProps.d.ts.map +1 -1
  295. package/dist/utils/themeProps.js +22 -3
  296. package/dist/utils/touchHitArea.d.ts.map +1 -1
  297. package/dist/utils/touchHitArea.js +4 -2
  298. package/dist/virtualization/useInlineListWindow.d.ts.map +1 -1
  299. package/dist/virtualization/useInlineListWindow.js +63 -4
  300. package/locales/en.json +26 -6
  301. package/locales/pseudo.json +15 -0
  302. package/package.json +10 -5
  303. package/src/AlertDialog/AlertDialog.tsx +15 -0
  304. package/src/AlertDialog/useImperativeAlertDialog.doc.mjs +7 -4
  305. package/src/AppShell/AppShell.tsx +6 -3
  306. package/src/AppShell/observeMainOverflow.ts +39 -9
  307. package/src/Badge/Badge.doc.mjs +3 -3
  308. package/src/BottomSheet/BottomSheet.tsx +15 -0
  309. package/src/BottomSheet/useSheetGestures.ts +26 -1
  310. package/src/Button/Button.tsx +3 -23
  311. package/src/Card/Card.doc.mjs +3 -3
  312. package/src/Card/Card.tsx +11 -6
  313. package/src/Chat/ChatSendButton.doc.mjs +6 -6
  314. package/src/Chat/ChatToolCalls.doc.mjs +1 -1
  315. package/src/CheckboxInput/CheckboxInput.doc.mjs +3 -3
  316. package/src/Citation/Citation.tsx +8 -2
  317. package/src/ClickableCard/ClickableCard.tsx +9 -2
  318. package/src/ComplexSelector/ComplexSelector.doc.mjs +3 -3
  319. package/src/ContextMenu/ContextMenuItem.doc.mjs +3 -3
  320. package/src/DateInput/DateInput.tsx +2 -4
  321. package/src/DateInput/NativeDateField.tsx +5 -4
  322. package/src/DateInput/TouchDateField.tsx +2 -3
  323. package/src/DateInput/useTypedDate.ts +13 -6
  324. package/src/DateRangeInput/DateRangeInput.tsx +14 -10
  325. package/src/DateTimeInput/DateTimeInput.tsx +2 -12
  326. package/src/DateTimeInput/TouchDateTimeField.tsx +2 -11
  327. package/src/Dialog/Dialog.tsx +15 -1
  328. package/src/Dialog/useImperativeDialog.doc.mjs +7 -4
  329. package/src/Drawer/Drawer.tsx +15 -0
  330. package/src/DropdownMenu/DropdownMenu.doc.mjs +1 -1
  331. package/src/DropdownMenu/DropdownMenuCheckboxItem.doc.mjs +3 -3
  332. package/src/DropdownMenu/DropdownMenuItem.doc.mjs +3 -3
  333. package/src/DropdownMenu/DropdownMenuRadioItem.doc.mjs +3 -3
  334. package/src/DropdownMenu/DropdownMenuSubMenu.doc.mjs +2 -2
  335. package/src/Field/Field.doc.mjs +1 -1
  336. package/src/Field/Field.tsx +2 -1
  337. package/src/Field/FieldLabel.doc.mjs +3 -3
  338. package/src/Field/FieldLabel.tsx +11 -3
  339. package/src/Field/InputClearButton.tsx +27 -0
  340. package/src/Field/inputStyles.stylex.ts +53 -6
  341. package/src/FieldStatus/FieldStatus.tsx +7 -2
  342. package/src/FileInput/FileInput.tsx +12 -2
  343. package/src/Icon/Icon.doc.mjs +17 -14
  344. package/src/Icon/useIcon.doc.mjs +6 -6
  345. package/src/IconButton/IconButton.doc.mjs +2 -2
  346. package/src/InfoTip/InfoTip.doc.mjs +1 -1
  347. package/src/InputGroup/InputGroup.tsx +5 -12
  348. package/src/InputGroup/InputGroupText.tsx +2 -3
  349. package/src/Item/Item.tsx +10 -1
  350. package/src/Kbd/Kbd.doc.mjs +5 -5
  351. package/src/Kbd/Kbd.tsx +3 -2
  352. package/src/Layer/gestureCounter.ts +39 -3
  353. package/src/Layer/inputHold.ts +241 -18
  354. package/src/Layer/layerHost.ts +3 -2
  355. package/src/Layer/outsidePanClaim.ts +50 -8
  356. package/src/Layer/outsidePress.ts +18 -4
  357. package/src/Layer/useLayer.tsx +128 -76
  358. package/src/Lightbox/Lightbox.tsx +15 -0
  359. package/src/MetadataList/MetadataList.tsx +8 -0
  360. package/src/MoreMenu/MoreMenu.doc.mjs +1 -1
  361. package/src/MultiSelector/MultiSelector.doc.mjs +2 -2
  362. package/src/MultiSelector/MultiSelector.tsx +45 -15
  363. package/src/NavIcon/NavIcon.doc.mjs +19 -10
  364. package/src/NavIcon/NavIcon.tsx +3 -2
  365. package/src/NavMenu/NavHeadingMenuItem.tsx +9 -3
  366. package/src/NumberInput/NumberInput.doc.mjs +12 -12
  367. package/src/NumberInput/NumberInput.tsx +12 -15
  368. package/src/NumberInput/numberParser.ts +15 -2
  369. package/src/Overlay/Overlay.doc.mjs +13 -1
  370. package/src/Overlay/OverlayScrim.tsx +45 -15
  371. package/src/Overlay/useOverlay.doc.mjs +7 -7
  372. package/src/Overlay/useOverlay.tsx +1 -1
  373. package/src/Pagination/Pagination.doc.mjs +9 -6
  374. package/src/Pagination/Pagination.tsx +15 -3
  375. package/src/Popover/usePopover.doc.mjs +14 -4
  376. package/src/Popover/usePopover.tsx +180 -23
  377. package/src/PowerSearch/PowerSearch.doc.mjs +165 -15
  378. package/src/PowerSearch/PowerSearch.tsx +6 -8
  379. package/src/PowerSearch/PowerSearchBottomSheet.tsx +182 -223
  380. package/src/PowerSearch/PowerSearchValueEditor.tsx +1 -51
  381. package/src/PowerSearch/formatFilterValue.ts +8 -9
  382. package/src/PowerSearch/formatTokenValue.ts +24 -42
  383. package/src/PowerSearch/relativeDateOptions.ts +84 -0
  384. package/src/ProgressBar/ProgressBar.doc.mjs +24 -5
  385. package/src/ProgressBar/ProgressBar.tsx +28 -18
  386. package/src/Resizable/createResizable.ts +46 -5
  387. package/src/SegmentedControl/SegmentedControlItem.tsx +4 -3
  388. package/src/SelectableCard/SelectableCard.tsx +8 -2
  389. package/src/Selector/Selector.doc.mjs +3 -3
  390. package/src/Selector/Selector.tsx +3 -1
  391. package/src/Selector/SelectorOption.doc.mjs +3 -3
  392. package/src/SideNav/SideNavItem.doc.mjs +6 -6
  393. package/src/SideNav/SideNavItem.tsx +3 -0
  394. package/src/Slider/Slider.tsx +48 -6
  395. package/src/Stepper/Step.tsx +7 -1
  396. package/src/Switch/Switch.doc.mjs +3 -3
  397. package/src/TabList/Tab.tsx +4 -0
  398. package/src/TabList/TabMenu.tsx +4 -0
  399. package/src/Table/BaseTable.tsx +35 -7
  400. package/src/Table/Table.doc.mjs +63 -6
  401. package/src/Table/Table.tsx +9 -4
  402. package/src/Table/TableCell.tsx +5 -2
  403. package/src/Table/TableHeaderCell.tsx +2 -8
  404. package/src/Table/TableRow.tsx +10 -1
  405. package/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx +250 -53
  406. package/src/Table/plugins/rowIndex/useTableRowIndex.tsx +10 -1
  407. package/src/Table/plugins/rowStatus/useTableRowStatus.tsx +5 -0
  408. package/src/Table/plugins/sortable/useTableSortable.tsx +41 -2
  409. package/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx +49 -20
  410. package/src/Table/tableColumnAdmission.ts +23 -0
  411. package/src/Table/types.ts +5 -5
  412. package/src/Table/useTableRowsVirtualization.doc.mjs +2 -2
  413. package/src/Text/Text.tsx +21 -7
  414. package/src/Text/TruncationTooltip.tsx +51 -184
  415. package/src/Text/cutText.tsx +126 -0
  416. package/src/Text/cutTextOnKeyboardFocus.tsx +158 -0
  417. package/src/Text/textClampContext.ts +14 -4
  418. package/src/Text/useTruncation.ts +85 -27
  419. package/src/TextArea/TextArea.doc.mjs +4 -4
  420. package/src/TextInput/TextInput.doc.mjs +3 -3
  421. package/src/Thumbnail/Thumbnail.tsx +1 -1
  422. package/src/TimeInput/TimeInput.tsx +3 -9
  423. package/src/TimeInput/TouchTimeField.tsx +6 -4
  424. package/src/Timestamp/Timestamp.tsx +29 -21
  425. package/src/Timestamp/TimestampHoverCard.tsx +44 -31
  426. package/src/Timestamp/formatInstant.ts +7 -3
  427. package/src/Timestamp/tooltipEntries.ts +4 -2
  428. package/src/Toast/Toast.doc.mjs +24 -37
  429. package/src/Toast/Toast.tsx +77 -29
  430. package/src/Toast/ToastViewport.tsx +33 -13
  431. package/src/Toast/useToast.tsx +42 -15
  432. package/src/Tokenizer/Tokenizer.doc.mjs +2 -2
  433. package/src/Toolbar/Toolbar.tsx +20 -6
  434. package/src/Tooltip/useTooltip.tsx +2 -1
  435. package/src/TopNav/TopNavMegaMenu.doc.mjs +13 -0
  436. package/src/TopNav/TopNavMenu.doc.mjs +2 -0
  437. package/src/Typeahead/Typeahead.doc.mjs +2 -2
  438. package/src/hooks/useAnnounceRenderedText.ts +15 -2
  439. package/src/hooks/useFocusTrap.ts +27 -4
  440. package/src/hooks/useHotkeys.doc.mjs +54 -11
  441. package/src/hooks/useHotkeys.ts +72 -3
  442. package/src/hooks/useInputStatusIcon.tsx +2 -1
  443. package/src/hooks/useKeyboardHint.tsx +3 -2
  444. package/src/i18n/generated-english/DateRangeInput/DateRangeInput.generated.ts +2 -0
  445. package/src/i18n/generated-english/MultiSelector/MultiSelector.generated.ts +1 -0
  446. package/src/i18n/generated-english/PowerSearch/PowerSearchValueEditor.generated.ts +0 -6
  447. package/src/i18n/generated-english/PowerSearch/relativeDateOptions.generated.ts +18 -0
  448. package/src/i18n/generated-english/Slider/Slider.generated.ts +1 -0
  449. package/src/i18n/generated-english/Thumbnail/Thumbnail.generated.ts +1 -0
  450. package/src/i18n/generated-locales/en.generated.ts +5 -0
  451. package/src/i18n/generated-locales/pseudo.generated.ts +5 -0
  452. package/src/i18n/getLocaleDirection.ts +57 -7
  453. package/src/i18n/listFormat.ts +55 -0
  454. package/src/i18n/useListFormatter.ts +22 -13
  455. package/src/internal/module-loader.ts +15 -0
  456. package/src/motion/animatedLayout.ts +215 -28
  457. package/src/palette/color.ts +41 -1
  458. package/src/palette/derive-look.ts +1186 -0
  459. package/src/palette/editor-look.ts +480 -0
  460. package/src/palette/mapping.ts +129 -15
  461. package/src/theme/SyntaxTheme.doc.mjs +1 -1
  462. package/src/theme/tokens.ts +2 -1
  463. package/src/theme/useThemeName.doc.mjs +1 -1
  464. package/src/utils/characters.ts +11 -0
  465. package/src/utils/devWarning.ts +35 -0
  466. package/src/utils/focusReturn.ts +3 -11
  467. package/src/utils/hitArea.ts +87 -18
  468. package/src/utils/mergeProps.ts +57 -34
  469. package/src/utils/scrollView.ts +3 -2
  470. package/src/utils/textDirection.ts +65 -5
  471. package/src/utils/themeProps.ts +22 -3
  472. package/src/utils/touchHitArea.ts +3 -2
  473. package/src/virtualization/useInlineListWindow.ts +102 -11
@@ -194,27 +194,54 @@ function countPinnedRuns(
194
194
  type StickySide = {edge: 'start' | 'end'; offset: string};
195
195
 
196
196
  /**
197
- * Resolve how a single column should be pinned given the start/end configs and
198
- * the full column list. A key (mis)configured on both edges resolves to start.
199
- * Returns `null` for columns that should not be pinned.
197
+ * Resolves how one column is pinned from the precomputed offsets. A key on
198
+ * both edges resolves to start. Returns `null` for a column that is not
199
+ * pinned.
200
200
  */
201
201
  function resolveStickySide(
202
- columns: ReadonlyArray<TableColumn<Record<string, unknown>>> | undefined,
202
+ offsets: PinnedOffsets,
203
203
  columnKey: string,
204
- startKeys: string[],
205
- endKeys: string[],
206
204
  ): StickySide | null {
207
- const startOffsets = computeStartOffsets(columns, startKeys);
208
- if (startOffsets?.has(columnKey)) {
209
- return {edge: 'start', offset: startOffsets.get(columnKey) ?? '0px'};
205
+ if (offsets.start?.has(columnKey)) {
206
+ return {edge: 'start', offset: offsets.start.get(columnKey) ?? '0px'};
210
207
  }
211
- const endOffsets = computeEndOffsets(columns, endKeys);
212
- if (endOffsets?.has(columnKey)) {
213
- return {edge: 'end', offset: endOffsets.get(columnKey) ?? '0px'};
208
+ if (offsets.end?.has(columnKey)) {
209
+ return {edge: 'end', offset: offsets.end.get(columnKey) ?? '0px'};
214
210
  }
215
211
  return null;
216
212
  }
217
213
 
214
+ interface PinnedOffsets {
215
+ start: Map<string, string> | null;
216
+ end: Map<string, string> | null;
217
+ }
218
+
219
+ /**
220
+ * Returns a reader of the pinned offsets for a column list. The offsets
221
+ * depend only on the columns and the pinned keys. Each cell of a render reads
222
+ * one result.
223
+ */
224
+ function createPinnedOffsetsReader(
225
+ startKeys: string[],
226
+ endKeys: string[],
227
+ ): (
228
+ columns: ReadonlyArray<TableColumn<Record<string, unknown>>> | undefined,
229
+ ) => PinnedOffsets {
230
+ let lastColumns:
231
+ ReadonlyArray<TableColumn<Record<string, unknown>>> | undefined;
232
+ let last: PinnedOffsets | undefined;
233
+ return columns => {
234
+ if (last === undefined || columns !== lastColumns) {
235
+ lastColumns = columns;
236
+ last = {
237
+ start: computeStartOffsets(columns, startKeys),
238
+ end: computeEndOffsets(columns, endKeys),
239
+ };
240
+ }
241
+ return last;
242
+ };
243
+ }
244
+
218
245
  // =============================================================================
219
246
  // Styles
220
247
  // =============================================================================
@@ -676,6 +703,10 @@ export function useTableStickyColumns<T extends Record<string, unknown>>(
676
703
  refreshRef.current?.();
677
704
  });
678
705
 
706
+ const readOffsets = useMemo(
707
+ () => createPinnedOffsetsReader(pinned.start, pinned.end),
708
+ [pinned],
709
+ );
679
710
  const plugin = useMemo(
680
711
  (): TablePlugin<T> => ({
681
712
  rowModel: 'flat',
@@ -691,8 +722,7 @@ export function useTableStickyColumns<T extends Record<string, unknown>>(
691
722
  props: HeaderCellRenderProps,
692
723
  column: TableColumn<T>,
693
724
  ): HeaderCellRenderProps {
694
- const {start: s, end: e} = pinned;
695
- const side = resolveStickySide(props.columns, column.key, s, e);
725
+ const side = resolveStickySide(readOffsets(props.columns), column.key);
696
726
  if (!side) {
697
727
  return props;
698
728
  }
@@ -732,8 +762,7 @@ export function useTableStickyColumns<T extends Record<string, unknown>>(
732
762
  props: BodyCellRenderProps,
733
763
  column: TableColumn<T>,
734
764
  ): BodyCellRenderProps {
735
- const {start: s, end: e} = pinned;
736
- const side = resolveStickySide(props.columns, column.key, s, e);
765
+ const side = resolveStickySide(readOffsets(props.columns), column.key);
737
766
  if (!side) {
738
767
  return props;
739
768
  }
@@ -801,10 +830,10 @@ export function useTableStickyColumns<T extends Record<string, unknown>>(
801
830
  };
802
831
  },
803
832
  }),
804
- // `pinned` keeps its identity while the pinned keys keep their values, and
805
- // `attachScrollShadow` is stable, so the plugin object is reused until the
806
- // pinned keys change.
807
- [attachScrollShadow, pinned],
833
+ // `attachScrollShadow` is stable, and `readOffsets` changes only with the
834
+ // pinned keys. So the plugin object changes only when the pinned keys
835
+ // change.
836
+ [attachScrollShadow, readOffsets],
808
837
  );
809
838
  registerPinnedColumnRuns(plugin, columns =>
810
839
  countPinnedRuns(columns, pinned.start, pinned.end),
@@ -7,7 +7,12 @@
7
7
  */
8
8
  import type {ReactNode} from 'react';
9
9
  import type {TableColumn} from './types';
10
+ import {sharedWeakMap} from '../utils/sharedRealm';
10
11
  const heightSafe = new WeakMap<object, boolean>();
12
+ const fallbackReasons = sharedWeakMap<object, string>(
13
+ 'table/table-column-admission/fallback-reasons',
14
+ 1,
15
+ );
11
16
  const logicalRenderers = new WeakMap<
12
17
  object,
13
18
  (logicalIndex: number) => ReactNode
@@ -24,6 +29,24 @@ export function registerFixedHeightColumn<T extends Record<string, unknown>>(
24
29
  }
25
30
  }
26
31
 
32
+ /**
33
+ * Names why a first-party column keeps Table from windowing its rows, for the
34
+ * development warning. Without one, the warning reads as a caller's renderCell.
35
+ */
36
+ export function registerWindowFallbackReason<T extends Record<string, unknown>>(
37
+ column: TableColumn<T>,
38
+ reason: string,
39
+ ): void {
40
+ fallbackReasons.set(column, reason);
41
+ }
42
+
43
+ /** The reason a first-party column keeps Table from windowing, if it has one. */
44
+ export function getWindowFallbackReason<T extends Record<string, unknown>>(
45
+ column: TableColumn<T>,
46
+ ): string | undefined {
47
+ return fallbackReasons.get(column);
48
+ }
49
+
27
50
  /**
28
51
  * Widens logical-position columns to the measured widths, by column index,
29
52
  * that fit the last position. A column keeps a declared width that already
@@ -201,18 +201,18 @@ export interface TableColumn<T extends Record<string, unknown>> {
201
201
  * badges, status dots, formatted text, icons, or composed layouts.
202
202
  *
203
203
  * @compositionHint Use renderCell to compose rich table cells:
204
- * - Badge for status labels (success/warning/error variants)
205
- * - StatusDot for colored indicators
204
+ * - StatusDot beside a Text label for a status column
206
205
  * - Text with color="success"|"error" for formatted values
207
206
  * - HStack to combine multiple elements in a cell
208
207
  * - Avatar for user/entity cells
208
+ * - Badge only for a rare state that needs action, not in every row
209
209
  *
210
210
  * @example
211
- * ```tsx
211
+ * ```
212
212
  * renderCell: (item) => (
213
213
  * <HStack gap={2} align="center">
214
- * <StatusDot status={item.isActive ? 'success' : 'error'} />
215
- * <Badge variant={item.isActive ? 'success' : 'error'} label={item.isActive ? 'Active' : 'Inactive'} />
214
+ * <StatusDot variant={item.isActive ? 'success' : 'neutral'} label={item.isActive ? 'Active' : 'Inactive'} />
215
+ * <Text>{item.isActive ? 'Active' : 'Inactive'}</Text>
216
216
  * </HStack>
217
217
  * )
218
218
  * ```
@@ -6,7 +6,7 @@ export const docs = {
6
6
  subComponentOf: 'Table',
7
7
  displayName: 'useTableRowsVirtualization',
8
8
  description:
9
- "Returns an opaque capability for fixed-height flat-row Table windowing. Pass the capability to Table.virtualization and keep the complete data, columns, explicit stable idKey and plugins on Table. Sizes are positive finite CSS pixels. The Table scrolls inside the height its parent gives it and fills all of it. Give the Table's parent a height, fixed or relative, or a flex child, so windowing can bound the rows; with no height every row renders. Make the Table the parent's only child, or a flex child with min-height: 0 beside a heading or toolbar. Supported rows use single-line content; explicit wrapping, arbitrary custom renderers, non-flat rows or invalid identity use ordinary full rendering. Windowing uses the Table-owned scroll wrapper; a caller-provided scrollWrapper takes diagnostic full-render fallback. Mounted rows retain native table semantics and full-table positions; unmounted rows are not promised screen-reader discovery.",
9
+ "Returns an opaque capability for fixed-height flat-row Table windowing. Pass the capability to Table.virtualization and keep the complete data, columns, explicit stable idKey and plugins on Table. Sizes are positive finite CSS pixels. The Table scrolls inside the height its parent gives it and fills all of it. Give the Table's parent a height, fixed or relative, or a flex child, so windowing can bound the rows; with no height every row renders. Make the Table the parent's only child, or a flex child with min-height: 0 beside a heading or toolbar. Supported rows use single-line content; explicit wrapping, non-flat rows or invalid identity use ordinary full rendering. What stays windowed: a column without renderCell (its default cell renders the row's value as single-line text) and the row-number (useTableRowIndex, counting from 1) and selection (useTableSelection) columns. A column with a custom renderCell turns windowing off for the whole table, because Table cannot check that the cell keeps the fixed row height; it renders every row and warns in development, naming the column. A useTableRowStatus column, or a useTableRowIndex column that counts from another number, turns windowing off too. To window a table, put the text a column shows in the row data and leave renderCell off that column. Windowing uses the Table-owned scroll wrapper; a caller-provided scrollWrapper takes diagnostic full-render fallback. Mounted rows retain native table semantics and full-table positions; unmounted rows are not promised screen-reader discovery.",
10
10
  props: [
11
11
  {
12
12
  name: 'rowHeight',
@@ -28,7 +28,7 @@ export const docs = {
28
28
  /** @type {import('@astryxdesign/cli/authoring').ComponentTranslationDoc} */
29
29
  export const docsDense = {
30
30
  description:
31
- 'Geometry-only fixed-height flat-row opt-in for Table.virtualization. Keep full data and stable idKey on Table. Positive finite CSS-pixel sizes; unsupported content, geometry, identity or a caller scrollWrapper falls back to full rendering. Native mounted-row semantics, not discovery of unmounted rows.',
31
+ 'Geometry-only fixed-height flat-row opt-in for Table.virtualization. Keep full data and stable idKey on Table. Positive finite CSS-pixel sizes; unsupported content, geometry, identity or a caller scrollWrapper falls back to full rendering. Native mounted-row semantics, not discovery of unmounted rows. Windowed: columns without renderCell, row-number (from 1) and selection columns; any custom renderCell turns windowing off for the table, with a development warning naming the column.',
32
32
  propDescriptions: {
33
33
  rowHeight:
34
34
  'Total body-row pitch including density padding and borders; text and supported controls must fit. Taller equal rows window at their measured height.',
package/src/Text/Text.tsx CHANGED
@@ -46,7 +46,7 @@ import {
46
46
  tabularNumbersStyle,
47
47
  truncationTooltipStyles,
48
48
  } from './text.stylex';
49
- import {useTruncation} from './useTruncation';
49
+ import {useTruncationMeasure} from './useTruncation';
50
50
  import {
51
51
  TruncationTooltip,
52
52
  useTruncationTooltipInterest,
@@ -57,7 +57,10 @@ import {mergeProps} from '../utils/mergeProps';
57
57
  import {useMergedRefs} from '../hooks/useMergedRefs';
58
58
  import type {BaseProps} from '../BaseProps';
59
59
  import {themeProps} from '../utils/themeProps';
60
- import {TextClampContext} from './textClampContext';
60
+ import {
61
+ TextClampContext,
62
+ TextMeasureOnInterestContext,
63
+ } from './textClampContext';
61
64
 
62
65
  export type {TextType, TextSize};
63
66
 
@@ -262,23 +265,34 @@ export function Text({
262
265
  // Resolve display - force block when maxLines > 0 or hasCapsize
263
266
  const resolvedDisplay = maxLines > 0 || hasCapsize ? 'block' : display;
264
267
 
268
+ // A Table's default cells mount many texts at once. Text in them measures at
269
+ // each hover, tap or focus, not at mount.
270
+ const measuresOnInterest =
271
+ use(TextMeasureOnInterestContext) &&
272
+ maxLines > 0 &&
273
+ hasTruncateTooltip !== false;
274
+
265
275
  // Truncation detection. Only the tooltip reads the measured overflow, so
266
276
  // with the tooltip off the text is clipped by CSS alone and nothing is
267
277
  // measured or observed.
268
- const truncation = useTruncation({
278
+ const truncation = useTruncationMeasure({
269
279
  maxLines: hasTruncateTooltip === false ? 0 : maxLines,
280
+ measuresOnInterest,
270
281
  });
271
282
 
283
+ // Ref for the text element (used as tooltip anchor)
284
+ const textRef = useRef<HTMLElement>(null);
285
+
272
286
  // Tooltip for truncated text
273
287
  const tooltipPlacement: LayerPlacement =
274
288
  typeof hasTruncateTooltip === 'string' ? hasTruncateTooltip : 'above';
275
289
  const tooltipEnabled =
276
290
  maxLines > 0 && hasTruncateTooltip !== false && truncation.isTruncated;
277
291
  // The tooltip mounts on the first hover, tap or focus, not with the text.
278
- const tooltipInterest = useTruncationTooltipInterest(tooltipEnabled);
279
-
280
- // Ref for the text element (used as tooltip anchor)
281
- const textRef = useRef<HTMLElement>(null);
292
+ const tooltipInterest = useTruncationTooltipInterest(
293
+ tooltipEnabled,
294
+ truncation.measure,
295
+ );
282
296
 
283
297
  // Keep the merged ref stable across rerenders.
284
298
  const mergedRef = useMergedRefs(ref, truncation.ref, textRef);
@@ -6,8 +6,9 @@
6
6
  * @file TruncationTooltip.tsx
7
7
  * @input A truncated element's ref, its full text and the tooltip placement
8
8
  * @output Exports `useTruncationTooltipInterest`, which loads the Tooltip
9
- * module once text is truncated and tracks the first hover, tap or focus on
10
- * it, and `TruncationTooltip`, the Tooltip that mounts on that interaction
9
+ * module once text is truncated, or after the page's first paint for text
10
+ * that measures on interest, and tracks the first hover, tap or focus on it,
11
+ * and `TruncationTooltip`, the Tooltip that mounts on that interaction
11
12
  * @position Shared by Text, Heading and Lab's LineClamp (through Core's internal
12
13
  * line-clamp entry). Until the first interaction a page of
13
14
  * truncated text mounts no tooltip layers, and the tooltip that then mounts
@@ -26,11 +27,7 @@ import {
26
27
  } from 'react';
27
28
  import type {LayerPlacement} from '../Layer';
28
29
  import {createModuleLoader} from '../utils/moduleLoader';
29
- import type {
30
- Tooltip as TooltipType,
31
- UndescribedTooltip as UndescribedTooltipType,
32
- } from '../Tooltip/Tooltip';
33
- import {useInteractionModalityTrackingFor} from '../utils/interactionModality';
30
+ import type {Tooltip as TooltipType} from '../Tooltip/Tooltip';
34
31
  import {useTapRecognizer} from '../Layer/gestureCounter';
35
32
  import {isElement} from '../utils/nodeType';
36
33
  import {
@@ -46,6 +43,19 @@ const tooltipModule = createModuleLoader(
46
43
  async () => import('../Tooltip/Tooltip'),
47
44
  );
48
45
 
46
+ // The page's texts share one preload. It waits a frame and a task for the
47
+ // paint, then loads the module once. The shared loader keeps no failed load,
48
+ // so the next text tries again.
49
+ const afterPaintModule = createModuleLoader(async () => {
50
+ await new Promise<void>(resolve => {
51
+ requestAnimationFrame(() => {
52
+ setTimeout(resolve, 0);
53
+ });
54
+ });
55
+ return tooltipModule.load();
56
+ });
57
+ const loadAfterNextPaint = afterPaintModule.load;
58
+
49
59
  export interface TruncationTooltipInterest {
50
60
  /** Whether a hover, tap or focus has reached the element. It stays true. */
51
61
  readonly isWanted: boolean;
@@ -62,54 +72,74 @@ export interface TruncationTooltipInterest {
62
72
 
63
73
  /**
64
74
  * Tracks the interaction that mounts a truncated element's tooltip, while
65
- * `isEnabled`, until the mounted tooltip reads it. A finger's arrival does not
75
+ * `isEnabled` or, with `measure`, while the interaction measures the text
76
+ * truncated, until the mounted tooltip reads it. A finger's arrival does not
66
77
  * count: only a press that the touch trigger's recognizer takes for a tap
67
78
  * does. Once the tooltip has read the interaction, its own listeners take
68
79
  * over.
69
80
  */
70
81
  export function useTruncationTooltipInterest(
71
82
  isEnabled: boolean,
83
+ // For text that measures on interest: measures now and returns whether the
84
+ // text is truncated, so the interaction that measures it can mount the
85
+ // tooltip.
86
+ measure?: () => boolean,
72
87
  ): TruncationTooltipInterest {
73
88
  const [isWanted, setIsWanted] = useState(false);
74
89
  const [tooltip, setTooltip] = useState<TooltipComponent | null>(
75
90
  () => tooltipModule.loaded()?.Tooltip ?? null,
76
91
  );
77
92
  // Syncs with the module loader: truncated text loads the Tooltip module, so
78
- // the first interaction mounts the tooltip at once.
93
+ // the first interaction mounts the tooltip at once. Text that measures on
94
+ // interest has no answer yet. It joins the page's one after-paint preload,
95
+ // so the page shows first, and a hover never hurries the load.
79
96
  useEffect(() => {
80
- if (!isEnabled || tooltip != null) {
97
+ if ((!isEnabled && measure == null) || tooltip != null) {
81
98
  return;
82
99
  }
83
100
  let isCurrent = true;
84
- tooltipModule.load().then(
85
- loaded => {
86
- if (isCurrent) {
87
- setTooltip(() => loaded.Tooltip);
88
- }
89
- },
101
+ const show = (loaded: {Tooltip: TooltipComponent}) => {
102
+ if (isCurrent) {
103
+ setTooltip(() => loaded.Tooltip);
104
+ }
105
+ };
106
+ (measure == null ? tooltipModule.load() : loadAfterNextPaint()).then(
107
+ show,
90
108
  () => {},
91
109
  );
92
110
  return () => {
93
111
  isCurrent = false;
94
112
  };
95
- }, [isEnabled, tooltip]);
113
+ }, [isEnabled, measure, tooltip]);
96
114
  const interestRef = useRef<TooltipPresentInterestState>({
97
115
  interest: null,
98
116
  tapEvent: null,
99
117
  isRead: false,
100
118
  });
101
119
  const tapRecognizer = useTapRecognizer();
120
+ // A tooltip that read an interaction unmounts while the text fits. When the
121
+ // text is cut off again, the next tooltip reads the next interaction.
122
+ const measureInterest = useCallback((): boolean => {
123
+ if (measure == null) {
124
+ return isEnabled;
125
+ }
126
+ const isTruncated = measure();
127
+ if (isTruncated && !isEnabled) {
128
+ interestRef.current.isRead = false;
129
+ }
130
+ return isTruncated;
131
+ }, [isEnabled, measure]);
102
132
  const want = useCallback(
103
133
  (interest: 'hover' | 'tap' | 'focus', tapEvent: Event | null = null) => {
104
134
  const state = interestRef.current;
105
- if (!isEnabled || state.isRead) {
135
+ if (!measureInterest() || state.isRead) {
106
136
  return;
107
137
  }
108
138
  state.interest = interest;
109
139
  state.tapEvent = tapEvent;
110
140
  setIsWanted(true);
111
141
  },
112
- [isEnabled],
142
+ [measureInterest],
113
143
  );
114
144
  const forget = useCallback((interest: 'hover' | 'focus') => {
115
145
  const state = interestRef.current;
@@ -128,7 +158,7 @@ export function useTruncationTooltipInterest(
128
158
  const onPointerLeave = useCallback(() => forget('hover'), [forget]);
129
159
  const onPointerDown = useCallback(
130
160
  (event: PointerEvent<HTMLElement>) => {
131
- if (!isEnabled || interestRef.current.isRead) {
161
+ if (!measureInterest() || interestRef.current.isRead) {
132
162
  tapRecognizer.forget();
133
163
  return;
134
164
  }
@@ -143,7 +173,7 @@ export function useTruncationTooltipInterest(
143
173
  forget('hover');
144
174
  }
145
175
  },
146
- [isEnabled, tapRecognizer, want, forget],
176
+ [measureInterest, tapRecognizer, want, forget],
147
177
  );
148
178
  const onFocus = useCallback(
149
179
  (event: FocusEvent<HTMLElement>) => {
@@ -197,166 +227,3 @@ export function TruncationTooltip({
197
227
  </TooltipPresentInterestContext>
198
228
  );
199
229
  }
200
-
201
- /** Whether a box clips its content. */
202
- function overflows(element: Element): boolean {
203
- const box =
204
- element.clientWidth ||
205
- (element instanceof HTMLElement ? element.offsetWidth : 0);
206
- return box > 0 && element.scrollWidth > box;
207
- }
208
-
209
- /** Whether an element is visually hidden: a screen-reader-only label. */
210
- function isVisuallyHidden(element: Element): boolean {
211
- const style = element.ownerDocument.defaultView?.getComputedStyle(element);
212
- return (
213
- style != null &&
214
- style.position === 'absolute' &&
215
- ((style.clip !== '' && style.clip !== 'auto') ||
216
- (style.clipPath !== '' && style.clipPath !== 'none'))
217
- );
218
- }
219
-
220
- // A field and its value: an input, or a widget that shows a chosen value (a
221
- // Selector's combobox). Its value is not the component's text.
222
- const FIELD_SELECTOR =
223
- 'input, textarea, select, [contenteditable]:not([contenteditable="false"]), [role="combobox"], [role="listbox"], [role="searchbox"], [role="spinbutton"], [role="slider"], [role="textbox"]';
224
-
225
- /**
226
- * Whether an element is left out of the measured text: hidden, a hidden copy
227
- * (ToggleButton's bold-width reservation), visually hidden, or a field, whose
228
- * value clips inside its own box and is not the cut text.
229
- */
230
- function isLeftOut(element: Element): boolean {
231
- return (
232
- element.closest(`[hidden], [aria-hidden="true"], ${FIELD_SELECTOR}`) !=
233
- null || isVisuallyHidden(element)
234
- );
235
- }
236
-
237
- /** Whether text is cut: its box, or a box inside it that a reader sees, clips it. */
238
- function isTextCut(element: HTMLElement): boolean {
239
- return (
240
- overflows(element) ||
241
- [...element.querySelectorAll('*')].some(
242
- child => !isLeftOut(child) && overflows(child),
243
- )
244
- );
245
- }
246
-
247
- /**
248
- * The text a sighted reader sees, without hidden, visually hidden and field
249
- * text: the label or heading itself.
250
- */
251
- function visibleText(root: HTMLElement): string {
252
- let text = '';
253
- const walk = (node: Node) => {
254
- if (node.nodeType === Node.TEXT_NODE) {
255
- text += node.textContent ?? '';
256
- } else if (node instanceof Element && !isLeftOut(node)) {
257
- node.childNodes.forEach(walk);
258
- }
259
- };
260
- walk(root);
261
- return text.replace(/\s+/g, ' ').trim();
262
- }
263
-
264
- type UndescribedTooltipComponent = typeof UndescribedTooltipType;
265
-
266
- export interface CutTextOnKeyboardFocus {
267
- /** The full text while keyboard focus is inside and the text is cut. */
268
- readonly cutText: string | null;
269
- /**
270
- * The tooltip that shows `cutText` with no description, once its module
271
- * has loaded (after the first render, as tooltip code loads).
272
- */
273
- readonly Tooltip: UndescribedTooltipComponent | null;
274
- /** Closes the tooltip; pass it as the tooltip's `onHide` (Escape). */
275
- readonly hide: () => void;
276
- readonly onFocus: (event: FocusEvent<HTMLElement>) => void;
277
- readonly onBlur: (event: FocusEvent<HTMLElement>) => void;
278
- /** A press closes it, as a press closes a tooltip. */
279
- readonly onPointerDown: () => void;
280
- }
281
-
282
- /**
283
- * Shows a component's cut text in an undescribed tooltip on keyboard focus:
284
- * a Button's cut label, a table header cell's cut heading. When keyboard focus
285
- * reaches the anchor (or an element inside it), it measures `measureRef`'s
286
- * text; if the text is cut, `cutText` holds it until focus leaves the anchor,
287
- * Escape, or a press. A hover, a pointer-focused field and a touch tap show
288
- * nothing, and nothing is measured at rest. Internal: the package does not
289
- * export it.
290
- */
291
- export function useCutTextOnKeyboardFocus({
292
- anchorRef,
293
- measureRef,
294
- isEnabled,
295
- isSuppressed,
296
- }: {
297
- /** The element focus reaches and the tooltip attaches to. */
298
- anchorRef: RefObject<HTMLElement | null>;
299
- /** The element whose text is cut; the anchor itself when omitted. */
300
- measureRef?: RefObject<HTMLElement | null>;
301
- isEnabled: boolean;
302
- /** Returns true when another tooltip already describes the anchor. */
303
- isSuppressed?: (anchor: HTMLElement) => boolean;
304
- }): CutTextOnKeyboardFocus {
305
- const [cutText, setCutText] = useState<string | null>(null);
306
- const [Tooltip, setTooltip] = useState<UndescribedTooltipComponent | null>(
307
- () => tooltipModule.loaded()?.UndescribedTooltip ?? null,
308
- );
309
- const readModality = useInteractionModalityTrackingFor(anchorRef, isEnabled);
310
- // Syncs with the module loader: the tooltip loads after the first render,
311
- // so keyboard focus shows it at once.
312
- useEffect(() => {
313
- if (!isEnabled || Tooltip != null) {
314
- return;
315
- }
316
- let isCurrent = true;
317
- tooltipModule.load().then(
318
- loaded => {
319
- if (isCurrent) {
320
- setTooltip(() => loaded.UndescribedTooltip);
321
- }
322
- },
323
- () => {},
324
- );
325
- return () => {
326
- isCurrent = false;
327
- };
328
- }, [isEnabled, Tooltip]);
329
- const hide = useCallback(() => setCutText(null), []);
330
- const onFocus = (event: FocusEvent<HTMLElement>) => {
331
- const anchor = anchorRef.current;
332
- const measured = measureRef?.current ?? anchor;
333
- const target = event.target;
334
- // `:focus-visible` also matches a text field a pointer focused, so the
335
- // modality reader decides: only keyboard focus counts.
336
- if (
337
- !isEnabled ||
338
- anchor == null ||
339
- measured == null ||
340
- !isElement(target) ||
341
- // React delivers focus from a portal (a header's filter popover) to the
342
- // anchor's handlers; only focus inside the anchor counts.
343
- !anchor.contains(target) ||
344
- !target.matches(':focus-visible') ||
345
- readModality() !== 'keyboard'
346
- ) {
347
- return;
348
- }
349
- const text = visibleText(measured);
350
- const isCut =
351
- text !== '' && !(isSuppressed?.(anchor) ?? false) && isTextCut(measured);
352
- setCutText(isCut ? text : null);
353
- };
354
- const onBlur = (event: FocusEvent<HTMLElement>) => {
355
- const next = event.relatedTarget;
356
- if (isElement(next) && anchorRef.current?.contains(next)) {
357
- return;
358
- }
359
- setCutText(null);
360
- };
361
- return {cutText, Tooltip, hide, onFocus, onBlur, onPointerDown: hide};
362
- }