@astryxdesign/core 0.1.6 → 0.1.7-canary.04cd8f7

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 (571) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/README.md +25 -14
  3. package/dist/AlertDialog/AlertDialog.d.ts +1 -1
  4. package/dist/AlertDialog/AlertDialog.d.ts.map +1 -1
  5. package/dist/AlertDialog/AlertDialog.js +4 -1
  6. package/dist/AppShell/AppShell.d.ts.map +1 -1
  7. package/dist/AppShell/AppShell.js +3 -1
  8. package/dist/AvatarGroup/AvatarGroup.d.ts +1 -1
  9. package/dist/AvatarGroup/AvatarGroup.d.ts.map +1 -1
  10. package/dist/AvatarGroup/AvatarGroup.js +4 -1
  11. package/dist/Banner/Banner.d.ts.map +1 -1
  12. package/dist/Banner/Banner.js +8 -6
  13. package/dist/Breadcrumbs/Breadcrumbs.d.ts +1 -1
  14. package/dist/Breadcrumbs/Breadcrumbs.d.ts.map +1 -1
  15. package/dist/Breadcrumbs/Breadcrumbs.js +4 -1
  16. package/dist/Button/Button.d.ts +10 -2
  17. package/dist/Button/Button.d.ts.map +1 -1
  18. package/dist/Button/Button.js +49 -6
  19. package/dist/ButtonGroup/ButtonGroup.d.ts +20 -5
  20. package/dist/ButtonGroup/ButtonGroup.d.ts.map +1 -1
  21. package/dist/ButtonGroup/ButtonGroup.js +27 -11
  22. package/dist/Calendar/Calendar.d.ts.map +1 -1
  23. package/dist/Calendar/Calendar.js +29 -7
  24. package/dist/Carousel/Carousel.d.ts +1 -1
  25. package/dist/Carousel/Carousel.d.ts.map +1 -1
  26. package/dist/Carousel/Carousel.js +8 -5
  27. package/dist/Chat/ChatComposer.d.ts.map +1 -1
  28. package/dist/Chat/ChatComposer.js +4 -1
  29. package/dist/Chat/ChatComposerDrawer.d.ts +1 -1
  30. package/dist/Chat/ChatComposerDrawer.d.ts.map +1 -1
  31. package/dist/Chat/ChatComposerDrawer.js +9 -2
  32. package/dist/Chat/ChatComposerInput.d.ts.map +1 -1
  33. package/dist/Chat/ChatComposerInput.js +6 -2
  34. package/dist/Chat/ChatLayout.d.ts +1 -11
  35. package/dist/Chat/ChatLayout.d.ts.map +1 -1
  36. package/dist/Chat/ChatLayout.js +6 -4
  37. package/dist/Chat/ChatLayoutScrollButton.d.ts.map +1 -1
  38. package/dist/Chat/ChatLayoutScrollButton.js +4 -2
  39. package/dist/Chat/ChatMessage.d.ts +1 -1
  40. package/dist/Chat/ChatMessage.d.ts.map +1 -1
  41. package/dist/Chat/ChatMessage.js +8 -2
  42. package/dist/Chat/ChatMessageBubble.d.ts +1 -1
  43. package/dist/Chat/ChatMessageBubble.d.ts.map +1 -1
  44. package/dist/Chat/ChatMessageBubble.js +3 -1
  45. package/dist/Chat/ChatMessageList.d.ts +1 -1
  46. package/dist/Chat/ChatMessageList.d.ts.map +1 -1
  47. package/dist/Chat/ChatMessageList.js +3 -1
  48. package/dist/Chat/ChatMessageMetadata.d.ts.map +1 -1
  49. package/dist/Chat/ChatMessageMetadata.js +13 -8
  50. package/dist/Chat/ChatPastedTextToken.d.ts.map +1 -1
  51. package/dist/Chat/ChatPastedTextToken.js +3 -1
  52. package/dist/Chat/ChatSendButton.d.ts.map +1 -1
  53. package/dist/Chat/ChatSendButton.js +3 -1
  54. package/dist/Chat/index.d.ts +1 -1
  55. package/dist/Chat/index.d.ts.map +1 -1
  56. package/dist/Chat/useChatStreamScroll.d.ts +12 -1
  57. package/dist/Chat/useChatStreamScroll.d.ts.map +1 -1
  58. package/dist/Chat/useChatStreamScroll.js +43 -6
  59. package/dist/Chat/useSpeechRecognition.d.ts.map +1 -1
  60. package/dist/Chat/useSpeechRecognition.js +4 -2
  61. package/dist/Chat/useTriggerMenu.d.ts.map +1 -1
  62. package/dist/Chat/useTriggerMenu.js +4 -2
  63. package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
  64. package/dist/CheckboxInput/CheckboxInput.js +4 -2
  65. package/dist/CheckboxList/CheckboxList.d.ts +1 -1
  66. package/dist/CheckboxList/CheckboxList.d.ts.map +1 -1
  67. package/dist/CheckboxList/CheckboxList.js +3 -1
  68. package/dist/CheckboxList/CheckboxListItem.d.ts.map +1 -1
  69. package/dist/CheckboxList/CheckboxListItem.js +3 -1
  70. package/dist/Citation/Citation.d.ts.map +1 -1
  71. package/dist/Citation/Citation.js +10 -2
  72. package/dist/CodeBlock/CodeBlock.d.ts.map +1 -1
  73. package/dist/CodeBlock/CodeBlock.js +71 -53
  74. package/dist/Collapsible/Collapsible.d.ts +11 -1
  75. package/dist/Collapsible/Collapsible.d.ts.map +1 -1
  76. package/dist/Collapsible/Collapsible.js +36 -4
  77. package/dist/CommandPalette/CommandPalette.d.ts +1 -1
  78. package/dist/CommandPalette/CommandPalette.d.ts.map +1 -1
  79. package/dist/CommandPalette/CommandPalette.js +8 -3
  80. package/dist/CommandPalette/CommandPaletteInput.d.ts +1 -1
  81. package/dist/CommandPalette/CommandPaletteInput.d.ts.map +1 -1
  82. package/dist/CommandPalette/CommandPaletteInput.js +4 -1
  83. package/dist/CommandPalette/CommandPaletteList.d.ts +1 -1
  84. package/dist/CommandPalette/CommandPaletteList.d.ts.map +1 -1
  85. package/dist/CommandPalette/CommandPaletteList.js +4 -1
  86. package/dist/ContextMenu/ContextMenu.d.ts +1 -1
  87. package/dist/ContextMenu/ContextMenu.d.ts.map +1 -1
  88. package/dist/ContextMenu/ContextMenu.js +8 -4
  89. package/dist/ContextMenu/index.d.ts +3 -0
  90. package/dist/ContextMenu/index.d.ts.map +1 -1
  91. package/dist/ContextMenu/index.js +7 -1
  92. package/dist/DateInput/DateInput.d.ts +1 -1
  93. package/dist/DateInput/DateInput.d.ts.map +1 -1
  94. package/dist/DateInput/DateInput.js +10 -5
  95. package/dist/DateRangeInput/DateRangeInput.d.ts +1 -1
  96. package/dist/DateRangeInput/DateRangeInput.d.ts.map +1 -1
  97. package/dist/DateRangeInput/DateRangeInput.js +11 -6
  98. package/dist/DateTimeInput/DateTimeInput.d.ts +1 -1
  99. package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
  100. package/dist/DateTimeInput/DateTimeInput.js +15 -7
  101. package/dist/Dialog/Dialog.d.ts.map +1 -1
  102. package/dist/Dialog/Dialog.js +15 -12
  103. package/dist/Dialog/DialogHeader.d.ts +1 -1
  104. package/dist/Dialog/DialogHeader.d.ts.map +1 -1
  105. package/dist/Dialog/DialogHeader.js +7 -3
  106. package/dist/DropdownMenu/DropdownMenu.d.ts +1 -1
  107. package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
  108. package/dist/DropdownMenu/DropdownMenu.js +19 -9
  109. package/dist/DropdownMenu/DropdownMenuCheckboxItem.d.ts +89 -0
  110. package/dist/DropdownMenu/DropdownMenuCheckboxItem.d.ts.map +1 -0
  111. package/dist/DropdownMenu/DropdownMenuCheckboxItem.js +170 -0
  112. package/dist/DropdownMenu/DropdownMenuContext.d.ts +17 -1
  113. package/dist/DropdownMenu/DropdownMenuContext.d.ts.map +1 -1
  114. package/dist/DropdownMenu/DropdownMenuContext.js +18 -0
  115. package/dist/DropdownMenu/DropdownMenuRadioGroup.d.ts +69 -0
  116. package/dist/DropdownMenu/DropdownMenuRadioGroup.d.ts.map +1 -0
  117. package/dist/DropdownMenu/DropdownMenuRadioGroup.js +70 -0
  118. package/dist/DropdownMenu/DropdownMenuRadioItem.d.ts +69 -0
  119. package/dist/DropdownMenu/DropdownMenuRadioItem.d.ts.map +1 -0
  120. package/dist/DropdownMenu/DropdownMenuRadioItem.js +178 -0
  121. package/dist/DropdownMenu/index.d.ts +5 -1
  122. package/dist/DropdownMenu/index.d.ts.map +1 -1
  123. package/dist/DropdownMenu/index.js +10 -1
  124. package/dist/DropdownMenu/menuItemRoles.d.ts +13 -0
  125. package/dist/DropdownMenu/menuItemRoles.d.ts.map +1 -0
  126. package/dist/DropdownMenu/menuItemRoles.js +15 -0
  127. package/dist/EmptyState/EmptyState.d.ts +4 -1
  128. package/dist/EmptyState/EmptyState.d.ts.map +1 -1
  129. package/dist/FileInput/FileInput.d.ts.map +1 -1
  130. package/dist/FileInput/FileInput.js +11 -1
  131. package/dist/Icon/Icon.d.ts +17 -12
  132. package/dist/Icon/Icon.d.ts.map +1 -1
  133. package/dist/Icon/Icon.js +28 -20
  134. package/dist/Kbd/Kbd.js +1 -1
  135. package/dist/Layer/useLayer.d.ts +10 -0
  136. package/dist/Layer/useLayer.d.ts.map +1 -1
  137. package/dist/Layer/useLayer.js +23 -1
  138. package/dist/Lightbox/Lightbox.d.ts.map +1 -1
  139. package/dist/Lightbox/Lightbox.js +6 -4
  140. package/dist/Link/Link.d.ts +5 -1
  141. package/dist/Link/Link.d.ts.map +1 -1
  142. package/dist/Link/Link.js +32 -1
  143. package/dist/Markdown/Markdown.d.ts.map +1 -1
  144. package/dist/Markdown/Markdown.js +10 -8
  145. package/dist/MobileNav/MobileNav.d.ts.map +1 -1
  146. package/dist/MobileNav/MobileNav.js +4 -2
  147. package/dist/MobileNav/MobileNavToggle.d.ts +1 -1
  148. package/dist/MobileNav/MobileNavToggle.d.ts.map +1 -1
  149. package/dist/MobileNav/MobileNavToggle.js +4 -1
  150. package/dist/MoreMenu/MoreMenu.d.ts +1 -1
  151. package/dist/MoreMenu/MoreMenu.d.ts.map +1 -1
  152. package/dist/MoreMenu/MoreMenu.js +4 -1
  153. package/dist/MultiSelector/MultiSelector.d.ts +1 -1
  154. package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
  155. package/dist/MultiSelector/MultiSelector.js +13 -6
  156. package/dist/NumberInput/NumberInput.d.ts.map +1 -1
  157. package/dist/NumberInput/NumberInput.js +5 -1
  158. package/dist/Outline/Outline.d.ts +1 -1
  159. package/dist/Outline/Outline.d.ts.map +1 -1
  160. package/dist/Outline/Outline.js +4 -1
  161. package/dist/Pagination/Pagination.d.ts +1 -1
  162. package/dist/Pagination/Pagination.d.ts.map +1 -1
  163. package/dist/Pagination/Pagination.js +38 -11
  164. package/dist/Popover/usePopover.d.ts.map +1 -1
  165. package/dist/Popover/usePopover.js +4 -1
  166. package/dist/PowerSearch/PowerSearch.d.ts +1 -1
  167. package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
  168. package/dist/PowerSearch/PowerSearch.js +22 -12
  169. package/dist/PowerSearch/PowerSearchEditPopover.d.ts +1 -1
  170. package/dist/PowerSearch/PowerSearchEditPopover.d.ts.map +1 -1
  171. package/dist/PowerSearch/PowerSearchEditPopover.js +26 -20
  172. package/dist/PowerSearch/PowerSearchToken.d.ts.map +1 -1
  173. package/dist/PowerSearch/PowerSearchToken.js +7 -3
  174. package/dist/PowerSearch/PowerSearchValueEditor.d.ts.map +1 -1
  175. package/dist/PowerSearch/PowerSearchValueEditor.js +34 -21
  176. package/dist/PowerSearch/formatFilterValue.d.ts +2 -1
  177. package/dist/PowerSearch/formatFilterValue.d.ts.map +1 -1
  178. package/dist/PowerSearch/formatFilterValue.js +19 -9
  179. package/dist/PowerSearch/index.d.ts +2 -1
  180. package/dist/PowerSearch/index.d.ts.map +1 -1
  181. package/dist/PowerSearch/index.js +1 -0
  182. package/dist/PowerSearch/resolveOperatorLabel.d.ts +23 -0
  183. package/dist/PowerSearch/resolveOperatorLabel.d.ts.map +1 -0
  184. package/dist/PowerSearch/resolveOperatorLabel.js +28 -0
  185. package/dist/PowerSearch/types.d.ts +28 -2
  186. package/dist/PowerSearch/types.d.ts.map +1 -1
  187. package/dist/PowerSearch/usePowerSearchConfig.d.ts.map +1 -1
  188. package/dist/PowerSearch/usePowerSearchConfig.js +27 -27
  189. package/dist/PowerSearch/usePowerSearchSource.d.ts.map +1 -1
  190. package/dist/PowerSearch/usePowerSearchSource.js +15 -8
  191. package/dist/Resizable/ResizeHandle.d.ts +1 -1
  192. package/dist/Resizable/ResizeHandle.d.ts.map +1 -1
  193. package/dist/Resizable/ResizeHandle.js +4 -1
  194. package/dist/Selector/Selector.d.ts.map +1 -1
  195. package/dist/Selector/Selector.js +52 -14
  196. package/dist/SideNav/SideNav.d.ts.map +1 -1
  197. package/dist/SideNav/SideNav.js +4 -2
  198. package/dist/SideNav/SideNavCollapseButton.d.ts.map +1 -1
  199. package/dist/SideNav/SideNavCollapseButton.js +3 -1
  200. package/dist/SideNav/SideNavHeading.d.ts.map +1 -1
  201. package/dist/SideNav/SideNavHeading.js +5 -3
  202. package/dist/SideNav/SideNavItem.d.ts.map +1 -1
  203. package/dist/SideNav/SideNavItem.js +7 -1
  204. package/dist/Switch/Switch.d.ts.map +1 -1
  205. package/dist/Switch/Switch.js +4 -2
  206. package/dist/TabList/Tab.d.ts.map +1 -1
  207. package/dist/TabList/Tab.js +2 -2
  208. package/dist/TabList/TabList.d.ts +1 -1
  209. package/dist/TabList/TabList.d.ts.map +1 -1
  210. package/dist/TabList/TabList.js +6 -1
  211. package/dist/TabList/TabMenu.d.ts.map +1 -1
  212. package/dist/TabList/TabMenu.js +1 -1
  213. package/dist/Table/BaseTable.d.ts.map +1 -1
  214. package/dist/Table/BaseTable.js +29 -16
  215. package/dist/Table/Table.d.ts.map +1 -1
  216. package/dist/Table/Table.js +5 -3
  217. package/dist/Table/index.d.ts +2 -0
  218. package/dist/Table/index.d.ts.map +1 -1
  219. package/dist/Table/index.js +1 -0
  220. package/dist/Table/plugins/columnResize/useTableColumnResize.js +1 -1
  221. package/dist/Table/plugins/filtering/useTableFiltering.d.ts.map +1 -1
  222. package/dist/Table/plugins/filtering/useTableFiltering.js +56 -19
  223. package/dist/Table/plugins/groupedRows/useTableGroupedRows.d.ts +1 -1
  224. package/dist/Table/plugins/groupedRows/useTableGroupedRows.d.ts.map +1 -1
  225. package/dist/Table/plugins/groupedRows/useTableGroupedRows.js +12 -5
  226. package/dist/Table/plugins/pagination/useTablePagination.d.ts.map +1 -1
  227. package/dist/Table/plugins/pagination/useTablePagination.js +6 -3
  228. package/dist/Table/plugins/rowExpansion/useTableRowExpansion.d.ts.map +1 -1
  229. package/dist/Table/plugins/rowExpansion/useTableRowExpansion.js +8 -6
  230. package/dist/Table/plugins/rowIndex/useTableRowIndex.d.ts +1 -1
  231. package/dist/Table/plugins/rowIndex/useTableRowIndex.js +1 -1
  232. package/dist/Table/plugins/selection/useTableSelection.d.ts.map +1 -1
  233. package/dist/Table/plugins/selection/useTableSelection.js +5 -2
  234. package/dist/Table/plugins/sortable/useTableSortable.d.ts.map +1 -1
  235. package/dist/Table/plugins/sortable/useTableSortable.js +6 -4
  236. package/dist/Table/plugins/stickyColumns/useTableStickyColumns.js +2 -2
  237. package/dist/Table/plugins/tree/index.d.ts +5 -0
  238. package/dist/Table/plugins/tree/index.d.ts.map +1 -0
  239. package/dist/Table/plugins/tree/index.js +4 -0
  240. package/dist/Table/plugins/tree/useTableTreeData.d.ts +38 -0
  241. package/dist/Table/plugins/tree/useTableTreeData.d.ts.map +1 -0
  242. package/dist/Table/plugins/tree/useTableTreeData.js +358 -0
  243. package/dist/Table/plugins/tree/useTableTreeState.d.ts +51 -0
  244. package/dist/Table/plugins/tree/useTableTreeState.d.ts.map +1 -0
  245. package/dist/Table/plugins/tree/useTableTreeState.js +175 -0
  246. package/dist/Table/types.d.ts +17 -10
  247. package/dist/Table/types.d.ts.map +1 -1
  248. package/dist/Table/useBaseTablePlugins.d.ts.map +1 -1
  249. package/dist/Table/useBaseTablePlugins.js +6 -3
  250. package/dist/TextInput/TextInput.d.ts.map +1 -1
  251. package/dist/TextInput/TextInput.js +5 -1
  252. package/dist/Thumbnail/Thumbnail.d.ts.map +1 -1
  253. package/dist/Thumbnail/Thumbnail.js +8 -2
  254. package/dist/TimeInput/TimeInput.d.ts +1 -1
  255. package/dist/TimeInput/TimeInput.d.ts.map +1 -1
  256. package/dist/TimeInput/TimeInput.js +7 -2
  257. package/dist/Timestamp/Timestamp.d.ts.map +1 -1
  258. package/dist/Timestamp/Timestamp.js +18 -3
  259. package/dist/Toast/Toast.d.ts.map +1 -1
  260. package/dist/Toast/Toast.js +3 -1
  261. package/dist/Toast/ToastViewport.d.ts.map +1 -1
  262. package/dist/Toast/ToastViewport.js +3 -1
  263. package/dist/Token/Token.d.ts.map +1 -1
  264. package/dist/Token/Token.js +8 -2
  265. package/dist/Tokenizer/Tokenizer.d.ts.map +1 -1
  266. package/dist/Tokenizer/Tokenizer.js +3 -1
  267. package/dist/Toolbar/Toolbar.d.ts.map +1 -1
  268. package/dist/Toolbar/Toolbar.js +8 -1
  269. package/dist/TopNav/TopNav.d.ts +2 -1
  270. package/dist/TopNav/TopNav.d.ts.map +1 -1
  271. package/dist/TopNav/TopNav.js +4 -1
  272. package/dist/TopNav/TopNavHeading.d.ts.map +1 -1
  273. package/dist/TopNav/TopNavHeading.js +5 -3
  274. package/dist/TreeList/TreeList.d.ts.map +1 -1
  275. package/dist/TreeList/TreeList.js +5 -1
  276. package/dist/TreeList/TreeListItem.d.ts.map +1 -1
  277. package/dist/TreeList/TreeListItem.js +7 -1
  278. package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
  279. package/dist/Typeahead/BaseTypeahead.js +8 -4
  280. package/dist/Typeahead/Typeahead.d.ts.map +1 -1
  281. package/dist/Typeahead/Typeahead.js +3 -1
  282. package/dist/VisuallyHidden/VisuallyHidden.d.ts +1 -0
  283. package/dist/VisuallyHidden/VisuallyHidden.d.ts.map +1 -1
  284. package/dist/VisuallyHidden/VisuallyHidden.js +1 -0
  285. package/dist/astryx.css +38 -4
  286. package/dist/astryx.umd.js +62 -60
  287. package/dist/astryx.umd.js.map +4 -4
  288. package/dist/authoring/doc.d.ts +145 -0
  289. package/dist/authoring/doc.d.ts.map +1 -0
  290. package/dist/authoring/doc.js +100 -0
  291. package/dist/authoring/index.d.ts +29 -0
  292. package/dist/authoring/index.d.ts.map +1 -0
  293. package/dist/authoring/index.js +28 -0
  294. package/dist/authoring/integration.d.ts +35 -0
  295. package/dist/authoring/integration.d.ts.map +1 -0
  296. package/dist/authoring/integration.js +30 -0
  297. package/dist/authoring/template.d.ts +66 -0
  298. package/dist/authoring/template.d.ts.map +1 -0
  299. package/dist/authoring/template.js +55 -0
  300. package/dist/config.d.ts +80 -0
  301. package/dist/config.d.ts.map +1 -0
  302. package/dist/config.js +40 -0
  303. package/dist/docs-types.d.ts +13 -4
  304. package/dist/docs-types.d.ts.map +1 -1
  305. package/dist/i18n/InternationalizationContext.d.ts +12 -0
  306. package/dist/i18n/InternationalizationContext.d.ts.map +1 -0
  307. package/dist/i18n/InternationalizationContext.js +29 -0
  308. package/dist/i18n/InternationalizationProvider.d.ts +61 -0
  309. package/dist/i18n/InternationalizationProvider.d.ts.map +1 -0
  310. package/dist/i18n/InternationalizationProvider.js +44 -0
  311. package/dist/i18n/index.d.ts +24 -0
  312. package/dist/i18n/index.d.ts.map +1 -0
  313. package/dist/i18n/index.js +21 -0
  314. package/dist/i18n/resolve.d.ts +22 -0
  315. package/dist/i18n/resolve.d.ts.map +1 -0
  316. package/dist/i18n/resolve.js +141 -0
  317. package/dist/i18n/translator.d.ts +25 -0
  318. package/dist/i18n/translator.d.ts.map +1 -0
  319. package/dist/i18n/translator.js +1 -0
  320. package/dist/i18n/types.d.ts +47 -0
  321. package/dist/i18n/types.d.ts.map +1 -0
  322. package/dist/i18n/types.js +1 -0
  323. package/dist/i18n/useTranslator.d.ts +15 -0
  324. package/dist/i18n/useTranslator.d.ts.map +1 -0
  325. package/dist/i18n/useTranslator.js +39 -0
  326. package/dist/index.d.ts +1 -0
  327. package/dist/index.d.ts.map +1 -1
  328. package/dist/index.js +3 -0
  329. package/dist/theme/Theme.js +1 -1
  330. package/dist/theme/defineTheme.d.ts +1 -1
  331. package/dist/theme/defineTheme.js +1 -1
  332. package/dist/theme/hct.d.ts +0 -1
  333. package/dist/theme/hct.d.ts.map +1 -1
  334. package/dist/theme/hct.js +0 -3
  335. package/dist/utils/color.d.ts +13 -1
  336. package/dist/utils/color.d.ts.map +1 -1
  337. package/dist/utils/color.js +23 -1
  338. package/dist/utils/index.d.ts +1 -1
  339. package/dist/utils/index.d.ts.map +1 -1
  340. package/dist/utils/index.js +1 -1
  341. package/locales/en.json +754 -0
  342. package/locales/pseudo.json +566 -0
  343. package/package.json +23 -2
  344. package/src/AlertDialog/AlertDialog.doc.mjs +5 -0
  345. package/src/AlertDialog/AlertDialog.tsx +4 -1
  346. package/src/AppShell/AppShell.doc.mjs +8 -2
  347. package/src/AppShell/AppShell.tsx +3 -1
  348. package/src/AvatarGroup/AvatarGroup.tsx +4 -1
  349. package/src/Banner/Banner.tsx +10 -5
  350. package/src/Breadcrumbs/Breadcrumbs.tsx +4 -1
  351. package/src/Button/Button.doc.mjs +8 -0
  352. package/src/Button/Button.test.tsx +27 -0
  353. package/src/Button/Button.tsx +51 -5
  354. package/src/ButtonGroup/ButtonGroup.test.tsx +386 -2
  355. package/src/ButtonGroup/ButtonGroup.tsx +27 -11
  356. package/src/Calendar/Calendar.test.tsx +103 -2
  357. package/src/Calendar/Calendar.tsx +29 -6
  358. package/src/Card/Card.doc.mjs +3 -3
  359. package/src/Carousel/Carousel.tsx +10 -7
  360. package/src/Chat/ChatComposer.tsx +5 -1
  361. package/src/Chat/ChatComposerDrawer.tsx +9 -2
  362. package/src/Chat/ChatComposerInput.tsx +10 -4
  363. package/src/Chat/ChatLayout.test.tsx +127 -2
  364. package/src/Chat/ChatLayout.tsx +5 -12
  365. package/src/Chat/ChatLayoutScrollButton.tsx +4 -2
  366. package/src/Chat/ChatMessage.tsx +5 -1
  367. package/src/Chat/ChatMessageBubble.tsx +2 -0
  368. package/src/Chat/ChatMessageList.doc.mjs +1 -1
  369. package/src/Chat/ChatMessageList.tsx +2 -0
  370. package/src/Chat/ChatMessageMetadata.tsx +15 -9
  371. package/src/Chat/ChatPastedTextToken.tsx +3 -1
  372. package/src/Chat/ChatSendButton.tsx +3 -1
  373. package/src/Chat/ChatToolCalls.doc.mjs +1 -1
  374. package/src/Chat/index.ts +1 -0
  375. package/src/Chat/useChatStreamScroll.test.tsx +168 -0
  376. package/src/Chat/useChatStreamScroll.ts +67 -11
  377. package/src/Chat/useSpeechRecognition.ts +11 -2
  378. package/src/Chat/useTriggerMenu.tsx +4 -2
  379. package/src/CheckboxInput/CheckboxInput.doc.mjs +1 -1
  380. package/src/CheckboxInput/CheckboxInput.test.tsx +16 -0
  381. package/src/CheckboxInput/CheckboxInput.tsx +4 -2
  382. package/src/CheckboxList/CheckboxList.doc.mjs +6 -1
  383. package/src/CheckboxList/CheckboxList.tsx +2 -0
  384. package/src/CheckboxList/CheckboxListItem.tsx +7 -1
  385. package/src/Citation/Citation.tsx +4 -2
  386. package/src/ClickableCard/ClickableCard.doc.mjs +1 -1
  387. package/src/CodeBlock/CodeBlock.tsx +91 -40
  388. package/src/Collapsible/Collapsible.doc.mjs +7 -0
  389. package/src/Collapsible/Collapsible.test.tsx +80 -0
  390. package/src/Collapsible/Collapsible.tsx +58 -5
  391. package/src/CommandPalette/CommandPalette.tsx +10 -3
  392. package/src/CommandPalette/CommandPaletteInput.test.tsx +1 -1
  393. package/src/CommandPalette/CommandPaletteInput.tsx +5 -1
  394. package/src/CommandPalette/CommandPaletteList.tsx +4 -1
  395. package/src/ContextMenu/ContextMenu.test.tsx +75 -1
  396. package/src/ContextMenu/ContextMenu.tsx +14 -6
  397. package/src/ContextMenu/index.ts +15 -0
  398. package/src/DateInput/DateInput.doc.mjs +2 -2
  399. package/src/DateInput/DateInput.test.tsx +17 -5
  400. package/src/DateInput/DateInput.tsx +13 -5
  401. package/src/DateRangeInput/DateRangeInput.doc.mjs +1 -1
  402. package/src/DateRangeInput/DateRangeInput.tsx +14 -6
  403. package/src/DateTimeInput/DateTimeInput.doc.mjs +2 -2
  404. package/src/DateTimeInput/DateTimeInput.tsx +17 -7
  405. package/src/Dialog/Dialog.tsx +11 -15
  406. package/src/Dialog/DialogHeader.tsx +7 -3
  407. package/src/DropdownMenu/DropdownMenu.doc.mjs +23 -0
  408. package/src/DropdownMenu/DropdownMenu.tsx +23 -14
  409. package/src/DropdownMenu/DropdownMenuCheckboxItem.doc.mjs +95 -0
  410. package/src/DropdownMenu/DropdownMenuCheckboxItem.tsx +237 -0
  411. package/src/DropdownMenu/DropdownMenuContext.tsx +29 -1
  412. package/src/DropdownMenu/DropdownMenuItem.doc.mjs +7 -1
  413. package/src/DropdownMenu/DropdownMenuRadioGroup.doc.mjs +80 -0
  414. package/src/DropdownMenu/DropdownMenuRadioGroup.tsx +119 -0
  415. package/src/DropdownMenu/DropdownMenuRadioItem.doc.mjs +80 -0
  416. package/src/DropdownMenu/DropdownMenuRadioItem.tsx +232 -0
  417. package/src/DropdownMenu/DropdownMenuSelectable.test.tsx +163 -0
  418. package/src/DropdownMenu/index.ts +23 -3
  419. package/src/DropdownMenu/menuItemRoles.ts +22 -0
  420. package/src/EmptyState/EmptyState.doc.mjs +3 -3
  421. package/src/EmptyState/EmptyState.tsx +4 -1
  422. package/src/Field/Field.doc.mjs +3 -3
  423. package/src/Field/FieldLabel.doc.mjs +1 -1
  424. package/src/FileInput/FileInput.test.tsx +40 -1
  425. package/src/FileInput/FileInput.tsx +12 -1
  426. package/src/Grid/Grid.doc.mjs +5 -5
  427. package/src/Icon/Icon.test.tsx +46 -0
  428. package/src/Icon/Icon.tsx +37 -24
  429. package/src/InputGroup/InputGroup.doc.mjs +1 -1
  430. package/src/Kbd/Kbd.test.tsx +26 -0
  431. package/src/Kbd/Kbd.tsx +1 -1
  432. package/src/Layer/useLayer.doc.mjs +8 -5
  433. package/src/Layer/useLayer.test.tsx +136 -1
  434. package/src/Layer/useLayer.tsx +34 -2
  435. package/src/Lightbox/Lightbox.doc.mjs +7 -2
  436. package/src/Lightbox/Lightbox.tsx +6 -4
  437. package/src/Link/Link.test.tsx +74 -2
  438. package/src/Link/Link.tsx +48 -1
  439. package/src/Markdown/Markdown.tsx +12 -4
  440. package/src/MobileNav/MobileNav.tsx +4 -2
  441. package/src/MobileNav/MobileNavToggle.tsx +5 -3
  442. package/src/MoreMenu/MoreMenu.tsx +4 -1
  443. package/src/MultiSelector/MultiSelector.tsx +14 -5
  444. package/src/NumberInput/NumberInput.doc.mjs +2 -2
  445. package/src/NumberInput/NumberInput.tsx +3 -1
  446. package/src/Outline/Outline.tsx +4 -1
  447. package/src/OverflowList/OverflowList.doc.mjs +2 -2
  448. package/src/Pagination/Pagination.tsx +35 -12
  449. package/src/Popover/usePopover.tsx +6 -1
  450. package/src/PowerSearch/PowerSearch.doc.mjs +9 -4
  451. package/src/PowerSearch/PowerSearch.tsx +22 -10
  452. package/src/PowerSearch/PowerSearchEditPopover.tsx +27 -20
  453. package/src/PowerSearch/PowerSearchToken.tsx +17 -6
  454. package/src/PowerSearch/PowerSearchValueEditor.tsx +34 -21
  455. package/src/PowerSearch/formatFilterValue.test.ts +282 -0
  456. package/src/PowerSearch/formatFilterValue.ts +21 -8
  457. package/src/PowerSearch/index.ts +5 -0
  458. package/src/PowerSearch/resolveOperatorLabel.ts +34 -0
  459. package/src/PowerSearch/types.ts +33 -9
  460. package/src/PowerSearch/usePowerSearchConfig.ts +59 -27
  461. package/src/PowerSearch/usePowerSearchSource.ts +17 -8
  462. package/src/RadioList/RadioList.doc.mjs +1 -1
  463. package/src/Resizable/ResizeHandle.tsx +4 -1
  464. package/src/Section/Section.doc.mjs +4 -4
  465. package/src/SelectableCard/SelectableCard.doc.mjs +1 -1
  466. package/src/Selector/Selector.doc.mjs +6 -3
  467. package/src/Selector/Selector.test.tsx +114 -6
  468. package/src/Selector/Selector.tsx +68 -17
  469. package/src/Selector/SelectorOption.doc.mjs +1 -1
  470. package/src/SideNav/SideNav.tsx +4 -2
  471. package/src/SideNav/SideNavCollapseButton.tsx +3 -1
  472. package/src/SideNav/SideNavHeading.tsx +5 -3
  473. package/src/SideNav/SideNavItem.doc.mjs +2 -2
  474. package/src/SideNav/SideNavItem.tsx +3 -1
  475. package/src/Slider/Slider.doc.mjs +2 -2
  476. package/src/Stack/Stack.doc.mjs +10 -10
  477. package/src/Switch/Switch.doc.mjs +3 -3
  478. package/src/Switch/Switch.test.tsx +16 -0
  479. package/src/Switch/Switch.tsx +4 -2
  480. package/src/TabList/Tab.tsx +5 -1
  481. package/src/TabList/TabList.doc.mjs +3 -3
  482. package/src/TabList/TabList.test.tsx +66 -0
  483. package/src/TabList/TabList.tsx +12 -1
  484. package/src/TabList/TabMenu.tsx +4 -1
  485. package/src/Table/BaseTable.tsx +36 -19
  486. package/src/Table/Table.doc.mjs +2 -0
  487. package/src/Table/Table.test.tsx +132 -1
  488. package/src/Table/Table.tsx +6 -4
  489. package/src/Table/index.ts +7 -0
  490. package/src/Table/plugins/columnResize/useTableColumnResize.tsx +1 -1
  491. package/src/Table/plugins/filtering/useTableFiltering.tsx +31 -30
  492. package/src/Table/plugins/groupedRows/useTableGroupedRows.tsx +7 -5
  493. package/src/Table/plugins/pagination/useTablePagination.tsx +4 -1
  494. package/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx +9 -8
  495. package/src/Table/plugins/rowIndex/useTableRowIndex.tsx +1 -1
  496. package/src/Table/plugins/selection/useTableSelection.tsx +6 -7
  497. package/src/Table/plugins/sortable/useTableSortable.tsx +8 -5
  498. package/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx +4 -4
  499. package/src/Table/plugins/tree/index.ts +12 -0
  500. package/src/Table/plugins/tree/useTableTreeData-perf.test.tsx +163 -0
  501. package/src/Table/plugins/tree/useTableTreeData.test.tsx +594 -0
  502. package/src/Table/plugins/tree/useTableTreeData.tsx +495 -0
  503. package/src/Table/plugins/tree/useTableTreeState.test.tsx +636 -0
  504. package/src/Table/plugins/tree/useTableTreeState.tsx +253 -0
  505. package/src/Table/types.ts +18 -12
  506. package/src/Table/useBaseTablePlugins.ts +6 -2
  507. package/src/Table/useTableFiltering.doc.mjs +2 -2
  508. package/src/Table/useTableGroupedRows.doc.mjs +3 -3
  509. package/src/Table/useTableSortable.doc.mjs +11 -11
  510. package/src/Table/useTableTreeData.doc.mjs +75 -0
  511. package/src/Table/useTableTreeState.doc.mjs +98 -0
  512. package/src/Text/Text.doc.mjs +2 -2
  513. package/src/TextArea/TextArea.doc.mjs +1 -1
  514. package/src/TextInput/TextInput.doc.mjs +1 -1
  515. package/src/TextInput/TextInput.tsx +3 -1
  516. package/src/Thumbnail/Thumbnail.tsx +4 -2
  517. package/src/TimeInput/TimeInput.doc.mjs +2 -2
  518. package/src/TimeInput/TimeInput.tsx +6 -2
  519. package/src/Timestamp/Timestamp.doc.mjs +4 -4
  520. package/src/Timestamp/Timestamp.test.tsx +120 -7
  521. package/src/Timestamp/Timestamp.tsx +21 -1
  522. package/src/Toast/Toast.tsx +3 -1
  523. package/src/Toast/ToastViewport.tsx +3 -1
  524. package/src/Token/Token.tsx +4 -2
  525. package/src/Tokenizer/Tokenizer.doc.mjs +2 -2
  526. package/src/Tokenizer/Tokenizer.tsx +4 -4
  527. package/src/Toolbar/Toolbar.doc.mjs +1 -1
  528. package/src/Toolbar/Toolbar.tsx +10 -3
  529. package/src/TopNav/TopNav.doc.mjs +1 -0
  530. package/src/TopNav/TopNav.test.tsx +30 -0
  531. package/src/TopNav/TopNav.tsx +6 -4
  532. package/src/TopNav/TopNavHeading.tsx +5 -3
  533. package/src/TreeList/TreeList.tsx +5 -1
  534. package/src/TreeList/TreeListItem.tsx +6 -1
  535. package/src/Typeahead/BaseTypeahead.tsx +11 -4
  536. package/src/Typeahead/Typeahead.doc.mjs +1 -1
  537. package/src/Typeahead/Typeahead.tsx +3 -1
  538. package/src/VisuallyHidden/VisuallyHidden.tsx +1 -0
  539. package/src/authoring/doc.ts +166 -0
  540. package/src/authoring/index.test.ts +52 -0
  541. package/src/authoring/index.ts +50 -0
  542. package/src/authoring/integration.ts +42 -0
  543. package/src/authoring/template.ts +74 -0
  544. package/src/config.test.ts +16 -0
  545. package/src/config.ts +92 -0
  546. package/src/docPropLiterals.test.ts +938 -0
  547. package/src/docs-types.ts +15 -10
  548. package/src/i18n/InternationalizationContext.ts +39 -0
  549. package/src/i18n/InternationalizationProvider.doc.mjs +72 -0
  550. package/src/i18n/InternationalizationProvider.tsx +82 -0
  551. package/src/i18n/__tests__/e2e-pagination.test.tsx +172 -0
  552. package/src/i18n/__tests__/e2e-powersearch.test.tsx +130 -0
  553. package/src/i18n/__tests__/resolve.test.ts +284 -0
  554. package/src/i18n/index.ts +32 -0
  555. package/src/i18n/resolve.ts +165 -0
  556. package/src/i18n/translator.ts +31 -0
  557. package/src/i18n/types.ts +53 -0
  558. package/src/i18n/useTranslator.doc.mjs +46 -0
  559. package/src/i18n/useTranslator.ts +50 -0
  560. package/src/index.ts +3 -0
  561. package/src/theme/Theme.doc.mjs +4 -4
  562. package/src/theme/Theme.tsx +1 -1
  563. package/src/theme/defineTheme.ts +1 -1
  564. package/src/theme/hct.ts +0 -4
  565. package/src/utils/color.test.ts +101 -1
  566. package/src/utils/color.ts +23 -1
  567. package/src/utils/index.ts +8 -1
  568. package/dist/NavItem/index.d.ts +0 -9
  569. package/dist/NavItem/index.d.ts.map +0 -1
  570. package/dist/NavItem/index.js +0 -10
  571. package/src/NavItem/index.ts +0 -11
