@astryxdesign/core 0.1.5 → 0.1.6-canary.02f2602

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 (564) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +2 -0
  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 +21 -18
  6. package/dist/AlertDialog/useImperativeAlertDialog.d.ts +0 -2
  7. package/dist/AlertDialog/useImperativeAlertDialog.d.ts.map +1 -1
  8. package/dist/AlertDialog/useImperativeAlertDialog.js +3 -5
  9. package/dist/AppShell/AppShell.d.ts.map +1 -1
  10. package/dist/AppShell/AppShell.js +55 -53
  11. package/dist/AspectRatio/AspectRatio.js +5 -5
  12. package/dist/Avatar/Avatar.js +19 -19
  13. package/dist/Avatar/AvatarStatusDot.js +5 -5
  14. package/dist/AvatarGroup/AvatarGroup.d.ts +1 -1
  15. package/dist/AvatarGroup/AvatarGroup.d.ts.map +1 -1
  16. package/dist/AvatarGroup/AvatarGroup.js +9 -6
  17. package/dist/AvatarGroup/AvatarGroupOverflow.js +5 -5
  18. package/dist/Badge/Badge.js +3 -3
  19. package/dist/Banner/Banner.d.ts.map +1 -1
  20. package/dist/Banner/Banner.js +32 -30
  21. package/dist/Blockquote/Blockquote.js +7 -7
  22. package/dist/Breadcrumbs/BreadcrumbItem.js +17 -17
  23. package/dist/Breadcrumbs/Breadcrumbs.d.ts +1 -1
  24. package/dist/Breadcrumbs/Breadcrumbs.d.ts.map +1 -1
  25. package/dist/Breadcrumbs/Breadcrumbs.js +11 -8
  26. package/dist/Button/Button.d.ts.map +1 -1
  27. package/dist/Button/Button.js +53 -23
  28. package/dist/ButtonGroup/ButtonGroup.d.ts +20 -5
  29. package/dist/ButtonGroup/ButtonGroup.d.ts.map +1 -1
  30. package/dist/ButtonGroup/ButtonGroup.js +34 -18
  31. package/dist/Calendar/Calendar.d.ts.map +1 -1
  32. package/dist/Calendar/Calendar.js +51 -48
  33. package/dist/Card/Card.js +3 -3
  34. package/dist/Carousel/Carousel.d.ts +1 -1
  35. package/dist/Carousel/Carousel.d.ts.map +1 -1
  36. package/dist/Carousel/Carousel.js +27 -24
  37. package/dist/Center/Center.js +3 -3
  38. package/dist/Chat/ChatComposer.d.ts.map +1 -1
  39. package/dist/Chat/ChatComposer.js +27 -24
  40. package/dist/Chat/ChatComposerDrawer.d.ts +1 -1
  41. package/dist/Chat/ChatComposerDrawer.d.ts.map +1 -1
  42. package/dist/Chat/ChatComposerDrawer.js +23 -16
  43. package/dist/Chat/ChatComposerInput.d.ts.map +1 -1
  44. package/dist/Chat/ChatComposerInput.js +20 -16
  45. package/dist/Chat/ChatDictationButton.js +10 -10
  46. package/dist/Chat/ChatLayout.d.ts +1 -11
  47. package/dist/Chat/ChatLayout.d.ts.map +1 -1
  48. package/dist/Chat/ChatLayout.js +23 -21
  49. package/dist/Chat/ChatLayoutScrollButton.d.ts.map +1 -1
  50. package/dist/Chat/ChatLayoutScrollButton.js +13 -11
  51. package/dist/Chat/ChatMessage.d.ts +1 -1
  52. package/dist/Chat/ChatMessage.d.ts.map +1 -1
  53. package/dist/Chat/ChatMessage.js +20 -14
  54. package/dist/Chat/ChatMessageBubble.d.ts +1 -1
  55. package/dist/Chat/ChatMessageBubble.d.ts.map +1 -1
  56. package/dist/Chat/ChatMessageBubble.js +10 -8
  57. package/dist/Chat/ChatMessageList.d.ts +1 -1
  58. package/dist/Chat/ChatMessageList.d.ts.map +1 -1
  59. package/dist/Chat/ChatMessageList.js +17 -15
  60. package/dist/Chat/ChatMessageMetadata.d.ts.map +1 -1
  61. package/dist/Chat/ChatMessageMetadata.js +24 -19
  62. package/dist/Chat/ChatPastedTextToken.d.ts.map +1 -1
  63. package/dist/Chat/ChatPastedTextToken.js +16 -14
  64. package/dist/Chat/ChatSendButton.d.ts.map +1 -1
  65. package/dist/Chat/ChatSendButton.js +6 -4
  66. package/dist/Chat/ChatSystemMessage.js +11 -11
  67. package/dist/Chat/ChatTokenizedText.js +8 -8
  68. package/dist/Chat/ChatToolCalls.js +73 -73
  69. package/dist/Chat/useSpeechRecognition.d.ts.map +1 -1
  70. package/dist/Chat/useSpeechRecognition.js +4 -2
  71. package/dist/Chat/useTriggerMenu.d.ts.map +1 -1
  72. package/dist/Chat/useTriggerMenu.js +19 -17
  73. package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
  74. package/dist/CheckboxInput/CheckboxInput.js +26 -24
  75. package/dist/CheckboxList/CheckboxList.d.ts +1 -1
  76. package/dist/CheckboxList/CheckboxList.d.ts.map +1 -1
  77. package/dist/CheckboxList/CheckboxList.js +12 -10
  78. package/dist/CheckboxList/CheckboxListItem.d.ts.map +1 -1
  79. package/dist/CheckboxList/CheckboxListItem.js +8 -6
  80. package/dist/Citation/Citation.d.ts.map +1 -1
  81. package/dist/Citation/Citation.js +20 -12
  82. package/dist/ClickableCard/ClickableCard.js +6 -6
  83. package/dist/Code/Code.js +3 -3
  84. package/dist/CodeBlock/CodeBlock.d.ts.map +1 -1
  85. package/dist/CodeBlock/CodeBlock.js +114 -96
  86. package/dist/Collapsible/Collapsible.js +11 -11
  87. package/dist/Collapsible/CollapsibleGroup.js +7 -7
  88. package/dist/CommandPalette/CommandPalette.d.ts +1 -1
  89. package/dist/CommandPalette/CommandPalette.d.ts.map +1 -1
  90. package/dist/CommandPalette/CommandPalette.js +39 -34
  91. package/dist/CommandPalette/CommandPaletteEmpty.js +3 -3
  92. package/dist/CommandPalette/CommandPaletteFooter.js +16 -16
  93. package/dist/CommandPalette/CommandPaletteGroup.js +5 -5
  94. package/dist/CommandPalette/CommandPaletteInput.d.ts +1 -1
  95. package/dist/CommandPalette/CommandPaletteInput.d.ts.map +1 -1
  96. package/dist/CommandPalette/CommandPaletteInput.js +17 -14
  97. package/dist/CommandPalette/CommandPaletteItem.js +3 -3
  98. package/dist/CommandPalette/CommandPaletteList.d.ts +1 -1
  99. package/dist/CommandPalette/CommandPaletteList.d.ts.map +1 -1
  100. package/dist/CommandPalette/CommandPaletteList.js +7 -4
  101. package/dist/ContextMenu/ContextMenu.d.ts +1 -1
  102. package/dist/ContextMenu/ContextMenu.d.ts.map +1 -1
  103. package/dist/ContextMenu/ContextMenu.js +14 -11
  104. package/dist/DateInput/DateInput.d.ts +1 -1
  105. package/dist/DateInput/DateInput.d.ts.map +1 -1
  106. package/dist/DateInput/DateInput.js +28 -23
  107. package/dist/DateRangeInput/DateRangeInput.d.ts +1 -1
  108. package/dist/DateRangeInput/DateRangeInput.d.ts.map +1 -1
  109. package/dist/DateRangeInput/DateRangeInput.js +32 -27
  110. package/dist/DateTimeInput/DateTimeInput.d.ts +1 -1
  111. package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
  112. package/dist/DateTimeInput/DateTimeInput.js +41 -33
  113. package/dist/Dialog/Dialog.js +9 -9
  114. package/dist/Dialog/DialogHeader.d.ts.map +1 -1
  115. package/dist/Dialog/DialogHeader.js +20 -18
  116. package/dist/Dialog/useImperativeDialog.js +3 -3
  117. package/dist/Divider/Divider.js +7 -7
  118. package/dist/DropdownMenu/DropdownMenu.d.ts +1 -1
  119. package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
  120. package/dist/DropdownMenu/DropdownMenu.js +21 -15
  121. package/dist/DropdownMenu/DropdownMenuItem.js +3 -3
  122. package/dist/DropdownMenu/renderDropdownItems.js +10 -10
  123. package/dist/EmptyState/EmptyState.d.ts +4 -1
  124. package/dist/EmptyState/EmptyState.d.ts.map +1 -1
  125. package/dist/EmptyState/EmptyState.js +9 -9
  126. package/dist/Field/Field.js +17 -17
  127. package/dist/Field/FieldLabel.js +15 -15
  128. package/dist/Field/InputClearButton.js +5 -5
  129. package/dist/FieldStatus/FieldStatus.js +3 -3
  130. package/dist/FileInput/FileInput.d.ts.map +1 -1
  131. package/dist/FileInput/FileInput.js +34 -30
  132. package/dist/FormLayout/FormLayout.js +5 -5
  133. package/dist/Grid/Grid.js +3 -3
  134. package/dist/Grid/GridSpan.js +3 -3
  135. package/dist/HStack/HStack.js +3 -3
  136. package/dist/Heading/Heading.js +10 -10
  137. package/dist/HoverCard/HoverCard.js +9 -9
  138. package/dist/HoverCard/useHoverCard.js +3 -3
  139. package/dist/Icon/Icon.js +11 -11
  140. package/dist/Icon/defaultIcons.js +116 -116
  141. package/dist/IconButton/IconButton.js +3 -3
  142. package/dist/InputGroup/InputGroup.js +9 -9
  143. package/dist/InputGroup/InputGroupText.js +3 -3
  144. package/dist/Item/Item.js +17 -17
  145. package/dist/Kbd/Kbd.js +5 -5
  146. package/dist/Layer/LayerProvider.js +7 -7
  147. package/dist/Layer/useLayer.js +5 -5
  148. package/dist/Layout/Layout.js +21 -21
  149. package/dist/Layout/LayoutContent.js +3 -3
  150. package/dist/Layout/LayoutFooter.js +5 -5
  151. package/dist/Layout/LayoutHeader.js +5 -5
  152. package/dist/Layout/LayoutPanel.js +3 -3
  153. package/dist/Lightbox/Lightbox.d.ts.map +1 -1
  154. package/dist/Lightbox/Lightbox.js +35 -33
  155. package/dist/Lightbox/useLightbox.d.ts +0 -1
  156. package/dist/Lightbox/useLightbox.d.ts.map +1 -1
  157. package/dist/Lightbox/useLightbox.js +3 -4
  158. package/dist/Link/Link.d.ts +5 -3
  159. package/dist/Link/Link.d.ts.map +1 -1
  160. package/dist/Link/Link.js +47 -18
  161. package/dist/Link/LinkProvider.js +3 -3
  162. package/dist/Link/useLinkify.js +3 -3
  163. package/dist/List/List.js +11 -11
  164. package/dist/List/ListItem.js +11 -11
  165. package/dist/Markdown/Markdown.d.ts.map +1 -1
  166. package/dist/Markdown/Markdown.js +111 -109
  167. package/dist/MetadataList/MetadataList.js +10 -10
  168. package/dist/MetadataList/MetadataListItem.js +15 -15
  169. package/dist/MobileNav/MobileNav.d.ts.map +1 -1
  170. package/dist/MobileNav/MobileNav.js +19 -17
  171. package/dist/MobileNav/MobileNavToggle.d.ts +1 -1
  172. package/dist/MobileNav/MobileNavToggle.d.ts.map +1 -1
  173. package/dist/MobileNav/MobileNavToggle.js +9 -6
  174. package/dist/MoreMenu/MoreMenu.d.ts +1 -1
  175. package/dist/MoreMenu/MoreMenu.d.ts.map +1 -1
  176. package/dist/MoreMenu/MoreMenu.js +7 -4
  177. package/dist/MultiSelector/MultiSelector.d.ts +1 -1
  178. package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
  179. package/dist/MultiSelector/MultiSelector.js +69 -62
  180. package/dist/NavIcon/NavIcon.js +3 -3
  181. package/dist/NavMenu/NavHeadingMenu.js +5 -5
  182. package/dist/NavMenu/NavHeadingMenuItem.js +8 -8
  183. package/dist/NumberInput/NumberInput.d.ts.map +1 -1
  184. package/dist/NumberInput/NumberInput.js +21 -17
  185. package/dist/Outline/Outline.d.ts +1 -1
  186. package/dist/Outline/Outline.d.ts.map +1 -1
  187. package/dist/Outline/Outline.js +19 -16
  188. package/dist/OverflowList/OverflowList.js +8 -8
  189. package/dist/Overlay/Overlay.js +3 -3
  190. package/dist/Overlay/OverlayScrim.js +5 -5
  191. package/dist/Overlay/useOverlay.d.ts +0 -3
  192. package/dist/Overlay/useOverlay.d.ts.map +1 -1
  193. package/dist/Overlay/useOverlay.js +3 -6
  194. package/dist/Pagination/Pagination.d.ts +1 -1
  195. package/dist/Pagination/Pagination.d.ts.map +1 -1
  196. package/dist/Pagination/Pagination.js +73 -46
  197. package/dist/Popover/Popover.js +16 -16
  198. package/dist/Popover/usePopover.d.ts.map +1 -1
  199. package/dist/Popover/usePopover.js +11 -8
  200. package/dist/PowerSearch/PowerSearch.d.ts +1 -1
  201. package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
  202. package/dist/PowerSearch/PowerSearch.js +95 -85
  203. package/dist/PowerSearch/PowerSearchEditPopover.d.ts +1 -1
  204. package/dist/PowerSearch/PowerSearchEditPopover.d.ts.map +1 -1
  205. package/dist/PowerSearch/PowerSearchEditPopover.js +109 -103
  206. package/dist/PowerSearch/PowerSearchFilterEditor.js +3 -3
  207. package/dist/PowerSearch/PowerSearchToken.d.ts.map +1 -1
  208. package/dist/PowerSearch/PowerSearchToken.js +12 -8
  209. package/dist/PowerSearch/PowerSearchValueEditor.d.ts.map +1 -1
  210. package/dist/PowerSearch/PowerSearchValueEditor.js +88 -75
  211. package/dist/PowerSearch/formatFilterValue.d.ts +2 -1
  212. package/dist/PowerSearch/formatFilterValue.d.ts.map +1 -1
  213. package/dist/PowerSearch/formatFilterValue.js +19 -9
  214. package/dist/PowerSearch/index.d.ts +2 -1
  215. package/dist/PowerSearch/index.d.ts.map +1 -1
  216. package/dist/PowerSearch/index.js +1 -0
  217. package/dist/PowerSearch/resolveOperatorLabel.d.ts +23 -0
  218. package/dist/PowerSearch/resolveOperatorLabel.d.ts.map +1 -0
  219. package/dist/PowerSearch/resolveOperatorLabel.js +28 -0
  220. package/dist/PowerSearch/types.d.ts +28 -2
  221. package/dist/PowerSearch/types.d.ts.map +1 -1
  222. package/dist/PowerSearch/usePowerSearchConfig.d.ts.map +1 -1
  223. package/dist/PowerSearch/usePowerSearchConfig.js +27 -27
  224. package/dist/PowerSearch/usePowerSearchSource.d.ts.map +1 -1
  225. package/dist/PowerSearch/usePowerSearchSource.js +15 -8
  226. package/dist/ProgressBar/ProgressBar.js +13 -13
  227. package/dist/RadioList/RadioList.js +7 -7
  228. package/dist/RadioList/RadioListItem.js +18 -18
  229. package/dist/Resizable/ResizeHandle.d.ts +1 -1
  230. package/dist/Resizable/ResizeHandle.d.ts.map +1 -1
  231. package/dist/Resizable/ResizeHandle.js +10 -7
  232. package/dist/Section/Section.js +5 -5
  233. package/dist/SegmentedControl/SegmentedControl.js +5 -5
  234. package/dist/SegmentedControl/SegmentedControlItem.js +7 -7
  235. package/dist/SelectableCard/SelectableCard.js +5 -5
  236. package/dist/Selector/Selector.d.ts.map +1 -1
  237. package/dist/Selector/Selector.js +57 -51
  238. package/dist/Selector/SelectorOption.js +3 -3
  239. package/dist/SideNav/SideNav.d.ts.map +1 -1
  240. package/dist/SideNav/SideNav.js +38 -36
  241. package/dist/SideNav/SideNavCollapseButton.d.ts.map +1 -1
  242. package/dist/SideNav/SideNavCollapseButton.js +8 -6
  243. package/dist/SideNav/SideNavHeading.d.ts.map +1 -1
  244. package/dist/SideNav/SideNavHeading.js +92 -90
  245. package/dist/SideNav/SideNavItem.d.ts.map +1 -1
  246. package/dist/SideNav/SideNavItem.js +49 -43
  247. package/dist/SideNav/SideNavSection.js +14 -14
  248. package/dist/Skeleton/Skeleton.js +3 -3
  249. package/dist/Slider/Slider.js +23 -23
  250. package/dist/Spinner/Spinner.js +9 -9
  251. package/dist/StatusDot/StatusDot.js +5 -5
  252. package/dist/Switch/Switch.d.ts.map +1 -1
  253. package/dist/Switch/Switch.js +29 -27
  254. package/dist/TabList/Tab.js +18 -18
  255. package/dist/TabList/TabList.d.ts +1 -1
  256. package/dist/TabList/TabList.d.ts.map +1 -1
  257. package/dist/TabList/TabList.js +9 -6
  258. package/dist/TabList/TabMenu.js +23 -23
  259. package/dist/Table/BaseTable.d.ts.map +1 -1
  260. package/dist/Table/BaseTable.js +39 -37
  261. package/dist/Table/Table.d.ts.map +1 -1
  262. package/dist/Table/Table.js +10 -8
  263. package/dist/Table/TableBody.js +3 -3
  264. package/dist/Table/TableCell.js +3 -3
  265. package/dist/Table/TableFooter.js +3 -3
  266. package/dist/Table/TableHeader.js +3 -3
  267. package/dist/Table/TableHeaderCell.js +3 -3
  268. package/dist/Table/TableRow.js +5 -5
  269. package/dist/Table/index.d.ts +4 -0
  270. package/dist/Table/index.d.ts.map +1 -1
  271. package/dist/Table/index.js +2 -0
  272. package/dist/Table/plugins/columnResize/useTableColumnResize.js +9 -9
  273. package/dist/Table/plugins/filtering/useTableFiltering.d.ts.map +1 -1
  274. package/dist/Table/plugins/filtering/useTableFiltering.js +127 -90
  275. package/dist/Table/plugins/groupedRows/index.d.ts +3 -0
  276. package/dist/Table/plugins/groupedRows/index.d.ts.map +1 -0
  277. package/dist/Table/plugins/groupedRows/index.js +3 -0
  278. package/dist/Table/plugins/groupedRows/useTableGroupedRows.d.ts +78 -0
  279. package/dist/Table/plugins/groupedRows/useTableGroupedRows.d.ts.map +1 -0
  280. package/dist/Table/plugins/groupedRows/useTableGroupedRows.js +257 -0
  281. package/dist/Table/plugins/pagination/useTablePagination.d.ts.map +1 -1
  282. package/dist/Table/plugins/pagination/useTablePagination.js +12 -9
  283. package/dist/Table/plugins/rowExpansion/useTableRowExpansion.d.ts +1 -1
  284. package/dist/Table/plugins/rowExpansion/useTableRowExpansion.d.ts.map +1 -1
  285. package/dist/Table/plugins/rowExpansion/useTableRowExpansion.js +30 -28
  286. package/dist/Table/plugins/rowIndex/index.d.ts +3 -0
  287. package/dist/Table/plugins/rowIndex/index.d.ts.map +1 -0
  288. package/dist/Table/plugins/rowIndex/index.js +3 -0
  289. package/dist/Table/plugins/rowIndex/useTableRowIndex.d.ts +50 -0
  290. package/dist/Table/plugins/rowIndex/useTableRowIndex.d.ts.map +1 -0
  291. package/dist/Table/plugins/rowIndex/useTableRowIndex.js +91 -0
  292. package/dist/Table/plugins/selection/useTableSelection.d.ts.map +1 -1
  293. package/dist/Table/plugins/selection/useTableSelection.js +23 -20
  294. package/dist/Table/plugins/sortable/useTableSortable.d.ts.map +1 -1
  295. package/dist/Table/plugins/sortable/useTableSortable.js +23 -21
  296. package/dist/Table/tableContextMenu.js +9 -9
  297. package/dist/Text/Text.js +10 -10
  298. package/dist/TextArea/TextArea.js +14 -14
  299. package/dist/TextInput/TextInput.d.ts.map +1 -1
  300. package/dist/TextInput/TextInput.js +20 -16
  301. package/dist/Thumbnail/Thumbnail.d.ts.map +1 -1
  302. package/dist/Thumbnail/Thumbnail.js +37 -31
  303. package/dist/TimeInput/TimeInput.d.ts +1 -1
  304. package/dist/TimeInput/TimeInput.d.ts.map +1 -1
  305. package/dist/TimeInput/TimeInput.js +28 -23
  306. package/dist/Timestamp/Timestamp.d.ts.map +1 -1
  307. package/dist/Timestamp/Timestamp.js +29 -14
  308. package/dist/Toast/Toast.d.ts.map +1 -1
  309. package/dist/Toast/Toast.js +17 -15
  310. package/dist/Toast/ToastViewport.d.ts.map +1 -1
  311. package/dist/Toast/ToastViewport.js +14 -12
  312. package/dist/Toast/useToast.js +4 -4
  313. package/dist/ToggleButton/ToggleButton.js +12 -12
  314. package/dist/ToggleButton/ToggleButtonGroup.js +5 -5
  315. package/dist/Token/Token.d.ts.map +1 -1
  316. package/dist/Token/Token.js +29 -23
  317. package/dist/Tokenizer/Tokenizer.d.ts.map +1 -1
  318. package/dist/Tokenizer/Tokenizer.js +33 -31
  319. package/dist/Toolbar/Toolbar.js +18 -18
  320. package/dist/Tooltip/Tooltip.js +11 -11
  321. package/dist/Tooltip/useTooltip.js +3 -3
  322. package/dist/TopNav/TopNav.d.ts +2 -1
  323. package/dist/TopNav/TopNav.d.ts.map +1 -1
  324. package/dist/TopNav/TopNav.js +36 -33
  325. package/dist/TopNav/TopNavHeading.d.ts.map +1 -1
  326. package/dist/TopNav/TopNavHeading.js +72 -70
  327. package/dist/TopNav/TopNavItem.js +5 -5
  328. package/dist/TopNav/TopNavMegaMenu.js +30 -30
  329. package/dist/TopNav/TopNavMegaMenuFeaturedCard.js +10 -10
  330. package/dist/TopNav/TopNavMegaMenuItem.js +16 -16
  331. package/dist/TopNav/TopNavMenu.js +32 -32
  332. package/dist/TreeList/TreeList.d.ts.map +1 -1
  333. package/dist/TreeList/TreeList.js +13 -9
  334. package/dist/TreeList/TreeListBranches.js +11 -11
  335. package/dist/TreeList/TreeListItem.d.ts.map +1 -1
  336. package/dist/TreeList/TreeListItem.js +37 -31
  337. package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
  338. package/dist/Typeahead/BaseTypeahead.js +26 -22
  339. package/dist/Typeahead/Typeahead.d.ts.map +1 -1
  340. package/dist/Typeahead/Typeahead.js +15 -13
  341. package/dist/Typeahead/TypeaheadItem.js +10 -10
  342. package/dist/VStack/VStack.js +3 -3
  343. package/dist/VisuallyHidden/VisuallyHidden.d.ts +1 -3
  344. package/dist/VisuallyHidden/VisuallyHidden.d.ts.map +1 -1
  345. package/dist/VisuallyHidden/VisuallyHidden.js +1 -3
  346. package/dist/astryx.css +20 -2
  347. package/dist/astryx.umd.js +66 -64
  348. package/dist/astryx.umd.js.map +4 -4
  349. package/dist/authoring/doc.d.ts +145 -0
  350. package/dist/authoring/doc.d.ts.map +1 -0
  351. package/dist/authoring/doc.js +100 -0
  352. package/dist/authoring/index.d.ts +29 -0
  353. package/dist/authoring/index.d.ts.map +1 -0
  354. package/dist/authoring/index.js +28 -0
  355. package/dist/authoring/integration.d.ts +35 -0
  356. package/dist/authoring/integration.d.ts.map +1 -0
  357. package/dist/authoring/integration.js +30 -0
  358. package/dist/authoring/template.d.ts +66 -0
  359. package/dist/authoring/template.d.ts.map +1 -0
  360. package/dist/authoring/template.js +55 -0
  361. package/dist/config.d.ts +80 -0
  362. package/dist/config.d.ts.map +1 -0
  363. package/dist/config.js +40 -0
  364. package/dist/hooks/useKeyboardHint.js +9 -9
  365. package/dist/i18n/InternationalizationContext.d.ts +12 -0
  366. package/dist/i18n/InternationalizationContext.d.ts.map +1 -0
  367. package/dist/i18n/InternationalizationContext.js +29 -0
  368. package/dist/i18n/InternationalizationProvider.d.ts +62 -0
  369. package/dist/i18n/InternationalizationProvider.d.ts.map +1 -0
  370. package/dist/i18n/InternationalizationProvider.js +44 -0
  371. package/dist/i18n/index.d.ts +24 -0
  372. package/dist/i18n/index.d.ts.map +1 -0
  373. package/dist/i18n/index.js +21 -0
  374. package/dist/i18n/resolve.d.ts +22 -0
  375. package/dist/i18n/resolve.d.ts.map +1 -0
  376. package/dist/i18n/resolve.js +141 -0
  377. package/dist/i18n/translator.d.ts +25 -0
  378. package/dist/i18n/translator.d.ts.map +1 -0
  379. package/dist/i18n/translator.js +1 -0
  380. package/dist/i18n/types.d.ts +47 -0
  381. package/dist/i18n/types.d.ts.map +1 -0
  382. package/dist/i18n/types.js +1 -0
  383. package/dist/i18n/useTranslator.d.ts +15 -0
  384. package/dist/i18n/useTranslator.d.ts.map +1 -0
  385. package/dist/i18n/useTranslator.js +39 -0
  386. package/dist/index.d.ts +1 -0
  387. package/dist/index.d.ts.map +1 -1
  388. package/dist/index.js +3 -0
  389. package/dist/theme/MediaTheme.js +3 -3
  390. package/dist/theme/Theme.js +7 -7
  391. package/dist/theme/syntax/SyntaxTheme.js +5 -5
  392. package/locales/en.json +746 -0
  393. package/locales/pseudo.json +560 -0
  394. package/package.json +24 -3
  395. package/src/AlertDialog/AlertDialog.doc.mjs +5 -0
  396. package/src/AlertDialog/AlertDialog.tsx +4 -1
  397. package/src/AlertDialog/useImperativeAlertDialog.tsx +0 -2
  398. package/src/AppShell/AppShell.doc.mjs +8 -2
  399. package/src/AppShell/AppShell.tsx +3 -1
  400. package/src/AvatarGroup/AvatarGroup.tsx +4 -1
  401. package/src/Banner/Banner.tsx +10 -5
  402. package/src/Breadcrumbs/Breadcrumbs.tsx +4 -1
  403. package/src/Button/Button.tsx +34 -4
  404. package/src/ButtonGroup/ButtonGroup.test.tsx +386 -2
  405. package/src/ButtonGroup/ButtonGroup.tsx +27 -11
  406. package/src/Calendar/Calendar.tsx +8 -5
  407. package/src/Card/Card.doc.mjs +3 -3
  408. package/src/Carousel/Carousel.tsx +10 -7
  409. package/src/Chat/ChatComposer.tsx +5 -1
  410. package/src/Chat/ChatComposerDrawer.tsx +9 -2
  411. package/src/Chat/ChatComposerInput.tsx +10 -4
  412. package/src/Chat/ChatLayout.tsx +5 -12
  413. package/src/Chat/ChatLayoutScrollButton.tsx +4 -2
  414. package/src/Chat/ChatMessage.tsx +5 -1
  415. package/src/Chat/ChatMessageBubble.tsx +2 -0
  416. package/src/Chat/ChatMessageList.doc.mjs +1 -1
  417. package/src/Chat/ChatMessageList.tsx +2 -0
  418. package/src/Chat/ChatMessageMetadata.tsx +15 -9
  419. package/src/Chat/ChatPastedTextToken.tsx +3 -1
  420. package/src/Chat/ChatSendButton.tsx +3 -1
  421. package/src/Chat/ChatToolCalls.doc.mjs +1 -1
  422. package/src/Chat/useSpeechRecognition.ts +11 -2
  423. package/src/Chat/useTriggerMenu.tsx +4 -2
  424. package/src/CheckboxInput/CheckboxInput.test.tsx +16 -0
  425. package/src/CheckboxInput/CheckboxInput.tsx +4 -2
  426. package/src/CheckboxList/CheckboxList.doc.mjs +6 -1
  427. package/src/CheckboxList/CheckboxList.tsx +2 -0
  428. package/src/CheckboxList/CheckboxListItem.tsx +7 -1
  429. package/src/Citation/Citation.tsx +4 -2
  430. package/src/ClickableCard/ClickableCard.doc.mjs +1 -1
  431. package/src/CodeBlock/CodeBlock.tsx +91 -40
  432. package/src/Collapsible/Collapsible.doc.mjs +3 -3
  433. package/src/CommandPalette/CommandPalette.tsx +10 -3
  434. package/src/CommandPalette/CommandPaletteInput.test.tsx +1 -1
  435. package/src/CommandPalette/CommandPaletteInput.tsx +5 -1
  436. package/src/CommandPalette/CommandPaletteList.tsx +4 -1
  437. package/src/ContextMenu/ContextMenu.tsx +4 -1
  438. package/src/DateInput/DateInput.doc.mjs +2 -2
  439. package/src/DateInput/DateInput.tsx +13 -5
  440. package/src/DateRangeInput/DateRangeInput.doc.mjs +7 -7
  441. package/src/DateRangeInput/DateRangeInput.tsx +14 -6
  442. package/src/DateTimeInput/DateTimeInput.doc.mjs +2 -2
  443. package/src/DateTimeInput/DateTimeInput.tsx +17 -7
  444. package/src/Dialog/DialogHeader.tsx +4 -2
  445. package/src/DropdownMenu/DropdownMenu.tsx +12 -8
  446. package/src/EmptyState/EmptyState.doc.mjs +3 -3
  447. package/src/EmptyState/EmptyState.tsx +4 -1
  448. package/src/Field/Field.doc.mjs +2 -2
  449. package/src/FileInput/FileInput.tsx +3 -1
  450. package/src/Grid/Grid.doc.mjs +5 -5
  451. package/src/InputGroup/InputGroup.doc.mjs +1 -1
  452. package/src/Layer/useLayer.doc.mjs +2 -2
  453. package/src/Lightbox/Lightbox.doc.mjs +7 -2
  454. package/src/Lightbox/Lightbox.tsx +6 -4
  455. package/src/Lightbox/useLightbox.tsx +0 -1
  456. package/src/Link/Link.test.tsx +74 -2
  457. package/src/Link/Link.tsx +48 -3
  458. package/src/Markdown/Markdown.tsx +12 -4
  459. package/src/MobileNav/MobileNav.tsx +4 -2
  460. package/src/MobileNav/MobileNavToggle.tsx +5 -3
  461. package/src/MoreMenu/MoreMenu.tsx +4 -1
  462. package/src/MultiSelector/MultiSelector.tsx +14 -5
  463. package/src/NumberInput/NumberInput.tsx +3 -1
  464. package/src/Outline/Outline.tsx +4 -1
  465. package/src/OverflowList/OverflowList.doc.mjs +2 -2
  466. package/src/Overlay/useOverlay.tsx +0 -3
  467. package/src/Pagination/Pagination.tsx +35 -12
  468. package/src/Popover/usePopover.tsx +6 -1
  469. package/src/PowerSearch/PowerSearch.doc.mjs +9 -4
  470. package/src/PowerSearch/PowerSearch.tsx +22 -10
  471. package/src/PowerSearch/PowerSearchEditPopover.tsx +27 -20
  472. package/src/PowerSearch/PowerSearchToken.tsx +17 -6
  473. package/src/PowerSearch/PowerSearchValueEditor.tsx +34 -21
  474. package/src/PowerSearch/formatFilterValue.test.ts +282 -0
  475. package/src/PowerSearch/formatFilterValue.ts +21 -8
  476. package/src/PowerSearch/index.ts +5 -0
  477. package/src/PowerSearch/resolveOperatorLabel.ts +34 -0
  478. package/src/PowerSearch/types.ts +33 -9
  479. package/src/PowerSearch/usePowerSearchConfig.ts +59 -27
  480. package/src/PowerSearch/usePowerSearchSource.ts +17 -8
  481. package/src/RadioList/RadioList.doc.mjs +1 -1
  482. package/src/Resizable/ResizeHandle.tsx +4 -1
  483. package/src/Section/Section.doc.mjs +4 -4
  484. package/src/SelectableCard/SelectableCard.doc.mjs +1 -1
  485. package/src/Selector/Selector.tsx +11 -6
  486. package/src/SideNav/SideNav.tsx +4 -2
  487. package/src/SideNav/SideNavCollapseButton.tsx +3 -1
  488. package/src/SideNav/SideNavHeading.tsx +5 -3
  489. package/src/SideNav/SideNavItem.tsx +3 -1
  490. package/src/Slider/Slider.doc.mjs +2 -2
  491. package/src/Stack/Stack.doc.mjs +10 -10
  492. package/src/Switch/Switch.doc.mjs +2 -2
  493. package/src/Switch/Switch.test.tsx +16 -0
  494. package/src/Switch/Switch.tsx +4 -2
  495. package/src/TabList/TabList.tsx +4 -1
  496. package/src/Table/BaseTable.tsx +8 -1
  497. package/src/Table/Table.doc.mjs +1 -1
  498. package/src/Table/Table.tsx +3 -1
  499. package/src/Table/index.ts +7 -0
  500. package/src/Table/plugins/filtering/useTableFiltering.tsx +31 -30
  501. package/src/Table/plugins/groupedRows/index.ts +7 -0
  502. package/src/Table/plugins/groupedRows/useTableGroupedRows.test.tsx +231 -0
  503. package/src/Table/plugins/groupedRows/useTableGroupedRows.tsx +351 -0
  504. package/src/Table/plugins/pagination/useTablePagination.tsx +4 -1
  505. package/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx +8 -4
  506. package/src/Table/plugins/rowIndex/index.ts +4 -0
  507. package/src/Table/plugins/rowIndex/useTableRowIndex.test.tsx +132 -0
  508. package/src/Table/plugins/rowIndex/useTableRowIndex.tsx +114 -0
  509. package/src/Table/plugins/selection/useTableSelection.tsx +6 -7
  510. package/src/Table/plugins/sortable/useTableSortable.tsx +8 -5
  511. package/src/Table/useTableFiltering.doc.mjs +2 -2
  512. package/src/Table/useTableGroupedRows.doc.mjs +71 -0
  513. package/src/Table/useTableRowIndex.doc.mjs +50 -0
  514. package/src/Table/useTableSortable.doc.mjs +11 -11
  515. package/src/Text/Text.doc.mjs +2 -2
  516. package/src/TextInput/TextInput.tsx +3 -1
  517. package/src/Thumbnail/Thumbnail.tsx +4 -2
  518. package/src/TimeInput/TimeInput.doc.mjs +2 -2
  519. package/src/TimeInput/TimeInput.tsx +6 -2
  520. package/src/Timestamp/Timestamp.doc.mjs +4 -4
  521. package/src/Timestamp/Timestamp.test.tsx +120 -7
  522. package/src/Timestamp/Timestamp.tsx +21 -1
  523. package/src/Toast/Toast.tsx +3 -1
  524. package/src/Toast/ToastViewport.tsx +3 -1
  525. package/src/Token/Token.tsx +4 -2
  526. package/src/Tokenizer/Tokenizer.doc.mjs +2 -2
  527. package/src/Tokenizer/Tokenizer.tsx +4 -4
  528. package/src/Toolbar/Toolbar.doc.mjs +1 -1
  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 -3
  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 +902 -0
  547. package/src/hooks/useHotkeys.doc.mjs +5 -5
  548. package/src/i18n/InternationalizationContext.ts +39 -0
  549. package/src/i18n/InternationalizationProvider.doc.mjs +72 -0
  550. package/src/i18n/InternationalizationProvider.tsx +83 -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/dist/NavItem/index.d.ts +0 -9
  562. package/dist/NavItem/index.d.ts.map +0 -1
  563. package/dist/NavItem/index.js +0 -10
  564. package/src/NavItem/index.ts +0 -11
