@slipstream-ui/core 0.11.10 → 0.12.1
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 +154 -163
- package/dist/index.d.ts +154 -163
- package/dist/index.js +1358 -1165
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1355 -1165
- 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 +1 -1
- package/dist/manifests/menu.manifest.json +1 -1
- package/dist/manifests/metric-card.manifest.json +1 -1
- package/dist/manifests/month-schedule.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 +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 +3 -10
- package/dist/src/components/media-card/MediaCard.js +2 -1
- package/dist/src/components/media-card/MediaCard.js.map +1 -1
- package/dist/src/components/media-card/MediaCard.mjs +2 -1
- package/dist/src/components/media-card/MediaCard.mjs.map +1 -1
- package/dist/src/components/month-schedule/MonthSchedule.d.ts +2 -5
- package/dist/src/components/month-schedule/MonthSchedule.js +3 -2
- package/dist/src/components/month-schedule/MonthSchedule.js.map +1 -1
- package/dist/src/components/month-schedule/MonthSchedule.mjs +3 -2
- package/dist/src/components/month-schedule/MonthSchedule.mjs.map +1 -1
- 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 +162 -133
- package/dist/src/components/site-header/SiteHeader.js.map +1 -1
- package/dist/src/components/site-header/SiteHeader.mjs +162 -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 +3 -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 +4 -4
- 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.tsx +3 -6
- package/src/components/month-schedule/MonthSchedule.tsx +4 -7
- 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 +53 -0
- package/src/components/site-header/SiteHeader.tsx +77 -32
- package/src/components/tombstone-card/TombstoneCard.test.tsx +17 -0
- package/src/components/tombstone-card/TombstoneCard.tsx +4 -4
- package/src/index.ts +3 -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 +1 -1
- package/src/manifests/menu.manifest.json +1 -1
- package/src/manifests/metric-card.manifest.json +1 -1
- package/src/manifests/month-schedule.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 +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
|
@@ -34,6 +34,7 @@ module.exports = __toCommonJS(TombstoneCard_exports);
|
|
|
34
34
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
35
|
var React = __toESM(require("react"));
|
|
36
36
|
var import_cn = require("../../utils/cn.js");
|
|
37
|
+
var import_link = require("../../utils/link.js");
|
|
37
38
|
var import_Badge = require("../badge/Badge.js");
|
|
38
39
|
var import_Card = require("../card/Card.js");
|
|
39
40
|
const statusConfig = {
|
|
@@ -49,6 +50,7 @@ const TombstoneCard = React.forwardRef(function TombstoneCard2({
|
|
|
49
50
|
href,
|
|
50
51
|
actionLabel = "View details",
|
|
51
52
|
linkComponent,
|
|
53
|
+
linkHrefProp = "href",
|
|
52
54
|
className,
|
|
53
55
|
...props
|
|
54
56
|
}, ref) {
|
|
@@ -70,7 +72,7 @@ const TombstoneCard = React.forwardRef(function TombstoneCard2({
|
|
|
70
72
|
href && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
71
73
|
Link,
|
|
72
74
|
{
|
|
73
|
-
href,
|
|
75
|
+
...(0, import_link.linkDestination)(href, linkHrefProp),
|
|
74
76
|
className: "mt-auto text-sm font-medium text-primary-ink underline-offset-4 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
75
77
|
children: actionLabel
|
|
76
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/tombstone-card/TombstoneCard.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../utils/cn';\nimport { Badge } from '../badge/Badge';\nimport { Card, CardContent } from '../card/Card';\n\nexport type TombstoneStatus = 'archived' | 'unavailable' | 'closed';\n\nexport type TombstoneCardProps = Omit<React.HTMLAttributes<HTMLElement>, 'title'> & {\n /** Listing, deal or document name. */\n title: string;\n /** Why the item is unavailable. */\n reason?: string;\n /** Unavailable state. Default 'unavailable'. */\n status?: TombstoneStatus;\n /** Logo or document icon slot. */\n logo?: React.ReactNode;\n /** Optional detail destination. */\n href?: string;\n /** Link label. Default \"View details\". */\n actionLabel?: string;\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/tombstone-card/TombstoneCard.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../utils/cn';\nimport { linkDestination, type LinkLikeProps } from '../../utils/link';\nimport { Badge } from '../badge/Badge';\nimport { Card, CardContent } from '../card/Card';\n\nexport type TombstoneStatus = 'archived' | 'unavailable' | 'closed';\n\nexport type TombstoneCardProps = Omit<React.HTMLAttributes<HTMLElement>, 'title'> & LinkLikeProps & {\n /** Listing, deal or document name. */\n title: string;\n /** Why the item is unavailable. */\n reason?: string;\n /** Unavailable state. Default 'unavailable'. */\n status?: TombstoneStatus;\n /** Logo or document icon slot. */\n logo?: React.ReactNode;\n /** Optional detail destination. */\n href?: string;\n /** Link label. Default \"View details\". */\n actionLabel?: string;\n};\n\nconst statusConfig: Record<TombstoneStatus, { label: string; variant: 'secondary' | 'warning' | 'outline' }> = {\n archived: { label: 'Archived', variant: 'secondary' },\n unavailable: { label: 'Unavailable', variant: 'warning' },\n closed: { label: 'Closed', variant: 'outline' },\n};\n\n/**\n * Placeholder card for archived, closed or unavailable marketplace items. It\n * explains why the item is unavailable instead of silently removing it from a\n * list or leaving a broken detail link.\n */\nexport const TombstoneCard = React.forwardRef<HTMLElement, TombstoneCardProps>(function TombstoneCard(\n {\n title,\n reason,\n status = 'unavailable',\n logo,\n href,\n actionLabel = 'View details',\n linkComponent,\n linkHrefProp = 'href',\n className,\n ...props\n },\n ref\n) {\n const Link = linkComponent ?? 'a';\n const statusInfo = statusConfig[status];\n\n return (\n <Card\n ref={ref as never}\n className={cn('flex h-full flex-col border-dashed bg-muted/30 shadow-none', className)}\n {...props}\n >\n <CardContent className=\"flex flex-1 flex-col gap-3 p-5\">\n <div className=\"flex items-start justify-between gap-2\">\n {logo && <div className=\"min-w-0 opacity-70\">{logo}</div>}\n <Badge variant={statusInfo.variant}>{statusInfo.label}</Badge>\n </div>\n <h3 className=\"text-base font-semibold tracking-tight text-foreground/80\">{title}</h3>\n {reason && <p className=\"text-sm leading-relaxed text-muted-foreground\">{reason}</p>}\n {href && (\n <Link\n {...linkDestination(href, linkHrefProp)}\n className=\"mt-auto text-sm font-medium text-primary-ink underline-offset-4 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {actionLabel}\n </Link>\n )}\n </CardContent>\n </Card>\n );\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA2DQ;AA3DR,YAAuB;AACvB,gBAAmB;AACnB,kBAAoD;AACpD,mBAAsB;AACtB,kBAAkC;AAmBlC,MAAM,eAAyG;AAAA,EAC7G,UAAU,EAAE,OAAO,YAAY,SAAS,YAAY;AAAA,EACpD,aAAa,EAAE,OAAO,eAAe,SAAS,UAAU;AAAA,EACxD,QAAQ,EAAE,OAAO,UAAU,SAAS,UAAU;AAChD;AAOO,MAAM,gBAAgB,MAAM,WAA4C,SAASA,eACtF;AAAA,EACE;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd;AAAA,EACA,eAAe;AAAA,EACf;AAAA,EACA,GAAG;AACL,GACA,KACA;AACA,QAAM,OAAO,iBAAiB;AAC9B,QAAM,aAAa,aAAa,MAAM;AAEtC,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,eAAW,cAAG,8DAA8D,SAAS;AAAA,MACpF,GAAG;AAAA,MAEJ,uDAAC,2BAAY,WAAU,kCACrB;AAAA,qDAAC,SAAI,WAAU,0CACZ;AAAA,kBAAQ,4CAAC,SAAI,WAAU,sBAAsB,gBAAK;AAAA,UACnD,4CAAC,sBAAM,SAAS,WAAW,SAAU,qBAAW,OAAM;AAAA,WACxD;AAAA,QACA,4CAAC,QAAG,WAAU,6DAA6D,iBAAM;AAAA,QAChF,UAAU,4CAAC,OAAE,WAAU,iDAAiD,kBAAO;AAAA,QAC/E,QACC;AAAA,UAAC;AAAA;AAAA,YACE,OAAG,6BAAgB,MAAM,YAAY;AAAA,YACtC,WAAU;AAAA,YAET;AAAA;AAAA,QACH;AAAA,SAEJ;AAAA;AAAA,EACF;AAEJ,CAAC;","names":["TombstoneCard"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { cn } from "../../utils/cn.mjs";
|
|
4
|
+
import { linkDestination } from "../../utils/link.mjs";
|
|
4
5
|
import { Badge } from "../badge/Badge.mjs";
|
|
5
6
|
import { Card, CardContent } from "../card/Card.mjs";
|
|
6
7
|
const statusConfig = {
|
|
@@ -16,6 +17,7 @@ const TombstoneCard = React.forwardRef(function TombstoneCard2({
|
|
|
16
17
|
href,
|
|
17
18
|
actionLabel = "View details",
|
|
18
19
|
linkComponent,
|
|
20
|
+
linkHrefProp = "href",
|
|
19
21
|
className,
|
|
20
22
|
...props
|
|
21
23
|
}, ref) {
|
|
@@ -37,7 +39,7 @@ const TombstoneCard = React.forwardRef(function TombstoneCard2({
|
|
|
37
39
|
href && /* @__PURE__ */ jsx(
|
|
38
40
|
Link,
|
|
39
41
|
{
|
|
40
|
-
href,
|
|
42
|
+
...linkDestination(href, linkHrefProp),
|
|
41
43
|
className: "mt-auto text-sm font-medium text-primary-ink underline-offset-4 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
42
44
|
children: actionLabel
|
|
43
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/tombstone-card/TombstoneCard.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../utils/cn';\nimport { Badge } from '../badge/Badge';\nimport { Card, CardContent } from '../card/Card';\n\nexport type TombstoneStatus = 'archived' | 'unavailable' | 'closed';\n\nexport type TombstoneCardProps = Omit<React.HTMLAttributes<HTMLElement>, 'title'> & {\n /** Listing, deal or document name. */\n title: string;\n /** Why the item is unavailable. */\n reason?: string;\n /** Unavailable state. Default 'unavailable'. */\n status?: TombstoneStatus;\n /** Logo or document icon slot. */\n logo?: React.ReactNode;\n /** Optional detail destination. */\n href?: string;\n /** Link label. Default \"View details\". */\n actionLabel?: string;\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/tombstone-card/TombstoneCard.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../utils/cn';\nimport { linkDestination, type LinkLikeProps } from '../../utils/link';\nimport { Badge } from '../badge/Badge';\nimport { Card, CardContent } from '../card/Card';\n\nexport type TombstoneStatus = 'archived' | 'unavailable' | 'closed';\n\nexport type TombstoneCardProps = Omit<React.HTMLAttributes<HTMLElement>, 'title'> & LinkLikeProps & {\n /** Listing, deal or document name. */\n title: string;\n /** Why the item is unavailable. */\n reason?: string;\n /** Unavailable state. Default 'unavailable'. */\n status?: TombstoneStatus;\n /** Logo or document icon slot. */\n logo?: React.ReactNode;\n /** Optional detail destination. */\n href?: string;\n /** Link label. Default \"View details\". */\n actionLabel?: string;\n};\n\nconst statusConfig: Record<TombstoneStatus, { label: string; variant: 'secondary' | 'warning' | 'outline' }> = {\n archived: { label: 'Archived', variant: 'secondary' },\n unavailable: { label: 'Unavailable', variant: 'warning' },\n closed: { label: 'Closed', variant: 'outline' },\n};\n\n/**\n * Placeholder card for archived, closed or unavailable marketplace items. It\n * explains why the item is unavailable instead of silently removing it from a\n * list or leaving a broken detail link.\n */\nexport const TombstoneCard = React.forwardRef<HTMLElement, TombstoneCardProps>(function TombstoneCard(\n {\n title,\n reason,\n status = 'unavailable',\n logo,\n href,\n actionLabel = 'View details',\n linkComponent,\n linkHrefProp = 'href',\n className,\n ...props\n },\n ref\n) {\n const Link = linkComponent ?? 'a';\n const statusInfo = statusConfig[status];\n\n return (\n <Card\n ref={ref as never}\n className={cn('flex h-full flex-col border-dashed bg-muted/30 shadow-none', className)}\n {...props}\n >\n <CardContent className=\"flex flex-1 flex-col gap-3 p-5\">\n <div className=\"flex items-start justify-between gap-2\">\n {logo && <div className=\"min-w-0 opacity-70\">{logo}</div>}\n <Badge variant={statusInfo.variant}>{statusInfo.label}</Badge>\n </div>\n <h3 className=\"text-base font-semibold tracking-tight text-foreground/80\">{title}</h3>\n {reason && <p className=\"text-sm leading-relaxed text-muted-foreground\">{reason}</p>}\n {href && (\n <Link\n {...linkDestination(href, linkHrefProp)}\n className=\"mt-auto text-sm font-medium text-primary-ink underline-offset-4 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {actionLabel}\n </Link>\n )}\n </CardContent>\n </Card>\n );\n});\n"],"mappings":"AA2DQ,SACW,KADX;AA3DR,YAAY,WAAW;AACvB,SAAS,UAAU;AACnB,SAAS,uBAA2C;AACpD,SAAS,aAAa;AACtB,SAAS,MAAM,mBAAmB;AAmBlC,MAAM,eAAyG;AAAA,EAC7G,UAAU,EAAE,OAAO,YAAY,SAAS,YAAY;AAAA,EACpD,aAAa,EAAE,OAAO,eAAe,SAAS,UAAU;AAAA,EACxD,QAAQ,EAAE,OAAO,UAAU,SAAS,UAAU;AAChD;AAOO,MAAM,gBAAgB,MAAM,WAA4C,SAASA,eACtF;AAAA,EACE;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd;AAAA,EACA,eAAe;AAAA,EACf;AAAA,EACA,GAAG;AACL,GACA,KACA;AACA,QAAM,OAAO,iBAAiB;AAC9B,QAAM,aAAa,aAAa,MAAM;AAEtC,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,WAAW,GAAG,8DAA8D,SAAS;AAAA,MACpF,GAAG;AAAA,MAEJ,+BAAC,eAAY,WAAU,kCACrB;AAAA,6BAAC,SAAI,WAAU,0CACZ;AAAA,kBAAQ,oBAAC,SAAI,WAAU,sBAAsB,gBAAK;AAAA,UACnD,oBAAC,SAAM,SAAS,WAAW,SAAU,qBAAW,OAAM;AAAA,WACxD;AAAA,QACA,oBAAC,QAAG,WAAU,6DAA6D,iBAAM;AAAA,QAChF,UAAU,oBAAC,OAAE,WAAU,iDAAiD,kBAAO;AAAA,QAC/E,QACC;AAAA,UAAC;AAAA;AAAA,YACE,GAAG,gBAAgB,MAAM,YAAY;AAAA,YACtC,WAAU;AAAA,YAET;AAAA;AAAA,QACH;AAAA,SAEJ;AAAA;AAAA,EACF;AAEJ,CAAC;","names":["TombstoneCard"]}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ export * from './types/manifest';
|
|
|
2
2
|
export * from './utils/cn';
|
|
3
3
|
export * from './utils/gap';
|
|
4
4
|
export * from './utils/presence';
|
|
5
|
+
export * from './utils/consent';
|
|
6
|
+
export type { LinkLikeProps } from './utils/link';
|
|
5
7
|
export * from './components/app-shell';
|
|
6
8
|
export * from './components/button';
|
|
7
9
|
export * from './components/button-group';
|
|
@@ -39,6 +41,7 @@ export * from './components/calendar';
|
|
|
39
41
|
export * from './components/month-schedule';
|
|
40
42
|
export * from './components/card';
|
|
41
43
|
export * from './components/confirm-dialog';
|
|
44
|
+
export * from './components/consent-banner';
|
|
42
45
|
export * from './components/table-of-contents';
|
|
43
46
|
export * from './components/prose';
|
|
44
47
|
export * from './components/site-footer';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-purpose consent choices, e.g. `{ analytics: true, marketing: false }`.
|
|
3
|
+
* Consumers define their own purpose keys via `useConsent({ purposes })`.
|
|
4
|
+
*/
|
|
5
|
+
export type ConsentPreferences = Record<string, boolean>;
|
|
6
|
+
export type UseConsentOptions = {
|
|
7
|
+
/** localStorage key for the stored decision. Default 'slipstream-consent'. */
|
|
8
|
+
storageKey?: string;
|
|
9
|
+
/** Consent purposes persisted as booleans. Default ['analytics']. */
|
|
10
|
+
purposes?: readonly string[];
|
|
11
|
+
/**
|
|
12
|
+
* How long a stored decision stays valid before the visitor is asked
|
|
13
|
+
* again. Default 180 days (common EU consent-refresh guidance).
|
|
14
|
+
*/
|
|
15
|
+
maxAgeMs?: number;
|
|
16
|
+
};
|
|
17
|
+
export type Consent = {
|
|
18
|
+
/** Current per-purpose preferences, or null when undecided or expired. */
|
|
19
|
+
preferences: ConsentPreferences | null;
|
|
20
|
+
/** True once the visitor has a valid stored decision. */
|
|
21
|
+
decided: boolean;
|
|
22
|
+
/** Set every purpose to the same value — the banner's accept/decline. */
|
|
23
|
+
setAll(allowed: boolean): void;
|
|
24
|
+
/** Store an explicit preference map (e.g. from a preferences dialog). */
|
|
25
|
+
set(preferences: ConsentPreferences): void;
|
|
26
|
+
/** Forget the stored choice so the banner returns and gated code stops. */
|
|
27
|
+
clear(): void;
|
|
28
|
+
};
|
|
29
|
+
/** Window event fired whenever a consent decision is written or cleared. */
|
|
30
|
+
export declare const CONSENT_CHANGE_EVENT = "slipstream:consent-change";
|
|
31
|
+
/**
|
|
32
|
+
* Headless consent state: reads a per-purpose decision from localStorage,
|
|
33
|
+
* persists accept/decline/customize choices, expires stale decisions, and
|
|
34
|
+
* keeps every `useConsent` instance on the page in sync through a window
|
|
35
|
+
* event (plus the native `storage` event for other tabs).
|
|
36
|
+
*
|
|
37
|
+
* The first client render reports `decided: false` so SSR markup matches;
|
|
38
|
+
* the stored value is read in an effect after mount. To avoid a banner
|
|
39
|
+
* flash for returning visitors, gate first paint with a theme-script class
|
|
40
|
+
* the way cookie-banner implementations typically do.
|
|
41
|
+
*/
|
|
42
|
+
export declare function useConsent({ storageKey, purposes, maxAgeMs, }?: UseConsentOptions): Consent;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var consent_exports = {};
|
|
30
|
+
__export(consent_exports, {
|
|
31
|
+
CONSENT_CHANGE_EVENT: () => CONSENT_CHANGE_EVENT,
|
|
32
|
+
useConsent: () => useConsent
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(consent_exports);
|
|
35
|
+
var React = __toESM(require("react"));
|
|
36
|
+
const DEFAULT_STORAGE_KEY = "slipstream-consent";
|
|
37
|
+
const DEFAULT_MAX_AGE_MS = 180 * 24 * 60 * 60 * 1e3;
|
|
38
|
+
const DEFAULT_PURPOSES = ["analytics"];
|
|
39
|
+
const CONSENT_CHANGE_EVENT = "slipstream:consent-change";
|
|
40
|
+
function isPurposeMap(value, purposes) {
|
|
41
|
+
if (typeof value !== "object" || value === null) return false;
|
|
42
|
+
const record = value;
|
|
43
|
+
return purposes.every((purpose) => typeof record[purpose] === "boolean");
|
|
44
|
+
}
|
|
45
|
+
function readStored(storageKey, purposes, maxAgeMs) {
|
|
46
|
+
try {
|
|
47
|
+
const raw = window.localStorage.getItem(storageKey);
|
|
48
|
+
if (!raw) return null;
|
|
49
|
+
const parsed = JSON.parse(raw);
|
|
50
|
+
if (typeof parsed !== "object" || parsed === null) return null;
|
|
51
|
+
const { p, at } = parsed;
|
|
52
|
+
if (typeof at !== "number" || !Number.isFinite(at)) return null;
|
|
53
|
+
if (Date.now() - at >= maxAgeMs) return null;
|
|
54
|
+
if (!isPurposeMap(p, purposes)) return null;
|
|
55
|
+
const preferences = {};
|
|
56
|
+
for (const purpose of purposes) preferences[purpose] = p[purpose];
|
|
57
|
+
return preferences;
|
|
58
|
+
} catch {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function writeStored(storageKey, preferences) {
|
|
63
|
+
try {
|
|
64
|
+
window.localStorage.setItem(storageKey, JSON.stringify({ p: preferences, at: Date.now() }));
|
|
65
|
+
} catch {
|
|
66
|
+
}
|
|
67
|
+
window.dispatchEvent(
|
|
68
|
+
new CustomEvent(CONSENT_CHANGE_EVENT, {
|
|
69
|
+
detail: { storageKey, preferences }
|
|
70
|
+
})
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
function clearStored(storageKey) {
|
|
74
|
+
try {
|
|
75
|
+
window.localStorage.removeItem(storageKey);
|
|
76
|
+
} catch {
|
|
77
|
+
}
|
|
78
|
+
window.dispatchEvent(
|
|
79
|
+
new CustomEvent(CONSENT_CHANGE_EVENT, {
|
|
80
|
+
detail: { storageKey, preferences: null }
|
|
81
|
+
})
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
function useConsent({
|
|
85
|
+
storageKey = DEFAULT_STORAGE_KEY,
|
|
86
|
+
purposes = DEFAULT_PURPOSES,
|
|
87
|
+
maxAgeMs = DEFAULT_MAX_AGE_MS
|
|
88
|
+
} = {}) {
|
|
89
|
+
const [preferences, setPreferences] = React.useState(null);
|
|
90
|
+
const purposesRef = React.useRef(purposes);
|
|
91
|
+
purposesRef.current = purposes;
|
|
92
|
+
const purposesKey = purposes.join("");
|
|
93
|
+
React.useEffect(() => {
|
|
94
|
+
const active = purposesRef.current;
|
|
95
|
+
const sync = () => setPreferences(readStored(storageKey, active, maxAgeMs));
|
|
96
|
+
sync();
|
|
97
|
+
const onChange = (event) => {
|
|
98
|
+
const detail = event.detail;
|
|
99
|
+
if (detail?.storageKey === storageKey) {
|
|
100
|
+
setPreferences(detail.preferences);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const onStorage = (event) => {
|
|
104
|
+
if (event.key === storageKey || event.key === null) sync();
|
|
105
|
+
};
|
|
106
|
+
window.addEventListener(CONSENT_CHANGE_EVENT, onChange);
|
|
107
|
+
window.addEventListener("storage", onStorage);
|
|
108
|
+
return () => {
|
|
109
|
+
window.removeEventListener(CONSENT_CHANGE_EVENT, onChange);
|
|
110
|
+
window.removeEventListener("storage", onStorage);
|
|
111
|
+
};
|
|
112
|
+
}, [storageKey, maxAgeMs, purposesKey]);
|
|
113
|
+
const setAll = React.useCallback(
|
|
114
|
+
(allowed) => {
|
|
115
|
+
const next = {};
|
|
116
|
+
for (const purpose of purposesRef.current) next[purpose] = allowed;
|
|
117
|
+
writeStored(storageKey, next);
|
|
118
|
+
setPreferences(next);
|
|
119
|
+
},
|
|
120
|
+
[storageKey]
|
|
121
|
+
);
|
|
122
|
+
const set = React.useCallback(
|
|
123
|
+
(next) => {
|
|
124
|
+
const merged = {};
|
|
125
|
+
for (const purpose of purposesRef.current) merged[purpose] = next[purpose] === true;
|
|
126
|
+
writeStored(storageKey, merged);
|
|
127
|
+
setPreferences(merged);
|
|
128
|
+
},
|
|
129
|
+
[storageKey]
|
|
130
|
+
);
|
|
131
|
+
const clear = React.useCallback(() => {
|
|
132
|
+
clearStored(storageKey);
|
|
133
|
+
setPreferences(null);
|
|
134
|
+
}, [storageKey]);
|
|
135
|
+
return { preferences, decided: preferences !== null, setAll, set, clear };
|
|
136
|
+
}
|
|
137
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
138
|
+
0 && (module.exports = {
|
|
139
|
+
CONSENT_CHANGE_EVENT,
|
|
140
|
+
useConsent
|
|
141
|
+
});
|
|
142
|
+
//# sourceMappingURL=consent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/consent.ts"],"sourcesContent":["import * as React from 'react';\n\n/**\n * Per-purpose consent choices, e.g. `{ analytics: true, marketing: false }`.\n * Consumers define their own purpose keys via `useConsent({ purposes })`.\n */\nexport type ConsentPreferences = Record<string, boolean>;\n\nexport type UseConsentOptions = {\n /** localStorage key for the stored decision. Default 'slipstream-consent'. */\n storageKey?: string;\n /** Consent purposes persisted as booleans. Default ['analytics']. */\n purposes?: readonly string[];\n /**\n * How long a stored decision stays valid before the visitor is asked\n * again. Default 180 days (common EU consent-refresh guidance).\n */\n maxAgeMs?: number;\n};\n\nexport type Consent = {\n /** Current per-purpose preferences, or null when undecided or expired. */\n preferences: ConsentPreferences | null;\n /** True once the visitor has a valid stored decision. */\n decided: boolean;\n /** Set every purpose to the same value — the banner's accept/decline. */\n setAll(allowed: boolean): void;\n /** Store an explicit preference map (e.g. from a preferences dialog). */\n set(preferences: ConsentPreferences): void;\n /** Forget the stored choice so the banner returns and gated code stops. */\n clear(): void;\n};\n\nconst DEFAULT_STORAGE_KEY = 'slipstream-consent';\nconst DEFAULT_MAX_AGE_MS = 180 * 24 * 60 * 60 * 1000;\nconst DEFAULT_PURPOSES = ['analytics'] as const;\n\n/** Window event fired whenever a consent decision is written or cleared. */\nexport const CONSENT_CHANGE_EVENT = 'slipstream:consent-change';\n\ntype ConsentChangeDetail = { storageKey: string; preferences: ConsentPreferences | null };\n\ntype StoredConsent = { p?: unknown; at?: unknown };\n\nfunction isPurposeMap(value: unknown, purposes: readonly string[]): value is ConsentPreferences {\n if (typeof value !== 'object' || value === null) return false;\n const record = value as Record<string, unknown>;\n return purposes.every((purpose) => typeof record[purpose] === 'boolean');\n}\n\nfunction readStored(\n storageKey: string,\n purposes: readonly string[],\n maxAgeMs: number\n): ConsentPreferences | null {\n try {\n const raw = window.localStorage.getItem(storageKey);\n if (!raw) return null;\n const parsed: unknown = JSON.parse(raw);\n if (typeof parsed !== 'object' || parsed === null) return null;\n const { p, at } = parsed as StoredConsent;\n if (typeof at !== 'number' || !Number.isFinite(at)) return null;\n if (Date.now() - at >= maxAgeMs) return null;\n if (!isPurposeMap(p, purposes)) return null;\n const preferences: ConsentPreferences = {};\n for (const purpose of purposes) preferences[purpose] = p[purpose];\n return preferences;\n } catch {\n return null;\n }\n}\n\nfunction writeStored(storageKey: string, preferences: ConsentPreferences): void {\n try {\n window.localStorage.setItem(storageKey, JSON.stringify({ p: preferences, at: Date.now() }));\n } catch {\n /* storage blocked — consent simply isn't persisted */\n }\n window.dispatchEvent(\n new CustomEvent<ConsentChangeDetail>(CONSENT_CHANGE_EVENT, {\n detail: { storageKey, preferences },\n })\n );\n}\n\nfunction clearStored(storageKey: string): void {\n try {\n window.localStorage.removeItem(storageKey);\n } catch {\n /* storage blocked — nothing to clear */\n }\n window.dispatchEvent(\n new CustomEvent<ConsentChangeDetail>(CONSENT_CHANGE_EVENT, {\n detail: { storageKey, preferences: null },\n })\n );\n}\n\n/**\n * Headless consent state: reads a per-purpose decision from localStorage,\n * persists accept/decline/customize choices, expires stale decisions, and\n * keeps every `useConsent` instance on the page in sync through a window\n * event (plus the native `storage` event for other tabs).\n *\n * The first client render reports `decided: false` so SSR markup matches;\n * the stored value is read in an effect after mount. To avoid a banner\n * flash for returning visitors, gate first paint with a theme-script class\n * the way cookie-banner implementations typically do.\n */\nexport function useConsent({\n storageKey = DEFAULT_STORAGE_KEY,\n purposes = DEFAULT_PURPOSES,\n maxAgeMs = DEFAULT_MAX_AGE_MS,\n}: UseConsentOptions = {}): Consent {\n const [preferences, setPreferences] = React.useState<ConsentPreferences | null>(null);\n // Callbacks stay referentially stable while always seeing the latest\n // purposes array, which consumers often pass inline.\n const purposesRef = React.useRef(purposes);\n purposesRef.current = purposes;\n const purposesKey = purposes.join('\u0001');\n\n React.useEffect(() => {\n const active = purposesRef.current;\n const sync = () => setPreferences(readStored(storageKey, active, maxAgeMs));\n sync();\n const onChange = (event: Event) => {\n const detail = (event as CustomEvent<ConsentChangeDetail>).detail;\n if (detail?.storageKey === storageKey) {\n setPreferences(detail.preferences);\n }\n };\n const onStorage = (event: StorageEvent) => {\n if (event.key === storageKey || event.key === null) sync();\n };\n window.addEventListener(CONSENT_CHANGE_EVENT, onChange);\n window.addEventListener('storage', onStorage);\n return () => {\n window.removeEventListener(CONSENT_CHANGE_EVENT, onChange);\n window.removeEventListener('storage', onStorage);\n };\n }, [storageKey, maxAgeMs, purposesKey]);\n\n const setAll = React.useCallback(\n (allowed: boolean) => {\n const next: ConsentPreferences = {};\n for (const purpose of purposesRef.current) next[purpose] = allowed;\n writeStored(storageKey, next);\n setPreferences(next);\n },\n [storageKey]\n );\n\n const set = React.useCallback(\n (next: ConsentPreferences) => {\n const merged: ConsentPreferences = {};\n for (const purpose of purposesRef.current) merged[purpose] = next[purpose] === true;\n writeStored(storageKey, merged);\n setPreferences(merged);\n },\n [storageKey]\n );\n\n const clear = React.useCallback(() => {\n clearStored(storageKey);\n setPreferences(null);\n }, [storageKey]);\n\n return { preferences, decided: preferences !== null, setAll, set, clear };\n}\n"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const DEFAULT_STORAGE_KEY = "slipstream-consent";
|
|
3
|
+
const DEFAULT_MAX_AGE_MS = 180 * 24 * 60 * 60 * 1e3;
|
|
4
|
+
const DEFAULT_PURPOSES = ["analytics"];
|
|
5
|
+
const CONSENT_CHANGE_EVENT = "slipstream:consent-change";
|
|
6
|
+
function isPurposeMap(value, purposes) {
|
|
7
|
+
if (typeof value !== "object" || value === null) return false;
|
|
8
|
+
const record = value;
|
|
9
|
+
return purposes.every((purpose) => typeof record[purpose] === "boolean");
|
|
10
|
+
}
|
|
11
|
+
function readStored(storageKey, purposes, maxAgeMs) {
|
|
12
|
+
try {
|
|
13
|
+
const raw = window.localStorage.getItem(storageKey);
|
|
14
|
+
if (!raw) return null;
|
|
15
|
+
const parsed = JSON.parse(raw);
|
|
16
|
+
if (typeof parsed !== "object" || parsed === null) return null;
|
|
17
|
+
const { p, at } = parsed;
|
|
18
|
+
if (typeof at !== "number" || !Number.isFinite(at)) return null;
|
|
19
|
+
if (Date.now() - at >= maxAgeMs) return null;
|
|
20
|
+
if (!isPurposeMap(p, purposes)) return null;
|
|
21
|
+
const preferences = {};
|
|
22
|
+
for (const purpose of purposes) preferences[purpose] = p[purpose];
|
|
23
|
+
return preferences;
|
|
24
|
+
} catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function writeStored(storageKey, preferences) {
|
|
29
|
+
try {
|
|
30
|
+
window.localStorage.setItem(storageKey, JSON.stringify({ p: preferences, at: Date.now() }));
|
|
31
|
+
} catch {
|
|
32
|
+
}
|
|
33
|
+
window.dispatchEvent(
|
|
34
|
+
new CustomEvent(CONSENT_CHANGE_EVENT, {
|
|
35
|
+
detail: { storageKey, preferences }
|
|
36
|
+
})
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
function clearStored(storageKey) {
|
|
40
|
+
try {
|
|
41
|
+
window.localStorage.removeItem(storageKey);
|
|
42
|
+
} catch {
|
|
43
|
+
}
|
|
44
|
+
window.dispatchEvent(
|
|
45
|
+
new CustomEvent(CONSENT_CHANGE_EVENT, {
|
|
46
|
+
detail: { storageKey, preferences: null }
|
|
47
|
+
})
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
function useConsent({
|
|
51
|
+
storageKey = DEFAULT_STORAGE_KEY,
|
|
52
|
+
purposes = DEFAULT_PURPOSES,
|
|
53
|
+
maxAgeMs = DEFAULT_MAX_AGE_MS
|
|
54
|
+
} = {}) {
|
|
55
|
+
const [preferences, setPreferences] = React.useState(null);
|
|
56
|
+
const purposesRef = React.useRef(purposes);
|
|
57
|
+
purposesRef.current = purposes;
|
|
58
|
+
const purposesKey = purposes.join("");
|
|
59
|
+
React.useEffect(() => {
|
|
60
|
+
const active = purposesRef.current;
|
|
61
|
+
const sync = () => setPreferences(readStored(storageKey, active, maxAgeMs));
|
|
62
|
+
sync();
|
|
63
|
+
const onChange = (event) => {
|
|
64
|
+
const detail = event.detail;
|
|
65
|
+
if (detail?.storageKey === storageKey) {
|
|
66
|
+
setPreferences(detail.preferences);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const onStorage = (event) => {
|
|
70
|
+
if (event.key === storageKey || event.key === null) sync();
|
|
71
|
+
};
|
|
72
|
+
window.addEventListener(CONSENT_CHANGE_EVENT, onChange);
|
|
73
|
+
window.addEventListener("storage", onStorage);
|
|
74
|
+
return () => {
|
|
75
|
+
window.removeEventListener(CONSENT_CHANGE_EVENT, onChange);
|
|
76
|
+
window.removeEventListener("storage", onStorage);
|
|
77
|
+
};
|
|
78
|
+
}, [storageKey, maxAgeMs, purposesKey]);
|
|
79
|
+
const setAll = React.useCallback(
|
|
80
|
+
(allowed) => {
|
|
81
|
+
const next = {};
|
|
82
|
+
for (const purpose of purposesRef.current) next[purpose] = allowed;
|
|
83
|
+
writeStored(storageKey, next);
|
|
84
|
+
setPreferences(next);
|
|
85
|
+
},
|
|
86
|
+
[storageKey]
|
|
87
|
+
);
|
|
88
|
+
const set = React.useCallback(
|
|
89
|
+
(next) => {
|
|
90
|
+
const merged = {};
|
|
91
|
+
for (const purpose of purposesRef.current) merged[purpose] = next[purpose] === true;
|
|
92
|
+
writeStored(storageKey, merged);
|
|
93
|
+
setPreferences(merged);
|
|
94
|
+
},
|
|
95
|
+
[storageKey]
|
|
96
|
+
);
|
|
97
|
+
const clear = React.useCallback(() => {
|
|
98
|
+
clearStored(storageKey);
|
|
99
|
+
setPreferences(null);
|
|
100
|
+
}, [storageKey]);
|
|
101
|
+
return { preferences, decided: preferences !== null, setAll, set, clear };
|
|
102
|
+
}
|
|
103
|
+
export {
|
|
104
|
+
CONSENT_CHANGE_EVENT,
|
|
105
|
+
useConsent
|
|
106
|
+
};
|
|
107
|
+
//# sourceMappingURL=consent.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/consent.ts"],"sourcesContent":["import * as React from 'react';\n\n/**\n * Per-purpose consent choices, e.g. `{ analytics: true, marketing: false }`.\n * Consumers define their own purpose keys via `useConsent({ purposes })`.\n */\nexport type ConsentPreferences = Record<string, boolean>;\n\nexport type UseConsentOptions = {\n /** localStorage key for the stored decision. Default 'slipstream-consent'. */\n storageKey?: string;\n /** Consent purposes persisted as booleans. Default ['analytics']. */\n purposes?: readonly string[];\n /**\n * How long a stored decision stays valid before the visitor is asked\n * again. Default 180 days (common EU consent-refresh guidance).\n */\n maxAgeMs?: number;\n};\n\nexport type Consent = {\n /** Current per-purpose preferences, or null when undecided or expired. */\n preferences: ConsentPreferences | null;\n /** True once the visitor has a valid stored decision. */\n decided: boolean;\n /** Set every purpose to the same value — the banner's accept/decline. */\n setAll(allowed: boolean): void;\n /** Store an explicit preference map (e.g. from a preferences dialog). */\n set(preferences: ConsentPreferences): void;\n /** Forget the stored choice so the banner returns and gated code stops. */\n clear(): void;\n};\n\nconst DEFAULT_STORAGE_KEY = 'slipstream-consent';\nconst DEFAULT_MAX_AGE_MS = 180 * 24 * 60 * 60 * 1000;\nconst DEFAULT_PURPOSES = ['analytics'] as const;\n\n/** Window event fired whenever a consent decision is written or cleared. */\nexport const CONSENT_CHANGE_EVENT = 'slipstream:consent-change';\n\ntype ConsentChangeDetail = { storageKey: string; preferences: ConsentPreferences | null };\n\ntype StoredConsent = { p?: unknown; at?: unknown };\n\nfunction isPurposeMap(value: unknown, purposes: readonly string[]): value is ConsentPreferences {\n if (typeof value !== 'object' || value === null) return false;\n const record = value as Record<string, unknown>;\n return purposes.every((purpose) => typeof record[purpose] === 'boolean');\n}\n\nfunction readStored(\n storageKey: string,\n purposes: readonly string[],\n maxAgeMs: number\n): ConsentPreferences | null {\n try {\n const raw = window.localStorage.getItem(storageKey);\n if (!raw) return null;\n const parsed: unknown = JSON.parse(raw);\n if (typeof parsed !== 'object' || parsed === null) return null;\n const { p, at } = parsed as StoredConsent;\n if (typeof at !== 'number' || !Number.isFinite(at)) return null;\n if (Date.now() - at >= maxAgeMs) return null;\n if (!isPurposeMap(p, purposes)) return null;\n const preferences: ConsentPreferences = {};\n for (const purpose of purposes) preferences[purpose] = p[purpose];\n return preferences;\n } catch {\n return null;\n }\n}\n\nfunction writeStored(storageKey: string, preferences: ConsentPreferences): void {\n try {\n window.localStorage.setItem(storageKey, JSON.stringify({ p: preferences, at: Date.now() }));\n } catch {\n /* storage blocked — consent simply isn't persisted */\n }\n window.dispatchEvent(\n new CustomEvent<ConsentChangeDetail>(CONSENT_CHANGE_EVENT, {\n detail: { storageKey, preferences },\n })\n );\n}\n\nfunction clearStored(storageKey: string): void {\n try {\n window.localStorage.removeItem(storageKey);\n } catch {\n /* storage blocked — nothing to clear */\n }\n window.dispatchEvent(\n new CustomEvent<ConsentChangeDetail>(CONSENT_CHANGE_EVENT, {\n detail: { storageKey, preferences: null },\n })\n );\n}\n\n/**\n * Headless consent state: reads a per-purpose decision from localStorage,\n * persists accept/decline/customize choices, expires stale decisions, and\n * keeps every `useConsent` instance on the page in sync through a window\n * event (plus the native `storage` event for other tabs).\n *\n * The first client render reports `decided: false` so SSR markup matches;\n * the stored value is read in an effect after mount. To avoid a banner\n * flash for returning visitors, gate first paint with a theme-script class\n * the way cookie-banner implementations typically do.\n */\nexport function useConsent({\n storageKey = DEFAULT_STORAGE_KEY,\n purposes = DEFAULT_PURPOSES,\n maxAgeMs = DEFAULT_MAX_AGE_MS,\n}: UseConsentOptions = {}): Consent {\n const [preferences, setPreferences] = React.useState<ConsentPreferences | null>(null);\n // Callbacks stay referentially stable while always seeing the latest\n // purposes array, which consumers often pass inline.\n const purposesRef = React.useRef(purposes);\n purposesRef.current = purposes;\n const purposesKey = purposes.join('\u0001');\n\n React.useEffect(() => {\n const active = purposesRef.current;\n const sync = () => setPreferences(readStored(storageKey, active, maxAgeMs));\n sync();\n const onChange = (event: Event) => {\n const detail = (event as CustomEvent<ConsentChangeDetail>).detail;\n if (detail?.storageKey === storageKey) {\n setPreferences(detail.preferences);\n }\n };\n const onStorage = (event: StorageEvent) => {\n if (event.key === storageKey || event.key === null) sync();\n };\n window.addEventListener(CONSENT_CHANGE_EVENT, onChange);\n window.addEventListener('storage', onStorage);\n return () => {\n window.removeEventListener(CONSENT_CHANGE_EVENT, onChange);\n window.removeEventListener('storage', onStorage);\n };\n }, [storageKey, maxAgeMs, purposesKey]);\n\n const setAll = React.useCallback(\n (allowed: boolean) => {\n const next: ConsentPreferences = {};\n for (const purpose of purposesRef.current) next[purpose] = allowed;\n writeStored(storageKey, next);\n setPreferences(next);\n },\n [storageKey]\n );\n\n const set = React.useCallback(\n (next: ConsentPreferences) => {\n const merged: ConsentPreferences = {};\n for (const purpose of purposesRef.current) merged[purpose] = next[purpose] === true;\n writeStored(storageKey, merged);\n setPreferences(merged);\n },\n [storageKey]\n );\n\n const clear = React.useCallback(() => {\n clearStored(storageKey);\n setPreferences(null);\n }, [storageKey]);\n\n return { preferences, decided: preferences !== null, setAll, set, clear };\n}\n"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ElementType } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Shared props for components that can render a destination through a
|
|
4
|
+
* router-aware link element. `linkComponent` swaps the underlying element
|
|
5
|
+
* (Next `Link`, react-router `Link`); `linkHrefProp` names the prop that
|
|
6
|
+
* carries the destination on that element (`href` or `to`).
|
|
7
|
+
*/
|
|
8
|
+
export type LinkLikeProps = {
|
|
9
|
+
/** Custom link element for routers (Next Link, react-router Link). */
|
|
10
|
+
linkComponent?: ElementType;
|
|
11
|
+
/** Prop used to pass the destination to `linkComponent`. */
|
|
12
|
+
linkHrefProp?: 'href' | 'to';
|
|
13
|
+
};
|
|
14
|
+
/** Props object carrying a destination for `linkComponent`/`linkHrefProp`. */
|
|
15
|
+
export declare function linkDestination(href: string, linkHrefProp?: 'href' | 'to'): {
|
|
16
|
+
to: string;
|
|
17
|
+
href?: undefined;
|
|
18
|
+
} | {
|
|
19
|
+
href: string;
|
|
20
|
+
to?: undefined;
|
|
21
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var link_exports = {};
|
|
20
|
+
__export(link_exports, {
|
|
21
|
+
linkDestination: () => linkDestination
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(link_exports);
|
|
24
|
+
function linkDestination(href, linkHrefProp = "href") {
|
|
25
|
+
return linkHrefProp === "to" ? { to: href } : { href };
|
|
26
|
+
}
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
linkDestination
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=link.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/link.ts"],"sourcesContent":["import type { ElementType } from 'react';\n\n/**\n * Shared props for components that can render a destination through a\n * router-aware link element. `linkComponent` swaps the underlying element\n * (Next `Link`, react-router `Link`); `linkHrefProp` names the prop that\n * carries the destination on that element (`href` or `to`).\n */\nexport type LinkLikeProps = {\n /** Custom link element for routers (Next Link, react-router Link). */\n linkComponent?: ElementType;\n /** Prop used to pass the destination to `linkComponent`. */\n linkHrefProp?: 'href' | 'to';\n};\n\n/** Props object carrying a destination for `linkComponent`/`linkHrefProp`. */\nexport function linkDestination(href: string, linkHrefProp: 'href' | 'to' = 'href') {\n return linkHrefProp === 'to' ? { to: href } : { href };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBO,SAAS,gBAAgB,MAAc,eAA8B,QAAQ;AAClF,SAAO,iBAAiB,OAAO,EAAE,IAAI,KAAK,IAAI,EAAE,KAAK;AACvD;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/link.ts"],"sourcesContent":["import type { ElementType } from 'react';\n\n/**\n * Shared props for components that can render a destination through a\n * router-aware link element. `linkComponent` swaps the underlying element\n * (Next `Link`, react-router `Link`); `linkHrefProp` names the prop that\n * carries the destination on that element (`href` or `to`).\n */\nexport type LinkLikeProps = {\n /** Custom link element for routers (Next Link, react-router Link). */\n linkComponent?: ElementType;\n /** Prop used to pass the destination to `linkComponent`. */\n linkHrefProp?: 'href' | 'to';\n};\n\n/** Props object carrying a destination for `linkComponent`/`linkHrefProp`. */\nexport function linkDestination(href: string, linkHrefProp: 'href' | 'to' = 'href') {\n return linkHrefProp === 'to' ? { to: href } : { href };\n}\n"],"mappings":"AAgBO,SAAS,gBAAgB,MAAc,eAA8B,QAAQ;AAClF,SAAO,iBAAiB,OAAO,EAAE,IAAI,KAAK,IAAI,EAAE,KAAK;AACvD;","names":[]}
|