@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
package/src/docs-types.ts
CHANGED
|
@@ -76,7 +76,7 @@ export interface PropDoc {
|
|
|
76
76
|
* A theming target — a stable selector surface that `defineTheme` can target
|
|
77
77
|
* via `@scope` selectors. Each component renders one or more stable `xds-*`
|
|
78
78
|
* class names and reflects visual props/states as `data-*` attributes via
|
|
79
|
-
* `
|
|
79
|
+
* `themeProps()`, so themes and external CSS have an explicit prop-aware selector surface.
|
|
80
80
|
*
|
|
81
81
|
* @example
|
|
82
82
|
* ```
|
|
@@ -91,7 +91,7 @@ export interface ThemingTarget {
|
|
|
91
91
|
* e.g. `"astryx-button"`, `"astryx-avatar-status-dot"`, `"astryx-card"` */
|
|
92
92
|
className: string;
|
|
93
93
|
/** Visual prop names reflected on this element.
|
|
94
|
-
* These are the props passed to `
|
|
94
|
+
* These are the props passed to `themeProps()` as the second argument.
|
|
95
95
|
* Use these names to derive preferred data selectors: `variant` →
|
|
96
96
|
* `[data-variant="secondary"]`, `level` → `[data-level="2"]`. Legacy bare
|
|
97
97
|
* classes are still emitted for compatibility but should not be the primary
|
|
@@ -494,7 +494,7 @@ interface BaseDoc {
|
|
|
494
494
|
* `--layout-padding-*` tokens instead of emitting raw CSS. */
|
|
495
495
|
container?: boolean;
|
|
496
496
|
/** Selector targets rendered by this component.
|
|
497
|
-
* Each entry corresponds to an `
|
|
497
|
+
* Each entry corresponds to an `themeProps()` call in the source. */
|
|
498
498
|
targets: ThemingTarget[];
|
|
499
499
|
/** CSS custom properties exposed for theming. */
|
|
500
500
|
vars?: ComponentVar[];
|
|
@@ -23,7 +23,7 @@ export const docs = {
|
|
|
23
23
|
],
|
|
24
24
|
usage: {
|
|
25
25
|
description:
|
|
26
|
-
'Returns a StyleX style for animating an element on mount. Only animates when the element is dynamically inserted after the initial page paint; elements rendered on page load are not animated. Uses
|
|
26
|
+
'Returns a StyleX style for animating an element on mount. Only animates when the element is dynamically inserted after the initial page paint; elements rendered on page load are not animated. Uses Astryx motion tokens (duration, easing) for consistent animation timing. Requires "use client"; does not support SSR.',
|
|
27
27
|
bestPractices: [
|
|
28
28
|
{ guidance: true, description: 'Use for conditionally rendered elements like validation messages, toasts, or expanding sections.' },
|
|
29
29
|
{ guidance: true, description: 'Spread the returned style into stylex.props() alongside other styles.' },
|
|
@@ -39,7 +39,7 @@ export const docs = {
|
|
|
39
39
|
/** @type {import('../docs-types').HookTranslationDoc} */
|
|
40
40
|
export const docsDense = {
|
|
41
41
|
description:
|
|
42
|
-
'Returns StyleX style for animating element on mount. Only animates when element dynamically inserted after initial page paint; elements rendered on page load not animated. Uses
|
|
42
|
+
'Returns StyleX style for animating element on mount. Only animates when element dynamically inserted after initial page paint; elements rendered on page load not animated. Uses Astryx motion tokens (duration, easing) for consistent timing. Requires "use client"; does not support SSR.',
|
|
43
43
|
paramDescriptions: {
|
|
44
44
|
preset: 'animation preset applied on mount.',
|
|
45
45
|
},
|
|
@@ -48,7 +48,7 @@ export const docsDense = {
|
|
|
48
48
|
},
|
|
49
49
|
usage: {
|
|
50
50
|
description:
|
|
51
|
-
'Returns StyleX style for animating element on mount. Only animates when element dynamically inserted after initial page paint; elements rendered on page load not animated. Uses
|
|
51
|
+
'Returns StyleX style for animating element on mount. Only animates when element dynamically inserted after initial page paint; elements rendered on page load not animated. Uses Astryx motion tokens (duration, easing) for consistent timing. Requires "use client"; does not support SSR.',
|
|
52
52
|
bestPractices: [
|
|
53
53
|
{ guidance: true, description: 'Use for conditionally rendered elements like validation messages, toasts, expanding sections.' },
|
|
54
54
|
{ guidance: true, description: 'Spread returned style into stylex.props() alongside other styles.' },
|
|
@@ -24,7 +24,7 @@ export const docs = {
|
|
|
24
24
|
description: 'SSR-safe media query hook that subscribes to window.matchMedia changes. Returns whether the given media query matches. Always returns false on first render for SSR compatibility.',
|
|
25
25
|
bestPractices: [
|
|
26
26
|
{ guidance: true, description: 'Use for responsive layout switching based on viewport width, color scheme, or motion preferences.' },
|
|
27
|
-
{ guidance: true, description: 'Prefer
|
|
27
|
+
{ guidance: true, description: 'Prefer Astryx responsive tokens and component props over manual breakpoint logic when possible.' },
|
|
28
28
|
{ guidance: false, description: 'Use for server-rendered content that must match on first paint; the hook always returns false initially.' },
|
|
29
29
|
],
|
|
30
30
|
},
|
|
@@ -47,7 +47,7 @@ export const docsDense = {
|
|
|
47
47
|
description: 'SSR-safe media query hook subscribing to window.matchMedia changes. Returns whether given media query matches. Always returns false on first render for SSR compatibility.',
|
|
48
48
|
bestPractices: [
|
|
49
49
|
{ guidance: true, description: 'Use for responsive layout switching based on viewport width, color scheme, or motion preferences.' },
|
|
50
|
-
{ guidance: true, description: 'Prefer
|
|
50
|
+
{ guidance: true, description: 'Prefer Astryx responsive tokens + component props over manual breakpoint logic when possible.' },
|
|
51
51
|
{ guidance: false, description: 'Use for server-rendered content that must match on first paint; hook always returns false initially.' },
|
|
52
52
|
],
|
|
53
53
|
},
|
|
@@ -41,7 +41,7 @@ export const docs = {
|
|
|
41
41
|
],
|
|
42
42
|
usage: {
|
|
43
43
|
description:
|
|
44
|
-
'Smooths bursty streamed text into a steady character-by-character reveal using requestAnimationFrame. Decouples arrival rate from display rate. Advances on word and syntax boundaries to avoid slicing mid-markdown or mid-word, preventing visual glitches with markdown renderers. Animation timing derives from
|
|
44
|
+
'Smooths bursty streamed text into a steady character-by-character reveal using requestAnimationFrame. Decouples arrival rate from display rate. Advances on word and syntax boundaries to avoid slicing mid-markdown or mid-word, preventing visual glitches with markdown renderers. Animation timing derives from Astryx motion tokens via useTheme when available, with sensible fallbacks outside a theme provider. Snaps to full text when isStreaming becomes false.',
|
|
45
45
|
bestPractices: [
|
|
46
46
|
{ guidance: true, description: 'Pass the accumulated text (not individual chunks) as targetText; the hook handles incremental reveal internally.' },
|
|
47
47
|
{ guidance: true, description: 'Set isStreaming to false when the stream completes to snap to the final text.' },
|
|
@@ -58,7 +58,7 @@ export const docs = {
|
|
|
58
58
|
/** @type {import('../docs-types').HookTranslationDoc} */
|
|
59
59
|
export const docsDense = {
|
|
60
60
|
description:
|
|
61
|
-
'Smooths bursty streamed text into steady character-by-character reveal using requestAnimationFrame. Decouples arrival rate from display rate. Advances on word + syntax boundaries to avoid slicing mid-markdown / mid-word, preventing visual glitches w/ markdown renderers. Animation timing derives from
|
|
61
|
+
'Smooths bursty streamed text into steady character-by-character reveal using requestAnimationFrame. Decouples arrival rate from display rate. Advances on word + syntax boundaries to avoid slicing mid-markdown / mid-word, preventing visual glitches w/ markdown renderers. Animation timing derives from Astryx motion tokens via useTheme when available, w/ sensible fallbacks outside theme provider. Snaps to full text when isStreaming becomes false.',
|
|
62
62
|
paramDescriptions: {
|
|
63
63
|
targetText: 'full target text to reveal. As new chunks arrive, update this value w/ accumulated text.',
|
|
64
64
|
isStreaming: 'whether text currently being streamed. When false, hook returns full targetText immediately.',
|
|
@@ -70,7 +70,7 @@ export const docsDense = {
|
|
|
70
70
|
},
|
|
71
71
|
usage: {
|
|
72
72
|
description:
|
|
73
|
-
'Smooths bursty streamed text into steady character-by-character reveal using requestAnimationFrame. Decouples arrival rate from display rate. Advances on word + syntax boundaries to avoid slicing mid-markdown / mid-word, preventing visual glitches w/ markdown renderers. Animation timing derives from
|
|
73
|
+
'Smooths bursty streamed text into steady character-by-character reveal using requestAnimationFrame. Decouples arrival rate from display rate. Advances on word + syntax boundaries to avoid slicing mid-markdown / mid-word, preventing visual glitches w/ markdown renderers. Animation timing derives from Astryx motion tokens via useTheme when available, w/ sensible fallbacks outside theme provider. Snaps to full text when isStreaming becomes false.',
|
|
74
74
|
bestPractices: [
|
|
75
75
|
{ guidance: true, description: 'Pass accumulated text (not individual chunks) as targetText; hook handles incremental reveal internally.' },
|
|
76
76
|
{ guidance: true, description: 'Set isStreaming to false when stream completes to snap to final text.' },
|
package/src/naming.ts
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* - CSS custom properties: `--astryx-*` via {@link cssVarNamespace} / {@link cssVar}.
|
|
28
28
|
* - CSS layers: `astryx-base` / `astryx-theme`.
|
|
29
29
|
*
|
|
30
|
-
* SYNC: packages/core/src/utils/
|
|
30
|
+
* SYNC: packages/core/src/utils/themeProps.ts (consumes classPrefix)
|
|
31
31
|
* SYNC: packages/core/src/utils/parseStyleKey.ts
|
|
32
32
|
* SYNC: packages/cli/src/commands/build-theme.mjs (imports @astryxdesign/core/naming)
|
|
33
33
|
*/
|
package/src/reset.css
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* 2. Combine with base styles and theme:
|
|
24
24
|
* import '@astryxdesign/core/reset.css'; // @layer reset — clean slate
|
|
25
25
|
* import '@astryxdesign/core/astryx.css'; // @layer astryx-base — component styles
|
|
26
|
-
* import '@astryxdesign/theme-
|
|
26
|
+
* import '@astryxdesign/theme-neutral/theme.css'; // @layer astryx-theme — theme overrides
|
|
27
27
|
*
|
|
28
28
|
* Layer order: reset → astryx-base → astryx-theme
|
|
29
29
|
* Consumer styles (unlayered) always override all Astryx layers.
|
package/src/tailwind-theme.css
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* @import "tailwindcss/preflight.css" layer(base);
|
|
21
21
|
* @import "@astryxdesign/core/reset.css";
|
|
22
22
|
* @import "@astryxdesign/core/astryx.css";
|
|
23
|
-
* @import "@astryxdesign/theme-
|
|
23
|
+
* @import "@astryxdesign/theme-neutral/theme.css";
|
|
24
24
|
* @import "@astryxdesign/core/tailwind-theme.css";
|
|
25
25
|
* @import "tailwindcss/utilities.css" layer(utilities);
|
|
26
26
|
*
|
package/src/theme/Theme.doc.mjs
CHANGED
|
@@ -39,7 +39,7 @@ export const docs = {
|
|
|
39
39
|
},
|
|
40
40
|
usage: {
|
|
41
41
|
description:
|
|
42
|
-
'Wraps a subtree with a specific
|
|
42
|
+
'Wraps a subtree with a specific Astryx theme. For static production themes, use `npx astryx theme build` and import the generated CSS plus built theme object for first-paint and SSR performance. Use runtime `defineTheme()` when themes are dynamic or for prototyping.\n\n`defineTheme` accepts a `tokens` object whose keys are CSS custom property names (always prefixed with `--`). Common token names include `--color-accent`, `--color-background-surface`, `--color-background-body`, `--color-text-primary`, `--color-text-secondary`, `--radius-container`, `--spacing-1` through `--spacing-6`. Values can be a string (same for light/dark) or a `[light, dark]` tuple.\n\nExample:\n```ts\nimport {defineTheme} from \'@astryxdesign/core/theme\';\nconst myTheme = defineTheme({\n name: \'ocean\',\n tokens: {\n \'--color-accent\': [\'#0077B6\', \'#48CAE4\'],\n \'--color-background-surface\': [\'#F0F8FF\', \'#0A1628\'],\n \'--color-text-primary\': [\'#0A1317\', \'#FFFFFF\'],\n \'--radius-container\': \'16px\',\n },\n});\n```',
|
|
43
43
|
bestPractices: [
|
|
44
44
|
{
|
|
45
45
|
guidance: true,
|
|
@@ -90,7 +90,7 @@ export const docs = {
|
|
|
90
90
|
export const docsDense = {
|
|
91
91
|
usage: {
|
|
92
92
|
description:
|
|
93
|
-
'Wraps subtree w/ specific
|
|
93
|
+
'Wraps subtree w/ specific Astryx theme. For static production themes, use `npx astryx theme build` + generated CSS + built theme object for first-paint/SSR performance. Use runtime `defineTheme()` for dynamic themes or prototyping. Token names always start with `--` (e.g. `--color-accent`, `--color-background-surface`).',
|
|
94
94
|
bestPractices: [
|
|
95
95
|
{
|
|
96
96
|
guidance: true,
|
package/src/theme/Theme.tsx
CHANGED
|
@@ -123,7 +123,7 @@ function useThemeStyleInjection(theme: DefinedTheme): void {
|
|
|
123
123
|
if (!warnedThemes.has(theme.name)) {
|
|
124
124
|
warnedThemes.add(theme.name);
|
|
125
125
|
console.warn(
|
|
126
|
-
`[
|
|
126
|
+
`[Astryx] Theme "${theme.name}" is using runtime style injection. ` +
|
|
127
127
|
`For better performance, use the pre-built theme:\n\n` +
|
|
128
128
|
` import {${theme.name}Theme} from '@astryxdesign/theme-${theme.name}/built';\n` +
|
|
129
129
|
` import '@astryxdesign/theme-${theme.name}/theme.css';\n\n` +
|
package/src/theme/defineTheme.ts
CHANGED
|
@@ -173,11 +173,11 @@ export interface DefineThemeInput {
|
|
|
173
173
|
*
|
|
174
174
|
* @example
|
|
175
175
|
* ```tsx
|
|
176
|
-
* import {
|
|
176
|
+
* import {neutralTheme} from '@astryxdesign/theme-neutral';
|
|
177
177
|
*
|
|
178
178
|
* const myTheme = defineTheme({
|
|
179
179
|
* name: 'my-brand',
|
|
180
|
-
* extends:
|
|
180
|
+
* extends: neutralTheme,
|
|
181
181
|
* icons: myIcons,
|
|
182
182
|
* tokens: { '--color-accent': '#FF0000' },
|
|
183
183
|
* });
|
|
@@ -361,7 +361,7 @@ export interface DefinedTheme {
|
|
|
361
361
|
// =============================================================================
|
|
362
362
|
|
|
363
363
|
/** All Astryx token defaults as a flat map. Useful for resolving full token sets. */
|
|
364
|
-
export const
|
|
364
|
+
export const tokenDefaults: Record<string, string> = {
|
|
365
365
|
...colorDefaults,
|
|
366
366
|
...spacingDefaults,
|
|
367
367
|
...sizeDefaults,
|
package/src/theme/index.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* - Token exports for direct use in StyleX
|
|
12
12
|
*
|
|
13
13
|
* Themes are in separate packages:
|
|
14
|
-
* import {
|
|
14
|
+
* import { neutralTheme } from '@astryxdesign/theme-neutral';
|
|
15
15
|
* import { neutralTheme } from '@astryxdesign/theme-neutral';
|
|
16
16
|
*/
|
|
17
17
|
|
|
@@ -28,7 +28,7 @@ export {
|
|
|
28
28
|
type ThemeCSSOutput,
|
|
29
29
|
type ThemeRulesSplit,
|
|
30
30
|
isDefinedTheme,
|
|
31
|
-
|
|
31
|
+
tokenDefaults,
|
|
32
32
|
} from './defineTheme';
|
|
33
33
|
export type {
|
|
34
34
|
DefineThemeInput,
|
|
@@ -134,7 +134,7 @@ export function defineSyntaxTheme(input: SyntaxThemeInput): SyntaxThemeDefinitio
|
|
|
134
134
|
const missing = ALL_SYNTAX_KEYS.filter(key => !(key in input.tokens));
|
|
135
135
|
if (missing.length > 0) {
|
|
136
136
|
console.warn(
|
|
137
|
-
'[
|
|
137
|
+
'[Astryx] defineSyntaxTheme("' + input.name + '"): missing tokens: ' +
|
|
138
138
|
missing.join(', ') + '. All 14 syntax tokens are required.',
|
|
139
139
|
);
|
|
140
140
|
}
|
package/src/theme/tokens.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import {
|
|
19
|
-
|
|
19
|
+
tokenDefaults,
|
|
20
20
|
type DefinedTheme,
|
|
21
21
|
type TokenName,
|
|
22
22
|
type TokenValue,
|
|
@@ -60,7 +60,7 @@ export function tokenVar(name: TokenName | (string & {})): string {
|
|
|
60
60
|
|
|
61
61
|
/** Flat map of every known Astryx token name to its `var(--token-name)` reference. */
|
|
62
62
|
export const tokenVars: Record<TokenName, string> = Object.fromEntries(
|
|
63
|
-
Object.keys(
|
|
63
|
+
Object.keys(tokenDefaults).map(name => [name, tokenVar(name)]),
|
|
64
64
|
) as Record<TokenName, string>;
|
|
65
65
|
|
|
66
66
|
/**
|
|
@@ -147,7 +147,7 @@ function resolveXDSTokenValue(
|
|
|
147
147
|
/**
|
|
148
148
|
* Resolve all Astryx token values for a theme and effective color mode.
|
|
149
149
|
*
|
|
150
|
-
* The result starts with `
|
|
150
|
+
* The result starts with `tokenDefaults`, applies `theme.tokens`, then
|
|
151
151
|
* reapplies `theme.__inputTokens` when available so explicit tuple overrides
|
|
152
152
|
* retain their original light/dark sides instead of relying on CSS parsing.
|
|
153
153
|
* This mirrors the token resolution used by `useTheme()` but does not need
|
|
@@ -162,7 +162,7 @@ export function resolveThemeTokens(
|
|
|
162
162
|
const {mode} = options;
|
|
163
163
|
const resolved: Record<string, string> = {};
|
|
164
164
|
|
|
165
|
-
for (const [key, value] of Object.entries(
|
|
165
|
+
for (const [key, value] of Object.entries(tokenDefaults)) {
|
|
166
166
|
resolved[key] = resolveXDSTokenValue(value, mode);
|
|
167
167
|
}
|
|
168
168
|
|
package/src/theme/useTheme.ts
CHANGED
|
@@ -63,7 +63,7 @@ export interface UseThemeReturn {
|
|
|
63
63
|
* For tokens with [light, dark] tuples, returns the value matching
|
|
64
64
|
* the current mode. For single-value tokens, returns the value as-is.
|
|
65
65
|
*
|
|
66
|
-
* Falls back to
|
|
66
|
+
* Falls back to tokenDefaults if the token isn't overridden by the theme.
|
|
67
67
|
*
|
|
68
68
|
* @example
|
|
69
69
|
* ```
|
|
@@ -75,7 +75,7 @@ export interface UseThemeReturn {
|
|
|
75
75
|
/**
|
|
76
76
|
* All tokens resolved for the current color mode.
|
|
77
77
|
*
|
|
78
|
-
* Merges
|
|
78
|
+
* Merges tokenDefaults with the theme's overrides, resolving
|
|
79
79
|
* light-dark() values based on the effective color mode.
|
|
80
80
|
*
|
|
81
81
|
* Memoized — stable reference unless theme or mode changes.
|
|
@@ -320,5 +320,31 @@ describe('parseDateInput', () => {
|
|
|
320
320
|
it('rejects mixed separators', () => {
|
|
321
321
|
expect(parseDateInput('1/25.2026')).toBeNull();
|
|
322
322
|
});
|
|
323
|
+
|
|
324
|
+
it('treats a single typed digit as incomplete, not a date', () => {
|
|
325
|
+
// A user starting to type a month (e.g. "0" or "1" for January) should
|
|
326
|
+
// not produce a date. Native Date parsing would otherwise coerce these
|
|
327
|
+
// into arbitrary dates (and a year of 0 in some engines).
|
|
328
|
+
expect(parseDateInput('0')).toBeNull();
|
|
329
|
+
expect(parseDateInput('1')).toBeNull();
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
it('treats bare numeric input as incomplete, not a date', () => {
|
|
333
|
+
expect(parseDateInput('00')).toBeNull();
|
|
334
|
+
expect(parseDateInput('01')).toBeNull();
|
|
335
|
+
expect(parseDateInput('12')).toBeNull();
|
|
336
|
+
expect(parseDateInput('2026')).toBeNull();
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
it('never returns an out-of-range date for partial input', () => {
|
|
340
|
+
// Regression: partial input must never yield a date with year < 1,
|
|
341
|
+
// which would throw when later re-parsed and crash the page.
|
|
342
|
+
for (const input of ['0', '1', '01', '00', '9', '99']) {
|
|
343
|
+
const result = parseDateInput(input);
|
|
344
|
+
if (result !== null) {
|
|
345
|
+
expect(result.year).toBeGreaterThanOrEqual(1);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
});
|
|
323
349
|
});
|
|
324
350
|
});
|
package/src/utils/dateParser.ts
CHANGED
|
@@ -124,10 +124,24 @@ export function parseDateInput(input: string): PlainDate | null {
|
|
|
124
124
|
return parseNumericDate(+first, +second, currentYear);
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
// 6. Fall back to native Date parsing for other formats
|
|
127
|
+
// 6. Fall back to native Date parsing for other formats.
|
|
128
|
+
//
|
|
129
|
+
// Skip bare numeric input (e.g. "0", "1", "01", "2026"). These are
|
|
130
|
+
// in-progress values a user is still typing, not complete dates. Native
|
|
131
|
+
// `Date` parsing coerces them into arbitrary dates ("0" -> year 2000 in V8,
|
|
132
|
+
// year 0 in some engines), which is both surprising and — when the year
|
|
133
|
+
// resolves to 0 — produces an out-of-range date that throws downstream.
|
|
134
|
+
// Treat them as not-yet-a-valid-date instead.
|
|
135
|
+
if (/^\d+$/.test(trimmed)) {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
|
|
128
139
|
const parsed = new Date(trimmed);
|
|
129
140
|
if (!isNaN(parsed.getTime())) {
|
|
130
|
-
|
|
141
|
+
const fromDate = plainDateFromDate(parsed);
|
|
142
|
+
// Validate the result so we never return an out-of-range date (e.g. a
|
|
143
|
+
// year of 0), which would throw when later re-parsed.
|
|
144
|
+
return tryCreatePlainDate(fromDate.year, fromDate.month, fromDate.day);
|
|
131
145
|
}
|
|
132
146
|
|
|
133
147
|
return null;
|
package/src/utils/mergeProps.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Merge xds-* props, stylex.props result, and optional consumer className/style.
|
|
5
5
|
*
|
|
6
6
|
* stylex.props() returns { className, style }. This merges the Astryx stable
|
|
7
|
-
* class name plus any data-attribute reflection from `
|
|
7
|
+
* class name plus any data-attribute reflection from `themeProps()` with the
|
|
8
8
|
* StyleX class name so both StyleX styles and the theme-targeting surface are
|
|
9
9
|
* applied.
|
|
10
10
|
*
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
15
15
|
* ```tsx
|
|
16
|
-
* // Root element with
|
|
16
|
+
* // Root element with themeProps
|
|
17
17
|
* <div {...mergeProps(
|
|
18
|
-
*
|
|
18
|
+
* themeProps('button', { variant }),
|
|
19
19
|
* stylex.props(styles.base, variants[variant]),
|
|
20
20
|
* className,
|
|
21
21
|
* style,
|
|
@@ -66,7 +66,7 @@ export function mergeProps(
|
|
|
66
66
|
style?: React.CSSProperties,
|
|
67
67
|
): PropsObject {
|
|
68
68
|
// Disambiguate: first arg is string → (xdsClass, stylexResult, className?, style?)
|
|
69
|
-
// first arg is object → merge arbitrary props (supports
|
|
69
|
+
// first arg is object → merge arbitrary props (supports themeProps + data attrs).
|
|
70
70
|
if (typeof xdsClassOrStylexResult === 'string') {
|
|
71
71
|
const xdsClass = xdsClassOrStylexResult;
|
|
72
72
|
const stylexResult = (stylexResultOrClassName as PropsObject) ?? {
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
* Used by both defineTheme (CSS generation) and components (class name rendering)
|
|
7
7
|
* to ensure the same convention is applied consistently.
|
|
8
8
|
*
|
|
9
|
-
* <!-- SYNC: packages/core/src/utils/
|
|
9
|
+
* <!-- SYNC: packages/core/src/utils/themeProps.ts -->
|
|
10
10
|
*
|
|
11
11
|
* Emits the legacy class-selector suffix used by defineTheme/component override
|
|
12
12
|
* generation today. Components also reflect the same prop values as data
|
|
13
|
-
* attributes via `
|
|
13
|
+
* attributes via `themeProps()` (`variant:secondary` renders both `.secondary`
|
|
14
14
|
* and `[data-variant="secondary"]` in the DOM), but generated theme CSS still
|
|
15
15
|
* uses these class selectors until the selector contract migrates fully.
|
|
16
16
|
*
|
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
import {describe, it, expect} from 'vitest';
|
|
4
|
-
import {
|
|
4
|
+
import {themeDataAttributes, themeProps} from './themeProps';
|
|
5
5
|
|
|
6
|
-
describe('
|
|
6
|
+
describe('themeProps', () => {
|
|
7
7
|
it('returns base class for component', () => {
|
|
8
|
-
expect(
|
|
8
|
+
expect(themeProps('card').className).toBe('astryx-card');
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
it('adds variant classes', () => {
|
|
12
12
|
expect(
|
|
13
|
-
|
|
13
|
+
themeProps('button', {variant: 'secondary', size: 'sm'}).className,
|
|
14
14
|
).toBe('astryx-button secondary sm');
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
it('prefixes numeric values with prop name', () => {
|
|
18
|
-
expect(
|
|
18
|
+
expect(themeProps('heading', {level: 1}).className).toBe(
|
|
19
19
|
'astryx-heading level-1',
|
|
20
20
|
);
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
it('skips null and undefined props', () => {
|
|
24
24
|
expect(
|
|
25
|
-
|
|
25
|
+
themeProps('button', {variant: 'primary', size: undefined}).className,
|
|
26
26
|
).toBe('astryx-button primary');
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
it('works with no props', () => {
|
|
30
|
-
expect(
|
|
30
|
+
expect(themeProps('divider').className).toBe('astryx-divider');
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
it('handles string numeric values', () => {
|
|
34
|
-
expect(
|
|
34
|
+
expect(themeProps('heading', {level: '3'}).className).toBe(
|
|
35
35
|
'astryx-heading level-3',
|
|
36
36
|
);
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
it('reflects visual props as data attributes', () => {
|
|
40
40
|
expect(
|
|
41
|
-
|
|
41
|
+
themeDataAttributes({variant: 'secondary', size: 'sm', level: 2}),
|
|
42
42
|
).toEqual({
|
|
43
43
|
'data-variant': 'secondary',
|
|
44
44
|
'data-size': 'sm',
|
|
@@ -47,19 +47,19 @@ describe('xdsThemeProps', () => {
|
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
it('kebab-cases data attribute names', () => {
|
|
50
|
-
expect(
|
|
50
|
+
expect(themeDataAttributes({listStyle: 'ordered'})).toEqual({
|
|
51
51
|
'data-list-style': 'ordered',
|
|
52
52
|
});
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
it('omits nullish data attributes', () => {
|
|
56
|
-
expect(
|
|
56
|
+
expect(themeDataAttributes({variant: 'primary', size: null})).toEqual({
|
|
57
57
|
'data-variant': 'primary',
|
|
58
58
|
});
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
it('returns class and data attributes together', () => {
|
|
62
|
-
expect(
|
|
62
|
+
expect(themeProps('button', {variant: 'primary', size: 'sm'})).toEqual({
|
|
63
63
|
className: 'astryx-button primary sm',
|
|
64
64
|
'data-variant': 'primary',
|
|
65
65
|
'data-size': 'sm',
|
|
@@ -21,7 +21,7 @@ function classTokenForPropValue(prop: string, value: string): string {
|
|
|
21
21
|
*
|
|
22
22
|
* Every component renders a stable base class (`astryx-button`, `astryx-card`,
|
|
23
23
|
* etc.) plus variant classes derived from visual props. Components also reflect
|
|
24
|
-
* those visual props as data attributes via `
|
|
24
|
+
* those visual props as data attributes via `themeProps()` (`data-variant`,
|
|
25
25
|
* `data-size`, `data-level`, etc.) so consumers target stable data-attribute
|
|
26
26
|
* selectors rather than collision-prone bare class names.
|
|
27
27
|
*
|
|
@@ -73,7 +73,7 @@ function buildClassName(component: string, props?: ClassProps): string {
|
|
|
73
73
|
* literal prop values, including numeric values (`level: 1` → `data-level="1"`).
|
|
74
74
|
* Nullish values are omitted.
|
|
75
75
|
*/
|
|
76
|
-
export function
|
|
76
|
+
export function themeDataAttributes(
|
|
77
77
|
props?: ClassProps,
|
|
78
78
|
): ThemeDataAttributes {
|
|
79
79
|
const attrs: ThemeDataAttributes = {};
|
|
@@ -98,16 +98,16 @@ export function xdsThemeDataAttributes(
|
|
|
98
98
|
* surface. For example:
|
|
99
99
|
*
|
|
100
100
|
* ```ts
|
|
101
|
-
*
|
|
101
|
+
* themeProps('button', { variant: 'primary', size: 'sm' })
|
|
102
102
|
* // → { className: 'astryx-button primary sm', data-variant: 'primary', data-size: 'sm' }
|
|
103
103
|
* ```
|
|
104
104
|
*/
|
|
105
|
-
export function
|
|
105
|
+
export function themeProps(
|
|
106
106
|
component: string,
|
|
107
107
|
props?: ClassProps,
|
|
108
108
|
): ThemeProps {
|
|
109
109
|
return {
|
|
110
110
|
className: buildClassName(component, props),
|
|
111
|
-
...
|
|
111
|
+
...themeDataAttributes(props),
|
|
112
112
|
};
|
|
113
113
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"renderXDSDropdownItems.d.ts","sourceRoot":"","sources":["../../src/DropdownMenu/renderXDSDropdownItems.tsx"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAUrC,OAAO,KAAK,EAEV,kBAAkB,EAEnB,MAAM,gBAAgB,CAAC;AAyBxB;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,kBAAkB,EAAE,GAC1B,SAAS,CA8CX"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"xdsThemeProps.d.ts","sourceRoot":"","sources":["../../src/utils/xdsThemeProps.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;AAC5D,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AACpD,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,QAAQ,MAAM,EAAE,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAC/E,MAAM,MAAM,UAAU,GAAG;IAAC,SAAS,EAAE,MAAM,CAAA;CAAC,GAAG,mBAAmB,CAAC;AA6DnE;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,CAAC,EAAE,UAAU,GACjB,mBAAmB,CAarB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAC3B,SAAS,EAAE,MAAM,EACjB,KAAK,CAAC,EAAE,UAAU,GACjB,UAAU,CAKZ"}
|