@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,315 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
3
|
+
import { userEvent, within, expect } from "storybook/test"
|
|
4
|
+
import { Archive, CircleCheck, Link2, Send } from "lucide-react"
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
SnackbarProvider,
|
|
8
|
+
useSnackbar,
|
|
9
|
+
SNACKBAR_ANCHORS,
|
|
10
|
+
type SnackbarOptions,
|
|
11
|
+
} from "@behavioral-agentic-design-system/core/components/ui/snackbar"
|
|
12
|
+
import { Button } from "@behavioral-agentic-design-system/core/components/ui/button"
|
|
13
|
+
|
|
14
|
+
const meta: Meta<typeof SnackbarProvider> = {
|
|
15
|
+
title: "Components/Feedback/Snackbar",
|
|
16
|
+
component: SnackbarProvider,
|
|
17
|
+
// The outlet is position: fixed at the bottom of the viewport, so the
|
|
18
|
+
// story needs the whole canvas, not a centered box.
|
|
19
|
+
parameters: {
|
|
20
|
+
layout: "fullscreen",
|
|
21
|
+
docs: {
|
|
22
|
+
description: {
|
|
23
|
+
component:
|
|
24
|
+
"One transient feedback message at a time, anchored to the bottom of the screen, that auto-dismisses. Imperative API: `const { show, dismiss } = useSnackbar()` inside a `<SnackbarProvider>`. The next message queues behind the current one — nothing stacks. Use Sonner for a stacked queue of async events; use Snackbar for lightweight confirmations of something the user just did (copied, saved, moved · Undo). The timer pauses on hover and focus-within; a sticky message (`duration: Infinity`) is always dismissible; the live region is mounted before the first message so screen readers announce it.",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
tags: ["autodocs"],
|
|
29
|
+
argTypes: {
|
|
30
|
+
anchor: { control: "select", options: [...SNACKBAR_ANCHORS] },
|
|
31
|
+
duration: { control: { type: "number", min: 500, step: 500 } },
|
|
32
|
+
container: { control: false },
|
|
33
|
+
children: { control: false },
|
|
34
|
+
className: { control: false },
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default meta
|
|
39
|
+
type Story = StoryObj<typeof meta>
|
|
40
|
+
|
|
41
|
+
// Content from content/personas/bads.json → primary.names / orgs.
|
|
42
|
+
const PERSON = "Seo-yun Park"
|
|
43
|
+
const ORG = "Harborline Logistics"
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Shared harness: a Button inside the provider that calls `show()` with the
|
|
47
|
+
* story's options. `play` clicks it so the snackbar is on screen when the
|
|
48
|
+
* story (and Chromatic) first looks at it.
|
|
49
|
+
*/
|
|
50
|
+
function Trigger({
|
|
51
|
+
label,
|
|
52
|
+
options,
|
|
53
|
+
}: {
|
|
54
|
+
label: string
|
|
55
|
+
options: SnackbarOptions | string
|
|
56
|
+
}) {
|
|
57
|
+
const { show } = useSnackbar()
|
|
58
|
+
return (
|
|
59
|
+
<Button variant="outline" size="xl" onClick={() => show(options)}>
|
|
60
|
+
{label}
|
|
61
|
+
</Button>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function Frame({ children }: { children: React.ReactNode }) {
|
|
66
|
+
return (
|
|
67
|
+
<div className="flex min-h-[360px] flex-wrap items-start gap-3 p-8">
|
|
68
|
+
{children}
|
|
69
|
+
</div>
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const clickThenExpect =
|
|
74
|
+
(buttonName: RegExp, text: string | RegExp) =>
|
|
75
|
+
async ({ canvasElement }: { canvasElement: HTMLElement }) => {
|
|
76
|
+
const canvas = within(canvasElement)
|
|
77
|
+
await userEvent.click(canvas.getByRole("button", { name: buttonName }))
|
|
78
|
+
// The snackbar portals to the story iframe's <body>, outside canvasElement.
|
|
79
|
+
const body = within(canvasElement.ownerDocument.body)
|
|
80
|
+
const status = await body.findByRole("status")
|
|
81
|
+
await expect(within(status).getByText(text)).toBeInTheDocument()
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export const Default: Story = {
|
|
85
|
+
args: { anchor: "bottom-center", duration: 4000 },
|
|
86
|
+
render: (args) => (
|
|
87
|
+
<SnackbarProvider {...args}>
|
|
88
|
+
<Frame>
|
|
89
|
+
<Trigger label="Save settings" options="Settings saved" />
|
|
90
|
+
</Frame>
|
|
91
|
+
</SnackbarProvider>
|
|
92
|
+
),
|
|
93
|
+
play: clickThenExpect(/save settings/i, "Settings saved"),
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export const WithAction: Story = {
|
|
97
|
+
parameters: { controls: { disable: true } },
|
|
98
|
+
render: () => (
|
|
99
|
+
<SnackbarProvider>
|
|
100
|
+
<Frame>
|
|
101
|
+
<Trigger
|
|
102
|
+
label="Archive component"
|
|
103
|
+
options={{
|
|
104
|
+
message: "Pill moved to Archive",
|
|
105
|
+
action: { label: "Undo", onClick: () => {} },
|
|
106
|
+
}}
|
|
107
|
+
/>
|
|
108
|
+
</Frame>
|
|
109
|
+
</SnackbarProvider>
|
|
110
|
+
),
|
|
111
|
+
play: clickThenExpect(/archive component/i, "Pill moved to Archive"),
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export const WithIcon: Story = {
|
|
115
|
+
parameters: { controls: { disable: true } },
|
|
116
|
+
render: () => (
|
|
117
|
+
<SnackbarProvider>
|
|
118
|
+
<Frame>
|
|
119
|
+
<Trigger
|
|
120
|
+
label="Copy token name"
|
|
121
|
+
options={{
|
|
122
|
+
message: "Copied --primary to clipboard",
|
|
123
|
+
icon: <CircleCheck strokeWidth={1.5} className="text-icon-success" />,
|
|
124
|
+
}}
|
|
125
|
+
/>
|
|
126
|
+
</Frame>
|
|
127
|
+
</SnackbarProvider>
|
|
128
|
+
),
|
|
129
|
+
play: clickThenExpect(/copy token name/i, "Copied --primary to clipboard"),
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** A long single-word identifier wraps with overflow-wrap:anywhere instead of pushing the controls out. */
|
|
133
|
+
export const LongMessage: Story = {
|
|
134
|
+
parameters: { controls: { disable: true } },
|
|
135
|
+
render: () => (
|
|
136
|
+
<SnackbarProvider>
|
|
137
|
+
<Frame>
|
|
138
|
+
<Trigger
|
|
139
|
+
label="Share link"
|
|
140
|
+
options={{
|
|
141
|
+
message:
|
|
142
|
+
"Share link copied: https://design.harborline-logistics.example/preview/components#snackbar-queue-and-pause-on-hover-behaviour",
|
|
143
|
+
icon: <Link2 strokeWidth={1.5} />,
|
|
144
|
+
action: { label: "Open", onClick: () => {} },
|
|
145
|
+
}}
|
|
146
|
+
/>
|
|
147
|
+
</Frame>
|
|
148
|
+
</SnackbarProvider>
|
|
149
|
+
),
|
|
150
|
+
play: clickThenExpect(/share link/i, /Share link copied/),
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** 1.5 s — a quick confirmation that gets out of the way. */
|
|
154
|
+
export const CustomDuration: Story = {
|
|
155
|
+
parameters: { controls: { disable: true } },
|
|
156
|
+
render: () => (
|
|
157
|
+
<SnackbarProvider>
|
|
158
|
+
<Frame>
|
|
159
|
+
<Trigger
|
|
160
|
+
label="Save draft"
|
|
161
|
+
options={{ message: "Draft saved", duration: 1500 }}
|
|
162
|
+
/>
|
|
163
|
+
</Frame>
|
|
164
|
+
</SnackbarProvider>
|
|
165
|
+
),
|
|
166
|
+
play: clickThenExpect(/save draft/i, "Draft saved"),
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export const Anchor_BottomLeft: Story = {
|
|
170
|
+
parameters: { controls: { disable: true } },
|
|
171
|
+
render: () => (
|
|
172
|
+
<SnackbarProvider anchor="bottom-left">
|
|
173
|
+
<Frame>
|
|
174
|
+
<Trigger label="Save settings" options="Settings saved" />
|
|
175
|
+
</Frame>
|
|
176
|
+
</SnackbarProvider>
|
|
177
|
+
),
|
|
178
|
+
play: clickThenExpect(/save settings/i, "Settings saved"),
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export const Anchor_BottomRight: Story = {
|
|
182
|
+
parameters: { controls: { disable: true } },
|
|
183
|
+
render: () => (
|
|
184
|
+
<SnackbarProvider anchor="bottom-right">
|
|
185
|
+
<Frame>
|
|
186
|
+
<Trigger label="Save settings" options="Settings saved" />
|
|
187
|
+
</Frame>
|
|
188
|
+
</SnackbarProvider>
|
|
189
|
+
),
|
|
190
|
+
play: clickThenExpect(/save settings/i, "Settings saved"),
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** `duration: Infinity` — stays until dismissed. The × shows by default so the message can never trap itself. */
|
|
194
|
+
export const Sticky: Story = {
|
|
195
|
+
parameters: { controls: { disable: true } },
|
|
196
|
+
render: () => (
|
|
197
|
+
<SnackbarProvider>
|
|
198
|
+
<Frame>
|
|
199
|
+
<Trigger
|
|
200
|
+
label="Go offline"
|
|
201
|
+
options={{
|
|
202
|
+
message: `You're offline. Changes to ${ORG} sync when you reconnect.`,
|
|
203
|
+
duration: Infinity,
|
|
204
|
+
}}
|
|
205
|
+
/>
|
|
206
|
+
</Frame>
|
|
207
|
+
</SnackbarProvider>
|
|
208
|
+
),
|
|
209
|
+
play: clickThenExpect(/go offline/i, /You're offline/),
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** Three `show()` calls in a row — one visible, two waiting. The next mounts only after the current one has fully exited. */
|
|
213
|
+
export const Queue: Story = {
|
|
214
|
+
parameters: { controls: { disable: true } },
|
|
215
|
+
render: function QueueStory() {
|
|
216
|
+
function QueueTrigger() {
|
|
217
|
+
const { show, dismiss } = useSnackbar()
|
|
218
|
+
return (
|
|
219
|
+
<>
|
|
220
|
+
<Button
|
|
221
|
+
variant="outline"
|
|
222
|
+
size="xl"
|
|
223
|
+
onClick={() => {
|
|
224
|
+
show({ message: `Invitation sent to ${PERSON}`, duration: 2000 })
|
|
225
|
+
show({ message: "Role updated to Editor", duration: 2000 })
|
|
226
|
+
show({ message: "Workspace settings saved", duration: 2000 })
|
|
227
|
+
}}
|
|
228
|
+
>
|
|
229
|
+
Queue three messages
|
|
230
|
+
</Button>
|
|
231
|
+
<Button variant="ghost" size="xl" onClick={() => dismiss("all")}>
|
|
232
|
+
Clear queue
|
|
233
|
+
</Button>
|
|
234
|
+
</>
|
|
235
|
+
)
|
|
236
|
+
}
|
|
237
|
+
return (
|
|
238
|
+
<SnackbarProvider>
|
|
239
|
+
<Frame>
|
|
240
|
+
<QueueTrigger />
|
|
241
|
+
</Frame>
|
|
242
|
+
</SnackbarProvider>
|
|
243
|
+
)
|
|
244
|
+
},
|
|
245
|
+
play: clickThenExpect(/queue three messages/i, `Invitation sent to ${PERSON}`),
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/** A team settings page: invite → confirmation with Undo, archive → confirmation with Undo. One snackbar, one message at a time. */
|
|
249
|
+
export const RealisticUse: Story = {
|
|
250
|
+
parameters: { controls: { disable: true } },
|
|
251
|
+
render: function RealisticUseStory() {
|
|
252
|
+
function TeamActions() {
|
|
253
|
+
const { show } = useSnackbar()
|
|
254
|
+
const [members, setMembers] = React.useState([PERSON, "Marcus Lindqvist", "Anika Patel"])
|
|
255
|
+
const [archived, setArchived] = React.useState<string[]>([])
|
|
256
|
+
return (
|
|
257
|
+
<div className="w-full max-w-md space-y-4">
|
|
258
|
+
<div>
|
|
259
|
+
<h3 className="text-lg font-semibold tracking-tight">{ORG} · Team</h3>
|
|
260
|
+
<p className="text-sm text-muted-foreground">
|
|
261
|
+
{members.length} members · {archived.length} archived
|
|
262
|
+
</p>
|
|
263
|
+
</div>
|
|
264
|
+
<ul className="divide-y rounded-lg border">
|
|
265
|
+
{members.map((name) => (
|
|
266
|
+
<li key={name} className="flex items-center justify-between gap-3 px-4 py-2">
|
|
267
|
+
<span className="min-w-0 truncate text-sm font-medium">{name}</span>
|
|
268
|
+
<Button
|
|
269
|
+
variant="ghost"
|
|
270
|
+
size="default"
|
|
271
|
+
className="min-h-11 shrink-0"
|
|
272
|
+
onClick={() => {
|
|
273
|
+
setMembers((m) => m.filter((n) => n !== name))
|
|
274
|
+
setArchived((a) => [...a, name])
|
|
275
|
+
show({
|
|
276
|
+
message: `${name} archived`,
|
|
277
|
+
icon: <Archive strokeWidth={1.5} />,
|
|
278
|
+
action: {
|
|
279
|
+
label: "Undo",
|
|
280
|
+
onClick: () => {
|
|
281
|
+
setArchived((a) => a.filter((n) => n !== name))
|
|
282
|
+
setMembers((m) => [...m, name])
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
})
|
|
286
|
+
}}
|
|
287
|
+
>
|
|
288
|
+
Archive
|
|
289
|
+
</Button>
|
|
290
|
+
</li>
|
|
291
|
+
))}
|
|
292
|
+
</ul>
|
|
293
|
+
<Button
|
|
294
|
+
size="xl"
|
|
295
|
+
onClick={() =>
|
|
296
|
+
show({
|
|
297
|
+
message: "Invitation sent to Tomás Herrera",
|
|
298
|
+
icon: <Send strokeWidth={1.5} />,
|
|
299
|
+
})
|
|
300
|
+
}
|
|
301
|
+
>
|
|
302
|
+
Invite Tomás Herrera
|
|
303
|
+
</Button>
|
|
304
|
+
</div>
|
|
305
|
+
)
|
|
306
|
+
}
|
|
307
|
+
return (
|
|
308
|
+
<SnackbarProvider>
|
|
309
|
+
<Frame>
|
|
310
|
+
<TeamActions />
|
|
311
|
+
</Frame>
|
|
312
|
+
</SnackbarProvider>
|
|
313
|
+
)
|
|
314
|
+
},
|
|
315
|
+
}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
3
|
+
import { SortableList } from "@behavioral-agentic-design-system/core/components/ui/sortable-list"
|
|
4
|
+
import {
|
|
5
|
+
Field,
|
|
6
|
+
FieldLabel,
|
|
7
|
+
FieldHelper,
|
|
8
|
+
} from "@behavioral-agentic-design-system/core/components/ui/field"
|
|
9
|
+
import { Badge } from "@behavioral-agentic-design-system/core/components/ui/badge"
|
|
10
|
+
|
|
11
|
+
// ─── Meta ─────────────────────────────────────────────────────────────────────
|
|
12
|
+
|
|
13
|
+
const meta = {
|
|
14
|
+
title: "Components/Layout/SortableList",
|
|
15
|
+
component: SortableList,
|
|
16
|
+
parameters: {
|
|
17
|
+
layout: "padded",
|
|
18
|
+
docs: {
|
|
19
|
+
description: {
|
|
20
|
+
component:
|
|
21
|
+
"Drag-and-drop reorderable list using @dnd-kit. Keyboard accessible — Space/Enter to lift, arrow keys to move, Space/Enter/Escape to drop/cancel. Items require a stable `id`.",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
} satisfies Meta<typeof SortableList>
|
|
26
|
+
|
|
27
|
+
export default meta
|
|
28
|
+
|
|
29
|
+
// ─── Fixtures ─────────────────────────────────────────────────────────────────
|
|
30
|
+
|
|
31
|
+
const PRIORITIES = [
|
|
32
|
+
{ id: "p1", label: "Northwind Health integration", priority: "high" },
|
|
33
|
+
{ id: "p2", label: "Token refresh for Cedar & Pine Studio", priority: "medium" },
|
|
34
|
+
{ id: "p3", label: "Harborline Logistics onboarding flow", priority: "medium" },
|
|
35
|
+
{ id: "p4", label: "WCAG AAA audit — Meridian Payments", priority: "low" },
|
|
36
|
+
{ id: "p5", label: "Lumen Analytics dashboard components", priority: "low" },
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
const PIPELINE_STAGES = [
|
|
40
|
+
{ id: "s1", label: "Qualification" },
|
|
41
|
+
{ id: "s2", label: "Discovery" },
|
|
42
|
+
{ id: "s3", label: "Proposal" },
|
|
43
|
+
{ id: "s4", label: "Negotiation" },
|
|
44
|
+
{ id: "s5", label: "Closed" },
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
const TEAM_MEMBERS = [
|
|
48
|
+
{ id: "u1", name: "Jordan Reeves", role: "Design Lead" },
|
|
49
|
+
{ id: "u2", name: "Seo-yun Park", role: "Senior Engineer" },
|
|
50
|
+
{ id: "u3", name: "Marcus Lindqvist", role: "Product Manager" },
|
|
51
|
+
{ id: "u4", name: "Anika Patel", role: "QA Engineer" },
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
// ─── Story helpers ────────────────────────────────────────────────────────────
|
|
55
|
+
|
|
56
|
+
function useItems<T>(initial: T[]) {
|
|
57
|
+
const [items, setItems] = React.useState(initial)
|
|
58
|
+
return { items, setItems }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// ─── Stories ──────────────────────────────────────────────────────────────────
|
|
62
|
+
|
|
63
|
+
type Story = StoryObj<typeof meta>
|
|
64
|
+
|
|
65
|
+
export const Default: Story = {
|
|
66
|
+
parameters: { controls: { disable: true } },
|
|
67
|
+
render: () => {
|
|
68
|
+
const { items, setItems } = useItems(PIPELINE_STAGES)
|
|
69
|
+
return (
|
|
70
|
+
<div className="w-80">
|
|
71
|
+
<SortableList
|
|
72
|
+
items={items}
|
|
73
|
+
onReorder={setItems}
|
|
74
|
+
aria-label="Pipeline stages"
|
|
75
|
+
renderItem={(item) => (
|
|
76
|
+
<span className="text-sm text-foreground">{item.label}</span>
|
|
77
|
+
)}
|
|
78
|
+
/>
|
|
79
|
+
</div>
|
|
80
|
+
)
|
|
81
|
+
},
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export const WithBadges: Story = {
|
|
85
|
+
parameters: { controls: { disable: true } },
|
|
86
|
+
render: () => {
|
|
87
|
+
const { items, setItems } = useItems(PRIORITIES)
|
|
88
|
+
return (
|
|
89
|
+
<div className="w-96">
|
|
90
|
+
<SortableList
|
|
91
|
+
items={items}
|
|
92
|
+
onReorder={setItems}
|
|
93
|
+
aria-label="Project priorities"
|
|
94
|
+
renderItem={(item) => (
|
|
95
|
+
<div className="flex min-w-0 items-center gap-2">
|
|
96
|
+
<span className="min-w-0 flex-1 truncate text-sm text-foreground">
|
|
97
|
+
{item.label}
|
|
98
|
+
</span>
|
|
99
|
+
<Badge
|
|
100
|
+
variant={
|
|
101
|
+
item.priority === "high"
|
|
102
|
+
? "destructive"
|
|
103
|
+
: item.priority === "medium"
|
|
104
|
+
? "secondary"
|
|
105
|
+
: "outline"
|
|
106
|
+
}
|
|
107
|
+
className="shrink-0 text-xs"
|
|
108
|
+
>
|
|
109
|
+
{item.priority}
|
|
110
|
+
</Badge>
|
|
111
|
+
</div>
|
|
112
|
+
)}
|
|
113
|
+
/>
|
|
114
|
+
</div>
|
|
115
|
+
)
|
|
116
|
+
},
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export const NoHandle: Story = {
|
|
120
|
+
parameters: { controls: { disable: true } },
|
|
121
|
+
render: () => {
|
|
122
|
+
const { items, setItems } = useItems(PIPELINE_STAGES)
|
|
123
|
+
return (
|
|
124
|
+
<div className="w-80">
|
|
125
|
+
<SortableList
|
|
126
|
+
items={items}
|
|
127
|
+
onReorder={setItems}
|
|
128
|
+
handle={false}
|
|
129
|
+
aria-label="Pipeline stages — full row draggable"
|
|
130
|
+
renderItem={(item) => (
|
|
131
|
+
<span className="cursor-grab text-sm text-foreground active:cursor-grabbing">
|
|
132
|
+
{item.label}
|
|
133
|
+
</span>
|
|
134
|
+
)}
|
|
135
|
+
/>
|
|
136
|
+
</div>
|
|
137
|
+
)
|
|
138
|
+
},
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export const Size_Sm: Story = {
|
|
142
|
+
parameters: { controls: { disable: true } },
|
|
143
|
+
render: () => {
|
|
144
|
+
const { items, setItems } = useItems(PIPELINE_STAGES)
|
|
145
|
+
return (
|
|
146
|
+
<div className="w-72">
|
|
147
|
+
<SortableList
|
|
148
|
+
items={items}
|
|
149
|
+
onReorder={setItems}
|
|
150
|
+
size="sm"
|
|
151
|
+
aria-label="Pipeline stages (small)"
|
|
152
|
+
renderItem={(item) => (
|
|
153
|
+
<span className="text-xs text-foreground">{item.label}</span>
|
|
154
|
+
)}
|
|
155
|
+
/>
|
|
156
|
+
</div>
|
|
157
|
+
)
|
|
158
|
+
},
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export const Size_Default: Story = {
|
|
162
|
+
parameters: { controls: { disable: true } },
|
|
163
|
+
render: () => {
|
|
164
|
+
const { items, setItems } = useItems(PIPELINE_STAGES)
|
|
165
|
+
return (
|
|
166
|
+
<div className="w-80">
|
|
167
|
+
<SortableList
|
|
168
|
+
items={items}
|
|
169
|
+
onReorder={setItems}
|
|
170
|
+
size="default"
|
|
171
|
+
aria-label="Pipeline stages (default)"
|
|
172
|
+
renderItem={(item) => (
|
|
173
|
+
<span className="text-sm text-foreground">{item.label}</span>
|
|
174
|
+
)}
|
|
175
|
+
/>
|
|
176
|
+
</div>
|
|
177
|
+
)
|
|
178
|
+
},
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export const Size_Lg: Story = {
|
|
182
|
+
parameters: { controls: { disable: true } },
|
|
183
|
+
render: () => {
|
|
184
|
+
const { items, setItems } = useItems(PIPELINE_STAGES)
|
|
185
|
+
return (
|
|
186
|
+
<div className="w-80">
|
|
187
|
+
<SortableList
|
|
188
|
+
items={items}
|
|
189
|
+
onReorder={setItems}
|
|
190
|
+
size="lg"
|
|
191
|
+
aria-label="Pipeline stages (large)"
|
|
192
|
+
renderItem={(item) => (
|
|
193
|
+
<span className="text-base text-foreground">{item.label}</span>
|
|
194
|
+
)}
|
|
195
|
+
/>
|
|
196
|
+
</div>
|
|
197
|
+
)
|
|
198
|
+
},
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export const Disabled: Story = {
|
|
202
|
+
parameters: { controls: { disable: true } },
|
|
203
|
+
render: () => {
|
|
204
|
+
const { items, setItems } = useItems(PIPELINE_STAGES)
|
|
205
|
+
return (
|
|
206
|
+
<div className="w-80">
|
|
207
|
+
<SortableList
|
|
208
|
+
items={items}
|
|
209
|
+
onReorder={setItems}
|
|
210
|
+
disabled
|
|
211
|
+
aria-label="Pipeline stages (read-only)"
|
|
212
|
+
renderItem={(item) => (
|
|
213
|
+
<span className="text-sm text-muted-foreground">{item.label}</span>
|
|
214
|
+
)}
|
|
215
|
+
/>
|
|
216
|
+
</div>
|
|
217
|
+
)
|
|
218
|
+
},
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// ─── Realistic use ────────────────────────────────────────────────────────────
|
|
222
|
+
|
|
223
|
+
function RealisticUseDemo() {
|
|
224
|
+
const [members, setMembers] = React.useState(TEAM_MEMBERS)
|
|
225
|
+
|
|
226
|
+
return (
|
|
227
|
+
<div className="w-80 space-y-3">
|
|
228
|
+
<Field name="team-order">
|
|
229
|
+
<FieldLabel>Review order</FieldLabel>
|
|
230
|
+
<FieldHelper>
|
|
231
|
+
Drag to set the order in which the team reviews Fieldnote Labs pull
|
|
232
|
+
requests.
|
|
233
|
+
</FieldHelper>
|
|
234
|
+
<SortableList
|
|
235
|
+
items={members}
|
|
236
|
+
onReorder={setMembers}
|
|
237
|
+
aria-label="Team review order"
|
|
238
|
+
renderItem={(member) => (
|
|
239
|
+
<div className="min-w-0">
|
|
240
|
+
<p className="truncate text-sm font-medium text-foreground">
|
|
241
|
+
{member.name}
|
|
242
|
+
</p>
|
|
243
|
+
<p className="truncate text-xs text-muted-foreground">
|
|
244
|
+
{member.role}
|
|
245
|
+
</p>
|
|
246
|
+
</div>
|
|
247
|
+
)}
|
|
248
|
+
/>
|
|
249
|
+
</Field>
|
|
250
|
+
<p className="text-xs text-muted-foreground">
|
|
251
|
+
Current order:{" "}
|
|
252
|
+
{members.map((m) => m.name.split(" ")[0]).join(" → ")}
|
|
253
|
+
</p>
|
|
254
|
+
</div>
|
|
255
|
+
)
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export const RealisticUse: Story = {
|
|
259
|
+
parameters: {
|
|
260
|
+
controls: { disable: true },
|
|
261
|
+
},
|
|
262
|
+
render: () => <RealisticUseDemo />,
|
|
263
|
+
}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"story files.",
|
|
16
16
|
"",
|
|
17
17
|
"GROUP NAMES ARE FOR PEOPLE SCANNING A SIDEBAR. They are not an architectural",
|
|
18
|
-
"statement and they are not the layer model
|
|
18
|
+
"statement and they are not the layer model \u2014 they answer 'where would someone",
|
|
19
19
|
"look for this', which is why Accordion sits under Layout rather than Actions",
|
|
20
20
|
"and Carousel sits under Layout rather than Content.",
|
|
21
21
|
"",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"SearchInput",
|
|
43
43
|
"Textarea",
|
|
44
44
|
"PasswordInput",
|
|
45
|
+
"PasswordStrengthInput",
|
|
45
46
|
"NumberInput",
|
|
46
47
|
"PinInput",
|
|
47
48
|
"TagsInput",
|
|
@@ -52,7 +53,8 @@
|
|
|
52
53
|
"FloatLabel",
|
|
53
54
|
"FileUpload",
|
|
54
55
|
"SignaturePad",
|
|
55
|
-
"Questionnaire"
|
|
56
|
+
"Questionnaire",
|
|
57
|
+
"JsonInput"
|
|
56
58
|
],
|
|
57
59
|
"Selection": [
|
|
58
60
|
"Select",
|
|
@@ -111,6 +113,7 @@
|
|
|
111
113
|
"AlertDialog",
|
|
112
114
|
"Notification",
|
|
113
115
|
"Sonner",
|
|
116
|
+
"Snackbar",
|
|
114
117
|
"Spinner",
|
|
115
118
|
"Progress",
|
|
116
119
|
"CircularProgress",
|
|
@@ -127,7 +130,9 @@
|
|
|
127
130
|
"ToggleTip",
|
|
128
131
|
"Presence",
|
|
129
132
|
"Callout",
|
|
130
|
-
"AnnouncementBar"
|
|
133
|
+
"AnnouncementBar",
|
|
134
|
+
"ScrollProgress",
|
|
135
|
+
"NavigationProgress"
|
|
131
136
|
],
|
|
132
137
|
"Layout": [
|
|
133
138
|
"Container",
|
|
@@ -138,6 +143,7 @@
|
|
|
138
143
|
"Separator",
|
|
139
144
|
"AspectRatio",
|
|
140
145
|
"ScrollArea",
|
|
146
|
+
"InfiniteScroll",
|
|
141
147
|
"Resizable",
|
|
142
148
|
"Affix",
|
|
143
149
|
"Collapsible",
|
|
@@ -151,7 +157,8 @@
|
|
|
151
157
|
"FloatingPanel",
|
|
152
158
|
"Carousel",
|
|
153
159
|
"Card",
|
|
154
|
-
"PageHeader"
|
|
160
|
+
"PageHeader",
|
|
161
|
+
"SortableList"
|
|
155
162
|
],
|
|
156
163
|
"Content and data": [
|
|
157
164
|
"Table",
|
|
@@ -179,20 +186,24 @@
|
|
|
179
186
|
"Reveal",
|
|
180
187
|
"Sparkline",
|
|
181
188
|
"Icon",
|
|
182
|
-
"ProgressStack"
|
|
189
|
+
"ProgressStack",
|
|
190
|
+
"GaugeChart",
|
|
191
|
+
"Heatmap"
|
|
183
192
|
],
|
|
184
193
|
"Badges and avatars": [
|
|
185
194
|
"Avatar",
|
|
186
195
|
"Badge",
|
|
187
196
|
"Tag",
|
|
188
197
|
"Chip",
|
|
198
|
+
"Pill",
|
|
189
199
|
"Indicator",
|
|
190
200
|
"Kbd",
|
|
191
201
|
"KeyboardShortcut",
|
|
192
202
|
"ThemeIcon",
|
|
193
203
|
"AiBadge",
|
|
194
204
|
"ChatBubble",
|
|
195
|
-
"ChatMarker"
|
|
205
|
+
"ChatMarker",
|
|
206
|
+
"Attachment"
|
|
196
207
|
],
|
|
197
208
|
"Overlays": [
|
|
198
209
|
"Dialog",
|