ai-design-system 0.1.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 (290) hide show
  1. package/README.md +307 -0
  2. package/components/ai-elements/actions.tsx +65 -0
  3. package/components/ai-elements/artifact.tsx +147 -0
  4. package/components/ai-elements/branch.tsx +212 -0
  5. package/components/ai-elements/canvas.tsx +24 -0
  6. package/components/ai-elements/chain-of-thought.tsx +228 -0
  7. package/components/ai-elements/code-block.tsx +179 -0
  8. package/components/ai-elements/confirmation.tsx +169 -0
  9. package/components/ai-elements/connection.tsx +28 -0
  10. package/components/ai-elements/context.tsx +408 -0
  11. package/components/ai-elements/controls.tsx +18 -0
  12. package/components/ai-elements/conversation.tsx +97 -0
  13. package/components/ai-elements/edge.tsx +140 -0
  14. package/components/ai-elements/image.tsx +24 -0
  15. package/components/ai-elements/inline-citation.tsx +287 -0
  16. package/components/ai-elements/loader.tsx +96 -0
  17. package/components/ai-elements/message.tsx +80 -0
  18. package/components/ai-elements/node.tsx +71 -0
  19. package/components/ai-elements/open-in-chat.tsx +363 -0
  20. package/components/ai-elements/panel.tsx +15 -0
  21. package/components/ai-elements/plan.tsx +142 -0
  22. package/components/ai-elements/prompt-input.tsx +1352 -0
  23. package/components/ai-elements/queue.tsx +274 -0
  24. package/components/ai-elements/reasoning.tsx +178 -0
  25. package/components/ai-elements/response.tsx +22 -0
  26. package/components/ai-elements/shimmer.tsx +64 -0
  27. package/components/ai-elements/sources.tsx +77 -0
  28. package/components/ai-elements/suggestion.tsx +56 -0
  29. package/components/ai-elements/task.tsx +87 -0
  30. package/components/ai-elements/tool.tsx +179 -0
  31. package/components/ai-elements/toolbar.tsx +16 -0
  32. package/components/ai-elements/web-preview.tsx +263 -0
  33. package/components/blocks/AIConversation/AIConversation.stories.tsx +164 -0
  34. package/components/blocks/AIConversation/AIConversation.tsx +186 -0
  35. package/components/blocks/AIConversation/index.ts +8 -0
  36. package/components/blocks/AppSidebar/AppSidebar.stories.tsx +63 -0
  37. package/components/blocks/AppSidebar/AppSidebar.tsx +87 -0
  38. package/components/blocks/AppSidebar/index.ts +2 -0
  39. package/components/blocks/DocumentEditorWithComments/DocumentEditorWithComments.stories.tsx +341 -0
  40. package/components/blocks/DocumentEditorWithComments/DocumentEditorWithComments.tsx +255 -0
  41. package/components/blocks/DocumentEditorWithComments/index.ts +9 -0
  42. package/components/blocks/FileChangeQueue/FileChangeQueue.stories.tsx +207 -0
  43. package/components/blocks/FileChangeQueue/FileChangeQueue.tsx +143 -0
  44. package/components/blocks/FileChangeQueue/index.ts +7 -0
  45. package/components/blocks/LayoutProvider/LayoutProvider.tsx +34 -0
  46. package/components/blocks/LayoutProvider/index.ts +1 -0
  47. package/components/blocks/index.ts +2 -0
  48. package/components/composites/AgentIndicator/AgentIndicator.stories.tsx +154 -0
  49. package/components/composites/AgentIndicator/AgentIndicator.tsx +102 -0
  50. package/components/composites/AgentIndicator/index.ts +8 -0
  51. package/components/composites/AppHeader/AppHeader.stories.tsx +46 -0
  52. package/components/composites/AppHeader/AppHeader.tsx +24 -0
  53. package/components/composites/AppHeader/index.ts +2 -0
  54. package/components/composites/CommentBox/CommentBox.stories.tsx +192 -0
  55. package/components/composites/CommentBox/CommentBox.tsx +364 -0
  56. package/components/composites/CommentBox/index.ts +8 -0
  57. package/components/composites/Confirmation/Confirmation.stories.tsx +151 -0
  58. package/components/composites/Confirmation/Confirmation.tsx +93 -0
  59. package/components/composites/Confirmation/index.ts +7 -0
  60. package/components/composites/DataTable/DataTable.stories.tsx +35 -0
  61. package/components/composites/DataTable/DataTable.tsx +95 -0
  62. package/components/composites/DataTable/index.ts +2 -0
  63. package/components/composites/DocumentEditor/DocumentEditor.css +106 -0
  64. package/components/composites/DocumentEditor/DocumentEditor.stories.tsx +927 -0
  65. package/components/composites/DocumentEditor/DocumentEditor.tsx +279 -0
  66. package/components/composites/DocumentEditor/index.ts +8 -0
  67. package/components/composites/FileQueue/FileQueue.stories.tsx +175 -0
  68. package/components/composites/FileQueue/FileQueue.tsx +161 -0
  69. package/components/composites/FileQueue/FileStatusBadge.tsx +74 -0
  70. package/components/composites/FileQueue/index.ts +24 -0
  71. package/components/composites/InteractiveChart/InteractiveChart.stories.tsx +49 -0
  72. package/components/composites/InteractiveChart/InteractiveChart.tsx +69 -0
  73. package/components/composites/InteractiveChart/index.ts +2 -0
  74. package/components/composites/ModeToggle/ModeToggle.stories.tsx +212 -0
  75. package/components/composites/ModeToggle/ModeToggle.tsx +100 -0
  76. package/components/composites/ModeToggle/index.ts +7 -0
  77. package/components/composites/NavUser/NavUser.stories.tsx +50 -0
  78. package/components/composites/NavUser/NavUser.tsx +60 -0
  79. package/components/composites/NavUser/index.ts +2 -0
  80. package/components/composites/NavigationList/NavigationList.stories.tsx +46 -0
  81. package/components/composites/NavigationList/NavigationList.tsx +46 -0
  82. package/components/composites/NavigationList/index.ts +2 -0
  83. package/components/composites/OrchestratorMessage/OrchestratorMessage.stories.tsx +188 -0
  84. package/components/composites/OrchestratorMessage/OrchestratorMessage.tsx +72 -0
  85. package/components/composites/OrchestratorMessage/index.ts +8 -0
  86. package/components/composites/PageContainer/PageContainer.stories.tsx +41 -0
  87. package/components/composites/PageContainer/PageContainer.tsx +24 -0
  88. package/components/composites/PageContainer/index.ts +2 -0
  89. package/components/composites/PromptInput/PromptInput.stories.tsx +200 -0
  90. package/components/composites/PromptInput/PromptInput.tsx +129 -0
  91. package/components/composites/PromptInput/index.ts +8 -0
  92. package/components/composites/SpecialistMessage/SpecialistMessage.stories.tsx +286 -0
  93. package/components/composites/SpecialistMessage/SpecialistMessage.tsx +107 -0
  94. package/components/composites/SpecialistMessage/index.ts +8 -0
  95. package/components/composites/StatsCard/StatsCard.stories.tsx +76 -0
  96. package/components/composites/StatsCard/StatsCard.tsx +81 -0
  97. package/components/composites/StatsCard/index.ts +2 -0
  98. package/components/composites/TablePagination/TablePagination.stories.tsx +38 -0
  99. package/components/composites/TablePagination/TablePagination.tsx +119 -0
  100. package/components/composites/TablePagination/index.ts +2 -0
  101. package/components/composites/TableToolbar/TableToolbar.stories.tsx +60 -0
  102. package/components/composites/TableToolbar/TableToolbar.tsx +66 -0
  103. package/components/composites/TableToolbar/index.ts +2 -0
  104. package/components/composites/ThemeSelector/ThemeSelector.stories.tsx +48 -0
  105. package/components/composites/ThemeSelector/ThemeSelector.tsx +79 -0
  106. package/components/composites/ThemeSelector/index.ts +2 -0
  107. package/components/composites/ToolCallDisplay/ToolCallDisplay.stories.tsx +49 -0
  108. package/components/composites/ToolCallDisplay/ToolCallDisplay.tsx +108 -0
  109. package/components/composites/ToolCallDisplay/index.ts +8 -0
  110. package/components/composites/UserMessage/UserMessage.stories.tsx +59 -0
  111. package/components/composites/UserMessage/UserMessage.tsx +52 -0
  112. package/components/composites/UserMessage/index.ts +8 -0
  113. package/components/composites/index.ts +90 -0
  114. package/components/features/AIDocEditor/AIDocEditor.behaviors.stories.tsx +451 -0
  115. package/components/features/AIDocEditor/AIDocEditor.mocks.ts +96 -0
  116. package/components/features/AIDocEditor/AIDocEditor.stories.tsx +140 -0
  117. package/components/features/AIDocEditor/AIDocEditor.tsx +130 -0
  118. package/components/features/AIDocEditor/index.ts +8 -0
  119. package/components/features/AIDocEditor/useAIDocEditor.d.ts +97 -0
  120. package/components/features/AIDocEditor/useAIDocEditor.mock.ts +83 -0
  121. package/components/features/PageLayout/PageLayout.behaviors.stories.tsx +119 -0
  122. package/components/features/PageLayout/PageLayout.mocks.ts +27 -0
  123. package/components/features/PageLayout/PageLayout.stories.tsx +142 -0
  124. package/components/features/PageLayout/PageLayout.tsx +94 -0
  125. package/components/features/PageLayout/index.ts +4 -0
  126. package/components/features/PageLayout/usePageLayout.d.ts +24 -0
  127. package/components/features/PageLayout/usePageLayout.mock.ts +19 -0
  128. package/components/features/RefinementPanel/README.md +189 -0
  129. package/components/features/RefinementPanel/RefinementPanel.behaviors.stories.tsx +475 -0
  130. package/components/features/RefinementPanel/RefinementPanel.mocks.ts +131 -0
  131. package/components/features/RefinementPanel/RefinementPanel.stories.tsx +141 -0
  132. package/components/features/RefinementPanel/RefinementPanel.tsx +160 -0
  133. package/components/features/RefinementPanel/index.ts +25 -0
  134. package/components/features/RefinementPanel/useRefinementPanel.d.ts +74 -0
  135. package/components/features/RefinementPanel/useRefinementPanel.mock.ts +121 -0
  136. package/components/features/SpecNavigator/SpecNavigator.behaviors.stories.tsx +379 -0
  137. package/components/features/SpecNavigator/SpecNavigator.mocks.ts +131 -0
  138. package/components/features/SpecNavigator/SpecNavigator.stories.tsx +122 -0
  139. package/components/features/SpecNavigator/SpecNavigator.tsx +43 -0
  140. package/components/features/SpecNavigator/index.ts +2 -0
  141. package/components/features/SpecNavigator/useSpecNavigator.d.ts +122 -0
  142. package/components/features/SpecNavigator/useSpecNavigator.mock.ts +93 -0
  143. package/components/features/index.ts +18 -0
  144. package/components/index.ts +14 -0
  145. package/components/primitives/Accordion/Accordion.stories.tsx +87 -0
  146. package/components/primitives/Accordion/Accordion.tsx +66 -0
  147. package/components/primitives/Accordion/index.ts +13 -0
  148. package/components/primitives/Alert/Alert.stories.tsx +422 -0
  149. package/components/primitives/Alert/Alert.tsx +61 -0
  150. package/components/primitives/Alert/index.ts +8 -0
  151. package/components/primitives/AlertDialog/AlertDialog.stories.tsx +367 -0
  152. package/components/primitives/AlertDialog/AlertDialog.tsx +182 -0
  153. package/components/primitives/AlertDialog/index.ts +25 -0
  154. package/components/primitives/Avatar/Avatar.stories.tsx +321 -0
  155. package/components/primitives/Avatar/Avatar.tsx +63 -0
  156. package/components/primitives/Avatar/index.ts +8 -0
  157. package/components/primitives/Badge/Badge.stories.tsx +74 -0
  158. package/components/primitives/Badge/Badge.tsx +49 -0
  159. package/components/primitives/Badge/index.ts +2 -0
  160. package/components/primitives/Button/Button.stories.tsx +445 -0
  161. package/components/primitives/Button/Button.tsx +89 -0
  162. package/components/primitives/Button/index.ts +7 -0
  163. package/components/primitives/Card/Card.stories.tsx +831 -0
  164. package/components/primitives/Card/Card.tsx +242 -0
  165. package/components/primitives/Card/index.ts +30 -0
  166. package/components/primitives/Carousel/Carousel.stories.tsx +32 -0
  167. package/components/primitives/Carousel/Carousel.tsx +63 -0
  168. package/components/primitives/Carousel/index.ts +13 -0
  169. package/components/primitives/Chart/Chart.stories.tsx +346 -0
  170. package/components/primitives/Chart/Chart.tsx +117 -0
  171. package/components/primitives/Chart/index.ts +20 -0
  172. package/components/primitives/Checkbox/Checkbox.stories.tsx +87 -0
  173. package/components/primitives/Checkbox/Checkbox.tsx +38 -0
  174. package/components/primitives/Checkbox/index.ts +2 -0
  175. package/components/primitives/Collapsible/Collapsible.stories.tsx +38 -0
  176. package/components/primitives/Collapsible/Collapsible.tsx +39 -0
  177. package/components/primitives/Collapsible/index.ts +8 -0
  178. package/components/primitives/Command/Command.stories.tsx +150 -0
  179. package/components/primitives/Command/Command.tsx +147 -0
  180. package/components/primitives/Command/index.ts +20 -0
  181. package/components/primitives/Dialog/Dialog.stories.tsx +390 -0
  182. package/components/primitives/Dialog/Dialog.tsx +140 -0
  183. package/components/primitives/Dialog/index.ts +22 -0
  184. package/components/primitives/Drawer/Drawer.stories.tsx +327 -0
  185. package/components/primitives/Drawer/Drawer.tsx +208 -0
  186. package/components/primitives/Drawer/index.ts +27 -0
  187. package/components/primitives/DropdownMenu/DropdownMenu.stories.tsx +150 -0
  188. package/components/primitives/DropdownMenu/DropdownMenu.tsx +73 -0
  189. package/components/primitives/DropdownMenu/index.ts +1 -0
  190. package/components/primitives/HoverCard/HoverCard.stories.tsx +26 -0
  191. package/components/primitives/HoverCard/HoverCard.tsx +39 -0
  192. package/components/primitives/HoverCard/index.ts +8 -0
  193. package/components/primitives/Icon/Icon.stories.tsx +281 -0
  194. package/components/primitives/Icon/Icon.tsx +87 -0
  195. package/components/primitives/Icon/index.ts +8 -0
  196. package/components/primitives/Input/Input.stories.tsx +370 -0
  197. package/components/primitives/Input/Input.tsx +88 -0
  198. package/components/primitives/Input/index.ts +7 -0
  199. package/components/primitives/InputGroup/InputGroup.stories.tsx +40 -0
  200. package/components/primitives/InputGroup/InputGroup.tsx +72 -0
  201. package/components/primitives/InputGroup/index.ts +14 -0
  202. package/components/primitives/Label/Label.stories.tsx +227 -0
  203. package/components/primitives/Label/Label.tsx +53 -0
  204. package/components/primitives/Label/index.ts +7 -0
  205. package/components/primitives/Popover/Popover.stories.tsx +42 -0
  206. package/components/primitives/Popover/Popover.tsx +107 -0
  207. package/components/primitives/Popover/index.ts +2 -0
  208. package/components/primitives/Progress/Progress.stories.tsx +340 -0
  209. package/components/primitives/Progress/Progress.tsx +31 -0
  210. package/components/primitives/Progress/index.ts +1 -0
  211. package/components/primitives/ScrollArea/ScrollArea.stories.tsx +26 -0
  212. package/components/primitives/ScrollArea/ScrollArea.tsx +28 -0
  213. package/components/primitives/ScrollArea/index.ts +6 -0
  214. package/components/primitives/Select/Select.stories.tsx +288 -0
  215. package/components/primitives/Select/Select.tsx +162 -0
  216. package/components/primitives/Select/index.ts +22 -0
  217. package/components/primitives/Separator/Separator.stories.tsx +264 -0
  218. package/components/primitives/Separator/Separator.tsx +48 -0
  219. package/components/primitives/Separator/index.ts +7 -0
  220. package/components/primitives/Sidebar/Sidebar.stories.tsx +358 -0
  221. package/components/primitives/Sidebar/Sidebar.tsx +317 -0
  222. package/components/primitives/Sidebar/index.ts +41 -0
  223. package/components/primitives/Table/Table.stories.tsx +389 -0
  224. package/components/primitives/Table/Table.tsx +191 -0
  225. package/components/primitives/Table/index.ts +26 -0
  226. package/components/primitives/Tabs/Tabs.stories.tsx +129 -0
  227. package/components/primitives/Tabs/Tabs.tsx +70 -0
  228. package/components/primitives/Tabs/index.ts +13 -0
  229. package/components/primitives/Textarea/Textarea.stories.tsx +358 -0
  230. package/components/primitives/Textarea/Textarea.tsx +91 -0
  231. package/components/primitives/Textarea/index.ts +7 -0
  232. package/components/primitives/ToggleGroup/ToggleGroup.stories.tsx +87 -0
  233. package/components/primitives/ToggleGroup/ToggleGroup.tsx +52 -0
  234. package/components/primitives/ToggleGroup/index.ts +6 -0
  235. package/components/primitives/Tooltip/Tooltip.stories.tsx +336 -0
  236. package/components/primitives/Tooltip/Tooltip.tsx +78 -0
  237. package/components/primitives/Tooltip/index.ts +10 -0
  238. package/components/primitives/index.ts +34 -0
  239. package/components/ui/accordion.tsx +66 -0
  240. package/components/ui/alert-dialog.tsx +157 -0
  241. package/components/ui/alert.tsx +66 -0
  242. package/components/ui/avatar.tsx +53 -0
  243. package/components/ui/badge.tsx +46 -0
  244. package/components/ui/button.tsx +60 -0
  245. package/components/ui/card.tsx +117 -0
  246. package/components/ui/carousel.tsx +241 -0
  247. package/components/ui/chart.tsx +334 -0
  248. package/components/ui/checkbox.tsx +32 -0
  249. package/components/ui/collapsible.tsx +33 -0
  250. package/components/ui/command.tsx +184 -0
  251. package/components/ui/dialog.tsx +143 -0
  252. package/components/ui/drawer.tsx +118 -0
  253. package/components/ui/dropdown-menu.tsx +257 -0
  254. package/components/ui/hover-card.tsx +44 -0
  255. package/components/ui/input-group.tsx +170 -0
  256. package/components/ui/input.tsx +48 -0
  257. package/components/ui/label.tsx +26 -0
  258. package/components/ui/popover.tsx +33 -0
  259. package/components/ui/progress.tsx +31 -0
  260. package/components/ui/scroll-area.tsx +58 -0
  261. package/components/ui/select.tsx +187 -0
  262. package/components/ui/separator.tsx +31 -0
  263. package/components/ui/sidebar.tsx +577 -0
  264. package/components/ui/table.tsx +120 -0
  265. package/components/ui/tabs.tsx +66 -0
  266. package/components/ui/textarea.tsx +46 -0
  267. package/components/ui/toggle-group.tsx +83 -0
  268. package/components/ui/toggle.tsx +47 -0
  269. package/components/ui/tooltip.tsx +61 -0
  270. package/dist/index.cjs +7389 -0
  271. package/dist/index.cjs.map +1 -0
  272. package/dist/index.css +75 -0
  273. package/dist/index.css.map +1 -0
  274. package/dist/index.js +7160 -0
  275. package/dist/index.js.map +1 -0
  276. package/hooks/useAIDocReviewer.d.ts +0 -0
  277. package/lib/utils.ts +6 -0
  278. package/package.json +140 -0
  279. package/tokens/color/base.json +14 -0
  280. package/tokens/color/dark.json +40 -0
  281. package/tokens/color/green.json +21 -0
  282. package/tokens/color/light.json +52 -0
  283. package/tokens/color/neutral.json +20 -0
  284. package/tokens/color/violet.json +21 -0
  285. package/tokens/spacing.json +22 -0
  286. package/utils/ai-editor/format-date.ts +41 -0
  287. package/utils/ai-editor/index.ts +22 -0
  288. package/utils/ai-editor/type-guards.ts +72 -0
  289. package/utils/ai-editor/validation.ts +130 -0
  290. package/utils/editor-annotations.ts +122 -0
