torch-glare 2.5.6 → 2.6.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 (362) hide show
  1. package/README.md +4 -3
  2. package/dist/bin/index.js +9 -24
  3. package/dist/bin/index.js.map +1 -1
  4. package/dist/src/commands/add.d.ts +2 -2
  5. package/dist/src/commands/add.d.ts.map +1 -1
  6. package/dist/src/commands/add.js +4 -70
  7. package/dist/src/commands/add.js.map +1 -1
  8. package/dist/src/commands/hook.d.ts +5 -4
  9. package/dist/src/commands/hook.d.ts.map +1 -1
  10. package/dist/src/commands/hook.js +7 -75
  11. package/dist/src/commands/hook.js.map +1 -1
  12. package/dist/src/commands/init.js +1 -1
  13. package/dist/src/commands/init.js.map +1 -1
  14. package/dist/src/commands/layout.d.ts +5 -4
  15. package/dist/src/commands/layout.d.ts.map +1 -1
  16. package/dist/src/commands/layout.js +7 -75
  17. package/dist/src/commands/layout.js.map +1 -1
  18. package/dist/src/commands/provider.d.ts +5 -4
  19. package/dist/src/commands/provider.d.ts.map +1 -1
  20. package/dist/src/commands/provider.js +7 -75
  21. package/dist/src/commands/provider.js.map +1 -1
  22. package/dist/src/commands/update.d.ts.map +1 -1
  23. package/dist/src/commands/update.js +78 -43
  24. package/dist/src/commands/update.js.map +1 -1
  25. package/dist/src/commands/utils.d.ts +5 -4
  26. package/dist/src/commands/utils.d.ts.map +1 -1
  27. package/dist/src/commands/utils.js +7 -80
  28. package/dist/src/commands/utils.js.map +1 -1
  29. package/dist/src/shared/addFromRegistry.d.ts +16 -0
  30. package/dist/src/shared/addFromRegistry.d.ts.map +1 -0
  31. package/dist/src/shared/addFromRegistry.js +88 -0
  32. package/dist/src/shared/addFromRegistry.js.map +1 -0
  33. package/dist/src/shared/getInstallCommand.d.ts.map +1 -1
  34. package/dist/src/shared/getInstallCommand.js +5 -0
  35. package/dist/src/shared/getInstallCommand.js.map +1 -1
  36. package/dist/src/shared/installDependencies.d.ts +0 -10
  37. package/dist/src/shared/installDependencies.d.ts.map +1 -1
  38. package/dist/src/shared/installDependencies.js +0 -17
  39. package/dist/src/shared/installDependencies.js.map +1 -1
  40. package/dist/src/shared/installFromPlan.d.ts +7 -5
  41. package/dist/src/shared/installFromPlan.d.ts.map +1 -1
  42. package/dist/src/shared/installFromPlan.js +103 -36
  43. package/dist/src/shared/installFromPlan.js.map +1 -1
  44. package/dist/src/shared/loadRegistry.d.ts +12 -3
  45. package/dist/src/shared/loadRegistry.d.ts.map +1 -1
  46. package/dist/src/shared/loadRegistry.js +19 -20
  47. package/dist/src/shared/loadRegistry.js.map +1 -1
  48. package/dist/src/shared/registryClient.d.ts +19 -0
  49. package/dist/src/shared/registryClient.d.ts.map +1 -0
  50. package/dist/src/shared/registryClient.js +128 -0
  51. package/dist/src/shared/registryClient.js.map +1 -0
  52. package/dist/src/shared/resolveEntry.d.ts +10 -7
  53. package/dist/src/shared/resolveEntry.d.ts.map +1 -1
  54. package/dist/src/shared/resolveEntry.js +18 -13
  55. package/dist/src/shared/resolveEntry.js.map +1 -1
  56. package/dist/src/shared/suggestOtherCommand.d.ts +7 -1
  57. package/dist/src/shared/suggestOtherCommand.d.ts.map +1 -1
  58. package/dist/src/shared/suggestOtherCommand.js +29 -23
  59. package/dist/src/shared/suggestOtherCommand.js.map +1 -1
  60. package/dist/src/types/main.d.ts +31 -2
  61. package/dist/src/types/main.d.ts.map +1 -1
  62. package/package.json +6 -11
  63. package/apps/lib/components/ActionButton.tsx +0 -93
  64. package/apps/lib/components/ActionsGroup.tsx +0 -27
  65. package/apps/lib/components/AlertDialog.tsx +0 -204
  66. package/apps/lib/components/Avatar.tsx +0 -46
  67. package/apps/lib/components/Badge.tsx +0 -250
  68. package/apps/lib/components/BadgeField.tsx +0 -403
  69. package/apps/lib/components/Breadcrumb.tsx +0 -280
  70. package/apps/lib/components/Button.tsx +0 -325
  71. package/apps/lib/components/ButtonGroup.tsx +0 -190
  72. package/apps/lib/components/Calendar.tsx +0 -115
  73. package/apps/lib/components/Card.tsx +0 -95
  74. package/apps/lib/components/Checkbox.tsx +0 -42
  75. package/apps/lib/components/ColorPicker.tsx +0 -441
  76. package/apps/lib/components/ConclusionHeader.tsx +0 -148
  77. package/apps/lib/components/ContextMenu.tsx +0 -571
  78. package/apps/lib/components/CountBadge.tsx +0 -52
  79. package/apps/lib/components/DataTable.tsx +0 -213
  80. package/apps/lib/components/DataViews/badge.ts +0 -49
  81. package/apps/lib/components/DataViews/cell.tsx +0 -324
  82. package/apps/lib/components/DataViews/context.ts +0 -144
  83. package/apps/lib/components/DataViews/data-views.tsx +0 -395
  84. package/apps/lib/components/DataViews/filters/children.tsx +0 -98
  85. package/apps/lib/components/DataViews/filters/custom.tsx +0 -34
  86. package/apps/lib/components/DataViews/filters/filters.tsx +0 -157
  87. package/apps/lib/components/DataViews/filters/index.ts +0 -4
  88. package/apps/lib/components/DataViews/filters/labelled.tsx +0 -20
  89. package/apps/lib/components/DataViews/filters/presets.tsx +0 -65
  90. package/apps/lib/components/DataViews/filters/sync.tsx +0 -35
  91. package/apps/lib/components/DataViews/filters/values.ts +0 -173
  92. package/apps/lib/components/DataViews/header.tsx +0 -220
  93. package/apps/lib/components/DataViews/hooks/index.ts +0 -5
  94. package/apps/lib/components/DataViews/hooks/useActiveRow.ts +0 -22
  95. package/apps/lib/components/DataViews/hooks/useControllable.ts +0 -52
  96. package/apps/lib/components/DataViews/index.ts +0 -88
  97. package/apps/lib/components/DataViews/panel/columns.tsx +0 -153
  98. package/apps/lib/components/DataViews/panel/controls.tsx +0 -106
  99. package/apps/lib/components/DataViews/panel/index.ts +0 -3
  100. package/apps/lib/components/DataViews/panel/panel.tsx +0 -164
  101. package/apps/lib/components/DataViews/panel/saved-views.tsx +0 -67
  102. package/apps/lib/components/DataViews/panel/section.tsx +0 -81
  103. package/apps/lib/components/DataViews/panel/sort.tsx +0 -42
  104. package/apps/lib/components/DataViews/panel/tab.tsx +0 -31
  105. package/apps/lib/components/DataViews/slots.ts +0 -72
  106. package/apps/lib/components/DataViews/states.tsx +0 -73
  107. package/apps/lib/components/DataViews/types.ts +0 -510
  108. package/apps/lib/components/DataViews/views/board-view.tsx +0 -381
  109. package/apps/lib/components/DataViews/views/card-rows.tsx +0 -36
  110. package/apps/lib/components/DataViews/views/inbox-view.tsx +0 -260
  111. package/apps/lib/components/DataViews/views/pane-views.tsx +0 -196
  112. package/apps/lib/components/DataViews/views/table-view.tsx +0 -493
  113. package/apps/lib/components/DataViews/views/tree-view.tsx +0 -367
  114. package/apps/lib/components/DatePicker.tsx +0 -232
  115. package/apps/lib/components/Dialog.tsx +0 -116
  116. package/apps/lib/components/Divider.tsx +0 -28
  117. package/apps/lib/components/Drawer.tsx +0 -451
  118. package/apps/lib/components/DropdownMenu.tsx +0 -554
  119. package/apps/lib/components/FieldHint.tsx +0 -69
  120. package/apps/lib/components/Form.tsx +0 -182
  121. package/apps/lib/components/FormBuilder/context.ts +0 -85
  122. package/apps/lib/components/FormBuilder/field-kind.ts +0 -28
  123. package/apps/lib/components/FormBuilder/fields/ChoiceFields.tsx +0 -60
  124. package/apps/lib/components/FormBuilder/fields/ColorField.tsx +0 -59
  125. package/apps/lib/components/FormBuilder/fields/CustomField.tsx +0 -11
  126. package/apps/lib/components/FormBuilder/fields/DateField.tsx +0 -32
  127. package/apps/lib/components/FormBuilder/fields/FieldArray.tsx +0 -74
  128. package/apps/lib/components/FormBuilder/fields/FieldShell.tsx +0 -168
  129. package/apps/lib/components/FormBuilder/fields/FileField.tsx +0 -39
  130. package/apps/lib/components/FormBuilder/fields/OptionListFields.tsx +0 -132
  131. package/apps/lib/components/FormBuilder/fields/OtpField.tsx +0 -31
  132. package/apps/lib/components/FormBuilder/fields/PhoneField.tsx +0 -109
  133. package/apps/lib/components/FormBuilder/fields/RichTextEditorField.tsx +0 -31
  134. package/apps/lib/components/FormBuilder/fields/SelectField.tsx +0 -114
  135. package/apps/lib/components/FormBuilder/fields/SignatureField.tsx +0 -157
  136. package/apps/lib/components/FormBuilder/fields/SliderField.tsx +0 -67
  137. package/apps/lib/components/FormBuilder/fields/SwitchBoxField.tsx +0 -41
  138. package/apps/lib/components/FormBuilder/fields/TableField.tsx +0 -336
  139. package/apps/lib/components/FormBuilder/fields/TextField.tsx +0 -213
  140. package/apps/lib/components/FormBuilder/fields/TreeSelectField.tsx +0 -43
  141. package/apps/lib/components/FormBuilder/fields/countries.ts +0 -303
  142. package/apps/lib/components/FormBuilder/fields/index.ts +0 -25
  143. package/apps/lib/components/FormBuilder/form-builder.tsx +0 -198
  144. package/apps/lib/components/FormBuilder/index.ts +0 -31
  145. package/apps/lib/components/FormBuilder/numberFormat.ts +0 -16
  146. package/apps/lib/components/FormBuilder/submit.tsx +0 -67
  147. package/apps/lib/components/FormBuilder/types.ts +0 -316
  148. package/apps/lib/components/FormRenderer/FormDrawer.tsx +0 -250
  149. package/apps/lib/components/FormRenderer/detail.tsx +0 -256
  150. package/apps/lib/components/FormRenderer/form-renderer.tsx +0 -358
  151. package/apps/lib/components/FormRenderer/header.tsx +0 -88
  152. package/apps/lib/components/FormRenderer/index.ts +0 -17
  153. package/apps/lib/components/FormRenderer/notch-action.tsx +0 -64
  154. package/apps/lib/components/FormRenderer/section.tsx +0 -39
  155. package/apps/lib/components/FormRenderer/stepper.tsx +0 -393
  156. package/apps/lib/components/FormRenderer/types.ts +0 -115
  157. package/apps/lib/components/FormSummary.tsx +0 -282
  158. package/apps/lib/components/HeaderBar.tsx +0 -117
  159. package/apps/lib/components/ImageAttachment.tsx +0 -209
  160. package/apps/lib/components/InnerLabelField.tsx +0 -154
  161. package/apps/lib/components/Input.tsx +0 -224
  162. package/apps/lib/components/InputField.tsx +0 -147
  163. package/apps/lib/components/InputOTP.tsx +0 -84
  164. package/apps/lib/components/Label.tsx +0 -129
  165. package/apps/lib/components/LabelField.tsx +0 -76
  166. package/apps/lib/components/LabeledCheckBox.tsx +0 -51
  167. package/apps/lib/components/LabeledRadio.tsx +0 -51
  168. package/apps/lib/components/LinkButton.tsx +0 -94
  169. package/apps/lib/components/LoginButton.tsx +0 -51
  170. package/apps/lib/components/PasswordLevel.tsx +0 -58
  171. package/apps/lib/components/Popover.tsx +0 -312
  172. package/apps/lib/components/ProfileMenu.tsx +0 -85
  173. package/apps/lib/components/Radio.tsx +0 -59
  174. package/apps/lib/components/RadioCard.tsx +0 -50
  175. package/apps/lib/components/ScrollArea.tsx +0 -54
  176. package/apps/lib/components/SearchField.tsx +0 -62
  177. package/apps/lib/components/SearchableSelect.tsx +0 -318
  178. package/apps/lib/components/SearchableTable.tsx +0 -344
  179. package/apps/lib/components/SearchableTree.tsx +0 -485
  180. package/apps/lib/components/SearchableTreeDialog.tsx +0 -502
  181. package/apps/lib/components/SectionBlock.tsx +0 -168
  182. package/apps/lib/components/Select.tsx +0 -347
  183. package/apps/lib/components/SimpleSelect.tsx +0 -225
  184. package/apps/lib/components/Skeleton.tsx +0 -12
  185. package/apps/lib/components/SlideDatePicker.tsx +0 -255
  186. package/apps/lib/components/SpinLoading.tsx +0 -174
  187. package/apps/lib/components/Stepper.tsx +0 -480
  188. package/apps/lib/components/Switch.tsx +0 -82
  189. package/apps/lib/components/TabFormItem.tsx +0 -153
  190. package/apps/lib/components/TabSwitch.tsx +0 -172
  191. package/apps/lib/components/Table.tsx +0 -597
  192. package/apps/lib/components/TextEditor/ChartBlockTool.ts +0 -676
  193. package/apps/lib/components/TextEditor/RichTextField.tsx +0 -46
  194. package/apps/lib/components/TextEditor/TableDnDWrapper.ts +0 -462
  195. package/apps/lib/components/TextEditor/TextEditor.tsx +0 -1164
  196. package/apps/lib/components/TextEditor/TextEditorToolbar.tsx +0 -429
  197. package/apps/lib/components/TextEditor/editor-tools/AlignmentTune.ts +0 -70
  198. package/apps/lib/components/TextEditor/editor-tools/ColorInlineTool.ts +0 -50
  199. package/apps/lib/components/TextEditor/editor-tools/StrikethroughInlineTool.ts +0 -48
  200. package/apps/lib/components/TextEditor/editor-tools/inlineFormat.ts +0 -98
  201. package/apps/lib/components/TextEditor/editorjs.d.ts +0 -60
  202. package/apps/lib/components/TextEditor/index.ts +0 -7
  203. package/apps/lib/components/TextEditor/markdownParser.ts +0 -346
  204. package/apps/lib/components/Textarea.tsx +0 -117
  205. package/apps/lib/components/Timeline.tsx +0 -263
  206. package/apps/lib/components/Toast.tsx +0 -87
  207. package/apps/lib/components/Toggle.tsx +0 -125
  208. package/apps/lib/components/ToggleButton.tsx +0 -140
  209. package/apps/lib/components/Tooltip.tsx +0 -116
  210. package/apps/lib/components/TransparentLabel.tsx +0 -71
  211. package/apps/lib/components/TreeDropDown.tsx +0 -115
  212. package/apps/lib/components/TreeFolder/TreeFolder.tsx +0 -380
  213. package/apps/lib/components/TreeFolder/TreeFolderBreadcrumb.tsx +0 -75
  214. package/apps/lib/components/TreeFolder/TreeFolderRow.tsx +0 -354
  215. package/apps/lib/components/TreeFolder/TreeFolderStyles.tsx +0 -60
  216. package/apps/lib/components/TreeFolder/icons.tsx +0 -60
  217. package/apps/lib/components/TreeFolder/index.ts +0 -24
  218. package/apps/lib/components/TreeFolder/treeFolderUtils.ts +0 -109
  219. package/apps/lib/components/TreeFolder/types.ts +0 -77
  220. package/apps/lib/components/TreeFolder/useTreeFolderDnD.ts +0 -118
  221. package/apps/lib/hooks/useActiveTreeItem.ts +0 -61
  222. package/apps/lib/hooks/useClickOutside.ts +0 -27
  223. package/apps/lib/hooks/useDragDrop.tsx +0 -365
  224. package/apps/lib/hooks/useHtmlDir.ts +0 -31
  225. package/apps/lib/hooks/useInfiniteScroll.ts +0 -108
  226. package/apps/lib/hooks/useIsMobile.ts +0 -21
  227. package/apps/lib/hooks/useResize.ts +0 -67
  228. package/apps/lib/hooks/useTagSelection.ts +0 -300
  229. package/apps/lib/layouts/CNLayout.tsx +0 -372
  230. package/apps/lib/layouts/DataViewCard.tsx +0 -62
  231. package/apps/lib/layouts/FieldSection.tsx +0 -91
  232. package/apps/lib/layouts/TreeSubLayout.tsx +0 -173
  233. package/apps/lib/providers/ThemeProvider.tsx +0 -84
  234. package/apps/lib/registry.json +0 -1217
  235. package/apps/lib/tsconfig.json +0 -9
  236. package/apps/lib/tsconfig.tsbuildinfo +0 -1
  237. package/apps/lib/utils/cn.ts +0 -6
  238. package/apps/lib/utils/color.ts +0 -175
  239. package/apps/lib/utils/dataViews/path.ts +0 -67
  240. package/apps/lib/utils/dataViews/query.ts +0 -73
  241. package/apps/lib/utils/dataViews/types.ts +0 -187
  242. package/apps/lib/utils/dateFormat.ts +0 -108
  243. package/apps/lib/utils/resize.ts +0 -31
  244. package/apps/lib/utils/scroller.ts +0 -26
  245. package/apps/lib/utils/types.ts +0 -16
  246. package/docs/BLOCKS.md +0 -129
  247. package/docs/CHANGELOG-1.1.16.md +0 -108
  248. package/docs/Cover.png +0 -0
  249. package/docs/README.md +0 -215
  250. package/docs/components/action-button.md +0 -638
  251. package/docs/components/actions-group.md +0 -708
  252. package/docs/components/alert-dialog.md +0 -920
  253. package/docs/components/avatar.md +0 -709
  254. package/docs/components/badge-field.md +0 -738
  255. package/docs/components/badge.md +0 -301
  256. package/docs/components/breadcrumb.md +0 -930
  257. package/docs/components/button-group.md +0 -650
  258. package/docs/components/button.md +0 -639
  259. package/docs/components/calendar.md +0 -555
  260. package/docs/components/card.md +0 -622
  261. package/docs/components/chart-block-tool.md +0 -129
  262. package/docs/components/checkbox.md +0 -699
  263. package/docs/components/cn-layout.md +0 -854
  264. package/docs/components/color-picker.md +0 -101
  265. package/docs/components/conclusion-header.md +0 -80
  266. package/docs/components/context-menu.md +0 -483
  267. package/docs/components/count-badge.md +0 -560
  268. package/docs/components/data-table.md +0 -854
  269. package/docs/components/data-views/backend-response.md +0 -324
  270. package/docs/components/data-views/examples/a11y-rtl.md +0 -250
  271. package/docs/components/data-views/examples/api-orders-route.md +0 -130
  272. package/docs/components/data-views/examples/fields.md +0 -362
  273. package/docs/components/data-views/examples/filters.md +0 -307
  274. package/docs/components/data-views/examples/inbox-routing.md +0 -218
  275. package/docs/components/data-views/examples/index.md +0 -29
  276. package/docs/components/data-views/examples/overview.md +0 -244
  277. package/docs/components/data-views/examples/panel.md +0 -212
  278. package/docs/components/data-views/examples/scale.md +0 -231
  279. package/docs/components/data-views/examples/server-side.md +0 -210
  280. package/docs/components/data-views/examples/state.md +0 -250
  281. package/docs/components/data-views/examples/tree-custom.md +0 -388
  282. package/docs/components/data-views/examples/view-registry.md +0 -313
  283. package/docs/components/data-views/examples/views.md +0 -534
  284. package/docs/components/data-views/guide.md +0 -405
  285. package/docs/components/data-views/index.md +0 -1521
  286. package/docs/components/data-views/migration.md +0 -81
  287. package/docs/components/date-picker.md +0 -857
  288. package/docs/components/dialog.md +0 -929
  289. package/docs/components/divider.md +0 -766
  290. package/docs/components/drawer.md +0 -654
  291. package/docs/components/dropdown-menu.md +0 -668
  292. package/docs/components/field-hint.md +0 -898
  293. package/docs/components/field-section.md +0 -781
  294. package/docs/components/form-builder.md +0 -284
  295. package/docs/components/form-renderer.md +0 -396
  296. package/docs/components/form-summary.md +0 -138
  297. package/docs/components/form.md +0 -785
  298. package/docs/components/header-bar.md +0 -188
  299. package/docs/components/image-attachment.md +0 -906
  300. package/docs/components/inner-label-field.md +0 -819
  301. package/docs/components/input-field.md +0 -623
  302. package/docs/components/input-otp.md +0 -756
  303. package/docs/components/input.md +0 -634
  304. package/docs/components/label-field.md +0 -770
  305. package/docs/components/label.md +0 -761
  306. package/docs/components/labeled-check-box.md +0 -642
  307. package/docs/components/labeled-radio.md +0 -796
  308. package/docs/components/link-button.md +0 -685
  309. package/docs/components/login-button.md +0 -872
  310. package/docs/components/password-level.md +0 -803
  311. package/docs/components/popover.md +0 -649
  312. package/docs/components/profile-menu.md +0 -656
  313. package/docs/components/radio-card.md +0 -801
  314. package/docs/components/radio.md +0 -735
  315. package/docs/components/scroll-area.md +0 -691
  316. package/docs/components/search-field.md +0 -702
  317. package/docs/components/searchable-select.md +0 -368
  318. package/docs/components/searchable-table.md +0 -438
  319. package/docs/components/searchable-tree-dialog.md +0 -190
  320. package/docs/components/searchable-tree.md +0 -200
  321. package/docs/components/section-block.md +0 -483
  322. package/docs/components/select.md +0 -709
  323. package/docs/components/simple-select.md +0 -741
  324. package/docs/components/skeleton.md +0 -706
  325. package/docs/components/slide-date-picker.md +0 -837
  326. package/docs/components/spin-loading.md +0 -696
  327. package/docs/components/stepper.md +0 -316
  328. package/docs/components/switch.md +0 -770
  329. package/docs/components/tab-form-item.md +0 -773
  330. package/docs/components/tab-switch.md +0 -170
  331. package/docs/components/table-dnd-wrapper.md +0 -107
  332. package/docs/components/table.md +0 -1088
  333. package/docs/components/text-editor.md +0 -735
  334. package/docs/components/textarea.md +0 -681
  335. package/docs/components/timeline.md +0 -254
  336. package/docs/components/toast.md +0 -773
  337. package/docs/components/toggle-button.md +0 -643
  338. package/docs/components/toggle.md +0 -882
  339. package/docs/components/tooltip.md +0 -513
  340. package/docs/components/transparent-label.md +0 -721
  341. package/docs/components/tree-drop-down.md +0 -740
  342. package/docs/components/tree-folder.md +0 -110
  343. package/docs/components/tree-sub-layout.md +0 -707
  344. package/docs/explanation/architecture.md +0 -54
  345. package/docs/explanation/design-system.md +0 -52
  346. package/docs/how-to/form-and-list-recipes.md +0 -386
  347. package/docs/how-to/forms-with-form-builder.md +0 -472
  348. package/docs/how-to/guides.md +0 -1027
  349. package/docs/migration/changelog.md +0 -60
  350. package/docs/migration/form-builder-2.5.2.md +0 -113
  351. package/docs/reference/cli.md +0 -112
  352. package/docs/reference/components.md +0 -572
  353. package/docs/reference/hooks.md +0 -1523
  354. package/docs/reference/providers.md +0 -866
  355. package/docs/reference/tailwind-plugins.md +0 -942
  356. package/docs/reference/theme.md +0 -85
  357. package/docs/reference/types.md +0 -1016
  358. package/docs/reference/utilities.md +0 -726
  359. package/docs/tutorials/building-first-form.md +0 -846
  360. package/docs/tutorials/component-composition.md +0 -882
  361. package/docs/tutorials/getting-started.md +0 -302
  362. package/docs/tutorials/theming-basics.md +0 -785
