torch-glare 2.5.5 → 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 (359) 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 -338
  69. package/apps/lib/components/Breadcrumb.tsx +0 -280
  70. package/apps/lib/components/Button.tsx +0 -317
  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 -383
  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 -84
  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 -63
  106. package/apps/lib/components/DataViews/states.tsx +0 -38
  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 -420
  118. package/apps/lib/components/DropdownMenu.tsx +0 -540
  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 -73
  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 -163
  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 -91
  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 -47
  147. package/apps/lib/components/FormBuilder/types.ts +0 -311
  148. package/apps/lib/components/FormRenderer/FormDrawer.tsx +0 -128
  149. package/apps/lib/components/FormRenderer/detail.tsx +0 -207
  150. package/apps/lib/components/FormRenderer/form-renderer.tsx +0 -297
  151. package/apps/lib/components/FormRenderer/header.tsx +0 -88
  152. package/apps/lib/components/FormRenderer/index.ts +0 -15
  153. package/apps/lib/components/FormRenderer/section.tsx +0 -39
  154. package/apps/lib/components/FormRenderer/stepper.tsx +0 -339
  155. package/apps/lib/components/FormRenderer/types.ts +0 -78
  156. package/apps/lib/components/FormSummary.tsx +0 -282
  157. package/apps/lib/components/HeaderBar.tsx +0 -117
  158. package/apps/lib/components/ImageAttachment.tsx +0 -209
  159. package/apps/lib/components/InnerLabelField.tsx +0 -154
  160. package/apps/lib/components/Input.tsx +0 -224
  161. package/apps/lib/components/InputField.tsx +0 -147
  162. package/apps/lib/components/InputOTP.tsx +0 -84
  163. package/apps/lib/components/Label.tsx +0 -129
  164. package/apps/lib/components/LabelField.tsx +0 -76
  165. package/apps/lib/components/LabeledCheckBox.tsx +0 -51
  166. package/apps/lib/components/LabeledRadio.tsx +0 -51
  167. package/apps/lib/components/LinkButton.tsx +0 -94
  168. package/apps/lib/components/LoginButton.tsx +0 -51
  169. package/apps/lib/components/PasswordLevel.tsx +0 -58
  170. package/apps/lib/components/Popover.tsx +0 -312
  171. package/apps/lib/components/ProfileMenu.tsx +0 -85
  172. package/apps/lib/components/Radio.tsx +0 -59
  173. package/apps/lib/components/RadioCard.tsx +0 -50
  174. package/apps/lib/components/ScrollArea.tsx +0 -54
  175. package/apps/lib/components/SearchField.tsx +0 -62
  176. package/apps/lib/components/SearchableSelect.tsx +0 -318
  177. package/apps/lib/components/SearchableTable.tsx +0 -344
  178. package/apps/lib/components/SearchableTree.tsx +0 -485
  179. package/apps/lib/components/SearchableTreeDialog.tsx +0 -502
  180. package/apps/lib/components/SectionBlock.tsx +0 -147
  181. package/apps/lib/components/Select.tsx +0 -347
  182. package/apps/lib/components/SimpleSelect.tsx +0 -225
  183. package/apps/lib/components/Skeleton.tsx +0 -12
  184. package/apps/lib/components/SlideDatePicker.tsx +0 -253
  185. package/apps/lib/components/SpinLoading.tsx +0 -174
  186. package/apps/lib/components/Stepper.tsx +0 -480
  187. package/apps/lib/components/Switch.tsx +0 -82
  188. package/apps/lib/components/TabFormItem.tsx +0 -153
  189. package/apps/lib/components/TabSwitch.tsx +0 -172
  190. package/apps/lib/components/Table.tsx +0 -610
  191. package/apps/lib/components/TextEditor/ChartBlockTool.ts +0 -676
  192. package/apps/lib/components/TextEditor/RichTextField.tsx +0 -46
  193. package/apps/lib/components/TextEditor/TableDnDWrapper.ts +0 -462
  194. package/apps/lib/components/TextEditor/TextEditor.tsx +0 -1164
  195. package/apps/lib/components/TextEditor/TextEditorToolbar.tsx +0 -429
  196. package/apps/lib/components/TextEditor/editor-tools/AlignmentTune.ts +0 -70
  197. package/apps/lib/components/TextEditor/editor-tools/ColorInlineTool.ts +0 -50
  198. package/apps/lib/components/TextEditor/editor-tools/StrikethroughInlineTool.ts +0 -48
  199. package/apps/lib/components/TextEditor/editor-tools/inlineFormat.ts +0 -98
  200. package/apps/lib/components/TextEditor/editorjs.d.ts +0 -60
  201. package/apps/lib/components/TextEditor/index.ts +0 -7
  202. package/apps/lib/components/TextEditor/markdownParser.ts +0 -346
  203. package/apps/lib/components/Textarea.tsx +0 -117
  204. package/apps/lib/components/Timeline.tsx +0 -263
  205. package/apps/lib/components/Toast.tsx +0 -87
  206. package/apps/lib/components/Toggle.tsx +0 -125
  207. package/apps/lib/components/ToggleButton.tsx +0 -140
  208. package/apps/lib/components/Tooltip.tsx +0 -116
  209. package/apps/lib/components/TransparentLabel.tsx +0 -71
  210. package/apps/lib/components/TreeDropDown.tsx +0 -115
  211. package/apps/lib/components/TreeFolder/TreeFolder.tsx +0 -380
  212. package/apps/lib/components/TreeFolder/TreeFolderBreadcrumb.tsx +0 -75
  213. package/apps/lib/components/TreeFolder/TreeFolderRow.tsx +0 -354
  214. package/apps/lib/components/TreeFolder/TreeFolderStyles.tsx +0 -60
  215. package/apps/lib/components/TreeFolder/icons.tsx +0 -60
  216. package/apps/lib/components/TreeFolder/index.ts +0 -24
  217. package/apps/lib/components/TreeFolder/treeFolderUtils.ts +0 -109
  218. package/apps/lib/components/TreeFolder/types.ts +0 -77
  219. package/apps/lib/components/TreeFolder/useTreeFolderDnD.ts +0 -118
  220. package/apps/lib/hooks/useActiveTreeItem.ts +0 -58
  221. package/apps/lib/hooks/useClickOutside.ts +0 -27
  222. package/apps/lib/hooks/useDragDrop.tsx +0 -365
  223. package/apps/lib/hooks/useInfiniteScroll.ts +0 -108
  224. package/apps/lib/hooks/useIsMobile.ts +0 -21
  225. package/apps/lib/hooks/useResize.ts +0 -67
  226. package/apps/lib/hooks/useTagSelection.ts +0 -214
  227. package/apps/lib/layouts/CNLayout.tsx +0 -372
  228. package/apps/lib/layouts/DataViewCard.tsx +0 -62
  229. package/apps/lib/layouts/FieldSection.tsx +0 -91
  230. package/apps/lib/layouts/TreeSubLayout.tsx +0 -173
  231. package/apps/lib/providers/ThemeProvider.tsx +0 -84
  232. package/apps/lib/registry.json +0 -1201
  233. package/apps/lib/tsconfig.json +0 -9
  234. package/apps/lib/tsconfig.tsbuildinfo +0 -1
  235. package/apps/lib/utils/cn.ts +0 -6
  236. package/apps/lib/utils/color.ts +0 -175
  237. package/apps/lib/utils/dataViews/path.ts +0 -67
  238. package/apps/lib/utils/dataViews/query.ts +0 -73
  239. package/apps/lib/utils/dataViews/types.ts +0 -187
  240. package/apps/lib/utils/dateFormat.ts +0 -108
  241. package/apps/lib/utils/resize.ts +0 -31
  242. package/apps/lib/utils/types.ts +0 -16
  243. package/docs/BLOCKS.md +0 -129
  244. package/docs/CHANGELOG-1.1.16.md +0 -108
  245. package/docs/Cover.png +0 -0
  246. package/docs/README.md +0 -215
  247. package/docs/components/action-button.md +0 -638
  248. package/docs/components/actions-group.md +0 -708
  249. package/docs/components/alert-dialog.md +0 -920
  250. package/docs/components/avatar.md +0 -709
  251. package/docs/components/badge-field.md +0 -712
  252. package/docs/components/badge.md +0 -301
  253. package/docs/components/breadcrumb.md +0 -930
  254. package/docs/components/button-group.md +0 -650
  255. package/docs/components/button.md +0 -639
  256. package/docs/components/calendar.md +0 -555
  257. package/docs/components/card.md +0 -622
  258. package/docs/components/chart-block-tool.md +0 -129
  259. package/docs/components/checkbox.md +0 -699
  260. package/docs/components/cn-layout.md +0 -854
  261. package/docs/components/color-picker.md +0 -101
  262. package/docs/components/conclusion-header.md +0 -80
  263. package/docs/components/context-menu.md +0 -483
  264. package/docs/components/count-badge.md +0 -560
  265. package/docs/components/data-table.md +0 -854
  266. package/docs/components/data-views/backend-response.md +0 -324
  267. package/docs/components/data-views/examples/a11y-rtl.md +0 -250
  268. package/docs/components/data-views/examples/api-orders-route.md +0 -130
  269. package/docs/components/data-views/examples/fields.md +0 -362
  270. package/docs/components/data-views/examples/filters.md +0 -307
  271. package/docs/components/data-views/examples/inbox-routing.md +0 -218
  272. package/docs/components/data-views/examples/index.md +0 -29
  273. package/docs/components/data-views/examples/overview.md +0 -244
  274. package/docs/components/data-views/examples/panel.md +0 -212
  275. package/docs/components/data-views/examples/scale.md +0 -231
  276. package/docs/components/data-views/examples/server-side.md +0 -210
  277. package/docs/components/data-views/examples/state.md +0 -250
  278. package/docs/components/data-views/examples/tree-custom.md +0 -388
  279. package/docs/components/data-views/examples/view-registry.md +0 -313
  280. package/docs/components/data-views/examples/views.md +0 -534
  281. package/docs/components/data-views/guide.md +0 -405
  282. package/docs/components/data-views/index.md +0 -1495
  283. package/docs/components/data-views/migration.md +0 -79
  284. package/docs/components/date-picker.md +0 -857
  285. package/docs/components/dialog.md +0 -929
  286. package/docs/components/divider.md +0 -766
  287. package/docs/components/drawer.md +0 -654
  288. package/docs/components/dropdown-menu.md +0 -668
  289. package/docs/components/field-hint.md +0 -898
  290. package/docs/components/field-section.md +0 -781
  291. package/docs/components/form-builder.md +0 -276
  292. package/docs/components/form-renderer.md +0 -326
  293. package/docs/components/form-summary.md +0 -138
  294. package/docs/components/form.md +0 -785
  295. package/docs/components/header-bar.md +0 -188
  296. package/docs/components/image-attachment.md +0 -906
  297. package/docs/components/inner-label-field.md +0 -819
  298. package/docs/components/input-field.md +0 -623
  299. package/docs/components/input-otp.md +0 -756
  300. package/docs/components/input.md +0 -634
  301. package/docs/components/label-field.md +0 -770
  302. package/docs/components/label.md +0 -761
  303. package/docs/components/labeled-check-box.md +0 -642
  304. package/docs/components/labeled-radio.md +0 -796
  305. package/docs/components/link-button.md +0 -685
  306. package/docs/components/login-button.md +0 -872
  307. package/docs/components/password-level.md +0 -803
  308. package/docs/components/popover.md +0 -649
  309. package/docs/components/profile-menu.md +0 -656
  310. package/docs/components/radio-card.md +0 -801
  311. package/docs/components/radio.md +0 -735
  312. package/docs/components/scroll-area.md +0 -691
  313. package/docs/components/search-field.md +0 -702
  314. package/docs/components/searchable-select.md +0 -368
  315. package/docs/components/searchable-table.md +0 -438
  316. package/docs/components/searchable-tree-dialog.md +0 -190
  317. package/docs/components/searchable-tree.md +0 -200
  318. package/docs/components/section-block.md +0 -477
  319. package/docs/components/select.md +0 -709
  320. package/docs/components/simple-select.md +0 -741
  321. package/docs/components/skeleton.md +0 -706
  322. package/docs/components/slide-date-picker.md +0 -837
  323. package/docs/components/spin-loading.md +0 -696
  324. package/docs/components/stepper.md +0 -316
  325. package/docs/components/switch.md +0 -770
  326. package/docs/components/tab-form-item.md +0 -773
  327. package/docs/components/tab-switch.md +0 -170
  328. package/docs/components/table-dnd-wrapper.md +0 -107
  329. package/docs/components/table.md +0 -1088
  330. package/docs/components/text-editor.md +0 -735
  331. package/docs/components/textarea.md +0 -681
  332. package/docs/components/timeline.md +0 -254
  333. package/docs/components/toast.md +0 -773
  334. package/docs/components/toggle-button.md +0 -643
  335. package/docs/components/toggle.md +0 -882
  336. package/docs/components/tooltip.md +0 -513
  337. package/docs/components/transparent-label.md +0 -721
  338. package/docs/components/tree-drop-down.md +0 -740
  339. package/docs/components/tree-folder.md +0 -110
  340. package/docs/components/tree-sub-layout.md +0 -707
  341. package/docs/explanation/architecture.md +0 -54
  342. package/docs/explanation/design-system.md +0 -52
  343. package/docs/how-to/form-and-list-recipes.md +0 -386
  344. package/docs/how-to/forms-with-form-builder.md +0 -472
  345. package/docs/how-to/guides.md +0 -1027
  346. package/docs/migration/changelog.md +0 -54
  347. package/docs/migration/form-builder-2.5.2.md +0 -113
  348. package/docs/reference/cli.md +0 -112
  349. package/docs/reference/components.md +0 -572
  350. package/docs/reference/hooks.md +0 -1500
  351. package/docs/reference/providers.md +0 -866
  352. package/docs/reference/tailwind-plugins.md +0 -942
  353. package/docs/reference/theme.md +0 -85
  354. package/docs/reference/types.md +0 -1016
  355. package/docs/reference/utilities.md +0 -704
  356. package/docs/tutorials/building-first-form.md +0 -846
  357. package/docs/tutorials/component-composition.md +0 -882
  358. package/docs/tutorials/getting-started.md +0 -302
  359. package/docs/tutorials/theming-basics.md +0 -785
