@astryxdesign/core 0.4.7 → 0.5.0-canary.009bcb3
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 +161 -1
- package/dist/AlertDialog/AlertDialog.d.ts +1 -1
- package/dist/AlertDialog/AlertDialog.d.ts.map +1 -1
- package/dist/AlertDialog/AlertDialog.js +45 -20
- package/dist/AppShell/AppShell.d.ts.map +1 -1
- package/dist/AppShell/AppShell.js +3 -2
- package/dist/AspectRatio/AspectRatio.d.ts +24 -0
- package/dist/AspectRatio/AspectRatio.d.ts.map +1 -1
- package/dist/AspectRatio/AspectRatio.js +23 -4
- package/dist/Avatar/Avatar.d.ts +25 -1
- package/dist/Avatar/Avatar.d.ts.map +1 -1
- package/dist/Avatar/Avatar.js +58 -19
- package/dist/Avatar/index.d.ts +2 -2
- package/dist/Avatar/index.d.ts.map +1 -1
- package/dist/Avatar/index.js +1 -1
- package/dist/AvatarGroup/AvatarGroup.d.ts +9 -2
- package/dist/AvatarGroup/AvatarGroup.d.ts.map +1 -1
- package/dist/AvatarGroup/AvatarGroup.js +8 -4
- package/dist/AvatarGroup/AvatarGroupContext.d.ts +2 -1
- package/dist/AvatarGroup/AvatarGroupContext.d.ts.map +1 -1
- package/dist/AvatarGroup/AvatarGroupOverflow.d.ts.map +1 -1
- package/dist/AvatarGroup/AvatarGroupOverflow.js +10 -6
- package/dist/Banner/Banner.d.ts +49 -15
- package/dist/Banner/Banner.d.ts.map +1 -1
- package/dist/Banner/Banner.js +62 -20
- package/dist/BottomSheet/BottomSheet.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheet.js +17 -4
- package/dist/BottomSheet/BottomSheetSwitcher.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheetSwitcher.js +3 -2
- package/dist/Breadcrumbs/BreadcrumbItem.d.ts.map +1 -1
- package/dist/Breadcrumbs/BreadcrumbItem.js +11 -10
- package/dist/Button/Button.d.ts.map +1 -1
- package/dist/Button/Button.js +11 -6
- package/dist/ButtonGroup/ButtonGroup.d.ts +5 -1
- package/dist/ButtonGroup/ButtonGroup.d.ts.map +1 -1
- package/dist/ButtonGroup/ButtonGroup.js +26 -7
- package/dist/Calendar/Calendar.d.ts +7 -3
- package/dist/Calendar/Calendar.d.ts.map +1 -1
- package/dist/Calendar/Calendar.js +21 -23
- package/dist/Calendar/getInitialFocusDate.d.ts +46 -0
- package/dist/Calendar/getInitialFocusDate.d.ts.map +1 -0
- package/dist/Calendar/getInitialFocusDate.js +62 -0
- package/dist/Calendar/styles.d.ts +5 -14
- package/dist/Calendar/styles.d.ts.map +1 -1
- package/dist/Calendar/styles.js +15 -15
- package/dist/Card/Card.d.ts +12 -12
- package/dist/Card/Card.d.ts.map +1 -1
- package/dist/Card/Card.js +17 -9
- package/dist/Card/index.d.ts +35 -1
- package/dist/Card/index.d.ts.map +1 -1
- package/dist/Card/index.js +21 -1
- package/dist/Carousel/Carousel.d.ts.map +1 -1
- package/dist/Carousel/Carousel.js +3 -3
- package/dist/Chat/ChatComposerInput.d.ts.map +1 -1
- package/dist/Chat/ChatComposerInput.js +2 -3
- package/dist/Chat/ChatLayout.d.ts.map +1 -1
- package/dist/Chat/ChatLayout.js +3 -3
- package/dist/Chat/ChatMessageList.d.ts +22 -3
- package/dist/Chat/ChatMessageList.d.ts.map +1 -1
- package/dist/Chat/ChatMessageList.js +6 -3
- package/dist/Chat/ChatTokenizedText.d.ts +2 -0
- package/dist/Chat/ChatTokenizedText.d.ts.map +1 -1
- package/dist/Chat/ChatTokenizedText.js +11 -6
- package/dist/Chat/useChatComposerTokens.js +1 -1
- package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
- package/dist/CheckboxInput/CheckboxInput.js +10 -3
- package/dist/ClickableCard/ClickableCard.d.ts.map +1 -1
- package/dist/ClickableCard/ClickableCard.js +3 -3
- package/dist/CodeBlock/CodeBlock.d.ts.map +1 -1
- package/dist/CodeBlock/CodeBlock.js +15 -4
- package/dist/CodeBlock/highlightRanges.js +1 -1
- package/dist/CodeBlock/highlightStyles.js +13 -13
- package/dist/CommandPalette/CommandPaletteInput.d.ts.map +1 -1
- package/dist/CommandPalette/CommandPaletteInput.js +3 -2
- package/dist/CommandPalette/CommandPaletteItem.d.ts.map +1 -1
- package/dist/CommandPalette/CommandPaletteItem.js +3 -2
- package/dist/ComplexSelector/ComplexSelector.d.ts.map +1 -1
- package/dist/ComplexSelector/ComplexSelector.js +1 -3
- package/dist/ContextMenu/ContextMenu.d.ts.map +1 -1
- package/dist/ContextMenu/ContextMenu.js +4 -3
- package/dist/DateInput/DateInput.d.ts +43 -0
- package/dist/DateInput/DateInput.d.ts.map +1 -1
- package/dist/DateInput/DateInput.js +22 -2
- package/dist/DateInput/NativeDateField.d.ts +10 -0
- package/dist/DateInput/NativeDateField.d.ts.map +1 -0
- package/dist/DateInput/NativeDateField.js +494 -0
- package/dist/DateInput/TouchDateField.d.ts.map +1 -1
- package/dist/DateInput/TouchDateField.js +82 -23
- package/dist/DateInput/index.d.ts +1 -1
- package/dist/DateInput/index.d.ts.map +1 -1
- package/dist/DateInput/nativeDateSegments.d.ts +22 -0
- package/dist/DateInput/nativeDateSegments.d.ts.map +1 -0
- package/dist/DateInput/nativeDateSegments.js +111 -0
- package/dist/DateRangeInput/DateRangeInput.d.ts +4 -2
- package/dist/DateRangeInput/DateRangeInput.d.ts.map +1 -1
- package/dist/DateTimeInput/DateTimeInput.d.ts +21 -1
- package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
- package/dist/DateTimeInput/DateTimeInput.js +406 -12
- package/dist/DateTimeInput/index.d.ts +1 -1
- package/dist/DateTimeInput/index.d.ts.map +1 -1
- package/dist/Dialog/Dialog.d.ts +21 -1
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +110 -58
- package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenu.js +4 -13
- package/dist/DropdownMenu/DropdownMenuSubMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuSubMenu.js +6 -5
- package/dist/Field/FieldLabel.d.ts.map +1 -1
- package/dist/Field/FieldLabel.js +9 -1
- package/dist/Field/InputClearButton.d.ts +9 -3
- package/dist/Field/InputClearButton.d.ts.map +1 -1
- package/dist/Field/InputClearButton.js +14 -3
- package/dist/FileInput/FileInput.d.ts.map +1 -1
- package/dist/FileInput/FileInput.js +3 -2
- package/dist/Heading/Heading.d.ts.map +1 -1
- package/dist/Heading/Heading.js +6 -3
- package/dist/HoverCard/HoverCard.d.ts +6 -0
- package/dist/HoverCard/HoverCard.d.ts.map +1 -1
- package/dist/HoverCard/HoverCard.js +104 -3
- package/dist/HoverCard/useHoverCard.d.ts +19 -2
- package/dist/HoverCard/useHoverCard.d.ts.map +1 -1
- package/dist/HoverCard/useHoverCard.js +74 -26
- package/dist/Indicator/CheckboxIndicator.d.ts.map +1 -1
- package/dist/Indicator/CheckboxIndicator.js +6 -2
- package/dist/Item/Item.d.ts.map +1 -1
- package/dist/Item/Item.js +4 -2
- package/dist/Kbd/Kbd.d.ts.map +1 -1
- package/dist/Kbd/Kbd.js +2 -19
- package/dist/Layer/LayerDepthContext.d.ts +52 -0
- package/dist/Layer/LayerDepthContext.d.ts.map +1 -0
- package/dist/Layer/LayerDepthContext.js +66 -0
- package/dist/Layer/gestureCounter.d.ts +8 -0
- package/dist/Layer/gestureCounter.d.ts.map +1 -0
- package/dist/Layer/gestureCounter.js +53 -0
- package/dist/Layer/index.d.ts +3 -0
- package/dist/Layer/index.d.ts.map +1 -1
- package/dist/Layer/index.js +4 -0
- package/dist/Layer/layerStack.d.ts +98 -0
- package/dist/Layer/layerStack.d.ts.map +1 -0
- package/dist/Layer/layerStack.js +306 -0
- package/dist/Layer/useLayer.d.ts +23 -13
- package/dist/Layer/useLayer.d.ts.map +1 -1
- package/dist/Layer/useLayer.js +128 -8
- package/dist/Layer/useLayerDismissal.d.ts +93 -0
- package/dist/Layer/useLayerDismissal.d.ts.map +1 -0
- package/dist/Layer/useLayerDismissal.js +91 -0
- package/dist/Lightbox/Lightbox.d.ts +1 -0
- package/dist/Lightbox/Lightbox.d.ts.map +1 -1
- package/dist/Lightbox/Lightbox.js +103 -81
- package/dist/List/List.d.ts +1 -1
- package/dist/List/List.d.ts.map +1 -1
- package/dist/List/List.js +15 -4
- package/dist/Markdown/Markdown.d.ts +1 -1
- package/dist/Markdown/Markdown.d.ts.map +1 -1
- package/dist/Markdown/Markdown.js +20 -7
- package/dist/Markdown/index.d.ts +1 -1
- package/dist/Markdown/index.d.ts.map +1 -1
- package/dist/Markdown/parser.d.ts +38 -1
- package/dist/Markdown/parser.d.ts.map +1 -1
- package/dist/Markdown/parser.js +182 -32
- package/dist/MetadataList/MetadataListItem.d.ts +1 -1
- package/dist/MetadataList/MetadataListItem.d.ts.map +1 -1
- package/dist/MetadataList/MetadataListItem.js +4 -1
- package/dist/MobileNav/MobileNav.d.ts +6 -1
- package/dist/MobileNav/MobileNav.d.ts.map +1 -1
- package/dist/MobileNav/MobileNav.js +61 -36
- package/dist/MultiSelector/MultiSelector.d.ts +32 -1
- package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
- package/dist/MultiSelector/MultiSelector.js +73 -15
- package/dist/MultiSelector/hooks.d.ts +7 -1
- package/dist/MultiSelector/hooks.d.ts.map +1 -1
- package/dist/MultiSelector/hooks.js +3 -2
- package/dist/MultiSelector/index.d.ts +1 -1
- package/dist/MultiSelector/index.d.ts.map +1 -1
- package/dist/NavIcon/NavIcon.d.ts.map +1 -1
- package/dist/NavIcon/NavIcon.js +5 -1
- package/dist/NavMenu/NavHeadingMenu.d.ts +1 -1
- package/dist/NavMenu/NavHeadingMenu.d.ts.map +1 -1
- package/dist/NavMenu/NavHeadingMenu.js +9 -5
- package/dist/NumberInput/NumberInput.d.ts +6 -1
- package/dist/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/NumberInput/NumberInput.js +54 -104
- package/dist/NumberInput/numberInputCommit.d.ts +34 -0
- package/dist/NumberInput/numberInputCommit.d.ts.map +1 -0
- package/dist/NumberInput/numberInputCommit.js +71 -0
- package/dist/NumberInput/numberParser.d.ts +64 -0
- package/dist/NumberInput/numberParser.d.ts.map +1 -0
- package/dist/NumberInput/numberParser.js +350 -0
- package/dist/Outline/Outline.d.ts.map +1 -1
- package/dist/Outline/Outline.js +3 -2
- package/dist/OverflowList/OverflowList.d.ts.map +1 -1
- package/dist/OverflowList/OverflowList.js +3 -2
- package/dist/Overlay/Overlay.d.ts.map +1 -1
- package/dist/Overlay/Overlay.js +3 -2
- package/dist/Popover/Popover.d.ts.map +1 -1
- package/dist/Popover/Popover.js +1 -9
- package/dist/Popover/usePopover.d.ts +7 -41
- package/dist/Popover/usePopover.d.ts.map +1 -1
- package/dist/Popover/usePopover.js +40 -21
- package/dist/PowerSearch/PowerSearch.d.ts +8 -2
- package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearch.js +19 -6
- package/dist/PowerSearch/PowerSearchEditPopover.d.ts +3 -1
- package/dist/PowerSearch/PowerSearchEditPopover.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchEditPopover.js +28 -6
- package/dist/PowerSearch/PowerSearchValueEditor.d.ts +3 -1
- package/dist/PowerSearch/PowerSearchValueEditor.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchValueEditor.js +110 -27
- package/dist/PowerSearch/types.d.ts +2 -0
- package/dist/PowerSearch/types.d.ts.map +1 -1
- package/dist/PowerSearch/usePowerSearchSource.d.ts +6 -1
- package/dist/PowerSearch/usePowerSearchSource.d.ts.map +1 -1
- package/dist/PowerSearch/usePowerSearchSource.js +14 -5
- package/dist/ProgressBar/ProgressBar.d.ts.map +1 -1
- package/dist/ProgressBar/ProgressBar.js +18 -5
- package/dist/Resizable/ResizeHandle.d.ts.map +1 -1
- package/dist/Resizable/ResizeHandle.js +3 -2
- package/dist/SegmentedControl/SegmentedControl.d.ts.map +1 -1
- package/dist/SegmentedControl/SegmentedControl.js +3 -2
- package/dist/SelectableCard/SelectableCard.d.ts.map +1 -1
- package/dist/SelectableCard/SelectableCard.js +12 -3
- package/dist/Selector/Selector.d.ts +18 -1
- package/dist/Selector/Selector.d.ts.map +1 -1
- package/dist/Selector/Selector.js +91 -18
- package/dist/Selector/hooks.d.ts +7 -1
- package/dist/Selector/hooks.d.ts.map +1 -1
- package/dist/Selector/hooks.js +3 -2
- package/dist/SideNav/SideNav.d.ts.map +1 -1
- package/dist/SideNav/SideNav.js +4 -3
- package/dist/SideNav/SideNavHeading.d.ts.map +1 -1
- package/dist/SideNav/SideNavHeading.js +8 -7
- package/dist/SideNav/SideNavItem.d.ts.map +1 -1
- package/dist/SideNav/SideNavItem.js +4 -3
- package/dist/Slider/Slider.d.ts.map +1 -1
- package/dist/Slider/Slider.js +37 -5
- package/dist/Spinner/Spinner.d.ts +3 -3
- package/dist/Spinner/Spinner.d.ts.map +1 -1
- package/dist/Spinner/Spinner.js +130 -78
- package/dist/StatusDot/StatusDot.d.ts.map +1 -1
- package/dist/StatusDot/StatusDot.js +6 -1
- package/dist/Stepper/Step.d.ts +140 -0
- package/dist/Stepper/Step.d.ts.map +1 -0
- package/dist/Stepper/Step.js +1045 -0
- package/dist/Stepper/StepStatus.d.ts +24 -0
- package/dist/Stepper/StepStatus.d.ts.map +1 -0
- package/dist/Stepper/StepStatus.js +1 -0
- package/dist/Stepper/Stepper.d.ts +93 -0
- package/dist/Stepper/Stepper.d.ts.map +1 -0
- package/dist/Stepper/Stepper.js +184 -0
- package/dist/Stepper/StepperContext.d.ts +41 -0
- package/dist/Stepper/StepperContext.d.ts.map +1 -0
- package/dist/Stepper/StepperContext.js +34 -0
- package/dist/Stepper/index.d.ts +8 -0
- package/dist/Stepper/index.d.ts.map +1 -0
- package/dist/Stepper/index.js +7 -0
- package/dist/Stepper/stepper.stylex.d.ts +15 -0
- package/dist/Stepper/stepper.stylex.d.ts.map +1 -0
- package/dist/Stepper/stepper.stylex.js +20 -0
- package/dist/Switch/Switch.d.ts.map +1 -1
- package/dist/Switch/Switch.js +8 -3
- package/dist/TabList/Tab.d.ts +15 -2
- package/dist/TabList/Tab.d.ts.map +1 -1
- package/dist/TabList/Tab.js +32 -7
- package/dist/TabList/TabList.d.ts +46 -7
- package/dist/TabList/TabList.d.ts.map +1 -1
- package/dist/TabList/TabList.js +353 -23
- package/dist/TabList/TabListContext.d.ts +11 -1
- package/dist/TabList/TabListContext.d.ts.map +1 -1
- package/dist/TabList/TabListContext.js +11 -2
- package/dist/TabList/TabMenu.d.ts.map +1 -1
- package/dist/TabList/TabMenu.js +3 -2
- package/dist/TabList/index.d.ts +2 -2
- package/dist/TabList/index.d.ts.map +1 -1
- package/dist/Table/BaseTable.d.ts.map +1 -1
- package/dist/Table/BaseTable.js +10 -2
- package/dist/Table/Table.d.ts.map +1 -1
- package/dist/Table/Table.js +3 -6
- package/dist/Table/TableRow.d.ts +16 -5
- package/dist/Table/TableRow.d.ts.map +1 -1
- package/dist/Table/TableRow.js +16 -5
- package/dist/Table/plugins/filtering/useTableFiltering.d.ts.map +1 -1
- package/dist/Table/plugins/filtering/useTableFiltering.js +73 -4
- package/dist/Table/plugins/groupedRows/useTableGroupedRows.d.ts +26 -0
- package/dist/Table/plugins/groupedRows/useTableGroupedRows.d.ts.map +1 -1
- package/dist/Table/plugins/groupedRows/useTableGroupedRows.js +54 -11
- package/dist/Table/plugins/pagination/useTablePagination.d.ts +3 -0
- package/dist/Table/plugins/pagination/useTablePagination.d.ts.map +1 -1
- package/dist/Table/plugins/pagination/useTablePagination.js +21 -4
- package/dist/Table/plugins/rowExpansion/useTableRowExpansion.d.ts.map +1 -1
- package/dist/Table/plugins/rowExpansion/useTableRowExpansion.js +7 -2
- package/dist/Table/plugins/rowStatus/useTableRowStatus.d.ts.map +1 -1
- package/dist/Table/plugins/rowStatus/useTableRowStatus.js +10 -3
- package/dist/Table/plugins/selection/useTableSelection.d.ts +16 -0
- package/dist/Table/plugins/selection/useTableSelection.d.ts.map +1 -1
- package/dist/Table/plugins/selection/useTableSelection.js +43 -5
- package/dist/Table/plugins/stickyColumns/useTableStickyColumns.d.ts.map +1 -1
- package/dist/Table/plugins/stickyColumns/useTableStickyColumns.js +3 -4
- package/dist/Table/types.d.ts +22 -4
- package/dist/Table/types.d.ts.map +1 -1
- package/dist/Table/useBaseTablePlugins.d.ts.map +1 -1
- package/dist/Table/useBaseTablePlugins.js +5 -0
- package/dist/Text/Text.d.ts.map +1 -1
- package/dist/Text/Text.js +6 -3
- package/dist/TextArea/TextArea.d.ts.map +1 -1
- package/dist/TextArea/TextArea.js +16 -10
- package/dist/TextInput/TextInput.d.ts.map +1 -1
- package/dist/TextInput/TextInput.js +3 -2
- package/dist/TimeInput/TimeInput.d.ts.map +1 -1
- package/dist/TimeInput/TimeInput.js +3 -2
- package/dist/Timestamp/Timestamp.d.ts +1 -1
- package/dist/Timestamp/Timestamp.d.ts.map +1 -1
- package/dist/Timestamp/Timestamp.js +15 -21
- package/dist/Toast/Toast.d.ts.map +1 -1
- package/dist/Toast/Toast.js +22 -7
- package/dist/Toast/ToastViewport.d.ts +1 -0
- package/dist/Toast/ToastViewport.d.ts.map +1 -1
- package/dist/Toast/ToastViewport.js +71 -18
- package/dist/Token/Token.d.ts +1 -1
- package/dist/Token/Token.d.ts.map +1 -1
- package/dist/Token/Token.js +20 -9
- package/dist/Token/TokenLink.d.ts +1 -1
- package/dist/Token/TokenLink.d.ts.map +1 -1
- package/dist/Token/TokenLink.js +7 -4
- package/dist/Tokenizer/Tokenizer.d.ts +14 -1
- package/dist/Tokenizer/Tokenizer.d.ts.map +1 -1
- package/dist/Tokenizer/Tokenizer.js +33 -21
- package/dist/Tooltip/Tooltip.d.ts +5 -0
- package/dist/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/Tooltip/useTooltip.d.ts +5 -0
- package/dist/Tooltip/useTooltip.d.ts.map +1 -1
- package/dist/Tooltip/useTooltip.js +39 -24
- package/dist/TopNav/TopNavHeading.d.ts.map +1 -1
- package/dist/TopNav/TopNavHeading.js +5 -4
- package/dist/TopNav/TopNavMegaMenu.d.ts +1 -1
- package/dist/TopNav/TopNavMegaMenu.d.ts.map +1 -1
- package/dist/TopNav/TopNavMegaMenu.js +31 -11
- package/dist/TopNav/TopNavMenu.d.ts +1 -1
- package/dist/TopNav/TopNavMenu.d.ts.map +1 -1
- package/dist/TopNav/TopNavMenu.js +22 -7
- package/dist/TreeList/TreeList.d.ts +1 -1
- package/dist/TreeList/TreeList.d.ts.map +1 -1
- package/dist/TreeList/TreeList.js +7 -2
- package/dist/Typeahead/BaseTypeahead.d.ts +35 -0
- package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
- package/dist/Typeahead/BaseTypeahead.js +119 -37
- package/dist/Typeahead/Typeahead.d.ts +8 -1
- package/dist/Typeahead/Typeahead.d.ts.map +1 -1
- package/dist/Typeahead/Typeahead.js +5 -2
- package/dist/Typeahead/TypeaheadItem.d.ts +1 -1
- package/dist/Typeahead/TypeaheadItem.d.ts.map +1 -1
- package/dist/Typeahead/TypeaheadItem.js +7 -2
- package/dist/astryx.css +113 -11
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useFocusTrap.d.ts +7 -4
- package/dist/hooks/useFocusTrap.d.ts.map +1 -1
- package/dist/hooks/useFocusTrap.js +60 -95
- package/dist/hooks/useHotkeys.d.ts.map +1 -1
- package/dist/hooks/useHotkeys.js +3 -18
- package/dist/hooks/useMergedRefs.d.ts +18 -0
- package/dist/hooks/useMergedRefs.d.ts.map +1 -0
- package/dist/hooks/useMergedRefs.js +25 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/theme/Theme.d.ts.map +1 -1
- package/dist/theme/Theme.js +46 -10
- package/dist/theme/derivedVarRegistry.d.ts.map +1 -1
- package/dist/theme/derivedVarRegistry.js +24 -4
- package/dist/theme/generateThemeRules.d.ts +21 -0
- package/dist/theme/generateThemeRules.d.ts.map +1 -1
- package/dist/theme/generateThemeRules.js +26 -0
- package/dist/theme/syntax/tokens.d.ts +1 -1
- package/dist/theme/syntax/tokens.d.ts.map +1 -1
- package/dist/theme/syntax/tokens.js +5 -2
- package/dist/utils/groupItems.d.ts +5 -1
- package/dist/utils/groupItems.d.ts.map +1 -1
- package/dist/utils/groupItems.js +9 -9
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/isApplePlatform.d.ts +18 -0
- package/dist/utils/isApplePlatform.d.ts.map +1 -0
- package/dist/utils/isApplePlatform.js +37 -0
- package/dist/utils/sharedResizeObserver.d.ts.map +1 -1
- package/dist/utils/sharedResizeObserver.js +10 -1
- package/dist/utils/timeParser.d.ts +1 -1
- package/dist/utils/timeParser.d.ts.map +1 -1
- package/dist/utils/timeParser.js +26 -12
- package/locales/af-ZA.json +6 -6
- package/locales/ar-SA.json +6 -6
- package/locales/ca-ES.json +5 -5
- package/locales/cs-CZ.json +6 -6
- package/locales/da-DK.json +6 -6
- package/locales/de-DE.json +6 -6
- package/locales/el-GR.json +6 -6
- package/locales/en.json +163 -11
- package/locales/es-ES.json +5 -5
- package/locales/fi-FI.json +6 -6
- package/locales/fr-FR.json +6 -6
- package/locales/he-IL.json +6 -6
- package/locales/hu-HU.json +6 -6
- package/locales/it-IT.json +6 -6
- package/locales/ja-JP.json +6 -6
- package/locales/ko-KR.json +6 -6
- package/locales/nl-NL.json +6 -6
- package/locales/no-NO.json +6 -6
- package/locales/pl-PL.json +6 -6
- package/locales/pseudo.json +114 -0
- package/locales/pt-BR.json +6 -6
- package/locales/pt-PT.json +6 -6
- package/locales/ro-RO.json +6 -6
- package/locales/ru-RU.json +6 -6
- package/locales/sr-SP.json +6 -6
- package/locales/sv-SE.json +6 -6
- package/locales/tr-TR.json +6 -6
- package/locales/uk-UA.json +6 -6
- package/locales/vi-VN.json +6 -6
- package/locales/zh-CN.json +6 -6
- package/locales/zh-TW.json +6 -6
- package/package.json +8 -3
- package/src/AlertDialog/AlertDialog.doc.mjs +114 -30
- package/src/AlertDialog/AlertDialog.test.tsx +211 -2
- package/src/AlertDialog/AlertDialog.tsx +62 -20
- package/src/AppShell/AppShell.tsx +3 -2
- package/src/AspectRatio/AspectRatio.doc.mjs +6 -3
- package/src/AspectRatio/AspectRatio.test.tsx +57 -10
- package/src/AspectRatio/AspectRatio.tsx +40 -1
- package/src/Avatar/Avatar.doc.mjs +14 -3
- package/src/Avatar/Avatar.test.tsx +97 -0
- package/src/Avatar/Avatar.tsx +125 -52
- package/src/Avatar/index.ts +2 -2
- package/src/AvatarGroup/AvatarGroup.doc.mjs +8 -2
- package/src/AvatarGroup/AvatarGroup.test.tsx +24 -0
- package/src/AvatarGroup/AvatarGroup.tsx +15 -6
- package/src/AvatarGroup/AvatarGroupContext.ts +5 -3
- package/src/AvatarGroup/AvatarGroupOverflow.tsx +10 -4
- package/src/Banner/Banner.doc.mjs +22 -11
- package/src/Banner/Banner.test.tsx +177 -25
- package/src/Banner/Banner.tsx +93 -27
- package/src/BottomSheet/BottomSheet.test.tsx +123 -0
- package/src/BottomSheet/BottomSheet.tsx +17 -4
- package/src/BottomSheet/BottomSheetSwitcher.tsx +3 -2
- package/src/Breadcrumbs/BreadcrumbItem.tsx +9 -5
- package/src/Button/Button.doc.mjs +24 -1
- package/src/Button/Button.test.tsx +32 -4
- package/src/Button/Button.tsx +12 -5
- package/src/ButtonGroup/ButtonGroup.doc.mjs +10 -1
- package/src/ButtonGroup/ButtonGroup.test.tsx +404 -1
- package/src/ButtonGroup/ButtonGroup.tsx +23 -5
- package/src/Calendar/Calendar.doc.mjs +7 -6
- package/src/Calendar/Calendar.test.tsx +143 -0
- package/src/Calendar/Calendar.tsx +30 -26
- package/src/Calendar/getInitialFocusDate.test.ts +94 -0
- package/src/Calendar/getInitialFocusDate.ts +93 -0
- package/src/Calendar/styles.ts +49 -31
- package/src/Card/Card.doc.mjs +10 -7
- package/src/Card/Card.test.tsx +113 -19
- package/src/Card/Card.tsx +67 -89
- package/src/Card/index.ts +36 -1
- package/src/Carousel/Carousel.tsx +3 -2
- package/src/Chat/ChatComposerInput.tsx +5 -1
- package/src/Chat/ChatLayout.tsx +3 -2
- package/src/Chat/ChatMessageList.doc.mjs +9 -1
- package/src/Chat/ChatMessageList.test.tsx +46 -0
- package/src/Chat/ChatMessageList.tsx +28 -4
- package/src/Chat/ChatTokenizedText.tsx +17 -10
- package/src/Chat/useChatComposerTokens.ts +1 -1
- package/src/CheckboxInput/CheckboxInput.doc.mjs +2 -0
- package/src/CheckboxInput/CheckboxInput.test.tsx +15 -0
- package/src/CheckboxInput/CheckboxInput.tsx +8 -2
- package/src/ClickableCard/ClickableCard.tsx +3 -2
- package/src/CodeBlock/CodeBlock.doc.mjs +16 -4
- package/src/CodeBlock/CodeBlock.test.tsx +37 -0
- package/src/CodeBlock/CodeBlock.tsx +20 -4
- package/src/CodeBlock/highlightRanges.ts +1 -1
- package/src/CodeBlock/highlightStyles.ts +13 -13
- package/src/CommandPalette/CommandPaletteInput.tsx +3 -2
- package/src/CommandPalette/CommandPaletteItem.tsx +3 -2
- package/src/ComplexSelector/ComplexSelector.test.tsx +32 -0
- package/src/ComplexSelector/ComplexSelector.tsx +1 -3
- package/src/ContextMenu/ContextMenu.doc.mjs +5 -0
- package/src/ContextMenu/ContextMenu.tsx +4 -3
- package/src/DateInput/DateInput.doc.mjs +16 -0
- package/src/DateInput/DateInput.tsx +55 -2
- package/src/DateInput/DateInputTouch.test.tsx +146 -32
- package/src/DateInput/NativeDateField.test.tsx +635 -0
- package/src/DateInput/NativeDateField.tsx +641 -0
- package/src/DateInput/TouchDateField.tsx +108 -24
- package/src/DateInput/index.ts +1 -0
- package/src/DateInput/nativeDateSegments.ts +127 -0
- package/src/DateRangeInput/DateRangeInput.doc.mjs +2 -2
- package/src/DateRangeInput/DateRangeInput.test.tsx +22 -0
- package/src/DateRangeInput/DateRangeInput.tsx +4 -2
- package/src/DateTimeInput/DateTimeInput.doc.mjs +18 -0
- package/src/DateTimeInput/DateTimeInput.test.tsx +1088 -0
- package/src/DateTimeInput/DateTimeInput.tsx +556 -24
- package/src/DateTimeInput/index.ts +1 -0
- package/src/Dialog/Dialog.doc.mjs +8 -3
- package/src/Dialog/Dialog.test.tsx +429 -2
- package/src/Dialog/Dialog.tsx +133 -58
- package/src/DropdownMenu/DropdownMenu.doc.mjs +6 -0
- package/src/DropdownMenu/DropdownMenu.test.tsx +44 -10
- package/src/DropdownMenu/DropdownMenu.tsx +4 -13
- package/src/DropdownMenu/DropdownMenuSubMenu.test.tsx +8 -5
- package/src/DropdownMenu/DropdownMenuSubMenu.tsx +8 -11
- package/src/Field/Field.doc.mjs +13 -2
- package/src/Field/FieldLabel.test.tsx +29 -0
- package/src/Field/FieldLabel.tsx +7 -0
- package/src/Field/InputClearButton.test.tsx +15 -1
- package/src/Field/InputClearButton.tsx +28 -4
- package/src/FileInput/FileInput.tsx +3 -2
- package/src/Heading/Heading.test.tsx +23 -1
- package/src/Heading/Heading.tsx +6 -3
- package/src/HoverCard/HoverCard.doc.mjs +13 -2
- package/src/HoverCard/HoverCard.test.tsx +154 -4
- package/src/HoverCard/HoverCard.tsx +143 -3
- package/src/HoverCard/useHoverCard.tsx +104 -33
- package/src/Indicator/CheckboxIndicator.tsx +14 -8
- package/src/Indicator/Indicator.doc.mjs +2 -0
- package/src/Item/Item.tsx +5 -4
- package/src/Kbd/Kbd.tsx +2 -19
- package/src/Layer/LayerDepthContext.tsx +62 -0
- package/src/Layer/gestureCounter.ts +57 -0
- package/src/Layer/index.ts +9 -0
- package/src/Layer/layerDismissalFamilies.test.tsx +359 -0
- package/src/Layer/layerDismissalInvariants.test.tsx +417 -0
- package/src/Layer/layerStack.ts +362 -0
- package/src/Layer/useLayer.test.tsx +324 -15
- package/src/Layer/useLayer.tsx +164 -8
- package/src/Layer/useLayerDismissal.test.tsx +469 -0
- package/src/Layer/useLayerDismissal.ts +173 -0
- package/src/Layout/Layout.doc.mjs +2 -2
- package/src/Layout/__tests__/edgeCompensation.test.tsx +1 -1
- package/src/Lightbox/Lightbox.doc.mjs +12 -0
- package/src/Lightbox/Lightbox.tsx +124 -102
- package/src/Link/Link.doc.mjs +39 -0
- package/src/List/List.test.tsx +38 -0
- package/src/List/List.tsx +8 -1
- package/src/Markdown/Markdown.doc.mjs +5 -0
- package/src/Markdown/Markdown.test.tsx +37 -0
- package/src/Markdown/Markdown.tsx +16 -5
- package/src/Markdown/incremental.test.ts +16 -2
- package/src/Markdown/index.ts +1 -0
- package/src/Markdown/parser.perf.test.ts +96 -1
- package/src/Markdown/parser.test.ts +178 -2
- package/src/Markdown/parser.ts +253 -32
- package/src/MetadataList/MetadataList.test.tsx +75 -2
- package/src/MetadataList/MetadataListItem.tsx +5 -2
- package/src/MobileNav/MobileNav.tsx +62 -36
- package/src/MoreMenu/MoreMenu.doc.mjs +7 -1
- package/src/MultiSelector/MultiSelector.doc.mjs +49 -1
- package/src/MultiSelector/MultiSelector.test.tsx +311 -0
- package/src/MultiSelector/MultiSelector.tsx +151 -15
- package/src/MultiSelector/hooks.ts +9 -2
- package/src/MultiSelector/index.ts +1 -0
- package/src/NavIcon/NavIcon.doc.mjs +8 -2
- package/src/NavIcon/NavIcon.test.tsx +9 -0
- package/src/NavIcon/NavIcon.tsx +5 -1
- package/src/NavMenu/NavHeadingMenu.test.tsx +30 -0
- package/src/NavMenu/NavHeadingMenu.tsx +9 -5
- package/src/NumberInput/NumberInput.doc.mjs +31 -7
- package/src/NumberInput/NumberInput.test.tsx +436 -8
- package/src/NumberInput/NumberInput.tsx +62 -114
- package/src/NumberInput/numberInputCommit.test.ts +72 -0
- package/src/NumberInput/numberInputCommit.ts +103 -0
- package/src/NumberInput/numberParser.docblock.test.ts +234 -0
- package/src/NumberInput/numberParser.test.ts +222 -0
- package/src/NumberInput/numberParser.ts +403 -0
- package/src/Outline/Outline.tsx +3 -2
- package/src/OverflowList/OverflowList.tsx +3 -2
- package/src/Overlay/Overlay.tsx +3 -2
- package/src/Pagination/Pagination.test.tsx +3 -2
- package/src/Popover/Popover.test.tsx +14 -0
- package/src/Popover/Popover.tsx +1 -9
- package/src/Popover/usePopover.tsx +57 -32
- package/src/PowerSearch/PowerSearch.doc.mjs +160 -28
- package/src/PowerSearch/PowerSearch.test.tsx +240 -1
- package/src/PowerSearch/PowerSearch.tsx +34 -5
- package/src/PowerSearch/PowerSearchEditPopover.test.tsx +288 -0
- package/src/PowerSearch/PowerSearchEditPopover.tsx +29 -2
- package/src/PowerSearch/PowerSearchValueEditor.test.tsx +111 -1
- package/src/PowerSearch/PowerSearchValueEditor.tsx +124 -10
- package/src/PowerSearch/types.ts +2 -0
- package/src/PowerSearch/usePowerSearchSource.test.ts +82 -2
- package/src/PowerSearch/usePowerSearchSource.ts +13 -3
- package/src/ProgressBar/ProgressBar.doc.mjs +42 -6
- package/src/ProgressBar/ProgressBar.test.tsx +24 -0
- package/src/ProgressBar/ProgressBar.tsx +28 -8
- package/src/Resizable/ResizeHandle.tsx +3 -2
- package/src/SegmentedControl/SegmentedControl.tsx +3 -2
- package/src/SelectableCard/SelectableCard.doc.mjs +3 -0
- package/src/SelectableCard/SelectableCard.tsx +19 -2
- package/src/Selector/Selector.doc.mjs +26 -1
- package/src/Selector/Selector.test.tsx +346 -1
- package/src/Selector/Selector.tsx +148 -21
- package/src/Selector/hooks.ts +17 -2
- package/src/SideNav/SideNav.doc.mjs +6 -6
- package/src/SideNav/SideNav.tsx +4 -2
- package/src/SideNav/SideNavHeading.tsx +12 -12
- package/src/SideNav/SideNavItem.tsx +4 -2
- package/src/Slider/Slider.test.tsx +106 -1
- package/src/Slider/Slider.tsx +55 -3
- package/src/Spinner/Spinner.test.tsx +147 -1
- package/src/Spinner/Spinner.tsx +120 -101
- package/src/StatusDot/StatusDot.doc.mjs +8 -2
- package/src/StatusDot/StatusDot.test.tsx +9 -0
- package/src/StatusDot/StatusDot.tsx +7 -1
- package/src/Stepper/Step.doc.mjs +98 -0
- package/src/Stepper/Step.tsx +1638 -0
- package/src/Stepper/StepStatus.ts +26 -0
- package/src/Stepper/Stepper.doc.mjs +370 -0
- package/src/Stepper/Stepper.test.tsx +1024 -0
- package/src/Stepper/Stepper.tsx +258 -0
- package/src/Stepper/StepperContext.ts +71 -0
- package/src/Stepper/index.ts +18 -0
- package/src/Stepper/stepper.stylex.ts +19 -0
- package/src/Switch/Switch.doc.mjs +2 -0
- package/src/Switch/Switch.test.tsx +10 -0
- package/src/Switch/Switch.tsx +6 -2
- package/src/TabList/Tab.doc.mjs +13 -1
- package/src/TabList/Tab.tsx +67 -7
- package/src/TabList/TabList.doc.mjs +22 -6
- package/src/TabList/TabList.test.tsx +559 -0
- package/src/TabList/TabList.tsx +490 -22
- package/src/TabList/TabListContext.ts +13 -2
- package/src/TabList/TabMenu.tsx +3 -2
- package/src/TabList/index.ts +6 -2
- package/src/Table/BaseTable.tsx +12 -4
- package/src/Table/Table.doc.mjs +9 -2
- package/src/Table/Table.test.tsx +132 -14
- package/src/Table/Table.tsx +3 -8
- package/src/Table/TableBody.doc.mjs +40 -0
- package/src/Table/TableFooter.doc.mjs +40 -0
- package/src/Table/TableHeader.doc.mjs +40 -0
- package/src/Table/TableRow.tsx +16 -5
- package/src/Table/plugins/filtering/useTableFiltering.test.tsx +44 -6
- package/src/Table/plugins/filtering/useTableFiltering.tsx +100 -4
- package/src/Table/plugins/groupedRows/useTableGroupedRows-perf.test.tsx +112 -0
- package/src/Table/plugins/groupedRows/useTableGroupedRows.test.tsx +100 -0
- package/src/Table/plugins/groupedRows/useTableGroupedRows.tsx +67 -12
- package/src/Table/plugins/pagination/useTablePagination.test.tsx +34 -4
- package/src/Table/plugins/pagination/useTablePagination.tsx +35 -3
- package/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx +9 -2
- package/src/Table/plugins/rowStatus/useTableRowStatus.test.tsx +13 -7
- package/src/Table/plugins/rowStatus/useTableRowStatus.tsx +12 -3
- package/src/Table/plugins/selection/useTableSelection.test.tsx +138 -0
- package/src/Table/plugins/selection/useTableSelection.tsx +63 -7
- package/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx +1 -2
- package/src/Table/types.ts +22 -4
- package/src/Table/useBaseTablePlugins.ts +5 -0
- package/src/Table/useTableGroupedRows.doc.mjs +5 -4
- package/src/Table/useTablePagination.doc.mjs +7 -0
- package/src/Table/useTableRowStatus.doc.mjs +1 -1
- package/src/Table/useTableSelection.doc.mjs +31 -0
- package/src/Text/Text.test.tsx +67 -1
- package/src/Text/Text.tsx +6 -3
- package/src/TextArea/TextArea.doc.mjs +12 -2
- package/src/TextArea/TextArea.test.tsx +11 -0
- package/src/TextArea/TextArea.tsx +37 -24
- package/src/TextInput/TextInput.doc.mjs +10 -0
- package/src/TextInput/TextInput.tsx +3 -2
- package/src/Thumbnail/Thumbnail.doc.mjs +1 -1
- package/src/TimeInput/TimeInput.tsx +2 -2
- package/src/Timestamp/Timestamp.test.tsx +58 -0
- package/src/Timestamp/Timestamp.tsx +12 -10
- package/src/Toast/Toast.doc.mjs +26 -12
- package/src/Toast/Toast.tsx +28 -4
- package/src/Toast/ToastViewport.test.tsx +536 -8
- package/src/Toast/ToastViewport.tsx +81 -12
- package/src/Token/Token.test.tsx +95 -0
- package/src/Token/Token.tsx +15 -10
- package/src/Token/TokenLink.tsx +14 -5
- package/src/Tokenizer/Tokenizer.doc.mjs +43 -3
- package/src/Tokenizer/Tokenizer.test.tsx +161 -0
- package/src/Tokenizer/Tokenizer.tsx +53 -24
- package/src/Toolbar/Toolbar.doc.mjs +5 -0
- package/src/Tooltip/Tooltip.doc.mjs +5 -0
- package/src/Tooltip/Tooltip.test.tsx +32 -0
- package/src/Tooltip/Tooltip.tsx +5 -0
- package/src/Tooltip/useTooltip.tsx +47 -24
- package/src/TopNav/TopNavHeading.tsx +5 -4
- package/src/TopNav/TopNavMegaMenu.test.tsx +104 -0
- package/src/TopNav/TopNavMegaMenu.tsx +47 -5
- package/src/TopNav/TopNavMenu.test.tsx +133 -1
- package/src/TopNav/TopNavMenu.tsx +38 -7
- package/src/TreeList/TreeList.test.tsx +49 -0
- package/src/TreeList/TreeList.tsx +7 -2
- package/src/Typeahead/BaseTypeahead.doc.mjs +24 -0
- package/src/Typeahead/BaseTypeahead.tsx +181 -39
- package/src/Typeahead/Typeahead.doc.mjs +11 -0
- package/src/Typeahead/Typeahead.test.tsx +203 -0
- package/src/Typeahead/Typeahead.tsx +12 -2
- package/src/Typeahead/TypeaheadItem.test.tsx +43 -0
- package/src/Typeahead/TypeaheadItem.tsx +8 -1
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useAnnounce.doc.mjs +96 -0
- package/src/hooks/useContainerReveal.doc.mjs +2 -2
- package/src/hooks/useDevWarning.doc.mjs +96 -0
- package/src/hooks/useFocusTrap.test.tsx +14 -0
- package/src/hooks/useFocusTrap.ts +62 -111
- package/src/hooks/useFocusTrapEscapeShim.test.tsx +165 -0
- package/src/hooks/useHotkeys.ts +3 -18
- package/src/hooks/useIndicatorFocusRing.doc.mjs +104 -0
- package/src/hooks/useInputStatusIcon.doc.mjs +142 -0
- package/src/hooks/useInteractiveRole.doc.mjs +119 -0
- package/src/hooks/useLongPress.doc.mjs +123 -0
- package/src/hooks/useMergedRefs.doc.mjs +79 -0
- package/src/hooks/useMergedRefs.test.tsx +62 -0
- package/src/hooks/useMergedRefs.ts +36 -0
- package/src/hooks/useTypeahead.doc.mjs +153 -0
- package/src/index.ts +1 -0
- package/src/raw-import.d.ts +14 -0
- package/src/theme/MediaTheme.doc.mjs +5 -5
- package/src/theme/Theme.test.tsx +104 -2
- package/src/theme/Theme.tsx +49 -14
- package/src/theme/defineTheme.test.ts +23 -0
- package/src/theme/derivedVarRegistry.test.ts +26 -3
- package/src/theme/derivedVarRegistry.ts +23 -4
- package/src/theme/generateThemeRules.test.ts +99 -1
- package/src/theme/generateThemeRules.ts +28 -0
- package/src/theme/syntax/tokens.ts +5 -2
- package/src/utils/groupItems.ts +12 -6
- package/src/utils/index.ts +1 -1
- package/src/utils/isApplePlatform.test.ts +61 -0
- package/src/utils/isApplePlatform.ts +37 -0
- package/src/utils/sharedResizeObserver.ts +10 -2
- package/src/utils/timeParser.test.ts +6 -1
- package/src/utils/timeParser.ts +35 -13
- package/src/__tests__/inputWidthContract.test.tsx +0 -69
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @file useMergedRefs.ts
|
|
7
|
+
* @input React refs to combine into one stable callback ref
|
|
8
|
+
* @output Exports useMergedRefs
|
|
9
|
+
* @position Core hook; use when one element must receive multiple refs
|
|
10
|
+
*
|
|
11
|
+
* SYNC: When modified, update:
|
|
12
|
+
* - /packages/core/src/hooks/index.ts
|
|
13
|
+
* - /packages/core/src/hooks/useMergedRefs.doc.mjs
|
|
14
|
+
* - /packages/core/src/hooks/useMergedRefs.test.tsx
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import {useMemo, type Ref, type RefCallback} from 'react';
|
|
18
|
+
import {mergeRefs} from '../utils/mergeRefs';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Combine up to six refs into a callback ref whose identity changes only when
|
|
22
|
+
* one of the input refs changes.
|
|
23
|
+
*/
|
|
24
|
+
export function useMergedRefs<T>(
|
|
25
|
+
refA?: Ref<T>,
|
|
26
|
+
refB?: Ref<T>,
|
|
27
|
+
refC?: Ref<T>,
|
|
28
|
+
refD?: Ref<T>,
|
|
29
|
+
refE?: Ref<T>,
|
|
30
|
+
refF?: Ref<T>,
|
|
31
|
+
): RefCallback<T> {
|
|
32
|
+
return useMemo(
|
|
33
|
+
() => mergeRefs(refA, refB, refC, refD, refE, refF),
|
|
34
|
+
[refA, refB, refC, refD, refE, refF],
|
|
35
|
+
);
|
|
36
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/** @type {import('@astryxdesign/cli/authoring').HookDoc} */
|
|
4
|
+
export const docs = {
|
|
5
|
+
name: 'useTypeahead',
|
|
6
|
+
displayName: 'useTypeahead',
|
|
7
|
+
keywords: [
|
|
8
|
+
'typeahead',
|
|
9
|
+
'type to focus',
|
|
10
|
+
'first character',
|
|
11
|
+
'keyboard',
|
|
12
|
+
'search',
|
|
13
|
+
'jump',
|
|
14
|
+
'menu',
|
|
15
|
+
'listbox',
|
|
16
|
+
'select',
|
|
17
|
+
'apg',
|
|
18
|
+
'accessibility',
|
|
19
|
+
'a11y',
|
|
20
|
+
],
|
|
21
|
+
params: [
|
|
22
|
+
{
|
|
23
|
+
name: 'options',
|
|
24
|
+
type: 'UseTypeaheadOptions',
|
|
25
|
+
description: 'Configuration object.',
|
|
26
|
+
required: true,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'options.getItemLabels',
|
|
30
|
+
type: '() => ReadonlyArray<string | null | undefined>',
|
|
31
|
+
description:
|
|
32
|
+
"Returns the item labels in DOM order. A null or empty entry marks a non-matchable slot and keeps indices aligned with the caller's items.",
|
|
33
|
+
required: true,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'options.onMatch',
|
|
37
|
+
type: '(index: number) => void',
|
|
38
|
+
description:
|
|
39
|
+
"Called with the index of the matched item so the caller can focus or select it; typically useListFocus's focusItem.",
|
|
40
|
+
required: true,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'options.getCurrentIndex',
|
|
44
|
+
type: '() => number',
|
|
45
|
+
description:
|
|
46
|
+
'The index to search from, usually the focused item, so repeated presses of one letter cycle through matches. A negative value means nothing is current.',
|
|
47
|
+
default: '() => -1',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'options.resetMs',
|
|
51
|
+
type: 'number',
|
|
52
|
+
description:
|
|
53
|
+
'Milliseconds of inactivity after which the typed buffer resets.',
|
|
54
|
+
default: '750',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'options.isDisabled',
|
|
58
|
+
type: '(index: number) => boolean',
|
|
59
|
+
description: 'Whether an index should be skipped, e.g. disabled items.',
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
returns: [
|
|
63
|
+
{
|
|
64
|
+
name: 'onKeyDown',
|
|
65
|
+
type: '(e: React.KeyboardEvent | KeyboardEvent) => boolean',
|
|
66
|
+
description:
|
|
67
|
+
'Keydown handler. Returns true when it consumed a printable character, so the caller can stop its own key handling.',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'reset',
|
|
71
|
+
type: '() => void',
|
|
72
|
+
description:
|
|
73
|
+
'Clears the pending buffer, e.g. when the collection closes.',
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
usage: {
|
|
77
|
+
description:
|
|
78
|
+
"Adds APG type-to-focus search to a collection: printable keystrokes are buffered (resetting after a pause), and the first item whose label starts with the buffer is reported through onMatch. Pressing the same letter repeatedly cycles through the matches rather than filtering deeper. It moves nothing itself; pair it with the collection's own focus management, most often useListFocus or useGridFocus.",
|
|
79
|
+
bestPractices: [
|
|
80
|
+
{
|
|
81
|
+
guidance: true,
|
|
82
|
+
description:
|
|
83
|
+
'Wire onMatch to the focus manager you already have (useListFocus.focusItem) instead of moving focus yourself.',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
guidance: true,
|
|
87
|
+
description:
|
|
88
|
+
'Let it see the key event first and fall through to arrow-key navigation only when it returns false.',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
guidance: true,
|
|
92
|
+
description:
|
|
93
|
+
'Pass getCurrentIndex so repeated presses of one letter walk through matches instead of sticking on the first.',
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
guidance: false,
|
|
97
|
+
description:
|
|
98
|
+
'Use it on a text input; the field already receives the characters, and typeahead would fight the value.',
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
relatedComponents: ['DropdownMenu', 'Selector', 'TreeList'],
|
|
103
|
+
relatedHooks: ['useListFocus', 'useGridFocus', 'useTreeFocus'],
|
|
104
|
+
importPath: '@astryxdesign/core/hooks',
|
|
105
|
+
category: 'focus',
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/** @type {import('@astryxdesign/cli/authoring').HookTranslationDoc} */
|
|
109
|
+
export const docsDense = {
|
|
110
|
+
description:
|
|
111
|
+
'APG type-to-focus search for a collection. Buffers printable keys (resets after pause), matches labels by prefix, reports index via onMatch. Same letter pressed repeatedly cycles matches. Moves nothing itself; pair w/ useListFocus / useGridFocus.',
|
|
112
|
+
paramDescriptions: {
|
|
113
|
+
options: 'config.',
|
|
114
|
+
'options.getItemLabels':
|
|
115
|
+
'item labels in DOM order; null / empty = non-matchable slot, indices stay aligned.',
|
|
116
|
+
'options.onMatch':
|
|
117
|
+
'called w/ matched index so caller focuses / selects (e.g. useListFocus focusItem).',
|
|
118
|
+
'options.getCurrentIndex':
|
|
119
|
+
'index to search from (usually focused item) so repeat presses cycle. negative = nothing current.',
|
|
120
|
+
'options.resetMs': 'ms of inactivity before typed buffer resets.',
|
|
121
|
+
'options.isDisabled': 'whether an index is skipped (e.g. disabled items).',
|
|
122
|
+
},
|
|
123
|
+
returnDescriptions: {
|
|
124
|
+
onKeyDown:
|
|
125
|
+
'keydown handler; true = consumed a printable char, caller can stop its own handling.',
|
|
126
|
+
reset: 'clears pending buffer (e.g. on close).',
|
|
127
|
+
},
|
|
128
|
+
usage: {
|
|
129
|
+
description:
|
|
130
|
+
'Type-to-jump for menus / listboxes / trees. Buffered prefix match w/ APG same-letter cycling; reports index, caller owns focus.',
|
|
131
|
+
bestPractices: [
|
|
132
|
+
{
|
|
133
|
+
guidance: true,
|
|
134
|
+
description:
|
|
135
|
+
'Wire onMatch to existing focus manager (useListFocus.focusItem), do not move focus yourself.',
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
guidance: true,
|
|
139
|
+
description:
|
|
140
|
+
'Give it the key event first; fall through to arrow navigation when it returns false.',
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
guidance: true,
|
|
144
|
+
description:
|
|
145
|
+
'Pass getCurrentIndex so repeat presses walk matches instead of sticking on first.',
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
guidance: false,
|
|
149
|
+
description: 'Use on a text input; field already gets the characters.',
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
},
|
|
153
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Ambient module declaration for Vite's `?raw` imports.
|
|
5
|
+
*
|
|
6
|
+
* numberParser.docblock.test.ts reads its own subject's source as text, to
|
|
7
|
+
* check the prose in it against the parser's behaviour. Vite serves that with
|
|
8
|
+
* the `?raw` query; without this declaration TypeScript fails with TS2307.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
declare module '*?raw' {
|
|
12
|
+
const content: string;
|
|
13
|
+
export default content;
|
|
14
|
+
}
|
|
@@ -68,7 +68,7 @@ export const docs = {
|
|
|
68
68
|
{
|
|
69
69
|
guidance: true,
|
|
70
70
|
description:
|
|
71
|
-
'Prefer mode="auto" when the surface color comes from a theme token. A token named "inverted" is not guaranteed to be inverted, and auto measures what was actually painted instead of trusting the name
|
|
71
|
+
'Prefer mode="auto" when the surface color comes from a theme token. A token named "inverted" is not guaranteed to be inverted, and auto measures what was actually painted instead of trusting the name. It can even decide that a surface needs no media context at all.',
|
|
72
72
|
},
|
|
73
73
|
{
|
|
74
74
|
guidance: true,
|
|
@@ -93,14 +93,14 @@ export const docs = {
|
|
|
93
93
|
type: "'dark' | 'light' | 'auto' | 'off'",
|
|
94
94
|
required: true,
|
|
95
95
|
description:
|
|
96
|
-
'Surface luminance context: dark for content over dark backgrounds (light text, white-tinted interactions), light for content over light backgrounds (dark text, black-tinted interactions), auto to decide from the painted surface
|
|
96
|
+
'Surface luminance context: dark for content over dark backgrounds (light text, white-tinted interactions), light for content over light backgrounds (dark text, black-tinted interactions), auto to decide from the painted surface (no media context when the ambient text already reads on the surface at 3:1, otherwise the side that reads better), and off to turn it off explicitly. The element renders either way, so a surface can switch contexts without remounting children.',
|
|
97
97
|
},
|
|
98
98
|
{
|
|
99
99
|
name: 'fallback',
|
|
100
100
|
type: "'dark' | 'light'",
|
|
101
101
|
default: "'dark'",
|
|
102
102
|
description:
|
|
103
|
-
'Which side auto uses when the surface cannot be measured: during SSR, on the first client frame, and whenever the backdrop is not knowable from CSS
|
|
103
|
+
'Which side auto uses when the surface cannot be measured: during SSR, on the first client frame, and whenever the backdrop is not knowable from CSS, most often a background-image, whose pixels need sampling (useImageMode) rather than a computed style. Ignored unless mode is auto.',
|
|
104
104
|
},
|
|
105
105
|
{
|
|
106
106
|
name: 'children',
|
|
@@ -126,7 +126,7 @@ export const docsDense = {
|
|
|
126
126
|
{
|
|
127
127
|
guidance: true,
|
|
128
128
|
description:
|
|
129
|
-
'Prefer mode="auto" when surface color comes from a theme token
|
|
129
|
+
'Prefer mode="auto" when surface color comes from a theme token; a token named "inverted" is not guaranteed to be; auto measures what was painted.',
|
|
130
130
|
},
|
|
131
131
|
{
|
|
132
132
|
guidance: true,
|
|
@@ -148,6 +148,6 @@ export const docsDense = {
|
|
|
148
148
|
propDescriptions: {
|
|
149
149
|
mode: 'surface luminance context: dark for content over dark backgrounds (light text, white-tinted interactions), light for content over light backgrounds (dark text, black-tinted interactions), auto to decide from painted surface (none if ambient text already reads at 3:1, else better-reading side), off to turn off explicitly (element still renders, so children never remount)',
|
|
150
150
|
fallback:
|
|
151
|
-
'side auto uses when surface is unmeasurable (SSR, first frame, background-image
|
|
151
|
+
'side auto uses when surface is unmeasurable (SSR, first frame, background-image, which needs useImageMode sampling); ignored unless mode is auto',
|
|
152
152
|
},
|
|
153
153
|
};
|
package/src/theme/Theme.test.tsx
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
|
-
import {describe, it, expect, beforeEach, afterEach} from 'vitest';
|
|
3
|
+
import {describe, it, expect, beforeEach, afterEach, vi} from 'vitest';
|
|
4
4
|
import {render, cleanup} from '@testing-library/react';
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import {Theme} from './Theme';
|
|
7
7
|
import {defineTheme} from './defineTheme';
|
|
8
|
+
import {dataTokenDefaults} from './domainTokens';
|
|
9
|
+
import type * as DefineThemeModule from './defineTheme';
|
|
10
|
+
|
|
11
|
+
const {generateThemeCSSSpy} = vi.hoisted(() => ({
|
|
12
|
+
generateThemeCSSSpy: vi.fn(),
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
vi.mock('./defineTheme', async importOriginal => {
|
|
16
|
+
const actual = await importOriginal<typeof DefineThemeModule>();
|
|
17
|
+
generateThemeCSSSpy.mockImplementation(actual.generateThemeCSS);
|
|
18
|
+
return {...actual, generateThemeCSS: generateThemeCSSSpy};
|
|
19
|
+
});
|
|
8
20
|
|
|
9
21
|
const testTheme = defineTheme({
|
|
10
22
|
name: 'test',
|
|
@@ -25,6 +37,7 @@ describe('Theme', () => {
|
|
|
25
37
|
// Clean up documentElement state before each test
|
|
26
38
|
document.documentElement.removeAttribute('data-theme');
|
|
27
39
|
document.documentElement.removeAttribute('data-astryx-theme');
|
|
40
|
+
generateThemeCSSSpy.mockClear();
|
|
28
41
|
});
|
|
29
42
|
|
|
30
43
|
afterEach(() => {
|
|
@@ -120,7 +133,9 @@ describe('Theme', () => {
|
|
|
120
133
|
'test',
|
|
121
134
|
);
|
|
122
135
|
unmount();
|
|
123
|
-
expect(document.documentElement.hasAttribute('data-astryx-theme')).toBe(
|
|
136
|
+
expect(document.documentElement.hasAttribute('data-astryx-theme')).toBe(
|
|
137
|
+
false,
|
|
138
|
+
);
|
|
124
139
|
});
|
|
125
140
|
|
|
126
141
|
// =========================================================================
|
|
@@ -166,4 +181,91 @@ describe('Theme', () => {
|
|
|
166
181
|
expect(nestedWrapper).toBeTruthy();
|
|
167
182
|
expect(nestedWrapper?.getAttribute('data-theme')).toBe('light');
|
|
168
183
|
});
|
|
184
|
+
|
|
185
|
+
// =========================================================================
|
|
186
|
+
// Data token defaults — one shared :root block, not one per theme scope
|
|
187
|
+
// =========================================================================
|
|
188
|
+
|
|
189
|
+
const baseTags = () =>
|
|
190
|
+
Array.from(document.head.querySelectorAll('style[data-astryx-theme-base]'));
|
|
191
|
+
|
|
192
|
+
it('injects the data token defaults into @layer astryx-base', () => {
|
|
193
|
+
render(
|
|
194
|
+
<Theme theme={testTheme}>
|
|
195
|
+
<span>child</span>
|
|
196
|
+
</Theme>,
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
expect(baseTags()).toHaveLength(1);
|
|
200
|
+
const css = baseTags()[0].textContent ?? '';
|
|
201
|
+
expect(css).toContain('@layer astryx-base {');
|
|
202
|
+
expect(css).toContain(':root {');
|
|
203
|
+
expect(css).toContain(
|
|
204
|
+
`--color-data-categorical-blue: ${dataTokenDefaults['--color-data-categorical-blue']};`,
|
|
205
|
+
);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it('injects one shared block for nested themes, not one per scope', () => {
|
|
209
|
+
render(
|
|
210
|
+
<Theme theme={testTheme}>
|
|
211
|
+
<Theme theme={altTheme}>
|
|
212
|
+
<span>nested</span>
|
|
213
|
+
</Theme>
|
|
214
|
+
</Theme>,
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
expect(baseTags()).toHaveLength(1);
|
|
218
|
+
|
|
219
|
+
// The nested theme declares no --color-data-* of its own, so nothing
|
|
220
|
+
// shadows a value the parent theme set: that is what lets the override
|
|
221
|
+
// inherit through the ordinary cascade.
|
|
222
|
+
const themeTags = Array.from(
|
|
223
|
+
document.head.querySelectorAll('style[data-astryx-theme]'),
|
|
224
|
+
);
|
|
225
|
+
for (const tag of themeTags) {
|
|
226
|
+
expect(tag.textContent).not.toContain('--color-data-');
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
it('keeps the defaults while any theme is still mounted', () => {
|
|
231
|
+
const outer = render(
|
|
232
|
+
<Theme theme={testTheme}>
|
|
233
|
+
<span>a</span>
|
|
234
|
+
</Theme>,
|
|
235
|
+
);
|
|
236
|
+
render(
|
|
237
|
+
<Theme theme={altTheme}>
|
|
238
|
+
<span>b</span>
|
|
239
|
+
</Theme>,
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
outer.unmount();
|
|
243
|
+
expect(baseTags()).toHaveLength(1);
|
|
244
|
+
|
|
245
|
+
cleanup();
|
|
246
|
+
expect(baseTags()).toHaveLength(0);
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
it('generates a theme once across nested and sibling mounts', () => {
|
|
250
|
+
render(
|
|
251
|
+
<Theme theme={testTheme}>
|
|
252
|
+
<Theme theme={testTheme}>
|
|
253
|
+
<span>nested</span>
|
|
254
|
+
</Theme>
|
|
255
|
+
</Theme>,
|
|
256
|
+
);
|
|
257
|
+
render(
|
|
258
|
+
<Theme theme={testTheme}>
|
|
259
|
+
<span>sibling</span>
|
|
260
|
+
</Theme>,
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
expect(generateThemeCSSSpy).toHaveBeenCalledTimes(1);
|
|
264
|
+
expect(baseTags()).toHaveLength(1);
|
|
265
|
+
|
|
266
|
+
const injected = Array.from(document.querySelectorAll('style'))
|
|
267
|
+
.map(tag => tag.textContent ?? '')
|
|
268
|
+
.join('\n');
|
|
269
|
+
expect(injected.match(/:root\s*\{/g)).toHaveLength(1);
|
|
270
|
+
});
|
|
169
271
|
});
|
package/src/theme/Theme.tsx
CHANGED
|
@@ -42,6 +42,7 @@ import * as stylex from '@stylexjs/stylex';
|
|
|
42
42
|
import type {ThemeMode} from './types';
|
|
43
43
|
import {colorVars, typographyVars} from './tokens.stylex';
|
|
44
44
|
import {generateThemeCSS, type DefinedTheme} from './defineTheme';
|
|
45
|
+
import {generateDataTokenDefaultsCSS} from './generateThemeRules';
|
|
45
46
|
import {registerTheme} from './themeRegistry';
|
|
46
47
|
import {dataAttr} from '../naming';
|
|
47
48
|
import {ThemeContext} from './useTheme';
|
|
@@ -98,6 +99,16 @@ ThemeNestingContext.displayName = 'ThemeNestingContext';
|
|
|
98
99
|
/** Track which themes have already been injected */
|
|
99
100
|
const injectedThemes = new Set<string>();
|
|
100
101
|
|
|
102
|
+
/**
|
|
103
|
+
* How many mounted `Theme`s are relying on the injected data-token defaults.
|
|
104
|
+
*
|
|
105
|
+
* The defaults are one document-wide `:root` block, shared by every theme, so
|
|
106
|
+
* they are injected once and removed only when the last theme that took a
|
|
107
|
+
* reference unmounts — tearing them down with whichever provider happened to
|
|
108
|
+
* inject them would strip the palette from the providers still mounted.
|
|
109
|
+
*/
|
|
110
|
+
let dataTokenDefaultsRefCount = 0;
|
|
111
|
+
|
|
101
112
|
/**
|
|
102
113
|
* Hook to inject theme CSS into the document.
|
|
103
114
|
* Built themes (from `astryx theme build`) skip injection — their CSS
|
|
@@ -112,6 +123,8 @@ function useThemeStyleInjection(theme: DefinedTheme): void {
|
|
|
112
123
|
return;
|
|
113
124
|
}
|
|
114
125
|
|
|
126
|
+
// Second and later `Theme`s using this theme do no work at all —
|
|
127
|
+
// generation included. Its CSS is document-wide and identical for each.
|
|
115
128
|
const themeKey = `astryx-theme-${theme.name}`;
|
|
116
129
|
if (injectedThemes.has(themeKey)) {
|
|
117
130
|
return;
|
|
@@ -130,8 +143,26 @@ function useThemeStyleInjection(theme: DefinedTheme): void {
|
|
|
130
143
|
);
|
|
131
144
|
|
|
132
145
|
const {prose, component} = generateThemeCSS(theme);
|
|
133
|
-
|
|
134
|
-
|
|
146
|
+
const base = generateDataTokenDefaultsCSS();
|
|
147
|
+
injectedThemes.add(themeKey);
|
|
148
|
+
const cleanups: (() => void)[] = [() => injectedThemes.delete(themeKey)];
|
|
149
|
+
|
|
150
|
+
// Data token defaults go into @layer astryx-base, where StyleX puts the
|
|
151
|
+
// core token defaults, so a theme's own `--color-data-*` outranks them by
|
|
152
|
+
// layer. Appended (never prepended) so it cannot register `astryx-base`
|
|
153
|
+
// ahead of `reset` and invert the layer order.
|
|
154
|
+
if (base) {
|
|
155
|
+
if (dataTokenDefaultsRefCount++ === 0) {
|
|
156
|
+
const baseStyle = document.createElement('style');
|
|
157
|
+
baseStyle.setAttribute(dataAttr('theme-base'), '');
|
|
158
|
+
baseStyle.textContent = `@layer astryx-base {\n${base}\n}`;
|
|
159
|
+
document.head.appendChild(baseStyle);
|
|
160
|
+
}
|
|
161
|
+
cleanups.push(() => {
|
|
162
|
+
if (--dataTokenDefaultsRefCount === 0) {
|
|
163
|
+
document.querySelector(`style[${dataAttr('theme-base')}]`)?.remove();
|
|
164
|
+
}
|
|
165
|
+
});
|
|
135
166
|
}
|
|
136
167
|
|
|
137
168
|
// Prose defaults go into @layer reset — lowest priority, scoped to
|
|
@@ -154,20 +185,24 @@ function useThemeStyleInjection(theme: DefinedTheme): void {
|
|
|
154
185
|
document.head.appendChild(compStyle);
|
|
155
186
|
}
|
|
156
187
|
|
|
157
|
-
|
|
188
|
+
if (prose || component) {
|
|
189
|
+
cleanups.push(() => {
|
|
190
|
+
// Matched by the astryx id marker, which is always written above.
|
|
191
|
+
const proseEl = document.querySelector(
|
|
192
|
+
`style[${dataAttr('theme-prose')}="${theme.name}"][${dataAttr('id')}="${id}"]`,
|
|
193
|
+
);
|
|
194
|
+
const compEl = document.querySelector(
|
|
195
|
+
`style[${dataAttr('theme')}="${theme.name}"][${dataAttr('id')}="${id}"]`,
|
|
196
|
+
);
|
|
197
|
+
proseEl?.remove();
|
|
198
|
+
compEl?.remove();
|
|
199
|
+
});
|
|
200
|
+
}
|
|
158
201
|
|
|
159
202
|
return () => {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
`style[${dataAttr('theme-prose')}="${theme.name}"][${dataAttr('id')}="${id}"]`,
|
|
164
|
-
);
|
|
165
|
-
const compEl = document.querySelector(
|
|
166
|
-
`style[${dataAttr('theme')}="${theme.name}"][${dataAttr('id')}="${id}"]`,
|
|
167
|
-
);
|
|
168
|
-
proseEl?.remove();
|
|
169
|
-
compEl?.remove();
|
|
170
|
-
injectedThemes.delete(themeKey);
|
|
203
|
+
for (const cleanup of cleanups) {
|
|
204
|
+
cleanup();
|
|
205
|
+
}
|
|
171
206
|
};
|
|
172
207
|
}, [theme, id]);
|
|
173
208
|
}
|
|
@@ -116,6 +116,29 @@ describe('generateThemeCSS', () => {
|
|
|
116
116
|
expect(css).toContain('font-family: var(--font-family-heading)');
|
|
117
117
|
});
|
|
118
118
|
|
|
119
|
+
it('keeps the data palette out of a theme that never mentions it', () => {
|
|
120
|
+
// That the palette IS declared is covered by `seeds the whole palette
|
|
121
|
+
// once, at :root` in generateThemeRules.test.ts. It is theme-independent,
|
|
122
|
+
// so there is nothing about it a theme can be used to assert.
|
|
123
|
+
const {component} = generateThemeCSS(defineTheme({name: 'chartless'}));
|
|
124
|
+
expect(component).not.toContain('--color-data-');
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('puts only the named data token in the theme block, not its siblings', () => {
|
|
128
|
+
const theme = defineTheme({
|
|
129
|
+
name: 'brand-charts',
|
|
130
|
+
tokens: {'--color-data-categorical-blue': '#00A3FF'},
|
|
131
|
+
});
|
|
132
|
+
const {component} = generateThemeCSS(theme);
|
|
133
|
+
expect(component).toContain('--color-data-categorical-blue: #00A3FF;');
|
|
134
|
+
// Leaving the siblings out of the theme's own block is what lets a nested
|
|
135
|
+
// theme inherit a parent's override instead of shadowing it.
|
|
136
|
+
expect(component).not.toContain('--color-data-categorical-orange');
|
|
137
|
+
// Defaults reach the stylesheet without entering the theme's own tokens,
|
|
138
|
+
// which are what `astryx theme build` reports as overrides.
|
|
139
|
+
expect(theme.tokens['--color-data-categorical-orange']).toBeUndefined();
|
|
140
|
+
});
|
|
141
|
+
|
|
119
142
|
it('splits prose into reset layer and components into astryx-theme', () => {
|
|
120
143
|
const theme = defineTheme({
|
|
121
144
|
name: 'split-test',
|
|
@@ -213,6 +213,7 @@ function discoverComponents(): ComponentInfo[] {
|
|
|
213
213
|
// ---------------------------------------------------------------------------
|
|
214
214
|
|
|
215
215
|
const DIR_TO_REGISTRY_KEY: Record<string, string> = {
|
|
216
|
+
Avatar: 'avatar',
|
|
216
217
|
Banner: 'banner',
|
|
217
218
|
Button: 'button',
|
|
218
219
|
Card: 'card',
|
|
@@ -221,13 +222,13 @@ const DIR_TO_REGISTRY_KEY: Record<string, string> = {
|
|
|
221
222
|
Dialog: 'dialog',
|
|
222
223
|
DropdownMenu: 'dropdown-menu',
|
|
223
224
|
Field: 'field',
|
|
224
|
-
HoverCard: '
|
|
225
|
+
HoverCard: 'hover-card',
|
|
225
226
|
NumberInput: 'number-input',
|
|
226
227
|
Popover: 'popover',
|
|
227
|
-
ProgressBar: '
|
|
228
|
+
ProgressBar: 'progress-bar-mark',
|
|
228
229
|
Section: 'section',
|
|
229
230
|
SegmentedControl: 'segmented-control',
|
|
230
|
-
TextArea: '
|
|
231
|
+
TextArea: 'text-area',
|
|
231
232
|
};
|
|
232
233
|
|
|
233
234
|
/**
|
|
@@ -279,6 +280,9 @@ const VARS_WITHOUT_DERIVED_MAPPING = new Set([
|
|
|
279
280
|
'--_thumbnail-hit-inset',
|
|
280
281
|
'--_input-clear-hit-inset',
|
|
281
282
|
'--_input-clear-hit-content',
|
|
283
|
+
// Placement-driven motion is private Toast behavior. A theme author controls
|
|
284
|
+
// the surface transform as a whole, not this one offset within it.
|
|
285
|
+
'--_toast-slide-y',
|
|
282
286
|
// Indentation and row-spacing metrics: --tree-list-indent is the authorable
|
|
283
287
|
// step, --_tree-indent the per-row distance TreeListItem computes from it.
|
|
284
288
|
// --tree-list-row-gap is applied as half a padding-block on each row wrapper,
|
|
@@ -292,6 +296,10 @@ const VARS_WITHOUT_DERIVED_MAPPING = new Set([
|
|
|
292
296
|
// other.
|
|
293
297
|
'--_card-elevation',
|
|
294
298
|
'--_card-ring',
|
|
299
|
+
// The colour inside that composed ring, for a variant only a theme knows.
|
|
300
|
+
// It is one component of one shadow in the list, so no standard property
|
|
301
|
+
// maps onto it either — a theme sets it beside the fill it has to contrast.
|
|
302
|
+
'--selectable-card-ring-color',
|
|
295
303
|
]);
|
|
296
304
|
|
|
297
305
|
// ---------------------------------------------------------------------------
|
|
@@ -418,6 +426,21 @@ describe('getDerivedVars', () => {
|
|
|
418
426
|
expect(getDerivedVars('unknown', 'borderRadius')).toEqual([]);
|
|
419
427
|
});
|
|
420
428
|
|
|
429
|
+
it('resolves a deprecated key to the entries of the key that replaced it', () => {
|
|
430
|
+
// A theme written against the old spelling still selects the element (the
|
|
431
|
+
// component emits both classes), so its derived vars must still expand —
|
|
432
|
+
// otherwise the rule lands and the var half of it silently does nothing.
|
|
433
|
+
expect(getDerivedVars('hovercard', 'borderRadius')).toEqual(
|
|
434
|
+
getDerivedVars('hover-card', 'borderRadius'),
|
|
435
|
+
);
|
|
436
|
+
expect(getDerivedVars('textarea', 'paddingInline')).toEqual(
|
|
437
|
+
getDerivedVars('text-area', 'paddingInline'),
|
|
438
|
+
);
|
|
439
|
+
expect(getDerivedVars('progressbar-mark', 'width')).toEqual(
|
|
440
|
+
getDerivedVars('progress-bar-mark', 'width'),
|
|
441
|
+
);
|
|
442
|
+
});
|
|
443
|
+
|
|
421
444
|
it('returns empty for unregistered property', () => {
|
|
422
445
|
expect(getDerivedVars('card', 'color')).toEqual([]);
|
|
423
446
|
});
|
|
@@ -43,6 +43,7 @@ export interface DerivedVarEntry {
|
|
|
43
43
|
* entries share the same property.
|
|
44
44
|
*/
|
|
45
45
|
export const derivedVarRegistry: Record<string, DerivedVarEntry[]> = {
|
|
46
|
+
avatar: [{property: 'borderRadius', vars: ['--_avatar-radius']}],
|
|
46
47
|
banner: [{property: 'borderRadius', vars: ['--_banner-radius']}],
|
|
47
48
|
button: [{property: 'borderRadius', vars: ['--_button-radius']}],
|
|
48
49
|
card: [
|
|
@@ -66,13 +67,13 @@ export const derivedVarRegistry: Record<string, DerivedVarEntry[]> = {
|
|
|
66
67
|
{property: 'padding', vars: ['--_dropdown-menu-padding']},
|
|
67
68
|
],
|
|
68
69
|
field: [{property: 'borderRadius', vars: ['--_field-radius']}],
|
|
69
|
-
|
|
70
|
+
'hover-card': [{property: 'borderRadius', vars: ['--_hovercard-radius']}],
|
|
70
71
|
'number-input': [
|
|
71
72
|
{property: 'padding', expand: 'container'},
|
|
72
73
|
{property: 'borderRadius', vars: ['--_field-radius']},
|
|
73
74
|
],
|
|
74
75
|
popover: [{property: 'borderRadius', vars: ['--_popover-radius']}],
|
|
75
|
-
'
|
|
76
|
+
'progress-bar-mark': [
|
|
76
77
|
{property: 'width', vars: ['--_progressbar-mark-width'], replaces: true},
|
|
77
78
|
{property: 'height', vars: ['--_progressbar-mark-height'], replaces: true},
|
|
78
79
|
],
|
|
@@ -81,7 +82,7 @@ export const derivedVarRegistry: Record<string, DerivedVarEntry[]> = {
|
|
|
81
82
|
{property: 'borderRadius', vars: ['--_segmented-control-radius']},
|
|
82
83
|
{property: 'padding', vars: ['--_segmented-control-padding']},
|
|
83
84
|
],
|
|
84
|
-
|
|
85
|
+
'text-area': [
|
|
85
86
|
{
|
|
86
87
|
property: 'paddingInline',
|
|
87
88
|
vars: ['--_textarea-inline-padding'],
|
|
@@ -90,6 +91,21 @@ export const derivedVarRegistry: Record<string, DerivedVarEntry[]> = {
|
|
|
90
91
|
],
|
|
91
92
|
};
|
|
92
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Deprecated component keys → the key that superseded them.
|
|
96
|
+
*
|
|
97
|
+
* A renamed target keeps emitting its old class, so a theme written against
|
|
98
|
+
* the old key still selects the element. Without this the rule would land but
|
|
99
|
+
* its derived vars would not expand, and the half that travels through a var
|
|
100
|
+
* (a hover card's radius, a text area's inline padding) would silently do
|
|
101
|
+
* nothing. Drop these with the classes, in the next major.
|
|
102
|
+
*/
|
|
103
|
+
const DEPRECATED_REGISTRY_KEYS: Record<string, string> = {
|
|
104
|
+
hovercard: 'hover-card',
|
|
105
|
+
'progressbar-mark': 'progress-bar-mark',
|
|
106
|
+
textarea: 'text-area',
|
|
107
|
+
};
|
|
108
|
+
|
|
93
109
|
/**
|
|
94
110
|
* Look up derived var entries for a component + CSS property.
|
|
95
111
|
* Returns matching entries in priority order, or empty array if none.
|
|
@@ -98,7 +114,10 @@ export function getDerivedVars(
|
|
|
98
114
|
component: string,
|
|
99
115
|
property: string,
|
|
100
116
|
): DerivedVarEntry[] {
|
|
101
|
-
const
|
|
117
|
+
const renamedTo = DEPRECATED_REGISTRY_KEYS[component];
|
|
118
|
+
const entries =
|
|
119
|
+
derivedVarRegistry[component] ??
|
|
120
|
+
(renamedTo ? derivedVarRegistry[renamedTo] : undefined);
|
|
102
121
|
if (!entries) {
|
|
103
122
|
return [];
|
|
104
123
|
}
|