@@ -0,0 +1,367 @@
1
+ import type { Meta, StoryObj } from "@storybook/react"
2
+ import * as React from "react"
3
+ import {
4
+ AlertDialog,
5
+ AlertDialogAction,
6
+ AlertDialogCancel,
7
+ AlertDialogContent,
8
+ AlertDialogDescription,
9
+ AlertDialogFooter,
10
+ AlertDialogHeader,
11
+ AlertDialogTitle,
12
+ AlertDialogTrigger,
13
+ } from "./AlertDialog"
14
+ import { Button } from "../Button"
15
+
16
+ /**
17
+ * AlertDialog Primitive Stories
18
+ *
19
+ * The AlertDialog component is specifically designed for critical confirmations and
20
+ * destructive actions that require explicit user acknowledgment. Unlike Dialog, AlertDialog
21
+ * enforces a more restrictive interaction model.
22
+ *
23
+ * ## Accessibility Features
24
+ * - Focus is trapped within the alert dialog
25
+ * - Screen reader announces with alert role
26
+ * - Escape key triggers cancel action
27
+ * - No overlay dismiss (requires explicit choice)
28
+ * - Clear distinction between cancel and action buttons
29
+ * - Proper ARIA attributes (role="alertdialog")
30
+ *
31
+ * ## Usage Guidelines
32
+ * - Use for irreversible or destructive actions
33
+ * - Always provide both Cancel and Action buttons
34
+ * - Use clear, action-oriented button labels
35
+ * - Explain consequences in the description
36
+ * - Keep title short and direct (question format works well)
37
+ *
38
+ * ## When to Use
39
+ * - Confirming destructive actions (delete, remove, disable)
40
+ * - Warning about irreversible changes
41
+ * - Critical security confirmations
42
+ * - Data loss warnings
43
+ *
44
+ * ## When NOT to Use
45
+ * - For non-critical confirmations (use Dialog instead)
46
+ * - For collecting input (use Dialog instead)
47
+ * - For informational messages (use Toast or Alert instead)
48
+ * - For dismissible notifications
49
+ */
50
+ const meta = {
51
+ title: "Primitives/AlertDialog",
52
+ component: AlertDialog,
53
+ parameters: {
54
+ layout: "centered",
55
+ docs: {
56
+ description: {
57
+ component:
58
+ "A critical confirmation dialog for destructive or irreversible actions. Built on Radix UI AlertDialog primitive.",
59
+ },
60
+ },
61
+ },
62
+ tags: ["autodocs"],
63
+ } satisfies Meta<typeof AlertDialog>
64
+
65
+ export default meta
66
+ type Story = StoryObj<typeof meta>
67
+
68
+ /**
69
+ * Default AlertDialog
70
+ *
71
+ * Basic alert dialog with warning message and confirmation buttons.
72
+ * This is the standard pattern for destructive actions.
73
+ */
74
+ export const Default: Story = {
75
+ render: () => (
76
+ <AlertDialog>
77
+ <AlertDialogTrigger asChild>
78
+ <Button variant="destructive">Delete Account</Button>
79
+ </AlertDialogTrigger>
80
+ <AlertDialogContent>
81
+ <AlertDialogHeader>
82
+ <AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
83
+ <AlertDialogDescription>
84
+ This action cannot be undone. This will permanently delete your
85
+ account and remove your data from our servers.
86
+ </AlertDialogDescription>
87
+ </AlertDialogHeader>
88
+ <AlertDialogFooter>
89
+ <AlertDialogCancel>Cancel</AlertDialogCancel>
90
+ <AlertDialogAction>Delete Account</AlertDialogAction>
91
+ </AlertDialogFooter>
92
+ </AlertDialogContent>
93
+ </AlertDialog>
94
+ ),
95
+ }
96
+
97
+ /**
98
+ * Destructive Action
99
+ *
100
+ * Alert dialog for confirming a destructive action with clear consequences.
101
+ * Uses destructive variant for the action button.
102
+ */
103
+ export const DestructiveAction: Story = {
104
+ render: () => (
105
+ <AlertDialog>
106
+ <AlertDialogTrigger asChild>
107
+ <Button variant="outline">Delete File</Button>
108
+ </AlertDialogTrigger>
109
+ <AlertDialogContent>
110
+ <AlertDialogHeader>
111
+ <AlertDialogTitle>Delete this file?</AlertDialogTitle>
112
+ <AlertDialogDescription>
113
+ This will permanently delete "document.pdf" from your workspace.
114
+ This action cannot be undone.
115
+ </AlertDialogDescription>
116
+ </AlertDialogHeader>
117
+ <AlertDialogFooter>
118
+ <AlertDialogCancel>Cancel</AlertDialogCancel>
119
+ <AlertDialogAction className="bg-destructive text-destructive-foreground hover:bg-destructive/90">
120
+ Delete File
121
+ </AlertDialogAction>
122
+ </AlertDialogFooter>
123
+ </AlertDialogContent>
124
+ </AlertDialog>
125
+ ),
126
+ }
127
+
128
+ /**
129
+ * Data Loss Warning
130
+ *
131
+ * Alert dialog warning about potential data loss.
132
+ * Emphasizes the consequences of the action.
133
+ */
134
+ export const DataLossWarning: Story = {
135
+ render: () => (
136
+ <AlertDialog>
137
+ <AlertDialogTrigger asChild>
138
+ <Button variant="outline">Discard Changes</Button>
139
+ </AlertDialogTrigger>
140
+ <AlertDialogContent>
141
+ <AlertDialogHeader>
142
+ <AlertDialogTitle>Discard unsaved changes?</AlertDialogTitle>
143
+ <AlertDialogDescription>
144
+ You have unsaved changes that will be lost. Are you sure you want
145
+ to discard them?
146
+ </AlertDialogDescription>
147
+ </AlertDialogHeader>
148
+ <AlertDialogFooter>
149
+ <AlertDialogCancel>Keep Editing</AlertDialogCancel>
150
+ <AlertDialogAction>Discard Changes</AlertDialogAction>
151
+ </AlertDialogFooter>
152
+ </AlertDialogContent>
153
+ </AlertDialog>
154
+ ),
155
+ }
156
+
157
+ /**
158
+ * Permission Request
159
+ *
160
+ * Alert dialog requesting user permission for sensitive operations.
161
+ * Action button uses default styling for non-destructive confirmations.
162
+ */
163
+ export const PermissionRequest: Story = {
164
+ render: () => (
165
+ <AlertDialog>
166
+ <AlertDialogTrigger asChild>
167
+ <Button>Request Access</Button>
168
+ </AlertDialogTrigger>
169
+ <AlertDialogContent>
170
+ <AlertDialogHeader>
171
+ <AlertDialogTitle>Allow access to your camera?</AlertDialogTitle>
172
+ <AlertDialogDescription>
173
+ This application needs access to your camera to capture photos.
174
+ You can revoke this permission at any time in settings.
175
+ </AlertDialogDescription>
176
+ </AlertDialogHeader>
177
+ <AlertDialogFooter>
178
+ <AlertDialogCancel>Deny</AlertDialogCancel>
179
+ <AlertDialogAction>Allow Access</AlertDialogAction>
180
+ </AlertDialogFooter>
181
+ </AlertDialogContent>
182
+ </AlertDialog>
183
+ ),
184
+ }
185
+
186
+ /**
187
+ * Multiple Consequences
188
+ *
189
+ * Alert dialog listing multiple consequences of an action.
190
+ * Uses a list to clearly communicate all impacts.
191
+ */
192
+ export const MultipleConsequences: Story = {
193
+ render: () => (
194
+ <AlertDialog>
195
+ <AlertDialogTrigger asChild>
196
+ <Button variant="destructive">Deactivate Account</Button>
197
+ </AlertDialogTrigger>
198
+ <AlertDialogContent>
199
+ <AlertDialogHeader>
200
+ <AlertDialogTitle>Deactivate your account?</AlertDialogTitle>
201
+ <AlertDialogDescription>
202
+ Deactivating your account will have the following effects:
203
+ </AlertDialogDescription>
204
+ </AlertDialogHeader>
205
+ <ul className="list-disc list-inside text-sm space-y-1 py-4">
206
+ <li>Your profile will no longer be visible</li>
207
+ <li>Active subscriptions will be cancelled</li>
208
+ <li>Saved content will be deleted after 30 days</li>
209
+ <li>You can reactivate within 30 days</li>
210
+ </ul>
211
+ <AlertDialogFooter>
212
+ <AlertDialogCancel>Cancel</AlertDialogCancel>
213
+ <AlertDialogAction className="bg-destructive text-destructive-foreground hover:bg-destructive/90">
214
+ Deactivate Account
215
+ </AlertDialogAction>
216
+ </AlertDialogFooter>
217
+ </AlertDialogContent>
218
+ </AlertDialog>
219
+ ),
220
+ }
221
+
222
+ /**
223
+ * Controlled AlertDialog
224
+ *
225
+ * Alert dialog with controlled open state using React state.
226
+ * Useful for programmatic control or async confirmation handling.
227
+ */
228
+ export const ControlledAlertDialog: Story = {
229
+ render: () => {
230
+ const [open, setOpen] = React.useState(false)
231
+ const [loading, setLoading] = React.useState(false)
232
+
233
+ const handleConfirm = async () => {
234
+ setLoading(true)
235
+ // Simulate async operation
236
+ await new Promise((resolve) => setTimeout(resolve, 1000))
237
+ setLoading(false)
238
+ setOpen(false)
239
+ }
240
+
241
+ return (
242
+ <>
243
+ <Button variant="destructive" onClick={() => setOpen(true)}>
244
+ Delete Item
245
+ </Button>
246
+ <AlertDialog open={open} onOpenChange={setOpen}>
247
+ <AlertDialogContent>
248
+ <AlertDialogHeader>
249
+ <AlertDialogTitle>Confirm deletion</AlertDialogTitle>
250
+ <AlertDialogDescription>
251
+ This action is permanent and cannot be undone.
252
+ </AlertDialogDescription>
253
+ </AlertDialogHeader>
254
+ <AlertDialogFooter>
255
+ <AlertDialogCancel disabled={loading}>Cancel</AlertDialogCancel>
256
+ <AlertDialogAction
257
+ onClick={(e) => {
258
+ e.preventDefault()
259
+ handleConfirm()
260
+ }}
261
+ disabled={loading}
262
+ >
263
+ {loading ? "Deleting..." : "Delete"}
264
+ </AlertDialogAction>
265
+ </AlertDialogFooter>
266
+ </AlertDialogContent>
267
+ </AlertDialog>
268
+ </>
269
+ )
270
+ },
271
+ }
272
+
273
+ /**
274
+ * Security Confirmation
275
+ *
276
+ * Alert dialog for critical security actions.
277
+ * Emphasizes the security implications of the action.
278
+ */
279
+ export const SecurityConfirmation: Story = {
280
+ render: () => (
281
+ <AlertDialog>
282
+ <AlertDialogTrigger asChild>
283
+ <Button variant="outline">Revoke API Key</Button>
284
+ </AlertDialogTrigger>
285
+ <AlertDialogContent>
286
+ <AlertDialogHeader>
287
+ <AlertDialogTitle>Revoke API key?</AlertDialogTitle>
288
+ <AlertDialogDescription>
289
+ This will immediately invalidate the API key. Any applications
290
+ using this key will lose access. Generate a new key if needed.
291
+ </AlertDialogDescription>
292
+ </AlertDialogHeader>
293
+ <AlertDialogFooter>
294
+ <AlertDialogCancel>Cancel</AlertDialogCancel>
295
+ <AlertDialogAction className="bg-destructive text-destructive-foreground hover:bg-destructive/90">
296
+ Revoke Key
297
+ </AlertDialogAction>
298
+ </AlertDialogFooter>
299
+ </AlertDialogContent>
300
+ </AlertDialog>
301
+ ),
302
+ }
303
+
304
+ /**
305
+ * Custom Button Labels
306
+ *
307
+ * Alert dialog with action-specific button labels instead of generic "Cancel/Confirm".
308
+ * Always use clear, descriptive action verbs.
309
+ */
310
+ export const CustomButtonLabels: Story = {
311
+ render: () => (
312
+ <AlertDialog>
313
+ <AlertDialogTrigger asChild>
314
+ <Button variant="outline">Leave Team</Button>
315
+ </AlertDialogTrigger>
316
+ <AlertDialogContent>
317
+ <AlertDialogHeader>
318
+ <AlertDialogTitle>Leave this team?</AlertDialogTitle>
319
+ <AlertDialogDescription>
320
+ You will lose access to all team projects and resources. A team
321
+ admin can re-invite you later if needed.
322
+ </AlertDialogDescription>
323
+ </AlertDialogHeader>
324
+ <AlertDialogFooter>
325
+ <AlertDialogCancel>Stay in Team</AlertDialogCancel>
326
+ <AlertDialogAction>Leave Team</AlertDialogAction>
327
+ </AlertDialogFooter>
328
+ </AlertDialogContent>
329
+ </AlertDialog>
330
+ ),
331
+ }
332
+
333
+ /**
334
+ * Dark Mode AlertDialog
335
+ *
336
+ * Alert dialog appearance in dark mode.
337
+ * All styles are theme-aware and maintain proper contrast in dark mode.
338
+ */
339
+ export const DarkMode: Story = {
340
+ parameters: {
341
+ backgrounds: { default: "dark" },
342
+ },
343
+ render: () => (
344
+ <div className="dark">
345
+ <AlertDialog>
346
+ <AlertDialogTrigger asChild>
347
+ <Button variant="destructive">Delete Account</Button>
348
+ </AlertDialogTrigger>
349
+ <AlertDialogContent>
350
+ <AlertDialogHeader>
351
+ <AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
352
+ <AlertDialogDescription>
353
+ This action cannot be undone. This will permanently delete your
354
+ account and remove your data from our servers.
355
+ </AlertDialogDescription>
356
+ </AlertDialogHeader>
357
+ <AlertDialogFooter>
358
+ <AlertDialogCancel>Cancel</AlertDialogCancel>
359
+ <AlertDialogAction className="bg-destructive text-destructive-foreground hover:bg-destructive/90">
360
+ Delete Account
361
+ </AlertDialogAction>
362
+ </AlertDialogFooter>
363
+ </AlertDialogContent>
364
+ </AlertDialog>
365
+ </div>
366
+ ),
367
+ }
@@ -0,0 +1,182 @@
1
+ import * as React from "react"
2
+ import {
3
+ AlertDialog as ShadcnAlertDialog,
4
+ AlertDialogAction,
5
+ AlertDialogCancel,
6
+ AlertDialogContent,
7
+ AlertDialogDescription,
8
+ AlertDialogFooter,
9
+ AlertDialogHeader,
10
+ AlertDialogOverlay,
11
+ AlertDialogPortal,
12
+ AlertDialogTitle,
13
+ AlertDialogTrigger,
14
+ } from "../../ui/alert-dialog"
15
+
16
+ /**
17
+ * AlertDialog Primitive
18
+ *
19
+ * A foundational alert dialog component for critical user confirmations and destructive actions.
20
+ * This primitive wraps shadcn/ui AlertDialog with extensibility for design system-specific
21
+ * enhancements.
22
+ *
23
+ * Built on Radix UI AlertDialog primitive with WCAG 2.1 Level AA compliance:
24
+ * - Focus trapping and restoration
25
+ * - Keyboard navigation (Escape to cancel)
26
+ * - Screen reader announcements with alert role
27
+ * - Forced interaction (no overlay dismiss by default)
28
+ * - Clear action/cancel distinction
29
+ *
30
+ * ## Key Differences from Dialog
31
+ * - AlertDialog is specifically for critical confirmations
32
+ * - Users must explicitly choose an action (Cancel or Action)
33
+ * - No close button in corner (forces explicit choice)
34
+ * - More restrictive interaction model
35
+ * - Semantic alert role for screen readers
36
+ *
37
+ * @example
38
+ * ```tsx
39
+ * <AlertDialog>
40
+ * <AlertDialogTrigger asChild>
41
+ * <Button variant="destructive">Delete Account</Button>
42
+ * </AlertDialogTrigger>
43
+ * <AlertDialogContent>
44
+ * <AlertDialogHeader>
45
+ * <AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
46
+ * <AlertDialogDescription>
47
+ * This action cannot be undone. This will permanently delete your
48
+ * account and remove your data from our servers.
49
+ * </AlertDialogDescription>
50
+ * </AlertDialogHeader>
51
+ * <AlertDialogFooter>
52
+ * <AlertDialogCancel>Cancel</AlertDialogCancel>
53
+ * <AlertDialogAction>Delete Account</AlertDialogAction>
54
+ * </AlertDialogFooter>
55
+ * </AlertDialogContent>
56
+ * </AlertDialog>
57
+ * ```
58
+ *
59
+ * @see https://ui.shadcn.com/docs/components/alert-dialog - shadcn/ui AlertDialog documentation
60
+ * @see https://www.radix-ui.com/primitives/docs/components/alert-dialog - Radix UI AlertDialog primitive
61
+ */
62
+
63
+ /**
64
+ * AlertDialog Root component props
65
+ * Controls the open state and alert behavior
66
+ */
67
+ export type AlertDialogProps = React.ComponentProps<typeof ShadcnAlertDialog>
68
+
69
+ /**
70
+ * AlertDialogContent component props
71
+ * Main content container for alert dialog
72
+ */
73
+ export type AlertDialogContentProps = React.ComponentProps<
74
+ typeof AlertDialogContent
75
+ >
76
+
77
+ /**
78
+ * AlertDialogTrigger component props
79
+ * Element that opens the alert dialog
80
+ */
81
+ export type AlertDialogTriggerProps = React.ComponentProps<
82
+ typeof AlertDialogTrigger
83
+ >
84
+
85
+ /**
86
+ * AlertDialogHeader component props
87
+ * Header section for title and description
88
+ */
89
+ export type AlertDialogHeaderProps = React.ComponentProps<
90
+ typeof AlertDialogHeader
91
+ >
92
+
93
+ /**
94
+ * AlertDialogFooter component props
95
+ * Footer section with cancel and action buttons
96
+ */
97
+ export type AlertDialogFooterProps = React.ComponentProps<
98
+ typeof AlertDialogFooter
99
+ >
100
+
101
+ /**
102
+ * AlertDialogTitle component props
103
+ * Accessible title for the alert dialog (required)
104
+ */
105
+ export type AlertDialogTitleProps = React.ComponentProps<
106
+ typeof AlertDialogTitle
107
+ >
108
+
109
+ /**
110
+ * AlertDialogDescription component props
111
+ * Accessible description for the alert dialog (required)
112
+ */
113
+ export type AlertDialogDescriptionProps = React.ComponentProps<
114
+ typeof AlertDialogDescription
115
+ >
116
+
117
+ /**
118
+ * AlertDialogAction component props
119
+ * Primary action button (typically destructive or confirming)
120
+ */
121
+ export type AlertDialogActionProps = React.ComponentProps<
122
+ typeof AlertDialogAction
123
+ >
124
+
125
+ /**
126
+ * AlertDialogCancel component props
127
+ * Cancel button to dismiss the alert
128
+ */
129
+ export type AlertDialogCancelProps = React.ComponentProps<
130
+ typeof AlertDialogCancel
131
+ >
132
+
133
+ /**
134
+ * AlertDialog component
135
+ *
136
+ * A modal dialog for critical user confirmations and destructive actions.
137
+ * Built on Radix UI AlertDialog primitive with strict interaction requirements.
138
+ *
139
+ * Features:
140
+ * - Focus trapping and restoration
141
+ * - Keyboard navigation (Escape to cancel)
142
+ * - Screen reader announcements with alert role
143
+ * - Forced interaction (no overlay dismiss)
144
+ * - Clear action/cancel distinction
145
+ * - Dark mode support
146
+ */
147
+ export const AlertDialog = React.forwardRef<
148
+ React.ElementRef<typeof ShadcnAlertDialog>,
149
+ AlertDialogProps
150
+ >((props, ref) => {
151
+ return <ShadcnAlertDialog {...props} />
152
+ })
153
+
154
+ AlertDialog.displayName = "AlertDialog"
155
+
156
+ /**
157
+ * Re-export all AlertDialog sub-components for composition
158
+ *
159
+ * These components should be used together to build complete alert dialog experiences:
160
+ * - AlertDialogTrigger: Opens the alert dialog
161
+ * - AlertDialogContent: Main content container
162
+ * - AlertDialogHeader: Header section with title and description
163
+ * - AlertDialogFooter: Footer section with cancel and action buttons
164
+ * - AlertDialogTitle: Accessible title (required for a11y)
165
+ * - AlertDialogDescription: Accessible description (required for a11y)
166
+ * - AlertDialogAction: Primary action button (closes dialog on click)
167
+ * - AlertDialogCancel: Cancel button (closes dialog on click)
168
+ * - AlertDialogPortal: Advanced portal customization (rarely needed)
169
+ * - AlertDialogOverlay: Advanced overlay customization (rarely needed)
170
+ */
171
+ export {
172
+ AlertDialogAction,
173
+ AlertDialogCancel,
174
+ AlertDialogContent,
175
+ AlertDialogDescription,
176
+ AlertDialogFooter,
177
+ AlertDialogHeader,
178
+ AlertDialogOverlay,
179
+ AlertDialogPortal,
180
+ AlertDialogTitle,
181
+ AlertDialogTrigger,
182
+ }
@@ -0,0 +1,25 @@
1
+ export {
2
+ AlertDialog,
3
+ AlertDialogAction,
4
+ AlertDialogCancel,
5
+ AlertDialogContent,
6
+ AlertDialogDescription,
7
+ AlertDialogFooter,
8
+ AlertDialogHeader,
9
+ AlertDialogOverlay,
10
+ AlertDialogPortal,
11
+ AlertDialogTitle,
12
+ AlertDialogTrigger,
13
+ } from "./AlertDialog"
14
+
15
+ export type {
16
+ AlertDialogProps,
17
+ AlertDialogContentProps,
18
+ AlertDialogTriggerProps,
19
+ AlertDialogHeaderProps,
20
+ AlertDialogFooterProps,
21
+ AlertDialogTitleProps,
22
+ AlertDialogDescriptionProps,
23
+ AlertDialogActionProps,
24
+ AlertDialogCancelProps,
25
+ } from "./AlertDialog"