@behavioral-agentic-design-system/core 0.39.0 → 0.40.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.
Files changed (78) hide show
  1. package/package.json +8 -3
  2. package/scripts/a11y-lint.cjs +93 -39
  3. package/scripts/a11y-ratchet.mjs +10 -23
  4. package/scripts/bads-components.mjs +118 -0
  5. package/scripts/build-tokens.cjs +175 -17
  6. package/scripts/check-stories.mjs +1 -1
  7. package/scripts/health-report.mjs +52 -10
  8. package/scripts/lib/scan-roots.cjs +143 -0
  9. package/scripts/lint-component-source.mjs +100 -0
  10. package/scripts/lint-microanimation.mjs +267 -0
  11. package/scripts/lint-slop.mjs +21 -28
  12. package/scripts/lint-token-intent.mjs +10 -16
  13. package/scripts/size-audit.cjs +94 -27
  14. package/scripts/source-of-truth.cjs +58 -0
  15. package/scripts/ux-smoke.mjs +438 -0
  16. package/scripts/wcag-audit.cjs +49 -1
  17. package/src/api/layers/file.ts +2 -0
  18. package/src/app/preview/components/page.tsx +972 -0
  19. package/src/app/preview/health/page.tsx +8 -5
  20. package/src/app/preview/history/page.tsx +11 -0
  21. package/src/app/shell.tsx +261 -87
  22. package/src/components/customize/brand-mark-section.tsx +4 -2
  23. package/src/components/customize/design-controls.tsx +1 -1
  24. package/src/components/customize/discipline-section.tsx +91 -0
  25. package/src/components/customize/font-pickers.tsx +1 -1
  26. package/src/components/customize/letter-spacing.tsx +1 -1
  27. package/src/components/customize/save-bar.tsx +2 -2
  28. package/src/components/customize/theme-io.tsx +7 -7
  29. package/src/components/customize/type-scale.tsx +1 -1
  30. package/src/components/customize-tab.tsx +9 -4
  31. package/src/components/home-tab.tsx +3 -0
  32. package/src/components/ui/accordion.tsx +7 -0
  33. package/src/components/ui/alert.tsx +1 -0
  34. package/src/components/ui/announcement-bar.tsx +256 -0
  35. package/src/components/ui/badge.tsx +1 -0
  36. package/src/components/ui/callout.tsx +218 -0
  37. package/src/components/ui/chart.tsx +2 -14
  38. package/src/components/ui/color-picker.tsx +1 -1
  39. package/src/components/ui/format-relative-time.tsx +139 -0
  40. package/src/components/ui/grid.tsx +255 -0
  41. package/src/components/ui/icon.tsx +108 -0
  42. package/src/components/ui/index.ts +8 -0
  43. package/src/components/ui/page-header.tsx +63 -0
  44. package/src/components/ui/portal.tsx +111 -0
  45. package/src/components/ui/presence.tsx +172 -0
  46. package/src/components/ui/progress-stack.tsx +258 -0
  47. package/src/components/ui/select.tsx +89 -4
  48. package/src/components/ui/separator.tsx +1 -0
  49. package/src/components/ui/slider.tsx +83 -3
  50. package/src/components/ui/sparkline.tsx +15 -15
  51. package/src/components/ui/textarea.tsx +28 -1
  52. package/src/data/docs-index.ts +5 -0
  53. package/src/data/history.json +269 -0
  54. package/src/hooks/use-reduced-motion.ts +6 -0
  55. package/src/stories/Accordion.stories.tsx +59 -0
  56. package/src/stories/Alert.stories.tsx +3 -1
  57. package/src/stories/AnnouncementBar.stories.tsx +261 -0
  58. package/src/stories/Badge.stories.tsx +3 -0
  59. package/src/stories/Calendar.stories.tsx +1 -1
  60. package/src/stories/Callout.stories.tsx +219 -0
  61. package/src/stories/Chart.stories.tsx +4 -0
  62. package/src/stories/ColorPicker.stories.tsx +23 -0
  63. package/src/stories/FormatRelativeTime.stories.tsx +116 -0
  64. package/src/stories/Grid.stories.tsx +197 -0
  65. package/src/stories/Icon.stories.tsx +175 -0
  66. package/src/stories/MultiSelect.stories.tsx +1 -1
  67. package/src/stories/PageHeader.stories.tsx +102 -0
  68. package/src/stories/Portal.stories.tsx +189 -0
  69. package/src/stories/Presence.stories.tsx +228 -0
  70. package/src/stories/ProgressStack.stories.tsx +287 -0
  71. package/src/stories/Select.stories.tsx +25 -0
  72. package/src/stories/Separator.stories.tsx +3 -0
  73. package/src/stories/Sheet.stories.tsx +9 -3
  74. package/src/stories/Slider.stories.tsx +54 -5
  75. package/src/stories/Sparkline.stories.tsx +39 -0
  76. package/src/stories/Textarea.stories.tsx +18 -0
  77. package/src/stories/story-groups.json +14 -5
  78. package/src/styles.css +133 -12