@@ -1,920 +0,0 @@
1
- ---
2
- title: AlertDialog
3
- description: Confirmation and alert dialog component with status variants for important user decisions
4
- group: Overlays & Dialogs
5
- keywords: [alert-dialog, confirmation, modal, alert, warning, error, radix-ui]
6
- ---
7
-
8
- # AlertDialog
9
-
10
- > A specialized modal dialog for alerts and confirmations that require user acknowledgment or decision. Features status variants (info, success, warning, error) and integrated action buttons.
11
-
12
- ## Installation
13
-
14
- TORCH Glare is a copy-in library: the CLI copies this component's source into your project
15
- (you do **not** install it from the npm package). Run `init` once, then `add`:
16
-
17
- ```bash
18
- npx torch-glare@latest init
19
- npx torch-glare@latest add AlertDialog
20
- ```
21
-
22
- `add` also copies any components, hooks, and utilities that `AlertDialog` depends on.
23
-
24
- ## Import
25
-
26
- Import from your project's local path — the alias configured in `glare.json` (e.g. `@/*`):
27
-
28
- ```tsx
29
- import { AlertDialog } from "@/components/AlertDialog";
30
- ```
31
-
32
- ## Quick Examples
33
-
34
- ### Basic Alert
35
-
36
- ```typescript
37
- import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogTitle, AlertDialogDescription, AlertDialogAction } from "@/components/AlertDialog";
38
- import { Button } from "@/components/Button";
39
-
40
- function Example() {
41
- return (
42
- <AlertDialog>
43
- <AlertDialogTrigger asChild>
44
- <Button>Show Alert</Button>
45
- </AlertDialogTrigger>
46
- <AlertDialogContent>
47
- <AlertDialogTitle>Notification</AlertDialogTitle>
48
- <AlertDialogDescription>
49
- This is an important message that requires your attention.
50
- </AlertDialogDescription>
51
- <AlertDialogFooter>
52
- <AlertDialogAction>OK</AlertDialogAction>
53
- </AlertDialogFooter>
54
- </AlertDialogContent>
55
- </AlertDialog>
56
- )
57
- }
58
- ```
59
-
60
- ### Delete Confirmation (Error Variant)
61
-
62
- ```typescript
63
- import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogLabel, AlertDialogDescription, AlertDialogFooter, AlertDialogAction, AlertDialogCancel } from "@/components/AlertDialog";
64
- import { Button } from "@/components/Button";
65
-
66
- function DeleteConfirmation() {
67
- const handleDelete = () => {
68
- // Perform delete operation
69
- console.log('Deleted!')
70
- }
71
-
72
- return (
73
- <AlertDialog>
74
- <AlertDialogTrigger asChild>
75
- <Button variant="RedSecStyle">Delete Item</Button>
76
- </AlertDialogTrigger>
77
- <AlertDialogContent variant="error">
78
- <AlertDialogHeader>
79
- <AlertDialogLabel title="Delete Item" />
80
- </AlertDialogHeader>
81
- <AlertDialogDescription>
82
- This action cannot be undone. This will permanently delete the item
83
- and remove it from our servers.
84
- </AlertDialogDescription>
85
- <AlertDialogFooter>
86
- <AlertDialogCancel>
87
- <i className="ri-close-line" />
88
- </AlertDialogCancel>
89
- <AlertDialogAction
90
- variant="RedSecStyle"
91
- onClick={handleDelete}
92
- >
93
- Delete Permanently
94
- </AlertDialogAction>
95
- </AlertDialogFooter>
96
- </AlertDialogContent>
97
- </AlertDialog>
98
- )
99
- }
100
- ```
101
-
102
- ### Success Alert
103
-
104
- ```typescript
105
- import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogLabel, AlertDialogDescription, AlertDialogAction } from "@/components/AlertDialog";
106
-
107
- function SuccessAlert() {
108
- return (
109
- <AlertDialog>
110
- <AlertDialogTrigger asChild>
111
- <button>Complete Task</button>
112
- </AlertDialogTrigger>
113
- <AlertDialogContent variant="success">
114
- <AlertDialogLabel title="Task Completed" />
115
- <AlertDialogDescription>
116
- Your task has been successfully completed and saved.
117
- </AlertDialogDescription>
118
- <AlertDialogFooter>
119
- <AlertDialogAction variant="PrimeStyle">
120
- Continue
121
- </AlertDialogAction>
122
- </AlertDialogFooter>
123
- </AlertDialogContent>
124
- </AlertDialog>
125
- )
126
- }
127
- ```
128
-
129
- ### Warning Alert
130
-
131
- ```typescript
132
- import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogLabel, AlertDialogDescription, AlertDialogFooter, AlertDialogAction, AlertDialogCancel } from "@/components/AlertDialog";
133
-
134
- function WarningAlert() {
135
- return (
136
- <AlertDialog>
137
- <AlertDialogTrigger asChild>
138
- <button>Proceed with Caution</button>
139
- </AlertDialogTrigger>
140
- <AlertDialogContent variant="warning">
141
- <AlertDialogLabel title="Warning Unsaved Changes" />
142
- <AlertDialogDescription>
143
- You have unsaved changes. If you leave now, your changes will be lost.
144
- Are you sure you want to continue?
145
- </AlertDialogDescription>
146
- <AlertDialogFooter>
147
- <AlertDialogCancel>
148
- <i className="ri-close-line" />
149
- </AlertDialogCancel>
150
- <AlertDialogAction variant="PrimeStyle">
151
- Leave Anyway
152
- </AlertDialogAction>
153
- </AlertDialogFooter>
154
- </AlertDialogContent>
155
- </AlertDialog>
156
- )
157
- }
158
- ```
159
-
160
- ### Info Alert
161
-
162
- ```typescript
163
- import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogLabel, AlertDialogDescription, AlertDialogAction } from "@/components/AlertDialog";
164
-
165
- function InfoAlert() {
166
- return (
167
- <AlertDialog>
168
- <AlertDialogTrigger asChild>
169
- <button>View Information</button>
170
- </AlertDialogTrigger>
171
- <AlertDialogContent variant="info">
172
- <AlertDialogLabel title="Information System Update" />
173
- <AlertDialogDescription>
174
- A new system update is available. The update will be installed during
175
- your next restart. This may take a few minutes.
176
- </AlertDialogDescription>
177
- <AlertDialogFooter>
178
- <AlertDialogAction variant="PrimeStyle">
179
- Got It
180
- </AlertDialogAction>
181
- </AlertDialogFooter>
182
- </AlertDialogContent>
183
- </AlertDialog>
184
- )
185
- }
186
- ```
187
-
188
- ### Controlled State
189
-
190
- ```typescript
191
- import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogTitle, AlertDialogDescription, AlertDialogAction } from "@/components/AlertDialog";
192
- import { useState } from 'react'
193
-
194
- function ControlledAlert() {
195
- const [open, setOpen] = useState(false)
196
-
197
- const handleAction = () => {
198
- // Perform action
199
- setOpen(false)
200
- }
201
-
202
- return (
203
- <>
204
- <button onClick={() => setOpen(true)}>Show Alert</button>
205
- <AlertDialog open={open} onOpenChange={setOpen}>
206
- <AlertDialogContent variant="warning">
207
- <AlertDialogTitle>Confirm Action</AlertDialogTitle>
208
- <AlertDialogDescription>
209
- This is a controlled alert dialog.
210
- </AlertDialogDescription>
211
- <AlertDialogFooter>
212
- <AlertDialogCancel onClick={() => setOpen(false)}>
213
- Cancel
214
- </AlertDialogCancel>
215
- <AlertDialogAction onClick={handleAction}>
216
- Confirm
217
- </AlertDialogAction>
218
- </AlertDialogFooter>
219
- </AlertDialogContent>
220
- </AlertDialog>
221
- </>
222
- )
223
- }
224
- ```
225
-
226
- ### Account Deletion Flow
227
-
228
- ```typescript
229
- import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogLabel, AlertDialogDescription, AlertDialogFooter, AlertDialogAction, AlertDialogCancel } from "@/components/AlertDialog";
230
- import { Button } from "@/components/Button";
231
- import { Input } from "@/components/Input";
232
- import { useState } from 'react'
233
-
234
- function DeleteAccountDialog() {
235
- const [confirmText, setConfirmText] = useState('')
236
- const isValid = confirmText === 'DELETE'
237
-
238
- return (
239
- <AlertDialog>
240
- <AlertDialogTrigger asChild>
241
- <Button variant="RedSecStyle">Delete Account</Button>
242
- </AlertDialogTrigger>
243
- <AlertDialogContent variant="error">
244
- <AlertDialogLabel title="Delete Account" />
245
- <AlertDialogDescription>
246
- <div className="space-y-4">
247
- <p>This will permanently delete your account and all associated data.</p>
248
- <p>Type <strong>DELETE</strong> to confirm:</p>
249
- <Input
250
- value={confirmText}
251
- onChange={(e) => setConfirmText(e.target.value)}
252
- placeholder="Type DELETE"
253
- />
254
- </div>
255
- </AlertDialogDescription>
256
- <AlertDialogFooter>
257
- <AlertDialogCancel>
258
- <i className="ri-close-line" />
259
- </AlertDialogCancel>
260
- <AlertDialogAction
261
- variant="RedSecStyle"
262
- disabled={!isValid}
263
- >
264
- Delete My Account
265
- </AlertDialogAction>
266
- </AlertDialogFooter>
267
- </AlertDialogContent>
268
- </AlertDialog>
269
- )
270
- }
271
- ```
272
-
273
- ### Multi-Action Alert
274
-
275
- ```typescript
276
- import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogLabel, AlertDialogDescription, AlertDialogFooter, AlertDialogAction, AlertDialogCancel } from "@/components/AlertDialog";
277
-
278
- function MultiActionAlert() {
279
- const handleSave = () => console.log('Saved')
280
- const handleDiscard = () => console.log('Discarded')
281
-
282
- return (
283
- <AlertDialog>
284
- <AlertDialogTrigger asChild>
285
- <button>Close Document</button>
286
- </AlertDialogTrigger>
287
- <AlertDialogContent variant="warning">
288
- <AlertDialogLabel title="Unsaved Changes" />
289
- <AlertDialogDescription>
290
- Do you want to save your changes before closing?
291
- </AlertDialogDescription>
292
- <AlertDialogFooter className="flex gap-2">
293
- <AlertDialogCancel>
294
- Cancel
295
- </AlertDialogCancel>
296
- <AlertDialogAction variant="BluSecStyle" onClick={handleDiscard}>
297
- Don't Save
298
- </AlertDialogAction>
299
- <AlertDialogAction variant="PrimeStyle" onClick={handleSave}>
300
- Save Changes
301
- </AlertDialogAction>
302
- </AlertDialogFooter>
303
- </AlertDialogContent>
304
- </AlertDialog>
305
- )
306
- }
307
- ```
308
-
309
- ### With Loading State
310
-
311
- ```typescript
312
- import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogLabel, AlertDialogDescription, AlertDialogFooter, AlertDialogAction, AlertDialogCancel } from "@/components/AlertDialog";
313
- import { SpinLoading } from "@/components/SpinLoading";
314
- import { useState } from 'react'
315
-
316
- function AsyncAlert() {
317
- const [loading, setLoading] = useState(false)
318
-
319
- const handleConfirm = async () => {
320
- setLoading(true)
321
- await performAsyncAction()
322
- setLoading(false)
323
- }
324
-
325
- return (
326
- <AlertDialog>
327
- <AlertDialogTrigger asChild>
328
- <button>Sync Data</button>
329
- </AlertDialogTrigger>
330
- <AlertDialogContent>
331
- <AlertDialogLabel title="Sync Confirmation" />
332
- <AlertDialogDescription>
333
- {loading ? (
334
- <div className="flex items-center justify-center p-4">
335
- <SpinLoading />
336
- <span className="ml-2">Syncing...</span>
337
- </div>
338
- ) : (
339
- 'This will sync all your data with the server.'
340
- )}
341
- </AlertDialogDescription>
342
- <AlertDialogFooter>
343
- <AlertDialogCancel disabled={loading}>
344
- Cancel
345
- </AlertDialogCancel>
346
- <AlertDialogAction onClick={handleConfirm} disabled={loading}>
347
- {loading ? 'Syncing...' : 'Start Sync'}
348
- </AlertDialogAction>
349
- </AlertDialogFooter>
350
- </AlertDialogContent>
351
- </AlertDialog>
352
- )
353
- }
354
- ```
355
-
356
- ### Permission Request
357
-
358
- ```typescript
359
- import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogLabel, AlertDialogDescription, AlertDialogFooter, AlertDialogAction, AlertDialogCancel } from "@/components/AlertDialog";
360
-
361
- function PermissionAlert() {
362
- const handleAllow = () => {
363
- // Request permission
364
- navigator.mediaDevices.getUserMedia({ video: true })
365
- }
366
-
367
- return (
368
- <AlertDialog>
369
- <AlertDialogTrigger asChild>
370
- <button>Enable Camera</button>
371
- </AlertDialogTrigger>
372
- <AlertDialogContent variant="info">
373
- <AlertDialogLabel title="Camera Access Required" />
374
- <AlertDialogDescription>
375
- This app needs access to your camera to take photos. Your privacy is
376
- important to us and camera access can be revoked at any time.
377
- </AlertDialogDescription>
378
- <AlertDialogFooter>
379
- <AlertDialogCancel>
380
- Not Now
381
- </AlertDialogCancel>
382
- <AlertDialogAction variant="PrimeStyle" onClick={handleAllow}>
383
- Allow Camera Access
384
- </AlertDialogAction>
385
- </AlertDialogFooter>
386
- </AlertDialogContent>
387
- </AlertDialog>
388
- )
389
- }
390
- ```
391
-
392
- ## API Reference
393
-
394
- ### AlertDialog (Root)
395
-
396
- | Prop | Type | Default | Description |
397
- |------|------|---------|-------------|
398
- | `open` | `boolean` | - | Controlled open state |
399
- | `onOpenChange` | `(open: boolean) => void` | - | Callback when open state changes |
400
- | `defaultOpen` | `boolean` | `false` | Uncontrolled default open state |
401
-
402
- ### AlertDialogTrigger
403
-
404
- | Prop | Type | Default | Description |
405
- |------|------|---------|-------------|
406
- | `asChild` | `boolean` | `false` | Render trigger as child element |
407
-
408
- ### AlertDialogContent
409
-
410
- | Prop | Type | Default | Description |
411
- |------|------|---------|-------------|
412
- | `variant` | `'default' \| 'info' \| 'success' \| 'warning' \| 'error'` | `'default'` | Status variant for styling |
413
- | `className` | `string` | - | Additional CSS classes |
414
-
415
- ### AlertDialogHeader, AlertDialogFooter
416
-
417
- | Prop | Type | Default | Description |
418
- |------|------|---------|-------------|
419
- | `className` | `string` | - | Additional CSS classes |
420
-
421
- ### AlertDialogTitle
422
-
423
- | Prop | Type | Default | Description |
424
- |------|------|---------|-------------|
425
- | `className` | `string` | - | Additional CSS classes |
426
-
427
- ### AlertDialogLabel
428
-
429
- | Prop | Type | Default | Description |
430
- |------|------|---------|-------------|
431
- | `title` | `string` | Required | Title text with first word bolded |
432
- | `className` | `string` | - | Additional CSS classes |
433
-
434
- ### AlertDialogDescription
435
-
436
- | Prop | Type | Default | Description |
437
- |------|------|---------|-------------|
438
- | `className` | `string` | - | Additional CSS classes |
439
-
440
- ### AlertDialogAction
441
-
442
- | Prop | Type | Default | Description |
443
- |------|------|---------|-------------|
444
- | `size` | `'M' \| 'S' \| 'L' \| 'XL'` | `'M'` | Button size |
445
- | `variant` | `ButtonVariant` | `'BorderStyle'` | Button variant |
446
- | `buttonType` | `'button' \| 'icon'` | `'button'` | Button type |
447
- | `onClick` | `() => void` | - | Click handler |
448
-
449
- ### AlertDialogCancel
450
-
451
- | Prop | Type | Default | Description |
452
- |------|------|---------|-------------|
453
- | `size` | `'M' \| 'S' \| 'L' \| 'XL'` | `'M'` | Button size |
454
- | `variant` | `ButtonVariant` | `'RedSecStyle'` | Button variant |
455
- | `buttonType` | `'button' \| 'icon'` | `'icon'` | Button type |
456
-
457
- ## Known Limitations & Frontend Patterns
458
-
459
- ### Every AlertDialog subcomponent ships without panel/typography defaults — and worse than `Dialog`
460
-
461
- `AlertDialogContent` ships with `p-[12px]` (too tight), `AlertDialogHeader` with `flex justify-between` (instead of `flex-col` for stacked title+description), `AlertDialogFooter` with `flex-col-reverse sm:flex-row` (vertical-on-mobile), and `AlertDialogDescription` with the bizarre `bg-background-presentation-form-base border ... rounded-[8px] p-[24px_48px_48px_48px]` — a 48 px-padded bordered box wrapped around what should be a one-line subtitle.
462
-
463
- **Production-tested override** — patch `AlertDialog.tsx` once after `npx torch-glare add AlertDialog`. Same surface-token corrections as `Dialog`: use `bg-background-presentation-body-primary` and `text-content-presentation-global-*`, never `*-system-*` and never `form-base`.
464
-
465
- ```tsx
466
- "use client";
467
-
468
- import * as React from "react";
469
- import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
470
- import { cn } from "@/utils/cn";
471
-
472
- const AlertDialog = AlertDialogPrimitive.Root;
473
- const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
474
- const AlertDialogPortal = AlertDialogPrimitive.Portal;
475
-
476
- const AlertDialogOverlay = React.forwardRef<
477
- React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
478
- React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>
479
- >(({ className, ...props }, ref) => (
480
- <AlertDialogPrimitive.Overlay
481
- ref={ref}
482
- className={cn(
483
- "fixed inset-0 z-50 bg-black/60",
484
- "data-[state=open]:animate-in data-[state=closed]:animate-out",
485
- "data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
486
- className,
487
- )}
488
- {...props}
489
- />
490
- ));
491
- AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
492
-
493
- const AlertDialogContent = React.forwardRef<
494
- React.ElementRef<typeof AlertDialogPrimitive.Content>,
495
- React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>
496
- >(({ className, ...props }, ref) => (
497
- <AlertDialogPortal>
498
- <AlertDialogOverlay />
499
- <AlertDialogPrimitive.Content
500
- ref={ref}
501
- className={cn(
502
- "fixed left-[50%] top-[50%] z-50 translate-x-[-50%] translate-y-[-50%]",
503
- "flex flex-col items-stretch justify-start",
504
- "w-[92vw] sm:max-w-md",
505
- "bg-background-presentation-body-primary",
506
- "border border-border-presentation-global-primary",
507
- "rounded-xl shadow-lg",
508
- "p-0 gap-0 overflow-hidden",
509
- "duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out",
510
- className,
511
- )}
512
- {...props}
513
- />
514
- </AlertDialogPortal>
515
- ));
516
- AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
517
-
518
- const AlertDialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
519
- <div
520
- className={cn("flex flex-col space-y-1.5 text-left px-6 pt-5 pb-2", className)}
521
- {...props}
522
- />
523
- );
524
- AlertDialogHeader.displayName = "AlertDialogHeader";
525
-
526
- const AlertDialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
527
- <div
528
- className={cn("flex flex-row justify-end gap-2 px-6 py-4", className)}
529
- {...props}
530
- />
531
- );
532
- AlertDialogFooter.displayName = "AlertDialogFooter";
533
-
534
- const AlertDialogTitle = React.forwardRef<
535
- React.ElementRef<typeof AlertDialogPrimitive.Title>,
536
- React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>
537
- >(({ className, ...props }, ref) => (
538
- <AlertDialogPrimitive.Title
539
- ref={ref}
540
- className={cn(
541
- "typography-headers-small-semibold text-content-presentation-global-primary",
542
- className,
543
- )}
544
- {...props}
545
- />
546
- ));
547
- AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
548
-
549
- const AlertDialogDescription = React.forwardRef<
550
- React.ElementRef<typeof AlertDialogPrimitive.Description>,
551
- React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description>
552
- >(({ className, ...props }, ref) => (
553
- <AlertDialogPrimitive.Description
554
- ref={ref}
555
- className={cn(
556
- "typography-body-small-regular text-content-presentation-global-secondary px-6 pb-2",
557
- className,
558
- )}
559
- {...props}
560
- />
561
- ));
562
- AlertDialogDescription.displayName = AlertDialogPrimitive.Description.displayName;
563
-
564
- const AlertDialogAction = AlertDialogPrimitive.Action;
565
- const AlertDialogCancel = AlertDialogPrimitive.Cancel;
566
-
567
- export {
568
- AlertDialog,
569
- AlertDialogTrigger,
570
- AlertDialogPortal,
571
- AlertDialogOverlay,
572
- AlertDialogContent,
573
- AlertDialogHeader,
574
- AlertDialogFooter,
575
- AlertDialogTitle,
576
- AlertDialogDescription,
577
- AlertDialogAction,
578
- AlertDialogCancel,
579
- };
580
- ```
581
-
582
- Critical default decisions:
583
-
584
- - **Drop the bordered box on `AlertDialogDescription`.** The shipped default wraps the description in a 48 px-padded bordered box, which produces a visually heavy nested panel. Description is a one-line subtitle — same typography pattern as `DialogDescription`.
585
- - **`AlertDialogHeader` → `flex flex-col` (NOT `flex justify-between`)** so title and description stack with proper rhythm.
586
- - **`AlertDialogFooter` → `flex-row justify-end`** on all viewports, no `flex-col-reverse sm:flex-row` weirdness.
587
- - **`AlertDialogDescription` carries `px-6 pb-2`** since alert dialogs typically don't have a separate body section between header and footer.
588
- - Surface and text tokens are **identical to `Dialog`** — `bg-background-presentation-body-primary` + `text-content-presentation-global-primary` + `text-content-presentation-global-secondary`. Never `*-system-*`. Never `form-base`. Never `action-secondary`.
589
-
590
- ### Standard usage after the override
591
-
592
- Once the patches above are in place, every consumer renders correctly with bare components:
593
-
594
- ```tsx
595
- <AlertDialog open={open} onOpenChange={setOpen}>
596
- <AlertDialogContent>
597
- <AlertDialogHeader>
598
- <AlertDialogTitle>Delete this template?</AlertDialogTitle>
599
- <AlertDialogDescription>
600
- This action cannot be undone. The template will be permanently removed.
601
- </AlertDialogDescription>
602
- </AlertDialogHeader>
603
- <AlertDialogFooter>
604
- <AlertDialogCancel asChild>
605
- <Button type="button" variant="BorderStyle" size="M">Cancel</Button>
606
- </AlertDialogCancel>
607
- <AlertDialogAction asChild>
608
- <Button type="button" variant="RedColStyle" size="M" onClick={handleDelete}>
609
- Delete
610
- </Button>
611
- </AlertDialogAction>
612
- </AlertDialogFooter>
613
- </AlertDialogContent>
614
- </AlertDialog>
615
- ```
616
-
617
- ## Variants
618
-
619
- ### Default Variant
620
- - Neutral gray styling
621
- - For general confirmations
622
-
623
- ### Info Variant
624
- - Blue accent
625
- - For informational messages
626
- - Use when providing information that doesn't require critical action
627
-
628
- ### Success Variant
629
- - Green accent
630
- - For success confirmations
631
- - Use after successful operations
632
-
633
- ### Warning Variant
634
- - Yellow/orange accent
635
- - For cautionary messages
636
- - Use before potentially risky actions
637
-
638
- ### Error/Destructive Variant
639
- - Red accent
640
- - For destructive actions
641
- - Use for delete, remove, or permanent changes
642
-
643
- ## TypeScript
644
-
645
- ### Full Type Definitions
646
-
647
- ```typescript
648
- import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog'
649
- import { ButtonVariant } from "@/utils/types";
650
-
651
- // Root component
652
- interface AlertDialogProps {
653
- open?: boolean
654
- onOpenChange?: (open: boolean) => void
655
- defaultOpen?: boolean
656
- children: React.ReactNode
657
- }
658
-
659
- export const AlertDialog: React.FC<AlertDialogProps>
660
-
661
- // Content component
662
- interface AlertDialogContentProps
663
- extends React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content> {
664
- variant?: 'info' | 'success' | 'warning' | 'error' | 'default'
665
- }
666
-
667
- export const AlertDialogContent: React.ForwardRefExoticComponent<AlertDialogContentProps>
668
-
669
- // Label component (special title with first word bolded)
670
- interface AlertDialogLabelProps {
671
- title: string
672
- className?: string
673
- }
674
-
675
- export const AlertDialogLabel: React.ForwardRefExoticComponent<AlertDialogLabelProps>
676
-
677
- // Action buttons
678
- interface AlertDialogActionProps
679
- extends React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action> {
680
- size?: 'M' | 'S' | 'L' | 'XL'
681
- variant?: ButtonVariant
682
- buttonType?: 'button' | 'icon'
683
- }
684
-
685
- export const AlertDialogAction: React.ForwardRefExoticComponent<AlertDialogActionProps>
686
- export const AlertDialogCancel: React.ForwardRefExoticComponent<AlertDialogActionProps>
687
- ```
688
-
689
- ## Common Patterns
690
-
691
- ### useAlertDialog Hook
692
-
693
- ```typescript
694
- import { AlertDialog, AlertDialogContent, AlertDialogLabel, AlertDialogDescription, AlertDialogFooter, AlertDialogAction, AlertDialogCancel } from "@/components/AlertDialog";
695
- import { useState } from 'react'
696
-
697
- function useAlertDialog() {
698
- const [open, setOpen] = useState(false)
699
- const [config, setConfig] = useState<{
700
- title: string
701
- description: string
702
- variant?: 'info' | 'success' | 'warning' | 'error'
703
- onConfirm: () => void
704
- } | null>(null)
705
-
706
- const show = (newConfig: typeof config) => {
707
- setConfig(newConfig)
708
- setOpen(true)
709
- }
710
-
711
- const AlertDialogComponent = config && (
712
- <AlertDialog open={open} onOpenChange={setOpen}>
713
- <AlertDialogContent variant={config.variant}>
714
- <AlertDialogLabel title={config.title} />
715
- <AlertDialogDescription>{config.description}</AlertDialogDescription>
716
- <AlertDialogFooter>
717
- <AlertDialogCancel onClick={() => setOpen(false)}>
718
- Cancel
719
- </AlertDialogCancel>
720
- <AlertDialogAction
721
- onClick={() => {
722
- config.onConfirm()
723
- setOpen(false)
724
- }}
725
- >
726
- Confirm
727
- </AlertDialogAction>
728
- </AlertDialogFooter>
729
- </AlertDialogContent>
730
- </AlertDialog>
731
- )
732
-
733
- return { show, AlertDialogComponent }
734
- }
735
-
736
- // Usage
737
- function App() {
738
- const { show, AlertDialogComponent } = useAlertDialog()
739
-
740
- const handleDelete = () => {
741
- show({
742
- title: 'Delete Item',
743
- description: 'Are you sure?',
744
- variant: 'error',
745
- onConfirm: () => console.log('Deleted'),
746
- })
747
- }
748
-
749
- return (
750
- <>
751
- <button onClick={handleDelete}>Delete</button>
752
- {AlertDialogComponent}
753
- </>
754
- )
755
- }
756
- ```
757
-
758
- ## Testing
759
-
760
- ### Unit Test Example
761
-
762
- ```typescript
763
- import { render, screen, fireEvent } from '@testing-library/react'
764
- import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogTitle, AlertDialogAction } from "@/components/AlertDialog";
765
-
766
- describe('AlertDialog', () => {
767
- it('renders with correct variant', () => {
768
- render(
769
- <AlertDialog defaultOpen>
770
- <AlertDialogContent variant="error">
771
- <AlertDialogTitle>Error</AlertDialogTitle>
772
- </AlertDialogContent>
773
- </AlertDialog>
774
- )
775
-
776
- // AlertDialogContent applies the variant as StatusTextStyle classes
777
- // (it does not set a data-variant attribute).
778
- const content = screen.getByRole('alertdialog')
779
- expect(content).toHaveClass('[&_strong]:text-content-presentation-state-negative')
780
- })
781
-
782
- it('calls action handler', () => {
783
- const handleAction = jest.fn()
784
-
785
- render(
786
- <AlertDialog defaultOpen>
787
- <AlertDialogContent>
788
- <AlertDialogTitle>Confirm</AlertDialogTitle>
789
- <AlertDialogAction onClick={handleAction}>OK</AlertDialogAction>
790
- </AlertDialogContent>
791
- </AlertDialog>
792
- )
793
-
794
- fireEvent.click(screen.getByText('OK'))
795
- expect(handleAction).toHaveBeenCalled()
796
- })
797
- })
798
- ```
799
-
800
- ## Accessibility
801
-
802
- - **Role**: Automatically has `role="alertdialog"`
803
- - **Keyboard Support**:
804
- - Escape: Cancel/close
805
- - Tab: Navigate between actions
806
- - Enter/Space: Activate focused action
807
- - **ARIA Attributes**:
808
- - `aria-labelledby` links to title
809
- - `aria-describedby` links to description
810
- - `aria-modal="true"`
811
- - **Focus Management**:
812
- - Focus trapped within alert
813
- - Cancel action focused by default
814
- - Focus returned to trigger on close
815
-
816
- ### Best Practices
817
-
818
- ```typescript
819
- // Always provide both title and description
820
- <AlertDialogContent>
821
- <AlertDialogTitle>Required Title</AlertDialogTitle>
822
- <AlertDialogDescription>
823
- Clear explanation of what will happen
824
- </AlertDialogDescription>
825
- </AlertDialogContent>
826
-
827
- // Use appropriate variant for context
828
- <AlertDialogContent variant="error"> {/* For destructive actions */}
829
-
830
- // Provide clear action labels
831
- <AlertDialogAction>Delete Permanently</AlertDialogAction> {/* Not just "OK" */}
832
- ```
833
-
834
- ## Performance
835
-
836
- | Metric | Value |
837
- |--------|-------|
838
- | Bundle size (minified) | ~10kb |
839
- | Bundle size (gzipped) | ~4kb |
840
- | Dependencies | @radix-ui/react-alert-dialog (~14kb) |
841
- | First render | <15ms |
842
- | Animation duration | 200ms |
843
- | Tree-shakeable | ✅ |
844
-
845
- ## Migration from Dialog
846
-
847
- ```diff
848
- - import { Dialog, DialogTrigger, DialogContent } from "@/components/Dialog";
849
- + import { AlertDialog, AlertDialogTrigger, AlertDialogContent } from "@/components/AlertDialog";
850
-
851
- - <Dialog>
852
- - <DialogTrigger>Delete</DialogTrigger>
853
- - <DialogContent>
854
- - <DialogTitle>Confirm</DialogTitle>
855
- - </DialogContent>
856
- - </Dialog>
857
-
858
- + <AlertDialog>
859
- + <AlertDialogTrigger>Delete</AlertDialogTrigger>
860
- + <AlertDialogContent variant="error">
861
- + <AlertDialogTitle>Confirm Deletion</AlertDialogTitle>
862
- + <AlertDialogFooter>
863
- + <AlertDialogCancel>Cancel</AlertDialogCancel>
864
- + <AlertDialogAction>Delete</AlertDialogAction>
865
- + </AlertDialogFooter>
866
- + </AlertDialogContent>
867
- + </AlertDialog>
868
- ```
869
-
870
- ## Best Practices
871
-
872
- 1. **Use appropriate variant**: Match variant to action severity
873
- ```typescript
874
- <AlertDialogContent variant="error"> {/* For delete */}
875
- <AlertDialogContent variant="warning"> {/* For unsaved changes */}
876
- ```
877
-
878
- 2. **Provide clear descriptions**: Explain consequences
879
- ```typescript
880
- <AlertDialogDescription>
881
- This will permanently delete 5 items and cannot be undone.
882
- </AlertDialogDescription>
883
- ```
884
-
885
- 3. **Use AlertDialogLabel for emphasis**: First word is automatically bolded
886
- ```typescript
887
- <AlertDialogLabel title="Delete Permanently" />
888
- {/* Renders: <strong>Delete</strong> Permanently */}
889
- ```
890
-
891
- 4. **Distinguish action buttons**: Make destructive action clear
892
- ```typescript
893
- <AlertDialogCancel>Cancel</AlertDialogCancel>
894
- <AlertDialogAction variant="RedSecStyle">Delete</AlertDialogAction>
895
- ```
896
-
897
- 5. **Don't overuse**: Reserve for important decisions only
898
- ```typescript
899
- // Good: Delete, logout, discard changes
900
- // Bad: Every form submission, navigation
901
- ```
902
-
903
- 6. **Handle async actions**: Show loading state
904
- ```typescript
905
- <AlertDialogAction disabled={loading}>
906
- {loading ? 'Processing...' : 'Confirm'}
907
- </AlertDialogAction>
908
- ```
909
-
910
- 7. **Prevent accidental actions**: Add confirmation text input for critical operations
911
- ```typescript
912
- const isValid = confirmText === 'DELETE'
913
- <AlertDialogAction disabled={!isValid}>
914
- ```
915
-
916
- ## Related Components
917
-
918
- - [Dialog](./dialog.md) - General purpose modal dialog
919
- - [Toast](./toast.md) - Non-blocking notifications
920
- - [Button](./button.md) - Used for action buttons