@astryxdesign/core 0.7.1 → 0.7.2-canary.020e1fe
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/dist/AppShell/AppShell.d.ts.map +1 -1
- package/dist/AppShell/AppShell.js +40 -1
- package/dist/AspectRatio/AspectRatio.d.ts +6 -8
- package/dist/AspectRatio/AspectRatio.d.ts.map +1 -1
- package/dist/AspectRatio/AspectRatio.js +44 -3
- package/dist/Breadcrumbs/BreadcrumbItem.d.ts.map +1 -1
- package/dist/Breadcrumbs/BreadcrumbItem.js +5 -2
- package/dist/Button/Button.d.ts.map +1 -1
- package/dist/Button/Button.js +38 -14
- package/dist/CheckboxInput/CheckboxInput.d.ts +1 -1
- package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
- package/dist/CheckboxInput/CheckboxInput.js +3 -1
- package/dist/CheckboxList/CheckboxListItem.d.ts +9 -1
- package/dist/CheckboxList/CheckboxListItem.d.ts.map +1 -1
- package/dist/CheckboxList/CheckboxListItem.js +4 -2
- package/dist/CommandPalette/CommandPaletteInput.d.ts +1 -1
- package/dist/CommandPalette/CommandPaletteInput.d.ts.map +1 -1
- package/dist/CommandPalette/CommandPaletteInput.js +37 -5
- package/dist/ContextMenu/ContextMenu.d.ts.map +1 -1
- package/dist/ContextMenu/ContextMenu.js +5 -2
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +20 -8
- package/dist/Drawer/Drawer.d.ts +191 -0
- package/dist/Drawer/Drawer.d.ts.map +1 -0
- package/dist/Drawer/Drawer.js +382 -0
- package/dist/Drawer/DrawerHeader.d.ts +85 -0
- package/dist/Drawer/DrawerHeader.d.ts.map +1 -0
- package/dist/Drawer/DrawerHeader.js +134 -0
- package/dist/Drawer/index.d.ts +11 -0
- package/dist/Drawer/index.d.ts.map +1 -0
- package/dist/Drawer/index.js +11 -0
- package/dist/Drawer/useDrawerDialogPresence.d.ts +42 -0
- package/dist/Drawer/useDrawerDialogPresence.d.ts.map +1 -0
- package/dist/Drawer/useDrawerDialogPresence.js +236 -0
- package/dist/DropdownMenu/DropdownMenu.d.ts +1 -1
- package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenu.js +83 -11
- package/dist/DropdownMenu/DropdownMenuContext.d.ts +17 -0
- package/dist/DropdownMenu/DropdownMenuContext.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuContext.js +21 -0
- package/dist/DropdownMenu/DropdownMenuDivider.d.ts +5 -3
- package/dist/DropdownMenu/DropdownMenuDivider.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuDivider.js +7 -3
- package/dist/DropdownMenu/DropdownMenuGroup.d.ts +6 -4
- package/dist/DropdownMenu/DropdownMenuGroup.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuGroup.js +4 -3
- package/dist/DropdownMenu/DropdownMenuSubMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuSubMenu.js +19 -8
- package/dist/DropdownMenu/lazyMenuBottomSheet.d.ts +24 -0
- package/dist/DropdownMenu/lazyMenuBottomSheet.d.ts.map +1 -0
- package/dist/DropdownMenu/lazyMenuBottomSheet.js +46 -0
- package/dist/EmptyState/EmptyState.d.ts.map +1 -1
- package/dist/EmptyState/EmptyState.js +4 -10
- package/dist/Field/Field.d.ts +1 -1
- package/dist/Field/Field.d.ts.map +1 -1
- package/dist/Field/Field.js +8 -4
- package/dist/Grid/GridSpan.d.ts.map +1 -1
- package/dist/Grid/GridSpan.js +1 -0
- package/dist/Heading/Heading.d.ts.map +1 -1
- package/dist/Heading/Heading.js +4 -2
- package/dist/HoverCard/useHoverCard.d.ts.map +1 -1
- package/dist/HoverCard/useHoverCard.js +10 -2
- package/dist/Item/Item.d.ts +6 -2
- package/dist/Item/Item.d.ts.map +1 -1
- package/dist/Item/Item.js +19 -4
- package/dist/Layer/layerViewportInset.stylex.d.ts +6 -2
- package/dist/Layer/layerViewportInset.stylex.d.ts.map +1 -1
- package/dist/Layer/layerViewportInset.stylex.js +6 -2
- package/dist/Layer/useLayer.d.ts.map +1 -1
- package/dist/Layer/useLayer.js +13 -7
- package/dist/Layer/useLayerDismissal.d.ts +1 -1
- package/dist/Layer/useLayerDismissal.js +1 -1
- package/dist/Layout/container.stylex.d.ts +5 -5
- package/dist/Layout/container.stylex.js +4 -4
- package/dist/List/List.d.ts +46 -19
- package/dist/List/List.d.ts.map +1 -1
- package/dist/List/List.js +28 -10
- package/dist/List/ListContext.d.ts +8 -3
- package/dist/List/ListContext.d.ts.map +1 -1
- package/dist/List/ListContext.js +7 -2
- package/dist/List/ListItem.d.ts +13 -5
- package/dist/List/ListItem.d.ts.map +1 -1
- package/dist/List/ListItem.js +21 -8
- package/dist/List/index.d.ts +1 -1
- package/dist/List/index.d.ts.map +1 -1
- package/dist/Markdown/Markdown.d.ts.map +1 -1
- package/dist/Markdown/Markdown.js +8 -1
- package/dist/Markdown/plugins/frontmatter.d.ts.map +1 -1
- package/dist/Markdown/plugins/frontmatter.js +7 -3
- package/dist/MetadataList/MetadataList.d.ts.map +1 -1
- package/dist/MetadataList/MetadataList.js +5 -1
- package/dist/MetadataList/MetadataListContext.d.ts +1 -1
- package/dist/MetadataList/MetadataListContext.d.ts.map +1 -1
- package/dist/MobileNav/MobileNav.d.ts +9 -0
- package/dist/MobileNav/MobileNav.d.ts.map +1 -1
- package/dist/MobileNav/MobileNav.js +30 -3
- package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
- package/dist/MultiSelector/MultiSelector.js +22 -8
- package/dist/MultiSelector/OptionActions.a11y.chromium.spec.js +100 -2
- package/dist/MultiSelector/hooks.d.ts.map +1 -1
- package/dist/MultiSelector/hooks.js +3 -1
- package/dist/Pagination/Pagination.d.ts +8 -5
- package/dist/Pagination/Pagination.d.ts.map +1 -1
- package/dist/Pagination/Pagination.js +21 -8
- package/dist/Popover/Popover.js +2 -2
- package/dist/PowerSearch/PowerSearch.js +1 -1
- package/dist/RadioList/RadioList.d.ts +1 -1
- package/dist/RadioList/RadioList.d.ts.map +1 -1
- package/dist/RadioList/RadioList.js +6 -2
- package/dist/RadioList/RadioListItem.d.ts +9 -1
- package/dist/RadioList/RadioListItem.d.ts.map +1 -1
- package/dist/RadioList/RadioListItem.js +2 -0
- package/dist/Selector/hooks.d.ts.map +1 -1
- package/dist/Selector/hooks.js +6 -2
- package/dist/SideNav/SideNavItem.d.ts +8 -1
- package/dist/SideNav/SideNavItem.d.ts.map +1 -1
- package/dist/SideNav/SideNavItem.js +71 -9
- package/dist/Switch/Switch.d.ts +1 -1
- package/dist/Switch/Switch.d.ts.map +1 -1
- package/dist/Switch/Switch.js +13 -1
- package/dist/TabList/TabMenu.d.ts +2 -2
- package/dist/TabList/TabMenu.d.ts.map +1 -1
- package/dist/TabList/TabMenu.js +6 -3
- package/dist/Text/Text.d.ts.map +1 -1
- package/dist/Text/Text.js +4 -2
- package/dist/Text/useTruncation.d.ts +7 -5
- package/dist/Text/useTruncation.d.ts.map +1 -1
- package/dist/Text/useTruncation.js +16 -5
- package/dist/ToggleButton/ToggleButton.d.ts +3 -2
- package/dist/ToggleButton/ToggleButton.d.ts.map +1 -1
- package/dist/ToggleButton/ToggleButton.js +12 -1
- package/dist/Tooltip/useTooltip.d.ts.map +1 -1
- package/dist/Tooltip/useTooltip.js +11 -0
- package/dist/TopNav/TopNavMegaMenu.d.ts.map +1 -1
- package/dist/TopNav/TopNavMegaMenu.js +3 -3
- package/dist/TopNav/TopNavMenu.d.ts.map +1 -1
- package/dist/TopNav/TopNavMenu.js +3 -3
- package/dist/TreeList/TreeList.d.ts.map +1 -1
- package/dist/TreeList/TreeList.js +1 -0
- package/dist/TreeList/TreeListBranches.d.ts.map +1 -1
- package/dist/TreeList/TreeListBranches.js +2 -2
- package/dist/TreeList/TreeListItem.d.ts.map +1 -1
- package/dist/TreeList/TreeListItem.js +57 -9
- package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
- package/dist/Typeahead/BaseTypeahead.js +26 -0
- package/dist/astryx.css +47 -13
- package/dist/hooks/useEntryAnimation.d.ts +2 -1
- package/dist/hooks/useEntryAnimation.d.ts.map +1 -1
- package/dist/hooks/useEntryAnimation.js +14 -12
- package/dist/hooks/useIsHydrating.d.ts +6 -0
- package/dist/hooks/useIsHydrating.d.ts.map +1 -0
- package/dist/hooks/useIsHydrating.js +30 -0
- package/dist/hooks/useMenuHover.d.ts.map +1 -1
- package/dist/hooks/useMenuHover.js +18 -13
- package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/en.generated.js +112 -1
- package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/pseudo.generated.js +112 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/theme/derivedVarRegistry.d.ts.map +1 -1
- package/dist/theme/derivedVarRegistry.js +0 -3
- package/dist/utils/focusOutline.stylex.d.ts +4 -0
- package/dist/utils/focusOutline.stylex.d.ts.map +1 -1
- package/dist/utils/focusOutline.stylex.js +4 -0
- package/dist/utils/plainDate.d.ts.map +1 -1
- package/dist/utils/plainDate.js +15 -9
- package/dist/utils/sharedMutationObserver.d.ts +21 -0
- package/dist/utils/sharedMutationObserver.d.ts.map +1 -0
- package/dist/utils/sharedMutationObserver.js +69 -0
- package/locales/en.json +444 -0
- package/locales/pseudo.json +333 -0
- package/package.json +9 -4
- package/scripts/agent-doc-state.mjs +38 -0
- package/scripts/postinstall.mjs +1 -1
- package/src/AppShell/AppShell.tsx +45 -1
- package/src/AspectRatio/AspectRatio.test.tsx +44 -43
- package/src/AspectRatio/AspectRatio.tsx +38 -18
- package/src/AspectRatio/__tests__/AspectRatioFitLayers.a11y.browser.spec.ts +157 -0
- package/src/Avatar/Avatar.doc.mjs +5 -3
- package/src/AvatarGroup/AvatarGroup.doc.mjs +3 -2
- package/src/Breadcrumbs/BreadcrumbItem.tsx +4 -1
- package/src/Breadcrumbs/Breadcrumbs.test.tsx +30 -1
- package/src/Button/Button.doc.mjs +2 -2
- package/src/Button/Button.test.tsx +155 -9
- package/src/Button/Button.tsx +39 -16
- package/src/Button/__tests__/Button.a11y.known-failures.ts +1 -62
- package/src/Button/__tests__/Button.a11y.states.ts +0 -10
- package/src/Card/Card.doc.mjs +1 -1
- package/src/Chat/__tests__/ChatMessageMetadata.a11y.chromium.spec.ts +3 -1
- package/src/CheckboxInput/CheckboxInput.test.tsx +34 -0
- package/src/CheckboxInput/CheckboxInput.tsx +3 -1
- package/src/CheckboxList/CheckboxList.test.tsx +22 -0
- package/src/CheckboxList/CheckboxListItem.doc.mjs +16 -0
- package/src/CheckboxList/CheckboxListItem.tsx +10 -0
- package/src/Code/Code.doc.mjs +1 -0
- package/src/CommandPalette/CommandPalette.doc.mjs +2 -0
- package/src/CommandPalette/CommandPaletteInput.test.tsx +53 -4
- package/src/CommandPalette/CommandPaletteInput.tsx +33 -3
- package/src/CommandPalette/__tests__/CommandPaletteInputAudit.a11y.chromium.spec.ts +335 -0
- package/src/CommandPalette/__tests__/CommandPaletteItemAudit.a11y.chromium.spec.ts +292 -0
- package/src/ContextMenu/ContextMenu.doc.mjs +2 -3
- package/src/ContextMenu/ContextMenu.tsx +4 -1
- package/src/ContextMenu/__tests__/ContextMenuAudit.a11y.chromium.spec.ts +438 -0
- package/src/Dialog/Dialog.test.tsx +46 -0
- package/src/Dialog/Dialog.tsx +20 -7
- package/src/Dialog/__tests__/Dialog.a11y.known-failures.ts +0 -14
- package/src/Drawer/Drawer.doc.mjs +473 -0
- package/src/Drawer/Drawer.spec.md +357 -0
- package/src/Drawer/Drawer.test.tsx +1300 -0
- package/src/Drawer/Drawer.tsx +613 -0
- package/src/Drawer/DrawerDirection.test.tsx +127 -0
- package/src/Drawer/DrawerHeader.doc.mjs +293 -0
- package/src/Drawer/DrawerHeader.test.tsx +102 -0
- package/src/Drawer/DrawerHeader.tsx +235 -0
- package/src/Drawer/__tests__/DrawerAudit.a11y.chromium.spec.ts +401 -0
- package/src/Drawer/__tests__/DrawerHeaderAudit.a11y.chromium.spec.ts +297 -0
- package/src/Drawer/index.ts +13 -0
- package/src/Drawer/useDrawerDialogPresence.ts +284 -0
- package/src/DropdownMenu/DropdownMenu.ssr.test.tsx +57 -0
- package/src/DropdownMenu/DropdownMenu.test.tsx +79 -18
- package/src/DropdownMenu/DropdownMenu.tsx +83 -12
- package/src/DropdownMenu/DropdownMenuContext.tsx +24 -0
- package/src/DropdownMenu/DropdownMenuDivider.doc.mjs +2 -2
- package/src/DropdownMenu/DropdownMenuDivider.spec.md +192 -0
- package/src/DropdownMenu/DropdownMenuDivider.tsx +9 -5
- package/src/DropdownMenu/DropdownMenuGroup.doc.mjs +169 -10
- package/src/DropdownMenu/DropdownMenuGroup.tsx +6 -4
- package/src/DropdownMenu/DropdownMenuLazySheet.test.tsx +126 -0
- package/src/DropdownMenu/DropdownMenuSubMenu.test.tsx +185 -0
- package/src/DropdownMenu/DropdownMenuSubMenu.tsx +19 -5
- package/src/DropdownMenu/__tests__/DropdownMenuDividerAudit.a11y.chromium.spec.ts +280 -0
- package/src/DropdownMenu/__tests__/DropdownMenuGroupAudit.a11y.chromium.spec.ts +334 -0
- package/src/DropdownMenu/__tests__/Menu.a11y.chromium.spec.ts +145 -0
- package/src/DropdownMenu/__tests__/Menu.a11y.known-failures.ts +26 -0
- package/src/DropdownMenu/__tests__/Menu.a11y.renders.tsx +65 -0
- package/src/DropdownMenu/__tests__/Menu.a11y.states.ts +138 -0
- package/src/DropdownMenu/__tests__/Menu.a11y.test.tsx +136 -0
- package/src/DropdownMenu/__tests__/warmMenuBottomSheet.tsx +43 -0
- package/src/DropdownMenu/lazyMenuBottomSheet.ts +71 -0
- package/src/EmptyState/EmptyState.doc.mjs +3 -2
- package/src/EmptyState/EmptyState.spec.md +189 -0
- package/src/EmptyState/EmptyState.test.tsx +74 -3
- package/src/EmptyState/EmptyState.tsx +4 -8
- package/src/Field/Field.doc.mjs +14 -8
- package/src/Field/Field.spec.md +217 -0
- package/src/Field/Field.test.tsx +60 -2
- package/src/Field/Field.tsx +17 -8
- package/src/Field/FieldLabel.doc.mjs +133 -26
- package/src/Field/FieldLabel.spec.md +172 -0
- package/src/Field/__tests__/FieldLabelAudit.a11y.chromium.spec.ts +296 -0
- package/src/Grid/GridSpan.tsx +3 -0
- package/src/Heading/Heading.test.tsx +57 -0
- package/src/Heading/Heading.tsx +6 -2
- package/src/HoverCard/HoverCard.test.tsx +58 -0
- package/src/HoverCard/useHoverCard.tsx +10 -2
- package/src/Icon/Icon.doc.mjs +36 -0
- package/src/IconButton/IconButton.doc.mjs +2 -2
- package/src/IconButton/IconButton.test.tsx +3 -1
- package/src/Item/Item.doc.mjs +12 -8
- package/src/Item/Item.spec.md +226 -0
- package/src/Item/Item.test.tsx +61 -0
- package/src/Item/Item.tsx +40 -4
- package/src/Layer/layerViewportInset.source-build.test.mjs +90 -0
- package/src/Layer/layerViewportInset.stylex.ts +6 -2
- package/src/Layer/layerViewportInset.test.ts +1 -0
- package/src/Layer/useLayer.tsx +24 -13
- package/src/Layer/useLayerDismissal.ts +1 -1
- package/src/Layout/LayoutHeader.doc.mjs +5 -0
- package/src/Layout/container.stylex.ts +6 -6
- package/src/List/List.doc.mjs +14 -1
- package/src/List/List.spec.md +129 -77
- package/src/List/List.test.tsx +163 -94
- package/src/List/List.tsx +74 -18
- package/src/List/ListContext.tsx +9 -3
- package/src/List/ListItem.doc.mjs +24 -5
- package/src/List/ListItem.tsx +56 -27
- package/src/List/index.ts +1 -1
- package/src/Markdown/Markdown.tsx +14 -1
- package/src/Markdown/plugins/frontmatter.test.tsx +25 -0
- package/src/Markdown/plugins/frontmatter.ts +7 -3
- package/src/MetadataList/MetadataList.doc.mjs +3 -3
- package/src/MetadataList/MetadataList.test.tsx +38 -0
- package/src/MetadataList/MetadataList.tsx +8 -1
- package/src/MetadataList/MetadataListContext.tsx +1 -1
- package/src/MobileNav/MobileNav.tsx +30 -3
- package/src/MobileNav/MobileNavCloseEdgeCases.test.tsx +173 -15
- package/src/MoreMenu/MoreMenu.test.tsx +5 -1
- package/src/MultiSelector/MultiSelector.test.tsx +159 -0
- package/src/MultiSelector/MultiSelector.tsx +40 -7
- package/src/MultiSelector/OptionActions.a11y.chromium.spec.ts +112 -2
- package/src/MultiSelector/hooks.ts +3 -1
- package/src/MultiSelector/useMultiCombobox.doc.mjs +267 -0
- package/src/Pagination/Pagination.doc.mjs +7 -7
- package/src/Pagination/Pagination.spec.md +9 -9
- package/src/Pagination/Pagination.test.tsx +242 -0
- package/src/Pagination/Pagination.tsx +27 -11
- package/src/Popover/Popover.test.tsx +2 -2
- package/src/Popover/Popover.tsx +4 -4
- package/src/PowerSearch/PowerSearch.test.tsx +85 -0
- package/src/PowerSearch/PowerSearch.tsx +2 -2
- package/src/ProgressBar/ProgressBar.doc.mjs +1 -0
- package/src/RadioList/RadioList.fr10.test.tsx +45 -2
- package/src/RadioList/RadioList.test.tsx +22 -0
- package/src/RadioList/RadioList.tsx +4 -1
- package/src/RadioList/RadioListItem.doc.mjs +16 -0
- package/src/RadioList/RadioListItem.tsx +10 -1
- package/src/Resizable/useResizable.doc.mjs +2 -0
- package/src/ScrollableArea/ScrollableArea.doc.mjs +1 -1
- package/src/Selector/hooks.ts +6 -2
- package/src/Selector/useCombobox.doc.mjs +237 -0
- package/src/SideNav/SideNav.spec.md +227 -0
- package/src/SideNav/SideNav.test.tsx +179 -0
- package/src/SideNav/SideNavItem.doc.mjs +2 -2
- package/src/SideNav/SideNavItem.tsx +96 -17
- package/src/Slider/Slider.spec.md +39 -18
- package/src/Spinner/Spinner.doc.mjs +1 -1
- package/src/Switch/Switch.test.tsx +49 -0
- package/src/Switch/Switch.tsx +11 -0
- package/src/TabList/TabList.spec.md +57 -44
- package/src/TabList/TabList.test.tsx +67 -0
- package/src/TabList/TabMenu.doc.mjs +4 -3
- package/src/TabList/TabMenu.tsx +7 -4
- package/src/Text/Text.test.tsx +57 -0
- package/src/Text/Text.tsx +6 -2
- package/src/Text/useTruncation.test.tsx +69 -0
- package/src/Text/useTruncation.ts +16 -5
- package/src/TimeInput/TimeInput.fr10.test.tsx +15 -0
- package/src/Timestamp/Timestamp.doc.mjs +1 -1
- package/src/ToggleButton/ToggleButton.test.tsx +95 -0
- package/src/ToggleButton/ToggleButton.tsx +12 -1
- package/src/ToggleButton/ToggleButtonGroup.doc.mjs +4 -0
- package/src/Tokenizer/Tokenizer.test.tsx +54 -1
- package/src/Toolbar/Toolbar.test.tsx +0 -8
- package/src/Toolbar/__tests__/Toolbar.a11y.chromium.spec.ts +163 -0
- package/src/Toolbar/__tests__/Toolbar.a11y.renders.tsx +63 -0
- package/src/Toolbar/__tests__/Toolbar.a11y.states.ts +142 -0
- package/src/Toolbar/__tests__/Toolbar.a11y.test.tsx +126 -0
- package/src/Tooltip/Tooltip.test.tsx +31 -0
- package/src/Tooltip/useTooltip.test.tsx +13 -0
- package/src/Tooltip/useTooltip.tsx +11 -0
- package/src/TopNav/TopNavMegaMenu.test.tsx +22 -0
- package/src/TopNav/TopNavMegaMenu.tsx +7 -3
- package/src/TopNav/TopNavMenu.test.tsx +19 -0
- package/src/TopNav/TopNavMenu.tsx +11 -3
- package/src/TreeList/TreeList.doc.mjs +1 -0
- package/src/TreeList/TreeList.spec.md +29 -17
- package/src/TreeList/TreeList.test.tsx +327 -6
- package/src/TreeList/TreeList.tsx +5 -1
- package/src/TreeList/TreeListBranches.tsx +6 -0
- package/src/TreeList/TreeListItem.tsx +88 -13
- package/src/Typeahead/BaseTypeahead.tsx +26 -0
- package/src/Typeahead/Typeahead.test.tsx +260 -2
- package/src/docPropLiterals.test.ts +36 -10
- package/src/hooks/useEntryAnimation.doc.mjs +4 -4
- package/src/hooks/useEntryAnimation.ssr.test.tsx +143 -0
- package/src/hooks/useEntryAnimation.ts +15 -16
- package/src/hooks/useIsHydrating.test.tsx +70 -0
- package/src/hooks/useIsHydrating.ts +31 -0
- package/src/hooks/useMenuHover.ts +18 -13
- package/src/i18n/InternationalizationProvider.doc.mjs +8 -0
- package/src/i18n/InternationalizationProvider.spec.md +252 -0
- package/src/i18n/__tests__/InternationalizationProvider.test.tsx +128 -0
- package/src/i18n/generated-locales/en.generated.ts +121 -0
- package/src/i18n/generated-locales/pseudo.generated.ts +121 -0
- package/src/i18n/useTranslator.test.tsx +37 -0
- package/src/index.ts +1 -0
- package/src/postinstall.test.mjs +46 -0
- package/src/reset.css +0 -29
- package/src/theme/derivedVarRegistry.test.ts +7 -3
- package/src/theme/derivedVarRegistry.ts +0 -3
- package/src/utils/focusOutline.stylex.ts +4 -0
- package/src/utils/plainDate.test.ts +37 -1
- package/src/utils/plainDate.ts +15 -5
- package/src/utils/sharedMutationObserver.test.ts +53 -0
- package/src/utils/sharedMutationObserver.ts +78 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file DrawerDirection.test.tsx
|
|
5
|
+
* @input Drawer closed transforms and the matching @starting-style declarations
|
|
6
|
+
* @output Regression coverage for resolved DOM LTR/RTL motion on both logical sides
|
|
7
|
+
* @position Focused direction contract; complements Drawer.test.tsx behavior coverage
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import {readFileSync} from 'node:fs';
|
|
11
|
+
import {join} from 'node:path';
|
|
12
|
+
import * as ts from 'typescript';
|
|
13
|
+
import {describe, expect, it} from 'vitest';
|
|
14
|
+
import {render, screen} from '@testing-library/react';
|
|
15
|
+
import {Drawer} from './Drawer';
|
|
16
|
+
|
|
17
|
+
function closedTransform(): string {
|
|
18
|
+
return getComputedStyle(screen.getByRole('dialog', {hidden: true})).transform;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
describe.each([
|
|
22
|
+
{side: 'start' as const, ltr: 'translateX(-100%)', rtl: 'translateX(100%)'},
|
|
23
|
+
{side: 'end' as const, ltr: 'translateX(100%)', rtl: 'translateX(-100%)'},
|
|
24
|
+
])('Drawer direction on side=$side', ({side, ltr, rtl}) => {
|
|
25
|
+
it('uses a self-applied RTL direction', () => {
|
|
26
|
+
render(
|
|
27
|
+
<Drawer
|
|
28
|
+
isOpen={false}
|
|
29
|
+
onOpenChange={() => {}}
|
|
30
|
+
label="Details"
|
|
31
|
+
side={side}
|
|
32
|
+
dir="rtl">
|
|
33
|
+
Content
|
|
34
|
+
</Drawer>,
|
|
35
|
+
);
|
|
36
|
+
expect(closedTransform()).toBe(rtl);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('honors a nearer LTR override inside an RTL page', () => {
|
|
40
|
+
render(
|
|
41
|
+
<div dir="rtl">
|
|
42
|
+
<Drawer
|
|
43
|
+
isOpen={false}
|
|
44
|
+
onOpenChange={() => {}}
|
|
45
|
+
label="Details"
|
|
46
|
+
side={side}
|
|
47
|
+
dir="ltr">
|
|
48
|
+
Content
|
|
49
|
+
</Drawer>
|
|
50
|
+
</div>,
|
|
51
|
+
);
|
|
52
|
+
expect(closedTransform()).toBe(ltr);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const SOURCE = readFileSync(join(__dirname, 'Drawer.tsx'), 'utf8');
|
|
57
|
+
|
|
58
|
+
function styleDefinition(name: string): ts.ObjectLiteralExpression {
|
|
59
|
+
const file = ts.createSourceFile(
|
|
60
|
+
'Drawer.tsx',
|
|
61
|
+
SOURCE,
|
|
62
|
+
ts.ScriptTarget.Latest,
|
|
63
|
+
true,
|
|
64
|
+
ts.ScriptKind.TSX,
|
|
65
|
+
);
|
|
66
|
+
let found: ts.ObjectLiteralExpression | undefined;
|
|
67
|
+
const visit = (node: ts.Node) => {
|
|
68
|
+
if (
|
|
69
|
+
ts.isPropertyAssignment(node) &&
|
|
70
|
+
ts.isIdentifier(node.name) &&
|
|
71
|
+
node.name.text === name &&
|
|
72
|
+
ts.isObjectLiteralExpression(node.initializer)
|
|
73
|
+
) {
|
|
74
|
+
found = node.initializer;
|
|
75
|
+
}
|
|
76
|
+
ts.forEachChild(node, visit);
|
|
77
|
+
};
|
|
78
|
+
visit(file);
|
|
79
|
+
if (found == null) {
|
|
80
|
+
throw new Error(`No style named "${name}" in Drawer.tsx`);
|
|
81
|
+
}
|
|
82
|
+
return found;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function property(style: ts.ObjectLiteralExpression, key: string): string {
|
|
86
|
+
const entry = style.properties.find(
|
|
87
|
+
candidate =>
|
|
88
|
+
ts.isPropertyAssignment(candidate) &&
|
|
89
|
+
(ts.isIdentifier(candidate.name) || ts.isStringLiteral(candidate.name)) &&
|
|
90
|
+
candidate.name.text === key,
|
|
91
|
+
);
|
|
92
|
+
if (entry == null) {
|
|
93
|
+
throw new Error(`No "${key}" in ${style.getText().slice(0, 40)}…`);
|
|
94
|
+
}
|
|
95
|
+
return (entry as ts.PropertyAssignment).initializer.getText();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
describe.each([
|
|
99
|
+
{
|
|
100
|
+
side: 'start',
|
|
101
|
+
closed: 'start',
|
|
102
|
+
open: 'startOpen',
|
|
103
|
+
ltr: 'translateX(-100%)',
|
|
104
|
+
rtl: 'translateX(100%)',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
side: 'end',
|
|
108
|
+
closed: 'end',
|
|
109
|
+
open: 'endOpen',
|
|
110
|
+
ltr: 'translateX(100%)',
|
|
111
|
+
rtl: 'translateX(-100%)',
|
|
112
|
+
},
|
|
113
|
+
])('Drawer $side entry declaration', ({closed, open, ltr, rtl}) => {
|
|
114
|
+
it('parks closed on the computed logical edge', () => {
|
|
115
|
+
const transform = property(styleDefinition(closed), 'transform');
|
|
116
|
+
expect(transform).toContain(`default: '${ltr}'`);
|
|
117
|
+
expect(transform).toContain(`':dir(rtl)': '${rtl}'`);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('starts opening from the same computed logical edge', () => {
|
|
121
|
+
const transform = property(styleDefinition(open), 'transform');
|
|
122
|
+
expect(transform).toContain("default: 'translateX(0)'");
|
|
123
|
+
expect(transform).toContain('@starting-style');
|
|
124
|
+
expect(transform).toContain(`default: '${ltr}'`);
|
|
125
|
+
expect(transform).toContain(`':dir(rtl)': '${rtl}'`);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file DrawerHeader.doc.mjs
|
|
5
|
+
* @input DrawerHeader props, anatomy, theming targets, and examples
|
|
6
|
+
* @output Consumer documentation for DrawerHeader, a sub-component of Drawer
|
|
7
|
+
* @position CLI and docsite metadata for the Drawer header; runnable docsite demos live in packages/cli/assets/templates/blocks/components/DrawerHeader
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** @type {import('@astryxdesign/cli/authoring').ComponentDoc} */
|
|
11
|
+
|
|
12
|
+
export const docs = {
|
|
13
|
+
name: 'DrawerHeader',
|
|
14
|
+
subComponentOf: 'Drawer',
|
|
15
|
+
displayName: 'Drawer Header',
|
|
16
|
+
// Keeps the registry route DrawerHeader had as a canary-only Lab component.
|
|
17
|
+
registry: {aliases: ['lab/drawer-header']},
|
|
18
|
+
isHiddenFromOverview: true,
|
|
19
|
+
description:
|
|
20
|
+
'Header for drawers with a title, optional subtitle, close button, and start/end content slots. Same API as DialogHeader.',
|
|
21
|
+
usage: {
|
|
22
|
+
description:
|
|
23
|
+
'Compose DrawerHeader in the header slot of a Layout inside the Drawer, as DialogHeader is composed in Dialog, for a title row and, when you pass onOpenChange, a close button. The Layout keeps the header on the drawer inset instead of padding it twice. Drawer renders no close button of its own. Unlike DialogHeader it does not take focus on open (Drawer uses data-autofocus) and does not name the drawer (Drawer label does).',
|
|
24
|
+
anatomy: [
|
|
25
|
+
{
|
|
26
|
+
name: 'Header row',
|
|
27
|
+
required: true,
|
|
28
|
+
description:
|
|
29
|
+
'Arranges the title block, optional start/end content, and close control.',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'Start content',
|
|
33
|
+
required: false,
|
|
34
|
+
description: 'Wraps optional leading content.',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'Title block',
|
|
38
|
+
required: true,
|
|
39
|
+
description: 'Groups the title and optional subtitle.',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'End content',
|
|
43
|
+
required: false,
|
|
44
|
+
description:
|
|
45
|
+
'Groups optional trailing content with the optional close control.',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'Close icon',
|
|
49
|
+
required: false,
|
|
50
|
+
description: 'Visual close glyph inside the close button.',
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
props: [
|
|
55
|
+
{
|
|
56
|
+
name: 'title',
|
|
57
|
+
type: 'ReactNode',
|
|
58
|
+
description:
|
|
59
|
+
'Drawer title, rendered as an h2. Keep it inline and non-interactive. It does not name the drawer; pass Drawer a label.',
|
|
60
|
+
required: true,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'subtitle',
|
|
64
|
+
type: 'ReactNode',
|
|
65
|
+
description:
|
|
66
|
+
'Subtitle below the title. Accepts inline content such as a Link; avoid block elements.',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'onOpenChange',
|
|
70
|
+
type: '(isOpen: boolean) => unknown',
|
|
71
|
+
description:
|
|
72
|
+
"Close button callback, called with false (no button if omitted). Pass the Drawer's own onOpenChange.",
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: 'startContent',
|
|
76
|
+
type: 'ReactNode',
|
|
77
|
+
description: 'Content before the title (e.g., a back button).',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: 'endContent',
|
|
81
|
+
type: 'ReactNode',
|
|
82
|
+
description: 'Content after the title, before the close button.',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: 'endContentEdgeCompensation',
|
|
86
|
+
type: "'inline' | 'block' | 'all'",
|
|
87
|
+
description:
|
|
88
|
+
'Selects compensation axes for the end-content slot. Omit to preserve automatic close-action compensation.',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: 'hasDivider',
|
|
92
|
+
type: 'boolean',
|
|
93
|
+
description:
|
|
94
|
+
"Adds a border at the bottom edge. Defaults to the parent Layout's defaultHasDividers.",
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
playground: {
|
|
98
|
+
defaults: {
|
|
99
|
+
title: 'Host details',
|
|
100
|
+
subtitle: 'web-prod-04',
|
|
101
|
+
hasDivider: true,
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
theming: {
|
|
105
|
+
targets: [
|
|
106
|
+
{className: 'astryx-drawer-header'},
|
|
107
|
+
{className: 'astryx-drawer-header-start-content'},
|
|
108
|
+
{className: 'astryx-drawer-header-title-block'},
|
|
109
|
+
{className: 'astryx-drawer-header-end-content'},
|
|
110
|
+
{className: 'astryx-drawer-header-close-icon'},
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
examples: [
|
|
114
|
+
{
|
|
115
|
+
label: 'With close button',
|
|
116
|
+
code: `
|
|
117
|
+
import {useState} from 'react';
|
|
118
|
+
import {Drawer, DrawerHeader} from '@astryxdesign/core/Drawer';
|
|
119
|
+
import {Layout, LayoutContent} from '@astryxdesign/core/Layout';
|
|
120
|
+
|
|
121
|
+
function Inspector() {
|
|
122
|
+
const [isOpen, setIsOpen] = useState(true);
|
|
123
|
+
|
|
124
|
+
// Passing onOpenChange renders a close button that calls it with false.
|
|
125
|
+
return (
|
|
126
|
+
<Drawer isOpen={isOpen} onOpenChange={setIsOpen} label="Details">
|
|
127
|
+
<Layout
|
|
128
|
+
header={<DrawerHeader title="Details" onOpenChange={setIsOpen} />}
|
|
129
|
+
content={<LayoutContent>Content</LayoutContent>}
|
|
130
|
+
/>
|
|
131
|
+
</Drawer>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
`,
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
label: 'With subtitle and end content',
|
|
138
|
+
code: `
|
|
139
|
+
import {DrawerHeader} from '@astryxdesign/core/Drawer';
|
|
140
|
+
import {Badge} from '@astryxdesign/core/Badge';
|
|
141
|
+
|
|
142
|
+
<DrawerHeader
|
|
143
|
+
title="web-prod-04"
|
|
144
|
+
subtitle="us-east-1"
|
|
145
|
+
endContent={<Badge label="Healthy" />}
|
|
146
|
+
/>;
|
|
147
|
+
`,
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export const docsZh = {
|
|
153
|
+
name: 'DrawerHeader',
|
|
154
|
+
isHiddenFromOverview: true,
|
|
155
|
+
displayName: 'Drawer Header',
|
|
156
|
+
description:
|
|
157
|
+
'抽屉头部,包含标题、可选副标题、关闭按钮以及首尾内容插槽;API 与 DialogHeader 相同。',
|
|
158
|
+
usage: {
|
|
159
|
+
description:
|
|
160
|
+
'像 Dialog 中的 DialogHeader 一样,把 DrawerHeader 放在 Drawer 内 Layout 的 header 插槽,提供标题行;传入 onOpenChange 时显示关闭按钮。Layout 让页眉对齐抽屉的内边距,而不是重复缩进。Drawer 本身不渲染关闭按钮。与 DialogHeader 不同,它不会在打开时获得焦点(Drawer 使用 data-autofocus),也不为抽屉命名(由 Drawer 的 label 命名)。',
|
|
161
|
+
anatomy: [
|
|
162
|
+
{
|
|
163
|
+
name: 'Header row',
|
|
164
|
+
required: true,
|
|
165
|
+
description: '排列标题区、可选的首尾内容和关闭控件。',
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: 'Start content',
|
|
169
|
+
required: false,
|
|
170
|
+
description: '包装可选的首部内容。',
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
name: 'Title block',
|
|
174
|
+
required: true,
|
|
175
|
+
description: '组合标题和可选副标题。',
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
name: 'End content',
|
|
179
|
+
required: false,
|
|
180
|
+
description: '组合可选尾部内容和可选关闭控件。',
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: 'Close icon',
|
|
184
|
+
required: false,
|
|
185
|
+
description: '关闭按钮内的关闭图标。',
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
},
|
|
189
|
+
props: [
|
|
190
|
+
{
|
|
191
|
+
name: 'title',
|
|
192
|
+
type: 'ReactNode',
|
|
193
|
+
description:
|
|
194
|
+
'抽屉标题,渲染为 h2。请使用非交互的行内内容。它不为抽屉命名;请为 Drawer 传入 label。',
|
|
195
|
+
required: true,
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
name: 'subtitle',
|
|
199
|
+
type: 'ReactNode',
|
|
200
|
+
description: '标题下方的副标题,可包含链接等行内内容;避免使用块级元素。',
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
name: 'onOpenChange',
|
|
204
|
+
type: '(isOpen: boolean) => unknown',
|
|
205
|
+
description:
|
|
206
|
+
'关闭按钮的回调,以 false 调用(省略时不显示按钮)。传入 Drawer 自己的 onOpenChange。',
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
name: 'startContent',
|
|
210
|
+
type: 'ReactNode',
|
|
211
|
+
description: '标题之前的内容(例如返回按钮)。',
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: 'endContent',
|
|
215
|
+
type: 'ReactNode',
|
|
216
|
+
description: '标题之后、关闭按钮之前的内容。',
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
name: 'endContentEdgeCompensation',
|
|
220
|
+
type: "'inline' | 'block' | 'all'",
|
|
221
|
+
description: '选择尾部内容插槽的补偿轴;省略时保留关闭操作的自动补偿。',
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
name: 'hasDivider',
|
|
225
|
+
type: 'boolean',
|
|
226
|
+
description:
|
|
227
|
+
'在底部边缘添加分隔线。默认取父级 Layout 的 defaultHasDividers。',
|
|
228
|
+
},
|
|
229
|
+
],
|
|
230
|
+
theming: {
|
|
231
|
+
targets: [
|
|
232
|
+
{className: 'astryx-drawer-header'},
|
|
233
|
+
{className: 'astryx-drawer-header-start-content'},
|
|
234
|
+
{className: 'astryx-drawer-header-title-block'},
|
|
235
|
+
{className: 'astryx-drawer-header-end-content'},
|
|
236
|
+
{className: 'astryx-drawer-header-close-icon'},
|
|
237
|
+
],
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
export const docsDense = {
|
|
242
|
+
name: 'DrawerHeader',
|
|
243
|
+
isHiddenFromOverview: true,
|
|
244
|
+
displayName: 'Drawer Header',
|
|
245
|
+
description:
|
|
246
|
+
'drawer header w/ title, optional subtitle, close button, start/end content slots; same API as DialogHeader',
|
|
247
|
+
usage: {
|
|
248
|
+
description:
|
|
249
|
+
'header slot of a Layout inside Drawer, like DialogHeader in Dialog; close button only when given onOpenChange (Drawer has none built in); no focus on open (Drawer uses data-autofocus); does not name the drawer (Drawer label does)',
|
|
250
|
+
anatomy: [
|
|
251
|
+
{
|
|
252
|
+
name: 'Header row',
|
|
253
|
+
required: true,
|
|
254
|
+
description:
|
|
255
|
+
'arranges title block, optional start/end content, close control',
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
name: 'Start content',
|
|
259
|
+
required: false,
|
|
260
|
+
description: 'wraps optional leading content',
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
name: 'Title block',
|
|
264
|
+
required: true,
|
|
265
|
+
description: 'groups title + optional subtitle',
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
name: 'End content',
|
|
269
|
+
required: false,
|
|
270
|
+
description:
|
|
271
|
+
'groups optional trailing content + optional close control',
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
name: 'Close icon',
|
|
275
|
+
required: false,
|
|
276
|
+
description: 'close glyph inside close button',
|
|
277
|
+
},
|
|
278
|
+
],
|
|
279
|
+
},
|
|
280
|
+
propDescriptions: {
|
|
281
|
+
title:
|
|
282
|
+
'drawer title node, rendered as h2; inline, non-interactive; does not name the drawer',
|
|
283
|
+
subtitle:
|
|
284
|
+
'subtitle node below title; inline content ok (e.g. Link), no block elements',
|
|
285
|
+
onOpenChange:
|
|
286
|
+
"close button callback, called with false (omit=no button); pass the Drawer's onOpenChange",
|
|
287
|
+
startContent: 'content before title (e.g. back button)',
|
|
288
|
+
endContent: 'content after title, before close button',
|
|
289
|
+
endContentEdgeCompensation:
|
|
290
|
+
'end-content slot axes: inline | block | all; omit=automatic close-action compensation',
|
|
291
|
+
hasDivider: 'bottom border; default = parent Layout defaultHasDividers',
|
|
292
|
+
},
|
|
293
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file DrawerHeader.test.tsx
|
|
5
|
+
* @input Uses vitest, @testing-library/react, DrawerHeader component
|
|
6
|
+
* @output Unit tests for DrawerHeader rendering, close action, slots, and theming targets
|
|
7
|
+
* @position Core testing; validates DrawerHeader.tsx implementation
|
|
8
|
+
*
|
|
9
|
+
* SYNC: When DrawerHeader.tsx changes, update tests to match new behavior
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import {describe, it, expect, vi} from 'vitest';
|
|
13
|
+
import {render, screen, fireEvent} from '@testing-library/react';
|
|
14
|
+
import {DrawerHeader} from './DrawerHeader';
|
|
15
|
+
|
|
16
|
+
describe('DrawerHeader', () => {
|
|
17
|
+
it('renders the title as an h2 and the subtitle below it', () => {
|
|
18
|
+
render(<DrawerHeader title="Host details" subtitle="web-prod-04" />);
|
|
19
|
+
expect(
|
|
20
|
+
screen.getByRole('heading', {level: 2, name: 'Host details'}),
|
|
21
|
+
).toBeInTheDocument();
|
|
22
|
+
expect(screen.getByText('web-prod-04')).toBeInTheDocument();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('renders no close button without onOpenChange', () => {
|
|
26
|
+
render(<DrawerHeader title="Details" />);
|
|
27
|
+
expect(screen.queryByRole('button')).not.toBeInTheDocument();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('renders a named close button that calls onOpenChange(false)', () => {
|
|
31
|
+
const handleOpenChange = vi.fn();
|
|
32
|
+
render(<DrawerHeader title="Details" onOpenChange={handleOpenChange} />);
|
|
33
|
+
fireEvent.click(screen.getByRole('button', {name: 'Close'}));
|
|
34
|
+
expect(handleOpenChange).toHaveBeenCalledTimes(1);
|
|
35
|
+
expect(handleOpenChange).toHaveBeenCalledWith(false);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('renders start and end content around the title', () => {
|
|
39
|
+
render(
|
|
40
|
+
<DrawerHeader
|
|
41
|
+
title="Details"
|
|
42
|
+
startContent={<button type="button">Back</button>}
|
|
43
|
+
endContent={<button type="button">Edit</button>}
|
|
44
|
+
onOpenChange={() => {}}
|
|
45
|
+
/>,
|
|
46
|
+
);
|
|
47
|
+
const names = screen
|
|
48
|
+
.getAllByRole('button')
|
|
49
|
+
.map(button => button.getAttribute('aria-label') ?? button.textContent);
|
|
50
|
+
expect(names).toEqual(['Back', 'Edit', 'Close']);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('renders 0 values inside their start and end content slots', () => {
|
|
54
|
+
const {container} = render(
|
|
55
|
+
<DrawerHeader title="Details" startContent={0} endContent={0} />,
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
expect(
|
|
59
|
+
container.querySelector('.astryx-drawer-header-start-content'),
|
|
60
|
+
).toHaveTextContent('0');
|
|
61
|
+
expect(
|
|
62
|
+
container.querySelector('.astryx-drawer-header-end-content'),
|
|
63
|
+
).toHaveTextContent('0');
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('renders a 0 subtitle and skips an empty one', () => {
|
|
67
|
+
const {rerender, container} = render(
|
|
68
|
+
<DrawerHeader title="Details" subtitle={0} />,
|
|
69
|
+
);
|
|
70
|
+
expect(screen.getByText('0')).toBeInTheDocument();
|
|
71
|
+
rerender(<DrawerHeader title="Details" subtitle="" />);
|
|
72
|
+
const titleBlock = container.querySelector(
|
|
73
|
+
'.astryx-drawer-header-title-block',
|
|
74
|
+
);
|
|
75
|
+
expect(titleBlock?.children).toHaveLength(1);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('emits its theming targets', () => {
|
|
79
|
+
const {container} = render(
|
|
80
|
+
<DrawerHeader
|
|
81
|
+
title="Details"
|
|
82
|
+
startContent="Start"
|
|
83
|
+
endContent="End"
|
|
84
|
+
onOpenChange={() => {}}
|
|
85
|
+
/>,
|
|
86
|
+
);
|
|
87
|
+
for (const target of [
|
|
88
|
+
'drawer-header',
|
|
89
|
+
'drawer-header-start-content',
|
|
90
|
+
'drawer-header-title-block',
|
|
91
|
+
'drawer-header-end-content',
|
|
92
|
+
'drawer-header-close-icon',
|
|
93
|
+
]) {
|
|
94
|
+
expect(container.querySelector(`.astryx-${target}`)).not.toBeNull();
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('does not move focus on mount', () => {
|
|
99
|
+
render(<DrawerHeader title="Details" onOpenChange={() => {}} />);
|
|
100
|
+
expect(document.activeElement).toBe(document.body);
|
|
101
|
+
});
|
|
102
|
+
});
|