@@ -0,0 +1,282 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ import {describe, expect, it} from 'vitest';
4
+ import {formatFilterValue} from './formatFilterValue';
5
+ import type {TranslatorFn} from '../i18n';
6
+ import type {OperatorValue, FilterValue} from './types';
7
+
8
+ // Minimal stand-in for the real translator: resolves just the count/range keys
9
+ // formatFilterValue uses, with the same singular/plural forms as en.json so the
10
+ // overflow-summary assertions ("3 items", "2 entities", "1 filter") hold.
11
+ const t: TranslatorFn = (key, values) => {
12
+ const count = Number(values?.count ?? 0);
13
+ switch (key) {
14
+ case '@astryx.powersearch.valueEditor.itemsCount':
15
+ return `${count} ${count === 1 ? 'item' : 'items'}`;
16
+ case '@astryx.powersearch.valueEditor.entitiesCount':
17
+ return `${count} ${count === 1 ? 'entity' : 'entities'}`;
18
+ case '@astryx.powersearch.valueEditor.filtersCount':
19
+ return `${count} ${count === 1 ? 'filter' : 'filters'}`;
20
+ case '@astryx.powersearch.valueEditor.dateRange':
21
+ return 'date range';
22
+ default:
23
+ return key;
24
+ }
25
+ };
26
+
27
+ // _config is unused by formatFilterValue; a stub keeps the call type-clean.
28
+ const fmt = (
29
+ operator: OperatorValue,
30
+ value: FilterValue,
31
+ maxLength = 20,
32
+ timezoneID?: string,
33
+ ): string =>
34
+ formatFilterValue({} as never, operator, value, maxLength, t, timezoneID);
35
+
36
+ const ELLIPSIS = '…';
37
+
38
+ describe('formatFilterValue', () => {
39
+ it('returns an empty string for an empty value', () => {
40
+ expect(fmt({type: 'empty'}, {type: 'empty'})).toBe('');
41
+ });
42
+
43
+ describe('string', () => {
44
+ it('returns the string unchanged when within maxLength', () => {
45
+ expect(fmt({type: 'string'}, {type: 'string', value: 'hello'})).toBe(
46
+ 'hello',
47
+ );
48
+ });
49
+
50
+ it('truncates with an ellipsis when longer than maxLength', () => {
51
+ const out = fmt(
52
+ {type: 'string'},
53
+ {type: 'string', value: 'abcdefghij'},
54
+ 5,
55
+ );
56
+ expect(out).toBe('abcd' + ELLIPSIS);
57
+ expect(out.length).toBe(5);
58
+ });
59
+
60
+ it('keeps a string exactly at the boundary intact', () => {
61
+ expect(fmt({type: 'string'}, {type: 'string', value: 'abcde'}, 5)).toBe(
62
+ 'abcde',
63
+ );
64
+ });
65
+ });
66
+
67
+ describe('integer / float', () => {
68
+ it('formats an integer with locale grouping', () => {
69
+ const expected = new Intl.NumberFormat().format(1234567);
70
+ expect(
71
+ fmt({type: 'integer'}, {type: 'integer', value: 1234567}, 40),
72
+ ).toBe(expected);
73
+ });
74
+
75
+ it('appends integer units only when the operator is an integer', () => {
76
+ expect(
77
+ fmt({type: 'integer', units: 'ms'}, {type: 'integer', value: 42}),
78
+ ).toBe('42 ms');
79
+ // mismatched operator type → no units
80
+ expect(fmt({type: 'string'}, {type: 'integer', value: 42})).toBe('42');
81
+ });
82
+
83
+ it('appends float units only when the operator is a float', () => {
84
+ expect(
85
+ fmt({type: 'float', units: 'kg'}, {type: 'float', value: 3.5}),
86
+ ).toBe('3.5 kg');
87
+ expect(fmt({type: 'string'}, {type: 'float', value: 3.5})).toBe('3.5');
88
+ });
89
+ });
90
+
91
+ describe('enum', () => {
92
+ const enumOp: OperatorValue = {
93
+ type: 'enum',
94
+ values: [
95
+ {value: 'us', label: 'United States'},
96
+ {value: 'ca', label: 'Canada'},
97
+ ],
98
+ };
99
+
100
+ it('maps the stored value to its label', () => {
101
+ expect(fmt(enumOp, {type: 'enum', value: 'ca'}, 40)).toBe('Canada');
102
+ });
103
+
104
+ it('falls back to the raw value when no label matches', () => {
105
+ expect(fmt(enumOp, {type: 'enum', value: 'mx'}, 40)).toBe('mx');
106
+ });
107
+
108
+ it('uses the raw value when the operator is not an enum', () => {
109
+ expect(fmt({type: 'string'}, {type: 'enum', value: 'ca'}, 40)).toBe('ca');
110
+ });
111
+
112
+ it('truncates a long enum label', () => {
113
+ expect(fmt(enumOp, {type: 'enum', value: 'us'}, 5)).toBe(
114
+ 'Unit' + ELLIPSIS,
115
+ );
116
+ });
117
+ });
118
+
119
+ describe('string_list', () => {
120
+ const op: OperatorValue = {type: 'string_list'};
121
+ it('returns an empty string for no items', () => {
122
+ expect(fmt(op, {type: 'string_list', value: []})).toBe('');
123
+ });
124
+ it('returns the single item, truncated', () => {
125
+ expect(fmt(op, {type: 'string_list', value: ['solo']})).toBe('solo');
126
+ });
127
+ it('joins multiple items when they fit', () => {
128
+ expect(fmt(op, {type: 'string_list', value: ['a', 'b', 'c']})).toBe(
129
+ 'a, b, c',
130
+ );
131
+ });
132
+ it('summarizes as a count when the join exceeds maxLength', () => {
133
+ expect(
134
+ fmt(op, {type: 'string_list', value: ['alpha', 'bravo', 'charlie']}, 8),
135
+ ).toBe('3 items');
136
+ });
137
+ });
138
+
139
+ describe('enum_list', () => {
140
+ const enumOp: OperatorValue = {
141
+ type: 'enum_list',
142
+ values: [
143
+ {value: 'r', label: 'Red'},
144
+ {value: 'g', label: 'Green'},
145
+ ],
146
+ };
147
+ it('returns an empty string for no items', () => {
148
+ expect(fmt(enumOp, {type: 'enum_list', value: []})).toBe('');
149
+ });
150
+ it('maps a single value to its label', () => {
151
+ expect(fmt(enumOp, {type: 'enum_list', value: ['g']}, 40)).toBe('Green');
152
+ });
153
+ it('joins mapped labels when they fit', () => {
154
+ expect(fmt(enumOp, {type: 'enum_list', value: ['r', 'g']}, 40)).toBe(
155
+ 'Red, Green',
156
+ );
157
+ });
158
+ it('summarizes labels as a count when too long', () => {
159
+ expect(fmt(enumOp, {type: 'enum_list', value: ['r', 'g']}, 5)).toBe(
160
+ '2 items',
161
+ );
162
+ });
163
+ it('uses raw values with a non-enum operator', () => {
164
+ expect(
165
+ fmt({type: 'string'}, {type: 'enum_list', value: ['x', 'y']}, 40),
166
+ ).toBe('2 items');
167
+ expect(
168
+ fmt({type: 'string'}, {type: 'enum_list', value: ['solo']}, 40),
169
+ ).toBe('solo');
170
+ });
171
+ });
172
+
173
+ describe('entity_list', () => {
174
+ const op: OperatorValue = {type: 'entity_list'};
175
+ it('returns an empty string for no entities', () => {
176
+ expect(fmt(op, {type: 'entity_list', value: []})).toBe('');
177
+ });
178
+ it('returns a single entity label', () => {
179
+ expect(
180
+ fmt(op, {type: 'entity_list', value: [{id: '1', label: 'Ada'}]}),
181
+ ).toBe('Ada');
182
+ });
183
+ it('joins entity labels when they fit', () => {
184
+ expect(
185
+ fmt(op, {
186
+ type: 'entity_list',
187
+ value: [
188
+ {id: '1', label: 'Ada'},
189
+ {id: '2', label: 'Bob'},
190
+ ],
191
+ }),
192
+ ).toBe('Ada, Bob');
193
+ });
194
+ it('summarizes as an entity count when too long', () => {
195
+ expect(
196
+ fmt(
197
+ op,
198
+ {
199
+ type: 'entity_list',
200
+ value: [
201
+ {id: '1', label: 'Alexander'},
202
+ {id: '2', label: 'Bartholomew'},
203
+ ],
204
+ },
205
+ 8,
206
+ ),
207
+ ).toBe('2 entities');
208
+ });
209
+ });
210
+
211
+ describe('dates and time', () => {
212
+ it('returns a time value verbatim', () => {
213
+ expect(fmt({type: 'time'}, {type: 'time', value: '14:30'})).toBe('14:30');
214
+ });
215
+ it('returns a relative date value verbatim', () => {
216
+ expect(
217
+ fmt({type: 'date_relative'}, {type: 'date_relative', value: '7d'}),
218
+ ).toBe('7d');
219
+ });
220
+ it('renders a fixed placeholder for a date range', () => {
221
+ expect(
222
+ fmt(
223
+ {type: 'date_range'},
224
+ {
225
+ type: 'date_range',
226
+ value: {start: {type: 'NOW'}, end: {type: 'NOW'}},
227
+ },
228
+ ),
229
+ ).toBe('date range');
230
+ });
231
+ it('formats an absolute date and truncates to maxLength', () => {
232
+ const full = fmt(
233
+ {type: 'date_absolute'},
234
+ {type: 'date_absolute', unixSeconds: 0},
235
+ 60,
236
+ 'UTC',
237
+ );
238
+ expect(full).toContain('1970');
239
+ const short = fmt(
240
+ {type: 'date_absolute'},
241
+ {type: 'date_absolute', unixSeconds: 0},
242
+ 6,
243
+ 'UTC',
244
+ );
245
+ expect(short.length).toBe(6);
246
+ expect(short.endsWith(ELLIPSIS)).toBe(true);
247
+ });
248
+ });
249
+
250
+ describe('custom', () => {
251
+ it('stringifies via the operator getString and truncates', () => {
252
+ const op: OperatorValue = {
253
+ type: 'custom',
254
+ Editor: (() => null) as never,
255
+ getString: v => `custom:${v}`,
256
+ };
257
+ expect(fmt(op, {type: 'custom', value: 'x'})).toBe('custom:x');
258
+ });
259
+ it('returns the raw value when the operator is not custom', () => {
260
+ expect(fmt({type: 'string'}, {type: 'custom', value: 'raw'})).toBe('raw');
261
+ });
262
+ });
263
+
264
+ describe('nested', () => {
265
+ it('uses the singular form for a single nested filter', () => {
266
+ expect(
267
+ fmt({type: 'nested'}, {type: 'nested', value: [{} as never]}),
268
+ ).toBe('1 filter');
269
+ });
270
+ it('uses the plural form for multiple nested filters', () => {
271
+ expect(
272
+ fmt(
273
+ {type: 'nested'},
274
+ {
275
+ type: 'nested',
276
+ value: [{} as never, {} as never, {} as never],
277
+ },
278
+ ),
279
+ ).toBe('3 filters');
280
+ });
281
+ });
282
+ });
@@ -12,6 +12,7 @@
12
12
 