@@ -0,0 +1,358 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ /**
6
+ * @file useTableTreeData.tsx
7
+ * @input React, StyleX, Icon, Table types, theme tokens, i18n (useTranslator)
8
+ * @output Exports useTableTreeData hook + config/meta types
9
+ * @position Tree plugin; consumed by Table via plugins prop.
10
+ * Pairs with useTableTreeState (owns expansion state + flattening).
11
+ *
12
+ * ## Architecture (mirrors useTableSelection)
13
+ *
14
+ * The tree affordance decorates the tree column's cells in place — no
15
+ * synthetic column. `transformColumns` wraps the tree column's renderCell
16
+ * with a flex wrapper carrying per-level indentation and an expander
17
+ * button (or a fixed-width spacer on leaves). Other columns get zero
18
+ * extra DOM.
19
+ *
20
+ * Expansion state flows through an external store (TreeStore) so each
21
+ * row's expander subscribes independently — a toggle re-renders only the
22
+ * affected cells, not the whole body. Row ARIA (aria-level,
23
+ * aria-expanded) is applied imperatively via a ref callback on each
24
+ * <tr>, exactly like selection's row styling; each subscription
25
+ * self-cleans when the row disconnects.
26
+ *
27
+ * When `hasExpandableRows` is false (flat data), every transform is a
28
+ * pass-through: adopting the plugin ahead of hierarchical data is a
29
+ * no-op.
30
+ */
31
+ import { createContext, use, useCallback, useEffect, useMemo, useRef, useSyncExternalStore } from 'react';
32
+ import * as stylex from '@stylexjs/stylex';
33
+ import "../../../theme/tokens.stylex.js";
34
+ import { colorVars, radiusVars, spacingVars } from "../../../theme/tokens.stylex.js";
35
+ import { Icon } from "../../../Icon/index.js";
36
+ import { mergeRefs } from "../../../utils/index.js";
37
+ import { useTranslator } from "../../../i18n/index.js";
38
+
39
+ // =============================================================================
40
+ // Types
41
+ // =============================================================================
42
+
43
+ /** Structural position of one visible row within the tree. */
44
+
45
+ /**
46
+ * Configuration for useTableTreeData. `useTableTreeState` returns a
47
+ * ready-made value (`treeConfig`); consumers with server-driven or
48
+ * pre-flattened trees can construct one directly.
49
+ */
50
+
51
+ // =============================================================================
52
+ // Tree Store (external store for fine-grained row subscriptions)
53
+ // =============================================================================
54
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
55
+ function createTreeStore(configRef) {
56
+ const listeners = new Set();
57
+ return {
58
+ subscribe(listener) {
59
+ listeners.add(listener);
60
+ return () => listeners.delete(listener);
61
+ },
62
+ notify() {
63
+ for (const listener of listeners) {
64
+ listener();
65
+ }
66
+ },
67
+ getConfig() {
68
+ return configRef.current;
69
+ }
70
+ };
71
+ }
72
+
73
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
74
+ const TreeStoreContext = /*#__PURE__*/createContext(null);
75
+ TreeStoreContext.displayName = 'TreeStoreContext';
76
+
77
+ /** Indent token -> index, for the numeric row snapshot. */
78
+ const INDENT_INDEX = {
79
+ sm: 0,
80
+ md: 1,
81
+ lg: 2
82
+ };
83
+
84
+ /**
85
+ * Encode a row's tree meta as a primitive for useSyncExternalStore —
86
+ * object snapshots would tear. The indent token participates so a
87
+ * runtime `indent` change re-renders the affected cells.
88
+ * Encoding: level * 16 + indentIndex * 4 + hasChildren * 2 + isExpanded;
89
+ * -1 = no meta.
90
+ */
91
+ function encodeRowMeta(config, item) {
92
+ const meta = config.getRowMeta(item);
93
+ if (!meta) {
94
+ return -1;
95
+ }
96
+ return meta.level * 16 + INDENT_INDEX[config.indent ?? 'md'] * 4 + (meta.hasChildren ? 2 : 0) + (meta.isExpanded ? 1 : 0);
97
+ }
98
+ function useRowMetaSnapshot(store, item) {
99
+ const getSnapshot = useCallback(() => encodeRowMeta(store.getConfig(), item), [store, item]);
100
+ return useSyncExternalStore(store.subscribe, getSnapshot, getSnapshot);
101
+ }
102
+
103
+ // =============================================================================
104
+ // Row ARIA (imperative, mirrors selection's row styling)
105
+ // =============================================================================
106
+
107
+ function applyRowTreeAria(el, meta) {
108
+ if (!meta) {
109
+ el.removeAttribute('aria-level');
110
+ el.removeAttribute('aria-expanded');
111
+ return;
112
+ }
113
+ el.setAttribute('aria-level', String(meta.level + 1));
114
+ if (meta.hasChildren) {
115
+ el.setAttribute('aria-expanded', String(meta.isExpanded));
116
+ } else {
117
+ el.removeAttribute('aria-expanded');
118
+ }
119
+ }
120
+
121
+ // =============================================================================
122
+ // Styles
123
+ // =============================================================================
124
+
125
+ /** Indent step per level, by the `indent` config token. */
126
+ const INDENT_STEP = {
127
+ sm: spacingVars['--spacing-3'],
128
+ md: spacingVars['--spacing-4'],
129
+ lg: spacingVars['--spacing-6']
130
+ };
131
+ const treeStyles = {
132
+ cell: {
133
+ k1xSpc: "x78zum5",
134
+ kGNEyG: "x6s0dn4",
135
+ kOIVth: "xzye2dw",
136
+ $$css: true
137
+ },
138
+ indent: paddingInlineStart => [{
139
+ kZCmMZ: paddingInlineStart != null ? "xnvo3vl" : paddingInlineStart,
140
+ $$css: true
141
+ }, {
142
+ "--x-paddingInlineStart": (val => typeof val === "number" ? val + "px" : val != null ? val : undefined)(paddingInlineStart)
143
+ }]
144
+ };
145
+
146
+ // =============================================================================
147
+ // Cell content
148
+ // =============================================================================
149
+
150
+ function TreeExpander({
151
+ isExpanded,
152
+ onToggle
153
+ }) {
154
+ const t = useTranslator();
155
+ return /*#__PURE__*/_jsx("button", {
156
+ type: "button",
157
+ ...{
158
+ className: "x3nfvp2 x6s0dn4 xl56j7k xvy4d1p xxk0z11 xx3sua9 x1ypdohk xv9yike x1gbuem2 xx6bhzk x1717udv x2lah0s x1ilzqfv x1cqbx0l"
159
+ },
160
+ onClick: e => {
161
+ e.stopPropagation();
162
+ onToggle();
163
+ },
164
+ "aria-label": isExpanded ? t('@astryx.tableTree.collapseRow') : t('@astryx.tableTree.expandRow'),
165
+ "aria-expanded": isExpanded,
166
+ children: /*#__PURE__*/_jsx("span", {
167
+ ...{
168
+ 0: {
169
+ className: "x3nfvp2 x11xpdln xx6bhzk x7p49u4"
170
+ },
171
+ 1: {
172
+ className: "x3nfvp2 x11xpdln xx6bhzk x1iffjtl"
173
+ }
174
+ }[!!isExpanded << 0],
175
+ children: /*#__PURE__*/_jsx(Icon, {
176
+ icon: "chevronRight",
177
+ size: "xsm"
178
+ })
179
+ })
180
+ });
181
+ }
182
+ function TreeCellContent({
183
+ item,
184
+ children
185
+ }) {
186
+ const store = use(TreeStoreContext);
187
+ if (!store) {
188
+ return /*#__PURE__*/_jsx(_Fragment, {
189
+ children: children
190
+ });
191
+ }
192
+ return /*#__PURE__*/_jsx(TreeCellContentInner, {
193
+ store: store,
194
+ item: item,
195
+ children: children
196
+ });
197
+ }
198
+ function TreeCellContentInner({
199
+ store,
200
+ item,
201
+ children
202
+ }) {
203
+ // Subscribe to this row's structural meta so a toggle re-renders only
204
+ // the affected cells.
205
+ useRowMetaSnapshot(store, item);
206
+ const config = store.getConfig();
207
+ const meta = config.getRowMeta(item);
208
+ if (!meta) {
209
+ return /*#__PURE__*/_jsx(_Fragment, {
210
+ children: children
211
+ });
212
+ }
213
+ const step = INDENT_STEP[config.indent ?? 'md'];
214
+ const indent = `calc(${meta.level} * ${step})`;
215
+ return /*#__PURE__*/_jsxs("div", {
216
+ ...stylex.props(treeStyles.cell, meta.level > 0 && treeStyles.indent(indent)),
217
+ children: [meta.hasChildren ? /*#__PURE__*/_jsx(TreeExpander, {
218
+ isExpanded: meta.isExpanded,
219
+ onToggle: () => store.getConfig().onToggleItem(item)
220
+ }) : /*#__PURE__*/_jsx("span", {
221
+ ...{
222
+ className: "x1rg5ohu xvy4d1p xxk0z11 x2lah0s"
223
+ }
224
+ }), children]
225
+ });
226
+ }
227
+
228
+ // =============================================================================
229
+ // Hook
230
+ // =============================================================================
231
+
232
+ export function useTableTreeData(config) {
233
+ const configRef = useRef(config);
234
+ configRef.current = config;
235
+ const storeRef = useRef(null);
236
+ if (storeRef.current == null) {
237
+ storeRef.current = createTreeStore(configRef);
238
+ }
239
+ const store = storeRef.current;
240
+
241
+ // Notify subscribers on every render — useSyncExternalStore only
242
+ // re-renders cells whose snapshot actually changed. Row ref subscribers
243
+ // apply imperative ARIA independently.
244
+ useEffect(() => {
245
+ store.notify();
246
+ });
247
+
248
+ // transformColumns runs on every table render; wrapped column objects
249
+ // must keep their identity across renders or the per-row memo breaks
250
+ // and a toggle re-renders the whole body. Earlier plugins may rebuild
251
+ // structurally-identical arrays each render, so the cache compares
252
+ // input columns by shallow equality, not array identity. Held in a ref
253
+ // (like rowExpansion's column tracking) — transforms run during
254
+ // BaseTable's render, where a closure variable reassignment trips the
255
+ // react-compiler lint.
256
+ const columnsCacheRef = useRef(null);
257
+
258
+ // The plugin object is created once per store and never changes shape:
259
+ // every transform reads the live config through the store, and
260
+ // internally no-ops when hasExpandableRows is false. Swapping between
261
+ // an empty and a context-wrapping plugin would change the element tree
262
+ // and remount the whole table when flat data turns nested.
263
+ return useMemo(() => {
264
+ const getCachedColumns = (columns, treeKey, wrapped) => {
265
+ const cache = columnsCacheRef.current;
266
+ if (!cache || cache.treeKey !== treeKey || cache.wrapped !== wrapped) {
267
+ return null;
268
+ }
269
+ const prev = cache.input;
270
+ if (prev !== columns) {
271
+ if (prev.length !== columns.length) {
272
+ return null;
273
+ }
274
+ for (let i = 0; i < prev.length; i++) {
275
+ if (prev[i] !== columns[i]) {
276
+ return null;
277
+ }
278
+ }
279
+ }
280
+ return cache.output;
281
+ };
282
+ return {
283
+ transformTableContext(children) {
284
+ return /*#__PURE__*/_jsx(TreeStoreContext, {
285
+ value: store,
286
+ children: children
287
+ });
288
+ },
289
+ transformColumns(columns) {
290
+ const {
291
+ hasExpandableRows,
292
+ treeColumnKey
293
+ } = store.getConfig();
294
+
295
+ // Resolve the tree column: the configured key when present, else
296
+ // the first non-synthetic column (a configured column may have
297
+ // been hidden by columnSettings — the expander must not vanish).
298
+ const configuredExists = treeColumnKey != null && columns.some(c => c.key === treeColumnKey);
299
+ const treeKey = configuredExists ? treeColumnKey : columns.find(c => !c.key.startsWith('__'))?.key ?? columns[0]?.key;
300
+
301
+ // Migration guarantee: flat data renders identically to a Table
302
+ // without the plugin.
303
+ const wrapped = hasExpandableRows;
304
+ const cached = getCachedColumns(columns, treeKey, wrapped);
305
+ if (cached) {
306
+ return cached;
307
+ }
308
+ const output = !wrapped ? columns : columns.map(col => {
309
+ if (col.key !== treeKey) {
310
+ return col;
311
+ }
312
+ const originalRenderCell = col.renderCell;
313
+ return {
314
+ ...col,
315
+ renderCell: item => /*#__PURE__*/_jsx(TreeCellContent, {
316
+ item: item,
317
+ children: originalRenderCell ? originalRenderCell(item) : String(item[col.key] ?? '')
318
+ })
319
+ };
320
+ });
321
+ columnsCacheRef.current = {
322
+ input: columns,
323
+ treeKey,
324
+ wrapped,
325
+ output
326
+ };
327
+ return output;
328
+ },
329
+ transformBodyRow(props, item) {
330
+ // Attach a ref that subscribes to the store for imperative row
331
+ // ARIA. The ref returns a cleanup so React unsubscribes on
332
+ // detach — without it, every row re-render would leak one
333
+ // subscription (toggles shift rowIndex and re-render rows, so
334
+ // the listener set would grow on every toggle). The ref is
335
+ // attached even when no row is expandable so tree ARIA is
336
+ // removed if the data turns flat.
337
+ const treeRef = el => {
338
+ if (!el) {
339
+ return;
340
+ }
341
+ const apply = () => {
342
+ const cfg = store.getConfig();
343
+ applyRowTreeAria(el, cfg.hasExpandableRows ? cfg.getRowMeta(item) : undefined);
344
+ };
345
+ apply();
346
+ const unsub = store.subscribe(apply);
347
+ return () => {
348
+ unsub();
349
+ };
350
+ };
351
+ return {
352
+ ...props,
353
+ ref: props.ref ? mergeRefs(props.ref, treeRef) : treeRef
354
+ };
355
+ }
356
+ };
357
+ }, [store]);
358
+ }
@@ -0,0 +1,51 @@
1
+ import type { UseTableTreeDataConfig } from './useTableTreeData';
2
+ export interface UseTableTreeStateConfig<T extends Record<string, unknown>> {
3
+ /** Nested data: rows may carry child rows under `childrenKey`. */
4
+ data: T[];
5
+ /** Row ID accessor: property name, or a function returning a unique id. */
6
+ idKey: (keyof T & string) | ((item: T) => string | number);
7
+ /**
8
+ * Property holding each row's children array.
9
+ * @default 'children'
10
+ */
11
+ childrenKey?: string;
12
+ /** Initial expanded row ids for uncontrolled mode. Ignored when `expandedIds` is provided. */
13
+ defaultExpandedIds?: Iterable<string>;
14
+ /**
15
+ * Controlled set of expanded row ids. When provided, the hook uses this
16
+ * instead of internal state. Pair with `onExpandedIdsChange`.
17
+ */
18
+ expandedIds?: ReadonlySet<string>;
19
+ /** Called with the next expanded set whenever expansion changes. */
20
+ onExpandedIdsChange?: (ids: ReadonlySet<string>) => void;
21
+ /**
22
+ * Should this row show an expander? Overrides the default
23
+ * "has a non-empty children array" check — use for lazy loading, where a
24
+ * row is expandable before its children have been fetched.
25
+ */
26
+ isItemExpandable?: (item: T) => boolean;
27
+ /**
28
+ * Sort each sibling group independently during flattening. Children always
29
+ * stay directly under their parent — sorting never crosses levels. Pass
30
+ * `applySort` from `useTableSortableState` to compose with column sorting.
31
+ */
32
+ sortSiblings?: (siblings: T[]) => T[];
33
+ /** Indent step per level, forwarded to useTableTreeData. */
34
+ indent?: 'sm' | 'md' | 'lg';
35
+ /** Column that carries the tree affordance, forwarded to useTableTreeData. */
36
+ treeColumnKey?: string;
37
+ }
38
+ export interface UseTableTreeStateResult<T extends Record<string, unknown>> {
39
+ /** The flattened, currently-visible rows. Pass to `<Table data>`. */
40
+ visibleData: T[];
41
+ /** Ready-to-use config for useTableTreeData. */
42
+ treeConfig: UseTableTreeDataConfig<T>;
43
+ /** The current expanded row ids. */
44
+ expandedIds: ReadonlySet<string>;
45
+ /** Expand every expandable row in the tree. */
46
+ expandAll: () => void;
47
+ /** Collapse every row. */
48
+ collapseAll: () => void;
49
+ }
50
+ export declare function useTableTreeState<T extends Record<string, unknown>>(config: UseTableTreeStateConfig<T>): UseTableTreeStateResult<T>;
51
+ //# sourceMappingURL=useTableTreeState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTableTreeState.d.ts","sourceRoot":"","sources":["../../../../src/Table/plugins/tree/useTableTreeState.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAEV,sBAAsB,EACvB,MAAM,oBAAoB,CAAC;AAM5B,MAAM,WAAW,uBAAuB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACxE,kEAAkE;IAClE,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,2EAA2E;IAC3E,KAAK,EAAE,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,CAAC,CAAC;IAC3D;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8FAA8F;IAC9F,kBAAkB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACtC;;;OAGG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAClC,oEAAoE;IACpE,mBAAmB,CAAC,EAAE,CAAC,GAAG,EAAE,WAAW,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC;IACzD;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC;IACxC;;;;OAIG;IACH,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;IACtC,4DAA4D;IAC5D,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC5B,8EAA8E;IAC9E,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAMD,MAAM,WAAW,uBAAuB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACxE,qEAAqE;IACrE,WAAW,EAAE,CAAC,EAAE,CAAC;IACjB,gDAAgD;IAChD,UAAU,EAAE,sBAAsB,CAAC,CAAC,CAAC,CAAC;IACtC,oCAAoC;IACpC,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACjC,+CAA+C;IAC/C,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,0BAA0B;IAC1B,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB;AAMD,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjE,MAAM,EAAE,uBAAuB,CAAC,CAAC,CAAC,GACjC,uBAAuB,CAAC,CAAC,CAAC,CAoK5B"}
@@ -0,0 +1,175 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ /**
6
+ * @file useTableTreeState.tsx
7
+ * @input React
8
+ * @output Exports useTableTreeState hook and config/result types
9
+ * @position Tree state helper; owns the expanded set + flattens nested data.
10
+ * Pairs with useTableTreeData (the headless tree plugin).
11
+ *
12
+ * Modeled after useTableSortableState — a convenience layer that owns state
13
+ * (controlled or uncontrolled) and produces both the visible flattened rows
14
+ * and a ready-to-use config for the headless plugin. Data shaping stays
15
+ * outside the render pipeline: Table always receives exactly the rows it
16
+ * renders, so collapsed subtrees are unmounted, not hidden.
17
+ */
18
+ import { useCallback, useMemo, useRef, useState } from 'react';
19
+
20
+ // =============================================================================
21
+ // Config
22
+ // =============================================================================
23
+
24
+ // =============================================================================
25
+ // Result
26
+ // =============================================================================
27
+
28
+ // =============================================================================
29
+ // Hook
30
+ // =============================================================================
31
+
32
+ export function useTableTreeState(config) {
33
+ const {
34
+ data,
35
+ idKey,
36
+ childrenKey = 'children',
37
+ defaultExpandedIds,
38
+ expandedIds: controlledExpandedIds,
39
+ onExpandedIdsChange,
40
+ isItemExpandable,
41
+ sortSiblings,
42
+ indent,
43
+ treeColumnKey
44
+ } = config;
45
+ const getId = useCallback(item => typeof idKey === 'function' ? String(idKey(item)) : String(item[idKey]), [idKey]);
46
+ const getChildren = useCallback(item => {
47
+ const children = item[childrenKey];
48
+ return Array.isArray(children) ? children : [];
49
+ }, [childrenKey]);
50
+ const getIsExpandable = useCallback(item => isItemExpandable ? isItemExpandable(item) : getChildren(item).length > 0, [isItemExpandable, getChildren]);
51
+
52
+ // Internal state (used in uncontrolled mode)
53
+ const [internalExpandedIds, setInternalExpandedIds] = useState(() => new Set(defaultExpandedIds));
54
+
55
+ // Resolve controlled vs uncontrolled
56
+ const isControlled = controlledExpandedIds !== undefined;
57
+ const expandedIds = isControlled ? controlledExpandedIds : internalExpandedIds;
58
+
59
+ // Stable refs so callbacks don't churn on inline-prop identity changes
60
+ const expandedIdsRef = useRef(expandedIds);
61
+ expandedIdsRef.current = expandedIds;
62
+ const onExpandedIdsChangeRef = useRef(onExpandedIdsChange);
63
+ onExpandedIdsChangeRef.current = onExpandedIdsChange;
64
+ const commitExpandedIds = useCallback(next => {
65
+ // Advance the ref immediately so a second commit in the same React
66
+ // batch (e.g. two onToggleItem calls in one event handler) builds
67
+ // on this one instead of the pre-batch set. The ref re-syncs from
68
+ // the resolved state on the next render either way.
69
+ expandedIdsRef.current = next;
70
+ if (!isControlled) {
71
+ setInternalExpandedIds(next);
72
+ }
73
+ onExpandedIdsChangeRef.current?.(next);
74
+ }, [isControlled]);
75
+
76
+ // Flatten: depth-first walk emitting only visible rows, collecting per-row
77
+ // meta ({level, hasChildren, isExpanded}) in the same pass. Children mount
78
+ // only when their parent is expanded, so collapsed subtrees stay unmounted.
79
+ // `path` holds the ids on the current ancestor chain: an edge pointing back
80
+ // at an ancestor is skipped instead of recursing forever. Sibling arrays
81
+ // are copied before sortSiblings so an in-place sorter can't reorder the
82
+ // consumer's data.
83
+ const {
84
+ visibleData,
85
+ metaMap
86
+ } = useMemo(() => {
87
+ const rows = [];
88
+ const meta = new Map();
89
+ const path = new Set();
90
+ const walk = (items, level) => {
91
+ const siblings = sortSiblings ? sortSiblings([...items]) : items;
92
+ for (const item of siblings) {
93
+ const id = getId(item);
94
+ if (path.has(id)) {
95
+ continue; // cyclic edge — this row is its own ancestor
96
+ }
97
+ const hasChildren = getIsExpandable(item);
98
+ const isExpanded = hasChildren && expandedIds.has(id);
99
+ rows.push(item);
100
+ meta.set(id, {
101
+ id,
102
+ level,
103
+ hasChildren,
104
+ isExpanded
105
+ });
106
+ if (isExpanded) {
107
+ path.add(id);
108
+ walk(getChildren(item), level + 1);
109
+ path.delete(id);
110
+ }
111
+ }
112
+ };
113
+ walk(data, 0);
114
+ return {
115
+ visibleData: rows,
116
+ metaMap: meta
117
+ };
118
+ }, [data, expandedIds, getId, getChildren, getIsExpandable, sortSiblings]);
119
+
120
+ // Every expandable row id across the whole tree, including collapsed
121
+ // subtrees (drives expandAll and the migration no-op flag). Same
122
+ // ancestor-chain guard as the flatten walk.
123
+ const allExpandableIds = useMemo(() => {
124
+ const idsAcc = [];
125
+ const path = new Set();
126
+ const walk = items => {
127
+ for (const item of items) {
128
+ const id = getId(item);
129
+ if (path.has(id)) {
130
+ continue;
131
+ }
132
+ if (getIsExpandable(item)) {
133
+ idsAcc.push(id);
134
+ }
135
+ path.add(id);
136
+ walk(getChildren(item));
137
+ path.delete(id);
138
+ }
139
+ };
140
+ walk(data);
141
+ return idsAcc;
142
+ }, [data, getId, getChildren, getIsExpandable]);
143
+ const hasExpandableRows = allExpandableIds.length > 0;
144
+ const onToggleItem = useCallback(item => {
145
+ const id = getId(item);
146
+ const next = new Set(expandedIdsRef.current);
147
+ if (next.has(id)) {
148
+ next.delete(id);
149
+ } else {
150
+ next.add(id);
151
+ }
152
+ commitExpandedIds(next);
153
+ }, [getId, commitExpandedIds]);
154
+ const expandAll = useCallback(() => {
155
+ commitExpandedIds(new Set(allExpandableIds));
156
+ }, [commitExpandedIds, allExpandableIds]);
157
+ const collapseAll = useCallback(() => {
158
+ commitExpandedIds(new Set());
159
+ }, [commitExpandedIds]);
160
+ const getRowMeta = useCallback(item => metaMap.get(getId(item)), [metaMap, getId]);
161
+ const treeConfig = useMemo(() => ({
162
+ getRowMeta,
163
+ onToggleItem,
164
+ hasExpandableRows,
165
+ indent,
166
+ treeColumnKey
167
+ }), [getRowMeta, onToggleItem, hasExpandableRows, indent, treeColumnKey]);
168
+ return {
169
+ visibleData,
170
+ treeConfig,
171
+ expandedIds,
172
+ expandAll,
173
+ collapseAll
174
+ };
175
+ }
@@ -181,12 +181,12 @@ export interface TableColumn<T extends Record<string, unknown>> {
181
181
  /** Props passed through the plugin pipeline for the `<table>` element */
182
182
  export interface TableRenderProps {
183
183
  htmlProps: HTMLAttributes<HTMLTableElement>;
184
- styles: StyleXStyles[];
184
+ xstyle: StyleXStyles[];
185
185
  }
186
186
  /** Props passed through the plugin pipeline for the header `<tr>` */
187
187
  export interface HeaderRowRenderProps {
188
188
  htmlProps: HTMLAttributes<HTMLTableRowElement>;
189
- styles: StyleXStyles[];
189
+ xstyle: StyleXStyles[];
190
190
  children: ReactNode;
191
191
  }
192
192
  /**
@@ -206,7 +206,7 @@ export interface HeaderRowRenderProps {
206
206
  */
207
207
  export interface HeaderCellRenderProps {
208
208
  htmlProps: ThHTMLAttributes<HTMLTableCellElement>;
209
- styles: StyleXStyles[];
209
+ xstyle: StyleXStyles[];
210
210
  /** Content rendered before the header label. */
211
211
  before?: ReactNode;
212
212
  /** The header label content. Initialized from `column.header ?? column.key`. Plugins may wrap or replace. */
@@ -241,7 +241,7 @@ export interface HeaderCellRenderProps {
241
241
  /** Props passed through the plugin pipeline for each body `<tr>` */
242
242
  export interface BodyRowRenderProps {
243
243
  htmlProps: HTMLAttributes<HTMLTableRowElement>;
244
- styles: StyleXStyles[];
244
+ xstyle: StyleXStyles[];
245
245
  children: ReactNode;
246
246
  /** Ref for the `<tr>` element. Plugins can set this to access the row DOM node. */
247
247
  ref?: Ref<HTMLTableRowElement>;
@@ -249,7 +249,7 @@ export interface BodyRowRenderProps {
249
249
  /** Props passed through the plugin pipeline for each body `<td>` */
250
250
  export interface BodyCellRenderProps {
251
251
  htmlProps: TdHTMLAttributes<HTMLTableCellElement>;
252
- styles: StyleXStyles[];
252
+ xstyle: StyleXStyles[];
253
253
  /**
254
254
  * Right-click context-menu actions for this body cell. Plugins append their
255
255
  * actions in `transformBodyCell`; BaseTable concatenates the arrays across
@@ -294,7 +294,7 @@ export interface ScrollWrapperRenderProps {
294
294
  htmlProps: HTMLAttributes<HTMLDivElement> & {
295
295
  ref?: Ref<HTMLDivElement>;
296
296
  };
297
- styles: StyleXStyles[];
297
+ xstyle: StyleXStyles[];
298
298
  /** Content rendered before the `<table>`, inside the scroll container. */
299
299
  beforeTable?: ReactNode;
300
300
  /** Content rendered after the `<table>`, inside the scroll container. */
@@ -449,7 +449,14 @@ export interface BaseTableProps<T extends Record<string, unknown>> extends BaseP
449
449
  plugins?: TablePlugin<T>[];
450
450
  /** Children mode — render `<tr>`/`<td>` directly instead of data-driven */
451
451
  children?: ReactNode;
452
- /** Additional HTML attributes for the `<table>` element */
452
+ /**
453
+ * Additional HTML attributes for the `<table>` element.
454
+ *
455
+ * @deprecated Pass `className`, `style`, `xstyle`, and other HTML
456
+ * attributes directly on the component instead — they now reach the root
457
+ * `<table>` and win over `tableProps` on conflicts. Migrate with
458
+ * `npx astryx upgrade --codemod migrate-table-tableprops-to-direct-props`.
459
+ */
453
460
  tableProps?: HTMLAttributes<HTMLTableElement>;
454
461
  /**
455
462
  * Optional wrapper rendered around the `<table>` element, inside the
@@ -457,9 +464,9 @@ export interface BaseTableProps<T extends Record<string, unknown>> extends BaseP
457
464
  * horizontal scroll container so plugin chrome (pagination, toolbars)
458
465
  * stays outside the scrollable area.
459
466
  *
460
- * Receives `htmlProps` (including an optional `ref`) and `styles` produced
467
+ * Receives `htmlProps` (including an optional `ref`) and `xstyle` produced
461
468
  * by the plugin `transformScrollWrapper` pipeline, plus `beforeTable`/`afterTable`
462
- * chrome. The wrapper must spread `htmlProps` (and apply `styles`) onto its
469
+ * chrome. The wrapper must spread `htmlProps` (and apply `xstyle`) onto its
463
470
  * scroll-container element so plugins can attach refs / scroll listeners.
464
471
  */
465
472
  scrollWrapper?: ComponentType<{
@@ -467,7 +474,7 @@ export interface BaseTableProps<T extends Record<string, unknown>> extends BaseP
467
474
  htmlProps?: HTMLAttributes<HTMLDivElement> & {
468
475
  ref?: Ref<HTMLDivElement>;
469
476
  };
470
- styles?: StyleXStyles[];
477
+ xstyle?: StyleXStyles[];
471
478
  beforeTable?: ReactNode;
472
479
  afterTable?: ReactNode;
473
480
  }>;