@astryxdesign/core 0.1.6 → 0.1.7-canary.04cd8f7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +68 -0
- package/README.md +25 -14
- package/dist/AlertDialog/AlertDialog.d.ts +1 -1
- package/dist/AlertDialog/AlertDialog.d.ts.map +1 -1
- package/dist/AlertDialog/AlertDialog.js +4 -1
- package/dist/AppShell/AppShell.d.ts.map +1 -1
- package/dist/AppShell/AppShell.js +3 -1
- package/dist/AvatarGroup/AvatarGroup.d.ts +1 -1
- package/dist/AvatarGroup/AvatarGroup.d.ts.map +1 -1
- package/dist/AvatarGroup/AvatarGroup.js +4 -1
- package/dist/Banner/Banner.d.ts.map +1 -1
- package/dist/Banner/Banner.js +8 -6
- package/dist/Breadcrumbs/Breadcrumbs.d.ts +1 -1
- package/dist/Breadcrumbs/Breadcrumbs.d.ts.map +1 -1
- package/dist/Breadcrumbs/Breadcrumbs.js +4 -1
- package/dist/Button/Button.d.ts +10 -2
- package/dist/Button/Button.d.ts.map +1 -1
- package/dist/Button/Button.js +49 -6
- package/dist/ButtonGroup/ButtonGroup.d.ts +20 -5
- package/dist/ButtonGroup/ButtonGroup.d.ts.map +1 -1
- package/dist/ButtonGroup/ButtonGroup.js +27 -11
- package/dist/Calendar/Calendar.d.ts.map +1 -1
- package/dist/Calendar/Calendar.js +29 -7
- package/dist/Carousel/Carousel.d.ts +1 -1
- package/dist/Carousel/Carousel.d.ts.map +1 -1
- package/dist/Carousel/Carousel.js +8 -5
- package/dist/Chat/ChatComposer.d.ts.map +1 -1
- package/dist/Chat/ChatComposer.js +4 -1
- package/dist/Chat/ChatComposerDrawer.d.ts +1 -1
- package/dist/Chat/ChatComposerDrawer.d.ts.map +1 -1
- package/dist/Chat/ChatComposerDrawer.js +9 -2
- package/dist/Chat/ChatComposerInput.d.ts.map +1 -1
- package/dist/Chat/ChatComposerInput.js +6 -2
- package/dist/Chat/ChatLayout.d.ts +1 -11
- package/dist/Chat/ChatLayout.d.ts.map +1 -1
- package/dist/Chat/ChatLayout.js +6 -4
- package/dist/Chat/ChatLayoutScrollButton.d.ts.map +1 -1
- package/dist/Chat/ChatLayoutScrollButton.js +4 -2
- package/dist/Chat/ChatMessage.d.ts +1 -1
- package/dist/Chat/ChatMessage.d.ts.map +1 -1
- package/dist/Chat/ChatMessage.js +8 -2
- package/dist/Chat/ChatMessageBubble.d.ts +1 -1
- package/dist/Chat/ChatMessageBubble.d.ts.map +1 -1
- package/dist/Chat/ChatMessageBubble.js +3 -1
- package/dist/Chat/ChatMessageList.d.ts +1 -1
- package/dist/Chat/ChatMessageList.d.ts.map +1 -1
- package/dist/Chat/ChatMessageList.js +3 -1
- package/dist/Chat/ChatMessageMetadata.d.ts.map +1 -1
- package/dist/Chat/ChatMessageMetadata.js +13 -8
- package/dist/Chat/ChatPastedTextToken.d.ts.map +1 -1
- package/dist/Chat/ChatPastedTextToken.js +3 -1
- package/dist/Chat/ChatSendButton.d.ts.map +1 -1
- package/dist/Chat/ChatSendButton.js +3 -1
- package/dist/Chat/index.d.ts +1 -1
- package/dist/Chat/index.d.ts.map +1 -1
- package/dist/Chat/useChatStreamScroll.d.ts +12 -1
- package/dist/Chat/useChatStreamScroll.d.ts.map +1 -1
- package/dist/Chat/useChatStreamScroll.js +43 -6
- package/dist/Chat/useSpeechRecognition.d.ts.map +1 -1
- package/dist/Chat/useSpeechRecognition.js +4 -2
- package/dist/Chat/useTriggerMenu.d.ts.map +1 -1
- package/dist/Chat/useTriggerMenu.js +4 -2
- package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
- package/dist/CheckboxInput/CheckboxInput.js +4 -2
- package/dist/CheckboxList/CheckboxList.d.ts +1 -1
- package/dist/CheckboxList/CheckboxList.d.ts.map +1 -1
- package/dist/CheckboxList/CheckboxList.js +3 -1
- package/dist/CheckboxList/CheckboxListItem.d.ts.map +1 -1
- package/dist/CheckboxList/CheckboxListItem.js +3 -1
- package/dist/Citation/Citation.d.ts.map +1 -1
- package/dist/Citation/Citation.js +10 -2
- package/dist/CodeBlock/CodeBlock.d.ts.map +1 -1
- package/dist/CodeBlock/CodeBlock.js +71 -53
- package/dist/Collapsible/Collapsible.d.ts +11 -1
- package/dist/Collapsible/Collapsible.d.ts.map +1 -1
- package/dist/Collapsible/Collapsible.js +36 -4
- package/dist/CommandPalette/CommandPalette.d.ts +1 -1
- package/dist/CommandPalette/CommandPalette.d.ts.map +1 -1
- package/dist/CommandPalette/CommandPalette.js +8 -3
- package/dist/CommandPalette/CommandPaletteInput.d.ts +1 -1
- package/dist/CommandPalette/CommandPaletteInput.d.ts.map +1 -1
- package/dist/CommandPalette/CommandPaletteInput.js +4 -1
- package/dist/CommandPalette/CommandPaletteList.d.ts +1 -1
- package/dist/CommandPalette/CommandPaletteList.d.ts.map +1 -1
- package/dist/CommandPalette/CommandPaletteList.js +4 -1
- package/dist/ContextMenu/ContextMenu.d.ts +1 -1
- package/dist/ContextMenu/ContextMenu.d.ts.map +1 -1
- package/dist/ContextMenu/ContextMenu.js +8 -4
- package/dist/ContextMenu/index.d.ts +3 -0
- package/dist/ContextMenu/index.d.ts.map +1 -1
- package/dist/ContextMenu/index.js +7 -1
- package/dist/DateInput/DateInput.d.ts +1 -1
- package/dist/DateInput/DateInput.d.ts.map +1 -1
- package/dist/DateInput/DateInput.js +10 -5
- package/dist/DateRangeInput/DateRangeInput.d.ts +1 -1
- package/dist/DateRangeInput/DateRangeInput.d.ts.map +1 -1
- package/dist/DateRangeInput/DateRangeInput.js +11 -6
- package/dist/DateTimeInput/DateTimeInput.d.ts +1 -1
- package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
- package/dist/DateTimeInput/DateTimeInput.js +15 -7
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +15 -12
- package/dist/Dialog/DialogHeader.d.ts +1 -1
- package/dist/Dialog/DialogHeader.d.ts.map +1 -1
- package/dist/Dialog/DialogHeader.js +7 -3
- package/dist/DropdownMenu/DropdownMenu.d.ts +1 -1
- package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenu.js +19 -9
- package/dist/DropdownMenu/DropdownMenuCheckboxItem.d.ts +89 -0
- package/dist/DropdownMenu/DropdownMenuCheckboxItem.d.ts.map +1 -0
- package/dist/DropdownMenu/DropdownMenuCheckboxItem.js +170 -0
- package/dist/DropdownMenu/DropdownMenuContext.d.ts +17 -1
- package/dist/DropdownMenu/DropdownMenuContext.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuContext.js +18 -0
- package/dist/DropdownMenu/DropdownMenuRadioGroup.d.ts +69 -0
- package/dist/DropdownMenu/DropdownMenuRadioGroup.d.ts.map +1 -0
- package/dist/DropdownMenu/DropdownMenuRadioGroup.js +70 -0
- package/dist/DropdownMenu/DropdownMenuRadioItem.d.ts +69 -0
- package/dist/DropdownMenu/DropdownMenuRadioItem.d.ts.map +1 -0
- package/dist/DropdownMenu/DropdownMenuRadioItem.js +178 -0
- package/dist/DropdownMenu/index.d.ts +5 -1
- package/dist/DropdownMenu/index.d.ts.map +1 -1
- package/dist/DropdownMenu/index.js +10 -1
- package/dist/DropdownMenu/menuItemRoles.d.ts +13 -0
- package/dist/DropdownMenu/menuItemRoles.d.ts.map +1 -0
- package/dist/DropdownMenu/menuItemRoles.js +15 -0
- package/dist/EmptyState/EmptyState.d.ts +4 -1
- package/dist/EmptyState/EmptyState.d.ts.map +1 -1
- package/dist/FileInput/FileInput.d.ts.map +1 -1
- package/dist/FileInput/FileInput.js +11 -1
- package/dist/Icon/Icon.d.ts +17 -12
- package/dist/Icon/Icon.d.ts.map +1 -1
- package/dist/Icon/Icon.js +28 -20
- package/dist/Kbd/Kbd.js +1 -1
- package/dist/Layer/useLayer.d.ts +10 -0
- package/dist/Layer/useLayer.d.ts.map +1 -1
- package/dist/Layer/useLayer.js +23 -1
- package/dist/Lightbox/Lightbox.d.ts.map +1 -1
- package/dist/Lightbox/Lightbox.js +6 -4
- package/dist/Link/Link.d.ts +5 -1
- package/dist/Link/Link.d.ts.map +1 -1
- package/dist/Link/Link.js +32 -1
- package/dist/Markdown/Markdown.d.ts.map +1 -1
- package/dist/Markdown/Markdown.js +10 -8
- package/dist/MobileNav/MobileNav.d.ts.map +1 -1
- package/dist/MobileNav/MobileNav.js +4 -2
- package/dist/MobileNav/MobileNavToggle.d.ts +1 -1
- package/dist/MobileNav/MobileNavToggle.d.ts.map +1 -1
- package/dist/MobileNav/MobileNavToggle.js +4 -1
- package/dist/MoreMenu/MoreMenu.d.ts +1 -1
- package/dist/MoreMenu/MoreMenu.d.ts.map +1 -1
- package/dist/MoreMenu/MoreMenu.js +4 -1
- package/dist/MultiSelector/MultiSelector.d.ts +1 -1
- package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
- package/dist/MultiSelector/MultiSelector.js +13 -6
- package/dist/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/NumberInput/NumberInput.js +5 -1
- package/dist/Outline/Outline.d.ts +1 -1
- package/dist/Outline/Outline.d.ts.map +1 -1
- package/dist/Outline/Outline.js +4 -1
- package/dist/Pagination/Pagination.d.ts +1 -1
- package/dist/Pagination/Pagination.d.ts.map +1 -1
- package/dist/Pagination/Pagination.js +38 -11
- package/dist/Popover/usePopover.d.ts.map +1 -1
- package/dist/Popover/usePopover.js +4 -1
- package/dist/PowerSearch/PowerSearch.d.ts +1 -1
- package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearch.js +22 -12
- package/dist/PowerSearch/PowerSearchEditPopover.d.ts +1 -1
- package/dist/PowerSearch/PowerSearchEditPopover.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchEditPopover.js +26 -20
- package/dist/PowerSearch/PowerSearchToken.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchToken.js +7 -3
- package/dist/PowerSearch/PowerSearchValueEditor.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchValueEditor.js +34 -21
- package/dist/PowerSearch/formatFilterValue.d.ts +2 -1
- package/dist/PowerSearch/formatFilterValue.d.ts.map +1 -1
- package/dist/PowerSearch/formatFilterValue.js +19 -9
- package/dist/PowerSearch/index.d.ts +2 -1
- package/dist/PowerSearch/index.d.ts.map +1 -1
- package/dist/PowerSearch/index.js +1 -0
- package/dist/PowerSearch/resolveOperatorLabel.d.ts +23 -0
- package/dist/PowerSearch/resolveOperatorLabel.d.ts.map +1 -0
- package/dist/PowerSearch/resolveOperatorLabel.js +28 -0
- package/dist/PowerSearch/types.d.ts +28 -2
- 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 +15 -8
- package/dist/Resizable/ResizeHandle.d.ts +1 -1
- package/dist/Resizable/ResizeHandle.d.ts.map +1 -1
- package/dist/Resizable/ResizeHandle.js +4 -1
- package/dist/Selector/Selector.d.ts.map +1 -1
- package/dist/Selector/Selector.js +52 -14
- package/dist/SideNav/SideNav.d.ts.map +1 -1
- package/dist/SideNav/SideNav.js +4 -2
- package/dist/SideNav/SideNavCollapseButton.d.ts.map +1 -1
- package/dist/SideNav/SideNavCollapseButton.js +3 -1
- package/dist/SideNav/SideNavHeading.d.ts.map +1 -1
- package/dist/SideNav/SideNavHeading.js +5 -3
- package/dist/SideNav/SideNavItem.d.ts.map +1 -1
- package/dist/SideNav/SideNavItem.js +7 -1
- package/dist/Switch/Switch.d.ts.map +1 -1
- package/dist/Switch/Switch.js +4 -2
- package/dist/TabList/Tab.d.ts.map +1 -1
- package/dist/TabList/Tab.js +2 -2
- package/dist/TabList/TabList.d.ts +1 -1
- package/dist/TabList/TabList.d.ts.map +1 -1
- package/dist/TabList/TabList.js +6 -1
- package/dist/TabList/TabMenu.d.ts.map +1 -1
- package/dist/TabList/TabMenu.js +1 -1
- package/dist/Table/BaseTable.d.ts.map +1 -1
- package/dist/Table/BaseTable.js +29 -16
- package/dist/Table/Table.d.ts.map +1 -1
- package/dist/Table/Table.js +5 -3
- package/dist/Table/index.d.ts +2 -0
- package/dist/Table/index.d.ts.map +1 -1
- package/dist/Table/index.js +1 -0
- 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 +56 -19
- package/dist/Table/plugins/groupedRows/useTableGroupedRows.d.ts +1 -1
- package/dist/Table/plugins/groupedRows/useTableGroupedRows.d.ts.map +1 -1
- package/dist/Table/plugins/groupedRows/useTableGroupedRows.js +12 -5
- package/dist/Table/plugins/pagination/useTablePagination.d.ts.map +1 -1
- package/dist/Table/plugins/pagination/useTablePagination.js +6 -3
- package/dist/Table/plugins/rowExpansion/useTableRowExpansion.d.ts.map +1 -1
- package/dist/Table/plugins/rowExpansion/useTableRowExpansion.js +8 -6
- package/dist/Table/plugins/rowIndex/useTableRowIndex.d.ts +1 -1
- package/dist/Table/plugins/rowIndex/useTableRowIndex.js +1 -1
- package/dist/Table/plugins/selection/useTableSelection.d.ts.map +1 -1
- package/dist/Table/plugins/selection/useTableSelection.js +5 -2
- package/dist/Table/plugins/sortable/useTableSortable.d.ts.map +1 -1
- package/dist/Table/plugins/sortable/useTableSortable.js +6 -4
- package/dist/Table/plugins/stickyColumns/useTableStickyColumns.js +2 -2
- package/dist/Table/plugins/tree/index.d.ts +5 -0
- package/dist/Table/plugins/tree/index.d.ts.map +1 -0
- package/dist/Table/plugins/tree/index.js +4 -0
- package/dist/Table/plugins/tree/useTableTreeData.d.ts +38 -0
- package/dist/Table/plugins/tree/useTableTreeData.d.ts.map +1 -0
- package/dist/Table/plugins/tree/useTableTreeData.js +358 -0
- package/dist/Table/plugins/tree/useTableTreeState.d.ts +51 -0
- package/dist/Table/plugins/tree/useTableTreeState.d.ts.map +1 -0
- package/dist/Table/plugins/tree/useTableTreeState.js +175 -0
- package/dist/Table/types.d.ts +17 -10
- package/dist/Table/types.d.ts.map +1 -1
- package/dist/Table/useBaseTablePlugins.d.ts.map +1 -1
- package/dist/Table/useBaseTablePlugins.js +6 -3
- package/dist/TextInput/TextInput.d.ts.map +1 -1
- package/dist/TextInput/TextInput.js +5 -1
- package/dist/Thumbnail/Thumbnail.d.ts.map +1 -1
- package/dist/Thumbnail/Thumbnail.js +8 -2
- package/dist/TimeInput/TimeInput.d.ts +1 -1
- package/dist/TimeInput/TimeInput.d.ts.map +1 -1
- package/dist/TimeInput/TimeInput.js +7 -2
- package/dist/Timestamp/Timestamp.d.ts.map +1 -1
- package/dist/Timestamp/Timestamp.js +18 -3
- package/dist/Toast/Toast.d.ts.map +1 -1
- package/dist/Toast/Toast.js +3 -1
- package/dist/Toast/ToastViewport.d.ts.map +1 -1
- package/dist/Toast/ToastViewport.js +3 -1
- package/dist/Token/Token.d.ts.map +1 -1
- package/dist/Token/Token.js +8 -2
- package/dist/Tokenizer/Tokenizer.d.ts.map +1 -1
- package/dist/Tokenizer/Tokenizer.js +3 -1
- package/dist/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/Toolbar/Toolbar.js +8 -1
- package/dist/TopNav/TopNav.d.ts +2 -1
- package/dist/TopNav/TopNav.d.ts.map +1 -1
- package/dist/TopNav/TopNav.js +4 -1
- package/dist/TopNav/TopNavHeading.d.ts.map +1 -1
- package/dist/TopNav/TopNavHeading.js +5 -3
- package/dist/TreeList/TreeList.d.ts.map +1 -1
- package/dist/TreeList/TreeList.js +5 -1
- package/dist/TreeList/TreeListItem.d.ts.map +1 -1
- package/dist/TreeList/TreeListItem.js +7 -1
- package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
- package/dist/Typeahead/BaseTypeahead.js +8 -4
- package/dist/Typeahead/Typeahead.d.ts.map +1 -1
- package/dist/Typeahead/Typeahead.js +3 -1
- package/dist/VisuallyHidden/VisuallyHidden.d.ts +1 -0
- package/dist/VisuallyHidden/VisuallyHidden.d.ts.map +1 -1
- package/dist/VisuallyHidden/VisuallyHidden.js +1 -0
- package/dist/astryx.css +38 -4
- package/dist/astryx.umd.js +62 -60
- package/dist/astryx.umd.js.map +4 -4
- package/dist/authoring/doc.d.ts +145 -0
- package/dist/authoring/doc.d.ts.map +1 -0
- package/dist/authoring/doc.js +100 -0
- package/dist/authoring/index.d.ts +29 -0
- package/dist/authoring/index.d.ts.map +1 -0
- package/dist/authoring/index.js +28 -0
- package/dist/authoring/integration.d.ts +35 -0
- package/dist/authoring/integration.d.ts.map +1 -0
- package/dist/authoring/integration.js +30 -0
- package/dist/authoring/template.d.ts +66 -0
- package/dist/authoring/template.d.ts.map +1 -0
- package/dist/authoring/template.js +55 -0
- package/dist/config.d.ts +80 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +40 -0
- package/dist/docs-types.d.ts +13 -4
- package/dist/docs-types.d.ts.map +1 -1
- package/dist/i18n/InternationalizationContext.d.ts +12 -0
- package/dist/i18n/InternationalizationContext.d.ts.map +1 -0
- package/dist/i18n/InternationalizationContext.js +29 -0
- package/dist/i18n/InternationalizationProvider.d.ts +61 -0
- package/dist/i18n/InternationalizationProvider.d.ts.map +1 -0
- package/dist/i18n/InternationalizationProvider.js +44 -0
- package/dist/i18n/index.d.ts +24 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +21 -0
- package/dist/i18n/resolve.d.ts +22 -0
- package/dist/i18n/resolve.d.ts.map +1 -0
- package/dist/i18n/resolve.js +141 -0
- package/dist/i18n/translator.d.ts +25 -0
- package/dist/i18n/translator.d.ts.map +1 -0
- package/dist/i18n/translator.js +1 -0
- package/dist/i18n/types.d.ts +47 -0
- package/dist/i18n/types.d.ts.map +1 -0
- package/dist/i18n/types.js +1 -0
- package/dist/i18n/useTranslator.d.ts +15 -0
- package/dist/i18n/useTranslator.d.ts.map +1 -0
- package/dist/i18n/useTranslator.js +39 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/theme/Theme.js +1 -1
- package/dist/theme/defineTheme.d.ts +1 -1
- package/dist/theme/defineTheme.js +1 -1
- package/dist/theme/hct.d.ts +0 -1
- package/dist/theme/hct.d.ts.map +1 -1
- package/dist/theme/hct.js +0 -3
- package/dist/utils/color.d.ts +13 -1
- package/dist/utils/color.d.ts.map +1 -1
- package/dist/utils/color.js +23 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -1
- package/locales/en.json +754 -0
- package/locales/pseudo.json +566 -0
- package/package.json +23 -2
- package/src/AlertDialog/AlertDialog.doc.mjs +5 -0
- package/src/AlertDialog/AlertDialog.tsx +4 -1
- package/src/AppShell/AppShell.doc.mjs +8 -2
- package/src/AppShell/AppShell.tsx +3 -1
- package/src/AvatarGroup/AvatarGroup.tsx +4 -1
- package/src/Banner/Banner.tsx +10 -5
- package/src/Breadcrumbs/Breadcrumbs.tsx +4 -1
- package/src/Button/Button.doc.mjs +8 -0
- package/src/Button/Button.test.tsx +27 -0
- package/src/Button/Button.tsx +51 -5
- package/src/ButtonGroup/ButtonGroup.test.tsx +386 -2
- package/src/ButtonGroup/ButtonGroup.tsx +27 -11
- package/src/Calendar/Calendar.test.tsx +103 -2
- package/src/Calendar/Calendar.tsx +29 -6
- package/src/Card/Card.doc.mjs +3 -3
- package/src/Carousel/Carousel.tsx +10 -7
- package/src/Chat/ChatComposer.tsx +5 -1
- package/src/Chat/ChatComposerDrawer.tsx +9 -2
- package/src/Chat/ChatComposerInput.tsx +10 -4
- package/src/Chat/ChatLayout.test.tsx +127 -2
- package/src/Chat/ChatLayout.tsx +5 -12
- package/src/Chat/ChatLayoutScrollButton.tsx +4 -2
- package/src/Chat/ChatMessage.tsx +5 -1
- package/src/Chat/ChatMessageBubble.tsx +2 -0
- package/src/Chat/ChatMessageList.doc.mjs +1 -1
- package/src/Chat/ChatMessageList.tsx +2 -0
- package/src/Chat/ChatMessageMetadata.tsx +15 -9
- package/src/Chat/ChatPastedTextToken.tsx +3 -1
- package/src/Chat/ChatSendButton.tsx +3 -1
- package/src/Chat/ChatToolCalls.doc.mjs +1 -1
- package/src/Chat/index.ts +1 -0
- package/src/Chat/useChatStreamScroll.test.tsx +168 -0
- package/src/Chat/useChatStreamScroll.ts +67 -11
- package/src/Chat/useSpeechRecognition.ts +11 -2
- package/src/Chat/useTriggerMenu.tsx +4 -2
- package/src/CheckboxInput/CheckboxInput.doc.mjs +1 -1
- package/src/CheckboxInput/CheckboxInput.test.tsx +16 -0
- package/src/CheckboxInput/CheckboxInput.tsx +4 -2
- package/src/CheckboxList/CheckboxList.doc.mjs +6 -1
- package/src/CheckboxList/CheckboxList.tsx +2 -0
- package/src/CheckboxList/CheckboxListItem.tsx +7 -1
- package/src/Citation/Citation.tsx +4 -2
- package/src/ClickableCard/ClickableCard.doc.mjs +1 -1
- package/src/CodeBlock/CodeBlock.tsx +91 -40
- package/src/Collapsible/Collapsible.doc.mjs +7 -0
- package/src/Collapsible/Collapsible.test.tsx +80 -0
- package/src/Collapsible/Collapsible.tsx +58 -5
- package/src/CommandPalette/CommandPalette.tsx +10 -3
- package/src/CommandPalette/CommandPaletteInput.test.tsx +1 -1
- package/src/CommandPalette/CommandPaletteInput.tsx +5 -1
- package/src/CommandPalette/CommandPaletteList.tsx +4 -1
- package/src/ContextMenu/ContextMenu.test.tsx +75 -1
- package/src/ContextMenu/ContextMenu.tsx +14 -6
- package/src/ContextMenu/index.ts +15 -0
- package/src/DateInput/DateInput.doc.mjs +2 -2
- package/src/DateInput/DateInput.test.tsx +17 -5
- package/src/DateInput/DateInput.tsx +13 -5
- package/src/DateRangeInput/DateRangeInput.doc.mjs +1 -1
- package/src/DateRangeInput/DateRangeInput.tsx +14 -6
- package/src/DateTimeInput/DateTimeInput.doc.mjs +2 -2
- package/src/DateTimeInput/DateTimeInput.tsx +17 -7
- package/src/Dialog/Dialog.tsx +11 -15
- package/src/Dialog/DialogHeader.tsx +7 -3
- package/src/DropdownMenu/DropdownMenu.doc.mjs +23 -0
- package/src/DropdownMenu/DropdownMenu.tsx +23 -14
- package/src/DropdownMenu/DropdownMenuCheckboxItem.doc.mjs +95 -0
- package/src/DropdownMenu/DropdownMenuCheckboxItem.tsx +237 -0
- package/src/DropdownMenu/DropdownMenuContext.tsx +29 -1
- package/src/DropdownMenu/DropdownMenuItem.doc.mjs +7 -1
- package/src/DropdownMenu/DropdownMenuRadioGroup.doc.mjs +80 -0
- package/src/DropdownMenu/DropdownMenuRadioGroup.tsx +119 -0
- package/src/DropdownMenu/DropdownMenuRadioItem.doc.mjs +80 -0
- package/src/DropdownMenu/DropdownMenuRadioItem.tsx +232 -0
- package/src/DropdownMenu/DropdownMenuSelectable.test.tsx +163 -0
- package/src/DropdownMenu/index.ts +23 -3
- package/src/DropdownMenu/menuItemRoles.ts +22 -0
- package/src/EmptyState/EmptyState.doc.mjs +3 -3
- package/src/EmptyState/EmptyState.tsx +4 -1
- package/src/Field/Field.doc.mjs +3 -3
- package/src/Field/FieldLabel.doc.mjs +1 -1
- package/src/FileInput/FileInput.test.tsx +40 -1
- package/src/FileInput/FileInput.tsx +12 -1
- package/src/Grid/Grid.doc.mjs +5 -5
- package/src/Icon/Icon.test.tsx +46 -0
- package/src/Icon/Icon.tsx +37 -24
- package/src/InputGroup/InputGroup.doc.mjs +1 -1
- package/src/Kbd/Kbd.test.tsx +26 -0
- package/src/Kbd/Kbd.tsx +1 -1
- package/src/Layer/useLayer.doc.mjs +8 -5
- package/src/Layer/useLayer.test.tsx +136 -1
- package/src/Layer/useLayer.tsx +34 -2
- package/src/Lightbox/Lightbox.doc.mjs +7 -2
- package/src/Lightbox/Lightbox.tsx +6 -4
- package/src/Link/Link.test.tsx +74 -2
- package/src/Link/Link.tsx +48 -1
- package/src/Markdown/Markdown.tsx +12 -4
- package/src/MobileNav/MobileNav.tsx +4 -2
- package/src/MobileNav/MobileNavToggle.tsx +5 -3
- package/src/MoreMenu/MoreMenu.tsx +4 -1
- package/src/MultiSelector/MultiSelector.tsx +14 -5
- package/src/NumberInput/NumberInput.doc.mjs +2 -2
- package/src/NumberInput/NumberInput.tsx +3 -1
- package/src/Outline/Outline.tsx +4 -1
- package/src/OverflowList/OverflowList.doc.mjs +2 -2
- package/src/Pagination/Pagination.tsx +35 -12
- package/src/Popover/usePopover.tsx +6 -1
- package/src/PowerSearch/PowerSearch.doc.mjs +9 -4
- package/src/PowerSearch/PowerSearch.tsx +22 -10
- package/src/PowerSearch/PowerSearchEditPopover.tsx +27 -20
- package/src/PowerSearch/PowerSearchToken.tsx +17 -6
- package/src/PowerSearch/PowerSearchValueEditor.tsx +34 -21
- package/src/PowerSearch/formatFilterValue.test.ts +282 -0
- package/src/PowerSearch/formatFilterValue.ts +21 -8
- package/src/PowerSearch/index.ts +5 -0
- package/src/PowerSearch/resolveOperatorLabel.ts +34 -0
- package/src/PowerSearch/types.ts +33 -9
- package/src/PowerSearch/usePowerSearchConfig.ts +59 -27
- package/src/PowerSearch/usePowerSearchSource.ts +17 -8
- package/src/RadioList/RadioList.doc.mjs +1 -1
- package/src/Resizable/ResizeHandle.tsx +4 -1
- package/src/Section/Section.doc.mjs +4 -4
- package/src/SelectableCard/SelectableCard.doc.mjs +1 -1
- package/src/Selector/Selector.doc.mjs +6 -3
- package/src/Selector/Selector.test.tsx +114 -6
- package/src/Selector/Selector.tsx +68 -17
- package/src/Selector/SelectorOption.doc.mjs +1 -1
- package/src/SideNav/SideNav.tsx +4 -2
- package/src/SideNav/SideNavCollapseButton.tsx +3 -1
- package/src/SideNav/SideNavHeading.tsx +5 -3
- package/src/SideNav/SideNavItem.doc.mjs +2 -2
- package/src/SideNav/SideNavItem.tsx +3 -1
- package/src/Slider/Slider.doc.mjs +2 -2
- package/src/Stack/Stack.doc.mjs +10 -10
- package/src/Switch/Switch.doc.mjs +3 -3
- package/src/Switch/Switch.test.tsx +16 -0
- package/src/Switch/Switch.tsx +4 -2
- package/src/TabList/Tab.tsx +5 -1
- package/src/TabList/TabList.doc.mjs +3 -3
- package/src/TabList/TabList.test.tsx +66 -0
- package/src/TabList/TabList.tsx +12 -1
- package/src/TabList/TabMenu.tsx +4 -1
- package/src/Table/BaseTable.tsx +36 -19
- package/src/Table/Table.doc.mjs +2 -0
- package/src/Table/Table.test.tsx +132 -1
- package/src/Table/Table.tsx +6 -4
- package/src/Table/index.ts +7 -0
- package/src/Table/plugins/columnResize/useTableColumnResize.tsx +1 -1
- package/src/Table/plugins/filtering/useTableFiltering.tsx +31 -30
- package/src/Table/plugins/groupedRows/useTableGroupedRows.tsx +7 -5
- package/src/Table/plugins/pagination/useTablePagination.tsx +4 -1
- package/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx +9 -8
- package/src/Table/plugins/rowIndex/useTableRowIndex.tsx +1 -1
- package/src/Table/plugins/selection/useTableSelection.tsx +6 -7
- package/src/Table/plugins/sortable/useTableSortable.tsx +8 -5
- package/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx +4 -4
- package/src/Table/plugins/tree/index.ts +12 -0
- package/src/Table/plugins/tree/useTableTreeData-perf.test.tsx +163 -0
- package/src/Table/plugins/tree/useTableTreeData.test.tsx +594 -0
- package/src/Table/plugins/tree/useTableTreeData.tsx +495 -0
- package/src/Table/plugins/tree/useTableTreeState.test.tsx +636 -0
- package/src/Table/plugins/tree/useTableTreeState.tsx +253 -0
- package/src/Table/types.ts +18 -12
- package/src/Table/useBaseTablePlugins.ts +6 -2
- package/src/Table/useTableFiltering.doc.mjs +2 -2
- package/src/Table/useTableGroupedRows.doc.mjs +3 -3
- package/src/Table/useTableSortable.doc.mjs +11 -11
- package/src/Table/useTableTreeData.doc.mjs +75 -0
- package/src/Table/useTableTreeState.doc.mjs +98 -0
- package/src/Text/Text.doc.mjs +2 -2
- package/src/TextArea/TextArea.doc.mjs +1 -1
- package/src/TextInput/TextInput.doc.mjs +1 -1
- package/src/TextInput/TextInput.tsx +3 -1
- package/src/Thumbnail/Thumbnail.tsx +4 -2
- package/src/TimeInput/TimeInput.doc.mjs +2 -2
- package/src/TimeInput/TimeInput.tsx +6 -2
- package/src/Timestamp/Timestamp.doc.mjs +4 -4
- package/src/Timestamp/Timestamp.test.tsx +120 -7
- package/src/Timestamp/Timestamp.tsx +21 -1
- package/src/Toast/Toast.tsx +3 -1
- package/src/Toast/ToastViewport.tsx +3 -1
- package/src/Token/Token.tsx +4 -2
- 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/Toolbar/Toolbar.tsx +10 -3
- package/src/TopNav/TopNav.doc.mjs +1 -0
- package/src/TopNav/TopNav.test.tsx +30 -0
- package/src/TopNav/TopNav.tsx +6 -4
- package/src/TopNav/TopNavHeading.tsx +5 -3
- package/src/TreeList/TreeList.tsx +5 -1
- package/src/TreeList/TreeListItem.tsx +6 -1
- package/src/Typeahead/BaseTypeahead.tsx +11 -4
- package/src/Typeahead/Typeahead.doc.mjs +1 -1
- package/src/Typeahead/Typeahead.tsx +3 -1
- package/src/VisuallyHidden/VisuallyHidden.tsx +1 -0
- package/src/authoring/doc.ts +166 -0
- package/src/authoring/index.test.ts +52 -0
- package/src/authoring/index.ts +50 -0
- package/src/authoring/integration.ts +42 -0
- package/src/authoring/template.ts +74 -0
- package/src/config.test.ts +16 -0
- package/src/config.ts +92 -0
- package/src/docPropLiterals.test.ts +938 -0
- package/src/docs-types.ts +15 -10
- package/src/i18n/InternationalizationContext.ts +39 -0
- package/src/i18n/InternationalizationProvider.doc.mjs +72 -0
- package/src/i18n/InternationalizationProvider.tsx +82 -0
- package/src/i18n/__tests__/e2e-pagination.test.tsx +172 -0
- package/src/i18n/__tests__/e2e-powersearch.test.tsx +130 -0
- package/src/i18n/__tests__/resolve.test.ts +284 -0
- package/src/i18n/index.ts +32 -0
- package/src/i18n/resolve.ts +165 -0
- package/src/i18n/translator.ts +31 -0
- package/src/i18n/types.ts +53 -0
- package/src/i18n/useTranslator.doc.mjs +46 -0
- package/src/i18n/useTranslator.ts +50 -0
- package/src/index.ts +3 -0
- package/src/theme/Theme.doc.mjs +4 -4
- package/src/theme/Theme.tsx +1 -1
- package/src/theme/defineTheme.ts +1 -1
- package/src/theme/hct.ts +0 -4
- package/src/utils/color.test.ts +101 -1
- package/src/utils/color.ts +23 -1
- package/src/utils/index.ts +8 -1
- package/dist/NavItem/index.d.ts +0 -9
- package/dist/NavItem/index.d.ts.map +0 -1
- package/dist/NavItem/index.js +0 -10
- package/src/NavItem/index.ts +0 -11
|
@@ -0,0 +1,636 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file useTableTreeState.test.tsx
|
|
5
|
+
* @input Uses vitest, @testing-library/react
|
|
6
|
+
* @output Unit tests for useTableTreeState hook
|
|
7
|
+
* @position Testing; validates tree expansion state + nested-data flattening
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import {describe, it, expect, vi} from 'vitest';
|
|
11
|
+
import {act, renderHook} from '@testing-library/react';
|
|
12
|
+
import {useTableTreeState} from './useTableTreeState';
|
|
13
|
+
|
|
14
|
+
// =============================================================================
|
|
15
|
+
// Test Data
|
|
16
|
+
// =============================================================================
|
|
17
|
+
|
|
18
|
+
interface FileRow extends Record<string, unknown> {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
size: number;
|
|
22
|
+
children?: FileRow[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* src/
|
|
27
|
+
* components/
|
|
28
|
+
* Button.tsx
|
|
29
|
+
* Input.tsx
|
|
30
|
+
* utils.ts
|
|
31
|
+
* README.md
|
|
32
|
+
*/
|
|
33
|
+
const fileTree: FileRow[] = [
|
|
34
|
+
{
|
|
35
|
+
id: 'src',
|
|
36
|
+
name: 'src',
|
|
37
|
+
size: 0,
|
|
38
|
+
children: [
|
|
39
|
+
{
|
|
40
|
+
id: 'components',
|
|
41
|
+
name: 'components',
|
|
42
|
+
size: 0,
|
|
43
|
+
children: [
|
|
44
|
+
{id: 'button', name: 'Button.tsx', size: 120},
|
|
45
|
+
{id: 'input', name: 'Input.tsx', size: 80},
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
{id: 'utils', name: 'utils.ts', size: 40},
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
{id: 'readme', name: 'README.md', size: 10},
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
const ids = (rows: FileRow[]) => rows.map(r => r.id);
|
|
55
|
+
|
|
56
|
+
// =============================================================================
|
|
57
|
+
// Flattening
|
|
58
|
+
// =============================================================================
|
|
59
|
+
|
|
60
|
+
describe('useTableTreeState — flattening', () => {
|
|
61
|
+
it('emits only root rows when nothing is expanded', () => {
|
|
62
|
+
const {result} = renderHook(() =>
|
|
63
|
+
useTableTreeState({data: fileTree, idKey: 'id'}),
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
expect(ids(result.current.visibleData)).toEqual(['src', 'readme']);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('reveals children of defaultExpandedIds in depth-first order', () => {
|
|
70
|
+
const {result} = renderHook(() =>
|
|
71
|
+
useTableTreeState({
|
|
72
|
+
data: fileTree,
|
|
73
|
+
idKey: 'id',
|
|
74
|
+
defaultExpandedIds: ['src', 'components'],
|
|
75
|
+
}),
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
expect(ids(result.current.visibleData)).toEqual([
|
|
79
|
+
'src',
|
|
80
|
+
'components',
|
|
81
|
+
'button',
|
|
82
|
+
'input',
|
|
83
|
+
'utils',
|
|
84
|
+
'readme',
|
|
85
|
+
]);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('keeps a collapsed subtree unmounted even when its descendants are in the expanded set', () => {
|
|
89
|
+
// 'components' is expanded but its parent 'src' is not — nothing below
|
|
90
|
+
// 'src' is visible.
|
|
91
|
+
const {result} = renderHook(() =>
|
|
92
|
+
useTableTreeState({
|
|
93
|
+
data: fileTree,
|
|
94
|
+
idKey: 'id',
|
|
95
|
+
defaultExpandedIds: ['components'],
|
|
96
|
+
}),
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
expect(ids(result.current.visibleData)).toEqual(['src', 'readme']);
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// =============================================================================
|
|
104
|
+
// Toggling (uncontrolled)
|
|
105
|
+
// =============================================================================
|
|
106
|
+
|
|
107
|
+
describe('useTableTreeState — uncontrolled toggling', () => {
|
|
108
|
+
it('expands a row via treeConfig.onToggleItem', () => {
|
|
109
|
+
const {result} = renderHook(() =>
|
|
110
|
+
useTableTreeState({data: fileTree, idKey: 'id'}),
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
act(() => {
|
|
114
|
+
result.current.treeConfig.onToggleItem(fileTree[0]);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
expect(ids(result.current.visibleData)).toEqual([
|
|
118
|
+
'src',
|
|
119
|
+
'components',
|
|
120
|
+
'utils',
|
|
121
|
+
'readme',
|
|
122
|
+
]);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it('collapses an expanded row via treeConfig.onToggleItem', () => {
|
|
126
|
+
const {result} = renderHook(() =>
|
|
127
|
+
useTableTreeState({
|
|
128
|
+
data: fileTree,
|
|
129
|
+
idKey: 'id',
|
|
130
|
+
defaultExpandedIds: ['src'],
|
|
131
|
+
}),
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
act(() => {
|
|
135
|
+
result.current.treeConfig.onToggleItem(fileTree[0]);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
expect(ids(result.current.visibleData)).toEqual(['src', 'readme']);
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// =============================================================================
|
|
143
|
+
// Controlled mode
|
|
144
|
+
// =============================================================================
|
|
145
|
+
|
|
146
|
+
describe('useTableTreeState — controlled mode', () => {
|
|
147
|
+
it('derives visibility from the controlled expandedIds set', () => {
|
|
148
|
+
const {result, rerender} = renderHook(
|
|
149
|
+
({expanded}: {expanded: ReadonlySet<string>}) =>
|
|
150
|
+
useTableTreeState({
|
|
151
|
+
data: fileTree,
|
|
152
|
+
idKey: 'id',
|
|
153
|
+
expandedIds: expanded,
|
|
154
|
+
onExpandedIdsChange: () => {},
|
|
155
|
+
}),
|
|
156
|
+
{initialProps: {expanded: new Set<string>()}},
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
expect(ids(result.current.visibleData)).toEqual(['src', 'readme']);
|
|
160
|
+
|
|
161
|
+
rerender({expanded: new Set(['src'])});
|
|
162
|
+
expect(ids(result.current.visibleData)).toEqual([
|
|
163
|
+
'src',
|
|
164
|
+
'components',
|
|
165
|
+
'utils',
|
|
166
|
+
'readme',
|
|
167
|
+
]);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('reports toggles through onExpandedIdsChange without mutating its own state', () => {
|
|
171
|
+
const onExpandedIdsChange = vi.fn();
|
|
172
|
+
const {result} = renderHook(() =>
|
|
173
|
+
useTableTreeState({
|
|
174
|
+
data: fileTree,
|
|
175
|
+
idKey: 'id',
|
|
176
|
+
expandedIds: new Set<string>(),
|
|
177
|
+
onExpandedIdsChange,
|
|
178
|
+
}),
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
act(() => {
|
|
182
|
+
result.current.treeConfig.onToggleItem(fileTree[0]);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
expect(onExpandedIdsChange).toHaveBeenCalledWith(new Set(['src']));
|
|
186
|
+
// Controlled: the visible rows only change when the owner passes a new set.
|
|
187
|
+
expect(ids(result.current.visibleData)).toEqual(['src', 'readme']);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it('fires onExpandedIdsChange in uncontrolled mode too', () => {
|
|
191
|
+
const onExpandedIdsChange = vi.fn();
|
|
192
|
+
const {result} = renderHook(() =>
|
|
193
|
+
useTableTreeState({
|
|
194
|
+
data: fileTree,
|
|
195
|
+
idKey: 'id',
|
|
196
|
+
onExpandedIdsChange,
|
|
197
|
+
}),
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
act(() => {
|
|
201
|
+
result.current.treeConfig.onToggleItem(fileTree[0]);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
expect(onExpandedIdsChange).toHaveBeenCalledWith(new Set(['src']));
|
|
205
|
+
expect(ids(result.current.visibleData)).toEqual([
|
|
206
|
+
'src',
|
|
207
|
+
'components',
|
|
208
|
+
'utils',
|
|
209
|
+
'readme',
|
|
210
|
+
]);
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
// =============================================================================
|
|
215
|
+
// expandAll / collapseAll
|
|
216
|
+
// =============================================================================
|
|
217
|
+
|
|
218
|
+
describe('useTableTreeState — expandAll / collapseAll', () => {
|
|
219
|
+
it('expandAll reveals every level of the tree', () => {
|
|
220
|
+
const {result} = renderHook(() =>
|
|
221
|
+
useTableTreeState({data: fileTree, idKey: 'id'}),
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
act(() => {
|
|
225
|
+
result.current.expandAll();
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
expect(ids(result.current.visibleData)).toEqual([
|
|
229
|
+
'src',
|
|
230
|
+
'components',
|
|
231
|
+
'button',
|
|
232
|
+
'input',
|
|
233
|
+
'utils',
|
|
234
|
+
'readme',
|
|
235
|
+
]);
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
it('collapseAll returns to roots only', () => {
|
|
239
|
+
const {result} = renderHook(() =>
|
|
240
|
+
useTableTreeState({
|
|
241
|
+
data: fileTree,
|
|
242
|
+
idKey: 'id',
|
|
243
|
+
defaultExpandedIds: ['src', 'components'],
|
|
244
|
+
}),
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
act(() => {
|
|
248
|
+
result.current.collapseAll();
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
expect(ids(result.current.visibleData)).toEqual(['src', 'readme']);
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
it('exposes the current expandedIds set', () => {
|
|
255
|
+
const {result} = renderHook(() =>
|
|
256
|
+
useTableTreeState({
|
|
257
|
+
data: fileTree,
|
|
258
|
+
idKey: 'id',
|
|
259
|
+
defaultExpandedIds: ['src'],
|
|
260
|
+
}),
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
expect(result.current.expandedIds).toEqual(new Set(['src']));
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
// =============================================================================
|
|
268
|
+
// Row meta
|
|
269
|
+
// =============================================================================
|
|
270
|
+
|
|
271
|
+
describe('useTableTreeState — row meta', () => {
|
|
272
|
+
it('reports 0-based level, hasChildren, and isExpanded per row', () => {
|
|
273
|
+
const {result} = renderHook(() =>
|
|
274
|
+
useTableTreeState({
|
|
275
|
+
data: fileTree,
|
|
276
|
+
idKey: 'id',
|
|
277
|
+
defaultExpandedIds: ['src', 'components'],
|
|
278
|
+
}),
|
|
279
|
+
);
|
|
280
|
+
|
|
281
|
+
const meta = (id: string) => {
|
|
282
|
+
const item = result.current.visibleData.find(r => r.id === id);
|
|
283
|
+
if (!item) {
|
|
284
|
+
throw new Error(`row ${id} not visible`);
|
|
285
|
+
}
|
|
286
|
+
return result.current.treeConfig.getRowMeta(item);
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
expect(meta('src')).toEqual({
|
|
290
|
+
id: 'src',
|
|
291
|
+
level: 0,
|
|
292
|
+
hasChildren: true,
|
|
293
|
+
isExpanded: true,
|
|
294
|
+
});
|
|
295
|
+
expect(meta('components')).toEqual({
|
|
296
|
+
id: 'components',
|
|
297
|
+
level: 1,
|
|
298
|
+
hasChildren: true,
|
|
299
|
+
isExpanded: true,
|
|
300
|
+
});
|
|
301
|
+
expect(meta('button')).toEqual({
|
|
302
|
+
id: 'button',
|
|
303
|
+
level: 2,
|
|
304
|
+
hasChildren: false,
|
|
305
|
+
isExpanded: false,
|
|
306
|
+
});
|
|
307
|
+
expect(meta('readme')).toEqual({
|
|
308
|
+
id: 'readme',
|
|
309
|
+
level: 0,
|
|
310
|
+
hasChildren: false,
|
|
311
|
+
isExpanded: false,
|
|
312
|
+
});
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
it('treats an empty children array as a leaf', () => {
|
|
316
|
+
const data: FileRow[] = [
|
|
317
|
+
{id: 'a', name: 'a', size: 0, children: []},
|
|
318
|
+
{id: 'b', name: 'b', size: 0, children: [{id: 'c', name: 'c', size: 0}]},
|
|
319
|
+
];
|
|
320
|
+
const {result} = renderHook(() => useTableTreeState({data, idKey: 'id'}));
|
|
321
|
+
|
|
322
|
+
expect(result.current.treeConfig.getRowMeta(data[0])?.hasChildren).toBe(
|
|
323
|
+
false,
|
|
324
|
+
);
|
|
325
|
+
expect(result.current.treeConfig.getRowMeta(data[1])?.hasChildren).toBe(
|
|
326
|
+
true,
|
|
327
|
+
);
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
it('flags hasExpandableRows=false for flat data (migration no-op)', () => {
|
|
331
|
+
const flat: FileRow[] = [
|
|
332
|
+
{id: 'a', name: 'a', size: 1},
|
|
333
|
+
{id: 'b', name: 'b', size: 2},
|
|
334
|
+
];
|
|
335
|
+
const {result} = renderHook(() =>
|
|
336
|
+
useTableTreeState({data: flat, idKey: 'id'}),
|
|
337
|
+
);
|
|
338
|
+
|
|
339
|
+
expect(result.current.treeConfig.hasExpandableRows).toBe(false);
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
it('flags hasExpandableRows=true when any row has children', () => {
|
|
343
|
+
const {result} = renderHook(() =>
|
|
344
|
+
useTableTreeState({data: fileTree, idKey: 'id'}),
|
|
345
|
+
);
|
|
346
|
+
|
|
347
|
+
expect(result.current.treeConfig.hasExpandableRows).toBe(true);
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
// =============================================================================
|
|
352
|
+
// Lazy loading (isItemExpandable)
|
|
353
|
+
// =============================================================================
|
|
354
|
+
|
|
355
|
+
describe('useTableTreeState — isItemExpandable', () => {
|
|
356
|
+
it('forces an expander on rows whose children have not loaded yet', () => {
|
|
357
|
+
const lazy: FileRow[] = [
|
|
358
|
+
{id: 'folder', name: 'folder', size: 0}, // no children yet
|
|
359
|
+
{id: 'file', name: 'file', size: 5},
|
|
360
|
+
];
|
|
361
|
+
const {result} = renderHook(() =>
|
|
362
|
+
useTableTreeState({
|
|
363
|
+
data: lazy,
|
|
364
|
+
idKey: 'id',
|
|
365
|
+
isItemExpandable: item => item.id === 'folder',
|
|
366
|
+
}),
|
|
367
|
+
);
|
|
368
|
+
|
|
369
|
+
expect(result.current.treeConfig.getRowMeta(lazy[0])?.hasChildren).toBe(
|
|
370
|
+
true,
|
|
371
|
+
);
|
|
372
|
+
expect(result.current.treeConfig.getRowMeta(lazy[1])?.hasChildren).toBe(
|
|
373
|
+
false,
|
|
374
|
+
);
|
|
375
|
+
expect(result.current.treeConfig.hasExpandableRows).toBe(true);
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
it('expandAll includes isItemExpandable rows without loaded children', () => {
|
|
379
|
+
const lazy: FileRow[] = [{id: 'folder', name: 'folder', size: 0}];
|
|
380
|
+
const onExpandedIdsChange = vi.fn();
|
|
381
|
+
const {result} = renderHook(() =>
|
|
382
|
+
useTableTreeState({
|
|
383
|
+
data: lazy,
|
|
384
|
+
idKey: 'id',
|
|
385
|
+
isItemExpandable: () => true,
|
|
386
|
+
onExpandedIdsChange,
|
|
387
|
+
}),
|
|
388
|
+
);
|
|
389
|
+
|
|
390
|
+
act(() => {
|
|
391
|
+
result.current.expandAll();
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
expect(onExpandedIdsChange).toHaveBeenCalledWith(new Set(['folder']));
|
|
395
|
+
});
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
// =============================================================================
|
|
399
|
+
// Sibling sorting
|
|
400
|
+
// =============================================================================
|
|
401
|
+
|
|
402
|
+
describe('useTableTreeState — sortSiblings', () => {
|
|
403
|
+
it('sorts within sibling groups, never across levels', () => {
|
|
404
|
+
const byNameDesc = (siblings: FileRow[]) =>
|
|
405
|
+
[...siblings].sort((a, b) => b.name.localeCompare(a.name));
|
|
406
|
+
|
|
407
|
+
const {result} = renderHook(() =>
|
|
408
|
+
useTableTreeState({
|
|
409
|
+
data: fileTree,
|
|
410
|
+
idKey: 'id',
|
|
411
|
+
defaultExpandedIds: ['src', 'components'],
|
|
412
|
+
sortSiblings: byNameDesc,
|
|
413
|
+
}),
|
|
414
|
+
);
|
|
415
|
+
|
|
416
|
+
// Roots sorted desc: src > README.md; src's children desc: utils > components;
|
|
417
|
+
// components' children desc: Input.tsx > Button.tsx. Children always stay
|
|
418
|
+
// directly under their parent.
|
|
419
|
+
expect(ids(result.current.visibleData)).toEqual([
|
|
420
|
+
'src',
|
|
421
|
+
'utils',
|
|
422
|
+
'components',
|
|
423
|
+
'input',
|
|
424
|
+
'button',
|
|
425
|
+
'readme',
|
|
426
|
+
]);
|
|
427
|
+
});
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
// =============================================================================
|
|
431
|
+
// Accessors
|
|
432
|
+
// =============================================================================
|
|
433
|
+
|
|
434
|
+
describe('useTableTreeState — accessors', () => {
|
|
435
|
+
it('supports a custom childrenKey', () => {
|
|
436
|
+
interface OrgRow extends Record<string, unknown> {
|
|
437
|
+
id: string;
|
|
438
|
+
reports?: OrgRow[];
|
|
439
|
+
}
|
|
440
|
+
const org: OrgRow[] = [{id: 'ceo', reports: [{id: 'cto'}, {id: 'cfo'}]}];
|
|
441
|
+
const {result} = renderHook(() =>
|
|
442
|
+
useTableTreeState({
|
|
443
|
+
data: org,
|
|
444
|
+
idKey: 'id',
|
|
445
|
+
childrenKey: 'reports',
|
|
446
|
+
defaultExpandedIds: ['ceo'],
|
|
447
|
+
}),
|
|
448
|
+
);
|
|
449
|
+
|
|
450
|
+
expect(result.current.visibleData.map(r => r.id)).toEqual([
|
|
451
|
+
'ceo',
|
|
452
|
+
'cto',
|
|
453
|
+
'cfo',
|
|
454
|
+
]);
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
it('supports a function idKey returning numbers', () => {
|
|
458
|
+
interface NumRow extends Record<string, unknown> {
|
|
459
|
+
num: number;
|
|
460
|
+
children?: NumRow[];
|
|
461
|
+
}
|
|
462
|
+
const data: NumRow[] = [{num: 1, children: [{num: 2}]}];
|
|
463
|
+
const {result} = renderHook(() =>
|
|
464
|
+
useTableTreeState({
|
|
465
|
+
data,
|
|
466
|
+
idKey: item => item.num,
|
|
467
|
+
defaultExpandedIds: ['1'],
|
|
468
|
+
}),
|
|
469
|
+
);
|
|
470
|
+
|
|
471
|
+
expect(result.current.visibleData.map(r => r.num)).toEqual([1, 2]);
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
it('passes indent and treeColumnKey through to the tree config', () => {
|
|
475
|
+
const {result} = renderHook(() =>
|
|
476
|
+
useTableTreeState({
|
|
477
|
+
data: fileTree,
|
|
478
|
+
idKey: 'id',
|
|
479
|
+
indent: 'lg',
|
|
480
|
+
treeColumnKey: 'name',
|
|
481
|
+
}),
|
|
482
|
+
);
|
|
483
|
+
|
|
484
|
+
expect(result.current.treeConfig.indent).toBe('lg');
|
|
485
|
+
expect(result.current.treeConfig.treeColumnKey).toBe('name');
|
|
486
|
+
});
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
// =============================================================================
|
|
490
|
+
// Hostile / degenerate data
|
|
491
|
+
// =============================================================================
|
|
492
|
+
|
|
493
|
+
describe('useTableTreeState — hostile data', () => {
|
|
494
|
+
it('does not blow the stack on a self-referencing cycle', () => {
|
|
495
|
+
const a: FileRow = {id: 'a', name: 'a', size: 0};
|
|
496
|
+
a.children = [a]; // self-cycle
|
|
497
|
+
const {result} = renderHook(() =>
|
|
498
|
+
useTableTreeState({
|
|
499
|
+
data: [a],
|
|
500
|
+
idKey: 'id',
|
|
501
|
+
defaultExpandedIds: ['a'],
|
|
502
|
+
}),
|
|
503
|
+
);
|
|
504
|
+
|
|
505
|
+
// The cyclic edge is skipped: 'a' renders exactly once.
|
|
506
|
+
expect(ids(result.current.visibleData)).toEqual(['a']);
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
it('does not blow the stack when a descendant points back at an ancestor', () => {
|
|
510
|
+
const parent: FileRow = {id: 'p', name: 'p', size: 0};
|
|
511
|
+
const child: FileRow = {id: 'c', name: 'c', size: 0, children: [parent]};
|
|
512
|
+
parent.children = [child];
|
|
513
|
+
const {result} = renderHook(() =>
|
|
514
|
+
useTableTreeState({
|
|
515
|
+
data: [parent],
|
|
516
|
+
idKey: 'id',
|
|
517
|
+
defaultExpandedIds: ['p', 'c'],
|
|
518
|
+
}),
|
|
519
|
+
);
|
|
520
|
+
|
|
521
|
+
expect(ids(result.current.visibleData)).toEqual(['p', 'c']);
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
it('renders duplicate ids in different subtrees without crashing (shared expansion state)', () => {
|
|
525
|
+
const data: FileRow[] = [
|
|
526
|
+
{
|
|
527
|
+
id: 'x',
|
|
528
|
+
name: 'first-x',
|
|
529
|
+
size: 0,
|
|
530
|
+
children: [{id: 'dup', name: 'dup-under-x', size: 1}],
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
id: 'y',
|
|
534
|
+
name: 'second-y',
|
|
535
|
+
size: 0,
|
|
536
|
+
children: [{id: 'dup', name: 'dup-under-y', size: 2}],
|
|
537
|
+
},
|
|
538
|
+
];
|
|
539
|
+
const {result} = renderHook(() =>
|
|
540
|
+
useTableTreeState({
|
|
541
|
+
data,
|
|
542
|
+
idKey: 'id',
|
|
543
|
+
defaultExpandedIds: ['x', 'y'],
|
|
544
|
+
}),
|
|
545
|
+
);
|
|
546
|
+
|
|
547
|
+
// Both duplicate rows stay visible; ids sharing a key share expansion.
|
|
548
|
+
expect(ids(result.current.visibleData)).toEqual(['x', 'dup', 'y', 'dup']);
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
it('ignores expanded ids that match no row', () => {
|
|
552
|
+
const {result} = renderHook(() =>
|
|
553
|
+
useTableTreeState({
|
|
554
|
+
data: fileTree,
|
|
555
|
+
idKey: 'id',
|
|
556
|
+
defaultExpandedIds: ['ghost', 'src'],
|
|
557
|
+
}),
|
|
558
|
+
);
|
|
559
|
+
|
|
560
|
+
expect(ids(result.current.visibleData)).toEqual([
|
|
561
|
+
'src',
|
|
562
|
+
'components',
|
|
563
|
+
'utils',
|
|
564
|
+
'readme',
|
|
565
|
+
]);
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
it('handles empty data', () => {
|
|
569
|
+
const {result} = renderHook(() =>
|
|
570
|
+
useTableTreeState<FileRow>({data: [], idKey: 'id'}),
|
|
571
|
+
);
|
|
572
|
+
|
|
573
|
+
expect(result.current.visibleData).toEqual([]);
|
|
574
|
+
expect(result.current.treeConfig.hasExpandableRows).toBe(false);
|
|
575
|
+
act(() => {
|
|
576
|
+
result.current.expandAll(); // must not throw
|
|
577
|
+
});
|
|
578
|
+
expect(result.current.expandedIds).toEqual(new Set());
|
|
579
|
+
});
|
|
580
|
+
|
|
581
|
+
it('never mutates the consumer data when sortSiblings sorts in place', () => {
|
|
582
|
+
const inPlaceSorter = (siblings: FileRow[]) =>
|
|
583
|
+
siblings.sort((a, b) => b.name.localeCompare(a.name));
|
|
584
|
+
|
|
585
|
+
const childOrderBefore = fileTree[0].children!.map(c => c.id);
|
|
586
|
+
renderHook(() =>
|
|
587
|
+
useTableTreeState({
|
|
588
|
+
data: fileTree,
|
|
589
|
+
idKey: 'id',
|
|
590
|
+
defaultExpandedIds: ['src'],
|
|
591
|
+
sortSiblings: inPlaceSorter,
|
|
592
|
+
}),
|
|
593
|
+
);
|
|
594
|
+
|
|
595
|
+
expect(fileTree[0].children!.map(c => c.id)).toEqual(childOrderBefore);
|
|
596
|
+
});
|
|
597
|
+
});
|
|
598
|
+
|
|
599
|
+
// =============================================================================
|
|
600
|
+
// Semantics edge cases
|
|
601
|
+
// =============================================================================
|
|
602
|
+
|
|
603
|
+
describe('useTableTreeState — semantics edges', () => {
|
|
604
|
+
it('defaultExpandedIds is ignored when expandedIds is controlled', () => {
|
|
605
|
+
const {result} = renderHook(() =>
|
|
606
|
+
useTableTreeState({
|
|
607
|
+
data: fileTree,
|
|
608
|
+
idKey: 'id',
|
|
609
|
+
defaultExpandedIds: ['src'],
|
|
610
|
+
expandedIds: new Set<string>(),
|
|
611
|
+
onExpandedIdsChange: () => {},
|
|
612
|
+
}),
|
|
613
|
+
);
|
|
614
|
+
|
|
615
|
+
expect(ids(result.current.visibleData)).toEqual(['src', 'readme']);
|
|
616
|
+
});
|
|
617
|
+
|
|
618
|
+
it('toggling a leaf never marks it expanded', () => {
|
|
619
|
+
const {result} = renderHook(() =>
|
|
620
|
+
useTableTreeState({data: fileTree, idKey: 'id'}),
|
|
621
|
+
);
|
|
622
|
+
const readme = fileTree[1];
|
|
623
|
+
|
|
624
|
+
act(() => {
|
|
625
|
+
result.current.treeConfig.onToggleItem(readme);
|
|
626
|
+
});
|
|
627
|
+
|
|
628
|
+
expect(result.current.treeConfig.getRowMeta(readme)).toEqual({
|
|
629
|
+
id: 'readme',
|
|
630
|
+
level: 0,
|
|
631
|
+
hasChildren: false,
|
|
632
|
+
isExpanded: false,
|
|
633
|
+
});
|
|
634
|
+
expect(ids(result.current.visibleData)).toEqual(['src', 'readme']);
|
|
635
|
+
});
|
|
636
|
+
});
|