@astryxdesign/core 0.1.6-canary.1b61ba6 → 0.1.6-canary.1d64659
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.
- package/README.md +0 -2
- package/dist/AlertDialog/AlertDialog.d.ts +1 -1
- package/dist/AlertDialog/AlertDialog.d.ts.map +1 -1
- package/dist/AlertDialog/AlertDialog.js +1 -4
- package/dist/AppShell/AppShell.d.ts.map +1 -1
- package/dist/AppShell/AppShell.js +1 -3
- package/dist/AvatarGroup/AvatarGroup.d.ts +1 -1
- package/dist/AvatarGroup/AvatarGroup.d.ts.map +1 -1
- package/dist/AvatarGroup/AvatarGroup.js +1 -4
- package/dist/Banner/Banner.d.ts.map +1 -1
- package/dist/Banner/Banner.js +6 -8
- package/dist/Breadcrumbs/Breadcrumbs.d.ts +1 -1
- package/dist/Breadcrumbs/Breadcrumbs.d.ts.map +1 -1
- package/dist/Breadcrumbs/Breadcrumbs.js +1 -4
- package/dist/Button/Button.d.ts.map +1 -1
- package/dist/Button/Button.js +4 -34
- package/dist/ButtonGroup/ButtonGroup.d.ts +5 -20
- package/dist/ButtonGroup/ButtonGroup.d.ts.map +1 -1
- package/dist/ButtonGroup/ButtonGroup.js +11 -27
- package/dist/Calendar/Calendar.d.ts.map +1 -1
- package/dist/Calendar/Calendar.js +5 -8
- package/dist/Carousel/Carousel.d.ts +1 -1
- package/dist/Carousel/Carousel.d.ts.map +1 -1
- package/dist/Carousel/Carousel.js +5 -8
- package/dist/Chat/ChatComposer.d.ts.map +1 -1
- package/dist/Chat/ChatComposer.js +1 -4
- package/dist/Chat/ChatComposerDrawer.d.ts +1 -1
- package/dist/Chat/ChatComposerDrawer.d.ts.map +1 -1
- package/dist/Chat/ChatComposerDrawer.js +2 -9
- package/dist/Chat/ChatComposerInput.d.ts.map +1 -1
- package/dist/Chat/ChatComposerInput.js +2 -6
- package/dist/Chat/ChatLayout.d.ts +11 -1
- package/dist/Chat/ChatLayout.d.ts.map +1 -1
- package/dist/Chat/ChatLayout.js +4 -6
- package/dist/Chat/ChatLayoutScrollButton.d.ts.map +1 -1
- package/dist/Chat/ChatLayoutScrollButton.js +2 -4
- package/dist/Chat/ChatMessage.d.ts +1 -1
- package/dist/Chat/ChatMessage.d.ts.map +1 -1
- package/dist/Chat/ChatMessage.js +2 -8
- package/dist/Chat/ChatMessageBubble.d.ts +1 -1
- package/dist/Chat/ChatMessageBubble.d.ts.map +1 -1
- package/dist/Chat/ChatMessageBubble.js +1 -3
- package/dist/Chat/ChatMessageList.d.ts +1 -1
- package/dist/Chat/ChatMessageList.d.ts.map +1 -1
- package/dist/Chat/ChatMessageList.js +1 -3
- package/dist/Chat/ChatMessageMetadata.d.ts.map +1 -1
- package/dist/Chat/ChatMessageMetadata.js +8 -13
- package/dist/Chat/ChatPastedTextToken.d.ts.map +1 -1
- package/dist/Chat/ChatPastedTextToken.js +1 -3
- package/dist/Chat/ChatSendButton.d.ts.map +1 -1
- package/dist/Chat/ChatSendButton.js +1 -3
- package/dist/Chat/index.d.ts +1 -1
- package/dist/Chat/index.d.ts.map +1 -1
- package/dist/Chat/useChatStreamScroll.d.ts +1 -12
- package/dist/Chat/useChatStreamScroll.d.ts.map +1 -1
- package/dist/Chat/useChatStreamScroll.js +6 -43
- package/dist/Chat/useSpeechRecognition.d.ts.map +1 -1
- package/dist/Chat/useSpeechRecognition.js +2 -4
- package/dist/Chat/useTriggerMenu.d.ts.map +1 -1
- package/dist/Chat/useTriggerMenu.js +2 -4
- package/dist/CheckboxList/CheckboxList.d.ts +1 -1
- package/dist/CheckboxList/CheckboxList.d.ts.map +1 -1
- package/dist/CheckboxList/CheckboxList.js +1 -3
- package/dist/CheckboxList/CheckboxListItem.d.ts.map +1 -1
- package/dist/CheckboxList/CheckboxListItem.js +1 -3
- package/dist/Citation/Citation.d.ts.map +1 -1
- package/dist/Citation/Citation.js +2 -10
- package/dist/CodeBlock/CodeBlock.d.ts.map +1 -1
- package/dist/CodeBlock/CodeBlock.js +2 -4
- package/dist/CommandPalette/CommandPalette.d.ts +1 -1
- package/dist/CommandPalette/CommandPalette.d.ts.map +1 -1
- package/dist/CommandPalette/CommandPalette.js +3 -8
- package/dist/CommandPalette/CommandPaletteInput.d.ts +1 -1
- package/dist/CommandPalette/CommandPaletteInput.d.ts.map +1 -1
- package/dist/CommandPalette/CommandPaletteInput.js +1 -4
- package/dist/CommandPalette/CommandPaletteList.d.ts +1 -1
- package/dist/CommandPalette/CommandPaletteList.d.ts.map +1 -1
- package/dist/CommandPalette/CommandPaletteList.js +1 -4
- package/dist/ContextMenu/ContextMenu.d.ts +1 -1
- package/dist/ContextMenu/ContextMenu.d.ts.map +1 -1
- package/dist/ContextMenu/ContextMenu.js +1 -4
- package/dist/DateInput/DateInput.d.ts +1 -1
- package/dist/DateInput/DateInput.d.ts.map +1 -1
- package/dist/DateInput/DateInput.js +5 -10
- package/dist/DateRangeInput/DateRangeInput.d.ts +1 -1
- package/dist/DateRangeInput/DateRangeInput.d.ts.map +1 -1
- package/dist/DateRangeInput/DateRangeInput.js +6 -11
- package/dist/DateTimeInput/DateTimeInput.d.ts +1 -1
- package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
- package/dist/DateTimeInput/DateTimeInput.js +7 -15
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +12 -15
- package/dist/Dialog/DialogHeader.d.ts +1 -1
- package/dist/Dialog/DialogHeader.d.ts.map +1 -1
- package/dist/Dialog/DialogHeader.js +3 -7
- package/dist/DropdownMenu/DropdownMenu.d.ts +1 -1
- package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenu.js +5 -11
- package/dist/FileInput/FileInput.d.ts.map +1 -1
- package/dist/FileInput/FileInput.js +1 -11
- package/dist/Lightbox/Lightbox.d.ts.map +1 -1
- package/dist/Lightbox/Lightbox.js +4 -6
- package/dist/Link/Link.d.ts +1 -1
- package/dist/Link/Link.d.ts.map +1 -1
- package/dist/Link/Link.js +1 -4
- package/dist/Markdown/Markdown.d.ts.map +1 -1
- package/dist/Markdown/Markdown.js +8 -10
- package/dist/MobileNav/MobileNav.d.ts.map +1 -1
- package/dist/MobileNav/MobileNav.js +2 -4
- package/dist/MobileNav/MobileNavToggle.d.ts +1 -1
- package/dist/MobileNav/MobileNavToggle.d.ts.map +1 -1
- package/dist/MobileNav/MobileNavToggle.js +1 -4
- package/dist/MoreMenu/MoreMenu.d.ts +1 -1
- package/dist/MoreMenu/MoreMenu.d.ts.map +1 -1
- package/dist/MoreMenu/MoreMenu.js +1 -4
- package/dist/MultiSelector/MultiSelector.d.ts +1 -1
- package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
- package/dist/MultiSelector/MultiSelector.js +6 -13
- package/dist/NavItem/index.d.ts +9 -0
- package/dist/NavItem/index.d.ts.map +1 -0
- package/dist/NavItem/index.js +10 -0
- package/dist/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/NumberInput/NumberInput.js +1 -5
- package/dist/Outline/Outline.d.ts +1 -1
- package/dist/Outline/Outline.d.ts.map +1 -1
- package/dist/Outline/Outline.js +1 -4
- package/dist/Pagination/Pagination.d.ts +1 -1
- package/dist/Pagination/Pagination.d.ts.map +1 -1
- package/dist/Pagination/Pagination.js +11 -38
- package/dist/Popover/usePopover.d.ts.map +1 -1
- package/dist/Popover/usePopover.js +1 -4
- package/dist/PowerSearch/PowerSearch.d.ts +1 -1
- package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearch.js +12 -22
- package/dist/PowerSearch/PowerSearchEditPopover.d.ts +1 -1
- package/dist/PowerSearch/PowerSearchEditPopover.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchEditPopover.js +20 -26
- package/dist/PowerSearch/PowerSearchToken.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchToken.js +3 -7
- package/dist/PowerSearch/PowerSearchValueEditor.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchValueEditor.js +21 -34
- package/dist/PowerSearch/formatFilterValue.d.ts +1 -2
- package/dist/PowerSearch/formatFilterValue.d.ts.map +1 -1
- package/dist/PowerSearch/formatFilterValue.js +9 -19
- package/dist/PowerSearch/index.d.ts +1 -2
- package/dist/PowerSearch/index.d.ts.map +1 -1
- package/dist/PowerSearch/index.js +0 -1
- package/dist/PowerSearch/types.d.ts +2 -28
- package/dist/PowerSearch/types.d.ts.map +1 -1
- package/dist/PowerSearch/usePowerSearchConfig.d.ts.map +1 -1
- package/dist/PowerSearch/usePowerSearchConfig.js +27 -27
- package/dist/PowerSearch/usePowerSearchSource.d.ts.map +1 -1
- package/dist/PowerSearch/usePowerSearchSource.js +8 -15
- package/dist/Resizable/ResizeHandle.d.ts +1 -1
- package/dist/Resizable/ResizeHandle.d.ts.map +1 -1
- package/dist/Resizable/ResizeHandle.js +1 -4
- package/dist/Selector/Selector.d.ts.map +1 -1
- package/dist/Selector/Selector.js +5 -11
- package/dist/SideNav/SideNav.d.ts.map +1 -1
- package/dist/SideNav/SideNav.js +2 -4
- package/dist/SideNav/SideNavCollapseButton.d.ts.map +1 -1
- package/dist/SideNav/SideNavCollapseButton.js +1 -3
- package/dist/SideNav/SideNavHeading.d.ts.map +1 -1
- package/dist/SideNav/SideNavHeading.js +3 -5
- package/dist/SideNav/SideNavItem.d.ts.map +1 -1
- package/dist/SideNav/SideNavItem.js +1 -7
- package/dist/TabList/TabList.d.ts +1 -1
- package/dist/TabList/TabList.d.ts.map +1 -1
- package/dist/TabList/TabList.js +1 -4
- package/dist/Table/BaseTable.d.ts.map +1 -1
- package/dist/Table/BaseTable.js +16 -29
- package/dist/Table/Table.d.ts.map +1 -1
- package/dist/Table/Table.js +3 -5
- package/dist/Table/plugins/columnResize/useTableColumnResize.js +1 -1
- package/dist/Table/plugins/filtering/useTableFiltering.d.ts.map +1 -1
- package/dist/Table/plugins/filtering/useTableFiltering.js +19 -56
- package/dist/Table/plugins/groupedRows/useTableGroupedRows.d.ts.map +1 -1
- package/dist/Table/plugins/groupedRows/useTableGroupedRows.js +4 -11
- package/dist/Table/plugins/pagination/useTablePagination.d.ts.map +1 -1
- package/dist/Table/plugins/pagination/useTablePagination.js +3 -6
- package/dist/Table/plugins/rowExpansion/useTableRowExpansion.d.ts.map +1 -1
- package/dist/Table/plugins/rowExpansion/useTableRowExpansion.js +6 -8
- package/dist/Table/plugins/selection/useTableSelection.d.ts.map +1 -1
- package/dist/Table/plugins/selection/useTableSelection.js +2 -5
- package/dist/Table/plugins/sortable/useTableSortable.d.ts.map +1 -1
- package/dist/Table/plugins/sortable/useTableSortable.js +4 -6
- package/dist/Table/plugins/stickyColumns/useTableStickyColumns.js +2 -2
- package/dist/Table/types.d.ts +10 -17
- package/dist/Table/types.d.ts.map +1 -1
- package/dist/TextInput/TextInput.d.ts.map +1 -1
- package/dist/TextInput/TextInput.js +1 -5
- package/dist/Thumbnail/Thumbnail.d.ts.map +1 -1
- package/dist/Thumbnail/Thumbnail.js +2 -8
- package/dist/TimeInput/TimeInput.d.ts +1 -1
- package/dist/TimeInput/TimeInput.d.ts.map +1 -1
- package/dist/TimeInput/TimeInput.js +2 -7
- package/dist/Toast/Toast.d.ts.map +1 -1
- package/dist/Toast/Toast.js +1 -3
- package/dist/Toast/ToastViewport.d.ts.map +1 -1
- package/dist/Toast/ToastViewport.js +1 -3
- package/dist/Token/Token.d.ts.map +1 -1
- package/dist/Token/Token.js +2 -8
- package/dist/Tokenizer/Tokenizer.d.ts.map +1 -1
- package/dist/Tokenizer/Tokenizer.js +1 -3
- package/dist/TopNav/TopNav.d.ts +1 -1
- package/dist/TopNav/TopNav.d.ts.map +1 -1
- package/dist/TopNav/TopNav.js +1 -4
- package/dist/TopNav/TopNavHeading.d.ts.map +1 -1
- package/dist/TopNav/TopNavHeading.js +3 -5
- package/dist/TreeList/TreeList.d.ts.map +1 -1
- package/dist/TreeList/TreeList.js +1 -5
- package/dist/TreeList/TreeListItem.d.ts.map +1 -1
- package/dist/TreeList/TreeListItem.js +1 -7
- package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
- package/dist/Typeahead/BaseTypeahead.js +4 -8
- package/dist/Typeahead/Typeahead.d.ts.map +1 -1
- package/dist/Typeahead/Typeahead.js +1 -3
- package/dist/VisuallyHidden/VisuallyHidden.d.ts +0 -1
- package/dist/VisuallyHidden/VisuallyHidden.d.ts.map +1 -1
- package/dist/VisuallyHidden/VisuallyHidden.js +0 -1
- package/dist/astryx.css +1 -3
- package/dist/astryx.umd.js +60 -62
- package/dist/astryx.umd.js.map +4 -4
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -3
- package/package.json +2 -23
- package/src/AlertDialog/AlertDialog.tsx +1 -4
- package/src/AppShell/AppShell.doc.mjs +2 -8
- package/src/AppShell/AppShell.tsx +1 -3
- package/src/AvatarGroup/AvatarGroup.tsx +1 -4
- package/src/Banner/Banner.tsx +5 -10
- package/src/Breadcrumbs/Breadcrumbs.tsx +1 -4
- package/src/Button/Button.tsx +4 -34
- package/src/ButtonGroup/ButtonGroup.test.tsx +2 -386
- package/src/ButtonGroup/ButtonGroup.tsx +11 -27
- package/src/Calendar/Calendar.tsx +5 -8
- package/src/Card/Card.doc.mjs +3 -3
- package/src/Carousel/Carousel.tsx +7 -10
- package/src/Chat/ChatComposer.tsx +1 -5
- package/src/Chat/ChatComposerDrawer.tsx +2 -9
- package/src/Chat/ChatComposerInput.tsx +4 -10
- package/src/Chat/ChatLayout.test.tsx +2 -127
- package/src/Chat/ChatLayout.tsx +12 -5
- package/src/Chat/ChatLayoutScrollButton.tsx +2 -4
- package/src/Chat/ChatMessage.tsx +1 -5
- package/src/Chat/ChatMessageBubble.tsx +0 -2
- package/src/Chat/ChatMessageList.doc.mjs +1 -1
- package/src/Chat/ChatMessageList.tsx +0 -2
- package/src/Chat/ChatMessageMetadata.tsx +9 -15
- package/src/Chat/ChatPastedTextToken.tsx +1 -3
- package/src/Chat/ChatSendButton.tsx +1 -3
- package/src/Chat/ChatToolCalls.doc.mjs +1 -1
- package/src/Chat/index.ts +0 -1
- package/src/Chat/useChatStreamScroll.ts +11 -67
- package/src/Chat/useSpeechRecognition.ts +2 -11
- package/src/Chat/useTriggerMenu.tsx +2 -4
- package/src/CheckboxList/CheckboxList.doc.mjs +1 -1
- package/src/CheckboxList/CheckboxList.tsx +0 -2
- package/src/CheckboxList/CheckboxListItem.tsx +1 -7
- package/src/Citation/Citation.tsx +2 -4
- package/src/ClickableCard/ClickableCard.doc.mjs +1 -1
- package/src/CodeBlock/CodeBlock.tsx +2 -4
- package/src/CommandPalette/CommandPalette.tsx +3 -10
- package/src/CommandPalette/CommandPaletteInput.test.tsx +1 -1
- package/src/CommandPalette/CommandPaletteInput.tsx +1 -5
- package/src/CommandPalette/CommandPaletteList.tsx +1 -4
- package/src/ContextMenu/ContextMenu.tsx +1 -4
- package/src/DateInput/DateInput.doc.mjs +2 -2
- package/src/DateInput/DateInput.tsx +5 -13
- package/src/DateRangeInput/DateRangeInput.doc.mjs +1 -1
- package/src/DateRangeInput/DateRangeInput.tsx +6 -14
- package/src/DateTimeInput/DateTimeInput.doc.mjs +2 -2
- package/src/DateTimeInput/DateTimeInput.tsx +7 -17
- package/src/Dialog/Dialog.tsx +15 -11
- package/src/Dialog/DialogHeader.tsx +3 -7
- package/src/DropdownMenu/DropdownMenu.tsx +8 -12
- package/src/Field/Field.doc.mjs +2 -2
- package/src/FileInput/FileInput.test.tsx +1 -40
- package/src/FileInput/FileInput.tsx +1 -12
- package/src/Grid/Grid.doc.mjs +5 -5
- package/src/InputGroup/InputGroup.doc.mjs +1 -1
- package/src/Lightbox/Lightbox.doc.mjs +2 -7
- package/src/Lightbox/Lightbox.tsx +4 -6
- package/src/Link/Link.tsx +1 -4
- package/src/Markdown/Markdown.tsx +4 -12
- package/src/MobileNav/MobileNav.tsx +2 -4
- package/src/MobileNav/MobileNavToggle.tsx +3 -5
- package/src/MoreMenu/MoreMenu.tsx +1 -4
- package/src/MultiSelector/MultiSelector.tsx +5 -14
- package/src/NavItem/index.ts +11 -0
- package/src/NumberInput/NumberInput.tsx +1 -3
- package/src/Outline/Outline.tsx +1 -4
- package/src/OverflowList/OverflowList.doc.mjs +2 -2
- package/src/Pagination/Pagination.tsx +12 -35
- package/src/Popover/usePopover.tsx +1 -6
- package/src/PowerSearch/PowerSearch.doc.mjs +4 -4
- package/src/PowerSearch/PowerSearch.tsx +10 -22
- package/src/PowerSearch/PowerSearchEditPopover.tsx +20 -27
- package/src/PowerSearch/PowerSearchToken.tsx +6 -17
- package/src/PowerSearch/PowerSearchValueEditor.tsx +21 -34
- package/src/PowerSearch/formatFilterValue.ts +8 -21
- package/src/PowerSearch/index.ts +0 -5
- package/src/PowerSearch/types.ts +9 -33
- package/src/PowerSearch/usePowerSearchConfig.ts +27 -59
- package/src/PowerSearch/usePowerSearchSource.ts +8 -17
- package/src/RadioList/RadioList.doc.mjs +1 -1
- package/src/Resizable/ResizeHandle.tsx +1 -4
- package/src/Section/Section.doc.mjs +4 -4
- package/src/SelectableCard/SelectableCard.doc.mjs +1 -1
- package/src/Selector/Selector.tsx +6 -11
- package/src/SideNav/SideNav.tsx +2 -4
- package/src/SideNav/SideNavCollapseButton.tsx +1 -3
- package/src/SideNav/SideNavHeading.tsx +3 -5
- package/src/SideNav/SideNavItem.tsx +1 -3
- package/src/Slider/Slider.doc.mjs +2 -2
- package/src/Stack/Stack.doc.mjs +10 -10
- package/src/Switch/Switch.doc.mjs +2 -2
- package/src/TabList/TabList.tsx +1 -4
- package/src/Table/BaseTable.tsx +19 -36
- package/src/Table/Table.test.tsx +1 -132
- package/src/Table/Table.tsx +4 -6
- package/src/Table/plugins/columnResize/useTableColumnResize.tsx +1 -1
- package/src/Table/plugins/filtering/useTableFiltering.tsx +30 -31
- package/src/Table/plugins/groupedRows/useTableGroupedRows.tsx +4 -6
- package/src/Table/plugins/pagination/useTablePagination.tsx +1 -4
- package/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx +8 -9
- package/src/Table/plugins/selection/useTableSelection.tsx +7 -6
- package/src/Table/plugins/sortable/useTableSortable.tsx +5 -8
- package/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx +4 -4
- package/src/Table/types.ts +12 -18
- package/src/Table/useTableFiltering.doc.mjs +2 -2
- package/src/Table/useTableSortable.doc.mjs +11 -11
- package/src/Text/Text.doc.mjs +2 -2
- package/src/TextInput/TextInput.tsx +1 -3
- package/src/Thumbnail/Thumbnail.tsx +2 -4
- package/src/TimeInput/TimeInput.doc.mjs +2 -2
- package/src/TimeInput/TimeInput.tsx +2 -6
- package/src/Timestamp/Timestamp.doc.mjs +4 -4
- package/src/Toast/Toast.tsx +1 -3
- package/src/Toast/ToastViewport.tsx +1 -3
- package/src/Token/Token.tsx +2 -4
- package/src/Tokenizer/Tokenizer.doc.mjs +2 -2
- package/src/Tokenizer/Tokenizer.tsx +4 -4
- package/src/Toolbar/Toolbar.doc.mjs +1 -1
- package/src/TopNav/TopNav.tsx +1 -4
- package/src/TopNav/TopNavHeading.tsx +3 -5
- package/src/TreeList/TreeList.tsx +1 -5
- package/src/TreeList/TreeListItem.tsx +1 -6
- package/src/Typeahead/BaseTypeahead.tsx +4 -11
- package/src/Typeahead/Typeahead.doc.mjs +1 -1
- package/src/Typeahead/Typeahead.tsx +1 -3
- package/src/VisuallyHidden/VisuallyHidden.tsx +0 -1
- package/src/index.ts +0 -3
- package/dist/PowerSearch/resolveOperatorLabel.d.ts +0 -23
- package/dist/PowerSearch/resolveOperatorLabel.d.ts.map +0 -1
- package/dist/PowerSearch/resolveOperatorLabel.js +0 -28
- package/dist/authoring/doc.d.ts +0 -145
- package/dist/authoring/doc.d.ts.map +0 -1
- package/dist/authoring/doc.js +0 -100
- package/dist/authoring/index.d.ts +0 -29
- package/dist/authoring/index.d.ts.map +0 -1
- package/dist/authoring/index.js +0 -28
- package/dist/authoring/integration.d.ts +0 -35
- package/dist/authoring/integration.d.ts.map +0 -1
- package/dist/authoring/integration.js +0 -30
- package/dist/authoring/template.d.ts +0 -66
- package/dist/authoring/template.d.ts.map +0 -1
- package/dist/authoring/template.js +0 -55
- package/dist/config.d.ts +0 -80
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -40
- package/dist/i18n/InternationalizationContext.d.ts +0 -12
- package/dist/i18n/InternationalizationContext.d.ts.map +0 -1
- package/dist/i18n/InternationalizationContext.js +0 -29
- package/dist/i18n/InternationalizationProvider.d.ts +0 -62
- package/dist/i18n/InternationalizationProvider.d.ts.map +0 -1
- package/dist/i18n/InternationalizationProvider.js +0 -44
- package/dist/i18n/index.d.ts +0 -24
- package/dist/i18n/index.d.ts.map +0 -1
- package/dist/i18n/index.js +0 -21
- package/dist/i18n/resolve.d.ts +0 -22
- package/dist/i18n/resolve.d.ts.map +0 -1
- package/dist/i18n/resolve.js +0 -141
- package/dist/i18n/translator.d.ts +0 -25
- package/dist/i18n/translator.d.ts.map +0 -1
- package/dist/i18n/translator.js +0 -1
- package/dist/i18n/types.d.ts +0 -47
- package/dist/i18n/types.d.ts.map +0 -1
- package/dist/i18n/types.js +0 -1
- package/dist/i18n/useTranslator.d.ts +0 -15
- package/dist/i18n/useTranslator.d.ts.map +0 -1
- package/dist/i18n/useTranslator.js +0 -39
- package/locales/en.json +0 -746
- package/locales/pseudo.json +0 -560
- package/src/Chat/useChatStreamScroll.test.tsx +0 -168
- package/src/PowerSearch/formatFilterValue.test.ts +0 -282
- package/src/PowerSearch/resolveOperatorLabel.ts +0 -34
- package/src/authoring/doc.ts +0 -166
- package/src/authoring/index.test.ts +0 -52
- package/src/authoring/index.ts +0 -50
- package/src/authoring/integration.ts +0 -42
- package/src/authoring/template.ts +0 -74
- package/src/config.test.ts +0 -16
- package/src/config.ts +0 -92
- package/src/docPropLiterals.test.ts +0 -938
- package/src/i18n/InternationalizationContext.ts +0 -39
- package/src/i18n/InternationalizationProvider.doc.mjs +0 -72
- package/src/i18n/InternationalizationProvider.tsx +0 -83
- package/src/i18n/__tests__/e2e-pagination.test.tsx +0 -172
- package/src/i18n/__tests__/e2e-powersearch.test.tsx +0 -130
- package/src/i18n/__tests__/resolve.test.ts +0 -284
- package/src/i18n/index.ts +0 -32
- package/src/i18n/resolve.ts +0 -165
- package/src/i18n/translator.ts +0 -31
- package/src/i18n/types.ts +0 -53
- package/src/i18n/useTranslator.doc.mjs +0 -46
- package/src/i18n/useTranslator.ts +0 -50
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file resolve.test.ts
|
|
5
|
-
* @input packages/core/src/i18n/resolve.ts
|
|
6
|
-
* @output Unit tests for the shared i18n lookup + format core
|
|
7
|
-
* @position Colocated tests; targets locale-chain fallback, ICU formatting,
|
|
8
|
-
* overrides, and missing-key behavior.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import {describe, expect, test, beforeEach, vi} from 'vitest';
|
|
12
|
-
import {__resetForTests, resolve, resolveLocaleChain} from '../resolve';
|
|
13
|
-
import type {Catalog, MessagesByLocale, Overrides} from '../types';
|
|
14
|
-
|
|
15
|
-
// Reset caches between tests so warn-once and formatter cache don't bleed.
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
__resetForTests();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
describe('resolveLocaleChain', () => {
|
|
21
|
-
test('single-part tag returns single-item chain', () => {
|
|
22
|
-
expect(resolveLocaleChain('en')).toEqual(['en']);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
test('regional tag walks to base language', () => {
|
|
26
|
-
expect(resolveLocaleChain('pt-BR')).toEqual(['pt-BR', 'pt']);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test('script-tagged locale walks to script and then base', () => {
|
|
30
|
-
expect(resolveLocaleChain('zh-Hans-CN')).toEqual([
|
|
31
|
-
'zh-Hans-CN',
|
|
32
|
-
'zh-Hans',
|
|
33
|
-
'zh',
|
|
34
|
-
]);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
test('canonicalizes casing via Intl.Locale', () => {
|
|
38
|
-
// Consumers who pass "en-us" (lowercase region) should get the canonical
|
|
39
|
-
// BCP 47 form back so lookups match spec-canonical catalog keys.
|
|
40
|
-
expect(resolveLocaleChain('en-us')).toEqual(['en-US', 'en']);
|
|
41
|
-
expect(resolveLocaleChain('PT-br')).toEqual(['pt-BR', 'pt']);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
test('malformed input falls back to the raw string chain', () => {
|
|
45
|
-
// Intl.Locale throws on invalid input; we don't want the whole render to
|
|
46
|
-
// die because a consumer passed a bad tag.
|
|
47
|
-
expect(resolveLocaleChain('not_a_locale')).toEqual(['not_a_locale']);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
describe('resolve — basic lookup', () => {
|
|
52
|
-
test('falls back to shipped en catalog when locale is en and no messages passed', () => {
|
|
53
|
-
// The shipped en.json is imported at module load; Pagination keys should
|
|
54
|
-
// resolve. This asserts the module wiring works end-to-end.
|
|
55
|
-
const out = resolve(
|
|
56
|
-
'@astryx.pagination.next',
|
|
57
|
-
undefined,
|
|
58
|
-
'en',
|
|
59
|
-
{},
|
|
60
|
-
undefined,
|
|
61
|
-
);
|
|
62
|
-
expect(out).toBe('Go to next page');
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
test('returns the key itself and warns for unknown key', () => {
|
|
66
|
-
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
67
|
-
const out = resolve(
|
|
68
|
-
'@astryx.does.not.exist',
|
|
69
|
-
undefined,
|
|
70
|
-
'en',
|
|
71
|
-
{},
|
|
72
|
-
undefined,
|
|
73
|
-
);
|
|
74
|
-
expect(out).toBe('@astryx.does.not.exist');
|
|
75
|
-
expect(warn).toHaveBeenCalledWith(expect.stringContaining('missing key'));
|
|
76
|
-
warn.mockRestore();
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
describe('resolve — provider messages', () => {
|
|
81
|
-
const catalog: Catalog = {
|
|
82
|
-
'@astryx.pagination.next': {defaultMessage: 'Suivant'},
|
|
83
|
-
};
|
|
84
|
-
const messages: MessagesByLocale = {fr: catalog};
|
|
85
|
-
|
|
86
|
-
test('uses provider messages for the current locale', () => {
|
|
87
|
-
const out = resolve(
|
|
88
|
-
'@astryx.pagination.next',
|
|
89
|
-
undefined,
|
|
90
|
-
'fr',
|
|
91
|
-
messages,
|
|
92
|
-
undefined,
|
|
93
|
-
);
|
|
94
|
-
expect(out).toBe('Suivant');
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
test('falls back to en for keys not in the provider catalog, silently', () => {
|
|
98
|
-
// pagination.previous is only in en; fr catalog has only .next.
|
|
99
|
-
// Missing translations for a locale are expected during rollout — the
|
|
100
|
-
// fallback should be silent (matches i18next / FormatJS default). We
|
|
101
|
-
// reserve console.warn for real bugs (key missing even from en).
|
|
102
|
-
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
103
|
-
const out = resolve(
|
|
104
|
-
'@astryx.pagination.previous',
|
|
105
|
-
undefined,
|
|
106
|
-
'fr',
|
|
107
|
-
messages,
|
|
108
|
-
undefined,
|
|
109
|
-
);
|
|
110
|
-
expect(out).toBe('Go to previous page');
|
|
111
|
-
expect(warn).not.toHaveBeenCalled();
|
|
112
|
-
warn.mockRestore();
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
describe('resolve — locale-chain fallback (regional → language)', () => {
|
|
117
|
-
const messages: MessagesByLocale = {
|
|
118
|
-
'pt-BR': {
|
|
119
|
-
'@astryx.pagination.next': {defaultMessage: 'Próxima (BR)'},
|
|
120
|
-
},
|
|
121
|
-
pt: {
|
|
122
|
-
'@astryx.pagination.next': {defaultMessage: 'Próxima'},
|
|
123
|
-
'@astryx.pagination.previous': {defaultMessage: 'Anterior'},
|
|
124
|
-
},
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
test('exact regional match wins', () => {
|
|
128
|
-
const out = resolve(
|
|
129
|
-
'@astryx.pagination.next',
|
|
130
|
-
undefined,
|
|
131
|
-
'pt-BR',
|
|
132
|
-
messages,
|
|
133
|
-
undefined,
|
|
134
|
-
);
|
|
135
|
-
expect(out).toBe('Próxima (BR)');
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
test('falls back to base language when regional entry missing', () => {
|
|
139
|
-
// pt-BR catalog has no .previous — should walk pt-BR → pt
|
|
140
|
-
const out = resolve(
|
|
141
|
-
'@astryx.pagination.previous',
|
|
142
|
-
undefined,
|
|
143
|
-
'pt-BR',
|
|
144
|
-
messages,
|
|
145
|
-
undefined,
|
|
146
|
-
);
|
|
147
|
-
expect(out).toBe('Anterior');
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
test('falls back to en when neither regional nor base has the key', () => {
|
|
151
|
-
// pt-BR nor pt has .label — walk to en
|
|
152
|
-
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
153
|
-
const out = resolve(
|
|
154
|
-
'@astryx.pagination.label',
|
|
155
|
-
undefined,
|
|
156
|
-
'pt-BR',
|
|
157
|
-
messages,
|
|
158
|
-
undefined,
|
|
159
|
-
);
|
|
160
|
-
expect(out).toBe('Pagination');
|
|
161
|
-
warn.mockRestore();
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
describe('resolve — overrides', () => {
|
|
166
|
-
test('per-locale override wins over shipped catalog', () => {
|
|
167
|
-
const messages: MessagesByLocale = {
|
|
168
|
-
fr: {'@astryx.pagination.next': {defaultMessage: 'Suivant'}},
|
|
169
|
-
};
|
|
170
|
-
const overrides: Overrides = {
|
|
171
|
-
fr: {'@astryx.pagination.next': 'Suiv.'},
|
|
172
|
-
};
|
|
173
|
-
const out = resolve(
|
|
174
|
-
'@astryx.pagination.next',
|
|
175
|
-
undefined,
|
|
176
|
-
'fr',
|
|
177
|
-
messages,
|
|
178
|
-
overrides,
|
|
179
|
-
);
|
|
180
|
-
expect(out).toBe('Suiv.');
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
test('overrides respect the locale chain (pt-BR → pt)', () => {
|
|
184
|
-
// Override defined at pt level, current locale is pt-BR
|
|
185
|
-
const overrides: Overrides = {
|
|
186
|
-
pt: {'@astryx.pagination.next': 'Próxima (pt override)'},
|
|
187
|
-
};
|
|
188
|
-
const out = resolve(
|
|
189
|
-
'@astryx.pagination.next',
|
|
190
|
-
undefined,
|
|
191
|
-
'pt-BR',
|
|
192
|
-
{},
|
|
193
|
-
overrides,
|
|
194
|
-
);
|
|
195
|
-
expect(out).toBe('Próxima (pt override)');
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
test('override for a different locale does not apply', () => {
|
|
199
|
-
const overrides: Overrides = {
|
|
200
|
-
es: {'@astryx.pagination.next': 'Siguiente'},
|
|
201
|
-
};
|
|
202
|
-
const out = resolve(
|
|
203
|
-
'@astryx.pagination.next',
|
|
204
|
-
undefined,
|
|
205
|
-
'fr',
|
|
206
|
-
{},
|
|
207
|
-
overrides,
|
|
208
|
-
);
|
|
209
|
-
// Should fall through to en since fr has no messages and es override doesn't apply
|
|
210
|
-
expect(out).toBe('Go to next page');
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
describe('resolve — ICU MessageFormat', () => {
|
|
215
|
-
test('interpolates simple named placeholders', () => {
|
|
216
|
-
const out = resolve(
|
|
217
|
-
'@astryx.pagination.goToPage',
|
|
218
|
-
{page: 5},
|
|
219
|
-
'en',
|
|
220
|
-
{},
|
|
221
|
-
undefined,
|
|
222
|
-
);
|
|
223
|
-
expect(out).toContain('5');
|
|
224
|
-
expect(out).toMatch(/Go to page/);
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
test('formats numbers using Intl.NumberFormat for the locale', () => {
|
|
228
|
-
// Pagination.count uses {from, number}, {to, number}, {total, number}
|
|
229
|
-
// In en-US, 1000 formats as "1,000"
|
|
230
|
-
const out = resolve(
|
|
231
|
-
'@astryx.pagination.count',
|
|
232
|
-
{from: 1, to: 10, total: 1000},
|
|
233
|
-
'en-US',
|
|
234
|
-
{},
|
|
235
|
-
undefined,
|
|
236
|
-
);
|
|
237
|
-
expect(out).toContain('1,000');
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
test('formats numbers for locales with different separators', () => {
|
|
241
|
-
// In de-DE, 1000 formats as "1.000"
|
|
242
|
-
const out = resolve(
|
|
243
|
-
'@astryx.pagination.count',
|
|
244
|
-
{from: 1, to: 10, total: 1000},
|
|
245
|
-
'de-DE',
|
|
246
|
-
{},
|
|
247
|
-
undefined,
|
|
248
|
-
);
|
|
249
|
-
// We don't have a de catalog so falls back to en's PATTERN, but the
|
|
250
|
-
// number formatting uses the locale passed to IntlMessageFormat.
|
|
251
|
-
expect(out).toContain('1.000');
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
test('handles plural forms with ICU {n, plural, one {} other {}} pattern', () => {
|
|
255
|
-
const catalog: Catalog = {
|
|
256
|
-
'test.items': {
|
|
257
|
-
defaultMessage:
|
|
258
|
-
'{count, plural, =0 {no items} one {# item} other {# items}}',
|
|
259
|
-
},
|
|
260
|
-
};
|
|
261
|
-
const messages = {en: catalog};
|
|
262
|
-
|
|
263
|
-
expect(resolve('test.items', {count: 0}, 'en', messages, undefined)).toBe(
|
|
264
|
-
'no items',
|
|
265
|
-
);
|
|
266
|
-
expect(resolve('test.items', {count: 1}, 'en', messages, undefined)).toBe(
|
|
267
|
-
'1 item',
|
|
268
|
-
);
|
|
269
|
-
expect(resolve('test.items', {count: 5}, 'en', messages, undefined)).toBe(
|
|
270
|
-
'5 items',
|
|
271
|
-
);
|
|
272
|
-
});
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
describe('resolve — warn-once behavior', () => {
|
|
276
|
-
test('duplicate missing-key warnings are suppressed', () => {
|
|
277
|
-
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
278
|
-
resolve('@astryx.does.not.exist', undefined, 'en', {}, undefined);
|
|
279
|
-
resolve('@astryx.does.not.exist', undefined, 'en', {}, undefined);
|
|
280
|
-
resolve('@astryx.does.not.exist', undefined, 'en', {}, undefined);
|
|
281
|
-
expect(warn).toHaveBeenCalledTimes(1);
|
|
282
|
-
warn.mockRestore();
|
|
283
|
-
});
|
|
284
|
-
});
|
package/src/i18n/index.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file index.ts
|
|
5
|
-
* @input Imports from InternationalizationProvider, InternationalizationContext,
|
|
6
|
-
* useTranslator, translator, types
|
|
7
|
-
* @output Public surface for the i18n subpackage
|
|
8
|
-
* @position Component entry point; re-exported by /packages/core/src/index.ts
|
|
9
|
-
*
|
|
10
|
-
* The public API is deliberately small:
|
|
11
|
-
* - InternationalizationProvider — provider component
|
|
12
|
-
* - useTranslator — hook returning a translator function
|
|
13
|
-
* - Translator — interface for consumer-injected runtimes
|
|
14
|
-
*
|
|
15
|
-
* SYNC: When modified, update these files to stay in sync:
|
|
16
|
-
* - /packages/core/src/index.ts
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
export {InternationalizationProvider} from './InternationalizationProvider';
|
|
20
|
-
export type {InternationalizationProviderProps} from './InternationalizationProvider';
|
|
21
|
-
export {InternationalizationContext} from './InternationalizationContext';
|
|
22
|
-
export type {InternationalizationContextValue} from './InternationalizationContext';
|
|
23
|
-
export {useTranslator} from './useTranslator';
|
|
24
|
-
export type {TranslatorFn} from './useTranslator';
|
|
25
|
-
export type {Translator} from './translator';
|
|
26
|
-
export type {
|
|
27
|
-
Locale,
|
|
28
|
-
Catalog,
|
|
29
|
-
MessageEntry,
|
|
30
|
-
MessagesByLocale,
|
|
31
|
-
Overrides,
|
|
32
|
-
} from './types';
|
package/src/i18n/resolve.ts
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file resolve.ts
|
|
5
|
-
* @input Key + values + locale + catalog + overrides
|
|
6
|
-
* @output Formatted message string
|
|
7
|
-
* @position Shared lookup + ICU formatting core, used by useTranslator().
|
|
8
|
-
*
|
|
9
|
-
* Lookup order:
|
|
10
|
-
* 1. Per-locale override for the exact locale
|
|
11
|
-
* 2. Per-locale override for a parent locale (pt-BR → pt)
|
|
12
|
-
* 3. Shipped catalog entry for the exact locale
|
|
13
|
-
* 4. Shipped catalog entry for a parent locale (pt-BR → pt)
|
|
14
|
-
* 5. Shipped en catalog (the source of truth, always present)
|
|
15
|
-
* 6. The key itself (dev-visible fallback, warns once)
|
|
16
|
-
*
|
|
17
|
-
* SYNC: When modified, update these files to stay in sync:
|
|
18
|
-
* - /packages/core/src/i18n/useTranslator.ts
|
|
19
|
-
* - /packages/core/src/i18n/__tests__/resolve.test.ts
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
import IntlMessageFormat from 'intl-messageformat';
|
|
23
|
-
import type {Catalog, Locale, MessagesByLocale, Overrides} from './types';
|
|
24
|
-
import enSource from '../../locales/en.json' with {type: 'json'};
|
|
25
|
-
|
|
26
|
-
const EN_CATALOG = enSource as Catalog;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Cache of parsed ICU MessageFormat objects keyed by `${locale}::${message}`.
|
|
30
|
-
* IntlMessageFormat parsing is non-trivial; caching avoids reparsing on every
|
|
31
|
-
* render. The cache is unbounded in principle but bounded in practice by the
|
|
32
|
-
* static set of astryx keys.
|
|
33
|
-
*/
|
|
34
|
-
const formatterCache = new Map<string, IntlMessageFormat>();
|
|
35
|
-
|
|
36
|
-
function getFormatter(message: string, locale: Locale): IntlMessageFormat {
|
|
37
|
-
const cacheKey = `${locale}::${message}`;
|
|
38
|
-
let f = formatterCache.get(cacheKey);
|
|
39
|
-
if (f === undefined) {
|
|
40
|
-
f = new IntlMessageFormat(message, locale);
|
|
41
|
-
formatterCache.set(cacheKey, f);
|
|
42
|
-
}
|
|
43
|
-
return f;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Walk a BCP 47 tag from most-specific to least-specific.
|
|
48
|
-
* Input is canonicalized via `Intl.Locale.baseName` so `pt-br` and `PT-BR`
|
|
49
|
-
* both produce `['pt-BR', 'pt']`.
|
|
50
|
-
*
|
|
51
|
-
* Examples:
|
|
52
|
-
* 'pt-BR' → ['pt-BR', 'pt']
|
|
53
|
-
* 'zh-Hans-CN' → ['zh-Hans-CN', 'zh-Hans', 'zh']
|
|
54
|
-
* 'en' → ['en']
|
|
55
|
-
*
|
|
56
|
-
* `en` is intentionally NOT appended here — the caller falls back to the
|
|
57
|
-
* shipped en catalog separately as the final source-of-truth.
|
|
58
|
-
*/
|
|
59
|
-
export function resolveLocaleChain(locale: Locale): Locale[] {
|
|
60
|
-
let canonical: string;
|
|
61
|
-
try {
|
|
62
|
-
canonical = new Intl.Locale(locale).baseName;
|
|
63
|
-
} catch {
|
|
64
|
-
// Malformed input — fall back to the raw string so callers still get a chain.
|
|
65
|
-
canonical = locale;
|
|
66
|
-
}
|
|
67
|
-
const parts = canonical.split('-');
|
|
68
|
-
const chain: Locale[] = [];
|
|
69
|
-
for (let i = parts.length; i > 0; i--) {
|
|
70
|
-
chain.push(parts.slice(0, i).join('-'));
|
|
71
|
-
}
|
|
72
|
-
return chain;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Missing-key warn-once tracking. Fires ONLY when a key is missing from
|
|
77
|
-
* every source including the shipped `en` catalog — that's a real bug
|
|
78
|
-
* (typo, stale catalog, deleted key). Fallback to `en` from a non-en
|
|
79
|
-
* locale is expected and silent, matching the FormatJS / i18next default
|
|
80
|
-
* of not spamming the console when a translation simply hasn't been
|
|
81
|
-
* written yet.
|
|
82
|
-
*/
|
|
83
|
-
const warnedMissing = new Set<string>();
|
|
84
|
-
|
|
85
|
-
function warnOnce(bucket: Set<string>, key: string, message: string): void {
|
|
86
|
-
if (!bucket.has(key)) {
|
|
87
|
-
bucket.add(key);
|
|
88
|
-
console.warn(message);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function lookup(
|
|
93
|
-
key: string,
|
|
94
|
-
locale: Locale,
|
|
95
|
-
messages: MessagesByLocale,
|
|
96
|
-
overrides: Overrides | undefined,
|
|
97
|
-
): string | null {
|
|
98
|
-
const chain = resolveLocaleChain(locale);
|
|
99
|
-
|
|
100
|
-
// 1 + 2. Overrides (most specific to least specific in the chain)
|
|
101
|
-
if (overrides !== undefined) {
|
|
102
|
-
for (const tag of chain) {
|
|
103
|
-
const value = overrides[tag]?.[key];
|
|
104
|
-
if (value !== undefined) {
|
|
105
|
-
return value;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// 3 + 4. Shipped catalogs (most specific to least specific)
|
|
111
|
-
for (const tag of chain) {
|
|
112
|
-
const entry = messages[tag]?.[key];
|
|
113
|
-
if (entry !== undefined) {
|
|
114
|
-
return entry.defaultMessage;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// 5. Shipped en catalog — always present
|
|
119
|
-
const enEntry = EN_CATALOG[key];
|
|
120
|
-
if (enEntry !== undefined) {
|
|
121
|
-
return enEntry.defaultMessage;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// 6. Nothing found
|
|
125
|
-
return null;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export function resolve(
|
|
129
|
-
key: string,
|
|
130
|
-
values: Record<string, unknown> | undefined,
|
|
131
|
-
locale: Locale,
|
|
132
|
-
messages: MessagesByLocale,
|
|
133
|
-
overrides: Overrides | undefined,
|
|
134
|
-
): string {
|
|
135
|
-
const result = lookup(key, locale, messages, overrides);
|
|
136
|
-
|
|
137
|
-
if (result === null) {
|
|
138
|
-
warnOnce(
|
|
139
|
-
warnedMissing,
|
|
140
|
-
`${locale}::${key}`,
|
|
141
|
-
`[astryx-i18n] missing key: ${key} (locale: ${locale})`,
|
|
142
|
-
);
|
|
143
|
-
return key;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if (values === undefined) {
|
|
147
|
-
// Static string — skip the parser entirely for the common case
|
|
148
|
-
return result;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
const formatted = getFormatter(result, locale).format(values);
|
|
152
|
-
// IntlMessageFormat.format returns string | (string | React elements) — we
|
|
153
|
-
// only ever pass string values so it will be a string; assert for the type
|
|
154
|
-
// system.
|
|
155
|
-
return formatted as string;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Reset internal caches. Test-only.
|
|
160
|
-
* @internal
|
|
161
|
-
*/
|
|
162
|
-
export function __resetForTests(): void {
|
|
163
|
-
formatterCache.clear();
|
|
164
|
-
warnedMissing.clear();
|
|
165
|
-
}
|
package/src/i18n/translator.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file translator.ts
|
|
5
|
-
* @input Translator interface for consumer i18n runtime injection
|
|
6
|
-
* @output Type surface for pluggable translators
|
|
7
|
-
* @position Public API for i18n adapter integration
|
|
8
|
-
*
|
|
9
|
-
* Consumers who already run an i18n runtime (react-intl, Lingui, i18next, etc.)
|
|
10
|
-
* can inject their own Translator instead of using the default provider. The
|
|
11
|
-
* interface is deliberately small so any real i18n library can satisfy it in a
|
|
12
|
-
* few lines.
|
|
13
|
-
*
|
|
14
|
-
* SYNC: When modified, update these files to stay in sync:
|
|
15
|
-
* - /packages/core/src/i18n/index.ts
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* A Translator formats ICU MessageFormat strings for a given locale.
|
|
20
|
-
* Consumers can supply their own to reuse their existing i18n runtime.
|
|
21
|
-
*/
|
|
22
|
-
export interface Translator {
|
|
23
|
-
/**
|
|
24
|
-
* Format an ICU MessageFormat message with values in the given locale.
|
|
25
|
-
*/
|
|
26
|
-
format(
|
|
27
|
-
message: string,
|
|
28
|
-
values?: Record<string, unknown>,
|
|
29
|
-
locale?: string,
|
|
30
|
-
): string;
|
|
31
|
-
}
|
package/src/i18n/types.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file types.ts
|
|
5
|
-
* @input None
|
|
6
|
-
* @output Shared types for the i18n subpackage
|
|
7
|
-
* @position Type-only module; used across client + server t() implementations
|
|
8
|
-
*
|
|
9
|
-
* SYNC: When modified, update these files to stay in sync:
|
|
10
|
-
* - /packages/core/src/i18n/InternationalizationContext.ts
|
|
11
|
-
* - /packages/core/src/i18n/InternationalizationProvider.tsx
|
|
12
|
-
* - /packages/core/src/i18n/serverStore.ts
|
|
13
|
-
* - /packages/core/src/i18n/resolve.ts
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* A BCP 47 language tag. Examples: `'en'`, `'pt'`, `'pt-BR'`, `'zh-Hans'`.
|
|
18
|
-
*
|
|
19
|
-
* Regional tags are meaningful — `pt-BR` and `pt` are different catalogs.
|
|
20
|
-
* When resolving a message, the runtime walks the tag from most-specific
|
|
21
|
-
* to least-specific and falls back to `en` if nothing matches
|
|
22
|
-
* (see `resolveLocaleChain` in `resolve.ts`).
|
|
23
|
-
*/
|
|
24
|
-
export type Locale = string;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* A single entry in a translation catalog. The `defaultMessage` is an ICU
|
|
28
|
-
* MessageFormat string; `description` is optional context for translators
|
|
29
|
-
* (surfaced by Crowdin's `react_intl` file type parser).
|
|
30
|
-
*/
|
|
31
|
-
export interface MessageEntry {
|
|
32
|
-
defaultMessage: string;
|
|
33
|
-
description?: string;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* A translation catalog — a map of stable message keys to entries.
|
|
38
|
-
* Astryx's own keys are namespaced under `@astryx.<component>.<name>`.
|
|
39
|
-
*/
|
|
40
|
-
export type Catalog = Record<string, MessageEntry>;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* A map of BCP 47 tags to catalogs. Passed as `messages` on
|
|
44
|
-
* `<InternationalizationProvider>`.
|
|
45
|
-
*/
|
|
46
|
-
export type MessagesByLocale = Record<Locale, Catalog>;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Sparse per-locale overrides applied on top of the shipped defaults.
|
|
50
|
-
* Only the keys the consumer cares to override need to be listed.
|
|
51
|
-
* Overrides are locale-keyed so a runtime locale swap picks up the right ones.
|
|
52
|
-
*/
|
|
53
|
-
export type Overrides = Partial<Record<Locale, Record<string, string>>>;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/** @type {import('../docs-types').HookDoc} */
|
|
4
|
-
export const docs = {
|
|
5
|
-
name: 'useTranslator',
|
|
6
|
-
displayName: 'useTranslator',
|
|
7
|
-
group: 'Utilities',
|
|
8
|
-
keywords: [
|
|
9
|
-
'i18n',
|
|
10
|
-
'internationalization',
|
|
11
|
-
'localization',
|
|
12
|
-
'translation',
|
|
13
|
-
'translate',
|
|
14
|
-
'locale',
|
|
15
|
-
'hook',
|
|
16
|
-
],
|
|
17
|
-
params: [],
|
|
18
|
-
returns: [
|
|
19
|
-
{
|
|
20
|
-
name: 'value',
|
|
21
|
-
type: '(key: string, values?: Record<string, string | number | Date>) => string',
|
|
22
|
-
description:
|
|
23
|
-
'A stable translator function bound to the current InternationalizationProvider context. Call it with a message key and optional ICU MessageFormat values to get the formatted string in the active locale. Safe to use in render, event handlers, effects, or any code that runs during the parent component\'s lifecycle.',
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
usage: {
|
|
27
|
-
description:
|
|
28
|
-
'Returns a translator function that resolves keys against the current locale, provider overrides, and the shipped English fallback catalog. Call inside a component; the returned function can be used anywhere within that component\'s scope.',
|
|
29
|
-
},
|
|
30
|
-
relatedComponents: ['InternationalizationProvider'],
|
|
31
|
-
importPath: '@astryxdesign/core',
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/** @type {import('../docs-types').HookTranslationDoc} */
|
|
35
|
-
export const docsDense = {
|
|
36
|
-
description:
|
|
37
|
-
'Hook returning a translator function bound to the current InternationalizationProvider context. Call with an ICU MessageFormat key and values to get the formatted string for the active locale.',
|
|
38
|
-
usage: {
|
|
39
|
-
description:
|
|
40
|
-
'Returns a translator function that resolves keys against the current locale, provider overrides, and the shipped English fallback catalog.',
|
|
41
|
-
},
|
|
42
|
-
returnDescriptions: {
|
|
43
|
-
value:
|
|
44
|
-
'translator function bound to current InternationalizationProvider context. Call with message key + optional ICU MessageFormat values; returns formatted string in active locale. Safe in render, event handlers, effects.',
|
|
45
|
-
},
|
|
46
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
'use client';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @file useTranslator.ts
|
|
7
|
-
* @input InternationalizationContext (via use())
|
|
8
|
-
* @output Exports useTranslator hook returning a stable translator function
|
|
9
|
-
* @position Client-side hook for translating outside of render (event handlers,
|
|
10
|
-
* effects, non-component code) while still resolving against the current
|
|
11
|
-
* provider's locale.
|
|
12
|
-
*
|
|
13
|
-
* Prefer `t()` for translations at the callsite during render. When you need
|
|
14
|
-
* to translate inside an event handler or effect, capture a translator during
|
|
15
|
-
* render via useTranslator() and call it later.
|
|
16
|
-
*
|
|
17
|
-
* SYNC: When modified, update these files to stay in sync:
|
|
18
|
-
* - /packages/core/src/i18n/index.ts
|
|
19
|
-
* - /packages/core/src/i18n/t.client.ts
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
import {use, useCallback} from 'react';
|
|
23
|
-
import {InternationalizationContext} from './InternationalizationContext';
|
|
24
|
-
import {resolve} from './resolve';
|
|
25
|
-
|
|
26
|
-
export type TranslatorFn = (
|
|
27
|
-
key: string,
|
|
28
|
-
values?: Record<string, unknown>,
|
|
29
|
-
) => string;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Returns a translator function bound to the current provider's locale.
|
|
33
|
-
* Safe to call from event handlers and effects.
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```
|
|
37
|
-
* function MyComponent() {
|
|
38
|
-
* const translate = useTranslator();
|
|
39
|
-
* const onClick = () => announce(translate('@astryx.pagination.pageAnnounce', {current: 1}));
|
|
40
|
-
* }
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
export function useTranslator(): TranslatorFn {
|
|
44
|
-
const ctx = use(InternationalizationContext);
|
|
45
|
-
return useCallback(
|
|
46
|
-
(key: string, values?: Record<string, unknown>) =>
|
|
47
|
-
resolve(key, values, ctx.locale, ctx.messages, ctx.overrides),
|
|
48
|
-
[ctx.locale, ctx.messages, ctx.overrides],
|
|
49
|
-
);
|
|
50
|
-
}
|