@astryxdesign/core 0.1.3 → 0.1.4-canary.01e5b29
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 +51 -0
- package/dist/AlertDialog/AlertDialog.d.ts +1 -1
- package/dist/AlertDialog/AlertDialog.d.ts.map +1 -1
- package/dist/AlertDialog/AlertDialog.js +20 -18
- package/dist/AlertDialog/useImperativeAlertDialog.js +3 -3
- package/dist/AppShell/AppShell.d.ts +1 -1
- 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.d.ts.map +1 -1
- package/dist/Avatar/Avatar.js +27 -25
- package/dist/Avatar/AvatarStatusDot.js +5 -5
- package/dist/AvatarGroup/AvatarGroup.js +5 -5
- 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 -25
- package/dist/Blockquote/Blockquote.js +7 -7
- package/dist/Breadcrumbs/BreadcrumbItem.js +17 -17
- package/dist/Breadcrumbs/Breadcrumbs.js +7 -7
- package/dist/Button/Button.d.ts.map +1 -1
- package/dist/Button/Button.js +47 -26
- package/dist/ButtonGroup/ButtonGroup.js +7 -7
- package/dist/Calendar/Calendar.d.ts.map +1 -1
- package/dist/Calendar/Calendar.js +108 -64
- package/dist/Calendar/dayCellUtils.d.ts +67 -5
- package/dist/Calendar/dayCellUtils.d.ts.map +1 -1
- package/dist/Calendar/dayCellUtils.js +139 -18
- package/dist/Calendar/styles.d.ts +2 -2
- package/dist/Calendar/styles.d.ts.map +1 -1
- package/dist/Calendar/styles.js +2 -2
- package/dist/Card/Card.d.ts +4 -2
- package/dist/Card/Card.d.ts.map +1 -1
- package/dist/Card/Card.js +18 -10
- package/dist/Carousel/Carousel.d.ts.map +1 -1
- package/dist/Carousel/Carousel.js +20 -19
- package/dist/Center/Center.js +3 -3
- package/dist/Chat/ChatComposer.js +23 -23
- package/dist/Chat/ChatComposerDrawer.js +14 -14
- package/dist/Chat/ChatComposerInput.d.ts.map +1 -1
- package/dist/Chat/ChatComposerInput.js +27 -15
- package/dist/Chat/ChatDictationButton.d.ts +1 -1
- package/dist/Chat/ChatDictationButton.d.ts.map +1 -1
- package/dist/Chat/ChatDictationButton.js +13 -11
- package/dist/Chat/ChatLayout.js +17 -17
- package/dist/Chat/ChatLayoutScrollButton.d.ts +1 -1
- package/dist/Chat/ChatLayoutScrollButton.d.ts.map +1 -1
- package/dist/Chat/ChatLayoutScrollButton.js +12 -10
- package/dist/Chat/ChatMessage.js +12 -12
- package/dist/Chat/ChatMessageBubble.js +7 -7
- package/dist/Chat/ChatMessageList.js +14 -14
- package/dist/Chat/ChatMessageMetadata.d.ts +1 -1
- package/dist/Chat/ChatMessageMetadata.d.ts.map +1 -1
- package/dist/Chat/ChatMessageMetadata.js +14 -12
- package/dist/Chat/ChatPastedTextToken.js +13 -13
- package/dist/Chat/ChatSendButton.js +3 -3
- package/dist/Chat/ChatSystemMessage.d.ts +1 -1
- package/dist/Chat/ChatSystemMessage.d.ts.map +1 -1
- package/dist/Chat/ChatSystemMessage.js +17 -17
- package/dist/Chat/ChatTokenizedText.d.ts +1 -1
- package/dist/Chat/ChatTokenizedText.d.ts.map +1 -1
- package/dist/Chat/ChatTokenizedText.js +24 -15
- package/dist/Chat/ChatToolCalls.d.ts.map +1 -1
- package/dist/Chat/ChatToolCalls.js +81 -74
- package/dist/Chat/index.d.ts +1 -1
- package/dist/Chat/index.d.ts.map +1 -1
- package/dist/Chat/useTriggerMenu.js +15 -15
- package/dist/CheckboxInput/CheckboxInput.d.ts +6 -1
- package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
- package/dist/CheckboxInput/CheckboxInput.js +32 -24
- package/dist/CheckboxList/CheckboxList.js +9 -9
- package/dist/CheckboxList/CheckboxListItem.d.ts +1 -1
- package/dist/CheckboxList/CheckboxListItem.d.ts.map +1 -1
- package/dist/CheckboxList/CheckboxListItem.js +8 -6
- package/dist/Citation/Citation.js +10 -10
- package/dist/ClickableCard/ClickableCard.d.ts.map +1 -1
- package/dist/ClickableCard/ClickableCard.js +32 -9
- package/dist/Code/Code.d.ts +15 -1
- package/dist/Code/Code.d.ts.map +1 -1
- package/dist/Code/Code.js +35 -5
- package/dist/Code/index.d.ts +1 -1
- package/dist/Code/index.d.ts.map +1 -1
- package/dist/CodeBlock/CodeBlock.d.ts +10 -1
- package/dist/CodeBlock/CodeBlock.d.ts.map +1 -1
- package/dist/CodeBlock/CodeBlock.js +88 -52
- package/dist/CodeBlock/index.d.ts +1 -1
- package/dist/CodeBlock/index.d.ts.map +1 -1
- package/dist/Collapsible/Collapsible.d.ts +9 -3
- package/dist/Collapsible/Collapsible.d.ts.map +1 -1
- package/dist/Collapsible/Collapsible.js +110 -22
- package/dist/Collapsible/CollapsibleGroup.d.ts +39 -7
- package/dist/Collapsible/CollapsibleGroup.d.ts.map +1 -1
- package/dist/Collapsible/CollapsibleGroup.js +73 -12
- package/dist/Collapsible/CollapsibleGroupContext.d.ts +31 -0
- package/dist/Collapsible/CollapsibleGroupContext.d.ts.map +1 -1
- package/dist/Collapsible/CollapsibleGroupContext.js +33 -3
- package/dist/Collapsible/index.d.ts +1 -0
- package/dist/Collapsible/index.d.ts.map +1 -1
- package/dist/Collapsible/useCollapsible.d.ts +4 -1
- package/dist/Collapsible/useCollapsible.d.ts.map +1 -1
- package/dist/Collapsible/useCollapsible.js +20 -6
- package/dist/CommandPalette/CommandPalette.d.ts.map +1 -1
- package/dist/CommandPalette/CommandPalette.js +36 -34
- package/dist/CommandPalette/CommandPaletteEmpty.d.ts +1 -1
- package/dist/CommandPalette/CommandPaletteEmpty.d.ts.map +1 -1
- package/dist/CommandPalette/CommandPaletteEmpty.js +27 -7
- package/dist/CommandPalette/CommandPaletteFooter.js +16 -16
- package/dist/CommandPalette/CommandPaletteGroup.js +5 -5
- package/dist/CommandPalette/CommandPaletteInput.js +13 -13
- package/dist/CommandPalette/CommandPaletteItem.js +3 -3
- package/dist/CommandPalette/CommandPaletteList.js +3 -3
- package/dist/ContextMenu/ContextMenu.d.ts +9 -1
- package/dist/ContextMenu/ContextMenu.d.ts.map +1 -1
- package/dist/ContextMenu/ContextMenu.js +16 -11
- package/dist/DateInput/DateInput.js +18 -18
- package/dist/DateRangeInput/DateRangeInput.js +23 -23
- package/dist/DateTimeInput/DateTimeInput.d.ts +5 -7
- package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
- package/dist/DateTimeInput/DateTimeInput.js +30 -26
- package/dist/DateTimeInput/index.d.ts +1 -1
- package/dist/DateTimeInput/index.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +9 -9
- package/dist/Dialog/DialogHeader.js +16 -16
- package/dist/Dialog/useImperativeDialog.js +3 -3
- package/dist/Divider/Divider.d.ts +0 -22
- package/dist/Divider/Divider.d.ts.map +1 -1
- package/dist/Divider/Divider.js +7 -7
- package/dist/DropdownMenu/DropdownMenu.js +10 -10
- package/dist/DropdownMenu/DropdownMenuItem.d.ts +2 -17
- package/dist/DropdownMenu/DropdownMenuItem.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuItem.js +3 -3
- package/dist/DropdownMenu/renderDropdownItems.js +10 -10
- 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.js +29 -29
- package/dist/FormLayout/FormLayout.js +5 -5
- package/dist/Grid/Grid.d.ts +4 -3
- package/dist/Grid/Grid.d.ts.map +1 -1
- package/dist/Grid/Grid.js +29 -12
- 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.d.ts.map +1 -1
- package/dist/Icon/Icon.js +16 -12
- package/dist/Icon/defaultIcons.js +116 -116
- package/dist/IconButton/IconButton.js +3 -3
- package/dist/InputGroup/InputGroup.js +11 -11
- package/dist/InputGroup/InputGroupText.js +3 -3
- package/dist/Item/Item.js +18 -18
- 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 +55 -31
- package/dist/Lightbox/useLightbox.js +3 -3
- package/dist/Link/Link.js +15 -15
- 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 +102 -102
- package/dist/Markdown/parser.d.ts +7 -0
- package/dist/Markdown/parser.d.ts.map +1 -1
- package/dist/Markdown/parser.js +300 -6
- package/dist/MetadataList/MetadataList.js +10 -10
- package/dist/MetadataList/MetadataListItem.js +15 -15
- package/dist/MobileNav/MobileNav.js +15 -15
- package/dist/MobileNav/MobileNavToggle.js +5 -5
- package/dist/MoreMenu/MoreMenu.js +3 -3
- package/dist/MultiSelector/MultiSelector.d.ts +7 -1
- package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
- package/dist/MultiSelector/MultiSelector.js +64 -55
- 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 +48 -32
- package/dist/Outline/Outline.js +15 -15
- 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.js +3 -3
- package/dist/Pagination/Pagination.d.ts +1 -1
- package/dist/Pagination/Pagination.d.ts.map +1 -1
- package/dist/Pagination/Pagination.js +125 -72
- package/dist/Popover/Popover.js +16 -16
- package/dist/Popover/usePopover.js +7 -7
- package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearch.js +110 -92
- package/dist/PowerSearch/PowerSearchEditPopover.js +84 -84
- package/dist/PowerSearch/PowerSearchFilterEditor.js +3 -3
- package/dist/PowerSearch/PowerSearchToken.js +5 -5
- package/dist/PowerSearch/PowerSearchValueEditor.js +54 -54
- package/dist/ProgressBar/ProgressBar.d.ts.map +1 -1
- package/dist/ProgressBar/ProgressBar.js +25 -18
- package/dist/RadioList/RadioList.d.ts +7 -1
- package/dist/RadioList/RadioList.d.ts.map +1 -1
- package/dist/RadioList/RadioList.js +10 -8
- package/dist/RadioList/RadioListItem.d.ts +1 -1
- package/dist/RadioList/RadioListItem.d.ts.map +1 -1
- package/dist/RadioList/RadioListItem.js +30 -22
- package/dist/Resizable/ResizeHandle.d.ts.map +1 -1
- package/dist/Resizable/ResizeHandle.js +28 -10
- package/dist/Section/Section.js +5 -5
- package/dist/SegmentedControl/SegmentedControl.d.ts +1 -1
- package/dist/SegmentedControl/SegmentedControl.d.ts.map +1 -1
- package/dist/SegmentedControl/SegmentedControl.js +32 -10
- package/dist/SegmentedControl/SegmentedControlItem.d.ts +1 -1
- package/dist/SegmentedControl/SegmentedControlItem.d.ts.map +1 -1
- package/dist/SegmentedControl/SegmentedControlItem.js +18 -12
- package/dist/SelectableCard/SelectableCard.js +5 -5
- package/dist/Selector/Selector.d.ts +6 -0
- package/dist/Selector/Selector.d.ts.map +1 -1
- package/dist/Selector/Selector.js +54 -45
- package/dist/Selector/SelectorOption.js +3 -3
- package/dist/SideNav/SideNav.d.ts.map +1 -1
- package/dist/SideNav/SideNav.js +38 -34
- package/dist/SideNav/SideNavCollapseButton.d.ts +1 -1
- package/dist/SideNav/SideNavCollapseButton.d.ts.map +1 -1
- package/dist/SideNav/SideNavCollapseButton.js +8 -6
- package/dist/SideNav/SideNavHeading.js +87 -87
- package/dist/SideNav/SideNavItem.js +42 -42
- package/dist/SideNav/SideNavSection.d.ts +1 -1
- package/dist/SideNav/SideNavSection.d.ts.map +1 -1
- package/dist/SideNav/SideNavSection.js +18 -16
- package/dist/Skeleton/Skeleton.js +3 -3
- package/dist/Slider/Slider.d.ts +6 -0
- package/dist/Slider/Slider.d.ts.map +1 -1
- package/dist/Slider/Slider.js +31 -22
- package/dist/Spinner/Spinner.d.ts.map +1 -1
- package/dist/Spinner/Spinner.js +10 -10
- package/dist/StatusDot/StatusDot.js +5 -5
- package/dist/Switch/Switch.d.ts +13 -4
- package/dist/Switch/Switch.d.ts.map +1 -1
- package/dist/Switch/Switch.js +41 -30
- package/dist/TabList/Tab.js +18 -18
- package/dist/TabList/TabList.js +5 -5
- package/dist/TabList/TabMenu.d.ts.map +1 -1
- package/dist/TabList/TabMenu.js +57 -30
- package/dist/TabList/tab.markers.stylex.d.ts +1 -1
- package/dist/Table/BaseTable.d.ts.map +1 -1
- package/dist/Table/BaseTable.js +51 -39
- package/dist/Table/Table.js +7 -7
- package/dist/Table/TableBody.d.ts +1 -1
- package/dist/Table/TableBody.d.ts.map +1 -1
- package/dist/Table/TableBody.js +9 -5
- package/dist/Table/TableCell.d.ts.map +1 -1
- package/dist/Table/TableCell.js +76 -7
- package/dist/Table/TableFooter.d.ts +1 -1
- package/dist/Table/TableFooter.d.ts.map +1 -1
- package/dist/Table/TableFooter.js +9 -5
- package/dist/Table/TableHeader.d.ts +1 -1
- package/dist/Table/TableHeader.d.ts.map +1 -1
- package/dist/Table/TableHeader.js +9 -5
- package/dist/Table/TableHeaderCell.js +3 -3
- package/dist/Table/TableRow.js +5 -5
- 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.d.ts.map +1 -1
- package/dist/Table/plugins/columnResize/useTableColumnResize.js +14 -11
- package/dist/Table/plugins/filtering/useTableFiltering.js +71 -71
- package/dist/Table/plugins/pagination/paginateData.d.ts.map +1 -1
- package/dist/Table/plugins/pagination/paginateData.js +5 -1
- package/dist/Table/plugins/pagination/useTablePagination.js +7 -7
- package/dist/Table/plugins/rowExpansion/index.d.ts +3 -0
- package/dist/Table/plugins/rowExpansion/index.d.ts.map +1 -0
- package/dist/Table/plugins/rowExpansion/index.js +3 -0
- package/dist/Table/plugins/rowExpansion/useTableRowExpansion.d.ts +90 -0
- package/dist/Table/plugins/rowExpansion/useTableRowExpansion.d.ts.map +1 -0
- package/dist/Table/plugins/rowExpansion/useTableRowExpansion.js +398 -0
- package/dist/Table/plugins/selection/useTableSelection.js +18 -18
- package/dist/Table/plugins/selection/useTableSelectionState.d.ts.map +1 -1
- package/dist/Table/plugins/selection/useTableSelectionState.js +11 -1
- package/dist/Table/plugins/sortable/useTableSortable.js +17 -17
- package/dist/Table/plugins/sortable/useTableSortableState.d.ts.map +1 -1
- package/dist/Table/plugins/sortable/useTableSortableState.js +8 -4
- package/dist/Table/tableContextMenu.d.ts +5 -1
- package/dist/Table/tableContextMenu.d.ts.map +1 -1
- package/dist/Table/tableContextMenu.js +19 -12
- package/dist/Text/Text.d.ts +1 -1
- package/dist/Text/Text.d.ts.map +1 -1
- package/dist/Text/Text.js +14 -13
- package/dist/Text/text.stylex.d.ts +35 -0
- package/dist/Text/text.stylex.d.ts.map +1 -1
- package/dist/Text/text.stylex.js +52 -1
- package/dist/TextArea/TextArea.js +14 -14
- package/dist/TextInput/TextInput.js +15 -15
- package/dist/Thumbnail/Thumbnail.d.ts +3 -2
- package/dist/Thumbnail/Thumbnail.d.ts.map +1 -1
- package/dist/Thumbnail/Thumbnail.js +30 -29
- package/dist/TimeInput/TimeInput.d.ts.map +1 -1
- package/dist/TimeInput/TimeInput.js +26 -21
- package/dist/Timestamp/Timestamp.d.ts +1 -1
- package/dist/Timestamp/Timestamp.d.ts.map +1 -1
- package/dist/Timestamp/Timestamp.js +37 -26
- package/dist/Toast/Toast.d.ts.map +1 -1
- package/dist/Toast/Toast.js +25 -17
- package/dist/Toast/ToastViewport.d.ts.map +1 -1
- package/dist/Toast/ToastViewport.js +23 -11
- 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.js +21 -21
- package/dist/Tokenizer/Tokenizer.d.ts +6 -1
- package/dist/Tokenizer/Tokenizer.d.ts.map +1 -1
- package/dist/Tokenizer/Tokenizer.js +38 -29
- 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.js +32 -32
- package/dist/TopNav/TopNavHeading.js +67 -67
- package/dist/TopNav/TopNavItem.js +5 -5
- package/dist/TopNav/TopNavMegaMenu.js +30 -30
- package/dist/TopNav/TopNavMegaMenuFeaturedCard.d.ts +1 -1
- package/dist/TopNav/TopNavMegaMenuFeaturedCard.d.ts.map +1 -1
- package/dist/TopNav/TopNavMegaMenuFeaturedCard.js +25 -14
- package/dist/TopNav/TopNavMegaMenuItem.js +16 -16
- package/dist/TopNav/TopNavMenu.js +32 -32
- package/dist/TreeList/TreeList.js +8 -8
- package/dist/TreeList/TreeListBranches.js +11 -11
- package/dist/TreeList/TreeListItem.js +30 -30
- package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
- package/dist/Typeahead/BaseTypeahead.js +23 -20
- package/dist/Typeahead/Typeahead.js +12 -12
- package/dist/Typeahead/TypeaheadItem.js +10 -10
- package/dist/VStack/VStack.js +3 -3
- package/dist/astryx.css +23 -0
- package/dist/astryx.umd.js +60 -58
- package/dist/astryx.umd.js.map +4 -4
- package/dist/docs-types.d.ts +13 -1
- package/dist/docs-types.d.ts.map +1 -1
- package/dist/hooks/focusableSelector.d.ts +1 -1
- package/dist/hooks/focusableSelector.d.ts.map +1 -1
- package/dist/hooks/focusableSelector.js +1 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useFocusTrap.d.ts +3 -0
- package/dist/hooks/useFocusTrap.d.ts.map +1 -1
- package/dist/hooks/useFocusTrap.js +38 -1
- package/dist/hooks/useHotkeys.d.ts +51 -0
- package/dist/hooks/useHotkeys.d.ts.map +1 -0
- package/dist/hooks/useHotkeys.js +160 -0
- package/dist/hooks/useInteractiveRole.d.ts +6 -2
- package/dist/hooks/useInteractiveRole.d.ts.map +1 -1
- package/dist/hooks/useInteractiveRole.js +6 -2
- package/dist/hooks/useKeyboardHint.js +9 -9
- package/dist/hooks/useStreamingText.d.ts +3 -1
- package/dist/hooks/useStreamingText.d.ts.map +1 -1
- package/dist/hooks/useStreamingText.js +14 -5
- package/dist/theme/MediaTheme.js +3 -3
- package/dist/theme/Theme.js +7 -7
- package/dist/theme/defineTheme.d.ts +1 -1
- package/dist/theme/defineTheme.d.ts.map +1 -1
- package/dist/theme/expandColorScale.d.ts.map +1 -1
- package/dist/theme/expandColorScale.js +10 -3
- package/dist/theme/hct.d.ts +0 -15
- package/dist/theme/hct.d.ts.map +1 -1
- package/dist/theme/hct.js +9 -9
- package/dist/theme/syntax/SyntaxTheme.js +5 -5
- package/dist/theme/tokens.d.ts +10 -2
- package/dist/theme/tokens.d.ts.map +1 -1
- package/dist/theme/tokens.js +220 -4
- package/dist/utils/color.d.ts +42 -0
- package/dist/utils/color.d.ts.map +1 -0
- package/dist/utils/color.js +150 -0
- package/dist/utils/composeEventHandlers.d.ts +30 -0
- package/dist/utils/composeEventHandlers.d.ts.map +1 -0
- package/dist/utils/composeEventHandlers.js +40 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +3 -1
- package/dist/utils/timeParser.d.ts.map +1 -1
- package/dist/utils/timeParser.js +8 -5
- package/package.json +3 -3
- package/src/AlertDialog/AlertDialog.tsx +2 -0
- package/src/AppShell/AppShell.tsx +2 -0
- package/src/AspectRatio/AspectRatio.doc.mjs +1 -1
- package/src/Avatar/Avatar.doc.mjs +13 -2
- package/src/Avatar/Avatar.test.tsx +32 -1
- package/src/Avatar/Avatar.tsx +12 -20
- package/src/Banner/Banner.doc.mjs +8 -0
- package/src/Banner/Banner.test.tsx +38 -0
- package/src/Banner/Banner.tsx +8 -1
- package/src/Button/Button.tsx +39 -6
- package/src/ButtonGroup/ButtonGroup.doc.mjs +1 -1
- package/src/Calendar/Calendar.doc.mjs +1 -1
- package/src/Calendar/Calendar.test.tsx +201 -17
- package/src/Calendar/Calendar.tsx +79 -26
- package/src/Calendar/dayCellUtils.test.ts +306 -1
- package/src/Calendar/dayCellUtils.ts +206 -13
- package/src/Calendar/styles.ts +12 -2
- package/src/Card/Card.doc.mjs +1 -1
- package/src/Card/Card.tsx +16 -6
- package/src/Carousel/Carousel.doc.mjs +12 -12
- package/src/Carousel/Carousel.test.tsx +13 -0
- package/src/Carousel/Carousel.tsx +1 -0
- package/src/Chat/Chat.doc.mjs +1 -1
- package/src/Chat/ChatComposerInput.test.tsx +24 -0
- package/src/Chat/ChatComposerInput.tsx +17 -1
- package/src/Chat/ChatDictationButton.test.tsx +43 -0
- package/src/Chat/ChatDictationButton.tsx +4 -4
- package/src/Chat/ChatLayoutScrollButton.test.tsx +33 -0
- package/src/Chat/ChatLayoutScrollButton.tsx +3 -1
- package/src/Chat/ChatMessageMetadata.test.tsx +32 -0
- package/src/Chat/ChatMessageMetadata.tsx +4 -6
- package/src/Chat/ChatSystemMessage.test.tsx +26 -11
- package/src/Chat/ChatSystemMessage.tsx +7 -7
- package/src/Chat/ChatTokenizedText.test.tsx +29 -16
- package/src/Chat/ChatTokenizedText.tsx +15 -8
- package/src/Chat/ChatToolCalls.test.tsx +55 -0
- package/src/Chat/ChatToolCalls.tsx +10 -12
- package/src/Chat/index.ts +1 -4
- package/src/Chat/useChatNewMessages.test.tsx +4 -4
- package/src/CheckboxInput/CheckboxInput.doc.mjs +12 -4
- package/src/CheckboxInput/CheckboxInput.test.tsx +103 -0
- package/src/CheckboxInput/CheckboxInput.tsx +13 -0
- package/src/CheckboxList/CheckboxList.doc.mjs +1 -1
- package/src/CheckboxList/CheckboxList.test.tsx +19 -0
- package/src/CheckboxList/CheckboxListItem.tsx +11 -2
- package/src/Citation/Citation.doc.mjs +5 -0
- package/src/ClickableCard/ClickableCard.tsx +45 -2
- package/src/Code/Code.test.tsx +54 -0
- package/src/Code/Code.tsx +48 -4
- package/src/Code/index.ts +1 -1
- package/src/CodeBlock/CodeBlock.doc.mjs +7 -2
- package/src/CodeBlock/CodeBlock.test.tsx +122 -3
- package/src/CodeBlock/CodeBlock.tsx +62 -4
- package/src/CodeBlock/index.ts +1 -1
- package/src/Collapsible/Collapsible.doc.mjs +8 -4
- package/src/Collapsible/Collapsible.test.tsx +405 -0
- package/src/Collapsible/Collapsible.tsx +86 -10
- package/src/Collapsible/CollapsibleGroup.doc.mjs +27 -3
- package/src/Collapsible/CollapsibleGroup.test.tsx +318 -0
- package/src/Collapsible/CollapsibleGroup.tsx +107 -9
- package/src/Collapsible/CollapsibleGroupContext.tsx +42 -2
- package/src/Collapsible/index.ts +4 -0
- package/src/Collapsible/useCollapsible.ts +20 -6
- package/src/CommandPalette/CommandPalette.tsx +5 -3
- package/src/CommandPalette/CommandPaletteEmpty.doc.mjs +5 -0
- package/src/CommandPalette/CommandPaletteEmpty.tsx +15 -1
- package/src/CommandPalette/CommandPaletteGroup.doc.mjs +10 -0
- package/src/CommandPalette/CommandPaletteInput.doc.mjs +6 -0
- package/src/CommandPalette/CommandPaletteItem.doc.mjs +6 -0
- package/src/CommandPalette/CommandPaletteList.doc.mjs +9 -0
- package/src/ContextMenu/ContextMenu.doc.mjs +15 -0
- package/src/ContextMenu/ContextMenu.test.tsx +15 -0
- package/src/ContextMenu/ContextMenu.tsx +19 -1
- package/src/ContextMenu/ContextMenuItem.doc.mjs +6 -0
- package/src/DateInput/DateInput.doc.mjs +6 -1
- package/src/DateInput/DateInput.test.tsx +11 -20
- package/src/DateRangeInput/DateRangeInput.doc.mjs +1 -1
- package/src/DateRangeInput/DateRangeInput.test.tsx +31 -44
- package/src/DateRangeInput/DateRangeInput.tsx +2 -2
- package/src/DateTimeInput/DateTimeInput.doc.mjs +4 -3
- package/src/DateTimeInput/DateTimeInput.test.tsx +118 -16
- package/src/DateTimeInput/DateTimeInput.tsx +9 -8
- package/src/DateTimeInput/index.ts +1 -0
- package/src/Dialog/DialogHeader.doc.mjs +45 -0
- package/src/Divider/Divider.tsx +1 -23
- package/src/DropdownMenu/DropdownMenu.doc.mjs +1 -1
- package/src/DropdownMenu/DropdownMenu.test.tsx +5 -3
- package/src/DropdownMenu/DropdownMenuItem.tsx +5 -17
- package/src/EmptyState/EmptyState.doc.mjs +1 -1
- package/src/Field/Field.doc.mjs +1 -1
- package/src/Field/FieldLabel.test.tsx +2 -2
- package/src/FieldStatus/FieldStatus.test.tsx +282 -0
- package/src/FileInput/FileInput.doc.mjs +1 -1
- package/src/FormLayout/__snapshots__/FormLayout.test.tsx.snap +0 -3
- package/src/Grid/Grid.doc.mjs +3 -3
- package/src/Grid/Grid.test.tsx +43 -18
- package/src/Grid/Grid.tsx +26 -9
- package/src/Icon/Icon.test.tsx +41 -29
- package/src/Icon/Icon.tsx +6 -2
- package/src/InputGroup/InputGroup.tsx +2 -2
- package/src/InteractiveRoleContext/InteractiveRoleContext.test.tsx +185 -0
- package/src/Item/Item.tsx +1 -1
- package/src/Layout/Layout.test.tsx +285 -0
- package/src/Layout/LayoutContent.doc.mjs +12 -0
- package/src/Layout/LayoutPanel.doc.mjs +40 -0
- package/src/Layout/LayoutSlots.test.tsx +364 -0
- package/src/Layout/__tests__/edgeCompensation.test.tsx +72 -0
- package/src/Lightbox/Lightbox.doc.mjs +5 -0
- package/src/Lightbox/Lightbox.test.tsx +123 -2
- package/src/Lightbox/Lightbox.tsx +29 -1
- package/src/Markdown/Markdown.test.tsx +23 -0
- package/src/Markdown/Markdown.tsx +9 -7
- package/src/Markdown/incremental.test.ts +36 -0
- package/src/Markdown/parser.perf.test.ts +34 -12
- package/src/Markdown/parser.test.ts +210 -0
- package/src/Markdown/parser.ts +301 -6
- package/src/MobileNav/MobileNav.doc.mjs +20 -0
- package/src/MultiSelector/MultiSelector.doc.mjs +14 -1
- package/src/MultiSelector/MultiSelector.test.tsx +33 -0
- package/src/MultiSelector/MultiSelector.tsx +20 -0
- package/src/NavMenu/NavMenu.doc.mjs +15 -0
- package/src/NumberInput/NumberInput.test.tsx +48 -3
- package/src/NumberInput/NumberInput.tsx +32 -15
- package/src/Outline/parseOutlineFromMarkdown.test.ts +80 -0
- package/src/OverflowList/OverflowList.test.tsx +416 -0
- package/src/Overlay/Overlay.doc.mjs +6 -0
- package/src/Overlay/Overlay.test.tsx +356 -0
- package/src/Pagination/Pagination.test.tsx +162 -0
- package/src/Pagination/Pagination.tsx +80 -26
- package/src/Popover/Popover.test.tsx +65 -0
- package/src/PowerSearch/PowerSearch.doc.mjs +4 -4
- package/src/PowerSearch/PowerSearch.test.tsx +109 -1
- package/src/PowerSearch/PowerSearch.tsx +37 -16
- package/src/ProgressBar/ProgressBar.test.tsx +30 -0
- package/src/ProgressBar/ProgressBar.tsx +12 -5
- package/src/RadioList/RadioList.doc.mjs +7 -1
- package/src/RadioList/RadioList.test.tsx +65 -0
- package/src/RadioList/RadioList.tsx +10 -1
- package/src/RadioList/RadioListItem.tsx +13 -4
- package/src/Resizable/ResizeHandle.test.tsx +218 -0
- package/src/Resizable/ResizeHandle.tsx +22 -4
- package/src/Section/Section.test.tsx +4 -10
- package/src/SegmentedControl/SegmentedControl.doc.mjs +2 -2
- package/src/SegmentedControl/SegmentedControl.test.tsx +192 -0
- package/src/SegmentedControl/SegmentedControl.tsx +27 -5
- package/src/SegmentedControl/SegmentedControlItem.tsx +9 -4
- package/src/SelectableCard/SelectableCard.doc.mjs +1 -1
- package/src/Selector/Selector.doc.mjs +12 -1
- package/src/Selector/Selector.test.tsx +30 -0
- package/src/Selector/Selector.tsx +18 -0
- package/src/SideNav/SideNav.doc.mjs +7 -1
- package/src/SideNav/SideNav.test.tsx +66 -0
- package/src/SideNav/SideNav.tsx +6 -2
- package/src/SideNav/SideNavCollapseButton.tsx +4 -3
- package/src/SideNav/SideNavSection.tsx +6 -4
- package/src/SizeContext/SizeContext.test.tsx +226 -0
- package/src/Slider/Slider.doc.mjs +14 -2
- package/src/Slider/Slider.test.tsx +30 -0
- package/src/Slider/Slider.tsx +20 -0
- package/src/Spinner/Spinner.tsx +1 -0
- package/src/Switch/Switch.doc.mjs +21 -9
- package/src/Switch/Switch.test.tsx +137 -0
- package/src/Switch/Switch.tsx +32 -7
- package/src/TabList/TabList.doc.mjs +3 -3
- package/src/TabList/TabList.test.tsx +185 -1
- package/src/TabList/TabMenu.tsx +45 -9
- package/src/Table/BaseTable.tsx +16 -3
- package/src/Table/Table.test.tsx +87 -0
- package/src/Table/TableBody.tsx +15 -2
- package/src/Table/TableCell.tsx +87 -8
- package/src/Table/TableFooter.tsx +15 -2
- package/src/Table/TableHeader.tsx +15 -2
- package/src/Table/index.ts +5 -0
- package/src/Table/plugins/columnResize/useTableColumnResize.test.tsx +13 -0
- package/src/Table/plugins/columnResize/useTableColumnResize.tsx +3 -1
- package/src/Table/plugins/pagination/paginateData.ts +5 -1
- package/src/Table/plugins/pagination/useTablePagination.test.tsx +13 -0
- package/src/Table/plugins/rowExpansion/index.ts +7 -0
- package/src/Table/plugins/rowExpansion/useTableRowExpansion.test.tsx +155 -0
- package/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx +590 -0
- package/src/Table/plugins/selection/useTableSelectionState.test.tsx +23 -0
- package/src/Table/plugins/selection/useTableSelectionState.tsx +11 -6
- package/src/Table/plugins/sortable/useTableSortableState.test.tsx +35 -1
- package/src/Table/plugins/sortable/useTableSortableState.tsx +8 -4
- package/src/Table/tableContextMenu.test.tsx +27 -3
- package/src/Table/tableContextMenu.tsx +20 -2
- package/src/Table/useTablePagination.doc.mjs +4 -1
- package/src/Table/useTableRowExpansion.doc.mjs +80 -0
- package/src/Table/useTableSortable.doc.mjs +4 -1
- package/src/Text/Text.doc.mjs +2 -2
- package/src/Text/Text.test.tsx +11 -0
- package/src/Text/Text.tsx +4 -2
- package/src/Text/text.stylex.ts +41 -0
- package/src/TextArea/TextArea.doc.mjs +1 -1
- package/src/TextArea/TextArea.test.tsx +3 -3
- package/src/TextInput/TextInput.doc.mjs +1 -1
- package/src/TextInput/TextInput.test.tsx +3 -3
- package/src/Thumbnail/Thumbnail.test.tsx +36 -2
- package/src/Thumbnail/Thumbnail.tsx +4 -2
- package/src/TimeInput/TimeInput.doc.mjs +11 -6
- package/src/TimeInput/TimeInput.test.tsx +37 -0
- package/src/TimeInput/TimeInput.tsx +11 -1
- package/src/Timestamp/Timestamp.doc.mjs +1 -1
- package/src/Timestamp/Timestamp.test.tsx +52 -0
- package/src/Timestamp/Timestamp.tsx +30 -16
- package/src/Toast/Toast.tsx +11 -3
- package/src/Toast/ToastViewport.test.tsx +64 -0
- package/src/Toast/ToastViewport.tsx +12 -0
- package/src/ToggleButton/ToggleButton.doc.mjs +1 -0
- package/src/Tokenizer/Tokenizer.doc.mjs +16 -4
- package/src/Tokenizer/Tokenizer.test.tsx +33 -0
- package/src/Tokenizer/Tokenizer.tsx +19 -0
- package/src/Toolbar/Toolbar.test.tsx +1 -1
- package/src/TopNav/TopNav.doc.mjs +1 -1
- package/src/TopNav/TopNav.test.tsx +18 -0
- package/src/TopNav/TopNavMegaMenuFeaturedCard.tsx +9 -2
- package/src/TreeList/TreeList.doc.mjs +2 -2
- package/src/Typeahead/BaseTypeahead.doc.mjs +19 -0
- package/src/Typeahead/BaseTypeahead.tsx +5 -2
- package/src/Typeahead/Typeahead.doc.mjs +7 -2
- package/src/Typeahead/Typeahead.test.tsx +45 -1
- package/src/__tests__/TestIcon.tsx +26 -0
- package/src/__tests__/fastRoleQueries.ts +66 -0
- package/src/docPropReferences.test.ts +178 -0
- package/src/docs-types.ts +14 -0
- package/src/hooks/focusableSelector.ts +1 -1
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useFocusTrap.doc.mjs +4 -2
- package/src/hooks/useFocusTrap.test.tsx +149 -1
- package/src/hooks/useFocusTrap.ts +50 -1
- package/src/hooks/useHotkeys.doc.mjs +52 -0
- package/src/hooks/useHotkeys.test.ts +245 -0
- package/src/hooks/useHotkeys.ts +203 -0
- package/src/hooks/useInteractiveRole.ts +12 -4
- package/src/hooks/useKeyboardHint.doc.mjs +6 -6
- package/src/hooks/useStreamingText.test.ts +54 -19
- package/src/hooks/useStreamingText.ts +16 -5
- package/src/theme/SyntaxTheme.doc.mjs +4 -4
- package/src/theme/defineTheme.ts +4 -13
- package/src/theme/derivedVarRegistry.test.ts +2 -2
- package/src/theme/expandColorScale.test.ts +29 -0
- package/src/theme/expandColorScale.ts +11 -6
- package/src/theme/hct.ts +9 -17
- package/src/theme/tokens.test.ts +182 -9
- package/src/theme/tokens.ts +239 -4
- package/src/theme/useTheme.test.tsx +20 -0
- package/src/utils/color.test.ts +133 -0
- package/src/utils/color.ts +148 -0
- package/src/utils/composeEventHandlers.test.ts +71 -0
- package/src/utils/composeEventHandlers.ts +44 -0
- package/src/utils/index.ts +4 -0
- package/src/utils/mergeProps.test.ts +166 -0
- package/src/utils/sharedResizeObserver.test.ts +2 -2
- package/src/utils/timeParser.test.ts +13 -0
- package/src/utils/timeParser.ts +8 -5
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* for builders to wire up.
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
import React, {useState, useCallback, type ReactNode} from 'react';
|
|
21
|
+
import React, {useState, useCallback, useId, type ReactNode} from 'react';
|
|
22
22
|
import type {BaseProps} from '../BaseProps';
|
|
23
23
|
import * as stylex from '@stylexjs/stylex';
|
|
24
24
|
import {
|
|
@@ -41,11 +41,7 @@ import {themeProps} from '../utils/themeProps';
|
|
|
41
41
|
// Types
|
|
42
42
|
// =============================================================================
|
|
43
43
|
|
|
44
|
-
export type ChatToolCallStatus =
|
|
45
|
-
| 'pending'
|
|
46
|
-
| 'running'
|
|
47
|
-
| 'complete'
|
|
48
|
-
| 'error';
|
|
44
|
+
export type ChatToolCallStatus = 'pending' | 'running' | 'complete' | 'error';
|
|
49
45
|
|
|
50
46
|
export interface ChatToolCallItem {
|
|
51
47
|
/** Tool/function name. */
|
|
@@ -356,6 +352,7 @@ function CallRow({call}: {call: ChatToolCallItem}) {
|
|
|
356
352
|
const status = call.status ?? 'complete';
|
|
357
353
|
const hasDetail = call.resultDetail != null;
|
|
358
354
|
const [isDetailOpen, setIsDetailOpen] = useState(false);
|
|
355
|
+
const detailId = useId();
|
|
359
356
|
|
|
360
357
|
const toggleDetail = hasDetail
|
|
361
358
|
? () => setIsDetailOpen(prev => !prev)
|
|
@@ -365,6 +362,8 @@ function CallRow({call}: {call: ChatToolCallItem}) {
|
|
|
365
362
|
<div
|
|
366
363
|
role={hasDetail ? 'button' : undefined}
|
|
367
364
|
tabIndex={hasDetail ? 0 : undefined}
|
|
365
|
+
aria-expanded={hasDetail ? isDetailOpen : undefined}
|
|
366
|
+
aria-controls={hasDetail && isDetailOpen ? detailId : undefined}
|
|
368
367
|
onClick={toggleDetail}
|
|
369
368
|
onKeyDown={
|
|
370
369
|
hasDetail
|
|
@@ -399,11 +398,7 @@ function CallRow({call}: {call: ChatToolCallItem}) {
|
|
|
399
398
|
</span>
|
|
400
399
|
<span {...stylex.props(styles.callName)}>{call.name}</span>
|
|
401
400
|
{call.node != null && (
|
|
402
|
-
<Badge
|
|
403
|
-
label={call.node}
|
|
404
|
-
variant="neutral"
|
|
405
|
-
xstyle={styles.nodePill}
|
|
406
|
-
/>
|
|
401
|
+
<Badge label={call.node} variant="neutral" xstyle={styles.nodePill} />
|
|
407
402
|
)}
|
|
408
403
|
{call.target != null && (
|
|
409
404
|
<span {...stylex.props(styles.callLabel)}>{call.target}</span>
|
|
@@ -448,7 +443,7 @@ function CallRow({call}: {call: ChatToolCallItem}) {
|
|
|
448
443
|
<div>
|
|
449
444
|
{row}
|
|
450
445
|
{isDetailOpen && (
|
|
451
|
-
<div {...stylex.props(styles.callDetailContent)}>
|
|
446
|
+
<div id={detailId} {...stylex.props(styles.callDetailContent)}>
|
|
452
447
|
{call.resultDetail}
|
|
453
448
|
</div>
|
|
454
449
|
)}
|
|
@@ -497,6 +492,7 @@ export function ChatToolCalls(props: ChatToolCallsProps) {
|
|
|
497
492
|
|
|
498
493
|
const autoDefault = defaultIsExpanded ?? false;
|
|
499
494
|
const [internalExpanded, setInternalExpanded] = useState(autoDefault);
|
|
495
|
+
const contentId = useId();
|
|
500
496
|
const isControlled = controlledExpanded !== undefined;
|
|
501
497
|
const isExpanded = isControlled ? controlledExpanded : internalExpanded;
|
|
502
498
|
|
|
@@ -548,6 +544,7 @@ export function ChatToolCalls(props: ChatToolCallsProps) {
|
|
|
548
544
|
role="button"
|
|
549
545
|
tabIndex={0}
|
|
550
546
|
aria-expanded={isExpanded}
|
|
547
|
+
aria-controls={contentId}
|
|
551
548
|
onClick={toggle}
|
|
552
549
|
onKeyDown={e => {
|
|
553
550
|
if (e.key === 'Enter' || e.key === ' ') {
|
|
@@ -613,6 +610,7 @@ export function ChatToolCalls(props: ChatToolCallsProps) {
|
|
|
613
610
|
|
|
614
611
|
{/* Expanded: all calls with full metadata */}
|
|
615
612
|
<div
|
|
613
|
+
id={contentId}
|
|
616
614
|
{...stylex.props(
|
|
617
615
|
styles.groupContent,
|
|
618
616
|
isExpanded && styles.groupContentExpanded,
|
package/src/Chat/index.ts
CHANGED
|
@@ -21,10 +21,7 @@ export type {ChatSendButtonProps} from './ChatSendButton';
|
|
|
21
21
|
export {ChatComposerDrawer} from './ChatComposerDrawer';
|
|
22
22
|
export type {ChatComposerDrawerProps} from './ChatComposerDrawer';
|
|
23
23
|
|
|
24
|
-
export {
|
|
25
|
-
ChatComposerInput,
|
|
26
|
-
ChatComposerTokenElement,
|
|
27
|
-
} from './ChatComposerInput';
|
|
24
|
+
export {ChatComposerInput, ChatComposerTokenElement} from './ChatComposerInput';
|
|
28
25
|
export type {
|
|
29
26
|
ChatComposerInputProps,
|
|
30
27
|
ChatComposerInputHandle,
|
|
@@ -64,7 +64,7 @@ describe('useChatNewMessages — callback ref (issue #2282)', () => {
|
|
|
64
64
|
const {contentRef} = useChatNewMessages({isLocked: true, onResize});
|
|
65
65
|
return (
|
|
66
66
|
<div ref={contentRef} data-testid="content">
|
|
67
|
-
<div className="
|
|
67
|
+
<div className="astryx-chat-message">msg</div>
|
|
68
68
|
</div>
|
|
69
69
|
);
|
|
70
70
|
}
|
|
@@ -91,7 +91,7 @@ describe('useChatNewMessages — callback ref (issue #2282)', () => {
|
|
|
91
91
|
</button>
|
|
92
92
|
{mounted && (
|
|
93
93
|
<div ref={contentRef} data-testid="content">
|
|
94
|
-
<div className="
|
|
94
|
+
<div className="astryx-chat-message">msg</div>
|
|
95
95
|
</div>
|
|
96
96
|
)}
|
|
97
97
|
</>
|
|
@@ -129,7 +129,7 @@ describe('useChatNewMessages — callback ref (issue #2282)', () => {
|
|
|
129
129
|
</button>
|
|
130
130
|
{mounted && (
|
|
131
131
|
<div ref={contentRef} data-testid="content">
|
|
132
|
-
<div className="
|
|
132
|
+
<div className="astryx-chat-message">msg</div>
|
|
133
133
|
</div>
|
|
134
134
|
)}
|
|
135
135
|
</>
|
|
@@ -198,7 +198,7 @@ describe('useChatNewMessages — callback ref (issue #2282)', () => {
|
|
|
198
198
|
if (!el.querySelector?.('.astryx-chat-message')) {
|
|
199
199
|
return false;
|
|
200
200
|
}
|
|
201
|
-
if (el.className?.includes('
|
|
201
|
+
if (el.className?.includes('astryx-chat-layout')) {
|
|
202
202
|
return false;
|
|
203
203
|
}
|
|
204
204
|
return true;
|
|
@@ -63,11 +63,17 @@ export const docs = {
|
|
|
63
63
|
description: 'Whether the checkbox is disabled.',
|
|
64
64
|
default: 'false',
|
|
65
65
|
},
|
|
66
|
+
{
|
|
67
|
+
name: 'htmlName',
|
|
68
|
+
type: 'string',
|
|
69
|
+
description:
|
|
70
|
+
'The HTML name attribute for the underlying checkbox input, useful for form submissions (submits "on" when checked).',
|
|
71
|
+
},
|
|
66
72
|
{
|
|
67
73
|
name: 'disabledMessage',
|
|
68
74
|
type: 'string',
|
|
69
75
|
description:
|
|
70
|
-
'Explains why the checkbox is disabled. With isDisabled, shows a tooltip on hover/keyboard focus and keeps the checkbox focusable via aria-disabled (toggling stays blocked). Use this instead of wrapping a disabled CheckboxInput in Tooltip
|
|
76
|
+
'Explains why the checkbox is disabled. With isDisabled, shows a tooltip on hover/keyboard focus and keeps the checkbox focusable via aria-disabled (toggling stays blocked). Use this instead of wrapping a disabled CheckboxInput in Tooltip. Disabled controls swallow the hover events an external Tooltip needs.',
|
|
71
77
|
},
|
|
72
78
|
{
|
|
73
79
|
name: 'isReadOnly',
|
|
@@ -119,7 +125,7 @@ export const docs = {
|
|
|
119
125
|
theming: {
|
|
120
126
|
targets: [
|
|
121
127
|
{className: 'astryx-checkbox-input', visualProps: ['size']},
|
|
122
|
-
{className: 'astryx-checkbox'},
|
|
128
|
+
{className: 'astryx-checkbox', visualProps: ['size'], states: ['checked', 'disabled']},
|
|
123
129
|
],
|
|
124
130
|
},
|
|
125
131
|
usage: {
|
|
@@ -171,7 +177,8 @@ export const docsZh = {
|
|
|
171
177
|
},
|
|
172
178
|
{name: 'isLoading', type: 'boolean', description: '复选框是否处于加载状态。显示旋转器并阻止交互。', default: 'false'},
|
|
173
179
|
{name: 'isDisabled', type: 'boolean', description: '复选框是否禁用。', default: 'false'},
|
|
174
|
-
{name: '
|
|
180
|
+
{name: 'htmlName', type: 'string', description: '底层复选框输入的 HTML name 属性,用于表单提交(勾选时提交 "on")。'},
|
|
181
|
+
{name: 'disabledMessage', type: 'string', description: 'Explains why the checkbox is disabled. With isDisabled, shows a tooltip on hover/keyboard focus and keeps the checkbox focusable via aria-disabled (toggling stays blocked). Use this instead of wrapping a disabled CheckboxInput in Tooltip: disabled controls swallow the hover events an external Tooltip needs.'},
|
|
175
182
|
{name: 'isReadOnly', type: 'boolean', description: '复选框是否为只读。以完整不透明度显示当前状态但阻止交互。与 isDisabled 不同,只读复选框不会变暗。', default: 'false'},
|
|
176
183
|
{name: 'isOptional', type: 'boolean', description: '字段是否可选。与 isRequired 互斥。', default: 'false'},
|
|
177
184
|
{name: 'isRequired', type: 'boolean', description: '复选框是否必填。与 isOptional 互斥。', default: 'false'},
|
|
@@ -193,7 +200,7 @@ export const docsZh = {
|
|
|
193
200
|
'size',
|
|
194
201
|
],
|
|
195
202
|
},
|
|
196
|
-
{className: 'astryx-checkbox'},
|
|
203
|
+
{className: 'astryx-checkbox', visualProps: ['size'], states: ['checked', 'disabled']},
|
|
197
204
|
],
|
|
198
205
|
},
|
|
199
206
|
};
|
|
@@ -222,6 +229,7 @@ export const docsDense = {
|
|
|
222
229
|
changeAction: 'async action; fires after onChange, shows spinner while pending',
|
|
223
230
|
isLoading: 'shows spinner + prevents interaction',
|
|
224
231
|
isDisabled: 'disable checkbox',
|
|
232
|
+
htmlName: 'HTML name attr for the checkbox; submits "on" when checked.',
|
|
225
233
|
isOptional: 'mark field as optional (mutually exclusive w/ isRequired)',
|
|
226
234
|
isRequired: 'mark field as required (mutually exclusive w/ isOptional)',
|
|
227
235
|
size: 'sm (compact) or md (default)',
|
|
@@ -167,6 +167,59 @@ describe('CheckboxInput', () => {
|
|
|
167
167
|
expect(handleChange).not.toHaveBeenCalled();
|
|
168
168
|
});
|
|
169
169
|
|
|
170
|
+
it('forwards data-testid to the input', () => {
|
|
171
|
+
render(
|
|
172
|
+
<CheckboxInput
|
|
173
|
+
label="Accept terms"
|
|
174
|
+
value={false}
|
|
175
|
+
onChange={() => {}}
|
|
176
|
+
data-testid="accept-terms-checkbox"
|
|
177
|
+
/>,
|
|
178
|
+
);
|
|
179
|
+
expect(screen.getByTestId('accept-terms-checkbox')).toBe(
|
|
180
|
+
screen.getByRole('checkbox'),
|
|
181
|
+
);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it('forwards arbitrary data-* attributes to the input', () => {
|
|
185
|
+
render(
|
|
186
|
+
<CheckboxInput
|
|
187
|
+
label="Accept terms"
|
|
188
|
+
value={false}
|
|
189
|
+
onChange={() => {}}
|
|
190
|
+
data-tracking-id="checkbox-42"
|
|
191
|
+
/>,
|
|
192
|
+
);
|
|
193
|
+
expect(screen.getByRole('checkbox')).toHaveAttribute(
|
|
194
|
+
'data-tracking-id',
|
|
195
|
+
'checkbox-42',
|
|
196
|
+
);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('does not let rest props override checked, disabled, or type', () => {
|
|
200
|
+
// Not part of CheckboxInputProps; spread (rather than named attributes)
|
|
201
|
+
// to sidestep JSX excess-property checks the same way a real caller's
|
|
202
|
+
// spread rest-props object would arrive untyped at runtime.
|
|
203
|
+
const foreignAttrs: Record<string, unknown> = {
|
|
204
|
+
checked: false,
|
|
205
|
+
disabled: false,
|
|
206
|
+
type: 'text',
|
|
207
|
+
};
|
|
208
|
+
render(
|
|
209
|
+
<CheckboxInput
|
|
210
|
+
{...foreignAttrs}
|
|
211
|
+
label="Accept terms"
|
|
212
|
+
value={true}
|
|
213
|
+
onChange={() => {}}
|
|
214
|
+
isDisabled
|
|
215
|
+
/>,
|
|
216
|
+
);
|
|
217
|
+
const checkbox = screen.getByRole('checkbox');
|
|
218
|
+
expect(checkbox).toBeChecked();
|
|
219
|
+
expect(checkbox).toBeDisabled();
|
|
220
|
+
expect(checkbox).toHaveAttribute('type', 'checkbox');
|
|
221
|
+
});
|
|
222
|
+
|
|
170
223
|
it('forwards ref correctly', () => {
|
|
171
224
|
const ref = vi.fn();
|
|
172
225
|
render(
|
|
@@ -392,4 +445,54 @@ describe('CheckboxInput', () => {
|
|
|
392
445
|
expect(screen.getByRole('checkbox')).toBeDisabled();
|
|
393
446
|
});
|
|
394
447
|
});
|
|
448
|
+
describe('form participation', () => {
|
|
449
|
+
it('submits under htmlName when checked', () => {
|
|
450
|
+
const {container} = render(
|
|
451
|
+
<form>
|
|
452
|
+
<CheckboxInput
|
|
453
|
+
label="Terms"
|
|
454
|
+
htmlName="terms"
|
|
455
|
+
value={true}
|
|
456
|
+
onChange={() => {}}
|
|
457
|
+
/>
|
|
458
|
+
</form>,
|
|
459
|
+
);
|
|
460
|
+
const data = new FormData(container.querySelector('form')!);
|
|
461
|
+
expect(data.get('terms')).toBe('on');
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
it('is excluded from form data when disabled, even with a disabledMessage', () => {
|
|
465
|
+
const {container} = render(
|
|
466
|
+
<form>
|
|
467
|
+
<CheckboxInput
|
|
468
|
+
label="Terms"
|
|
469
|
+
htmlName="terms"
|
|
470
|
+
value={true}
|
|
471
|
+
onChange={() => {}}
|
|
472
|
+
isDisabled
|
|
473
|
+
disabledMessage="Locked"
|
|
474
|
+
/>
|
|
475
|
+
</form>,
|
|
476
|
+
);
|
|
477
|
+
expect([
|
|
478
|
+
...new FormData(container.querySelector('form')!).keys(),
|
|
479
|
+
]).toEqual([]);
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
it('submits nothing when unchecked', () => {
|
|
483
|
+
const {container} = render(
|
|
484
|
+
<form>
|
|
485
|
+
<CheckboxInput
|
|
486
|
+
label="Terms"
|
|
487
|
+
htmlName="terms"
|
|
488
|
+
value={false}
|
|
489
|
+
onChange={() => {}}
|
|
490
|
+
/>
|
|
491
|
+
</form>,
|
|
492
|
+
);
|
|
493
|
+
expect([
|
|
494
|
+
...new FormData(container.querySelector('form')!).keys(),
|
|
495
|
+
]).toEqual([]);
|
|
496
|
+
});
|
|
497
|
+
});
|
|
395
498
|
});
|
|
@@ -272,6 +272,12 @@ export interface CheckboxInputProps extends Omit<BaseProps, 'onChange'> {
|
|
|
272
272
|
* @default false
|
|
273
273
|
*/
|
|
274
274
|
isDisabled?: boolean;
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* The HTML name attribute for the underlying checkbox input.
|
|
278
|
+
* Useful for form submissions.
|
|
279
|
+
*/
|
|
280
|
+
htmlName?: string;
|
|
275
281
|
/**
|
|
276
282
|
* Explains why the checkbox is disabled. When set together with
|
|
277
283
|
* `isDisabled`, the checkbox shows a tooltip with this text on hover and
|
|
@@ -374,6 +380,7 @@ export function CheckboxInput({
|
|
|
374
380
|
isLoading = false,
|
|
375
381
|
value,
|
|
376
382
|
isDisabled = false,
|
|
383
|
+
htmlName,
|
|
377
384
|
disabledMessage,
|
|
378
385
|
isReadOnly = false,
|
|
379
386
|
isOptional = false,
|
|
@@ -388,6 +395,7 @@ export function CheckboxInput({
|
|
|
388
395
|
className,
|
|
389
396
|
style,
|
|
390
397
|
ref,
|
|
398
|
+
...rest
|
|
391
399
|
}: CheckboxInputProps) {
|
|
392
400
|
const id = useId();
|
|
393
401
|
const descriptionID = useId();
|
|
@@ -477,6 +485,7 @@ export function CheckboxInput({
|
|
|
477
485
|
)}>
|
|
478
486
|
<div {...stylex.props(styles.checkboxWrapper, wrapperSizeStyles[size])}>
|
|
479
487
|
<input
|
|
488
|
+
{...rest}
|
|
480
489
|
ref={mergeRefs(
|
|
481
490
|
ref,
|
|
482
491
|
indeterminateRef,
|
|
@@ -484,6 +493,10 @@ export function CheckboxInput({
|
|
|
484
493
|
)}
|
|
485
494
|
id={id}
|
|
486
495
|
type="checkbox"
|
|
496
|
+
// Withhold the name while disabled: with a disabledMessage the
|
|
497
|
+
// input stays focusable (not natively disabled), and a disabled
|
|
498
|
+
// control must not submit.
|
|
499
|
+
name={isDisabled ? undefined : htmlName}
|
|
487
500
|
checked={isChecked}
|
|
488
501
|
// With a disabledMessage the checkbox keeps focusability via
|
|
489
502
|
// aria-disabled so the reason is focus-discoverable; toggling is
|
|
@@ -81,7 +81,7 @@ export const docs = {
|
|
|
81
81
|
name: 'disabledMessage',
|
|
82
82
|
type: 'string',
|
|
83
83
|
description:
|
|
84
|
-
'Explains why the group is disabled. Applies to the whole-group disabled state (isDisabled), not per item. With isDisabled, shows a tooltip on hover/keyboard focus and keeps the checkboxes focusable via aria-disabled (toggling stays blocked). Use this instead of wrapping a disabled CheckboxList in Tooltip
|
|
84
|
+
'Explains why the group is disabled. Applies to the whole-group disabled state (isDisabled), not per item. With isDisabled, shows a tooltip on hover/keyboard focus and keeps the checkboxes focusable via aria-disabled (toggling stays blocked). Use this instead of wrapping a disabled CheckboxList in Tooltip. Disabled controls swallow the hover events an external Tooltip needs.',
|
|
85
85
|
},
|
|
86
86
|
{
|
|
87
87
|
name: 'status',
|
|
@@ -135,6 +135,25 @@ describe('CheckboxList', () => {
|
|
|
135
135
|
expect(handleChange).toHaveBeenCalledWith(['b']);
|
|
136
136
|
});
|
|
137
137
|
|
|
138
|
+
it('fires a consumer onClick on an item in addition to toggling', async () => {
|
|
139
|
+
const user = userEvent.setup();
|
|
140
|
+
const handleChange = vi.fn();
|
|
141
|
+
const handleClick = vi.fn();
|
|
142
|
+
render(
|
|
143
|
+
<CheckboxList label="Preferences" value={['a']} onChange={handleChange}>
|
|
144
|
+
<CheckboxListItem label="Option A" value="a" />
|
|
145
|
+
<CheckboxListItem label="Option B" value="b" onClick={handleClick} />
|
|
146
|
+
</CheckboxList>,
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
// Click the interactive row (invisible-button pattern), which is where the
|
|
150
|
+
// composed onClick lives — not the inner checkbox.
|
|
151
|
+
await user.click(screen.getByRole('button', {name: 'Option B'}));
|
|
152
|
+
|
|
153
|
+
expect(handleClick).toHaveBeenCalledTimes(1);
|
|
154
|
+
expect(handleChange).toHaveBeenCalledWith(['a', 'b']);
|
|
155
|
+
});
|
|
156
|
+
|
|
138
157
|
it('disables all checkboxes when group isDisabled is true', () => {
|
|
139
158
|
render(
|
|
140
159
|
<CheckboxList
|
|
@@ -16,11 +16,12 @@
|
|
|
16
16
|
* - /packages/cli/templates/blocks/components/CheckboxList/ (showcase blocks)
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import {use, type ReactNode} from 'react';
|
|
19
|
+
import {use, type MouseEvent, type ReactNode} from 'react';
|
|
20
20
|
import * as stylex from '@stylexjs/stylex';
|
|
21
21
|
import type {StyleXStyles} from '@stylexjs/stylex';
|
|
22
22
|
import {colorVars} from '../theme/tokens.stylex';
|
|
23
23
|
import type {BaseProps} from '../BaseProps';
|
|
24
|
+
import {composeEventHandlers} from '../utils';
|
|
24
25
|
import {CheckboxInput} from '../CheckboxInput/CheckboxInput';
|
|
25
26
|
import {ListItem} from '../List/ListItem';
|
|
26
27
|
import {ListContext} from '../List/ListContext';
|
|
@@ -128,6 +129,7 @@ export function CheckboxListItem({
|
|
|
128
129
|
xstyle,
|
|
129
130
|
className,
|
|
130
131
|
style,
|
|
132
|
+
onClick: onClickProp,
|
|
131
133
|
...restProps
|
|
132
134
|
}: CheckboxListItemProps) {
|
|
133
135
|
const ctx = use(CheckboxListContext);
|
|
@@ -200,7 +202,14 @@ export function CheckboxListItem({
|
|
|
200
202
|
description={description}
|
|
201
203
|
endContent={endContent}
|
|
202
204
|
isDisabled={effectiveDisabled}
|
|
203
|
-
onClick={
|
|
205
|
+
onClick={
|
|
206
|
+
isInteractive || onClickProp
|
|
207
|
+
? composeEventHandlers<MouseEvent>(
|
|
208
|
+
onClickProp as ((event: MouseEvent) => void) | undefined,
|
|
209
|
+
isInteractive ? handleToggle : undefined,
|
|
210
|
+
)
|
|
211
|
+
: undefined
|
|
212
|
+
}
|
|
204
213
|
aria-busy={isBusy || undefined}
|
|
205
214
|
xstyle={
|
|
206
215
|
[
|
|
@@ -31,7 +31,12 @@
|
|
|
31
31
|
import {type ReactNode, type MouseEvent, useRef, type Ref} from 'react';
|
|
32
32
|
import * as stylex from '@stylexjs/stylex';
|
|
33
33
|
import type {StyleXStyles} from '@stylexjs/stylex';
|
|
34
|
-
import {
|
|
34
|
+
import {
|
|
35
|
+
borderVars,
|
|
36
|
+
colorVars,
|
|
37
|
+
durationVars,
|
|
38
|
+
easeVars,
|
|
39
|
+
} from '../theme/tokens.stylex';
|
|
35
40
|
import type {SizeValue, SpacingStep} from '../utils/types';
|
|
36
41
|
import {mergeProps, mergeRefs} from '../utils';
|
|
37
42
|
import {Card} from '../Card/Card';
|
|
@@ -66,7 +71,6 @@ const styles = stylex.create({
|
|
|
66
71
|
content: '""',
|
|
67
72
|
position: 'absolute',
|
|
68
73
|
inset: 0,
|
|
69
|
-
borderRadius: 'inherit',
|
|
70
74
|
pointerEvents: 'none',
|
|
71
75
|
transitionProperty: 'background-color',
|
|
72
76
|
transitionDuration: durationVars['--duration-fast'],
|
|
@@ -84,6 +88,38 @@ const styles = stylex.create({
|
|
|
84
88
|
},
|
|
85
89
|
},
|
|
86
90
|
},
|
|
91
|
+
// Borderless variants (everything except `default`): drop the transparent
|
|
92
|
+
// 1px border Card applies. The overlay is inset to the padding box — inside
|
|
93
|
+
// that border — so a transparent border strip stays untinted on hover and
|
|
94
|
+
// reads as a faint ring. With no border, the overlay covers the full box
|
|
95
|
+
// edge-to-edge and the ring disappears.
|
|
96
|
+
borderless: {
|
|
97
|
+
borderWidth: 0,
|
|
98
|
+
},
|
|
99
|
+
// Bordered variant (`default`): draw the 1px border *within* the padding by
|
|
100
|
+
// subtracting the border width from every side. Total inset (border +
|
|
101
|
+
// padding) then equals the borderless variants' padding, so content geometry
|
|
102
|
+
// and outer dimensions stay identical across all variants. The border rests
|
|
103
|
+
// at the subtle token and emphasizes on hover.
|
|
104
|
+
bordered: {
|
|
105
|
+
borderColor: colorVars['--color-border'],
|
|
106
|
+
paddingInlineStart: `calc(var(--container-padding-inline-start) - ${borderVars['--border-width']})`,
|
|
107
|
+
paddingInlineEnd: `calc(var(--container-padding-inline-end) - ${borderVars['--border-width']})`,
|
|
108
|
+
paddingBlockStart: `calc(var(--container-padding-block-start) - ${borderVars['--border-width']})`,
|
|
109
|
+
paddingBlockEnd: `calc(var(--container-padding-block-end) - ${borderVars['--border-width']})`,
|
|
110
|
+
transitionProperty: 'border-color',
|
|
111
|
+
transitionDuration: durationVars['--duration-fast'],
|
|
112
|
+
transitionTimingFunction: easeVars['--ease-standard'],
|
|
113
|
+
},
|
|
114
|
+
// Emphasize the bordered variant's border on hover. Guarded by
|
|
115
|
+
// @media (hover: hover) so touch devices don't get a stuck hover state.
|
|
116
|
+
borderedHoverOnPointer: {
|
|
117
|
+
'@media (hover: hover)': {
|
|
118
|
+
':hover': {
|
|
119
|
+
borderColor: colorVars['--color-border-emphasized'],
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
},
|
|
87
123
|
disabled: {
|
|
88
124
|
cursor: 'not-allowed',
|
|
89
125
|
opacity: 0.5,
|
|
@@ -248,6 +284,11 @@ export function ClickableCard({
|
|
|
248
284
|
|
|
249
285
|
const isLink = href != null;
|
|
250
286
|
|
|
287
|
+
// Only the `default` variant has a visible border. Card draws a transparent
|
|
288
|
+
// 1px border on every other variant purely to avoid layout jitter; we drop
|
|
289
|
+
// it here so the hover overlay covers the full box with no untinted ring.
|
|
290
|
+
const hasBorder = variant === 'default';
|
|
291
|
+
|
|
251
292
|
return (
|
|
252
293
|
<Card
|
|
253
294
|
ref={mergeRefs(ref, containerRef)}
|
|
@@ -264,8 +305,10 @@ export function ClickableCard({
|
|
|
264
305
|
[
|
|
265
306
|
styles.interactive,
|
|
266
307
|
styles.focusWithin,
|
|
308
|
+
hasBorder ? styles.bordered : styles.borderless,
|
|
267
309
|
!isDisabled && styles.overlay,
|
|
268
310
|
!isDisabled && styles.hoverOnPointer,
|
|
311
|
+
!isDisabled && hasBorder && styles.borderedHoverOnPointer,
|
|
269
312
|
isDisabled && styles.disabled,
|
|
270
313
|
xstyleProp,
|
|
271
314
|
] as unknown as StyleXStyles
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Code.test.tsx
|
|
5
|
+
* @input Uses vitest, @testing-library/react, Code component
|
|
6
|
+
* @output Unit tests for Code component behavior
|
|
7
|
+
* @position Testing; validates Code.tsx implementation
|
|
8
|
+
*
|
|
9
|
+
* SYNC: When Code.tsx changes, update tests to match new behavior
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import {describe, it, expect, vi} from 'vitest';
|
|
13
|
+
import {render, screen} from '@testing-library/react';
|
|
14
|
+
import {Code} from './Code';
|
|
15
|
+
|
|
16
|
+
describe('Code', () => {
|
|
17
|
+
it('renders children inside a <code> element', () => {
|
|
18
|
+
render(<Code>const x = 1</Code>);
|
|
19
|
+
const el = screen.getByText('const x = 1');
|
|
20
|
+
expect(el.tagName).toBe('CODE');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('forwards ref to the root element', () => {
|
|
24
|
+
const ref = vi.fn();
|
|
25
|
+
render(<Code ref={ref}>code</Code>);
|
|
26
|
+
expect(ref).toHaveBeenCalledWith(expect.any(HTMLElement));
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('defaults color to primary', () => {
|
|
30
|
+
render(<Code>code</Code>);
|
|
31
|
+
expect(screen.getByText('code')).toHaveClass('astryx-code', 'primary');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('applies the secondary color', () => {
|
|
35
|
+
render(<Code color="secondary">code</Code>);
|
|
36
|
+
expect(screen.getByText('code')).toHaveClass('astryx-code', 'secondary');
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('applies the inherit color', () => {
|
|
40
|
+
render(<Code color="inherit">code</Code>);
|
|
41
|
+
expect(screen.getByText('code')).toHaveClass('astryx-code', 'inherit');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('adds a size class when size="inherit" (font-size + line-height inherit)', () => {
|
|
45
|
+
const {rerender} = render(<Code>code</Code>);
|
|
46
|
+
const defaultClass = screen.getByText('code').getAttribute('class');
|
|
47
|
+
|
|
48
|
+
rerender(<Code size="inherit">code</Code>);
|
|
49
|
+
const inheritClass = screen.getByText('code').getAttribute('class');
|
|
50
|
+
|
|
51
|
+
// size="inherit" adds an extra StyleX class beyond the default rendering.
|
|
52
|
+
expect(inheritClass).not.toEqual(defaultClass);
|
|
53
|
+
});
|
|
54
|
+
});
|
package/src/Code/Code.tsx
CHANGED
|
@@ -42,9 +42,46 @@ const styles = stylex.create({
|
|
|
42
42
|
},
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
+
const colorStyles = stylex.create({
|
|
46
|
+
primary: {
|
|
47
|
+
color: colorVars['--color-text-primary'],
|
|
48
|
+
},
|
|
49
|
+
secondary: {
|
|
50
|
+
color: colorVars['--color-text-secondary'],
|
|
51
|
+
},
|
|
52
|
+
inherit: {
|
|
53
|
+
color: 'inherit',
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const sizeStyles = stylex.create({
|
|
58
|
+
// Adopt the surrounding text's font-size and line-height, for inline code
|
|
59
|
+
// that should match differently-sized text around it.
|
|
60
|
+
inherit: {
|
|
61
|
+
fontSize: 'inherit',
|
|
62
|
+
lineHeight: 'inherit',
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
/** Text color for {@link Code}, mirroring the primary/secondary/inherit subset of Text. */
|
|
67
|
+
export type CodeColor = 'primary' | 'secondary' | 'inherit';
|
|
68
|
+
|
|
69
|
+
/** Font size for {@link Code}. `'inherit'` adopts the surrounding text size. */
|
|
70
|
+
export type CodeSize = 'inherit';
|
|
71
|
+
|
|
45
72
|
export interface CodeProps extends BaseProps<HTMLElement> {
|
|
46
73
|
/** Ref forwarded to the root element */
|
|
47
74
|
ref?: React.Ref<HTMLElement>;
|
|
75
|
+
/**
|
|
76
|
+
* Text color. Mirrors the Text color subset.
|
|
77
|
+
* @default 'primary'
|
|
78
|
+
*/
|
|
79
|
+
color?: CodeColor;
|
|
80
|
+
/**
|
|
81
|
+
* Font size. Set to `'inherit'` to adopt the surrounding text's font-size
|
|
82
|
+
* and line-height (useful for inline code inside larger/smaller text).
|
|
83
|
+
*/
|
|
84
|
+
size?: CodeSize;
|
|
48
85
|
/** Code content */
|
|
49
86
|
children: ReactNode;
|
|
50
87
|
}
|
|
@@ -64,6 +101,8 @@ export interface CodeProps extends BaseProps<HTMLElement> {
|
|
|
64
101
|
*/
|
|
65
102
|
export function Code({
|
|
66
103
|
children,
|
|
104
|
+
color = 'primary',
|
|
105
|
+
size,
|
|
67
106
|
xstyle,
|
|
68
107
|
className,
|
|
69
108
|
style,
|
|
@@ -73,13 +112,18 @@ export function Code({
|
|
|
73
112
|
return (
|
|
74
113
|
<code
|
|
75
114
|
ref={ref}
|
|
115
|
+
{...props}
|
|
76
116
|
{...mergeProps(
|
|
77
|
-
themeProps('code'),
|
|
78
|
-
stylex.props(
|
|
117
|
+
themeProps('code', {color}),
|
|
118
|
+
stylex.props(
|
|
119
|
+
styles.base,
|
|
120
|
+
colorStyles[color],
|
|
121
|
+
size && sizeStyles[size],
|
|
122
|
+
xstyle,
|
|
123
|
+
),
|
|
79
124
|
className,
|
|
80
125
|
style,
|
|
81
|
-
)}
|
|
82
|
-
data-testid={props['data-testid']}>
|
|
126
|
+
)}>
|
|
83
127
|
{children}
|
|
84
128
|
</code>
|
|
85
129
|
);
|
package/src/Code/index.ts
CHANGED