@@ -1,77 +0,0 @@
1
- import type { ReactNode } from "react";
2
-
3
- export type TreeFolderNodeType =
4
- | "folder"
5
- | "file"
6
- | "frame"
7
- | "group"
8
- | "component"
9
- | "instance"
10
- | "text"
11
- | "image"
12
- | "vector"
13
- | "link"
14
- | "section"
15
- | "container"
16
- | (string & Record<never, never>);
17
-
18
- export type TreeFolderNode = {
19
- id: string;
20
- name: string;
21
- type?: TreeFolderNodeType;
22
- icon?: ReactNode;
23
- meta?: ReactNode;
24
- disabled?: boolean;
25
- draggable?: boolean;
26
- droppable?: boolean;
27
- data?: unknown;
28
- children?: TreeFolderNode[];
29
- };
30
-
31
- export type TreeFolderMoveArgs = {
32
- dragIds: string[];
33
- parentId: string | null;
34
- index: number;
35
- };
36
-
37
- export type TreeFolderIconResolver = (
38
- node: TreeFolderNode,
39
- state: { isOpen: boolean; isInternal: boolean; isSelected: boolean },
40
- ) => ReactNode;
41
-
42
- export type TreeFolderBreadcrumb = Array<{ id: string; name: string }>;
43
-
44
- // ---------------------------------------------------------------------------
45
- // Visible-row + DnD primitives.
46
- // ---------------------------------------------------------------------------
47
-
48
- export type TreeFolderVisibleRow = {
49
- node: TreeFolderNode;
50
- level: number;
51
- /** Resolved parent id (null for roots). */
52
- parentId: string | null;
53
- /** Position of this node among its siblings in the source tree (0-based). */
54
- childIndex: number;
55
- /** True when the node is internal AND open. */
56
- isOpen: boolean;
57
- /** True for internal nodes (any node with non-empty children). */
58
- isInternal: boolean;
59
- /**
60
- * Connector-line geometry. `isLastChild` toggles the row's own bend between L
61
- * (last) and T (non-last). `ancestorHasMoreSiblings[d]` is true when the
62
- * ancestor at depth `d` still has visible siblings after this row — that
63
- * controls whether the vertical guide renders in that ancestor's gutter.
64
- * Length === `level`.
65
- */
66
- isLastChild: boolean;
67
- ancestorHasMoreSiblings: boolean[];
68
- };
69
-
70
- /** Where the pointer is dropping relative to the hovered row. */
71
- export type TreeFolderDropPosition = "before" | "after" | "inside";
72
-
73
- export type TreeFolderDropTarget = {
74
- /** The id whose `parentId` the drop will resolve to. */
75
- rowId: string;
76
- position: TreeFolderDropPosition;
77
- };
@@ -1,118 +0,0 @@
1
- "use client";
2
-
3
- import { useCallback, useMemo } from "react";
4
- import { useDragDrop, type DragMove } from "../../hooks/useDragDrop";
5
- import { isAncestor } from "./treeFolderUtils";
6
- import type { TreeFolderDropTarget, TreeFolderMoveArgs, TreeFolderNode } from "./types";
7
- import type { TreeFolderVisibleRow } from "./types";
8
-
9
- type RowLookup = Map<string, TreeFolderVisibleRow>;
10
-
11
- export type UseTreeFolderDnDOptions = {
12
- data: TreeFolderNode[];
13
- rowsById: RowLookup;
14
- enabled: boolean;
15
- onMove?: (args: TreeFolderMoveArgs) => void;
16
- /**
17
- * Predicate. Return false to forbid the drop. Defaults to allow except for
18
- * dropping a node into itself or a descendant.
19
- */
20
- canDrop?: (args: { dragIds: string[]; parentId: string | null; index: number }) => boolean;
21
- };
22
-
23
- /**
24
- * The tree's drag, expressed as a translation.
25
- *
26
- * All this does is turn one `DragMove` — an id, a target row and whether the pointer sat above,
27
- * on or below it — into the `{dragIds, parentId, index}` a tree move is written in. Picking the
28
- * item up, following the pointer, deciding which row is underneath, scrolling when the drag nears
29
- * an edge and answering the keyboard all belong to `useDragDrop`, which every other draggable
30
- * surface in the library now shares.
31
- *
32
- * What stays here is the part only a tree knows: that "inside" means the end of the target's
33
- * children, that "before" and "after" are indices in the target's parent, and that a branch
34
- * dropped into its own descendant would detach itself from the root.
35
- */
36
- export function useTreeFolderDnD({
37
- data,
38
- rowsById,
39
- enabled,
40
- onMove,
41
- canDrop,
42
- }: UseTreeFolderDnDOptions) {
43
- /** A row can only take children if it is a folder; a file's middle band is not a drop zone. */
44
- const canNestInto = useCallback(
45
- (id: string) => rowsById.get(id)?.isInternal ?? false,
46
- [rowsById],
47
- );
48
-
49
- /** `{row, position}` → `{parentId, index}`, or null if the move is impossible or pointless. */
50
- const resolve = useCallback(
51
- (dragIds: string[], move: DragMove): TreeFolderMoveArgs | null => {
52
- const targetRow = move.to ? rowsById.get(move.to) : undefined;
53
- if (!targetRow) return null;
54
-
55
- const position = move.position ?? "after";
56
- const parentId = position === "inside" ? targetRow.node.id : targetRow.parentId;
57
- const index =
58
- position === "inside"
59
- ? // Dropped onto a folder: land at the end of what it already holds.
60
- (targetRow.node.children?.length ?? 0)
61
- : position === "before"
62
- ? targetRow.childIndex
63
- : targetRow.childIndex + 1;
64
-
65
- // A node cannot become its own descendant's child — that severs the branch from the root.
66
- for (const id of dragIds) {
67
- const node = rowsById.get(id)?.node;
68
- if (!node) continue;
69
- if (parentId && (node.id === parentId || isAncestor(node, parentId))) return null;
70
- }
71
-
72
- if (canDrop && !canDrop({ dragIds, parentId, index })) return null;
73
-
74
- // "Drop where you already are" is not a move; reporting it would churn the caller's data.
75
- if (dragIds.length === 1) {
76
- const only = rowsById.get(dragIds[0]);
77
- if (
78
- only &&
79
- only.parentId === parentId &&
80
- (only.childIndex === index || only.childIndex + 1 === index)
81
- ) {
82
- return null;
83
- }
84
- }
85
-
86
- return { dragIds, parentId, index };
87
- },
88
- [rowsById, canDrop],
89
- );
90
-
91
- const { contextProps, activeId, overId, position } = useDragDrop({
92
- mode: "tree",
93
- disabled: !enabled,
94
- canNestInto,
95
- onMove: (move) => {
96
- const args = resolve([move.id], move);
97
- if (args) onMove?.(args);
98
- },
99
- });
100
-
101
- /**
102
- * Kept as a list because a move is defined over a set of nodes: a tree that gains multi-select
103
- * drag changes what fills this, and nothing downstream — the guard, the resolver, `onMove` — has
104
- * to change with it.
105
- */
106
- const dragIds = useMemo(() => (activeId ? [activeId] : []), [activeId]);
107
-
108
- /** Where the indicator is painted. Null while nothing is over a valid row. */
109
- const dropTarget: TreeFolderDropTarget | null =
110
- activeId && overId && position && overId !== activeId
111
- ? { rowId: overId, position }
112
- : null;
113
-
114
- /** The rows the tree can drop on, in painted order — `data` is what changes them. */
115
- const ids = useMemo(() => [...rowsById.keys()], [rowsById, data]); // eslint-disable-line react-hooks/exhaustive-deps
116
-
117
- return { dragIds, dropTarget, contextProps, ids, enabled };
118
- }
@@ -1,58 +0,0 @@
1
- "use client";
2
- import { useState, useEffect } from "react";
3
-
4
- export function useActiveTreeItem(itemIds: string[]) {
5
- const [activeId, setActiveId] = useState<string | null>(null);
6
-
7
- useEffect(() => {
8
- if (!itemIds || itemIds.length === 0) {
9
- console.warn("No itemIds provided to useActiveTreeItem.");
10
- return;
11
- }
12
-
13
- const observer = new IntersectionObserver(
14
- (entries) => {
15
- let mostVisibleEntry: IntersectionObserverEntry | null = null;
16
-
17
- for (const entry of entries) {
18
- if (entry.isIntersecting) {
19
- // Track the most visible entry (highest intersection ratio)
20
- if (!mostVisibleEntry || entry.intersectionRatio > mostVisibleEntry.intersectionRatio) {
21
- mostVisibleEntry = entry;
22
- }
23
- }
24
- }
25
-
26
- if (mostVisibleEntry) {
27
- setActiveId(mostVisibleEntry.target.id);
28
- }
29
- },
30
- {
31
- rootMargin: "-10% 0% -5% 0%", // Adjust based on your layout
32
- threshold: [0, 0.25, 0.5, 0.75, 1], // Multiple thresholds for better accuracy
33
- },
34
- );
35
-
36
- // Observe all elements
37
- itemIds.forEach((id) => {
38
- const element = document.getElementById(id);
39
- if (element) {
40
- observer.observe(element);
41
- } else {
42
- console.warn(`Element with id "${id}" not found.`);
43
- }
44
- });
45
-
46
- // Cleanup observer
47
- return () => {
48
- itemIds.forEach((id) => {
49
- const element = document.getElementById(id);
50
- if (element) {
51
- observer.unobserve(element);
52
- }
53
- });
54
- };
55
- }, [itemIds]);
56
-
57
- return { activeId };
58
- }
@@ -1,27 +0,0 @@
1
- import { useEffect, useRef } from "react";
2
-
3
- export function useClickOutside<T extends HTMLElement>(
4
- callback: (event?: MouseEvent | PointerEvent) => void,
5
- otherwise?: (event?: MouseEvent | PointerEvent) => void,
6
- ) {
7
- const ref = useRef<T>(null);
8
-
9
- useEffect(() => {
10
- function handleOutsideClick(event: MouseEvent | PointerEvent) {
11
- if (ref.current && !ref.current.contains(event.target as Node)) {
12
- callback(event);
13
- } else {
14
- otherwise?.(event);
15
- }
16
- }
17
-
18
- document.addEventListener("mousedown", handleOutsideClick);
19
- document.addEventListener("pointerdown", handleOutsideClick);
20
- return () => {
21
- document.removeEventListener("mousedown", handleOutsideClick);
22
- document.removeEventListener("pointerdown", handleOutsideClick);
23
- };
24
- }, [callback]);
25
-
26
- return ref;
27
- }
@@ -1,365 +0,0 @@
1
- "use client";
2
-
3
- import { useCallback, useMemo, useRef, useState, type ReactNode } from "react";
4
- import {
5
- DndContext,
6
- DragOverlay,
7
- useDroppable,
8
- KeyboardSensor,
9
- MouseSensor,
10
- TouchSensor,
11
- closestCenter,
12
- closestCorners,
13
- useSensor,
14
- useSensors,
15
- type DragEndEvent,
16
- type DragMoveEvent,
17
- type DragOverEvent,
18
- type DragStartEvent,
19
- } from "@dnd-kit/core";
20
- import {
21
- SortableContext,
22
- sortableKeyboardCoordinates,
23
- useSortable,
24
- verticalListSortingStrategy,
25
- } from "@dnd-kit/sortable";
26
- import { CSS } from "@dnd-kit/utilities";
27
-
28
- /**
29
- * Drag and drop, once, for every surface that needs it.
30
- *
31
- * It exists because the same thing was written three times — the board, the config rail's column
32
- * list and the tree each had their own — all three on the **HTML5 drag and drop API**, which
33
- * mobile browsers do not drive from touch. A finger never fires `dragstart`, so on a phone none of
34
- * it worked at all, and there was no keyboard path either.
35
- *
36
- * This is built on `@dnd-kit`, already used by `DataTable` and `FormBuilder.Table`. Its pointer
37
- * sensor speaks Pointer Events, which cover mouse, touch and pen alike, and its keyboard sensor
38
- * makes a drag reachable without a pointing device.
39
- *
40
- * The hook does not move anything. It reports a `DragMove` and the caller decides — the same
41
- * contract the rest of DataViews keeps, and the reason a failed save leaves the UI showing the
42
- * truth rather than a lie.
43
- */
44
-
45
- // Re-exported so a surface can render the provider without also importing @dnd-kit directly —
46
- // the point of this file is that it is the only place that does.
47
- export { DndContext };
48
-
49
- /**
50
- * The thing that follows the pointer.
51
- *
52
- * A list does not need one: its items slide apart, so the gap says where the drop will land. A
53
- * board does. Once a card is dragged over a *different* column, dnd-kit stops transforming it —
54
- * it has left the list that was arranging it — and without an overlay the card just sits faded in
55
- * its old column while the pointer moves off alone.
56
- *
57
- * Render whatever the item looks like inside; it is drawn above everything, at the pointer.
58
- */
59
- export function DragGhost({ children }: { children: ReactNode }) {
60
- return (
61
- <DragOverlay dropAnimation={null}>
62
- {children ? <div data-dnd-overlay>{children}</div> : null}
63
- </DragOverlay>
64
- );
65
- }
66
-
67
- export type DropPosition = "before" | "inside" | "after";
68
-
69
- export interface DragMove {
70
- /** The item being dragged. */
71
- id: string;
72
- /** The container it started in. `null` for a flat list, which has only one. */
73
- from: string | null;
74
- /** The container it was dropped on. */
75
- to: string | null;
76
- /** Its position within `to`, when the surface has an order. */
77
- index?: number;
78
- /** Trees only: dropped above the target, into it, or below it. */
79
- position?: DropPosition;
80
- }
81
-
82
- export type DragMode =
83
- /** Items move between containers — a kanban board. */
84
- | "board"
85
- /** One ordered list — the column rail, table rows. */
86
- | "list"
87
- /** A hierarchy, where a drop can also mean "inside". */
88
- | "tree";
89
-
90
- export interface UseDragDropOptions {
91
- mode: DragMode;
92
- /** Called on drop. Nothing has moved yet; that is your job. */
93
- onMove: (move: DragMove) => void;
94
- disabled?: boolean;
95
- /**
96
- * Veto a drop before it is reported — a tree uses this to refuse a node dropped into its own
97
- * descendant, which would detach the branch from the root.
98
- */
99
- canDrop?: (move: DragMove) => boolean;
100
- /**
101
- * Which container an item currently belongs to. Board mode needs it to report `from`, since the
102
- * drop target only knows where the item landed.
103
- */
104
- containerOf?: (id: string) => string | null;
105
- /** Where in `to` the item landed. Supplied by the caller, which knows its own ordering. */
106
- indexOf?: (id: string) => number;
107
- /**
108
- * Tree mode: can this row hold children? A leaf has no inside, so its middle band collapses and
109
- * the whole row reads as before-or-after — otherwise a drop on a file would silently do nothing.
110
- */
111
- canNestInto?: (id: string) => boolean;
112
- }
113
-
114
- /** How far the mouse travels before a press becomes a drag, so a click stays a click. */
115
- const MOUSE_DISTANCE = 8;
116
-
117
- /**
118
- * Touch is deliberately *not* handled by the pointer sensor.
119
- *
120
- * A finger has one gesture for two intentions: dragging an item and scrolling the list it is in.
121
- * A distance threshold cannot separate them — whichever wins, the other becomes impossible. So
122
- * touch drags start on a long press instead, which is the convention every mobile list uses: hold
123
- * to pick up, swipe to scroll.
124
- *
125
- * `tolerance` is how far the finger may wander during the hold before it is treated as a scroll
126
- * rather than an impatient drag.
127
- */
128
- const TOUCH_DELAY_MS = 200;
129
- const TOUCH_TOLERANCE = 8;
130
-
131
- /** Within this fraction of a row's top or bottom edge, a tree drop means "beside", not "into". */
132
- const EDGE_BAND = 0.25;
133
-
134
- /**
135
- * Where the pointer is, in viewport coordinates.
136
- *
137
- * dnd-kit reports a *delta* from wherever the drag was activated, so the absolute position is the
138
- * activator plus that delta. A touch activator carries its coordinates on `touches`, a keyboard
139
- * activator carries none at all — hence the null, which the caller reads as "aim at the middle".
140
- */
141
- function pointerY(activator: Event | null, delta: number): number | null {
142
- const e = activator as (MouseEvent & TouchEvent) | null;
143
- const start = e?.clientY ?? e?.touches?.[0]?.clientY;
144
- return typeof start === "number" ? start + delta : null;
145
- }
146
-
147
- /**
148
- * `CSS.escape`, reached through `window` because `CSS` in this file is dnd-kit's transform helper.
149
- * The fallback covers environments without it (jsdom, older Safari).
150
- */
151
- const escapeId = (v: string) =>
152
- typeof window !== "undefined" && window.CSS?.escape
153
- ? window.CSS.escape(v)
154
- : v.replace(/["\\]/g, "\\$&");
155
-
156
- export function useDragDrop({
157
- mode,
158
- onMove,
159
- disabled = false,
160
- canDrop,
161
- containerOf,
162
- indexOf,
163
- canNestInto,
164
- }: UseDragDropOptions) {
165
- const [activeId, setActiveId] = useState<string | null>(null);
166
- const [overId, setOverId] = useState<string | null>(null);
167
- const [position, setPosition] = useState<DropPosition | null>(null);
168
- // The state paints the drop indicator; the ref is what the drop itself reads. See `onDragEnd`.
169
- const positionRef = useRef<DropPosition | null>(null);
170
- const setPositionState = useCallback((next: DropPosition | null) => {
171
- positionRef.current = next;
172
- setPosition((prev) => (prev === next ? prev : next));
173
- }, []);
174
-
175
- const sensors = useSensors(
176
- useSensor(MouseSensor, { activationConstraint: { distance: MOUSE_DISTANCE } }),
177
- useSensor(TouchSensor, {
178
- activationConstraint: { delay: TOUCH_DELAY_MS, tolerance: TOUCH_TOLERANCE },
179
- }),
180
- useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }),
181
- );
182
-
183
- const onDragStart = useCallback((event: DragStartEvent) => {
184
- setActiveId(String(event.active.id));
185
- }, []);
186
-
187
- const onDragOver = useCallback((event: DragOverEvent) => {
188
- setOverId(event.over ? String(event.over.id) : null);
189
- }, []);
190
-
191
- /**
192
- * A tree's drop position changes *within* one row — top edge means "before", middle means
193
- * "inside" — and `onDragOver` fires only when the row underneath changes. So the position is
194
- * tracked on every move instead.
195
- */
196
- const onDragMove = useCallback(
197
- (event: DragMoveEvent) => {
198
- if (mode !== "tree") return;
199
- const over = event.over;
200
- setOverId(over ? String(over.id) : null);
201
- if (!over) {
202
- setPositionState(null);
203
- return;
204
- }
205
- // Measured live off the row itself: dnd-kit's cached rect predates any scrolling the drag
206
- // has caused, and near a scrolling edge is exactly where a tree drop is hardest to aim.
207
- const el = document.querySelector(`[data-dnd-item="${escapeId(String(over.id))}"]`);
208
- const rect = el?.getBoundingClientRect() ?? over.rect;
209
- const y = pointerY(event.activatorEvent, event.delta.y) ?? rect.top + rect.height / 2;
210
- const offset = (y - rect.top) / (rect.height || 1);
211
-
212
- const nests = canNestInto ? canNestInto(String(over.id)) : true;
213
- setPositionState(
214
- !nests
215
- ? offset < 0.5
216
- ? "before"
217
- : "after"
218
- : offset < EDGE_BAND
219
- ? "before"
220
- : offset > 1 - EDGE_BAND
221
- ? "after"
222
- : "inside",
223
- );
224
- },
225
- [mode, canNestInto, setPositionState],
226
- );
227
-
228
- const reset = useCallback(() => {
229
- setActiveId(null);
230
- setOverId(null);
231
- setPositionState(null);
232
- }, [setPositionState]);
233
-
234
- const onDragEnd = useCallback(
235
- (event: DragEndEvent) => {
236
- const { active, over } = event;
237
- // Read before resetting: `reset` clears this, and it is the whole answer to "before, inside
238
- // or after".
239
- const dropped = positionRef.current;
240
- reset();
241
- if (!over) return;
242
-
243
- const id = String(active.id);
244
- const to = String(over.id);
245
- if (id === to && mode !== "list") return;
246
-
247
- const move: DragMove = {
248
- id,
249
- from: containerOf?.(id) ?? null,
250
- to,
251
- ...(indexOf ? { index: indexOf(to) } : null),
252
- // From the ref, not the state: the drop lands in the same tick as the last move, and the
253
- // handler dnd-kit is holding was built before that move could re-render.
254
- ...(mode === "tree" && dropped ? { position: dropped } : null),
255
- };
256
-
257
- if (canDrop && !canDrop(move)) return;
258
- onMove(move);
259
- },
260
- [canDrop, containerOf, indexOf, mode, onMove, reset],
261
- );
262
-
263
- const contextProps = useMemo(
264
- () => ({
265
- sensors,
266
- // A board's columns are large targets, so the *corner* nearest the pointer identifies the
267
- // intended one better than its centre; a list wants the centre.
268
- collisionDetection: mode === "board" ? closestCorners : closestCenter,
269
- onDragStart,
270
- onDragOver,
271
- onDragMove,
272
- onDragEnd,
273
- onDragCancel: reset,
274
- }),
275
- [sensors, mode, onDragStart, onDragOver, onDragMove, onDragEnd, reset],
276
- );
277
-
278
- return {
279
- /** Spread onto `<DndContext>`. */
280
- contextProps,
281
- DndContext,
282
- activeId,
283
- overId,
284
- position,
285
- disabled,
286
- };
287
- }
288
-
289
- /**
290
- * The ordered part of a surface — a column list, a table body, a tree's visible rows.
291
- *
292
- * `ids` must be in the order they are painted; that is how a drop position is worked out.
293
- *
294
- * `makeRoom` is the list's answer to "where will this land?". A flat list answers by sliding its
295
- * items apart to open a gap. A tree cannot: its rows have to stay put for a drop to mean *inside*
296
- * one of them rather than between two, and the gap would move the very row the pointer is being
297
- * measured against. It draws an indicator line instead.
298
- */
299
- export function DragList({
300
- ids,
301
- children,
302
- makeRoom = true,
303
- }: {
304
- ids: string[];
305
- children: ReactNode;
306
- makeRoom?: boolean;
307
- }) {
308
- return (
309
- <SortableContext items={ids} strategy={makeRoom ? verticalListSortingStrategy : NO_SHIFT}>
310
- {children}
311
- </SortableContext>
312
- );
313
- }
314
-
315
- /** A sorting strategy that moves nothing. */
316
- const NO_SHIFT = () => null;
317
-
318
- /**
319
- * One draggable item.
320
- *
321
- * `handleProps` go on whatever should start the drag — spread them on the row for a
322
- * drag-anywhere feel, or on a grip so the rest of the row stays clickable.
323
- */
324
- export function useDragItem(id: string, disabled = false, { follow = true } = {}) {
325
- const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({
326
- id,
327
- disabled,
328
- });
329
-
330
- // `follow` is whether the item travels with the pointer. A card should — it is the thing being
331
- // moved and there is nothing else to look at. A tree row should not: the drop indicator is
332
- // painted on the *target* row, and a ghost sliding over it hides the very answer it is giving.
333
- const moving = follow ? transform : null;
334
-
335
- return {
336
- ref: setNodeRef,
337
- handleProps: {
338
- ...attributes,
339
- ...listeners,
340
- // A stable hook for styling and for tests. dnd-kit sets no `draggable` attribute — it
341
- // works on pointer events — so there is otherwise nothing in the DOM saying "this drags".
342
- "data-dnd-item": id,
343
- },
344
- style: {
345
- transform: CSS.Transform.toString(moving),
346
- transition: follow ? transition : undefined,
347
- // `manipulation` keeps panning and scrolling working while suppressing the double-tap
348
- // zoom delay. `none` would kill scrolling on the item entirely, which is the usual
349
- // mistake — the long-press constraint above is what separates drag from scroll.
350
- touchAction: "manipulation" as const,
351
- },
352
- isDragging,
353
- };
354
- }
355
-
356
- /**
357
- * A container an item can be dropped into — one board column.
358
- *
359
- * A list does not need this: its items are their own drop targets. A board does, or dropping on
360
- * an empty column would have nothing to hit.
361
- */
362
- export function useDropContainer(id: string, disabled = false) {
363
- const { setNodeRef, isOver } = useDroppable({ id, disabled });
364
- return { ref: setNodeRef, isOver, containerProps: { "data-dnd-container": id } };
365
- }