@behavioral-agentic-design-system/core 0.40.0 → 0.42.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/README.md +2 -0
- package/package.json +19 -3
- package/scripts/a11y-lint.cjs +41 -2
- package/scripts/health-report.mjs +16 -2
- package/scripts/lint-slop.mjs +25 -1
- package/scripts/wcag-audit.cjs +72 -5
- package/src/app/opengraph-image.tsx +5 -0
- package/src/app/preview/components/page.tsx +1269 -2
- package/src/app/shell.tsx +8 -5
- package/src/components/Foundations/Motion.stories.tsx +1 -0
- package/src/components/customize/design-controls.tsx +16 -1
- package/src/components/studio/studio.tsx +153 -0
- package/src/components/ui/anchor.tsx +37 -3
- package/src/components/ui/attachment.tsx +211 -0
- package/src/components/ui/chart.tsx +3 -0
- package/src/components/ui/code.tsx +1 -1
- package/src/components/ui/color-picker.tsx +1 -1
- package/src/components/ui/gauge-chart.tsx +238 -0
- package/src/components/ui/heatmap.tsx +256 -0
- package/src/components/ui/index.ts +9 -0
- package/src/components/ui/infinite-scroll.tsx +103 -0
- package/src/components/ui/json-input.tsx +351 -0
- package/src/components/ui/navigation-progress.tsx +281 -0
- package/src/components/ui/number-input.tsx +1 -4
- package/src/components/ui/password-input.tsx +2 -1
- package/src/components/ui/password-strength-input.tsx +288 -0
- package/src/components/ui/pill.tsx +140 -0
- package/src/components/ui/popover.tsx +27 -4
- package/src/components/ui/scroll-progress.tsx +100 -0
- package/src/components/ui/snackbar.tsx +393 -0
- package/src/components/ui/sortable-list.tsx +342 -0
- package/src/components/ui/squircle.tsx +1 -1
- package/src/components/ui/table.tsx +1 -1
- package/src/components/ui/tour.tsx +1 -3
- package/src/data/docs-index.ts +24 -0
- package/src/lib/clamp.ts +2 -0
- package/src/stories/Anchor.stories.tsx +54 -0
- package/src/stories/Attachment.stories.tsx +189 -0
- package/src/stories/Chart.stories.tsx +4 -0
- package/src/stories/Code.stories.tsx +1 -0
- package/src/stories/ColorPicker.stories.tsx +1 -0
- package/src/stories/GaugeChart.stories.tsx +163 -0
- package/src/stories/Heatmap.stories.tsx +172 -0
- package/src/stories/InfiniteScroll.stories.tsx +225 -0
- package/src/stories/JsonInput.stories.tsx +212 -0
- package/src/stories/NavigationProgress.stories.tsx +159 -0
- package/src/stories/NumberInput.stories.tsx +1 -0
- package/src/stories/PasswordInput.stories.tsx +4 -0
- package/src/stories/PasswordStrengthInput.stories.tsx +211 -0
- package/src/stories/Pill.stories.tsx +201 -0
- package/src/stories/Popover.stories.tsx +29 -1
- package/src/stories/Portal.stories.tsx +3 -1
- package/src/stories/ScrollProgress.stories.tsx +117 -0
- package/src/stories/Snackbar.stories.tsx +315 -0
- package/src/stories/SortableList.stories.tsx +263 -0
- package/src/stories/Squircle.stories.tsx +1 -0
- package/src/stories/Table.stories.tsx +1 -0
- package/src/stories/Tour.stories.tsx +1 -0
- package/src/stories/story-groups.json +17 -6
- package/LICENSE +0 -21
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
2
|
+
import * as React from "react"
|
|
3
|
+
import { InfiniteScroll } from "@behavioral-agentic-design-system/core/components/ui/infinite-scroll"
|
|
4
|
+
import { Card, CardContent } from "@behavioral-agentic-design-system/core/components/ui/card"
|
|
5
|
+
import { Avatar, AvatarFallback } from "@behavioral-agentic-design-system/core/components/ui/avatar"
|
|
6
|
+
import { Badge } from "@behavioral-agentic-design-system/core/components/ui/badge"
|
|
7
|
+
import { Separator } from "@behavioral-agentic-design-system/core/components/ui/separator"
|
|
8
|
+
|
|
9
|
+
const meta: Meta<typeof InfiniteScroll> = {
|
|
10
|
+
title: "Components/Layout/InfiniteScroll",
|
|
11
|
+
component: InfiniteScroll,
|
|
12
|
+
parameters: { layout: "padded" },
|
|
13
|
+
tags: ["autodocs"],
|
|
14
|
+
}
|
|
15
|
+
export default meta
|
|
16
|
+
type Story = StoryObj<typeof InfiniteScroll>
|
|
17
|
+
|
|
18
|
+
type Item = { id: number; name: string; role: string; initials: string }
|
|
19
|
+
|
|
20
|
+
function makeItems(start: number, count: number): Item[] {
|
|
21
|
+
const names = [
|
|
22
|
+
{ name: "Priya Chandrasekaran", role: "Product designer", initials: "PC" },
|
|
23
|
+
{ name: "Marcus Oliveira", role: "Frontend engineer", initials: "MO" },
|
|
24
|
+
{ name: "Aisha Tanaka", role: "Engineering manager", initials: "AT" },
|
|
25
|
+
{ name: "Samuel Adeyemi", role: "Backend engineer", initials: "SA" },
|
|
26
|
+
{ name: "Lena Bergmann", role: "UX researcher", initials: "LB" },
|
|
27
|
+
]
|
|
28
|
+
return Array.from({ length: count }, (_, i) => ({
|
|
29
|
+
id: start + i,
|
|
30
|
+
...names[(start + i) % names.length],
|
|
31
|
+
}))
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const Default: Story = {
|
|
35
|
+
parameters: {
|
|
36
|
+
controls: { disable: true },
|
|
37
|
+
docs: {
|
|
38
|
+
description: {
|
|
39
|
+
story:
|
|
40
|
+
"Scroll to the bottom repeatedly: every time the sentinel re-enters the viewport another page loads (8 → 16 → 24 → 32), then the end message renders. `onLoadMore` fires once per sentinel entry, not once per `hasMore` change.",
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
render: () => {
|
|
45
|
+
const PAGE = 8
|
|
46
|
+
const MAX = 32
|
|
47
|
+
const [items, setItems] = React.useState<Item[]>(() => makeItems(0, PAGE))
|
|
48
|
+
const [loading, setLoading] = React.useState(false)
|
|
49
|
+
|
|
50
|
+
function loadMore() {
|
|
51
|
+
if (loading) return
|
|
52
|
+
setLoading(true)
|
|
53
|
+
setTimeout(() => {
|
|
54
|
+
setItems((prev) => [...prev, ...makeItems(prev.length, PAGE)])
|
|
55
|
+
setLoading(false)
|
|
56
|
+
}, 800)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<div className="max-h-[480px] overflow-y-auto rounded-lg border bg-card">
|
|
61
|
+
<InfiniteScroll
|
|
62
|
+
onLoadMore={loadMore}
|
|
63
|
+
hasMore={items.length < MAX}
|
|
64
|
+
endMessage={
|
|
65
|
+
<p className="py-6 text-center text-sm text-muted-foreground">
|
|
66
|
+
All {MAX} team members loaded
|
|
67
|
+
</p>
|
|
68
|
+
}
|
|
69
|
+
>
|
|
70
|
+
<ul>
|
|
71
|
+
{items.map((item, i) => (
|
|
72
|
+
<li key={item.id}>
|
|
73
|
+
{i > 0 && <Separator />}
|
|
74
|
+
<div className="flex items-center gap-3 px-4 py-3">
|
|
75
|
+
<Avatar size="sm">
|
|
76
|
+
<AvatarFallback>{item.initials}</AvatarFallback>
|
|
77
|
+
</Avatar>
|
|
78
|
+
<div className="min-w-0 flex-1">
|
|
79
|
+
<p className="truncate text-sm font-medium">{item.name}</p>
|
|
80
|
+
<p className="truncate text-xs text-muted-foreground">{item.role}</p>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
</li>
|
|
84
|
+
))}
|
|
85
|
+
</ul>
|
|
86
|
+
</InfiniteScroll>
|
|
87
|
+
</div>
|
|
88
|
+
)
|
|
89
|
+
},
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export const CardGrid: Story = {
|
|
93
|
+
parameters: { controls: { disable: true } },
|
|
94
|
+
render: () => {
|
|
95
|
+
const PAGE = 6
|
|
96
|
+
const MAX = 24
|
|
97
|
+
const [items, setItems] = React.useState<Item[]>(() => makeItems(0, PAGE))
|
|
98
|
+
|
|
99
|
+
function loadMore() {
|
|
100
|
+
setTimeout(() => {
|
|
101
|
+
setItems((prev) => [...prev, ...makeItems(prev.length, PAGE)])
|
|
102
|
+
}, 600)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<div className="max-h-[500px] overflow-y-auto">
|
|
107
|
+
<InfiniteScroll
|
|
108
|
+
onLoadMore={loadMore}
|
|
109
|
+
hasMore={items.length < MAX}
|
|
110
|
+
endMessage={
|
|
111
|
+
<p className="py-4 text-center text-sm text-muted-foreground">
|
|
112
|
+
No more results
|
|
113
|
+
</p>
|
|
114
|
+
}
|
|
115
|
+
>
|
|
116
|
+
<div className="grid grid-cols-2 gap-3 p-1 sm:grid-cols-3">
|
|
117
|
+
{items.map((item) => (
|
|
118
|
+
<Card key={item.id} className="shadow-none">
|
|
119
|
+
<CardContent className="flex flex-col items-center gap-2 p-4 text-center">
|
|
120
|
+
<Avatar size="lg">
|
|
121
|
+
<AvatarFallback>{item.initials}</AvatarFallback>
|
|
122
|
+
</Avatar>
|
|
123
|
+
<div className="min-w-0">
|
|
124
|
+
<p className="truncate text-sm font-medium">{item.name}</p>
|
|
125
|
+
<Badge variant="secondary" className="mt-1 text-xs">
|
|
126
|
+
{item.role}
|
|
127
|
+
</Badge>
|
|
128
|
+
</div>
|
|
129
|
+
</CardContent>
|
|
130
|
+
</Card>
|
|
131
|
+
))}
|
|
132
|
+
</div>
|
|
133
|
+
</InfiniteScroll>
|
|
134
|
+
</div>
|
|
135
|
+
)
|
|
136
|
+
},
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export const CustomLoader: Story = {
|
|
140
|
+
parameters: { controls: { disable: true } },
|
|
141
|
+
render: () => {
|
|
142
|
+
const PAGE = 5
|
|
143
|
+
const MAX = 15
|
|
144
|
+
const [items, setItems] = React.useState<Item[]>(() => makeItems(0, PAGE))
|
|
145
|
+
const [loading, setLoading] = React.useState(false)
|
|
146
|
+
|
|
147
|
+
function loadMore() {
|
|
148
|
+
setLoading(true)
|
|
149
|
+
setTimeout(() => {
|
|
150
|
+
setItems((prev) => [...prev, ...makeItems(prev.length, PAGE)])
|
|
151
|
+
setLoading(false)
|
|
152
|
+
}, 1000)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return (
|
|
156
|
+
<div className="max-h-[400px] overflow-y-auto rounded-lg border">
|
|
157
|
+
<InfiniteScroll
|
|
158
|
+
onLoadMore={loadMore}
|
|
159
|
+
hasMore={items.length < MAX}
|
|
160
|
+
loader={
|
|
161
|
+
loading ? (
|
|
162
|
+
<p className="py-4 text-center text-sm text-muted-foreground animate-pulse">
|
|
163
|
+
Loading more…
|
|
164
|
+
</p>
|
|
165
|
+
) : null
|
|
166
|
+
}
|
|
167
|
+
>
|
|
168
|
+
<ul className="divide-y">
|
|
169
|
+
{items.map((item) => (
|
|
170
|
+
<li key={item.id} className="px-4 py-3 text-sm">
|
|
171
|
+
<span className="font-medium">{item.name}</span>{" "}
|
|
172
|
+
<span className="text-muted-foreground">— {item.role}</span>
|
|
173
|
+
</li>
|
|
174
|
+
))}
|
|
175
|
+
</ul>
|
|
176
|
+
</InfiniteScroll>
|
|
177
|
+
</div>
|
|
178
|
+
)
|
|
179
|
+
},
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export const RealisticUse: Story = {
|
|
183
|
+
parameters: { controls: { disable: true } },
|
|
184
|
+
render: () => {
|
|
185
|
+
const [items, setItems] = React.useState<Item[]>(() => makeItems(0, 10))
|
|
186
|
+
|
|
187
|
+
return (
|
|
188
|
+
<div className="space-y-2">
|
|
189
|
+
<p className="text-sm text-muted-foreground">
|
|
190
|
+
Scroll the list to load more. Total cap: 40 items.
|
|
191
|
+
</p>
|
|
192
|
+
<div className="max-h-[360px] overflow-y-auto rounded-lg border bg-background">
|
|
193
|
+
<InfiniteScroll
|
|
194
|
+
onLoadMore={() =>
|
|
195
|
+
setTimeout(
|
|
196
|
+
() => setItems((p) => [...p, ...makeItems(p.length, 10)]),
|
|
197
|
+
700
|
|
198
|
+
)
|
|
199
|
+
}
|
|
200
|
+
hasMore={items.length < 40}
|
|
201
|
+
endMessage={
|
|
202
|
+
<div className="py-6 text-center text-sm text-muted-foreground">
|
|
203
|
+
You've seen everything
|
|
204
|
+
</div>
|
|
205
|
+
}
|
|
206
|
+
>
|
|
207
|
+
<ul className="divide-y">
|
|
208
|
+
{items.map((item) => (
|
|
209
|
+
<li key={item.id} className="flex items-center gap-3 px-4 py-3">
|
|
210
|
+
<Avatar size="sm">
|
|
211
|
+
<AvatarFallback>{item.initials}</AvatarFallback>
|
|
212
|
+
</Avatar>
|
|
213
|
+
<div className="min-w-0">
|
|
214
|
+
<p className="truncate text-sm font-medium">{item.name}</p>
|
|
215
|
+
<p className="truncate text-xs text-muted-foreground">{item.role}</p>
|
|
216
|
+
</div>
|
|
217
|
+
</li>
|
|
218
|
+
))}
|
|
219
|
+
</ul>
|
|
220
|
+
</InfiniteScroll>
|
|
221
|
+
</div>
|
|
222
|
+
</div>
|
|
223
|
+
)
|
|
224
|
+
},
|
|
225
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
3
|
+
import { JsonInput } from "@behavioral-agentic-design-system/core/components/ui/json-input"
|
|
4
|
+
import {
|
|
5
|
+
Field,
|
|
6
|
+
FieldLabel,
|
|
7
|
+
FieldHelper,
|
|
8
|
+
} from "@behavioral-agentic-design-system/core/components/ui/field"
|
|
9
|
+
|
|
10
|
+
// Real content from content/personas/bads.json — names/orgs, never Lorem/Acme.
|
|
11
|
+
// Storybook 8 + autodocs.
|
|
12
|
+
|
|
13
|
+
const meta: Meta<typeof JsonInput> = {
|
|
14
|
+
title: "Components/Forms/JsonInput",
|
|
15
|
+
component: JsonInput,
|
|
16
|
+
parameters: {
|
|
17
|
+
layout: "centered",
|
|
18
|
+
docs: {
|
|
19
|
+
description: {
|
|
20
|
+
component:
|
|
21
|
+
"A <Textarea> specialized for JSON text entry. Validates on every keystroke (or on blur) and shows an inline error when the text is not valid JSON. Fires onValidChange(parsed) whenever valid JSON is present. An optional \"Format\" button auto-indents the content. Peer parity: Mantine JsonInput, config-panel patterns in Ant Design and shadcn. Zero new dependencies — uses native JSON.parse.",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
tags: ["autodocs"],
|
|
26
|
+
argTypes: {
|
|
27
|
+
validateOn: { control: "select", options: ["change", "blur"] },
|
|
28
|
+
size: { control: "select", options: ["sm", "default", "lg", "xl"] },
|
|
29
|
+
showFormatButton: { control: "boolean" },
|
|
30
|
+
formatIndent: { control: { type: "number", min: 0, max: 8 } },
|
|
31
|
+
disabled: { control: "boolean" },
|
|
32
|
+
externalError: { control: "text" },
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default meta
|
|
37
|
+
type Story = StoryObj<typeof meta>
|
|
38
|
+
|
|
39
|
+
// ─── Default ───────────────────────────────────────────────────────────────────
|
|
40
|
+
|
|
41
|
+
export const Default: Story = {
|
|
42
|
+
args: {
|
|
43
|
+
placeholder: '{"key": "value"}',
|
|
44
|
+
className: "w-80",
|
|
45
|
+
},
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// ─── With valid JSON pre-filled ────────────────────────────────────────────────
|
|
49
|
+
|
|
50
|
+
const meridianConfig = JSON.stringify(
|
|
51
|
+
{
|
|
52
|
+
brand: "Meridian Payments",
|
|
53
|
+
primaryColor: "#1a56db",
|
|
54
|
+
radius: "md",
|
|
55
|
+
density: "comfortable",
|
|
56
|
+
},
|
|
57
|
+
null,
|
|
58
|
+
2
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
export const WithValidJson: Story = {
|
|
62
|
+
args: {
|
|
63
|
+
defaultValue: meridianConfig,
|
|
64
|
+
className: "w-96",
|
|
65
|
+
},
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// ─── With invalid JSON pre-filled ──────────────────────────────────────────────
|
|
69
|
+
|
|
70
|
+
export const WithInvalidJson: Story = {
|
|
71
|
+
args: {
|
|
72
|
+
defaultValue: '{"brand": "Fieldnote Labs", missing_quote: true}',
|
|
73
|
+
className: "w-96",
|
|
74
|
+
},
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// ─── Validate on blur ──────────────────────────────────────────────────────────
|
|
78
|
+
|
|
79
|
+
export const ValidateOnBlur: Story = {
|
|
80
|
+
args: {
|
|
81
|
+
validateOn: "blur",
|
|
82
|
+
placeholder: '{"brand": "Lumen Analytics"}',
|
|
83
|
+
className: "w-80",
|
|
84
|
+
},
|
|
85
|
+
parameters: {
|
|
86
|
+
docs: {
|
|
87
|
+
description: {
|
|
88
|
+
story:
|
|
89
|
+
"Set `validateOn=\"blur\"` to defer validation until the user leaves the field — preferred for forms where live inline errors would feel intrusive.",
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// ─── Without Format button ─────────────────────────────────────────────────────
|
|
96
|
+
|
|
97
|
+
export const NoFormatButton: Story = {
|
|
98
|
+
args: {
|
|
99
|
+
showFormatButton: false,
|
|
100
|
+
defaultValue: '{"org":"Cedar & Pine Studio","theme":"light","compact":false}',
|
|
101
|
+
className: "w-80",
|
|
102
|
+
},
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// ─── Size_Sm ───────────────────────────────────────────────────────────────────
|
|
106
|
+
|
|
107
|
+
export const Size_Sm: Story = {
|
|
108
|
+
args: {
|
|
109
|
+
size: "sm",
|
|
110
|
+
placeholder: '{"key": "value"}',
|
|
111
|
+
className: "w-72",
|
|
112
|
+
},
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// ─── Size_Default ─────────────────────────────────────────────────────────────
|
|
116
|
+
|
|
117
|
+
export const Size_Default: Story = {
|
|
118
|
+
args: {
|
|
119
|
+
size: "default",
|
|
120
|
+
placeholder: '{"key": "value"}',
|
|
121
|
+
className: "w-80",
|
|
122
|
+
},
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// ─── Size_Lg ──────────────────────────────────────────────────────────────────
|
|
126
|
+
|
|
127
|
+
export const Size_Lg: Story = {
|
|
128
|
+
args: {
|
|
129
|
+
size: "lg",
|
|
130
|
+
placeholder: '{"key": "value"}',
|
|
131
|
+
className: "w-96",
|
|
132
|
+
},
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// ─── Disabled ─────────────────────────────────────────────────────────────────
|
|
136
|
+
|
|
137
|
+
export const Disabled: Story = {
|
|
138
|
+
args: {
|
|
139
|
+
disabled: true,
|
|
140
|
+
defaultValue: JSON.stringify({ org: "Northwind Health", locale: "en-US" }, null, 2),
|
|
141
|
+
className: "w-80",
|
|
142
|
+
},
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// ─── External error (server validation) ───────────────────────────────────────
|
|
146
|
+
|
|
147
|
+
export const ExternalError: Story = {
|
|
148
|
+
args: {
|
|
149
|
+
defaultValue: '{"plan":"enterprise","seats":25}',
|
|
150
|
+
externalError: "\"seats\" must be 50 or greater on the enterprise plan",
|
|
151
|
+
className: "w-96",
|
|
152
|
+
},
|
|
153
|
+
parameters: {
|
|
154
|
+
docs: {
|
|
155
|
+
description: {
|
|
156
|
+
story:
|
|
157
|
+
"Pass `externalError` to surface a server-side validation message even when the JSON itself parses correctly. Set `externalError={null}` to clear it.",
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// ─── Realistic use — inside a Field ───────────────────────────────────────────
|
|
164
|
+
|
|
165
|
+
function RealisticUseDemo() {
|
|
166
|
+
const [value, setValue] = React.useState<string>("")
|
|
167
|
+
const [parsed, setParsed] = React.useState<unknown>(null)
|
|
168
|
+
const [error, setError] = React.useState<string | null>(null)
|
|
169
|
+
|
|
170
|
+
return (
|
|
171
|
+
<div className="w-96 space-y-4">
|
|
172
|
+
<Field name="json-webhook">
|
|
173
|
+
<FieldLabel>Webhook filter rules</FieldLabel>
|
|
174
|
+
<FieldHelper>Enter a JSON object that defines which events trigger this webhook.</FieldHelper>
|
|
175
|
+
<JsonInput
|
|
176
|
+
id="json-webhook"
|
|
177
|
+
value={value}
|
|
178
|
+
onChange={(e) => setValue(e.target.value)}
|
|
179
|
+
onValidChange={setParsed}
|
|
180
|
+
onError={setError}
|
|
181
|
+
placeholder='{"events": ["user.created"], "org": "Harborline Logistics"}'
|
|
182
|
+
className="w-full"
|
|
183
|
+
/>
|
|
184
|
+
</Field>
|
|
185
|
+
|
|
186
|
+
{parsed !== null && (
|
|
187
|
+
<div className="rounded-md border border-border bg-muted p-3 text-xs text-muted-foreground">
|
|
188
|
+
<p className="mb-1 font-medium text-foreground">Parsed result:</p>
|
|
189
|
+
<pre className="font-mono text-xs whitespace-pre-wrap break-all">
|
|
190
|
+
{JSON.stringify(parsed, null, 2)}
|
|
191
|
+
</pre>
|
|
192
|
+
</div>
|
|
193
|
+
)}
|
|
194
|
+
{error && (
|
|
195
|
+
<p className="text-xs text-muted-foreground">Validation state: invalid</p>
|
|
196
|
+
)}
|
|
197
|
+
</div>
|
|
198
|
+
)
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export const RealisticUse: Story = {
|
|
202
|
+
render: () => <RealisticUseDemo />,
|
|
203
|
+
parameters: {
|
|
204
|
+
controls: { disable: true },
|
|
205
|
+
docs: {
|
|
206
|
+
description: {
|
|
207
|
+
story:
|
|
208
|
+
"Used inside a `Field` wrapper with `label`, `description`, controlled state, and `onValidChange` to capture the parsed result for downstream use — e.g. a webhook configuration panel at Harborline Logistics.",
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import {
|
|
4
|
+
NavigationProgress,
|
|
5
|
+
useNavigationProgress,
|
|
6
|
+
} from "@behavioral-agentic-design-system/core/components/ui/navigation-progress";
|
|
7
|
+
import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";
|
|
8
|
+
import {
|
|
9
|
+
Card,
|
|
10
|
+
CardContent,
|
|
11
|
+
CardDescription,
|
|
12
|
+
CardHeader,
|
|
13
|
+
CardTitle,
|
|
14
|
+
} from "@behavioral-agentic-design-system/core/components/ui/card";
|
|
15
|
+
|
|
16
|
+
// Content from content/personas/bads.json → primary (Jordan Reeves, Fieldnote
|
|
17
|
+
// Labs). The bar is fixed to the top edge of the story canvas; the controls
|
|
18
|
+
// below drive the module store.
|
|
19
|
+
|
|
20
|
+
const meta: Meta<typeof NavigationProgress> = {
|
|
21
|
+
title: "Components/Feedback/NavigationProgress",
|
|
22
|
+
component: NavigationProgress,
|
|
23
|
+
parameters: { layout: "fullscreen" },
|
|
24
|
+
tags: ["autodocs"],
|
|
25
|
+
argTypes: {
|
|
26
|
+
size: { control: "select", options: ["sm", "md", "lg"] },
|
|
27
|
+
color: { control: "text" },
|
|
28
|
+
initialProgress: { control: { type: "number", min: 0, max: 100 } },
|
|
29
|
+
stepInterval: { control: { type: "number", min: 50, step: 50 } },
|
|
30
|
+
label: { control: "text" },
|
|
31
|
+
},
|
|
32
|
+
args: {
|
|
33
|
+
size: "md",
|
|
34
|
+
initialProgress: 8,
|
|
35
|
+
stepInterval: 500,
|
|
36
|
+
label: "Page loading",
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default meta;
|
|
41
|
+
type Story = StoryObj<typeof meta>;
|
|
42
|
+
|
|
43
|
+
// The bar + a control strip. Every button is a flow-changing CTA → min-h-11.
|
|
44
|
+
function Demo(args: Story["args"]) {
|
|
45
|
+
const { progress, active, start, set, increment, stop, complete, reset } =
|
|
46
|
+
useNavigationProgress();
|
|
47
|
+
return (
|
|
48
|
+
<div className="min-h-[220px] p-6">
|
|
49
|
+
<NavigationProgress {...args} />
|
|
50
|
+
<p className="mb-4 text-sm text-muted-foreground">
|
|
51
|
+
{active ? `Loading — ${Math.round(progress)}%` : "Idle — the bar is hidden"}
|
|
52
|
+
</p>
|
|
53
|
+
<div className="flex flex-wrap gap-2">
|
|
54
|
+
<Button size="xl" onClick={() => start()}>Start</Button>
|
|
55
|
+
<Button size="xl" variant="outline" onClick={() => set(60)}>Set 60%</Button>
|
|
56
|
+
<Button size="xl" variant="outline" onClick={() => increment(10)}>+10</Button>
|
|
57
|
+
<Button size="xl" variant="outline" onClick={() => stop()}>Stop</Button>
|
|
58
|
+
<Button size="xl" variant="secondary" onClick={() => complete()}>Complete</Button>
|
|
59
|
+
<Button size="xl" variant="ghost" onClick={() => reset()}>Reset</Button>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export const Default: Story = {
|
|
66
|
+
render: (args) => <Demo {...args} />,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const Size_SM: Story = {
|
|
70
|
+
args: { size: "sm" },
|
|
71
|
+
render: (args) => <Demo {...args} />,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const Size_MD: Story = {
|
|
75
|
+
args: { size: "md" },
|
|
76
|
+
render: (args) => <Demo {...args} />,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const Size_LG: Story = {
|
|
80
|
+
args: { size: "lg" },
|
|
81
|
+
render: (args) => <Demo {...args} />,
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// Any CSS color. Monochrome here — a fork whose primary is near-black on a
|
|
85
|
+
// dark shell may want the bar to read as foreground instead.
|
|
86
|
+
export const Color: Story = {
|
|
87
|
+
args: { color: "var(--foreground)", size: "lg" },
|
|
88
|
+
render: (args) => <Demo {...args} />,
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// Simulated route change: "Open Billing" starts the bar, the new screen lands
|
|
92
|
+
// 1.6 s later and completes it. This is the shape a Next.js route hook or a
|
|
93
|
+
// fetch wrapper produces — start() on navigation, complete() on data.
|
|
94
|
+
function RouteChangeDemo() {
|
|
95
|
+
const { start, complete, active } = useNavigationProgress();
|
|
96
|
+
const [screen, setScreen] = React.useState<"workspace" | "billing">("workspace");
|
|
97
|
+
const timer = React.useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
98
|
+
|
|
99
|
+
React.useEffect(() => () => {
|
|
100
|
+
if (timer.current) clearTimeout(timer.current);
|
|
101
|
+
}, []);
|
|
102
|
+
|
|
103
|
+
function navigate(to: "workspace" | "billing") {
|
|
104
|
+
if (timer.current) clearTimeout(timer.current);
|
|
105
|
+
start();
|
|
106
|
+
timer.current = setTimeout(() => {
|
|
107
|
+
setScreen(to);
|
|
108
|
+
complete();
|
|
109
|
+
}, 1600);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<div className="min-h-[320px] p-6">
|
|
114
|
+
<NavigationProgress />
|
|
115
|
+
<nav aria-label="Workspace" className="mb-6 flex gap-2">
|
|
116
|
+
<Button
|
|
117
|
+
size="xl"
|
|
118
|
+
variant={screen === "workspace" ? "secondary" : "ghost"}
|
|
119
|
+
aria-current={screen === "workspace" ? "page" : undefined}
|
|
120
|
+
onClick={() => navigate("workspace")}
|
|
121
|
+
disabled={active}
|
|
122
|
+
>
|
|
123
|
+
Workspace
|
|
124
|
+
</Button>
|
|
125
|
+
<Button
|
|
126
|
+
size="xl"
|
|
127
|
+
variant={screen === "billing" ? "secondary" : "ghost"}
|
|
128
|
+
aria-current={screen === "billing" ? "page" : undefined}
|
|
129
|
+
onClick={() => navigate("billing")}
|
|
130
|
+
disabled={active}
|
|
131
|
+
>
|
|
132
|
+
Billing
|
|
133
|
+
</Button>
|
|
134
|
+
</nav>
|
|
135
|
+
<Card className="max-w-md" aria-busy={active || undefined}>
|
|
136
|
+
<CardHeader>
|
|
137
|
+
<CardTitle className="text-base">
|
|
138
|
+
{screen === "workspace" ? "Fieldnote Labs workspace" : "Billing"}
|
|
139
|
+
</CardTitle>
|
|
140
|
+
<CardDescription>
|
|
141
|
+
{screen === "workspace"
|
|
142
|
+
? "36 components · 8 members · updated 2026-05-26 by Jordan Reeves"
|
|
143
|
+
: "Team plan · next invoice 2026-11-01 · billing contact jordan@reeves.design"}
|
|
144
|
+
</CardDescription>
|
|
145
|
+
</CardHeader>
|
|
146
|
+
<CardContent className="text-sm text-muted-foreground">
|
|
147
|
+
{active
|
|
148
|
+
? "Loading the next screen — the bar at the top edge is the only indicator; nothing in the page blocks."
|
|
149
|
+
: "Switch tabs to watch the bar start, trickle, and complete when the screen lands."}
|
|
150
|
+
</CardContent>
|
|
151
|
+
</Card>
|
|
152
|
+
</div>
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export const RealisticUse: Story = {
|
|
157
|
+
parameters: { controls: { disable: true } },
|
|
158
|
+
render: () => <RouteChangeDemo />,
|
|
159
|
+
};
|
|
@@ -12,6 +12,10 @@ const meta: Meta<typeof PasswordInput> = {
|
|
|
12
12
|
export default meta;
|
|
13
13
|
type Story = StoryObj<typeof PasswordInput>;
|
|
14
14
|
|
|
15
|
+
// Tab to the show/hide toggle button and confirm it paints the standard
|
|
16
|
+
// focus-visible ring (ring-ring/50) rather than falling back to the UA
|
|
17
|
+
// default outline — see corrections.md and ledgers/ux-tests.jsonl
|
|
18
|
+
// (PasswordInput, 2026-07-14, resolved 2026-10-05).
|
|
15
19
|
export const Default: Story = {};
|
|
16
20
|
|
|
17
21
|
export const Size_Sm: Story = {
|