@treenity/react 3.0.0 → 3.0.1

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 (369) hide show
  1. package/README.md +91 -0
  2. package/dist/AclEditor.d.ts +1 -1
  3. package/dist/AclEditor.d.ts.map +1 -1
  4. package/dist/AclEditor.js +5 -5
  5. package/dist/AclEditor.js.map +1 -1
  6. package/dist/ActionCards.d.ts +9 -0
  7. package/dist/ActionCards.d.ts.map +1 -0
  8. package/dist/ActionCards.js +96 -0
  9. package/dist/ActionCards.js.map +1 -0
  10. package/dist/App.d.ts.map +1 -1
  11. package/dist/App.js +71 -185
  12. package/dist/App.js.map +1 -1
  13. package/dist/ComponentSection.d.ts +15 -0
  14. package/dist/ComponentSection.d.ts.map +1 -0
  15. package/dist/ComponentSection.js +25 -0
  16. package/dist/ComponentSection.js.map +1 -0
  17. package/dist/ErrorBoundary.d.ts +18 -0
  18. package/dist/ErrorBoundary.d.ts.map +1 -0
  19. package/dist/ErrorBoundary.js +17 -0
  20. package/dist/ErrorBoundary.js.map +1 -0
  21. package/dist/Inspector.d.ts +1 -0
  22. package/dist/Inspector.d.ts.map +1 -1
  23. package/dist/Inspector.js +22 -347
  24. package/dist/Inspector.js.map +1 -1
  25. package/dist/Login.d.ts +8 -0
  26. package/dist/Login.d.ts.map +1 -0
  27. package/dist/Login.js +45 -0
  28. package/dist/Login.js.map +1 -0
  29. package/dist/NodeEditor.d.ts +11 -0
  30. package/dist/NodeEditor.d.ts.map +1 -0
  31. package/dist/NodeEditor.js +157 -0
  32. package/dist/NodeEditor.js.map +1 -0
  33. package/dist/Tree.d.ts +1 -0
  34. package/dist/Tree.d.ts.map +1 -1
  35. package/dist/Tree.js +8 -27
  36. package/dist/Tree.js.map +1 -1
  37. package/dist/bind/engine.js +1 -1
  38. package/dist/bind/engine.js.map +1 -1
  39. package/dist/bind/eval.d.ts +1 -1
  40. package/dist/bind/eval.d.ts.map +1 -1
  41. package/dist/bind/hook.d.ts +1 -1
  42. package/dist/bind/hook.d.ts.map +1 -1
  43. package/dist/bind/hook.js +1 -1
  44. package/dist/bind/hook.js.map +1 -1
  45. package/dist/cache.d.ts +1 -1
  46. package/dist/cache.d.ts.map +1 -1
  47. package/dist/cache.js +4 -0
  48. package/dist/cache.js.map +1 -1
  49. package/dist/client-tree.d.ts +1 -2
  50. package/dist/client-tree.d.ts.map +1 -1
  51. package/dist/client-tree.js +12 -5
  52. package/dist/client-tree.js.map +1 -1
  53. package/dist/client.d.ts +1 -1
  54. package/dist/client.d.ts.map +1 -1
  55. package/dist/client.js +2 -4
  56. package/dist/client.js.map +1 -1
  57. package/dist/components/ConfirmDialog.d.ts +9 -0
  58. package/dist/components/ConfirmDialog.d.ts.map +1 -0
  59. package/dist/components/ConfirmDialog.js +6 -0
  60. package/dist/components/ConfirmDialog.js.map +1 -0
  61. package/dist/components/ConfirmPopover.d.ts +8 -0
  62. package/dist/components/ConfirmPopover.d.ts.map +1 -0
  63. package/dist/components/ConfirmPopover.js +9 -0
  64. package/dist/components/ConfirmPopover.js.map +1 -0
  65. package/dist/components/PathBreadcrumb.d.ts +5 -0
  66. package/dist/components/PathBreadcrumb.d.ts.map +1 -0
  67. package/dist/components/PathBreadcrumb.js +16 -0
  68. package/dist/components/PathBreadcrumb.js.map +1 -0
  69. package/dist/components/lib/utils.d.ts +3 -0
  70. package/dist/components/lib/utils.d.ts.map +1 -0
  71. package/dist/components/lib/utils.js +6 -0
  72. package/dist/components/lib/utils.js.map +1 -0
  73. package/dist/components/ui/accordion.js +1 -1
  74. package/dist/components/ui/accordion.js.map +1 -1
  75. package/dist/components/ui/alert-dialog.d.ts +19 -0
  76. package/dist/components/ui/alert-dialog.d.ts.map +1 -0
  77. package/dist/components/ui/alert-dialog.js +42 -0
  78. package/dist/components/ui/alert-dialog.js.map +1 -0
  79. package/dist/components/ui/badge.js +1 -1
  80. package/dist/components/ui/badge.js.map +1 -1
  81. package/dist/components/ui/breadcrumb.d.ts +12 -0
  82. package/dist/components/ui/breadcrumb.d.ts.map +1 -0
  83. package/dist/components/ui/breadcrumb.js +28 -0
  84. package/dist/components/ui/breadcrumb.js.map +1 -0
  85. package/dist/components/ui/button.d.ts +9 -8
  86. package/dist/components/ui/button.d.ts.map +1 -1
  87. package/dist/components/ui/button.js +26 -21
  88. package/dist/components/ui/button.js.map +1 -1
  89. package/dist/components/ui/card.d.ts +10 -0
  90. package/dist/components/ui/card.d.ts.map +1 -0
  91. package/dist/components/ui/card.js +25 -0
  92. package/dist/components/ui/card.js.map +1 -0
  93. package/dist/components/ui/checkbox.js +1 -1
  94. package/dist/components/ui/checkbox.js.map +1 -1
  95. package/dist/components/ui/collapsible.d.ts +6 -0
  96. package/dist/components/ui/collapsible.d.ts.map +1 -0
  97. package/dist/components/ui/collapsible.js +13 -0
  98. package/dist/components/ui/collapsible.js.map +1 -0
  99. package/dist/components/ui/command.d.ts +19 -0
  100. package/dist/components/ui/command.d.ts.map +1 -0
  101. package/dist/components/ui/command.js +35 -0
  102. package/dist/components/ui/command.js.map +1 -0
  103. package/dist/components/ui/dialog.d.ts.map +1 -1
  104. package/dist/components/ui/dialog.js +1 -1
  105. package/dist/components/ui/dialog.js.map +1 -1
  106. package/dist/components/ui/drawer.js +1 -1
  107. package/dist/components/ui/drawer.js.map +1 -1
  108. package/dist/components/ui/dropdown-menu.d.ts +26 -0
  109. package/dist/components/ui/dropdown-menu.d.ts.map +1 -0
  110. package/dist/components/ui/dropdown-menu.js +52 -0
  111. package/dist/components/ui/dropdown-menu.js.map +1 -0
  112. package/dist/components/ui/form-field.d.ts +7 -0
  113. package/dist/components/ui/form-field.d.ts.map +1 -0
  114. package/dist/components/ui/form-field.js +17 -0
  115. package/dist/components/ui/form-field.js.map +1 -0
  116. package/dist/components/ui/input.js +1 -1
  117. package/dist/components/ui/input.js.map +1 -1
  118. package/dist/components/ui/label.js +1 -1
  119. package/dist/components/ui/label.js.map +1 -1
  120. package/dist/components/ui/pagination.d.ts +14 -0
  121. package/dist/components/ui/pagination.d.ts.map +1 -0
  122. package/dist/components/ui/pagination.js +30 -0
  123. package/dist/components/ui/pagination.js.map +1 -0
  124. package/dist/components/ui/popover.js +2 -2
  125. package/dist/components/ui/popover.js.map +1 -1
  126. package/dist/components/ui/progress.js +1 -1
  127. package/dist/components/ui/progress.js.map +1 -1
  128. package/dist/components/ui/resizable.d.ts +8 -0
  129. package/dist/components/ui/resizable.d.ts.map +1 -0
  130. package/dist/components/ui/resizable.js +14 -0
  131. package/dist/components/ui/resizable.js.map +1 -0
  132. package/dist/components/ui/scroll-area.d.ts +6 -0
  133. package/dist/components/ui/scroll-area.d.ts.map +1 -0
  134. package/dist/components/ui/scroll-area.js +13 -0
  135. package/dist/components/ui/scroll-area.js.map +1 -0
  136. package/dist/components/ui/select.js +1 -1
  137. package/dist/components/ui/select.js.map +1 -1
  138. package/dist/components/ui/separator.d.ts +5 -0
  139. package/dist/components/ui/separator.d.ts.map +1 -0
  140. package/dist/components/ui/separator.js +9 -0
  141. package/dist/components/ui/separator.js.map +1 -0
  142. package/dist/components/ui/sheet.d.ts +15 -0
  143. package/dist/components/ui/sheet.d.ts.map +1 -0
  144. package/dist/components/ui/sheet.js +40 -0
  145. package/dist/components/ui/sheet.js.map +1 -0
  146. package/dist/components/ui/skeleton.d.ts +3 -0
  147. package/dist/components/ui/skeleton.d.ts.map +1 -0
  148. package/dist/components/ui/skeleton.js +7 -0
  149. package/dist/components/ui/skeleton.js.map +1 -0
  150. package/dist/components/ui/slider.js +1 -1
  151. package/dist/components/ui/slider.js.map +1 -1
  152. package/dist/components/ui/switch.js +1 -1
  153. package/dist/components/ui/switch.js.map +1 -1
  154. package/dist/components/ui/table.d.ts +11 -0
  155. package/dist/components/ui/table.d.ts.map +1 -0
  156. package/dist/components/ui/table.js +29 -0
  157. package/dist/components/ui/table.js.map +1 -0
  158. package/dist/components/ui/tabs.d.ts +12 -0
  159. package/dist/components/ui/tabs.d.ts.map +1 -0
  160. package/dist/components/ui/tabs.js +29 -0
  161. package/dist/components/ui/tabs.js.map +1 -0
  162. package/dist/components/ui/textarea.js +1 -1
  163. package/dist/components/ui/textarea.js.map +1 -1
  164. package/dist/components/ui/toggle-group.d.ts +10 -0
  165. package/dist/components/ui/toggle-group.d.ts.map +1 -0
  166. package/dist/components/ui/toggle-group.js +23 -0
  167. package/dist/components/ui/toggle-group.js.map +1 -0
  168. package/dist/components/ui/toggle.d.ts +10 -0
  169. package/dist/components/ui/toggle.d.ts.map +1 -0
  170. package/dist/components/ui/toggle.js +27 -0
  171. package/dist/components/ui/toggle.js.map +1 -0
  172. package/dist/components/ui/tooltip.js +1 -1
  173. package/dist/components/ui/tooltip.js.map +1 -1
  174. package/dist/context/index.d.ts +27 -10
  175. package/dist/context/index.d.ts.map +1 -1
  176. package/dist/context/index.js +43 -36
  177. package/dist/context/index.js.map +1 -1
  178. package/dist/events.d.ts +10 -0
  179. package/dist/events.d.ts.map +1 -0
  180. package/dist/events.js +78 -0
  181. package/dist/events.js.map +1 -0
  182. package/dist/fiber-tree.d.ts +3 -0
  183. package/dist/fiber-tree.d.ts.map +1 -0
  184. package/dist/fiber-tree.js +93 -0
  185. package/dist/fiber-tree.js.map +1 -0
  186. package/dist/hooks.d.ts +5 -2
  187. package/dist/hooks.d.ts.map +1 -1
  188. package/dist/hooks.js +66 -6
  189. package/dist/hooks.js.map +1 -1
  190. package/dist/idb.d.ts +1 -1
  191. package/dist/idb.d.ts.map +1 -1
  192. package/dist/lib/to-plain.d.ts +2 -0
  193. package/dist/lib/to-plain.d.ts.map +1 -0
  194. package/dist/lib/to-plain.js +21 -0
  195. package/dist/lib/to-plain.js.map +1 -0
  196. package/dist/main.d.ts +1 -1
  197. package/dist/main.d.ts.map +1 -1
  198. package/dist/main.js +4 -3
  199. package/dist/main.js.map +1 -1
  200. package/dist/mods/clients.d.ts +3 -0
  201. package/dist/mods/clients.d.ts.map +1 -0
  202. package/dist/mods/clients.js +4 -0
  203. package/dist/mods/clients.js.map +1 -0
  204. package/dist/mods/editor-ui/FieldLabel.d.ts +15 -0
  205. package/dist/mods/editor-ui/FieldLabel.d.ts.map +1 -0
  206. package/dist/mods/editor-ui/FieldLabel.js +55 -0
  207. package/dist/mods/editor-ui/FieldLabel.js.map +1 -0
  208. package/dist/mods/editor-ui/client.d.ts +1 -1
  209. package/dist/mods/editor-ui/client.d.ts.map +1 -1
  210. package/dist/mods/editor-ui/client.js +1 -1
  211. package/dist/mods/editor-ui/client.js.map +1 -1
  212. package/dist/mods/editor-ui/default-edit.d.ts +2 -0
  213. package/dist/mods/editor-ui/default-edit.d.ts.map +1 -0
  214. package/dist/mods/editor-ui/default-edit.js +54 -0
  215. package/dist/mods/editor-ui/default-edit.js.map +1 -0
  216. package/dist/mods/editor-ui/default-view.d.ts +8 -1
  217. package/dist/mods/editor-ui/default-view.d.ts.map +1 -1
  218. package/dist/mods/editor-ui/default-view.js +8 -5
  219. package/dist/mods/editor-ui/default-view.js.map +1 -1
  220. package/dist/mods/editor-ui/dir-view.js +0 -2
  221. package/dist/mods/editor-ui/dir-view.js.map +1 -1
  222. package/dist/mods/editor-ui/empty-placeholder.d.ts +5 -0
  223. package/dist/mods/editor-ui/empty-placeholder.d.ts.map +1 -0
  224. package/dist/mods/editor-ui/empty-placeholder.js +14 -0
  225. package/dist/mods/editor-ui/empty-placeholder.js.map +1 -0
  226. package/dist/mods/editor-ui/form-field.d.ts +17 -0
  227. package/dist/mods/editor-ui/form-field.d.ts.map +1 -0
  228. package/dist/mods/editor-ui/form-field.js +68 -0
  229. package/dist/mods/editor-ui/form-field.js.map +1 -0
  230. package/dist/mods/editor-ui/form-fields.d.ts +1 -2
  231. package/dist/mods/editor-ui/form-fields.d.ts.map +1 -1
  232. package/dist/mods/editor-ui/form-fields.js +56 -60
  233. package/dist/mods/editor-ui/form-fields.js.map +1 -1
  234. package/dist/mods/editor-ui/layout-view.js +3 -2
  235. package/dist/mods/editor-ui/layout-view.js.map +1 -1
  236. package/dist/mods/editor-ui/list-items.js +1 -1
  237. package/dist/mods/editor-ui/list-items.js.map +1 -1
  238. package/dist/mods/editor-ui/node-utils.d.ts +2 -2
  239. package/dist/mods/editor-ui/node-utils.d.ts.map +1 -1
  240. package/dist/mods/editor-ui/node-utils.js +4 -5
  241. package/dist/mods/editor-ui/node-utils.js.map +1 -1
  242. package/dist/mods/editor-ui/type-picker.d.ts +15 -0
  243. package/dist/mods/editor-ui/type-picker.d.ts.map +1 -0
  244. package/dist/mods/editor-ui/type-picker.js +69 -0
  245. package/dist/mods/editor-ui/type-picker.js.map +1 -0
  246. package/dist/mods/editor-ui/user-view.js +1 -1
  247. package/dist/mods/editor-ui/user-view.js.map +1 -1
  248. package/dist/mods/servers.d.ts +1 -0
  249. package/dist/mods/servers.d.ts.map +1 -0
  250. package/dist/mods/servers.js +4 -0
  251. package/dist/mods/servers.js.map +1 -0
  252. package/dist/mods/treenity/groups/index.js +1 -1
  253. package/dist/mods/treenity/groups/index.js.map +1 -1
  254. package/dist/mods/treenity/preview.js +1 -1
  255. package/dist/mods/treenity/preview.js.map +1 -1
  256. package/dist/mods/treenity/ref-view.js +1 -1
  257. package/dist/mods/treenity/ref-view.js.map +1 -1
  258. package/dist/mods/treenity/schema-form.js +1 -1
  259. package/dist/mods/treenity/schema-form.js.map +1 -1
  260. package/dist/mods/treenity/seed.js +1 -1
  261. package/dist/mods/treenity/seed.js.map +1 -1
  262. package/dist/mods/treenity/type-view.js +1 -1
  263. package/dist/mods/treenity/type-view.js.map +1 -1
  264. package/dist/schema-loader.d.ts +1 -1
  265. package/dist/schema-loader.d.ts.map +1 -1
  266. package/dist/schema-loader.js +1 -1
  267. package/dist/schema-loader.js.map +1 -1
  268. package/dist/symbols.d.ts +5 -0
  269. package/dist/symbols.d.ts.map +1 -0
  270. package/dist/symbols.js +16 -0
  271. package/dist/symbols.js.map +1 -0
  272. package/dist/trpc.d.ts +10 -3
  273. package/dist/trpc.d.ts.map +1 -1
  274. package/package.json +74 -8
  275. package/src/AclEditor.tsx +11 -18
  276. package/src/ActionCards.tsx +224 -0
  277. package/src/App.tsx +204 -385
  278. package/src/ComponentSection.tsx +113 -0
  279. package/src/ErrorBoundary.tsx +37 -0
  280. package/src/Inspector.css +54 -0
  281. package/src/Inspector.tsx +73 -793
  282. package/src/Login.tsx +97 -0
  283. package/src/NodeEditor.tsx +300 -0
  284. package/src/Tree.css +91 -0
  285. package/src/Tree.tsx +40 -43
  286. package/src/bind/bind.test.ts +1 -1
  287. package/src/bind/engine.ts +1 -1
  288. package/src/bind/eval.ts +1 -1
  289. package/src/bind/hook.ts +1 -1
  290. package/src/bind/pipes.ts +1 -1
  291. package/src/cache.ts +5 -1
  292. package/src/client-tree.test.ts +1 -1
  293. package/src/client-tree.ts +22 -16
  294. package/src/client.ts +2 -4
  295. package/src/components/ConfirmDialog.tsx +34 -0
  296. package/src/components/ConfirmPopover.tsx +41 -0
  297. package/src/components/PathBreadcrumb.tsx +36 -0
  298. package/src/components/lib/utils.ts +6 -0
  299. package/src/components/lib/utils.ts.bak +6 -0
  300. package/src/components/ui/accordion.tsx +1 -1
  301. package/src/components/ui/alert-dialog.tsx +189 -0
  302. package/src/components/ui/badge.tsx +1 -1
  303. package/src/components/ui/breadcrumb.tsx +108 -0
  304. package/src/components/ui/button.tsx +53 -31
  305. package/src/components/ui/card.tsx +91 -0
  306. package/src/components/ui/checkbox.tsx +1 -1
  307. package/src/components/ui/collapsible.tsx +31 -0
  308. package/src/components/ui/command.tsx +177 -0
  309. package/src/components/ui/dialog.tsx +1 -2
  310. package/src/components/ui/drawer.tsx +1 -1
  311. package/src/components/ui/dropdown-menu.tsx +256 -0
  312. package/src/components/ui/form-field.tsx +37 -0
  313. package/src/components/ui/input.tsx +1 -1
  314. package/src/components/ui/label.tsx +1 -1
  315. package/src/components/ui/pagination.tsx +127 -0
  316. package/src/components/ui/popover.tsx +2 -2
  317. package/src/components/ui/progress.tsx +1 -1
  318. package/src/components/ui/resizable.tsx +47 -0
  319. package/src/components/ui/scroll-area.tsx +55 -0
  320. package/src/components/ui/select.tsx +1 -1
  321. package/src/components/ui/separator.tsx +27 -0
  322. package/src/components/ui/sheet.tsx +140 -0
  323. package/src/components/ui/skeleton.tsx +13 -0
  324. package/src/components/ui/slider.tsx +1 -1
  325. package/src/components/ui/switch.tsx +1 -1
  326. package/src/components/ui/table.tsx +115 -0
  327. package/src/components/ui/tabs.tsx +88 -0
  328. package/src/components/ui/textarea.tsx +1 -1
  329. package/src/components/ui/toggle-group.tsx +82 -0
  330. package/src/components/ui/toggle.tsx +46 -0
  331. package/src/components/ui/tooltip.tsx +1 -1
  332. package/src/context/index.tsx +75 -42
  333. package/src/events.ts +81 -0
  334. package/src/fiber-tree.ts +112 -0
  335. package/src/hooks.ts +88 -9
  336. package/src/idb.ts +1 -1
  337. package/src/lib/to-plain.ts +21 -0
  338. package/src/main.tsx +3 -1
  339. package/src/mods/clients.ts +3 -0
  340. package/src/mods/editor-ui/FieldLabel.tsx +124 -0
  341. package/src/mods/editor-ui/client.ts +1 -1
  342. package/src/mods/editor-ui/default-edit.tsx +99 -0
  343. package/src/mods/editor-ui/default-view.tsx +13 -8
  344. package/src/mods/editor-ui/dir-view.tsx +2 -2
  345. package/src/mods/editor-ui/editor-ui.css +174 -0
  346. package/src/mods/editor-ui/empty-placeholder.tsx +39 -0
  347. package/src/mods/editor-ui/form-field.tsx +144 -0
  348. package/src/mods/editor-ui/form-fields.tsx +132 -113
  349. package/src/mods/editor-ui/layout-view.tsx +4 -2
  350. package/src/mods/editor-ui/list-items.tsx +2 -2
  351. package/src/mods/editor-ui/node-utils.ts +4 -5
  352. package/src/mods/editor-ui/type-picker.tsx +147 -0
  353. package/src/mods/editor-ui/user-view.tsx +1 -1
  354. package/src/mods/servers.ts +2 -0
  355. package/src/mods/treenity/groups/index.tsx +1 -1
  356. package/src/mods/treenity/preview.tsx +1 -1
  357. package/src/mods/treenity/ref-view.tsx +1 -1
  358. package/src/mods/treenity/schema-form.tsx +1 -1
  359. package/src/mods/treenity/seed.ts +1 -1
  360. package/src/mods/treenity/type-view.tsx +1 -1
  361. package/src/optimistic.test.ts +111 -0
  362. package/src/remote-tree.test.ts +1 -1
  363. package/src/remote-tree.ts +1 -1
  364. package/src/root.css +117 -0
  365. package/src/schema-loader.ts +1 -1
  366. package/src/symbols.ts +18 -0
  367. package/src/index.html +0 -14
  368. package/src/style.css +0 -1269
  369. package/src/vite-env.d.ts +0 -3
