@behavioral-agentic-design-system/core 0.27.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 +5 -5
- 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 +5735 -2500
- 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 +91 -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/ai-badge.tsx +74 -0
- package/src/components/ui/alert.tsx +12 -0
- package/src/components/ui/badge.tsx +19 -0
- package/src/components/ui/chat-bubble.tsx +298 -0
- package/src/components/ui/chat-marker.tsx +120 -0
- package/src/components/ui/checkbox.tsx +9 -1
- package/src/components/ui/clipboard.tsx +291 -0
- 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/copy-button.tsx +5 -1
- package/src/components/ui/data-table.tsx +388 -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/focus-trap.tsx +184 -0
- package/src/components/ui/format-byte.tsx +113 -0
- package/src/components/ui/index.ts +28 -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/mark.tsx +69 -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 +201 -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/typing-indicator.tsx +2 -2
- package/src/components/ui/word-rotate.tsx +6 -1
- 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/AiBadge.stories.tsx +67 -0
- package/src/stories/Alert.stories.tsx +31 -1
- package/src/stories/Badge.stories.tsx +63 -6
- package/src/stories/ChatBubble.stories.tsx +222 -0
- package/src/stories/ChatMarker.stories.tsx +59 -0
- package/src/stories/Checkbox.stories.tsx +5 -0
- package/src/stories/Clipboard.stories.tsx +136 -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/CopyButton.stories.tsx +2 -0
- package/src/stories/DataTable.stories.tsx +271 -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/FocusTrap.stories.tsx +218 -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/Mark.stories.tsx +84 -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 +226 -0
- 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/TypingIndicator.stories.tsx +1 -0
- package/src/stories/WordRotate.stories.tsx +1 -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,298 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ChatBubble — styled message bubble for chat/messaging surfaces.
|
|
5
|
+
*
|
|
6
|
+
* Sources: Base UI / shadcn community chat message pattern (June 2026);
|
|
7
|
+
* 21st.dev community registry (multiple independent authors).
|
|
8
|
+
*
|
|
9
|
+
* Compound component: ChatBubble (row) + ChatBubbleAvatar + ChatBubbleMessage
|
|
10
|
+
* (sent / received / typing) + ChatBubbleTimestamp + ChatBubbleReadReceipt +
|
|
11
|
+
* ChatBubbleActions / ChatBubbleAction.
|
|
12
|
+
*
|
|
13
|
+
* Semantics split: each ChatBubble row is role="group"; the conversation
|
|
14
|
+
* CONTAINER is the consumer's responsibility (role="log", scrollable) — see
|
|
15
|
+
* the registry a11yContract. Message text is read naturally by screen
|
|
16
|
+
* readers (no per-message aria-label — that would double-announce every
|
|
17
|
+
* message); only the typing variant carries an accessible name because it
|
|
18
|
+
* has no visible text.
|
|
19
|
+
*
|
|
20
|
+
* Motion (spec §4):
|
|
21
|
+
* - entrance: tw-animate-css `animate-in fade-in-0 slide-in-from-{left,right}-2`
|
|
22
|
+
* (pattern a — same vocabulary as tooltip/menubar/dialog)
|
|
23
|
+
* - typing dots: `chat-typing-bounce` keyframe keyed off
|
|
24
|
+
* [data-slot="chat-bubble-typing"] in build-tokens.cjs (pattern b)
|
|
25
|
+
* - hover-action reveal: transition-opacity + inline var(--duration-fast) /
|
|
26
|
+
* var(--ease-out) (pattern c), with focus-within reveal for keyboard parity
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
import * as React from "react"
|
|
30
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
31
|
+
import { Check, CheckCheck } from "lucide-react"
|
|
32
|
+
|
|
33
|
+
import { cn } from "../../lib/utils"
|
|
34
|
+
import { Avatar, AvatarFallback, AvatarImage } from "./avatar"
|
|
35
|
+
import { Button } from "./button"
|
|
36
|
+
|
|
37
|
+
type ChatBubblePosition = "sent" | "received"
|
|
38
|
+
|
|
39
|
+
const ChatBubblePositionContext =
|
|
40
|
+
React.createContext<ChatBubblePosition>("received")
|
|
41
|
+
|
|
42
|
+
function ChatBubble({
|
|
43
|
+
position,
|
|
44
|
+
className,
|
|
45
|
+
children,
|
|
46
|
+
...props
|
|
47
|
+
}: React.ComponentProps<"div"> & {
|
|
48
|
+
/** Which side of the conversation this row aligns to. */
|
|
49
|
+
position: ChatBubblePosition
|
|
50
|
+
}) {
|
|
51
|
+
return (
|
|
52
|
+
<ChatBubblePositionContext.Provider value={position}>
|
|
53
|
+
<div
|
|
54
|
+
role="group"
|
|
55
|
+
data-slot="chat-bubble"
|
|
56
|
+
data-position={position}
|
|
57
|
+
className={cn(
|
|
58
|
+
"group/chat-bubble relative flex w-max max-w-[75%] items-end gap-2",
|
|
59
|
+
"animate-in fade-in-0",
|
|
60
|
+
position === "sent"
|
|
61
|
+
? "ml-auto flex-row-reverse slide-in-from-right-2"
|
|
62
|
+
: "mr-auto slide-in-from-left-2",
|
|
63
|
+
className
|
|
64
|
+
)}
|
|
65
|
+
{...props}
|
|
66
|
+
>
|
|
67
|
+
{children}
|
|
68
|
+
</div>
|
|
69
|
+
</ChatBubblePositionContext.Provider>
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function ChatBubbleAvatar({
|
|
74
|
+
src,
|
|
75
|
+
alt = "",
|
|
76
|
+
fallback,
|
|
77
|
+
className,
|
|
78
|
+
children,
|
|
79
|
+
...props
|
|
80
|
+
}: React.ComponentProps<typeof Avatar> & {
|
|
81
|
+
/** Image source for the sender's avatar. */
|
|
82
|
+
src?: string
|
|
83
|
+
/** Alt text for the avatar image. Empty (decorative) when the sender's name is visible next to the message. */
|
|
84
|
+
alt?: string
|
|
85
|
+
/** Fallback initials shown while the image loads or when no src is given. */
|
|
86
|
+
fallback?: React.ReactNode
|
|
87
|
+
}) {
|
|
88
|
+
return (
|
|
89
|
+
<Avatar
|
|
90
|
+
data-slot="chat-bubble-avatar"
|
|
91
|
+
className={cn("shrink-0 self-end", className)}
|
|
92
|
+
{...props}
|
|
93
|
+
>
|
|
94
|
+
{src ? <AvatarImage src={src} alt={alt} /> : null}
|
|
95
|
+
{fallback != null ? <AvatarFallback>{fallback}</AvatarFallback> : null}
|
|
96
|
+
{children}
|
|
97
|
+
</Avatar>
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const chatBubbleMessageVariants = cva(
|
|
102
|
+
// min-w-0 + break-words: long-label overflow contract — URLs, identifiers,
|
|
103
|
+
// and non-Latin strings wrap instead of bleeding past the bubble.
|
|
104
|
+
"min-w-0 break-words px-4 py-2.5 text-sm leading-relaxed",
|
|
105
|
+
{
|
|
106
|
+
variants: {
|
|
107
|
+
variant: {
|
|
108
|
+
sent: "rounded-tl-2xl rounded-tr-2xl rounded-bl-2xl rounded-br-sm bg-primary text-primary-foreground",
|
|
109
|
+
received:
|
|
110
|
+
"rounded-tl-2xl rounded-tr-2xl rounded-br-2xl rounded-bl-sm bg-muted text-foreground",
|
|
111
|
+
typing:
|
|
112
|
+
"rounded-tl-2xl rounded-tr-2xl rounded-br-2xl rounded-bl-sm bg-muted text-foreground",
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
defaultVariants: {
|
|
116
|
+
variant: "received",
|
|
117
|
+
},
|
|
118
|
+
}
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
function ChatBubbleMessage({
|
|
122
|
+
variant,
|
|
123
|
+
className,
|
|
124
|
+
children,
|
|
125
|
+
...props
|
|
126
|
+
}: React.ComponentProps<"div"> &
|
|
127
|
+
VariantProps<typeof chatBubbleMessageVariants>) {
|
|
128
|
+
const position = React.useContext(ChatBubblePositionContext)
|
|
129
|
+
// Variant defaults to the parent row's position so the common case is
|
|
130
|
+
// just <ChatBubbleMessage>text</ChatBubbleMessage>.
|
|
131
|
+
const resolved = variant ?? position
|
|
132
|
+
|
|
133
|
+
if (resolved === "typing") {
|
|
134
|
+
return (
|
|
135
|
+
<div
|
|
136
|
+
data-slot="chat-bubble-typing"
|
|
137
|
+
role="status"
|
|
138
|
+
aria-live="polite"
|
|
139
|
+
aria-label="Typing…"
|
|
140
|
+
className={cn(
|
|
141
|
+
chatBubbleMessageVariants({ variant: "typing" }),
|
|
142
|
+
"flex w-max items-center gap-1",
|
|
143
|
+
className
|
|
144
|
+
)}
|
|
145
|
+
{...props}
|
|
146
|
+
>
|
|
147
|
+
{/* Dots are decorative — the accessible name above carries the meaning.
|
|
148
|
+
Bounce keyframe (chat-typing-bounce) is applied from the design-
|
|
149
|
+
system CSS via the data-slot selectors; stagger is 0 / 150 / 300ms
|
|
150
|
+
driven by var(--duration-fast) steps. */}
|
|
151
|
+
<span
|
|
152
|
+
aria-hidden="true"
|
|
153
|
+
data-slot="chat-bubble-typing-dot"
|
|
154
|
+
className="size-1.5 rounded-full bg-muted-foreground"
|
|
155
|
+
/>
|
|
156
|
+
<span
|
|
157
|
+
aria-hidden="true"
|
|
158
|
+
data-slot="chat-bubble-typing-dot"
|
|
159
|
+
className="size-1.5 rounded-full bg-muted-foreground"
|
|
160
|
+
/>
|
|
161
|
+
<span
|
|
162
|
+
aria-hidden="true"
|
|
163
|
+
data-slot="chat-bubble-typing-dot"
|
|
164
|
+
className="size-1.5 rounded-full bg-muted-foreground"
|
|
165
|
+
/>
|
|
166
|
+
</div>
|
|
167
|
+
)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return (
|
|
171
|
+
<div
|
|
172
|
+
data-slot="chat-bubble-message"
|
|
173
|
+
className={cn(chatBubbleMessageVariants({ variant: resolved }), className)}
|
|
174
|
+
{...props}
|
|
175
|
+
>
|
|
176
|
+
{children}
|
|
177
|
+
</div>
|
|
178
|
+
)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function ChatBubbleTimestamp({
|
|
182
|
+
timestamp,
|
|
183
|
+
className,
|
|
184
|
+
...props
|
|
185
|
+
}: React.ComponentProps<"span"> & {
|
|
186
|
+
/** Pre-formatted display string ("10:42 AM"). Formatting is the consumer's job. */
|
|
187
|
+
timestamp: string
|
|
188
|
+
}) {
|
|
189
|
+
return (
|
|
190
|
+
<span
|
|
191
|
+
data-slot="chat-bubble-timestamp"
|
|
192
|
+
className={cn("text-xs text-muted-foreground select-none", className)}
|
|
193
|
+
{...props}
|
|
194
|
+
>
|
|
195
|
+
{timestamp}
|
|
196
|
+
</span>
|
|
197
|
+
)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const READ_RECEIPT_LABEL: Record<"sent" | "delivered" | "read", string> = {
|
|
201
|
+
sent: "Sent",
|
|
202
|
+
delivered: "Delivered",
|
|
203
|
+
read: "Read",
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function ChatBubbleReadReceipt({
|
|
207
|
+
status,
|
|
208
|
+
className,
|
|
209
|
+
...props
|
|
210
|
+
}: React.ComponentProps<"span"> & {
|
|
211
|
+
/** Delivery state: sent (single tick), delivered (double tick), read (double tick, primary). */
|
|
212
|
+
status: "sent" | "delivered" | "read"
|
|
213
|
+
}) {
|
|
214
|
+
const Icon = status === "sent" ? Check : CheckCheck
|
|
215
|
+
return (
|
|
216
|
+
<span
|
|
217
|
+
data-slot="chat-bubble-read-receipt"
|
|
218
|
+
data-status={status}
|
|
219
|
+
className={cn(
|
|
220
|
+
"inline-flex items-center",
|
|
221
|
+
// No --color-info utility is mapped in the theme; "read" uses the
|
|
222
|
+
// brand primary so state is still triple-encoded (icon shape + color
|
|
223
|
+
// + sr-only text), never color alone.
|
|
224
|
+
status === "read" ? "text-primary" : "text-muted-foreground",
|
|
225
|
+
className
|
|
226
|
+
)}
|
|
227
|
+
{...props}
|
|
228
|
+
>
|
|
229
|
+
<Icon strokeWidth={1.5} className="size-4" aria-hidden="true" />
|
|
230
|
+
<span className="sr-only">{READ_RECEIPT_LABEL[status]}</span>
|
|
231
|
+
</span>
|
|
232
|
+
)
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function ChatBubbleActions({
|
|
236
|
+
className,
|
|
237
|
+
style,
|
|
238
|
+
children,
|
|
239
|
+
...props
|
|
240
|
+
}: React.ComponentProps<"div">) {
|
|
241
|
+
return (
|
|
242
|
+
<div
|
|
243
|
+
data-slot="chat-bubble-actions"
|
|
244
|
+
className={cn(
|
|
245
|
+
// Hidden until the row is hovered OR any action has keyboard focus —
|
|
246
|
+
// focus-within keeps hover-revealed actions reachable without a mouse.
|
|
247
|
+
"flex items-center gap-1 self-center opacity-0 transition-opacity",
|
|
248
|
+
"group-hover/chat-bubble:opacity-100 focus-within:opacity-100",
|
|
249
|
+
className
|
|
250
|
+
)}
|
|
251
|
+
style={{
|
|
252
|
+
transitionDuration: "var(--duration-fast)",
|
|
253
|
+
transitionTimingFunction: "var(--ease-out)",
|
|
254
|
+
...style,
|
|
255
|
+
}}
|
|
256
|
+
{...props}
|
|
257
|
+
>
|
|
258
|
+
{children}
|
|
259
|
+
</div>
|
|
260
|
+
)
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function ChatBubbleAction({
|
|
264
|
+
icon,
|
|
265
|
+
label,
|
|
266
|
+
className,
|
|
267
|
+
...props
|
|
268
|
+
}: Omit<React.ComponentProps<typeof Button>, "children" | "aria-label"> & {
|
|
269
|
+
/** Icon node — pass lucide icons with strokeWidth={1.5}. */
|
|
270
|
+
icon: React.ReactNode
|
|
271
|
+
/** Accessible name for the icon-only button (required). */
|
|
272
|
+
label: string
|
|
273
|
+
}) {
|
|
274
|
+
return (
|
|
275
|
+
<Button
|
|
276
|
+
type="button"
|
|
277
|
+
variant="ghost"
|
|
278
|
+
size="icon-xl"
|
|
279
|
+
data-slot="chat-bubble-action"
|
|
280
|
+
aria-label={label}
|
|
281
|
+
className={className}
|
|
282
|
+
{...props}
|
|
283
|
+
>
|
|
284
|
+
{icon}
|
|
285
|
+
</Button>
|
|
286
|
+
)
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export {
|
|
290
|
+
ChatBubble,
|
|
291
|
+
ChatBubbleAvatar,
|
|
292
|
+
ChatBubbleMessage,
|
|
293
|
+
ChatBubbleTimestamp,
|
|
294
|
+
ChatBubbleReadReceipt,
|
|
295
|
+
ChatBubbleActions,
|
|
296
|
+
ChatBubbleAction,
|
|
297
|
+
chatBubbleMessageVariants,
|
|
298
|
+
}
|
|
@@ -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}
|