@slipstream-ui/core 0.11.9 → 0.12.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 +254 -148
- package/dist/index.d.ts +254 -148
- package/dist/index.js +1582 -1156
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1577 -1156
- package/dist/index.mjs.map +1 -1
- package/dist/manifests/accordion.manifest.json +1 -1
- package/dist/manifests/alert.manifest.json +1 -1
- package/dist/manifests/announcement-bar.manifest.json +12 -1
- package/dist/manifests/app-shell.manifest.json +12 -1
- package/dist/manifests/applied-filters.manifest.json +1 -1
- package/dist/manifests/article-card.manifest.json +12 -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 +1 -1
- 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/consent-banner.manifest.json +130 -0
- package/dist/manifests/contact-strip.manifest.json +12 -1
- package/dist/manifests/container.manifest.json +1 -1
- package/dist/manifests/cover-image.manifest.json +1 -1
- package/dist/manifests/cta-section.manifest.json +1 -1
- package/dist/manifests/data-table.manifest.json +1 -1
- package/dist/manifests/date-picker-popover.manifest.json +1 -1
- 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 +12 -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 +12 -1
- package/dist/manifests/feature-grid.manifest.json +12 -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 +1 -1
- 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-toolbar.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/media-card.manifest.json +161 -0
- package/dist/manifests/menu.manifest.json +1 -1
- package/dist/manifests/metric-card.manifest.json +1 -1
- package/dist/manifests/month-schedule.manifest.json +217 -0
- 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 +1 -1
- 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 +7 -1
- 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 +1 -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 +12 -1
- package/dist/manifests/tooltip.manifest.json +1 -1
- package/dist/src/components/announcement-bar/AnnouncementBar.d.ts +3 -6
- package/dist/src/components/announcement-bar/AnnouncementBar.js +3 -1
- package/dist/src/components/announcement-bar/AnnouncementBar.js.map +1 -1
- package/dist/src/components/announcement-bar/AnnouncementBar.mjs +3 -1
- package/dist/src/components/announcement-bar/AnnouncementBar.mjs.map +1 -1
- package/dist/src/components/app-shell/AppShell.d.ts +3 -4
- package/dist/src/components/app-shell/AppShell.js +3 -1
- package/dist/src/components/app-shell/AppShell.js.map +1 -1
- package/dist/src/components/app-shell/AppShell.mjs +3 -1
- package/dist/src/components/app-shell/AppShell.mjs.map +1 -1
- package/dist/src/components/article-card/ArticleCard.d.ts +3 -6
- package/dist/src/components/article-card/ArticleCard.js +3 -1
- package/dist/src/components/article-card/ArticleCard.js.map +1 -1
- package/dist/src/components/article-card/ArticleCard.mjs +3 -1
- package/dist/src/components/article-card/ArticleCard.mjs.map +1 -1
- package/dist/src/components/bottom-nav/BottomNav.d.ts +2 -5
- package/dist/src/components/bottom-nav/BottomNav.js +2 -1
- package/dist/src/components/bottom-nav/BottomNav.js.map +1 -1
- package/dist/src/components/bottom-nav/BottomNav.mjs +2 -1
- package/dist/src/components/bottom-nav/BottomNav.mjs.map +1 -1
- package/dist/src/components/breadcrumb/Breadcrumb.d.ts +3 -16
- package/dist/src/components/breadcrumb/Breadcrumb.js +2 -1
- package/dist/src/components/breadcrumb/Breadcrumb.js.map +1 -1
- package/dist/src/components/breadcrumb/Breadcrumb.mjs +2 -1
- package/dist/src/components/breadcrumb/Breadcrumb.mjs.map +1 -1
- package/dist/src/components/consent-banner/ConsentBanner.d.ts +53 -0
- package/dist/src/components/consent-banner/ConsentBanner.js +83 -0
- package/dist/src/components/consent-banner/ConsentBanner.js.map +1 -0
- package/dist/src/components/consent-banner/ConsentBanner.mjs +49 -0
- package/dist/src/components/consent-banner/ConsentBanner.mjs.map +1 -0
- package/dist/src/components/consent-banner/index.d.ts +1 -0
- package/dist/src/components/consent-banner/index.js +23 -0
- package/dist/src/components/consent-banner/index.js.map +1 -0
- package/dist/src/components/consent-banner/index.mjs +2 -0
- package/dist/src/components/consent-banner/index.mjs.map +1 -0
- package/dist/src/components/contact-strip/ContactStrip.d.ts +3 -6
- package/dist/src/components/contact-strip/ContactStrip.js +3 -2
- package/dist/src/components/contact-strip/ContactStrip.js.map +1 -1
- package/dist/src/components/contact-strip/ContactStrip.mjs +3 -2
- package/dist/src/components/contact-strip/ContactStrip.mjs.map +1 -1
- package/dist/src/components/deal-card/DealCard.d.ts +3 -6
- package/dist/src/components/deal-card/DealCard.js +3 -1
- package/dist/src/components/deal-card/DealCard.js.map +1 -1
- package/dist/src/components/deal-card/DealCard.mjs +3 -1
- package/dist/src/components/deal-card/DealCard.mjs.map +1 -1
- package/dist/src/components/empty-state/EmptyState.d.ts +3 -10
- package/dist/src/components/empty-state/EmptyState.js +2 -1
- package/dist/src/components/empty-state/EmptyState.js.map +1 -1
- package/dist/src/components/empty-state/EmptyState.mjs +2 -1
- package/dist/src/components/empty-state/EmptyState.mjs.map +1 -1
- package/dist/src/components/entity-card/EntityCard.d.ts +4 -9
- package/dist/src/components/entity-card/EntityCard.js +4 -2
- package/dist/src/components/entity-card/EntityCard.js.map +1 -1
- package/dist/src/components/entity-card/EntityCard.mjs +4 -2
- package/dist/src/components/entity-card/EntityCard.mjs.map +1 -1
- package/dist/src/components/feature-grid/FeatureGrid.d.ts +3 -6
- package/dist/src/components/feature-grid/FeatureGrid.js +3 -2
- package/dist/src/components/feature-grid/FeatureGrid.js.map +1 -1
- package/dist/src/components/feature-grid/FeatureGrid.mjs +3 -2
- package/dist/src/components/feature-grid/FeatureGrid.mjs.map +1 -1
- package/dist/src/components/link-tabs/LinkTabs.d.ts +3 -16
- package/dist/src/components/link-tabs/LinkTabs.js +2 -1
- package/dist/src/components/link-tabs/LinkTabs.js.map +1 -1
- package/dist/src/components/link-tabs/LinkTabs.mjs +2 -1
- package/dist/src/components/link-tabs/LinkTabs.mjs.map +1 -1
- package/dist/src/components/logo-cloud/LogoCloud.d.ts +3 -10
- package/dist/src/components/logo-cloud/LogoCloud.js +2 -1
- package/dist/src/components/logo-cloud/LogoCloud.js.map +1 -1
- package/dist/src/components/logo-cloud/LogoCloud.mjs +2 -1
- package/dist/src/components/logo-cloud/LogoCloud.mjs.map +1 -1
- package/dist/src/components/media-card/MediaCard.d.ts +54 -0
- package/dist/src/components/media-card/MediaCard.js +89 -0
- package/dist/src/components/media-card/MediaCard.js.map +1 -0
- package/dist/src/components/media-card/MediaCard.mjs +55 -0
- package/dist/src/components/media-card/MediaCard.mjs.map +1 -0
- package/dist/src/components/media-card/index.d.ts +1 -0
- package/dist/src/components/media-card/index.js +23 -0
- package/dist/src/components/media-card/index.js.map +1 -0
- package/dist/src/components/media-card/index.mjs +2 -0
- package/dist/src/components/media-card/index.mjs.map +1 -0
- package/dist/src/components/month-schedule/MonthSchedule.d.ts +53 -0
- package/dist/src/components/month-schedule/MonthSchedule.js +246 -0
- package/dist/src/components/month-schedule/MonthSchedule.js.map +1 -0
- package/dist/src/components/month-schedule/MonthSchedule.mjs +220 -0
- package/dist/src/components/month-schedule/MonthSchedule.mjs.map +1 -0
- package/dist/src/components/month-schedule/index.d.ts +1 -0
- package/dist/src/components/month-schedule/index.js +23 -0
- package/dist/src/components/month-schedule/index.js.map +1 -0
- package/dist/src/components/month-schedule/index.mjs +2 -0
- package/dist/src/components/month-schedule/index.mjs.map +1 -0
- package/dist/src/components/pagination/Pagination.d.ts +3 -10
- package/dist/src/components/pagination/Pagination.js +2 -1
- package/dist/src/components/pagination/Pagination.js.map +1 -1
- package/dist/src/components/pagination/Pagination.mjs +2 -1
- package/dist/src/components/pagination/Pagination.mjs.map +1 -1
- package/dist/src/components/segmented-control/SegmentedControl.d.ts +3 -10
- package/dist/src/components/segmented-control/SegmentedControl.js +2 -1
- package/dist/src/components/segmented-control/SegmentedControl.js.map +1 -1
- package/dist/src/components/segmented-control/SegmentedControl.mjs +2 -1
- package/dist/src/components/segmented-control/SegmentedControl.mjs.map +1 -1
- package/dist/src/components/site-footer/SiteFooter.d.ts +2 -9
- package/dist/src/components/site-footer/SiteFooter.js +2 -1
- package/dist/src/components/site-footer/SiteFooter.js.map +1 -1
- package/dist/src/components/site-footer/SiteFooter.mjs +2 -1
- package/dist/src/components/site-footer/SiteFooter.mjs.map +1 -1
- package/dist/src/components/site-header/SiteHeader.d.ts +9 -10
- package/dist/src/components/site-header/SiteHeader.js +138 -133
- package/dist/src/components/site-header/SiteHeader.js.map +1 -1
- package/dist/src/components/site-header/SiteHeader.mjs +138 -133
- package/dist/src/components/site-header/SiteHeader.mjs.map +1 -1
- package/dist/src/components/tombstone-card/TombstoneCard.d.ts +3 -6
- package/dist/src/components/tombstone-card/TombstoneCard.js +3 -1
- package/dist/src/components/tombstone-card/TombstoneCard.js.map +1 -1
- package/dist/src/components/tombstone-card/TombstoneCard.mjs +3 -1
- package/dist/src/components/tombstone-card/TombstoneCard.mjs.map +1 -1
- package/dist/src/index.d.ts +5 -0
- package/dist/src/utils/consent.d.ts +42 -0
- package/dist/src/utils/consent.js +142 -0
- package/dist/src/utils/consent.js.map +1 -0
- package/dist/src/utils/consent.mjs +107 -0
- package/dist/src/utils/consent.mjs.map +1 -0
- package/dist/src/utils/link.d.ts +21 -0
- package/dist/src/utils/link.js +31 -0
- package/dist/src/utils/link.js.map +1 -0
- package/dist/src/utils/link.mjs +7 -0
- package/dist/src/utils/link.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/announcement-bar/AnnouncementBar.test.tsx +18 -0
- package/src/components/announcement-bar/AnnouncementBar.tsx +4 -4
- package/src/components/app-shell/AppShell.test.tsx +10 -0
- package/src/components/app-shell/AppShell.tsx +4 -4
- package/src/components/article-card/ArticleCard.test.tsx +10 -0
- package/src/components/article-card/ArticleCard.tsx +4 -4
- package/src/components/bottom-nav/BottomNav.tsx +3 -6
- package/src/components/breadcrumb/Breadcrumb.tsx +3 -9
- package/src/components/consent-banner/ConsentBanner.test.tsx +58 -0
- package/src/components/consent-banner/ConsentBanner.tsx +93 -0
- package/src/components/consent-banner/index.ts +1 -0
- package/src/components/contact-strip/ContactStrip.test.tsx +16 -0
- package/src/components/contact-strip/ContactStrip.tsx +4 -5
- package/src/components/deal-card/DealCard.test.tsx +19 -0
- package/src/components/deal-card/DealCard.tsx +4 -4
- package/src/components/empty-state/EmptyState.tsx +3 -6
- package/src/components/entity-card/EntityCard.test.tsx +8 -0
- package/src/components/entity-card/EntityCard.tsx +5 -5
- package/src/components/feature-grid/FeatureGrid.test.tsx +16 -0
- package/src/components/feature-grid/FeatureGrid.tsx +4 -5
- package/src/components/link-tabs/LinkTabs.tsx +3 -9
- package/src/components/logo-cloud/LogoCloud.tsx +3 -6
- package/src/components/media-card/MediaCard.test.tsx +97 -0
- package/src/components/media-card/MediaCard.tsx +113 -0
- package/src/components/media-card/index.ts +1 -0
- package/src/components/month-schedule/MonthSchedule.test.tsx +137 -0
- package/src/components/month-schedule/MonthSchedule.tsx +329 -0
- package/src/components/month-schedule/index.ts +1 -0
- package/src/components/pagination/Pagination.tsx +3 -6
- package/src/components/segmented-control/SegmentedControl.tsx +3 -6
- package/src/components/site-footer/SiteFooter.tsx +3 -11
- package/src/components/site-header/SiteHeader.test.tsx +26 -0
- package/src/components/site-header/SiteHeader.tsx +17 -11
- package/src/components/tombstone-card/TombstoneCard.test.tsx +17 -0
- package/src/components/tombstone-card/TombstoneCard.tsx +4 -4
- package/src/index.ts +5 -0
- package/src/manifests/accordion.manifest.json +1 -1
- package/src/manifests/alert.manifest.json +1 -1
- package/src/manifests/announcement-bar.manifest.json +12 -1
- package/src/manifests/app-shell.manifest.json +12 -1
- package/src/manifests/applied-filters.manifest.json +1 -1
- package/src/manifests/article-card.manifest.json +12 -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 +1 -1
- 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/consent-banner.manifest.json +130 -0
- package/src/manifests/contact-strip.manifest.json +12 -1
- package/src/manifests/container.manifest.json +1 -1
- package/src/manifests/cover-image.manifest.json +1 -1
- package/src/manifests/cta-section.manifest.json +1 -1
- package/src/manifests/data-table.manifest.json +1 -1
- package/src/manifests/date-picker-popover.manifest.json +1 -1
- 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 +12 -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 +12 -1
- package/src/manifests/feature-grid.manifest.json +12 -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 +1 -1
- 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-toolbar.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/media-card.manifest.json +161 -0
- package/src/manifests/menu.manifest.json +1 -1
- package/src/manifests/metric-card.manifest.json +1 -1
- package/src/manifests/month-schedule.manifest.json +217 -0
- 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 +1 -1
- 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 +7 -1
- 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 +1 -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 +12 -1
- package/src/manifests/tooltip.manifest.json +1 -1
- package/src/utils/consent.test.ts +112 -0
- package/src/utils/consent.ts +169 -0
- package/src/utils/link.ts +19 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { act, renderHook } from '@testing-library/react';
|
|
2
|
+
import { beforeEach, describe, expect, it } from 'vitest';
|
|
3
|
+
import { useConsent } from './consent';
|
|
4
|
+
|
|
5
|
+
const KEY = 'test-consent';
|
|
6
|
+
|
|
7
|
+
function seed(raw: string) {
|
|
8
|
+
window.localStorage.setItem(KEY, raw);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
describe('useConsent', () => {
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
window.localStorage.clear();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('starts undecided with empty storage', () => {
|
|
17
|
+
const { result } = renderHook(() => useConsent({ storageKey: KEY }));
|
|
18
|
+
expect(result.current.decided).toBe(false);
|
|
19
|
+
expect(result.current.preferences).toBeNull();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('setAll grants every purpose and persists the decision', () => {
|
|
23
|
+
const { result } = renderHook(() =>
|
|
24
|
+
useConsent({ storageKey: KEY, purposes: ['analytics', 'marketing'] })
|
|
25
|
+
);
|
|
26
|
+
act(() => result.current.setAll(true));
|
|
27
|
+
expect(result.current.decided).toBe(true);
|
|
28
|
+
expect(result.current.preferences).toEqual({ analytics: true, marketing: true });
|
|
29
|
+
const stored = JSON.parse(window.localStorage.getItem(KEY)!);
|
|
30
|
+
expect(stored.p).toEqual({ analytics: true, marketing: true });
|
|
31
|
+
expect(typeof stored.at).toBe('number');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('setAll(false) denies every purpose', () => {
|
|
35
|
+
const { result } = renderHook(() => useConsent({ storageKey: KEY }));
|
|
36
|
+
act(() => result.current.setAll(false));
|
|
37
|
+
expect(result.current.preferences).toEqual({ analytics: false });
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('reads a persisted decision on mount', () => {
|
|
41
|
+
seed(JSON.stringify({ p: { analytics: true }, at: Date.now() }));
|
|
42
|
+
const { result } = renderHook(() => useConsent({ storageKey: KEY }));
|
|
43
|
+
expect(result.current.decided).toBe(true);
|
|
44
|
+
expect(result.current.preferences).toEqual({ analytics: true });
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('treats expired decisions as undecided', () => {
|
|
48
|
+
const stale = { p: { analytics: true }, at: Date.now() - 200 * 24 * 60 * 60 * 1000 };
|
|
49
|
+
seed(JSON.stringify(stale));
|
|
50
|
+
const { result } = renderHook(() => useConsent({ storageKey: KEY }));
|
|
51
|
+
expect(result.current.decided).toBe(false);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('honors a custom maxAgeMs', () => {
|
|
55
|
+
const entry = { p: { analytics: true }, at: Date.now() - 60_000 };
|
|
56
|
+
seed(JSON.stringify(entry));
|
|
57
|
+
const { result } = renderHook(() =>
|
|
58
|
+
useConsent({ storageKey: KEY, maxAgeMs: 30_000 })
|
|
59
|
+
);
|
|
60
|
+
expect(result.current.decided).toBe(false);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('treats malformed payloads as undecided', () => {
|
|
64
|
+
seed('not json');
|
|
65
|
+
const { result } = renderHook(() => useConsent({ storageKey: KEY }));
|
|
66
|
+
expect(result.current.decided).toBe(false);
|
|
67
|
+
seed(JSON.stringify({ p: { analytics: 'yes' }, at: Date.now() }));
|
|
68
|
+
const { result: second } = renderHook(() => useConsent({ storageKey: KEY }));
|
|
69
|
+
expect(second.current.decided).toBe(false);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('set() stores an explicit per-purpose map', () => {
|
|
73
|
+
const { result } = renderHook(() =>
|
|
74
|
+
useConsent({ storageKey: KEY, purposes: ['analytics', 'marketing'] })
|
|
75
|
+
);
|
|
76
|
+
act(() => result.current.set({ analytics: true, marketing: false }));
|
|
77
|
+
expect(result.current.preferences).toEqual({ analytics: true, marketing: false });
|
|
78
|
+
// Missing purposes default to denied rather than leaking through.
|
|
79
|
+
act(() => result.current.set({ analytics: true }));
|
|
80
|
+
expect(result.current.preferences).toEqual({ analytics: true, marketing: false });
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('clear() forgets the decision and removes storage', () => {
|
|
84
|
+
const { result } = renderHook(() => useConsent({ storageKey: KEY }));
|
|
85
|
+
act(() => result.current.setAll(true));
|
|
86
|
+
act(() => result.current.clear());
|
|
87
|
+
expect(result.current.decided).toBe(false);
|
|
88
|
+
expect(window.localStorage.getItem(KEY)).toBeNull();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('keeps separate hook instances in sync via the change event', () => {
|
|
92
|
+
const banner = renderHook(() => useConsent({ storageKey: KEY }));
|
|
93
|
+
const gate = renderHook(() => useConsent({ storageKey: KEY }));
|
|
94
|
+
act(() => banner.result.current.setAll(true));
|
|
95
|
+
expect(gate.result.current.decided).toBe(true);
|
|
96
|
+
expect(gate.result.current.preferences).toEqual({ analytics: true });
|
|
97
|
+
act(() => gate.result.current.clear());
|
|
98
|
+
expect(banner.result.current.decided).toBe(false);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('ignores change events for other storage keys', () => {
|
|
102
|
+
const { result } = renderHook(() => useConsent({ storageKey: KEY }));
|
|
103
|
+
act(() => {
|
|
104
|
+
window.dispatchEvent(
|
|
105
|
+
new CustomEvent('slipstream:consent-change', {
|
|
106
|
+
detail: { storageKey: 'other-key', preferences: { analytics: true } },
|
|
107
|
+
})
|
|
108
|
+
);
|
|
109
|
+
});
|
|
110
|
+
expect(result.current.decided).toBe(false);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Per-purpose consent choices, e.g. `{ analytics: true, marketing: false }`.
|
|
5
|
+
* Consumers define their own purpose keys via `useConsent({ purposes })`.
|
|
6
|
+
*/
|
|
7
|
+
export type ConsentPreferences = Record<string, boolean>;
|
|
8
|
+
|
|
9
|
+
export type UseConsentOptions = {
|
|
10
|
+
/** localStorage key for the stored decision. Default 'slipstream-consent'. */
|
|
11
|
+
storageKey?: string;
|
|
12
|
+
/** Consent purposes persisted as booleans. Default ['analytics']. */
|
|
13
|
+
purposes?: readonly string[];
|
|
14
|
+
/**
|
|
15
|
+
* How long a stored decision stays valid before the visitor is asked
|
|
16
|
+
* again. Default 180 days (common EU consent-refresh guidance).
|
|
17
|
+
*/
|
|
18
|
+
maxAgeMs?: number;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type Consent = {
|
|
22
|
+
/** Current per-purpose preferences, or null when undecided or expired. */
|
|
23
|
+
preferences: ConsentPreferences | null;
|
|
24
|
+
/** True once the visitor has a valid stored decision. */
|
|
25
|
+
decided: boolean;
|
|
26
|
+
/** Set every purpose to the same value — the banner's accept/decline. */
|
|
27
|
+
setAll(allowed: boolean): void;
|
|
28
|
+
/** Store an explicit preference map (e.g. from a preferences dialog). */
|
|
29
|
+
set(preferences: ConsentPreferences): void;
|
|
30
|
+
/** Forget the stored choice so the banner returns and gated code stops. */
|
|
31
|
+
clear(): void;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const DEFAULT_STORAGE_KEY = 'slipstream-consent';
|
|
35
|
+
const DEFAULT_MAX_AGE_MS = 180 * 24 * 60 * 60 * 1000;
|
|
36
|
+
const DEFAULT_PURPOSES = ['analytics'] as const;
|
|
37
|
+
|
|
38
|
+
/** Window event fired whenever a consent decision is written or cleared. */
|
|
39
|
+
export const CONSENT_CHANGE_EVENT = 'slipstream:consent-change';
|
|
40
|
+
|
|
41
|
+
type ConsentChangeDetail = { storageKey: string; preferences: ConsentPreferences | null };
|
|
42
|
+
|
|
43
|
+
type StoredConsent = { p?: unknown; at?: unknown };
|
|
44
|
+
|
|
45
|
+
function isPurposeMap(value: unknown, purposes: readonly string[]): value is ConsentPreferences {
|
|
46
|
+
if (typeof value !== 'object' || value === null) return false;
|
|
47
|
+
const record = value as Record<string, unknown>;
|
|
48
|
+
return purposes.every((purpose) => typeof record[purpose] === 'boolean');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function readStored(
|
|
52
|
+
storageKey: string,
|
|
53
|
+
purposes: readonly string[],
|
|
54
|
+
maxAgeMs: number
|
|
55
|
+
): ConsentPreferences | null {
|
|
56
|
+
try {
|
|
57
|
+
const raw = window.localStorage.getItem(storageKey);
|
|
58
|
+
if (!raw) return null;
|
|
59
|
+
const parsed: unknown = JSON.parse(raw);
|
|
60
|
+
if (typeof parsed !== 'object' || parsed === null) return null;
|
|
61
|
+
const { p, at } = parsed as StoredConsent;
|
|
62
|
+
if (typeof at !== 'number' || !Number.isFinite(at)) return null;
|
|
63
|
+
if (Date.now() - at >= maxAgeMs) return null;
|
|
64
|
+
if (!isPurposeMap(p, purposes)) return null;
|
|
65
|
+
const preferences: ConsentPreferences = {};
|
|
66
|
+
for (const purpose of purposes) preferences[purpose] = p[purpose];
|
|
67
|
+
return preferences;
|
|
68
|
+
} catch {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function writeStored(storageKey: string, preferences: ConsentPreferences): void {
|
|
74
|
+
try {
|
|
75
|
+
window.localStorage.setItem(storageKey, JSON.stringify({ p: preferences, at: Date.now() }));
|
|
76
|
+
} catch {
|
|
77
|
+
/* storage blocked — consent simply isn't persisted */
|
|
78
|
+
}
|
|
79
|
+
window.dispatchEvent(
|
|
80
|
+
new CustomEvent<ConsentChangeDetail>(CONSENT_CHANGE_EVENT, {
|
|
81
|
+
detail: { storageKey, preferences },
|
|
82
|
+
})
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function clearStored(storageKey: string): void {
|
|
87
|
+
try {
|
|
88
|
+
window.localStorage.removeItem(storageKey);
|
|
89
|
+
} catch {
|
|
90
|
+
/* storage blocked — nothing to clear */
|
|
91
|
+
}
|
|
92
|
+
window.dispatchEvent(
|
|
93
|
+
new CustomEvent<ConsentChangeDetail>(CONSENT_CHANGE_EVENT, {
|
|
94
|
+
detail: { storageKey, preferences: null },
|
|
95
|
+
})
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Headless consent state: reads a per-purpose decision from localStorage,
|
|
101
|
+
* persists accept/decline/customize choices, expires stale decisions, and
|
|
102
|
+
* keeps every `useConsent` instance on the page in sync through a window
|
|
103
|
+
* event (plus the native `storage` event for other tabs).
|
|
104
|
+
*
|
|
105
|
+
* The first client render reports `decided: false` so SSR markup matches;
|
|
106
|
+
* the stored value is read in an effect after mount. To avoid a banner
|
|
107
|
+
* flash for returning visitors, gate first paint with a theme-script class
|
|
108
|
+
* the way cookie-banner implementations typically do.
|
|
109
|
+
*/
|
|
110
|
+
export function useConsent({
|
|
111
|
+
storageKey = DEFAULT_STORAGE_KEY,
|
|
112
|
+
purposes = DEFAULT_PURPOSES,
|
|
113
|
+
maxAgeMs = DEFAULT_MAX_AGE_MS,
|
|
114
|
+
}: UseConsentOptions = {}): Consent {
|
|
115
|
+
const [preferences, setPreferences] = React.useState<ConsentPreferences | null>(null);
|
|
116
|
+
// Callbacks stay referentially stable while always seeing the latest
|
|
117
|
+
// purposes array, which consumers often pass inline.
|
|
118
|
+
const purposesRef = React.useRef(purposes);
|
|
119
|
+
purposesRef.current = purposes;
|
|
120
|
+
const purposesKey = purposes.join('');
|
|
121
|
+
|
|
122
|
+
React.useEffect(() => {
|
|
123
|
+
const active = purposesRef.current;
|
|
124
|
+
const sync = () => setPreferences(readStored(storageKey, active, maxAgeMs));
|
|
125
|
+
sync();
|
|
126
|
+
const onChange = (event: Event) => {
|
|
127
|
+
const detail = (event as CustomEvent<ConsentChangeDetail>).detail;
|
|
128
|
+
if (detail?.storageKey === storageKey) {
|
|
129
|
+
setPreferences(detail.preferences);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
const onStorage = (event: StorageEvent) => {
|
|
133
|
+
if (event.key === storageKey || event.key === null) sync();
|
|
134
|
+
};
|
|
135
|
+
window.addEventListener(CONSENT_CHANGE_EVENT, onChange);
|
|
136
|
+
window.addEventListener('storage', onStorage);
|
|
137
|
+
return () => {
|
|
138
|
+
window.removeEventListener(CONSENT_CHANGE_EVENT, onChange);
|
|
139
|
+
window.removeEventListener('storage', onStorage);
|
|
140
|
+
};
|
|
141
|
+
}, [storageKey, maxAgeMs, purposesKey]);
|
|
142
|
+
|
|
143
|
+
const setAll = React.useCallback(
|
|
144
|
+
(allowed: boolean) => {
|
|
145
|
+
const next: ConsentPreferences = {};
|
|
146
|
+
for (const purpose of purposesRef.current) next[purpose] = allowed;
|
|
147
|
+
writeStored(storageKey, next);
|
|
148
|
+
setPreferences(next);
|
|
149
|
+
},
|
|
150
|
+
[storageKey]
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
const set = React.useCallback(
|
|
154
|
+
(next: ConsentPreferences) => {
|
|
155
|
+
const merged: ConsentPreferences = {};
|
|
156
|
+
for (const purpose of purposesRef.current) merged[purpose] = next[purpose] === true;
|
|
157
|
+
writeStored(storageKey, merged);
|
|
158
|
+
setPreferences(merged);
|
|
159
|
+
},
|
|
160
|
+
[storageKey]
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
const clear = React.useCallback(() => {
|
|
164
|
+
clearStored(storageKey);
|
|
165
|
+
setPreferences(null);
|
|
166
|
+
}, [storageKey]);
|
|
167
|
+
|
|
168
|
+
return { preferences, decided: preferences !== null, setAll, set, clear };
|
|
169
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ElementType } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Shared props for components that can render a destination through a
|
|
5
|
+
* router-aware link element. `linkComponent` swaps the underlying element
|
|
6
|
+
* (Next `Link`, react-router `Link`); `linkHrefProp` names the prop that
|
|
7
|
+
* carries the destination on that element (`href` or `to`).
|
|
8
|
+
*/
|
|
9
|
+
export type LinkLikeProps = {
|
|
10
|
+
/** Custom link element for routers (Next Link, react-router Link). */
|
|
11
|
+
linkComponent?: ElementType;
|
|
12
|
+
/** Prop used to pass the destination to `linkComponent`. */
|
|
13
|
+
linkHrefProp?: 'href' | 'to';
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/** Props object carrying a destination for `linkComponent`/`linkHrefProp`. */
|
|
17
|
+
export function linkDestination(href: string, linkHrefProp: 'href' | 'to' = 'href') {
|
|
18
|
+
return linkHrefProp === 'to' ? { to: href } : { href };
|
|
19
|
+
}
|