@behavioral-agentic-design-system/core 0.6.0 → 0.7.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 (53) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +30 -5
  3. package/scripts/bads-sync.mjs +1 -1
  4. package/scripts/build-fonts.cjs +15 -8
  5. package/scripts/build-tokens.cjs +139 -23
  6. package/src/api/brand-fonts.ts +27 -6
  7. package/src/api/layers/file.ts +4 -3
  8. package/src/api/layers.ts +8 -7
  9. package/src/api/site-auth.ts +50 -0
  10. package/src/app/font-ready.tsx +1 -1
  11. package/src/app/layout.tsx +9 -3
  12. package/src/app/preview/components/page.tsx +78 -1
  13. package/src/app/preview/icons/page.tsx +5 -0
  14. package/src/app/shell.tsx +27 -22
  15. package/src/app/site-login/page.tsx +82 -0
  16. package/src/brand-fonts.css +5 -0
  17. package/src/components/Foundations/Motion.stories.tsx +66 -0
  18. package/src/components/customize/letter-spacing.tsx +3 -2
  19. package/src/components/customize/type-scale.tsx +3 -2
  20. package/src/components/customize-tab.tsx +8 -7
  21. package/src/components/home-tab.tsx +498 -235
  22. package/src/components/layers-tab.tsx +141 -3
  23. package/src/components/ui/alert.tsx +2 -2
  24. package/src/components/ui/bottom-sheet.tsx +124 -0
  25. package/src/components/ui/button.tsx +1 -1
  26. package/src/components/ui/chart.tsx +115 -14
  27. package/src/components/ui/checkbox.tsx +3 -2
  28. package/src/components/ui/dialog.tsx +3 -3
  29. package/src/components/ui/index.ts +1 -0
  30. package/src/components/ui/radio-group.tsx +4 -3
  31. package/src/components/ui/sheet.tsx +1 -1
  32. package/src/components/ui/switch.tsx +3 -3
  33. package/src/components/ui/tabs.tsx +6 -0
  34. package/src/fonts/HyperlegibleSans-Bold.woff2 +0 -0
  35. package/src/fonts/HyperlegibleSans-BoldItalic.woff2 +0 -0
  36. package/src/fonts/HyperlegibleSans-Italic.woff2 +0 -0
  37. package/src/fonts/HyperlegibleSans-Medium.woff2 +0 -0
  38. package/src/fonts/HyperlegibleSans-MediumItalic.woff2 +0 -0
  39. package/src/fonts/HyperlegibleSans-Regular.woff2 +0 -0
  40. package/src/fonts/InterVariable-Italic.woff2 +0 -0
  41. package/src/fonts/InterVariable.woff2 +0 -0
  42. package/src/fonts.css +99 -0
  43. package/src/hooks/use-global-primary-color.ts +114 -68
  44. package/src/hooks/use-global-serif-font.ts +1 -1
  45. package/src/lib/storage.ts +2 -2
  46. package/src/styles.css +151 -61
  47. package/src/tokens.default.json +4 -4
  48. package/src/tokens.json +159 -162
  49. package/src/app/preview/login/page.tsx +0 -5
  50. package/src/app/preview/mail/page.tsx +0 -4
  51. package/src/app/preview/pricing/page.tsx +0 -4
  52. package/src/components/admin-menu.stories.tsx +0 -68
  53. package/src/components/admin-menu.tsx +0 -59
@@ -2,6 +2,8 @@
2
2
 
3
3
  import { useEffect, useState } from "react";
4
4
  import { Loader2, FileText, GitCommit, ChevronRight, Check, AlertCircle } from "lucide-react";
5
+ import ReactMarkdown, { type Components } from "react-markdown";
6
+ import remarkGfm from "remark-gfm";
5
7
  import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";
6
8
  import { Input } from "@behavioral-agentic-design-system/core/components/ui/input";
7
9
  import { Textarea } from "@behavioral-agentic-design-system/core/components/ui/textarea";
@@ -10,12 +12,107 @@ import { ScrollArea } from "@behavioral-agentic-design-system/core/components/ui
10
12
  type LayerEntry = { slug: string; label: string; files: string[] };
11
13
  type SaveStatus = "idle" | "saving" | "success" | "error";
12
14
  type FileType = "editable" | "read-only";
