@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
|
@@ -11,7 +11,7 @@ const alertVariants = cva(
|
|
|
11
11
|
destructive: 'border-destructive/50 text-destructive bg-destructive/10 [&>svg]:text-destructive',
|
|
12
12
|
/** Alias kept for Bootstrap/shadcn-style codebases. */
|
|
13
13
|
danger: 'border-destructive/50 text-destructive bg-destructive/10 [&>svg]:text-destructive',
|
|
14
|
-
success: 'border-success/50 text-success bg-success/10 [&>svg]:text-success',
|
|
14
|
+
success: 'border-success/50 text-success-ink bg-success/10 [&>svg]:text-success-ink',
|
|
15
15
|
warning: 'border-warning/50 text-warning-ink bg-warning/10 [&>svg]:text-warning-ink',
|
|
16
16
|
info: 'border-info/50 text-info-ink bg-info/10 [&>svg]:text-info-ink',
|
|
17
17
|
},
|
|
@@ -55,7 +55,7 @@ function containsActive(item: SidebarItem, activeHref: string | undefined): bool
|
|
|
55
55
|
|
|
56
56
|
const itemClass =
|
|
57
57
|
'flex w-full items-center gap-2.5 rounded-md px-2.5 py-2 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
58
|
-
const activeClass = 'bg-primary/10 font-medium text-primary';
|
|
58
|
+
const activeClass = 'bg-primary/10 font-medium text-primary-ink';
|
|
59
59
|
const idleClass = 'text-muted-foreground hover:bg-accent hover:text-accent-foreground';
|
|
60
60
|
|
|
61
61
|
/**
|
|
@@ -59,9 +59,9 @@ export const ArticleCard = React.forwardRef<HTMLElement, ArticleCardProps>(funct
|
|
|
59
59
|
)}
|
|
60
60
|
<div className={cn('flex flex-1 flex-col gap-2', compact ? 'p-4' : 'p-5')}>
|
|
61
61
|
{eyebrow && (
|
|
62
|
-
<p className="text-xs font-semibold uppercase tracking-widest text-primary">{eyebrow}</p>
|
|
62
|
+
<p className="text-xs font-semibold uppercase tracking-widest text-primary-ink">{eyebrow}</p>
|
|
63
63
|
)}
|
|
64
|
-
<h3 className={cn('font-semibold tracking-tight transition-colors group-hover:text-primary', compact ? 'text-base' : 'text-lg')}>
|
|
64
|
+
<h3 className={cn('font-semibold tracking-tight transition-colors group-hover:text-primary-ink', compact ? 'text-base' : 'text-lg')}>
|
|
65
65
|
{title}
|
|
66
66
|
</h3>
|
|
67
67
|
{description && (
|
|
@@ -33,6 +33,42 @@ describe('AuthLayout', () => {
|
|
|
33
33
|
});
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
+
describe('AuthLayout migration aliases', () => {
|
|
37
|
+
it('reads subtitle and logo when description and brand are absent', () => {
|
|
38
|
+
render(<AuthLayout title="Sign in" subtitle="Welcome back." logo={<span>Acme</span>} />);
|
|
39
|
+
expect(screen.getByText('Welcome back.')).toBeInTheDocument();
|
|
40
|
+
expect(screen.getByText('Acme')).toBeInTheDocument();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('prefers description and brand when both forms are passed', () => {
|
|
44
|
+
render(
|
|
45
|
+
<AuthLayout
|
|
46
|
+
title="Sign in"
|
|
47
|
+
description="Canonical line"
|
|
48
|
+
subtitle="Alias line"
|
|
49
|
+
brand={<span>Canonical mark</span>}
|
|
50
|
+
logo={<span>Alias mark</span>}
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
expect(screen.getByText('Canonical line')).toBeInTheDocument();
|
|
54
|
+
expect(screen.queryByText('Alias line')).not.toBeInTheDocument();
|
|
55
|
+
expect(screen.getByText('Canonical mark')).toBeInTheDocument();
|
|
56
|
+
expect(screen.queryByText('Alias mark')).not.toBeInTheDocument();
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
describe('AuthLayout maxWidth', () => {
|
|
61
|
+
it('overrides the size preset with a pixel width', () => {
|
|
62
|
+
const { container } = render(<AuthLayout title="Sign in" maxWidth={420} />);
|
|
63
|
+
expect(container.querySelector('[style*="max-width: 420px"]')).not.toBeNull();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('accepts any CSS width', () => {
|
|
67
|
+
const { container } = render(<AuthLayout title="Sign in" maxWidth="26rem" />);
|
|
68
|
+
expect(container.querySelector('[style*="max-width: 26rem"]')).not.toBeNull();
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
36
72
|
describe('split variant', () => {
|
|
37
73
|
it('renders the aside after the form', () => {
|
|
38
74
|
const { container } = render(
|
|
@@ -4,8 +4,12 @@ import { cn } from '../../utils/cn';
|
|
|
4
4
|
export type AuthLayoutProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
5
5
|
title: string;
|
|
6
6
|
description?: string;
|
|
7
|
-
/**
|
|
7
|
+
/** Alias for `description` (migration-friendly). */
|
|
8
|
+
subtitle?: string;
|
|
9
|
+
/** Brand/mark above the card. Alias: logo. */
|
|
8
10
|
brand?: React.ReactNode;
|
|
11
|
+
/** Alias for `brand` (migration-friendly). */
|
|
12
|
+
logo?: React.ReactNode;
|
|
9
13
|
/** Links or legal copy under the card. */
|
|
10
14
|
footer?: React.ReactNode;
|
|
11
15
|
/** Rendered inside the card under the heading. */
|
|
@@ -19,6 +23,8 @@ export type AuthLayoutProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
19
23
|
* the centered variant; omitting it makes the split variant fall back.
|
|
20
24
|
*/
|
|
21
25
|
aside?: React.ReactNode;
|
|
26
|
+
/** Overrides the card width: pixels (420) or any CSS width ("26rem"). */
|
|
27
|
+
maxWidth?: number | string;
|
|
22
28
|
};
|
|
23
29
|
|
|
24
30
|
const sizeClasses: Record<NonNullable<AuthLayoutProps['size']>, string> = {
|
|
@@ -38,18 +44,27 @@ export const AuthLayout = React.forwardRef<HTMLDivElement, AuthLayoutProps>(func
|
|
|
38
44
|
{
|
|
39
45
|
title,
|
|
40
46
|
description,
|
|
47
|
+
subtitle,
|
|
41
48
|
brand,
|
|
49
|
+
logo,
|
|
42
50
|
footer,
|
|
43
51
|
children,
|
|
44
52
|
size = 'md',
|
|
45
53
|
variant = 'centered',
|
|
46
54
|
aside,
|
|
55
|
+
maxWidth,
|
|
47
56
|
className,
|
|
48
57
|
...props
|
|
49
58
|
},
|
|
50
59
|
ref
|
|
51
60
|
) {
|
|
52
61
|
const split = variant === 'split' && aside != null;
|
|
62
|
+
const supporting = description ?? subtitle;
|
|
63
|
+
const mark = brand ?? logo;
|
|
64
|
+
const widthStyle =
|
|
65
|
+
maxWidth === undefined
|
|
66
|
+
? undefined
|
|
67
|
+
: { maxWidth: typeof maxWidth === 'number' ? `${maxWidth}px` : maxWidth };
|
|
53
68
|
|
|
54
69
|
const form = (
|
|
55
70
|
<div
|
|
@@ -57,16 +72,18 @@ export const AuthLayout = React.forwardRef<HTMLDivElement, AuthLayoutProps>(func
|
|
|
57
72
|
'flex w-full flex-col',
|
|
58
73
|
split ? sizeClasses[size] : 'items-center'
|
|
59
74
|
)}
|
|
75
|
+
style={widthStyle}
|
|
60
76
|
>
|
|
61
|
-
{
|
|
77
|
+
{mark && <div className="mb-6">{mark}</div>}
|
|
62
78
|
<div
|
|
63
79
|
className={cn(
|
|
64
80
|
'w-full rounded-xl border border-border bg-card p-6 shadow-sm sm:p-8',
|
|
65
81
|
!split && sizeClasses[size]
|
|
66
82
|
)}
|
|
83
|
+
style={widthStyle}
|
|
67
84
|
>
|
|
68
85
|
<h1 className="text-xl font-semibold tracking-tight">{title}</h1>
|
|
69
|
-
{
|
|
86
|
+
{supporting && <p className="mt-1 text-sm text-muted-foreground">{supporting}</p>}
|
|
70
87
|
<div className="mt-6">{children}</div>
|
|
71
88
|
</div>
|
|
72
89
|
{footer && <div className="mt-6 text-center text-sm text-muted-foreground">{footer}</div>}
|
|
@@ -99,4 +99,11 @@ describe('Badge semantic and alias variants', () => {
|
|
|
99
99
|
expect(screen.getByText('accent')).toHaveClass('bg-accent');
|
|
100
100
|
expect(container.querySelectorAll('span')).toHaveLength(7);
|
|
101
101
|
});
|
|
102
|
+
|
|
103
|
+
it('applies size presets', () => {
|
|
104
|
+
const { rerender } = render(<Badge size="sm">small</Badge>);
|
|
105
|
+
expect(screen.getByText('small')).toHaveClass('text-[11px]');
|
|
106
|
+
rerender(<Badge size="lg">large</Badge>);
|
|
107
|
+
expect(screen.getByText('large')).toHaveClass('text-sm', 'px-3');
|
|
108
|
+
});
|
|
102
109
|
});
|
|
@@ -23,9 +23,15 @@ const badgeVariants = cva(
|
|
|
23
23
|
destructive: 'border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80',
|
|
24
24
|
outline: 'text-foreground',
|
|
25
25
|
},
|
|
26
|
+
size: {
|
|
27
|
+
sm: 'px-2 py-0 text-[11px]',
|
|
28
|
+
md: 'px-2.5 py-0.5 text-xs',
|
|
29
|
+
lg: 'px-3 py-1 text-sm',
|
|
30
|
+
},
|
|
26
31
|
},
|
|
27
32
|
defaultVariants: {
|
|
28
33
|
variant: 'default',
|
|
34
|
+
size: 'md',
|
|
29
35
|
},
|
|
30
36
|
}
|
|
31
37
|
);
|
|
@@ -37,9 +43,9 @@ export type BadgeProps = React.HTMLAttributes<HTMLSpanElement> &
|
|
|
37
43
|
};
|
|
38
44
|
|
|
39
45
|
const Badge = React.forwardRef<HTMLSpanElement, BadgeProps>(
|
|
40
|
-
({ className, variant, asChild = false, ...props }, ref) => {
|
|
46
|
+
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
41
47
|
const Comp = asChild ? Slot : 'span';
|
|
42
|
-
return <Comp ref={ref} className={cn(badgeVariants({ variant }), className)} {...props} />;
|
|
48
|
+
return <Comp ref={ref} className={cn(badgeVariants({ variant, size }), className)} {...props} />;
|
|
43
49
|
}
|
|
44
50
|
);
|
|
45
51
|
Badge.displayName = 'Badge';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { axe } from 'jest-axe';
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
4
|
+
import { BottomNav, type BottomNavItem } from './BottomNav';
|
|
5
|
+
|
|
6
|
+
const ITEMS: BottomNavItem[] = [
|
|
7
|
+
{ href: '/', label: 'Home', active: true },
|
|
8
|
+
{ href: '/search', label: 'Search', badge: 3 },
|
|
9
|
+
{ href: '/alerts', label: 'Alerts', disabled: true },
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
describe('BottomNav', () => {
|
|
13
|
+
it('renders a labelled nav landmark with one tab per item', () => {
|
|
14
|
+
render(<BottomNav items={ITEMS} />);
|
|
15
|
+
const nav = screen.getByRole('navigation', { name: 'Primary' });
|
|
16
|
+
expect(nav).toBeInTheDocument();
|
|
17
|
+
expect(screen.getAllByRole('link')).toHaveLength(2);
|
|
18
|
+
expect(screen.getByRole('link', { name: 'Home' })).toHaveAttribute('href', '/');
|
|
19
|
+
expect(screen.getByText('Search')).toBeInTheDocument();
|
|
20
|
+
expect(screen.getByText('3')).toBeInTheDocument();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('marks only the active tab with aria-current', () => {
|
|
24
|
+
render(<BottomNav items={ITEMS} />);
|
|
25
|
+
expect(screen.getByRole('link', { name: 'Home' })).toHaveAttribute('aria-current', 'page');
|
|
26
|
+
expect(screen.getByRole('link', { name: /Search/ })).not.toHaveAttribute('aria-current');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('renders a disabled tab without a link', () => {
|
|
30
|
+
render(<BottomNav items={ITEMS} />);
|
|
31
|
+
expect(screen.queryByRole('link', { name: 'Alerts' })).not.toBeInTheDocument();
|
|
32
|
+
expect(screen.getByText('Alerts').closest('[aria-disabled="true"]')).not.toBeNull();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('passes the destination through a router link component', () => {
|
|
36
|
+
function RouterLink({ to, ...rest }: { to: string } & React.AnchorHTMLAttributes<HTMLAnchorElement>) {
|
|
37
|
+
return <a href={to} data-router="" {...rest} />;
|
|
38
|
+
}
|
|
39
|
+
render(<BottomNav items={ITEMS} linkComponent={RouterLink} linkHrefProp="to" />);
|
|
40
|
+
expect(screen.getByRole('link', { name: 'Home' })).toHaveAttribute('href', '/');
|
|
41
|
+
expect(screen.getByRole('link', { name: 'Home' })).toHaveAttribute('data-router', '');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('has no accessibility violations', async () => {
|
|
45
|
+
const { container } = render(<BottomNav items={ITEMS} />);
|
|
46
|
+
expect(await axe(container)).toHaveNoViolations();
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { cn } from '../../utils/cn';
|
|
3
|
+
|
|
4
|
+
export type BottomNavItem = {
|
|
5
|
+
/** Destination URL for the tab. */
|
|
6
|
+
href: string;
|
|
7
|
+
/** Visible tab label. */
|
|
8
|
+
label: string;
|
|
9
|
+
/** Icon shown above the label; always rendered aria-hidden. */
|
|
10
|
+
icon?: React.ReactNode;
|
|
11
|
+
/** Marks the current tab and sets aria-current="page". */
|
|
12
|
+
active?: boolean;
|
|
13
|
+
/** Small count or dot shown in the tab's top corner. */
|
|
14
|
+
badge?: React.ReactNode;
|
|
15
|
+
/** Renders the tab as non-interactive. */
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type BottomNavProps = React.HTMLAttributes<HTMLElement> & {
|
|
20
|
+
/** Tabs in order. Keep to 3-5 so every target stays thumb-reachable. */
|
|
21
|
+
items: BottomNavItem[];
|
|
22
|
+
/** Router link component (Next Link, react-router Link). */
|
|
23
|
+
linkComponent?: React.ElementType;
|
|
24
|
+
/** Prop used to pass the destination to `linkComponent`. */
|
|
25
|
+
linkHrefProp?: 'href' | 'to';
|
|
26
|
+
/** Landmark label. Default "Primary". */
|
|
27
|
+
label?: string;
|
|
28
|
+
/** Pin the bar to the bottom edge with safe-area padding (default true). */
|
|
29
|
+
fixed?: boolean;
|
|
30
|
+
/** Hide the bar from the md breakpoint up (default true). */
|
|
31
|
+
mobileOnly?: boolean;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const tabClass =
|
|
35
|
+
'relative flex min-h-14 w-full flex-col items-center justify-center gap-0.5 px-2 py-2 text-[11px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset';
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Mobile bottom tab bar for the 3-5 primary destinations of an app shell.
|
|
39
|
+
* A nav landmark with aria-current="page" on the active tab, 44px minimum
|
|
40
|
+
* targets, an optional count badge and safe-area padding so the bar clears
|
|
41
|
+
* the iOS home indicator.
|
|
42
|
+
*/
|
|
43
|
+
export function BottomNav({
|
|
44
|
+
items,
|
|
45
|
+
linkComponent,
|
|
46
|
+
linkHrefProp = 'href',
|
|
47
|
+
label = 'Primary',
|
|
48
|
+
fixed = true,
|
|
49
|
+
mobileOnly = true,
|
|
50
|
+
className,
|
|
51
|
+
...props
|
|
52
|
+
}: BottomNavProps) {
|
|
53
|
+
const LinkEl = linkComponent ?? 'a';
|
|
54
|
+
const destination = (href: string) => (linkHrefProp === 'to' ? { to: href } : { href });
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<nav
|
|
58
|
+
aria-label={label}
|
|
59
|
+
className={cn(
|
|
60
|
+
'w-full border-t border-border bg-background pb-[env(safe-area-inset-bottom)]',
|
|
61
|
+
fixed && 'fixed inset-x-0 bottom-0 z-40',
|
|
62
|
+
mobileOnly && 'md:hidden',
|
|
63
|
+
className
|
|
64
|
+
)}
|
|
65
|
+
{...props}
|
|
66
|
+
>
|
|
67
|
+
<ul
|
|
68
|
+
className="mx-auto grid w-full max-w-lg"
|
|
69
|
+
style={{ gridTemplateColumns: `repeat(${Math.max(items.length, 1)}, minmax(0, 1fr))` }}
|
|
70
|
+
>
|
|
71
|
+
{items.map((item) => {
|
|
72
|
+
const content = (
|
|
73
|
+
<>
|
|
74
|
+
{item.icon && (
|
|
75
|
+
<span aria-hidden="true" className="[&_svg]:size-5">
|
|
76
|
+
{item.icon}
|
|
77
|
+
</span>
|
|
78
|
+
)}
|
|
79
|
+
<span>{item.label}</span>
|
|
80
|
+
{item.badge != null && (
|
|
81
|
+
<span className="absolute right-1/4 top-1 rounded-full bg-primary px-1.5 text-[10px] font-semibold leading-4 text-primary-foreground">
|
|
82
|
+
{item.badge}
|
|
83
|
+
</span>
|
|
84
|
+
)}
|
|
85
|
+
</>
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<li key={item.href}>
|
|
90
|
+
{item.disabled ? (
|
|
91
|
+
<span
|
|
92
|
+
aria-disabled="true"
|
|
93
|
+
className={cn(tabClass, 'text-muted-foreground opacity-50')}
|
|
94
|
+
>
|
|
95
|
+
{content}
|
|
96
|
+
</span>
|
|
97
|
+
) : (
|
|
98
|
+
<LinkEl
|
|
99
|
+
{...destination(item.href)}
|
|
100
|
+
aria-current={item.active ? 'page' : undefined}
|
|
101
|
+
className={cn(
|
|
102
|
+
tabClass,
|
|
103
|
+
item.active
|
|
104
|
+
? 'text-primary'
|
|
105
|
+
: 'text-muted-foreground hover:text-foreground'
|
|
106
|
+
)}
|
|
107
|
+
>
|
|
108
|
+
{content}
|
|
109
|
+
</LinkEl>
|
|
110
|
+
)}
|
|
111
|
+
</li>
|
|
112
|
+
);
|
|
113
|
+
})}
|
|
114
|
+
</ul>
|
|
115
|
+
</nav>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './BottomNav';
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { render, screen, waitFor, within } from '@testing-library/react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { axe } from 'jest-axe';
|
|
4
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
5
|
+
import { Calendar } from './Calendar';
|
|
6
|
+
|
|
7
|
+
const TODAY = '2026-11-13';
|
|
8
|
+
|
|
9
|
+
function setup(overrides: Partial<React.ComponentProps<typeof Calendar>> = {}) {
|
|
10
|
+
const onValueChange = vi.fn();
|
|
11
|
+
render(<Calendar today={TODAY} value="2026-11-13" onValueChange={onValueChange} {...overrides} />);
|
|
12
|
+
return { onValueChange };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function day(name: RegExp | string) {
|
|
16
|
+
return screen.getByRole('button', { name });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
describe('Calendar', () => {
|
|
20
|
+
it('renders a labelled month grid', () => {
|
|
21
|
+
setup();
|
|
22
|
+
expect(screen.getByRole('grid', { name: 'November 2026' })).toBeInTheDocument();
|
|
23
|
+
expect(screen.getByText('November 2026')).toBeInTheDocument();
|
|
24
|
+
expect(screen.getAllByRole('columnheader')).toHaveLength(7);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('marks the selected day and today', () => {
|
|
28
|
+
setup();
|
|
29
|
+
const selected = day(/Nov 13, 2026/);
|
|
30
|
+
expect(selected).toHaveAttribute('aria-current', 'date');
|
|
31
|
+
const cell = selected.closest('[role="gridcell"]');
|
|
32
|
+
expect(cell).toHaveAttribute('aria-selected', 'true');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('selects a day by click', async () => {
|
|
36
|
+
const user = userEvent.setup();
|
|
37
|
+
const { onValueChange } = setup();
|
|
38
|
+
await user.click(day(/Nov 20, 2026/));
|
|
39
|
+
expect(onValueChange).toHaveBeenCalledWith('2026-11-20');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('works uncontrolled', async () => {
|
|
43
|
+
const user = userEvent.setup();
|
|
44
|
+
const onValueChange = vi.fn();
|
|
45
|
+
render(<Calendar defaultValue="2026-11-13" today={TODAY} onValueChange={onValueChange} />);
|
|
46
|
+
await user.click(day(/Nov 5, 2026/));
|
|
47
|
+
expect(onValueChange).toHaveBeenCalledWith('2026-11-05');
|
|
48
|
+
expect(day(/Nov 5, 2026/).closest('[role="gridcell"]')).toHaveAttribute(
|
|
49
|
+
'aria-selected',
|
|
50
|
+
'true'
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('moves focus with every arrow key and selects with Enter', async () => {
|
|
55
|
+
const user = userEvent.setup();
|
|
56
|
+
const { onValueChange } = setup({ autoFocus: true });
|
|
57
|
+
|
|
58
|
+
await waitFor(() => expect(day(/Nov 13, 2026/)).toHaveFocus());
|
|
59
|
+
|
|
60
|
+
await user.keyboard('{ArrowRight}');
|
|
61
|
+
expect(day(/Nov 14, 2026/)).toHaveFocus();
|
|
62
|
+
await user.keyboard('{ArrowDown}');
|
|
63
|
+
expect(day(/Nov 21, 2026/)).toHaveFocus();
|
|
64
|
+
await user.keyboard('{ArrowLeft}');
|
|
65
|
+
expect(day(/Nov 20, 2026/)).toHaveFocus();
|
|
66
|
+
await user.keyboard('{ArrowUp}');
|
|
67
|
+
expect(day(/Nov 13, 2026/)).toHaveFocus();
|
|
68
|
+
await user.keyboard('{Home}');
|
|
69
|
+
expect(day(/Nov 8, 2026/)).toHaveFocus();
|
|
70
|
+
await user.keyboard('{End}');
|
|
71
|
+
expect(day(/Nov 14, 2026/)).toHaveFocus();
|
|
72
|
+
await user.keyboard('{PageDown}');
|
|
73
|
+
expect(day(/Dec 14, 2026/)).toHaveFocus();
|
|
74
|
+
await user.keyboard('{PageUp}');
|
|
75
|
+
expect(day(/Nov 14, 2026/)).toHaveFocus();
|
|
76
|
+
|
|
77
|
+
await user.keyboard('{Enter}');
|
|
78
|
+
expect(onValueChange).toHaveBeenCalledWith('2026-11-14');
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('pages months with the header buttons and clamps the day', async () => {
|
|
82
|
+
const user = userEvent.setup();
|
|
83
|
+
setup({ value: '2026-01-31' });
|
|
84
|
+
await user.click(screen.getByRole('button', { name: 'Next month' }));
|
|
85
|
+
expect(screen.getByRole('grid', { name: 'February 2026' })).toBeInTheDocument();
|
|
86
|
+
expect(day(/Feb 28, 2026/)).toBeInTheDocument();
|
|
87
|
+
await user.click(screen.getByRole('button', { name: 'Previous month' }));
|
|
88
|
+
expect(screen.getByRole('grid', { name: 'January 2026' })).toBeInTheDocument();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('disables days outside min and max', async () => {
|
|
92
|
+
const user = userEvent.setup();
|
|
93
|
+
const { onValueChange } = setup({ min: '2026-11-10', max: '2026-11-20' });
|
|
94
|
+
|
|
95
|
+
const blocked = day(/Nov 5, 2026/);
|
|
96
|
+
expect(blocked).toHaveAttribute('aria-disabled', 'true');
|
|
97
|
+
await user.click(blocked);
|
|
98
|
+
expect(onValueChange).not.toHaveBeenCalled();
|
|
99
|
+
|
|
100
|
+
await user.click(day(/Nov 15, 2026/));
|
|
101
|
+
expect(onValueChange).toHaveBeenCalledWith('2026-11-15');
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('honours isDateDisabled', async () => {
|
|
105
|
+
const user = userEvent.setup();
|
|
106
|
+
const { onValueChange } = setup({ isDateDisabled: (key) => key === '2026-11-13' });
|
|
107
|
+
const blocked = day(/Nov 13, 2026/);
|
|
108
|
+
expect(blocked).toHaveAttribute('aria-disabled', 'true');
|
|
109
|
+
await user.click(blocked);
|
|
110
|
+
expect(onValueChange).not.toHaveBeenCalled();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('does nothing while disabled', async () => {
|
|
114
|
+
const user = userEvent.setup();
|
|
115
|
+
const { onValueChange } = setup({ disabled: true });
|
|
116
|
+
await user.click(day(/Nov 15, 2026/));
|
|
117
|
+
expect(onValueChange).not.toHaveBeenCalled();
|
|
118
|
+
expect(screen.getByRole('button', { name: 'Next month' })).toBeDisabled();
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('starts the week on Monday when asked', () => {
|
|
122
|
+
setup({ weekStartsOn: 1 });
|
|
123
|
+
const headers = screen.getAllByRole('columnheader').map((node) => node.textContent);
|
|
124
|
+
expect(headers[0]).toBe('Mon');
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('hides outside days on request', () => {
|
|
128
|
+
const { unmount } = render(
|
|
129
|
+
<Calendar today={TODAY} value="2026-12-15" showOutsideDays={false} onValueChange={() => {}} />
|
|
130
|
+
);
|
|
131
|
+
// December 2026 starts on a Tuesday, so the first cells are November days.
|
|
132
|
+
expect(screen.queryByRole('button', { name: /Nov 30, 2026/ })).not.toBeInTheDocument();
|
|
133
|
+
unmount();
|
|
134
|
+
|
|
135
|
+
render(<Calendar today={TODAY} value="2026-12-15" onValueChange={() => {}} />);
|
|
136
|
+
expect(screen.getByRole('button', { name: /Nov 30, 2026/ })).toBeInTheDocument();
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('has no accessibility violations', async () => {
|
|
140
|
+
const { container } = render(
|
|
141
|
+
<Calendar today={TODAY} value="2026-11-13" onValueChange={() => {}} />
|
|
142
|
+
);
|
|
143
|
+
expect(await axe(container)).toHaveNoViolations();
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
describe('Calendar edge cases', () => {
|
|
148
|
+
it('accepts an aria-label for the grid', () => {
|
|
149
|
+
render(
|
|
150
|
+
<Calendar
|
|
151
|
+
today={TODAY}
|
|
152
|
+
value="2026-11-13"
|
|
153
|
+
aria-label="Choose a start date"
|
|
154
|
+
onValueChange={() => {}}
|
|
155
|
+
/>
|
|
156
|
+
);
|
|
157
|
+
expect(screen.getByRole('grid', { name: 'Choose a start date' })).toBeInTheDocument();
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it('follows a controlled value into its month', async () => {
|
|
161
|
+
const { rerender } = render(
|
|
162
|
+
<Calendar today={TODAY} value="2026-11-13" onValueChange={() => {}} />
|
|
163
|
+
);
|
|
164
|
+
expect(screen.getByRole('grid', { name: 'November 2026' })).toBeInTheDocument();
|
|
165
|
+
|
|
166
|
+
rerender(<Calendar today={TODAY} value="2027-02-10" onValueChange={() => {}} />);
|
|
167
|
+
await waitFor(() =>
|
|
168
|
+
expect(screen.getByRole('grid', { name: 'February 2027' })).toBeInTheDocument()
|
|
169
|
+
);
|
|
170
|
+
expect(day(/Feb 10, 2027/)).toHaveAttribute('tabindex', '0');
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('selects an outside day and follows it into the previous month', async () => {
|
|
174
|
+
const user = userEvent.setup();
|
|
175
|
+
const onValueChange = vi.fn();
|
|
176
|
+
render(<Calendar defaultValue="2026-12-15" today={TODAY} onValueChange={onValueChange} />);
|
|
177
|
+
|
|
178
|
+
await user.click(day(/Nov 30, 2026/));
|
|
179
|
+
expect(onValueChange).toHaveBeenCalledWith('2026-11-30');
|
|
180
|
+
await waitFor(() =>
|
|
181
|
+
expect(screen.getByRole('grid', { name: 'November 2026' })).toBeInTheDocument()
|
|
182
|
+
);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it('keeps exactly one tab stop and moves it with the keyboard', async () => {
|
|
186
|
+
const user = userEvent.setup();
|
|
187
|
+
render(<Calendar today={TODAY} value="2026-11-13" autoFocus onValueChange={() => {}} />);
|
|
188
|
+
await waitFor(() => expect(day(/Nov 13, 2026/)).toHaveFocus());
|
|
189
|
+
|
|
190
|
+
const tabbable = () =>
|
|
191
|
+
within(screen.getByRole('grid'))
|
|
192
|
+
.getAllByRole('button')
|
|
193
|
+
.filter((button) => button.tabIndex === 0);
|
|
194
|
+
expect(tabbable()).toHaveLength(1);
|
|
195
|
+
expect(tabbable()[0]).toHaveAttribute('data-date', '2026-11-13');
|
|
196
|
+
|
|
197
|
+
await user.keyboard('{ArrowRight}');
|
|
198
|
+
expect(tabbable()).toHaveLength(1);
|
|
199
|
+
expect(tabbable()[0]).toHaveAttribute('data-date', '2026-11-14');
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it('moves focus from the keyboard without autoFocus', async () => {
|
|
203
|
+
const user = userEvent.setup();
|
|
204
|
+
render(<Calendar today={TODAY} value="2026-11-13" onValueChange={() => {}} />);
|
|
205
|
+
|
|
206
|
+
// A keyboard user tabs into the grid rather than relying on autoFocus.
|
|
207
|
+
day(/Nov 13, 2026/).focus();
|
|
208
|
+
await user.keyboard('{ArrowRight}');
|
|
209
|
+
expect(day(/Nov 14, 2026/)).toHaveFocus();
|
|
210
|
+
await user.keyboard('{ArrowDown}');
|
|
211
|
+
expect(day(/Nov 21, 2026/)).toHaveFocus();
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it('selects with Space', async () => {
|
|
215
|
+
const user = userEvent.setup();
|
|
216
|
+
const onValueChange = vi.fn();
|
|
217
|
+
render(
|
|
218
|
+
<Calendar today={TODAY} value="2026-11-13" autoFocus onValueChange={onValueChange} />
|
|
219
|
+
);
|
|
220
|
+
await waitFor(() => expect(day(/Nov 13, 2026/)).toHaveFocus());
|
|
221
|
+
|
|
222
|
+
await user.keyboard(' ');
|
|
223
|
+
expect(onValueChange).toHaveBeenCalledWith('2026-11-13');
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
it('treats min and max as inclusive', async () => {
|
|
227
|
+
const user = userEvent.setup();
|
|
228
|
+
const onValueChange = vi.fn();
|
|
229
|
+
render(
|
|
230
|
+
<Calendar
|
|
231
|
+
today={TODAY}
|
|
232
|
+
value="2026-11-13"
|
|
233
|
+
min="2026-11-13"
|
|
234
|
+
max="2026-11-15"
|
|
235
|
+
onValueChange={onValueChange}
|
|
236
|
+
/>
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
expect(day(/Nov 13, 2026/)).not.toHaveAttribute('aria-disabled');
|
|
240
|
+
expect(day(/Nov 15, 2026/)).not.toHaveAttribute('aria-disabled');
|
|
241
|
+
expect(day(/Nov 12, 2026/)).toHaveAttribute('aria-disabled', 'true');
|
|
242
|
+
expect(day(/Nov 16, 2026/)).toHaveAttribute('aria-disabled', 'true');
|
|
243
|
+
|
|
244
|
+
await user.click(day(/Nov 15, 2026/));
|
|
245
|
+
expect(onValueChange).toHaveBeenCalledWith('2026-11-15');
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it('clamps the day when paging months from the 31st', async () => {
|
|
249
|
+
const user = userEvent.setup();
|
|
250
|
+
const onValueChange = vi.fn();
|
|
251
|
+
render(
|
|
252
|
+
<Calendar today="2026-01-31" value="2026-01-31" autoFocus onValueChange={onValueChange} />
|
|
253
|
+
);
|
|
254
|
+
await waitFor(() => expect(day(/Jan 31, 2026/)).toHaveFocus());
|
|
255
|
+
|
|
256
|
+
await user.keyboard('{PageDown}');
|
|
257
|
+
await waitFor(() => expect(day(/Feb 28, 2026/)).toHaveFocus());
|
|
258
|
+
await user.keyboard('{Enter}');
|
|
259
|
+
expect(onValueChange).toHaveBeenCalledWith('2026-02-28');
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it('renders a usable grid for an unparseable value', () => {
|
|
263
|
+
render(<Calendar today={TODAY} value="not-a-date" onValueChange={() => {}} />);
|
|
264
|
+
expect(screen.getByRole('grid', { name: 'January 1970' })).toBeInTheDocument();
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
it('marks every day unavailable when disabled', async () => {
|
|
268
|
+
const user = userEvent.setup();
|
|
269
|
+
const onValueChange = vi.fn();
|
|
270
|
+
render(
|
|
271
|
+
<Calendar today={TODAY} value="2026-11-13" disabled onValueChange={onValueChange} />
|
|
272
|
+
);
|
|
273
|
+
expect(day(/Nov 15, 2026/)).toHaveAttribute('aria-disabled', 'true');
|
|
274
|
+
await user.click(day(/Nov 15, 2026/));
|
|
275
|
+
expect(onValueChange).not.toHaveBeenCalled();
|
|
276
|
+
});
|
|
277
|
+
});
|