@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,495 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @file useTableTreeData.tsx
|
|
7
|
+
* @input React, StyleX, Icon, Table types, theme tokens, i18n (useTranslator)
|
|
8
|
+
* @output Exports useTableTreeData hook + config/meta types
|
|
9
|
+
* @position Tree plugin; consumed by Table via plugins prop.
|
|
10
|
+
* Pairs with useTableTreeState (owns expansion state + flattening).
|
|
11
|
+
*
|
|
12
|
+
* ## Architecture (mirrors useTableSelection)
|
|
13
|
+
*
|
|
14
|
+
* The tree affordance decorates the tree column's cells in place — no
|
|
15
|
+
* synthetic column. `transformColumns` wraps the tree column's renderCell
|
|
16
|
+
* with a flex wrapper carrying per-level indentation and an expander
|
|
17
|
+
* button (or a fixed-width spacer on leaves). Other columns get zero
|
|
18
|
+
* extra DOM.
|
|
19
|
+
*
|
|
20
|
+
* Expansion state flows through an external store (TreeStore) so each
|
|
21
|
+
* row's expander subscribes independently — a toggle re-renders only the
|
|
22
|
+
* affected cells, not the whole body. Row ARIA (aria-level,
|
|
23
|
+
* aria-expanded) is applied imperatively via a ref callback on each
|
|
24
|
+
* <tr>, exactly like selection's row styling; each subscription
|
|
25
|
+
* self-cleans when the row disconnects.
|
|
26
|
+
*
|
|
27
|
+
* When `hasExpandableRows` is false (flat data), every transform is a
|
|
28
|
+
* pass-through: adopting the plugin ahead of hierarchical data is a
|
|
29
|
+
* no-op.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
import {
|
|
33
|
+
createContext,
|
|
34
|
+
use,
|
|
35
|
+
useCallback,
|
|
36
|
+
useEffect,
|
|
37
|
+
useMemo,
|
|
38
|
+
useRef,
|
|
39
|
+
useSyncExternalStore,
|
|
40
|
+
type ReactNode,
|
|
41
|
+
} from 'react';
|
|
42
|
+
import * as stylex from '@stylexjs/stylex';
|
|
43
|
+
import {colorVars, radiusVars, spacingVars} from '../../../theme/tokens.stylex';
|
|
44
|
+
import {Icon} from '../../../Icon';
|
|
45
|
+
import {mergeRefs} from '../../../utils';
|
|
46
|
+
import type {TablePlugin, TableColumn, BodyRowRenderProps} from '../../types';
|
|
47
|
+
import {useTranslator} from '../../../i18n';
|
|
48
|
+
|
|
49
|
+
// =============================================================================
|
|
50
|
+
// Types
|
|
51
|
+
// =============================================================================
|
|
52
|
+
|
|
53
|
+
/** Structural position of one visible row within the tree. */
|
|
54
|
+
export interface TableTreeRowMeta {
|
|
55
|
+
/** The row's id (from `idKey`). */
|
|
56
|
+
id: string;
|
|
57
|
+
/** 0-based depth: roots are level 0. */
|
|
58
|
+
level: number;
|
|
59
|
+
/** Whether the row shows an expander. */
|
|
60
|
+
hasChildren: boolean;
|
|
61
|
+
/** Whether the row is currently expanded. */
|
|
62
|
+
isExpanded: boolean;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Configuration for useTableTreeData. `useTableTreeState` returns a
|
|
67
|
+
* ready-made value (`treeConfig`); consumers with server-driven or
|
|
68
|
+
* pre-flattened trees can construct one directly.
|
|
69
|
+
*/
|
|
70
|
+
export interface UseTableTreeDataConfig<T extends Record<string, unknown>> {
|
|
71
|
+
/** Structural meta for a visible row; undefined for unknown rows. */
|
|
72
|
+
getRowMeta: (item: T) => TableTreeRowMeta | undefined;
|
|
73
|
+
/** Toggle a row's expansion. */
|
|
74
|
+
onToggleItem: (item: T) => void;
|
|
75
|
+
/**
|
|
76
|
+
* Whether any row in the dataset is expandable. When false the plugin is
|
|
77
|
+
* a no-op: no expanders, no indent, no tree ARIA — flat data renders
|
|
78
|
+
* identically to a Table without the plugin.
|
|
79
|
+
*/
|
|
80
|
+
hasExpandableRows: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Indent step per level, as spacing tokens.
|
|
83
|
+
* @default 'md'
|
|
84
|
+
*/
|
|
85
|
+
indent?: 'sm' | 'md' | 'lg';
|
|
86
|
+
/** Column that carries the indent + expander. @default the first column */
|
|
87
|
+
treeColumnKey?: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// =============================================================================
|
|
91
|
+
// Tree Store (external store for fine-grained row subscriptions)
|
|
92
|
+
// =============================================================================
|
|
93
|
+
|
|
94
|
+
interface TreeStore<T extends Record<string, unknown>> {
|
|
95
|
+
subscribe: (listener: () => void) => () => void;
|
|
96
|
+
notify: () => void;
|
|
97
|
+
getConfig: () => UseTableTreeDataConfig<T>;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function createTreeStore<T extends Record<string, unknown>>(
|
|
101
|
+
configRef: React.RefObject<UseTableTreeDataConfig<T>>,
|
|
102
|
+
): TreeStore<T> {
|
|
103
|
+
const listeners = new Set<() => void>();
|
|
104
|
+
|
|
105
|
+
return {
|
|
106
|
+
subscribe(listener: () => void) {
|
|
107
|
+
listeners.add(listener);
|
|
108
|
+
return () => listeners.delete(listener);
|
|
109
|
+
},
|
|
110
|
+
notify() {
|
|
111
|
+
for (const listener of listeners) {
|
|
112
|
+
listener();
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
getConfig() {
|
|
116
|
+
return configRef.current;
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
122
|
+
const TreeStoreContext = createContext<TreeStore<any> | null>(null);
|
|
123
|
+
TreeStoreContext.displayName = 'TreeStoreContext';
|
|
124
|
+
|
|
125
|
+
/** Indent token -> index, for the numeric row snapshot. */
|
|
126
|
+
const INDENT_INDEX = {sm: 0, md: 1, lg: 2} as const;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Encode a row's tree meta as a primitive for useSyncExternalStore —
|
|
130
|
+
* object snapshots would tear. The indent token participates so a
|
|
131
|
+
* runtime `indent` change re-renders the affected cells.
|
|
132
|
+
* Encoding: level * 16 + indentIndex * 4 + hasChildren * 2 + isExpanded;
|
|
133
|
+
* -1 = no meta.
|
|
134
|
+
*/
|
|
135
|
+
function encodeRowMeta<T extends Record<string, unknown>>(
|
|
136
|
+
config: UseTableTreeDataConfig<T>,
|
|
137
|
+
item: T,
|
|
138
|
+
): number {
|
|
139
|
+
const meta = config.getRowMeta(item);
|
|
140
|
+
if (!meta) {
|
|
141
|
+
return -1;
|
|
142
|
+
}
|
|
143
|
+
return (
|
|
144
|
+
meta.level * 16 +
|
|
145
|
+
INDENT_INDEX[config.indent ?? 'md'] * 4 +
|
|
146
|
+
(meta.hasChildren ? 2 : 0) +
|
|
147
|
+
(meta.isExpanded ? 1 : 0)
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function useRowMetaSnapshot<T extends Record<string, unknown>>(
|
|
152
|
+
store: TreeStore<T>,
|
|
153
|
+
item: T,
|
|
154
|
+
): number {
|
|
155
|
+
const getSnapshot = useCallback(
|
|
156
|
+
() => encodeRowMeta(store.getConfig(), item),
|
|
157
|
+
[store, item],
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
return useSyncExternalStore(store.subscribe, getSnapshot, getSnapshot);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// =============================================================================
|
|
164
|
+
// Row ARIA (imperative, mirrors selection's row styling)
|
|
165
|
+
// =============================================================================
|
|
166
|
+
|
|
167
|
+
function applyRowTreeAria(
|
|
168
|
+
el: HTMLTableRowElement,
|
|
169
|
+
meta: TableTreeRowMeta | undefined,
|
|
170
|
+
): void {
|
|
171
|
+
if (!meta) {
|
|
172
|
+
el.removeAttribute('aria-level');
|
|
173
|
+
el.removeAttribute('aria-expanded');
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
el.setAttribute('aria-level', String(meta.level + 1));
|
|
177
|
+
if (meta.hasChildren) {
|
|
178
|
+
el.setAttribute('aria-expanded', String(meta.isExpanded));
|
|
179
|
+
} else {
|
|
180
|
+
el.removeAttribute('aria-expanded');
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// =============================================================================
|
|
185
|
+
// Styles
|
|
186
|
+
// =============================================================================
|
|
187
|
+
|
|
188
|
+
/** Indent step per level, by the `indent` config token. */
|
|
189
|
+
const INDENT_STEP = {
|
|
190
|
+
sm: spacingVars['--spacing-3'],
|
|
191
|
+
md: spacingVars['--spacing-4'],
|
|
192
|
+
lg: spacingVars['--spacing-6'],
|
|
193
|
+
} as const;
|
|
194
|
+
|
|
195
|
+
const treeStyles = stylex.create({
|
|
196
|
+
cell: {
|
|
197
|
+
display: 'flex',
|
|
198
|
+
alignItems: 'center',
|
|
199
|
+
gap: spacingVars['--spacing-1'],
|
|
200
|
+
},
|
|
201
|
+
indent: (paddingInlineStart: string) => ({
|
|
202
|
+
paddingInlineStart,
|
|
203
|
+
}),
|
|
204
|
+
expanderButton: {
|
|
205
|
+
display: 'inline-flex',
|
|
206
|
+
alignItems: 'center',
|
|
207
|
+
justifyContent: 'center',
|
|
208
|
+
width: '24px',
|
|
209
|
+
height: '24px',
|
|
210
|
+
background: 'transparent',
|
|
211
|
+
border: 'none',
|
|
212
|
+
borderRadius: radiusVars['--radius-inner'],
|
|
213
|
+
cursor: 'pointer',
|
|
214
|
+
color: colorVars['--color-icon-secondary'],
|
|
215
|
+
transitionProperty: 'color, background-color',
|
|
216
|
+
transitionDuration: '150ms',
|
|
217
|
+
padding: 0,
|
|
218
|
+
flexShrink: '0',
|
|
219
|
+
// Match IconButton ghost hover: subtle overlay background
|
|
220
|
+
backgroundImage: {
|
|
221
|
+
default: null,
|
|
222
|
+
':hover': {
|
|
223
|
+
'@media (hover: hover)': `linear-gradient(${colorVars['--color-overlay-hover']}, ${colorVars['--color-overlay-hover']})`,
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
':hover': {
|
|
227
|
+
color: colorVars['--color-icon-primary'],
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
chevron: {
|
|
231
|
+
display: 'inline-flex',
|
|
232
|
+
transitionProperty: 'transform',
|
|
233
|
+
transitionDuration: '150ms',
|
|
234
|
+
transform: 'rotate(0deg)',
|
|
235
|
+
},
|
|
236
|
+
chevronExpanded: {
|
|
237
|
+
transform: 'rotate(90deg)',
|
|
238
|
+
},
|
|
239
|
+
/** Keeps leaf content aligned with expandable siblings. */
|
|
240
|
+
leafSpacer: {
|
|
241
|
+
display: 'inline-block',
|
|
242
|
+
width: '24px',
|
|
243
|
+
height: '24px',
|
|
244
|
+
flexShrink: '0',
|
|
245
|
+
},
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
// =============================================================================
|
|
249
|
+
// Cell content
|
|
250
|
+
// =============================================================================
|
|
251
|
+
|
|
252
|
+
function TreeExpander({
|
|
253
|
+
isExpanded,
|
|
254
|
+
onToggle,
|
|
255
|
+
}: {
|
|
256
|
+
isExpanded: boolean;
|
|
257
|
+
onToggle: () => void;
|
|
258
|
+
}) {
|
|
259
|
+
const t = useTranslator();
|
|
260
|
+
return (
|
|
261
|
+
<button
|
|
262
|
+
type="button"
|
|
263
|
+
{...stylex.props(treeStyles.expanderButton)}
|
|
264
|
+
onClick={e => {
|
|
265
|
+
e.stopPropagation();
|
|
266
|
+
onToggle();
|
|
267
|
+
}}
|
|
268
|
+
aria-label={
|
|
269
|
+
isExpanded
|
|
270
|
+
? t('@astryx.tableTree.collapseRow')
|
|
271
|
+
: t('@astryx.tableTree.expandRow')
|
|
272
|
+
}
|
|
273
|
+
aria-expanded={isExpanded}>
|
|
274
|
+
<span
|
|
275
|
+
{...stylex.props(
|
|
276
|
+
treeStyles.chevron,
|
|
277
|
+
isExpanded && treeStyles.chevronExpanded,
|
|
278
|
+
)}>
|
|
279
|
+
<Icon icon="chevronRight" size="xsm" />
|
|
280
|
+
</span>
|
|
281
|
+
</button>
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function TreeCellContent<T extends Record<string, unknown>>({
|
|
286
|
+
item,
|
|
287
|
+
children,
|
|
288
|
+
}: {
|
|
289
|
+
item: T;
|
|
290
|
+
children: ReactNode;
|
|
291
|
+
}) {
|
|
292
|
+
const store = use(TreeStoreContext);
|
|
293
|
+
if (!store) {
|
|
294
|
+
return <>{children}</>;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return (
|
|
298
|
+
<TreeCellContentInner store={store} item={item}>
|
|
299
|
+
{children}
|
|
300
|
+
</TreeCellContentInner>
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function TreeCellContentInner<T extends Record<string, unknown>>({
|
|
305
|
+
store,
|
|
306
|
+
item,
|
|
307
|
+
children,
|
|
308
|
+
}: {
|
|
309
|
+
store: TreeStore<T>;
|
|
310
|
+
item: T;
|
|
311
|
+
children: ReactNode;
|
|
312
|
+
}) {
|
|
313
|
+
// Subscribe to this row's structural meta so a toggle re-renders only
|
|
314
|
+
// the affected cells.
|
|
315
|
+
useRowMetaSnapshot(store, item);
|
|
316
|
+
|
|
317
|
+
const config = store.getConfig();
|
|
318
|
+
const meta = config.getRowMeta(item);
|
|
319
|
+
if (!meta) {
|
|
320
|
+
return <>{children}</>;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const step = INDENT_STEP[config.indent ?? 'md'];
|
|
324
|
+
const indent = `calc(${meta.level} * ${step})`;
|
|
325
|
+
|
|
326
|
+
return (
|
|
327
|
+
<div
|
|
328
|
+
{...stylex.props(
|
|
329
|
+
treeStyles.cell,
|
|
330
|
+
meta.level > 0 && treeStyles.indent(indent),
|
|
331
|
+
)}>
|
|
332
|
+
{meta.hasChildren ? (
|
|
333
|
+
<TreeExpander
|
|
334
|
+
isExpanded={meta.isExpanded}
|
|
335
|
+
onToggle={() => store.getConfig().onToggleItem(item)}
|
|
336
|
+
/>
|
|
337
|
+
) : (
|
|
338
|
+
<span {...stylex.props(treeStyles.leafSpacer)} />
|
|
339
|
+
)}
|
|
340
|
+
{children}
|
|
341
|
+
</div>
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// =============================================================================
|
|
346
|
+
// Hook
|
|
347
|
+
// =============================================================================
|
|
348
|
+
|
|
349
|
+
export function useTableTreeData<T extends Record<string, unknown>>(
|
|
350
|
+
config: UseTableTreeDataConfig<T>,
|
|
351
|
+
): TablePlugin<T> {
|
|
352
|
+
const configRef = useRef(config);
|
|
353
|
+
configRef.current = config;
|
|
354
|
+
|
|
355
|
+
const storeRef = useRef<TreeStore<T> | null>(null);
|
|
356
|
+
if (storeRef.current == null) {
|
|
357
|
+
storeRef.current = createTreeStore(configRef);
|
|
358
|
+
}
|
|
359
|
+
const store = storeRef.current;
|
|
360
|
+
|
|
361
|
+
// Notify subscribers on every render — useSyncExternalStore only
|
|
362
|
+
// re-renders cells whose snapshot actually changed. Row ref subscribers
|
|
363
|
+
// apply imperative ARIA independently.
|
|
364
|
+
useEffect(() => {
|
|
365
|
+
store.notify();
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
// transformColumns runs on every table render; wrapped column objects
|
|
369
|
+
// must keep their identity across renders or the per-row memo breaks
|
|
370
|
+
// and a toggle re-renders the whole body. Earlier plugins may rebuild
|
|
371
|
+
// structurally-identical arrays each render, so the cache compares
|
|
372
|
+
// input columns by shallow equality, not array identity. Held in a ref
|
|
373
|
+
// (like rowExpansion's column tracking) — transforms run during
|
|
374
|
+
// BaseTable's render, where a closure variable reassignment trips the
|
|
375
|
+
// react-compiler lint.
|
|
376
|
+
const columnsCacheRef = useRef<{
|
|
377
|
+
input: TableColumn<T>[];
|
|
378
|
+
treeKey: string | undefined;
|
|
379
|
+
wrapped: boolean;
|
|
380
|
+
output: TableColumn<T>[];
|
|
381
|
+
} | null>(null);
|
|
382
|
+
|
|
383
|
+
// The plugin object is created once per store and never changes shape:
|
|
384
|
+
// every transform reads the live config through the store, and
|
|
385
|
+
// internally no-ops when hasExpandableRows is false. Swapping between
|
|
386
|
+
// an empty and a context-wrapping plugin would change the element tree
|
|
387
|
+
// and remount the whole table when flat data turns nested.
|
|
388
|
+
return useMemo((): TablePlugin<T> => {
|
|
389
|
+
const getCachedColumns = (
|
|
390
|
+
columns: TableColumn<T>[],
|
|
391
|
+
treeKey: string | undefined,
|
|
392
|
+
wrapped: boolean,
|
|
393
|
+
): TableColumn<T>[] | null => {
|
|
394
|
+
const cache = columnsCacheRef.current;
|
|
395
|
+
if (!cache || cache.treeKey !== treeKey || cache.wrapped !== wrapped) {
|
|
396
|
+
return null;
|
|
397
|
+
}
|
|
398
|
+
const prev = cache.input;
|
|
399
|
+
if (prev !== columns) {
|
|
400
|
+
if (prev.length !== columns.length) {
|
|
401
|
+
return null;
|
|
402
|
+
}
|
|
403
|
+
for (let i = 0; i < prev.length; i++) {
|
|
404
|
+
if (prev[i] !== columns[i]) {
|
|
405
|
+
return null;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
return cache.output;
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
return {
|
|
413
|
+
transformTableContext(children: ReactNode) {
|
|
414
|
+
return <TreeStoreContext value={store}>{children}</TreeStoreContext>;
|
|
415
|
+
},
|
|
416
|
+
|
|
417
|
+
transformColumns(columns: TableColumn<T>[]) {
|
|
418
|
+
const {hasExpandableRows, treeColumnKey} = store.getConfig();
|
|
419
|
+
|
|
420
|
+
// Resolve the tree column: the configured key when present, else
|
|
421
|
+
// the first non-synthetic column (a configured column may have
|
|
422
|
+
// been hidden by columnSettings — the expander must not vanish).
|
|
423
|
+
const configuredExists =
|
|
424
|
+
treeColumnKey != null && columns.some(c => c.key === treeColumnKey);
|
|
425
|
+
const treeKey = configuredExists
|
|
426
|
+
? treeColumnKey
|
|
427
|
+
: (columns.find(c => !c.key.startsWith('__'))?.key ??
|
|
428
|
+
columns[0]?.key);
|
|
429
|
+
|
|
430
|
+
// Migration guarantee: flat data renders identically to a Table
|
|
431
|
+
// without the plugin.
|
|
432
|
+
const wrapped = hasExpandableRows;
|
|
433
|
+
const cached = getCachedColumns(columns, treeKey, wrapped);
|
|
434
|
+
if (cached) {
|
|
435
|
+
return cached;
|
|
436
|
+
}
|
|
437
|
+
const output = !wrapped
|
|
438
|
+
? columns
|
|
439
|
+
: columns.map(col => {
|
|
440
|
+
if (col.key !== treeKey) {
|
|
441
|
+
return col;
|
|
442
|
+
}
|
|
443
|
+
const originalRenderCell = col.renderCell;
|
|
444
|
+
return {
|
|
445
|
+
...col,
|
|
446
|
+
renderCell: (item: T): ReactNode => (
|
|
447
|
+
<TreeCellContent item={item}>
|
|
448
|
+
{originalRenderCell
|
|
449
|
+
? originalRenderCell(item)
|
|
450
|
+
: String(
|
|
451
|
+
(item[col.key] as
|
|
452
|
+
string | number | null | undefined) ?? '',
|
|
453
|
+
)}
|
|
454
|
+
</TreeCellContent>
|
|
455
|
+
),
|
|
456
|
+
};
|
|
457
|
+
});
|
|
458
|
+
columnsCacheRef.current = {input: columns, treeKey, wrapped, output};
|
|
459
|
+
return output;
|
|
460
|
+
},
|
|
461
|
+
|
|
462
|
+
transformBodyRow(props: BodyRowRenderProps, item: T) {
|
|
463
|
+
// Attach a ref that subscribes to the store for imperative row
|
|
464
|
+
// ARIA. The ref returns a cleanup so React unsubscribes on
|
|
465
|
+
// detach — without it, every row re-render would leak one
|
|
466
|
+
// subscription (toggles shift rowIndex and re-render rows, so
|
|
467
|
+
// the listener set would grow on every toggle). The ref is
|
|
468
|
+
// attached even when no row is expandable so tree ARIA is
|
|
469
|
+
// removed if the data turns flat.
|
|
470
|
+
const treeRef: React.RefCallback<HTMLTableRowElement> = el => {
|
|
471
|
+
if (!el) {
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
const apply = () => {
|
|
475
|
+
const cfg = store.getConfig();
|
|
476
|
+
applyRowTreeAria(
|
|
477
|
+
el,
|
|
478
|
+
cfg.hasExpandableRows ? cfg.getRowMeta(item) : undefined,
|
|
479
|
+
);
|
|
480
|
+
};
|
|
481
|
+
apply();
|
|
482
|
+
const unsub = store.subscribe(apply);
|
|
483
|
+
return () => {
|
|
484
|
+
unsub();
|
|
485
|
+
};
|
|
486
|
+
};
|
|
487
|
+
|
|
488
|
+
return {
|
|
489
|
+
...props,
|
|
490
|
+
ref: props.ref ? mergeRefs(props.ref, treeRef) : treeRef,
|
|
491
|
+
};
|
|
492
|
+
},
|
|
493
|
+
};
|
|
494
|
+
}, [store]);
|
|
495
|
+
}
|