@astryxdesign/core 0.1.4 → 0.1.5-canary.76e6697
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 +141 -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.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 +1 -1
- package/dist/AppShell/AppShell.d.ts.map +1 -1
- package/dist/AppShell/AppShell.js +55 -53
- package/dist/AspectRatio/AspectRatio.d.ts +48 -10
- package/dist/AspectRatio/AspectRatio.d.ts.map +1 -1
- package/dist/AspectRatio/AspectRatio.js +33 -12
- package/dist/AspectRatio/index.d.ts +1 -1
- package/dist/AspectRatio/index.d.ts.map +1 -1
- package/dist/Avatar/Avatar.d.ts.map +1 -1
- package/dist/Avatar/Avatar.js +28 -26
- package/dist/Avatar/AvatarStatusDot.js +6 -6
- package/dist/AvatarGroup/AvatarGroup.js +6 -6
- package/dist/AvatarGroup/AvatarGroupOverflow.js +7 -7
- 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.js +19 -19
- package/dist/ButtonGroup/ButtonGroup.js +7 -7
- package/dist/Calendar/Calendar.d.ts.map +1 -1
- package/dist/Calendar/Calendar.js +68 -48
- package/dist/Calendar/dayCellUtils.d.ts.map +1 -1
- 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 +24 -21
- 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 +1 -1
- 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.d.ts.map +1 -1
- package/dist/Chat/useTriggerMenu.js +15 -15
- package/dist/CheckboxInput/CheckboxInput.d.ts +1 -1
- package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
- package/dist/CheckboxInput/CheckboxInput.js +25 -23
- 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.js +3 -3
- 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/Collapsible/Collapsible.d.ts +9 -3
- package/dist/Collapsible/Collapsible.d.ts.map +1 -1
- package/dist/Collapsible/Collapsible.js +109 -22
- package/dist/Collapsible/CollapsibleGroup.d.ts +37 -7
- package/dist/Collapsible/CollapsibleGroup.d.ts.map +1 -1
- package/dist/Collapsible/CollapsibleGroup.js +64 -12
- package/dist/Collapsible/CollapsibleGroupContext.d.ts +24 -0
- package/dist/Collapsible/CollapsibleGroupContext.d.ts.map +1 -1
- package/dist/Collapsible/CollapsibleGroupContext.js +26 -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.js +3 -3
- 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 +7 -2
- package/dist/ContextMenu/ContextMenu.d.ts.map +1 -1
- package/dist/ContextMenu/ContextMenu.js +76 -43
- package/dist/DateInput/DateInput.js +18 -18
- package/dist/DateRangeInput/DateRangeInput.js +21 -21
- package/dist/DateTimeInput/DateTimeInput.d.ts +5 -2
- 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.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.d.ts +5 -1
- package/dist/HoverCard/useHoverCard.d.ts.map +1 -1
- 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.d.ts +29 -2
- package/dist/Layer/useLayer.d.ts.map +1 -1
- package/dist/Layer/useLayer.js +44 -31
- 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.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 +0 -2
- package/dist/Link/Link.d.ts.map +1 -1
- package/dist/Link/Link.js +15 -17
- 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/MetadataList/MetadataList.js +10 -10
- package/dist/MetadataList/MetadataListItem.js +15 -15
- package/dist/MobileNav/MobileNav.d.ts +1 -1
- package/dist/MobileNav/MobileNav.d.ts.map +1 -1
- package/dist/MobileNav/MobileNav.js +26 -23
- package/dist/MobileNav/MobileNavToggle.js +5 -5
- package/dist/MoreMenu/MoreMenu.js +3 -3
- package/dist/MultiSelector/MultiSelector.js +56 -56
- 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.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 +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.js +7 -7
- package/dist/RadioList/RadioListItem.d.ts +1 -1
- package/dist/RadioList/RadioListItem.d.ts.map +1 -1
- package/dist/RadioList/RadioListItem.js +24 -21
- 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.js +46 -46
- 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.js +23 -23
- package/dist/Spinner/Spinner.js +9 -9
- package/dist/StatusDot/StatusDot.js +5 -5
- package/dist/Switch/Switch.d.ts +8 -4
- package/dist/Switch/Switch.d.ts.map +1 -1
- package/dist/Switch/Switch.js +34 -29
- 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 +50 -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.js +3 -3
- 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/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 +250 -0
- 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/useTableRowExpansion.d.ts +1 -1
- package/dist/Table/plugins/rowExpansion/useTableRowExpansion.js +23 -23
- 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.js +9 -9
- package/dist/Text/Text.js +10 -10
- 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.d.ts.map +1 -1
- package/dist/Toast/useToast.js +44 -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.map +1 -1
- package/dist/Tokenizer/Tokenizer.js +36 -34
- package/dist/Toolbar/Toolbar.js +18 -18
- package/dist/Tooltip/Tooltip.js +11 -11
- package/dist/Tooltip/useTooltip.d.ts +5 -1
- package/dist/Tooltip/useTooltip.d.ts.map +1 -1
- 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/VisuallyHidden/VisuallyHidden.d.ts +0 -3
- package/dist/VisuallyHidden/VisuallyHidden.d.ts.map +1 -1
- package/dist/VisuallyHidden/VisuallyHidden.js +0 -3
- package/dist/astryx.css +7 -0
- package/dist/astryx.umd.js +63 -63
- package/dist/astryx.umd.js.map +4 -4
- package/dist/docs-types.d.ts +8 -2
- 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/theme/useTheme.d.ts +3 -2
- package/dist/theme/useTheme.d.ts.map +1 -1
- package/dist/theme/useTheme.js +73 -6
- 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 +4 -4
- package/src/AlertDialog/AlertDialog.doc.mjs +4 -0
- package/src/AlertDialog/AlertDialog.tsx +2 -0
- package/src/AlertDialog/useImperativeAlertDialog.tsx +0 -2
- package/src/AppShell/AppShell.tsx +2 -0
- package/src/AspectRatio/AspectRatio.doc.mjs +28 -1
- package/src/AspectRatio/AspectRatio.test.tsx +142 -1
- package/src/AspectRatio/AspectRatio.tsx +70 -10
- package/src/AspectRatio/index.ts +5 -1
- package/src/Avatar/Avatar.doc.mjs +11 -0
- package/src/Avatar/Avatar.test.tsx +32 -1
- package/src/Avatar/Avatar.tsx +14 -22
- package/src/Avatar/AvatarStatusDot.tsx +2 -2
- package/src/AvatarGroup/AvatarGroup.doc.mjs +1 -0
- package/src/AvatarGroup/AvatarGroup.tsx +2 -2
- package/src/AvatarGroup/AvatarGroupOverflow.tsx +2 -2
- 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/Calendar/Calendar.doc.mjs +1 -1
- package/src/Calendar/Calendar.test.tsx +122 -17
- package/src/Calendar/Calendar.tsx +26 -5
- package/src/Calendar/dayCellUtils.ts +3 -1
- 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 +4 -2
- package/src/Chat/Chat.doc.mjs +1 -1
- package/src/Chat/ChatComposerInput.test.tsx +27 -1
- package/src/Chat/ChatComposerInput.tsx +20 -15
- 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/useTriggerMenu.tsx +1 -4
- package/src/CheckboxInput/CheckboxInput.doc.mjs +3 -3
- package/src/CheckboxInput/CheckboxInput.test.tsx +71 -4
- package/src/CheckboxInput/CheckboxInput.tsx +2 -0
- 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/CodeBlock/CodeBlock.doc.mjs +7 -2
- package/src/CodeBlock/CodeBlock.test.tsx +122 -3
- package/src/CodeBlock/CodeBlock.tsx +62 -4
- package/src/Collapsible/Collapsible.doc.mjs +8 -4
- package/src/Collapsible/Collapsible.test.tsx +403 -0
- package/src/Collapsible/Collapsible.tsx +85 -10
- package/src/Collapsible/CollapsibleGroup.doc.mjs +27 -3
- package/src/Collapsible/CollapsibleGroup.test.tsx +314 -0
- package/src/Collapsible/CollapsibleGroup.tsx +97 -9
- package/src/Collapsible/CollapsibleGroupContext.tsx +34 -2
- package/src/Collapsible/index.ts +1 -0
- package/src/Collapsible/useCollapsible.ts +20 -6
- package/src/CommandPalette/CommandPalette.doc.mjs +5 -0
- package/src/CommandPalette/CommandPalette.tsx +5 -3
- package/src/CommandPalette/CommandPaletteEmpty.doc.mjs +5 -0
- 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 +87 -0
- package/src/ContextMenu/ContextMenu.tsx +87 -28
- package/src/ContextMenu/ContextMenuItem.doc.mjs +6 -0
- package/src/DateInput/DateInput.test.tsx +11 -20
- package/src/DateRangeInput/DateRangeInput.doc.mjs +9 -6
- package/src/DateRangeInput/DateRangeInput.test.tsx +31 -44
- package/src/DateTimeInput/DateTimeInput.doc.mjs +3 -2
- package/src/DateTimeInput/DateTimeInput.test.tsx +118 -16
- package/src/DateTimeInput/DateTimeInput.tsx +8 -2
- package/src/DateTimeInput/index.ts +1 -0
- package/src/Dialog/Dialog.doc.mjs +4 -0
- package/src/Dialog/DialogHeader.doc.mjs +45 -0
- package/src/DropdownMenu/DropdownMenu.doc.mjs +1 -1
- package/src/DropdownMenu/DropdownMenu.test.tsx +22 -2
- package/src/DropdownMenu/DropdownMenuItem.tsx +5 -17
- package/src/EmptyState/EmptyState.doc.mjs +1 -1
- package/src/Field/Field.test.tsx +1 -4
- package/src/Field/FieldLabel.test.tsx +2 -2
- package/src/FieldStatus/FieldStatus.test.tsx +282 -0
- package/src/FormLayout/__snapshots__/FormLayout.test.tsx.snap +0 -3
- package/src/Grid/Grid.test.tsx +43 -18
- package/src/Grid/Grid.tsx +26 -9
- package/src/HoverCard/HoverCard.doc.mjs +6 -6
- package/src/HoverCard/useHoverCard.doc.mjs +5 -5
- package/src/HoverCard/useHoverCard.tsx +9 -2
- package/src/Icon/Icon.test.tsx +41 -29
- package/src/Icon/Icon.tsx +6 -2
- package/src/InputGroup/InputGroup.doc.mjs +1 -0
- package/src/InputGroup/InputGroup.tsx +2 -2
- package/src/InteractiveRoleContext/InteractiveRoleContext.test.tsx +185 -0
- package/src/Item/Item.tsx +1 -1
- package/src/Layer/useLayer.doc.mjs +2 -2
- package/src/Layer/useLayer.test.tsx +221 -2
- package/src/Layer/useLayer.tsx +69 -30
- 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/Lightbox/Lightbox.doc.mjs +5 -0
- package/src/Lightbox/Lightbox.test.tsx +123 -2
- package/src/Lightbox/Lightbox.tsx +29 -1
- package/src/Lightbox/useLightbox.tsx +0 -1
- package/src/Link/Link.tsx +0 -2
- package/src/Markdown/Markdown.tsx +9 -7
- package/src/Markdown/parser.perf.test.ts +34 -12
- package/src/MobileNav/MobileNav.test.tsx +56 -0
- package/src/MobileNav/MobileNav.tsx +13 -8
- 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/Outline.doc.mjs +2 -0
- 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/Overlay/useOverlay.tsx +0 -3
- package/src/Pagination/Pagination.test.tsx +162 -0
- package/src/Pagination/Pagination.tsx +80 -26
- package/src/Popover/Popover.doc.mjs +6 -6
- package/src/Popover/Popover.test.tsx +65 -0
- package/src/Popover/usePopover.doc.mjs +1 -1
- package/src/PowerSearch/PowerSearch.doc.mjs +2 -2
- package/src/PowerSearch/PowerSearch.test.tsx +109 -1
- package/src/PowerSearch/PowerSearch.tsx +37 -16
- package/src/ProgressBar/ProgressBar.doc.mjs +2 -0
- package/src/ProgressBar/ProgressBar.test.tsx +30 -0
- package/src/ProgressBar/ProgressBar.tsx +12 -5
- package/src/RadioList/RadioList.test.tsx +19 -0
- package/src/RadioList/RadioListItem.tsx +9 -4
- package/src/Resizable/ResizeHandle.test.tsx +218 -0
- package/src/Resizable/ResizeHandle.tsx +22 -4
- package/src/SegmentedControl/SegmentedControl.doc.mjs +1 -1
- 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.test.tsx +27 -1
- 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/Switch/Switch.doc.mjs +7 -7
- package/src/Switch/Switch.test.tsx +102 -3
- package/src/Switch/Switch.tsx +20 -7
- package/src/TabList/TabList.test.tsx +185 -1
- package/src/TabList/TabMenu.tsx +45 -9
- package/src/Table/BaseTable.tsx +13 -2
- package/src/Table/Table.doc.mjs +6 -1
- package/src/Table/Table.test.tsx +87 -0
- package/src/Table/TableBody.tsx +15 -2
- 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/groupedRows/index.ts +7 -0
- package/src/Table/plugins/groupedRows/useTableGroupedRows.test.tsx +231 -0
- package/src/Table/plugins/groupedRows/useTableGroupedRows.tsx +349 -0
- package/src/Table/plugins/pagination/paginateData.ts +5 -1
- package/src/Table/plugins/pagination/useTablePagination.test.tsx +13 -0
- package/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx +1 -1
- 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/useTableGroupedRows.doc.mjs +71 -0
- package/src/TextArea/TextArea.test.tsx +3 -3
- 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.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/Toast/useToast.test.tsx +258 -0
- package/src/Toast/useToast.tsx +41 -0
- package/src/ToggleButton/ToggleButton.doc.mjs +1 -0
- package/src/Tokenizer/Tokenizer.doc.mjs +2 -2
- package/src/Tokenizer/Tokenizer.test.tsx +54 -0
- package/src/Tokenizer/Tokenizer.tsx +5 -4
- package/src/Tooltip/Tooltip.doc.mjs +6 -6
- package/src/Tooltip/useTooltip.doc.mjs +5 -5
- package/src/Tooltip/useTooltip.tsx +12 -2
- package/src/TopNav/TopNav.doc.mjs +1 -1
- package/src/TopNav/TopNav.test.tsx +23 -7
- 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 +1 -1
- package/src/Typeahead/Typeahead.test.tsx +45 -1
- package/src/VisuallyHidden/VisuallyHidden.tsx +0 -3
- 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 +9 -1
- 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/useStreamingText.test.ts +54 -19
- package/src/hooks/useStreamingText.ts +16 -5
- package/src/hooks/useTreeFocus.test.tsx +1 -3
- package/src/reset.css +29 -0
- 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/themingTargets.test.ts +353 -0
- package/src/theme/tokens.test.ts +182 -9
- package/src/theme/tokens.ts +239 -4
- package/src/theme/useTheme.test.tsx +126 -2
- package/src/theme/useTheme.ts +87 -6
- 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
- package/dist/Carousel/carousel.markers.stylex.d.ts +0 -7
- package/dist/Carousel/carousel.markers.stylex.d.ts.map +0 -1
- package/dist/Carousel/carousel.markers.stylex.js +0 -12
- package/src/Carousel/carousel.markers.stylex.ts +0 -10
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file color.ts
|
|
3
|
+
* @input CSS color strings (hex, rgb()/rgba(), a small set of named colors)
|
|
4
|
+
* @output Shared color parsing/formatting primitives used across the design system
|
|
5
|
+
* @position Package utility; backs theme token resolution, HCT color math, and chart rendering
|
|
6
|
+
*
|
|
7
|
+
* A single home for the color parsers that were previously duplicated across
|
|
8
|
+
* the theme layer, charts, and lab. Consumers get one well-tested definition of
|
|
9
|
+
* "parse this color" rather than several subtly different regexes.
|
|
10
|
+
*/
|
|
11
|
+
/** A color decomposed into 0-255 RGB channels and a 0-1 alpha. */
|
|
12
|
+
export interface RGBA {
|
|
13
|
+
r: number;
|
|
14
|
+
g: number;
|
|
15
|
+
b: number;
|
|
16
|
+
a: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Parse a hex color into {@link RGBA}. Accepts `#rgb`, `#rgba`, `#rrggbb`, and
|
|
20
|
+
* `#rrggbbaa`, with or without the leading `#`. Returns null for anything else.
|
|
21
|
+
*/
|
|
22
|
+
export declare function parseHex(hex: string): RGBA | null;
|
|
23
|
+
/**
|
|
24
|
+
* Parse an `rgb()`/`rgba()` color into {@link RGBA}. Accepts comma- or
|
|
25
|
+
* space-separated channels, an optional `/ alpha`, and percentage channels.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseRgb(value: string): RGBA | null;
|
|
28
|
+
/**
|
|
29
|
+
* Parse a concrete CSS color string into {@link RGBA}. Supports hex,
|
|
30
|
+
* `rgb()`/`rgba()`, and the named colors used in token expressions. Returns
|
|
31
|
+
* null for anything it can't evaluate (e.g. `var()`, `oklch()`, unknown names)
|
|
32
|
+
* so callers can preserve the original expression rather than guessing.
|
|
33
|
+
*/
|
|
34
|
+
export declare function parseColor(value: string): RGBA | null;
|
|
35
|
+
/** Format RGB channels (0-255) as an uppercase `#RRGGBB` string. */
|
|
36
|
+
export declare function formatHex(r: number, g: number, b: number): string;
|
|
37
|
+
/**
|
|
38
|
+
* Serialize {@link RGBA} to a compact, JS-usable CSS color: `#RRGGBB` when
|
|
39
|
+
* fully opaque, otherwise `rgba(r, g, b, a)`.
|
|
40
|
+
*/
|
|
41
|
+
export declare function formatColor({ r, g, b, a }: RGBA): string;
|
|
42
|
+
//# sourceMappingURL=color.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../src/utils/color.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AAEH,kEAAkE;AAClE,MAAM,WAAW,IAAI;IACnB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAoBD;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAqBjD;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAqCnD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAarD;AAED,oEAAoE;AACpE,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAIjE;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,EAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAC,EAAE,IAAI,GAAG,MAAM,CAMtD"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file color.ts
|
|
5
|
+
* @input CSS color strings (hex, rgb()/rgba(), a small set of named colors)
|
|
6
|
+
* @output Shared color parsing/formatting primitives used across the design system
|
|
7
|
+
* @position Package utility; backs theme token resolution, HCT color math, and chart rendering
|
|
8
|
+
*
|
|
9
|
+
* A single home for the color parsers that were previously duplicated across
|
|
10
|
+
* the theme layer, charts, and lab. Consumers get one well-tested definition of
|
|
11
|
+
* "parse this color" rather than several subtly different regexes.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** A color decomposed into 0-255 RGB channels and a 0-1 alpha. */
|
|
15
|
+
|
|
16
|
+
/** The named colors the design system relies on in token expressions. */
|
|
17
|
+
const NAMED_COLORS = {
|
|
18
|
+
transparent: {
|
|
19
|
+
r: 0,
|
|
20
|
+
g: 0,
|
|
21
|
+
b: 0,
|
|
22
|
+
a: 0
|
|
23
|
+
},
|
|
24
|
+
black: {
|
|
25
|
+
r: 0,
|
|
26
|
+
g: 0,
|
|
27
|
+
b: 0,
|
|
28
|
+
a: 1
|
|
29
|
+
},
|
|
30
|
+
white: {
|
|
31
|
+
r: 255,
|
|
32
|
+
g: 255,
|
|
33
|
+
b: 255,
|
|
34
|
+
a: 1
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const clamp = (value, min, max) => Math.max(min, Math.min(max, value));
|
|
38
|
+
|
|
39
|
+
/** Expand a shorthand hex body (`rgb`/`rgba`) to its full form (`rrggbb`/`rrggbbaa`). */
|
|
40
|
+
function expandShorthand(body) {
|
|
41
|
+
return body.split('').map(c => c + c).join('');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Parse a hex color into {@link RGBA}. Accepts `#rgb`, `#rgba`, `#rrggbb`, and
|
|
46
|
+
* `#rrggbbaa`, with or without the leading `#`. Returns null for anything else.
|
|
47
|
+
*/
|
|
48
|
+
export function parseHex(hex) {
|
|
49
|
+
if (typeof hex !== 'string') {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const body = hex.trim().replace(/^#/, '');
|
|
53
|
+
const normalized = body.length === 3 || body.length === 4 ? expandShorthand(body) : body;
|
|
54
|
+
if (normalized.length !== 6 && normalized.length !== 8 || !/^[0-9a-fA-F]+$/.test(normalized)) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
r: parseInt(normalized.slice(0, 2), 16),
|
|
59
|
+
g: parseInt(normalized.slice(2, 4), 16),
|
|
60
|
+
b: parseInt(normalized.slice(4, 6), 16),
|
|
61
|
+
a: normalized.length === 8 ? parseInt(normalized.slice(6, 8), 16) / 255 : 1
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Parse an `rgb()`/`rgba()` color into {@link RGBA}. Accepts comma- or
|
|
67
|
+
* space-separated channels, an optional `/ alpha`, and percentage channels.
|
|
68
|
+
*/
|
|
69
|
+
export function parseRgb(value) {
|
|
70
|
+
const open = value.indexOf('(');
|
|
71
|
+
if (open === -1 || !value.trim().endsWith(')')) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
const body = value.slice(open + 1, value.lastIndexOf(')')).replace(/\//g, ' ');
|
|
75
|
+
const parts = body.split(/[\s,]+/).map(p => p.trim()).filter(Boolean);
|
|
76
|
+
if (parts.length < 3) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
const channel = p => {
|
|
80
|
+
const n = p.endsWith('%') ? parseFloat(p) / 100 * 255 : parseFloat(p);
|
|
81
|
+
return clamp(n, 0, 255);
|
|
82
|
+
};
|
|
83
|
+
const r = channel(parts[0]);
|
|
84
|
+
const g = channel(parts[1]);
|
|
85
|
+
const b = channel(parts[2]);
|
|
86
|
+
if ([r, g, b].some(Number.isNaN)) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
let a = 1;
|
|
90
|
+
if (parts.length >= 4) {
|
|
91
|
+
const raw = parts[3];
|
|
92
|
+
a = raw.endsWith('%') ? parseFloat(raw) / 100 : parseFloat(raw);
|
|
93
|
+
if (Number.isNaN(a)) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
a = clamp(a, 0, 1);
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
r,
|
|
100
|
+
g,
|
|
101
|
+
b,
|
|
102
|
+
a
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Parse a concrete CSS color string into {@link RGBA}. Supports hex,
|
|
108
|
+
* `rgb()`/`rgba()`, and the named colors used in token expressions. Returns
|
|
109
|
+
* null for anything it can't evaluate (e.g. `var()`, `oklch()`, unknown names)
|
|
110
|
+
* so callers can preserve the original expression rather than guessing.
|
|
111
|
+
*/
|
|
112
|
+
export function parseColor(value) {
|
|
113
|
+
const trimmed = value.trim();
|
|
114
|
+
const named = NAMED_COLORS[trimmed.toLowerCase()];
|
|
115
|
+
if (named) {
|
|
116
|
+
return {
|
|
117
|
+
...named
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
if (trimmed.startsWith('#')) {
|
|
121
|
+
return parseHex(trimmed);
|
|
122
|
+
}
|
|
123
|
+
if (/^rgba?\(/i.test(trimmed)) {
|
|
124
|
+
return parseRgb(trimmed);
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Format RGB channels (0-255) as an uppercase `#RRGGBB` string. */
|
|
130
|
+
export function formatHex(r, g, b) {
|
|
131
|
+
const channel = c => clamp(Math.round(c), 0, 255).toString(16).padStart(2, '0').toUpperCase();
|
|
132
|
+
return `#${channel(r)}${channel(g)}${channel(b)}`;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Serialize {@link RGBA} to a compact, JS-usable CSS color: `#RRGGBB` when
|
|
137
|
+
* fully opaque, otherwise `rgba(r, g, b, a)`.
|
|
138
|
+
*/
|
|
139
|
+
export function formatColor({
|
|
140
|
+
r,
|
|
141
|
+
g,
|
|
142
|
+
b,
|
|
143
|
+
a
|
|
144
|
+
}) {
|
|
145
|
+
if (a >= 1) {
|
|
146
|
+
return formatHex(r, g, b);
|
|
147
|
+
}
|
|
148
|
+
const round = n => clamp(Math.round(n), 0, 255);
|
|
149
|
+
return `rgba(${round(r)}, ${round(g)}, ${round(b)}, ${parseFloat(a.toFixed(4))})`;
|
|
150
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file composeEventHandlers.ts
|
|
3
|
+
* @input Multiple React event handlers (or undefined)
|
|
4
|
+
* @output A single handler that calls each in order, stopping if one prevents default
|
|
5
|
+
* @position Utility; used by components that own an interaction (a click that
|
|
6
|
+
* selects, a keydown that drives arrow navigation) but also accept a consumer
|
|
7
|
+
* handler for the same event through {...rest}. Composes them instead of
|
|
8
|
+
* letting one clobber the other.
|
|
9
|
+
*
|
|
10
|
+
* Order is call order: the first argument runs first. Put the consumer handler
|
|
11
|
+
* first so it can opt out of the component's built-in behavior via
|
|
12
|
+
* `event.preventDefault()`; put the component's handler first when its behavior
|
|
13
|
+
* must always run regardless of the consumer.
|
|
14
|
+
*/
|
|
15
|
+
import type { SyntheticEvent } from 'react';
|
|
16
|
+
/**
|
|
17
|
+
* Compose event handlers into one. Each handler runs in argument order; if any
|
|
18
|
+
* calls `event.preventDefault()`, the remaining handlers are skipped.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* // Consumer first: a consumer onClick can preventDefault to block selection.
|
|
23
|
+
* <button onClick={composeEventHandlers(onClickProp, handleSelect)} />
|
|
24
|
+
*
|
|
25
|
+
* // Component first: built-in keyboard nav always runs.
|
|
26
|
+
* <div onKeyDown={composeEventHandlers(handleArrowKeys, onKeyDownProp)} />
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function composeEventHandlers<E extends SyntheticEvent>(...handlers: (((event: E) => void) | undefined)[]): (event: E) => void;
|
|
30
|
+
//# sourceMappingURL=composeEventHandlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composeEventHandlers.d.ts","sourceRoot":"","sources":["../../src/utils/composeEventHandlers.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,OAAO,CAAC;AAE1C;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,cAAc,EAC3D,GAAG,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC,EAAE,GAChD,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CASpB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file composeEventHandlers.ts
|
|
5
|
+
* @input Multiple React event handlers (or undefined)
|
|
6
|
+
* @output A single handler that calls each in order, stopping if one prevents default
|
|
7
|
+
* @position Utility; used by components that own an interaction (a click that
|
|
8
|
+
* selects, a keydown that drives arrow navigation) but also accept a consumer
|
|
9
|
+
* handler for the same event through {...rest}. Composes them instead of
|
|
10
|
+
* letting one clobber the other.
|
|
11
|
+
*
|
|
12
|
+
* Order is call order: the first argument runs first. Put the consumer handler
|
|
13
|
+
* first so it can opt out of the component's built-in behavior via
|
|
14
|
+
* `event.preventDefault()`; put the component's handler first when its behavior
|
|
15
|
+
* must always run regardless of the consumer.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Compose event handlers into one. Each handler runs in argument order; if any
|
|
20
|
+
* calls `event.preventDefault()`, the remaining handlers are skipped.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* // Consumer first: a consumer onClick can preventDefault to block selection.
|
|
25
|
+
* <button onClick={composeEventHandlers(onClickProp, handleSelect)} />
|
|
26
|
+
*
|
|
27
|
+
* // Component first: built-in keyboard nav always runs.
|
|
28
|
+
* <div onKeyDown={composeEventHandlers(handleArrowKeys, onKeyDownProp)} />
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export function composeEventHandlers(...handlers) {
|
|
32
|
+
return event => {
|
|
33
|
+
for (const handler of handlers) {
|
|
34
|
+
handler?.(event);
|
|
35
|
+
if (event.defaultPrevented) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export { parseStyleKey } from './parseStyleKey';
|
|
|
14
14
|
export { getKey, type Key, type KeyFallback } from './getKey';
|
|
15
15
|
export { mergeProps } from './mergeProps';
|
|
16
16
|
export { mergeRefs } from './mergeRefs';
|
|
17
|
+
export { composeEventHandlers } from './composeEventHandlers';
|
|
17
18
|
export { themeProps, themeDataAttributes } from './themeProps';
|
|
18
19
|
export type { ClassValue, ClassProps, ThemeDataAttributes, ThemeProps, } from './themeProps';
|
|
19
20
|
export { groupItems, getItemGroup } from './groupItems';
|
|
@@ -22,4 +23,6 @@ export { observeResize, unobserveResize } from './sharedResizeObserver';
|
|
|
22
23
|
export { isRenderable } from './isRenderable';
|
|
23
24
|
export { getInputARIA } from './inputAria';
|
|
24
25
|
export type { InputARIA, InputARIAInputGroup } from './inputAria';
|
|
26
|
+
export { parseHex, parseRgb, parseColor, formatHex, formatColor } from './color';
|
|
27
|
+
export type { RGBA } from './color';
|
|
25
28
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,YAAY,EAAC,SAAS,EAAC,MAAM,SAAS,CAAC;AAEvC,YAAY,EAAC,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAC,MAAM,aAAa,CAAC;AAEhF,OAAO,EACL,cAAc,EACd,SAAS,EACT,QAAQ,EACR,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,cAAc,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AAM,wBAAwB,CAAC;AAC5D,OAAO,EAAC,UAAU,EAAE,mBAAmB,EAAC,MAAM,cAAc,CAAC;AAC7D,YAAY,EACV,UAAU,EACV,UAAU,EACV,mBAAmB,EACnB,UAAU,GACX,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,UAAU,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AACtD,YAAY,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAC,aAAa,EAAE,eAAe,EAAC,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AACzC,YAAY,EAAC,SAAS,EAAE,mBAAmB,EAAC,MAAM,aAAa,CAAC;AAEhE,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAC,MAAM,SAAS,CAAC;AAC/E,YAAY,EAAC,IAAI,EAAC,MAAM,SAAS,CAAC"}
|
package/dist/utils/index.js
CHANGED
|
@@ -14,8 +14,10 @@ export { parseStyleKey } from "./parseStyleKey.js";
|
|
|
14
14
|
export { getKey } from "./getKey.js";
|
|
15
15
|
export { mergeProps } from "./mergeProps.js";
|
|
16
16
|
export { mergeRefs } from "./mergeRefs.js";
|
|
17
|
+
export { composeEventHandlers } from "./composeEventHandlers.js";
|
|
17
18
|
export { themeProps, themeDataAttributes } from "./themeProps.js";
|
|
18
19
|
export { groupItems, getItemGroup } from "./groupItems.js";
|
|
19
20
|
export { observeResize, unobserveResize } from "./sharedResizeObserver.js";
|
|
20
21
|
export { isRenderable } from "./isRenderable.js";
|
|
21
|
-
export { getInputARIA } from "./inputAria.js";
|
|
22
|
+
export { getInputARIA } from "./inputAria.js";
|
|
23
|
+
export { parseHex, parseRgb, parseColor, formatHex, formatColor } from "./color.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeParser.d.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;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,CAAC,EAAE,aAAa,GAAG,SAAS,EAC5B,CAAC,EAAE,aAAa,GAAG,SAAS,GAC3B,MAAM,CA4BR;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,aAAa,EACnB,GAAG,CAAC,EAAE,aAAa,EACnB,GAAG,CAAC,EAAE,aAAa,GAClB,OAAO,CAQT;AAED;;GAEG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,aAAa,EACnB,GAAG,CAAC,EAAE,aAAa,EACnB,GAAG,CAAC,EAAE,aAAa,EACnB,cAAc,GAAE,OAAe,GAC9B,aAAa,CAoBf;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,aAAa,EACnB,YAAY,EAAE,MAAM,EACpB,cAAc,GAAE,OAAe,GAC9B,aAAa,CAwBf"}
|
package/dist/utils/timeParser.js
CHANGED
|
@@ -305,13 +305,16 @@ export function adjustTime(time, deltaMinutes, includeSeconds = false) {
|
|
|
305
305
|
if (!parsed) {
|
|
306
306
|
return time;
|
|
307
307
|
}
|
|
308
|
-
let totalMinutes = parsed.hour * 60 + parsed.minute + deltaMinutes;
|
|
309
308
|
|
|
310
|
-
//
|
|
311
|
-
|
|
312
|
-
|
|
309
|
+
// A non-finite delta would spin the wrap-around forever (-Infinity) or
|
|
310
|
+
// produce "NaN:NaN" (NaN) — return the input unchanged instead.
|
|
311
|
+
if (!Number.isFinite(deltaMinutes)) {
|
|
312
|
+
return time;
|
|
313
313
|
}
|
|
314
|
-
totalMinutes =
|
|
314
|
+
let totalMinutes = parsed.hour * 60 + parsed.minute + deltaMinutes;
|
|
315
|
+
|
|
316
|
+
// Wrap around midnight (double-modulo handles negatives in O(1))
|
|
317
|
+
totalMinutes = (totalMinutes % (24 * 60) + 24 * 60) % (24 * 60);
|
|
315
318
|
const newHour = Math.floor(totalMinutes / 60);
|
|
316
319
|
const newMinute = totalMinutes % 60;
|
|
317
320
|
return formatISOTime({
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/core",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"displayName": "
|
|
3
|
+
"version": "0.1.5-canary.76e6697",
|
|
4
|
+
"displayName": "Astryx Core",
|
|
5
5
|
"description": "The component library. Accessible, themeable React components with built-in spacing, dark mode, and StyleX styling.",
|
|
6
6
|
"author": "Meta Open Source",
|
|
7
7
|
"license": "MIT",
|
|
@@ -626,14 +626,14 @@
|
|
|
626
626
|
"CHANGELOG.md"
|
|
627
627
|
],
|
|
628
628
|
"peerDependencies": {
|
|
629
|
-
"@stylexjs/stylex": "^0.
|
|
629
|
+
"@stylexjs/stylex": "^0.19.0",
|
|
630
630
|
"react": ">=19.0.0",
|
|
631
631
|
"react-dom": ">=19.0.0"
|
|
632
632
|
},
|
|
633
633
|
"devDependencies": {
|
|
634
634
|
"@babel/cli": "^7.29.7",
|
|
635
635
|
"@babel/core": "^7.29.7",
|
|
636
|
-
"@babel/preset-react": "^
|
|
636
|
+
"@babel/preset-react": "^8.0.1",
|
|
637
637
|
"@babel/preset-typescript": "^7.29.7",
|
|
638
638
|
"@stylexjs/babel-plugin": "^0.19.0",
|
|
639
639
|
"@testing-library/dom": "^10.0.0",
|
|
@@ -28,6 +28,10 @@ export const docs = {
|
|
|
28
28
|
{guidance: false, description: 'Use AlertDialog for non-destructive actions; use a standard Dialog instead.'},
|
|
29
29
|
],
|
|
30
30
|
},
|
|
31
|
+
// Intentionally a contained isInline preview, not playground.overlay: the
|
|
32
|
+
// component stays visible on load and knobs stay live, whereas a real
|
|
33
|
+
// showModal() overlay makes the page inert — see PlaygroundConfig.overlay
|
|
34
|
+
// in docs-types.ts (#3657).
|
|
31
35
|
playground: {
|
|
32
36
|
defaults: {
|
|
33
37
|
isOpen: true,
|
|
@@ -132,6 +132,7 @@ export function AlertDialog({
|
|
|
132
132
|
className,
|
|
133
133
|
style,
|
|
134
134
|
'data-testid': testId,
|
|
135
|
+
...rest
|
|
135
136
|
}: AlertDialogProps) {
|
|
136
137
|
const titleId = useId();
|
|
137
138
|
const descriptionId = useId();
|
|
@@ -142,6 +143,7 @@ export function AlertDialog({
|
|
|
142
143
|
|
|
143
144
|
return (
|
|
144
145
|
<Dialog
|
|
146
|
+
{...rest}
|
|
145
147
|
ref={ref}
|
|
146
148
|
isOpen={isOpen}
|
|
147
149
|
isInline={isInline}
|
|
@@ -36,7 +36,6 @@ export interface ImperativeAlertDialogReturn {
|
|
|
36
36
|
* @example
|
|
37
37
|
* ```
|
|
38
38
|
* const alert = useImperativeAlertDialog();
|
|
39
|
-
*
|
|
40
39
|
* const handleDelete = () => {
|
|
41
40
|
* alert.show({
|
|
42
41
|
* title: 'Delete item?',
|
|
@@ -45,7 +44,6 @@ export interface ImperativeAlertDialogReturn {
|
|
|
45
44
|
* onAction: async () => { await deleteItem(); alert.hide(); },
|
|
46
45
|
* });
|
|
47
46
|
* };
|
|
48
|
-
*
|
|
49
47
|
* return (
|
|
50
48
|
* <>
|
|
51
49
|
* <button onClick={handleDelete}>Delete</button>
|
|
@@ -470,6 +470,7 @@ export function AppShell({
|
|
|
470
470
|
className,
|
|
471
471
|
style,
|
|
472
472
|
ref,
|
|
473
|
+
...rest
|
|
473
474
|
}: AppShellProps) {
|
|
474
475
|
// =========================================================================
|
|
475
476
|
// Parse mobileNav prop — normalize to config, custom element, or disabled
|
|
@@ -768,6 +769,7 @@ export function AppShell({
|
|
|
768
769
|
return (
|
|
769
770
|
<AppShellMobileContext value={mobileContextValue}>
|
|
770
771
|
<div
|
|
772
|
+
{...rest}
|
|
771
773
|
ref={mergeRefs(ref, shellRef)}
|
|
772
774
|
data-testid={dataTestId}
|
|
773
775
|
{...mergeProps(
|
|
@@ -13,6 +13,7 @@ export const docs = {
|
|
|
13
13
|
bestPractices: [
|
|
14
14
|
{guidance: true, description: 'Express the ratio as a fraction like `16/9` or `4/3` for readability.'},
|
|
15
15
|
{guidance: true, description: 'Use for media that needs consistent proportions across screen sizes.'},
|
|
16
|
+
{guidance: true, description: 'Use `fit="cover"` for images and video so the component sizes the child; the child should not repeat `width`/`height`/`objectFit` styles.'},
|
|
16
17
|
{guidance: false, description: 'Use for general layout containers; use standard layout components instead.'},
|
|
17
18
|
{guidance: false, description: 'Nest AspectRatio containers; one level is sufficient.'},
|
|
18
19
|
],
|
|
@@ -24,6 +25,17 @@ export const docs = {
|
|
|
24
25
|
description: 'Aspect ratio as width/height (e.g. 16/9, 1).',
|
|
25
26
|
required: true,
|
|
26
27
|
},
|
|
28
|
+
{
|
|
29
|
+
name: 'shape',
|
|
30
|
+
type: "'rectangle' | 'ellipse'",
|
|
31
|
+
description: 'Container shape. Both respect the `ratio`. `ellipse` clips to an oval (a circle when `ratio={1}`).',
|
|
32
|
+
default: "'rectangle'",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'fit',
|
|
36
|
+
type: "'cover' | 'contain' | 'center'",
|
|
37
|
+
description: 'How the child is sized inside the ratio box. `cover` fills and crops media, `contain` fills and letterboxes, `center` keeps the natural size centered. When omitted, the child styles itself.',
|
|
38
|
+
},
|
|
27
39
|
{
|
|
28
40
|
name: 'children',
|
|
29
41
|
type: 'ReactNode',
|
|
@@ -60,12 +72,24 @@ export const docsZh = {
|
|
|
60
72
|
bestPractices: [
|
|
61
73
|
{guidance: true, description: 'Express the ratio as a fraction like `16/9` or `4/3` for readability.'},
|
|
62
74
|
{guidance: true, description: 'Use for media that needs consistent proportions across screen sizes.'},
|
|
75
|
+
{guidance: true, description: 'Use `fit="cover"` for images and video so the component sizes the child; the child should not repeat `width`/`height`/`objectFit` styles.'},
|
|
63
76
|
{guidance: false, description: 'Use for general layout containers; use standard layout components instead.'},
|
|
64
77
|
{guidance: false, description: 'Nest AspectRatio containers; one level is sufficient.'},
|
|
65
78
|
],
|
|
66
79
|
},
|
|
67
80
|
props: [
|
|
68
81
|
{name: 'ratio', type: 'number', description: '宽高比,以宽/高表示(例如 16/9、1)。', required: true},
|
|
82
|
+
{
|
|
83
|
+
name: 'shape',
|
|
84
|
+
type: "'rectangle' | 'ellipse'",
|
|
85
|
+
description: '容器形状。两种形状都遵循 `ratio`。`ellipse` 裁剪为椭圆(`ratio={1}` 时为正圆)。',
|
|
86
|
+
default: "'rectangle'",
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'fit',
|
|
90
|
+
type: "'cover' | 'contain' | 'center'",
|
|
91
|
+
description: '子元素在比例框内的布局方式。`cover` 填满并裁剪媒体,`contain` 填满并留边,`center` 保持原始尺寸居中。省略时子元素自行设置样式。',
|
|
92
|
+
},
|
|
69
93
|
{name: 'children', type: 'ReactNode', description: '通过绝对定位填充容器的内容。', required: true},
|
|
70
94
|
{
|
|
71
95
|
name: 'xstyle',
|
|
@@ -76,7 +100,7 @@ export const docsZh = {
|
|
|
76
100
|
],
|
|
77
101
|
theming: {
|
|
78
102
|
targets: [
|
|
79
|
-
{className: 'astryx-aspect-ratio'},
|
|
103
|
+
{className: 'astryx-aspect-ratio', visualProps: ['shape']},
|
|
80
104
|
],
|
|
81
105
|
},
|
|
82
106
|
};
|
|
@@ -90,12 +114,15 @@ export const docsDense = {
|
|
|
90
114
|
bestPractices: [
|
|
91
115
|
{guidance: true, description: 'Express the ratio as a fraction like `16/9` or `4/3` for readability.'},
|
|
92
116
|
{guidance: true, description: 'Use for media that needs consistent proportions across screen sizes.'},
|
|
117
|
+
{guidance: true, description: 'Use `fit="cover"` for images and video so the component sizes the child; the child should not repeat `width`/`height`/`objectFit` styles.'},
|
|
93
118
|
{guidance: false, description: 'Use for general layout containers; use standard layout components instead.'},
|
|
94
119
|
{guidance: false, description: 'Nest AspectRatio containers; one level is sufficient.'},
|
|
95
120
|
],
|
|
96
121
|
},
|
|
97
122
|
propDescriptions: {
|
|
98
123
|
ratio: 'width/height ratio (e.g. 16/9, 1)',
|
|
124
|
+
shape: "container shape: 'rectangle' (default) | 'ellipse' (circle at ratio 1)",
|
|
125
|
+
fit: "child layout: 'cover' fill+crop | 'contain' fill+letterbox | 'center' natural size; omitted = child styles itself",
|
|
99
126
|
children: 'content positioned absolutely to fill container',
|
|
100
127
|
xstyle: 'StyleX layout customization via stylex.create()',
|
|
101
128
|
},
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* SYNC: When AspectRatio.tsx changes, update tests to match new behavior
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import {describe, it, expect, vi} from 'vitest';
|
|
12
|
+
import {describe, it, expect, vi, beforeAll} from 'vitest';
|
|
13
13
|
import {render, screen} from '@testing-library/react';
|
|
14
14
|
import {AspectRatio} from './AspectRatio';
|
|
15
15
|
|
|
@@ -176,4 +176,145 @@ describe('AspectRatio', () => {
|
|
|
176
176
|
const video = screen.getByTestId('video');
|
|
177
177
|
expect(video).toBeInTheDocument();
|
|
178
178
|
});
|
|
179
|
+
|
|
180
|
+
describe('fit', () => {
|
|
181
|
+
it('marks the child\'s direct parent with data-astryx-aspect-ratio-override for fit="cover"', () => {
|
|
182
|
+
render(
|
|
183
|
+
<AspectRatio ratio={16 / 9} fit="cover">
|
|
184
|
+
<img src="test.jpg" alt="Test" data-testid="image" />
|
|
185
|
+
</AspectRatio>,
|
|
186
|
+
);
|
|
187
|
+
// The marker sits on the child's actual parent, so the reset.css
|
|
188
|
+
// sizing rules are direct-child selectors with no dependence on
|
|
189
|
+
// AspectRatio's internal structure.
|
|
190
|
+
const wrapper = screen.getByTestId('image').parentElement;
|
|
191
|
+
expect(wrapper).toHaveAttribute(
|
|
192
|
+
'data-astryx-aspect-ratio-override',
|
|
193
|
+
'cover',
|
|
194
|
+
);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it('marks the child\'s direct parent with data-astryx-aspect-ratio-override for fit="contain"', () => {
|
|
198
|
+
render(
|
|
199
|
+
<AspectRatio ratio={16 / 9} fit="contain">
|
|
200
|
+
<img src="test.jpg" alt="Test" data-testid="image" />
|
|
201
|
+
</AspectRatio>,
|
|
202
|
+
);
|
|
203
|
+
const wrapper = screen.getByTestId('image').parentElement;
|
|
204
|
+
expect(wrapper).toHaveAttribute(
|
|
205
|
+
'data-astryx-aspect-ratio-override',
|
|
206
|
+
'contain',
|
|
207
|
+
);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it('does not expose fit on the theming surface', () => {
|
|
211
|
+
render(
|
|
212
|
+
<AspectRatio ratio={16 / 9} fit="cover" data-testid="aspect-ratio">
|
|
213
|
+
<img src="test.jpg" alt="Test" />
|
|
214
|
+
</AspectRatio>,
|
|
215
|
+
);
|
|
216
|
+
const element = screen.getByTestId('aspect-ratio');
|
|
217
|
+
// fit is structural, not visual — no data-fit attribute or class
|
|
218
|
+
// token on the themeable root (only shape is a theming target).
|
|
219
|
+
expect(element).not.toHaveAttribute('data-fit');
|
|
220
|
+
expect(element.className).not.toContain('cover');
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
it('emits no marker when fit is omitted (back-compat)', () => {
|
|
224
|
+
render(
|
|
225
|
+
<AspectRatio ratio={16 / 9} data-testid="aspect-ratio">
|
|
226
|
+
<img src="test.jpg" alt="Test" data-testid="image" />
|
|
227
|
+
</AspectRatio>,
|
|
228
|
+
);
|
|
229
|
+
const wrapper = screen.getByTestId('image').parentElement;
|
|
230
|
+
expect(wrapper).not.toHaveAttribute('data-astryx-aspect-ratio-override');
|
|
231
|
+
// Without the marker, none of the reset.css fit rules can match, so
|
|
232
|
+
// existing self-styled children render exactly as before.
|
|
233
|
+
expect(screen.getByTestId('image')).not.toHaveAttribute('class');
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
it('never touches the child element props', () => {
|
|
237
|
+
render(
|
|
238
|
+
<AspectRatio ratio={16 / 9} fit="cover">
|
|
239
|
+
<img
|
|
240
|
+
src="test.jpg"
|
|
241
|
+
alt="Test"
|
|
242
|
+
data-testid="image"
|
|
243
|
+
className="consumer-class"
|
|
244
|
+
style={{objectFit: 'contain'}}
|
|
245
|
+
/>
|
|
246
|
+
</AspectRatio>,
|
|
247
|
+
);
|
|
248
|
+
const image = screen.getByTestId('image');
|
|
249
|
+
// Fit styling is pure CSS (zero-specificity reset rules); the child's
|
|
250
|
+
// own className/style pass through untouched and always win, so
|
|
251
|
+
// children that already size themselves keep their behavior.
|
|
252
|
+
expect(image.className).toBe('consumer-class');
|
|
253
|
+
expect(image.style.objectFit).toBe('contain');
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
it('centers the child via the wrapper with fit="center"', () => {
|
|
257
|
+
render(
|
|
258
|
+
<AspectRatio ratio={16 / 9} fit="center">
|
|
259
|
+
<img src="test.jpg" alt="Test" data-testid="image" />
|
|
260
|
+
</AspectRatio>,
|
|
261
|
+
);
|
|
262
|
+
const image = screen.getByTestId('image');
|
|
263
|
+
expect(image).not.toHaveAttribute('class');
|
|
264
|
+
const wrapper = image.parentElement;
|
|
265
|
+
expect(wrapper?.className).toContain('childCenter');
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
it('does not center the wrapper for other fit values', () => {
|
|
269
|
+
render(
|
|
270
|
+
<AspectRatio ratio={16 / 9} fit="cover">
|
|
271
|
+
<img src="test.jpg" alt="Test" data-testid="image" />
|
|
272
|
+
</AspectRatio>,
|
|
273
|
+
);
|
|
274
|
+
const wrapper = screen.getByTestId('image').parentElement;
|
|
275
|
+
expect(wrapper?.className).not.toContain('childCenter');
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
describe('reset.css fit baseline rules', () => {
|
|
280
|
+
// The cover/contain child sizing ships as zero-specificity baseline
|
|
281
|
+
// rules in reset.css keyed on the data-astryx-aspect-ratio-override
|
|
282
|
+
// marker the component sets on the child's direct parent. These
|
|
283
|
+
// assertions keep the stylesheet in sync with the component contract.
|
|
284
|
+
let resetCSS: string;
|
|
285
|
+
|
|
286
|
+
beforeAll(async () => {
|
|
287
|
+
const fs = await import('fs');
|
|
288
|
+
const path = await import('path');
|
|
289
|
+
resetCSS = fs.readFileSync(
|
|
290
|
+
path.resolve(__dirname, '../reset.css'),
|
|
291
|
+
'utf-8',
|
|
292
|
+
);
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
it('sizes the child to fill the box for cover and contain', () => {
|
|
296
|
+
const fillMatch = resetCSS.match(
|
|
297
|
+
/:where\(\[data-astryx-aspect-ratio-override="cover"\], \[data-astryx-aspect-ratio-override="contain"\]\)\s*>\s*:where\(\*\)\s*\{([^}]+)\}/,
|
|
298
|
+
);
|
|
299
|
+
expect(fillMatch).not.toBeNull();
|
|
300
|
+
expect(fillMatch![1]).toContain('width: 100%');
|
|
301
|
+
expect(fillMatch![1]).toContain('height: 100%');
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
it('crops media with object-fit: cover for fit="cover"', () => {
|
|
305
|
+
const coverMatch = resetCSS.match(
|
|
306
|
+
/:where\(\[data-astryx-aspect-ratio-override="cover"\]\)\s*>\s*:where\(img, video\)\s*\{([^}]+)\}/,
|
|
307
|
+
);
|
|
308
|
+
expect(coverMatch).not.toBeNull();
|
|
309
|
+
expect(coverMatch![1]).toContain('object-fit: cover');
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
it('letterboxes media with object-fit: contain for fit="contain"', () => {
|
|
313
|
+
const containMatch = resetCSS.match(
|
|
314
|
+
/:where\(\[data-astryx-aspect-ratio-override="contain"\]\)\s*>\s*:where\(img, video\)\s*\{([^}]+)\}/,
|
|
315
|
+
);
|
|
316
|
+
expect(containMatch).not.toBeNull();
|
|
317
|
+
expect(containMatch![1]).toContain('object-fit: contain');
|
|
318
|
+
});
|
|
319
|
+
});
|
|
179
320
|
});
|