@astryxdesign/core 0.1.5 → 0.1.6-canary.02f2602
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/README.md +2 -0
- package/dist/AlertDialog/AlertDialog.d.ts +1 -1
- package/dist/AlertDialog/AlertDialog.d.ts.map +1 -1
- package/dist/AlertDialog/AlertDialog.js +21 -18
- package/dist/AlertDialog/useImperativeAlertDialog.d.ts +0 -2
- package/dist/AlertDialog/useImperativeAlertDialog.d.ts.map +1 -1
- package/dist/AlertDialog/useImperativeAlertDialog.js +3 -5
- package/dist/AppShell/AppShell.d.ts.map +1 -1
- package/dist/AppShell/AppShell.js +55 -53
- package/dist/AspectRatio/AspectRatio.js +5 -5
- package/dist/Avatar/Avatar.js +19 -19
- package/dist/Avatar/AvatarStatusDot.js +5 -5
- package/dist/AvatarGroup/AvatarGroup.d.ts +1 -1
- package/dist/AvatarGroup/AvatarGroup.d.ts.map +1 -1
- package/dist/AvatarGroup/AvatarGroup.js +9 -6
- package/dist/AvatarGroup/AvatarGroupOverflow.js +5 -5
- package/dist/Badge/Badge.js +3 -3
- package/dist/Banner/Banner.d.ts.map +1 -1
- package/dist/Banner/Banner.js +32 -30
- package/dist/Blockquote/Blockquote.js +7 -7
- package/dist/Breadcrumbs/BreadcrumbItem.js +17 -17
- package/dist/Breadcrumbs/Breadcrumbs.d.ts +1 -1
- package/dist/Breadcrumbs/Breadcrumbs.d.ts.map +1 -1
- package/dist/Breadcrumbs/Breadcrumbs.js +11 -8
- package/dist/Button/Button.d.ts.map +1 -1
- package/dist/Button/Button.js +53 -23
- package/dist/ButtonGroup/ButtonGroup.d.ts +20 -5
- package/dist/ButtonGroup/ButtonGroup.d.ts.map +1 -1
- package/dist/ButtonGroup/ButtonGroup.js +34 -18
- package/dist/Calendar/Calendar.d.ts.map +1 -1
- package/dist/Calendar/Calendar.js +51 -48
- package/dist/Card/Card.js +3 -3
- package/dist/Carousel/Carousel.d.ts +1 -1
- package/dist/Carousel/Carousel.d.ts.map +1 -1
- package/dist/Carousel/Carousel.js +27 -24
- package/dist/Center/Center.js +3 -3
- package/dist/Chat/ChatComposer.d.ts.map +1 -1
- package/dist/Chat/ChatComposer.js +27 -24
- package/dist/Chat/ChatComposerDrawer.d.ts +1 -1
- package/dist/Chat/ChatComposerDrawer.d.ts.map +1 -1
- package/dist/Chat/ChatComposerDrawer.js +23 -16
- package/dist/Chat/ChatComposerInput.d.ts.map +1 -1
- package/dist/Chat/ChatComposerInput.js +20 -16
- package/dist/Chat/ChatDictationButton.js +10 -10
- package/dist/Chat/ChatLayout.d.ts +1 -11
- package/dist/Chat/ChatLayout.d.ts.map +1 -1
- package/dist/Chat/ChatLayout.js +23 -21
- package/dist/Chat/ChatLayoutScrollButton.d.ts.map +1 -1
- package/dist/Chat/ChatLayoutScrollButton.js +13 -11
- package/dist/Chat/ChatMessage.d.ts +1 -1
- package/dist/Chat/ChatMessage.d.ts.map +1 -1
- package/dist/Chat/ChatMessage.js +20 -14
- package/dist/Chat/ChatMessageBubble.d.ts +1 -1
- package/dist/Chat/ChatMessageBubble.d.ts.map +1 -1
- package/dist/Chat/ChatMessageBubble.js +10 -8
- package/dist/Chat/ChatMessageList.d.ts +1 -1
- package/dist/Chat/ChatMessageList.d.ts.map +1 -1
- package/dist/Chat/ChatMessageList.js +17 -15
- package/dist/Chat/ChatMessageMetadata.d.ts.map +1 -1
- package/dist/Chat/ChatMessageMetadata.js +24 -19
- package/dist/Chat/ChatPastedTextToken.d.ts.map +1 -1
- package/dist/Chat/ChatPastedTextToken.js +16 -14
- package/dist/Chat/ChatSendButton.d.ts.map +1 -1
- package/dist/Chat/ChatSendButton.js +6 -4
- package/dist/Chat/ChatSystemMessage.js +11 -11
- package/dist/Chat/ChatTokenizedText.js +8 -8
- package/dist/Chat/ChatToolCalls.js +73 -73
- 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 +19 -17
- package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
- package/dist/CheckboxInput/CheckboxInput.js +26 -24
- package/dist/CheckboxList/CheckboxList.d.ts +1 -1
- package/dist/CheckboxList/CheckboxList.d.ts.map +1 -1
- package/dist/CheckboxList/CheckboxList.js +12 -10
- package/dist/CheckboxList/CheckboxListItem.d.ts.map +1 -1
- package/dist/CheckboxList/CheckboxListItem.js +8 -6
- package/dist/Citation/Citation.d.ts.map +1 -1
- package/dist/Citation/Citation.js +20 -12
- package/dist/ClickableCard/ClickableCard.js +6 -6
- package/dist/Code/Code.js +3 -3
- package/dist/CodeBlock/CodeBlock.d.ts.map +1 -1
- package/dist/CodeBlock/CodeBlock.js +114 -96
- package/dist/Collapsible/Collapsible.js +11 -11
- package/dist/Collapsible/CollapsibleGroup.js +7 -7
- package/dist/CommandPalette/CommandPalette.d.ts +1 -1
- package/dist/CommandPalette/CommandPalette.d.ts.map +1 -1
- package/dist/CommandPalette/CommandPalette.js +39 -34
- package/dist/CommandPalette/CommandPaletteEmpty.js +3 -3
- package/dist/CommandPalette/CommandPaletteFooter.js +16 -16
- package/dist/CommandPalette/CommandPaletteGroup.js +5 -5
- package/dist/CommandPalette/CommandPaletteInput.d.ts +1 -1
- package/dist/CommandPalette/CommandPaletteInput.d.ts.map +1 -1
- package/dist/CommandPalette/CommandPaletteInput.js +17 -14
- package/dist/CommandPalette/CommandPaletteItem.js +3 -3
- package/dist/CommandPalette/CommandPaletteList.d.ts +1 -1
- package/dist/CommandPalette/CommandPaletteList.d.ts.map +1 -1
- package/dist/CommandPalette/CommandPaletteList.js +7 -4
- package/dist/ContextMenu/ContextMenu.d.ts +1 -1
- package/dist/ContextMenu/ContextMenu.d.ts.map +1 -1
- package/dist/ContextMenu/ContextMenu.js +14 -11
- package/dist/DateInput/DateInput.d.ts +1 -1
- package/dist/DateInput/DateInput.d.ts.map +1 -1
- package/dist/DateInput/DateInput.js +28 -23
- package/dist/DateRangeInput/DateRangeInput.d.ts +1 -1
- package/dist/DateRangeInput/DateRangeInput.d.ts.map +1 -1
- package/dist/DateRangeInput/DateRangeInput.js +32 -27
- package/dist/DateTimeInput/DateTimeInput.d.ts +1 -1
- package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
- package/dist/DateTimeInput/DateTimeInput.js +41 -33
- package/dist/Dialog/Dialog.js +9 -9
- package/dist/Dialog/DialogHeader.d.ts.map +1 -1
- package/dist/Dialog/DialogHeader.js +20 -18
- package/dist/Dialog/useImperativeDialog.js +3 -3
- package/dist/Divider/Divider.js +7 -7
- package/dist/DropdownMenu/DropdownMenu.d.ts +1 -1
- package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenu.js +21 -15
- package/dist/DropdownMenu/DropdownMenuItem.js +3 -3
- package/dist/DropdownMenu/renderDropdownItems.js +10 -10
- package/dist/EmptyState/EmptyState.d.ts +4 -1
- package/dist/EmptyState/EmptyState.d.ts.map +1 -1
- package/dist/EmptyState/EmptyState.js +9 -9
- package/dist/Field/Field.js +17 -17
- package/dist/Field/FieldLabel.js +15 -15
- package/dist/Field/InputClearButton.js +5 -5
- package/dist/FieldStatus/FieldStatus.js +3 -3
- package/dist/FileInput/FileInput.d.ts.map +1 -1
- package/dist/FileInput/FileInput.js +34 -30
- package/dist/FormLayout/FormLayout.js +5 -5
- package/dist/Grid/Grid.js +3 -3
- package/dist/Grid/GridSpan.js +3 -3
- package/dist/HStack/HStack.js +3 -3
- package/dist/Heading/Heading.js +10 -10
- package/dist/HoverCard/HoverCard.js +9 -9
- package/dist/HoverCard/useHoverCard.js +3 -3
- package/dist/Icon/Icon.js +11 -11
- package/dist/Icon/defaultIcons.js +116 -116
- package/dist/IconButton/IconButton.js +3 -3
- package/dist/InputGroup/InputGroup.js +9 -9
- package/dist/InputGroup/InputGroupText.js +3 -3
- package/dist/Item/Item.js +17 -17
- package/dist/Kbd/Kbd.js +5 -5
- package/dist/Layer/LayerProvider.js +7 -7
- package/dist/Layer/useLayer.js +5 -5
- package/dist/Layout/Layout.js +21 -21
- package/dist/Layout/LayoutContent.js +3 -3
- package/dist/Layout/LayoutFooter.js +5 -5
- package/dist/Layout/LayoutHeader.js +5 -5
- package/dist/Layout/LayoutPanel.js +3 -3
- package/dist/Lightbox/Lightbox.d.ts.map +1 -1
- package/dist/Lightbox/Lightbox.js +35 -33
- package/dist/Lightbox/useLightbox.d.ts +0 -1
- package/dist/Lightbox/useLightbox.d.ts.map +1 -1
- package/dist/Lightbox/useLightbox.js +3 -4
- package/dist/Link/Link.d.ts +5 -3
- package/dist/Link/Link.d.ts.map +1 -1
- package/dist/Link/Link.js +47 -18
- package/dist/Link/LinkProvider.js +3 -3
- package/dist/Link/useLinkify.js +3 -3
- package/dist/List/List.js +11 -11
- package/dist/List/ListItem.js +11 -11
- package/dist/Markdown/Markdown.d.ts.map +1 -1
- package/dist/Markdown/Markdown.js +111 -109
- package/dist/MetadataList/MetadataList.js +10 -10
- package/dist/MetadataList/MetadataListItem.js +15 -15
- package/dist/MobileNav/MobileNav.d.ts.map +1 -1
- package/dist/MobileNav/MobileNav.js +19 -17
- package/dist/MobileNav/MobileNavToggle.d.ts +1 -1
- package/dist/MobileNav/MobileNavToggle.d.ts.map +1 -1
- package/dist/MobileNav/MobileNavToggle.js +9 -6
- package/dist/MoreMenu/MoreMenu.d.ts +1 -1
- package/dist/MoreMenu/MoreMenu.d.ts.map +1 -1
- package/dist/MoreMenu/MoreMenu.js +7 -4
- package/dist/MultiSelector/MultiSelector.d.ts +1 -1
- package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
- package/dist/MultiSelector/MultiSelector.js +69 -62
- package/dist/NavIcon/NavIcon.js +3 -3
- package/dist/NavMenu/NavHeadingMenu.js +5 -5
- package/dist/NavMenu/NavHeadingMenuItem.js +8 -8
- package/dist/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/NumberInput/NumberInput.js +21 -17
- package/dist/Outline/Outline.d.ts +1 -1
- package/dist/Outline/Outline.d.ts.map +1 -1
- package/dist/Outline/Outline.js +19 -16
- package/dist/OverflowList/OverflowList.js +8 -8
- package/dist/Overlay/Overlay.js +3 -3
- package/dist/Overlay/OverlayScrim.js +5 -5
- package/dist/Overlay/useOverlay.d.ts +0 -3
- package/dist/Overlay/useOverlay.d.ts.map +1 -1
- package/dist/Overlay/useOverlay.js +3 -6
- package/dist/Pagination/Pagination.d.ts +1 -1
- package/dist/Pagination/Pagination.d.ts.map +1 -1
- package/dist/Pagination/Pagination.js +73 -46
- package/dist/Popover/Popover.js +16 -16
- package/dist/Popover/usePopover.d.ts.map +1 -1
- package/dist/Popover/usePopover.js +11 -8
- package/dist/PowerSearch/PowerSearch.d.ts +1 -1
- package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearch.js +95 -85
- package/dist/PowerSearch/PowerSearchEditPopover.d.ts +1 -1
- package/dist/PowerSearch/PowerSearchEditPopover.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchEditPopover.js +109 -103
- package/dist/PowerSearch/PowerSearchFilterEditor.js +3 -3
- package/dist/PowerSearch/PowerSearchToken.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchToken.js +12 -8
- package/dist/PowerSearch/PowerSearchValueEditor.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchValueEditor.js +88 -75
- 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/ProgressBar/ProgressBar.js +13 -13
- package/dist/RadioList/RadioList.js +7 -7
- package/dist/RadioList/RadioListItem.js +18 -18
- package/dist/Resizable/ResizeHandle.d.ts +1 -1
- package/dist/Resizable/ResizeHandle.d.ts.map +1 -1
- package/dist/Resizable/ResizeHandle.js +10 -7
- package/dist/Section/Section.js +5 -5
- package/dist/SegmentedControl/SegmentedControl.js +5 -5
- package/dist/SegmentedControl/SegmentedControlItem.js +7 -7
- package/dist/SelectableCard/SelectableCard.js +5 -5
- package/dist/Selector/Selector.d.ts.map +1 -1
- package/dist/Selector/Selector.js +57 -51
- package/dist/Selector/SelectorOption.js +3 -3
- package/dist/SideNav/SideNav.d.ts.map +1 -1
- package/dist/SideNav/SideNav.js +38 -36
- package/dist/SideNav/SideNavCollapseButton.d.ts.map +1 -1
- package/dist/SideNav/SideNavCollapseButton.js +8 -6
- package/dist/SideNav/SideNavHeading.d.ts.map +1 -1
- package/dist/SideNav/SideNavHeading.js +92 -90
- package/dist/SideNav/SideNavItem.d.ts.map +1 -1
- package/dist/SideNav/SideNavItem.js +49 -43
- package/dist/SideNav/SideNavSection.js +14 -14
- package/dist/Skeleton/Skeleton.js +3 -3
- package/dist/Slider/Slider.js +23 -23
- package/dist/Spinner/Spinner.js +9 -9
- package/dist/StatusDot/StatusDot.js +5 -5
- package/dist/Switch/Switch.d.ts.map +1 -1
- package/dist/Switch/Switch.js +29 -27
- package/dist/TabList/Tab.js +18 -18
- package/dist/TabList/TabList.d.ts +1 -1
- package/dist/TabList/TabList.d.ts.map +1 -1
- package/dist/TabList/TabList.js +9 -6
- package/dist/TabList/TabMenu.js +23 -23
- package/dist/Table/BaseTable.d.ts.map +1 -1
- package/dist/Table/BaseTable.js +39 -37
- package/dist/Table/Table.d.ts.map +1 -1
- package/dist/Table/Table.js +10 -8
- package/dist/Table/TableBody.js +3 -3
- package/dist/Table/TableCell.js +3 -3
- package/dist/Table/TableFooter.js +3 -3
- package/dist/Table/TableHeader.js +3 -3
- package/dist/Table/TableHeaderCell.js +3 -3
- package/dist/Table/TableRow.js +5 -5
- package/dist/Table/index.d.ts +4 -0
- package/dist/Table/index.d.ts.map +1 -1
- package/dist/Table/index.js +2 -0
- package/dist/Table/plugins/columnResize/useTableColumnResize.js +9 -9
- package/dist/Table/plugins/filtering/useTableFiltering.d.ts.map +1 -1
- package/dist/Table/plugins/filtering/useTableFiltering.js +127 -90
- package/dist/Table/plugins/groupedRows/index.d.ts +3 -0
- package/dist/Table/plugins/groupedRows/index.d.ts.map +1 -0
- package/dist/Table/plugins/groupedRows/index.js +3 -0
- package/dist/Table/plugins/groupedRows/useTableGroupedRows.d.ts +78 -0
- package/dist/Table/plugins/groupedRows/useTableGroupedRows.d.ts.map +1 -0
- package/dist/Table/plugins/groupedRows/useTableGroupedRows.js +257 -0
- package/dist/Table/plugins/pagination/useTablePagination.d.ts.map +1 -1
- package/dist/Table/plugins/pagination/useTablePagination.js +12 -9
- package/dist/Table/plugins/rowExpansion/useTableRowExpansion.d.ts +1 -1
- package/dist/Table/plugins/rowExpansion/useTableRowExpansion.d.ts.map +1 -1
- package/dist/Table/plugins/rowExpansion/useTableRowExpansion.js +30 -28
- package/dist/Table/plugins/rowIndex/index.d.ts +3 -0
- package/dist/Table/plugins/rowIndex/index.d.ts.map +1 -0
- package/dist/Table/plugins/rowIndex/index.js +3 -0
- package/dist/Table/plugins/rowIndex/useTableRowIndex.d.ts +50 -0
- package/dist/Table/plugins/rowIndex/useTableRowIndex.d.ts.map +1 -0
- package/dist/Table/plugins/rowIndex/useTableRowIndex.js +91 -0
- package/dist/Table/plugins/selection/useTableSelection.d.ts.map +1 -1
- package/dist/Table/plugins/selection/useTableSelection.js +23 -20
- package/dist/Table/plugins/sortable/useTableSortable.d.ts.map +1 -1
- package/dist/Table/plugins/sortable/useTableSortable.js +23 -21
- package/dist/Table/tableContextMenu.js +9 -9
- package/dist/Text/Text.js +10 -10
- package/dist/TextArea/TextArea.js +14 -14
- package/dist/TextInput/TextInput.d.ts.map +1 -1
- package/dist/TextInput/TextInput.js +20 -16
- package/dist/Thumbnail/Thumbnail.d.ts.map +1 -1
- package/dist/Thumbnail/Thumbnail.js +37 -31
- package/dist/TimeInput/TimeInput.d.ts +1 -1
- package/dist/TimeInput/TimeInput.d.ts.map +1 -1
- package/dist/TimeInput/TimeInput.js +28 -23
- package/dist/Timestamp/Timestamp.d.ts.map +1 -1
- package/dist/Timestamp/Timestamp.js +29 -14
- package/dist/Toast/Toast.d.ts.map +1 -1
- package/dist/Toast/Toast.js +17 -15
- package/dist/Toast/ToastViewport.d.ts.map +1 -1
- package/dist/Toast/ToastViewport.js +14 -12
- package/dist/Toast/useToast.js +4 -4
- package/dist/ToggleButton/ToggleButton.js +12 -12
- package/dist/ToggleButton/ToggleButtonGroup.js +5 -5
- package/dist/Token/Token.d.ts.map +1 -1
- package/dist/Token/Token.js +29 -23
- package/dist/Tokenizer/Tokenizer.d.ts.map +1 -1
- package/dist/Tokenizer/Tokenizer.js +33 -31
- package/dist/Toolbar/Toolbar.js +18 -18
- package/dist/Tooltip/Tooltip.js +11 -11
- package/dist/Tooltip/useTooltip.js +3 -3
- package/dist/TopNav/TopNav.d.ts +2 -1
- package/dist/TopNav/TopNav.d.ts.map +1 -1
- package/dist/TopNav/TopNav.js +36 -33
- package/dist/TopNav/TopNavHeading.d.ts.map +1 -1
- package/dist/TopNav/TopNavHeading.js +72 -70
- package/dist/TopNav/TopNavItem.js +5 -5
- package/dist/TopNav/TopNavMegaMenu.js +30 -30
- package/dist/TopNav/TopNavMegaMenuFeaturedCard.js +10 -10
- package/dist/TopNav/TopNavMegaMenuItem.js +16 -16
- package/dist/TopNav/TopNavMenu.js +32 -32
- package/dist/TreeList/TreeList.d.ts.map +1 -1
- package/dist/TreeList/TreeList.js +13 -9
- package/dist/TreeList/TreeListBranches.js +11 -11
- package/dist/TreeList/TreeListItem.d.ts.map +1 -1
- package/dist/TreeList/TreeListItem.js +37 -31
- package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
- package/dist/Typeahead/BaseTypeahead.js +26 -22
- package/dist/Typeahead/Typeahead.d.ts.map +1 -1
- package/dist/Typeahead/Typeahead.js +15 -13
- package/dist/Typeahead/TypeaheadItem.js +10 -10
- package/dist/VStack/VStack.js +3 -3
- package/dist/VisuallyHidden/VisuallyHidden.d.ts +1 -3
- package/dist/VisuallyHidden/VisuallyHidden.d.ts.map +1 -1
- package/dist/VisuallyHidden/VisuallyHidden.js +1 -3
- package/dist/astryx.css +20 -2
- package/dist/astryx.umd.js +66 -64
- 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/hooks/useKeyboardHint.js +9 -9
- 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 +62 -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/MediaTheme.js +3 -3
- package/dist/theme/Theme.js +7 -7
- package/dist/theme/syntax/SyntaxTheme.js +5 -5
- package/locales/en.json +746 -0
- package/locales/pseudo.json +560 -0
- package/package.json +24 -3
- package/src/AlertDialog/AlertDialog.doc.mjs +5 -0
- package/src/AlertDialog/AlertDialog.tsx +4 -1
- package/src/AlertDialog/useImperativeAlertDialog.tsx +0 -2
- 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.tsx +34 -4
- package/src/ButtonGroup/ButtonGroup.test.tsx +386 -2
- package/src/ButtonGroup/ButtonGroup.tsx +27 -11
- package/src/Calendar/Calendar.tsx +8 -5
- 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.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/useSpeechRecognition.ts +11 -2
- package/src/Chat/useTriggerMenu.tsx +4 -2
- 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 +3 -3
- 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.tsx +4 -1
- package/src/DateInput/DateInput.doc.mjs +2 -2
- package/src/DateInput/DateInput.tsx +13 -5
- package/src/DateRangeInput/DateRangeInput.doc.mjs +7 -7
- 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/DialogHeader.tsx +4 -2
- package/src/DropdownMenu/DropdownMenu.tsx +12 -8
- package/src/EmptyState/EmptyState.doc.mjs +3 -3
- package/src/EmptyState/EmptyState.tsx +4 -1
- package/src/Field/Field.doc.mjs +2 -2
- package/src/FileInput/FileInput.tsx +3 -1
- package/src/Grid/Grid.doc.mjs +5 -5
- package/src/InputGroup/InputGroup.doc.mjs +1 -1
- package/src/Layer/useLayer.doc.mjs +2 -2
- package/src/Lightbox/Lightbox.doc.mjs +7 -2
- package/src/Lightbox/Lightbox.tsx +6 -4
- package/src/Lightbox/useLightbox.tsx +0 -1
- package/src/Link/Link.test.tsx +74 -2
- package/src/Link/Link.tsx +48 -3
- 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.tsx +3 -1
- package/src/Outline/Outline.tsx +4 -1
- package/src/OverflowList/OverflowList.doc.mjs +2 -2
- package/src/Overlay/useOverlay.tsx +0 -3
- 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.tsx +11 -6
- 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.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 +2 -2
- package/src/Switch/Switch.test.tsx +16 -0
- package/src/Switch/Switch.tsx +4 -2
- package/src/TabList/TabList.tsx +4 -1
- package/src/Table/BaseTable.tsx +8 -1
- package/src/Table/Table.doc.mjs +1 -1
- package/src/Table/Table.tsx +3 -1
- package/src/Table/index.ts +7 -0
- package/src/Table/plugins/filtering/useTableFiltering.tsx +31 -30
- package/src/Table/plugins/groupedRows/index.ts +7 -0
- package/src/Table/plugins/groupedRows/useTableGroupedRows.test.tsx +231 -0
- package/src/Table/plugins/groupedRows/useTableGroupedRows.tsx +351 -0
- package/src/Table/plugins/pagination/useTablePagination.tsx +4 -1
- package/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx +8 -4
- package/src/Table/plugins/rowIndex/index.ts +4 -0
- package/src/Table/plugins/rowIndex/useTableRowIndex.test.tsx +132 -0
- package/src/Table/plugins/rowIndex/useTableRowIndex.tsx +114 -0
- package/src/Table/plugins/selection/useTableSelection.tsx +6 -7
- package/src/Table/plugins/sortable/useTableSortable.tsx +8 -5
- package/src/Table/useTableFiltering.doc.mjs +2 -2
- package/src/Table/useTableGroupedRows.doc.mjs +71 -0
- package/src/Table/useTableRowIndex.doc.mjs +50 -0
- package/src/Table/useTableSortable.doc.mjs +11 -11
- package/src/Text/Text.doc.mjs +2 -2
- 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/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 -3
- 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 +902 -0
- package/src/hooks/useHotkeys.doc.mjs +5 -5
- package/src/i18n/InternationalizationContext.ts +39 -0
- package/src/i18n/InternationalizationProvider.doc.mjs +72 -0
- package/src/i18n/InternationalizationProvider.tsx +83 -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/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,257 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @file useTableGroupedRows.tsx
|
|
7
|
+
* @input React, StyleX, Icon, Table types + the flat data array
|
|
8
|
+
* @output Exports useTableGroupedRows hook + config/result types
|
|
9
|
+
* @position Grouped-rows plugin; consumed by Table via plugins prop
|
|
10
|
+
*
|
|
11
|
+
* SYNC: When modified, update these files to stay in sync:
|
|
12
|
+
* - /packages/core/src/Table/index.ts (exports)
|
|
13
|
+
*/
|
|
14
|
+
import { useCallback, useMemo } from 'react';
|
|
15
|
+
import * as stylex from '@stylexjs/stylex';
|
|
16
|
+
import "../../../theme/tokens.stylex.js";
|
|
17
|
+
import { spacingVars, colorVars, fontWeightVars } from "../../../theme/tokens.stylex.js";
|
|
18
|
+
import { Icon } from "../../../Icon/index.js";
|
|
19
|
+
import { useTranslator } from "../../../i18n/index.js";
|
|
20
|
+
|
|
21
|
+
// A synthetic group-header row injected into the flattened data. Real rows
|
|
22
|
+
// never carry this marker.
|
|
23
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
+
const GROUP_HEADER = Symbol('tableGroupHeader');
|
|
25
|
+
function isGroupHeader(item) {
|
|
26
|
+
return typeof item === 'object' && item !== null && item[GROUP_HEADER] === true;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Proxy handler: any field access beyond the marker fields resolves to `''`
|
|
30
|
+
// so user cell renderers (`item.name.toUpperCase()`) never throw on a header.
|
|
31
|
+
const HEADER_PROXY_HANDLER = {
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/promise-function-async -- Proxy get trap, not a promise-returning fn
|
|
33
|
+
get(t, prop) {
|
|
34
|
+
if (prop === GROUP_HEADER || prop === 'groupKey' || prop === 'count') {
|
|
35
|
+
return t[prop];
|
|
36
|
+
}
|
|
37
|
+
return prop in t ? t[prop] : '';
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Build a synthetic header row wrapped in a Proxy so arbitrary field access
|
|
43
|
+
* from user cell renderers (e.g. `item.name.toUpperCase()`) resolves to `''`
|
|
44
|
+
* instead of throwing — BaseTable evaluates `col.renderCell(item)` on every
|
|
45
|
+
* row (including synthetic headers) before `transformBodyRow` can replace the
|
|
46
|
+
* row's cells. `transformBodyRow` then discards those cells and renders a
|
|
47
|
+
* single full-width header cell.
|
|
48
|
+
*/
|
|
49
|
+
function makeHeader(groupKey, count) {
|
|
50
|
+
const target = {
|
|
51
|
+
[GROUP_HEADER]: true,
|
|
52
|
+
groupKey,
|
|
53
|
+
count
|
|
54
|
+
};
|
|
55
|
+
return new Proxy(target, HEADER_PROXY_HANDLER);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Configuration for {@link useTableGroupedRows}. */
|
|
59
|
+
|
|
60
|
+
const styles = {
|
|
61
|
+
headerRow: {
|
|
62
|
+
kkrTdU: "x1ypdohk",
|
|
63
|
+
kfSwDN: "x87ps6o",
|
|
64
|
+
kWkggS: "xwmxj5m",
|
|
65
|
+
kt9PQ7: "xso031l",
|
|
66
|
+
kfdmCh: "x1q0q8m5",
|
|
67
|
+
kL6WhQ: "xw8gpjh",
|
|
68
|
+
$$css: true
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Groups a flat data array into collapsible section rows. Each distinct
|
|
74
|
+
* `groupBy` value becomes a full-width section-header row with a chevron
|
|
75
|
+
* toggle, the group label, and a member count; collapsing hides that group's
|
|
76
|
+
* data rows while keeping the header visible.
|
|
77
|
+
*
|
|
78
|
+
* Mirrors {@link useTableRowExpansionState}: the consumer owns the
|
|
79
|
+
* `collapsedGroups` set and this hook returns `{data, plugin, idKey}` —
|
|
80
|
+
* pass all three to `<Table>`.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```
|
|
84
|
+
* const [collapsed, setCollapsed] = useState<Set<string>>(new Set());
|
|
85
|
+
* const grouped = useTableGroupedRows({
|
|
86
|
+
* data: rows,
|
|
87
|
+
* groupBy: r => r.team,
|
|
88
|
+
* collapsedGroups: collapsed,
|
|
89
|
+
* onToggleGroup: key =>
|
|
90
|
+
* setCollapsed(prev => {
|
|
91
|
+
* const next = new Set(prev);
|
|
92
|
+
* next.has(key) ? next.delete(key) : next.add(key);
|
|
93
|
+
* return next;
|
|
94
|
+
* }),
|
|
95
|
+
* getRowKey: r => r.id,
|
|
96
|
+
* });
|
|
97
|
+
* <Table
|
|
98
|
+
* data={grouped.data}
|
|
99
|
+
* columns={columns}
|
|
100
|
+
* idKey={grouped.idKey}
|
|
101
|
+
* plugins={{grouped: grouped.plugin}}
|
|
102
|
+
* />;
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
export function useTableGroupedRows(config) {
|
|
106
|
+
const t = useTranslator();
|
|
107
|
+
const {
|
|
108
|
+
data,
|
|
109
|
+
groupBy,
|
|
110
|
+
collapsedGroups,
|
|
111
|
+
onToggleGroup,
|
|
112
|
+
renderGroupHeader,
|
|
113
|
+
getRowKey: getRowKeyProp,
|
|
114
|
+
groupOrder
|
|
115
|
+
} = config;
|
|
116
|
+
const flattened = useMemo(() => {
|
|
117
|
+
if (data.length === 0) {
|
|
118
|
+
return [];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Group preserving first-seen order.
|
|
122
|
+
const groups = new Map();
|
|
123
|
+
for (const item of data) {
|
|
124
|
+
const key = groupBy(item);
|
|
125
|
+
const bucket = groups.get(key);
|
|
126
|
+
if (bucket) {
|
|
127
|
+
bucket.push(item);
|
|
128
|
+
} else {
|
|
129
|
+
groups.set(key, [item]);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Determine iteration order.
|
|
134
|
+
let keys = [...groups.keys()];
|
|
135
|
+
if (groupOrder && groupOrder.length > 0) {
|
|
136
|
+
const ordered = groupOrder.filter(k => groups.has(k));
|
|
137
|
+
const rest = keys.filter(k => !groupOrder.includes(k));
|
|
138
|
+
keys = [...ordered, ...rest];
|
|
139
|
+
}
|
|
140
|
+
const out = [];
|
|
141
|
+
for (const key of keys) {
|
|
142
|
+
const rows = groups.get(key) ?? [];
|
|
143
|
+
out.push(makeHeader(key, rows.length));
|
|
144
|
+
if (!collapsedGroups.has(key)) {
|
|
145
|
+
out.push(...rows);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return out;
|
|
149
|
+
}, [data, groupBy, collapsedGroups, groupOrder]);
|
|
150
|
+
|
|
151
|
+
// Positional fallback index, built once per flattened array so key lookup
|
|
152
|
+
// stays O(1) instead of O(n) per row (which would make table keying O(n²)).
|
|
153
|
+
const positionByItem = useMemo(() => {
|
|
154
|
+
if (getRowKeyProp) {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
const map = new Map();
|
|
158
|
+
for (let i = 0; i < flattened.length; i++) {
|
|
159
|
+
map.set(flattened[i], i);
|
|
160
|
+
}
|
|
161
|
+
return map;
|
|
162
|
+
}, [flattened, getRowKeyProp]);
|
|
163
|
+
const idKey = useCallback(item => {
|
|
164
|
+
if (isGroupHeader(item)) {
|
|
165
|
+
return `__group_${item.groupKey}`;
|
|
166
|
+
}
|
|
167
|
+
if (getRowKeyProp) {
|
|
168
|
+
return getRowKeyProp(item);
|
|
169
|
+
}
|
|
170
|
+
return String(positionByItem?.get(item) ?? -1);
|
|
171
|
+
}, [getRowKeyProp, positionByItem]);
|
|
172
|
+
const plugin = useMemo(() => ({
|
|
173
|
+
// Replace a header row's pre-rendered cells with one full-width cell.
|
|
174
|
+
transformBodyRow(props, item) {
|
|
175
|
+
if (!isGroupHeader(item)) {
|
|
176
|
+
return props;
|
|
177
|
+
}
|
|
178
|
+
const header = item;
|
|
179
|
+
const collapsed = collapsedGroups.has(header.groupKey);
|
|
180
|
+
const toggle = () => onToggleGroup(header.groupKey);
|
|
181
|
+
const content = renderGroupHeader ? renderGroupHeader(header.groupKey, header.count, collapsed) : /*#__PURE__*/_jsxs("span", {
|
|
182
|
+
...{
|
|
183
|
+
className: "x2mo6ok x1tgivj0"
|
|
184
|
+
},
|
|
185
|
+
children: [header.groupKey, ' ', /*#__PURE__*/_jsxs("span", {
|
|
186
|
+
...{
|
|
187
|
+
className: "x1sodnla xv1l7n4"
|
|
188
|
+
},
|
|
189
|
+
children: ["(", header.count, ")"]
|
|
190
|
+
})]
|
|
191
|
+
});
|
|
192
|
+
return {
|
|
193
|
+
...props,
|
|
194
|
+
htmlProps: {
|
|
195
|
+
...props.htmlProps,
|
|
196
|
+
// Convenience: clicking anywhere on the row toggles it. The chevron
|
|
197
|
+
// button below is the accessible, keyboard-operable control, so the
|
|
198
|
+
// row keeps its implicit `row` role (no role override here).
|
|
199
|
+
onClick: toggle,
|
|
200
|
+
'aria-expanded': !collapsed
|
|
201
|
+
},
|
|
202
|
+
styles: [...props.styles, styles.headerRow],
|
|
203
|
+
children:
|
|
204
|
+
/*#__PURE__*/
|
|
205
|
+
// colSpan larger than the column count is clamped by the browser
|
|
206
|
+
// to the actual number of columns, so the header always spans the
|
|
207
|
+
// full width without the plugin knowing the column count.
|
|
208
|
+
_jsx("td", {
|
|
209
|
+
colSpan: 999,
|
|
210
|
+
...{
|
|
211
|
+
className: "xce4md1 x1vsv5vr x1t818jl"
|
|
212
|
+
},
|
|
213
|
+
children: /*#__PURE__*/_jsxs("span", {
|
|
214
|
+
...{
|
|
215
|
+
className: "x78zum5 x6s0dn4 xzye2dw"
|
|
216
|
+
},
|
|
217
|
+
children: [/*#__PURE__*/_jsx("button", {
|
|
218
|
+
type: "button",
|
|
219
|
+
...{
|
|
220
|
+
className: "x3nfvp2 x6s0dn4 xl56j7k x2lah0s x1717udv x1ghz6dp x1ypdohk xv9yike x1cqbx0l"
|
|
221
|
+
},
|
|
222
|
+
onClick: e => {
|
|
223
|
+
e.stopPropagation();
|
|
224
|
+
toggle();
|
|
225
|
+
},
|
|
226
|
+
"aria-label": collapsed ? t('@astryx.tableGroupedRows.expandGroup', {
|
|
227
|
+
groupKey: header.groupKey
|
|
228
|
+
}) : t('@astryx.tableGroupedRows.collapseGroup', {
|
|
229
|
+
groupKey: header.groupKey
|
|
230
|
+
}),
|
|
231
|
+
"aria-expanded": !collapsed,
|
|
232
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
233
|
+
...{
|
|
234
|
+
0: {
|
|
235
|
+
className: "x3nfvp2 x11xpdln xx6bhzk"
|
|
236
|
+
},
|
|
237
|
+
1: {
|
|
238
|
+
className: "x3nfvp2 x11xpdln xx6bhzk x1iffjtl"
|
|
239
|
+
}
|
|
240
|
+
}[!!!collapsed << 0],
|
|
241
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
242
|
+
icon: "chevronRight",
|
|
243
|
+
size: "xsm"
|
|
244
|
+
})
|
|
245
|
+
})
|
|
246
|
+
}), content]
|
|
247
|
+
})
|
|
248
|
+
})
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
}), [collapsedGroups, onToggleGroup, renderGroupHeader, t]);
|
|
252
|
+
return {
|
|
253
|
+
plugin,
|
|
254
|
+
data: flattened,
|
|
255
|
+
idKey
|
|
256
|
+
};
|
|
257
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTablePagination.d.ts","sourceRoot":"","sources":["../../../../src/Table/plugins/pagination/useTablePagination.tsx"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"useTablePagination.d.ts","sourceRoot":"","sources":["../../../../src/Table/plugins/pagination/useTablePagination.tsx"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,aAAa,CAAC;AAgC7C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,wBAAwB;IAGvC,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;IAEb,sEAAsE;IACtE,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAIrC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAIlB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAE9C;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAI3B;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;IAE1D;;;OAGG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAEnB;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IAE/C;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;IAInC;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAMD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClE,MAAM,EAAE,wBAAwB,GAC/B,WAAW,CAAC,CAAC,CAAC,CAmGhB"}
|
|
@@ -20,11 +20,12 @@ import * as stylex from '@stylexjs/stylex';
|
|
|
20
20
|
import "../../../theme/tokens.stylex.js";
|
|
21
21
|
import { spacingVars } from "../../../theme/tokens.stylex.js";
|
|
22
22
|
import { Pagination } from "../../../Pagination/index.js";
|
|
23
|
-
import {
|
|
23
|
+
import { useTranslator } from "../../../i18n/index.js";
|
|
24
|
+
|
|
24
25
|
// =============================================================================
|
|
25
26
|
// Styles
|
|
26
27
|
// =============================================================================
|
|
27
|
-
|
|
28
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
28
29
|
const styles = {
|
|
29
30
|
wrapper: {
|
|
30
31
|
k1xSpc: "x78zum5",
|
|
@@ -98,6 +99,7 @@ const styles = {
|
|
|
98
99
|
* ```
|
|
99
100
|
*/
|
|
100
101
|
export function useTablePagination(config) {
|
|
102
|
+
const t = useTranslator();
|
|
101
103
|
const {
|
|
102
104
|
page,
|
|
103
105
|
onPageChange,
|
|
@@ -111,8 +113,9 @@ export function useTablePagination(config) {
|
|
|
111
113
|
size = 'md',
|
|
112
114
|
position = 'below',
|
|
113
115
|
align = 'center',
|
|
114
|
-
label
|
|
116
|
+
label: labelFromProps
|
|
115
117
|
} = config;
|
|
118
|
+
const label = labelFromProps ?? t('@astryx.table.pagination.label');
|
|
116
119
|
|
|
117
120
|
// Same guard as Pagination itself: 0/NaN/negative pageSize would produce an
|
|
118
121
|
// Infinity/NaN totalPages here, which bypasses Pagination's own coercion
|
|
@@ -166,15 +169,15 @@ export function useTablePagination(config) {
|
|
|
166
169
|
if (isSinglePage) {
|
|
167
170
|
return children;
|
|
168
171
|
}
|
|
169
|
-
const makeWrapper = side => /*#__PURE__*/
|
|
172
|
+
const makeWrapper = side => /*#__PURE__*/_jsx("div", {
|
|
170
173
|
...stylex.props(styles.wrapper, side === 'below' && styles.marginTop, side === 'above' && styles.marginBottom, a === 'center' && styles.alignCenter, a === 'end' && styles.alignEnd, a === 'start' && styles.alignStart),
|
|
171
|
-
children: /*#__PURE__*/
|
|
174
|
+
children: /*#__PURE__*/_jsx(Pagination, {
|
|
172
175
|
...props
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
return /*#__PURE__*/
|
|
176
|
+
})
|
|
177
|
+
});
|
|
178
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
176
179
|
children: [(pos === 'above' || pos === 'both') && makeWrapper('above'), children, (pos === 'below' || pos === 'both') && makeWrapper('below')]
|
|
177
|
-
}
|
|
180
|
+
});
|
|
178
181
|
}
|
|
179
182
|
}), []);
|
|
180
183
|
}
|
|
@@ -72,7 +72,7 @@ export interface UseTableRowExpansionStateResult<T extends Record<string, unknow
|
|
|
72
72
|
* computing the expand-all state.
|
|
73
73
|
*
|
|
74
74
|
* @example
|
|
75
|
-
* ```
|
|
75
|
+
* ```
|
|
76
76
|
* const [expandedKeys, setExpandedKeys] = useState<Set<string>>(new Set());
|
|
77
77
|
* const {data, expansionConfig} = useTableRowExpansionState({
|
|
78
78
|
* baseData: tree,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTableRowExpansion.d.ts","sourceRoot":"","sources":["../../../../src/Table/plugins/rowExpansion/useTableRowExpansion.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useTableRowExpansion.d.ts","sourceRoot":"","sources":["../../../../src/Table/plugins/rowExpansion/useTableRowExpansion.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EACV,WAAW,EAKZ,MAAM,aAAa,CAAC;AAMrB;;;;;;;GAOG;AACH,MAAM,WAAW,0BAA0B,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC3E,0CAA0C;IAC1C,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,gDAAgD;IAChD,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,kDAAkD;IAClD,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IAC/B,sEAAsE;IACtE,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;IAC9B,kEAAkE;IAClE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IAC/B,uFAAuF;IACvF,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC;IAC3C;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,GAAG,eAAe,CAAC;IAC1C,2DAA2D;IAC3D,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;CAC/C;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,+BAA+B,CAC9C,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAEjC,mCAAmC;IACnC,QAAQ,EAAE,CAAC,EAAE,CAAC;IACd,qEAAqE;IACrE,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;IAC9B,kDAAkD;IAClD,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IAC/B;;;OAGG;IACH,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC;IAC3C,qDAAqD;IACrD,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,+CAA+C;IAC/C,eAAe,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;CACpE;AAED,MAAM,WAAW,+BAA+B,CAC9C,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAEjC,qEAAqE;IACrE,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,4DAA4D;IAC5D,eAAe,EAAE,0BAA0B,CAAC,CAAC,CAAC,CAAC;CAChD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC3E,QAAQ,EACR,WAAW,EACX,SAAS,EACT,mBAAmB,EACnB,YAAY,EACZ,eAAe,GAChB,EAAE,+BAA+B,CAAC,CAAC,CAAC,GAAG,+BAA+B,CAAC,CAAC,CAAC,CAyHzE;AAuGD,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpE,MAAM,EAAE,0BAA0B,CAAC,CAAC,CAAC,GACpC,WAAW,CAAC,CAAC,CAAC,CA2OhB"}
|
|
@@ -17,6 +17,7 @@ import "../../../theme/tokens.stylex.js";
|
|
|
17
17
|
import { spacingVars, colorVars, radiusVars } from "../../../theme/tokens.stylex.js";
|
|
18
18
|
import { Icon } from "../../../Icon/index.js";
|
|
19
19
|
import { resolveContextActions } from "../../tableContextMenu.js";
|
|
20
|
+
import { useTranslator } from "../../../i18n/index.js";
|
|
20
21
|
|
|
21
22
|
// =============================================================================
|
|
22
23
|
// Config
|
|
@@ -39,7 +40,7 @@ import { resolveContextActions } from "../../tableContextMenu.js";
|
|
|
39
40
|
* plugin needs — the flattened `data`, per-row depth, expand/collapse
|
|
40
41
|
* handlers, and the expand-all toggle state.
|
|
41
42
|
*/
|
|
42
|
-
import {
|
|
43
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
43
44
|
/**
|
|
44
45
|
* Manages row-expansion state and derives the config for
|
|
45
46
|
* {@link useTableRowExpansion}. This is the recommended entry point — it
|
|
@@ -47,7 +48,7 @@ import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
|
|
|
47
48
|
* computing the expand-all state.
|
|
48
49
|
*
|
|
49
50
|
* @example
|
|
50
|
-
* ```
|
|
51
|
+
* ```
|
|
51
52
|
* const [expandedKeys, setExpandedKeys] = useState<Set<string>>(new Set());
|
|
52
53
|
* const {data, expansionConfig} = useTableRowExpansionState({
|
|
53
54
|
* baseData: tree,
|
|
@@ -196,7 +197,7 @@ function ExpansionChevron({
|
|
|
196
197
|
onToggle,
|
|
197
198
|
ariaLabel
|
|
198
199
|
}) {
|
|
199
|
-
return /*#__PURE__*/
|
|
200
|
+
return /*#__PURE__*/_jsx("button", {
|
|
200
201
|
type: "button",
|
|
201
202
|
...{
|
|
202
203
|
className: "x3nfvp2 x6s0dn4 xl56j7k xvy4d1p xxk0z11 xx3sua9 x1ypdohk xv9yike xefglzl xx6bhzk x1717udv x2lah0s x1ilzqfv x1cqbx0l"
|
|
@@ -207,7 +208,7 @@ function ExpansionChevron({
|
|
|
207
208
|
},
|
|
208
209
|
"aria-label": ariaLabel,
|
|
209
210
|
"aria-expanded": isExpanded,
|
|
210
|
-
children: /*#__PURE__*/
|
|
211
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
211
212
|
...{
|
|
212
213
|
0: {
|
|
213
214
|
className: "x3nfvp2 x11xpdln xx6bhzk"
|
|
@@ -216,12 +217,12 @@ function ExpansionChevron({
|
|
|
216
217
|
className: "x3nfvp2 x11xpdln xx6bhzk x1iffjtl"
|
|
217
218
|
}
|
|
218
219
|
}[!!isExpanded << 0],
|
|
219
|
-
children: /*#__PURE__*/
|
|
220
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
220
221
|
icon: "chevronRight",
|
|
221
222
|
size: "xsm"
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
223
|
+
})
|
|
224
|
+
})
|
|
225
|
+
});
|
|
225
226
|
}
|
|
226
227
|
|
|
227
228
|
// =============================================================================
|
|
@@ -229,6 +230,7 @@ function ExpansionChevron({
|
|
|
229
230
|
// =============================================================================
|
|
230
231
|
|
|
231
232
|
export function useTableRowExpansion(config) {
|
|
233
|
+
const t = useTranslator();
|
|
232
234
|
const {
|
|
233
235
|
expandedKeys,
|
|
234
236
|
onToggle,
|
|
@@ -261,13 +263,13 @@ export function useTableRowExpansion(config) {
|
|
|
261
263
|
return null;
|
|
262
264
|
}
|
|
263
265
|
const isExpanded = expandedKeys.has(key);
|
|
264
|
-
return /*#__PURE__*/
|
|
266
|
+
return /*#__PURE__*/_jsx(ExpansionChevron, {
|
|
265
267
|
isExpanded: isExpanded,
|
|
266
268
|
onToggle: () => onToggle(key),
|
|
267
|
-
ariaLabel: isExpanded ? '
|
|
268
|
-
}
|
|
269
|
+
ariaLabel: isExpanded ? t('@astryx.tableRowExpansion.collapseRow') : t('@astryx.tableRowExpansion.expandRow')
|
|
270
|
+
});
|
|
269
271
|
}
|
|
270
|
-
}), [expandedKeys, onToggle, getRowKey, getChildren, getIsItemExpandable, getDepth]);
|
|
272
|
+
}), [expandedKeys, onToggle, getRowKey, getChildren, getIsItemExpandable, getDepth, t]);
|
|
271
273
|
return useMemo(() => ({
|
|
272
274
|
transformColumns(columns) {
|
|
273
275
|
// Track the first user column for indentation.
|
|
@@ -295,19 +297,19 @@ export function useTableRowExpansion(config) {
|
|
|
295
297
|
const key = getRowKey(item);
|
|
296
298
|
const isExpanded = expandedKeys.has(key);
|
|
297
299
|
const expandable = getIsItemExpandable ? getIsItemExpandable(item) : getChildren(item).length > 0;
|
|
298
|
-
const chevron = expandable ? /*#__PURE__*/
|
|
300
|
+
const chevron = expandable ? /*#__PURE__*/_jsx(ExpansionChevron, {
|
|
299
301
|
isExpanded: isExpanded,
|
|
300
302
|
onToggle: () => onToggle(key),
|
|
301
|
-
ariaLabel: isExpanded ? '
|
|
302
|
-
}
|
|
303
|
+
ariaLabel: isExpanded ? t('@astryx.tableRowExpansion.collapseRow') : t('@astryx.tableRowExpansion.expandRow')
|
|
304
|
+
}) : /*#__PURE__*/_jsx("span", {
|
|
303
305
|
...{
|
|
304
306
|
className: "x1rg5ohu xvy4d1p xxk0z11 x2lah0s"
|
|
305
307
|
}
|
|
306
|
-
}
|
|
307
|
-
return /*#__PURE__*/
|
|
308
|
+
});
|
|
309
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
308
310
|
...stylex.props(expansionStyles.indentedCell, indent > 0 && expansionStyles.indent(indent)),
|
|
309
311
|
children: [chevron, originalContent]
|
|
310
|
-
}
|
|
312
|
+
});
|
|
311
313
|
}
|
|
312
314
|
};
|
|
313
315
|
});
|
|
@@ -323,14 +325,14 @@ export function useTableRowExpansion(config) {
|
|
|
323
325
|
const allExpanded = isAllExpanded === true;
|
|
324
326
|
return {
|
|
325
327
|
...props,
|
|
326
|
-
content: /*#__PURE__*/
|
|
328
|
+
content: /*#__PURE__*/_jsx("button", {
|
|
327
329
|
type: "button",
|
|
328
330
|
...{
|
|
329
331
|
className: "x3nfvp2 x6s0dn4 xl56j7k xvy4d1p xxk0z11 xx3sua9 x1ypdohk xv9yike xefglzl xx6bhzk x1717udv x2lah0s x1ilzqfv x1cqbx0l"
|
|
330
332
|
},
|
|
331
333
|
onClick: () => onToggleExpandAll(!allExpanded),
|
|
332
|
-
"aria-label": allExpanded ? '
|
|
333
|
-
children: /*#__PURE__*/
|
|
334
|
+
"aria-label": allExpanded ? t('@astryx.tableRowExpansion.collapseAllRows') : t('@astryx.tableRowExpansion.expandAllRows'),
|
|
335
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
334
336
|
...{
|
|
335
337
|
0: {
|
|
336
338
|
className: "x3nfvp2 x11xpdln xx6bhzk"
|
|
@@ -339,12 +341,12 @@ export function useTableRowExpansion(config) {
|
|
|
339
341
|
className: "x3nfvp2 x11xpdln xx6bhzk x1iffjtl"
|
|
340
342
|
}
|
|
341
343
|
}[!!allExpanded << 0],
|
|
342
|
-
children: /*#__PURE__*/
|
|
344
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
343
345
|
icon: "chevronRight",
|
|
344
346
|
size: "xsm"
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
}
|
|
347
|
+
})
|
|
348
|
+
})
|
|
349
|
+
})
|
|
348
350
|
};
|
|
349
351
|
}
|
|
350
352
|
return {
|
|
@@ -367,11 +369,11 @@ export function useTableRowExpansion(config) {
|
|
|
367
369
|
id: 'row-expansion-toggle',
|
|
368
370
|
group: 'row-expansion',
|
|
369
371
|
label: isExpanded ? 'Collapse row' : 'Expand row',
|
|
370
|
-
icon: /*#__PURE__*/
|
|
372
|
+
icon: /*#__PURE__*/_jsx(Icon, {
|
|
371
373
|
icon: isExpanded ? 'chevronDown' : 'chevronRight',
|
|
372
374
|
size: "xsm",
|
|
373
375
|
"aria-hidden": true
|
|
374
|
-
}
|
|
376
|
+
}),
|
|
375
377
|
onSelect: () => onToggle(key)
|
|
376
378
|
}]
|
|
377
379
|
};
|
|
@@ -394,5 +396,5 @@ export function useTableRowExpansion(config) {
|
|
|
394
396
|
styles: [...props.styles, expansionStyles.clickableRow]
|
|
395
397
|
};
|
|
396
398
|
}
|
|
397
|
-
}), [expandedKeys, getRowKey, onToggle, getChildren, getDepth, getIsItemExpandable, hasRowClickExpansion, isAllExpanded, onToggleExpandAll, expansionColumn]);
|
|
399
|
+
}), [expandedKeys, getRowKey, onToggle, getChildren, getDepth, getIsItemExpandable, hasRowClickExpansion, isAllExpanded, onToggleExpandAll, expansionColumn, t]);
|
|
398
400
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Table/plugins/rowIndex/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AACpD,YAAY,EAAC,sBAAsB,EAAC,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file useTableRowIndex.tsx
|
|
3
|
+
* @input React, StyleX, Table types + the rendered data array
|
|
4
|
+
* @output Exports useTableRowIndex hook + config type
|
|
5
|
+
* @position Row-index plugin; consumed by Table via plugins prop
|
|
6
|
+
*
|
|
7
|
+
* SYNC: When modified, update these files to stay in sync:
|
|
8
|
+
* - /packages/core/src/Table/index.ts (exports)
|
|
9
|
+
*/
|
|
10
|
+
import { type ReactNode } from 'react';
|
|
11
|
+
import type { TablePlugin } from '../../types';
|
|
12
|
+
/**
|
|
13
|
+
* Configuration for {@link useTableRowIndex}.
|
|
14
|
+
*
|
|
15
|
+
* Astryx's `renderCell` receives only the row item (not its position), so the
|
|
16
|
+
* plugin needs the rendered `data` array — the same array passed to
|
|
17
|
+
* `<Table data>` — to derive each row's 1-based ordinal. Pass `getRowKey` when
|
|
18
|
+
* items don't have a stable identity by reference (e.g. new objects each
|
|
19
|
+
* render); it must return a **unique** string per row (duplicate keys collapse
|
|
20
|
+
* to a single ordinal).
|
|
21
|
+
*/
|
|
22
|
+
export interface UseTableRowIndexConfig<T extends Record<string, unknown>> {
|
|
23
|
+
/** The data array currently rendered by the table (post sort/filter/page). */
|
|
24
|
+
data: T[];
|
|
25
|
+
/**
|
|
26
|
+
* Optional key extractor returning a **unique** string per row. When
|
|
27
|
+
* provided, index lookup is keyed by the returned string (stable across new
|
|
28
|
+
* object identities); otherwise items are matched by reference identity.
|
|
29
|
+
* For a stable plugin identity across renders, memoize this with
|
|
30
|
+
* `useCallback`.
|
|
31
|
+
*/
|
|
32
|
+
getRowKey?: (item: T) => string;
|
|
33
|
+
/** Header label for the index column. @default '#' */
|
|
34
|
+
label?: ReactNode;
|
|
35
|
+
/** First index value. @default 1 */
|
|
36
|
+
startFrom?: number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Returns a {@link TablePlugin} that prepends a right-aligned, monospaced
|
|
40
|
+
* row-number column. Numbering follows the order of the rendered `data` array,
|
|
41
|
+
* so it reflects the current sort / filter / pagination view.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```
|
|
45
|
+
* const rowIndex = useTableRowIndex({data});
|
|
46
|
+
* <Table data={data} columns={columns} idKey="id" plugins={{rowIndex}} />;
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function useTableRowIndex<T extends Record<string, unknown>>(config: UseTableRowIndexConfig<T>): TablePlugin<T>;
|
|
50
|
+
//# sourceMappingURL=useTableRowIndex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTableRowIndex.d.ts","sourceRoot":"","sources":["../../../../src/Table/plugins/rowIndex/useTableRowIndex.tsx"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AAEH,OAAO,EAAU,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAI9C,OAAO,KAAK,EAAc,WAAW,EAAC,MAAM,aAAa,CAAC;AAE1D;;;;;;;;;GASG;AACH,MAAM,WAAW,sBAAsB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACvE,8EAA8E;IAC9E,IAAI,EAAE,CAAC,EAAE,CAAC;IACV;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IAChC,sDAAsD;IACtD,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,oCAAoC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAaD;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,MAAM,EAAE,sBAAsB,CAAC,CAAC,CAAC,GAChC,WAAW,CAAC,CAAC,CAAC,CA0ChB"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @file useTableRowIndex.tsx
|
|
7
|
+
* @input React, StyleX, Table types + the rendered data array
|
|
8
|
+
* @output Exports useTableRowIndex hook + config type
|
|
9
|
+
* @position Row-index plugin; consumed by Table via plugins prop
|
|
10
|
+
*
|
|
11
|
+
* SYNC: When modified, update these files to stay in sync:
|
|
12
|
+
* - /packages/core/src/Table/index.ts (exports)
|
|
13
|
+
*/
|
|
14
|
+
import { useMemo } from 'react';
|
|
15
|
+
import * as stylex from '@stylexjs/stylex';
|
|
16
|
+
import "../../../theme/tokens.stylex.js";
|
|
17
|
+
import { colorVars, typeScaleVars } from "../../../theme/tokens.stylex.js";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Configuration for {@link useTableRowIndex}.
|
|
21
|
+
*
|
|
22
|
+
* Astryx's `renderCell` receives only the row item (not its position), so the
|
|
23
|
+
* plugin needs the rendered `data` array — the same array passed to
|
|
24
|
+
* `<Table data>` — to derive each row's 1-based ordinal. Pass `getRowKey` when
|
|
25
|
+
* items don't have a stable identity by reference (e.g. new objects each
|
|
26
|
+
* render); it must return a **unique** string per row (duplicate keys collapse
|
|
27
|
+
* to a single ordinal).
|
|
28
|
+
*/
|
|
29
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
30
|
+
const INDEX_COLUMN_WIDTH = {
|
|
31
|
+
type: 'pixel',
|
|
32
|
+
value: 48
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Returns a {@link TablePlugin} that prepends a right-aligned, monospaced
|
|
36
|
+
* row-number column. Numbering follows the order of the rendered `data` array,
|
|
37
|
+
* so it reflects the current sort / filter / pagination view.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```
|
|
41
|
+
* const rowIndex = useTableRowIndex({data});
|
|
42
|
+
* <Table data={data} columns={columns} idKey="id" plugins={{rowIndex}} />;
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export function useTableRowIndex(config) {
|
|
46
|
+
const {
|
|
47
|
+
data,
|
|
48
|
+
getRowKey,
|
|
49
|
+
label = '#',
|
|
50
|
+
startFrom = 1
|
|
51
|
+
} = config;
|
|
52
|
+
|
|
53
|
+
// Single item → ordinal lookup, built in one pass and rebuilt only when the
|
|
54
|
+
// data array or key extractor changes. Keyed by getRowKey when provided
|
|
55
|
+
// (stable across new object identities), otherwise by object reference.
|
|
56
|
+
const lookup = useMemo(() => {
|
|
57
|
+
const map = new Map();
|
|
58
|
+
for (let i = 0; i < data.length; i++) {
|
|
59
|
+
const item = data[i];
|
|
60
|
+
map.set(getRowKey ? getRowKey(item) : item, i);
|
|
61
|
+
}
|
|
62
|
+
return item => map.get(getRowKey ? getRowKey(item) : item);
|
|
63
|
+
}, [data, getRowKey]);
|
|
64
|
+
|
|
65
|
+
// The plugin object depends only on the stable lookup and the presentational
|
|
66
|
+
// props — not on data directly — so it stays as stable as its inputs allow.
|
|
67
|
+
return useMemo(() => ({
|
|
68
|
+
transformColumns(columns) {
|
|
69
|
+
const indexColumn = {
|
|
70
|
+
key: '__rowIndex',
|
|
71
|
+
header: label,
|
|
72
|
+
width: INDEX_COLUMN_WIDTH,
|
|
73
|
+
align: 'end',
|
|
74
|
+
resizable: false,
|
|
75
|
+
renderCell: item => {
|
|
76
|
+
const idx = lookup(item);
|
|
77
|
+
if (idx == null) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
return /*#__PURE__*/_jsx("span", {
|
|
81
|
+
...{
|
|
82
|
+
className: "x9m5x89 x141an7d xss6m8b xv1l7n4"
|
|
83
|
+
},
|
|
84
|
+
children: idx + startFrom
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
return [indexColumn, ...columns];
|
|
89
|
+
}
|
|
90
|
+
}), [label, startFrom, lookup]);
|
|
91
|
+
}
|