@slipstream-ui/core 0.8.0 → 0.10.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 +203 -8
- package/dist/index.d.ts +203 -8
- package/dist/index.js +1737 -965
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1729 -961
- package/dist/index.mjs.map +1 -1
- package/dist/manifests/accordion.manifest.json +2 -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 +1 -1
- package/dist/manifests/autocomplete.manifest.json +1 -1
- package/dist/manifests/avatar.manifest.json +1 -1
- package/dist/manifests/badge.manifest.json +1 -1
- package/dist/manifests/block.manifest.json +1 -1
- package/dist/manifests/bottom-nav.manifest.json +1 -1
- 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 +1 -1
- 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 +13 -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 +1 -1
- package/dist/manifests/multi-select.manifest.json +1 -1
- package/dist/manifests/newsletter.manifest.json +1 -1
- package/dist/manifests/page-header.manifest.json +1 -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 +8 -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 +12 -1
- package/dist/src/components/accordion/Accordion.js +26 -19
- package/dist/src/components/accordion/Accordion.js.map +1 -1
- package/dist/src/components/accordion/Accordion.mjs +26 -19
- 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/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/checkbox/Checkbox.js +1 -1
- package/dist/src/components/checkbox/Checkbox.js.map +1 -1
- package/dist/src/components/checkbox/Checkbox.mjs +1 -1
- package/dist/src/components/checkbox/Checkbox.mjs.map +1 -1
- 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.js +2 -1
- package/dist/src/components/drawer/Drawer.js.map +1 -1
- package/dist/src/components/drawer/Drawer.mjs +2 -1
- package/dist/src/components/drawer/Drawer.mjs.map +1 -1
- package/dist/src/components/filter-chips/FilterChips.d.ts +4 -0
- package/dist/src/components/filter-chips/FilterChips.js +35 -4
- package/dist/src/components/filter-chips/FilterChips.js.map +1 -1
- package/dist/src/components/filter-chips/FilterChips.mjs +35 -4
- package/dist/src/components/filter-chips/FilterChips.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/page-header/PageHeader.js +1 -1
- package/dist/src/components/page-header/PageHeader.js.map +1 -1
- package/dist/src/components/page-header/PageHeader.mjs +1 -1
- 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/radio/Radio.js +1 -1
- package/dist/src/components/radio/Radio.js.map +1 -1
- package/dist/src/components/radio/Radio.mjs +1 -1
- package/dist/src/components/radio/Radio.mjs.map +1 -1
- package/dist/src/components/range-slider/RangeSlider.js +3 -3
- package/dist/src/components/range-slider/RangeSlider.js.map +1 -1
- package/dist/src/components/range-slider/RangeSlider.mjs +3 -3
- package/dist/src/components/range-slider/RangeSlider.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/select/Select.d.ts +10 -0
- package/dist/src/components/select/Select.js +2 -2
- package/dist/src/components/select/Select.js.map +1 -1
- package/dist/src/components/select/Select.mjs +2 -2
- package/dist/src/components/select/Select.mjs.map +1 -1
- 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/components/timeline/Timeline.js +17 -13
- package/dist/src/components/timeline/Timeline.js.map +1 -1
- package/dist/src/components/timeline/Timeline.mjs +17 -13
- package/dist/src/components/timeline/Timeline.mjs.map +1 -1
- package/dist/src/components/tooltip/Tooltip.d.ts +5 -0
- package/dist/src/components/tooltip/Tooltip.js +9 -2
- package/dist/src/components/tooltip/Tooltip.js.map +1 -1
- package/dist/src/components/tooltip/Tooltip.mjs +9 -2
- package/dist/src/components/tooltip/Tooltip.mjs.map +1 -1
- package/dist/src/index.d.ts +3 -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 +1 -1
- package/src/components/accordion/Accordion.test.tsx +14 -3
- package/src/components/accordion/Accordion.tsx +34 -21
- 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/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/checkbox/Checkbox.tsx +1 -1
- 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 +12 -0
- package/src/components/drawer/Drawer.tsx +8 -1
- package/src/components/filter-chips/FilterChips.test.tsx +11 -0
- package/src/components/filter-chips/FilterChips.tsx +40 -4
- 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/page-header/PageHeader.tsx +1 -1
- package/src/components/popover/Popover.test.tsx +307 -3
- package/src/components/popover/Popover.tsx +228 -91
- package/src/components/radio/Radio.tsx +1 -1
- package/src/components/range-slider/RangeSlider.tsx +3 -3
- package/src/components/section-heading/SectionHeading.tsx +1 -1
- package/src/components/select/Select.test.tsx +14 -0
- package/src/components/select/Select.tsx +7 -2
- 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/components/timeline/Timeline.test.tsx +11 -0
- package/src/components/timeline/Timeline.tsx +13 -2
- package/src/components/tooltip/Tooltip.test.tsx +15 -0
- package/src/components/tooltip/Tooltip.tsx +19 -2
- package/src/index.ts +3 -0
- package/src/manifests/accordion.manifest.json +2 -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 +1 -1
- package/src/manifests/autocomplete.manifest.json +1 -1
- package/src/manifests/avatar.manifest.json +1 -1
- package/src/manifests/badge.manifest.json +1 -1
- package/src/manifests/block.manifest.json +1 -1
- package/src/manifests/bottom-nav.manifest.json +1 -1
- 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 +1 -1
- 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 +13 -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 +1 -1
- package/src/manifests/multi-select.manifest.json +1 -1
- package/src/manifests/newsletter.manifest.json +1 -1
- package/src/manifests/page-header.manifest.json +1 -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 +8 -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 +12 -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
|
@@ -0,0 +1,223 @@
|
|
|
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 { DatePickerPopover } from './DatePickerPopover';
|
|
6
|
+
|
|
7
|
+
const TODAY = '2026-11-13';
|
|
8
|
+
|
|
9
|
+
function setup(props: Partial<React.ComponentProps<typeof DatePickerPopover>> = {}) {
|
|
10
|
+
const onValueChange = vi.fn();
|
|
11
|
+
render(
|
|
12
|
+
<DatePickerPopover
|
|
13
|
+
value="2026-11-13"
|
|
14
|
+
today={TODAY}
|
|
15
|
+
onValueChange={onValueChange}
|
|
16
|
+
{...props}
|
|
17
|
+
/>
|
|
18
|
+
);
|
|
19
|
+
return { onValueChange };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
describe('DatePickerPopover', () => {
|
|
23
|
+
it('shows the formatted selected date', () => {
|
|
24
|
+
setup();
|
|
25
|
+
expect(screen.getByRole('button', { name: /Nov 13, 2026/ })).toBeInTheDocument();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('shows a placeholder when empty', () => {
|
|
29
|
+
render(<DatePickerPopover today={TODAY} onValueChange={() => {}} />);
|
|
30
|
+
expect(screen.getByRole('button', { name: 'Pick a date' })).toBeInTheDocument();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('opens a calendar panel and focuses the selected day', async () => {
|
|
34
|
+
const user = userEvent.setup();
|
|
35
|
+
setup();
|
|
36
|
+
await user.click(screen.getByRole('button', { name: /Nov 13, 2026/ }));
|
|
37
|
+
|
|
38
|
+
expect(await screen.findByRole('grid', { name: 'November 2026' })).toBeInTheDocument();
|
|
39
|
+
await waitFor(() =>
|
|
40
|
+
expect(document.activeElement?.getAttribute('data-date')).toBe('2026-11-13')
|
|
41
|
+
);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('chooses a day, closes and restores focus to the trigger', async () => {
|
|
45
|
+
const user = userEvent.setup();
|
|
46
|
+
const { onValueChange } = setup();
|
|
47
|
+
await user.click(screen.getByRole('button', { name: /Nov 13, 2026/ }));
|
|
48
|
+
await screen.findByRole('grid');
|
|
49
|
+
|
|
50
|
+
await user.click(within(screen.getByRole('grid')).getByRole('button', { name: /Nov 20, 2026/ }));
|
|
51
|
+
expect(onValueChange).toHaveBeenCalledWith('2026-11-20');
|
|
52
|
+
await waitFor(() => expect(screen.queryByRole('grid')).not.toBeInTheDocument());
|
|
53
|
+
expect(screen.getByRole('button', { name: /Nov 13, 2026/ })).toHaveFocus();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('selects with the keyboard', async () => {
|
|
57
|
+
const user = userEvent.setup();
|
|
58
|
+
const { onValueChange } = setup();
|
|
59
|
+
await user.click(screen.getByRole('button', { name: /Nov 13, 2026/ }));
|
|
60
|
+
await screen.findByRole('grid');
|
|
61
|
+
await waitFor(() =>
|
|
62
|
+
expect(document.activeElement?.getAttribute('data-date')).toBe('2026-11-13')
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
await user.keyboard('{ArrowRight}');
|
|
66
|
+
await user.keyboard('{Enter}');
|
|
67
|
+
expect(onValueChange).toHaveBeenCalledWith('2026-11-14');
|
|
68
|
+
await waitFor(() => expect(screen.queryByRole('grid')).not.toBeInTheDocument());
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('blocks days outside min and max', async () => {
|
|
72
|
+
const user = userEvent.setup();
|
|
73
|
+
const { onValueChange } = setup({ min: '2026-11-13', max: '2026-11-20' });
|
|
74
|
+
await user.click(screen.getByRole('button', { name: /Nov 13, 2026/ }));
|
|
75
|
+
await screen.findByRole('grid');
|
|
76
|
+
|
|
77
|
+
const grid = within(screen.getByRole('grid'));
|
|
78
|
+
const early = grid.getByRole('button', { name: /Nov 10, 2026/ });
|
|
79
|
+
expect(early).toHaveAttribute('aria-disabled', 'true');
|
|
80
|
+
await user.click(early);
|
|
81
|
+
expect(onValueChange).not.toHaveBeenCalled();
|
|
82
|
+
|
|
83
|
+
await user.click(grid.getByRole('button', { name: /Nov 18, 2026/ }));
|
|
84
|
+
expect(onValueChange).toHaveBeenCalledWith('2026-11-18');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('closes on Escape', async () => {
|
|
88
|
+
const user = userEvent.setup();
|
|
89
|
+
setup();
|
|
90
|
+
await user.click(screen.getByRole('button', { name: /Nov 13, 2026/ }));
|
|
91
|
+
await screen.findByRole('grid');
|
|
92
|
+
await user.keyboard('{Escape}');
|
|
93
|
+
await waitFor(() => expect(screen.queryByRole('grid')).not.toBeInTheDocument());
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('submits through a hidden input when named', () => {
|
|
97
|
+
const { container } = render(
|
|
98
|
+
<form>
|
|
99
|
+
<DatePickerPopover name="date" value="2026-11-13" today={TODAY} onValueChange={() => {}} />
|
|
100
|
+
</form>
|
|
101
|
+
);
|
|
102
|
+
const input = container.querySelector('input[name="date"]') as HTMLInputElement;
|
|
103
|
+
expect(input.value).toBe('2026-11-13');
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('is not interactive when disabled', async () => {
|
|
107
|
+
const user = userEvent.setup();
|
|
108
|
+
setup({ disabled: true });
|
|
109
|
+
const trigger = screen.getByRole('button', { name: /Nov 13, 2026/ });
|
|
110
|
+
expect(trigger).toBeDisabled();
|
|
111
|
+
await user.click(trigger);
|
|
112
|
+
expect(screen.queryByRole('grid')).not.toBeInTheDocument();
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('has no accessibility violations', async () => {
|
|
116
|
+
const user = userEvent.setup();
|
|
117
|
+
const { container } = render(
|
|
118
|
+
<DatePickerPopover today={TODAY} value="2026-11-13" onValueChange={() => {}} />
|
|
119
|
+
);
|
|
120
|
+
await user.click(screen.getByRole('button', { name: /Nov 13, 2026/ }));
|
|
121
|
+
await screen.findByRole('grid');
|
|
122
|
+
expect(await axe(container)).toHaveNoViolations();
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
describe('DatePickerPopover field wiring', () => {
|
|
127
|
+
it('marks the hidden input required and keeps the ISO value', () => {
|
|
128
|
+
const { container } = render(
|
|
129
|
+
<form>
|
|
130
|
+
<DatePickerPopover
|
|
131
|
+
name="start"
|
|
132
|
+
required
|
|
133
|
+
value="2026-11-13"
|
|
134
|
+
today={TODAY}
|
|
135
|
+
onValueChange={() => {}}
|
|
136
|
+
/>
|
|
137
|
+
</form>
|
|
138
|
+
);
|
|
139
|
+
const input = container.querySelector('input[name="start"]') as HTMLInputElement;
|
|
140
|
+
expect(input.value).toBe('2026-11-13');
|
|
141
|
+
expect(input.required).toBe(true);
|
|
142
|
+
expect(input.type).toBe('hidden');
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('renders no hidden input without a name', () => {
|
|
146
|
+
const { container } = render(
|
|
147
|
+
<DatePickerPopover value="2026-11-13" today={TODAY} onValueChange={() => {}} />
|
|
148
|
+
);
|
|
149
|
+
expect(container.querySelector('input[type="hidden"]')).toBeNull();
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('passes id and aria-label through and labels the dialog', async () => {
|
|
153
|
+
const user = userEvent.setup();
|
|
154
|
+
render(
|
|
155
|
+
<DatePickerPopover
|
|
156
|
+
id="start-date"
|
|
157
|
+
aria-label="Start date"
|
|
158
|
+
value="2026-11-13"
|
|
159
|
+
today={TODAY}
|
|
160
|
+
onValueChange={() => {}}
|
|
161
|
+
/>
|
|
162
|
+
);
|
|
163
|
+
const trigger = screen.getByRole('button', { name: 'Start date' });
|
|
164
|
+
expect(trigger).toHaveAttribute('id', 'start-date');
|
|
165
|
+
|
|
166
|
+
await user.click(trigger);
|
|
167
|
+
const dialog = await screen.findByRole('dialog');
|
|
168
|
+
expect(dialog).toHaveAttribute('aria-labelledby', 'start-date');
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it('returns focus to the trigger on Escape', async () => {
|
|
172
|
+
const user = userEvent.setup();
|
|
173
|
+
setup();
|
|
174
|
+
const trigger = screen.getByRole('button', { name: /Nov 13, 2026/ });
|
|
175
|
+
await user.click(trigger);
|
|
176
|
+
await screen.findByRole('grid');
|
|
177
|
+
|
|
178
|
+
await user.keyboard('{Escape}');
|
|
179
|
+
await waitFor(() => expect(screen.queryByRole('grid')).not.toBeInTheDocument());
|
|
180
|
+
expect(trigger).toHaveFocus();
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it('honours the requested side', async () => {
|
|
184
|
+
const user = userEvent.setup();
|
|
185
|
+
vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockImplementation(function (
|
|
186
|
+
this: HTMLElement
|
|
187
|
+
) {
|
|
188
|
+
const base = {
|
|
189
|
+
top: 0,
|
|
190
|
+
left: 0,
|
|
191
|
+
right: 0,
|
|
192
|
+
bottom: 0,
|
|
193
|
+
width: 0,
|
|
194
|
+
height: 0,
|
|
195
|
+
x: 0,
|
|
196
|
+
y: 0,
|
|
197
|
+
toJSON: () => ({}),
|
|
198
|
+
} as DOMRect;
|
|
199
|
+
if (this.getAttribute('role') === 'dialog') return { ...base, width: 288, height: 320 };
|
|
200
|
+
return { ...base, top: 500, left: 40, width: 240, height: 40 };
|
|
201
|
+
});
|
|
202
|
+
setup({ side: 'top' });
|
|
203
|
+
|
|
204
|
+
await user.click(screen.getByRole('button', { name: /Nov 13, 2026/ }));
|
|
205
|
+
expect(await screen.findByRole('dialog')).toHaveAttribute('data-side', 'top');
|
|
206
|
+
vi.restoreAllMocks();
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it('treats min and max as inclusive', async () => {
|
|
210
|
+
const user = userEvent.setup();
|
|
211
|
+
const { onValueChange } = setup({ min: '2026-11-13', max: '2026-11-14' });
|
|
212
|
+
await user.click(screen.getByRole('button', { name: /Nov 13, 2026/ }));
|
|
213
|
+
const grid = within(await screen.findByRole('grid'));
|
|
214
|
+
|
|
215
|
+
expect(grid.getByRole('button', { name: /Nov 13, 2026/ })).not.toHaveAttribute(
|
|
216
|
+
'aria-disabled'
|
|
217
|
+
);
|
|
218
|
+
const last = grid.getByRole('button', { name: /Nov 14, 2026/ });
|
|
219
|
+
expect(last).not.toHaveAttribute('aria-disabled');
|
|
220
|
+
await user.click(last);
|
|
221
|
+
expect(onValueChange).toHaveBeenCalledWith('2026-11-14');
|
|
222
|
+
});
|
|
223
|
+
});
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { cn } from '../../utils/cn';
|
|
5
|
+
import { formatDateLabel } from '../../utils/date';
|
|
6
|
+
import { buttonVariants } from '../button';
|
|
7
|
+
import { Calendar } from '../calendar';
|
|
8
|
+
import { Popover, PopoverContent, PopoverTrigger } from '../popover';
|
|
9
|
+
|
|
10
|
+
export type DatePickerPopoverProps = {
|
|
11
|
+
/** Selected date as an ISO key (`YYYY-MM-DD`). */
|
|
12
|
+
value?: string;
|
|
13
|
+
/** Called with the ISO key when a day is chosen. */
|
|
14
|
+
onValueChange?: (value: string) => void;
|
|
15
|
+
/** Earliest selectable day, inclusive. */
|
|
16
|
+
min?: string;
|
|
17
|
+
/** Latest selectable day, inclusive. */
|
|
18
|
+
max?: string;
|
|
19
|
+
/** Override "today" for deterministic rendering. */
|
|
20
|
+
today?: string;
|
|
21
|
+
locale?: string;
|
|
22
|
+
weekStartsOn?: 0 | 1;
|
|
23
|
+
/** Text shown before a date is chosen. */
|
|
24
|
+
placeholder?: string;
|
|
25
|
+
/** Renders a hidden input so the value posts with a native form. */
|
|
26
|
+
name?: string;
|
|
27
|
+
required?: boolean;
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
/** Preferred side of the field; flips when it cannot fit. */
|
|
30
|
+
side?: 'top' | 'right' | 'bottom' | 'left';
|
|
31
|
+
align?: 'start' | 'center' | 'end';
|
|
32
|
+
id?: string;
|
|
33
|
+
className?: string;
|
|
34
|
+
'aria-label'?: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Date field with a month-grid panel. Values stay ISO `YYYY-MM-DD` strings, so
|
|
39
|
+
* a browser in a different zone cannot shift the chosen day.
|
|
40
|
+
*/
|
|
41
|
+
const DatePickerPopover = React.forwardRef<HTMLButtonElement, DatePickerPopoverProps>(
|
|
42
|
+
(
|
|
43
|
+
{
|
|
44
|
+
value,
|
|
45
|
+
onValueChange,
|
|
46
|
+
min,
|
|
47
|
+
max,
|
|
48
|
+
today,
|
|
49
|
+
locale = 'en-US',
|
|
50
|
+
weekStartsOn = 0,
|
|
51
|
+
placeholder = 'Pick a date',
|
|
52
|
+
name,
|
|
53
|
+
required,
|
|
54
|
+
disabled,
|
|
55
|
+
side = 'bottom',
|
|
56
|
+
align = 'start',
|
|
57
|
+
id,
|
|
58
|
+
className,
|
|
59
|
+
'aria-label': ariaLabel,
|
|
60
|
+
},
|
|
61
|
+
ref
|
|
62
|
+
) => {
|
|
63
|
+
const [open, setOpen] = React.useState(false);
|
|
64
|
+
const triggerRef = React.useRef<HTMLButtonElement | null>(null);
|
|
65
|
+
const setTriggerRef = React.useCallback(
|
|
66
|
+
(node: HTMLButtonElement | null) => {
|
|
67
|
+
triggerRef.current = node;
|
|
68
|
+
if (typeof ref === 'function') ref(node);
|
|
69
|
+
else if (ref) ref.current = node;
|
|
70
|
+
},
|
|
71
|
+
[ref]
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const label = value ? formatDateLabel(value, locale) : placeholder;
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<>
|
|
78
|
+
<Popover open={open} onOpenChange={setOpen}>
|
|
79
|
+
<PopoverTrigger
|
|
80
|
+
ref={setTriggerRef}
|
|
81
|
+
id={id}
|
|
82
|
+
disabled={disabled}
|
|
83
|
+
aria-label={ariaLabel}
|
|
84
|
+
className={cn(
|
|
85
|
+
buttonVariants({ variant: 'outline' }),
|
|
86
|
+
'w-full justify-start font-normal',
|
|
87
|
+
!value && 'text-muted-foreground',
|
|
88
|
+
className
|
|
89
|
+
)}
|
|
90
|
+
>
|
|
91
|
+
{label}
|
|
92
|
+
</PopoverTrigger>
|
|
93
|
+
<PopoverContent side={side} align={align} matchTriggerWidth className="w-auto p-3">
|
|
94
|
+
<Calendar
|
|
95
|
+
value={value}
|
|
96
|
+
min={min}
|
|
97
|
+
max={max}
|
|
98
|
+
today={today}
|
|
99
|
+
locale={locale}
|
|
100
|
+
weekStartsOn={weekStartsOn}
|
|
101
|
+
autoFocus
|
|
102
|
+
onValueChange={(next) => {
|
|
103
|
+
onValueChange?.(next);
|
|
104
|
+
setOpen(false);
|
|
105
|
+
triggerRef.current?.focus();
|
|
106
|
+
}}
|
|
107
|
+
/>
|
|
108
|
+
</PopoverContent>
|
|
109
|
+
</Popover>
|
|
110
|
+
{name ? <input type="hidden" name={name} value={value ?? ''} required={required} /> : null}
|
|
111
|
+
</>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
DatePickerPopover.displayName = 'DatePickerPopover';
|
|
116
|
+
|
|
117
|
+
export { DatePickerPopover };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DatePickerPopover';
|
|
@@ -67,6 +67,18 @@ describe('Drawer', () => {
|
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
describe('Drawer animate (optional slide)', () => {
|
|
70
|
+
it('dims the backdrop so content never flashes through on close', () => {
|
|
71
|
+
render(
|
|
72
|
+
<Drawer open animate onOpenChange={vi.fn()} title="Sliding" side="right">
|
|
73
|
+
body
|
|
74
|
+
</Drawer>
|
|
75
|
+
);
|
|
76
|
+
const backdrop = document.body.querySelector('.fixed.inset-0');
|
|
77
|
+
expect(backdrop).toHaveClass('bg-background/80');
|
|
78
|
+
expect(backdrop).toHaveClass('animate-in');
|
|
79
|
+
expect(backdrop?.className).toContain('fade-in-0');
|
|
80
|
+
});
|
|
81
|
+
|
|
70
82
|
it('applies side-aware slide-in classes when animate is on', () => {
|
|
71
83
|
render(
|
|
72
84
|
<Drawer open animate onOpenChange={vi.fn()} title="Sliding" side="left">
|
|
@@ -306,9 +306,16 @@ export function Drawer({
|
|
|
306
306
|
)
|
|
307
307
|
: undefined;
|
|
308
308
|
|
|
309
|
+
// The backdrop dims and fades with the panel. Without it the page showed
|
|
310
|
+
// through at full brightness while the drawer slid out, which read as a
|
|
311
|
+
// content flash during close.
|
|
312
|
+
const backdropMotion = animate
|
|
313
|
+
? cn('motion-reduce:animate-none', exiting ? 'animate-out fade-out-0' : 'animate-in fade-in-0')
|
|
314
|
+
: undefined;
|
|
315
|
+
|
|
309
316
|
return createPortal(
|
|
310
317
|
<div
|
|
311
|
-
className=
|
|
318
|
+
className={cn('fixed inset-0 z-50 bg-background/80', backdropMotion)}
|
|
312
319
|
onMouseDown={(event) => {
|
|
313
320
|
if (closeOnBackdrop && event.target === event.currentTarget) requestClose();
|
|
314
321
|
}}
|
|
@@ -19,6 +19,17 @@ describe('FilterChips', () => {
|
|
|
19
19
|
expect(onRemove).toHaveBeenCalled();
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
+
it('scales the chip set with size', () => {
|
|
23
|
+
const { rerender, container } = render(
|
|
24
|
+
<FilterChips size="sm" filters={[{ key: 'type', label: 'Type', value: 'PE' }]} />
|
|
25
|
+
);
|
|
26
|
+
expect(container.querySelector('span.text-xs')).not.toBeNull();
|
|
27
|
+
rerender(
|
|
28
|
+
<FilterChips size="lg" filters={[{ key: 'type', label: 'Type', value: 'PE' }]} />
|
|
29
|
+
);
|
|
30
|
+
expect(container.querySelector('span.text-base')).not.toBeNull();
|
|
31
|
+
});
|
|
32
|
+
|
|
22
33
|
it('renders a clear-all action', () => {
|
|
23
34
|
const onClearAll = vi.fn();
|
|
24
35
|
render(
|
|
@@ -17,6 +17,8 @@ export type FilterChip = {
|
|
|
17
17
|
export type FilterChipsProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
18
18
|
/** Active filters to render. */
|
|
19
19
|
filters: FilterChip[];
|
|
20
|
+
/** Chip scale. Default 'md'. */
|
|
21
|
+
size?: 'sm' | 'md' | 'lg';
|
|
20
22
|
/** Shows a clear-all action when provided. */
|
|
21
23
|
onClearAll?: () => void;
|
|
22
24
|
/** Label for the clear-all action. Default "Clear all". */
|
|
@@ -25,6 +27,28 @@ export type FilterChipsProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
25
27
|
emptyLabel?: string;
|
|
26
28
|
};
|
|
27
29
|
|
|
30
|
+
/** Literal size maps so the scanner keeps every chip utility. */
|
|
31
|
+
const CHIP_SIZES = {
|
|
32
|
+
sm: {
|
|
33
|
+
chip: 'gap-1 py-0.5 pl-2.5 pr-0.5 text-xs',
|
|
34
|
+
remove: 'p-0.5',
|
|
35
|
+
icon: 'h-3 w-3',
|
|
36
|
+
clear: 'text-xs',
|
|
37
|
+
},
|
|
38
|
+
md: {
|
|
39
|
+
chip: 'gap-1.5 py-1 pl-3 pr-1 text-sm',
|
|
40
|
+
remove: 'p-1',
|
|
41
|
+
icon: 'h-3.5 w-3.5',
|
|
42
|
+
clear: 'text-sm',
|
|
43
|
+
},
|
|
44
|
+
lg: {
|
|
45
|
+
chip: 'gap-2 py-1.5 pl-3.5 pr-1.5 text-base',
|
|
46
|
+
remove: 'p-1.5',
|
|
47
|
+
icon: 'h-4 w-4',
|
|
48
|
+
clear: 'text-base',
|
|
49
|
+
},
|
|
50
|
+
} as const;
|
|
51
|
+
|
|
28
52
|
/**
|
|
29
53
|
* Active-filter summary for list and dashboard pages. Each chip pairs a
|
|
30
54
|
* filter name with its current value and exposes a remove action; an optional
|
|
@@ -34,6 +58,7 @@ export type FilterChipsProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
34
58
|
export const FilterChips = React.forwardRef<HTMLDivElement, FilterChipsProps>(function FilterChips(
|
|
35
59
|
{
|
|
36
60
|
filters,
|
|
61
|
+
size = 'md',
|
|
37
62
|
onClearAll,
|
|
38
63
|
clearLabel = 'Clear all',
|
|
39
64
|
emptyLabel,
|
|
@@ -51,6 +76,8 @@ export const FilterChips = React.forwardRef<HTMLDivElement, FilterChipsProps>(fu
|
|
|
51
76
|
) : null;
|
|
52
77
|
}
|
|
53
78
|
|
|
79
|
+
const scale = CHIP_SIZES[size];
|
|
80
|
+
|
|
54
81
|
return (
|
|
55
82
|
<div
|
|
56
83
|
ref={ref}
|
|
@@ -62,7 +89,10 @@ export const FilterChips = React.forwardRef<HTMLDivElement, FilterChipsProps>(fu
|
|
|
62
89
|
{filters.map((filter) => (
|
|
63
90
|
<span
|
|
64
91
|
key={filter.key}
|
|
65
|
-
className=
|
|
92
|
+
className={cn(
|
|
93
|
+
'inline-flex max-w-full items-center rounded-full border border-border bg-muted/60',
|
|
94
|
+
scale.chip
|
|
95
|
+
)}
|
|
66
96
|
>
|
|
67
97
|
<span className="truncate">
|
|
68
98
|
<span className="text-muted-foreground">{filter.label}:</span>{' '}
|
|
@@ -73,9 +103,12 @@ export const FilterChips = React.forwardRef<HTMLDivElement, FilterChipsProps>(fu
|
|
|
73
103
|
type="button"
|
|
74
104
|
onClick={filter.onRemove}
|
|
75
105
|
aria-label={`Remove ${filter.label}${filter.value ? `: ${filter.value}` : ''}`}
|
|
76
|
-
className=
|
|
106
|
+
className={cn(
|
|
107
|
+
'rounded-full text-muted-foreground transition-colors hover:bg-background hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
|
|
108
|
+
scale.remove
|
|
109
|
+
)}
|
|
77
110
|
>
|
|
78
|
-
<svg aria-hidden="true" viewBox="0 0 20 20" className=
|
|
111
|
+
<svg aria-hidden="true" viewBox="0 0 20 20" className={scale.icon} fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round">
|
|
79
112
|
<path d="m5 5 10 10M15 5 5 15" />
|
|
80
113
|
</svg>
|
|
81
114
|
</button>
|
|
@@ -86,7 +119,10 @@ export const FilterChips = React.forwardRef<HTMLDivElement, FilterChipsProps>(fu
|
|
|
86
119
|
<button
|
|
87
120
|
type="button"
|
|
88
121
|
onClick={onClearAll}
|
|
89
|
-
className=
|
|
122
|
+
className={cn(
|
|
123
|
+
'rounded-sm px-1 font-medium text-primary underline-offset-4 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
|
|
124
|
+
scale.clear
|
|
125
|
+
)}
|
|
90
126
|
>
|
|
91
127
|
{clearLabel}
|
|
92
128
|
</button>
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
2
|
+
import { renderToString } from 'react-dom/server';
|
|
3
|
+
import { axe } from 'jest-axe';
|
|
4
|
+
import { describe, expect, it } from 'vitest';
|
|
5
|
+
import { Image } from './Image';
|
|
6
|
+
|
|
7
|
+
describe('Image', () => {
|
|
8
|
+
it('renders the primary source with intrinsic dimensions and lazy loading', () => {
|
|
9
|
+
render(<Image src="/event.jpg" alt="Fall Classic" />);
|
|
10
|
+
const img = screen.getByRole('img', { name: 'Fall Classic' });
|
|
11
|
+
expect(img).toHaveAttribute('src', '/event.jpg');
|
|
12
|
+
expect(img).toHaveAttribute('width', '1200');
|
|
13
|
+
expect(img).toHaveAttribute('height', '630');
|
|
14
|
+
expect(img).toHaveAttribute('loading', 'lazy');
|
|
15
|
+
expect(img).toHaveAttribute('fetchpriority', 'auto');
|
|
16
|
+
expect(img).toHaveAttribute('decoding', 'async');
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('loads eagerly only when priority is set', () => {
|
|
20
|
+
render(<Image src="/hero.jpg" alt="Hero" priority width={1600} height={900} />);
|
|
21
|
+
const img = screen.getByRole('img', { name: 'Hero' });
|
|
22
|
+
expect(img).toHaveAttribute('loading', 'eager');
|
|
23
|
+
expect(img).toHaveAttribute('fetchpriority', 'high');
|
|
24
|
+
expect(img).toHaveAttribute('width', '1600');
|
|
25
|
+
expect(img).toHaveAttribute('height', '900');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('falls back to fallbackSrc after the primary fails', () => {
|
|
29
|
+
render(
|
|
30
|
+
<Image src="/broken.jpg" fallbackSrc="/placeholder.svg" alt="Event" />
|
|
31
|
+
);
|
|
32
|
+
const img = screen.getByRole('img', { name: 'Event' });
|
|
33
|
+
fireEvent.error(img);
|
|
34
|
+
expect(screen.getByRole('img', { name: 'Event' })).toHaveAttribute(
|
|
35
|
+
'src',
|
|
36
|
+
'/placeholder.svg'
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('renders the fallback node when both URLs fail', () => {
|
|
41
|
+
render(
|
|
42
|
+
<Image
|
|
43
|
+
src="/broken.jpg"
|
|
44
|
+
fallbackSrc="/also-broken.svg"
|
|
45
|
+
alt="Event"
|
|
46
|
+
fallback={<span data-testid="fallback">No image</span>}
|
|
47
|
+
/>
|
|
48
|
+
);
|
|
49
|
+
fireEvent.error(screen.getByRole('img', { name: 'Event' }));
|
|
50
|
+
fireEvent.error(screen.getByRole('img', { name: 'Event' }));
|
|
51
|
+
expect(screen.queryByRole('img')).not.toBeInTheDocument();
|
|
52
|
+
expect(screen.getByTestId('fallback')).toHaveTextContent('No image');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('renders the fallback node on the first error without a fallbackSrc', () => {
|
|
56
|
+
render(
|
|
57
|
+
<Image src="/broken.jpg" alt="Event" fallback={<span data-testid="fallback">No image</span>} />
|
|
58
|
+
);
|
|
59
|
+
fireEvent.error(screen.getByRole('img', { name: 'Event' }));
|
|
60
|
+
expect(screen.getByTestId('fallback')).toBeInTheDocument();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('renders nothing when it fails without a fallback node', () => {
|
|
64
|
+
const { container } = render(<Image src="/broken.jpg" alt="Event" />);
|
|
65
|
+
fireEvent.error(screen.getByRole('img', { name: 'Event' }));
|
|
66
|
+
expect(container).toBeEmptyDOMElement();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('keeps dimensions in server-rendered markup', () => {
|
|
70
|
+
const html = renderToString(<Image src="/event.jpg" alt="Event" width={640} height={360} />);
|
|
71
|
+
expect(html).toContain('width="640"');
|
|
72
|
+
expect(html).toContain('height="360"');
|
|
73
|
+
expect(html).toContain('alt="Event"');
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('merges className and imgClassName', () => {
|
|
77
|
+
render(
|
|
78
|
+
<Image
|
|
79
|
+
src="/event.jpg"
|
|
80
|
+
alt="Event"
|
|
81
|
+
className="rounded-md"
|
|
82
|
+
imgClassName="object-cover"
|
|
83
|
+
/>
|
|
84
|
+
);
|
|
85
|
+
const img = screen.getByRole('img', { name: 'Event' });
|
|
86
|
+
expect(img).toHaveClass('rounded-md');
|
|
87
|
+
expect(img).toHaveClass('object-cover');
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('has no accessibility violations', async () => {
|
|
91
|
+
const { container } = render(<Image src="/event.jpg" alt="Fall Classic" />);
|
|
92
|
+
expect(await axe(container)).toHaveNoViolations();
|
|
93
|
+
});
|
|
94
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { cn } from '../../utils/cn';
|
|
5
|
+
|
|
6
|
+
export type ImageProps = {
|
|
7
|
+
/** Primary image URL. Hotlinked sources are expected. */
|
|
8
|
+
src: string;
|
|
9
|
+
/** Required: describes the image, not the component. */
|
|
10
|
+
alt: string;
|
|
11
|
+
/** Second chance before the fallback node (e.g. generated placeholder art). */
|
|
12
|
+
fallbackSrc?: string;
|
|
13
|
+
/** Rendered when every URL has failed (icon, initials, empty panel). */
|
|
14
|
+
fallback?: React.ReactNode;
|
|
15
|
+
/** Load eagerly and fetch at high priority for the LCP image. */
|
|
16
|
+
priority?: boolean;
|
|
17
|
+
/** Intrinsic width; always emitted so the browser reserves space. */
|
|
18
|
+
width?: number;
|
|
19
|
+
/** Intrinsic height; always emitted so the browser reserves space. */
|
|
20
|
+
height?: number;
|
|
21
|
+
/** Classes for the image; merged with imgClassName. */
|
|
22
|
+
className?: string;
|
|
23
|
+
/** Classes for the image when a consumer wants to keep them separate. */
|
|
24
|
+
imgClassName?: string;
|
|
25
|
+
style?: React.CSSProperties;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Resilient image: `src` -> `fallbackSrc` -> `fallback` node.
|
|
30
|
+
*
|
|
31
|
+
* Organizer images are hotlinked and occasionally 403, move, or die. Cards
|
|
32
|
+
* must never show a broken-image box or shift layout when that happens, so
|
|
33
|
+
* intrinsic dimensions are always rendered and only the priority image is
|
|
34
|
+
* eager.
|
|
35
|
+
*/
|
|
36
|
+
export function Image({
|
|
37
|
+
src,
|
|
38
|
+
alt,
|
|
39
|
+
fallbackSrc,
|
|
40
|
+
fallback,
|
|
41
|
+
priority = false,
|
|
42
|
+
width = 1200,
|
|
43
|
+
height = 630,
|
|
44
|
+
className,
|
|
45
|
+
imgClassName,
|
|
46
|
+
style,
|
|
47
|
+
}: ImageProps) {
|
|
48
|
+
const [stage, setStage] = React.useState<0 | 1 | 2>(0);
|
|
49
|
+
|
|
50
|
+
const onError = () => setStage((current) => (current === 0 && fallbackSrc ? 1 : 2));
|
|
51
|
+
const current = stage === 0 ? src : stage === 1 ? fallbackSrc : null;
|
|
52
|
+
|
|
53
|
+
if (!current || stage === 2) return <>{fallback ?? null}</>;
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<img
|
|
57
|
+
src={current}
|
|
58
|
+
alt={alt}
|
|
59
|
+
width={width}
|
|
60
|
+
height={height}
|
|
61
|
+
loading={priority ? 'eager' : 'lazy'}
|
|
62
|
+
fetchPriority={priority ? 'high' : 'auto'}
|
|
63
|
+
decoding="async"
|
|
64
|
+
className={cn(className, imgClassName)}
|
|
65
|
+
style={style}
|
|
66
|
+
onError={onError}
|
|
67
|
+
/>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
Image.displayName = 'Image';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Image, type ImageProps } from './Image';
|
|
@@ -8,7 +8,8 @@ describe('Link', () => {
|
|
|
8
8
|
render(<Link href="/docs">Docs</Link>);
|
|
9
9
|
const link = screen.getByRole('link', { name: 'Docs' });
|
|
10
10
|
expect(link).toHaveAttribute('href', '/docs');
|
|
11
|
-
expect(link).toHaveClass('text-primary');
|
|
11
|
+
expect(link).toHaveClass('text-primary-ink');
|
|
12
|
+
expect(link).not.toHaveClass('text-primary');
|
|
12
13
|
});
|
|
13
14
|
|
|
14
15
|
it('auto-detects external URLs and adds rel/noopener', () => {
|