@astryxdesign/core 0.0.15 → 0.1.0-canary.08d4cf4
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 +69 -0
- package/README.md +8 -10
- package/dist/AlertDialog/AlertDialog.js +2 -2
- package/dist/AppShell/AppShell.js +5 -5
- package/dist/AspectRatio/AspectRatio.js +2 -2
- package/dist/Avatar/Avatar.js +2 -2
- package/dist/Avatar/AvatarStatusDot.js +2 -2
- package/dist/AvatarGroup/AvatarGroup.js +2 -2
- package/dist/AvatarGroup/AvatarGroupOverflow.js +3 -3
- package/dist/Badge/Badge.js +2 -2
- package/dist/Banner/Banner.d.ts +2 -2
- package/dist/Banner/Banner.js +6 -6
- package/dist/Blockquote/Blockquote.js +2 -2
- package/dist/Breadcrumbs/BreadcrumbItem.js +3 -3
- package/dist/Breadcrumbs/Breadcrumbs.js +2 -2
- package/dist/Button/Button.js +2 -2
- package/dist/ButtonGroup/ButtonGroup.js +2 -2
- package/dist/Calendar/Calendar.js +3 -3
- package/dist/Card/Card.js +2 -2
- package/dist/Carousel/Carousel.js +2 -2
- package/dist/Center/Center.js +2 -2
- package/dist/Chat/ChatComposer.js +2 -2
- package/dist/Chat/ChatComposerDrawer.js +2 -2
- package/dist/Chat/ChatComposerInput.js +2 -2
- package/dist/Chat/ChatLayout.js +2 -2
- package/dist/Chat/ChatLayoutScrollButton.d.ts.map +1 -1
- package/dist/Chat/ChatLayoutScrollButton.js +5 -1
- package/dist/Chat/ChatMessage.js +2 -2
- package/dist/Chat/ChatMessageBubble.js +2 -2
- package/dist/Chat/ChatMessageList.js +2 -2
- package/dist/Chat/ChatMessageMetadata.js +2 -2
- package/dist/Chat/ChatSendButton.js +2 -2
- package/dist/Chat/ChatSystemMessage.js +3 -3
- package/dist/Chat/ChatTokenizedText.js +3 -3
- package/dist/Chat/ChatToolCalls.js +3 -3
- package/dist/Chat/useTriggerMenu.js +2 -2
- package/dist/CheckboxInput/CheckboxInput.js +3 -3
- package/dist/CheckboxList/CheckboxList.js +2 -2
- package/dist/Citation/Citation.js +3 -3
- package/dist/ClickableCard/ClickableCard.js +2 -2
- package/dist/Code/Code.js +2 -2
- package/dist/CodeBlock/CodeBlock.js +2 -2
- package/dist/Collapsible/Collapsible.js +2 -2
- package/dist/CommandPalette/CommandPaletteFooter.js +2 -2
- package/dist/CommandPalette/CommandPaletteGroup.js +2 -2
- package/dist/CommandPalette/CommandPaletteInput.js +2 -2
- package/dist/CommandPalette/CommandPaletteItem.js +2 -2
- package/dist/CommandPalette/CommandPaletteList.js +2 -2
- package/dist/ContextMenu/ContextMenu.js +4 -4
- package/dist/DateInput/DateInput.js +2 -2
- package/dist/DateRangeInput/DateRangeInput.js +2 -2
- package/dist/DateTimeInput/DateTimeInput.js +2 -2
- package/dist/Dialog/Dialog.js +3 -3
- package/dist/Divider/Divider.js +2 -2
- package/dist/DropdownMenu/DropdownMenu.js +4 -4
- package/dist/DropdownMenu/DropdownMenuItem.js +2 -2
- package/dist/DropdownMenu/{renderXDSDropdownItems.d.ts → renderDropdownItems.d.ts} +3 -3
- package/dist/DropdownMenu/renderDropdownItems.d.ts.map +1 -0
- package/dist/DropdownMenu/{renderXDSDropdownItems.js → renderDropdownItems.js} +2 -2
- package/dist/EmptyState/EmptyState.js +2 -2
- package/dist/Field/Field.js +3 -3
- package/dist/Field/FieldLabel.js +2 -2
- package/dist/FieldStatus/FieldStatus.js +2 -2
- package/dist/FileInput/FileInput.js +2 -2
- package/dist/FormLayout/FormLayout.js +2 -2
- package/dist/Grid/Grid.js +3 -3
- package/dist/Grid/GridSpan.js +2 -2
- package/dist/Heading/Heading.js +2 -2
- package/dist/HoverCard/useHoverCard.js +2 -2
- package/dist/Icon/Icon.js +3 -3
- package/dist/InputGroup/InputGroup.js +2 -2
- package/dist/InputGroup/InputGroupText.js +2 -2
- package/dist/Item/Item.js +2 -2
- package/dist/Kbd/Kbd.js +2 -2
- package/dist/Layer/useLayer.d.ts +2 -2
- package/dist/Layout/Layout.js +2 -2
- package/dist/Layout/LayoutContent.js +2 -2
- package/dist/Layout/LayoutFooter.js +2 -2
- package/dist/Layout/LayoutHeader.js +2 -2
- package/dist/Layout/LayoutPanel.js +2 -2
- package/dist/Lightbox/Lightbox.js +2 -2
- package/dist/Link/Link.js +3 -3
- package/dist/List/List.js +2 -2
- package/dist/List/ListItem.js +2 -2
- package/dist/Markdown/Markdown.js +3 -3
- package/dist/MetadataList/MetadataList.js +2 -2
- package/dist/MetadataList/MetadataListItem.js +3 -3
- package/dist/MobileNav/MobileNav.js +2 -2
- package/dist/MultiSelector/MultiSelector.js +2 -2
- package/dist/NavIcon/NavIcon.js +2 -2
- package/dist/NavMenu/NavHeadingMenu.js +2 -2
- package/dist/NavMenu/NavHeadingMenuItem.js +2 -2
- package/dist/NumberInput/NumberInput.js +2 -2
- package/dist/Outline/Outline.d.ts +3 -2
- package/dist/Outline/Outline.d.ts.map +1 -1
- package/dist/Outline/Outline.js +27 -8
- package/dist/Outline/useScrollSpy.d.ts +14 -1
- package/dist/Outline/useScrollSpy.d.ts.map +1 -1
- package/dist/Outline/useScrollSpy.js +161 -50
- package/dist/OverflowList/OverflowList.js +2 -2
- package/dist/Overlay/Overlay.js +2 -2
- package/dist/Overlay/OverlayScrim.js +2 -2
- package/dist/Pagination/Pagination.js +3 -3
- package/dist/Popover/Popover.js +4 -4
- package/dist/PowerSearch/PowerSearch.js +2 -2
- package/dist/ProgressBar/ProgressBar.js +5 -5
- package/dist/RadioList/RadioList.js +2 -2
- package/dist/RadioList/RadioListItem.js +4 -4
- package/dist/Resizable/ResizeHandle.js +4 -4
- package/dist/Resizable/useResizable.d.ts.map +1 -1
- package/dist/Resizable/useResizable.js +1 -5
- package/dist/Section/Section.js +2 -2
- package/dist/SegmentedControl/SegmentedControl.js +2 -2
- package/dist/SegmentedControl/SegmentedControlItem.js +2 -2
- package/dist/SelectableCard/SelectableCard.js +2 -2
- package/dist/Selector/Selector.d.ts.map +1 -1
- package/dist/Selector/Selector.js +3 -3
- package/dist/Selector/SelectorOption.js +2 -2
- package/dist/SideNav/SideNav.js +3 -3
- package/dist/SideNav/SideNavHeading.js +9 -9
- package/dist/SideNav/SideNavItem.js +3 -3
- package/dist/SideNav/SideNavSection.js +2 -2
- package/dist/Skeleton/Skeleton.js +2 -2
- package/dist/Slider/Slider.js +4 -4
- package/dist/Spinner/Spinner.js +3 -3
- package/dist/Stack/Stack.js +2 -2
- package/dist/Stack/StackItem.js +2 -2
- package/dist/StatusDot/StatusDot.js +2 -2
- package/dist/Switch/Switch.js +4 -4
- package/dist/TabList/Tab.js +3 -3
- package/dist/TabList/TabList.js +2 -2
- package/dist/TabList/TabMenu.js +5 -5
- package/dist/Table/BaseTable.js +2 -2
- package/dist/Table/Table.js +3 -3
- package/dist/Table/TableBody.js +2 -2
- package/dist/Table/TableCell.js +3 -3
- package/dist/Table/TableFooter.js +2 -2
- package/dist/Table/TableHeader.js +2 -2
- package/dist/Table/TableHeaderCell.js +3 -3
- package/dist/Table/TableRow.js +3 -3
- package/dist/Text/Text.js +2 -2
- package/dist/TextArea/TextArea.js +2 -2
- package/dist/TextInput/TextInput.js +2 -2
- package/dist/Thumbnail/Thumbnail.js +2 -2
- package/dist/TimeInput/TimeInput.js +2 -2
- package/dist/Timestamp/Timestamp.js +2 -2
- package/dist/Toast/Toast.js +2 -2
- package/dist/ToggleButton/ToggleButton.d.ts +10 -3
- package/dist/ToggleButton/ToggleButton.d.ts.map +1 -1
- package/dist/ToggleButton/ToggleButton.js +66 -20
- package/dist/ToggleButton/ToggleButtonGroup.js +2 -2
- package/dist/Token/Token.js +4 -4
- package/dist/Tokenizer/Tokenizer.js +3 -3
- package/dist/Toolbar/Toolbar.js +2 -2
- package/dist/Tooltip/useTooltip.js +2 -2
- package/dist/TopNav/TopNav.js +3 -3
- package/dist/TopNav/TopNavHeading.js +7 -7
- package/dist/TopNav/TopNavItem.js +3 -3
- package/dist/TopNav/TopNavMegaMenu.js +3 -3
- package/dist/TopNav/TopNavMegaMenuFeaturedCard.js +2 -2
- package/dist/TopNav/TopNavMegaMenuItem.js +3 -3
- package/dist/TopNav/TopNavMenu.js +2 -2
- package/dist/TreeList/TreeList.js +2 -2
- package/dist/TreeList/TreeListItem.js +2 -2
- package/dist/Typeahead/BaseTypeahead.js +2 -2
- package/dist/Typeahead/Typeahead.js +2 -2
- package/dist/Typeahead/TypeaheadItem.js +2 -2
- package/dist/docs-types.d.ts +3 -3
- package/dist/docs-types.d.ts.map +1 -1
- package/dist/naming.d.ts +1 -1
- package/dist/naming.js +1 -1
- package/dist/theme/Theme.js +1 -1
- package/dist/theme/defineTheme.d.ts +3 -3
- package/dist/theme/defineTheme.d.ts.map +1 -1
- package/dist/theme/defineTheme.js +1 -1
- package/dist/theme/index.d.ts +2 -2
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +2 -2
- package/dist/theme/syntax/defineSyntaxTheme.js +1 -1
- package/dist/theme/tokens.d.ts +1 -1
- package/dist/theme/tokens.js +4 -4
- package/dist/theme/useTheme.d.ts +2 -2
- package/dist/utils/dateParser.d.ts.map +1 -1
- package/dist/utils/dateParser.js +15 -2
- package/dist/utils/mergeProps.d.ts +3 -3
- package/dist/utils/mergeProps.js +4 -4
- package/dist/utils/parseStyleKey.d.ts +2 -2
- package/dist/utils/parseStyleKey.js +2 -2
- package/dist/utils/{xdsThemeProps.d.ts → themeProps.d.ts} +4 -4
- package/dist/utils/themeProps.d.ts.map +1 -0
- package/dist/utils/{xdsThemeProps.js → themeProps.js} +5 -5
- package/package.json +2 -2
- package/src/AlertDialog/AlertDialog.tsx +2 -2
- package/src/AppShell/AppShell.tsx +5 -5
- package/src/AspectRatio/AspectRatio.tsx +2 -2
- package/src/Avatar/Avatar.tsx +2 -2
- package/src/Avatar/AvatarStatusDot.tsx +2 -2
- package/src/AvatarGroup/AvatarGroup.tsx +2 -2
- package/src/AvatarGroup/AvatarGroupOverflow.tsx +3 -3
- package/src/Badge/Badge.tsx +2 -2
- package/src/Banner/Banner.tsx +6 -6
- package/src/Blockquote/Blockquote.tsx +2 -2
- package/src/Breadcrumbs/BreadcrumbItem.tsx +3 -3
- package/src/Breadcrumbs/Breadcrumbs.tsx +2 -2
- package/src/Button/Button.tsx +2 -2
- package/src/ButtonGroup/ButtonGroup.tsx +2 -2
- package/src/Calendar/Calendar.tsx +3 -3
- package/src/Card/Card.tsx +2 -2
- package/src/Carousel/Carousel.tsx +2 -2
- package/src/Center/Center.tsx +2 -2
- package/src/Chat/ChatComposer.tsx +2 -2
- package/src/Chat/ChatComposerDrawer.tsx +2 -2
- package/src/Chat/ChatComposerInput.tsx +2 -2
- package/src/Chat/ChatLayout.tsx +2 -2
- package/src/Chat/ChatLayoutScrollButton.tsx +7 -1
- package/src/Chat/ChatMessage.tsx +2 -2
- package/src/Chat/ChatMessageBubble.tsx +2 -2
- package/src/Chat/ChatMessageList.tsx +2 -2
- package/src/Chat/ChatMessageMetadata.tsx +2 -2
- package/src/Chat/ChatSendButton.tsx +2 -2
- package/src/Chat/ChatSystemMessage.tsx +3 -3
- package/src/Chat/ChatTokenizedText.tsx +3 -3
- package/src/Chat/ChatToolCalls.tsx +3 -3
- package/src/Chat/useTriggerMenu.tsx +2 -2
- package/src/CheckboxInput/CheckboxInput.tsx +3 -3
- package/src/CheckboxList/CheckboxList.tsx +2 -2
- package/src/Citation/Citation.tsx +3 -3
- package/src/ClickableCard/ClickableCard.tsx +2 -2
- package/src/Code/Code.tsx +2 -2
- package/src/CodeBlock/CodeBlock.tsx +2 -2
- package/src/Collapsible/Collapsible.tsx +2 -2
- package/src/Collapsible/useCollapsible.doc.mjs +2 -2
- package/src/CommandPalette/CommandPaletteFooter.tsx +2 -2
- package/src/CommandPalette/CommandPaletteGroup.tsx +2 -2
- package/src/CommandPalette/CommandPaletteInput.tsx +2 -2
- package/src/CommandPalette/CommandPaletteItem.tsx +2 -2
- package/src/CommandPalette/CommandPaletteList.tsx +2 -2
- package/src/ContextMenu/ContextMenu.tsx +4 -4
- package/src/DateInput/DateInput.test.tsx +68 -20
- package/src/DateInput/DateInput.tsx +2 -2
- package/src/DateRangeInput/DateRangeInput.tsx +2 -2
- package/src/DateTimeInput/DateTimeInput.tsx +2 -2
- package/src/Dialog/Dialog.tsx +3 -3
- package/src/Divider/Divider.doc.mjs +1 -1
- package/src/Divider/Divider.tsx +2 -2
- package/src/DropdownMenu/DropdownMenu.tsx +4 -4
- package/src/DropdownMenu/DropdownMenuItem.tsx +2 -2
- package/src/DropdownMenu/{renderXDSDropdownItems.tsx → renderDropdownItems.tsx} +2 -2
- package/src/EmptyState/EmptyState.tsx +2 -2
- package/src/Field/Field.tsx +3 -3
- package/src/Field/FieldLabel.tsx +2 -2
- package/src/FieldStatus/FieldStatus.tsx +2 -2
- package/src/FileInput/FileInput.tsx +2 -2
- package/src/FormLayout/FormLayout.doc.mjs +3 -3
- package/src/FormLayout/FormLayout.tsx +2 -2
- package/src/Grid/Grid.tsx +3 -3
- package/src/Grid/GridSpan.tsx +2 -2
- package/src/Heading/Heading.tsx +2 -2
- package/src/HoverCard/useHoverCard.tsx +2 -2
- package/src/Icon/Icon.doc.mjs +4 -4
- package/src/Icon/Icon.tsx +3 -3
- package/src/InputGroup/InputGroup.tsx +2 -2
- package/src/InputGroup/InputGroupText.tsx +2 -2
- package/src/Item/Item.doc.mjs +2 -2
- package/src/Item/Item.tsx +2 -2
- package/src/Kbd/Kbd.tsx +2 -2
- package/src/Layer/useLayer.tsx +2 -2
- package/src/Layout/Layout.tsx +2 -2
- package/src/Layout/LayoutContent.tsx +2 -2
- package/src/Layout/LayoutFooter.tsx +2 -2
- package/src/Layout/LayoutHeader.tsx +2 -2
- package/src/Layout/LayoutPanel.tsx +2 -2
- package/src/Lightbox/Lightbox.tsx +2 -2
- package/src/Link/Link.doc.mjs +3 -3
- package/src/Link/Link.tsx +3 -3
- package/src/Link/LinkProvider.doc.mjs +3 -3
- package/src/List/List.tsx +2 -2
- package/src/List/ListItem.tsx +2 -2
- package/src/Markdown/Markdown.doc.mjs +4 -4
- package/src/Markdown/Markdown.tsx +3 -3
- package/src/MetadataList/MetadataList.tsx +2 -2
- package/src/MetadataList/MetadataListItem.tsx +3 -3
- package/src/MobileNav/MobileNav.tsx +2 -2
- package/src/MoreMenu/MoreMenu.doc.mjs +0 -13
- package/src/MultiSelector/MultiSelector.tsx +2 -2
- package/src/NavIcon/NavIcon.tsx +2 -2
- package/src/NavMenu/NavHeadingMenu.tsx +2 -2
- package/src/NavMenu/NavHeadingMenuItem.tsx +2 -2
- package/src/NumberInput/NumberInput.tsx +2 -2
- package/src/Outline/Outline.doc.mjs +1 -1
- package/src/Outline/Outline.test.tsx +76 -38
- package/src/Outline/Outline.tsx +27 -8
- package/src/Outline/useScrollSpy.ts +196 -63
- package/src/OverflowList/OverflowList.tsx +2 -2
- package/src/Overlay/Overlay.tsx +2 -2
- package/src/Overlay/OverlayScrim.tsx +2 -2
- package/src/Pagination/Pagination.tsx +3 -3
- package/src/Popover/Popover.tsx +4 -4
- package/src/PowerSearch/PowerSearch.tsx +2 -2
- package/src/ProgressBar/ProgressBar.tsx +5 -5
- package/src/RadioList/RadioList.tsx +2 -2
- package/src/RadioList/RadioListItem.tsx +4 -4
- package/src/Resizable/Resizable.doc.mjs +2 -2
- package/src/Resizable/ResizeHandle.tsx +4 -4
- package/src/Resizable/useResizable.ts +1 -7
- package/src/Section/Section.tsx +2 -2
- package/src/SegmentedControl/SegmentedControl.tsx +2 -2
- package/src/SegmentedControl/SegmentedControlItem.tsx +2 -2
- package/src/SelectableCard/SelectableCard.tsx +2 -2
- package/src/Selector/Selector.tsx +7 -8
- package/src/Selector/SelectorOption.tsx +2 -2
- package/src/SideNav/SideNav.tsx +3 -3
- package/src/SideNav/SideNavHeading.tsx +9 -9
- package/src/SideNav/SideNavItem.tsx +3 -3
- package/src/SideNav/SideNavSection.tsx +2 -2
- package/src/Skeleton/Skeleton.tsx +2 -2
- package/src/Slider/Slider.tsx +4 -4
- package/src/Spinner/Spinner.tsx +3 -3
- package/src/Stack/Stack.tsx +2 -2
- package/src/Stack/StackItem.tsx +2 -2
- package/src/StatusDot/StatusDot.tsx +2 -2
- package/src/Switch/Switch.tsx +4 -4
- package/src/TabList/Tab.tsx +3 -3
- package/src/TabList/TabList.tsx +2 -2
- package/src/TabList/TabMenu.tsx +5 -5
- package/src/Table/BaseTable.tsx +2 -2
- package/src/Table/Table.doc.mjs +3 -3
- package/src/Table/Table.tsx +3 -3
- package/src/Table/TableBody.tsx +2 -2
- package/src/Table/TableCell.tsx +3 -3
- package/src/Table/TableFooter.tsx +2 -2
- package/src/Table/TableHeader.tsx +2 -2
- package/src/Table/TableHeaderCell.tsx +3 -3
- package/src/Table/TableRow.tsx +3 -3
- package/src/Text/Text.tsx +2 -2
- package/src/TextArea/TextArea.tsx +2 -2
- package/src/TextInput/TextInput.tsx +2 -2
- package/src/Thumbnail/Thumbnail.tsx +2 -2
- package/src/TimeInput/TimeInput.tsx +2 -2
- package/src/Timestamp/Timestamp.tsx +2 -2
- package/src/Toast/Toast.tsx +2 -2
- package/src/ToggleButton/ToggleButton.doc.mjs +2 -2
- package/src/ToggleButton/ToggleButton.test.tsx +148 -6
- package/src/ToggleButton/ToggleButton.tsx +85 -22
- package/src/ToggleButton/ToggleButtonGroup.tsx +2 -2
- package/src/Token/Token.tsx +4 -4
- package/src/Tokenizer/Tokenizer.tsx +3 -3
- package/src/Toolbar/Toolbar.doc.mjs +8 -7
- package/src/Toolbar/Toolbar.tsx +2 -2
- package/src/Tooltip/useTooltip.tsx +2 -2
- package/src/TopNav/TopNav.tsx +3 -3
- package/src/TopNav/TopNavHeading.tsx +7 -7
- package/src/TopNav/TopNavItem.tsx +3 -3
- package/src/TopNav/TopNavMegaMenu.tsx +3 -3
- package/src/TopNav/TopNavMegaMenuFeaturedCard.tsx +2 -2
- package/src/TopNav/TopNavMegaMenuItem.tsx +3 -3
- package/src/TopNav/TopNavMenu.tsx +2 -2
- package/src/TreeList/TreeList.tsx +2 -2
- package/src/TreeList/TreeListItem.tsx +2 -2
- package/src/Typeahead/BaseTypeahead.tsx +2 -2
- package/src/Typeahead/Typeahead.tsx +2 -2
- package/src/Typeahead/TypeaheadItem.tsx +2 -2
- package/src/docs-types.ts +3 -3
- package/src/hooks/useEntryAnimation.doc.mjs +3 -3
- package/src/hooks/useMediaQuery.doc.mjs +2 -2
- package/src/hooks/useStreamingText.doc.mjs +3 -3
- package/src/naming.ts +1 -1
- package/src/reset.css +1 -1
- package/src/tailwind-theme.css +1 -1
- package/src/theme/Theme.doc.mjs +2 -2
- package/src/theme/Theme.tsx +1 -1
- package/src/theme/defineTheme.ts +3 -3
- package/src/theme/index.ts +2 -2
- package/src/theme/syntax/defineSyntaxTheme.ts +1 -1
- package/src/theme/tokens.ts +4 -4
- package/src/theme/useTheme.ts +2 -2
- package/src/utils/dateParser.test.ts +26 -0
- package/src/utils/dateParser.ts +16 -2
- package/src/utils/mergeProps.ts +4 -4
- package/src/utils/parseStyleKey.ts +2 -2
- package/src/utils/{xdsThemeProps.test.ts → themeProps.test.ts} +12 -12
- package/src/utils/{xdsThemeProps.ts → themeProps.ts} +5 -5
- package/dist/DropdownMenu/renderXDSDropdownItems.d.ts.map +0 -1
- package/dist/utils/xdsThemeProps.d.ts.map +0 -1
|
@@ -21,7 +21,7 @@ import "../theme/tokens.stylex.js";
|
|
|
21
21
|
import { spacingVars, colorVars, typeScaleVars, fontWeightVars } from "../theme/tokens.stylex.js";
|
|
22
22
|
import { MetadataListContext } from "./MetadataListContext.js";
|
|
23
23
|
import { mergeProps } from "../utils/index.js";
|
|
24
|
-
import {
|
|
24
|
+
import { themeProps } from "../utils/themeProps.js";
|
|
25
25
|
|
|
26
26
|
// =============================================================================
|
|
27
27
|
// Types
|
|
@@ -164,7 +164,7 @@ export function MetadataList({
|
|
|
164
164
|
children: /*#__PURE__*/_jsxs("div", {
|
|
165
165
|
ref: ref,
|
|
166
166
|
"data-testid": testId,
|
|
167
|
-
...mergeProps(
|
|
167
|
+
...mergeProps(themeProps('metadata-list', {
|
|
168
168
|
columns: String(columns),
|
|
169
169
|
orientation
|
|
170
170
|
}), stylex.props(styles.root, xstyle), className, style),
|
|
@@ -21,7 +21,7 @@ import "../theme/tokens.stylex.js";
|
|
|
21
21
|
import { colorVars, spacingVars, typeScaleVars, fontWeightVars } from "../theme/tokens.stylex.js";
|
|
22
22
|
import { MetadataListContext } from "./MetadataListContext.js";
|
|
23
23
|
import { mergeProps } from "../utils/index.js";
|
|
24
|
-
import {
|
|
24
|
+
import { themeProps } from "../utils/themeProps.js";
|
|
25
25
|
|
|
26
26
|
// =============================================================================
|
|
27
27
|
// Types
|
|
@@ -99,7 +99,7 @@ export function MetadataListItem({
|
|
|
99
99
|
return /*#__PURE__*/_jsxs("div", {
|
|
100
100
|
ref: ref,
|
|
101
101
|
"data-testid": testId,
|
|
102
|
-
...mergeProps(
|
|
102
|
+
...mergeProps(themeProps('metadata-list-item'), stylex.props(styles.stackedWrapper, xstyle), className, style),
|
|
103
103
|
children: [/*#__PURE__*/_jsx("dt", {
|
|
104
104
|
...{
|
|
105
105
|
className: "xv1l7n4 xjm74w1 xw6l6zx x1e4wzip x78zum5 x6s0dn4 x1txdalj x1ghz6dp x1717udv"
|
|
@@ -119,7 +119,7 @@ export function MetadataListItem({
|
|
|
119
119
|
children: [/*#__PURE__*/_jsx("dt", {
|
|
120
120
|
ref: ref,
|
|
121
121
|
"data-testid": testId ? `${testId}-label` : undefined,
|
|
122
|
-
...mergeProps(
|
|
122
|
+
...mergeProps(themeProps('metadata-list-item'), stylex.props(styles.label, xstyle), className, style),
|
|
123
123
|
children: labelContent
|
|
124
124
|
}), /*#__PURE__*/_jsx("dd", {
|
|
125
125
|
"data-testid": testId ? `${testId}-value` : undefined,
|
|
@@ -34,7 +34,7 @@ import { Icon } from "../Icon/index.js";
|
|
|
34
34
|
import { Heading } from "../Heading/Heading.js";
|
|
35
35
|
import { useAppShellMobile } from "../AppShell/AppShellMobileContext.js";
|
|
36
36
|
import { mergeProps, mergeRefs } from "../utils/index.js";
|
|
37
|
-
import {
|
|
37
|
+
import { themeProps } from "../utils/themeProps.js";
|
|
38
38
|
|
|
39
39
|
// =============================================================================
|
|
40
40
|
// Styles
|
|
@@ -259,7 +259,7 @@ export function MobileNav({
|
|
|
259
259
|
"aria-label": label ?? (typeof header === 'string' ? header : 'Navigation'),
|
|
260
260
|
onClick: handleDialogClick,
|
|
261
261
|
onCancel: handleCancel,
|
|
262
|
-
...mergeProps(
|
|
262
|
+
...mergeProps(themeProps('mobile-nav', {
|
|
263
263
|
side: resolvedSide
|
|
264
264
|
}), stylex.props(styles.dialog, isOpen && styles.open, styles.backdrop, isOpen && styles.backdropOpen, xstyle)),
|
|
265
265
|
children: /*#__PURE__*/_jsxs("div", {
|
|
@@ -28,7 +28,7 @@ import { isOptionData, isDivider, isSection, normalizeOption, getSelectableOptio
|
|
|
28
28
|
import { useMultiCombobox } from "./hooks.js";
|
|
29
29
|
import { mergeProps } from "../utils/index.js";
|
|
30
30
|
import { useSize } from "../SizeContext/SizeContext.js";
|
|
31
|
-
import {
|
|
31
|
+
import { themeProps } from "../utils/themeProps.js";
|
|
32
32
|
|
|
33
33
|
// Sentinel value for the select-all item in keyboard navigation
|
|
34
34
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -636,7 +636,7 @@ export function MultiSelector({
|
|
|
636
636
|
},
|
|
637
637
|
onClick: onTriggerClick,
|
|
638
638
|
"data-testid": testId,
|
|
639
|
-
...mergeProps(
|
|
639
|
+
...mergeProps(themeProps('multi-selector', {
|
|
640
640
|
size,
|
|
641
641
|
status: status?.type ?? null
|
|
642
642
|
}), stylex.props(inputWrapperStyles.base, styles.triggerContainer, sizeStyles[size], isDisabled && inputWrapperStyles.disabled, optimisticValue.length === 0 && styles.triggerPlaceholder, status && inputStatusBorderStyles[status.type], status && inputStatusHoverShadowStyles[status.type], xstyle), className, style),
|
package/dist/NavIcon/NavIcon.js
CHANGED
|
@@ -18,7 +18,7 @@ import * as stylex from '@stylexjs/stylex';
|
|
|
18
18
|
import "../theme/tokens.stylex.js";
|
|
19
19
|
import { colorVars, sizeVars } from "../theme/tokens.stylex.js";
|
|
20
20
|
import { mergeProps } from "../utils/index.js";
|
|
21
|
-
import {
|
|
21
|
+
import { themeProps } from "../utils/themeProps.js";
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* NavIcon styles
|
|
@@ -67,7 +67,7 @@ export function NavIcon({
|
|
|
67
67
|
}) {
|
|
68
68
|
return /*#__PURE__*/_jsx("span", {
|
|
69
69
|
ref: ref,
|
|
70
|
-
...mergeProps(
|
|
70
|
+
...mergeProps(themeProps('navicon'), stylex.props(styles.base, xstyle), className, style),
|
|
71
71
|
...props,
|
|
72
72
|
children: icon
|
|
73
73
|
});
|
|
@@ -17,7 +17,7 @@ import "../theme/tokens.stylex.js";
|
|
|
17
17
|
import { spacingVars } from "../theme/tokens.stylex.js";
|
|
18
18
|
import { mergeProps, mergeRefs } from "../utils/index.js";
|
|
19
19
|
import { useListFocus } from "../hooks/useListFocus.js";
|
|
20
|
-
import {
|
|
20
|
+
import { themeProps } from "../utils/themeProps.js";
|
|
21
21
|
import { NavHeadingMenuContext, useNavHeadingCloseContext } from "./NavMenuContext.js";
|
|
22
22
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
23
|
const styles = {
|
|
@@ -98,7 +98,7 @@ export function NavHeadingMenu({
|
|
|
98
98
|
role: "menu",
|
|
99
99
|
onKeyDown: handleKeyDown,
|
|
100
100
|
"data-testid": testId,
|
|
101
|
-
...mergeProps(
|
|
101
|
+
...mergeProps(themeProps('nav-heading-menu', {
|
|
102
102
|
size
|
|
103
103
|
}), stylex.props(styles.root, sizeStyles[size], xstyle), className, inlineStyle),
|
|
104
104
|
children: children
|
|
@@ -20,7 +20,7 @@ import { colorVars, spacingVars, typographyVars, typeScaleVars, radiusVars } fro
|
|
|
20
20
|
import { mergeProps } from "../utils/index.js";
|
|
21
21
|
import { useNavHeadingMenuContext } from "./NavMenuContext.js";
|
|
22
22
|
import { useLinkComponent } from "../Link/useLinkComponent.js";
|
|
23
|
-
import {
|
|
23
|
+
import { themeProps } from "../utils/themeProps.js";
|
|
24
24
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
25
|
const styles = {
|
|
26
26
|
root: {
|
|
@@ -110,7 +110,7 @@ export function NavHeadingMenuItem({
|
|
|
110
110
|
href: href,
|
|
111
111
|
onClick: handleClick,
|
|
112
112
|
"data-testid": testId,
|
|
113
|
-
...mergeProps(
|
|
113
|
+
...mergeProps(themeProps('nav-heading-menu-item', {
|
|
114
114
|
size
|
|
115
115
|
}), stylex.props(styles.root, sizeStyles[size], isDisabled && styles.disabled, xstyle), className, style),
|
|
116
116
|
children: [icon && renderIconSlot(icon, {
|
|
@@ -49,7 +49,7 @@ import { groupStyles } from "../InputGroup/groupStyles.js";
|
|
|
49
49
|
// Re-export shared types for convenience
|
|
50
50
|
|
|
51
51
|
import { mergeProps, mergeRefs } from "../utils/index.js";
|
|
52
|
-
import {
|
|
52
|
+
import { themeProps } from "../utils/themeProps.js";
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* Without `hasClear`, onChange only receives valid numbers.
|
|
@@ -258,7 +258,7 @@ export function NumberInput({
|
|
|
258
258
|
ref: containerRef,
|
|
259
259
|
onClick: handleWrapperClick,
|
|
260
260
|
onMouseUp: handleWrapperMouseUp,
|
|
261
|
-
...mergeProps(
|
|
261
|
+
...mergeProps(themeProps('number-input', {
|
|
262
262
|
size,
|
|
263
263
|
status: status?.type ?? null
|
|
264
264
|
}), stylex.props(inputWrapperStyles.base, styles.wrapper, sizeStyles[size], isDisabled && inputWrapperStyles.disabled, status && inputStatusBorderStyles[status.type], status && inputStatusHoverShadowStyles[status.type], status && inputStatusFocusWithinStyles[status.type], inputGroup && groupStyles.inGroup, xstyle), className, style),
|
|
@@ -29,8 +29,9 @@ export interface OutlineProps extends BaseProps<HTMLElement> {
|
|
|
29
29
|
* indentation based on each heading level. Features a sliding indicator
|
|
30
30
|
* track that animates to the active item.
|
|
31
31
|
*
|
|
32
|
-
* When `activeId` is omitted, it
|
|
33
|
-
*
|
|
32
|
+
* When `activeId` is omitted, it tracks scroll position and marks the last
|
|
33
|
+
* heading whose top has passed its activation line (its scroll-margin-top)
|
|
34
|
+
* active — defaulting to the first item at the top and the last at the bottom.
|
|
34
35
|
*
|
|
35
36
|
* @example
|
|
36
37
|
* ```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Outline.d.ts","sourceRoot":"","sources":["../../src/Outline/Outline.tsx"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAGzC,YAAY,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAEzC,MAAM,WAAW,YAAa,SAAQ,SAAS,CAAC,WAAW,CAAC;IAC1D,6CAA6C;IAC7C,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAE7B,+CAA+C;IAC/C,KAAK,EAAE,WAAW,EAAE,CAAC;IAErB,oFAAoF;IACpF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,oEAAoE;IACpE,gBAAgB,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAExC,0EAA0E;IAC1E,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;;OAKG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAEhC,sCAAsC;IACtC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAgJD
|
|
1
|
+
{"version":3,"file":"Outline.d.ts","sourceRoot":"","sources":["../../src/Outline/Outline.tsx"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAGzC,YAAY,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAEzC,MAAM,WAAW,YAAa,SAAQ,SAAS,CAAC,WAAW,CAAC;IAC1D,6CAA6C;IAC7C,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAE7B,+CAA+C;IAC/C,KAAK,EAAE,WAAW,EAAE,CAAC;IAErB,oFAAoF;IACpF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,oEAAoE;IACpE,gBAAgB,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAExC,0EAA0E;IAC1E,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;;OAKG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAEhC,sCAAsC;IACtC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAgJD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,OAAO,CAAC,EACtB,KAAK,EACL,QAAQ,EACR,gBAAgB,EAChB,KAA2B,EAC3B,OAAmB,EACnB,MAAM,EACN,SAAS,EACT,KAAK,EACL,GAAG,EACH,aAAa,EAAE,MAAM,EACrB,GAAG,KAAK,EACT,EAAE,YAAY,+BAyGd;yBArHe,OAAO"}
|
package/dist/Outline/Outline.js
CHANGED
|
@@ -26,7 +26,7 @@ import { colorVars, durationVars, easeVars, radiusVars, spacingVars, typeScaleVa
|
|
|
26
26
|
import { useLinkComponent } from "../Link/useLinkComponent.js";
|
|
27
27
|
import { mergeProps, mergeRefs } from "../utils/index.js";
|
|
28
28
|
import { useScrollSpy } from "./useScrollSpy.js";
|
|
29
|
-
import {
|
|
29
|
+
import { themeProps } from "../utils/themeProps.js";
|
|
30
30
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
31
31
|
// =============================================================================
|
|
32
32
|
// Styles
|
|
@@ -133,8 +133,9 @@ function getIndentStyle(level) {
|
|
|
133
133
|
* indentation based on each heading level. Features a sliding indicator
|
|
134
134
|
* track that animates to the active item.
|
|
135
135
|
*
|
|
136
|
-
* When `activeId` is omitted, it
|
|
137
|
-
*
|
|
136
|
+
* When `activeId` is omitted, it tracks scroll position and marks the last
|
|
137
|
+
* heading whose top has passed its activation line (its scroll-margin-top)
|
|
138
|
+
* active — defaulting to the first item at the top and the last at the bottom.
|
|
138
139
|
*
|
|
139
140
|
* @example
|
|
140
141
|
* ```
|
|
@@ -162,7 +163,12 @@ export function Outline({
|
|
|
162
163
|
}) {
|
|
163
164
|
const rootRef = useRef(null);
|
|
164
165
|
const LinkComponent = useLinkComponent();
|
|
165
|
-
const
|
|
166
|
+
const isControlled = activeId !== undefined;
|
|
167
|
+
const {
|
|
168
|
+
activeId: resolvedActiveId,
|
|
169
|
+
setActiveId,
|
|
170
|
+
lockActiveId
|
|
171
|
+
} = useScrollSpy({
|
|
166
172
|
activeId,
|
|
167
173
|
items,
|
|
168
174
|
onActiveIdChange,
|
|
@@ -170,12 +176,25 @@ export function Outline({
|
|
|
170
176
|
});
|
|
171
177
|
const handleClick = id => event => {
|
|
172
178
|
const target = document.getElementById(id);
|
|
173
|
-
|
|
179
|
+
|
|
180
|
+
// Let the browser handle modified clicks (open in new tab, etc.) and
|
|
181
|
+
// missing targets without touching the active state.
|
|
174
182
|
if (target == null || event.defaultPrevented || event.metaKey || event.altKey || event.ctrlKey || event.shiftKey) {
|
|
175
183
|
return;
|
|
176
184
|
}
|
|
177
185
|
event.preventDefault();
|
|
178
186
|
window.history.pushState(null, '', `#${id}`);
|
|
187
|
+
|
|
188
|
+
// Move the indicator to the clicked item in a single step. Controlled
|
|
189
|
+
// consumers own the active state (notify only); uncontrolled mode pins
|
|
190
|
+
// the active id and suppresses scroll-spy until the next manual scroll,
|
|
191
|
+
// so the click is honored — even for short/last sections — and the
|
|
192
|
+
// indicator doesn't chase the smooth scroll through other sections.
|
|
193
|
+
if (isControlled) {
|
|
194
|
+
setActiveId(id);
|
|
195
|
+
} else {
|
|
196
|
+
lockActiveId(id);
|
|
197
|
+
}
|
|
179
198
|
target.scrollIntoView({
|
|
180
199
|
behavior: 'smooth',
|
|
181
200
|
block: 'start'
|
|
@@ -186,7 +205,7 @@ export function Outline({
|
|
|
186
205
|
ref: mergeRefs(rootRef, ref),
|
|
187
206
|
"aria-label": label,
|
|
188
207
|
"data-testid": testId,
|
|
189
|
-
...mergeProps(
|
|
208
|
+
...mergeProps(themeProps('outline', {
|
|
190
209
|
density
|
|
191
210
|
}), stylex.props(styles.root, xstyle), className, style),
|
|
192
211
|
children: [/*#__PURE__*/_jsx("ul", {
|
|
@@ -205,7 +224,7 @@ export function Outline({
|
|
|
205
224
|
href: `#${item.id}`,
|
|
206
225
|
"aria-current": isActive ? 'true' : undefined,
|
|
207
226
|
onClick: handleClick(item.id),
|
|
208
|
-
...mergeProps(
|
|
227
|
+
...mergeProps(themeProps('outline-item', {
|
|
209
228
|
active: isActive ? 'active' : null,
|
|
210
229
|
level: item.level
|
|
211
230
|
}), stylex.props(styles.link, densityStyles[density], getIndentStyle(item.level), isActive && styles.activeLink, isActive && styles.activeAnchor)),
|
|
@@ -229,7 +248,7 @@ export function Outline({
|
|
|
229
248
|
}
|
|
230
249
|
})
|
|
231
250
|
}), /*#__PURE__*/_jsx("span", {
|
|
232
|
-
...mergeProps(
|
|
251
|
+
...mergeProps(themeProps('outline-indicator'), {
|
|
233
252
|
className: "x10l6tqk x1o0tod xfo62xy xowkcby xjspbzw x47corl x1vjfegm x1tsffl5 x1ltwjim x1qjb5ga x1xuz8iz xkvfbh3 xlr8y92"
|
|
234
253
|
}),
|
|
235
254
|
"aria-hidden": "true"
|
|
@@ -5,6 +5,19 @@ interface UseScrollSpyOptions {
|
|
|
5
5
|
onActiveIdChange?: (id: string) => void;
|
|
6
6
|
rootRef: React.RefObject<HTMLElement | null>;
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
interface UseScrollSpyResult {
|
|
9
|
+
activeId: string | undefined;
|
|
10
|
+
/** Set the active id (notifies onActiveIdChange). For controlled consumers. */
|
|
11
|
+
setActiveId: (id: string) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Handle a click on the outline item with id `id`. Delays moving the
|
|
14
|
+
* indicator: scroll-spy is suppressed during the programmatic smooth scroll
|
|
15
|
+
* so the indicator doesn't chase it, then the indicator moves once to the
|
|
16
|
+
* clicked item when the scroll settles. If the user scrolls manually mid-way,
|
|
17
|
+
* scroll-position tracking resumes immediately instead.
|
|
18
|
+
*/
|
|
19
|
+
lockActiveId: (id: string) => void;
|
|
20
|
+
}
|
|
21
|
+
export declare function useScrollSpy({ activeId, items, onActiveIdChange, rootRef, }: UseScrollSpyOptions): UseScrollSpyResult;
|
|
9
22
|
export {};
|
|
10
23
|
//# sourceMappingURL=useScrollSpy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScrollSpy.d.ts","sourceRoot":"","sources":["../../src/Outline/useScrollSpy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useScrollSpy.d.ts","sourceRoot":"","sources":["../../src/Outline/useScrollSpy.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAuFzC,UAAU,mBAAmB;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,gBAAgB,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;CAC9C;AAED,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,+EAA+E;IAC/E,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC;;;;;;OAMG;IACH,YAAY,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAED,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,KAAK,EACL,gBAAgB,EAChB,OAAO,GACR,EAAE,mBAAmB,GAAG,kBAAkB,CA2I1C"}
|
|
@@ -4,13 +4,23 @@
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @file useScrollSpy.ts
|
|
7
|
-
* @input Uses React,
|
|
7
|
+
* @input Uses React, scroll position of heading elements, OutlineItem type
|
|
8
8
|
* @output Exports internal useScrollSpy hook
|
|
9
9
|
* @position Internal behavior hook; consumed by Outline.tsx
|
|
10
10
|
*
|
|
11
|
+
* Drives the active outline item from scroll position. On each scroll
|
|
12
|
+
* (rAF-throttled) it reads live heading positions and marks the last heading
|
|
13
|
+
* whose top has passed its activation line (its own scroll-margin-top, i.e.
|
|
14
|
+
* where it lands when navigated to). This is stable — it never compares stale
|
|
15
|
+
* cached positions — so the indicator moves monotonically instead of jumping.
|
|
16
|
+
* Defaults to the first item at the top and the last item at the bottom so
|
|
17
|
+
* short final sections still activate.
|
|
18
|
+
*
|
|
11
19
|
* SYNC: When modified, update /packages/core/src/Outline/Outline.tsx
|
|
12
20
|
*/
|
|
13
|
-
import { useEffect, useRef, useState } from 'react';
|
|
21
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
22
|
+
/** Keys that scroll the viewport — used to detect a manual scroll intent. */
|
|
23
|
+
const SCROLL_KEYS = new Set(['ArrowUp', 'ArrowDown', 'PageUp', 'PageDown', 'Home', 'End', ' ', 'Spacebar']);
|
|
14
24
|
function getScrollableAncestor(element) {
|
|
15
25
|
let current = element?.parentElement ?? null;
|
|
16
26
|
while (current != null) {
|
|
@@ -24,6 +34,41 @@ function getScrollableAncestor(element) {
|
|
|
24
34
|
}
|
|
25
35
|
return null;
|
|
26
36
|
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Resolve the active heading id from current scroll position.
|
|
40
|
+
*
|
|
41
|
+
* A heading is "passed" once its top reaches its activation line — the scroll
|
|
42
|
+
* root's top plus the heading's own scroll-margin-top. The active heading is
|
|
43
|
+
* the last passed one (headings are in document order). When none have passed
|
|
44
|
+
* (scrolled above the first), the first item is active; at the bottom, the
|
|
45
|
+
* last item is active.
|
|
46
|
+
*/
|
|
47
|
+
function resolveActiveId(items, scrollRoot) {
|
|
48
|
+
if (items.length === 0) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
const rootTop = scrollRoot != null ? scrollRoot.getBoundingClientRect().top : 0;
|
|
52
|
+
const atBottom = scrollRoot != null ? scrollRoot.scrollTop + scrollRoot.clientHeight >= scrollRoot.scrollHeight - 2 : window.innerHeight + window.scrollY >= document.documentElement.scrollHeight - 2;
|
|
53
|
+
if (atBottom) {
|
|
54
|
+
return items[items.length - 1].id;
|
|
55
|
+
}
|
|
56
|
+
let activeId = items[0].id;
|
|
57
|
+
for (const item of items) {
|
|
58
|
+
const element = document.getElementById(item.id);
|
|
59
|
+
if (element == null) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
const top = element.getBoundingClientRect().top;
|
|
63
|
+
const marginTop = Number.parseFloat(window.getComputedStyle(element).scrollMarginTop) || 0;
|
|
64
|
+
if (top <= rootTop + marginTop + 1) {
|
|
65
|
+
activeId = item.id;
|
|
66
|
+
} else {
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return activeId;
|
|
71
|
+
}
|
|
27
72
|
export function useScrollSpy({
|
|
28
73
|
activeId,
|
|
29
74
|
items,
|
|
@@ -32,72 +77,138 @@ export function useScrollSpy({
|
|
|
32
77
|
}) {
|
|
33
78
|
const isControlled = activeId !== undefined;
|
|
34
79
|
const [uncontrolledActiveId, setUncontrolledActiveId] = useState(items[0]?.id);
|
|
35
|
-
const visibleHeadingIdsRef = useRef(new Set());
|
|
36
|
-
const headingTopRef = useRef(new Map());
|
|
37
80
|
const activeIdRef = useRef(activeId);
|
|
81
|
+
// While true, scroll-spy ignores scroll updates because a click is driving a
|
|
82
|
+
// programmatic scroll. Released when that scroll settles or the user scrolls.
|
|
83
|
+
const suppressRef = useRef(false);
|
|
84
|
+
const releaseSuppressionRef = useRef(null);
|
|
85
|
+
// Latest scroll-position resolver, so the click handler can resume tracking
|
|
86
|
+
// when the user scrolls during a programmatic scroll.
|
|
87
|
+
const syncRef = useRef(null);
|
|
88
|
+
// Keep latest items/callback in refs so the scroll listener effect doesn't
|
|
89
|
+
// re-subscribe on every render (items is a fresh array each render).
|
|
90
|
+
const itemsRef = useRef(items);
|
|
91
|
+
itemsRef.current = items;
|
|
92
|
+
const onActiveIdChangeRef = useRef(onActiveIdChange);
|
|
93
|
+
onActiveIdChangeRef.current = onActiveIdChange;
|
|
38
94
|
const itemIds = items.map(item => item.id).join('\n');
|
|
39
95
|
activeIdRef.current = isControlled ? activeId : uncontrolledActiveId;
|
|
40
96
|
useEffect(() => {
|
|
41
|
-
if (isControlled || typeof
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
const headingElements = items.map(item => document.getElementById(item.id)).filter(element => element != null);
|
|
45
|
-
if (headingElements.length === 0) {
|
|
97
|
+
if (isControlled || typeof window === 'undefined') {
|
|
46
98
|
return;
|
|
47
99
|
}
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
100
|
+
const scrollRoot = getScrollableAncestor(rootRef.current);
|
|
101
|
+
const scrollTarget = scrollRoot ?? window;
|
|
102
|
+
let frame = 0;
|
|
103
|
+
const update = () => {
|
|
104
|
+
frame = 0;
|
|
105
|
+
if (suppressRef.current) {
|
|
52
106
|
return;
|
|
53
107
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
let nextActiveId;
|
|
60
|
-
let nextTop = Number.POSITIVE_INFINITY;
|
|
61
|
-
for (const id of visibleHeadingIds) {
|
|
62
|
-
const top = headingTop.get(id) ?? Number.POSITIVE_INFINITY;
|
|
63
|
-
if (top < nextTop) {
|
|
64
|
-
nextTop = top;
|
|
65
|
-
nextActiveId = id;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
if (nextActiveId != null) {
|
|
69
|
-
setNextActiveId(nextActiveId);
|
|
108
|
+
const nextActiveId = resolveActiveId(itemsRef.current, scrollRoot);
|
|
109
|
+
if (nextActiveId != null && nextActiveId !== activeIdRef.current) {
|
|
110
|
+
activeIdRef.current = nextActiveId;
|
|
111
|
+
setUncontrolledActiveId(nextActiveId);
|
|
112
|
+
onActiveIdChangeRef.current?.(nextActiveId);
|
|
70
113
|
}
|
|
71
114
|
};
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
headingTop.set(id, entry.boundingClientRect.top);
|
|
76
|
-
if (entry.isIntersecting) {
|
|
77
|
-
visibleHeadingIds.add(id);
|
|
78
|
-
} else {
|
|
79
|
-
visibleHeadingIds.delete(id);
|
|
80
|
-
}
|
|
115
|
+
const onScroll = () => {
|
|
116
|
+
if (frame === 0) {
|
|
117
|
+
frame = requestAnimationFrame(update);
|
|
81
118
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
119
|
+
};
|
|
120
|
+
syncRef.current = update;
|
|
121
|
+
update();
|
|
122
|
+
scrollTarget.addEventListener('scroll', onScroll, {
|
|
123
|
+
passive: true
|
|
124
|
+
});
|
|
125
|
+
window.addEventListener('resize', onScroll, {
|
|
126
|
+
passive: true
|
|
86
127
|
});
|
|
87
|
-
for (const headingElement of headingElements) {
|
|
88
|
-
observer.observe(headingElement);
|
|
89
|
-
}
|
|
90
128
|
return () => {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
129
|
+
syncRef.current = null;
|
|
130
|
+
scrollTarget.removeEventListener('scroll', onScroll);
|
|
131
|
+
window.removeEventListener('resize', onScroll);
|
|
132
|
+
if (frame !== 0) {
|
|
133
|
+
cancelAnimationFrame(frame);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}, [isControlled, itemIds, rootRef]);
|
|
137
|
+
|
|
138
|
+
// Tear down any pending suppression listeners when the Outline unmounts.
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
return () => {
|
|
141
|
+
releaseSuppressionRef.current?.();
|
|
94
142
|
};
|
|
95
|
-
}, [
|
|
143
|
+
}, []);
|
|
96
144
|
const setActiveId = nextActiveId => {
|
|
97
145
|
if (!isControlled) {
|
|
98
146
|
setUncontrolledActiveId(nextActiveId);
|
|
99
147
|
}
|
|
100
148
|
onActiveIdChange?.(nextActiveId);
|
|
101
149
|
};
|
|
102
|
-
|
|
150
|
+
const lockActiveId = useCallback(clickedId => {
|
|
151
|
+
if (typeof window === 'undefined') {
|
|
152
|
+
setUncontrolledActiveId(clickedId);
|
|
153
|
+
activeIdRef.current = clickedId;
|
|
154
|
+
onActiveIdChangeRef.current?.(clickedId);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Freeze the indicator during the programmatic smooth scroll instead of
|
|
159
|
+
// moving it immediately — it lands on the clicked item once the scroll
|
|
160
|
+
// settles, so it doesn't chase the scroll through intervening sections.
|
|
161
|
+
suppressRef.current = true;
|
|
162
|
+
// Replace any in-flight handlers from a previous click.
|
|
163
|
+
releaseSuppressionRef.current?.();
|
|
164
|
+
let settleTimer = 0;
|
|
165
|
+
const cleanup = () => {
|
|
166
|
+
window.removeEventListener('scrollend', onSettle);
|
|
167
|
+
window.removeEventListener('wheel', onManual);
|
|
168
|
+
window.removeEventListener('touchmove', onManual);
|
|
169
|
+
window.removeEventListener('keydown', onKeyDown);
|
|
170
|
+
if (settleTimer !== 0) {
|
|
171
|
+
clearTimeout(settleTimer);
|
|
172
|
+
settleTimer = 0;
|
|
173
|
+
}
|
|
174
|
+
releaseSuppressionRef.current = null;
|
|
175
|
+
};
|
|
176
|
+
// Programmatic scroll finished: move the indicator to the clicked item.
|
|
177
|
+
const onSettle = () => {
|
|
178
|
+
cleanup();
|
|
179
|
+
suppressRef.current = false;
|
|
180
|
+
setUncontrolledActiveId(clickedId);
|
|
181
|
+
activeIdRef.current = clickedId;
|
|
182
|
+
onActiveIdChangeRef.current?.(clickedId);
|
|
183
|
+
};
|
|
184
|
+
// User scrolled mid-flight: hand control back to scroll-position tracking.
|
|
185
|
+
const onManual = () => {
|
|
186
|
+
cleanup();
|
|
187
|
+
suppressRef.current = false;
|
|
188
|
+
syncRef.current?.();
|
|
189
|
+
};
|
|
190
|
+
const onKeyDown = event => {
|
|
191
|
+
if (SCROLL_KEYS.has(event.key)) {
|
|
192
|
+
onManual();
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
window.addEventListener('scrollend', onSettle, {
|
|
196
|
+
once: true
|
|
197
|
+
});
|
|
198
|
+
window.addEventListener('wheel', onManual, {
|
|
199
|
+
passive: true
|
|
200
|
+
});
|
|
201
|
+
window.addEventListener('touchmove', onManual, {
|
|
202
|
+
passive: true
|
|
203
|
+
});
|
|
204
|
+
window.addEventListener('keydown', onKeyDown);
|
|
205
|
+
// Fallback when scrollend is unsupported or no scroll is needed.
|
|
206
|
+
settleTimer = window.setTimeout(onSettle, 1200);
|
|
207
|
+
releaseSuppressionRef.current = cleanup;
|
|
208
|
+
}, []);
|
|
209
|
+
return {
|
|
210
|
+
activeId: isControlled ? activeId : uncontrolledActiveId,
|
|
211
|
+
setActiveId,
|
|
212
|
+
lockActiveId
|
|
213
|
+
};
|
|
103
214
|
}
|
|
@@ -22,7 +22,7 @@ import { mergeProps, mergeRefs } from "../utils/index.js";
|
|
|
22
22
|
import { useOverflow } from "../hooks/useOverflow.js";
|
|
23
23
|
import "../theme/tokens.stylex.js";
|
|
24
24
|
import { spacingVars } from "../theme/tokens.stylex.js";
|
|
25
|
-
import {
|
|
25
|
+
import { themeProps } from "../utils/themeProps.js";
|
|
26
26
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
27
27
|
const styles = {
|
|
28
28
|
container: {
|
|
@@ -192,7 +192,7 @@ export function OverflowList({
|
|
|
192
192
|
})]
|
|
193
193
|
}), /*#__PURE__*/_jsxs("div", {
|
|
194
194
|
ref: mergeRefs(ref, containerRef),
|
|
195
|
-
...mergeProps(
|
|
195
|
+
...mergeProps(themeProps('overflow-list'), stylex.props(styles.container, gapStyles[gap], observeParent && hasOverflow && styles.fillParent, xstyle), className, style),
|
|
196
196
|
...props,
|
|
197
197
|
children: [collapseFrom === 'start' && hasOverflow && overflowRenderer?.(overflowItems), visibleItems.map(({
|
|
198
198
|
child
|
package/dist/Overlay/Overlay.js
CHANGED
|
@@ -19,7 +19,7 @@ import { mergeProps, mergeRefs } from "../utils/index.js";
|
|
|
19
19
|
import { useOverlay } from "./useOverlay.js";
|
|
20
20
|
import { useIsomorphicLayoutEffect } from "../hooks/useIsomorphicLayoutEffect.js";
|
|
21
21
|
import { overlayScope, overlayContainerStyles } from "./overlay.markers.stylex.js";
|
|
22
|
-
import {
|
|
22
|
+
import { themeProps } from "../utils/themeProps.js";
|
|
23
23
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
24
|
/**
|
|
25
25
|
* Overlay — renders content on top of media with a scrim background
|
|
@@ -81,7 +81,7 @@ export function Overlay({
|
|
|
81
81
|
}, []);
|
|
82
82
|
return /*#__PURE__*/_jsxs("div", {
|
|
83
83
|
ref: mergeRefs(ref, overlay.containerRef),
|
|
84
|
-
...mergeProps(
|
|
84
|
+
...mergeProps(themeProps('overlay'), stylex.props(overlayScope, overlayContainerStyles.root, xstyle), className, style),
|
|
85
85
|
onClick: overlay.containerProps.onClick,
|
|
86
86
|
onMouseUp: overlay.containerProps.onMouseUp,
|
|
87
87
|
children: [children, overlay.element]
|
|
@@ -18,7 +18,7 @@ import { MediaTheme } from "../theme/MediaTheme.js";
|
|
|
18
18
|
import { mergeProps } from "../utils/index.js";
|
|
19
19
|
import "./overlay.markers.stylex.js";
|
|
20
20
|
import { overlayScope } from "./overlay.markers.stylex.js";
|
|
21
|
-
import {
|
|
21
|
+
import { themeProps } from "../utils/themeProps.js";
|
|
22
22
|
|
|
23
23
|
// =============================================================================
|
|
24
24
|
// Types (re-exported from index.ts for consumers)
|
|
@@ -220,7 +220,7 @@ export function OverlayScrim({
|
|
|
220
220
|
}) : children;
|
|
221
221
|
const visibility = isControlled ? getControlledVisibility(isOpen, position) : getShowOnVisibility(showOn, position);
|
|
222
222
|
return /*#__PURE__*/_jsx("div", {
|
|
223
|
-
...mergeProps(
|
|
223
|
+
...mergeProps(themeProps('overlay-scrim', {
|
|
224
224
|
position
|
|
225
225
|
}), stylex.props(styles.base, positionMap[position], alignMap[align], scrim === 'dark' && styles.scrimDark, scrim === 'light' && styles.scrimLight, visibility.base, visibility.bottom, visibility.top)),
|
|
226
226
|
inert: isControlled && !isOpen ? true : undefined,
|
|
@@ -27,7 +27,7 @@ import { Icon } from "../Icon/index.js";
|
|
|
27
27
|
import { Selector } from "../Selector/index.js";
|
|
28
28
|
import { Text } from "../Text/index.js";
|
|
29
29
|
import { mergeProps } from "../utils/index.js";
|
|
30
|
-
import {
|
|
30
|
+
import { themeProps } from "../utils/themeProps.js";
|
|
31
31
|
|
|
32
32
|
// =============================================================================
|
|
33
33
|
// Types
|
|
@@ -319,7 +319,7 @@ export function Pagination({
|
|
|
319
319
|
"aria-current": i + 1 === page ? 'page' : undefined,
|
|
320
320
|
onClick: () => handlePageChange(i + 1),
|
|
321
321
|
disabled: isDisabled,
|
|
322
|
-
...mergeProps(
|
|
322
|
+
...mergeProps(themeProps('pagination-dot', {
|
|
323
323
|
active: i + 1 === page ? 'active' : null,
|
|
324
324
|
size
|
|
325
325
|
}), {
|
|
@@ -360,7 +360,7 @@ export function Pagination({
|
|
|
360
360
|
ref: ref,
|
|
361
361
|
"aria-label": label,
|
|
362
362
|
"data-testid": testId,
|
|
363
|
-
...mergeProps(
|
|
363
|
+
...mergeProps(themeProps('pagination', {
|
|
364
364
|
variant,
|
|
365
365
|
size
|
|
366
366
|
}), stylex.props(styles.root, xstyle), className, style),
|