@behavioral-agentic-design-system/core 0.28.0 → 0.29.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 +2 -2
- package/scripts/a11y-lint.cjs +78 -9
- package/scripts/build-tokens.cjs +273 -15
- package/scripts/wcag-audit.cjs +37 -7
- package/src/api/layers/file.ts +1 -0
- package/src/app/font-ready.tsx +6 -5
- package/src/app/layout.tsx +54 -3
- package/src/app/preview/components/page.tsx +5532 -3044
- package/src/app/preview/layout.tsx +4 -1
- package/src/app/preview/showcase-filter.tsx +66 -0
- package/src/app/preview/tab-replay.tsx +63 -0
- package/src/app/shell.tsx +74 -18
- package/src/components/customize/save-bar.tsx +19 -6
- package/src/components/docs-tab.tsx +36 -24
- package/src/components/layers-tab.tsx +37 -5
- package/src/components/ui/alert.tsx +12 -0
- package/src/components/ui/badge.tsx +19 -0
- package/src/components/ui/chat-marker.tsx +120 -0
- package/src/components/ui/checkbox.tsx +9 -1
- package/src/components/ui/close-button.tsx +71 -0
- package/src/components/ui/combobox.tsx +62 -3
- package/src/components/ui/container.tsx +65 -0
- package/src/components/ui/date-field.tsx +368 -0
- package/src/components/ui/drawer.tsx +334 -0
- package/src/components/ui/file-button.tsx +145 -0
- package/src/components/ui/floating-indicator.tsx +217 -0
- package/src/components/ui/format-byte.tsx +113 -0
- package/src/components/ui/index.ts +21 -0
- package/src/components/ui/input.tsx +38 -3
- package/src/components/ui/keyboard-shortcut.tsx +146 -0
- package/src/components/ui/loading-dots.tsx +99 -0
- package/src/components/ui/month-picker.tsx +296 -0
- package/src/components/ui/multi-select.tsx +15 -13
- package/src/components/ui/nav-link.tsx +200 -0
- package/src/components/ui/navigation-rail.tsx +256 -0
- package/src/components/ui/notification.tsx +20 -0
- package/src/components/ui/password-input.tsx +34 -1
- package/src/components/ui/progress.tsx +15 -1
- package/src/components/ui/prose.tsx +62 -0
- package/src/components/ui/result.tsx +151 -0
- package/src/components/ui/rolling-number.tsx +1 -0
- package/src/components/ui/simple-grid.tsx +110 -0
- package/src/components/ui/skeleton.tsx +52 -3
- package/src/components/ui/squircle.tsx +274 -0
- package/src/components/ui/stack.tsx +105 -0
- package/src/components/ui/status-badge.tsx +93 -0
- package/src/components/ui/tabs.tsx +34 -7
- package/src/components/ui/tag.tsx +46 -5
- package/src/components/ui/theme-icon.tsx +138 -0
- package/src/components/ui/timeline.tsx +27 -10
- package/src/components/ui/tooltip.tsx +12 -1
- package/src/components/ui/tree-select.tsx +386 -0
- package/src/components/ui/year-picker.tsx +307 -0
- package/src/data/docs-index.ts +10 -0
- package/src/hooks/use-global-primary-color.ts +57 -6
- package/src/stories/Alert.stories.tsx +31 -1
- package/src/stories/Badge.stories.tsx +63 -6
- package/src/stories/ChatMarker.stories.tsx +59 -0
- package/src/stories/Checkbox.stories.tsx +5 -0
- package/src/stories/CloseButton.stories.tsx +65 -0
- package/src/stories/Combobox.stories.tsx +74 -3
- package/src/stories/Container.stories.tsx +134 -0
- package/src/stories/DateField.stories.tsx +114 -0
- package/src/stories/Drawer.stories.tsx +211 -0
- package/src/stories/FileButton.stories.tsx +117 -0
- package/src/stories/FloatingIndicator.stories.tsx +343 -0
- package/src/stories/FormatByte.stories.tsx +142 -0
- package/src/stories/Input.stories.tsx +91 -0
- package/src/stories/KeyboardShortcut.stories.tsx +87 -0
- package/src/stories/LoadingDots.stories.tsx +73 -0
- package/src/stories/MonthPicker.stories.tsx +99 -0
- package/src/stories/MultiSelect.stories.tsx +3 -1
- package/src/stories/NavLink.stories.tsx +213 -0
- package/src/stories/NavigationRail.stories.tsx +413 -0
- package/src/stories/Notification.stories.tsx +53 -0
- package/src/stories/PasswordInput.stories.tsx +21 -0
- package/src/stories/Progress.stories.tsx +38 -0
- package/src/stories/Prose.stories.tsx +232 -0
- package/src/stories/Result.stories.tsx +145 -0
- package/src/stories/RollingNumber.stories.tsx +1 -1
- package/src/stories/SimpleGrid.stories.tsx +130 -0
- package/src/stories/Skeleton.stories.tsx +62 -1
- package/src/stories/Squircle.stories.tsx +127 -0
- package/src/stories/Stack.stories.tsx +139 -0
- package/src/stories/StatusBadge.stories.tsx +125 -0
- package/src/stories/Tabs.stories.tsx +56 -1
- package/src/stories/Tag.stories.tsx +31 -0
- package/src/stories/ThemeIcon.stories.tsx +97 -0
- package/src/stories/Timeline.stories.tsx +69 -0
- package/src/stories/Tooltip.stories.tsx +18 -0
- package/src/stories/TreeSelect.stories.tsx +222 -0
- package/src/stories/YearPicker.stories.tsx +100 -0
- package/src/styles.css +289 -15
- package/src/tokens.json +96 -1
- package/LICENSE +0 -21
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ChatMarker — inline date, status, or session separator for chat flows.
|
|
5
|
+
*
|
|
6
|
+
* Sources: shadcn/ui June 2026 chat release (Marker); standard chat UI
|
|
7
|
+
* convention (iMessage, WhatsApp, Telegram, Slack date dividers).
|
|
8
|
+
*
|
|
9
|
+
* Usage: drop between groups of <ChatBubble> messages to separate by date
|
|
10
|
+
* ("Today", "Yesterday"), status ("Seen", "Delivered"), or session break
|
|
11
|
+
* (plain horizontal rule variant).
|
|
12
|
+
*
|
|
13
|
+
* Accessibility: role="separator" + aria-label for screen readers. The label
|
|
14
|
+
* defaults to the visible text; callers may pass a more descriptive
|
|
15
|
+
* aria-label when the visible label is ambiguous (e.g. "Mon" → "Monday").
|
|
16
|
+
*
|
|
17
|
+
* Motion (spec §4):
|
|
18
|
+
* - entrance: animate-in fade-in-0 (pattern a, same vocabulary as tooltips)
|
|
19
|
+
* - no hover state — this is a presentational separator
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import * as React from "react"
|
|
23
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
24
|
+
|
|
25
|
+
import { cn } from "../../lib/utils"
|
|
26
|
+
|
|
27
|
+
const chatMarkerVariants = cva(
|
|
28
|
+
[
|
|
29
|
+
"my-3 flex items-center gap-3 animate-in fade-in-0",
|
|
30
|
+
"text-xs text-muted-foreground select-none",
|
|
31
|
+
],
|
|
32
|
+
{
|
|
33
|
+
variants: {
|
|
34
|
+
variant: {
|
|
35
|
+
/** Label flanked by horizontal rules — for dates and session breaks. */
|
|
36
|
+
default: "",
|
|
37
|
+
/** Unadorned centered text — for status lines ("Seen 2:14 PM"). */
|
|
38
|
+
status: "justify-center",
|
|
39
|
+
/** Full-width rule with no text — a silent session break. */
|
|
40
|
+
divider: "",
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
defaultVariants: {
|
|
44
|
+
variant: "default",
|
|
45
|
+
},
|
|
46
|
+
}
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
export interface ChatMarkerProps
|
|
50
|
+
extends Omit<React.ComponentProps<"div">, "children">,
|
|
51
|
+
VariantProps<typeof chatMarkerVariants> {
|
|
52
|
+
/** Visible label text. Omit for the `divider` variant. */
|
|
53
|
+
label?: string
|
|
54
|
+
/** Accessible label override when the visible text is abbreviated. */
|
|
55
|
+
"aria-label"?: string
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function ChatMarker({
|
|
59
|
+
label,
|
|
60
|
+
variant = "default",
|
|
61
|
+
className,
|
|
62
|
+
"aria-label": ariaLabel,
|
|
63
|
+
...props
|
|
64
|
+
}: ChatMarkerProps) {
|
|
65
|
+
const effectiveAriaLabel = ariaLabel ?? label
|
|
66
|
+
|
|
67
|
+
if (variant === "divider") {
|
|
68
|
+
return (
|
|
69
|
+
<div
|
|
70
|
+
role="separator"
|
|
71
|
+
aria-label="conversation break"
|
|
72
|
+
data-slot="chat-marker"
|
|
73
|
+
data-variant="divider"
|
|
74
|
+
className={cn("my-4 h-px w-full bg-border/60", className)}
|
|
75
|
+
{...props}
|
|
76
|
+
/>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (variant === "status") {
|
|
81
|
+
return (
|
|
82
|
+
<div
|
|
83
|
+
role="separator"
|
|
84
|
+
aria-label={effectiveAriaLabel}
|
|
85
|
+
data-slot="chat-marker"
|
|
86
|
+
data-variant="status"
|
|
87
|
+
className={cn(chatMarkerVariants({ variant }), className)}
|
|
88
|
+
{...props}
|
|
89
|
+
>
|
|
90
|
+
{label && <span>{label}</span>}
|
|
91
|
+
</div>
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// default: label flanked by lines
|
|
96
|
+
return (
|
|
97
|
+
<div
|
|
98
|
+
role="separator"
|
|
99
|
+
aria-label={effectiveAriaLabel}
|
|
100
|
+
data-slot="chat-marker"
|
|
101
|
+
data-variant="default"
|
|
102
|
+
className={cn(chatMarkerVariants({ variant }), className)}
|
|
103
|
+
{...props}
|
|
104
|
+
>
|
|
105
|
+
<span
|
|
106
|
+
className="h-px flex-1 bg-border/60"
|
|
107
|
+
style={{
|
|
108
|
+
transitionDuration: "var(--duration-fast)",
|
|
109
|
+
transitionTimingFunction: "var(--ease-out)",
|
|
110
|
+
}}
|
|
111
|
+
/>
|
|
112
|
+
{label && (
|
|
113
|
+
<span className="shrink-0 font-medium">{label}</span>
|
|
114
|
+
)}
|
|
115
|
+
<span className="h-px flex-1 bg-border/60" />
|
|
116
|
+
</div>
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export { ChatMarker, chatMarkerVariants }
|
|
@@ -14,7 +14,15 @@ function Checkbox({
|
|
|
14
14
|
<CheckboxPrimitive.Root
|
|
15
15
|
data-slot="checkbox"
|
|
16
16
|
className={cn(
|
|
17
|
-
|
|
17
|
+
// The visible box stays 32px (size-8) for tonal density, but the
|
|
18
|
+
// POINTER TARGET must hit WCAG 2.2 SC 2.5.5 Enhanced (44×44, the AAA
|
|
19
|
+
// floor). A centered transparent ::before overlay (before:size-11 =
|
|
20
|
+
// 44px) extends the interactive area without enlarging the box — a
|
|
21
|
+
// pseudo-element hit-tests to its host, so clicks in the padding toggle
|
|
22
|
+
// the checkbox. It's absolutely positioned, so it adds zero layout
|
|
23
|
+
// (respects the no-jump / layout-stability principle) and never touches
|
|
24
|
+
// a neighbor's flow. Focus ring stays on the visible 32px box.
|
|
25
|
+
"peer relative 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 before:absolute before:left-1/2 before:top-1/2 before:size-11 before:-translate-x-1/2 before:-translate-y-1/2 before:content-[''] 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
26
|
className
|
|
19
27
|
)}
|
|
20
28
|
{...props}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { XIcon } from "lucide-react";
|
|
5
|
+
import type { VariantProps } from "class-variance-authority";
|
|
6
|
+
import { cn } from "../../lib/utils";
|
|
7
|
+
import { Button, buttonVariants } from "./button";
|
|
8
|
+
|
|
9
|
+
// ─── CloseButton ───────────────────────────────────────────────────────────────
|
|
10
|
+
//
|
|
11
|
+
// Standardized dismiss affordance: a ghost icon Button with a built-in
|
|
12
|
+
// 1.5-stroke X and a guaranteed accessible name (default aria-label "Close",
|
|
13
|
+
// always overridable). Exists so every hand-rolled close X — dismissible
|
|
14
|
+
// banners, filter pills, side panels, inline previews — ships with the
|
|
15
|
+
// accessible name and the system stroke weight by default, instead of
|
|
16
|
+
// re-triggering the "icon-only button with no accessible name" a11y-lint
|
|
17
|
+
// finding one surface at a time.
|
|
18
|
+
//
|
|
19
|
+
// Inherits Button's focus ring, disabled handling, and hover/press color
|
|
20
|
+
// motion (transition-colors) wholesale. Cross-system references: Mantine
|
|
21
|
+
// CloseButton, Chakra UI CloseButton.
|
|
22
|
+
//
|
|
23
|
+
// NOT for: Dialog/Sheet content (they ship their own corner X — don't double
|
|
24
|
+
// up), or destructive deletion (that's Button variant="destructive" behind an
|
|
25
|
+
// AlertDialog confirm).
|
|
26
|
+
|
|
27
|
+
type IconSize = "icon-xs" | "icon-sm" | "icon" | "icon-lg" | "icon-xl";
|
|
28
|
+
|
|
29
|
+
export interface CloseButtonProps
|
|
30
|
+
extends Omit<React.ComponentPropsWithoutRef<"button">, "children">,
|
|
31
|
+
Pick<VariantProps<typeof buttonVariants>, "variant"> {
|
|
32
|
+
/**
|
|
33
|
+
* Icon-button size from the Button scale. Default "icon" (36px) — the
|
|
34
|
+
* Dialog/Sheet corner-chrome register (documented dense-chrome exception
|
|
35
|
+
* to the 44px floor). When the close IS the surface's primary
|
|
36
|
+
* flow-changing dismiss affordance, use "icon-lg" (40px) or "icon-xl"
|
|
37
|
+
* (44px, meets SC 2.5.5 Enhanced).
|
|
38
|
+
*/
|
|
39
|
+
size?: IconSize;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const CloseButton = React.forwardRef<
|
|
43
|
+
HTMLButtonElement,
|
|
44
|
+
CloseButtonProps
|
|
45
|
+
>(
|
|
46
|
+
(
|
|
47
|
+
{
|
|
48
|
+
className,
|
|
49
|
+
variant = "ghost",
|
|
50
|
+
size = "icon",
|
|
51
|
+
"aria-label": ariaLabel = "Close",
|
|
52
|
+
type = "button",
|
|
53
|
+
...props
|
|
54
|
+
},
|
|
55
|
+
ref
|
|
56
|
+
) => (
|
|
57
|
+
<Button
|
|
58
|
+
ref={ref}
|
|
59
|
+
data-slot="close-button"
|
|
60
|
+
type={type}
|
|
61
|
+
variant={variant}
|
|
62
|
+
size={size}
|
|
63
|
+
aria-label={ariaLabel}
|
|
64
|
+
className={cn("shrink-0", className)}
|
|
65
|
+
{...props}
|
|
66
|
+
>
|
|
67
|
+
<XIcon strokeWidth={1.5} aria-hidden="true" />
|
|
68
|
+
</Button>
|
|
69
|
+
)
|
|
70
|
+
);
|
|
71
|
+
CloseButton.displayName = "CloseButton";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
3
|
import * as React from "react"
|
|
4
|
-
import { CheckIcon, ChevronsUpDownIcon } from "lucide-react"
|
|
4
|
+
import { CheckIcon, ChevronsUpDownIcon, PlusIcon } from "lucide-react"
|
|
5
5
|
|
|
6
6
|
import { cn } from "../../lib/utils"
|
|
7
7
|
import { Button } from "./button"
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
CommandInput,
|
|
13
13
|
CommandItem,
|
|
14
14
|
CommandList,
|
|
15
|
+
CommandSeparator,
|
|
15
16
|
} from "./command"
|
|
16
17
|
import { Popover, PopoverContent, PopoverTrigger } from "./popover"
|
|
17
18
|
|
|
@@ -30,6 +31,17 @@ export interface ComboboxProps {
|
|
|
30
31
|
emptyText?: string
|
|
31
32
|
disabled?: boolean
|
|
32
33
|
className?: string
|
|
34
|
+
/**
|
|
35
|
+
* When true, shows a "Create [typed text]" option at the bottom of the dropdown
|
|
36
|
+
* if the typed text does not exactly match any existing option label.
|
|
37
|
+
* Pair with `onCreateOption` to handle the creation event.
|
|
38
|
+
*/
|
|
39
|
+
creatable?: boolean
|
|
40
|
+
/**
|
|
41
|
+
* Called with the trimmed text the user typed when they select the "Create" item.
|
|
42
|
+
* Use this to add the new option to the `options` array and update `value`.
|
|
43
|
+
*/
|
|
44
|
+
onCreateOption?: (value: string) => void
|
|
33
45
|
}
|
|
34
46
|
|
|
35
47
|
function Combobox({
|
|
@@ -41,13 +53,30 @@ function Combobox({
|
|
|
41
53
|
emptyText = "No results found.",
|
|
42
54
|
disabled = false,
|
|
43
55
|
className,
|
|
56
|
+
creatable = false,
|
|
57
|
+
onCreateOption,
|
|
44
58
|
}: ComboboxProps) {
|
|
45
59
|
const [open, setOpen] = React.useState(false)
|
|
60
|
+
const [inputValue, setInputValue] = React.useState("")
|
|
46
61
|
|
|
47
62
|
const selected = options.find((o) => o.value === value)
|
|
48
63
|
|
|
64
|
+
// Derived values for creatable — computed unconditionally but only used when
|
|
65
|
+
// creatable=true, so there is no cost to the non-creatable code path.
|
|
66
|
+
const trimmedInput = inputValue.trim()
|
|
67
|
+
const hasExactMatch =
|
|
68
|
+
trimmedInput.length > 0 &&
|
|
69
|
+
options.some((o) => o.label.toLowerCase() === trimmedInput.toLowerCase())
|
|
70
|
+
const showCreateItem = creatable && trimmedInput.length > 0 && !hasExactMatch
|
|
71
|
+
|
|
49
72
|
return (
|
|
50
|
-
<Popover
|
|
73
|
+
<Popover
|
|
74
|
+
open={open}
|
|
75
|
+
onOpenChange={(isOpen) => {
|
|
76
|
+
setOpen(isOpen)
|
|
77
|
+
if (!isOpen) setInputValue("")
|
|
78
|
+
}}
|
|
79
|
+
>
|
|
51
80
|
<PopoverTrigger asChild>
|
|
52
81
|
<Button
|
|
53
82
|
data-slot="combobox"
|
|
@@ -72,7 +101,12 @@ function Combobox({
|
|
|
72
101
|
</PopoverTrigger>
|
|
73
102
|
<PopoverContent className="w-[var(--radix-popover-trigger-width)] min-w-[200px] p-0">
|
|
74
103
|
<Command>
|
|
75
|
-
<CommandInput
|
|
104
|
+
<CommandInput
|
|
105
|
+
placeholder={searchPlaceholder}
|
|
106
|
+
{...(creatable
|
|
107
|
+
? { value: inputValue, onValueChange: setInputValue }
|
|
108
|
+
: {})}
|
|
109
|
+
/>
|
|
76
110
|
<CommandList>
|
|
77
111
|
<CommandEmpty>{emptyText}</CommandEmpty>
|
|
78
112
|
<CommandGroup>
|
|
@@ -97,6 +131,31 @@ function Combobox({
|
|
|
97
131
|
</CommandItem>
|
|
98
132
|
))}
|
|
99
133
|
</CommandGroup>
|
|
134
|
+
{showCreateItem && (
|
|
135
|
+
<>
|
|
136
|
+
<CommandSeparator />
|
|
137
|
+
<CommandGroup>
|
|
138
|
+
<CommandItem
|
|
139
|
+
// forceMount bypasses cmdk's text-match filter so the Create
|
|
140
|
+
// item is always visible while the user is typing a new value.
|
|
141
|
+
forceMount
|
|
142
|
+
value={`__create__${trimmedInput}`}
|
|
143
|
+
onSelect={() => {
|
|
144
|
+
onCreateOption?.(trimmedInput)
|
|
145
|
+
onValueChange?.(trimmedInput)
|
|
146
|
+
setInputValue("")
|
|
147
|
+
setOpen(false)
|
|
148
|
+
}}
|
|
149
|
+
>
|
|
150
|
+
<PlusIcon
|
|
151
|
+
strokeWidth={1.5}
|
|
152
|
+
className="mr-2 size-4 shrink-0 text-muted-foreground"
|
|
153
|
+
/>
|
|
154
|
+
Create “{trimmedInput}”
|
|
155
|
+
</CommandItem>
|
|
156
|
+
</CommandGroup>
|
|
157
|
+
</>
|
|
158
|
+
)}
|
|
100
159
|
</CommandList>
|
|
101
160
|
</Command>
|
|
102
161
|
</PopoverContent>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
5
|
+
import { cn } from "../../lib/utils";
|
|
6
|
+
|
|
7
|
+
// ─── Container ─────────────────────────────────────────────────────────────────
|
|
8
|
+
//
|
|
9
|
+
// Centered max-width content wrapper. Replaces the ad-hoc
|
|
10
|
+
// `<div className="mx-auto w-full max-w-6xl px-4">` boilerplate with a
|
|
11
|
+
// token-keyed size scale, so every screen picks its content width from the
|
|
12
|
+
// same five stops instead of guessing between max-w-5xl / 6xl / 7xl.
|
|
13
|
+
//
|
|
14
|
+
// Layout-only primitive (same class as Stack/Group): no ARIA, no interaction,
|
|
15
|
+
// no motion. Cross-system references: Mantine Container, MUI Container,
|
|
16
|
+
// Chakra Container.
|
|
17
|
+
|
|
18
|
+
const containerVariants = cva("mx-auto w-full", {
|
|
19
|
+
variants: {
|
|
20
|
+
/**
|
|
21
|
+
* Maximum content width. sm → 672px (reading column), md → 896px (forms,
|
|
22
|
+
* article + aside), lg → 1152px (standard app/marketing content, default),
|
|
23
|
+
* xl → 1280px (wide dashboards), full → no cap (edge-to-edge sections
|
|
24
|
+
* that still want the shared gutters).
|
|
25
|
+
*/
|
|
26
|
+
size: {
|
|
27
|
+
sm: "max-w-2xl",
|
|
28
|
+
md: "max-w-4xl",
|
|
29
|
+
lg: "max-w-6xl",
|
|
30
|
+
xl: "max-w-7xl",
|
|
31
|
+
full: "max-w-full",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
defaultVariants: {
|
|
35
|
+
size: "lg",
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export interface ContainerProps
|
|
40
|
+
extends React.HTMLAttributes<HTMLDivElement>,
|
|
41
|
+
VariantProps<typeof containerVariants> {
|
|
42
|
+
/**
|
|
43
|
+
* Horizontal padding (px-4, sm:px-6) so content never touches the viewport
|
|
44
|
+
* edge on small screens. Default: true. Set false when a parent already
|
|
45
|
+
* provides page gutters (avoid double gutters from nested Containers —
|
|
46
|
+
* prefer not nesting at all).
|
|
47
|
+
*/
|
|
48
|
+
gutters?: boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const Container = React.forwardRef<HTMLDivElement, ContainerProps>(
|
|
52
|
+
({ className, size, gutters = true, ...props }, ref) => (
|
|
53
|
+
<div
|
|
54
|
+
ref={ref}
|
|
55
|
+
data-slot="container"
|
|
56
|
+
className={cn(
|
|
57
|
+
containerVariants({ size }),
|
|
58
|
+
gutters && "px-4 sm:px-6",
|
|
59
|
+
className
|
|
60
|
+
)}
|
|
61
|
+
{...props}
|
|
62
|
+
/>
|
|
63
|
+
)
|
|
64
|
+
);
|
|
65
|
+
Container.displayName = "Container";
|