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,1016 +0,0 @@
1
- ---
2
- title: TypeScript Types Reference
3
- description: Complete reference of TypeScript types and interfaces used in TORCH Glare Components Library.
4
- category: Reference
5
- tags: [typescript, types, interfaces, type-safety]
6
- related:
7
- - Component API Index
8
- - Utilities Reference
9
- ---
10
-
11
- # TypeScript Types Reference
12
-
13
- Complete catalog of TypeScript types, interfaces, and type utilities used throughout TORCH Glare.
14
-
15
- ## Table of Contents
16
-
17
- - [Core Types](#core-types)
18
- - [Component Props Types](#component-props-types)
19
- - [Theme Types](#theme-types)
20
- - [Form Types](#form-types)
21
- - [Layout Types](#layout-types)
22
- - [Data Display Types](#data-display-types)
23
- - [Utility Types](#utility-types)
24
- - [Type Guards](#type-guards)
25
-
26
- ---
27
-
28
- ## Core Types
29
-
30
- ### Themes
31
-
32
- Theme variant type used across all components.
33
-
34
- ```typescript
35
- export type Themes = "dark" | "light" | "default";
36
- ```
37
-
38
- **Usage:**
39
- ```typescript
40
- import type { Themes } from "@/utils/types";
41
-
42
- interface MyComponentProps {
43
- theme?: Themes;
44
- }
45
- ```
46
-
47
- **Values:**
48
- - `"light"` - Light theme
49
- - `"dark"` - Dark theme
50
- - `"default"` - System default (follows `prefers-color-scheme`)
51
-
52
- ---
53
-
54
- ## Component Props Types
55
-
56
- ### Button Types
57
-
58
- #### ButtonVariant
59
-
60
- ```typescript
61
- export type ButtonVariant =
62
- | "PrimeStyle" // Primary action
63
- | "BluSecStyle" // Blue secondary
64
- | "YelSecStyle" // Yellow secondary
65
- | "RedSecStyle" // Red secondary
66
- | "BorderStyle" // Outlined
67
- | "PrimeContStyle" // Primary contrast
68
- | "BluContStyle" // Blue contrast
69
- | "RedContStyle"; // Red contrast
70
- ```
71
-
72
- #### ButtonSize
73
-
74
- ```typescript
75
- type ButtonSize = "XS" | "S" | "M" | "L" | "XL";
76
- ```
77
-
78
- #### ButtonType
79
-
80
- ```typescript
81
- type ButtonType = "button" | "icon" | "text";
82
- ```
83
-
84
- #### ButtonProps
85
-
86
- ```typescript
87
- interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
88
- variant?: ButtonVariant;
89
- size?: ButtonSize;
90
- theme?: Themes;
91
- buttonType?: ButtonType;
92
- disabled?: boolean;
93
- className?: string;
94
- children?: React.ReactNode;
95
- }
96
- ```
97
-
98
- ### Input Types
99
-
100
- #### InputProps
101
-
102
- ```typescript
103
- interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
104
- theme?: Themes;
105
- errorMessage?: string;
106
- leftIcon?: React.ReactNode;
107
- rightIcon?: React.ReactNode;
108
- className?: string;
109
- }
110
- ```
111
-
112
- #### InputFieldProps
113
-
114
- ```typescript
115
- interface InputFieldProps extends InputProps {
116
- label?: string;
117
- helperText?: string;
118
- requiredLabel?: string;
119
- secondaryLabel?: string;
120
- }
121
- ```
122
-
123
- #### TextareaProps
124
-
125
- ```typescript
126
- interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {
127
- theme?: Themes;
128
- errorMessage?: string;
129
- resize?: boolean;
130
- maxLength?: number;
131
- }
132
- ```
133
-
134
- ### Select Types
135
-
136
- #### SelectOption
137
-
138
- ```typescript
139
- interface SelectOption {
140
- value: string;
141
- label: string;
142
- disabled?: boolean;
143
- icon?: React.ReactNode;
144
- }
145
- ```
146
-
147
- #### SelectProps
148
-
149
- ```typescript
150
- interface SelectProps {
151
- value?: string;
152
- onValueChange?: (value: string) => void;
153
- options?: SelectOption[];
154
- placeholder?: string;
155
- searchable?: boolean;
156
- disabled?: boolean;
157
- theme?: Themes;
158
- }
159
- ```
160
-
161
- ### Checkbox & Radio Types
162
-
163
- #### CheckboxProps
164
-
165
- ```typescript
166
- interface CheckboxProps {
167
- checked?: boolean;
168
- indeterminate?: boolean;
169
- onCheckedChange?: (checked: boolean) => void;
170
- disabled?: boolean;
171
- theme?: Themes;
172
- className?: string;
173
- }
174
- ```
175
-
176
- #### RadioProps
177
-
178
- ```typescript
179
- interface RadioProps {
180
- value: string;
181
- checked?: boolean;
182
- name?: string;
183
- disabled?: boolean;
184
- theme?: Themes;
185
- onChange?: (value: string) => void;
186
- }
187
- ```
188
-
189
- #### LabeledCheckBoxProps
190
-
191
- ```typescript
192
- interface LabeledCheckBoxProps extends CheckboxProps {
193
- label: string;
194
- description?: string;
195
- }
196
- ```
197
-
198
- ### Switch Types
199
-
200
- #### SwitchProps
201
-
202
- ```typescript
203
- interface SwitchProps {
204
- checked?: boolean;
205
- onCheckedChange?: (checked: boolean) => void;
206
- disabled?: boolean;
207
- theme?: Themes;
208
- className?: string;
209
- }
210
- ```
211
-
212
- ---
213
-
214
- ## Theme Types
215
-
216
- ### ThemeProviderProps
217
-
218
- ```typescript
219
- interface ThemeProviderProps {
220
- children: ReactNode;
221
- defaultTheme?: "light" | "dark" | "default";
222
- defaultThemeMode?: "CSS" | "TORCH";
223
- }
224
- ```
225
-
226
- ### ThemeContext
227
-
228
- ```typescript
229
- interface ThemeContext {
230
- theme: "light" | "dark" | "default";
231
- themeMode: "CSS" | "TORCH";
232
- updateTheme: (theme: "light" | "dark" | "default") => void;
233
- updateMode: (themeMode: "CSS" | "TORCH") => void;
234
- }
235
- ```
236
-
237
- ### useTheme Return Type
238
-
239
- ```typescript
240
- function useTheme(): {
241
- theme: "light" | "dark" | "default";
242
- themeMode: "CSS" | "TORCH";
243
- updateTheme: (theme: "light" | "dark" | "default") => void;
244
- updateMode: (themeMode: "CSS" | "TORCH") => void;
245
- }
246
- ```
247
-
248
- ---
249
-
250
- ## Form Types
251
-
252
- ### Form Validation Types
253
-
254
- #### ValidationRule
255
-
256
- ```typescript
257
- type ValidationRule<T> = (value: T) => string | undefined;
258
- ```
259
-
260
- #### ValidationRules
261
-
262
- ```typescript
263
- type ValidationRules<T> = {
264
- [K in keyof T]?: Array<ValidationRule<T[K]>>;
265
- };
266
- ```
267
-
268
- #### FormErrors
269
-
270
- ```typescript
271
- type FormErrors<T> = Partial<Record<keyof T, string>>;
272
- ```
273
-
274
- #### FormTouched
275
-
276
- ```typescript
277
- type FormTouched<T> = Partial<Record<keyof T, boolean>>;
278
- ```
279
-
280
- ### Form Hook Return Type
281
-
282
- ```typescript
283
- interface UseFormValidation<T> {
284
- values: T;
285
- errors: FormErrors<T>;
286
- touched: FormTouched<T>;
287
- handleChange: (field: keyof T) => (e: React.ChangeEvent<HTMLInputElement>) => void;
288
- handleBlur: (field: keyof T) => () => void;
289
- validateForm: () => boolean;
290
- reset: () => void;
291
- }
292
- ```
293
-
294
- ### Field Types
295
-
296
- #### FieldHintState
297
-
298
- ```typescript
299
- type FieldHintState = "info" | "warning" | "error" | "success";
300
- ```
301
-
302
- #### FieldHintProps
303
-
304
- ```typescript
305
- interface FieldHintProps {
306
- label: string;
307
- state: FieldHintState;
308
- icon?: React.ReactNode;
309
- theme?: Themes;
310
- className?: string;
311
- }
312
- ```
313
-
314
- ---
315
-
316
- ## Layout Types
317
-
318
- ### Layout Props
319
-
320
- #### CardProps
321
-
322
- ```typescript
323
- interface CardProps extends React.HTMLAttributes<HTMLDivElement> {
324
- variant?: "default" | "outlined" | "elevated";
325
- padding?: "none" | "small" | "medium" | "large";
326
- shadow?: boolean;
327
- theme?: Themes;
328
- }
329
- ```
330
-
331
- #### DividerProps
332
-
333
- ```typescript
334
- interface DividerProps {
335
- orientation?: "horizontal" | "vertical";
336
- label?: string;
337
- spacing?: "none" | "small" | "medium" | "large";
338
- theme?: Themes;
339
- }
340
- ```
341
-
342
- #### ScrollAreaProps
343
-
344
- ```typescript
345
- interface ScrollAreaProps extends React.HTMLAttributes<HTMLDivElement> {
346
- maxHeight?: number | string;
347
- scrollbars?: "auto" | "always" | "never";
348
- theme?: Themes;
349
- }
350
- ```
351
-
352
- ### Navigation Types
353
-
354
- #### TreeItem
355
-
356
- ```typescript
357
- interface TreeItem {
358
- id: string;
359
- label: string;
360
- children?: TreeItem[];
361
- icon?: React.ReactNode;
362
- href?: string;
363
- }
364
- ```
365
-
366
- #### TreeSubLayoutProps
367
-
368
- ```typescript
369
- interface TreeSubLayoutProps {
370
- tree: TreeItem[];
371
- activeItem?: string;
372
- onItemClick?: (id: string) => void;
373
- children: React.ReactNode;
374
- theme?: Themes;
375
- }
376
- ```
377
-
378
- ---
379
-
380
- ## Data Display Types
381
-
382
- ### Badge Types
383
-
384
- #### BadgeStyle
385
-
386
- ```typescript
387
- type BadgeStyle = "subtle" | "solid";
388
- ```
389
-
390
- #### BadgeColor
391
-
392
- ```typescript
393
- type BadgeColor =
394
- | "gray"
395
- | "slate"
396
- | "red"
397
- | "orange"
398
- | "yellow"
399
- | "green"
400
- | "ocean"
401
- | "blue"
402
- | "purple"
403
- | "rose";
404
- ```
405
-
406
- #### BadgeSize
407
-
408
- ```typescript
409
- type BadgeSize = "XS" | "S" | "M";
410
- ```
411
-
412
- #### BadgeProps
413
-
414
- ```typescript
415
- interface BadgeProps
416
- extends Omit<React.HTMLAttributes<HTMLSpanElement>, "color"> {
417
- label?: string;
418
- badgeStyle?: BadgeStyle; // default: "subtle"
419
- color?: BadgeColor; // default: "gray"
420
- size?: BadgeSize; // default: "S"
421
- showIcon?: boolean; // default: true
422
- badgeIcon?: React.ReactNode;
423
- isClosable?: boolean;
424
- onClose?: () => void;
425
- theme?: Themes;
426
- className?: string;
427
- }
428
- ```
429
-
430
- ### Avatar Types
431
-
432
- #### AvatarSize
433
-
434
- ```typescript
435
- type AvatarSize = "XS" | "S" | "M" | "L" | "XL";
436
- ```
437
-
438
- #### AvatarProps
439
-
440
- ```typescript
441
- interface AvatarProps {
442
- src?: string;
443
- alt: string;
444
- size?: AvatarSize;
445
- fallback?: string | React.ReactNode;
446
- theme?: Themes;
447
- }
448
- ```
449
-
450
- ### Table Types
451
-
452
- #### TableColumn
453
-
454
- ```typescript
455
- interface TableColumn<T = any> {
456
- key: keyof T | string;
457
- header: string;
458
- accessor?: (row: T) => React.ReactNode;
459
- sortable?: boolean;
460
- width?: number | string;
461
- }
462
- ```
463
-
464
- #### TableProps
465
-
466
- ```typescript
467
- interface TableProps<T = any> {
468
- columns: TableColumn<T>[];
469
- data: T[];
470
- sortable?: boolean;
471
- onRowClick?: (row: T) => void;
472
- theme?: Themes;
473
- }
474
- ```
475
-
476
- #### DataTableProps
477
-
478
- ```typescript
479
- interface DataTableProps<T = any> extends TableProps<T> {
480
- pagination?: boolean;
481
- pageSize?: number;
482
- currentPage?: number;
483
- onPageChange?: (page: number) => void;
484
- filtering?: boolean;
485
- selection?: boolean;
486
- onSelectionChange?: (selected: T[]) => void;
487
- }
488
- ```
489
-
490
- ### Skeleton Types
491
-
492
- #### SkeletonVariant
493
-
494
- ```typescript
495
- type SkeletonVariant = "text" | "circle" | "rectangle";
496
- ```
497
-
498
- #### SkeletonProps
499
-
500
- ```typescript
501
- interface SkeletonProps {
502
- variant?: SkeletonVariant;
503
- width?: number | string;
504
- height?: number | string;
505
- animation?: boolean;
506
- theme?: Themes;
507
- }
508
- ```
509
-
510
- ---
511
-
512
- ## Utility Types
513
-
514
- ### ClassValue
515
-
516
- ```typescript
517
- import type { ClassValue } from "clsx";
518
-
519
- // Used in cn utility function
520
- function cn(...inputs: ClassValue[]): string;
521
- ```
522
-
523
- ### PolymorphicProps
524
-
525
- ```typescript
526
- type PolymorphicProps<E extends React.ElementType> = {
527
- as?: E;
528
- } & React.ComponentPropsWithoutRef<E>;
529
- ```
530
-
531
- ### ForwardRefComponent
532
-
533
- ```typescript
534
- type ForwardRefComponent<T, P = {}> = React.ForwardRefExoticComponent<
535
- React.PropsWithoutRef<P> & React.RefAttributes<T>
536
- >;
537
- ```
538
-
539
- ### WithChildren
540
-
541
- ```typescript
542
- type WithChildren<T = {}> = T & {
543
- children?: React.ReactNode;
544
- };
545
- ```
546
-
547
- ### WithTheme
548
-
549
- ```typescript
550
- type WithTheme<T = {}> = T & {
551
- theme?: Themes;
552
- };
553
- ```
554
-
555
- ### WithClassName
556
-
557
- ```typescript
558
- type WithClassName<T = {}> = T & {
559
- className?: string;
560
- };
561
- ```
562
-
563
- ---
564
-
565
- ## Dialog & Overlay Types
566
-
567
- ### Dialog Types
568
-
569
- #### DialogProps
570
-
571
- ```typescript
572
- interface DialogProps {
573
- open?: boolean;
574
- onOpenChange?: (open: boolean) => void;
575
- theme?: Themes;
576
- children: React.ReactNode;
577
- }
578
- ```
579
-
580
- #### AlertDialogProps
581
-
582
- ```typescript
583
- interface AlertDialogProps extends DialogProps {
584
- title?: string;
585
- description?: string;
586
- action?: React.ReactNode;
587
- cancel?: React.ReactNode;
588
- }
589
- ```
590
-
591
- ### Drawer Types
592
-
593
- #### DrawerSide
594
-
595
- ```typescript
596
- type DrawerSide = "left" | "right" | "top" | "bottom";
597
- ```
598
-
599
- #### DrawerProps
600
-
601
- ```typescript
602
- interface DrawerProps {
603
- side?: DrawerSide;
604
- open?: boolean;
605
- onOpenChange?: (open: boolean) => void;
606
- theme?: Themes;
607
- children: React.ReactNode;
608
- }
609
- ```
610
-
611
- ### Popover Types
612
-
613
- #### PopoverPlacement
614
-
615
- ```typescript
616
- type PopoverPlacement =
617
- | "top"
618
- | "bottom"
619
- | "left"
620
- | "right"
621
- | "top-start"
622
- | "top-end"
623
- | "bottom-start"
624
- | "bottom-end"
625
- | "left-start"
626
- | "left-end"
627
- | "right-start"
628
- | "right-end";
629
- ```
630
-
631
- #### PopoverProps
632
-
633
- ```typescript
634
- interface PopoverProps {
635
- trigger: React.ReactNode;
636
- content: React.ReactNode;
637
- placement?: PopoverPlacement;
638
- open?: boolean;
639
- onOpenChange?: (open: boolean) => void;
640
- theme?: Themes;
641
- }
642
- ```
643
-
644
- ### Tooltip Types
645
-
646
- #### TooltipProps
647
-
648
- ```typescript
649
- interface TooltipProps {
650
- content: React.ReactNode;
651
- placement?: PopoverPlacement;
652
- delay?: number;
653
- theme?: Themes;
654
- children: React.ReactNode;
655
- }
656
- ```
657
-
658
- ---
659
-
660
- ## Date & Time Types
661
-
662
- ### Calendar Types
663
-
664
- #### CalendarMode
665
-
666
- ```typescript
667
- type CalendarMode = "single" | "multiple" | "range";
668
- ```
669
-
670
- #### DateRange
671
-
672
- ```typescript
673
- interface DateRange {
674
- from: Date | undefined;
675
- to?: Date | undefined;
676
- }
677
- ```
678
-
679
- #### CalendarProps
680
-
681
- ```typescript
682
- interface CalendarProps {
683
- mode?: CalendarMode;
684
- selected?: Date | Date[] | DateRange;
685
- onSelect?: (date: Date | Date[] | DateRange | undefined) => void;
686
- disabled?: Date[] | ((date: Date) => boolean);
687
- min?: number;
688
- max?: number;
689
- theme?: Themes;
690
- }
691
- ```
692
-
693
- ### DatePicker Types
694
-
695
- #### DatePickerProps
696
-
697
- ```typescript
698
- interface DatePickerProps {
699
- value?: Date;
700
- onChange?: (e: { target: { value: Date } }) => void;
701
- timePicker?: boolean;
702
- dateFormat?: string;
703
- disabled?: boolean;
704
- theme?: Themes;
705
- }
706
- ```
707
-
708
- ---
709
-
710
- ## Hook Types
711
-
712
- ### useActiveTreeItem
713
-
714
- ```typescript
715
- function useActiveTreeItem(itemIds: string[]): {
716
- activeId: string | null;
717
- }
718
- ```
719
-
720
- ### useClickOutside
721
-
722
- ```typescript
723
- function useClickOutside<T extends HTMLElement>(
724
- callback: (event?: MouseEvent | PointerEvent) => void,
725
- otherwise?: (event?: MouseEvent | PointerEvent) => void
726
- ): React.RefObject<T>
727
- ```
728
-
729
- ### useResize
730
-
731
- ```typescript
732
- function useResize(
733
- resizableRef: MutableRefObject<HTMLElement> | RefObject<HTMLElement>
734
- ): {
735
- width: number | undefined;
736
- isResizing: boolean;
737
- handleStartResize: (e: React.MouseEvent | React.TouchEvent) => void;
738
- }
739
- ```
740
-
741
- ### useTagSelection
742
-
743
- #### Tag Interface
744
-
745
- ```typescript
746
- interface Tag {
747
- id: string;
748
- name: string;
749
- variant?: string;
750
- value?: string;
751
- isSelected: boolean;
752
- [key: string]: any;
753
- }
754
- ```
755
-
756
- #### useTagSelection Return Type
757
-
758
- ```typescript
759
- function useTagSelection(params: {
760
- Tags: Tag[];
761
- onTagsChange?: (selectedTags: Tag[]) => void;
762
- inputRef?: React.RefObject<HTMLInputElement | null>;
763
- singleSelect?: boolean;
764
- }): {
765
- tags: Tag[];
766
- selectedTagsStack: Tag[];
767
- searchTags: string;
768
- filteredTags: Tag[];
769
- focusedTagIndex: number | null;
770
- focusedPopoverIndex: number | null;
771
- isPopoverOpen: boolean;
772
- handleSelectTag: (id: string) => void;
773
- handleUnselectTag: (id: string) => void;
774
- handleKeyDown: (e: React.KeyboardEvent<HTMLElement>) => void;
775
- setIsPopoverOpen: React.Dispatch<React.SetStateAction<boolean>>;
776
- filterTagsBySearch: React.Dispatch<React.SetStateAction<string>>;
777
- setFocusedTagIndex: React.Dispatch<React.SetStateAction<number | null>>;
778
- setFocusedPopoverIndex: React.Dispatch<React.SetStateAction<number | null>>;
779
- }
780
- ```
781
-
782
- ---
783
-
784
- ## Type Guards
785
-
786
- ### isTheme
787
-
788
- ```typescript
789
- function isTheme(value: unknown): value is Themes {
790
- return (
791
- typeof value === 'string' &&
792
- ['light', 'dark', 'default'].includes(value)
793
- );
794
- }
795
- ```
796
-
797
- ### isValidEmail
798
-
799
- ```typescript
800
- function isValidEmail(value: unknown): value is string {
801
- return (
802
- typeof value === 'string' &&
803
- /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)
804
- );
805
- }
806
- ```
807
-
808
- ### isReactNode
809
-
810
- ```typescript
811
- function isReactNode(value: unknown): value is React.ReactNode {
812
- return (
813
- value === null ||
814
- typeof value === 'string' ||
815
- typeof value === 'number' ||
816
- typeof value === 'boolean' ||
817
- React.isValidElement(value)
818
- );
819
- }
820
- ```
821
-
822
- ---
823
-
824
- ## Generic Component Types
825
-
826
- ### Polymorphic Component Example
827
-
828
- ```typescript
829
- type PolymorphicComponentProps<
830
- E extends React.ElementType,
831
- P = {}
832
- > = P & {
833
- as?: E;
834
- } & Omit<React.ComponentPropsWithoutRef<E>, keyof P | 'as'>;
835
-
836
- // Usage
837
- interface LabelOwnProps {
838
- label: string;
839
- theme?: Themes;
840
- }
841
-
842
- type LabelProps<E extends React.ElementType = 'label'> =
843
- PolymorphicComponentProps<E, LabelOwnProps>;
844
-
845
- const Label = <E extends React.ElementType = 'label'>({
846
- as,
847
- ...props
848
- }: LabelProps<E>) => {
849
- const Component = as || 'label';
850
- return <Component {...props} />;
851
- };
852
- ```
853
-
854
- ### Forward Ref Component Example
855
-
856
- ```typescript
857
- interface ButtonOwnProps {
858
- variant?: ButtonVariant;
859
- size?: ButtonSize;
860
- }
861
-
862
- type ButtonProps = ButtonOwnProps &
863
- React.ButtonHTMLAttributes<HTMLButtonElement>;
864
-
865
- const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
866
- (props, ref) => {
867
- return <button ref={ref} {...props} />;
868
- }
869
- );
870
-
871
- Button.displayName = 'Button';
872
- ```
873
-
874
- ---
875
-
876
- ## Extending Component Types
877
-
878
- ### Extending Button Props
879
-
880
- ```typescript
881
- import type { ButtonProps } from "@/components/LoginButton";
882
-
883
- interface CustomButtonProps extends ButtonProps {
884
- isLoading?: boolean;
885
- loadingText?: string;
886
- icon?: React.ReactNode;
887
- }
888
-
889
- const CustomButton: React.FC<CustomButtonProps> = ({
890
- isLoading,
891
- loadingText,
892
- icon,
893
- children,
894
- ...buttonProps
895
- }) => {
896
- return (
897
- <Button {...buttonProps}>
898
- {isLoading ? loadingText : (
899
- <>
900
- {icon && <span>{icon}</span>}
901
- {children}
902
- </>
903
- )}
904
- </Button>
905
- );
906
- };
907
- ```
908
-
909
- ### Creating Typed Form Component
910
-
911
- ```typescript
912
- interface LoginFormData {
913
- email: string;
914
- password: string;
915
- rememberMe: boolean;
916
- }
917
-
918
- type LoginFormProps = {
919
- onSubmit: (data: LoginFormData) => void;
920
- initialValues?: Partial<LoginFormData>;
921
- };
922
-
923
- const LoginForm: React.FC<LoginFormProps> = ({
924
- onSubmit,
925
- initialValues
926
- }) => {
927
- const [formData, setFormData] = useState<LoginFormData>({
928
- email: initialValues?.email || '',
929
- password: initialValues?.password || '',
930
- rememberMe: initialValues?.rememberMe || false,
931
- });
932
-
933
- const handleSubmit = (e: React.FormEvent) => {
934
- e.preventDefault();
935
- onSubmit(formData);
936
- };
937
-
938
- return <form onSubmit={handleSubmit}>{/* ... */}</form>;
939
- };
940
- ```
941
-
942
- ---
943
-
944
- ## Best Practices
945
-
946
- ### 1. Use Type Inference
947
-
948
- ```typescript
949
- // ✓ Good - Type is inferred
950
- const [count, setCount] = useState(0);
951
-
952
- // ✗ Unnecessary - Type is obvious
953
- const [count, setCount] = useState<number>(0);
954
- ```
955
-
956
- ### 2. Use Discriminated Unions
957
-
958
- ```typescript
959
- // ✓ Good
960
- type Result<T> =
961
- | { success: true; data: T }
962
- | { success: false; error: string };
963
-
964
- // Usage
965
- function processResult<T>(result: Result<T>) {
966
- if (result.success) {
967
- console.log(result.data); // ✓ Type is T
968
- } else {
969
- console.log(result.error); // ✓ Type is string
970
- }
971
- }
972
- ```
973
-
974
- ### 3. Use Generic Constraints
975
-
976
- ```typescript
977
- // ✓ Good - Constrained generic
978
- function getProperty<T, K extends keyof T>(obj: T, key: K): T[K] {
979
- return obj[key];
980
- }
981
-
982
- // Usage
983
- const user = { name: 'John', age: 30 };
984
- const name = getProperty(user, 'name'); // ✓ Type is string
985
- ```
986
-
987
- ### 4. Prefer Union Types Over Enums
988
-
989
- ```typescript
990
- // ✓ Good - Union type
991
- type Status = 'pending' | 'approved' | 'rejected';
992
-
993
- // ✗ Avoid - Enum (adds runtime overhead)
994
- enum Status {
995
- Pending = 'pending',
996
- Approved = 'approved',
997
- Rejected = 'rejected',
998
- }
999
- ```
1000
-
1001
- ---
1002
-
1003
- ## Related Documentation
1004
-
1005
- - [Component API Index](./components.md) - All component props
1006
- - [Hooks Reference](./hooks.md) - Custom hooks with types
1007
- - [Utilities Reference](./utilities.md) - Helper functions
1008
- - [How-to: TypeScript Integration](../how-to/guides.md#typescript-integration) - TypeScript best practices
1009
-
1010
- ---
1011
-
1012
- ## Additional Resources
1013
-
1014
- - [TypeScript Handbook](https://www.typescriptlang.org/docs/)
1015
- - [React TypeScript Cheatsheet](https://react-typescript-cheatsheet.netlify.app/)
1016
- - [Utility Types](https://www.typescriptlang.org/docs/handbook/utility-types.html)