@@ -4,6 +4,7 @@ import * as React from "react"
4
4
  import * as RechartsPrimitive from "recharts"
5
5
 
6
6
  import { cn } from "../../lib/utils"
7
+ import { useReducedMotion } from "../../hooks/use-reduced-motion"
7
8
 
8
9
  // Format: { THEME_NAME: CSS_SELECTOR }
9
10
  const THEMES = { light: "", dark: ".dark" } as const
@@ -81,19 +82,6 @@ function injectAnimationDefault(
81
82
  return React.cloneElement(element, nextProps)
82
83
  }
83
84
 
84
- function usePrefersReducedMotion() {
85
- const [reduced, setReduced] = React.useState(false)
86
- React.useEffect(() => {
87
- if (typeof window === "undefined" || !window.matchMedia) return
88
- const mql = window.matchMedia("(prefers-reduced-motion: reduce)")
89
- setReduced(mql.matches)
90
- const onChange = (e: MediaQueryListEvent) => setReduced(e.matches)
91
- mql.addEventListener("change", onChange)
92
- return () => mql.removeEventListener("change", onChange)
93
- }, [])
94
- return reduced
95
- }
96
-
97
85
  function ChartContainer({
98
86
  id,
99
87
  className,
@@ -120,7 +108,7 @@ function ChartContainer({
120
108
  }) {
121
109
  const uniqueId = React.useId()
122
110
  const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`
123
- const prefersReducedMotion = usePrefersReducedMotion()
111
+ const prefersReducedMotion = useReducedMotion()
124
112
  const effectiveAnimate = animate && !prefersReducedMotion
125
113
 
126
114
  // ResponsiveContainer logs "width(-1) and height(-1)" whenever it renders
@@ -549,7 +549,7 @@ export function ColorPicker({
549
549
  type="button"
550
550
  onClick={addColor}
551
551
  disabled={disabled || !isValidHex(draft)}
552
- className="w-full"
552
+ className="w-full min-h-11"
553
553
  >
554
554
  Add color
555
555
  </Button>
@@ -0,0 +1,139 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+
5
+ import { cn } from "../../lib/utils"
6
+
7
+ /**
8
+ * Explicit default locale — never reads navigator.language, which differs
9
+ * between server and client and causes hydration mismatches.
10
+ */
11
+ const FORMAT_RELATIVE_TIME_DEFAULT_LOCALE = "en-US"
12
+
13
+ /** Thresholds for picking the right Intl unit. */
14
+ const UNITS: { unit: Intl.RelativeTimeFormatUnit; ms: number }[] = [
15
+ { unit: "second", ms: 60_000 },
16
+ { unit: "minute", ms: 3_600_000 },
17
+ { unit: "hour", ms: 86_400_000 },
18
+ { unit: "day", ms: 2_592_000_000 },
19
+ { unit: "month", ms: 31_536_000_000 },
20
+ { unit: "year", ms: Infinity },
21
+ ]
22
+
23
+ function formatRelative(
24
+ date: Date,
25
+ locale: string,
26
+ numeric: Intl.RelativeTimeFormatNumeric,
27
+ style: Intl.RelativeTimeFormatStyle
28
+ ): string {
29
+ const diffMs = date.getTime() - Date.now()
30
+ const absDiff = Math.abs(diffMs)
31
+
32
+ for (let i = 0; i < UNITS.length; i++) {
33
+ const { unit, ms } = UNITS[i]
34
+ if (absDiff < ms) {
35
+ const prevMs = UNITS[i - 1]?.ms ?? 1_000
36
+ const value = Math.round(diffMs / prevMs)
37
+ return new Intl.RelativeTimeFormat(locale, { numeric, style }).format(
38
+ value,
39
+ unit
40
+ )
41
+ }
42
+ }
43
+ // Fallback: years
44
+ const value = Math.round(diffMs / 31_536_000_000)
45
+ return new Intl.RelativeTimeFormat(locale, { numeric, style }).format(
46
+ value,
47
+ "year"
48
+ )
49
+ }
50
+
51
+ export interface FormatRelativeTimeProps
52
+ extends Omit<React.ComponentProps<"time">, "children" | "dateTime"> {
53
+ /**
54
+ * The date to express as relative to now. Accepts a Date, ISO 8601 string,
55
+ * or UNIX timestamp (ms).
56
+ */
57
+ date: Date | string | number
58
+ /**
59
+ * BCP 47 locale tag. Defaults to "en-US" (explicit, SSR-safe).
60
+ */
61
+ locale?: string
62
+ /**
63
+ * Whether the displayed string should update automatically.
64
+ * @default true
65
+ */
66
+ live?: boolean
67
+ /**
68
+ * How often to recalculate the relative string, in milliseconds.
69
+ * Ignored when `live` is false.
70
+ * @default 30000 (30 s)
71
+ */
72
+ updateInterval?: number
73
+ /**
74
+ * `Intl.RelativeTimeFormat` numeric mode.
75
+ * "auto" produces "yesterday", "today", "tomorrow".
76
+ * "always" produces "-1 day", "0 days", "+1 day".
77
+ * @default "auto"
78
+ */
79
+ numeric?: Intl.RelativeTimeFormatNumeric
80
+ /**
81
+ * `Intl.RelativeTimeFormat` style.
82
+ * @default "long"
83
+ */
84
+ formatStyle?: Intl.RelativeTimeFormatStyle
85
+ }
86
+
87
+ /**
88
+ * Locale-aware relative-time display primitive — a thin wrapper around
89
+ * `Intl.RelativeTimeFormat`. Renders a `<time>` element with a machine-
90
+ * readable `dateTime` attribute and a human-readable relative string like
91
+ * "3 minutes ago" or "in 2 days". Optionally live-updates.
92
+ *
93
+ * Display-only. For editable date/time inputs use DatePicker or TimePicker.
94
+ */
95
+ function FormatRelativeTime({
96
+ date,
97
+ locale = FORMAT_RELATIVE_TIME_DEFAULT_LOCALE,
98
+ live = true,
99
+ updateInterval = 30_000,
100
+ numeric = "auto",
101
+ formatStyle = "long",
102
+ className,
103
+ title,
104
+ ...props
105
+ }: FormatRelativeTimeProps) {
106
+ const parsed = React.useMemo(
107
+ () => (date instanceof Date ? date : new Date(date)),
108
+ [date]
109
+ )
110
+
111
+ const [text, setText] = React.useState<string>(() =>
112
+ formatRelative(parsed, locale, numeric, formatStyle)
113
+ )
114
+
115
+ React.useEffect(() => {
116
+ setText(formatRelative(parsed, locale, numeric, formatStyle))
117
+ if (!live) return
118
+ const id = setInterval(() => {
119
+ setText(formatRelative(parsed, locale, numeric, formatStyle))
120
+ }, updateInterval)
121
+ return () => clearInterval(id)
122
+ }, [parsed, locale, live, updateInterval, numeric, formatStyle])
123
+
124
+ const isoString = parsed.toISOString()
125
+
126
+ return (
127
+ <time
128
+ data-slot="format-relative-time"
129
+ dateTime={isoString}
130
+ title={title ?? isoString}
131
+ className={cn(className)}
132
+ {...props}
133
+ >
134
+ {text}
135
+ </time>
136
+ )
137
+ }
138
+
139
+ export { FormatRelativeTime, FORMAT_RELATIVE_TIME_DEFAULT_LOCALE }
@@ -0,0 +1,255 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { cn } from "../../lib/utils";
5
+
6
+ // ─── Grid ─────────────────────────────────────────────────────────────────────
7
+ //
8
+ // Twelve-track span grid — the SimpleGrid sibling for UNEQUAL columns. A
9
+ // GridCol spans 1–12 tracks and may be pushed right by leading empty tracks
10
+ // (`offset`), per breakpoint. Same statically-safe contract as SimpleGrid:
11
+ // every span and start value maps to a literal Tailwind class from the lookup
12
+ // tables below, so a template-string `col-span-${n}` can never silently
13
+ // compile to nothing under the Tailwind v4 scanner.
14
+ //
15
+ // Cross-system references: Mantine Grid / Grid.Col (span, offset), MUI Grid
16
+ // (size, offset), Ant Design Row / Col (span, offset), Chakra Grid / GridItem
17
+ // (colSpan, colStart). Columns are fixed at 12 — every source defaults to it.
18
+ //
19
+ // Offset is implemented as `grid-column-start` (Chakra's model). With row
20
+ // auto-flow, an offset cell that no longer fits the current row wraps to the
21
+ // next — the same visible behavior as Mantine's / Ant's margin-based offset.
22
+ //
23
+ // Layout-only primitive (Stack / Group / Container / SimpleGrid class): no
24
+ // ARIA, no interaction, no motion. Deliberately NO `order` prop — a visual
25
+ // reorder desynchronizes reading order from DOM order (SC 1.3.2 / 2.4.3).
26
+ // For equal-width tracks reach for SimpleGrid; for variable-height packing,
27
+ // Masonry; for tabular data, Table / DataTable.
28
+
29
+ type Span = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
30
+ type Offset = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11;
31
+
32
+ /** Track counts per breakpoint. `base` applies from 0px up; sm/md/lg override upward. */
33
+ export interface ResponsiveSpan {
34
+ base?: Span;
35
+ sm?: Span;
36
+ md?: Span;
37
+ lg?: Span;
38
+ }
39
+
40
+ /** Leading empty tracks per breakpoint. `0` at a breakpoint resets to auto placement. */
41
+ export interface ResponsiveOffset {
42
+ base?: Offset;
43
+ sm?: Offset;
44
+ md?: Offset;
45
+ lg?: Offset;
46
+ }
47
+
48
+ // Literal class maps — every generated class must be spelled out so the
49
+ // Tailwind scanner ships it. Never build these strings dynamically.
50
+ const BASE_SPAN: Record<Span, string> = {
51
+ 1: "col-span-1",
52
+ 2: "col-span-2",
53
+ 3: "col-span-3",
54
+ 4: "col-span-4",
55
+ 5: "col-span-5",
56
+ 6: "col-span-6",
57
+ 7: "col-span-7",
58
+ 8: "col-span-8",
59
+ 9: "col-span-9",
60
+ 10: "col-span-10",
61
+ 11: "col-span-11",
62
+ 12: "col-span-12",
63
+ };
64
+ const SM_SPAN: Record<Span, string> = {
65
+ 1: "sm:col-span-1",
66
+ 2: "sm:col-span-2",
67
+ 3: "sm:col-span-3",
68
+ 4: "sm:col-span-4",
69
+ 5: "sm:col-span-5",
70
+ 6: "sm:col-span-6",
71
+ 7: "sm:col-span-7",
72
+ 8: "sm:col-span-8",
73
+ 9: "sm:col-span-9",
74
+ 10: "sm:col-span-10",
75
+ 11: "sm:col-span-11",
76
+ 12: "sm:col-span-12",
77
+ };
78
+ const MD_SPAN: Record<Span, string> = {
79
+ 1: "md:col-span-1",
80
+ 2: "md:col-span-2",
81
+ 3: "md:col-span-3",
82
+ 4: "md:col-span-4",
83
+ 5: "md:col-span-5",
84
+ 6: "md:col-span-6",
85
+ 7: "md:col-span-7",
86
+ 8: "md:col-span-8",
87
+ 9: "md:col-span-9",
88
+ 10: "md:col-span-10",
89
+ 11: "md:col-span-11",
90
+ 12: "md:col-span-12",
91
+ };
92
+ const LG_SPAN: Record<Span, string> = {
93
+ 1: "lg:col-span-1",
94
+ 2: "lg:col-span-2",
95
+ 3: "lg:col-span-3",
96
+ 4: "lg:col-span-4",
97
+ 5: "lg:col-span-5",
98
+ 6: "lg:col-span-6",
99
+ 7: "lg:col-span-7",
100
+ 8: "lg:col-span-8",
101
+ 9: "lg:col-span-9",
102
+ 10: "lg:col-span-10",
103
+ 11: "lg:col-span-11",
104
+ 12: "lg:col-span-12",
105
+ };
106
+
107
+ // Offset N → grid-column-start N+1. Offset 0 at the base breakpoint emits
108
+ // nothing (auto placement is the default); at sm/md/lg it emits an explicit
109
+ // `col-start-auto` so a smaller breakpoint's offset can be reset upward.
110
+ const BASE_START: Record<Offset, string> = {
111
+ 0: "",
112
+ 1: "col-start-2",
113
+ 2: "col-start-3",
114
+ 3: "col-start-4",
115
+ 4: "col-start-5",
116
+ 5: "col-start-6",
117
+ 6: "col-start-7",
118
+ 7: "col-start-8",
119
+ 8: "col-start-9",
120
+ 9: "col-start-10",
121
+ 10: "col-start-11",
122
+ 11: "col-start-12",
123
+ };
124
+ const SM_START: Record<Offset, string> = {
125
+ 0: "sm:col-start-auto",
126
+ 1: "sm:col-start-2",
127
+ 2: "sm:col-start-3",
128
+ 3: "sm:col-start-4",
129
+ 4: "sm:col-start-5",
130
+ 5: "sm:col-start-6",
131
+ 6: "sm:col-start-7",
132
+ 7: "sm:col-start-8",
133
+ 8: "sm:col-start-9",
134
+ 9: "sm:col-start-10",
135
+ 10: "sm:col-start-11",
136
+ 11: "sm:col-start-12",
137
+ };
138
+ const MD_START: Record<Offset, string> = {
139
+ 0: "md:col-start-auto",
140
+ 1: "md:col-start-2",
141
+ 2: "md:col-start-3",
142
+ 3: "md:col-start-4",
143
+ 4: "md:col-start-5",
144
+ 5: "md:col-start-6",
145
+ 6: "md:col-start-7",
146
+ 7: "md:col-start-8",
147
+ 8: "md:col-start-9",
148
+ 9: "md:col-start-10",
149
+ 10: "md:col-start-11",
150
+ 11: "md:col-start-12",
151
+ };
152
+ const LG_START: Record<Offset, string> = {
153
+ 0: "lg:col-start-auto",
154
+ 1: "lg:col-start-2",
155
+ 2: "lg:col-start-3",
156
+ 3: "lg:col-start-4",
157
+ 4: "lg:col-start-5",
158
+ 5: "lg:col-start-6",
159
+ 6: "lg:col-start-7",
160
+ 7: "lg:col-start-8",
161
+ 8: "lg:col-start-9",
162
+ 9: "lg:col-start-10",
163
+ 10: "lg:col-start-11",
164
+ 11: "lg:col-start-12",
165
+ };
166
+
167
+ /** Same token-keyed gap scale as Stack / Group / SimpleGrid (gap-0/1/2/4/6/8 → 0/4/8/16/24/32px). */
168
+ const GAP: Record<"none" | "xs" | "sm" | "md" | "lg" | "xl", string> = {
169
+ none: "gap-0",
170
+ xs: "gap-1",
171
+ sm: "gap-2",
172
+ md: "gap-4",
173
+ lg: "gap-6",
174
+ xl: "gap-8",
175
+ };
176
+
177
+ /** Cross-axis alignment of cells within each row (align-items). */
178
+ const ALIGN: Record<"start" | "center" | "end" | "stretch", string> = {
179
+ start: "items-start",
180
+ center: "items-center",
181
+ end: "items-end",
182
+ stretch: "items-stretch",
183
+ };
184
+
185
+ export interface GridProps extends React.HTMLAttributes<HTMLDivElement> {
186
+ /** Gap between cells, keyed to the BADS spacing scale. Default: "lg" (24px) — matches SimpleGrid. */
187
+ gap?: keyof typeof GAP;
188
+ /** Row cross-axis alignment. Default: "stretch" so sibling cards in a row share a height. */
189
+ align?: keyof typeof ALIGN;
190
+ }
191
+
192
+ export interface GridColProps extends React.HTMLAttributes<HTMLDivElement> {
193
+ /**
194
+ * Tracks this cell spans, out of 12 — a single number (fixed at all widths)
195
+ * or a responsive object, e.g. `{ base: 12, md: 8 }`. Default: 12 (full
196
+ * width), so a column stacks on mobile unless told otherwise.
197
+ */
198
+ span?: Span | ResponsiveSpan;
199
+ /**
200
+ * Leading empty tracks before this cell (0–11), fixed or responsive.
201
+ * Implemented as `grid-column-start`; a cell that no longer fits its row
202
+ * wraps to the next. Default: 0.
203
+ */
204
+ offset?: Offset | ResponsiveOffset;
205
+ }
206
+
207
+ function spanClasses(span: Span | ResponsiveSpan): string[] {
208
+ if (typeof span === "number") return [BASE_SPAN[span]];
209
+ const out: string[] = [BASE_SPAN[span.base ?? 12]];
210
+ if (span.sm) out.push(SM_SPAN[span.sm]);
211
+ if (span.md) out.push(MD_SPAN[span.md]);
212
+ if (span.lg) out.push(LG_SPAN[span.lg]);
213
+ return out;
214
+ }
215
+
216
+ function offsetClasses(offset: Offset | ResponsiveOffset): string[] {
217
+ if (typeof offset === "number") return [BASE_START[offset]];
218
+ const out: string[] = [BASE_START[offset.base ?? 0]];
219
+ if (offset.sm !== undefined) out.push(SM_START[offset.sm]);
220
+ if (offset.md !== undefined) out.push(MD_START[offset.md]);
221
+ if (offset.lg !== undefined) out.push(LG_START[offset.lg]);
222
+ return out;
223
+ }
224
+
225
+ export const Grid = React.forwardRef<HTMLDivElement, GridProps>(
226
+ ({ className, gap = "lg", align = "stretch", ...props }, ref) => (
227
+ <div
228
+ ref={ref}
229
+ data-slot="grid"
230
+ className={cn("grid grid-cols-12", GAP[gap], ALIGN[align], className)}
231
+ {...props}
232
+ />
233
+ )
234
+ );
235
+ Grid.displayName = "Grid";
236
+
237
+ export const GridCol = React.forwardRef<HTMLDivElement, GridColProps>(
238
+ ({ className, span = 12, offset = 0, ...props }, ref) => (
239
+ <div
240
+ ref={ref}
241
+ data-slot="grid-col"
242
+ // min-w-0 so a long runtime string inside a cell truncates / wraps
243
+ // instead of forcing the track wider (long-label overflow contract,
244
+ // corrections.md #001).
245
+ className={cn(
246
+ "min-w-0",
247
+ ...spanClasses(span),
248
+ ...offsetClasses(offset),
249
+ className
250
+ )}
251
+ {...props}
252
+ />
253
+ )
254
+ );
255
+ GridCol.displayName = "GridCol";
@@ -0,0 +1,108 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { cva, type VariantProps } from "class-variance-authority"
5
+
6
+ import { cn } from "../../lib/utils"
7
+ import { getIconColor, type IconRole } from "../../lib/get-icon-color"
8
+
9
+ /**
10
+ * Icon — the system wrapper for any Lucide (or SVG-prop-spreading) icon.
11
+ * Three rules from CLAUDE.md → Icons become unforgettable here:
12
+ *
13
+ * 1. **Stroke width is 1.5, always.** Lucide defaults to 2; this wrapper pins
14
+ * 1.5 and deliberately omits `strokeWidth` from its props. If an icon
15
+ * looks too thin or heavy at 1.5, swap the icon — never the stroke.
16
+ * 2. **Size is a token ladder** (`sm` 14 / `default` 16 / `lg` 20 / `xl` 24),
17
+ * not a per-call pixel number. `default` matches the `size-4` convention
18
+ * every BADS button and row already uses.
19
+ * 3. **Color is a semantic role**, not a class. `color="error"` resolves
20
+ * through `getIconColor()` to `text-icon-error` — the `icon-*` token
21
+ * family that aliases already-AAA-audited text roles. No `color` means
22
+ * `currentColor`, which is the right default for an icon beside text.
23
+ *
24
+ * Accessibility: decorative by default (`aria-hidden="true"`, the Lucide
25
+ * default). Pass `label` when the icon carries meaning on its own — it then
26
+ * renders `role="img"` + `aria-label`. Name the meaning ("Passing"), not the
27
+ * glyph ("check mark").
28
+ *
29
+ * Peer parity: Chakra UI Icon, MUI SvgIcon / Icon, Ant Design Icon,
30
+ * Component Gallery "Icon".
31
+ */
32
+
33
+ const iconVariants = cva("inline-block shrink-0 transition-colors", {
34
+ variants: {
35
+ size: {
36
+ sm: "size-3.5",
37
+ default: "size-4",
38
+ lg: "size-5",
39
+ xl: "size-6",
40
+ },
41
+ },
42
+ defaultVariants: {
43
+ size: "default",
44
+ },
45
+ })
46
+
47
+ type IconComponent = React.ComponentType<React.SVGProps<SVGSVGElement>>
48
+
49
+ interface IconProps
50
+ extends Omit<
51
+ React.ComponentPropsWithoutRef<"svg">,
52
+ "strokeWidth" | "color" | "children"
53
+ >,
54
+ VariantProps<typeof iconVariants> {
55
+ /** The icon component to render — any Lucide icon, or any component that
56
+ * spreads SVG props (`stroke="currentColor" fill="none"`). */
57
+ as: IconComponent
58
+ /**
59
+ * Semantic color role from the `icon-*` token family. Omit for
60
+ * `currentColor` (inherit from surrounding text). Never pass a token name
61
+ * or a Tailwind class here — `pnpm lint:icon-color` flags it.
62
+ */
63
+ color?: IconRole
64
+ /**
65
+ * Accessible name. When set, the icon is announced as an image with this
66
+ * label; when omitted the icon is decorative and hidden from assistive
67
+ * tech. Describe the meaning, not the shape.
68
+ */
69
+ label?: string
70
+ }
71
+
72
+ // Pattern-c motion: a parent-driven color change (group-hover, a role swap)
73
+ // eases on the fast token instead of snapping. The CSS vars resolve at
74
+ // runtime against :root in the generated styles.css.
75
+ const motionStyle: React.CSSProperties = {
76
+ transitionDuration: "var(--duration-fast)",
77
+ transitionTimingFunction: "var(--ease-out)",
78
+ }
79
+
80
+ const Icon = React.forwardRef<SVGSVGElement, IconProps>(
81
+ ({ as: Component, size, color, label, className, style, ...props }, ref) => {
82
+ const labelled = typeof label === "string" && label.length > 0
83
+ return (
84
+ <Component
85
+ ref={ref}
86
+ data-slot="icon"
87
+ data-size={size ?? "default"}
88
+ data-color={color}
89
+ strokeWidth={1.5}
90
+ focusable="false"
91
+ role={labelled ? "img" : undefined}
92
+ aria-label={labelled ? label : undefined}
93
+ aria-hidden={labelled ? undefined : true}
94
+ className={cn(
95
+ iconVariants({ size }),
96
+ color ? getIconColor(color) : undefined,
97
+ className
98
+ )}
99
+ style={{ ...motionStyle, ...style }}
100
+ {...props}
101
+ />
102
+ )
103
+ }
104
+ )
105
+ Icon.displayName = "Icon"
106
+
107
+ export { Icon, iconVariants }
108
+ export type { IconProps, IconComponent }
@@ -78,6 +78,7 @@ export * from "./editable";
78
78
  export * from "./qr-code";
79
79
  export * from "./highlight";
80
80
  export * from "./format-number";
81
+ export * from "./format-relative-time";
81
82
  export * from "./autocomplete";
82
83
  export * from "./button-group";
83
84
  export * from "./checkbox-group";
@@ -142,5 +143,12 @@ export * from "./date-field";
142
143
  export * from "./stack";
143
144
  export * from "./container";
144
145
  export * from "./simple-grid";
146
+ export * from "./grid";
145
147
  export * from "./close-button";
146
148
  export * from "./toggle-tip";
149
+ export * from "./presence";
150
+ export * from "./portal";
151
+ export * from "./icon";
152
+ export * from "./progress-stack";
153
+ export * from "./callout";
154
+ export * from "./announcement-bar";
@@ -0,0 +1,63 @@
1
+ import * as React from "react"
2
+ import { cn } from "../../lib/utils"
3
+
4
+ export interface PageHeaderProps {
5
+ /** Primary heading. Rendered as <h1> by default; use `asChild` on the heading slot if you need a different level. */
6
+ title: React.ReactNode
7
+ /** Supporting description rendered below the title at text-sm / muted-foreground. */
8
+ description?: React.ReactNode
9
+ /** Uppercase eyebrow kicker above the title — used for section category or breadcrumb-equivalent labels. */
10
+ eyebrow?: string
11
+ /** Right-aligned action slot: a Button, ButtonGroup, or any control. */
12
+ action?: React.ReactNode
13
+ /** Adds a bottom border that separates the header from its content region. */
14
+ bordered?: boolean
15
+ /** Pins the header to the top of its scroll container. */
16
+ sticky?: boolean
17
+ className?: string
18
+ }
19
+
20
+ function PageHeader({
21
+ title,
22
+ description,
23
+ eyebrow,
24
+ action,
25
+ bordered = false,
26
+ sticky = false,
27
+ className,
28
+ }: PageHeaderProps) {
29
+ return (
30
+ <div
31
+ data-slot="page-header"
32
+ className={cn(
33
+ "flex items-start justify-between gap-4",
34
+ bordered && "border-b border-border pb-6",
35
+ sticky && "sticky top-0 z-10 bg-background py-4",
36
+ className
37
+ )}
38
+ >
39
+ <div className="min-w-0 flex-1 space-y-1">
40
+ {eyebrow && (
41
+ <p className="text-xs font-medium uppercase tracking-widest text-muted-foreground">
42
+ {eyebrow}
43
+ </p>
44
+ )}
45
+ <h1 className="text-2xl font-semibold leading-tight tracking-tight text-foreground truncate">
46
+ {title}
47
+ </h1>
48
+ {description && (
49
+ <p className="text-sm text-muted-foreground leading-relaxed">
50
+ {description}
51
+ </p>
52
+ )}
53
+ </div>
54
+ {action && (
55
+ <div className="shrink-0 flex items-center gap-2">
56
+ {action}
57
+ </div>
58
+ )}
59
+ </div>
60
+ )
61
+ }
62
+
63
+ export { PageHeader }