15
+ type ViewMode = "preview" | "code";
13
16
 
14
17
  function getFileType(path: string): FileType {
15
18
  if (path.endsWith("tokens.json")) return "read-only";
16
19
  return "editable";
17
20
  }
18
21
 
22
+ function isMarkdown(path: string | null): boolean {
23
+ return !!path && path.toLowerCase().endsWith(".md");
24
+ }
25
+
26
+ // BADS-styled wrapper around react-markdown so the rendered preview reads
27
+ // like the rest of the system (token-aligned colors, AAA text contrast,
28
+ // 14px floor on body type via the global type scale).
29
+ const MARKDOWN_COMPONENTS: Components = {
30
+ h1: ({ children, ...props }: any) => (
31
+ <h1 className="mt-6 mb-3 text-2xl font-semibold tracking-tight first:mt-0" {...props}>{children}</h1>
32
+ ),
33
+ h2: ({ children, ...props }: any) => (
34
+ <h2 className="mt-6 mb-3 text-xl font-semibold tracking-tight first:mt-0" {...props}>{children}</h2>
35
+ ),
36
+ h3: ({ children, ...props }: any) => (
37
+ <h3 className="mt-5 mb-2 text-lg font-semibold tracking-tight" {...props}>{children}</h3>
38
+ ),
39
+ h4: ({ children, ...props }: any) => (
40
+ <h4 className="mt-4 mb-2 text-base font-semibold" {...props}>{children}</h4>
41
+ ),
42
+ h5: ({ children, ...props }: any) => (
43
+ <h5 className="mt-3 mb-1 text-sm font-semibold uppercase tracking-wide text-muted-foreground" {...props}>{children}</h5>
44
+ ),
45
+ h6: ({ children, ...props }: any) => (
46
+ <h6 className="mt-3 mb-1 text-sm font-semibold uppercase tracking-wide text-muted-foreground" {...props}>{children}</h6>
47
+ ),
48
+ p: ({ children, ...props }: any) => (
49
+ <p className="mb-3 leading-relaxed" {...props}>{children}</p>
50
+ ),
51
+ a: ({ children, href, ...props }: any) => (
52
+ <a href={href} target="_blank" rel="noreferrer" className="text-primary underline underline-offset-2 hover:text-primary/80" {...props}>{children}</a>
53
+ ),
54
+ ul: ({ children, ...props }: any) => (
55
+ <ul className="mb-3 list-disc space-y-1 pl-6" {...props}>{children}</ul>
56
+ ),
57
+ ol: ({ children, ...props }: any) => (
58
+ <ol className="mb-3 list-decimal space-y-1 pl-6" {...props}>{children}</ol>
59
+ ),
60
+ li: ({ children, ...props }: any) => (
61
+ <li className="leading-relaxed" {...props}>{children}</li>
62
+ ),
63
+ code: ({ children, className, ...props }: any) => {
64
+ const inline = !/language-/.test(className ?? "");
65
+ if (inline) {
66
+ return (
67
+ <code className="rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground" {...props}>{children}</code>
68
+ );
69
+ }
70
+ return (
71
+ <code className={`font-mono text-xs ${className ?? ""}`} {...props}>{children}</code>
72
+ );
73
+ },
74
+ pre: ({ children, ...props }: any) => (
75
+ <pre className="mb-3 overflow-x-auto rounded-md border bg-muted/50 p-4 text-xs leading-relaxed" {...props}>{children}</pre>
76
+ ),
77
+ blockquote: ({ children, ...props }: any) => (
78
+ <blockquote className="mb-3 border-l-4 border-border pl-4 italic text-muted-foreground" {...props}>{children}</blockquote>
79
+ ),
80
+ hr: () => <hr className="my-6 border-border" />,
81
+ table: ({ children, ...props }: any) => (
82
+ <div className="mb-3 overflow-x-auto">
83
+ <table className="w-full border-collapse text-xs" {...props}>{children}</table>
84
+ </div>
85
+ ),
86
+ thead: ({ children, ...props }: any) => (
87
+ <thead className="border-b bg-muted/40 text-left" {...props}>{children}</thead>
88
+ ),
89
+ th: ({ children, ...props }: any) => (
90
+ <th className="border border-border px-3 py-2 font-medium" {...props}>{children}</th>
91
+ ),
92
+ td: ({ children, ...props }: any) => (
93
+ <td className="border border-border px-3 py-2 align-top" {...props}>{children}</td>
94
+ ),
95
+ img: ({ src, alt, ...props }: any) => (
96
+ <img src={typeof src === "string" ? src : undefined} alt={alt ?? ""} className="my-3 max-w-full rounded-md border" {...props} />
97
+ ),
98
+ strong: ({ children, ...props }: any) => (
99
+ <strong className="font-semibold text-foreground" {...props}>{children}</strong>
100
+ ),
101
+ em: ({ children, ...props }: any) => (
102
+ <em className="italic" {...props}>{children}</em>
103
+ ),
104
+ };
105
+
106
+ function MarkdownPreview({ source }: { source: string }) {
107
+ return (
108
+ <div className="max-w-3xl text-sm text-foreground/90">
109
+ <ReactMarkdown remarkPlugins={[remarkGfm]} components={MARKDOWN_COMPONENTS}>
110
+ {source}
111
+ </ReactMarkdown>
112
+ </div>
113
+ );
114
+ }
115
+
19
116
  // fileType is set synchronously when activePath changes, but `content` only