@@ -0,0 +1,3 @@
1
+ // Barrel: all react mod client registrations
2
+ import './editor-ui/client';
3
+ import './treenity/client';
@@ -0,0 +1,124 @@
1
+ // FieldLabel — interactive label for Inspector fields
2
+ // Click → dropdown menu (value/$ref/$map + copy/clear), drop target for tree nodes
3
+
4
+ import {
5
+ DropdownMenu,
6
+ DropdownMenuContent,
7
+ DropdownMenuItem,
8
+ DropdownMenuSeparator,
9
+ DropdownMenuTrigger,
10
+ } from '#components/ui/dropdown-menu';
11
+ import { isRef } from '@treenity/core';
12
+ import { useState } from 'react';
13
+
14
+ type FieldMode = 'value' | 'ref' | 'map';
15
+
16
+ function getFieldMode(v: unknown): FieldMode {
17
+ if (v && typeof v === 'object' && isRef(v)) {
18
+ return (v as { $map?: string }).$map !== undefined ? 'map' : 'ref';
19
+ }
20
+ return 'value';
21
+ }
22
+
23
+ const MODE_LABELS: Record<FieldMode, string> = { value: 'val', ref: '$ref', map: '$map' };
24
+
25
+ /** Interactive field label — click for mode menu, drop target for tree nodes */
26
+ export function FieldLabel({ label, value, onChange }: {
27
+ label: string;
28
+ value: unknown;
29
+ onChange?: (next: unknown) => void;
30
+ }) {
31
+ const [dragOver, setDragOver] = useState(false);
32
+ const mode = getFieldMode(value);
33
+
34
+ function switchMode(next: FieldMode) {
35
+ if (!onChange || next === mode) return;
36
+ if (next === 'value') {
37
+ onChange(0);
38
+ } else if (next === 'ref') {
39
+ onChange({ $ref: '.' });
40
+ } else {
41
+ const r = isRef(value) ? (value as { $ref: string }).$ref : '.';
42
+ onChange({ $ref: r, $map: '' });
43
+ }
44
+ }
45
+
46
+ if (!onChange) {
47
+ return <label>{label}</label>;
48
+ }
49
+
50
+ return (
51
+ <label
52
+ className={dragOver ? 'text-primary cursor-pointer' : 'cursor-pointer'}
53
+ onDragOver={(e) => {
54
+ if (e.dataTransfer.types.includes('application/treenity-path')) {
55
+ e.preventDefault();
56
+ setDragOver(true);
57
+ }
58
+ }}
59
+ onDragLeave={() => setDragOver(false)}
60
+ onDrop={(e) => {
61
+ e.preventDefault();
62
+ setDragOver(false);
63
+ const path = e.dataTransfer.getData('application/treenity-path');
64
+ if (path && onChange) {
65
+ const existing = isRef(value) ? (value as { $map?: string }).$map : undefined;
66
+ onChange(existing !== undefined ? { $ref: path, $map: existing } : { $ref: path });
67
+ }
68
+ }}
69
+ >
70
+ <DropdownMenu>
71
+ <DropdownMenuTrigger asChild>
72
+ <span className="block overflow-hidden text-ellipsis">{label}</span>
73
+ </DropdownMenuTrigger>
74
+ <DropdownMenuContent align="start" className="min-w-[100px]">
75
+ {(['value', 'ref', 'map'] as FieldMode[]).map((m) => (
76
+ <DropdownMenuItem key={m} onClick={() => switchMode(m)}>
77
+ {mode === m ? '\u25CF ' : '\u00A0\u00A0'}{MODE_LABELS[m]}
78
+ </DropdownMenuItem>
79
+ ))}
80
+ <DropdownMenuSeparator />
81
+ <DropdownMenuItem onClick={() => navigator.clipboard.writeText(JSON.stringify(value))}>
82
+ Copy
83
+ </DropdownMenuItem>
84
+ <DropdownMenuItem onClick={() => onChange(undefined)}>
85
+ Clear
86
+ </DropdownMenuItem>
87
+ </DropdownMenuContent>
88
+ </DropdownMenu>
89
+ </label>
90
+ );
91
+ }
92
+
93
+ /** Inline ref/map editor — $ref + optional $map, compact single/double row */
94
+ export function RefEditor({ value, onChange }: {
95
+ value: { $ref: string; $map?: string };
96
+ onChange: (next: unknown) => void;
97
+ }) {
98
+ const hasMap = value.$map !== undefined;
99
+
100
+ return (
101
+ <div className="flex flex-col gap-1 flex-1 min-w-0">
102
+ <div className="flex items-center gap-1">
103
+ <span className="text-[9px] text-muted-foreground shrink-0 w-5">$ref</span>
104
+ <input
105
+ className="flex-1 min-w-0"
106
+ value={value.$ref}
107
+ onChange={(e) => onChange(hasMap ? { $ref: e.target.value, $map: value.$map } : { $ref: e.target.value })}
108
+ placeholder="path"
109
+ />
110
+ </div>
111
+ {hasMap && (
112
+ <div className="flex items-center gap-1">
113
+ <span className="text-[9px] text-muted-foreground shrink-0 w-5">$map</span>
114
+ <input
115
+ className="flex-1 min-w-0"
116
+ value={value.$map ?? ''}
117
+ onChange={(e) => onChange({ $ref: value.$ref, $map: e.target.value })}
118
+ placeholder="field"
119
+ />
120
+ </div>
121
+ )}
122
+ </div>
123
+ );
124
+ }
@@ -1,7 +1,7 @@
1
1
  import './default-view';