13
13
  import type {OperatorValue, FilterValue, EnumItem} from './types';
14
14
  import type {InternalConfig} from './useInternalConfig';
15
+ import type {TranslatorFn} from '../i18n';
15
16
 
16
17
  function truncate(str: string, maxLength: number): string {
17
18
  if (str.length <= maxLength) {
@@ -50,8 +51,11 @@ function formatRelativeDate(value: string): string {
50
51
  return value;
51
52
  }
52
53
 
53
- function formatDateRange(_value: {start: unknown; end: unknown}): string {
54
- return 'date range';
54
+ function formatDateRange(
55
+ _value: {start: unknown; end: unknown},
56
+ t: TranslatorFn,
57
+ ): string {
58
+ return t('@astryx.powersearch.valueEditor.dateRange');
55
59
  }
56
60
 
57
61
  export function formatFilterValue(
@@ -59,6 +63,7 @@ export function formatFilterValue(
59
63
  operatorValue: OperatorValue,
60
64
  filterValue: FilterValue,
61
65
  maxLength: number,
66
+ t: TranslatorFn,
62
67
  timezoneID?: string,
63
68
  ): string {
64
69
  switch (filterValue.type) {
@@ -101,7 +106,9 @@ export function formatFilterValue(
101
106
  if (joined.length <= maxLength) {
102
107
  return joined;
103
108
  }
104
- return `${items.length} items`;
109
+ return t('@astryx.powersearch.valueEditor.itemsCount', {
110
+ count: items.length,
111
+ });
105
112
  }
106
113
 
107
114
  case 'enum_list': {
@@ -118,12 +125,16 @@ export function formatFilterValue(
118
125
  if (joined.length <= maxLength) {
119
126
  return joined;
120
127
  }
121
- return `${labels.length} items`;
128
+ return t('@astryx.powersearch.valueEditor.itemsCount', {
129
+ count: labels.length,
130
+ });
122
131
  }
123
132
  if (items.length === 1) {
124
133
  return truncate(items[0], maxLength);
125
134
  }
126
- return `${items.length} items`;
135
+ return t('@astryx.powersearch.valueEditor.itemsCount', {
136
+ count: items.length,
137
+ });
127
138
  }
128
139
 
129
140
  case 'entity_list': {
@@ -138,7 +149,9 @@ export function formatFilterValue(
138
149
  if (joined.length <= maxLength) {
139
150
  return joined;
140
151
  }
141
- return `${entities.length} entities`;
152
+ return t('@astryx.powersearch.valueEditor.entitiesCount', {
153
+ count: entities.length,
154
+ });
142
155
  }
143
156
 
144
157
  case 'time':
@@ -154,7 +167,7 @@ export function formatFilterValue(
154
167
  return formatRelativeDate(filterValue.value);
155
168
 
156
169
  case 'date_range':
157
- return formatDateRange(filterValue.value);
170
+ return formatDateRange(filterValue.value, t);
158
171
 
159
172
  case 'custom':
160
173
  if (operatorValue.type === 'custom') {
@@ -164,7 +177,7 @@ export function formatFilterValue(
164
177
 
165
178
  case 'nested': {
166
179
  const count = filterValue.value.length;
167
- return count === 1 ? '1 filter' : `${count} filters`;
180
+ return t('@astryx.powersearch.valueEditor.filtersCount', {count});
168
181
  }
169
182
 
170
183
  default:
@@ -17,6 +17,8 @@ export type {PowerSearchProps, PowerSearchSize} from './PowerSearch';
17
17
  export {PowerSearchToken} from './PowerSearchToken';
18
18
  export {PowerSearchFilterEditor} from './PowerSearchFilterEditor';
19
19
 
20
+ export {resolveOperatorLabel} from './resolveOperatorLabel';
21
+
20
22
  export {
21
23
  createPowerSearchConfig,
22
24
  usePowerSearchConfig,
@@ -28,6 +30,9 @@ export type {
28
30
  PowerSearchConfig,
29
31
  PowerSearchField,
30
32
  PowerSearchOperator,
33
+ PowerSearchOperatorBase,
34
+ PowerSearchOperatorWithLabel,
35
+ PowerSearchOperatorWithI18nKey,
31
36
 
32
37
  // Operator value types
33
38
  OperatorValue,
@@ -0,0 +1,34 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file resolveOperatorLabel.ts
5
+ * @input PowerSearchOperator + translator function
6
+ * @output Display string for the operator label
7
+ * @position Shared label-resolution helper used at every render site that
8
+ * reads an operator's display text (PowerSearch.tsx, PowerSearchToken.tsx,
9
+ * PowerSearchEditPopover.tsx, usePowerSearchSource.ts).
10
+ *
11
+ * A PowerSearchOperator is a discriminated union of two variants:
12
+ * - `{key, value, label}` — consumer-supplied raw text (used verbatim)
13
+ * - `{key, value, i18nKey}` — catalog-driven text (looked up via t())
14
+ *
15
+ * Astryx's shipped default operators use the i18nKey variant; consumers
16
+ * writing custom operators typically use the label variant.
17
+ *
18
+ * SYNC: When modified, update:
19
+ * - /packages/core/src/PowerSearch/types.ts (PowerSearchOperator type)
20
+ * - /packages/core/src/PowerSearch/index.ts (re-export)
21
+ */
22
+
23
+ import type {TranslatorFn} from '../i18n';
24
+ import type {PowerSearchOperator} from './types';
25
+
26
+ export function resolveOperatorLabel(
27
+ operator: PowerSearchOperator,
28
+ t: TranslatorFn,
29
+ ): string {
30
+ if ('label' in operator && operator.label !== undefined) {
31
+ return operator.label;
32
+ }
33
+ return t(operator.i18nKey);
34
+ }
@@ -256,13 +256,7 @@ export type DateTimeRangePart =
256
256
  readonly type: 'RELATIVE';
257
257
  readonly backValue: number;
258
258
  readonly unit:
259
- | 'second'
260
- | 'minute'
261
- | 'hour'
262
- | 'day'
263
- | 'week'
264
- | 'month'
265
- | 'year';
259
+ 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
266
260
  readonly anchorKey?: string;
267
261
  };
268
262
 
@@ -285,12 +279,42 @@ export interface RelativeDateFilterPreset {
285
279
  // Config Types
286
280
  // =============================================================================
287
281
 
288
- export interface PowerSearchOperator {
282
+ export interface PowerSearchOperatorBase {
289
283
  readonly key: string;
290
- readonly label: string;
291
284
  readonly value: OperatorValue;
292
285
  }
293
286
 
287
+ /**
288
+ * Operator variant that provides its label as raw text. The consumer owns
289
+ * translation of that string. Use this for genuinely custom operator labels
290
+ * that don't correspond to an entry in astryx's shipped translation catalog
291
+ * (e.g. `label: 'in my rotations'`).
292
+ */
293
+ export interface PowerSearchOperatorWithLabel extends PowerSearchOperatorBase {
294
+ readonly label: string;
295
+ readonly i18nKey?: never;
296
+ }
297
+
298
+ /**
299
+ * Operator variant that references a translation-catalog key. The library
300
+ * looks the key up against the active InternationalizationProvider locale.
301
+ * Use `@astryx.powersearch.operator.*` for astryx's shipped defaults, or a
302
+ * key from your own catalog registered via InternationalizationProvider
303
+ * `messages` / `overrides` props.
304
+ */
305
+ export interface PowerSearchOperatorWithI18nKey extends PowerSearchOperatorBase {
306
+ readonly i18nKey: string;
307
+ readonly label?: never;
308
+ }
309
+
310
+ /**
311
+ * A discriminated union: an operator must supply EXACTLY ONE of `label`
312
+ * (raw text) or `i18nKey` (catalog lookup). The type system prevents
313
+ * accidental omission — a bare `{key, value}` is a compile error.
314
+ */
315
+ export type PowerSearchOperator =
316
+ PowerSearchOperatorWithLabel | PowerSearchOperatorWithI18nKey;
317
+
294
318
  export interface PowerSearchField {
295
319
  readonly key: string;
296
320
  readonly label: string;
@@ -119,30 +119,46 @@ function stringOperators(): {
119
119
  return {
120
120
  defaultOperator: StringOps.CONTAINS,
121
121
  operators: [
122
- {key: StringOps.CONTAINS, label: 'contains', value: {type: 'string'}},
122
+ {
123
+ key: StringOps.CONTAINS,
124
+ i18nKey: '@astryx.powersearch.operator.contains',
125
+ value: {type: 'string'},
126
+ },
123
127
  {
124
128
  key: StringOps.NOT_CONTAINS,
125
- label: 'does not contain',
129
+ i18nKey: '@astryx.powersearch.operator.notContains',
126
130
  value: {type: 'string'},
127
131
  },
128
132
  {
129
133
  key: StringOps.STARTS_WITH,
130
- label: 'starts with',
134
+ i18nKey: '@astryx.powersearch.operator.startsWith',
131
135
  value: {type: 'string'},
132
136
  },
133
137
  {
134
138
  key: StringOps.NOT_STARTS_WITH,
135
- label: 'does not start with',
139
+ i18nKey: '@astryx.powersearch.operator.notStartsWith',
140
+ value: {type: 'string'},
141
+ },
142
+ {
143
+ key: StringOps.ENDS_WITH,
144
+ i18nKey: '@astryx.powersearch.operator.endsWith',
136
145
  value: {type: 'string'},
137
146
  },
138
- {key: StringOps.ENDS_WITH, label: 'ends with', value: {type: 'string'}},
139
147
  {
140
148
  key: StringOps.NOT_ENDS_WITH,
141
- label: 'does not end with',
149
+ i18nKey: '@astryx.powersearch.operator.notEndsWith',
150
+ value: {type: 'string'},
151
+ },
152
+ {
153
+ key: StringOps.IS,
154
+ i18nKey: '@astryx.powersearch.operator.is',
155
+ value: {type: 'string'},
156
+ },
157
+ {
158
+ key: StringOps.IS_NOT,
159
+ i18nKey: '@astryx.powersearch.operator.isNot',
142
160
  value: {type: 'string'},
143
161
  },
144
- {key: StringOps.IS, label: 'is', value: {type: 'string'}},
145
- {key: StringOps.IS_NOT, label: 'is not', value: {type: 'string'}},
146
162
  ],
147
163
  };
148
164
  }
@@ -156,32 +172,32 @@ function numberOperators(): {
156
172
  operators: [
157
173
  {
158
174
  key: NumberOps.EQUALS,
159
- label: 'is',
175
+ i18nKey: '@astryx.powersearch.operator.equals',
160
176
  value: {type: 'float'},
161
177
  },
162
178
  {
163
179
  key: NumberOps.NOT_EQUALS,
164
- label: 'is not',
180
+ i18nKey: '@astryx.powersearch.operator.notEquals',
165
181
  value: {type: 'float'},
166
182
  },
167
183
  {
168
184
  key: NumberOps.GREATER_THAN,
169
- label: 'is greater than',
185
+ i18nKey: '@astryx.powersearch.operator.greaterThan',
170
186
  value: {type: 'float'},
171
187
  },
172
188
  {
173
189
  key: NumberOps.LESS_THAN,
174
- label: 'is less than',
190
+ i18nKey: '@astryx.powersearch.operator.lessThan',
175
191
  value: {type: 'float'},
176
192
  },
177
193
  {
178
194
  key: NumberOps.GREATER_THAN_OR_EQUAL,
179
- label: 'is greater than or equal to',
195
+ i18nKey: '@astryx.powersearch.operator.greaterThanOrEqual',
180
196
  value: {type: 'float'},
181
197
  },
182
198
  {
183
199
  key: NumberOps.LESS_THAN_OR_EQUAL,
184
- label: 'is less than or equal to',
200
+ i18nKey: '@astryx.powersearch.operator.lessThanOrEqual',
185
201
  value: {type: 'float'},
186
202
  },
187
203
  ],
@@ -197,17 +213,17 @@ function dateOperators(): {
197
213
  operators: [
198
214
  {
199
215
  key: DateOps.BEFORE,
200
- label: 'is before',
216
+ i18nKey: '@astryx.powersearch.operator.before',
201
217
  value: {type: 'date_absolute'},
202
218
  },
203
219
  {
204
220
  key: DateOps.AFTER,
205
- label: 'is after',
221
+ i18nKey: '@astryx.powersearch.operator.after',
206
222
  value: {type: 'date_absolute'},
207
223
  },
208
224
  {
209
225
  key: DateOps.BETWEEN,
210
- label: 'is between',
226
+ i18nKey: '@astryx.powersearch.operator.between',
211
227
  value: {type: 'date_range'},
212
228
  },
213
229
  ],
@@ -221,8 +237,16 @@ function booleanOperators(): {
221
237
  return {
222
238
  defaultOperator: BooleanOps.IS_TRUE,
223
239
  operators: [
224
- {key: BooleanOps.IS_TRUE, label: 'is true', value: {type: 'empty'}},
225
- {key: BooleanOps.IS_FALSE, label: 'is false', value: {type: 'empty'}},
240
+ {
241
+ key: BooleanOps.IS_TRUE,
242
+ i18nKey: '@astryx.powersearch.operator.isTrue',
243
+ value: {type: 'empty'},
244
+ },
245
+ {
246
+ key: BooleanOps.IS_FALSE,
247
+ i18nKey: '@astryx.powersearch.operator.isFalse',
248
+ value: {type: 'empty'},
249
+ },
226
250
  ],
227
251
  };
228
252
  }
@@ -234,16 +258,24 @@ function enumOperators(values: ReadonlyArray<EnumItem>): {
234
258
  return {
235
259
  defaultOperator: EnumOps.IS,
236
260
  operators: [
237
- {key: EnumOps.IS, label: 'is', value: {type: 'enum', values}},
238
- {key: EnumOps.IS_NOT, label: 'is not', value: {type: 'enum', values}},
261
+ {
262
+ key: EnumOps.IS,
263
+ i18nKey: '@astryx.powersearch.operator.is',
264
+ value: {type: 'enum', values},
265
+ },
266
+ {
267
+ key: EnumOps.IS_NOT,
268
+ i18nKey: '@astryx.powersearch.operator.isNot',
269
+ value: {type: 'enum', values},
270
+ },
239
271
  {
240
272
  key: EnumListOps.IS_ANY_OF,
241
- label: 'is any of',
273
+ i18nKey: '@astryx.powersearch.operator.isAnyOf',
242
274
  value: {type: 'enum_list', values},
243
275
  },
244
276
  {
245
277
  key: EnumListOps.IS_NONE_OF,
246
- label: 'is none of',
278
+ i18nKey: '@astryx.powersearch.operator.isNoneOf',
247
279
  value: {type: 'enum_list', values},
248
280
  },
249
281
  ],
@@ -259,12 +291,12 @@ function enumListOperators(values: ReadonlyArray<EnumItem>): {
259
291
  operators: [
260
292
  {
261
293
  key: EnumListOps.IS_ANY_OF,
262
- label: 'is any of',
294
+ i18nKey: '@astryx.powersearch.operator.isAnyOf',
263
295
  value: {type: 'enum_list', values},
264
296
  },
265
297
  {
266
298
  key: EnumListOps.IS_NONE_OF,
267
- label: 'is none of',
299
+ i18nKey: '@astryx.powersearch.operator.isNoneOf',
268
300
  value: {type: 'enum_list', values},
269
301
  },
270
302
  ],
@@ -280,12 +312,12 @@ function stringListOperators(): {
280
312
  operators: [
281
313
  {
282
314
  key: StringListOps.IS_ANY_OF,
283
- label: 'is any of',
315
+ i18nKey: '@astryx.powersearch.operator.isAnyOf',
284
316
  value: {type: 'string_list'},
285
317
  },
286
318
  {
287
319
  key: StringListOps.IS_NONE_OF,
288
- label: 'is none of',
320
+ i18nKey: '@astryx.powersearch.operator.isNoneOf',
289
321
  value: {type: 'string_list'},
290
322
  },
291
323
  ],