@behavioral-agentic-design-system/core 0.17.0 → 0.18.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.
Files changed (77) hide show
  1. package/package.json +1 -1
  2. package/scripts/check-stories.mjs +12 -5
  3. package/scripts/fix-stories.mjs +6 -6
  4. package/scripts/generate-stories.cjs +7 -7
  5. package/src/stories/Accordion.stories.tsx +152 -0
  6. package/src/stories/Alert.stories.tsx +102 -0
  7. package/src/stories/AlertDialog.stories.tsx +125 -0
  8. package/src/stories/AspectRatio.stories.tsx +82 -0
  9. package/src/stories/Avatar.stories.tsx +36 -0
  10. package/src/stories/Badge.stories.tsx +54 -0
  11. package/src/stories/Breadcrumb.stories.tsx +36 -0
  12. package/src/stories/Button.stories.tsx +144 -0
  13. package/src/stories/ButtonGroup.stories.tsx +176 -0
  14. package/src/stories/Calendar.stories.tsx +67 -0
  15. package/src/stories/Card.stories.tsx +43 -0
  16. package/src/stories/Carousel.stories.tsx +233 -0
  17. package/src/stories/Chart.stories.tsx +174 -0
  18. package/src/stories/Checkbox.stories.tsx +32 -0
  19. package/src/stories/CircularProgress.stories.tsx +136 -0
  20. package/src/stories/Code.stories.tsx +131 -0
  21. package/src/stories/Collapsible.stories.tsx +27 -0
  22. package/src/stories/ColorPicker.stories.tsx +155 -0
  23. package/src/stories/Combobox.stories.tsx +168 -0
  24. package/src/stories/Command.stories.tsx +40 -0
  25. package/src/stories/ContextMenu.stories.tsx +293 -0
  26. package/src/stories/CopyButton.stories.tsx +111 -0
  27. package/src/stories/DatePicker.stories.tsx +176 -0
  28. package/src/stories/DateRangePicker.stories.tsx +95 -0
  29. package/src/stories/Dialog.stories.tsx +186 -0
  30. package/src/stories/DropdownMenu.stories.tsx +47 -0
  31. package/src/stories/EmptyState.stories.tsx +199 -0
  32. package/src/stories/Field.stories.tsx +155 -0
  33. package/src/stories/FileUpload.stories.tsx +134 -0
  34. package/src/stories/HoverCard.stories.tsx +149 -0
  35. package/src/stories/Indicator.stories.tsx +255 -0
  36. package/src/stories/Input.stories.tsx +69 -0
  37. package/src/stories/Kbd.stories.tsx +123 -0
  38. package/src/stories/Label.stories.tsx +27 -0
  39. package/src/stories/List.stories.tsx +159 -0
  40. package/src/stories/Menubar.stories.tsx +190 -0
  41. package/src/stories/MultiSelect.stories.tsx +107 -0
  42. package/src/stories/NativeSelect.stories.tsx +107 -0
  43. package/src/stories/NavigationMenu.stories.tsx +322 -0
  44. package/src/stories/NumberInput.stories.tsx +100 -0
  45. package/src/stories/Pagination.stories.tsx +201 -0
  46. package/src/stories/PasswordInput.stories.tsx +62 -0
  47. package/src/stories/PinInput.stories.tsx +136 -0
  48. package/src/stories/Popover.stories.tsx +37 -0
  49. package/src/stories/Progress.stories.tsx +64 -0
  50. package/src/stories/RadioGroup.stories.tsx +39 -0
  51. package/src/stories/RatingGroup.stories.tsx +102 -0
  52. package/src/stories/Resizable.stories.tsx +28 -0
  53. package/src/stories/Reveal.stories.tsx +63 -0
  54. package/src/stories/ScrollArea.stories.tsx +76 -0
  55. package/src/stories/SegmentedControl.stories.tsx +182 -0
  56. package/src/stories/Select.stories.tsx +62 -0
  57. package/src/stories/Separator.stories.tsx +28 -0
  58. package/src/stories/Sheet.stories.tsx +193 -0
  59. package/src/stories/Sidebar.stories.tsx +53 -0
  60. package/src/stories/Skeleton.stories.tsx +32 -0
  61. package/src/stories/Slider.stories.tsx +67 -0
  62. package/src/stories/Sonner.stories.tsx +146 -0
  63. package/src/stories/Spinner.stories.tsx +94 -0
  64. package/src/stories/Stepper.stories.tsx +228 -0
  65. package/src/stories/Switch.stories.tsx +58 -0
  66. package/src/stories/Table.stories.tsx +38 -0
  67. package/src/stories/Tabs.stories.tsx +128 -0
  68. package/src/stories/Tag.stories.tsx +51 -0
  69. package/src/stories/TagsInput.stories.tsx +154 -0
  70. package/src/stories/Textarea.stories.tsx +31 -0
  71. package/src/stories/TimePicker.stories.tsx +54 -0
  72. package/src/stories/Timeline.stories.tsx +263 -0
  73. package/src/stories/Toggle.stories.tsx +45 -0
  74. package/src/stories/ToggleGroup.stories.tsx +39 -0
  75. package/src/stories/Toolbar.stories.tsx +295 -0
  76. package/src/stories/Tooltip.stories.tsx +37 -0
  77. package/src/stories/TreeView.stories.tsx +293 -0