2
+ import './default-edit';
2
3
  import './layout-view';
3
4
  import './user-view';
4
- import './dir-view';
5
5
  import './list-items';
6
6
  import { registerFormFields } from './form-fields';
7
7
 
@@ -0,0 +1,99 @@
1
+ import { useSchema } from '#schema-loader';
2
+ import { type ComponentData, isRef, register, resolve } from '@treenity/core';
3
+ import { createElement } from 'react';
4
+ import { FieldLabel, RefEditor } from './FieldLabel';
5
+ import { renderField, StringArrayField } from './form-field';
6
+
7
+ function DefaultEditForm({ value, onChange }: { value: ComponentData; onChange?: (next: ComponentData) => void }) {
8
+ const schema = useSchema(value.$type);
9
+ if (schema === undefined) return null;
10
+
11
+ const data: Record<string, unknown> = {};
12
+ for (const [k, v] of Object.entries(value)) {
13
+ if (!k.startsWith('$')) data[k] = v;
14
+ }
15
+
16
+ const setData = (fn: (prev: Record<string, unknown>) => Record<string, unknown>) => {
17
+ if (!onChange) return;
18
+ const next = fn(data);
19
+ onChange({ ...value, ...next } as ComponentData);
20
+ };
21
+
22
+ // Schema-driven form
23
+ if (schema && Object.keys(schema.properties).length > 0) {
24
+ return (
25
+ <div className="py-0.5 pb-2.5">
26
+ {Object.entries(schema.properties).map(([field, prop]) => {
27
+ const p = prop as {
28
+ type: string; title: string; format?: string; description?: string;
29
+ readOnly?: boolean; enum?: string[]; items?: { type?: string; properties?: Record<string, unknown> };
30
+ refType?: string;
31
+ };
32
+ return renderField(field, {
33
+ type: p.format ?? p.type, label: p.title ?? field, placeholder: p.description,
34
+ readOnly: p.readOnly || !onChange, enum: p.enum, items: p.items, refType: p.refType,
35
+ }, data, setData);
36
+ })}
37
+ </div>
38
+ );
39
+ }
40
+
41
+ // Fallback: raw field rendering
42
+ if (Object.keys(data).length > 0) {
43
+ return (
44
+ <div className="py-0.5 pb-2.5">
45
+ {Object.entries(data).map(([k, v]) => {
46
+ const onCh = (next: unknown) => setData((prev) => ({ ...prev, [k]: next }));
47
+ if (v && typeof v === 'object' && isRef(v)) {
48
+ return (
49
+ <div key={k} className="field">
50
+ <FieldLabel label={k} value={v} onChange={onCh} />
51
+ <RefEditor value={v as { $ref: string; $map?: string }} onChange={onCh} />
52
+ </div>
53
+ );
54
+ }
55
+ return (
56
+ <div key={k} className={`field${Array.isArray(v) || (typeof v === 'object' && v !== null) ? ' stack' : ''}`}>
57
+ <FieldLabel label={k} value={v} onChange={onCh} />
58
+ {typeof v === 'boolean' ? (
59
+ <label className="flex items-center gap-2 cursor-pointer">
60
+ <input type="checkbox" checked={!!data[k]} className="w-auto"
61
+ onChange={(e) => setData((prev) => ({ ...prev, [k]: e.target.checked }))} />
62
+ {data[k] ? 'true' : 'false'}
63
+ </label>
64
+ ) : typeof v === 'number' ? (
65
+ <input type="number" value={String(data[k] ?? 0)}
66
+ onChange={(e) => setData((prev) => ({ ...prev, [k]: Number(e.target.value) }))} />
67
+ ) : Array.isArray(v) ? (
68
+ <StringArrayField value={data[k] as unknown[]}
69
+ onChange={(next) => setData((prev) => ({ ...prev, [k]: next }))} />
70
+ ) : typeof v === 'object' ? (
71
+ (() => {
72
+ const h = resolve('object', 'react:form');
73
+ return h
74
+ ? createElement(h as any, {
75
+ value: { $type: 'object', value: data[k] },
76
+ onChange: (next: { value: unknown }) => setData((prev) => ({ ...prev, [k]: next.value })),
77
+ })
78
+ : <pre className="text-[11px] font-mono text-foreground/60">{JSON.stringify(data[k], null, 2)}</pre>;
79
+ })()
80
+ ) : (
81
+ <input value={String(data[k] ?? '')}
82
+ onChange={(e) => setData((prev) => ({ ...prev, [k]: e.target.value }))} />
83
+ )}
84
+ </div>
85
+ );
86
+ })}
87
+ </div>
88
+ );
89
+ }
90
+
91
+ // Empty
92
+ return (
93
+ <pre className="text-[11px] font-mono text-foreground/60 bg-muted/30 rounded p-2 whitespace-pre-wrap">
94
+ {JSON.stringify(data, null, 2)}
95
+ </pre>
96
+ );
97
+ }
98
+
99
+ register('default', 'react:edit', DefaultEditForm as any);
@@ -1,8 +1,11 @@
1
+ import './editor-ui.css';
2
+ import { Button } from '#components/ui/button';
1
3
  import { Render, RenderContext } from '#context';
