@behavioral-agentic-design-system/core 0.27.0 → 0.28.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 +4 -4
- package/src/app/preview/components/page.tsx +771 -24
- package/src/app/shell.tsx +17 -0
- package/src/components/ui/ai-badge.tsx +74 -0
- package/src/components/ui/chat-bubble.tsx +298 -0
- package/src/components/ui/clipboard.tsx +291 -0
- package/src/components/ui/copy-button.tsx +5 -1
- package/src/components/ui/data-table.tsx +388 -0
- package/src/components/ui/focus-trap.tsx +184 -0
- package/src/components/ui/index.ts +7 -0
- package/src/components/ui/mark.tsx +69 -0
- package/src/components/ui/rolling-number.tsx +200 -0
- package/src/components/ui/typing-indicator.tsx +2 -2
- package/src/components/ui/word-rotate.tsx +6 -1
- package/src/stories/AiBadge.stories.tsx +67 -0
- package/src/stories/ChatBubble.stories.tsx +222 -0
- package/src/stories/Clipboard.stories.tsx +136 -0
- package/src/stories/CopyButton.stories.tsx +2 -0
- package/src/stories/DataTable.stories.tsx +271 -0
- package/src/stories/FocusTrap.stories.tsx +218 -0
- package/src/stories/Mark.stories.tsx +84 -0
- package/src/stories/RollingNumber.stories.tsx +226 -0
- package/src/stories/TypingIndicator.stories.tsx +1 -0
- package/src/stories/WordRotate.stories.tsx +1 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { cn } from "../../lib/utils"
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* RollingNumber — animated digit counter that scrolls each digit independently
|
|
8
|
+
* (odometer / slot-machine style) when the value prop changes.
|
|
9
|
+
*
|
|
10
|
+
* Distinct from:
|
|
11
|
+
* - `FormatNumber` — static formatted display, no animation
|
|
12
|
+
* - `Stat` / `StatCard` — layout containers that hold a number; static
|
|
13
|
+
* - `Timer` — ticks on a live interval toward a deadline
|
|
14
|
+
*
|
|
15
|
+
* Use for dashboards, pricing counters, and KPI tiles where the value update
|
|
16
|
+
* itself is meaningful (revenue milestones, live seat counts, real-time stats).
|
|
17
|
+
* Don't use for values that change faster than ~1s — the animation will look
|
|
18
|
+
* like a blur rather than a meaningful transition.
|
|
19
|
+
*
|
|
20
|
+
* Motion: pattern (c) — inline style with var(--duration-base) + var(--ease-spring).
|
|
21
|
+
* Contained within each digit column; no layout shift. Base layer's
|
|
22
|
+
* prefers-reduced-motion rule silences the transition automatically.
|
|
23
|
+
*
|
|
24
|
+
* Accessibility: digits are aria-hidden; the containing span carries
|
|
25
|
+
* aria-label with the formatted value so screen readers announce the final
|
|
26
|
+
* number. aria-live="polite" is the default — value changes are typically
|
|
27
|
+
* meaningful events (a KPI crossed a milestone). Override with
|
|
28
|
+
* aria-live="off" for high-frequency updates.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
// --- types ---
|
|
32
|
+
|
|
33
|
+
export interface RollingNumberProps
|
|
34
|
+
extends Omit<React.ComponentProps<"span">, "children"> {
|
|
35
|
+
/** The numeric value to display. Digit columns animate when this changes. */
|
|
36
|
+
value: number
|
|
37
|
+
/** Fixed decimal places to show. When absent, uses the value's natural precision. */
|
|
38
|
+
decimalScale?: number
|
|
39
|
+
/**
|
|
40
|
+
* Force decimalScale digits even for whole numbers (e.g. 42 → "42.00").
|
|
41
|
+
* Requires `decimalScale`. Default false.
|
|
42
|
+
*/
|
|
43
|
+
fixedDecimalScale?: boolean
|
|
44
|
+
/**
|
|
45
|
+
* Thousands separator character (e.g. "," → "1,234,567").
|
|
46
|
+
* Default "" (no separator).
|
|
47
|
+
*/
|
|
48
|
+
thousandSeparator?: string
|
|
49
|
+
/** Static prefix rendered before the number (e.g. "$"). Not animated. */
|
|
50
|
+
prefix?: string
|
|
51
|
+
/** Static suffix rendered after the number (e.g. "%", "k"). Not animated. */
|
|
52
|
+
suffix?: string
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// --- helpers ---
|
|
56
|
+
|
|
57
|
+
type Part = { type: "digit"; value: number } | { type: "static"; char: string }
|
|
58
|
+
|
|
59
|
+
function toParts(
|
|
60
|
+
value: number,
|
|
61
|
+
thousandSeparator: string,
|
|
62
|
+
decimalScale: number | undefined,
|
|
63
|
+
fixedDecimalScale: boolean
|
|
64
|
+
): Part[] {
|
|
65
|
+
let str: string
|
|
66
|
+
if (decimalScale !== undefined) {
|
|
67
|
+
const naturalPlaces = value.toString().split(".")[1]?.length ?? 0
|
|
68
|
+
const places = fixedDecimalScale
|
|
69
|
+
? decimalScale
|
|
70
|
+
: Math.min(decimalScale, naturalPlaces)
|
|
71
|
+
str = value.toFixed(places)
|
|
72
|
+
} else {
|
|
73
|
+
str = String(value)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const [intRaw, decRaw] = str.split(".")
|
|
77
|
+
const intFormatted = thousandSeparator
|
|
78
|
+
? intRaw.replace(/\B(?=(\d{3})+(?!\d))/g, thousandSeparator)
|
|
79
|
+
: intRaw
|
|
80
|
+
const full = intFormatted + (decRaw !== undefined ? "." + decRaw : "")
|
|
81
|
+
|
|
82
|
+
return [...full].map((ch) =>
|
|
83
|
+
ch >= "0" && ch <= "9"
|
|
84
|
+
? { type: "digit" as const, value: Number(ch) }
|
|
85
|
+
: { type: "static" as const, char: ch }
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function formatLabel(
|
|
90
|
+
value: number,
|
|
91
|
+
prefix: string | undefined,
|
|
92
|
+
suffix: string | undefined,
|
|
93
|
+
decimalScale: number | undefined,
|
|
94
|
+
fixedDecimalScale: boolean
|
|
95
|
+
): string {
|
|
96
|
+
let str: string
|
|
97
|
+
if (decimalScale !== undefined) {
|
|
98
|
+
const naturalPlaces = value.toString().split(".")[1]?.length ?? 0
|
|
99
|
+
const places = fixedDecimalScale
|
|
100
|
+
? decimalScale
|
|
101
|
+
: Math.min(decimalScale, naturalPlaces)
|
|
102
|
+
str = value.toFixed(places)
|
|
103
|
+
} else {
|
|
104
|
+
str = String(value)
|
|
105
|
+
}
|
|
106
|
+
return (prefix ?? "") + str + (suffix ?? "")
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// --- digit column ---
|
|
110
|
+
|
|
111
|
+
function DigitColumn({ digit }: { digit: number }) {
|
|
112
|
+
return (
|
|
113
|
+
<span
|
|
114
|
+
aria-hidden="true"
|
|
115
|
+
data-slot="rolling-number-digit"
|
|
116
|
+
className="relative inline-block overflow-hidden"
|
|
117
|
+
style={{ height: "1em", lineHeight: "1em" }}
|
|
118
|
+
>
|
|
119
|
+
{/* The inner column is 10em tall (one em per digit 0-9).
|
|
120
|
+
translateY shifts it to reveal the correct digit through the 1em window.
|
|
121
|
+
-digit * 10% of 10em = -digit * 1em — one digit height per step. */}
|
|
122
|
+
<span
|
|
123
|
+
className="flex flex-col"
|
|
124
|
+
style={{
|
|
125
|
+
transform: `translateY(${-digit * 10}%)`,
|
|
126
|
+
transitionProperty: "transform",
|
|
127
|
+
transitionDuration: "var(--duration-base)",
|
|
128
|
+
transitionTimingFunction: "var(--ease-spring)",
|
|
129
|
+
}}
|
|
130
|
+
>
|
|
131
|
+
{[0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map((d) => (
|
|
132
|
+
<span
|
|
133
|
+
key={d}
|
|
134
|
+
style={{
|
|
135
|
+
height: "1em",
|
|
136
|
+
display: "flex",
|
|
137
|
+
alignItems: "center",
|
|
138
|
+
justifyContent: "center",
|
|
139
|
+
}}
|
|
140
|
+
>
|
|
141
|
+
{d}
|
|
142
|
+
</span>
|
|
143
|
+
))}
|
|
144
|
+
</span>
|
|
145
|
+
</span>
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// --- public component ---
|
|
150
|
+
|
|
151
|
+
export function RollingNumber({
|
|
152
|
+
value,
|
|
153
|
+
decimalScale,
|
|
154
|
+
fixedDecimalScale = false,
|
|
155
|
+
thousandSeparator = "",
|
|
156
|
+
prefix,
|
|
157
|
+
suffix,
|
|
158
|
+
className,
|
|
159
|
+
...props
|
|
160
|
+
}: RollingNumberProps) {
|
|
161
|
+
const parts = toParts(value, thousandSeparator, decimalScale, fixedDecimalScale)
|
|
162
|
+
const label = formatLabel(value, prefix, suffix, decimalScale, fixedDecimalScale)
|
|
163
|
+
|
|
164
|
+
return (
|
|
165
|
+
<span
|
|
166
|
+
data-slot="rolling-number"
|
|
167
|
+
aria-label={label}
|
|
168
|
+
aria-live="polite"
|
|
169
|
+
className={cn(
|
|
170
|
+
"inline-flex items-center tabular-nums",
|
|
171
|
+
className
|
|
172
|
+
)}
|
|
173
|
+
{...props}
|
|
174
|
+
>
|
|
175
|
+
{prefix && (
|
|
176
|
+
<span data-slot="rolling-number-prefix" aria-hidden="true">
|
|
177
|
+
{prefix}
|
|
178
|
+
</span>
|
|
179
|
+
)}
|
|
180
|
+
{parts.map((part, i) =>
|
|
181
|
+
part.type === "digit" ? (
|
|
182
|
+
<DigitColumn key={i} digit={part.value} />
|
|
183
|
+
) : (
|
|
184
|
+
<span
|
|
185
|
+
key={i}
|
|
186
|
+
data-slot="rolling-number-separator"
|
|
187
|
+
aria-hidden="true"
|
|
188
|
+
>
|
|
189
|
+
{part.char}
|
|
190
|
+
</span>
|
|
191
|
+
)
|
|
192
|
+
)}
|
|
193
|
+
{suffix && (
|
|
194
|
+
<span data-slot="rolling-number-suffix" aria-hidden="true">
|
|
195
|
+
{suffix}
|
|
196
|
+
</span>
|
|
197
|
+
)}
|
|
198
|
+
</span>
|
|
199
|
+
)
|
|
200
|
+
}
|
|
@@ -48,8 +48,8 @@ const GAP_SIZES: Record<NonNullable<TypingIndicatorProps["size"]>, string> = {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
const PADDING_SIZES: Record<NonNullable<TypingIndicatorProps["size"]>, string> = {
|
|
51
|
-
sm: "px-2 py-1",
|
|
52
|
-
default: "px-2.5 py-
|
|
51
|
+
sm: "px-2 py-1.5",
|
|
52
|
+
default: "px-2.5 py-2",
|
|
53
53
|
lg: "px-3 py-2",
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -58,7 +58,12 @@ function WordRotate({
|
|
|
58
58
|
data-slot="word-rotate"
|
|
59
59
|
aria-live="polite"
|
|
60
60
|
aria-atomic="true"
|
|
61
|
-
|
|
61
|
+
// inline-block + overflow-hidden would drop the box's baseline to its
|
|
62
|
+
// bottom edge (a CSS quirk), floating the rotating word ABOVE the
|
|
63
|
+
// surrounding text. Keep overflow visible and pin vertical-align to the
|
|
64
|
+
// text baseline so the word sits on the same line as its neighbours. The
|
|
65
|
+
// slide is a small translateY + fade, so the brief overflow is invisible.
|
|
66
|
+
className={cn("inline-block align-baseline", className)}
|
|
62
67
|
>
|
|
63
68
|
{/* Visual word — aria-hidden because sr-only below carries the live region */}
|
|
64
69
|
<span
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { AiBadge } from "@behavioral-agentic-design-system/core/components/ui/ai-badge";
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof AiBadge> = {
|
|
5
|
+
title: "Components/AiBadge",
|
|
6
|
+
component: AiBadge,
|
|
7
|
+
parameters: { layout: "centered" },
|
|
8
|
+
tags: ["autodocs"],
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof meta>;
|
|
13
|
+
|
|
14
|
+
export const Default: Story = {
|
|
15
|
+
render: () => (
|
|
16
|
+
<div className="flex items-center gap-2">
|
|
17
|
+
<AiBadge />
|
|
18
|
+
<AiBadge variant="solid" />
|
|
19
|
+
<AiBadge variant="outline" />
|
|
20
|
+
</div>
|
|
21
|
+
),
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const Variant_Subtle: Story = {
|
|
25
|
+
render: () => <AiBadge variant="subtle" />,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const Variant_Solid: Story = {
|
|
29
|
+
render: () => <AiBadge variant="solid" />,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const Variant_Outline: Story = {
|
|
33
|
+
render: () => <AiBadge variant="outline" />,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const Size_Sm: Story = {
|
|
37
|
+
render: () => <AiBadge size="sm" />,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const Size_Default: Story = {
|
|
41
|
+
render: () => <AiBadge size="default" />,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const NoIcon: Story = {
|
|
45
|
+
render: () => <AiBadge showIcon={false} />,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const CustomLabel: Story = {
|
|
49
|
+
render: () => <AiBadge>AI summary</AiBadge>,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const RealisticUse: Story = {
|
|
53
|
+
render: () => (
|
|
54
|
+
<div className="max-w-sm space-y-2 rounded-lg border border-border bg-card p-4">
|
|
55
|
+
<div className="flex items-center gap-2">
|
|
56
|
+
<span className="text-sm font-semibold text-foreground">
|
|
57
|
+
Weekly recap
|
|
58
|
+
</span>
|
|
59
|
+
<AiBadge size="sm" />
|
|
60
|
+
</div>
|
|
61
|
+
<p className="text-sm text-muted-foreground">
|
|
62
|
+
Deploys were up 18% this week, with the mail service accounting for most
|
|
63
|
+
of the increase. No incidents were reported.
|
|
64
|
+
</p>
|
|
65
|
+
</div>
|
|
66
|
+
),
|
|
67
|
+
};
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Reply, SmilePlus } from "lucide-react";
|
|
4
|
+
import {
|
|
5
|
+
ChatBubble,
|
|
6
|
+
ChatBubbleAction,
|
|
7
|
+
ChatBubbleActions,
|
|
8
|
+
ChatBubbleAvatar,
|
|
9
|
+
ChatBubbleMessage,
|
|
10
|
+
ChatBubbleReadReceipt,
|
|
11
|
+
ChatBubbleTimestamp,
|
|
12
|
+
} from "@behavioral-agentic-design-system/core/components/ui/chat-bubble";
|
|
13
|
+
|
|
14
|
+
const meta: Meta<typeof ChatBubble> = {
|
|
15
|
+
title: "Components/ChatBubble",
|
|
16
|
+
component: ChatBubble,
|
|
17
|
+
parameters: { layout: "padded" },
|
|
18
|
+
tags: ["autodocs"],
|
|
19
|
+
argTypes: {
|
|
20
|
+
position: { control: "radio", options: ["sent", "received"] },
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default meta;
|
|
25
|
+
type Story = StoryObj<typeof ChatBubble>;
|
|
26
|
+
|
|
27
|
+
// Real content from content/personas/bads.json — primary persona names
|
|
28
|
+
// (Jordan Reeves, Seo-yun Park) and design-system chatter built from the
|
|
29
|
+
// jargon / body_copy / notifications / urls pools. No placeholder content.
|
|
30
|
+
const THREAD = [
|
|
31
|
+
{
|
|
32
|
+
id: 1,
|
|
33
|
+
from: "Seo-yun Park",
|
|
34
|
+
initials: "SP",
|
|
35
|
+
position: "received" as const,
|
|
36
|
+
text: "Just pushed the tokens v2 proposal — can you look before standup? design.bads.com/share/tokens-v2-proposal",
|
|
37
|
+
time: "10:38 AM",
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: 2,
|
|
41
|
+
from: "Jordan Reeves",
|
|
42
|
+
initials: "JR",
|
|
43
|
+
position: "sent" as const,
|
|
44
|
+
text: "On it. Did the semantic layer change touch --muted-foreground?",
|
|
45
|
+
time: "10:40 AM",
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: 3,
|
|
49
|
+
from: "Seo-yun Park",
|
|
50
|
+
initials: "SP",
|
|
51
|
+
position: "received" as const,
|
|
52
|
+
text: "Yes — nudged it for the 7:1 floor. All 36 components still pass AAA contrast, wcag:audit is green.",
|
|
53
|
+
time: "10:41 AM",
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: 4,
|
|
57
|
+
from: "Jordan Reeves",
|
|
58
|
+
initials: "JR",
|
|
59
|
+
position: "sent" as const,
|
|
60
|
+
text: "Token changes saved. Running pnpm build:tokens now — both CSS files regenerate.",
|
|
61
|
+
time: "10:42 AM",
|
|
62
|
+
},
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
export const Default: Story = {
|
|
66
|
+
render: () => (
|
|
67
|
+
<div className="w-full max-w-md">
|
|
68
|
+
<ChatBubble position="received">
|
|
69
|
+
<ChatBubbleMessage>
|
|
70
|
+
Just pushed the tokens v2 proposal — can you look before standup?
|
|
71
|
+
</ChatBubbleMessage>
|
|
72
|
+
</ChatBubble>
|
|
73
|
+
</div>
|
|
74
|
+
),
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const Variant_Sent: Story = {
|
|
78
|
+
render: () => (
|
|
79
|
+
<div className="w-full max-w-md">
|
|
80
|
+
<ChatBubble position="sent">
|
|
81
|
+
<ChatBubbleMessage>
|
|
82
|
+
On it. Did the semantic layer change touch --muted-foreground?
|
|
83
|
+
</ChatBubbleMessage>
|
|
84
|
+
</ChatBubble>
|
|
85
|
+
</div>
|
|
86
|
+
),
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export const Variant_Received: Story = {
|
|
90
|
+
render: () => (
|
|
91
|
+
<div className="w-full max-w-md">
|
|
92
|
+
<ChatBubble position="received">
|
|
93
|
+
<ChatBubbleMessage variant="received">
|
|
94
|
+
Yes — nudged it for the 7:1 floor. All 36 components still pass AAA
|
|
95
|
+
contrast.
|
|
96
|
+
</ChatBubbleMessage>
|
|
97
|
+
</ChatBubble>
|
|
98
|
+
</div>
|
|
99
|
+
),
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export const Variant_Typing: Story = {
|
|
103
|
+
parameters: {
|
|
104
|
+
docs: {
|
|
105
|
+
description: {
|
|
106
|
+
story:
|
|
107
|
+
"Typing indicator — the bubble carries role=status + aria-live=polite + an accessible name (\"Typing…\") because it has no visible text. Only render it while a real participant is actually typing; a fake typing indicator is a dark pattern (see registry antiPatterns).",
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
render: () => (
|
|
112
|
+
<div className="w-full max-w-md">
|
|
113
|
+
<ChatBubble position="received">
|
|
114
|
+
<ChatBubbleAvatar fallback="SP" />
|
|
115
|
+
<ChatBubbleMessage variant="typing" />
|
|
116
|
+
</ChatBubble>
|
|
117
|
+
</div>
|
|
118
|
+
),
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export const WithAvatar: Story = {
|
|
122
|
+
render: () => (
|
|
123
|
+
<div className="w-full max-w-md">
|
|
124
|
+
<ChatBubble position="received">
|
|
125
|
+
<ChatBubbleAvatar fallback="SP" />
|
|
126
|
+
<ChatBubbleMessage>
|
|
127
|
+
Storybook coverage check passed — all components have matching
|
|
128
|
+
stories.
|
|
129
|
+
</ChatBubbleMessage>
|
|
130
|
+
</ChatBubble>
|
|
131
|
+
</div>
|
|
132
|
+
),
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export const WithReadReceipt: Story = {
|
|
136
|
+
render: () => (
|
|
137
|
+
<div className="w-full max-w-md space-y-3">
|
|
138
|
+
{(["sent", "delivered", "read"] as const).map((status) => (
|
|
139
|
+
<ChatBubble key={status} position="sent">
|
|
140
|
+
<div className="flex min-w-0 flex-col items-end gap-1">
|
|
141
|
+
<ChatBubbleMessage>
|
|
142
|
+
Token changes saved. Run pnpm build:tokens to regenerate CSS.
|
|
143
|
+
</ChatBubbleMessage>
|
|
144
|
+
<span className="flex items-center gap-1">
|
|
145
|
+
<ChatBubbleTimestamp timestamp="10:42 AM" />
|
|
146
|
+
<ChatBubbleReadReceipt status={status} />
|
|
147
|
+
</span>
|
|
148
|
+
</div>
|
|
149
|
+
</ChatBubble>
|
|
150
|
+
))}
|
|
151
|
+
</div>
|
|
152
|
+
),
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export const WithActions: Story = {
|
|
156
|
+
parameters: {
|
|
157
|
+
docs: {
|
|
158
|
+
description: {
|
|
159
|
+
story:
|
|
160
|
+
"Action row is hidden until the row is hovered — or until any action button receives keyboard focus (focus-within), so keyboard users are never locked out of a hover-only affordance. Each action is a 44×44 ghost Button with a required aria-label.",
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
render: () => (
|
|
165
|
+
<div className="w-full max-w-md">
|
|
166
|
+
<ChatBubble position="received">
|
|
167
|
+
<ChatBubbleAvatar fallback="SP" />
|
|
168
|
+
<ChatBubbleMessage>
|
|
169
|
+
The token pipeline paid for itself in a week. One tokens.json change,
|
|
170
|
+
both CSS files regenerate, every fork picks it up.
|
|
171
|
+
</ChatBubbleMessage>
|
|
172
|
+
<ChatBubbleActions>
|
|
173
|
+
<ChatBubbleAction
|
|
174
|
+
icon={<SmilePlus strokeWidth={1.5} className="size-5" />}
|
|
175
|
+
label="React to message"
|
|
176
|
+
/>
|
|
177
|
+
<ChatBubbleAction
|
|
178
|
+
icon={<Reply strokeWidth={1.5} className="size-5" />}
|
|
179
|
+
label="Reply to message"
|
|
180
|
+
/>
|
|
181
|
+
</ChatBubbleActions>
|
|
182
|
+
</ChatBubble>
|
|
183
|
+
</div>
|
|
184
|
+
),
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export const RealisticUse: Story = {
|
|
188
|
+
render: () => (
|
|
189
|
+
<div
|
|
190
|
+
role="log"
|
|
191
|
+
aria-label="Conversation with Seo-yun Park"
|
|
192
|
+
className="flex w-full max-w-md flex-col gap-3 overflow-y-auto rounded-lg border bg-background p-4"
|
|
193
|
+
>
|
|
194
|
+
{THREAD.map((msg) => (
|
|
195
|
+
<ChatBubble key={msg.id} position={msg.position}>
|
|
196
|
+
{msg.position === "received" ? (
|
|
197
|
+
<ChatBubbleAvatar fallback={msg.initials} />
|
|
198
|
+
) : null}
|
|
199
|
+
<div
|
|
200
|
+
className={
|
|
201
|
+
msg.position === "sent"
|
|
202
|
+
? "flex min-w-0 flex-col items-end gap-1"
|
|
203
|
+
: "flex min-w-0 flex-col items-start gap-1"
|
|
204
|
+
}
|
|
205
|
+
>
|
|
206
|
+
<ChatBubbleMessage>{msg.text}</ChatBubbleMessage>
|
|
207
|
+
<span className="flex items-center gap-1">
|
|
208
|
+
<ChatBubbleTimestamp timestamp={msg.time} />
|
|
209
|
+
{msg.position === "sent" ? (
|
|
210
|
+
<ChatBubbleReadReceipt status={msg.id === 4 ? "delivered" : "read"} />
|
|
211
|
+
) : null}
|
|
212
|
+
</span>
|
|
213
|
+
</div>
|
|
214
|
+
</ChatBubble>
|
|
215
|
+
))}
|
|
216
|
+
<ChatBubble position="received">
|
|
217
|
+
<ChatBubbleAvatar fallback="SP" />
|
|
218
|
+
<ChatBubbleMessage variant="typing" />
|
|
219
|
+
</ChatBubble>
|
|
220
|
+
</div>
|
|
221
|
+
),
|
|
222
|
+
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// Motion: input copied-tint + focus ring on transition-[color,box-shadow,border-color]
|
|
2
|
+
// with inline var(--duration-fast) + var(--ease-out); trigger swap is CopyButton's.
|
|
3
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
4
|
+
import * as React from "react"
|
|
5
|
+
import {
|
|
6
|
+
Clipboard,
|
|
7
|
+
ClipboardControl,
|
|
8
|
+
ClipboardInput,
|
|
9
|
+
ClipboardLabel,
|
|
10
|
+
ClipboardTrigger,
|
|
11
|
+
} from "@behavioral-agentic-design-system/core/components/ui/clipboard"
|
|
12
|
+
import {
|
|
13
|
+
Card,
|
|
14
|
+
CardContent,
|
|
15
|
+
CardDescription,
|
|
16
|
+
CardHeader,
|
|
17
|
+
CardTitle,
|
|
18
|
+
} from "@behavioral-agentic-design-system/core/components/ui/card"
|
|
19
|
+
|
|
20
|
+
const meta: Meta<typeof Clipboard> = {
|
|
21
|
+
title: "Components/Clipboard",
|
|
22
|
+
component: Clipboard,
|
|
23
|
+
parameters: {
|
|
24
|
+
layout: "centered",
|
|
25
|
+
docs: {
|
|
26
|
+
description: {
|
|
27
|
+
component:
|
|
28
|
+
"Compound clipboard widget: renders the copyable value inline as a read-only, select-on-focus input alongside a copy trigger. The trigger composes CopyButton (clipboard write, Copy→Check success animation, aria-live 'Copied to clipboard'). The input truncates long values (min-w-0 + truncate) and preserves the full string in title; its border tints to the ring token during the copied window. Label associates via htmlFor; without a ClipboardLabel the input falls back to aria-label='Copyable value'. Trigger defaults to size='xl' (44px CTA floor). Distinct from CopyButton, which copies without displaying the value.",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
export default meta
|
|
34
|
+
type Story = StoryObj<typeof Clipboard>
|
|
35
|
+
|
|
36
|
+
export const Default: Story = {
|
|
37
|
+
render: () => (
|
|
38
|
+
<div className="w-96">
|
|
39
|
+
<Clipboard value="pk_live_5K8mN2qR7tLwYjAb4cDeFgHi">
|
|
40
|
+
<ClipboardControl>
|
|
41
|
+
<ClipboardInput />
|
|
42
|
+
<ClipboardTrigger />
|
|
43
|
+
</ClipboardControl>
|
|
44
|
+
</Clipboard>
|
|
45
|
+
</div>
|
|
46
|
+
),
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const WithLabel: Story = {
|
|
50
|
+
render: () => (
|
|
51
|
+
<div className="w-96">
|
|
52
|
+
<Clipboard value="https://design.bads.com/share/tokens-v2-proposal">
|
|
53
|
+
<ClipboardLabel>Share link</ClipboardLabel>
|
|
54
|
+
<ClipboardControl>
|
|
55
|
+
<ClipboardInput />
|
|
56
|
+
<ClipboardTrigger>Copy link</ClipboardTrigger>
|
|
57
|
+
</ClipboardControl>
|
|
58
|
+
</Clipboard>
|
|
59
|
+
</div>
|
|
60
|
+
),
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const LongValue: Story = {
|
|
64
|
+
render: () => (
|
|
65
|
+
<div className="w-80">
|
|
66
|
+
<Clipboard value="https://design.bads.com/docs/getting-started?utm_source=onboarding&utm_campaign=client-fork-2026&session=jordan.reeves">
|
|
67
|
+
<ClipboardLabel>Onboarding link</ClipboardLabel>
|
|
68
|
+
<ClipboardControl>
|
|
69
|
+
<ClipboardInput />
|
|
70
|
+
<ClipboardTrigger />
|
|
71
|
+
</ClipboardControl>
|
|
72
|
+
</Clipboard>
|
|
73
|
+
</div>
|
|
74
|
+
),
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export const IconTrigger: Story = {
|
|
78
|
+
render: () => (
|
|
79
|
+
<div className="w-96">
|
|
80
|
+
<Clipboard value="npm install @behavioral-agentic-design-system/core">
|
|
81
|
+
<ClipboardLabel>Install command</ClipboardLabel>
|
|
82
|
+
<ClipboardControl>
|
|
83
|
+
<ClipboardInput />
|
|
84
|
+
<ClipboardTrigger size="icon-xl" aria-label="Copy install command" />
|
|
85
|
+
</ClipboardControl>
|
|
86
|
+
</Clipboard>
|
|
87
|
+
</div>
|
|
88
|
+
),
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export const Disabled: Story = {
|
|
92
|
+
render: () => (
|
|
93
|
+
<div className="w-96">
|
|
94
|
+
<Clipboard value="pk_live_5K8mN2qR7tLwYjAb4cDeFgHi" disabled>
|
|
95
|
+
<ClipboardLabel>API key</ClipboardLabel>
|
|
96
|
+
<ClipboardControl>
|
|
97
|
+
<ClipboardInput />
|
|
98
|
+
<ClipboardTrigger />
|
|
99
|
+
</ClipboardControl>
|
|
100
|
+
</Clipboard>
|
|
101
|
+
</div>
|
|
102
|
+
),
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export const RealisticUse: Story = {
|
|
106
|
+
render: () => {
|
|
107
|
+
const secretKey = "sk-proj-Xk9mNpQ2vR7tLwYjAb4cDeFgHiJkLmNo" // gitleaks:allow
|
|
108
|
+
return (
|
|
109
|
+
<Card className="w-[26rem]">
|
|
110
|
+
<CardHeader>
|
|
111
|
+
<CardTitle>API keys</CardTitle>
|
|
112
|
+
<CardDescription>
|
|
113
|
+
Authenticate requests from jordan@reeves.design's workspace. Keep
|
|
114
|
+
the secret key server-side.
|
|
115
|
+
</CardDescription>
|
|
116
|
+
</CardHeader>
|
|
117
|
+
<CardContent className="flex flex-col gap-6">
|
|
118
|
+
<Clipboard value="pk_live_5K8mN2qR7tLwYjAb4cDeFgHi">
|
|
119
|
+
<ClipboardLabel>Publishable key</ClipboardLabel>
|
|
120
|
+
<ClipboardControl>
|
|
121
|
+
<ClipboardInput />
|
|
122
|
+
<ClipboardTrigger />
|
|
123
|
+
</ClipboardControl>
|
|
124
|
+
</Clipboard>
|
|
125
|
+
<Clipboard value={secretKey}>
|
|
126
|
+
<ClipboardLabel>Secret key</ClipboardLabel>
|
|
127
|
+
<ClipboardControl>
|
|
128
|
+
<ClipboardInput />
|
|
129
|
+
<ClipboardTrigger />
|
|
130
|
+
</ClipboardControl>
|
|
131
|
+
</Clipboard>
|
|
132
|
+
</CardContent>
|
|
133
|
+
</Card>
|
|
134
|
+
)
|
|
135
|
+
},
|
|
136
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
// Motion: the copy↔copied swap narrowed transition-all → transition-[opacity,transform] (explicit-properties rule).
|
|
2
|
+
// Types: onCopy is (value: string) => void — the DOM ClipboardEventHandler is Omit-ed
|
|
3
|
+
// from the button props so the callback parameter is a clean string (2026-08-06).
|
|
2
4
|
import type { Meta, StoryObj } from "@storybook/react"
|
|
3
5
|
import * as React from "react"
|
|
4
6
|
import { CopyButton } from "@behavioral-agentic-design-system/core/components/ui/copy-button"
|