@@ -0,0 +1,186 @@
1
+ // NOTE: this primitive now respects PortalThemeProvider — when a parent\
2
+ // mounts <PortalThemeProvider scope="...">, the portal'd content auto-\
3
+ // applies the scope class so theme-scoped CSS variables resolve inside\
4
+ // the portal. See components/Sheet.stories.tsx → WithPortalTheme for the\
5
+ // canonical demonstration. Mechanism is identical here; no separate\
6
+ // story added because the demo would duplicate Sheet's.
7
+ import { Meta, StoryObj } from "@storybook/react";
8
+ import {
9
+ Dialog,
10
+ DialogTrigger,
11
+ DialogContent,
12
+ DialogHeader,
13
+ DialogTitle,
14
+ DialogDescription,
15
+ DialogFooter,
16
+ DialogClose,
17
+ } from "@behavioral-agentic-design-system/core/components/ui/dialog";
18
+ import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";
19
+
20
+ const meta: Meta<typeof Dialog> = {
21
+ title: "Components/Dialog",
22
+ component: Dialog,
23
+ parameters: {
24
+ layout: "centered",
25
+ },
26
+ tags: ["autodocs"],
27
+ };
28
+
29
+ export default meta;
30
+ type Story = StoryObj<typeof meta>;
31
+
32
+ export const Default: Story = {
33
+ render: () => (
34
+ <Dialog>
35
+ <DialogTrigger asChild>
36
+ <Button>Open Dialog</Button>
37
+ </DialogTrigger>
38
+ <DialogContent>
39
+ <DialogHeader>
40
+ <DialogTitle>Dialog Title</DialogTitle>
41
+ <DialogDescription>This is a default-sized dialog.</DialogDescription>
42
+ </DialogHeader>
43
+ <div className="py-4">Dialog content goes here.</div>
44
+ <DialogFooter>
45
+ <DialogClose asChild>
46
+ <Button>Close</Button>
47
+ </DialogClose>
48
+ </DialogFooter>
49
+ </DialogContent>
50
+ </Dialog>
51
+ ),
52
+ };
53
+
54
+ export const Size_SM: Story = {
55
+ render: () => (
56
+ <Dialog>
57
+ <DialogTrigger asChild>
58
+ <Button>Open Small Dialog</Button>
59
+ </DialogTrigger>
60
+ <DialogContent size="sm">
61
+ <DialogHeader>
62
+ <DialogTitle>Small Dialog</DialogTitle>
63
+ <DialogDescription>A small dialog window.</DialogDescription>
64
+ </DialogHeader>
65
+ <div className="py-4">Small dialog content.</div>
66
+ <DialogFooter>
67
+ <DialogClose asChild>
68
+ <Button>Close</Button>
69
+ </DialogClose>
70
+ </DialogFooter>
71
+ </DialogContent>
72
+ </Dialog>
73
+ ),
74
+ };
75
+
76
+ export const Size_LG: Story = {
77
+ render: () => (
78
+ <Dialog>
79
+ <DialogTrigger asChild>
80
+ <Button>Open Large Dialog</Button>
81
+ </DialogTrigger>
82
+ <DialogContent size="lg">
83
+ <DialogHeader>
84
+ <DialogTitle>Large Dialog</DialogTitle>
85
+ <DialogDescription>A large dialog window for more content.</DialogDescription>
86
+ </DialogHeader>
87
+ <div className="py-4">Large dialog content with more room.</div>
88
+ <DialogFooter>
89
+ <DialogClose asChild>
90
+ <Button>Close</Button>
91
+ </DialogClose>
92
+ </DialogFooter>
93
+ </DialogContent>
94
+ </Dialog>
95
+ ),
96
+ };
97
+
98
+ export const Size_XL: Story = {
99
+ render: () => (
100
+ <Dialog>
101
+ <DialogTrigger asChild>
102
+ <Button>Open XL Dialog</Button>
103
+ </DialogTrigger>
104
+ <DialogContent size="xl">
105
+ <DialogHeader>
106
+ <DialogTitle>Extra Large Dialog</DialogTitle>
107
+ <DialogDescription>An extra large dialog for complex layouts.</DialogDescription>
108
+ </DialogHeader>
109
+ <div className="py-4">XL dialog content with lots of space.</div>
110
+ <DialogFooter>
111
+ <DialogClose asChild>
112
+ <Button>Close</Button>
113
+ </DialogClose>
114
+ </DialogFooter>
115
+ </DialogContent>
116
+ </Dialog>
117
+ ),
118
+ };
119
+
120
+ export const Size_2XL: Story = {
121
+ render: () => (
122
+ <Dialog>
123
+ <DialogTrigger asChild>
124
+ <Button>Open 2XL Dialog</Button>
125
+ </DialogTrigger>
126
+ <DialogContent size="2xl">
127
+ <DialogHeader>
128
+ <DialogTitle>2X Large Dialog</DialogTitle>
129
+ <DialogDescription>A 2X large dialog for maximum content area.</DialogDescription>
130
+ </DialogHeader>
131
+ <div className="py-4">2XL dialog content with expansive space.</div>
132
+ <DialogFooter>
133
+ <DialogClose asChild>
134
+ <Button>Close</Button>
135
+ </DialogClose>
136
+ </DialogFooter>
137
+ </DialogContent>
138
+ </Dialog>
139
+ ),
140
+ };
141
+
142
+ export const Size_Full: Story = {
143
+ render: () => (
144
+ <Dialog>
145
+ <DialogTrigger asChild>
146
+ <Button>Open Full Dialog</Button>
147
+ </DialogTrigger>
148
+ <DialogContent size="full">
149
+ <DialogHeader>
150
+ <DialogTitle>Full-Width Dialog</DialogTitle>
151
+ <DialogDescription>A dialog that takes up almost the full viewport.</DialogDescription>
152
+ </DialogHeader>
153
+ <div className="py-4">Full-width dialog content.</div>
154
+ <DialogFooter>
155
+ <DialogClose asChild>
156
+ <Button>Close</Button>
157
+ </DialogClose>
158
+ </DialogFooter>
159
+ </DialogContent>
160
+ </Dialog>
161
+ ),
162
+ };
163
+
164
+ export const RealisticUse: Story = {
165
+ render: () => (
166
+ <Dialog>
167
+ <DialogTrigger asChild>
168
+ <Button>Confirm Action</Button>
169
+ </DialogTrigger>
170
+ <DialogContent size="sm">
171
+ <DialogHeader>
172
+ <DialogTitle>Confirm Deletion</DialogTitle>
173
+ <DialogDescription>This action cannot be undone.</DialogDescription>
174
+ </DialogHeader>
175
+ <div className="py-4">Are you sure you want to delete this item?</div>
176
+ <DialogFooter>
177
+ <DialogClose asChild>
178
+ <Button variant="outline">Cancel</Button>
179
+ </DialogClose>
180
+ <Button variant="destructive">Delete</Button>
181
+ </DialogFooter>
182
+ </DialogContent>
183
+ </Dialog>
184
+ ),
185
+ };
186
+
@@ -0,0 +1,47 @@
1
+ // NOTE: this primitive now respects PortalThemeProvider — when a parent\
2
+ // mounts <PortalThemeProvider scope="...">, the portal'd content auto-\
3
+ // applies the scope class so theme-scoped CSS variables resolve inside\
4
+ // the portal. See components/Sheet.stories.tsx → WithPortalTheme for the\
5
+ // canonical demonstration. Mechanism is identical here; no separate\
6
+ // story added because the demo would duplicate Sheet's.
7
+ import type { Meta, StoryObj } from "@storybook/react";
8
+ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "@behavioral-agentic-design-system/core/components/ui/dropdown-menu";
9
+ import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";
10
+
11
+ const meta: Meta<typeof DropdownMenu> = {
12
+ title: "Components/DropdownMenu",
13
+ component: DropdownMenu,
14
+ parameters: { layout: "centered" },
15
+ tags: ["autodocs"],
16
+ };
17
+
18
+ export default meta;
19
+ type Story = StoryObj<typeof meta>;
20
+
21
+ export const Default: Story = {
22
+ render: () => (<DropdownMenu>
23
+ <DropdownMenuTrigger asChild><Button variant="outline">Open menu</Button></DropdownMenuTrigger>
24
+ <DropdownMenuContent>
25
+ <DropdownMenuLabel>Account</DropdownMenuLabel>
26
+ <DropdownMenuSeparator />
27
+ <DropdownMenuItem>Profile</DropdownMenuItem>
28
+ <DropdownMenuItem>Settings</DropdownMenuItem>
29
+ <DropdownMenuSeparator />
30
+ <DropdownMenuItem>Log out</DropdownMenuItem>
31
+ </DropdownMenuContent>
32
+ </DropdownMenu>),
33
+ };
34
+
35
+ export const RealisticUse: Story = {
36
+ render: () => (<DropdownMenu>
37
+ <DropdownMenuTrigger asChild><Button variant="outline">Open menu</Button></DropdownMenuTrigger>
38
+ <DropdownMenuContent>
39
+ <DropdownMenuLabel>Account</DropdownMenuLabel>
40
+ <DropdownMenuSeparator />
41
+ <DropdownMenuItem>Profile</DropdownMenuItem>
42
+ <DropdownMenuItem>Settings</DropdownMenuItem>
43
+ <DropdownMenuSeparator />
44
+ <DropdownMenuItem>Log out</DropdownMenuItem>
45
+ </DropdownMenuContent>
46
+ </DropdownMenu>),
47
+ };
@@ -0,0 +1,199 @@
1
+ import type { Meta, StoryObj } from "@storybook/react"
2
+ import * as React from "react"
3
+ import {
4
+ InboxIcon,
5
+ SearchIcon,
6
+ CalendarIcon,
7
+ UsersIcon,
8
+ WifiOffIcon,
9
+ ClipboardListIcon,
10
+ TrophyIcon,
11
+ PlusIcon,
12
+ } from "lucide-react"
13
+ import {
14
+ EmptyState,
15
+ EmptyStateIcon,
16
+ EmptyStateTitle,
17
+ EmptyStateDescription,
18
+ EmptyStateAction,
19
+ } from "@behavioral-agentic-design-system/core/components/ui/empty-state"
20
+ import { Button } from "@behavioral-agentic-design-system/core/components/ui/button"
21
+
22
+ const meta: Meta<typeof EmptyState> = {
23
+ title: "Components/EmptyState",
24
+ component: EmptyState,
25
+ parameters: {
26
+ layout: "centered",
27
+ docs: {
28
+ description: {
29
+ component:
30
+ "Composable empty-state primitive: icon container, title, description, and optional action slot. Three size variants (sm/default/lg) for inline card contexts through full-page zero-data screens.",
31
+ },
32
+ },
33
+ },
34
+ tags: ["autodocs"],
35
+ }
36
+ export default meta
37
+
38
+ type Story = StoryObj<typeof EmptyState>
39
+
40
+ export const Default: Story = {
41
+ render: () => (
42
+ <EmptyState className="w-80">
43
+ <EmptyStateIcon>
44
+ <InboxIcon />
45
+ </EmptyStateIcon>
46
+ <EmptyStateTitle>No messages yet</EmptyStateTitle>
47
+ <EmptyStateDescription>
48
+ Messages from your coach will appear here after your first session.
49
+ </EmptyStateDescription>
50
+ </EmptyState>
51
+ ),
52
+ }
53
+
54
+ export const WithAction: Story = {
55
+ render: () => (
56
+ <EmptyState className="w-80">
57
+ <EmptyStateIcon>
58
+ <CalendarIcon />
59
+ </EmptyStateIcon>
60
+ <EmptyStateTitle>No practices scheduled</EmptyStateTitle>
61
+ <EmptyStateDescription>
62
+ Add your first practice block to start tracking attendance and yardage.
63
+ </EmptyStateDescription>
64
+ <EmptyStateAction>
65
+ <Button>
66
+ <PlusIcon strokeWidth={1.5} />
67
+ Schedule practice
68
+ </Button>
69
+ </EmptyStateAction>
70
+ </EmptyState>
71
+ ),
72
+ }
73
+
74
+ export const WithDualActions: Story = {
75
+ render: () => (
76
+ <EmptyState className="w-80">
77
+ <EmptyStateIcon>
78
+ <UsersIcon />
79
+ </EmptyStateIcon>
80
+ <EmptyStateTitle>No swimmers in this group</EmptyStateTitle>
81
+ <EmptyStateDescription>
82
+ Add swimmers individually or import a roster from SwimTopia.
83
+ </EmptyStateDescription>
84
+ <EmptyStateAction>
85
+ <Button>
86
+ <PlusIcon strokeWidth={1.5} />
87
+ Add swimmer
88
+ </Button>
89
+ <Button variant="outline">Import roster</Button>
90
+ </EmptyStateAction>
91
+ </EmptyState>
92
+ ),
93
+ }
94
+
95
+ export const SearchEmpty: Story = {
96
+ render: () => (
97
+ <EmptyState className="w-80">
98
+ <EmptyStateIcon>
99
+ <SearchIcon />
100
+ </EmptyStateIcon>
101
+ <EmptyStateTitle>No results for "butterfly relay"</EmptyStateTitle>
102
+ <EmptyStateDescription>
103
+ Try different keywords or check the event name spelling.
104
+ </EmptyStateDescription>
105
+ <EmptyStateAction>
106
+ <Button variant="outline">Clear search</Button>
107
+ </EmptyStateAction>
108
+ </EmptyState>
109
+ ),
110
+ }
111
+
112
+ export const ErrorState: Story = {
113
+ render: () => (
114
+ <EmptyState className="w-80">
115
+ <EmptyStateIcon className="bg-destructive/10 text-destructive">
116
+ <WifiOffIcon />
117
+ </EmptyStateIcon>
118
+ <EmptyStateTitle>Couldn&apos;t load roster</EmptyStateTitle>
119
+ <EmptyStateDescription>
120
+ Check your connection and try again. Your data is safe.
121
+ </EmptyStateDescription>
122
+ <EmptyStateAction>
123
+ <Button variant="outline">Retry</Button>
124
+ </EmptyStateAction>
125
+ </EmptyState>
126
+ ),
127
+ }
128
+
129
+ export const Size_Sm: Story = {
130
+ render: () => (
131
+ <EmptyState size="sm" className="w-64 border border-border rounded-lg">
132
+ <EmptyStateIcon className="size-9 [&>svg]:size-5">
133
+ <ClipboardListIcon />
134
+ </EmptyStateIcon>
135
+ <EmptyStateTitle>No notes</EmptyStateTitle>
136
+ <EmptyStateDescription>Add a note to this set.</EmptyStateDescription>
137
+ </EmptyState>
138
+ ),
139
+ }
140
+
141
+ export const Size_Default: Story = {
142
+ render: () => (
143
+ <EmptyState size="default" className="w-80">
144
+ <EmptyStateIcon>
145
+ <InboxIcon />
146
+ </EmptyStateIcon>
147
+ <EmptyStateTitle>Default size</EmptyStateTitle>
148
+ <EmptyStateDescription>
149
+ Standard spacing for most card and panel contexts.
150
+ </EmptyStateDescription>
151
+ </EmptyState>
152
+ ),
153
+ }
154
+
155
+ export const Size_Lg: Story = {
156
+ render: () => (
157
+ <EmptyState size="lg" className="w-96">
158
+ <EmptyStateIcon className="size-16 [&>svg]:size-8">
159
+ <TrophyIcon />
160
+ </EmptyStateIcon>
161
+ <EmptyStateTitle>Season results are not in yet</EmptyStateTitle>
162
+ <EmptyStateDescription>
163
+ Championship results will appear here once the meet director submits scores.
164
+ </EmptyStateDescription>
165
+ </EmptyState>
166
+ ),
167
+ }
168
+
169
+ export const RealisticUse: Story = {
170
+ render: () => (
171
+ <div className="w-[400px] rounded-xl border border-border bg-card overflow-hidden">
172
+ {/* Card header */}
173
+ <div className="px-5 py-4 border-b border-border flex items-center justify-between">
174
+ <div>
175
+ <p className="text-sm font-semibold">Upcoming meets</p>
176
+ <p className="text-xs text-muted-foreground mt-0.5">Breezy Hills Aquatic Club</p>
177
+ </div>
178
+ <Button variant="outline" size="sm">
179
+ <PlusIcon strokeWidth={1.5} />
180
+ Add meet
181
+ </Button>
182
+ </div>
183
+ {/* Empty state body */}
184
+ <EmptyState size="default">
185
+ <EmptyStateIcon>
186
+ <CalendarIcon />
187
+ </EmptyStateIcon>
188
+ <EmptyStateTitle>No meets registered yet</EmptyStateTitle>
189
+ <EmptyStateDescription>
190
+ Register for your first meet on SwimTopia, then sync it here.
191
+ </EmptyStateDescription>
192
+ <EmptyStateAction>
193
+ <Button size="sm">Register on SwimTopia</Button>
194
+ <Button variant="ghost" size="sm">Learn more</Button>
195
+ </EmptyStateAction>
196
+ </EmptyState>
197
+ </div>
198
+ ),
199
+ }
@@ -0,0 +1,155 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { useState } from "react";
3
+ import {
4
+ Field,
5
+ FieldLabel,
6
+ FieldHelper,
7
+ FieldError,
8
+ FieldControl,
9
+ FieldGroup,
10
+ } from "@behavioral-agentic-design-system/core/components/ui/field";
11
+ import { Input } from "@behavioral-agentic-design-system/core/components/ui/input";
12
+ import { Textarea } from "@behavioral-agentic-design-system/core/components/ui/textarea";
13
+ import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";
14
+
15
+ const meta: Meta<typeof Field> = {
16
+ title: "Components/Field",
17
+ component: Field,
18
+ parameters: { layout: "padded" },
19
+ tags: ["autodocs"],
20
+ };
21
+ export default meta;
22
+ type Story = StoryObj<typeof meta>;
23
+
24
+ export const Default: Story = {
25
+ render: () => (
26
+ <Field name="email" required>
27
+ <FieldLabel>Email address</FieldLabel>
28
+ <FieldControl>
29
+ <Input type="email" placeholder="you@example.com" autoComplete="email" />
30
+ </FieldControl>
31
+ <FieldHelper>We&apos;ll never share it.</FieldHelper>
32
+ </Field>
33
+ ),
34
+ };
35
+
36
+ export const Variant_WithError: Story = {
37
+ render: () => (
38
+ <Field name="email" required invalid>
39
+ <FieldLabel>Email address</FieldLabel>
40
+ <FieldControl>
41
+ <Input type="email" defaultValue="not-an-email" autoComplete="email" />
42
+ </FieldControl>
43
+ <FieldHelper>We&apos;ll never share it.</FieldHelper>
44
+ <FieldError>Enter a valid email address.</FieldError>
45
+ </Field>
46
+ ),
47
+ };
48
+
49
+ export const Variant_Horizontal: Story = {
50
+ render: () => (
51
+ <Field name="username" layout="horizontal">
52
+ <FieldLabel className="w-32 shrink-0">Username</FieldLabel>
53
+ <FieldControl>
54
+ <Input placeholder="ada-lovelace" autoComplete="username" />
55
+ </FieldControl>
56
+ </Field>
57
+ ),
58
+ };
59
+
60
+ export const Variant_Textarea: Story = {
61
+ render: () => (
62
+ <Field name="bio">
63
+ <FieldLabel>Bio</FieldLabel>
64
+ <FieldControl>
65
+ <Textarea placeholder="Tell us about yourself..." rows={4} />
66
+ </FieldControl>
67
+ <FieldHelper>Markdown is supported.</FieldHelper>
68
+ </Field>
69
+ ),
70
+ };
71
+
72
+ export const Disabled: Story = {
73
+ render: () => (
74
+ <Field name="readonly-field" disabled>
75
+ <FieldLabel>Locked field</FieldLabel>
76
+ <FieldControl>
77
+ <Input defaultValue="ada-lovelace" />
78
+ </FieldControl>
79
+ <FieldHelper>Contact support to change this.</FieldHelper>
80
+ </Field>
81
+ ),
82
+ };
83
+
84
+ export const RealisticUse: Story = {
85
+ render: () => {
86
+ const [email, setEmail] = useState("");
87
+ const [password, setPassword] = useState("");
88
+ const [submitted, setSubmitted] = useState(false);
89
+
90
+ const emailError = submitted && !email.includes("@") ? "Enter a valid email." : undefined;
91
+ const passwordError =
92
+ submitted && password.length < 8 ? "Password must be at least 8 characters." : undefined;
93
+
94
+ return (
95
+ <form
96
+ onSubmit={(e) => {
97
+ e.preventDefault();
98
+ setSubmitted(true);
99
+ }}
100
+ className="w-full max-w-md space-y-6"
101
+ >
102
+ <Field name="email" required invalid={!!emailError}>
103
+ <FieldLabel>Email</FieldLabel>
104
+ <FieldControl>
105
+ <Input
106
+ type="email"
107
+ autoComplete="email"
108
+ value={email}
109
+ onChange={(e) => setEmail(e.target.value)}
110
+ />
111
+ </FieldControl>
112
+ <FieldHelper>The email tied to your account.</FieldHelper>
113
+ <FieldError>{emailError}</FieldError>
114
+ </Field>
115
+
116
+ <Field name="password" required invalid={!!passwordError}>
117
+ <FieldLabel>Password</FieldLabel>
118
+ <FieldControl>
119
+ <Input
120
+ type="password"
121
+ autoComplete="current-password"
122
+ value={password}
123
+ onChange={(e) => setPassword(e.target.value)}
124
+ />
125
+ </FieldControl>
126
+ <FieldHelper>Minimum 8 characters.</FieldHelper>
127
+ <FieldError>{passwordError}</FieldError>
128
+ </Field>
129
+
130
+ <Button type="submit" className="w-full">
131
+ Sign in
132
+ </Button>
133
+ </form>
134
+ );
135
+ },
136
+ };
137
+
138
+ export const FieldGroup_TwoColumn: Story = {
139
+ render: () => (
140
+ <FieldGroup columns={2} className="w-full max-w-2xl">
141
+ <Field name="firstName" required>
142
+ <FieldLabel>First name</FieldLabel>
143
+ <FieldControl>
144
+ <Input autoComplete="given-name" />
145
+ </FieldControl>
146
+ </Field>
147
+ <Field name="lastName" required>
148
+ <FieldLabel>Last name</FieldLabel>
149
+ <FieldControl>
150
+ <Input autoComplete="family-name" />
151
+ </FieldControl>
152
+ </Field>
153
+ </FieldGroup>
154
+ ),
155
+ };