2
4
  import { useChildren } from '#hooks';
3
5
  import { trpc } from '#trpc';
4
- import { type ComponentData, type NodeData, register } from '@treenity/core/core';
6
+ import { type ComponentData, type NodeData, register } from '@treenity/core';
5
7
  import { useCallback, useState } from 'react';
8
+ import { EmptyNodePlaceholder } from './empty-placeholder';
6
9
  import { getComponents, getPlainFields, getSchema } from './node-utils';
7
10
 
8
11
  /** Fallback for components without their own react handler */
@@ -45,7 +48,7 @@ function ComponentFieldsView({ value }: { value: ComponentData }) {
45
48
  );
46
49
  }
47
50
 
48
- function GenerateViewButton({ type, sample }: { type: string; sample: NodeData }) {
51
+ export function GenerateViewButton({ type, sample, context, label }: { type: string; sample: NodeData; context?: string; label?: string }) {
49
52
  const [status, setStatus] = useState<'idle' | 'generating' | 'done' | 'error'>('idle');
50
53
  const [error, setError] = useState('');
51
54
 
@@ -58,7 +61,7 @@ function GenerateViewButton({ type, sample }: { type: string; sample: NodeData }
58
61
  await trpc.execute.mutate({
59
62
  path: '/metatron',
60
63
  action: 'task',
61
- data: { prompt: `Generate a React view for type "${type}". Sample data:\n${JSON.stringify(clean, null, 2)}` },
64
+ data: { prompt: `Generate a React view for type "${type}"${context ? ` in context "${context}"` : ''}. Sample data:\n${JSON.stringify(clean, null, 2)}` },
62
65
  });
63
66
  setStatus('done');
64
67
  } catch (err: any) {
@@ -78,12 +81,14 @@ function GenerateViewButton({ type, sample }: { type: string; sample: NodeData }
78
81
  }
79
82
 
80
83
  return (
81
- <button
84
+ <Button
85
+ variant="outline"
86
+ size="sm"
82
87
  onClick={generate}
83
- className="text-sm text-blue-400 hover:text-blue-300 border border-blue-400/30 rounded px-3 py-1.5 my-2"
88
+ className="text-blue-400 border-blue-400/30 hover:text-blue-300 my-2"
84
89
  >
85
- Generate AI View
86
- </button>
90
+ {label ?? 'Generate AI View'}
91
+ </Button>
87
92
  );
88
93
  }
89
94
 
@@ -134,7 +139,7 @@ function DefaultNodeView({ value }: { value: NodeData }) {
134
139
  </RenderContext>
135
140
  )}
136
141
 
137
- {children.length === 0 && !hasInfo && <div className="node-empty">Empty node</div>}
142
+ {children.length === 0 && !hasInfo && <EmptyNodePlaceholder value={value} />}
138
143
  </div>
139
144
  );