20
117
  // updates after the fetch resolves. That tick of stale content briefly
21
118
  // renders inside the read-only branch, crashing JSON.parse if the previous
@@ -39,6 +136,7 @@ export function LayersTab() {
39
136
  const [commitMessage, setCommitMessage] = useState<string>("");
40
137
  const [status, setStatus] = useState<SaveStatus>("idle");
41
138
  const [statusMessage, setStatusMessage] = useState<string>("");
139
+ const [viewMode, setViewMode] = useState<ViewMode>("preview");
42
140
 
43
141
  // Load tree
44
142
  useEffect(() => {
@@ -184,9 +282,45 @@ export function LayersTab() {
184
282
  {activePath.split("/").pop()}
185
283
  </h2>
186
284
  </div>
187
- {dirty && (
188
- <span className="text-xs text-muted-foreground shrink-0">Unsaved</span>
189
- )}
285
+ <div className="flex items-center gap-3 shrink-0">
286
+ {isMarkdown(activePath) && (
287
+ <div
288
+ role="tablist"
289
+ aria-label="View mode"
290
+ className="inline-flex items-center gap-1 rounded-md border bg-muted/40 p-1"
291
+ >
292
+ <button
293
+ role="tab"
294
+ type="button"
295
+ aria-selected={viewMode === "preview"}
296
+ onClick={() => setViewMode("preview")}
297
+ className={`rounded px-3 py-1 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${
298
+ viewMode === "preview"
299
+ ? "bg-background text-foreground shadow-xs"
300
+ : "text-muted-foreground hover:text-foreground"
301
+ }`}
302
+ >
303
+ Preview
304
+ </button>
305
+ <button
306
+ role="tab"
307
+ type="button"
308
+ aria-selected={viewMode === "code"}
309
+ onClick={() => setViewMode("code")}
310
+ className={`rounded px-3 py-1 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${
311
+ viewMode === "code"
312
+ ? "bg-background text-foreground shadow-xs"
313
+ : "text-muted-foreground hover:text-foreground"
314
+ }`}
315
+ >
316
+ Code
317
+ </button>
318
+ </div>
319
+ )}
320
+ {dirty && (
321
+ <span className="text-xs text-muted-foreground">Unsaved</span>
322
+ )}
323
+ </div>
190
324
  </header>
191
325
 
192
326
  {fileType === "read-only" ? (
@@ -195,6 +329,10 @@ export function LayersTab() {
195
329
  {prettyJsonOrRaw(content)}
196
330
  </pre>
197
331
  </div>
332
+ ) : isMarkdown(activePath) && viewMode === "preview" ? (
333
+ <div className="flex-1 overflow-auto px-6 py-8">
334
+ <MarkdownPreview source={content} />
335
+ </div>
198
336
  ) : (
199
337
  <Textarea
200
338
  value={content}
@@ -15,14 +15,14 @@ const alertVariants = cva(
15
15
  // bg-muted gives default alerts a subtle surface bump so they read as
16
16
  // a callout even when nested inside a Card (which is also bg-card).
17
17
  // Without this, default alert + card = identical surfaces, no hierarchy.
18
- default: "bg-muted text-foreground",
18
+ default: "border-l-4 border-l-primary bg-primary/5 text-foreground [&>svg]:text-primary dark:bg-primary/10",
19
19
  // bg-destructive/10 gives destructive alerts a soft red tint without
20
20
  // overwhelming the surface. Composite contrast (destructive on
21
21
  // destructive/10 over card) stays above AA 4.5:1 across the default
22
22
  // BADS palette; forks with very saturated destructive tokens should
23
23
  // re-check with `pnpm wcag:audit` after token edits.
24
24
  destructive:
25
- "bg-destructive/10 text-destructive *:data-[slot=alert-description]:text-destructive/90 [&>svg]:text-current",
25
+ "border-l-4 border-l-destructive bg-destructive/5 text-destructive *:data-[slot=alert-description]:text-destructive/90 [&>svg]:text-current dark:bg-destructive/10",
26
26
  },
27
27
  },
28
28
  defaultVariants: {
@@ -0,0 +1,124 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+
5
+ import { cn } from "../../lib/utils"
6
+ import {
7
+ Sheet,
8
+ SheetClose,
9
+ SheetContent,
10
+ SheetDescription,
11
+ SheetFooter,
12
+ SheetHeader,
13
+ SheetTitle,
14
+ SheetTrigger,
15
+ } from "./sheet"
16
+
17
+ /**
18
+ * BottomSheet — a bottom-anchored disclosure surface, the dominant
19
+ * secondary-content container in current production apps (Raycast, Linear
20
+ * mobile, Arc). Built on the Radix Dialog–backed Sheet primitive with
21
+ * `side="bottom"`, so it inherits Sheet's focus trap, ESC/overlay dismissal,
22
+ * scroll lock, and AAA-tuned focus ring for free.
23
+ *
24
+ * What this adds over `<SheetContent side="bottom">`:
25
+ * - Rounded top corners + a centered grab-handle affordance (the visual
26
+ * signal users now read as "this panel came from the bottom").
27
+ * - Mobile-first sizing: caps at 85svh and scrolls internally so a tall
28
+ * sheet never pushes its footer off-screen.
29
+ * - A coherent BottomSheet* API surface so callers don't mix Sheet and
30
+ * BottomSheet names.
31
+ *
32
+ * Not draggable. This wrapper is intentionally built on Radix, not vaul, so
33
+ * there are no drag-to-dismiss physics or snap points — dismissal is via the
34
+ * grab handle (decorative), overlay click, ESC, or an explicit close button.
35
+ * If a fork needs true drag/snap behavior, that's a separate vaul-backed
36
+ * primitive and a deliberate dependency decision (see CHANGELOG 2026-05-31).
37
+ */
38
+
39
+ function BottomSheet({ ...props }: React.ComponentProps<typeof Sheet>) {
40
+ return <Sheet data-slot="bottom-sheet" {...props} />
41
+ }
42
+
43
+ function BottomSheetTrigger({
44
+ ...props
45
+ }: React.ComponentProps<typeof SheetTrigger>) {
46
+ return <SheetTrigger data-slot="bottom-sheet-trigger" {...props} />
47
+ }
48
+
49
+ function BottomSheetClose({
50
+ ...props
51
+ }: React.ComponentProps<typeof SheetClose>) {
52
+ return <SheetClose data-slot="bottom-sheet-close" {...props} />
53
+ }
54
+
55
+ function BottomSheetContent({
56
+ className,
57
+ children,
58
+ showHandle = true,
59
+ showCloseButton = true,
60
+ ...props
61
+ }: React.ComponentProps<typeof SheetContent> & {
62
+ /** Show the decorative grab-handle affordance at the top. Default true. */
63
+ showHandle?: boolean
64
+ }) {
65
+ return (
66
+ <SheetContent
67
+ side="bottom"
68
+ showCloseButton={showCloseButton}
69
+ data-slot="bottom-sheet-content"
70
+ className={cn(
71
+ // Rounded top + capped height + internal scroll so a tall sheet keeps
72
+ // its footer reachable. svh tracks the mobile dynamic viewport.
73
+ "max-h-[85svh] gap-0 overflow-y-auto rounded-t-xl pb-[max(1rem,env(safe-area-inset-bottom))]",
74
+ className
75
+ )}
76
+ {...props}
77
+ >
78
+ {showHandle && (
79
+ <div
80
+ aria-hidden="true"
81
+ className="mx-auto mt-3 mb-1 h-1.5 w-12 shrink-0 rounded-full bg-muted-foreground/30"
82
+ />
83
+ )}
84
+ {children}
85
+ </SheetContent>
86
+ )
87
+ }
88
+
89
+ // Header/Footer/Title/Description are 1:1 with Sheet's — re-exported under the
90
+ // BottomSheet name so callers get a single coherent API.
91
+ function BottomSheetHeader({
92
+ ...props
93
+ }: React.ComponentProps<typeof SheetHeader>) {
94
+ return <SheetHeader data-slot="bottom-sheet-header" {...props} />
95
+ }
96
+
97
+ function BottomSheetFooter({
98
+ ...props
99
+ }: React.ComponentProps<typeof SheetFooter>) {
100
+ return <SheetFooter data-slot="bottom-sheet-footer" {...props} />
101
+ }
102
+
103
+ function BottomSheetTitle({
104
+ ...props
105
+ }: React.ComponentProps<typeof SheetTitle>) {
106
+ return <SheetTitle data-slot="bottom-sheet-title" {...props} />
107
+ }
108
+
109
+ function BottomSheetDescription({
110
+ ...props
111
+ }: React.ComponentProps<typeof SheetDescription>) {
112
+ return <SheetDescription data-slot="bottom-sheet-description" {...props} />
113
+ }
114
+
115
+ export {
116
+ BottomSheet,
117
+ BottomSheetTrigger,
118
+ BottomSheetClose,
119
+ BottomSheetContent,
120
+ BottomSheetHeader,
121
+ BottomSheetFooter,
122
+ BottomSheetTitle,
123
+ BottomSheetDescription,
124
+ }
@@ -5,7 +5,7 @@ import { Slot } from "@radix-ui/react-slot"
5
5
  import { cn } from "../../lib/utils"
6
6
 
7
7
  const buttonVariants = cva(
8
- "inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
8
+ "inline-flex shrink-0 items-center justify-center gap-2 rounded-full text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
9
9
  {
10
10
  variants: {
11
11
  variant: {
@@ -34,49 +34,150 @@ function useChart() {
34
34
  return context
35
35
  }
36
36
 
37
+ // Recharts v3 components that ship a stroke-dasharray entrance animation.
38
+ // Animation is ON by default — the ResizeObserver gate below ensures the
39
+ // chart never mounts during SSR or before its container has measurable
40
+ // dimensions, which is what causes the "invisible chart" bug in plain
41
+ // Recharts v3. Pass `animate={false}` on the container if you need to
42
+ // freeze the chart at its final state (e.g. for screenshots or print).
43
+ const ANIMATED_RECHARTS_COMPONENTS = new Set<React.ElementType>([
44
+ RechartsPrimitive.Line,
45
+ RechartsPrimitive.Area,
46
+ RechartsPrimitive.Bar,
47
+ RechartsPrimitive.Pie,
48
+ RechartsPrimitive.Radar,
49
+ RechartsPrimitive.RadialBar,
50
+ RechartsPrimitive.Scatter,
51
+ ])
52
+
53
+ function injectAnimationDefault(
54
+ node: React.ReactNode,
55
+ animate: boolean
56
+ ): React.ReactNode {
57
+ // When animate is true we leave Recharts' defaults alone (entrance
58
+ // animation on). When animate is false we walk the tree and force
59
+ // isAnimationActive={false} on every animated primitive.
60
+ if (animate) return node
61
+ if (Array.isArray(node)) {
62
+ return node.map((child, i) => (
63
+ <React.Fragment key={i}>{injectAnimationDefault(child, animate)}</React.Fragment>
64
+ ))
65
+ }
66
+ if (!React.isValidElement(node)) return node
67
+ const element = node as React.ReactElement<any>
68
+ const props = element.props || {}
69
+ const isAnimated = ANIMATED_RECHARTS_COMPONENTS.has(
70
+ element.type as React.ElementType
71
+ )
72
+ const needsDefault =
73
+ isAnimated && props.isAnimationActive === undefined
74
+ const hasChildren = props.children !== undefined
75
+ if (!needsDefault && !hasChildren) return element
76
+ const nextProps: Record<string, unknown> = {}
77
+ if (needsDefault) nextProps.isAnimationActive = false
78
+ if (hasChildren) {
79
+ nextProps.children = injectAnimationDefault(props.children, animate)
80
+ }
81
+ return React.cloneElement(element, nextProps)
82
+ }
83
+
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
+
37
97
  function ChartContainer({
38
98
  id,
39
99
  className,
40
100
  children,
41
101
  config,
42
102
  style,
103
+ animate = true,
43
104
  ...props
44
105
  }: React.ComponentProps<"div"> & {
45
106
  config: ChartConfig
107
+ /**
108
+ * Whether the chart plays Recharts' default entrance animation. On by
109
+ * default — the ResizeObserver gate ensures the chart only mounts once
110
+ * the container is measurable, which prevents the SSR-then-hydrate
111
+ * invisible-chart bug. Pass `animate={false}` to freeze the chart at
112
+ * its final state (e.g. for screenshots, print). Users with
113
+ * `prefers-reduced-motion: reduce` get `animate={false}` automatically
114
+ * regardless of this prop (SC 2.3.3).
115
+ */
116
+ animate?: boolean
46
117
  children: React.ComponentProps<
47
118
  typeof RechartsPrimitive.ResponsiveContainer
48
119
  >["children"]
49
120
  }) {
50
121
  const uniqueId = React.useId()
51
122
  const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`
52
-
53
- // Recharts' ResponsiveContainer can't measure during SSR (no DOM), so it
54
- // logs a "width(-1) and height(-1)" warning to the dev terminal on every
55
- // request. Gating render until after mount keeps the chart a client-only
56
- // tree — the wrapping div still SSRs and reserves layout, only the chart
57
- // itself waits one tick to mount once the container is measurable.
58
- const [mounted, setMounted] = React.useState(false)
59
- React.useEffect(() => setMounted(true), [])
123
+ const prefersReducedMotion = usePrefersReducedMotion()
124
+ const effectiveAnimate = animate && !prefersReducedMotion
125
+
126
+ // ResponsiveContainer logs "width(-1) and height(-1)" whenever it renders
127
+ // before the wrapping div has a measurable size — SSR, first paint, or
128
+ // any container-query-gated height that hasn't kicked in yet. Gate on a
129
+ // ResizeObserver so the chart only mounts once we've observed non-zero
130
+ // width AND height. The wrapping div still SSRs so layout is reserved.
131
+ const containerRef = React.useRef<HTMLDivElement | null>(null)
132
+ const [hasSize, setHasSize] = React.useState(false)
133
+
134
+ React.useEffect(() => {
135
+ const el = containerRef.current
136
+ if (!el) return
137
+ const observer = new ResizeObserver((entries) => {
138
+ for (const entry of entries) {
139
+ const { width, height } = entry.contentRect
140
+ if (width > 0 && height > 0) {
141
+ setHasSize(true)
142
+ return
143
+ }
144
+ }
145
+ setHasSize(false)
146
+ })
147
+ observer.observe(el)
148
+ return () => observer.disconnect()
149
+ }, [])
150
+
151
+ // Recursively default isAnimationActive={false} on every animated Recharts
152
+ // child. Consumers can override per-element by passing the prop explicitly,
153
+ // or opt the whole tree back in via the `animate` prop on the container.
154
+ const safeChildren = React.useMemo(
155
+ () => injectAnimationDefault(children, effectiveAnimate) as typeof children,
156
+ [children, effectiveAnimate]
157
+ )
60
158
 
61
159
  return (
62
160
  <ChartContext.Provider value={{ config }}>
63
161
  <div
162
+ ref={containerRef}
64
163
  data-slot="chart"
65
164
  data-chart={chartId}
66
165
  className={cn(
166
+ // Default to block. The prior default `display: grid` (a leftover
167
+ // from older shadcn chart code) confused Recharts v3's
168
+ // ResizeObserver and caused it to measure -1x-1 through the
169
+ // implicit auto rows. Consumers pass w-full + an explicit height
170
+ // class; block lets those determine the box.
67
171
  "relative w-full text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
68
172
  className
69
173
  )}
70
- style={{
71
- display: "grid",
72
- ...style,
73
- }}
174
+ style={style}
74
175
  {...props}
75
176
  >
76
177
  <ChartStyle id={chartId} config={config} />
77
- {mounted ? (
178
+ {hasSize ? (
78
179
  <RechartsPrimitive.ResponsiveContainer width="100%" height="100%">
79
- {children}
180
+ {safeChildren}
80
181
  </RechartsPrimitive.ResponsiveContainer>
81
182
  ) : null}
82
183
  </div>
@@ -14,14 +14,15 @@ function Checkbox({
14
14
  <CheckboxPrimitive.Root
15
15
  data-slot="checkbox"
16
16
  className={cn(
17
- "peer inline-flex size-8 shrink-0 items-center justify-center rounded-[4px] bg-muted leading-none outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-2 aria-invalid:ring-destructive/60 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
17
+ "peer inline-flex size-8 shrink-0 items-center justify-center rounded-[4px] border-2 border-muted-foreground/60 bg-white leading-none shadow-xs transition-[background-color,border-color,color] duration-[210ms] ease-in-out outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground dark:aria-invalid:ring-destructive/40",
18
18
  className
19
19
  )}
20
20
  {...props}
21
21
  >
22
22
  <CheckboxPrimitive.Indicator
23
+ forceMount
23
24
  data-slot="checkbox-indicator"
24
- className="grid place-content-center text-current transition-none"
25
+ className="grid place-content-center text-current opacity-0 scale-75 transition-[opacity,transform] duration-[120ms] ease-out data-[state=checked]:opacity-100 data-[state=checked]:scale-100 data-[state=indeterminate]:opacity-100 data-[state=indeterminate]:scale-100"
25
26
  >
26
27
  <CheckIcon className="size-6" strokeWidth={3} />
27
28
  </CheckboxPrimitive.Indicator>
@@ -9,7 +9,7 @@ import { cn } from "../../lib/utils"
9
9
  import { Button } from "./button"
10
10
 
11
11
  const dialogContentVariants = cva(
12
- "fixed left-[50%] top-[50%] z-50 grid w-full translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 sm:rounded-lg",
12
+ "fixed left-[50%] top-[50%] z-50 grid w-full translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-2xl ring-1 ring-white/10 duration-200 outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 sm:rounded-lg",
13
13
  {
14
14
  variants: {
15
15
  size: {
@@ -59,7 +59,7 @@ function DialogOverlay({
59
59
  <DialogPrimitive.Overlay
60
60
  data-slot="dialog-overlay"
61
61
  className={cn(
62
- "fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",
62
+ "fixed inset-0 z-50 bg-black/40 backdrop-blur-sm data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",
63
63
  className
64
64
  )}
65
65
  {...props}
@@ -90,7 +90,7 @@ function DialogContent({
90
90
  {showCloseButton && (
91
91
  <DialogPrimitive.Close
92
92
  data-slot="dialog-close"
93
- className="absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
93
+ className="absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-8"
94
94
  >
95
95
  <XIcon />
96
96
  <span className="sr-only">Close</span>
@@ -24,6 +24,7 @@ export * from "./scroll-area";
24
24
  export * from "./select";
25
25
  export * from "./separator";
26
26
  export * from "./sheet";
27
+ export * from "./bottom-sheet";
27
28
  export * from "./sidebar";
28
29
  export * from "./skeleton";
29
30
  export * from "./slider";
@@ -27,16 +27,17 @@ function RadioGroupItem({
27
27
  <RadioGroupPrimitive.Item
28
28
  data-slot="radio-group-item"
29
29
  className={cn(
30
- "aspect-square size-9 shrink-0 rounded-full bg-muted text-primary outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-2 aria-invalid:ring-destructive/60 data-[state=checked]:bg-primary",
30
+ "aspect-square size-9 shrink-0 rounded-full border-2 border-muted-foreground/60 bg-white text-primary shadow-xs transition-[background-color,border-color,color] duration-[210ms] ease-in-out outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 data-[state=checked]:bg-primary data-[state=checked]:border-primary",
31
31
  className
32
32
  )}
33
33
  {...props}
34
34
  >
35
35
  <RadioGroupPrimitive.Indicator
36
+ forceMount
36
37
  data-slot="radio-group-indicator"
37
- className="relative flex items-center justify-center"
38
+ className="flex h-full w-full items-center justify-center opacity-0 scale-75 transition-[opacity,transform] duration-[120ms] ease-out data-[state=checked]:opacity-100 data-[state=checked]:scale-100"
38
39
  >
39
- <CircleIcon className="absolute top-1/2 left-1/2 size-3 -translate-x-1/2 -translate-y-1/2 fill-primary-foreground" />
40
+ <CircleIcon className="size-4 fill-primary-foreground stroke-primary-foreground" />
40
41
  </RadioGroupPrimitive.Indicator>
41
42
  </RadioGroupPrimitive.Item>
42
43
  )
@@ -36,7 +36,7 @@ function SheetOverlay({
36
36
  <SheetPrimitive.Overlay
37
37
  data-slot="sheet-overlay"
38
38
  className={cn(
39
- "fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",
39
+ "fixed inset-0 z-50 bg-black/40 backdrop-blur-sm data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",
40
40
  className
41
41
  )}
42
42
  {...props}
@@ -18,14 +18,14 @@ function Switch({
18
18
  data-slot="switch"
19
19
  data-size={size}
20
20
  className={cn(
21
- "peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs transition-colors outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[2.3rem] data-[size=default]:w-16 data-[size=sm]:h-7 data-[size=sm]:w-12 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80",
21
+ "peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs transition-[background-color] duration-[210ms] ease-in-out outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[2.3rem] data-[size=default]:w-16 data-[size=sm]:h-7 data-[size=sm]:w-12 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80",
22
22
  className
23
23
  )}
24
24
  {...props}
25
25
  >
26
26
  <CheckIcon
27
27
  strokeWidth={3}
28
- className="pointer-events-none absolute left-2 size-4 text-primary-foreground opacity-0 scale-50 -translate-x-1 transition-all duration-200 group-data-[state=checked]/switch:opacity-100 group-data-[state=checked]/switch:scale-100 group-data-[state=checked]/switch:translate-x-0"
28
+ className="pointer-events-none absolute left-2 size-4 text-primary-foreground opacity-0 scale-75 transition-[opacity,transform] duration-[120ms] ease-out group-data-[state=checked]/switch:opacity-100 group-data-[state=checked]/switch:scale-100"
29
29
  />
30
30
  <SwitchPrimitive.Thumb
31
31
  data-slot="switch-thumb"
@@ -36,7 +36,7 @@ function Switch({
36
36
  // the thumb always contrasts the track: near-white thumb on
37
37
  // near-black track in light, near-black thumb on near-white
38
38
  // track in dark.
39
- "pointer-events-none block rounded-full bg-white data-[state=checked]:bg-primary-foreground ring-0 transition-[transform,background-color] duration-200 group-data-[size=default]/switch:size-8 group-data-[size=sm]/switch:size-6 data-[state=checked]:translate-x-[calc(100%-4px)] data-[state=unchecked]:translate-x-[2px]"
39
+ "pointer-events-none block rounded-full bg-white data-[state=checked]:bg-primary-foreground ring-0 shadow-sm transition-[translate,background-color] duration-[175ms] ease-[cubic-bezier(0.25,0.46,0.45,0.94)] group-data-[size=default]/switch:size-8 group-data-[size=sm]/switch:size-6 data-[state=checked]:translate-x-[calc(100%-4px)] data-[state=unchecked]:translate-x-[2px]"
40
40
  )}
41
41
  />
42
42
  </SwitchPrimitive.Root>
@@ -64,6 +64,12 @@ function TabsTrigger({
64
64
  <TabsPrimitive.Trigger
65
65
  data-slot="tabs-trigger"
66
66
  className={cn(
67
+ // Active-state text uses --foreground rather than --accent-foreground.
68
+ // The runtime brand-picker (use-global-primary-color → pickAccentForeground)
69
+ // already guards --accent-foreground against AAA failures, but
70
+ // --foreground vs --accent is structurally safe in every theme
71
+ // (~13:1 dark, ~20:1 light) and matches the Calendar range-middle
72
+ // pattern, so nested tabs can never regress on brand swaps.
67
73
  "inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground ring-offset-background transition-all focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-accent data-[state=active]:text-foreground data-[state=active]:shadow-xs",
68
74
  className
69
75
  )}
Binary file