@slipstream-ui/core 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +184 -8
- package/dist/index.d.ts +184 -8
- package/dist/index.js +1609 -887
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1651 -933
- package/dist/index.mjs.map +1 -1
- package/dist/manifests/accordion.manifest.json +2 -2
- package/dist/manifests/alert.manifest.json +1 -1
- package/dist/manifests/announcement-bar.manifest.json +1 -1
- package/dist/manifests/app-shell.manifest.json +1 -1
- package/dist/manifests/applied-filters.manifest.json +1 -1
- package/dist/manifests/article-card.manifest.json +1 -1
- package/dist/manifests/auth-layout.manifest.json +1 -1
- package/dist/manifests/autocomplete.manifest.json +1 -1
- package/dist/manifests/avatar.manifest.json +1 -1
- package/dist/manifests/badge.manifest.json +1 -1
- package/dist/manifests/block.manifest.json +1 -1
- package/dist/manifests/bottom-nav.manifest.json +1 -1
- package/dist/manifests/breadcrumb.manifest.json +1 -1
- package/dist/manifests/button-group.manifest.json +1 -1
- package/dist/manifests/button.manifest.json +1 -1
- package/dist/manifests/calendar.manifest.json +175 -0
- package/dist/manifests/card.manifest.json +1 -1
- package/dist/manifests/checkbox.manifest.json +1 -1
- package/dist/manifests/comparison-table.manifest.json +1 -1
- package/dist/manifests/confirm-dialog.manifest.json +1 -1
- package/dist/manifests/contact-strip.manifest.json +1 -1
- package/dist/manifests/container.manifest.json +1 -1
- package/dist/manifests/cta-section.manifest.json +1 -1
- package/dist/manifests/data-table.manifest.json +8 -1
- package/dist/manifests/date-picker-popover.manifest.json +202 -0
- package/dist/manifests/date-picker.manifest.json +1 -1
- package/dist/manifests/date-range-picker.manifest.json +1 -1
- package/dist/manifests/deal-card.manifest.json +1 -1
- package/dist/manifests/dialog.manifest.json +1 -1
- package/dist/manifests/document-card.manifest.json +1 -1
- package/dist/manifests/drawer.manifest.json +1 -1
- package/dist/manifests/empty-state.manifest.json +1 -1
- package/dist/manifests/entity-card.manifest.json +1 -1
- package/dist/manifests/feature-grid.manifest.json +1 -1
- package/dist/manifests/feature-row.manifest.json +1 -1
- package/dist/manifests/fieldset.manifest.json +1 -1
- package/dist/manifests/file-upload.manifest.json +1 -1
- package/dist/manifests/filter-bar.manifest.json +1 -1
- package/dist/manifests/filter-chips.manifest.json +1 -1
- package/dist/manifests/filter-panel.manifest.json +1 -1
- package/dist/manifests/flex.manifest.json +1 -1
- package/dist/manifests/form-field.manifest.json +1 -1
- package/dist/manifests/form-layout.manifest.json +1 -1
- package/dist/manifests/form.manifest.json +1 -1
- package/dist/manifests/grid.manifest.json +1 -1
- package/dist/manifests/heading.manifest.json +1 -1
- package/dist/manifests/hero.manifest.json +1 -1
- package/dist/manifests/image.manifest.json +142 -0
- package/dist/manifests/input-group.manifest.json +1 -1
- package/dist/manifests/input.manifest.json +1 -1
- package/dist/manifests/label.manifest.json +1 -1
- package/dist/manifests/link-tabs.manifest.json +1 -1
- package/dist/manifests/link.manifest.json +1 -1
- package/dist/manifests/list.manifest.json +1 -1
- package/dist/manifests/load-more.manifest.json +1 -1
- package/dist/manifests/logo-cloud.manifest.json +1 -1
- package/dist/manifests/menu.manifest.json +1 -1
- package/dist/manifests/metric-card.manifest.json +1 -1
- package/dist/manifests/multi-select.manifest.json +1 -1
- package/dist/manifests/newsletter.manifest.json +1 -1
- package/dist/manifests/page-header.manifest.json +1 -1
- package/dist/manifests/pagination.manifest.json +1 -1
- package/dist/manifests/password-input.manifest.json +1 -1
- package/dist/manifests/popover.manifest.json +86 -4
- package/dist/manifests/process-steps.manifest.json +1 -1
- package/dist/manifests/progress.manifest.json +1 -1
- package/dist/manifests/prose.manifest.json +1 -1
- package/dist/manifests/radio.manifest.json +1 -1
- package/dist/manifests/range-slider.manifest.json +1 -1
- package/dist/manifests/search.manifest.json +1 -1
- package/dist/manifests/section-heading.manifest.json +1 -1
- package/dist/manifests/section.manifest.json +1 -1
- package/dist/manifests/segmented-control.manifest.json +1 -1
- package/dist/manifests/select-menu.manifest.json +1 -1
- package/dist/manifests/select.manifest.json +1 -1
- package/dist/manifests/separator.manifest.json +1 -1
- package/dist/manifests/site-footer.manifest.json +1 -1
- package/dist/manifests/site-header.manifest.json +13 -3
- package/dist/manifests/skeleton.manifest.json +1 -1
- package/dist/manifests/spinner.manifest.json +1 -1
- package/dist/manifests/stat-band.manifest.json +1 -1
- package/dist/manifests/stepper.manifest.json +7 -1
- package/dist/manifests/switch.manifest.json +1 -1
- package/dist/manifests/table-card.manifest.json +1 -1
- package/dist/manifests/table-of-contents.manifest.json +1 -1
- package/dist/manifests/table.manifest.json +1 -1
- package/dist/manifests/tabs.manifest.json +1 -1
- package/dist/manifests/testimonial.manifest.json +1 -1
- package/dist/manifests/text.manifest.json +1 -1
- package/dist/manifests/textarea.manifest.json +1 -1
- package/dist/manifests/theme-toggle.manifest.json +1 -1
- package/dist/manifests/time-picker.manifest.json +1 -1
- package/dist/manifests/timeline.manifest.json +1 -1
- package/dist/manifests/toast.manifest.json +1 -1
- package/dist/manifests/tombstone-card.manifest.json +1 -1
- package/dist/manifests/tooltip.manifest.json +1 -1
- package/dist/src/components/alert/Alert.js +1 -1
- package/dist/src/components/alert/Alert.js.map +1 -1
- package/dist/src/components/alert/Alert.mjs +1 -1
- package/dist/src/components/alert/Alert.mjs.map +1 -1
- package/dist/src/components/app-shell/AppShell.js +1 -1
- package/dist/src/components/app-shell/AppShell.js.map +1 -1
- package/dist/src/components/app-shell/AppShell.mjs +1 -1
- package/dist/src/components/app-shell/AppShell.mjs.map +1 -1
- package/dist/src/components/article-card/ArticleCard.js +2 -2
- package/dist/src/components/article-card/ArticleCard.js.map +1 -1
- package/dist/src/components/article-card/ArticleCard.mjs +2 -2
- package/dist/src/components/article-card/ArticleCard.mjs.map +1 -1
- package/dist/src/components/calendar/Calendar.d.ts +34 -0
- package/dist/src/components/calendar/Calendar.js +233 -0
- package/dist/src/components/calendar/Calendar.js.map +1 -0
- package/dist/src/components/calendar/Calendar.mjs +208 -0
- package/dist/src/components/calendar/Calendar.mjs.map +1 -0
- package/dist/src/components/calendar/index.d.ts +1 -0
- package/dist/src/components/calendar/index.js +23 -0
- package/dist/src/components/calendar/index.js.map +1 -0
- package/dist/src/components/calendar/index.mjs +2 -0
- package/dist/src/components/calendar/index.mjs.map +1 -0
- package/dist/src/components/comparison-table/ComparisonTable.js +1 -1
- package/dist/src/components/comparison-table/ComparisonTable.js.map +1 -1
- package/dist/src/components/comparison-table/ComparisonTable.mjs +1 -1
- package/dist/src/components/comparison-table/ComparisonTable.mjs.map +1 -1
- package/dist/src/components/cta-section/CTASection.js +1 -1
- package/dist/src/components/cta-section/CTASection.js.map +1 -1
- package/dist/src/components/cta-section/CTASection.mjs +1 -1
- package/dist/src/components/cta-section/CTASection.mjs.map +1 -1
- package/dist/src/components/data-table/DataTable.d.ts +3 -1
- package/dist/src/components/data-table/DataTable.js +2 -4
- package/dist/src/components/data-table/DataTable.js.map +1 -1
- package/dist/src/components/data-table/DataTable.mjs +2 -4
- package/dist/src/components/data-table/DataTable.mjs.map +1 -1
- package/dist/src/components/date-picker-popover/DatePickerPopover.d.ts +33 -0
- package/dist/src/components/date-picker-popover/DatePickerPopover.js +117 -0
- package/dist/src/components/date-picker-popover/DatePickerPopover.js.map +1 -0
- package/dist/src/components/date-picker-popover/DatePickerPopover.mjs +83 -0
- package/dist/src/components/date-picker-popover/DatePickerPopover.mjs.map +1 -0
- package/dist/src/components/date-picker-popover/index.d.ts +1 -0
- package/dist/src/components/date-picker-popover/index.js +23 -0
- package/dist/src/components/date-picker-popover/index.js.map +1 -0
- package/dist/src/components/date-picker-popover/index.mjs +2 -0
- package/dist/src/components/date-picker-popover/index.mjs.map +1 -0
- package/dist/src/components/image/Image.d.ts +34 -0
- package/dist/src/components/image/Image.js +75 -0
- package/dist/src/components/image/Image.js.map +1 -0
- package/dist/src/components/image/Image.mjs +41 -0
- package/dist/src/components/image/Image.mjs.map +1 -0
- package/dist/src/components/image/index.d.ts +1 -0
- package/dist/src/components/image/index.js +29 -0
- package/dist/src/components/image/index.js.map +1 -0
- package/dist/src/components/image/index.mjs +5 -0
- package/dist/src/components/image/index.mjs.map +1 -0
- package/dist/src/components/link/Link.js +4 -4
- package/dist/src/components/link/Link.js.map +1 -1
- package/dist/src/components/link/Link.mjs +4 -4
- package/dist/src/components/link/Link.mjs.map +1 -1
- package/dist/src/components/page-header/PageHeader.js +1 -1
- package/dist/src/components/page-header/PageHeader.js.map +1 -1
- package/dist/src/components/page-header/PageHeader.mjs +1 -1
- package/dist/src/components/page-header/PageHeader.mjs.map +1 -1
- package/dist/src/components/popover/Popover.d.ts +36 -3
- package/dist/src/components/popover/Popover.js +118 -22
- package/dist/src/components/popover/Popover.js.map +1 -1
- package/dist/src/components/popover/Popover.mjs +117 -22
- package/dist/src/components/popover/Popover.mjs.map +1 -1
- package/dist/src/components/section-heading/SectionHeading.js +1 -1
- package/dist/src/components/section-heading/SectionHeading.js.map +1 -1
- package/dist/src/components/section-heading/SectionHeading.mjs +1 -1
- package/dist/src/components/section-heading/SectionHeading.mjs.map +1 -1
- package/dist/src/components/site-header/SiteHeader.d.ts +25 -3
- package/dist/src/components/site-header/SiteHeader.js +141 -6
- package/dist/src/components/site-header/SiteHeader.js.map +1 -1
- package/dist/src/components/site-header/SiteHeader.mjs +141 -6
- package/dist/src/components/site-header/SiteHeader.mjs.map +1 -1
- package/dist/src/components/stepper/Stepper.d.ts +18 -0
- package/dist/src/components/stepper/Stepper.js +2 -1
- package/dist/src/components/stepper/Stepper.js.map +1 -1
- package/dist/src/components/stepper/Stepper.mjs +2 -1
- package/dist/src/components/stepper/Stepper.mjs.map +1 -1
- package/dist/src/index.d.ts +3 -0
- package/dist/src/utils/date.d.ts +32 -0
- package/dist/src/utils/date.js +171 -0
- package/dist/src/utils/date.js.map +1 -0
- package/dist/src/utils/date.mjs +134 -0
- package/dist/src/utils/date.mjs.map +1 -0
- package/dist/src/utils/position.d.ts +42 -0
- package/dist/src/utils/position.js +91 -0
- package/dist/src/utils/position.js.map +1 -0
- package/dist/src/utils/position.mjs +67 -0
- package/dist/src/utils/position.mjs.map +1 -0
- package/dist/styles-full.css +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/components/alert/Alert.tsx +1 -1
- package/src/components/app-shell/AppShell.tsx +1 -1
- package/src/components/article-card/ArticleCard.tsx +2 -2
- package/src/components/calendar/Calendar.test.tsx +277 -0
- package/src/components/calendar/Calendar.tsx +273 -0
- package/src/components/calendar/index.ts +1 -0
- package/src/components/comparison-table/ComparisonTable.tsx +1 -1
- package/src/components/cta-section/CTASection.tsx +1 -1
- package/src/components/data-table/DataTable.test.tsx +21 -0
- package/src/components/data-table/DataTable.tsx +4 -1
- package/src/components/date-picker-popover/DatePickerPopover.test.tsx +223 -0
- package/src/components/date-picker-popover/DatePickerPopover.tsx +117 -0
- package/src/components/date-picker-popover/index.ts +1 -0
- package/src/components/image/Image.test.tsx +94 -0
- package/src/components/image/Image.tsx +71 -0
- package/src/components/image/index.ts +1 -0
- package/src/components/link/Link.test.tsx +2 -1
- package/src/components/link/Link.tsx +4 -4
- package/src/components/page-header/PageHeader.tsx +1 -1
- package/src/components/popover/Popover.test.tsx +307 -3
- package/src/components/popover/Popover.tsx +228 -91
- package/src/components/section-heading/SectionHeading.tsx +1 -1
- package/src/components/site-header/SiteHeader.test.tsx +103 -1
- package/src/components/site-header/SiteHeader.tsx +220 -16
- package/src/components/stepper/Stepper.test.tsx +12 -0
- package/src/components/stepper/Stepper.tsx +15 -1
- package/src/index.ts +3 -0
- package/src/manifests/accordion.manifest.json +2 -2
- package/src/manifests/alert.manifest.json +1 -1
- package/src/manifests/announcement-bar.manifest.json +1 -1
- package/src/manifests/app-shell.manifest.json +1 -1
- package/src/manifests/applied-filters.manifest.json +1 -1
- package/src/manifests/article-card.manifest.json +1 -1
- package/src/manifests/auth-layout.manifest.json +1 -1
- package/src/manifests/autocomplete.manifest.json +1 -1
- package/src/manifests/avatar.manifest.json +1 -1
- package/src/manifests/badge.manifest.json +1 -1
- package/src/manifests/block.manifest.json +1 -1
- package/src/manifests/bottom-nav.manifest.json +1 -1
- package/src/manifests/breadcrumb.manifest.json +1 -1
- package/src/manifests/button-group.manifest.json +1 -1
- package/src/manifests/button.manifest.json +1 -1
- package/src/manifests/calendar.manifest.json +175 -0
- package/src/manifests/card.manifest.json +1 -1
- package/src/manifests/checkbox.manifest.json +1 -1
- package/src/manifests/comparison-table.manifest.json +1 -1
- package/src/manifests/confirm-dialog.manifest.json +1 -1
- package/src/manifests/contact-strip.manifest.json +1 -1
- package/src/manifests/container.manifest.json +1 -1
- package/src/manifests/cta-section.manifest.json +1 -1
- package/src/manifests/data-table.manifest.json +8 -1
- package/src/manifests/date-picker-popover.manifest.json +202 -0
- package/src/manifests/date-picker.manifest.json +1 -1
- package/src/manifests/date-range-picker.manifest.json +1 -1
- package/src/manifests/deal-card.manifest.json +1 -1
- package/src/manifests/dialog.manifest.json +1 -1
- package/src/manifests/document-card.manifest.json +1 -1
- package/src/manifests/drawer.manifest.json +1 -1
- package/src/manifests/empty-state.manifest.json +1 -1
- package/src/manifests/entity-card.manifest.json +1 -1
- package/src/manifests/feature-grid.manifest.json +1 -1
- package/src/manifests/feature-row.manifest.json +1 -1
- package/src/manifests/fieldset.manifest.json +1 -1
- package/src/manifests/file-upload.manifest.json +1 -1
- package/src/manifests/filter-bar.manifest.json +1 -1
- package/src/manifests/filter-chips.manifest.json +1 -1
- package/src/manifests/filter-panel.manifest.json +1 -1
- package/src/manifests/flex.manifest.json +1 -1
- package/src/manifests/form-field.manifest.json +1 -1
- package/src/manifests/form-layout.manifest.json +1 -1
- package/src/manifests/form.manifest.json +1 -1
- package/src/manifests/grid.manifest.json +1 -1
- package/src/manifests/heading.manifest.json +1 -1
- package/src/manifests/hero.manifest.json +1 -1
- package/src/manifests/image.manifest.json +142 -0
- package/src/manifests/input-group.manifest.json +1 -1
- package/src/manifests/input.manifest.json +1 -1
- package/src/manifests/label.manifest.json +1 -1
- package/src/manifests/link-tabs.manifest.json +1 -1
- package/src/manifests/link.manifest.json +1 -1
- package/src/manifests/list.manifest.json +1 -1
- package/src/manifests/load-more.manifest.json +1 -1
- package/src/manifests/logo-cloud.manifest.json +1 -1
- package/src/manifests/menu.manifest.json +1 -1
- package/src/manifests/metric-card.manifest.json +1 -1
- package/src/manifests/multi-select.manifest.json +1 -1
- package/src/manifests/newsletter.manifest.json +1 -1
- package/src/manifests/page-header.manifest.json +1 -1
- package/src/manifests/pagination.manifest.json +1 -1
- package/src/manifests/password-input.manifest.json +1 -1
- package/src/manifests/popover.manifest.json +86 -4
- package/src/manifests/process-steps.manifest.json +1 -1
- package/src/manifests/progress.manifest.json +1 -1
- package/src/manifests/prose.manifest.json +1 -1
- package/src/manifests/radio.manifest.json +1 -1
- package/src/manifests/range-slider.manifest.json +1 -1
- package/src/manifests/search.manifest.json +1 -1
- package/src/manifests/section-heading.manifest.json +1 -1
- package/src/manifests/section.manifest.json +1 -1
- package/src/manifests/segmented-control.manifest.json +1 -1
- package/src/manifests/select-menu.manifest.json +1 -1
- package/src/manifests/select.manifest.json +1 -1
- package/src/manifests/separator.manifest.json +1 -1
- package/src/manifests/site-footer.manifest.json +1 -1
- package/src/manifests/site-header.manifest.json +13 -3
- package/src/manifests/skeleton.manifest.json +1 -1
- package/src/manifests/spinner.manifest.json +1 -1
- package/src/manifests/stat-band.manifest.json +1 -1
- package/src/manifests/stepper.manifest.json +7 -1
- package/src/manifests/switch.manifest.json +1 -1
- package/src/manifests/table-card.manifest.json +1 -1
- package/src/manifests/table-of-contents.manifest.json +1 -1
- package/src/manifests/table.manifest.json +1 -1
- package/src/manifests/tabs.manifest.json +1 -1
- package/src/manifests/testimonial.manifest.json +1 -1
- package/src/manifests/text.manifest.json +1 -1
- package/src/manifests/textarea.manifest.json +1 -1
- package/src/manifests/theme-toggle.manifest.json +1 -1
- package/src/manifests/time-picker.manifest.json +1 -1
- package/src/manifests/timeline.manifest.json +1 -1
- package/src/manifests/toast.manifest.json +1 -1
- package/src/manifests/tombstone-card.manifest.json +1 -1
- package/src/manifests/tooltip.manifest.json +1 -1
- package/src/utils/date.test.ts +190 -0
- package/src/utils/date.ts +162 -0
- package/src/utils/position.test.ts +227 -0
- package/src/utils/position.ts +129 -0
|
@@ -4,13 +4,36 @@ import * as React from 'react';
|
|
|
4
4
|
import { cn } from '../../utils/cn';
|
|
5
5
|
import { Drawer } from '../drawer/Drawer';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
/** A single destination in the header or inside a mega panel. */
|
|
8
|
+
export type SiteNavLink = {
|
|
8
9
|
href: string;
|
|
9
10
|
label: string;
|
|
10
11
|
/** Render with target=_blank + rel=noopener. */
|
|
11
12
|
external?: boolean;
|
|
13
|
+
/** Optional second line shown in a desktop mega panel. */
|
|
14
|
+
description?: string;
|
|
12
15
|
};
|
|
13
16
|
|
|
17
|
+
/** One column inside a mega panel: a heading and its links. */
|
|
18
|
+
export type SiteNavColumn = {
|
|
19
|
+
heading?: string;
|
|
20
|
+
items: SiteNavLink[];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type SiteNavItem =
|
|
24
|
+
| (SiteNavLink & { columns?: undefined })
|
|
25
|
+
| {
|
|
26
|
+
href?: string;
|
|
27
|
+
label: string;
|
|
28
|
+
external?: boolean;
|
|
29
|
+
description?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Nested navigation. Present items render as a disclosure trigger with
|
|
32
|
+
* a desktop panel and a mobile <details> group instead of a link.
|
|
33
|
+
*/
|
|
34
|
+
columns: SiteNavColumn[];
|
|
35
|
+
};
|
|
36
|
+
|
|
14
37
|
export type SiteHeaderProps = React.HTMLAttributes<HTMLElement> & {
|
|
15
38
|
/** Brand slot - logo/lockup or wordmark. Wrapped in a link to "/". */
|
|
16
39
|
brand: React.ReactNode;
|
|
@@ -53,18 +76,43 @@ export type SiteHeaderProps = React.HTMLAttributes<HTMLElement> & {
|
|
|
53
76
|
navClassName?: string;
|
|
54
77
|
};
|
|
55
78
|
|
|
56
|
-
function isActive(
|
|
79
|
+
function isActive(
|
|
80
|
+
itemHref: string,
|
|
81
|
+
activeHref: string | undefined,
|
|
82
|
+
match: 'prefix' | 'exact'
|
|
83
|
+
): boolean {
|
|
57
84
|
if (!activeHref) return false;
|
|
58
85
|
if (itemHref === activeHref) return true;
|
|
59
86
|
if (match === 'exact') return false;
|
|
60
87
|
// Prefix match on path boundaries: /docs matches /docs/components, not /docsx.
|
|
61
|
-
return
|
|
88
|
+
return (
|
|
89
|
+
activeHref === itemHref ||
|
|
90
|
+
activeHref.startsWith(itemHref.endsWith('/') ? itemHref : `${itemHref}/`)
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function Caret() {
|
|
95
|
+
return (
|
|
96
|
+
<svg
|
|
97
|
+
aria-hidden="true"
|
|
98
|
+
viewBox="0 0 12 12"
|
|
99
|
+
className="h-2.5 w-2.5"
|
|
100
|
+
fill="none"
|
|
101
|
+
stroke="currentColor"
|
|
102
|
+
strokeWidth="1.75"
|
|
103
|
+
strokeLinecap="round"
|
|
104
|
+
strokeLinejoin="round"
|
|
105
|
+
>
|
|
106
|
+
<path d="m2.5 4.5 3.5 3.5 3.5-3.5" />
|
|
107
|
+
</svg>
|
|
108
|
+
);
|
|
62
109
|
}
|
|
63
110
|
|
|
64
111
|
/**
|
|
65
112
|
* Marketing/site header: sticky bar with brand, horizontal navigation with
|
|
66
|
-
* prefix-aware active states,
|
|
67
|
-
* Router-agnostic through `linkComponent` +
|
|
113
|
+
* prefix-aware active states, optional nested mega panels, right-aligned
|
|
114
|
+
* actions and a mobile drawer. Router-agnostic through `linkComponent` +
|
|
115
|
+
* `linkHrefProp`.
|
|
68
116
|
*/
|
|
69
117
|
export function SiteHeader({
|
|
70
118
|
brand,
|
|
@@ -87,6 +135,8 @@ export function SiteHeader({
|
|
|
87
135
|
...props
|
|
88
136
|
}: SiteHeaderProps) {
|
|
89
137
|
const [mobileOpen, setMobileOpen] = React.useState(false);
|
|
138
|
+
const [openMenu, setOpenMenu] = React.useState<string | null>(null);
|
|
139
|
+
const pendingFocus = React.useRef<string | null>(null);
|
|
90
140
|
const generatedId = React.useId();
|
|
91
141
|
const menuId = `${generatedId}-menu`;
|
|
92
142
|
const Link = linkComponent ?? 'a';
|
|
@@ -94,7 +144,36 @@ export function SiteHeader({
|
|
|
94
144
|
const destination = (href: string) =>
|
|
95
145
|
linkHrefProp === 'to' ? { to: href } : { href };
|
|
96
146
|
|
|
97
|
-
|
|
147
|
+
// Escape and an outside pointer close the desktop panel. Focus movement
|
|
148
|
+
// inside the item is handled by onBlur so tabbing through stays open.
|
|
149
|
+
React.useEffect(() => {
|
|
150
|
+
if (!openMenu) return;
|
|
151
|
+
const onKey = (event: KeyboardEvent) => {
|
|
152
|
+
if (event.key === 'Escape') setOpenMenu(null);
|
|
153
|
+
};
|
|
154
|
+
const onPointer = (event: PointerEvent) => {
|
|
155
|
+
const target = event.target;
|
|
156
|
+
if (!(target instanceof Element)) return;
|
|
157
|
+
if (!target.closest('[data-site-nav-item]')) setOpenMenu(null);
|
|
158
|
+
};
|
|
159
|
+
document.addEventListener('keydown', onKey);
|
|
160
|
+
document.addEventListener('pointerdown', onPointer);
|
|
161
|
+
return () => {
|
|
162
|
+
document.removeEventListener('keydown', onKey);
|
|
163
|
+
document.removeEventListener('pointerdown', onPointer);
|
|
164
|
+
};
|
|
165
|
+
}, [openMenu]);
|
|
166
|
+
|
|
167
|
+
// ArrowDown opens the panel and asks for the first link to take focus, but
|
|
168
|
+
// the panel is hidden until the state render lands, so focus one tick later.
|
|
169
|
+
React.useEffect(() => {
|
|
170
|
+
if (!openMenu || !pendingFocus.current) return;
|
|
171
|
+
const panel = document.getElementById(pendingFocus.current);
|
|
172
|
+
pendingFocus.current = null;
|
|
173
|
+
panel?.querySelector<HTMLElement>('a[href]')?.focus();
|
|
174
|
+
}, [openMenu]);
|
|
175
|
+
|
|
176
|
+
const navLink = (item: SiteNavLink, extra?: 'mobile' | 'panel') => {
|
|
98
177
|
const active = isActive(item.href, activeHref, match);
|
|
99
178
|
return (
|
|
100
179
|
<Link
|
|
@@ -105,17 +184,32 @@ export function SiteHeader({
|
|
|
105
184
|
onClick={extra === 'mobile' ? () => setMobileOpen(false) : undefined}
|
|
106
185
|
className={cn(
|
|
107
186
|
'rounded-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
|
|
108
|
-
extra === 'mobile'
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
187
|
+
extra === 'mobile' &&
|
|
188
|
+
'block rounded-md px-3 py-2 text-base hover:bg-accent',
|
|
189
|
+
extra === 'panel' && 'block rounded-md p-2 hover:bg-accent',
|
|
190
|
+
!extra && 'text-sm hover:text-foreground',
|
|
191
|
+
!extra && (active ? 'font-medium text-foreground' : 'text-muted-foreground')
|
|
112
192
|
)}
|
|
113
193
|
>
|
|
114
|
-
{
|
|
194
|
+
{extra === 'panel' ? (
|
|
195
|
+
<>
|
|
196
|
+
<span className="block text-sm font-medium">{item.label}</span>
|
|
197
|
+
{item.description && (
|
|
198
|
+
<span className="mt-0.5 block text-xs text-muted-foreground">
|
|
199
|
+
{item.description}
|
|
200
|
+
</span>
|
|
201
|
+
)}
|
|
202
|
+
</>
|
|
203
|
+
) : (
|
|
204
|
+
item.label
|
|
205
|
+
)}
|
|
115
206
|
</Link>
|
|
116
207
|
);
|
|
117
208
|
};
|
|
118
209
|
|
|
210
|
+
const hasColumns = (item: SiteNavItem): item is SiteNavItem & { columns: SiteNavColumn[] } =>
|
|
211
|
+
Array.isArray(item.columns) && item.columns.length > 0;
|
|
212
|
+
|
|
119
213
|
return (
|
|
120
214
|
<>
|
|
121
215
|
<header
|
|
@@ -128,7 +222,10 @@ export function SiteHeader({
|
|
|
128
222
|
>
|
|
129
223
|
<nav
|
|
130
224
|
aria-label={navLabel}
|
|
131
|
-
className={cn(
|
|
225
|
+
className={cn(
|
|
226
|
+
'mx-auto flex h-14 w-full max-w-7xl items-center justify-between gap-4 px-4 sm:px-6',
|
|
227
|
+
navClassName
|
|
228
|
+
)}
|
|
132
229
|
>
|
|
133
230
|
<div className="flex min-w-0 items-center gap-6">
|
|
134
231
|
<Link
|
|
@@ -138,9 +235,88 @@ export function SiteHeader({
|
|
|
138
235
|
>
|
|
139
236
|
{brand}
|
|
140
237
|
</Link>
|
|
141
|
-
<
|
|
142
|
-
{
|
|
143
|
-
|
|
238
|
+
<ul
|
|
239
|
+
className={cn(
|
|
240
|
+
'hidden items-center gap-5',
|
|
241
|
+
desktopBreakpoint === 'lg' ? 'lg:flex' : 'md:flex'
|
|
242
|
+
)}
|
|
243
|
+
>
|
|
244
|
+
{items.map((item) => {
|
|
245
|
+
if (!hasColumns(item)) {
|
|
246
|
+
return <li key={item.href}>{navLink(item)}</li>;
|
|
247
|
+
}
|
|
248
|
+
const panelId = `${generatedId}-panel-${item.label.replace(/\s+/g, '-').toLowerCase()}`;
|
|
249
|
+
const open = openMenu === item.label;
|
|
250
|
+
return (
|
|
251
|
+
<li
|
|
252
|
+
key={item.label}
|
|
253
|
+
data-site-nav-item
|
|
254
|
+
className="relative"
|
|
255
|
+
onMouseEnter={() => setOpenMenu(item.label)}
|
|
256
|
+
onMouseLeave={() => setOpenMenu(null)}
|
|
257
|
+
onBlur={(event) => {
|
|
258
|
+
const next = event.relatedTarget as Node | null;
|
|
259
|
+
if (!next || !event.currentTarget.contains(next)) {
|
|
260
|
+
setOpenMenu(null);
|
|
261
|
+
}
|
|
262
|
+
}}
|
|
263
|
+
>
|
|
264
|
+
<button
|
|
265
|
+
type="button"
|
|
266
|
+
aria-expanded={open}
|
|
267
|
+
aria-controls={panelId}
|
|
268
|
+
onClick={() => setOpenMenu(item.label)}
|
|
269
|
+
onKeyDown={(event) => {
|
|
270
|
+
if (event.key === 'Escape') {
|
|
271
|
+
setOpenMenu(null);
|
|
272
|
+
event.currentTarget.focus();
|
|
273
|
+
}
|
|
274
|
+
if (event.key === 'ArrowDown') {
|
|
275
|
+
event.preventDefault();
|
|
276
|
+
pendingFocus.current = panelId;
|
|
277
|
+
setOpenMenu(item.label);
|
|
278
|
+
}
|
|
279
|
+
}}
|
|
280
|
+
className={cn(
|
|
281
|
+
'flex items-center gap-1 rounded-sm text-sm transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
|
|
282
|
+
isActive(item.href ?? '', activeHref, match)
|
|
283
|
+
? 'font-medium text-foreground'
|
|
284
|
+
: 'text-muted-foreground'
|
|
285
|
+
)}
|
|
286
|
+
>
|
|
287
|
+
{item.label}
|
|
288
|
+
<Caret />
|
|
289
|
+
</button>
|
|
290
|
+
<div
|
|
291
|
+
id={panelId}
|
|
292
|
+
hidden={!open}
|
|
293
|
+
className={cn(
|
|
294
|
+
'absolute left-0 top-full z-50 mt-2 grid gap-6 rounded-lg border border-border bg-popover p-5 shadow-lg',
|
|
295
|
+
item.columns.length > 1 ? 'grid-cols-2' : 'grid-cols-1',
|
|
296
|
+
'min-w-[22rem]'
|
|
297
|
+
)}
|
|
298
|
+
>
|
|
299
|
+
{item.columns.map((column, index) => (
|
|
300
|
+
<div key={column.heading ?? index} className="min-w-40">
|
|
301
|
+
{column.heading && (
|
|
302
|
+
<p className="mb-2 text-xs font-medium uppercase tracking-wide text-muted-foreground">
|
|
303
|
+
{column.heading}
|
|
304
|
+
</p>
|
|
305
|
+
)}
|
|
306
|
+
<ul className="flex flex-col gap-0.5">
|
|
307
|
+
{column.items.map((link) => (
|
|
308
|
+
<li key={`${column.heading ?? index}-${link.href}-${link.label}`}>
|
|
309
|
+
{navLink(link, 'panel')}
|
|
310
|
+
</li>
|
|
311
|
+
))}
|
|
312
|
+
</ul>
|
|
313
|
+
</div>
|
|
314
|
+
))}
|
|
315
|
+
</div>
|
|
316
|
+
</li>
|
|
317
|
+
);
|
|
318
|
+
})}
|
|
319
|
+
</ul>
|
|
144
320
|
</div>
|
|
145
321
|
<div className="flex items-center gap-2">
|
|
146
322
|
{actions}
|
|
@@ -187,7 +363,35 @@ export function SiteHeader({
|
|
|
187
363
|
animate
|
|
188
364
|
>
|
|
189
365
|
<nav id={menuId} aria-label={mobileNavLabel} className="flex flex-col gap-1">
|
|
190
|
-
{items.map((item) =>
|
|
366
|
+
{items.map((item) =>
|
|
367
|
+
hasColumns(item) ? (
|
|
368
|
+
<details key={item.label} className="rounded-md">
|
|
369
|
+
<summary className="cursor-pointer rounded-md px-3 py-2 text-base font-medium hover:bg-accent">
|
|
370
|
+
{item.label}
|
|
371
|
+
</summary>
|
|
372
|
+
<div className="mt-1 flex flex-col gap-2 pb-2">
|
|
373
|
+
{item.columns.map((column, index) => (
|
|
374
|
+
<div key={column.heading ?? index} className="px-3">
|
|
375
|
+
{column.heading && (
|
|
376
|
+
<p className="mb-1 text-xs font-medium uppercase tracking-wide text-muted-foreground">
|
|
377
|
+
{column.heading}
|
|
378
|
+
</p>
|
|
379
|
+
)}
|
|
380
|
+
<ul className="flex flex-col gap-1">
|
|
381
|
+
{column.items.map((link) => (
|
|
382
|
+
<li key={`${column.heading ?? index}-${link.href}-${link.label}`}>
|
|
383
|
+
{navLink(link, 'mobile')}
|
|
384
|
+
</li>
|
|
385
|
+
))}
|
|
386
|
+
</ul>
|
|
387
|
+
</div>
|
|
388
|
+
))}
|
|
389
|
+
</div>
|
|
390
|
+
</details>
|
|
391
|
+
) : (
|
|
392
|
+
navLink(item, 'mobile')
|
|
393
|
+
)
|
|
394
|
+
)}
|
|
191
395
|
</nav>
|
|
192
396
|
{(mobileActions ?? actions) && (
|
|
193
397
|
<div className="mt-4 border-t border-border pt-4">{mobileActions ?? actions}</div>
|
|
@@ -47,6 +47,18 @@ describe('Stepper', () => {
|
|
|
47
47
|
expect(container.querySelectorAll('li')[0]).toHaveClass('flex-1');
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
+
it('states progress in the caller language when labels are supplied', () => {
|
|
51
|
+
render(
|
|
52
|
+
<Stepper
|
|
53
|
+
steps={steps}
|
|
54
|
+
current={1}
|
|
55
|
+
labels={{ completed: ' (completado)', current: ' (paso actual)', upcoming: ' (próximo)' }}
|
|
56
|
+
/>
|
|
57
|
+
);
|
|
58
|
+
expect(screen.getByText('(completado)')).toBeInTheDocument();
|
|
59
|
+
expect(screen.getByText('(próximo)')).toBeInTheDocument();
|
|
60
|
+
});
|
|
61
|
+
|
|
50
62
|
it('has no accessibility violations', async () => {
|
|
51
63
|
const { container } = render(<Stepper steps={steps} current={1} />);
|
|
52
64
|
expect(await axe(container)).toHaveNoViolations();
|
|
@@ -28,6 +28,15 @@ export type StepperProps = Omit<React.OlHTMLAttributes<HTMLOListElement>, 'onCli
|
|
|
28
28
|
alignTitles?: 'start' | 'center';
|
|
29
29
|
/** Makes completed/upcoming steps clickable. */
|
|
30
30
|
onStepClick?: (index: number) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Screen-reader state suffixes for each step. Override for localization;
|
|
33
|
+
* defaults keep the English copy.
|
|
34
|
+
*/
|
|
35
|
+
labels?: {
|
|
36
|
+
completed?: string;
|
|
37
|
+
current?: string;
|
|
38
|
+
upcoming?: string;
|
|
39
|
+
};
|
|
31
40
|
};
|
|
32
41
|
|
|
33
42
|
/**
|
|
@@ -50,6 +59,7 @@ export const Stepper = React.forwardRef<HTMLOListElement, StepperProps>(function
|
|
|
50
59
|
labelPlacement = 'inline',
|
|
51
60
|
alignTitles = 'center',
|
|
52
61
|
onStepClick,
|
|
62
|
+
labels,
|
|
53
63
|
className,
|
|
54
64
|
...props
|
|
55
65
|
},
|
|
@@ -140,7 +150,11 @@ export const Stepper = React.forwardRef<HTMLOListElement, StepperProps>(function
|
|
|
140
150
|
</span>
|
|
141
151
|
)}
|
|
142
152
|
<span className="sr-only">
|
|
143
|
-
{state === 'complete'
|
|
153
|
+
{state === 'complete'
|
|
154
|
+
? (labels?.completed ?? ' (completed)')
|
|
155
|
+
: state === 'current'
|
|
156
|
+
? (labels?.current ?? ' (current step)')
|
|
157
|
+
: (labels?.upcoming ?? ' (upcoming)')}
|
|
144
158
|
</span>
|
|
145
159
|
</span>
|
|
146
160
|
);
|
package/src/index.ts
CHANGED
|
@@ -35,6 +35,7 @@ export * from './components/tabs';
|
|
|
35
35
|
export * from './components/link-tabs';
|
|
36
36
|
export * from './components/theme-toggle';
|
|
37
37
|
export * from './components/tooltip';
|
|
38
|
+
export * from './components/calendar';
|
|
38
39
|
export * from './components/card';
|
|
39
40
|
export * from './components/confirm-dialog';
|
|
40
41
|
export * from './components/table-of-contents';
|
|
@@ -46,6 +47,7 @@ export * from './components/table';
|
|
|
46
47
|
export * from './components/data-table';
|
|
47
48
|
export * from './components/list';
|
|
48
49
|
export * from './components/link';
|
|
50
|
+
export * from './components/image';
|
|
49
51
|
export * from './components/text';
|
|
50
52
|
export * from './components/heading';
|
|
51
53
|
export * from './components/empty-state';
|
|
@@ -56,6 +58,7 @@ export * from './components/password-input';
|
|
|
56
58
|
export * from './components/auth-layout';
|
|
57
59
|
export * from './components/filter-bar';
|
|
58
60
|
export * from './components/date-picker';
|
|
61
|
+
export * from './components/date-picker-popover';
|
|
59
62
|
export * from './components/time-picker';
|
|
60
63
|
export * from './components/stepper';
|
|
61
64
|
export * from './components/file-upload';
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"examples": [
|
|
83
83
|
{
|
|
84
84
|
"title": "FAQ accordion",
|
|
85
|
-
"code": "<Accordion defaultValue={['a']}>\n <AccordionItem id=\"a\">\n <AccordionTrigger>What is Slipstream?</AccordionTrigger>\n <AccordionContent>An AI-first component system.</AccordionContent>\n </AccordionItem>\n <AccordionItem id=\"b\">\n <AccordionTrigger>How do I install?</AccordionTrigger>\n <AccordionContent>Run npx slipstream-ui init.</AccordionContent>\n </AccordionItem>\n</Accordion>",
|
|
85
|
+
"code": "<Accordion defaultValue={['a']}>\n <AccordionItem id=\"a\">\n <AccordionTrigger>What is Slipstream?</AccordionTrigger>\n <AccordionContent>An AI-first component system.</AccordionContent>\n </AccordionItem>\n <AccordionItem id=\"b\">\n <AccordionTrigger>How do I install?</AccordionTrigger>\n <AccordionContent>Run npx @slipstream-ui/cli@latest init.</AccordionContent>\n </AccordionItem>\n</Accordion>",
|
|
86
86
|
"description": "Single-open accordion for FAQs"
|
|
87
87
|
}
|
|
88
88
|
],
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
],
|
|
139
139
|
"package": "@slipstream-ui/core",
|
|
140
140
|
"importPath": "@slipstream-ui/core",
|
|
141
|
-
"version": "0.
|
|
141
|
+
"version": "0.9.0",
|
|
142
142
|
"sourceDir": "accordion",
|
|
143
143
|
"exportName": "Accordion"
|
|
144
144
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"tier": "molecule",
|
|
5
5
|
"package": "@slipstream-ui/core",
|
|
6
6
|
"importPath": "@slipstream-ui/core",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.9.0",
|
|
8
8
|
"sourceDir": "announcement-bar",
|
|
9
9
|
"exportName": "AnnouncementBar",
|
|
10
10
|
"description": "Dismissible announcement bar with optional action, tone and sticky positioning.",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"tier": "molecule",
|
|
5
5
|
"package": "@slipstream-ui/core",
|
|
6
6
|
"importPath": "@slipstream-ui/core",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.9.0",
|
|
8
8
|
"sourceDir": "applied-filters",
|
|
9
9
|
"exportName": "AppliedFilters",
|
|
10
10
|
"description": "Applied-filter summary with a live count, removable chips and an edit action.",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"tier": "molecule",
|
|
5
5
|
"package": "@slipstream-ui/core",
|
|
6
6
|
"importPath": "@slipstream-ui/core",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.9.0",
|
|
8
8
|
"sourceDir": "article-card",
|
|
9
9
|
"exportName": "ArticleCard",
|
|
10
10
|
"description": "Linked article or resource card with media, eyebrow, title, summary and metadata.",
|