@behavioral-agentic-design-system/core 0.7.0 → 0.8.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/package.json +6 -2
- package/src/api/layers.ts +34 -6
- package/src/api/onboarding-extract.ts +435 -0
- package/src/api/onboarding.ts +82 -0
- package/src/app/shell.tsx +87 -25
- package/src/components/Foundations/Colors.stories.tsx +10 -1
- package/src/components/customize-tab.tsx +3 -0
- package/src/components/home-tab.tsx +1 -1
- package/src/components/layers-tab.tsx +172 -7
- package/src/components/onboarding-wizard.tsx +1421 -0
- package/src/components/ui/dialog.tsx +4 -1
- package/src/components/ui/dropdown-menu.tsx +4 -0
- package/src/components/ui/popover.tsx +6 -0
- package/src/components/ui/scroll-area.tsx +5 -0
- package/src/components/ui/select.tsx +4 -0
- package/src/components/ui/sheet.tsx +7 -0
- package/src/components/ui/slider.tsx +22 -7
- package/src/components/ui/tooltip.tsx +4 -0
- package/src/hooks/use-portal-theme-class.tsx +90 -0
|
@@ -6,6 +6,7 @@ import { XIcon } from "lucide-react"
|
|
|
6
6
|
import * as DialogPrimitive from "@radix-ui/react-dialog"
|
|
7
7
|
|
|
8
8
|
import { cn } from "../../lib/utils"
|
|
9
|
+
import { usePortalThemeClass } from "../../hooks/use-portal-theme-class"
|
|
9
10
|
import { Button } from "./button"
|
|
10
11
|
|
|
11
12
|
const dialogContentVariants = cva(
|
|
@@ -77,13 +78,15 @@ function DialogContent({
|
|
|
77
78
|
VariantProps<typeof dialogContentVariants> & {
|
|
78
79
|
showCloseButton?: boolean
|
|
79
80
|
}) {
|
|
81
|
+
// See use-portal-theme-class.ts.
|
|
82
|
+
const portalThemeClass = usePortalThemeClass()
|
|
80
83
|
return (
|
|
81
84
|
<DialogPortal data-slot="dialog-portal">
|
|
82
85
|
<DialogOverlay />
|
|
83
86
|
<DialogPrimitive.Content
|
|
84
87
|
data-slot="dialog-content"
|
|
85
88
|
data-size={size ?? "default"}
|
|
86
|
-
className={cn(dialogContentVariants({ size }), className)}
|
|
89
|
+
className={cn(dialogContentVariants({ size }), portalThemeClass, className)}
|
|
87
90
|
{...props}
|
|
88
91
|
>
|
|
89
92
|
{children}
|
|
@@ -5,6 +5,7 @@ import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react"
|
|
|
5
5
|
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"
|
|
6
6
|
|
|
7
7
|
import { cn } from "../../lib/utils"
|
|
8
|
+
import { usePortalThemeClass } from "../../hooks/use-portal-theme-class"
|
|
8
9
|
|
|
9
10
|
function DropdownMenu({
|
|
10
11
|
...props
|
|
@@ -36,6 +37,8 @@ function DropdownMenuContent({
|
|
|
36
37
|
sideOffset = 4,
|
|
37
38
|
...props
|
|
38
39
|
}: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) {
|
|
40
|
+
// See use-portal-theme-class.ts.
|
|
41
|
+
const portalThemeClass = usePortalThemeClass()
|
|
39
42
|
return (
|
|
40
43
|
<DropdownMenuPrimitive.Portal>
|
|
41
44
|
<DropdownMenuPrimitive.Content
|
|
@@ -43,6 +46,7 @@ function DropdownMenuContent({
|
|
|
43
46
|
sideOffset={sideOffset}
|
|
44
47
|
className={cn(
|
|
45
48
|
"z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
|
|
49
|
+
portalThemeClass,
|
|
46
50
|
className
|
|
47
51
|
)}
|
|
48
52
|
{...props}
|
|
@@ -4,6 +4,7 @@ import * as React from "react"
|
|
|
4
4
|
import * as PopoverPrimitive from "@radix-ui/react-popover"
|
|
5
5
|
|
|
6
6
|
import { cn } from "../../lib/utils"
|
|
7
|
+
import { usePortalThemeClass } from "../../hooks/use-portal-theme-class"
|
|
7
8
|
|
|
8
9
|
function Popover({
|
|
9
10
|
...props
|
|
@@ -23,6 +24,10 @@ function PopoverContent({
|
|
|
23
24
|
sideOffset = 4,
|
|
24
25
|
...props
|
|
25
26
|
}: React.ComponentProps<typeof PopoverPrimitive.Content>) {
|
|
27
|
+
// See use-portal-theme-class.ts: lets a PortalThemeProvider scope class
|
|
28
|
+
// (e.g. "atrium-theme") apply to portal content so theme-scoped CSS
|
|
29
|
+
// variables resolve inside the portal.
|
|
30
|
+
const portalThemeClass = usePortalThemeClass()
|
|
26
31
|
return (
|
|
27
32
|
<PopoverPrimitive.Portal>
|
|
28
33
|
<PopoverPrimitive.Content
|
|
@@ -31,6 +36,7 @@ function PopoverContent({
|
|
|
31
36
|
sideOffset={sideOffset}
|
|
32
37
|
className={cn(
|
|
33
38
|
"z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-hidden data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
|
|
39
|
+
portalThemeClass,
|
|
34
40
|
className
|
|
35
41
|
)}
|
|
36
42
|
{...props}
|
|
@@ -18,6 +18,11 @@ function ScrollArea({
|
|
|
18
18
|
>
|
|
19
19
|
<ScrollAreaPrimitive.Viewport
|
|
20
20
|
data-slot="scroll-area-viewport"
|
|
21
|
+
// tabIndex={0} makes the scroll region reachable by keyboard so its
|
|
22
|
+
// overflow content is navigable without a mouse (WCAG 2.1.1, axe
|
|
23
|
+
// scrollable-region-focusable). The focus-visible ring below already
|
|
24
|
+
// anticipates this — Radix's Viewport just isn't focusable on its own.
|
|
25
|
+
tabIndex={0}
|
|
21
26
|
className="size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1"
|
|
22
27
|
>
|
|
23
28
|
{children}
|
|
@@ -5,6 +5,7 @@ import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react"
|
|
|
5
5
|
import * as SelectPrimitive from "@radix-ui/react-select"
|
|
6
6
|
|
|
7
7
|
import { cn } from "../../lib/utils"
|
|
8
|
+
import { usePortalThemeClass } from "../../hooks/use-portal-theme-class"
|
|
8
9
|
|
|
9
10
|
function Select({
|
|
10
11
|
...props
|
|
@@ -57,6 +58,8 @@ function SelectContent({
|
|
|
57
58
|
align = "center",
|
|
58
59
|
...props
|
|
59
60
|
}: React.ComponentProps<typeof SelectPrimitive.Content>) {
|
|
61
|
+
// See use-portal-theme-class.ts.
|
|
62
|
+
const portalThemeClass = usePortalThemeClass()
|
|
60
63
|
return (
|
|
61
64
|
<SelectPrimitive.Portal>
|
|
62
65
|
<SelectPrimitive.Content
|
|
@@ -65,6 +68,7 @@ function SelectContent({
|
|
|
65
68
|
"relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
|
|
66
69
|
position === "popper" &&
|
|
67
70
|
"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
|
|
71
|
+
portalThemeClass,
|
|
68
72
|
className
|
|
69
73
|
)}
|
|
70
74
|
position={position}
|
|
@@ -5,6 +5,7 @@ import { XIcon } from "lucide-react"
|
|
|
5
5
|
import * as SheetPrimitive from "@radix-ui/react-dialog"
|
|
6
6
|
|
|
7
7
|
import { cn } from "../../lib/utils"
|
|
8
|
+
import { usePortalThemeClass } from "../../hooks/use-portal-theme-class"
|
|
8
9
|
|
|
9
10
|
function Sheet({ ...props }: React.ComponentProps<typeof SheetPrimitive.Root>) {
|
|
10
11
|
return <SheetPrimitive.Root data-slot="sheet" {...props} />
|
|
@@ -54,6 +55,11 @@ function SheetContent({
|
|
|
54
55
|
side?: "top" | "right" | "bottom" | "left"
|
|
55
56
|
showCloseButton?: boolean
|
|
56
57
|
}) {
|
|
58
|
+
// Apply the active portal theme scope to the content's className so any
|
|
59
|
+
// theme-scoped CSS variables a consumer uses (`--shell-chrome-bg-rgb`,
|
|
60
|
+
// `--brand-*`) resolve correctly inside the Radix portal. Returns "" if
|
|
61
|
+
// no PortalThemeProvider is mounted — additive, no breaking changes.
|
|
62
|
+
const portalThemeClass = usePortalThemeClass()
|
|
57
63
|
return (
|
|
58
64
|
<SheetPortal>
|
|
59
65
|
<SheetOverlay />
|
|
@@ -69,6 +75,7 @@ function SheetContent({
|
|
|
69
75
|
"inset-x-0 top-0 h-auto border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
|
|
70
76
|
side === "bottom" &&
|
|
71
77
|
"inset-x-0 bottom-0 h-auto border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
|
|
78
|
+
portalThemeClass,
|
|
72
79
|
className
|
|
73
80
|
)}
|
|
74
81
|
{...props}
|
|
@@ -11,6 +11,8 @@ function Slider({
|
|
|
11
11
|
value,
|
|
12
12
|
min = 0,
|
|
13
13
|
max = 100,
|
|
14
|
+
"aria-label": ariaLabel,
|
|
15
|
+
"aria-labelledby": ariaLabelledby,
|
|
14
16
|
...props
|
|
15
17
|
}: React.ComponentProps<typeof SliderPrimitive.Root>) {
|
|
16
18
|
const _values = React.useMemo(
|
|
@@ -54,13 +56,26 @@ function Slider({
|
|
|
54
56
|
)}
|
|
55
57
|
/>
|
|
56
58
|
</SliderPrimitive.Track>
|
|
57
|
-
{Array.from({ length: _values.length }, (_, index) =>
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
{Array.from({ length: _values.length }, (_, index) => {
|
|
60
|
+
// Radix puts role="slider" on the thumb, not the Root, so the
|
|
61
|
+
// accessible name has to live here — a label on Root alone fails
|
|
62
|
+
// axe's aria-input-field-name (WCAG 4.1.2). Forward the consumer's
|
|
63
|
+
// label to every thumb; for a range (2+ thumbs) disambiguate which
|
|
64
|
+
// end each thumb controls so they don't announce identically.
|
|
65
|
+
const thumbLabel =
|
|
66
|
+
ariaLabel && _values.length > 1
|
|
67
|
+
? `${ariaLabel} ${index === 0 ? "minimum" : "maximum"}`
|
|
68
|
+
: ariaLabel
|
|
69
|
+
return (
|
|
70
|
+
<SliderPrimitive.Thumb
|
|
71
|
+
data-slot="slider-thumb"
|
|
72
|
+
key={index}
|
|
73
|
+
aria-label={thumbLabel}
|
|
74
|
+
aria-labelledby={ariaLabelledby}
|
|
75
|
+
className="block size-8 shrink-0 rounded-full border-2 border-primary bg-white shadow-sm ring-ring/50 transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"
|
|
76
|
+
/>
|
|
77
|
+
)
|
|
78
|
+
})}
|
|
64
79
|
</SliderPrimitive.Root>
|
|
65
80
|
)
|
|
66
81
|
}
|
|
@@ -4,6 +4,7 @@ import * as React from "react"
|
|
|
4
4
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip"
|
|
5
5
|
|
|
6
6
|
import { cn } from "../../lib/utils"
|
|
7
|
+
import { usePortalThemeClass } from "../../hooks/use-portal-theme-class"
|
|
7
8
|
|
|
8
9
|
function TooltipProvider({
|
|
9
10
|
delayDuration = 0,
|
|
@@ -36,6 +37,8 @@ function TooltipContent({
|
|
|
36
37
|
children,
|
|
37
38
|
...props
|
|
38
39
|
}: React.ComponentProps<typeof TooltipPrimitive.Content>) {
|
|
40
|
+
// See use-portal-theme-class.ts.
|
|
41
|
+
const portalThemeClass = usePortalThemeClass()
|
|
39
42
|
return (
|
|
40
43
|
<TooltipPrimitive.Portal>
|
|
41
44
|
<TooltipPrimitive.Content
|
|
@@ -43,6 +46,7 @@ function TooltipContent({
|
|
|
43
46
|
sideOffset={sideOffset}
|
|
44
47
|
className={cn(
|
|
45
48
|
"z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md bg-foreground px-3 py-1.5 text-xs text-balance text-background fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
|
|
49
|
+
portalThemeClass,
|
|
46
50
|
className
|
|
47
51
|
)}
|
|
48
52
|
{...props}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Portal-theme-class — keeps Radix Portal'd content (Dialog / Sheet /
|
|
7
|
+
* Popover / Tooltip / HoverCard / DropdownMenu / Select content) inside
|
|
8
|
+
* a consumer's theme scope.
|
|
9
|
+
*
|
|
10
|
+
* Why this exists
|
|
11
|
+
* ----------------
|
|
12
|
+
* Radix portals every "content" surface to `<body>`. Theme classes a
|
|
13
|
+
* consumer applies to a page wrapper (e.g. `<div className="atrium-theme">`)
|
|
14
|
+
* sit ABOVE the body's children in the DOM tree, NOT above the portal —
|
|
15
|
+
* so theme-scoped CSS variables (`--shell-chrome-bg-rgb`, `--brand-*`)
|
|
16
|
+
* defined inside that wrapper class don't reach the portal'd content.
|
|
17
|
+
*
|
|
18
|
+
* The most visible failure mode: a SheetContent styled with
|
|
19
|
+
* `style={{ backgroundColor: "rgb(var(--shell-chrome-bg-rgb) / 0.98)" }}`
|
|
20
|
+
* evaluates to `rgb(undefined / 0.98)` inside the portal, the property
|
|
21
|
+
* is invalid at computed-value time, and the panel falls through to a
|
|
22
|
+
* transparent ghost over the dimmed page. Same root cause as the
|
|
23
|
+
* pre-2026-05 `:root { --shell-cta-bg: var(--shell-accent) }`
|
|
24
|
+
* "white-on-white CTA" bug — variable referenced outside its declaring
|
|
25
|
+
* scope.
|
|
26
|
+
*
|
|
27
|
+
* How it works
|
|
28
|
+
* ------------
|
|
29
|
+
* `<PortalThemeProvider scope="atrium-theme">` is placed once near the
|
|
30
|
+
* app root (typically in the shell's layout) and re-renders whenever
|
|
31
|
+
* the active scope changes. React context CROSSES portals: the body is
|
|
32
|
+
* the React parent of every Portal'd child, but the React TREE still
|
|
33
|
+
* walks up through the provider to find the context value. So Portal'd
|
|
34
|
+
* components reading `usePortalThemeClass()` get the live scope class
|
|
35
|
+
* regardless of where Radix moved their DOM.
|
|
36
|
+
*
|
|
37
|
+
* Each BADS-shipped Portal component (Sheet, Dialog, Popover, etc.)
|
|
38
|
+
* calls the hook and merges the returned class into its content's
|
|
39
|
+
* className via `cn()`. The scope className applied there re-introduces
|
|
40
|
+
* the theme-scoped CSS variables INSIDE the portal — so
|
|
41
|
+
* `rgb(var(--shell-chrome-bg-rgb) / 0.98)` resolves correctly because
|
|
42
|
+
* the var() lookup happens at the portal element, which now has the
|
|
43
|
+
* theme class applied.
|
|
44
|
+
*
|
|
45
|
+
* Multiple scope classes
|
|
46
|
+
* ----------------------
|
|
47
|
+
* `scope` accepts a space-separated string, so a consumer composing
|
|
48
|
+
* style + dark mode + brand can pass `"atrium-theme dark brand-pool"`.
|
|
49
|
+
* The hook returns whatever string the provider holds.
|
|
50
|
+
*
|
|
51
|
+
* SSR
|
|
52
|
+
* ---
|
|
53
|
+
* Defaults to `""` — no class is applied. Renders identically server-
|
|
54
|
+
* and client-side as long as the provider value is stable through
|
|
55
|
+
* hydration. Consumers reading state from localStorage should defer the
|
|
56
|
+
* provider value to a useEffect-mounted state to avoid hydration
|
|
57
|
+
* mismatch (`""` server, scope after hydrate).
|
|
58
|
+
*
|
|
59
|
+
* Backwards compat
|
|
60
|
+
* ----------------
|
|
61
|
+
* If a consumer never adds the provider, the hook returns `""` and
|
|
62
|
+
* every BADS Portal component renders as before. Additive — no
|
|
63
|
+
* breaking changes.
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
const PortalThemeContext = React.createContext<string>("");
|
|
67
|
+
|
|
68
|
+
export function PortalThemeProvider({
|
|
69
|
+
scope,
|
|
70
|
+
children,
|
|
71
|
+
}: {
|
|
72
|
+
/**
|
|
73
|
+
* Space-separated class names to apply to every Portal'd BADS
|
|
74
|
+
* component's content surface (Dialog/Sheet/Popover/Tooltip/etc.).
|
|
75
|
+
* Typically the active theme/scope class — e.g. `"atrium-theme"`,
|
|
76
|
+
* `"clap-brand dark"`, etc.
|
|
77
|
+
*/
|
|
78
|
+
scope: string;
|
|
79
|
+
children: React.ReactNode;
|
|
80
|
+
}) {
|
|
81
|
+
return (
|
|
82
|
+
<PortalThemeContext.Provider value={scope}>
|
|
83
|
+
{children}
|
|
84
|
+
</PortalThemeContext.Provider>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function usePortalThemeClass(): string {
|
|
89
|
+
return React.useContext(PortalThemeContext);
|
|
90
|
+
}
|