140
145
  }
@@ -1,6 +1,6 @@
1
1
  import { Render, RenderContext } from '#context';
2
2
  import { useChildren } from '#hooks';
3
- import { type NodeData, register } from '@treenity/core/core';
3
+ import { type NodeData } from '@treenity/core';
4
4
 
5
5
  const STATUS_COLORS: Record<string, [string, string]> = {
6
6
  draft: ['var(--accent-subtle, #1a2a3a)', 'var(--accent)'],
@@ -88,4 +88,4 @@ function FolderView({ value }: { value: NodeData }) {
88
88
  );
89
89
  }
90
90
 
91
- register('dir', 'react', FolderView as any);
91
+ // register('dir', 'react', FolderView as any);
@@ -0,0 +1,174 @@
1
+ /* Form fields */
2
+ .field {
3
+ display: flex;
4
+ align-items: center;
5
+ gap: 8px;
6
+ margin-bottom: 4px;
7
+ }
8
+ .field:last-child {
9
+ margin-bottom: 0;
10
+ }
11
+ .field label {
12
+ font-size: 11px;
13
+ font-weight: 500;
14
+ color: var(--text-2);
15
+ width: 60px;
16
+ flex-shrink: 0;
17
+ white-space: nowrap;
18
+ position: relative;
19
+ }
20
+ .field:has(textarea),
21
+ .field.stack {
22
+ flex-direction: column;
23
+ align-items: stretch;
24
+ }
25
+ .field:has(textarea) label,
26
+ .field.stack label {
27
+ min-width: unset;
28
+ margin-bottom: 3px;
29
+ }
30
+
31
+ /* Component data view — shows field values in default view */
32
+ .comp-view-card {
33
+ background: var(--surface);
34
+ border: 1px solid var(--border);
35
+ border-radius: var(--radius-lg);
36
+ padding: 14px 16px;
37
+ margin-bottom: 12px;
38
+ }
39
+ .comp-view-header {
40
+ font-size: 11px;
41
+ font-weight: 600;
42
+ color: var(--text-3);
43
+ text-transform: uppercase;
44
+ letter-spacing: 0.5px;
45
+ margin-bottom: 10px;
46
+ display: flex;
47
+ align-items: center;
48
+ gap: 8px;
49
+ }
50
+ .comp-view-header .comp-type {
51
+ font-family: var(--mono);
52
+ color: var(--accent);
53
+ background: var(--accent-subtle);
54
+ padding: 1px 6px;
55
+ border-radius: 10px;
56
+ font-size: 10px;
57
+ text-transform: none;
58
+ }
59
+ .comp-view-row {
60
+ display: flex;
61
+ gap: 8px;
62
+ font-size: 13px;
63
+ padding: 3px 0;
64
+ }
65
+ .comp-view-label {
66
+ color: var(--text-3);
67
+ min-width: 80px;
68
+ flex-shrink: 0;
69
+ }
70
+ .comp-view-value {
71
+ color: var(--text);
72
+ word-break: break-word;
73
+ }
74
+
75
+ /* Info bar — compact chips for components and fields */
76
+ .node-info-bar {
77
+ display: flex;
78
+ flex-wrap: wrap;
79
+ gap: 8px;
80
+ margin-bottom: 20px;
81
+ }
82
+ .node-info-chip {
83
+ display: inline-flex;
84
+ align-items: center;
85
+ gap: 6px;
86
+ padding: 4px 10px;
87
+ border-radius: 16px;
88
+ background: var(--surface);
89
+ border: 1px solid var(--border);
90
+ font-size: 12px;
91
+ }
92
+ .node-info-chip-label {
93
+ color: var(--text-2);
94
+ font-weight: 500;
95
+ }
96
+ .node-info-chip.data .node-info-chip-val {
97
+ color: var(--text);
98
+ max-width: 120px;
99
+ overflow: hidden;
100
+ text-overflow: ellipsis;
101
+ white-space: nowrap;
102
+ }
103
+
104
+ /* Children grid — file explorer cards with staggered reveal */
105
+ .children-grid {
106
+ display: flex;
107
+ flex-direction: column;
108
+ gap: 2px;
109
+ }
110
+
111
+ .child-card {
112
+ display: flex;
113
+ align-items: center;
114
+ gap: 12px;
115
+ padding: 10px 14px;
116
+ border-radius: var(--radius);
117
+ cursor: pointer;
118
+ transition: all var(--transition);
119
+ }
120
+ .child-card:hover {
121
+ background: var(--surface);
122
+ }
123
+
124
+ .child-icon {
125
+ width: 32px;
126
+ height: 32px;
127
+ border-radius: 8px;
128
+ background: var(--surface-2);
129
+ border: 1px solid var(--border);
130
+ display: flex;
131
+ align-items: center;
132
+ justify-content: center;
133
+ font-size: 13px;
134
+ font-weight: 600;
135
+ color: var(--text-2);
136
+ flex-shrink: 0;
137
+ }
138
+ .child-info {
139
+ flex: 1;
140
+ min-width: 0;
141
+ }
142
+ .child-name {
143
+ display: block;
144
+ font-size: 13px;
145
+ font-weight: 500;
146
+ color: var(--text);
147
+ overflow: hidden;
148
+ text-overflow: ellipsis;
149
+ white-space: nowrap;
150
+ }
151
+ .child-type {
152
+ display: block;
153
+ font-size: 11px;
154
+ color: var(--text-3);
155
+ font-family: var(--mono);
156
+ margin-top: 1px;
157
+ }
158
+ .child-chevron {
159
+ color: var(--text-3);
160
+ font-size: 18px;
161
+ flex-shrink: 0;
162
+ transition: transform var(--transition);
163
+ }
164
+ .child-card:hover .child-chevron {
165
+ transform: translateX(2px);
166
+ color: var(--text-2);
167
+ }
168
+
169
+ .node-empty {
170
+ color: var(--text-3);
171
+ font-size: 13px;
172
+ padding: 40px;
173
+ text-align: center;
174
+ }
@@ -0,0 +1,39 @@
1
+ import { Button } from '#components/ui/button';
2
+ import { set } from '#hooks';
3
+ import type { NodeData } from '@treenity/core';
4
+ import { Plus } from 'lucide-react';
5
+ import { useState } from 'react';
6
+ import { TypePicker } from './type-picker';
7
+
8
+ export function EmptyNodePlaceholder({ value }: { value: NodeData }) {
9
+ const [picking, setPicking] = useState(false);
10
+
11
+ return (
12
+ <div className="flex flex-col items-center justify-center gap-3 py-12 px-6">
13
+ <div className="text-[13px] text-[--text-3]">Empty node</div>
14
+ <Button
15
+ variant="outline"
16
+ size="sm"
17
+ onClick={() => setPicking(true)}
18
+ className="text-[12px] text-[--text-3] hover:text-[--accent] hover:bg-[--accent]/10"
19
+ >
20
+ <Plus className="w-3.5 h-3.5" />
21
+ Add Component
22
+ </Button>
23
+
24
+ {picking && (
25
+ <TypePicker
26
+ title="Add Component"
27
+ nameLabel="Component name"
28
+ action="Add"
29
+ autoName
30
+ onCancel={() => setPicking(false)}
31
+ onSelect={async (name, type) => {
32
+ setPicking(false);
33
+ await set({ ...value, [name]: { $type: type } });
34
+ }}
35
+ />
36
+ )}
37
+ </div>
38
+ );
39
+ }
@@ -0,0 +1,144 @@
1
+ import { Button } from '#components/ui/button';
2
+ import { Input } from '#components/ui/input';
3
+ import { isRef, resolveExact } from '@treenity/core';
4
+ import { createElement, useState } from 'react';
5
+ import { FieldLabel, RefEditor } from './FieldLabel';
6
+
7
+ export function renderField(
8
+ name: string,
9
+ fieldSchema: {
10
+ type: string;
11
+ label: string;
12
+ placeholder?: string;
13
+ readOnly?: boolean;
14
+ enum?: string[];
15
+ items?: { type?: string; properties?: Record<string, unknown> };
16
+ refType?: string;
17
+ },
18
+ data: Record<string, unknown>,
19
+ setData: (fn: (prev: Record<string, unknown>) => Record<string, unknown>) => void,
20
+ ) {
21
+ if (!fieldSchema.type) return null;
22
+
23
+ const rawValue = data[name];
24
+ const isRefValue = rawValue && typeof rawValue === 'object' && isRef(rawValue);
25
+
26
+ // If value is a $ref/$map, show ref editor instead of the normal field handler
27
+ if (isRefValue) {
28
+ const onFieldChange = fieldSchema.readOnly
29
+ ? undefined
30
+ : (next: unknown) => setData((prev) => ({ ...prev, [name]: next }));
31
+ return (
32
+ <div key={name} className="field">
33
+ <FieldLabel label={fieldSchema.label} value={rawValue} onChange={onFieldChange} />
34
+ {onFieldChange && (
35
+ <RefEditor value={rawValue as { $ref: string; $map?: string }} onChange={onFieldChange} />
36
+ )}
37
+ </div>
38
+ );
39
+ }
40
+
41
+ const ctx = fieldSchema.readOnly ? 'react' : 'react:form';
42
+ const handler = resolveExact(fieldSchema.type, ctx) ?? resolveExact('string', ctx);
43
+ if (!handler)
44
+ return (
45
+ <div key={name} className="text-[--danger] text-xs">
46
+ No form handler: {fieldSchema.type}
47
+ </div>
48
+ );
49
+
50
+ const fieldData: { $type: string; [k: string]: unknown } = {
51
+ $type: fieldSchema.type,
52
+ value: rawValue,
53
+ label: fieldSchema.label,
54
+ placeholder: fieldSchema.placeholder,
55
+ };
56
+ if (fieldSchema.items) fieldData.items = fieldSchema.items;
57
+ if (fieldSchema.enum) fieldData.enum = fieldSchema.enum;
58
+ if (fieldSchema.refType) fieldData.refType = fieldSchema.refType;
59
+
60
+ const isComplex = fieldSchema.type === 'object' || fieldSchema.type === 'array';
61
+ const onFieldChange = fieldSchema.readOnly
62
+ ? undefined
63
+ : (next: unknown) => setData((prev) => ({ ...prev, [name]: (next as { value: unknown }).value }));
64
+
65
+ return (
66
+ <div key={name} className={isComplex ? 'field stack' : 'field'}>
67
+ {fieldSchema.type !== 'boolean' && (
68
+ <FieldLabel
69
+ label={fieldSchema.label}
70
+ value={rawValue}
71
+ onChange={fieldSchema.readOnly ? undefined : (next: unknown) => setData((prev) => ({ ...prev, [name]: next }))}
72
+ />
73
+ )}
74
+ {createElement(handler as any, {
75
+ value: fieldData,
76
+ onChange: onFieldChange,
77
+ })}
78
+ </div>
79
+ );
80
+ }
81
+
82
+ export function StringArrayField({
83
+ value,
84
+ onChange,
85
+ }: {
86
+ value: unknown[];
87
+ onChange: (next: unknown[]) => void;
88
+ }) {
89
+ const [input, setInput] = useState('');
90
+ const isStrings = value.every((v) => typeof v === 'string');
91
+
92
+ if (!isStrings) {
93
+ return (
94
+ <textarea
95
+ value={JSON.stringify(value, null, 2)}
96
+ onChange={(e) => {
97
+ try {
98
+ onChange(JSON.parse(e.target.value));
99
+ } catch {
100
+ /* typing */
101
+ }
102
+ }}
103
+ />
104
+ );
105
+ }
106
+
107
+ const tags = value as string[];
108
+ return (
109
+ <div className="flex-1 space-y-1">
110
+ <div className="flex flex-wrap gap-1">
111
+ {tags.map((tag, i) => (
112
+ <span
113
+ key={i}
114
+ className="inline-flex items-center gap-0.5 text-[11px] font-mono bg-muted text-foreground/70 px-1.5 py-0.5 rounded"
115
+ >
116
+ {tag}
117
+ <Button
118
+ variant="ghost"
119
+ size="icon"
120
+ type="button"
121
+ className="h-5 w-5 p-0 ml-0.5 text-muted-foreground/40 hover:text-foreground leading-none"
122
+ onClick={() => onChange(tags.filter((_, j) => j !== i))}
123
+ >
124
+ x
125
+ </Button>
126
+ </span>
127
+ ))}
128
+ </div>
129
+ <Input
130
+ className="h-7 text-xs w-full"
131
+ placeholder="Add item..."
132
+ value={input}
133
+ onChange={(e) => setInput(e.target.value)}
134
+ onKeyDown={(e) => {
135
+ if (e.key !== 'Enter') return;
136
+ e.preventDefault();
137
+ const t = input.trim();
138
+ if (t && !tags.includes(t)) onChange([...tags, t]);
139
+ setInput('');
140
+ }}
141
+ />
142
+ </div>
143
+ );
144
+ }