@slipstream-ui/core 0.7.0 → 0.9.0
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/index.d.mts +317 -21
- package/dist/index.d.ts +317 -21
- package/dist/index.js +2004 -1069
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1998 -1068
- package/dist/index.mjs.map +1 -1
- package/dist/manifests/accordion.manifest.json +8 -2
- package/dist/manifests/alert.manifest.json +1 -1
- package/dist/manifests/announcement-bar.manifest.json +1 -1
- package/dist/manifests/app-shell.manifest.json +1 -1
- package/dist/manifests/applied-filters.manifest.json +1 -1
- package/dist/manifests/article-card.manifest.json +1 -1
- package/dist/manifests/auth-layout.manifest.json +19 -1
- package/dist/manifests/autocomplete.manifest.json +1 -1
- package/dist/manifests/avatar.manifest.json +1 -1
- package/dist/manifests/badge.manifest.json +13 -1
- package/dist/manifests/block.manifest.json +1 -1
- package/dist/manifests/bottom-nav.manifest.json +130 -0
- package/dist/manifests/breadcrumb.manifest.json +1 -1
- package/dist/manifests/button-group.manifest.json +1 -1
- package/dist/manifests/button.manifest.json +1 -1
- package/dist/manifests/calendar.manifest.json +175 -0
- package/dist/manifests/card.manifest.json +1 -1
- package/dist/manifests/checkbox.manifest.json +1 -1
- package/dist/manifests/comparison-table.manifest.json +1 -1
- package/dist/manifests/confirm-dialog.manifest.json +1 -1
- package/dist/manifests/contact-strip.manifest.json +1 -1
- package/dist/manifests/container.manifest.json +1 -1
- package/dist/manifests/cta-section.manifest.json +1 -1
- package/dist/manifests/data-table.manifest.json +8 -1
- package/dist/manifests/date-picker-popover.manifest.json +202 -0
- package/dist/manifests/date-picker.manifest.json +1 -1
- package/dist/manifests/date-range-picker.manifest.json +1 -1
- package/dist/manifests/deal-card.manifest.json +1 -1
- package/dist/manifests/dialog.manifest.json +1 -1
- package/dist/manifests/document-card.manifest.json +1 -1
- package/dist/manifests/drawer.manifest.json +48 -2
- package/dist/manifests/empty-state.manifest.json +1 -1
- package/dist/manifests/entity-card.manifest.json +1 -1
- package/dist/manifests/feature-grid.manifest.json +1 -1
- package/dist/manifests/feature-row.manifest.json +1 -1
- package/dist/manifests/fieldset.manifest.json +1 -1
- package/dist/manifests/file-upload.manifest.json +1 -1
- package/dist/manifests/filter-bar.manifest.json +1 -1
- package/dist/manifests/filter-chips.manifest.json +1 -1
- package/dist/manifests/filter-panel.manifest.json +1 -1
- package/dist/manifests/flex.manifest.json +1 -1
- package/dist/manifests/form-field.manifest.json +1 -1
- package/dist/manifests/form-layout.manifest.json +1 -1
- package/dist/manifests/form.manifest.json +1 -1
- package/dist/manifests/grid.manifest.json +1 -1
- package/dist/manifests/heading.manifest.json +1 -1
- package/dist/manifests/hero.manifest.json +1 -1
- package/dist/manifests/image.manifest.json +142 -0
- package/dist/manifests/input-group.manifest.json +1 -1
- package/dist/manifests/input.manifest.json +1 -1
- package/dist/manifests/label.manifest.json +1 -1
- package/dist/manifests/link-tabs.manifest.json +1 -1
- package/dist/manifests/link.manifest.json +1 -1
- package/dist/manifests/list.manifest.json +1 -1
- package/dist/manifests/load-more.manifest.json +1 -1
- package/dist/manifests/logo-cloud.manifest.json +1 -1
- package/dist/manifests/menu.manifest.json +1 -1
- package/dist/manifests/metric-card.manifest.json +36 -4
- package/dist/manifests/multi-select.manifest.json +1 -1
- package/dist/manifests/newsletter.manifest.json +1 -1
- package/dist/manifests/page-header.manifest.json +7 -1
- package/dist/manifests/pagination.manifest.json +1 -1
- package/dist/manifests/password-input.manifest.json +1 -1
- package/dist/manifests/popover.manifest.json +86 -4
- package/dist/manifests/process-steps.manifest.json +1 -1
- package/dist/manifests/progress.manifest.json +1 -1
- package/dist/manifests/prose.manifest.json +1 -1
- package/dist/manifests/radio.manifest.json +1 -1
- package/dist/manifests/range-slider.manifest.json +1 -1
- package/dist/manifests/search.manifest.json +1 -1
- package/dist/manifests/section-heading.manifest.json +1 -1
- package/dist/manifests/section.manifest.json +1 -1
- package/dist/manifests/segmented-control.manifest.json +1 -1
- package/dist/manifests/select-menu.manifest.json +1 -1
- package/dist/manifests/select.manifest.json +1 -1
- package/dist/manifests/separator.manifest.json +1 -1
- package/dist/manifests/site-footer.manifest.json +1 -1
- package/dist/manifests/site-header.manifest.json +13 -3
- package/dist/manifests/skeleton.manifest.json +1 -1
- package/dist/manifests/spinner.manifest.json +1 -1
- package/dist/manifests/stat-band.manifest.json +1 -1
- package/dist/manifests/stepper.manifest.json +7 -1
- package/dist/manifests/switch.manifest.json +1 -1
- package/dist/manifests/table-card.manifest.json +1 -1
- package/dist/manifests/table-of-contents.manifest.json +1 -1
- package/dist/manifests/table.manifest.json +1 -1
- package/dist/manifests/tabs.manifest.json +1 -1
- package/dist/manifests/testimonial.manifest.json +1 -1
- package/dist/manifests/text.manifest.json +1 -1
- package/dist/manifests/textarea.manifest.json +1 -1
- package/dist/manifests/theme-toggle.manifest.json +1 -1
- package/dist/manifests/time-picker.manifest.json +1 -1
- package/dist/manifests/timeline.manifest.json +1 -1
- package/dist/manifests/toast.manifest.json +1 -1
- package/dist/manifests/tombstone-card.manifest.json +1 -1
- package/dist/manifests/tooltip.manifest.json +1 -1
- package/dist/src/components/accordion/Accordion.d.ts +17 -1
- package/dist/src/components/accordion/Accordion.js +5 -1
- package/dist/src/components/accordion/Accordion.js.map +1 -1
- package/dist/src/components/accordion/Accordion.mjs +5 -1
- package/dist/src/components/accordion/Accordion.mjs.map +1 -1
- package/dist/src/components/alert/Alert.js +1 -1
- package/dist/src/components/alert/Alert.js.map +1 -1
- package/dist/src/components/alert/Alert.mjs +1 -1
- package/dist/src/components/alert/Alert.mjs.map +1 -1
- package/dist/src/components/app-shell/AppShell.js +1 -1
- package/dist/src/components/app-shell/AppShell.js.map +1 -1
- package/dist/src/components/app-shell/AppShell.mjs +1 -1
- package/dist/src/components/app-shell/AppShell.mjs.map +1 -1
- package/dist/src/components/article-card/ArticleCard.js +2 -2
- package/dist/src/components/article-card/ArticleCard.js.map +1 -1
- package/dist/src/components/article-card/ArticleCard.mjs +2 -2
- package/dist/src/components/article-card/ArticleCard.mjs.map +1 -1
- package/dist/src/components/auth-layout/AuthLayout.d.ts +14 -2
- package/dist/src/components/auth-layout/AuthLayout.js +10 -2
- package/dist/src/components/auth-layout/AuthLayout.js.map +1 -1
- package/dist/src/components/auth-layout/AuthLayout.mjs +10 -2
- package/dist/src/components/auth-layout/AuthLayout.mjs.map +1 -1
- package/dist/src/components/badge/Badge.d.ts +2 -0
- package/dist/src/components/badge/Badge.js +9 -3
- package/dist/src/components/badge/Badge.js.map +1 -1
- package/dist/src/components/badge/Badge.mjs +9 -3
- package/dist/src/components/badge/Badge.mjs.map +1 -1
- package/dist/src/components/bottom-nav/BottomNav.d.ts +36 -0
- package/dist/src/components/bottom-nav/BottomNav.js +90 -0
- package/dist/src/components/bottom-nav/BottomNav.js.map +1 -0
- package/dist/src/components/bottom-nav/BottomNav.mjs +66 -0
- package/dist/src/components/bottom-nav/BottomNav.mjs.map +1 -0
- package/dist/src/components/bottom-nav/index.d.ts +1 -0
- package/dist/src/components/bottom-nav/index.js +23 -0
- package/dist/src/components/bottom-nav/index.js.map +1 -0
- package/dist/src/components/bottom-nav/index.mjs +2 -0
- package/dist/src/components/bottom-nav/index.mjs.map +1 -0
- package/dist/src/components/calendar/Calendar.d.ts +34 -0
- package/dist/src/components/calendar/Calendar.js +233 -0
- package/dist/src/components/calendar/Calendar.js.map +1 -0
- package/dist/src/components/calendar/Calendar.mjs +208 -0
- package/dist/src/components/calendar/Calendar.mjs.map +1 -0
- package/dist/src/components/calendar/index.d.ts +1 -0
- package/dist/src/components/calendar/index.js +23 -0
- package/dist/src/components/calendar/index.js.map +1 -0
- package/dist/src/components/calendar/index.mjs +2 -0
- package/dist/src/components/calendar/index.mjs.map +1 -0
- package/dist/src/components/comparison-table/ComparisonTable.js +1 -1
- package/dist/src/components/comparison-table/ComparisonTable.js.map +1 -1
- package/dist/src/components/comparison-table/ComparisonTable.mjs +1 -1
- package/dist/src/components/comparison-table/ComparisonTable.mjs.map +1 -1
- package/dist/src/components/cta-section/CTASection.js +1 -1
- package/dist/src/components/cta-section/CTASection.js.map +1 -1
- package/dist/src/components/cta-section/CTASection.mjs +1 -1
- package/dist/src/components/cta-section/CTASection.mjs.map +1 -1
- package/dist/src/components/data-table/DataTable.d.ts +3 -1
- package/dist/src/components/data-table/DataTable.js +2 -4
- package/dist/src/components/data-table/DataTable.js.map +1 -1
- package/dist/src/components/data-table/DataTable.mjs +2 -4
- package/dist/src/components/data-table/DataTable.mjs.map +1 -1
- package/dist/src/components/date-picker-popover/DatePickerPopover.d.ts +33 -0
- package/dist/src/components/date-picker-popover/DatePickerPopover.js +117 -0
- package/dist/src/components/date-picker-popover/DatePickerPopover.js.map +1 -0
- package/dist/src/components/date-picker-popover/DatePickerPopover.mjs +83 -0
- package/dist/src/components/date-picker-popover/DatePickerPopover.mjs.map +1 -0
- package/dist/src/components/date-picker-popover/index.d.ts +1 -0
- package/dist/src/components/date-picker-popover/index.js +23 -0
- package/dist/src/components/date-picker-popover/index.js.map +1 -0
- package/dist/src/components/date-picker-popover/index.mjs +2 -0
- package/dist/src/components/date-picker-popover/index.mjs.map +1 -0
- package/dist/src/components/drawer/Drawer.d.ts +25 -2
- package/dist/src/components/drawer/Drawer.js +97 -6
- package/dist/src/components/drawer/Drawer.js.map +1 -1
- package/dist/src/components/drawer/Drawer.mjs +97 -6
- package/dist/src/components/drawer/Drawer.mjs.map +1 -1
- package/dist/src/components/empty-state/EmptyState.d.ts +13 -4
- package/dist/src/components/empty-state/EmptyState.js +13 -1
- package/dist/src/components/empty-state/EmptyState.js.map +1 -1
- package/dist/src/components/empty-state/EmptyState.mjs +13 -1
- package/dist/src/components/empty-state/EmptyState.mjs.map +1 -1
- package/dist/src/components/image/Image.d.ts +34 -0
- package/dist/src/components/image/Image.js +75 -0
- package/dist/src/components/image/Image.js.map +1 -0
- package/dist/src/components/image/Image.mjs +41 -0
- package/dist/src/components/image/Image.mjs.map +1 -0
- package/dist/src/components/image/index.d.ts +1 -0
- package/dist/src/components/image/index.js +29 -0
- package/dist/src/components/image/index.js.map +1 -0
- package/dist/src/components/image/index.mjs +5 -0
- package/dist/src/components/image/index.mjs.map +1 -0
- package/dist/src/components/link/Link.js +4 -4
- package/dist/src/components/link/Link.js.map +1 -1
- package/dist/src/components/link/Link.mjs +4 -4
- package/dist/src/components/link/Link.mjs.map +1 -1
- package/dist/src/components/metric-card/MetricCard.d.ts +23 -4
- package/dist/src/components/metric-card/MetricCard.js +32 -5
- package/dist/src/components/metric-card/MetricCard.js.map +1 -1
- package/dist/src/components/metric-card/MetricCard.mjs +32 -5
- package/dist/src/components/metric-card/MetricCard.mjs.map +1 -1
- package/dist/src/components/page-header/PageHeader.d.ts +4 -0
- package/dist/src/components/page-header/PageHeader.js +4 -3
- package/dist/src/components/page-header/PageHeader.js.map +1 -1
- package/dist/src/components/page-header/PageHeader.mjs +4 -3
- package/dist/src/components/page-header/PageHeader.mjs.map +1 -1
- package/dist/src/components/popover/Popover.d.ts +36 -3
- package/dist/src/components/popover/Popover.js +118 -22
- package/dist/src/components/popover/Popover.js.map +1 -1
- package/dist/src/components/popover/Popover.mjs +117 -22
- package/dist/src/components/popover/Popover.mjs.map +1 -1
- package/dist/src/components/section-heading/SectionHeading.js +1 -1
- package/dist/src/components/section-heading/SectionHeading.js.map +1 -1
- package/dist/src/components/section-heading/SectionHeading.mjs +1 -1
- package/dist/src/components/section-heading/SectionHeading.mjs.map +1 -1
- package/dist/src/components/separator/Separator.d.ts +3 -3
- package/dist/src/components/site-header/SiteHeader.d.ts +25 -3
- package/dist/src/components/site-header/SiteHeader.js +141 -6
- package/dist/src/components/site-header/SiteHeader.js.map +1 -1
- package/dist/src/components/site-header/SiteHeader.mjs +141 -6
- package/dist/src/components/site-header/SiteHeader.mjs.map +1 -1
- package/dist/src/components/stepper/Stepper.d.ts +18 -0
- package/dist/src/components/stepper/Stepper.js +2 -1
- package/dist/src/components/stepper/Stepper.js.map +1 -1
- package/dist/src/components/stepper/Stepper.mjs +2 -1
- package/dist/src/components/stepper/Stepper.mjs.map +1 -1
- package/dist/src/index.d.ts +4 -0
- package/dist/src/utils/date.d.ts +32 -0
- package/dist/src/utils/date.js +171 -0
- package/dist/src/utils/date.js.map +1 -0
- package/dist/src/utils/date.mjs +134 -0
- package/dist/src/utils/date.mjs.map +1 -0
- package/dist/src/utils/position.d.ts +42 -0
- package/dist/src/utils/position.js +91 -0
- package/dist/src/utils/position.js.map +1 -0
- package/dist/src/utils/position.mjs +67 -0
- package/dist/src/utils/position.mjs.map +1 -0
- package/dist/styles-full.css +1 -1
- package/dist/styles.css +1 -1
- package/package.json +3 -3
- package/src/components/accordion/Accordion.test.tsx +31 -0
- package/src/components/accordion/Accordion.tsx +27 -2
- package/src/components/alert/Alert.tsx +1 -1
- package/src/components/app-shell/AppShell.tsx +1 -1
- package/src/components/article-card/ArticleCard.tsx +2 -2
- package/src/components/auth-layout/AuthLayout.test.tsx +36 -0
- package/src/components/auth-layout/AuthLayout.tsx +20 -3
- package/src/components/badge/Badge.test.tsx +7 -0
- package/src/components/badge/Badge.tsx +8 -2
- package/src/components/bottom-nav/BottomNav.test.tsx +48 -0
- package/src/components/bottom-nav/BottomNav.tsx +117 -0
- package/src/components/bottom-nav/index.ts +1 -0
- package/src/components/calendar/Calendar.test.tsx +277 -0
- package/src/components/calendar/Calendar.tsx +273 -0
- package/src/components/calendar/index.ts +1 -0
- package/src/components/comparison-table/ComparisonTable.tsx +1 -1
- package/src/components/cta-section/CTASection.tsx +1 -1
- package/src/components/data-table/DataTable.test.tsx +21 -0
- package/src/components/data-table/DataTable.tsx +4 -1
- package/src/components/date-picker-popover/DatePickerPopover.test.tsx +223 -0
- package/src/components/date-picker-popover/DatePickerPopover.tsx +117 -0
- package/src/components/date-picker-popover/index.ts +1 -0
- package/src/components/drawer/Drawer.test.tsx +86 -1
- package/src/components/drawer/Drawer.tsx +135 -7
- package/src/components/empty-state/EmptyState.test.tsx +26 -1
- package/src/components/empty-state/EmptyState.tsx +40 -3
- package/src/components/image/Image.test.tsx +94 -0
- package/src/components/image/Image.tsx +71 -0
- package/src/components/image/index.ts +1 -0
- package/src/components/link/Link.test.tsx +2 -1
- package/src/components/link/Link.tsx +4 -4
- package/src/components/metric-card/MetricCard.test.tsx +32 -0
- package/src/components/metric-card/MetricCard.tsx +45 -7
- package/src/components/page-header/PageHeader.test.tsx +13 -0
- package/src/components/page-header/PageHeader.tsx +6 -3
- package/src/components/popover/Popover.test.tsx +307 -3
- package/src/components/popover/Popover.tsx +228 -91
- package/src/components/section-heading/SectionHeading.tsx +1 -1
- package/src/components/site-header/SiteHeader.test.tsx +103 -1
- package/src/components/site-header/SiteHeader.tsx +220 -16
- package/src/components/stepper/Stepper.test.tsx +12 -0
- package/src/components/stepper/Stepper.tsx +15 -1
- package/src/index.ts +4 -0
- package/src/manifests/accordion.manifest.json +8 -2
- package/src/manifests/alert.manifest.json +1 -1
- package/src/manifests/announcement-bar.manifest.json +1 -1
- package/src/manifests/app-shell.manifest.json +1 -1
- package/src/manifests/applied-filters.manifest.json +1 -1
- package/src/manifests/article-card.manifest.json +1 -1
- package/src/manifests/auth-layout.manifest.json +19 -1
- package/src/manifests/autocomplete.manifest.json +1 -1
- package/src/manifests/avatar.manifest.json +1 -1
- package/src/manifests/badge.manifest.json +13 -1
- package/src/manifests/block.manifest.json +1 -1
- package/src/manifests/bottom-nav.manifest.json +130 -0
- package/src/manifests/breadcrumb.manifest.json +1 -1
- package/src/manifests/button-group.manifest.json +1 -1
- package/src/manifests/button.manifest.json +1 -1
- package/src/manifests/calendar.manifest.json +175 -0
- package/src/manifests/card.manifest.json +1 -1
- package/src/manifests/checkbox.manifest.json +1 -1
- package/src/manifests/comparison-table.manifest.json +1 -1
- package/src/manifests/confirm-dialog.manifest.json +1 -1
- package/src/manifests/contact-strip.manifest.json +1 -1
- package/src/manifests/container.manifest.json +1 -1
- package/src/manifests/cta-section.manifest.json +1 -1
- package/src/manifests/data-table.manifest.json +8 -1
- package/src/manifests/date-picker-popover.manifest.json +202 -0
- package/src/manifests/date-picker.manifest.json +1 -1
- package/src/manifests/date-range-picker.manifest.json +1 -1
- package/src/manifests/deal-card.manifest.json +1 -1
- package/src/manifests/dialog.manifest.json +1 -1
- package/src/manifests/document-card.manifest.json +1 -1
- package/src/manifests/drawer.manifest.json +48 -2
- package/src/manifests/empty-state.manifest.json +1 -1
- package/src/manifests/entity-card.manifest.json +1 -1
- package/src/manifests/feature-grid.manifest.json +1 -1
- package/src/manifests/feature-row.manifest.json +1 -1
- package/src/manifests/fieldset.manifest.json +1 -1
- package/src/manifests/file-upload.manifest.json +1 -1
- package/src/manifests/filter-bar.manifest.json +1 -1
- package/src/manifests/filter-chips.manifest.json +1 -1
- package/src/manifests/filter-panel.manifest.json +1 -1
- package/src/manifests/flex.manifest.json +1 -1
- package/src/manifests/form-field.manifest.json +1 -1
- package/src/manifests/form-layout.manifest.json +1 -1
- package/src/manifests/form.manifest.json +1 -1
- package/src/manifests/grid.manifest.json +1 -1
- package/src/manifests/heading.manifest.json +1 -1
- package/src/manifests/hero.manifest.json +1 -1
- package/src/manifests/image.manifest.json +142 -0
- package/src/manifests/input-group.manifest.json +1 -1
- package/src/manifests/input.manifest.json +1 -1
- package/src/manifests/label.manifest.json +1 -1
- package/src/manifests/link-tabs.manifest.json +1 -1
- package/src/manifests/link.manifest.json +1 -1
- package/src/manifests/list.manifest.json +1 -1
- package/src/manifests/load-more.manifest.json +1 -1
- package/src/manifests/logo-cloud.manifest.json +1 -1
- package/src/manifests/menu.manifest.json +1 -1
- package/src/manifests/metric-card.manifest.json +36 -4
- package/src/manifests/multi-select.manifest.json +1 -1
- package/src/manifests/newsletter.manifest.json +1 -1
- package/src/manifests/page-header.manifest.json +7 -1
- package/src/manifests/pagination.manifest.json +1 -1
- package/src/manifests/password-input.manifest.json +1 -1
- package/src/manifests/popover.manifest.json +86 -4
- package/src/manifests/process-steps.manifest.json +1 -1
- package/src/manifests/progress.manifest.json +1 -1
- package/src/manifests/prose.manifest.json +1 -1
- package/src/manifests/radio.manifest.json +1 -1
- package/src/manifests/range-slider.manifest.json +1 -1
- package/src/manifests/search.manifest.json +1 -1
- package/src/manifests/section-heading.manifest.json +1 -1
- package/src/manifests/section.manifest.json +1 -1
- package/src/manifests/segmented-control.manifest.json +1 -1
- package/src/manifests/select-menu.manifest.json +1 -1
- package/src/manifests/select.manifest.json +1 -1
- package/src/manifests/separator.manifest.json +1 -1
- package/src/manifests/site-footer.manifest.json +1 -1
- package/src/manifests/site-header.manifest.json +13 -3
- package/src/manifests/skeleton.manifest.json +1 -1
- package/src/manifests/spinner.manifest.json +1 -1
- package/src/manifests/stat-band.manifest.json +1 -1
- package/src/manifests/stepper.manifest.json +7 -1
- package/src/manifests/switch.manifest.json +1 -1
- package/src/manifests/table-card.manifest.json +1 -1
- package/src/manifests/table-of-contents.manifest.json +1 -1
- package/src/manifests/table.manifest.json +1 -1
- package/src/manifests/tabs.manifest.json +1 -1
- package/src/manifests/testimonial.manifest.json +1 -1
- package/src/manifests/text.manifest.json +1 -1
- package/src/manifests/textarea.manifest.json +1 -1
- package/src/manifests/theme-toggle.manifest.json +1 -1
- package/src/manifests/time-picker.manifest.json +1 -1
- package/src/manifests/timeline.manifest.json +1 -1
- package/src/manifests/toast.manifest.json +1 -1
- package/src/manifests/tombstone-card.manifest.json +1 -1
- package/src/manifests/tooltip.manifest.json +1 -1
- package/src/utils/date.test.ts +190 -0
- package/src/utils/date.ts +162 -0
- package/src/utils/position.test.ts +227 -0
- package/src/utils/position.ts +129 -0
|
@@ -2,16 +2,26 @@ import * as React from 'react';
|
|
|
2
2
|
import { cn } from '../../utils/cn';
|
|
3
3
|
|
|
4
4
|
export type MetricTrend = 'up' | 'down' | 'flat';
|
|
5
|
+
export type MetricTone = 'default' | 'success' | 'warning' | 'destructive';
|
|
5
6
|
|
|
6
7
|
export type MetricCardProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'title'> & {
|
|
7
|
-
|
|
8
|
+
/** Metric name. Alias: title. */
|
|
9
|
+
label?: string;
|
|
8
10
|
value: string | number;
|
|
9
|
-
/** Secondary line under the value. */
|
|
11
|
+
/** Secondary line under the value. Alias: description. */
|
|
10
12
|
hint?: React.ReactNode;
|
|
13
|
+
/** Alias for `label` (migration-friendly). */
|
|
14
|
+
title?: string;
|
|
15
|
+
/** Alias for `hint` (migration-friendly). */
|
|
16
|
+
description?: React.ReactNode;
|
|
11
17
|
/** Signed change, e.g. "+12.4%" or "-3". */
|
|
12
18
|
delta?: string;
|
|
13
19
|
/** Direction colors the delta (green up / red down / muted flat). */
|
|
14
20
|
trend?: MetricTrend;
|
|
21
|
+
/** Semantic color for the value (not the delta). */
|
|
22
|
+
tone?: MetricTone;
|
|
23
|
+
/** Renders a skeleton instead of the value; sets aria-busy while true. */
|
|
24
|
+
loading?: boolean;
|
|
15
25
|
icon?: React.ReactNode;
|
|
16
26
|
};
|
|
17
27
|
|
|
@@ -21,6 +31,13 @@ const trendClasses: Record<MetricTrend, string> = {
|
|
|
21
31
|
flat: 'text-muted-foreground',
|
|
22
32
|
};
|
|
23
33
|
|
|
34
|
+
const toneClasses: Record<MetricTone, string> = {
|
|
35
|
+
default: '',
|
|
36
|
+
success: 'text-success',
|
|
37
|
+
warning: 'text-warning-ink',
|
|
38
|
+
destructive: 'text-destructive',
|
|
39
|
+
};
|
|
40
|
+
|
|
24
41
|
const trendGlyph: Record<MetricTrend, string> = { up: '↑', down: '↓', flat: '→' };
|
|
25
42
|
|
|
26
43
|
/**
|
|
@@ -29,24 +46,45 @@ const trendGlyph: Record<MetricTrend, string> = { up: '↑', down: '↓', flat:
|
|
|
29
46
|
* never communicated by color alone.
|
|
30
47
|
*/
|
|
31
48
|
export const MetricCard = React.forwardRef<HTMLDivElement, MetricCardProps>(function MetricCard(
|
|
32
|
-
{ label, value, hint, delta, trend = 'flat', icon, className, ...props },
|
|
49
|
+
{ label, value, hint, title, description, delta, trend = 'flat', tone = 'default', loading = false, icon, className, ...props },
|
|
33
50
|
ref
|
|
34
51
|
) {
|
|
52
|
+
const heading = label ?? title;
|
|
53
|
+
const supporting = hint ?? description;
|
|
54
|
+
|
|
55
|
+
if (loading) {
|
|
56
|
+
return (
|
|
57
|
+
<div
|
|
58
|
+
ref={ref}
|
|
59
|
+
aria-busy="true"
|
|
60
|
+
className={cn('rounded-xl border border-border bg-card p-5', className)}
|
|
61
|
+
{...props}
|
|
62
|
+
>
|
|
63
|
+
<div className="flex items-start justify-between gap-3">
|
|
64
|
+
{heading && <p className="text-sm text-muted-foreground">{heading}</p>}
|
|
65
|
+
{icon && <span className="text-muted-foreground [&_svg]:size-4">{icon}</span>}
|
|
66
|
+
</div>
|
|
67
|
+
<span aria-hidden="true" className="mt-3 block h-7 w-24 animate-pulse rounded-md bg-muted" />
|
|
68
|
+
<span className="sr-only">Loading</span>
|
|
69
|
+
</div>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
35
73
|
return (
|
|
36
74
|
<div ref={ref} className={cn('rounded-xl border border-border bg-card p-5', className)} {...props}>
|
|
37
75
|
<div className="flex items-start justify-between gap-3">
|
|
38
|
-
<p className="text-sm text-muted-foreground">{
|
|
76
|
+
{heading && <p className="text-sm text-muted-foreground">{heading}</p>}
|
|
39
77
|
{icon && <span className="text-muted-foreground [&_svg]:size-4">{icon}</span>}
|
|
40
78
|
</div>
|
|
41
|
-
<p className=
|
|
42
|
-
{(delta ||
|
|
79
|
+
<p className={cn('mt-2 text-2xl font-semibold tabular-nums', toneClasses[tone])}>{value}</p>
|
|
80
|
+
{(delta || supporting) && (
|
|
43
81
|
<p className="mt-1 flex items-center gap-2 text-sm">
|
|
44
82
|
{delta && (
|
|
45
83
|
<span className={cn('font-medium tabular-nums', trendClasses[trend])}>
|
|
46
84
|
<span aria-hidden="true">{trendGlyph[trend]}</span> {delta}
|
|
47
85
|
</span>
|
|
48
86
|
)}
|
|
49
|
-
{
|
|
87
|
+
{supporting && <span className="text-muted-foreground">{supporting}</span>}
|
|
50
88
|
</p>
|
|
51
89
|
)}
|
|
52
90
|
</div>
|
|
@@ -46,3 +46,16 @@ describe('PageHeader hero options', () => {
|
|
|
46
46
|
expect(screen.getByRole('heading', { level: 1 })).toHaveClass('text-4xl');
|
|
47
47
|
});
|
|
48
48
|
});
|
|
49
|
+
|
|
50
|
+
describe('PageHeader migration aliases', () => {
|
|
51
|
+
it('renders subtitle when description is absent', () => {
|
|
52
|
+
render(<PageHeader title="Billing" subtitle="Manage invoices." />);
|
|
53
|
+
expect(screen.getByText('Manage invoices.')).toBeInTheDocument();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('prefers description when both description and subtitle are passed', () => {
|
|
57
|
+
render(<PageHeader title="Billing" description="Canonical" subtitle="Alias" />);
|
|
58
|
+
expect(screen.getByText('Canonical')).toBeInTheDocument();
|
|
59
|
+
expect(screen.queryByText('Alias')).not.toBeInTheDocument();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -4,6 +4,8 @@ import { cn } from '../../utils/cn';
|
|
|
4
4
|
export type PageHeaderProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
5
5
|
title: string;
|
|
6
6
|
description?: string;
|
|
7
|
+
/** Alias for `description` (migration-friendly). */
|
|
8
|
+
subtitle?: string;
|
|
7
9
|
/** Breadcrumbs/eyebrow above the title. */
|
|
8
10
|
breadcrumbs?: React.ReactNode;
|
|
9
11
|
/** Right-aligned actions (buttons, menus). */
|
|
@@ -37,19 +39,20 @@ const sizeClasses: Record<NonNullable<PageHeaderProps['size']>, string> = {
|
|
|
37
39
|
* and heading hierarchy.
|
|
38
40
|
*/
|
|
39
41
|
export const PageHeader = React.forwardRef<HTMLDivElement, PageHeaderProps>(function PageHeader(
|
|
40
|
-
{ title, description, breadcrumbs, actions, eyebrow, size = 'md', align = 'left', titleClassName, descriptionClassName, eyebrowClassName, className, children, ...props },
|
|
42
|
+
{ title, description, subtitle, breadcrumbs, actions, eyebrow, size = 'md', align = 'left', titleClassName, descriptionClassName, eyebrowClassName, className, children, ...props },
|
|
41
43
|
ref
|
|
42
44
|
) {
|
|
45
|
+
const supporting = description ?? subtitle;
|
|
43
46
|
return (
|
|
44
47
|
<div ref={ref} className={cn('flex flex-col gap-2', align === 'center' && 'items-center text-center', className)} {...props}>
|
|
45
48
|
{breadcrumbs && <div className="text-sm text-muted-foreground">{breadcrumbs}</div>}
|
|
46
49
|
{eyebrow && (
|
|
47
|
-
<div className={cn('text-xs font-medium uppercase tracking-wide text-primary', eyebrowClassName)}>{eyebrow}</div>
|
|
50
|
+
<div className={cn('text-xs font-medium uppercase tracking-wide text-primary-ink', eyebrowClassName)}>{eyebrow}</div>
|
|
48
51
|
)}
|
|
49
52
|
<div className={cn('flex w-full flex-wrap items-start justify-between gap-3', align === 'center' && 'justify-center')}>
|
|
50
53
|
<div className={cn('min-w-0', align === 'center' && 'flex flex-col items-center')}>
|
|
51
54
|
<h1 className={cn('font-semibold tracking-tight', sizeClasses[size], titleClassName)}>{title}</h1>
|
|
52
|
-
{
|
|
55
|
+
{supporting && <p className={cn('mt-2 max-w-2xl text-base text-muted-foreground', descriptionClassName)}>{supporting}</p>}
|
|
53
56
|
</div>
|
|
54
57
|
{actions && <div className="flex shrink-0 items-center gap-2">{actions}</div>}
|
|
55
58
|
</div>
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { render, screen, waitFor } from '@testing-library/react';
|
|
1
|
+
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
|
2
2
|
import userEvent from '@testing-library/user-event';
|
|
3
3
|
import { axe } from 'jest-axe';
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
6
|
+
import { Popover, PopoverAnchor, PopoverContent, PopoverTrigger } from './Popover';
|
|
6
7
|
|
|
7
8
|
function BasicPopover({ onOpenChange }: { onOpenChange?: (open: boolean) => void }) {
|
|
8
9
|
return (
|
|
@@ -16,6 +17,34 @@ function BasicPopover({ onOpenChange }: { onOpenChange?: (open: boolean) => void
|
|
|
16
17
|
);
|
|
17
18
|
}
|
|
18
19
|
|
|
20
|
+
function mockBounds(anchor: Partial<DOMRect>, panel: Partial<DOMRect> = {}) {
|
|
21
|
+
const toRect = (value: Partial<DOMRect>, fallback: DOMRect) => ({ ...fallback, ...value }) as DOMRect;
|
|
22
|
+
vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockImplementation(function (
|
|
23
|
+
this: HTMLElement
|
|
24
|
+
) {
|
|
25
|
+
const empty = {
|
|
26
|
+
top: 0,
|
|
27
|
+
left: 0,
|
|
28
|
+
right: 0,
|
|
29
|
+
bottom: 0,
|
|
30
|
+
width: 0,
|
|
31
|
+
height: 0,
|
|
32
|
+
x: 0,
|
|
33
|
+
y: 0,
|
|
34
|
+
toJSON: () => ({}),
|
|
35
|
+
} as DOMRect;
|
|
36
|
+
if (this.getAttribute('role') === 'dialog') return toRect(panel, empty);
|
|
37
|
+
if (this.dataset.testid === 'anchor' || this.classList.contains('relative')) {
|
|
38
|
+
return toRect(anchor, empty);
|
|
39
|
+
}
|
|
40
|
+
return empty;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
afterEach(() => {
|
|
45
|
+
vi.restoreAllMocks();
|
|
46
|
+
});
|
|
47
|
+
|
|
19
48
|
describe('Popover', () => {
|
|
20
49
|
it('renders trigger with dialog semantics', () => {
|
|
21
50
|
render(<BasicPopover />);
|
|
@@ -74,3 +103,278 @@ describe('Popover', () => {
|
|
|
74
103
|
expect(await axe(container)).toHaveNoViolations();
|
|
75
104
|
});
|
|
76
105
|
});
|
|
106
|
+
|
|
107
|
+
describe('Popover placement', () => {
|
|
108
|
+
it('opens below the anchor by default', async () => {
|
|
109
|
+
mockBounds({ top: 100, left: 40, width: 160, height: 32 }, { width: 288, height: 180 });
|
|
110
|
+
render(<BasicPopover />);
|
|
111
|
+
fireEvent.click(screen.getByRole('button', { name: 'Open' }));
|
|
112
|
+
const dialog = screen.getByRole('dialog');
|
|
113
|
+
expect(dialog).toHaveAttribute('data-side', 'bottom');
|
|
114
|
+
expect(dialog.style.top).toBe('140px');
|
|
115
|
+
expect(dialog.style.left).toBe('40px');
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('opens above when the preferred side has no room', async () => {
|
|
119
|
+
mockBounds({ top: 700, left: 40, width: 160, height: 32 }, { width: 288, height: 180 });
|
|
120
|
+
render(
|
|
121
|
+
<Popover>
|
|
122
|
+
<PopoverTrigger>Open</PopoverTrigger>
|
|
123
|
+
<PopoverContent side="bottom">Panel</PopoverContent>
|
|
124
|
+
</Popover>
|
|
125
|
+
);
|
|
126
|
+
fireEvent.click(screen.getByRole('button', { name: 'Open' }));
|
|
127
|
+
const dialog = screen.getByRole('dialog');
|
|
128
|
+
expect(dialog).toHaveAttribute('data-side', 'top');
|
|
129
|
+
expect(dialog.style.top).toBe('512px');
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('honours the side prop', async () => {
|
|
133
|
+
mockBounds({ top: 200, left: 300, width: 120, height: 36 }, { width: 200, height: 120 });
|
|
134
|
+
render(
|
|
135
|
+
<Popover>
|
|
136
|
+
<PopoverTrigger>Open</PopoverTrigger>
|
|
137
|
+
<PopoverContent side="right">Panel</PopoverContent>
|
|
138
|
+
</Popover>
|
|
139
|
+
);
|
|
140
|
+
fireEvent.click(screen.getByRole('button', { name: 'Open' }));
|
|
141
|
+
expect(screen.getByRole('dialog')).toHaveAttribute('data-side', 'right');
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('matches the anchor width on request', async () => {
|
|
145
|
+
mockBounds({ top: 100, left: 40, width: 260, height: 32 }, { width: 288, height: 180 });
|
|
146
|
+
render(
|
|
147
|
+
<Popover>
|
|
148
|
+
<PopoverTrigger>Open</PopoverTrigger>
|
|
149
|
+
<PopoverContent matchTriggerWidth>Panel</PopoverContent>
|
|
150
|
+
</Popover>
|
|
151
|
+
);
|
|
152
|
+
fireEvent.click(screen.getByRole('button', { name: 'Open' }));
|
|
153
|
+
expect(screen.getByRole('dialog').style.width).toBe('260px');
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it('anchors to PopoverAnchor when present', async () => {
|
|
157
|
+
mockBounds({ top: 100, left: 0, width: 0, height: 0 }, { width: 200, height: 100 });
|
|
158
|
+
render(
|
|
159
|
+
<Popover>
|
|
160
|
+
<PopoverAnchor data-testid="anchor">Field</PopoverAnchor>
|
|
161
|
+
<PopoverTrigger>Open</PopoverTrigger>
|
|
162
|
+
<PopoverContent>Panel</PopoverContent>
|
|
163
|
+
</Popover>
|
|
164
|
+
);
|
|
165
|
+
vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockImplementation(function (
|
|
166
|
+
this: HTMLElement
|
|
167
|
+
) {
|
|
168
|
+
const base = {
|
|
169
|
+
top: 0,
|
|
170
|
+
left: 0,
|
|
171
|
+
right: 0,
|
|
172
|
+
bottom: 0,
|
|
173
|
+
width: 0,
|
|
174
|
+
height: 0,
|
|
175
|
+
x: 0,
|
|
176
|
+
y: 0,
|
|
177
|
+
toJSON: () => ({}),
|
|
178
|
+
} as DOMRect;
|
|
179
|
+
if (this.getAttribute('role') === 'dialog') return { ...base, width: 200, height: 100 };
|
|
180
|
+
if (this.dataset.testid === 'anchor') {
|
|
181
|
+
return { ...base, top: 300, left: 24, width: 180, height: 40 };
|
|
182
|
+
}
|
|
183
|
+
return base;
|
|
184
|
+
});
|
|
185
|
+
fireEvent.click(screen.getByRole('button', { name: 'Open' }));
|
|
186
|
+
expect(screen.getByRole('dialog').style.top).toBe('348px');
|
|
187
|
+
expect(screen.getByRole('dialog').style.left).toBe('24px');
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it('stays open and repositions on scroll', async () => {
|
|
191
|
+
let top = 100;
|
|
192
|
+
vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockImplementation(function (
|
|
193
|
+
this: HTMLElement
|
|
194
|
+
) {
|
|
195
|
+
const base = {
|
|
196
|
+
top: 0,
|
|
197
|
+
left: 0,
|
|
198
|
+
right: 0,
|
|
199
|
+
bottom: 0,
|
|
200
|
+
width: 0,
|
|
201
|
+
height: 0,
|
|
202
|
+
x: 0,
|
|
203
|
+
y: 0,
|
|
204
|
+
toJSON: () => ({}),
|
|
205
|
+
} as DOMRect;
|
|
206
|
+
if (this.getAttribute('role') === 'dialog') return { ...base, width: 288, height: 180 };
|
|
207
|
+
return { ...base, top, left: 40, width: 160, height: 32 };
|
|
208
|
+
});
|
|
209
|
+
render(<BasicPopover />);
|
|
210
|
+
fireEvent.click(screen.getByRole('button', { name: 'Open' }));
|
|
211
|
+
expect(screen.getByRole('dialog').style.top).toBe('140px');
|
|
212
|
+
|
|
213
|
+
top = 60;
|
|
214
|
+
fireEvent.scroll(window);
|
|
215
|
+
await waitFor(() => expect(screen.getByRole('dialog').style.top).toBe('100px'));
|
|
216
|
+
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
describe('Popover focus and labelling', () => {
|
|
221
|
+
it('restores focus to the trigger on Escape', async () => {
|
|
222
|
+
const user = userEvent.setup();
|
|
223
|
+
render(<BasicPopover />);
|
|
224
|
+
const trigger = screen.getByRole('button', { name: 'Open' });
|
|
225
|
+
await user.click(trigger);
|
|
226
|
+
await waitFor(() => expect(screen.getByRole('dialog')).toBeInTheDocument());
|
|
227
|
+
|
|
228
|
+
await user.keyboard('{Escape}');
|
|
229
|
+
await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument());
|
|
230
|
+
expect(trigger).toHaveFocus();
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
it('labels the dialog from the trigger', async () => {
|
|
234
|
+
const user = userEvent.setup();
|
|
235
|
+
render(<BasicPopover />);
|
|
236
|
+
const trigger = screen.getByRole('button', { name: 'Open' });
|
|
237
|
+
await user.click(trigger);
|
|
238
|
+
|
|
239
|
+
expect(trigger.id).not.toBe('');
|
|
240
|
+
expect(screen.getByRole('dialog')).toHaveAttribute('aria-labelledby', trigger.id);
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
it('keeps the label valid when the trigger has an explicit id', async () => {
|
|
244
|
+
const user = userEvent.setup();
|
|
245
|
+
render(
|
|
246
|
+
<Popover>
|
|
247
|
+
<PopoverTrigger id="filter-trigger">Open</PopoverTrigger>
|
|
248
|
+
<PopoverContent>Panel</PopoverContent>
|
|
249
|
+
</Popover>
|
|
250
|
+
);
|
|
251
|
+
const trigger = screen.getByRole('button', { name: 'Open' });
|
|
252
|
+
expect(trigger).toHaveAttribute('id', 'filter-trigger');
|
|
253
|
+
|
|
254
|
+
await user.click(trigger);
|
|
255
|
+
expect(screen.getByRole('dialog')).toHaveAttribute('aria-labelledby', 'filter-trigger');
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
it('does not emit a dangling aria-labelledby without a trigger', async () => {
|
|
259
|
+
render(
|
|
260
|
+
<Popover open>
|
|
261
|
+
<PopoverContent aria-label="Anchored panel">Panel</PopoverContent>
|
|
262
|
+
</Popover>
|
|
263
|
+
);
|
|
264
|
+
const dialog = screen.getByRole('dialog');
|
|
265
|
+
expect(dialog).not.toHaveAttribute('aria-labelledby');
|
|
266
|
+
expect(dialog).toHaveAttribute('aria-label', 'Anchored panel');
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
it('closes an anchor-only panel on Escape without throwing', async () => {
|
|
270
|
+
const user = userEvent.setup();
|
|
271
|
+
function AnchorOnly() {
|
|
272
|
+
const [open, setOpen] = React.useState(true);
|
|
273
|
+
return (
|
|
274
|
+
<Popover open={open} onOpenChange={setOpen}>
|
|
275
|
+
<PopoverAnchor data-testid="anchor">Field</PopoverAnchor>
|
|
276
|
+
<PopoverContent aria-label="Anchored panel">Panel</PopoverContent>
|
|
277
|
+
</Popover>
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
render(<AnchorOnly />);
|
|
281
|
+
await user.keyboard('{Escape}');
|
|
282
|
+
await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument());
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
describe('Popover controlled and interaction edges', () => {
|
|
287
|
+
it('follows a controlled open prop', async () => {
|
|
288
|
+
const { rerender } = render(
|
|
289
|
+
<Popover open>
|
|
290
|
+
<PopoverContent>Panel</PopoverContent>
|
|
291
|
+
</Popover>
|
|
292
|
+
);
|
|
293
|
+
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
|
294
|
+
|
|
295
|
+
rerender(
|
|
296
|
+
<Popover open={false}>
|
|
297
|
+
<PopoverContent>Panel</PopoverContent>
|
|
298
|
+
</Popover>
|
|
299
|
+
);
|
|
300
|
+
await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument());
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
it('toggles aria-expanded on the trigger', async () => {
|
|
304
|
+
const user = userEvent.setup();
|
|
305
|
+
render(<BasicPopover />);
|
|
306
|
+
const trigger = screen.getByRole('button', { name: 'Open' });
|
|
307
|
+
expect(trigger).toHaveAttribute('aria-expanded', 'false');
|
|
308
|
+
await user.click(trigger);
|
|
309
|
+
expect(trigger).toHaveAttribute('aria-expanded', 'true');
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
it('does not open from a disabled trigger', async () => {
|
|
313
|
+
const user = userEvent.setup();
|
|
314
|
+
render(
|
|
315
|
+
<Popover>
|
|
316
|
+
<PopoverTrigger disabled>Open</PopoverTrigger>
|
|
317
|
+
<PopoverContent>Panel</PopoverContent>
|
|
318
|
+
</Popover>
|
|
319
|
+
);
|
|
320
|
+
const trigger = screen.getByRole('button', { name: 'Open' });
|
|
321
|
+
expect(trigger).toBeDisabled();
|
|
322
|
+
await user.click(trigger);
|
|
323
|
+
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
it('stays open when the pointer goes down inside the panel', async () => {
|
|
327
|
+
render(<BasicPopover />);
|
|
328
|
+
fireEvent.click(screen.getByRole('button', { name: 'Open' }));
|
|
329
|
+
const dialog = screen.getByRole('dialog');
|
|
330
|
+
|
|
331
|
+
fireEvent.pointerDown(dialog);
|
|
332
|
+
fireEvent.pointerDown(screen.getByRole('button', { name: 'Inner button' }));
|
|
333
|
+
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
it('repositions on window resize', async () => {
|
|
337
|
+
let top = 100;
|
|
338
|
+
vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockImplementation(function (
|
|
339
|
+
this: HTMLElement
|
|
340
|
+
) {
|
|
341
|
+
const base = {
|
|
342
|
+
top: 0,
|
|
343
|
+
left: 0,
|
|
344
|
+
right: 0,
|
|
345
|
+
bottom: 0,
|
|
346
|
+
width: 0,
|
|
347
|
+
height: 0,
|
|
348
|
+
x: 0,
|
|
349
|
+
y: 0,
|
|
350
|
+
toJSON: () => ({}),
|
|
351
|
+
} as DOMRect;
|
|
352
|
+
if (this.getAttribute('role') === 'dialog') return { ...base, width: 288, height: 180 };
|
|
353
|
+
return { ...base, top, left: 40, width: 160, height: 32 };
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
render(<BasicPopover />);
|
|
357
|
+
fireEvent.click(screen.getByRole('button', { name: 'Open' }));
|
|
358
|
+
expect(screen.getByRole('dialog').style.top).toBe('140px');
|
|
359
|
+
|
|
360
|
+
top = 20;
|
|
361
|
+
fireEvent(window, new Event('resize'));
|
|
362
|
+
await waitFor(() => expect(screen.getByRole('dialog').style.top).toBe('60px'));
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
it('applies align and collisionPadding to the panel position', () => {
|
|
366
|
+
mockBounds({ top: 100, left: 900, width: 160, height: 32 }, { width: 288, height: 180 });
|
|
367
|
+
render(
|
|
368
|
+
<Popover>
|
|
369
|
+
<PopoverTrigger>Open</PopoverTrigger>
|
|
370
|
+
<PopoverContent align="end" collisionPadding={8}>
|
|
371
|
+
Panel
|
|
372
|
+
</PopoverContent>
|
|
373
|
+
</Popover>
|
|
374
|
+
);
|
|
375
|
+
fireEvent.click(screen.getByRole('button', { name: 'Open' }));
|
|
376
|
+
|
|
377
|
+
// align=end would start at 772; the viewport clamp keeps it at 1024-288-8.
|
|
378
|
+
expect(screen.getByRole('dialog').style.left).toBe('728px');
|
|
379
|
+
});
|
|
380
|
+
});
|