@dxos/react-ui-form 0.9.0 → 0.9.1-staging.ee54ba693a

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 (372) hide show
  1. package/dist/lib/browser/index.mjs +2337 -1919
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +2337 -1919
  5. package/dist/lib/node-esm/index.mjs.map +4 -4
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/types/src/annotations.d.ts +47 -0
  8. package/dist/types/src/annotations.d.ts.map +1 -0
  9. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts +3 -3
  10. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
  11. package/dist/types/src/components/Form/Form.d.ts +23 -110
  12. package/dist/types/src/components/Form/Form.d.ts.map +1 -1
  13. package/dist/types/src/components/Form/Form.stories.d.ts +48 -101
  14. package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
  15. package/dist/types/src/components/Form/Form.theme.d.ts +252 -0
  16. package/dist/types/src/components/Form/Form.theme.d.ts.map +1 -0
  17. package/dist/types/src/components/Form/Form.theme.test.d.ts +2 -0
  18. package/dist/types/src/components/Form/Form.theme.test.d.ts.map +1 -0
  19. package/dist/types/src/components/Form/FormControls.d.ts +75 -0
  20. package/dist/types/src/components/Form/FormControls.d.ts.map +1 -0
  21. package/dist/types/src/components/Form/FormField/FormField.d.ts +44 -0
  22. package/dist/types/src/components/Form/FormField/FormField.d.ts.map +1 -0
  23. package/dist/types/src/components/Form/FormField/FormFieldHeader.d.ts +27 -0
  24. package/dist/types/src/components/Form/FormField/FormFieldHeader.d.ts.map +1 -0
  25. package/dist/types/src/components/Form/FormField/FormRow.d.ts +85 -0
  26. package/dist/types/src/components/Form/FormField/FormRow.d.ts.map +1 -0
  27. package/dist/types/src/components/Form/{FormFieldComponent.stories.d.ts → FormField/FormRow.stories.d.ts} +6 -3
  28. package/dist/types/src/components/Form/FormField/FormRow.stories.d.ts.map +1 -0
  29. package/dist/types/src/components/Form/{fields → FormField/fields/ArrayField}/ArrayField.d.ts +2 -2
  30. package/dist/types/src/components/Form/FormField/fields/ArrayField/ArrayField.d.ts.map +1 -0
  31. package/dist/types/src/components/Form/FormField/fields/ArrayField/ArrayField.stories.d.ts +88 -0
  32. package/dist/types/src/components/Form/FormField/fields/ArrayField/ArrayField.stories.d.ts.map +1 -0
  33. package/dist/types/src/components/Form/FormField/fields/ArrayField/index.d.ts +2 -0
  34. package/dist/types/src/components/Form/FormField/fields/ArrayField/index.d.ts.map +1 -0
  35. package/dist/types/src/components/Form/FormField/fields/AsyncSelectField/AsyncSelectField.d.ts +12 -0
  36. package/dist/types/src/components/Form/FormField/fields/AsyncSelectField/AsyncSelectField.d.ts.map +1 -0
  37. package/dist/types/src/components/Form/FormField/fields/AsyncSelectField/index.d.ts +2 -0
  38. package/dist/types/src/components/Form/FormField/fields/AsyncSelectField/index.d.ts.map +1 -0
  39. package/dist/types/src/components/Form/FormField/fields/AutofillField/AutofillField.d.ts +12 -0
  40. package/dist/types/src/components/Form/FormField/fields/AutofillField/AutofillField.d.ts.map +1 -0
  41. package/dist/types/src/components/Form/FormField/fields/AutofillField/index.d.ts +2 -0
  42. package/dist/types/src/components/Form/FormField/fields/AutofillField/index.d.ts.map +1 -0
  43. package/dist/types/src/components/Form/FormField/fields/BooleanField/BooleanField.d.ts +4 -0
  44. package/dist/types/src/components/Form/FormField/fields/BooleanField/BooleanField.d.ts.map +1 -0
  45. package/dist/types/src/components/{Settings/Settings.stories.d.ts → Form/FormField/fields/BooleanField/BooleanField.stories.d.ts} +1 -2
  46. package/dist/types/src/components/Form/FormField/fields/BooleanField/BooleanField.stories.d.ts.map +1 -0
  47. package/dist/types/src/components/Form/FormField/fields/BooleanField/index.d.ts +2 -0
  48. package/dist/types/src/components/Form/FormField/fields/BooleanField/index.d.ts.map +1 -0
  49. package/dist/types/src/components/Form/FormField/fields/ComboboxField/ComboboxField.d.ts +12 -0
  50. package/dist/types/src/components/Form/FormField/fields/ComboboxField/ComboboxField.d.ts.map +1 -0
  51. package/dist/types/src/components/Form/FormField/fields/ComboboxField/index.d.ts +2 -0
  52. package/dist/types/src/components/Form/FormField/fields/ComboboxField/index.d.ts.map +1 -0
  53. package/dist/types/src/components/Form/FormField/fields/DateField/DateField.d.ts +4 -0
  54. package/dist/types/src/components/Form/FormField/fields/DateField/DateField.d.ts.map +1 -0
  55. package/dist/types/src/components/Form/FormField/fields/DateField/DateField.stories.d.ts +88 -0
  56. package/dist/types/src/components/Form/FormField/fields/DateField/DateField.stories.d.ts.map +1 -0
  57. package/dist/types/src/components/Form/FormField/fields/DateField/index.d.ts +2 -0
  58. package/dist/types/src/components/Form/FormField/fields/DateField/index.d.ts.map +1 -0
  59. package/dist/types/src/components/Form/FormField/fields/GeoPointField/GeoPointField.d.ts +5 -0
  60. package/dist/types/src/components/Form/FormField/fields/GeoPointField/GeoPointField.d.ts.map +1 -0
  61. package/dist/types/src/components/Form/FormField/fields/GeoPointField/GeoPointField.stories.d.ts +88 -0
  62. package/dist/types/src/components/Form/FormField/fields/GeoPointField/GeoPointField.stories.d.ts.map +1 -0
  63. package/dist/types/src/components/Form/FormField/fields/GeoPointField/index.d.ts +2 -0
  64. package/dist/types/src/components/Form/FormField/fields/GeoPointField/index.d.ts.map +1 -0
  65. package/dist/types/src/components/Form/{fields → FormField/fields/MarkdownField}/MarkdownField.d.ts +2 -2
  66. package/dist/types/src/components/Form/FormField/fields/MarkdownField/MarkdownField.d.ts.map +1 -0
  67. package/dist/types/src/components/Form/FormField/fields/MarkdownField/MarkdownField.stories.d.ts.map +1 -0
  68. package/dist/types/src/components/Form/FormField/fields/MarkdownField/index.d.ts +2 -0
  69. package/dist/types/src/components/Form/FormField/fields/MarkdownField/index.d.ts.map +1 -0
  70. package/dist/types/src/components/Form/FormField/fields/NumberField/NumberField.d.ts +15 -0
  71. package/dist/types/src/components/Form/FormField/fields/NumberField/NumberField.d.ts.map +1 -0
  72. package/dist/types/src/components/Form/FormField/fields/NumberField/NumberField.stories.d.ts +88 -0
  73. package/dist/types/src/components/Form/FormField/fields/NumberField/NumberField.stories.d.ts.map +1 -0
  74. package/dist/types/src/components/Form/FormField/fields/NumberField/NumberField.test.d.ts +2 -0
  75. package/dist/types/src/components/Form/FormField/fields/NumberField/NumberField.test.d.ts.map +1 -0
  76. package/dist/types/src/components/Form/FormField/fields/NumberField/index.d.ts +2 -0
  77. package/dist/types/src/components/Form/FormField/fields/NumberField/index.d.ts.map +1 -0
  78. package/dist/types/src/components/Form/FormField/fields/PasswordField/PasswordField.d.ts +4 -0
  79. package/dist/types/src/components/Form/FormField/fields/PasswordField/PasswordField.d.ts.map +1 -0
  80. package/dist/types/src/components/Form/FormField/fields/PasswordField/PasswordField.stories.d.ts +88 -0
  81. package/dist/types/src/components/Form/FormField/fields/PasswordField/PasswordField.stories.d.ts.map +1 -0
  82. package/dist/types/src/components/Form/FormField/fields/PasswordField/index.d.ts +2 -0
  83. package/dist/types/src/components/Form/FormField/fields/PasswordField/index.d.ts.map +1 -0
  84. package/dist/types/src/components/Form/FormField/fields/RefField/InlineRefField.d.ts.map +1 -0
  85. package/dist/types/src/components/Form/FormField/fields/RefField/RefField.d.ts +16 -0
  86. package/dist/types/src/components/Form/FormField/fields/RefField/RefField.d.ts.map +1 -0
  87. package/dist/types/src/components/Form/FormField/fields/RefField/RefField.stories.d.ts +92 -0
  88. package/dist/types/src/components/Form/FormField/fields/RefField/RefField.stories.d.ts.map +1 -0
  89. package/dist/types/src/components/Form/FormField/fields/RefField/RefField.test.d.ts.map +1 -0
  90. package/dist/types/src/components/Form/FormField/fields/RefField/index.d.ts +3 -0
  91. package/dist/types/src/components/Form/FormField/fields/RefField/index.d.ts.map +1 -0
  92. package/dist/types/src/components/Form/FormField/fields/SelectField/SelectField.d.ts +29 -0
  93. package/dist/types/src/components/Form/FormField/fields/SelectField/SelectField.d.ts.map +1 -0
  94. package/dist/types/src/components/Form/FormField/fields/SelectField/SelectField.stories.d.ts +88 -0
  95. package/dist/types/src/components/Form/FormField/fields/SelectField/SelectField.stories.d.ts.map +1 -0
  96. package/dist/types/src/components/Form/FormField/fields/SelectField/index.d.ts +2 -0
  97. package/dist/types/src/components/Form/FormField/fields/SelectField/index.d.ts.map +1 -0
  98. package/dist/types/src/components/Form/FormField/fields/SelectOptionField/SelectOptionField.d.ts +5 -0
  99. package/dist/types/src/components/Form/FormField/fields/SelectOptionField/SelectOptionField.d.ts.map +1 -0
  100. package/dist/types/src/components/Form/FormField/fields/SelectOptionField/SelectOptionField.stories.d.ts.map +1 -0
  101. package/dist/types/src/components/Form/FormField/fields/SelectOptionField/index.d.ts +2 -0
  102. package/dist/types/src/components/Form/FormField/fields/SelectOptionField/index.d.ts.map +1 -0
  103. package/dist/types/src/components/Form/FormField/fields/TextAreaField/TextAreaField.d.ts +4 -0
  104. package/dist/types/src/components/Form/FormField/fields/TextAreaField/TextAreaField.d.ts.map +1 -0
  105. package/dist/types/src/components/Form/FormField/fields/TextAreaField/TextAreaField.stories.d.ts +88 -0
  106. package/dist/types/src/components/Form/FormField/fields/TextAreaField/TextAreaField.stories.d.ts.map +1 -0
  107. package/dist/types/src/components/Form/FormField/fields/TextAreaField/index.d.ts +2 -0
  108. package/dist/types/src/components/Form/FormField/fields/TextAreaField/index.d.ts.map +1 -0
  109. package/dist/types/src/components/Form/FormField/fields/TextField/TextField.d.ts +4 -0
  110. package/dist/types/src/components/Form/FormField/fields/TextField/TextField.d.ts.map +1 -0
  111. package/dist/types/src/components/Form/FormField/fields/TextField/TextField.stories.d.ts +88 -0
  112. package/dist/types/src/components/Form/FormField/fields/TextField/TextField.stories.d.ts.map +1 -0
  113. package/dist/types/src/components/Form/FormField/fields/TextField/index.d.ts +2 -0
  114. package/dist/types/src/components/Form/FormField/fields/TextField/index.d.ts.map +1 -0
  115. package/dist/types/src/components/Form/{fields → FormField/fields/TupleField}/TupleField.d.ts +2 -2
  116. package/dist/types/src/components/Form/FormField/fields/TupleField/TupleField.d.ts.map +1 -0
  117. package/dist/types/src/components/Form/FormField/fields/TupleField/TupleField.stories.d.ts +88 -0
  118. package/dist/types/src/components/Form/FormField/fields/TupleField/TupleField.stories.d.ts.map +1 -0
  119. package/dist/types/src/components/Form/FormField/fields/TupleField/index.d.ts +2 -0
  120. package/dist/types/src/components/Form/FormField/fields/TupleField/index.d.ts.map +1 -0
  121. package/dist/types/src/components/Form/{fields → FormField/fields}/index.d.ts +4 -1
  122. package/dist/types/src/components/Form/FormField/fields/index.d.ts.map +1 -0
  123. package/dist/types/src/components/Form/FormField/index.d.ts +6 -0
  124. package/dist/types/src/components/Form/FormField/index.d.ts.map +1 -0
  125. package/dist/types/src/components/Form/FormField/presentation.d.ts +22 -0
  126. package/dist/types/src/components/Form/FormField/presentation.d.ts.map +1 -0
  127. package/dist/types/src/components/Form/FormFieldSet/FormFieldSet.d.ts +30 -0
  128. package/dist/types/src/components/Form/FormFieldSet/FormFieldSet.d.ts.map +1 -0
  129. package/dist/types/src/components/Form/FormFieldSet/FormFieldSetContainer.d.ts +22 -0
  130. package/dist/types/src/components/Form/FormFieldSet/FormFieldSetContainer.d.ts.map +1 -0
  131. package/dist/types/src/components/Form/FormFieldSet/index.d.ts +3 -0
  132. package/dist/types/src/components/Form/FormFieldSet/index.d.ts.map +1 -0
  133. package/dist/types/src/components/Form/{Layout → FormLayout}/FormLayout.d.ts +2 -0
  134. package/dist/types/src/components/Form/FormLayout/FormLayout.d.ts.map +1 -0
  135. package/dist/types/src/components/Form/{Layout → FormLayout}/FormLayout.stories.d.ts +5 -5
  136. package/dist/types/src/components/Form/FormLayout/FormLayout.stories.d.ts.map +1 -0
  137. package/dist/types/src/components/Form/FormLayout/FormLayout.stories.test.d.ts.map +1 -0
  138. package/dist/types/src/components/Form/FormLayout/FormLayout.test.d.ts.map +1 -0
  139. package/dist/types/src/components/Form/FormLayout/index.d.ts +3 -0
  140. package/dist/types/src/components/Form/FormLayout/index.d.ts.map +1 -0
  141. package/dist/types/src/components/Form/FormLayout/parser.d.ts.map +1 -0
  142. package/dist/types/src/components/Form/FormLayout/parser.test.d.ts.map +1 -0
  143. package/dist/types/src/components/Form/index.d.ts +3 -5
  144. package/dist/types/src/components/Form/index.d.ts.map +1 -1
  145. package/dist/types/src/components/Form/meta-tags.d.ts +1 -12
  146. package/dist/types/src/components/Form/meta-tags.d.ts.map +1 -1
  147. package/dist/types/src/components/ObjectForm/ObjectForm.d.ts.map +1 -1
  148. package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts +6 -23
  149. package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts.map +1 -1
  150. package/dist/types/src/components/ObjectProperties/ObjectProperties.d.ts +2 -1
  151. package/dist/types/src/components/ObjectProperties/ObjectProperties.d.ts.map +1 -1
  152. package/dist/types/src/components/RefEditor/RefEditor.stories.d.ts +2 -2
  153. package/dist/types/src/components/RefEditor/RefEditor.stories.d.ts.map +1 -1
  154. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +1 -1
  155. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
  156. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +2 -2
  157. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
  158. package/dist/types/src/components/index.d.ts +0 -1
  159. package/dist/types/src/components/index.d.ts.map +1 -1
  160. package/dist/types/src/hooks/index.d.ts +2 -0
  161. package/dist/types/src/hooks/index.d.ts.map +1 -1
  162. package/dist/types/src/hooks/useAsyncFieldEffect.d.ts +24 -0
  163. package/dist/types/src/hooks/useAsyncFieldEffect.d.ts.map +1 -0
  164. package/dist/types/src/hooks/useFormContext.d.ts +42 -0
  165. package/dist/types/src/hooks/useFormContext.d.ts.map +1 -0
  166. package/dist/types/src/hooks/useFormHandler.d.ts +9 -6
  167. package/dist/types/src/hooks/useFormHandler.d.ts.map +1 -1
  168. package/dist/types/src/index.d.ts +2 -0
  169. package/dist/types/src/index.d.ts.map +1 -1
  170. package/dist/types/src/{components/testing.d.ts → testing/TestLayout.d.ts} +2 -2
  171. package/dist/types/src/testing/TestLayout.d.ts.map +1 -0
  172. package/dist/types/src/testing/index.d.ts +3 -0
  173. package/dist/types/src/testing/index.d.ts.map +1 -0
  174. package/dist/types/src/testing/schema.d.ts +40 -0
  175. package/dist/types/src/testing/schema.d.ts.map +1 -0
  176. package/dist/types/src/types.d.ts +161 -0
  177. package/dist/types/src/types.d.ts.map +1 -0
  178. package/dist/types/src/util/index.d.ts +1 -1
  179. package/dist/types/src/util/index.d.ts.map +1 -1
  180. package/dist/types/src/util/omit.d.ts +12 -0
  181. package/dist/types/src/util/omit.d.ts.map +1 -0
  182. package/dist/types/tsconfig.tsbuildinfo +1 -1
  183. package/package.json +43 -41
  184. package/src/annotations.ts +63 -0
  185. package/src/components/FieldEditor/FieldEditor.stories.tsx +1 -1
  186. package/src/components/FieldEditor/FieldEditor.test.tsx +1 -1
  187. package/src/components/FieldEditor/FieldEditor.tsx +10 -6
  188. package/src/components/Form/DESIGN.md +24 -0
  189. package/src/components/Form/Form.stories.tsx +260 -61
  190. package/src/components/Form/Form.theme.test.ts +33 -0
  191. package/src/components/Form/Form.theme.ts +86 -0
  192. package/src/components/Form/Form.tsx +30 -453
  193. package/src/components/Form/FormControls.tsx +377 -0
  194. package/src/components/Form/{FormField.tsx → FormField/FormField.tsx} +98 -71
  195. package/src/components/Form/FormField/FormFieldHeader.tsx +68 -0
  196. package/src/components/Form/FormField/FormRow.stories.tsx +97 -0
  197. package/src/components/Form/FormField/FormRow.tsx +298 -0
  198. package/src/components/Form/FormField/fields/ArrayField/ArrayField.stories.tsx +119 -0
  199. package/src/components/Form/FormField/fields/ArrayField/ArrayField.tsx +328 -0
  200. package/src/components/Form/FormField/fields/ArrayField/index.ts +5 -0
  201. package/src/components/Form/FormField/fields/AsyncSelectField/AsyncSelectField.tsx +59 -0
  202. package/src/components/Form/FormField/fields/AsyncSelectField/index.ts +5 -0
  203. package/src/components/Form/FormField/fields/AutofillField/AutofillField.tsx +67 -0
  204. package/src/components/Form/FormField/fields/AutofillField/index.ts +5 -0
  205. package/src/components/Form/FormField/fields/BooleanField/BooleanField.stories.tsx +52 -0
  206. package/src/components/Form/FormField/fields/BooleanField/BooleanField.tsx +28 -0
  207. package/src/components/Form/FormField/fields/BooleanField/index.ts +5 -0
  208. package/src/components/Form/FormField/fields/ComboboxField/ComboboxField.tsx +104 -0
  209. package/src/components/Form/FormField/fields/ComboboxField/index.ts +5 -0
  210. package/src/components/Form/FormField/fields/DateField/DateField.stories.tsx +60 -0
  211. package/src/components/Form/{fields → FormField/fields/DateField}/DateField.tsx +12 -10
  212. package/src/components/Form/FormField/fields/DateField/index.ts +5 -0
  213. package/src/components/Form/FormField/fields/GeoPointField/GeoPointField.stories.tsx +53 -0
  214. package/src/components/Form/{fields → FormField/fields/GeoPointField}/GeoPointField.tsx +19 -21
  215. package/src/components/Form/FormField/fields/GeoPointField/index.ts +5 -0
  216. package/src/components/Form/{fields → FormField/fields/MarkdownField}/MarkdownField.stories.tsx +8 -8
  217. package/src/components/Form/{fields → FormField/fields/MarkdownField}/MarkdownField.tsx +41 -41
  218. package/src/components/Form/FormField/fields/MarkdownField/index.ts +5 -0
  219. package/src/components/Form/FormField/fields/NumberField/NumberField.stories.tsx +52 -0
  220. package/src/components/Form/FormField/fields/NumberField/NumberField.test.ts +29 -0
  221. package/src/components/Form/FormField/fields/NumberField/NumberField.tsx +140 -0
  222. package/src/components/Form/FormField/fields/NumberField/index.ts +5 -0
  223. package/src/components/Form/FormField/fields/PasswordField/PasswordField.stories.tsx +53 -0
  224. package/src/components/Form/FormField/fields/PasswordField/PasswordField.tsx +41 -0
  225. package/src/components/Form/FormField/fields/PasswordField/index.ts +5 -0
  226. package/src/components/Form/{fields → FormField/fields/RefField}/InlineRefField.tsx +21 -14
  227. package/src/components/Form/FormField/fields/RefField/RefField.stories.tsx +97 -0
  228. package/src/components/Form/{fields → FormField/fields/RefField}/RefField.test.ts +10 -1
  229. package/src/components/Form/{fields → FormField/fields/RefField}/RefField.tsx +55 -47
  230. package/src/components/Form/FormField/fields/RefField/index.ts +6 -0
  231. package/src/components/Form/FormField/fields/SelectField/SelectField.stories.tsx +53 -0
  232. package/src/components/Form/FormField/fields/SelectField/SelectField.tsx +136 -0
  233. package/src/components/Form/FormField/fields/SelectField/index.ts +5 -0
  234. package/src/components/Form/{fields → FormField/fields/SelectOptionField}/SelectOptionField.stories.tsx +5 -5
  235. package/src/components/Form/{fields → FormField/fields/SelectOptionField}/SelectOptionField.tsx +56 -54
  236. package/src/components/Form/FormField/fields/SelectOptionField/index.ts +5 -0
  237. package/src/components/Form/FormField/fields/TextAreaField/TextAreaField.stories.tsx +53 -0
  238. package/src/components/Form/{fields → FormField/fields/TextAreaField}/TextAreaField.tsx +6 -4
  239. package/src/components/Form/FormField/fields/TextAreaField/index.ts +5 -0
  240. package/src/components/Form/FormField/fields/TextField/TextField.stories.tsx +52 -0
  241. package/src/components/Form/{fields → FormField/fields/TextField}/TextField.tsx +6 -4
  242. package/src/components/Form/FormField/fields/TextField/index.ts +5 -0
  243. package/src/components/Form/FormField/fields/TupleField/TupleField.stories.tsx +55 -0
  244. package/src/components/Form/{fields → FormField/fields/TupleField}/TupleField.tsx +4 -2
  245. package/src/components/Form/FormField/fields/TupleField/index.ts +5 -0
  246. package/src/components/Form/{fields → FormField/fields}/index.ts +4 -1
  247. package/src/components/Form/FormField/index.ts +10 -0
  248. package/src/components/Form/FormField/presentation.tsx +32 -0
  249. package/src/components/Form/{FormFieldSet.tsx → FormFieldSet/FormFieldSet.tsx} +53 -90
  250. package/src/components/Form/FormFieldSet/FormFieldSetContainer.tsx +93 -0
  251. package/src/components/Form/FormFieldSet/index.ts +6 -0
  252. package/src/components/Form/{Layout → FormLayout}/FormLayout.stories.tsx +11 -9
  253. package/src/components/Form/{Layout → FormLayout}/FormLayout.tsx +29 -18
  254. package/src/components/Form/FormLayout/index.ts +6 -0
  255. package/src/components/Form/index.ts +3 -5
  256. package/src/components/Form/meta-tags.test.ts +1 -1
  257. package/src/components/Form/meta-tags.ts +1 -1
  258. package/src/components/ObjectForm/ObjectForm.tsx +15 -14
  259. package/src/components/ObjectPicker/ObjectPicker.tsx +20 -27
  260. package/src/components/ObjectProperties/ObjectProperties.stories.tsx +2 -2
  261. package/src/components/ObjectProperties/ObjectProperties.test.tsx +1 -1
  262. package/src/components/ObjectProperties/ObjectProperties.tsx +13 -8
  263. package/src/components/RefEditor/RefEditor.stories.tsx +2 -3
  264. package/src/components/RefEditor/RefEditor.tsx +1 -1
  265. package/src/components/ViewEditor/ViewEditor.stories.tsx +6 -7
  266. package/src/components/ViewEditor/ViewEditor.test.tsx +9 -3
  267. package/src/components/ViewEditor/ViewEditor.tsx +98 -128
  268. package/src/components/index.ts +0 -1
  269. package/src/hooks/index.ts +2 -0
  270. package/src/hooks/useAsyncFieldEffect.ts +81 -0
  271. package/src/hooks/useFormContext.ts +89 -0
  272. package/src/hooks/useFormHandler.ts +12 -10
  273. package/src/index.ts +2 -0
  274. package/src/{components/testing.tsx → testing/TestLayout.tsx} +16 -13
  275. package/src/testing/index.ts +7 -0
  276. package/src/testing/schema.ts +59 -0
  277. package/src/types.ts +186 -0
  278. package/src/util/index.ts +1 -1
  279. package/src/util/omit.ts +61 -0
  280. package/src/util/properties.test.ts +110 -28
  281. package/src/util/refs.ts +1 -1
  282. package/src/vitest-setup.ts +40 -0
  283. package/dist/types/src/components/Form/FormField.d.ts +0 -52
  284. package/dist/types/src/components/Form/FormField.d.ts.map +0 -1
  285. package/dist/types/src/components/Form/FormFieldComponent.d.ts +0 -98
  286. package/dist/types/src/components/Form/FormFieldComponent.d.ts.map +0 -1
  287. package/dist/types/src/components/Form/FormFieldComponent.stories.d.ts.map +0 -1
  288. package/dist/types/src/components/Form/FormFieldSet.d.ts +0 -26
  289. package/dist/types/src/components/Form/FormFieldSet.d.ts.map +0 -1
  290. package/dist/types/src/components/Form/FormTooltipsContext.d.ts +0 -19
  291. package/dist/types/src/components/Form/FormTooltipsContext.d.ts.map +0 -1
  292. package/dist/types/src/components/Form/Layout/FormLayout.d.ts.map +0 -1
  293. package/dist/types/src/components/Form/Layout/FormLayout.stories.d.ts.map +0 -1
  294. package/dist/types/src/components/Form/Layout/FormLayout.stories.test.d.ts.map +0 -1
  295. package/dist/types/src/components/Form/Layout/FormLayout.test.d.ts.map +0 -1
  296. package/dist/types/src/components/Form/Layout/annotation.d.ts +0 -30
  297. package/dist/types/src/components/Form/Layout/annotation.d.ts.map +0 -1
  298. package/dist/types/src/components/Form/Layout/index.d.ts +0 -4
  299. package/dist/types/src/components/Form/Layout/index.d.ts.map +0 -1
  300. package/dist/types/src/components/Form/Layout/parser.d.ts.map +0 -1
  301. package/dist/types/src/components/Form/Layout/parser.test.d.ts.map +0 -1
  302. package/dist/types/src/components/Form/fields/ArrayField.d.ts.map +0 -1
  303. package/dist/types/src/components/Form/fields/BooleanField.d.ts +0 -4
  304. package/dist/types/src/components/Form/fields/BooleanField.d.ts.map +0 -1
  305. package/dist/types/src/components/Form/fields/DateField.d.ts +0 -4
  306. package/dist/types/src/components/Form/fields/DateField.d.ts.map +0 -1
  307. package/dist/types/src/components/Form/fields/GeoPointField.d.ts +0 -5
  308. package/dist/types/src/components/Form/fields/GeoPointField.d.ts.map +0 -1
  309. package/dist/types/src/components/Form/fields/InlineRefField.d.ts.map +0 -1
  310. package/dist/types/src/components/Form/fields/MarkdownField.d.ts.map +0 -1
  311. package/dist/types/src/components/Form/fields/MarkdownField.stories.d.ts.map +0 -1
  312. package/dist/types/src/components/Form/fields/NumberField.d.ts +0 -4
  313. package/dist/types/src/components/Form/fields/NumberField.d.ts.map +0 -1
  314. package/dist/types/src/components/Form/fields/RefField.d.ts +0 -34
  315. package/dist/types/src/components/Form/fields/RefField.d.ts.map +0 -1
  316. package/dist/types/src/components/Form/fields/RefField.test.d.ts.map +0 -1
  317. package/dist/types/src/components/Form/fields/SelectField.d.ts +0 -13
  318. package/dist/types/src/components/Form/fields/SelectField.d.ts.map +0 -1
  319. package/dist/types/src/components/Form/fields/SelectOptionField.d.ts +0 -5
  320. package/dist/types/src/components/Form/fields/SelectOptionField.d.ts.map +0 -1
  321. package/dist/types/src/components/Form/fields/SelectOptionField.stories.d.ts.map +0 -1
  322. package/dist/types/src/components/Form/fields/TextAreaField.d.ts +0 -4
  323. package/dist/types/src/components/Form/fields/TextAreaField.d.ts.map +0 -1
  324. package/dist/types/src/components/Form/fields/TextField.d.ts +0 -4
  325. package/dist/types/src/components/Form/fields/TextField.d.ts.map +0 -1
  326. package/dist/types/src/components/Form/fields/TupleField.d.ts.map +0 -1
  327. package/dist/types/src/components/Form/fields/index.d.ts.map +0 -1
  328. package/dist/types/src/components/Settings/Settings.d.ts +0 -51
  329. package/dist/types/src/components/Settings/Settings.d.ts.map +0 -1
  330. package/dist/types/src/components/Settings/Settings.stories.d.ts.map +0 -1
  331. package/dist/types/src/components/Settings/SettingsFieldSet.d.ts +0 -43
  332. package/dist/types/src/components/Settings/SettingsFieldSet.d.ts.map +0 -1
  333. package/dist/types/src/components/Settings/SettingsItem.d.ts +0 -16
  334. package/dist/types/src/components/Settings/SettingsItem.d.ts.map +0 -1
  335. package/dist/types/src/components/Settings/SettingsSelectField.d.ts +0 -18
  336. package/dist/types/src/components/Settings/SettingsSelectField.d.ts.map +0 -1
  337. package/dist/types/src/components/Settings/index.d.ts +0 -4
  338. package/dist/types/src/components/Settings/index.d.ts.map +0 -1
  339. package/dist/types/src/components/testing.d.ts.map +0 -1
  340. package/dist/types/src/util/field-type.d.ts +0 -19
  341. package/dist/types/src/util/field-type.d.ts.map +0 -1
  342. package/src/components/Form/AUDIT.md +0 -17
  343. package/src/components/Form/FormFieldComponent.stories.tsx +0 -65
  344. package/src/components/Form/FormFieldComponent.tsx +0 -253
  345. package/src/components/Form/FormTooltipsContext.ts +0 -25
  346. package/src/components/Form/Layout/annotation.ts +0 -38
  347. package/src/components/Form/Layout/index.ts +0 -7
  348. package/src/components/Form/README.md +0 -3
  349. package/src/components/Form/fields/ArrayField.tsx +0 -173
  350. package/src/components/Form/fields/BooleanField.tsx +0 -22
  351. package/src/components/Form/fields/NumberField.tsx +0 -76
  352. package/src/components/Form/fields/SelectField.tsx +0 -77
  353. package/src/components/Settings/AUDIT.md +0 -51
  354. package/src/components/Settings/Settings.stories.tsx +0 -104
  355. package/src/components/Settings/Settings.tsx +0 -81
  356. package/src/components/Settings/SettingsFieldSet.tsx +0 -257
  357. package/src/components/Settings/SettingsItem.tsx +0 -58
  358. package/src/components/Settings/SettingsSelectField.tsx +0 -59
  359. package/src/components/Settings/index.ts +0 -7
  360. package/src/util/field-type.ts +0 -60
  361. /package/dist/types/src/components/Form/{fields → FormField/fields/MarkdownField}/MarkdownField.stories.d.ts +0 -0
  362. /package/dist/types/src/components/Form/{fields → FormField/fields/RefField}/InlineRefField.d.ts +0 -0
  363. /package/dist/types/src/components/Form/{fields → FormField/fields/RefField}/RefField.test.d.ts +0 -0
  364. /package/dist/types/src/components/Form/{fields → FormField/fields/SelectOptionField}/SelectOptionField.stories.d.ts +0 -0
  365. /package/dist/types/src/components/Form/{Layout → FormLayout}/FormLayout.stories.test.d.ts +0 -0
  366. /package/dist/types/src/components/Form/{Layout → FormLayout}/FormLayout.test.d.ts +0 -0
  367. /package/dist/types/src/components/Form/{Layout → FormLayout}/parser.d.ts +0 -0
  368. /package/dist/types/src/components/Form/{Layout → FormLayout}/parser.test.d.ts +0 -0
  369. /package/src/components/Form/{Layout → FormLayout}/FormLayout.stories.test.tsx +0 -0
  370. /package/src/components/Form/{Layout → FormLayout}/FormLayout.test.ts +0 -0
  371. /package/src/components/Form/{Layout → FormLayout}/parser.test.ts +0 -0
  372. /package/src/components/Form/{Layout → FormLayout}/parser.ts +0 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/components/FieldEditor/FieldEditor.tsx", "../../../src/util/field.ts", "../../../src/util/field-type.ts", "../../../src/util/formatting.ts", "../../../src/util/properties.ts", "../../../src/util/refs.ts", "../../../src/components/Form/fields/ArrayField.tsx", "../../../src/components/Form/Form.tsx", "../../../src/hooks/useFormHandler.ts", "../../../src/hooks/useKeyHandler.tsx", "../../../src/components/Form/FormFieldComponent.tsx", "../../../src/components/Form/FormTooltipsContext.ts", "../../../src/components/Form/FormFieldSet.tsx", "../../../src/components/Form/FormField.tsx", "../../../src/components/Form/Layout/annotation.ts", "../../../src/components/Form/Layout/FormLayout.tsx", "../../../src/components/Form/Layout/parser.ts", "../../../src/components/Form/fields/BooleanField.tsx", "../../../src/components/Form/fields/DateField.tsx", "../../../src/components/Form/fields/GeoPointField.tsx", "../../../src/components/Form/fields/InlineRefField.tsx", "../../../src/components/Form/fields/MarkdownField.tsx", "../../../src/components/Form/fields/NumberField.tsx", "../../../src/components/Form/fields/RefField.tsx", "../../../src/components/ObjectPicker/ObjectPicker.tsx", "../../../src/components/Form/fields/SelectField.tsx", "../../../src/components/Form/fields/SelectOptionField.tsx", "../../../src/components/Form/fields/TextField.tsx", "../../../src/components/Form/fields/TextAreaField.tsx", "../../../src/components/Form/fields/TupleField.tsx", "../../../src/components/Form/meta-tags.ts", "../../../src/components/ObjectForm/ObjectForm.tsx", "../../../src/components/ObjectProperties/ObjectProperties.tsx", "../../../src/components/ObjectTree/ObjectTree.tsx", "../../../src/components/RefEditor/RefEditor.tsx", "../../../src/components/RefEditor/ref-editor-extension.ts", "../../../src/components/Settings/Settings.tsx", "../../../src/components/Settings/SettingsFieldSet.tsx", "../../../src/components/Settings/SettingsItem.tsx", "../../../src/components/Settings/SettingsSelectField.tsx", "../../../src/components/ViewEditor/ViewEditor.tsx"],
4
- "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useCallback, useEffect, useMemo, useState } from 'react';\n\nimport { Filter, Obj, type Registry, Type, type View } from '@dxos/echo';\nimport { Format, FormatEnums, formatToType } from '@dxos/echo/Format';\nimport { SchemaEx } from '@dxos/effect';\nimport { log } from '@dxos/log';\nimport { useAsyncEffect, useTranslation } from '@dxos/react-ui';\nimport {\n type ProjectionModel,\n type PropertyType,\n formatToAdditionalPropertyAttributes,\n getFormatSchema,\n} from '@dxos/schema';\n\nimport { translationKey } from '#translations';\n\nimport { getFormProperties } from '../../util';\nimport { Form, type FormFieldMap, type FormRootProps, SelectField, SelectOptionField } from '../Form';\n\nexport type FieldEditorProps = {\n projection: ProjectionModel;\n field: View.FieldType;\n registry?: Registry.Registry;\n view?: Obj.Unknown;\n onSave: () => void;\n onCancel?: () => void;\n} & Pick<FormRootProps<any>, 'readonly'>;\n\n/**\n * Displays a Form representing the metadata for a given `Field` and `View`.\n */\nexport const FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCancel }: FieldEditorProps) => {\n const { t } = useTranslation(translationKey);\n const [props, setProps] = useState<PropertyType>(projection.getFieldProjection(field.id).props);\n useEffect(() => setProps(projection.getFieldProjection(field.id).props), [field, projection]);\n\n const [schemas, setSchemas] = useState<Type.Type[]>([]);\n useAsyncEffect(async () => {\n if (!registry) {\n return;\n }\n\n const subscription = registry\n .query(Filter.type(Type.Type))\n .subscribe((query) => setSchemas(query.results), { fire: true });\n\n // TODO(dmaretskyi): This shouldn't be needed.\n const schemas = await registry.query(Filter.type(Type.Type)).run();\n setSchemas(schemas);\n\n return () => subscription?.();\n }, [registry]);\n\n const [referenceSchema, setReferenceSchema] = useState<Type.Type>();\n useEffect(() => {\n setReferenceSchema(schemas.find((schema) => Type.getTypename(schema) === props?.referenceSchema));\n }, [schemas, props?.referenceSchema]);\n\n // TODO(burdon): Need to wrap otherwise throws error:\n // Class constructor SchemaClass cannot be invoked without 'new'.\n const [{ fieldSchema }, setFieldSchema] = useState({ fieldSchema: getFormatSchema(props?.format) });\n\n const fieldMap = useMemo<FormFieldMap>(\n () => ({\n ['format' satisfies keyof PropertyType]: (props) => (\n <SelectField\n {...props}\n options={FormatEnums.filter((value) => value !== Format.TypeFormat.None).map((value) => ({\n value,\n label: t(`format.${value}.label`),\n }))}\n />\n ),\n ['referenceSchema' satisfies keyof PropertyType]: (props) => (\n <SelectField\n {...props}\n options={schemas\n .map((schema) => Type.getTypename(schema))\n .filter((typename): typename is string => typename != null)\n .map((typename) => ({\n value: typename,\n }))}\n />\n ),\n ['referencePath' satisfies keyof PropertyType]: (props) => (\n <SelectField\n {...props}\n options={\n referenceSchema\n ? getFormProperties(Type.getSchema(referenceSchema).ast)\n .sort((a, b) => a.name.toString().localeCompare(b.name.toString()))\n .map((p) => ({ value: p.name.toString() }))\n : []\n }\n />\n ),\n ['options' satisfies keyof PropertyType]: (props) => <SelectOptionField {...props} />,\n }),\n [t, schemas, referenceSchema],\n );\n\n const propIsNotType = useCallback(\n (props: SchemaEx.SchemaProperty[]) => props.filter((prop) => prop.name !== 'type'),\n [],\n );\n\n const handleValuesChanged = useCallback<NonNullable<FormRootProps<PropertyType>['onValuesChanged']>>(\n (_props) => {\n // TODO(Zaymon): Workout why old and new format values are the same sometimes even when selecting novel format values.\n setFieldSchema((prev) => {\n const fieldSchema = getFormatSchema(_props.format);\n if (prev.fieldSchema === fieldSchema) {\n return prev;\n }\n return { fieldSchema };\n });\n\n setReferenceSchema((prev) => {\n if (_props.referenceSchema !== (prev ? Type.getTypename(prev) : undefined)) {\n const newSchema = schemas.find((schema) => Type.getTypename(schema) === _props.referenceSchema);\n if (newSchema) {\n return newSchema;\n }\n }\n return prev;\n });\n\n setProps((props) => {\n const type = formatToType[_props.format as keyof typeof formatToType];\n const additionalProps =\n formatToAdditionalPropertyAttributes[_props.format as keyof typeof formatToAdditionalPropertyAttributes];\n if (props.type !== type) {\n return { ...props, ..._props, ...additionalProps, type } as PropertyType;\n }\n\n return _props as PropertyType;\n });\n },\n [schemas, props.format, props.referenceSchema],\n );\n\n const handleValidate = useCallback<NonNullable<FormRootProps<PropertyType>['onValidate']>>(\n ({ property }) => {\n if (property && projection.getFields().find((f) => f.path === property && f.path !== field.path)) {\n return [\n {\n path: 'property',\n message: `property is not unique: '${property}'`,\n },\n ];\n }\n },\n [projection.getFields(), field],\n );\n\n const handleSave = useCallback<NonNullable<FormRootProps<PropertyType>['onSave']>>(\n (props) => {\n if (view) {\n Obj.update(view, () => {\n projection.setFieldProjection({ field, props });\n });\n } else {\n projection.setFieldProjection({ field, props });\n }\n onSave();\n },\n [projection, field, view, onSave],\n );\n\n const handleCancel = useCallback<NonNullable<FormRootProps<PropertyType>['onCancel']>>(() => {\n onSave();\n // Need to defer to allow form to close.\n requestAnimationFrame(() => onCancel?.());\n }, [onSave]);\n\n if (!fieldSchema) {\n log.warn('invalid format', { props });\n return null;\n }\n\n return (\n <Form.Root<PropertyType>\n key={field.id}\n fieldMap={fieldMap}\n autoFocus\n readonly={readonly}\n schema={fieldSchema}\n values={props}\n exclude={propIsNotType}\n sort={['property', 'format']}\n onValuesChanged={handleValuesChanged}\n onValidate={handleValidate}\n onSave={handleSave}\n onCancel={handleCancel}\n >\n <Form.Content>\n <Form.FieldSet />\n <Form.Actions />\n </Form.Content>\n </Form.Root>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { Format, GeoLocation, TypeEnum } from '@dxos/echo/Format';\nimport { type ValidationError } from '@dxos/schema';\n\n/**\n * Parse value by field value type.\n * Used by Table, Sheet, etc.\n * Handles various data types including booleans, numbers, dates, and strings.\n * Returns undefined for empty or null inputs.\n */\nexport type ParseProps = {\n type?: TypeEnum;\n format?: Format.TypeFormat;\n value: any;\n};\n\nexport const parseValue = ({ type, format, value }: ParseProps) => {\n if (value === undefined || value === null || value === '') {\n return undefined;\n }\n\n const parseScalar = (type?: TypeEnum) => {\n switch (type) {\n case TypeEnum.Boolean: {\n if (typeof value === 'string') {\n const lowercaseValue = value.toLowerCase();\n if (lowercaseValue === '0' || lowercaseValue === 'false') {\n return false;\n } else if (lowercaseValue === '1' || lowercaseValue === 'true') {\n return true;\n }\n }\n return Boolean(value);\n }\n\n case TypeEnum.Number: {\n const cleaned = typeof value === 'string' ? value.replace(/[^0-9.-]+/g, '') : value;\n const num = Number(cleaned);\n return Number.isNaN(num) ? null : num;\n }\n\n case TypeEnum.String:\n case TypeEnum.Ref:\n return String(value);\n\n default: {\n return value;\n }\n }\n };\n\n if (!format) {\n return parseScalar(type);\n }\n\n switch (format) {\n case Format.TypeFormat.Boolean:\n return parseScalar(TypeEnum.Boolean);\n\n case Format.TypeFormat.Number:\n case Format.TypeFormat.Percent:\n case Format.TypeFormat.Currency:\n return parseScalar(TypeEnum.Number);\n\n case Format.TypeFormat.String:\n case Format.TypeFormat.Markdown: {\n return parseScalar(TypeEnum.String);\n }\n\n case Format.TypeFormat.Ref:\n throw new Error(`unexpected format: ${Format.TypeFormat.Ref}`);\n\n case Format.TypeFormat.DateTime:\n case Format.TypeFormat.Date:\n case Format.TypeFormat.Time:\n case Format.TypeFormat.Timestamp: {\n const date = new Date(value as string | number);\n return isNaN(date.getTime()) ? null : date;\n }\n\n case Format.TypeFormat.GeoPoint: {\n // Parse string in format \"lat,long\" to GeoPoint [longitude, latitude].\n if (typeof value === 'string') {\n // Only keep digits, decimal points, minus signs, and commas.\n const cleaned = value.replace(/[^0-9.,-]+/g, '');\n const parts = cleaned.split(',');\n if (parts.length === 2) {\n const lat = parseFloat(parts[0]);\n const long = parseFloat(parts[1]);\n if (!isNaN(lat) && !isNaN(long)) {\n return GeoLocation.toGeoPoint({ latitude: lat, longitude: long });\n }\n }\n }\n\n return [0, 0];\n }\n\n default: {\n return value;\n }\n }\n};\n\n// TODO(burdon): Type and format.\nexport type CellClassesForFieldTypeProps = {\n type?: TypeEnum;\n format?: Format.TypeFormat;\n};\n\nexport const cellClassesForFieldType = ({ type, format }: CellClassesForFieldTypeProps): string[] | undefined => {\n switch (format || type) {\n case Format.TypeFormat.Markdown:\n return undefined;\n case Format.TypeFormat.Time:\n case Format.TypeFormat.Timestamp:\n case Format.TypeFormat.DateTime:\n case Format.TypeFormat.Date:\n case Format.TypeFormat.Duration:\n return ['font-mono', 'text-right'];\n case Format.TypeFormat.Currency:\n return ['text-right'];\n case Format.TypeFormat.JSON:\n case Format.TypeFormat.DID:\n return ['font-mono'];\n case TypeEnum.Number:\n case TypeEnum.Boolean:\n return ['text-right', 'font-mono'];\n case TypeEnum.String:\n return undefined;\n case TypeEnum.Ref:\n return undefined;\n default:\n return undefined;\n }\n};\n\n// TODO(ZaymonFC): How to do this with translations?\nexport const pathNotUniqueError = (path: string): ValidationError => ({\n path: 'path',\n message: `'${path}' is already present`,\n});\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { SchemaEx } from '@dxos/effect';\n\n/**\n * Detected field type for a schema property.\n */\nexport type SettingsFieldType = 'boolean' | 'string' | 'number' | 'select' | 'struct';\n\nexport type SelectOption = {\n value: string | number;\n label?: string;\n};\n\n/**\n * Detect the field type from an Effect Schema AST node.\n */\nexport const detectFieldType = (ast: SchemaAST.AST): SettingsFieldType | undefined => {\n if (SchemaEx.isLiteralUnion(ast)) {\n return 'select';\n }\n if (SchemaAST.isTypeLiteral(ast)) {\n return 'struct';\n }\n\n switch (ast._tag) {\n case 'BooleanKeyword':\n return 'boolean';\n case 'StringKeyword':\n return 'string';\n case 'NumberKeyword':\n return 'number';\n }\n\n return undefined;\n};\n\n/**\n * Extract select options from a literal union AST node.\n * Reads title annotations from individual literals for labels.\n */\nexport const getSelectOptionsFromAst = (ast: SchemaAST.AST): SelectOption[] | undefined => {\n if (!SchemaEx.isLiteralUnion(ast)) {\n return undefined;\n }\n\n return (ast as SchemaAST.Union<SchemaAST.Literal>).types.flatMap((literalNode) => {\n const value = literalNode.literal;\n if (typeof value !== 'string' && typeof value !== 'number') {\n return [];\n }\n const title = SchemaEx.getAnnotation<string>(SchemaAST.TitleAnnotationId, false)(literalNode);\n const label = title ?? (typeof value === 'string' ? value.charAt(0).toUpperCase() + value.slice(1) : String(value));\n return [{ value, label }];\n });\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { format as formatDate } from 'date-fns/format';\n\nimport { Format, GeoLocation, TypeEnum } from '@dxos/echo/Format';\n\ntype ValueFormatProps = {\n type: TypeEnum;\n format?: Format.TypeFormat | undefined;\n value: any;\n locale?: string | undefined;\n};\n\n/**\n * Format value by type.\n * Used by Table, Sheet, etc.\n */\n// TODO(burdon): Move to react-ui-form.\n// TODO(burdon): Formatting is different from kind format (e.g., percent is not a data format).\nexport const formatForDisplay = ({ type, format, value, locale = undefined }: ValueFormatProps): string => {\n const formatScalar = (type: TypeEnum) => {\n switch (type) {\n case TypeEnum.Boolean:\n return (value as boolean).toLocaleString().toUpperCase();\n case TypeEnum.Number:\n return value.toLocaleString(locale);\n case TypeEnum.String:\n case TypeEnum.Ref:\n return String(value);\n\n default: {\n return String(value);\n }\n }\n };\n\n if (!format) {\n return formatScalar(type);\n }\n\n switch (format) {\n case Format.TypeFormat.Boolean: {\n return formatScalar(TypeEnum.Boolean);\n }\n case Format.TypeFormat.Number: {\n return formatScalar(TypeEnum.Number);\n }\n case Format.TypeFormat.String:\n case Format.TypeFormat.Ref: {\n return formatScalar(TypeEnum.String);\n }\n case Format.TypeFormat.Percent: {\n return `${(value as number) * 100}%`;\n }\n case Format.TypeFormat.Currency: {\n // TODO(burdon): Get from property annotation.\n return (value as number).toLocaleString(locale, {\n style: 'currency',\n currency: 'USD',\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n });\n }\n case Format.TypeFormat.Date: {\n try {\n return formatDate(new Date(value as number), 'yyyy-MM-dd');\n } catch (error) {\n return 'Invalid Date';\n }\n }\n case Format.TypeFormat.Time: {\n try {\n return formatDate(new Date(value as number), 'HH:mm:ss');\n } catch (error) {\n return 'Invalid Time';\n }\n }\n case Format.TypeFormat.DateTime: {\n try {\n return formatDate(new Date(value as number), 'yyyy-MM-dd HH:mm:ss');\n } catch (error) {\n return 'Invalid DateTime';\n }\n }\n case Format.TypeFormat.GeoPoint: {\n if (value === null || value === undefined) {\n return '';\n }\n\n // For GeoPoint format [longitude, latitude].\n if (Array.isArray(value) && value.length >= 2 && value.every(Number.isFinite)) {\n const { latitude, longitude } = GeoLocation.fromGeoPoint(value as [number, number]);\n return `${latitude},${longitude}`;\n }\n\n return String(value);\n }\n default: {\n if (value === null || value === 'undefined') {\n return '';\n }\n return String(value);\n }\n }\n};\n\nexport const formatForEditing = ({ type, format, value, locale = undefined }: ValueFormatProps): string => {\n const formatScalar = (type: TypeEnum) => {\n switch (type) {\n case TypeEnum.Boolean:\n case TypeEnum.Number:\n case TypeEnum.String:\n case TypeEnum.Ref:\n return String(value);\n\n default:\n return String(value);\n }\n };\n\n if (!format) {\n return formatScalar(type);\n }\n\n switch (format) {\n case Format.TypeFormat.Boolean:\n case Format.TypeFormat.Number:\n case Format.TypeFormat.String:\n case Format.TypeFormat.Ref: {\n return formatScalar(type);\n }\n case Format.TypeFormat.Percent: {\n return String(value * 100);\n }\n case Format.TypeFormat.Currency: {\n return String(value);\n }\n case Format.TypeFormat.DateTime: {\n const date = new Date(value as number);\n return date.toISOString();\n }\n case Format.TypeFormat.Date: {\n const date = new Date(value as number);\n return date.toISOString().split('T')[0];\n }\n case Format.TypeFormat.Time: {\n const date = new Date(value as number);\n return date.toISOString().split('T')[1].split('.')[0];\n }\n case Format.TypeFormat.GeoPoint: {\n // Handle null or undefined\n if (value === null || value === undefined) {\n return '';\n }\n\n // For GeoPoint format [longitude, latitude].\n if (Array.isArray(value) && value.length >= 2 && value.every(Number.isFinite)) {\n const { latitude, longitude } = GeoLocation.fromGeoPoint(value as [number, number]);\n return `${latitude},${longitude}`;\n }\n\n return String(value);\n }\n\n default: {\n return String(value);\n }\n }\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Option from 'effect/Option';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { Annotation } from '@dxos/echo';\nimport { type AnyProperties } from '@dxos/echo/internal';\nimport { SchemaEx } from '@dxos/effect';\n\n/** The property's type with an optional `T | undefined` union unwrapped to its inner `T`. */\nconst unwrapOptional = (prop: SchemaAST.PropertySignature): SchemaAST.AST => {\n if (!prop.isOptional || !SchemaAST.isUnion(prop.type)) {\n return prop.type;\n }\n // Drop the `undefined` member, preserving the remaining union (don't collapse `A | B | undefined` to `A`).\n const defined = prop.type.types.filter((type) => type._tag !== 'UndefinedKeyword');\n if (defined.length === 0) {\n return prop.type;\n }\n return defined.length === 1 ? defined[0] : SchemaAST.Union.make(defined, prop.type.annotations);\n};\n\n/**\n * Resolve the properties to render for a field set's *root* schema, given the current form values.\n *\n * A top-level discriminated union is rendered flat: the fields of the member selected by the current\n * discriminator value, with the discriminator field keeping the union-wide set of literals so it stays\n * switchable. (`SchemaAST.getPropertySignatures` on a union returns only the common discriminator, so a\n * union root would otherwise render just that one field.) Non-union roots are unchanged. Nested unions are\n * unaffected — those are expanded per-field by `FormField`, which passes a single-member type literal here.\n */\nexport const getRootFormProperties = (\n ast: SchemaAST.AST,\n values: AnyProperties | undefined,\n): SchemaEx.SchemaProperty[] => {\n if (!SchemaEx.isDiscriminatedUnion(ast)) {\n return getFormProperties(ast);\n }\n\n const activeType = SchemaEx.getDiscriminatedType(ast, values ?? {});\n if (!activeType) {\n return getFormProperties(ast);\n }\n const activeProps = getFormProperties(activeType);\n\n const discriminators = new Set((SchemaEx.getDiscriminatingProps(ast) ?? []).map((name) => name.toString()));\n if (discriminators.size === 0) {\n return activeProps;\n }\n // The matched member types its discriminator as a single literal; swap in the union-wide literal so the\n // field renders as a full select rather than a fixed value.\n const fullType = SchemaEx.getDiscriminatedType(ast, {});\n const fullDiscriminatorProps = fullType ? getFormProperties(fullType) : activeProps;\n return activeProps.map((prop) =>\n discriminators.has(prop.name.toString())\n ? (fullDiscriminatorProps.find((candidate) => candidate.name === prop.name) ?? prop)\n : prop,\n );\n};\n\n/**\n * Get the property types of an AST and filter out properties that are not form inputs.\n *\n * The `FormInputAnnotation` is read from the raw property signature's AST (before\n * `encodedBoundAST` is applied by `SchemaEx.getProperties`), because `encodedBoundAST` strips\n * annotations from non-keyword inner types (e.g., `Schema.Struct`, `Schema.Array`).\n * Without this, fields like `Routine.input` (a JsonSchema struct) annotated\n * `FormInputAnnotation.set(false)` would still render in the form.\n *\n * For optional fields, `prop.type` is the union `T | undefined` — the annotation\n * lives on the inner `T`. Unwrap before reading so that the conventional pattern\n * `Schema.String.pipe(FormInputAnnotation.set(false), Schema.optional)` works.\n *\n * Container properties (nested structs, unions, arrays) keep their *raw* AST rather than\n * the `encodedBoundAST` produced by `SchemaEx.getProperties`. `encodedBoundAST` strips annotations\n * from non-keyword inner types, so a `FormInputAnnotation` nested beneath an encoded container\n * (e.g. `RouteLeg.geometry`, reached via `Segment → details → routes → Route → legs`) would\n * otherwise be lost by the time recursion reaches it. Leaf/transformation fields stay encoded\n * (e.g. a `DateTime` still renders as its encoded string input).\n */\nexport const getFormProperties = (ast: SchemaAST.AST): SchemaEx.SchemaProperty[] => {\n const signatures = SchemaAST.getPropertySignatures(ast);\n const rawByName = new Map<PropertyKey, SchemaAST.AST>(signatures.map((prop) => [prop.name, unwrapOptional(prop)]));\n const hidden = new Set(\n signatures\n .filter(\n (prop) =>\n Annotation.FormInputAnnotation.getFromAst(unwrapOptional(prop)).pipe(Option.getOrElse(() => true)) === false,\n )\n .map((prop) => prop.name),\n );\n return SchemaEx.getProperties(ast)\n .filter((prop) => !hidden.has(prop.name))\n .map((prop) => {\n const raw = rawByName.get(prop.name);\n return raw && (SchemaEx.isNestedType(raw) || SchemaEx.isArrayType(raw)) ? { ...prop, type: raw } : prop;\n });\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as SchemaAST from 'effect/SchemaAST';\n\nimport { Ref } from '@dxos/echo';\nimport { type ReferenceAnnotationValue, ReferenceAnnotationId } from '@dxos/echo/Annotation';\nimport { SchemaEx } from '@dxos/effect';\n\ntype RefProps = {\n ast: SchemaAST.AST;\n isArray: boolean;\n typename?: string;\n};\n\nexport const getRefProps = (ast: SchemaAST.AST): RefProps | undefined => {\n // Array of references.\n if (SchemaEx.isArrayType(ast)) {\n const elementType = SchemaEx.getArrayElementType(ast);\n if (elementType) {\n if (Ref.isRefType(elementType)) {\n const typename = SchemaEx.findAnnotation<ReferenceAnnotationValue>(\n elementType,\n ReferenceAnnotationId,\n )?.typename;\n return { ast: elementType, isArray: true, typename };\n }\n }\n }\n\n // Direct reference.\n if (Ref.isRefType(ast)) {\n const typename = SchemaEx.findAnnotation<ReferenceAnnotationValue>(ast, ReferenceAnnotationId)?.typename;\n return { ast, isArray: false, typename };\n }\n\n return undefined;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Option from 'effect/Option';\nimport * as SchemaAST from 'effect/SchemaAST';\nimport React, { useCallback } from 'react';\n\nimport { Ref } from '@dxos/echo';\nimport { SchemaEx } from '@dxos/effect';\nimport { useTranslation } from '@dxos/react-ui';\n\nimport { translationKey } from '#translations';\n\nimport { getFormProperties } from '../../../util';\nimport { useFormValues } from '../Form';\nimport { FormField, IconBlock, type FormFieldProps } from '../FormField';\nimport { FormFieldLabel, type FormFieldStateProps } from '../FormFieldComponent';\n\nexport type ArrayFieldProps = {\n label: string;\n fieldProps: FormFieldStateProps;\n} & FormFieldProps;\n\nexport const ArrayField = ({\n type,\n path,\n label,\n readonly,\n layout,\n fieldProps: inputProps,\n ...props\n}: ArrayFieldProps) => {\n const { t } = useTranslation(translationKey);\n const elementType = SchemaEx.getArrayElementType(type);\n const { onValueChange } = inputProps;\n const values = useFormValues(ArrayField.displayName, path, () => []);\n\n const getDefaultObjectValue = (typeNode: SchemaAST.AST): any => {\n const baseNode = SchemaEx.findNode(typeNode, SchemaEx.isDiscriminatedUnion);\n const typeLiteral = baseNode\n ? SchemaEx.getDiscriminatedType(baseNode, {})\n : SchemaEx.findNode(typeNode, SchemaAST.isTypeLiteral);\n if (!typeLiteral) {\n return {};\n }\n\n return Object.fromEntries(\n getFormProperties(typeLiteral).map((prop) => {\n const defaultValue = SchemaAST.getDefaultAnnotation(prop.type).pipe((annotation) =>\n Option.getOrUndefined(annotation),\n );\n return [prop.name, defaultValue];\n }),\n );\n };\n\n const handleAdd = useCallback(() => {\n const defaultValue =\n SchemaEx.isNestedType(type) && elementType ? getDefaultObjectValue(elementType) : getDefaultValue(elementType);\n // `values` is `undefined` on first render for arrays whose parent path\n // hasn't been materialised in the form values yet (e.g. `package.repos`\n // when the form starts with no `package`). `useFormValues`'s default-\n // value effect would eventually backfill it to `[]`, but until then the\n // old `values && ...` guard silently swallowed the click. Treat a\n // missing array as empty so Add always produces `[defaultValue]`.\n onValueChange(type, [...(values ?? []), defaultValue]);\n }, [onValueChange, type, elementType, values]);\n\n const handleDelete = useCallback(\n (idx: number) => {\n onValueChange(\n type,\n values?.filter((_, i) => i !== idx),\n );\n },\n [onValueChange, type, values],\n );\n\n if (!elementType || ((readonly || layout === 'static') && values && values.length < 1)) {\n return null;\n }\n\n const renderItemAsObject = elementType && SchemaEx.isNestedType(elementType) && !Ref.isRefType(elementType);\n\n return (\n <>\n {(layout !== 'static' || (values && values.length > 0)) && (\n <div className='flex items-center gap-2'>\n <div className='flex-1 min-w-0'>\n <FormFieldLabel readonly={readonly} label={label} path={SchemaEx.createJsonPath(path ?? [])} asChild />\n </div>\n {!readonly && layout !== 'static' && (\n <IconBlock inline icon='ph--plus--regular' label={t('add-item.button')} onClick={handleAdd} />\n )}\n </div>\n )}\n\n <div className='flex flex-col'>\n {values?.map((_, index) => {\n const isLast = index === values.length - 1;\n\n // Object items: each row contains a recursively-rendered FormField\n // (multiple sub-rows for the object's fields) wrapped in a border,\n // with the delete button bottom-aligned next to it.\n // Scalar items: a single-row inline FormField with a center-aligned\n // delete button. Refs and primitive arrays use this layout.\n const fieldField = (\n <FormField\n {...props}\n autoFocus={isLast}\n type={elementType}\n // Suppress the per-item header for object items only — the recursive\n // form already renders labels for each sub-field. Scalar items\n // (refs, primitives) keep the parent name so inline-layout\n // children (e.g. RefField) have a real label to use as a\n // fallback placeholder.\n {...(renderItemAsObject && { name: null })}\n path={[...(path ?? []), index]}\n readonly={readonly || layout === 'static'}\n layout={renderItemAsObject ? (layout === 'static' ? 'static' : undefined) : 'inline'}\n />\n );\n\n return (\n <div key={index} className='grid grid-cols-[1fr_min-content] items-center mb-1 last:mb-form-gap'>\n {fieldField}\n {!readonly && layout !== 'static' && (\n <IconBlock\n inline={!renderItemAsObject}\n icon='ph--x--regular'\n label={t('remove-item.button')}\n onClick={() => handleDelete(index)}\n />\n )}\n </div>\n );\n })}\n </div>\n </>\n );\n};\n\nArrayField.displayName = 'Form.ArrayField';\n\n/**\n * Returns the default empty value for a given AST.\n * Used for initializing new array values etc.\n */\n// TODO(wittjosiah): Factor out?\nexport const getDefaultValue = (ast?: SchemaAST.AST): any => {\n switch (ast?._tag) {\n case 'StringKeyword': {\n return '';\n }\n case 'NumberKeyword': {\n return 0;\n }\n case 'BooleanKeyword': {\n return false;\n }\n case 'Suspend': {\n return getDefaultValue(ast.f());\n }\n default: {\n if (ast && SchemaEx.isNestedType(ast)) {\n return {};\n } else {\n throw new Error(`Unsupported type: ${ast?._tag}`);\n }\n }\n }\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { createContext } from '@radix-ui/react-context';\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\nimport React, { type PropsWithChildren, useEffect, useMemo, useRef } from 'react';\n\nimport { Annotation as EchoAnnotation, Type } from '@dxos/echo';\nimport { type AnyProperties } from '@dxos/echo/internal';\nimport { SchemaEx } from '@dxos/effect';\nimport {\n Column,\n type ColumnRootProps,\n IconButton,\n type IconButtonProps,\n Input,\n ScrollArea,\n type ThemedClassName,\n useMergeRefs,\n useTranslation,\n} from '@dxos/react-ui';\nimport { composable, composableProps, withColumn } from '@dxos/react-ui';\nimport { mx } from '@dxos/ui-theme';\n\nimport { translationKey } from '#translations';\n\nimport {\n type FormHandler,\n type FormHandlerProps,\n type FormUpdateMeta,\n useFormHandler,\n useKeyHandler,\n} from '../../hooks';\nimport { FormFieldLabel, type FormFieldLabelProps, type FormFieldStateProps } from './FormFieldComponent';\nimport {\n FormFieldSet as NaturalFormFieldSet,\n type FormFieldSetProps as NaturalFormFieldSetProps,\n} from './FormFieldSet';\nimport { FormTooltipsContext } from './FormTooltipsContext';\nimport { FormLayout as NaturalFormLayout } from './Layout';\nimport { type FormLayoutProps as NaturalFormLayoutProps } from './Layout/FormLayout';\n\n// TODO(burdon): Move styles to form.ts (as with ui-theme).\n\n// TODO(burdon): Reconcile with @dxos/echo.\nexport type ExcludeId<S extends Schema.Schema.AnyNoContext | Type.AnyEntity> = Omit<\n S extends Type.AnyEntity\n ? Type.InstanceType<S>\n : S extends Schema.Schema.AnyNoContext\n ? Schema.Schema.Type<S>\n : never,\n 'id'\n>;\n\n// TODO(burdon): Move to @dxos/schema (re-export here).\nexport const omitId = <S extends Schema.Schema.AnyNoContext | Type.AnyEntity>(\n schemaOrType: S,\n): Schema.Schema<ExcludeId<S>, ExcludeId<S>> => {\n const schema = Type.isType(schemaOrType)\n ? Type.getSchema(schemaOrType)\n : (schemaOrType as Schema.Schema.AnyNoContext);\n return schema.pipe(Schema.omit('id')) as any;\n};\n\n/**\n * Drop fields annotated with `FormInputAnnotation.set(false)` from a schema so\n * the form's validator doesn't trip on required-but-hidden fields. Used by\n * the picker's inline create form, where a `FactoryAnnotation` typically\n * supplies the hidden values (e.g. a backing-object Ref) outside the form.\n */\nexport const omitHiddenFormFields = <S extends Schema.Schema.AnyNoContext>(schema: S): S => {\n const properties = SchemaAST.getPropertySignatures(schema.ast);\n const hidden = properties\n .filter((prop) => Option.getOrElse(EchoAnnotation.FormInputAnnotation.getFromAst(prop.type), () => true) === false)\n .map((prop) => prop.name as string);\n return hidden.length === 0 ? schema : (schema.pipe(Schema.omit(...(hidden as [string, ...string[]]))) as any);\n};\n\n//\n// Context\n//\n\ntype FormContextValue<T extends AnyProperties = any> = {\n /**\n * Form handler.\n */\n form: FormHandler<T>;\n\n /**\n * Show field tooltips (currently: JSON path on each label). Defaults to\n * `true`; pass `false` to suppress.\n */\n tooltips?: boolean;\n\n /**\n * Testing.\n */\n testId?: string;\n} & Pick<\n NaturalFormFieldSetProps<T>,\n 'readonly' | 'layout' | 'fieldMap' | 'fieldProvider' | 'projection' | 'createTypename' | 'createFieldMap' | 'db'\n>;\n\nconst [FormContextProvider, useFormContext] = createContext<FormContextValue>('Form');\n\n/**\n * Get the current form values.\n */\nconst useFormValues: {\n <T extends AnyProperties>(componentName: string, path?: (string | number)[]): T;\n <T extends AnyProperties>(\n componentName: string,\n path: (string | number)[] | undefined,\n defaultValue: () => T,\n ): T | undefined;\n} = (componentName: string, path?: (string | number)[], defaultValue?: () => any) => {\n const stablePath = useMemo(() => path ?? [], [path ? path.join('.') : undefined]);\n const jsonPath = SchemaEx.createJsonPath(stablePath);\n const {\n form: { values, onValueChange },\n } = useFormContext(componentName);\n\n const value = SchemaEx.getValue(values, jsonPath);\n\n // Apply default value once when the field has no value. lastAppliedPathRef prevents\n // re-applying on every render (e.g. when defaultValue() returns null) and ensures\n // we apply per path when the hook is used for different fields.\n const lastAppliedPathRef = useRef<string | null>(null);\n useEffect(() => {\n if (value == null && defaultValue && lastAppliedPathRef.current !== jsonPath) {\n lastAppliedPathRef.current = jsonPath;\n onValueChange(stablePath, SchemaAST.stringKeyword, defaultValue());\n }\n }, [value, defaultValue, onValueChange, stablePath, jsonPath]);\n\n return value;\n};\n\n/**\n * Get the state props for the given field.\n */\nconst useFormFieldState = (componentName: string, path: (string | number)[] = []): FormFieldStateProps => {\n const stablePath = useMemo(() => path, [Array.isArray(path) ? path.join('.') : path]);\n const {\n form: { getStatus, getValue, onBlur, onValueChange },\n } = useFormContext(componentName);\n\n return useMemo(\n () => ({\n getStatus: () => getStatus(stablePath),\n getValue: () => getValue(stablePath),\n onBlur: () => onBlur(stablePath),\n onValueChange: (ast: SchemaAST.AST, value: any) => onValueChange(stablePath, ast, value),\n }),\n [getStatus, getValue, onBlur, onValueChange, stablePath],\n );\n};\n\n//\n// Root\n//\n\ntype FormRootProps<T extends AnyProperties = AnyProperties> = PropsWithChildren<\n {\n /**\n * Called when the form is submitted and passes validation.\n */\n onSave?: (values: T, meta: FormUpdateMeta<T>) => void;\n\n /**\n * Called when the form is canceled to abandon/undo any pending changes.\n */\n onCancel?: () => void;\n } & Omit<FormContextValue<T>, 'form'> &\n Pick<FormHandlerProps<T>, 'schema' | 'autoSave' | 'values' | 'defaultValues' | 'onValidate' | 'onValuesChanged'> &\n Omit<NaturalFormFieldSetProps<T>, 'schema' | 'path'>\n>;\n\nconst FormRoot = <T extends AnyProperties = AnyProperties>({\n children,\n schema,\n values,\n onSave,\n onCancel,\n ...props\n}: FormRootProps<T>) => {\n const form = useFormHandler({ schema, values, onSave, onCancel, ...props });\n\n return (\n <FormTooltipsContext.Provider value={props.tooltips ?? true}>\n <FormContextProvider form={form} {...props}>\n {children}\n </FormContextProvider>\n </FormTooltipsContext.Provider>\n );\n};\n\nFormRoot.displayName = 'Form.Root';\n\n//\n// Viewport\n//\n\nconst FORM_VIEWPORT_NAME = 'Form.Viewport';\n\ntype FormViewportProps = { scroll?: boolean; gutter?: ColumnRootProps['gutter'] };\n\n// The viewing window: owns the gutter Column (chrome/side-padding).\n// Content-height by default; `scroll` makes it fill its parent and scroll (the gutter then hosts the scrollbar).\nconst FormViewport = composable<HTMLDivElement, FormViewportProps>(\n ({ children, scroll, gutter = 'xs', ...props }, forwardedRef) => {\n // Span the full width when nested inside another Column grid (e.g. Card.Root)\n // instead of landing in a single narrow track.\n const span = '[.dx-column-root_&]:col-span-full';\n if (scroll) {\n return (\n <Column.Root gutter={gutter} classNames={['dx-expander', span]}>\n <ScrollArea.Root {...composableProps(props)} orientation='vertical' centered padding thin ref={forwardedRef}>\n <ScrollArea.Viewport>{children}</ScrollArea.Viewport>\n </ScrollArea.Root>\n </Column.Root>\n );\n }\n\n return (\n <Column.Root {...composableProps(props)} gutter={gutter} classNames={['w-full min-w-0', span]} ref={forwardedRef}>\n {children}\n </Column.Root>\n );\n },\n);\n\nFormViewport.displayName = FORM_VIEWPORT_NAME;\n\n//\n// Content\n//\n\nconst FORM_CONTENT_NAME = 'Form.Content';\n\ntype FormContentProps = ThemedClassName<PropsWithChildren<{}>>;\n\n// The viewed body: centered in the viewport's gutter. Pure body — the gutter Column is owned by `Form.Viewport`.\nconst FormContent = composable<HTMLDivElement, FormContentProps>(({ children, ...props }, forwardedRef) => {\n const { form, testId } = useFormContext(FORM_CONTENT_NAME);\n const localRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMergeRefs([forwardedRef, localRef]);\n useKeyHandler(localRef, form);\n\n return (\n <div\n {...composableProps(props, {\n role: 'form',\n classNames: mx(withColumn.center(), 'flex flex-col w-full'),\n })}\n data-testid={testId}\n ref={mergedRef}\n >\n {children}\n </div>\n );\n});\n\nFormContent.displayName = FORM_CONTENT_NAME;\n\n//\n// FieldSet\n//\n\nconst FORM_FIELDSET_NAME = 'Form.FieldSet';\n\ntype FormFieldSetProps = ThemedClassName<NaturalFormFieldSetProps<any>>;\n\nconst FormFieldSet = (props: FormFieldSetProps) => {\n const { form, ...contextProps } = useFormContext(FORM_FIELDSET_NAME);\n\n return <NaturalFormFieldSet schema={form.schema} {...contextProps} {...props} />;\n};\n\nFormFieldSet.displayName = FORM_FIELDSET_NAME;\n\n//\n// Layout\n//\n\nconst FORM_LAYOUT_NAME = 'Form.Layout';\n\ntype FormLayoutProps = Omit<NaturalFormLayoutProps, 'schema'> & { schema?: NaturalFormLayoutProps['schema'] };\n\nconst FormLayout = ({ schema, ...props }: FormLayoutProps) => {\n const { form, ...contextProps } = useFormContext(FORM_LAYOUT_NAME);\n const resolvedSchema = schema ?? form.schema;\n if (!resolvedSchema) {\n return null;\n }\n\n return <NaturalFormLayout schema={resolvedSchema} {...contextProps} {...props} />;\n};\n\nFormLayout.displayName = FORM_LAYOUT_NAME;\n\n//\n// Actions\n//\n\nconst FORM_ACTIONS_NAME = 'Form.Actions';\n\ntype FormActionsProps = ThemedClassName<{}>;\n\nconst FormActions = ({ classNames }: FormActionsProps) => {\n const { t } = useTranslation(translationKey);\n const {\n form: { canSave, onSave, onCancel },\n readonly,\n layout,\n } = useFormContext(FORM_ACTIONS_NAME);\n\n if (readonly || layout === 'static') {\n return null;\n }\n\n // TODO(burdon): Currently onCancel is a no-op; implement \"revert values\".\n // Deprecate FormSubmit ans use FormActions without Cancel button if no callback is supplied.\n\n return (\n <div\n className={mx(withColumn.center(), 'grid grid-flow-col gap-form-gap auto-cols-fr py-form-padding', classNames)}\n >\n {onCancel && (\n <IconButton\n icon='ph--x--regular'\n iconEnd\n label={t('cancel-button.label')}\n onClick={onCancel}\n data-testid='cancel-button'\n />\n )}\n {onSave && (\n <IconButton\n type='submit'\n variant='primary'\n disabled={!canSave}\n icon='ph--check--regular'\n iconEnd\n label={t('save-button.label')}\n onClick={onSave}\n data-testid='save-button'\n />\n )}\n </div>\n );\n};\n\nFormActions.displayName = FORM_ACTIONS_NAME;\n\n//\n// Section\n//\n\nconst FORM_SECTION_NAME = 'Form.Section';\n\ntype FormSectionProps = ThemedClassName<{ label?: string; description?: string }>;\n\nconst FormSection = composable<HTMLDivElement, FormSectionProps>(\n ({ children, label, description, ...props }, forwardedRef) => {\n return (\n <div\n {...composableProps(props, { classNames: 'flex flex-col pt-form-section-gap first:pt-0' })}\n ref={forwardedRef}\n >\n {label && <h2 className='text-lg'>{label}</h2>}\n {description && <p className='text-description'>{description}</p>}\n {children}\n </div>\n );\n },\n);\n\nFormSection.displayName = FORM_SECTION_NAME;\n\n//\n// Submit\n//\n\nconst FORM_SUBMIT_NAME = 'Form.Submit';\n\ntype FormSubmitProps = ThemedClassName<Partial<Pick<IconButtonProps, 'icon' | 'label' | 'disabled'>>>;\n\nconst FormSubmit = ({ classNames, label, icon, disabled }: FormSubmitProps) => {\n const { t } = useTranslation(translationKey);\n const {\n form: { canSave, onSave },\n readonly,\n layout,\n } = useFormContext(FORM_SUBMIT_NAME);\n\n if (readonly || layout === 'static') {\n return null;\n }\n\n return (\n <div className={mx('flex w-full pt-form-padding', classNames)}>\n <IconButton\n classNames='w-full'\n type='submit'\n variant='primary'\n disabled={disabled ?? !canSave}\n icon={icon ?? 'ph--check--regular'}\n label={label ?? t('save-button.label')}\n onClick={onSave}\n data-testid='save-button'\n />\n </div>\n );\n};\n\nFormSubmit.displayName = FORM_SUBMIT_NAME;\n\n//\n// Error\n//\n\nconst FORM_ERROR_NAME = 'Form.Error';\n\ntype FormErrorProps = ThemedClassName<PropsWithChildren>;\n\n/** Form-level error/validation message (e.g. a failed submit), styled via the error valence. */\nconst FormError = ({ children, classNames }: FormErrorProps) => {\n if (!children) {\n return null;\n }\n\n return (\n <Input.Root validationValence='error'>\n <Input.Validation classNames={classNames}>{children}</Input.Validation>\n </Input.Root>\n );\n};\n\nFormError.displayName = FORM_ERROR_NAME;\n\n//\n// Form\n// https://www.radix-ui.com/primitives/docs/guides/composition\n//\n\nexport const Form = {\n Root: FormRoot,\n Viewport: FormViewport,\n Content: FormContent,\n Section: FormSection,\n FieldSet: FormFieldSet,\n Layout: FormLayout,\n Label: FormFieldLabel,\n Actions: FormActions,\n Submit: FormSubmit,\n Error: FormError,\n};\n\nexport { useFormContext, useFormValues, useFormFieldState };\n\nexport type {\n FormRootProps,\n FormViewportProps,\n FormContentProps,\n FormSectionProps,\n FormFieldSetProps,\n FormLayoutProps,\n FormFieldLabelProps,\n FormActionsProps,\n FormSubmitProps,\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport type * as Schema from 'effect/Schema';\nimport type * as SchemaAST from 'effect/SchemaAST';\nimport { useCallback, useEffect, useMemo, useState } from 'react';\n\nimport { type AnyProperties } from '@dxos/echo/internal';\nimport { SchemaEx } from '@dxos/effect';\nimport { log } from '@dxos/log';\nimport { useDefaultValue } from '@dxos/react-ui';\nimport { type ValidationError, validateSchema } from '@dxos/schema';\nimport { type MaybePromise } from '@dxos/util';\n\nexport type FormFieldStatus = {\n status?: 'error';\n error?: string;\n};\n\n/**\n * Form properties.\n */\nexport interface FormHandlerProps<T extends AnyProperties> {\n /**\n * Effect schema (Type literal).\n */\n schema?: Schema.Schema<T, any>;\n\n /**\n * Values for the form if controlled.\n */\n values?: Partial<T>;\n\n /**\n * Default values for the form which will be used if values is not provided.\n */\n defaultValues?: Partial<T>;\n\n /**\n * Auto-save the form when the values change.\n */\n autoSave?: boolean;\n\n /**\n * Callback for value changes. Note: This is called even when values are invalid.\n * Sometimes the parent component may want to know about changes even if the form is\n * in an invalid state.\n */\n onValuesChanged?: (values: Partial<T>, meta: FormUpdateMeta<T>) => void;\n\n /**\n * Custom validation function that runs only after schema validation passes.\n * Use this for complex validation logic that can't be expressed in the schema.\n * @returns Array of validation errors, or undefined if validation passes\n */\n onValidate?: (values: T) => ValidationError[] | undefined;\n\n /**\n * Called when the form is submitted and passes validation.\n */\n onSave?: (values: T, meta: FormUpdateMeta<T>) => MaybePromise<void>;\n\n /**\n * Called when the form is canceled.\n */\n onCancel?: () => void;\n}\n\nexport type FormUpdateMeta<T extends AnyProperties> = {\n changed: FormHandler<T>['changed'];\n isValid: boolean;\n};\n\n/**\n * Form handler properties and methods.\n */\nexport type FormHandler<T extends AnyProperties> = Pick<FormHandlerProps<T>, 'schema' | 'autoSave'> & {\n /** Initial values (which may not pass validation). */\n values: Partial<T>;\n\n /** Map of changed fields. */\n changed: Record<SchemaEx.JsonPath, boolean>;\n // TODO(burdon): How is this different from above?\n touched: Record<SchemaEx.JsonPath, boolean>;\n\n /** Map of error strings. */\n errors: Record<SchemaEx.JsonPath, string>;\n\n /** Whether the form can be saved (i.e., data is valid). */\n isValid: boolean;\n // TODO(burdon): Why is this needed separately from isValid?\n canSave: boolean;\n\n onSave: () => void;\n onCancel: () => void;\n\n //\n // Form field state management\n //\n\n getStatus: (path: string | (string | number)[]) => FormFieldStatus;\n getValue: <V>(path: (string | number)[]) => V | undefined;\n onBlur: (path: (string | number)[]) => void;\n onValueChange: <V>(path: (string | number)[], type: SchemaAST.AST, value: V) => void;\n};\n\n/**\n * Creates a hook for managing form state, including values, validation, and submission.\n * Deeply integrated with `@dxos/schema` for schema-based validation.\n */\nexport const useFormHandler = <T extends AnyProperties>({\n schema,\n autoSave,\n values: valuesProp,\n defaultValues: defaultValuesProp,\n onValuesChanged,\n onValidate,\n onSave,\n onCancel,\n ...props\n}: FormHandlerProps<T>): FormHandler<T> => {\n const [changed, setChanged] = useState<Record<SchemaEx.JsonPath, boolean>>({});\n const [touched, setTouched] = useState<Record<SchemaEx.JsonPath, boolean>>({});\n const [errors, setErrors] = useState<Record<SchemaEx.JsonPath, string>>({});\n const [saving, setSaving] = useState(false);\n const defaultValues = useDefaultValue<Partial<T>>(defaultValuesProp, () => ({}));\n const [values$, setValues] = useControllableState<Partial<T>>({\n prop: valuesProp,\n defaultProp: defaultValues,\n onChange: () => {\n // Only reset when controlled: parent passed new values.\n // Uncontrolled updates come from setValues in onValueChange.\n if (valuesProp !== undefined) {\n setValues(valuesProp ?? defaultValues);\n setChanged({});\n setTouched({});\n setErrors({});\n setSaving(false);\n }\n },\n });\n // TODO(wittjosiah): Upgrade @radix-ui/react-use-controllable-state.\n const values = values$ as Partial<T>;\n\n // Validate.\n const validate = useCallback(\n (values: Partial<T>): values is T => {\n if (!schema) {\n return false;\n }\n\n let errors: ValidationError[] = validateSchema(schema, values) ?? [];\n log('validate', { values, errors });\n if (errors.length === 0 && onValidate) {\n const validatedValues = values as T;\n errors = onValidate(validatedValues) ?? [];\n }\n\n setErrors(flatMap(errors));\n const valid = errors.length === 0;\n return valid;\n },\n [schema, onValidate],\n );\n\n // Validate on schema change.\n const [schemaChanged, setSchemaChanged] = useState(false);\n useEffect(() => setSchemaChanged(true), [schema]);\n useEffect(() => {\n if (schemaChanged) {\n validate(values);\n setSchemaChanged(false);\n }\n }, [validate, values, schemaChanged]);\n\n const isValid = useMemo(() => {\n return Object.keys(errors).length === 0;\n }, [errors]);\n\n /**\n * NOTE: We can submit if there is no touched field that has an error.\n * If there's a validation message visible in the form, submit should be disabled.\n */\n const canSave = useMemo(\n () =>\n !saving &&\n // Check if any error paths that are touched have errors.\n !Object.entries(touched).some(\n ([path, isTouched]) =>\n isTouched &&\n Object.keys(errors).some(\n (errorPath) => errorPath === path || errorPath.startsWith(`${path}.`) || errorPath.startsWith(`${path}[`),\n ),\n ),\n [touched, errors, saving],\n );\n\n const handleSave = useCallback(async () => {\n if (validate(values)) {\n setSaving(true);\n try {\n await onSave?.(values, { changed, isValid });\n } finally {\n setSaving(false);\n }\n }\n }, [values, validate, onSave, changed, isValid]);\n\n const handleCancel = useCallback(() => {\n onCancel?.();\n }, [onCancel]);\n\n //\n // Fields.\n //\n\n const getStatus = useCallback<FormHandler<T>['getStatus']>(\n (path) => {\n const jsonPath = Array.isArray(path) ? SchemaEx.createJsonPath(path) : path;\n const [_, error] =\n Object.entries(errors).find(\n ([errorPath]) =>\n errorPath === jsonPath || errorPath.startsWith(`${jsonPath}.`) || errorPath.startsWith(`${jsonPath}[`),\n ) ?? [];\n\n // Only show errors for touched fields.\n const isTouched = touched[jsonPath as SchemaEx.JsonPath];\n if (!isTouched) {\n return {\n status: undefined,\n error: undefined,\n };\n }\n\n return {\n status: error ? 'error' : undefined,\n error: error ? (error ?? undefined) : undefined,\n };\n },\n [errors, touched],\n );\n\n const getValue = useCallback<FormHandler<T>['getValue']>(\n (path) => {\n return SchemaEx.getValue(values, SchemaEx.createJsonPath(path));\n },\n [values],\n );\n\n const onValueChange = useCallback<FormHandler<T>['onValueChange']>(\n (path, type, value) => {\n log('onValueChange', { path, value });\n\n const jsonPath = SchemaEx.createJsonPath(path);\n const pathArray = path;\n let parsedValue = value as any;\n try {\n if (type._tag === 'NumberKeyword') {\n parsedValue = parseFloat(value as string) || 0;\n }\n } catch (err) {\n log.catch(err);\n parsedValue = undefined;\n }\n\n // Create merged values for validation and callback. Form never mutates; parent applies via onValuesChanged.\n const newValues = mergeAtPath(values, pathArray as (string | number)[], parsedValue) as Partial<T>;\n\n // TODO(burdon): Check value has changed from original.\n const newChanged = { [jsonPath]: true };\n setChanged((prev) => ({ ...prev, ...newChanged }));\n\n // Validate.\n const isValid = validate(newValues);\n\n // Notify parent; parent is responsible for applying the change.\n onValuesChanged?.(newValues, { isValid, changed: newChanged });\n\n // For uncontrolled mode, update internal state. Controlled mode relies on parent to pass new values.\n if (valuesProp === undefined) {\n setValues(newValues);\n }\n },\n [values, validate, onValuesChanged, valuesProp],\n );\n\n const onBlur = useCallback(\n async (path: (string | number)[]) => {\n const jsonPath = SchemaEx.createJsonPath(path);\n\n // TODO(burdon): Check value has changed from original.\n setTouched((touched) => ({ ...touched, [jsonPath]: true }));\n const isValid = validate(values);\n\n // Auto-save when a field is blurred and is valid.\n if (Object.keys(changed).length > 0 && isValid && autoSave) {\n await onSave?.(values as T, { changed, isValid });\n }\n },\n [validate, values, changed, autoSave, onSave],\n );\n\n return useMemo<FormHandler<T>>(\n () => ({\n // State.\n schema,\n values,\n errors,\n touched,\n changed,\n isValid,\n canSave,\n autoSave,\n\n // Actions.\n onSave: handleSave,\n onCancel: handleCancel,\n\n // Field utils.\n getStatus,\n getValue,\n onBlur,\n onValueChange,\n\n ...props,\n }),\n [\n schema,\n values,\n errors,\n touched,\n changed,\n canSave,\n isValid,\n getStatus,\n getValue,\n onBlur,\n onValueChange,\n onSave,\n onCancel,\n ],\n );\n};\n\n/**\n * Creates a new object with value at path. Does not mutate source.\n * Preserves arrays when path segments are numeric indices.\n */\nconst mergeAtPath = (obj: any, path: readonly (string | number)[], value: any): any => {\n if (path.length === 0) {\n return value;\n }\n\n const [head, ...rest] = path;\n const child = rest.length === 0 ? value : mergeAtPath(obj?.[head], rest, value);\n\n if (Array.isArray(obj)) {\n const copy = [...obj];\n copy[head as number] = child;\n return copy;\n }\n\n return { ...obj, [head]: child };\n};\n\nconst flatMap = (errors: ValidationError[]) => {\n return errors.reduce(\n (result, { path, message }) => {\n // Convert the validation error path format to our SchemaEx.JsonPath format.\n const jsonPath = SchemaEx.fromEffectValidationPath(path);\n if (!(jsonPath in result)) {\n result[jsonPath] = message;\n }\n return result;\n },\n {} as Record<SchemaEx.JsonPath, string>,\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type RefObject, useCallback, useLayoutEffect } from 'react';\n\nimport { addEventListener } from '@dxos/async';\n\nimport { type FormHandler } from './useFormHandler';\n\n/**\n * Key handler.\n */\nexport const useKeyHandler = (elRef: RefObject<HTMLDivElement | null>, form: FormHandler<any>) => {\n const handleKeyDown = useCallback(\n (event: KeyboardEvent) => {\n switch (event.key) {\n case 'Enter': {\n if (event.metaKey && form.canSave) {\n form.onSave();\n }\n break;\n }\n }\n },\n [form.isValid, form.canSave, form.onSave, form.autoSave],\n );\n\n useLayoutEffect(() => {\n const el = elRef.current;\n if (!el) {\n return;\n }\n\n return addEventListener(el, 'keydown', handleKeyDown);\n }, [elRef, handleKeyDown]);\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { format as formatDate } from 'date-fns';\nimport type * as Schema from 'effect/Schema';\nimport type * as SchemaAST from 'effect/SchemaAST';\nimport React, {\n Component,\n type FC,\n type FocusEvent,\n type PropsWithChildren,\n type ReactElement,\n type ReactNode,\n} from 'react';\n\nimport { type Database, Format } from '@dxos/echo';\nimport { Icon, Input, ThemedClassName, Tooltip } from '@dxos/react-ui';\nimport { inputTextLabel } from '@dxos/react-ui';\nimport { mx } from '@dxos/ui-theme';\n\nimport { type FormFieldStatus } from '../../hooks';\nimport { useFormTooltips } from './FormTooltipsContext';\n\n/**\n * Dynamic props passed to input components.\n */\nexport type FormFieldStateProps<T = any> = {\n getStatus: () => FormFieldStatus;\n getValue: () => T | undefined;\n onBlur: (event: FocusEvent<HTMLElement>) => void;\n onValueChange: (type: SchemaAST.AST, value: T) => void;\n};\n\n/**\n * Presentation mode.\n * - full: Show label, control, and status.\n * - compact: Show label and control.\n * - inline: Control only.\n * - static: Plain DOM; omit all undefined values.\n */\n// TODO(burdon): 'inline' should be orthogonal to the layout (e.g., array of inline static).\nexport type Presentation = 'full' | 'compact' | 'inline' | 'static';\n\n/**\n * Props passed to input components.\n */\nexport type FormFieldComponentProps<T = any> = {\n /** Database the form is editing against; populated for fields whose value is an ECHO object/Ref. */\n db?: Database.Database;\n type: SchemaAST.AST;\n format?: Format.TypeFormat;\n readonly?: boolean;\n label: string;\n /**\n * Dotted JSON path of this field within the form values (e.g.\n * `runtime.client.storage.persistent`). Forwarded to `FormFieldLabel` so\n * that it can render the path as a debug hint when the enclosing\n * `Form.Root` has `debug` enabled.\n */\n jsonPath?: string;\n placeholder?: string;\n autoFocus?: boolean;\n layout?: Presentation;\n} & FormFieldStateProps<T>;\n\nexport type FormFieldComponent = FC<FormFieldComponentProps>;\n\nexport type FormFieldMap = Record<string, FormFieldComponent>;\n\nexport type FormFieldProvider = (props: {\n prop: string;\n schema: Schema.Schema<any>;\n fieldProps: FormFieldComponentProps;\n}) => ReactElement | null | undefined;\n\n//\n// FormFieldLabel\n//\n\nexport type FormFieldLabelProps = ThemedClassName<\n {\n asChild?: boolean;\n error?: string;\n /**\n * JSON path of the field this label describes (e.g. `runtime.client.storage.persistent`).\n * Surfaced as a hover tooltip on the label when the enclosing `Form.Root`\n * has `tooltips` enabled (the default) -- useful for spotting which field\n * maps to which path when authoring schemas or filing bugs against a form.\n * Callers can supply the path unconditionally; the label suppresses the\n * tooltip when `Form.Root tooltips={false}`.\n */\n path?: string;\n /**\n * Trailing button rendered at the end of the label row (third grid column).\n * Used by nested-object field sets to surface a collapse toggle.\n */\n button?: ReactNode;\n onClick?: () => void;\n } & Pick<FormFieldComponentProps, 'label' | 'readonly'>\n>;\n\nexport const FormFieldLabel = ({\n classNames,\n label,\n error,\n readonly,\n asChild,\n path,\n button,\n onClick,\n}: FormFieldLabelProps) => {\n const tooltips = useFormTooltips();\n const Label = readonly || asChild ? 'span' : Input.Label;\n const labelNode = <Label className={mx(inputTextLabel, 'text-sm')}>{label}</Label>;\n\n return (\n <div\n className={mx('grid grid-cols-[1fr_auto_auto] items-center select-none', onClick && 'cursor-pointer', classNames)}\n onClick={onClick}\n >\n {tooltips && path ? (\n <Tooltip.Trigger asChild content={path} side='bottom'>\n {labelNode}\n </Tooltip.Trigger>\n ) : (\n labelNode\n )}\n {error ? (\n <Tooltip.Trigger asChild content={error} side='bottom'>\n <Icon icon='ph--warning--regular' size={4} classNames='text-error-text' />\n </Tooltip.Trigger>\n ) : (\n <span />\n )}\n {button}\n </div>\n );\n};\n\nFormFieldLabel.displayName = 'Form.FieldLabel';\n\n//\n// FormFieldWrapper\n//\n\nexport type FormFieldWrapperProps<T = any> = Pick<\n FormFieldComponentProps,\n 'readonly' | 'label' | 'layout' | 'getStatus' | 'getValue' | 'jsonPath' | 'format'\n> & {\n children?: (props: { value: T }) => ReactNode;\n};\n\n/**\n * Formats a value for `static` (read-only, plain-DOM) presentation based on its\n * type `format`. Dates/times are rendered human-readable; everything else falls\n * back to `String(value)`.\n */\nconst formatStaticValue = (value: unknown, format?: Format.TypeFormat): string => {\n if (value == null) {\n return '';\n }\n\n switch (format) {\n case Format.TypeFormat.DateTime:\n case Format.TypeFormat.Date:\n case Format.TypeFormat.Time: {\n const date = new Date(value as string);\n if (Number.isNaN(date.getTime())) {\n return String(value);\n }\n const pattern = format === Format.TypeFormat.DateTime ? 'PPp' : format === Format.TypeFormat.Date ? 'PP' : 'p';\n return formatDate(date, pattern);\n }\n default:\n return String(value);\n }\n};\n\nexport const FormFieldWrapper = <T,>(props: FormFieldWrapperProps<T>) => {\n const { children, readonly, layout, label, jsonPath, format, getStatus, getValue } = props;\n const { status, error } = getStatus();\n\n const value = getValue();\n if (layout === 'static' && value == null) {\n return null;\n }\n\n const str = formatStaticValue(value, format);\n\n return (\n <div className='contents'>\n <Input.Root validationValence={status}>\n {layout !== 'inline' && <FormFieldLabel error={error} readonly={readonly} label={label} path={jsonPath} />}\n {layout === 'static' ? (\n <p className='truncate min-w-0' title={str}>\n {str}\n </p>\n ) : children ? (\n children({ value })\n ) : null}\n {layout === 'full' && error && (\n <Input.DescriptionAndValidation>\n <Input.Validation>{error}</Input.Validation>\n </Input.DescriptionAndValidation>\n )}\n </Input.Root>\n </div>\n );\n};\n\n//\n// FormFieldErrorBoundary\n//\n\ntype FormFieldErrorState = {\n error: Error | undefined;\n};\n\ntype FormFieldErrorBoundaryProps = PropsWithChildren<{\n path?: (string | number)[];\n}>;\n\nexport class FormFieldErrorBoundary extends Component<FormFieldErrorBoundaryProps, FormFieldErrorState> {\n static getDerivedStateFromError(error: Error): { error: Error } {\n return { error };\n }\n\n override state = { error: undefined };\n\n override componentDidUpdate(prevProps: FormFieldErrorBoundaryProps) {\n if (prevProps.path !== this.props.path) {\n this.resetError();\n }\n }\n\n override render() {\n if (this.state.error) {\n return (\n <div className='flex gap-2 border border-rose-bg font-mono text-sm'>\n <span className='bg-rose-bg text-base-fg px-1 font-thin'>ERROR</span>\n {String(this.props.path?.join('.'))}\n </div>\n );\n }\n\n return this.props.children;\n }\n\n private resetError() {\n this.setState({ error: undefined });\n }\n}\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { createContext, useContext } from 'react';\n\n/**\n * A standalone context for the `tooltips` flag (Form.Root's only label\n * decoration today: a JSON-path hover tooltip rendered by\n * `FormFieldLabel`).\n *\n * Lives in its own module so that `FormFieldComponent.tsx` -- imported at\n * the top of `Form.tsx` -- can read the flag without re-importing from\n * `Form.tsx`. That round-trip used to create a circular module-eval\n * dependency that intermittently hit a TDZ (\"Cannot access 'FormFieldLabel'\n * before initialization\") in browser-mode storybook tests.\n *\n * Defaults to `true` both when `Form.Root` doesn't pass an explicit value\n * AND when there is no enclosing `Form.Root` (e.g. `FormFieldWrapper`\n * stories that render an input without a Form provider).\n */\nexport const FormTooltipsContext = createContext<boolean>(true);\n\n/** Returns whether the enclosing `Form.Root` has field tooltips enabled. */\nexport const useFormTooltips = (): boolean => useContext(FormTooltipsContext);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Option from 'effect/Option';\nimport React, { useMemo, useState } from 'react';\n\nimport { type AnyProperties } from '@dxos/echo/internal';\nimport { SchemaEx } from '@dxos/effect';\nimport { IconButton, useTranslation } from '@dxos/react-ui';\nimport { mx } from '@dxos/ui-theme';\n\nimport { translationKey } from '#translations';\n\nimport { type FormHandlerProps } from '../../hooks';\nimport { getRootFormProperties } from '../../util';\nimport { useFormValues } from './Form';\nimport { FormField, type FormFieldProps } from './FormField';\nimport { FormFieldErrorBoundary, FormFieldLabel } from './FormFieldComponent';\nimport { DEFAULT_LAYOUT_NAME, FormLayout, FormLayoutAnnotation } from './Layout';\n\nconst FORM_FIELDSET_NAME = 'Form.FieldSet';\n\nexport type FormFieldSetProps<T extends AnyProperties> = {\n label?: string;\n sort?: string[];\n /**\n * When set, renders a toggle button at the end of the label row that\n * shows/hides the field set body. Used for nested objects.\n */\n collapsible?: boolean;\n exclude?: (props: SchemaEx.SchemaProperty[]) => SchemaEx.SchemaProperty[];\n /**\n * Picks a named layout out of `FormLayoutAnnotation` when present.\n * Falls back to `'default'`. Ignored when the schema has no annotation\n * (linear rendering then takes over).\n */\n layoutName?: string;\n} & Pick<FormHandlerProps<T>, 'schema'> &\n Pick<\n FormFieldProps,\n | 'path'\n | 'autoFocus'\n | 'readonly'\n | 'layout'\n | 'projection'\n | 'fieldMap'\n | 'fieldProvider'\n | 'createTypename'\n | 'createOptionLabel'\n | 'createOptionIcon'\n | 'createInitialValuePath'\n | 'createFieldMap'\n | 'db'\n | 'useType'\n | 'getOptions'\n | 'onCreate'\n >;\n\n/**\n * Renders a set of form fields derived from a schema object.\n */\nexport const FormFieldSet = ({\n label,\n schema,\n readonly,\n path,\n sort,\n collapsible,\n exclude,\n projection,\n layout,\n layoutName = DEFAULT_LAYOUT_NAME,\n ...props\n}: FormFieldSetProps<any>) => {\n const { t } = useTranslation(translationKey);\n const values = useFormValues(FORM_FIELDSET_NAME, path);\n const properties = useFormFieldSetProperties({ schema, values, exclude, sort, projection });\n // TODO(burdon): Generalize collapse state (cf. useSelected in react-ui-attention, plugin-markdown cursor state).\n const [collapsed, setCollapsed] = useState(false);\n if ((readonly || layout === 'static') && values == null) {\n return null;\n }\n\n // If the schema carries a layout template, hand off to <Form.Layout/> which renders the DSL.\n // Linear rendering still runs when no annotation is present, so existing call sites are unchanged.\n const layouts = schema ? Option.getOrUndefined(FormLayoutAnnotation.get(schema)) : undefined;\n const body =\n layouts?.[layoutName] !== undefined && schema ? (\n <FormLayout\n schema={schema}\n name={layoutName}\n path={path}\n readonly={readonly}\n layout={layout}\n projection={projection}\n {...props}\n />\n ) : (\n properties.map((property) => {\n const name = property.name.toString();\n return (\n <FormFieldErrorBoundary key={name} path={[...(path ?? []), name]}>\n <FormField\n type={property.type}\n name={name}\n path={[...(path ?? []), name]}\n readonly={readonly}\n layout={layout}\n projection={projection}\n {...props}\n />\n </FormFieldErrorBoundary>\n );\n })\n );\n\n const showBody = !(collapsible && collapsed);\n const content = (\n <>\n {layout !== 'inline' && label && (\n <FormFieldLabel\n asChild\n classNames='pl-2'\n label={label}\n path={SchemaEx.createJsonPath(path ?? [])}\n button={\n collapsible && (\n <IconButton\n classNames='px-1 mr-0.5'\n variant='ghost'\n density='xs'\n iconOnly\n icon='ph--caret-right--regular'\n iconClassNames={mx('transition-transform', !collapsed && 'rotate-90')}\n label={t(collapsed ? 'expand-fields.label' : 'collapse-fields.label')}\n />\n )\n }\n onClick={() => setCollapsed((value) => !value)}\n />\n )}\n {showBody && (collapsible ? <div className='px-2 pb-2'>{body}</div> : body)}\n </>\n );\n\n // Nested field sets render inside an indented, bordered container with a collapse toggle.\n if (collapsible) {\n return <div className='border border-subdued-separator rounded-sm mt-2'>{content}</div>;\n }\n\n return content;\n};\n\nFormFieldSet.displayName = FORM_FIELDSET_NAME;\n\ntype UseFormFieldSetPropertiesParams = Pick<FormFieldSetProps<any>, 'schema' | 'exclude' | 'projection' | 'sort'> & {\n values: AnyProperties | undefined;\n sort?: string[];\n};\n\n/**\n * Resolves ordered schema properties for a field set (projection order, exclude, or sort).\n */\nconst useFormFieldSetProperties = ({\n schema,\n exclude,\n projection,\n values,\n sort,\n}: UseFormFieldSetPropertiesParams): SchemaEx.SchemaProperty[] => {\n // TODO(burdon): Updates on every value change.\n // Remove values dep if can remove from getSchemaProperties.\n return useMemo(() => {\n if (!schema) {\n return [];\n }\n\n // TODO(wittjosiah): Reconcile FormInputAnnotation with projection hidden properties & exclude function.\n const schemaProps = getRootFormProperties(schema.ast, values);\n const filteredProps = exclude ? exclude(schemaProps) : schemaProps;\n\n // Use projection-based field management when view and projection are available.\n if (projection) {\n const fieldProjections = projection.getFieldProjections();\n const hiddenProperties = new Set(projection.getHiddenProperties());\n\n // Filter properties to only include visible ones and order by projection.\n const visibleProps = filteredProps.filter((prop) => !hiddenProperties.has(prop.name.toString()));\n const orderedProps: SchemaEx.SchemaProperty[] = [];\n\n // Add properties in projection field order.\n for (const fieldProjection of fieldProjections) {\n const fieldPath = String(fieldProjection.field.path);\n const prop = visibleProps.find((prop) => prop.name === fieldPath);\n if (prop) {\n orderedProps.push(prop);\n }\n }\n\n // Add any remaining properties not in projection.\n const projectionPaths = new Set(fieldProjections.map((projection) => String(projection.field.path)));\n const remainingProps = visibleProps.filter((prop) => !projectionPaths.has(prop.name.toString()));\n orderedProps.push(...remainingProps);\n return orderedProps;\n }\n\n // Fallback to legacy filter/sort behavior.\n return sort\n ? [...filteredProps].sort(({ name: a }, { name: b }) => sort.indexOf(a.toString()) - sort.indexOf(b.toString()))\n : filteredProps;\n }, [schema, values, exclude, sort, projection]);\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Match from 'effect/Match';\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\nimport * as String from 'effect/String';\nimport React, { useMemo } from 'react';\n\nimport { Annotation, Format } from '@dxos/echo';\nimport { SchemaEx } from '@dxos/effect';\nimport { IconButton, IconButtonProps, useTranslation } from '@dxos/react-ui';\nimport { type ProjectionModel } from '@dxos/schema';\nimport { mx } from '@dxos/ui-theme';\n\nimport { translationKey } from '#translations';\n\nimport { getRefProps } from '../../util';\nimport {\n ArrayField,\n BooleanField,\n DateField,\n GeoPointField,\n InlineRefField,\n MarkdownField,\n NumberField,\n RefField,\n type RefFieldProps,\n SelectField,\n TextAreaField,\n TextField,\n} from './fields';\nimport { useFormFieldState } from './Form';\nimport {\n type FormFieldComponent,\n type FormFieldComponentProps,\n type FormFieldMap,\n type FormFieldProvider,\n} from './FormFieldComponent';\nimport { FormFieldSet } from './FormFieldSet';\n\nexport type FormFieldProps = {\n /**\n * AST of the property to render.\n */\n type: SchemaAST.AST;\n\n /**\n * Name of the property. Used to derive a default label\n * (`title ?? capitalize(name)`) and as the projection lookup key. Pass\n * `null` to suppress the header label entirely -- the form still renders\n * the field/struct, but `FormFieldSet`'s top-level `<FormFieldLabel>` is\n * skipped. Used by `ArrayField` for object-array items, where every item\n * would otherwise repeat the array's parent name.\n */\n name: string | null;\n\n /**\n * Path to the current object from the root. Used with nested forms.\n */\n path?: (string | number)[];\n\n /**\n * Optional projection for projection-based field management.\n */\n projection?: ProjectionModel;\n\n /**\n * Map of custom renderers for specific properties.\n * Prefer fieldProvider for plugin specific input surfaces.\n */\n fieldMap?: FormFieldMap;\n\n /**\n * Function to lookup custom renderers for specific properties.\n */\n fieldProvider?: FormFieldProvider;\n\n /**\n * Typename of the ref type that the create props apply to.\n * When set, createOptionLabel/createOptionIcon/createInitialValuePath/createFieldMap/onCreate\n * are only passed to ref fields whose typename matches.\n */\n createTypename?: string;\n} & Pick<FormFieldComponentProps, 'autoFocus' | 'readonly' | 'layout'> &\n Pick<\n RefFieldProps,\n | 'createOptionLabel'\n | 'createOptionIcon'\n | 'createInitialValuePath'\n | 'createFieldMap'\n | 'db'\n | 'useType'\n | 'getOptions'\n | 'onCreate'\n >;\n\nexport const FormField = (props: FormFieldProps) => {\n const {\n type,\n name,\n path,\n projection,\n fieldMap,\n fieldProvider,\n readonly,\n layout,\n\n // RefFieldProps\n createTypename,\n createOptionLabel,\n createOptionIcon,\n createInitialValuePath,\n createFieldMap,\n db,\n useType: schemaHook,\n getOptions,\n onCreate,\n } = props;\n const { t } = useTranslation(translationKey);\n const title = SchemaEx.getAnnotation<string>(SchemaAST.TitleAnnotationId)(type);\n const description = SchemaEx.getAnnotation<string>(SchemaAST.DescriptionAnnotationId)(type);\n const examples = SchemaEx.getAnnotation<string[]>(SchemaAST.ExamplesAnnotationId)(type);\n\n // `name === null` means \"no header\" -- collapse to an empty string so\n // downstream consumers keep their `label: string` types, and the falsy\n // value lets `FormFieldSet`'s `label && <FormFieldLabel ...>` guard skip\n // the header.\n const label = useMemo(() => title ?? (name == null ? '' : String.capitalize(name)), [title, name]);\n const placeholder = useMemo(\n () => (examples?.length ? `${t('example.placeholder')}: ${examples[0]}` : (description ?? label)),\n [examples, description, label],\n );\n\n const fieldState = useFormFieldState(FormField.displayName, path);\n const jsonPath = SchemaEx.createJsonPath(path ?? []);\n const fieldProps: FormFieldComponentProps = {\n type,\n format: Format.FormatAnnotation.getFromAst(type).pipe((annotation) => Option.getOrUndefined(annotation)),\n readonly,\n label,\n jsonPath,\n placeholder,\n layout,\n db,\n ...fieldState,\n };\n\n // Omit empty fields entirely in read-only mode -- an empty value has nothing\n // to display, so a labelled row with a blank input is just noise. This\n // mirrors what `FormFieldWrapper` already does for `layout === 'static'`, but\n // covers every field type (including those that bypass the wrapper:\n // RefField, SelectField, MarkdownField, ...). Container fields\n // (`ArrayField`, nested-struct -> `FormFieldSet`) keep their own\n // empty-value checks, but those branches only apply when the value is\n // actually a non-null array/object, so this check doesn't interfere.\n if (readonly && fieldState.getValue() == null) {\n return null;\n }\n\n //\n // Custom field.\n //\n\n const CustomField = fieldMap?.[jsonPath];\n if (CustomField) {\n return <CustomField {...fieldProps} />;\n }\n\n // TODO(burdon): Expensive to create schema each time; pass AST?\n const component = fieldProvider?.({ schema: Schema.make(type), prop: name ?? '', fieldProps });\n if (component) {\n return component;\n }\n\n //\n // Array field.\n //\n\n if (SchemaEx.isArrayType(type)) {\n return <ArrayField fieldProps={fieldState} label={label} {...props} />;\n }\n\n //\n // Regular field.\n //\n\n const Field = getFormField(fieldProps);\n if (Field) {\n return <Field {...fieldProps} />;\n }\n\n //\n // Select field.\n //\n\n const options = getSelectOptions(type);\n if (options) {\n // Resolve labels from projection metadata when available.\n const fieldProjections = projection?.getFieldProjections();\n const fieldProjection = fieldProjections?.find((fp) => fp.field.path === name);\n const selectOptions = fieldProjection?.props.options;\n\n return (\n <SelectField\n {...fieldProps}\n options={options.map((option) => {\n const selectOption = selectOptions?.find((so) => so.id === globalThis.String(option));\n return {\n value: option,\n label: selectOption?.title ?? option.toString(),\n };\n })}\n />\n );\n }\n\n //\n // Ref field.\n //\n\n const refProps = getRefProps(type);\n if (refProps) {\n // Inline a single referenced object's own fields (nested form) instead of a picker.\n const inline = Annotation.FormInlineAnnotation.getFromAst(refProps.ast).pipe(Option.getOrElse(() => false));\n if (inline && !refProps.isArray) {\n return <InlineRefField {...fieldProps} {...refProps} db={db} useType={schemaHook} onCreate={onCreate} />;\n }\n\n const isCreateTarget = !createTypename || refProps.typename === createTypename;\n return (\n <RefField\n {...fieldProps}\n {...refProps}\n createOptionLabel={isCreateTarget ? createOptionLabel : undefined}\n createOptionIcon={isCreateTarget ? createOptionIcon : undefined}\n createInitialValuePath={isCreateTarget ? createInitialValuePath : undefined}\n createFieldMap={isCreateTarget ? createFieldMap : undefined}\n db={db}\n useType={schemaHook}\n getOptions={getOptions}\n onCreate={onCreate}\n />\n );\n }\n\n //\n // Nested Object field.\n //\n\n if (SchemaEx.isNestedType(type)) {\n const baseNode = SchemaEx.findNode(type, SchemaEx.isDiscriminatedUnion);\n const typeLiteral = baseNode\n ? SchemaEx.getDiscriminatedType(baseNode, fieldState.getValue() as any)\n : SchemaEx.findNode(type, SchemaAST.isTypeLiteral);\n\n if (typeLiteral) {\n const schema = Schema.make(typeLiteral);\n return (\n <FormFieldSet\n schema={schema}\n path={path}\n readonly={readonly}\n layout={layout}\n label={label}\n collapsible\n projection={projection}\n fieldMap={fieldMap}\n fieldProvider={fieldProvider}\n createOptionLabel={createOptionLabel}\n createOptionIcon={createOptionIcon}\n createInitialValuePath={createInitialValuePath}\n db={db}\n useType={schemaHook}\n getOptions={getOptions}\n onCreate={onCreate}\n />\n );\n }\n }\n\n return null;\n};\n\nFormField.displayName = 'Form.FormField';\n\n//\n// Layout components\n//\n\nexport const IconBlock = ({ inline, ...props }: IconButtonProps & { inline?: boolean }) => {\n return (\n <div className={mx('h-full flex px-1', inline ? 'items-center' : 'flex-col pt-2.5')}>\n <IconButton variant='ghost' density='xs' square iconOnly {...props} />\n </div>\n );\n};\n\n/**\n * Get property input component.\n */\nconst getFormField = ({ type, format }: FormFieldComponentProps): FormFieldComponent | undefined => {\n //\n // Standard formats.\n //\n\n const formatField = Match.value(format).pipe(\n Match.withReturnType<FormFieldComponent | undefined>(),\n Match.when(Format.TypeFormat.Date, () => DateField),\n Match.when(Format.TypeFormat.DateTime, () => DateField),\n Match.when(Format.TypeFormat.GeoPoint, () => GeoPointField),\n Match.when(Format.TypeFormat.Markdown, () => MarkdownField),\n Match.when(Format.TypeFormat.Text, () => TextAreaField),\n Match.when(Format.TypeFormat.Time, () => DateField),\n Match.orElse(() => undefined),\n );\n if (formatField) {\n return formatField;\n }\n\n //\n // Standard types.\n //\n\n switch (type._tag) {\n // TODO(wittjosiah): Schema.Any is currently used to represent template inputs.\n case 'AnyKeyword':\n case 'StringKeyword':\n return TextField;\n case 'NumberKeyword':\n return NumberField;\n case 'BooleanKeyword':\n return BooleanField;\n }\n};\n\nconst getSelectOptions = (ast: SchemaAST.AST): Format.Options[] | undefined => {\n if (SchemaEx.isLiteralUnion(ast)) {\n return ast.types.map((type) => type.literal).filter((v): v is string | number => v !== null);\n }\n\n return Format.OptionsAnnotation.getFromAst(ast).pipe((annotation) => Option.getOrUndefined(annotation));\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { createAnnotationHelper } from '@dxos/echo/internal';\n\n/**\n * Annotation carrying one or more named `FormLayout` DSL templates that\n * control how `Form.FieldSet` / `Form.Layout` arrange a schema's fields.\n * Callers select a variant via the `name` prop; the implicit name is\n * `DEFAULT_LAYOUT_NAME` (`'default'`).\n *\n * Templates use a minimal XML grammar — see `parser.ts`. Example:\n *\n * FormLayoutAnnotation.set({\n * default: `\n * <grid cols=\"2\">\n * <field name=\"origin\"/>\n * <field name=\"destination\"/>\n * <field name=\"provider\" span=\"2\"/>\n * </grid>\n * `,\n * card: `\n * <grid cols=\"1\">\n * <field name=\"provider\"/>\n * <field name=\"number\"/>\n * </grid>\n * `,\n * })\n */\nexport const FormLayoutAnnotationId = Symbol.for('@dxos/react-ui-form/annotation/Layout');\n\nexport type FormLayoutMap = Record<string, string>;\n\nexport const FormLayoutAnnotation = createAnnotationHelper<FormLayoutMap>(FormLayoutAnnotationId);\n\n/** Name used when no explicit variant is requested. */\nexport const DEFAULT_LAYOUT_NAME = 'default';\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\nimport * as String from 'effect/String';\nimport React, { Fragment, useMemo } from 'react';\n\nimport { Annotation } from '@dxos/echo';\nimport { type AnyProperties } from '@dxos/echo/internal';\nimport { SchemaEx } from '@dxos/effect';\nimport { Input } from '@dxos/react-ui';\n\nimport { useFormFieldState } from '../Form';\nimport { FormField, type FormFieldProps } from '../FormField';\nimport { FormFieldErrorBoundary, FormFieldLabel, type Presentation } from '../FormFieldComponent';\nimport { DEFAULT_LAYOUT_NAME, FormLayoutAnnotation } from './annotation';\nimport { LayoutParseError, type LayoutNode, parseLayout } from './parser';\n\nconst FORM_LAYOUT_NAME = 'Form.Layout';\n\nexport type FormLayoutProps = {\n /**\n * Template string in the FormLayout DSL (`<grid cols=…><field name=…/></grid>`).\n * If omitted, the layout is read from the schema's `FormLayoutAnnotation` —\n * the entry named by `name` (default: `'default'`).\n */\n template?: string;\n /**\n * Picks a named layout out of `FormLayoutAnnotation`'s map when no\n * explicit `template` is supplied. Defaults to `'default'`.\n */\n name?: string;\n} & Pick<FormFieldSetSubset, 'schema' | 'path' | 'readonly' | 'layout' | 'projection' | 'fieldMap' | 'fieldProvider'>;\n\ntype FormFieldSetSubset = Pick<\n FormFieldProps,\n 'path' | 'readonly' | 'layout' | 'projection' | 'fieldMap' | 'fieldProvider'\n> & {\n schema: Schema.Schema<AnyProperties>;\n};\n\n/**\n * Lays out schema fields according to a `FormLayout` DSL template. The template\n * is either passed via the `template` prop or read from the schema's\n * `FormLayoutAnnotation`. Fields not referenced in the template are hidden —\n * the template controls exactly what renders.\n *\n * A `<field name=…/>` resolves against the schema:\n * - A dotted name (`origin.code`) drills into a nested struct and renders the leaf field.\n * - A name that resolves to a nested struct carrying a `LabelAnnotation` auto-converts\n * to the struct's computed label, rendered as a single read-only text (rather than\n * expanding the struct's sub-fields).\n */\nexport const FormLayout = ({\n schema,\n template,\n name = DEFAULT_LAYOUT_NAME,\n path,\n readonly,\n layout,\n projection,\n ...props\n}: FormLayoutProps) => {\n const annotated = Option.getOrUndefined(FormLayoutAnnotation.get(schema));\n const source = template ?? annotated?.[name];\n if (source === undefined) {\n throw new LayoutParseError(\n annotated\n ? `no layout named \"${name}\" on schema (available: ${Object.keys(annotated).join(', ') || '∅'})`\n : `no template provided and schema has no FormLayoutAnnotation`,\n );\n }\n\n const tree = useMemo(() => parseLayout(source), [source]);\n\n return (\n <RenderNode\n node={tree}\n schema={schema}\n basePath={path ?? []}\n readonly={readonly}\n layout={layout}\n projection={projection}\n {...props}\n />\n );\n};\n\nFormLayout.displayName = FORM_LAYOUT_NAME;\n\ntype RenderNodeProps = Omit<FormLayoutProps, 'template' | 'path'> & {\n node: LayoutNode;\n basePath: (string | number)[];\n};\n\nconst RenderNode = ({ node, schema, basePath, ...props }: RenderNodeProps) => {\n if (node.kind === 'grid') {\n return (\n <div className='grid gap-x-form-gap' style={{ gridTemplateColumns: `repeat(${node.cols}, minmax(0, 1fr))` }}>\n {node.children.map((child, index) => (\n <Fragment key={index}>\n <RenderNode node={child} schema={schema} basePath={basePath} {...props} />\n </Fragment>\n ))}\n </div>\n );\n }\n\n const resolved = resolveLayoutField(schema, node.name);\n if (!resolved) {\n throw new LayoutParseError(`field \"${node.name}\" not found on schema`);\n }\n\n const { type, segments, leafName, title, labelType } = resolved;\n const path = [...basePath, ...segments];\n const span = node.span ? { gridColumn: `span ${node.span} / span ${node.span}` } : undefined;\n\n return (\n <div className='min-w-0' style={span}>\n <FormFieldErrorBoundary path={path}>\n {labelType ? (\n <LabelField\n schema={Schema.make(labelType)}\n label={title ?? String.capitalize(leafName)}\n path={path}\n layout={props.layout}\n />\n ) : (\n <FormField type={type} name={leafName} path={path} {...props} />\n )}\n </FormFieldErrorBoundary>\n </div>\n );\n};\n\nexport type ResolvedLayoutField = {\n /** Resolved leaf AST node for the field. */\n type: SchemaAST.AST;\n /** Path segments (dotted names split on `.`). */\n segments: string[];\n /** Last path segment; used to derive the field label when there is no `title` annotation. */\n leafName: string;\n /** Resolved `title` annotation for the field, if any. */\n title?: string;\n /**\n * Set when the field resolves to a nested struct carrying a `LabelAnnotation` —\n * the type literal whose computed label should render in place of the struct's\n * sub-fields. Undefined for ordinary (non-auto-labelled) fields.\n */\n labelType?: SchemaAST.AST;\n};\n\n/**\n * Walks a dotted path of property names through nested struct ASTs, returning the\n * leaf `PropertySignature` (or `undefined` if any segment is missing).\n */\nconst resolvePropertySignature = (ast: SchemaAST.AST, segments: string[]): SchemaAST.PropertySignature | undefined => {\n let node: SchemaAST.AST = ast;\n for (let index = 0; index < segments.length; index++) {\n const typeLiteral = SchemaEx.findNode(node, SchemaAST.isTypeLiteral);\n if (!typeLiteral) {\n return undefined;\n }\n const prop = SchemaAST.getPropertySignatures(typeLiteral).find(\n (p) => globalThis.String(p.name) === segments[index],\n );\n if (!prop) {\n return undefined;\n }\n if (index === segments.length - 1) {\n return prop;\n }\n node = prop.type;\n }\n\n return undefined;\n};\n\n/**\n * Resolves a (possibly dotted) layout field name against a schema.\n * - `origin.code` drills through nested structs to the leaf field.\n * - A name resolving to a nested struct with a `LabelAnnotation` is flagged via\n * `labelType` so the layout can auto-convert it to a single read-only label.\n * Returns `undefined` when the name does not resolve to a property.\n */\nexport const resolveLayoutField = (schema: Schema.Schema<any>, name: string): ResolvedLayoutField | undefined => {\n const segments = name.split('.');\n const prop = resolvePropertySignature(schema.ast, segments);\n if (!prop) {\n return undefined;\n }\n\n // Normalized leaf type (optional unwrapped, refinements stripped, signature-level\n // annotations merged) — matches how `getProperties` feeds `FormField`.\n const { type: baseType } = SchemaEx.getBaseType(prop);\n const type =\n prop.annotations && Reflect.ownKeys(prop.annotations).length > 0\n ? ({ ...baseType, annotations: { ...baseType.annotations, ...prop.annotations } } as SchemaAST.AST)\n : baseType;\n\n const title = SchemaEx.getAnnotation<string>(SchemaAST.TitleAnnotationId)(type);\n\n // Label detection reads the *raw* property type: `SchemaEx.getBaseType`'s `encodedBoundAST`\n // strips annotations from non-keyword inner types (e.g. nested structs), which would\n // drop the `LabelAnnotation` we rely on here.\n const labelType = SchemaEx.findNode(prop.type, SchemaAST.isTypeLiteral);\n const labelled = labelType != null && Option.isSome(Annotation.LabelAnnotation.getFromAst(labelType));\n\n return {\n type,\n segments,\n leafName: segments[segments.length - 1],\n title,\n labelType: labelled ? labelType : undefined,\n };\n};\n\ntype LabelFieldProps = {\n schema: Schema.Schema<any>;\n label: string;\n path: (string | number)[];\n layout?: Presentation;\n};\n\n/**\n * Renders a nested struct value as its computed label (via `LabelAnnotation`),\n * as a single read-only text. Empty values are omitted, mirroring the static\n * presentation of regular fields.\n */\nconst LabelField = ({ schema, label, path, layout }: LabelFieldProps) => {\n const { getValue } = useFormFieldState(FORM_LAYOUT_NAME, path);\n const value = getValue();\n const text = value == null ? undefined : Annotation.getLabelWithSchema(schema, value);\n if (text == null || text.trim().length === 0) {\n return null;\n }\n\n return (\n <div className='contents'>\n <Input.Root>\n {layout !== 'inline' && <FormFieldLabel readonly label={label} path={SchemaEx.createJsonPath(path)} />}\n <p className='truncate min-w-0' title={text}>\n {text}\n </p>\n </Input.Root>\n </div>\n );\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\n/**\n * Minimal XML-style DSL for laying out schema fields in a grid.\n *\n * Grammar:\n * <grid cols=\"N\"> ...children... </grid>\n * <field name=\"x\" span=\"N\"/>\n *\n * - Attributes accept `\"…\"`, `'…'`, or unquoted integers.\n * - Whitespace between tags is ignored. Text content (between tags) is forbidden.\n * - Self-closing form (`<field … />`) is required for `field`; `grid` must use a closing tag.\n *\n * The parser is hand-rolled (no HTML parser) because the grammar is tiny.\n */\n\n/** Node type for the parsed layout tree. */\nexport type LayoutNode =\n | { readonly kind: 'grid'; readonly cols: number; readonly children: readonly LayoutNode[] }\n | { readonly kind: 'field'; readonly name: string; readonly span?: number };\n\nexport class LayoutParseError extends Error {\n readonly _tag = 'LayoutParseError';\n constructor(\n message: string,\n readonly position?: number,\n ) {\n super(position !== undefined ? `${message} (at position ${position})` : message);\n }\n}\n\nconst TAG_RE = /<\\s*(\\/?)\\s*(\\w+)([^>]*?)(\\/?)\\s*>/g;\nconst ATTR_RE = /([\\w-]+)\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|(\\d+))/g;\n\ntype Token =\n | { type: 'open'; name: string; attrs: Record<string, string>; selfClosing: boolean; position: number }\n | { type: 'close'; name: string; position: number };\n\nconst parseAttrs = (raw: string): Record<string, string> => {\n const attrs: Record<string, string> = {};\n ATTR_RE.lastIndex = 0;\n let match: RegExpExecArray | null;\n while ((match = ATTR_RE.exec(raw)) !== null) {\n const [, key, doubleQuoted, singleQuoted, bare] = match;\n attrs[key] = doubleQuoted ?? singleQuoted ?? bare;\n }\n return attrs;\n};\n\nconst tokenize = (input: string): Token[] => {\n const tokens: Token[] = [];\n TAG_RE.lastIndex = 0;\n let match: RegExpExecArray | null;\n let cursor = 0;\n while ((match = TAG_RE.exec(input)) !== null) {\n // Validate that any text between the previous tag and this one is whitespace-only.\n const between = input.slice(cursor, match.index);\n if (between.trim().length > 0) {\n throw new LayoutParseError(`unexpected text content: ${JSON.stringify(between.trim())}`, cursor);\n }\n const [, slash, name, attrsRaw, selfSlash] = match;\n if (slash) {\n tokens.push({ type: 'close', name, position: match.index });\n } else {\n tokens.push({\n type: 'open',\n name,\n attrs: parseAttrs(attrsRaw),\n selfClosing: selfSlash === '/',\n position: match.index,\n });\n }\n cursor = match.index + match[0].length;\n }\n // Any trailing text after the last tag must also be whitespace.\n const trailing = input.slice(cursor);\n if (trailing.trim().length > 0) {\n throw new LayoutParseError(`unexpected text content: ${JSON.stringify(trailing.trim())}`, cursor);\n }\n return tokens;\n};\n\nconst requireAttr = (attrs: Record<string, string>, key: string, tag: string, position: number): string => {\n const value = attrs[key];\n if (value === undefined) {\n throw new LayoutParseError(`<${tag}> missing required attribute \"${key}\"`, position);\n }\n return value;\n};\n\nconst parseInteger = (value: string, attr: string, tag: string, position: number): number => {\n if (!/^\\d+$/.test(value)) {\n throw new LayoutParseError(\n `<${tag}> attribute \"${attr}\" expects an integer, got ${JSON.stringify(value)}`,\n position,\n );\n }\n return Number.parseInt(value, 10);\n};\n\n/** Parses a layout template string into a single root node. The root must be `<grid>`. */\nexport const parseLayout = (template: string): LayoutNode => {\n const tokens = tokenize(template);\n if (tokens.length === 0) {\n throw new LayoutParseError('empty template');\n }\n\n let index = 0;\n\n const parseNode = (): LayoutNode => {\n const token = tokens[index];\n if (!token || token.type !== 'open') {\n throw new LayoutParseError(`expected an opening tag, got ${JSON.stringify(token)}`, token?.position);\n }\n\n if (token.name === 'field') {\n if (!token.selfClosing) {\n throw new LayoutParseError('<field> must be self-closing (e.g. <field name=\"x\"/>)', token.position);\n }\n const name = requireAttr(token.attrs, 'name', 'field', token.position);\n const spanRaw = token.attrs.span;\n const span = spanRaw !== undefined ? parseInteger(spanRaw, 'span', 'field', token.position) : undefined;\n index += 1;\n return { kind: 'field', name, span };\n }\n\n if (token.name === 'grid') {\n if (token.selfClosing) {\n throw new LayoutParseError('<grid> must wrap children (cannot self-close)', token.position);\n }\n const cols = parseInteger(\n requireAttr(token.attrs, 'cols', 'grid', token.position),\n 'cols',\n 'grid',\n token.position,\n );\n index += 1;\n const children: LayoutNode[] = [];\n while (index < tokens.length && !(tokens[index].type === 'close' && tokens[index].name === 'grid')) {\n children.push(parseNode());\n }\n const closing = tokens[index];\n if (!closing || closing.type !== 'close' || closing.name !== 'grid') {\n throw new LayoutParseError('<grid> not closed', token.position);\n }\n index += 1;\n return { kind: 'grid', cols, children };\n }\n\n throw new LayoutParseError(`unknown element <${token.name}>`, token.position);\n };\n\n const root = parseNode();\n if (index !== tokens.length) {\n const trailing = tokens[index];\n throw new LayoutParseError(\n `unexpected trailing tag <${trailing.type === 'open' ? '' : '/'}${trailing.name}>`,\n trailing.position,\n );\n }\n if (root.kind !== 'grid') {\n throw new LayoutParseError('root element must be <grid>');\n }\n return root;\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useCallback } from 'react';\n\nimport { Input, type SwitchProps } from '@dxos/react-ui';\n\nimport { type FormFieldComponentProps, FormFieldWrapper } from '../FormFieldComponent';\n\nexport const BooleanField = ({ type, readonly, onValueChange, ...props }: FormFieldComponentProps<boolean>) => {\n const handleChange = useCallback<NonNullable<SwitchProps['onCheckedChange']>>(\n (value) => onValueChange?.(type, value),\n [type, onValueChange],\n );\n\n return (\n <FormFieldWrapper<boolean> readonly={readonly} {...props}>\n {({ value }) => <Input.Switch disabled={!!readonly} checked={value} onCheckedChange={handleChange} />}\n </FormFieldWrapper>\n );\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { format as formatDate } from 'date-fns';\nimport React, { useCallback } from 'react';\n\nimport { Format } from '@dxos/echo';\nimport { Input } from '@dxos/react-ui';\n\nimport { type FormFieldComponentProps, FormFieldWrapper } from '../FormFieldComponent';\n\n/**\n * Stored value shapes:\n * - `Format.DateTime` -> ISO 8601 (`2018-11-13T20:20:39.000Z`).\n * - `Format.Date` -> `YYYY-MM-DD`.\n * - `Format.Time` -> `HH:mm:ss`.\n *\n * Segmented input value shapes (react-aria-components-backed):\n * - `Input.DateTime` -> `YYYY-MM-DDTHH:mm` in local time.\n * - `Input.Date` -> `YYYY-MM-DD`.\n * - `Input.Time` -> `HH:mm`.\n */\n\n/** ISO 8601 → `YYYY-MM-DDTHH:mm` in the user's local timezone. */\nconst isoToLocalDateTime = (value: string | undefined): string => {\n if (!value) {\n return '';\n }\n const date = new Date(value);\n if (Number.isNaN(date.getTime())) {\n return '';\n }\n return formatDate(date, \"yyyy-MM-dd'T'HH:mm\");\n};\n\n/** `YYYY-MM-DDTHH:mm` (local) → ISO 8601 with timezone. */\nconst localDateTimeToIso = (value: string): string | undefined => {\n if (!value) {\n return undefined;\n }\n // Treat the input as local time. `new Date('YYYY-MM-DDTHH:mm')` parses as local.\n const date = new Date(value);\n return Number.isNaN(date.getTime()) ? undefined : date.toISOString();\n};\n\nexport const DateField = ({\n type,\n format,\n readonly,\n placeholder: _placeholder,\n onValueChange,\n onBlur: _onBlur,\n ...props\n}: FormFieldComponentProps<string>) => {\n const handleSimpleChange = useCallback((next: string) => onValueChange(type, next), [type, onValueChange]);\n\n const handleDateTimeChange = useCallback(\n (next: string) => {\n const iso = localDateTimeToIso(next);\n onValueChange(type, iso as string);\n },\n [type, onValueChange],\n );\n\n return (\n <FormFieldWrapper<string> readonly={readonly} format={format} {...props}>\n {({ value }) => {\n switch (format) {\n case Format.TypeFormat.Date:\n return (\n <div className='grid grid-cols-[minmax(0,1fr)_min-content] items-stretch gap-1'>\n <Input.Date\n classNames='min-w-0 overflow-hidden'\n disabled={!!readonly}\n value={value ?? ''}\n onValueChange={handleSimpleChange}\n />\n <Input.TriggerIcon classNames='h-full' />\n </div>\n );\n case Format.TypeFormat.Time:\n return <Input.Time disabled={!!readonly} value={value ?? ''} onValueChange={handleSimpleChange} />;\n case Format.TypeFormat.DateTime:\n default:\n return (\n <div className='grid grid-cols-[minmax(0,1fr)_min-content] items-stretch gap-1'>\n <Input.DateTime\n classNames='min-w-0 overflow-hidden'\n disabled={!!readonly}\n value={isoToLocalDateTime(value)}\n onValueChange={handleDateTimeChange}\n />\n <Input.TriggerIcon classNames='h-full' />\n </div>\n );\n }\n }}\n </FormFieldWrapper>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { type ChangeEvent, useCallback, useEffect, useMemo, useState } from 'react';\n\nimport { GeoLocation, type GeoPoint } from '@dxos/echo/Format';\nimport { Input, useTranslation } from '@dxos/react-ui';\nimport { safeParseFloat } from '@dxos/util';\n\nimport { translationKey } from '#translations';\n\nimport { type FormFieldComponentProps, FormFieldLabel } from '../FormFieldComponent';\n\nexport const GeoPointField = ({\n type,\n label,\n jsonPath,\n readonly,\n layout,\n getStatus,\n getValue,\n onValueChange,\n onBlur,\n}: FormFieldComponentProps<GeoPoint>) => {\n const { t } = useTranslation(translationKey);\n const { status, error } = getStatus();\n const geoPoint = useMemo<GeoPoint>(() => getValue() ?? [0, 0], [getValue]);\n const value = useMemo(() => GeoLocation.fromGeoPoint(geoPoint), [geoPoint]);\n\n const [longitudeText, setLongitudeText] = useState(value.longitude?.toString());\n const [latitudeText, setLatitudeText] = useState(value.latitude?.toString());\n useEffect(() => {\n const location = GeoLocation.fromGeoPoint(geoPoint);\n setLongitudeText(location.longitude?.toString());\n setLatitudeText(location.latitude?.toString());\n }, [geoPoint]);\n\n const handleChange = useCallback(\n (coordinateType: keyof Pick<GeoLocation, 'longitude' | 'latitude'>, setText: (text: string) => void) =>\n (event: ChangeEvent<HTMLInputElement>) => {\n const inputText = event.target.value;\n setText(inputText);\n if (inputText !== '' && inputText !== '-') {\n const coord = safeParseFloat(inputText);\n if (coord !== undefined && !isNaN(coord)) {\n const currentLocation = GeoLocation.fromGeoPoint(getValue() ?? [0, 0]);\n const newLocation = { ...currentLocation, [coordinateType]: coord };\n const newValue = GeoLocation.toGeoPoint(newLocation);\n onValueChange(type, newValue);\n }\n }\n },\n [type, getValue, onValueChange],\n );\n\n if ((readonly || layout === 'static') && !value?.latitude && !value?.longitude) {\n return null;\n }\n\n return (\n <Input.Root validationValence={status}>\n {layout !== 'inline' && (\n <FormFieldLabel error={error} readonly={readonly} label={label} path={jsonPath} asChild />\n )}\n {layout === 'static' ? (\n <LatLng {...value} />\n ) : (\n <div className='grid grid-cols-2 gap-form-gap'>\n <div>\n <Input.Root>\n {layout !== 'inline' && <Input.Label>{t('latitude.label')}</Input.Label>}\n <Input.TextInput\n type='number'\n step='0.00001'\n min='-90'\n max='90'\n disabled={!!readonly}\n placeholder={t('latitude.placeholder')}\n value={latitudeText ?? ''}\n onChange={handleChange('latitude', setLatitudeText)}\n onBlur={onBlur}\n />\n </Input.Root>\n </div>\n <div>\n <Input.Root>\n {layout !== 'inline' && <Input.Label>{t('longitude.label')}</Input.Label>}\n <Input.TextInput\n type='number'\n step='0.00001'\n min='-180'\n max='180'\n disabled={!!readonly}\n placeholder={t('longitude.placeholder')}\n value={longitudeText ?? ''}\n onChange={handleChange('longitude', setLongitudeText)}\n onBlur={onBlur}\n />\n </Input.Root>\n </div>\n </div>\n )}\n </Input.Root>\n );\n};\n\nconst LatLng = ({ latitude = 0, longitude = 0 }: GeoLocation) => {\n const latHem = latitude >= 0 ? 'N' : 'S';\n const lngHem = longitude >= 0 ? 'E' : 'W';\n\n return (\n <span className='inline-flex items-center gap-form-gap'>\n <span>\n <span>{Math.abs(latitude).toFixed(5)}</span>\n <span className='text-subdued'>°{latHem}</span>\n </span>\n <span>\n <span>{Math.abs(longitude).toFixed(5)}</span>\n <span className='text-subdued'>°{lngHem}</span>\n </span>\n </span>\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useAtomValue } from '@effect-atom/atom-react';\nimport React, { useCallback, useMemo } from 'react';\n\nimport { type Database, Obj, Ref, Type } from '@dxos/echo';\nimport { useType as defaultUseType } from '@dxos/echo-react';\nimport { ReferenceAnnotationId, type ReferenceAnnotationValue } from '@dxos/echo/Annotation';\nimport { SchemaEx } from '@dxos/effect';\nimport { DXN, URI } from '@dxos/keys';\nimport { Button, Icon, Input, useTranslation } from '@dxos/react-ui';\n\nimport { translationKey } from '#translations';\n\nimport { Form, omitId } from '../Form';\nimport { FormFieldLabel } from '../FormFieldComponent';\nimport { type RefFieldProps } from './RefField';\n\n/**\n * Renders a referenced object's own fields inline (a nested form bound to the\n * target) rather than the {@link RefField} picker. Activated by\n * `FormInlineAnnotation.set(true)` on the `Ref` property.\n *\n * The nested form edits the target object directly: each changed path is\n * written back via `Obj.setValue` within an `Obj.update`, mirroring\n * `ObjectProperties` (without the synthetic meta-tags row).\n */\nexport const InlineRefField = (props: RefFieldProps) => {\n const {\n type,\n readonly,\n label,\n jsonPath,\n layout,\n db,\n getValue,\n onValueChange,\n onCreate,\n useType = defaultUseType,\n } = props;\n const { t } = useTranslation(translationKey);\n\n const reference = getValue() as Ref.Ref<any> | undefined;\n const typename = useMemo(\n () => (type ? SchemaEx.findAnnotation<ReferenceAnnotationValue>(type, ReferenceAnnotationId)?.typename : undefined),\n [type],\n );\n\n // Empty ref: offer to create the referenced object so the inline form has a target.\n const createType = useType(db, typename ? DXN.make(typename) : undefined);\n const handleCreate = useCallback(async () => {\n if (!createType || !onCreate) {\n return;\n }\n const newObject = await onCreate(createType, {});\n if (newObject) {\n onValueChange(type, Ref.make(newObject));\n }\n }, [createType, onCreate, type, onValueChange]);\n\n if (readonly && !reference) {\n return null;\n }\n\n return (\n <Input.Root>\n {layout !== 'inline' && <FormFieldLabel readonly={readonly} label={label} path={jsonPath} />}\n {reference ? (\n <InlineForm reference={reference} db={db} readonly={readonly} useType={useType} />\n ) : (\n !readonly &&\n onCreate && (\n <Button classNames='w-full gap-form-gap' disabled={!createType || !db} onClick={() => void handleCreate()}>\n <Icon icon='ph--plus--regular' size={4} />\n <span>{label || t('ref-field.placeholder')}</span>\n </Button>\n )\n )}\n </Input.Root>\n );\n};\n\ntype InlineFormProps = {\n reference: Ref.Ref<any>;\n db?: Database.Database;\n readonly?: boolean;\n // Accepts both the generic `defaultUseType` and `RefFieldProps['useType']`.\n useType?: (db?: Database.Database, typeUri?: URI.URI) => Type.AnyEntity | undefined;\n};\n\nconst InlineForm = ({ reference, db, readonly, useType = defaultUseType }: InlineFormProps) => {\n const target = useAtomValue(useMemo(() => reference.atom, [reference]));\n const typeUri = target ? Obj.getTypeURI(target) : undefined;\n const typeFromRegistry = useType(db, typeUri);\n const targetType = (target && Obj.getType(target)) || typeFromRegistry;\n // Drop the ECHO `id` property (mirrors `ObjectProperties` via `withMetaTags`);\n // otherwise the nested form renders an \"Id\" field. Hidden fields\n // (`FormInputAnnotation.set(false)`) are already filtered by the field set.\n const formSchema = useMemo(() => (targetType ? omitId(Type.getSchema(targetType)) : undefined), [targetType]);\n const defaultValues = useMemo(() => (target ? { ...target } : {}), [target]);\n\n // `formSchema` is resolved at runtime (the referenced object's schema), so the\n // form's value type is not statically known here — `any` at this form-value\n // boundary mirrors `ObjectProperties`. Each changed path is written back to the\n // live target via `Obj.setValue`.\n const handleChange = useCallback(\n (values: any, { isValid, changed }: { isValid: boolean; changed: Record<SchemaEx.JsonPath, boolean> }) => {\n if (!isValid || !target) {\n return;\n }\n const changedPaths = (Object.keys(changed) as SchemaEx.JsonPath[]).filter((path) => changed[path]);\n if (changedPaths.length === 0) {\n return;\n }\n Obj.update(target, () => {\n for (const path of changedPaths) {\n const parts = SchemaEx.splitJsonPath(path);\n Obj.setValue(target, parts, Obj.getValue(values, parts));\n }\n });\n },\n [target],\n );\n\n if (!target || !formSchema) {\n return null;\n }\n\n return (\n <Form.Root db={db} schema={formSchema} defaultValues={defaultValues as any} onValuesChanged={handleChange}>\n <Form.Content>\n <Form.FieldSet collapsible readonly={readonly} />\n </Form.Content>\n </Form.Root>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { useAtomValue } from '@effect-atom/atom-react';\nimport React, { useCallback, useMemo } from 'react';\n\nimport { type Database, Obj, Ref } from '@dxos/echo';\nimport { createDocAccessor } from '@dxos/echo-client';\nimport { Button, Icon, Input, useTranslation } from '@dxos/react-ui';\nimport { Editor, useBasicMarkdownExtensions } from '@dxos/react-ui-editor';\nimport { Text } from '@dxos/schema';\nimport { createDataExtensions } from '@dxos/ui-editor';\n\nimport { translationKey } from '#translations';\n\nimport { type FormFieldComponentProps, FormFieldLabel } from '../FormFieldComponent';\n\nconst editorClassNames =\n 'transition-colors bg-input-surface focus-within:bg-focus-surface border border-separator rounded-xs p-1 px-2';\n\n/**\n * Form field that edits a markdown value in a CodeMirror editor.\n * Supports two backings:\n * - `Schema.String` annotated with `Format.TypeFormat.Markdown`: edited as plain text via `getValue`/`onValueChange`.\n * - `Ref<Text>` annotated with `Format.TypeFormat.Markdown`: edited in-place via an Automerge doc accessor.\n * When the ref is empty and a database is available, a create button is shown to allocate a new Text.\n */\nexport const MarkdownField = ({\n type,\n readonly,\n label,\n jsonPath,\n placeholder,\n layout,\n db,\n getStatus,\n getValue,\n onValueChange,\n}: FormFieldComponentProps) => {\n const { status, error } = getStatus();\n const isRef = Ref.isRefType(type);\n const value = getValue();\n\n if ((readonly || layout === 'static') && value == null) {\n return null;\n }\n\n const renderEditor = () => {\n if (isRef) {\n const reference = value as Ref.Ref<any> | undefined;\n if (reference) {\n return <RefMarkdownEditor reference={reference} placeholder={placeholder} />;\n }\n\n if (readonly) {\n return null;\n }\n\n return <CreateTextButton db={db} disabled={!db} onCreate={(ref) => onValueChange(type, ref)} />;\n }\n\n return (\n <StringMarkdownEditor\n value={(value as string | undefined) ?? ''}\n placeholder={placeholder}\n readonly={!!readonly}\n onChange={(next) => onValueChange(type, next)}\n />\n );\n };\n\n const renderStatic = () => {\n if (isRef) {\n const reference = value as Ref.Ref<any> | undefined;\n return reference ? <RefStaticText reference={reference} /> : null;\n }\n return <p className='whitespace-pre-wrap'>{(value as string | undefined) ?? ''}</p>;\n };\n\n return (\n <Input.Root validationValence={status}>\n {layout !== 'inline' && <FormFieldLabel error={error} readonly={readonly} label={label} path={jsonPath} />}\n {layout === 'static' ? renderStatic() : renderEditor()}\n {layout === 'full' && <Input.Validation>{error}</Input.Validation>}\n </Input.Root>\n );\n};\n\n/** Read-only static rendering for a `Ref<Text>` value: resolve the ref and print its content. */\nconst RefStaticText = ({ reference }: { reference: Ref.Ref<any> }) => {\n const text = useAtomValue(useMemo(() => reference.atom, [reference]));\n if (!text?.content) {\n return null;\n }\n return <p className='whitespace-pre-wrap'>{text.content}</p>;\n};\n\ntype RefMarkdownEditorProps = {\n reference: Ref.Ref<any>;\n placeholder?: string;\n};\n\nconst RefMarkdownEditor = ({ reference, placeholder }: RefMarkdownEditorProps) => {\n const text = useAtomValue(useMemo(() => reference.atom, [reference]));\n const dataExtensions = useMemo(\n () => (text ? [createDataExtensions({ id: reference.uri, text: createDocAccessor(text, ['content']) })] : []),\n [text, reference],\n );\n const extensions = useBasicMarkdownExtensions({ placeholder, extensions: dataExtensions });\n if (!text) {\n return null;\n }\n\n return (\n <Editor.Root>\n <Editor.View classNames={editorClassNames} extensions={extensions} />\n </Editor.Root>\n );\n};\n\ntype StringMarkdownEditorProps = {\n value: string;\n placeholder?: string;\n readonly?: boolean;\n onChange: (value: string) => void;\n};\n\nconst StringMarkdownEditor = ({ value, placeholder, readonly, onChange }: StringMarkdownEditorProps) => {\n const extensions = useBasicMarkdownExtensions({ placeholder });\n const handleChange = useCallback((next: string) => onChange(next), [onChange]);\n\n return (\n <Editor.Root>\n <Editor.View\n classNames={editorClassNames}\n extensions={extensions}\n value={value}\n onChange={readonly ? undefined : handleChange}\n />\n </Editor.Root>\n );\n};\n\ntype CreateTextButtonProps = {\n db?: Database.Database;\n disabled?: boolean;\n onCreate: (ref: Ref.Ref<Text.Text>) => void;\n};\n\nconst CreateTextButton = ({ db, disabled, onCreate }: CreateTextButtonProps) => {\n const { t } = useTranslation(translationKey);\n const handleClick = useCallback(() => {\n if (!db) {\n return;\n }\n const text = db.add(Obj.make(Text.Text, { content: '' }));\n onCreate(Ref.make(text));\n }, [db, onCreate]);\n\n return (\n <Button onClick={handleClick} disabled={disabled}>\n <Icon icon='ph--plus--regular' size={4} />\n <span>{t('create-text.label')}</span>\n </Button>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useCallback, useEffect, useState } from 'react';\n\nimport { Input, type TextInputProps } from '@dxos/react-ui';\nimport { safeParseFloat } from '@dxos/util';\n\nimport { type FormFieldComponentProps, FormFieldWrapper } from '../FormFieldComponent';\n\nexport const NumberField = ({\n type,\n readonly,\n placeholder,\n getValue,\n onValueChange,\n onBlur,\n ...props\n}: FormFieldComponentProps<number>) => {\n // Track raw string input so the user can clear the field before typing a new number.\n // We only commit to onValueChange when the raw string parses to a valid number.\n const [raw, setRaw] = useState<string>(() => {\n const v = getValue();\n return v !== undefined ? String(v) : '';\n });\n\n // Sync display when an external change updates the committed value (e.g. reactive form\n // calculations). Only overwrite raw when the external value differs from what raw parses\n // to, preserving partial edits like \"1.\" which correctly parse to 1.\n const externalValue = getValue();\n useEffect(() => {\n if (externalValue !== safeParseFloat(raw)) {\n setRaw(externalValue !== undefined ? String(externalValue) : '');\n }\n }, [externalValue]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const handleChange = useCallback<NonNullable<TextInputProps['onChange']>>(\n (event) => {\n const value = event.target.value;\n setRaw(value);\n const parsed = safeParseFloat(value);\n if (parsed !== undefined) {\n onValueChange(type, parsed);\n }\n },\n [type, onValueChange],\n );\n\n const handleBlur = useCallback(\n (event: React.FocusEvent<HTMLElement>) => {\n // If the field was left empty or invalid, reset to the last committed value.\n if (safeParseFloat(raw) === undefined) {\n const committed = getValue();\n setRaw(committed !== undefined ? String(committed) : '');\n }\n onBlur(event);\n },\n [raw, getValue, onBlur],\n );\n\n return (\n <FormFieldWrapper<number> readonly={readonly} getValue={getValue} {...props}>\n {() => (\n <Input.TextInput\n type='number'\n disabled={!!readonly}\n placeholder={placeholder}\n value={raw}\n onChange={handleChange}\n onBlur={handleBlur}\n />\n )}\n </FormFieldWrapper>\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { useCallback, useMemo, useState } from 'react';\n\nimport '@dxos/lit-ui/dx-tag-picker.pcss';\nimport { type Database, Entity, Filter, Obj, Query, Ref, Scope, Type } from '@dxos/echo';\nimport { useQuery, useType as defaultUseType } from '@dxos/echo-react';\nimport { ANY_OBJECT_TYPENAME, ReferenceAnnotationId, type ReferenceAnnotationValue } from '@dxos/echo/internal';\nimport { SchemaEx } from '@dxos/effect';\nimport { DXN, EID, URI } from '@dxos/keys';\nimport { DxAnchor } from '@dxos/lit-ui/react';\nimport { Button, Icon, Input, useTranslation } from '@dxos/react-ui';\nimport { ParentLabelAnnotationId } from '@dxos/schema';\n\nimport { translationKey } from '#translations';\n\nimport { ObjectPicker, type ObjectPickerContentProps, type RefOption } from '../../ObjectPicker';\nimport { omitHiddenFormFields, omitId } from '../Form';\nimport { type FormFieldComponentProps, FormFieldLabel } from '../FormFieldComponent';\n\n// TODO(burdon): Factor out.\nconst isRefSnapshot = (val: any): val is { '/': string } => {\n return typeof val === 'object' && typeof (val as any)?.['/'] === 'string';\n};\n\n/**\n * Find the option a ref-like form value points at. Matches on the local (entity-id) form so a bare local EID\n * (`echo:/<id>`, produced by `Ref.make`) still resolves against an option keyed by the entity's qualified\n * self URI (`echo://<space>/<id>`). Returns `undefined` when the value is not a ref or no option matches.\n *\n * Comparing by entity id is only sound within one space (ids are unique there, not globally). Two EIDs that\n * both carry a space authority must therefore agree on it: a qualified value and a qualified option from\n * different spaces never match, even when their entity ids coincide.\n */\nexport const findRefOption = (value: unknown, options: RefOption[]): RefOption | undefined => {\n const isRef = Ref.isRef(value);\n if (!isRef && !isRefSnapshot(value)) {\n return undefined;\n }\n const valueEid = EID.tryParse(isRef ? value.uri : value['/']);\n if (!valueEid) {\n return undefined;\n }\n const valueSpaceId = EID.getSpaceId(valueEid);\n const valueLocal = EID.toLocal(valueEid);\n return options.find((option) => {\n const optionEid = EID.tryParse(option.id);\n if (!optionEid) {\n return false;\n }\n const optionSpaceId = EID.getSpaceId(optionEid);\n if (valueSpaceId != null && optionSpaceId != null && valueSpaceId !== optionSpaceId) {\n return false;\n }\n return EID.equals(EID.toLocal(optionEid), valueLocal);\n });\n};\n\nconst defaultGetOptions: NonNullable<RefFieldProps['getOptions']> = (\n results,\n { parentLabel, getTypePlaceholder } = {},\n) =>\n results\n // When labeling by parent, only surface objects that actually have a parent — an unparented object\n // (e.g. a system feed) has no meaningful parent to label by.\n .filter((result) => !parentLabel || Obj.getParent(result as Obj.Unknown) != null)\n .map((result) => {\n const id = Entity.getURI(result, { prefer: 'named' });\n const parent = parentLabel ? Obj.getParent(result as Obj.Unknown) : undefined;\n const labelEntity = parent ?? result;\n const typename = Entity.getTypename(labelEntity);\n // Fall back to the entity's type placeholder when it has no label of its own — matching the\n // app-graph/navtree (`object-name.placeholder` in the entity's typename namespace).\n const label = Entity.getLabel(labelEntity) ?? (typename ? getTypePlaceholder?.(typename) : undefined) ?? id;\n return { id, label };\n });\n\nconst defaultUseResults: NonNullable<RefFieldProps['useResults']> = (db, typename) =>\n useQuery(\n db,\n !typename\n ? Query.select(Filter.nothing())\n : typename === ANY_OBJECT_TYPENAME\n ? // Untyped refs show space objects only; the registry is too broad for \"any\".\n Query.select(Filter.everything())\n : // Include registry scope so keyed entities (blueprints, operations) appear as options.\n Query.select(Filter.type(DXN.make(typename))).from(Scope.space(), Scope.registry()),\n );\n\nexport type RefFieldProps = FormFieldComponentProps &\n Pick<\n ObjectPickerContentProps,\n 'createOptionLabel' | 'createOptionIcon' | 'createInitialValuePath' | 'createFieldMap'\n > & {\n db?: Database.Database;\n // TODO(burdon): Replace hooks with callbacks.\n useType?: (db?: Database.Database, typeUri?: URI.URI) => Type.AnyEntity;\n useResults?: (db?: Database.Database, typename?: string) => Entity.Any[];\n getOptions?: (\n objects: Entity.Any[],\n options?: { parentLabel?: boolean; getTypePlaceholder?: (typename: string) => string },\n ) => RefOption[];\n /**\n * Persist a newly-created object. Called after the user fills out the\n * inline create form and clicks Save. Should add the object to the\n * database and return it (sync or async). The returned object is then\n * wired into this slot's form value as a Ref.\n */\n onCreate?: (schema: Type.AnyEntity, values: any) => Obj.Unknown | Promise<Obj.Unknown> | undefined | void;\n };\n\nexport const RefField = (props: RefFieldProps) => {\n const {\n type,\n readonly,\n label,\n jsonPath,\n placeholder,\n layout,\n getStatus,\n getValue,\n createOptionLabel,\n createOptionIcon,\n createInitialValuePath,\n createFieldMap,\n db,\n useType = defaultUseType,\n useResults = defaultUseResults,\n getOptions = defaultGetOptions,\n onCreate,\n onValueChange,\n } = props;\n const { t } = useTranslation(translationKey);\n const { status, error } = getStatus();\n\n const typename = useMemo(\n () => (type ? SchemaEx.findAnnotation<ReferenceAnnotationValue>(type, ReferenceAnnotationId)?.typename : undefined),\n [type],\n );\n\n // Resolve a type-based placeholder label for entities that have no label of their own — the entity's\n // `object-name.placeholder` in its own typename namespace, like the app-graph/navtree. Falls back to a\n // humanized typename segment so we never surface a raw DXN for a type that hasn't registered one.\n const getTypePlaceholder = useCallback(\n (placeholderTypename: string): string => {\n const segment = placeholderTypename.split(/[.:/]/).filter(Boolean).pop() ?? placeholderTypename;\n const humanized = segment.charAt(0).toUpperCase() + segment.slice(1);\n return t('object-name.placeholder', { ns: placeholderTypename, defaultValue: humanized });\n },\n [t],\n );\n\n const results = useResults(db, typename);\n const options = useMemo(() => {\n const parentLabel = type ? SchemaEx.findAnnotation<boolean>(type, ParentLabelAnnotationId) === true : false;\n return getOptions(results, { parentLabel, getTypePlaceholder });\n }, [results, getOptions, type, getTypePlaceholder]);\n\n const handleGetValue = useCallback(() => findRefOption(getValue(), options), [options, getValue]);\n\n const item = handleGetValue();\n const selectedIds = useMemo(() => (item ? [item.id] : []), [item]);\n const createSchema = useType(db, typename && typename !== ANY_OBJECT_TYPENAME ? DXN.make(typename) : undefined);\n\n // Lift the popover open state so we can dismiss it after a successful create.\n const [open, setOpen] = useState(false);\n\n const handleCreate = useCallback(\n async (values: any) => {\n if (!createSchema || !onCreate) {\n return;\n }\n const newObject = await onCreate(createSchema, values);\n if (newObject) {\n // Wire the newly-created object into this slot's form value. ArrayField\n // owns the array; this RefField represents a single slot, so writing a\n // Ref via `onValueChange` populates that slot.\n onValueChange(type, Ref.make(newObject));\n }\n setOpen(false);\n },\n [createSchema, onCreate, type, onValueChange],\n );\n\n const handleUpdate = useCallback(\n (id: string | undefined) => {\n const item = options.find((option) => option.id === id);\n const ref = item ? Ref.fromURI(URI.make(item.id)) : undefined;\n onValueChange(type, ref);\n },\n [options, type, onValueChange],\n );\n\n const handleSelect = useCallback(\n (id: string) => {\n if (item?.id === id) {\n handleUpdate(undefined);\n } else {\n handleUpdate(id);\n }\n },\n [item, handleUpdate],\n );\n\n if (!typename || ((readonly || layout === 'static') && !item)) {\n return null;\n }\n\n return (\n <Input.Root validationValence={status}>\n {layout !== 'inline' && <FormFieldLabel error={error} readonly={readonly} label={label} path={jsonPath} />}\n <div>\n {readonly ? (\n !item ? (\n <p className='text-description mb-2'>{t('empty-readonly-ref-field.label')}</p>\n ) : (\n <DxAnchor key={item.id} dxn={item.id} rootclassname='me-1'>\n {item.label}\n </DxAnchor>\n )\n ) : (\n <ObjectPicker.Root open={open} onOpenChange={setOpen}>\n <ObjectPicker.Trigger asChild classNames='p-0'>\n {item ? (\n <div className='flex gap-form-gap w-full'>\n <Input.Root key={item.id}>\n <Input.TextInput value={item.label} readOnly classNames='w-full' />\n </Input.Root>\n </div>\n ) : (\n <Button classNames='w-full text-start gap-form-gap'>\n <div className='grow overflow-hidden'>\n <span className='truncate text-description'>\n {placeholder || label || t('ref-field.placeholder')}\n </span>\n </div>\n <Icon size={3} icon='ph--caret-down--bold' />\n </Button>\n )}\n </ObjectPicker.Trigger>\n <ObjectPicker.Portal>\n <ObjectPicker.Content\n classNames='dx-card-popover-width'\n options={options}\n selectedIds={selectedIds}\n // Strip hidden (`FormInputAnnotation.set(false)`) fields so the\n // form's validator doesn't reject required-but-hidden fields\n // such as backing-object refs supplied by a `FactoryAnnotation`.\n createSchema={createSchema && omitHiddenFormFields(omitId(Type.getSchema(createSchema)))}\n createOptionLabel={createOptionLabel}\n createOptionIcon={createOptionIcon}\n createInitialValuePath={createInitialValuePath}\n createFieldMap={createFieldMap}\n onCreate={handleCreate}\n onSelect={handleSelect}\n />\n </ObjectPicker.Portal>\n </ObjectPicker.Root>\n )}\n </div>\n {layout === 'full' && <Input.DescriptionAndValidation>{error}</Input.DescriptionAndValidation>}\n </Input.Root>\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Schema from 'effect/Schema';\nimport React, { type KeyboardEvent, forwardRef, useCallback, useState } from 'react';\n\nimport { type Palette, Popover, type ThemedClassName, useTranslation } from '@dxos/react-ui';\nimport { Combobox } from '@dxos/react-ui-list';\nimport { useSearchListResults } from '@dxos/react-ui-search';\n\nimport { translationKey } from '#translations';\n\nimport { Form } from '../Form';\nimport { type FormFieldMap } from '../Form/FormFieldComponent';\n\nexport type RefOption = {\n id: string;\n label: string;\n hue?: Palette;\n};\n\nexport type ObjectPickerContentProps = ThemedClassName<{\n options: RefOption[];\n selectedIds?: string[];\n createOptionLabel?: [string, { ns: string | readonly string[] }];\n createOptionIcon?: string;\n createSchema?: Schema.Schema.AnyNoContext;\n createInitialValuePath?: string;\n createFieldMap?: FormFieldMap;\n /**\n * Persist a newly-created object given the form values. May be async (e.g.\n * to write to a database). The Promise is awaited before the inline create\n * form is collapsed back to the picker list, so consumers can complete\n * follow-up work (assign the new ref to a parent slot, close the popover)\n * before the picker UI re-renders.\n */\n onCreate?: (values: any) => unknown | Promise<unknown>;\n onSelect: (id: string) => void;\n}>;\n\nconst ObjectPickerContent = forwardRef<HTMLDivElement, ObjectPickerContentProps>(\n (\n {\n options,\n selectedIds,\n createSchema,\n createOptionLabel,\n createOptionIcon,\n createInitialValuePath,\n createFieldMap,\n onSelect,\n onCreate,\n ...props\n },\n forwardedRef,\n ) => {\n const { t } = useTranslation(translationKey);\n const [showForm, setShowForm] = useState(false);\n const [formInitialValue, setFormInitialValue] = useState<string>('');\n\n const { results, query, handleSearch } = useSearchListResults({\n items: options,\n });\n\n const handleFormSave = useCallback(\n async (values: any) => {\n await onCreate?.(values);\n setShowForm(false);\n setFormInitialValue('');\n },\n [onCreate],\n );\n\n const handleFormCancel = useCallback(() => {\n setShowForm(false);\n setFormInitialValue('');\n }, []);\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (\n event.key === 'Enter' &&\n createSchema &&\n (event.currentTarget as HTMLElement).querySelector(\n '[role=\"option\"][aria-selected=\"true\"][data-value=\"__create__\"]',\n )\n ) {\n event.stopPropagation();\n event.preventDefault();\n // Get the current query from the input element\n const input = (event.currentTarget as HTMLElement).querySelector('input[type=\"text\"]') as HTMLInputElement;\n const currentQuery = input?.value || '';\n setFormInitialValue(currentQuery);\n setShowForm(true);\n }\n },\n [createSchema],\n );\n\n if (showForm && createSchema) {\n return (\n <Combobox.Content {...props} onKeyDownCapture={handleKeyDown} ref={forwardedRef}>\n <Popover.Viewport>\n <Form.Root\n testId='create-referenced-object-form'\n schema={createSchema}\n defaultValues={createInitialValuePath ? { [createInitialValuePath]: formInitialValue } : {}}\n fieldMap={createFieldMap}\n onSave={handleFormSave}\n onCancel={handleFormCancel}\n >\n <Form.Viewport>\n <Form.Content>\n <Form.FieldSet />\n <Form.Actions />\n </Form.Content>\n </Form.Viewport>\n </Form.Root>\n </Popover.Viewport>\n <Combobox.Arrow />\n </Combobox.Content>\n );\n }\n\n return (\n <Combobox.Content {...props} onKeyDownCapture={handleKeyDown} ref={forwardedRef}>\n <Combobox.Input\n placeholder={t('ref-field-combobox-input.placeholder')}\n autoFocus\n value={query}\n onValueChange={handleSearch}\n />\n <Combobox.List>\n {results.map((option) => (\n <Combobox.Item\n key={option.id}\n value={option.id}\n label={option.label}\n checked={selectedIds?.includes(option.id)}\n onSelect={() => onSelect(option.id)}\n classNames='flex items-center gap-2'\n />\n ))}\n {createSchema && onCreate && (\n <CreateItem\n query={query}\n createOptionLabel={createOptionLabel}\n createOptionIcon={createOptionIcon ?? 'ph--plus--regular'}\n onCreateItemSelect={(currentQuery: string) => {\n setFormInitialValue(currentQuery);\n setShowForm(true);\n }}\n />\n )}\n </Combobox.List>\n <Combobox.Arrow />\n </Combobox.Content>\n );\n },\n);\n\nconst CreateItem = ({\n query,\n createOptionLabel,\n createOptionIcon,\n onCreateItemSelect,\n}: {\n query: string;\n createOptionLabel?: [string, { ns: string | readonly string[] }];\n createOptionIcon: string;\n onCreateItemSelect: (query: string) => void;\n}) => {\n const { t } = useTranslation(translationKey);\n\n const label = createOptionLabel\n ? t(createOptionLabel[0], { ns: createOptionLabel[1].ns, text: query })\n : t('create-option.label');\n\n return (\n <Combobox.Item\n value='__create__'\n label={label}\n icon={createOptionIcon}\n classNames='flex items-center gap-2'\n closeOnSelect={false}\n onSelect={() => {\n onCreateItemSelect(query);\n }}\n />\n );\n};\n\nObjectPickerContent.displayName = 'ObjectPicker.Content';\n\nexport const ObjectPicker = {\n Root: Combobox.Root,\n Portal: Combobox.Portal,\n Trigger: Combobox.Trigger,\n VirtualTrigger: Combobox.VirtualTrigger,\n Content: ObjectPickerContent,\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useCallback } from 'react';\n\nimport { Icon, Input, Select, type SelectRootProps } from '@dxos/react-ui';\nimport { getStyles } from '@dxos/ui-theme';\n\nimport { type FormFieldComponentProps, FormFieldLabel } from '../FormFieldComponent';\n\nexport type SelectFieldOptions = FormFieldComponentProps & {\n options?: Array<{ value: string | number; label?: string; secondaryLabel?: string; icon?: string; iconHue?: string }>;\n};\n\nexport const SelectField = ({\n type,\n readonly,\n label,\n jsonPath,\n layout,\n placeholder,\n options,\n getStatus,\n getValue,\n onValueChange,\n}: SelectFieldOptions) => {\n const { status, error } = getStatus();\n const value = getValue() as string | undefined;\n\n const handleValueChange = useCallback<NonNullable<SelectRootProps['onValueChange']>>(\n (value) => onValueChange(type, value),\n [type, onValueChange],\n );\n\n if ((readonly || layout === 'static') && value == null) {\n return null;\n }\n\n return (\n <Input.Root validationValence={status}>\n {layout !== 'inline' && <FormFieldLabel error={error} readonly={readonly} label={label} path={jsonPath} />}\n {layout === 'static' ? (\n <p>{options?.find(({ value: optionValue }) => optionValue === value)?.label ?? String(value)}</p>\n ) : (\n <Select.Root value={value} onValueChange={handleValueChange}>\n {/* TODO(burdon): Placeholder not working? */}\n <Select.TriggerButton classNames='w-full' disabled={!!readonly} placeholder={placeholder} />\n <Select.Portal>\n <Select.Content>\n <Select.Viewport>\n {options?.map(({ value, label, secondaryLabel, icon, iconHue }) => (\n // NOTE: Numeric values are converted to and from strings.\n <Select.Option key={String(value)} value={String(value)}>\n <span className='flex items-center flex-row gap-2'>\n {icon && <Icon icon={icon} classNames={getIconHueStyles(iconHue)} />}\n {label ?? String(value)}\n {secondaryLabel && <span className='text-subdued text-xs'>{secondaryLabel}</span>}\n </span>\n </Select.Option>\n ))}\n </Select.Viewport>\n <Select.Arrow />\n </Select.Content>\n </Select.Portal>\n </Select.Root>\n )}\n {layout === 'full' && <Input.DescriptionAndValidation>{error}</Input.DescriptionAndValidation>}\n </Input.Root>\n );\n};\n\nconst getIconHueStyles = (iconHue?: string): string | undefined => {\n const styles = iconHue ? getStyles(iconHue) : undefined;\n\n return styles?.fg;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { type ChangeEvent, type KeyboardEvent, useCallback, useEffect, useRef, useState } from 'react';\n\nimport { type SelectOption } from '@dxos/echo/Format';\nimport { PublicKey } from '@dxos/keys';\nimport { type ChromaticPalette, IconButton, Input, Tag, useTranslation } from '@dxos/react-ui';\nimport { List } from '@dxos/react-ui-list';\nimport { HuePicker } from '@dxos/react-ui-pickers';\nimport { hues, osTranslations } from '@dxos/ui-theme';\n\nimport { translationKey } from '#translations';\n\nimport { type FormFieldComponentProps, FormFieldLabel } from '../FormFieldComponent';\n\nexport const SelectOptionField = ({\n type,\n readonly,\n label,\n jsonPath,\n getStatus,\n getValue,\n onValueChange,\n}: FormFieldComponentProps<SelectOption[] | undefined>) => {\n const { t } = useTranslation(translationKey);\n const { status, error } = getStatus();\n const [selected, setSelectedId] = useState<string | null>(null);\n const [isNewOption, setIsNewOption] = useState(false);\n const inputRef = useRef<HTMLInputElement>(null);\n const options = getValue();\n\n // Initialization.\n useEffect(() => {\n if (options === undefined) {\n onValueChange(type, []);\n }\n }, [options, type, onValueChange]);\n\n const randomHue = () => {\n const usedHues = new Set(options?.map((option) => option.color) ?? []);\n // Pick a random unused option from hueTokenThemes.\n const unusedHues = hues.filter((hue) => !usedHues.has(hue));\n if (unusedHues.length > 0) {\n return unusedHues[Math.floor(Math.random() * unusedHues.length)];\n }\n\n // Pick a random one that hasn't been used in the last three options\n const lastThree = new Set(options?.slice(-3).map((option) => option.color) ?? []);\n const availableHues = hues.filter((hue) => !lastThree.has(hue));\n return (\n availableHues[Math.floor(Math.random() * availableHues.length)] ?? hues[Math.floor(Math.random() * hues.length)]\n );\n };\n\n const handleAdd = useCallback(() => {\n const newId = PublicKey.random().truncate();\n const newOption = { id: newId, title: '', color: randomHue() };\n onValueChange(type, [...(options ?? []), newOption]);\n setSelectedId(newId);\n setIsNewOption(true);\n }, [options, type, onValueChange]);\n\n const handleDelete = useCallback(\n (id: string) => {\n const newOptions = options?.filter((option) => option.id !== id) ?? [];\n onValueChange(type, newOptions);\n setSelectedId(null);\n },\n [options, type, onValueChange],\n );\n\n const handleMove = useCallback(\n (from: number, to: number) => {\n if (!options) {\n return;\n }\n\n const newOptions = [...options];\n const [removed] = newOptions.splice(from, 1);\n newOptions.splice(to, 0, removed);\n onValueChange(type, newOptions);\n },\n [options, type, onValueChange],\n );\n\n const handleClick = useCallback((id: string) => {\n setSelectedId((current) => (current === id ? null : id));\n }, []);\n\n const handleTitleChange = useCallback(\n (id: string) => (e: ChangeEvent<HTMLInputElement>) => {\n const newOptions = options?.map((o) => (o.id === id ? { ...o, title: e.target.value } : o));\n onValueChange(type, newOptions ?? []);\n },\n [options, type, onValueChange],\n );\n\n const handleKeyDown = useCallback((ev: KeyboardEvent<HTMLInputElement>) => {\n if (ev.key === 'Enter') {\n setSelectedId(null);\n }\n }, []);\n\n const handleColorChange = useCallback(\n (id: string) => (hue: string) => {\n const newOptions = options?.map((o) => (o.id === id ? { ...o, color: hue } : o));\n onValueChange(type, newOptions ?? []);\n },\n [options, type, onValueChange],\n );\n\n useEffect(() => {\n if (selected && isNewOption && inputRef.current) {\n inputRef.current.focus();\n setIsNewOption(false);\n }\n }, [selected, isNewOption]);\n\n return (\n <Input.Root validationValence={status}>\n <FormFieldLabel error={error} readonly={readonly} label={label} path={jsonPath} />\n <div>\n {options && (\n <List.Root\n items={options}\n isItem={(_item) => true}\n onMove={readonly ? undefined : handleMove}\n readonly={!!readonly}\n >\n {({ items }) => (\n <div role='list' className='w-full overflow-auto'>\n {items?.map((item) => (\n <div key={item.id}>\n <List.Item\n role='button'\n item={item}\n classNames='flex flex-col cursor-pointer rounded-xs dx-hover'\n aria-expanded={selected === item.id}\n >\n <div className='flex items-center'>\n <List.ItemDragHandle disabled={!!readonly} />\n <List.ItemTitle onClick={() => handleClick(item.id)} classNames='flex-1'>\n {/* TODO(ZaymonFC): Move spacer into Tag component. */}\n <Tag palette={item.color as ChromaticPalette}>{item.title || '\\u200b'}</Tag>\n </List.ItemTitle>\n <IconButton\n iconOnly\n variant='ghost'\n label={t(selected === item.id ? 'collapse.label' : 'expand.label', { ns: osTranslations })}\n icon={selected === item.id ? 'ph--caret-down--regular' : 'ph--caret-right--regular'}\n onClick={() => handleClick(item.id)}\n />\n </div>\n {selected === item.id && (\n <div className='flex flex-col p-form-padding gap-form-gap dx-density-md'>\n <Input.Label classNames='text-sm'>{t('select-option.label')}</Input.Label>\n <div className='grid grid-cols-[1fr_min-content_min-content] gap-form-gap'>\n <Input.TextInput\n disabled={!!readonly}\n placeholder={t('select-option-label.placeholder')}\n ref={selected === item.id ? inputRef : undefined}\n value={item.title}\n onChange={handleTitleChange(item.id)}\n onKeyDown={handleKeyDown}\n classNames='flex-1'\n />\n <HuePicker disabled={!!readonly} value={item.color} onChange={handleColorChange(item.id)} />\n <IconButton\n disabled={!!readonly}\n icon='ph--trash--fill'\n iconOnly\n label={t('select-option-delete.button')}\n onClick={() => handleDelete(item.id)}\n />\n </div>\n </div>\n )}\n </List.Item>\n </div>\n ))}\n <IconButton\n variant='ghost'\n icon='ph--plus--regular'\n label={t('select-option-add.button')}\n onClick={handleAdd}\n disabled={!!readonly}\n classNames='w-full'\n />\n </div>\n )}\n </List.Root>\n )}\n </div>\n </Input.Root>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useCallback } from 'react';\n\nimport { Input, type TextInputProps } from '@dxos/react-ui';\n\nimport { type FormFieldComponentProps, FormFieldWrapper } from '../FormFieldComponent';\n\nexport const TextField = ({\n type,\n readonly,\n placeholder,\n onBlur,\n onValueChange,\n ...props\n}: FormFieldComponentProps<string>) => {\n const handleChange = useCallback<NonNullable<TextInputProps['onChange']>>(\n (event) => onValueChange(type, event.target.value),\n [type, onValueChange],\n );\n\n return (\n <FormFieldWrapper<string> readonly={readonly} {...props}>\n {({ value = '' }) => (\n <Input.TextInput\n noAutoFill\n disabled={!!readonly}\n placeholder={placeholder}\n value={value}\n onBlur={onBlur}\n onChange={handleChange}\n />\n )}\n </FormFieldWrapper>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useCallback } from 'react';\n\nimport { Input, type TextAreaProps } from '@dxos/react-ui';\n\nimport { type FormFieldComponentProps, FormFieldWrapper } from '../FormFieldComponent';\n\nexport const TextAreaField = ({\n type,\n readonly,\n placeholder,\n onValueChange,\n onBlur,\n ...props\n}: FormFieldComponentProps<string>) => {\n const handleChange = useCallback<NonNullable<TextAreaProps['onChange']>>(\n (event) => onValueChange(type, event.target.value),\n [type, onValueChange],\n );\n\n return (\n <FormFieldWrapper<string> readonly={readonly} {...props}>\n {({ value = '' }) => (\n <Input.TextArea\n rows={5}\n disabled={!!readonly}\n placeholder={placeholder}\n value={value}\n onChange={handleChange}\n onBlur={onBlur}\n />\n )}\n </FormFieldWrapper>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { Input } from '@dxos/react-ui';\nimport { mx } from '@dxos/ui-theme';\nimport { safeParseFloat } from '@dxos/util';\n\nimport { type FormFieldComponentProps, FormFieldLabel } from '../FormFieldComponent';\n\nconst gridCols = ['grid-cols-1', 'grid-cols-2', 'grid-cols-3', 'grid-cols-4'];\n\nexport const TupleField = ({\n binding,\n type,\n readonly,\n label,\n jsonPath,\n getStatus,\n getValue,\n onValueChange,\n onBlur,\n}: FormFieldComponentProps<Record<string, number>> & {\n binding: string[];\n}) => {\n const { status, error } = getStatus();\n\n // TODO(burdon): Generalize number/float/string, etc.\n const values: Record<string, number> = getValue() ?? {};\n\n return (\n <Input.Root validationValence={status}>\n <FormFieldLabel error={error} readonly={readonly} label={label} path={jsonPath} />\n <div className={mx('grid gap-form-gap', gridCols[binding.length - 1])}>\n {binding.map((prop) => (\n <Input.TextInput\n key={prop}\n type='number'\n disabled={!!readonly}\n value={values[prop]}\n onChange={(event) => {\n onValueChange(type, {\n ...values,\n [prop]: safeParseFloat(event.target.value, 0),\n });\n }}\n onBlur={onBlur}\n />\n ))}\n </div>\n </Input.Root>\n );\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Ref, Tag } from '@dxos/echo';\n\nimport { omitId } from './Form';\n\n/**\n * Form-field key for the synthetic meta-tags array spliced into property/create forms.\n *\n * An object's tags live in `Obj.getMeta(obj).tags` (off-schema), so the form surfaces them as an\n * extra field rather than reading the schema. The key is underscore-prefixed so it never collides\n * with a `tags` field an object schema declares itself — e.g. a `TagIndex` record on a feed host,\n * whose `tags` is `Record<tagId, objectId[]>`, not an array. Extending such a schema with a `tags`\n * array threw \"overlapping types at path: [\\\"tags\\\"]\"; the disjoint `_tags` key avoids it. The\n * human-facing label is restored via the `title` annotation on {@link withMetaTags}.\n */\nexport const META_TAGS_KEY = '_tags';\n\n/**\n * Splices the synthetic meta-tags array (an object's `meta.tags`, surfaced as {@link Tag} refs) onto\n * a schema for editing and drops `id`. Keyed by {@link META_TAGS_KEY} so it never collides with a\n * `tags` field the schema declares itself.\n */\nexport const withMetaTags = (schema: Schema.Schema.AnyNoContext) =>\n omitId(\n Schema.Struct({\n [META_TAGS_KEY]: Schema.Array(Ref.Ref(Tag.Tag)).pipe(Schema.annotations({ title: 'Tags' }), Schema.optional),\n }).pipe(Schema.extend(schema)),\n );\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { useCallback, useMemo } from 'react';\n\nimport { Obj, Ref, Tag, Type } from '@dxos/echo';\nimport { SchemaEx } from '@dxos/effect';\nimport { invariant } from '@dxos/invariant';\nimport { HuePicker } from '@dxos/react-ui-pickers';\n\nimport { translationKey } from '#translations';\n\nimport { Form, type FormFieldMap, META_TAGS_KEY, withMetaTags } from '../Form';\n\nexport type ObjectFormProps = {\n type: Type.AnyEntity;\n object: Obj.Unknown;\n};\n\nconst createFieldMap: FormFieldMap = {\n hue: ({ type, label, layout, getValue, onValueChange }) => {\n const handleChange = useCallback((nextHue: string) => onValueChange(type, nextHue), [onValueChange, type]);\n const handleReset = useCallback(() => onValueChange(type, undefined), [onValueChange, type]);\n return (\n <>\n {layout !== 'inline' && <Form.Label label={label} />}\n <HuePicker value={getValue()} onChange={handleChange} onReset={handleReset} />\n </>\n );\n },\n};\n\nexport const ObjectForm = ({ object, type }: ObjectFormProps) => {\n const db = Obj.getDatabase(object);\n const meta = Obj.getMeta(object);\n // `meta.tags` already holds `Ref<Tag>`s (materialized by the database handler).\n const tags = [...meta.tags];\n const values = useMemo(() => ({ [META_TAGS_KEY]: tags, ...object }), [object, tags]);\n const formSchema = useMemo(() => withMetaTags(Type.getSchema(type)), [type]);\n\n const handleCreate = useCallback((type: Type.AnyEntity, values: any) => {\n invariant(db);\n invariant(Type.isObject(type));\n const newObject = db.add(Obj.make(type, values));\n if (Obj.instanceOf(Tag.Tag, newObject)) {\n Obj.update(object, (object) => {\n Obj.getMeta(object).tags = [...Obj.getMeta(object).tags, Ref.make(newObject)];\n });\n }\n }, []);\n\n // TODO(wittjosiah): Use FormRootProps type.\n const handleChange = useCallback(\n (\n { [META_TAGS_KEY]: metaTags, ...values }: any,\n { isValid, changed }: { isValid: boolean; changed: Record<SchemaEx.JsonPath, boolean> },\n ) => {\n if (!isValid) {\n return;\n }\n\n const changedPaths = Object.keys(changed).filter(\n (path) => changed[path as SchemaEx.JsonPath],\n ) as SchemaEx.JsonPath[];\n\n // Handle meta-tags separately using Obj.update.\n const hasTagsChange = changedPaths.some((path) => SchemaEx.splitJsonPath(path)[0] === META_TAGS_KEY);\n if (hasTagsChange) {\n Obj.update(object, (object) => {\n // Copy so later in-place form mutations don't bypass the `Obj.update` boundary.\n Obj.getMeta(object).tags = Array.isArray(metaTags) ? [...(metaTags as Ref.Ref<Tag.Tag>[])] : [];\n });\n }\n\n // Handle other property changes.\n const nonTagPaths = changedPaths.filter((path) => SchemaEx.splitJsonPath(path)[0] !== META_TAGS_KEY);\n if (nonTagPaths.length > 0) {\n Obj.update(object, () => {\n for (const path of nonTagPaths) {\n const parts = SchemaEx.splitJsonPath(path);\n const value = Obj.getValue(values, parts);\n Obj.setValue(object, parts, value);\n }\n });\n }\n },\n [object],\n );\n\n return (\n <Form.Root\n schema={formSchema}\n defaultValues={values}\n createTypename={Type.getTypename(Tag.Tag)}\n createOptionIcon='ph--plus--regular'\n createOptionLabel={['add-tag.label', { ns: translationKey }]}\n createInitialValuePath='label'\n createFieldMap={createFieldMap}\n db={db}\n onValuesChanged={handleChange}\n onCreate={handleCreate}\n >\n <Form.Viewport>\n <Form.Content>\n <Form.FieldSet />\n </Form.Content>\n </Form.Viewport>\n </Form.Root>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Function from 'effect/Function';\nimport * as Option from 'effect/Option';\nimport React, { type PropsWithChildren, useCallback, useMemo } from 'react';\n\nimport { Obj, Ref, Tag, Type } from '@dxos/echo';\nimport { useType } from '@dxos/echo-react';\nimport { SchemaEx } from '@dxos/effect';\nimport { invariant } from '@dxos/invariant';\nimport { composable, composableProps } from '@dxos/react-ui';\nimport { HuePicker } from '@dxos/react-ui-pickers';\nimport { FactoryAnnotation } from '@dxos/schema';\n\nimport { translationKey } from '#translations';\n\nimport { Form, type FormFieldMap, META_TAGS_KEY, withMetaTags } from '../Form';\n\nexport type ObjectPropertiesProps = PropsWithChildren<{ object: Obj.Unknown }>;\n\n// TODO(wittjosiah): Reconcile w/ ObjectForm.\nexport const ObjectProperties = composable<HTMLDivElement, ObjectPropertiesProps>(\n ({ children, object, ...props }, forwardedRef) => {\n const db = Obj.getDatabase(object);\n const meta = Obj.getMeta(object);\n // `meta.tags` already holds `Ref<Tag>`s (materialized by the database handler).\n const tags = [...meta.tags];\n const values = useMemo(() => ({ [META_TAGS_KEY]: tags, ...object }), [object, tags]);\n\n // Obj.getType fails for database-registered (dynamic) schemas due to DXN mismatch;\n // useType queries by the object's stored type URI, resolving both static and dynamic schemas.\n const typeUri = Obj.getTypeURI(object);\n const typeFromRegistry = useType(db, typeUri);\n const type = Obj.getType(object) ?? typeFromRegistry;\n\n const formSchema = useMemo(() => {\n return Function.pipe(\n type,\n Option.fromNullable,\n Option.map((type) => Type.getSchema(type)),\n Option.map((schema) => withMetaTags(schema)),\n Option.getOrUndefined,\n );\n }, [type]);\n\n // Persist a newly-created object referenced by one of the form's ref\n // fields and return it. The calling RefField wires the new Ref into its\n // own slot's form value; for the synthetic `_tags` array, the resulting\n // form change is then synced back to `Obj.getMeta(object).tags` by\n // `handleChange` below — so Tag.Tag follows the same generic path as any\n // other ref-array field, no type-specific branching required here.\n //\n // Schemas whose required structure can't be produced by `Obj.make(schema,\n // values)` alone (e.g. types with a required ref to a backing object) can\n // declare a `FactoryAnnotation` to take over construction.\n const handleCreate = useCallback(\n (type: Type.AnyEntity, values: any): Obj.Unknown => {\n invariant(db);\n invariant(Type.isObject(type));\n const factory = Option.getOrUndefined(FactoryAnnotation.get(Type.getSchema(type)));\n const newObject = factory ? (factory(values) as Obj.Unknown) : Obj.make(type, values);\n return db.add(newObject) as Obj.Unknown;\n },\n [db],\n );\n\n // TODO(wittjosiah): Use FormRootProps type.\n const handleChange = useCallback(\n (\n { [META_TAGS_KEY]: metaTags, ...values }: any,\n { isValid, changed }: { isValid: boolean; changed: Record<SchemaEx.JsonPath, boolean> },\n ) => {\n if (!isValid) {\n return;\n }\n\n const changedPaths = Object.keys(changed).filter(\n (path) => changed[path as SchemaEx.JsonPath],\n ) as SchemaEx.JsonPath[];\n\n // Handle meta-tags separately using Obj.update.\n const hasTagsChange = changedPaths.some((path) => SchemaEx.splitJsonPath(path)[0] === META_TAGS_KEY);\n if (hasTagsChange) {\n Obj.update(object, (object) => {\n // Copy so later in-place form mutations don't bypass the `Obj.update` boundary.\n Obj.getMeta(object).tags = Array.isArray(metaTags) ? [...(metaTags as Ref.Ref<Tag.Tag>[])] : [];\n });\n }\n\n // Handle other property changes.\n const nonTagPaths = changedPaths.filter((path) => SchemaEx.splitJsonPath(path)[0] !== META_TAGS_KEY);\n if (nonTagPaths.length > 0) {\n Obj.update(object, () => {\n for (const path of nonTagPaths) {\n const parts = SchemaEx.splitJsonPath(path);\n const value = Obj.getValue(values as any, parts);\n Obj.setValue(object, parts, value);\n }\n });\n }\n },\n [object],\n );\n\n if (!formSchema) {\n return null;\n }\n\n return (\n <Form.Root\n schema={formSchema}\n defaultValues={values as any}\n createTypename={Type.getTypename(Tag.Tag)}\n createOptionIcon='ph--plus--regular'\n createOptionLabel={['add-tag.label', { ns: translationKey }]}\n createInitialValuePath='label'\n createFieldMap={createFieldMap}\n db={db}\n onValuesChanged={handleChange}\n onCreate={handleCreate}\n >\n <Form.Viewport {...composableProps(props)} ref={forwardedRef}>\n <Form.Content>\n <Form.FieldSet />\n {children}\n </Form.Content>\n </Form.Viewport>\n </Form.Root>\n );\n },\n);\n\nconst createFieldMap: FormFieldMap = {\n hue: ({ type, label, layout, getValue, onValueChange }) => {\n const handleChange = useCallback((nextHue: string) => onValueChange(type, nextHue), [onValueChange, type]);\n const handleReset = useCallback(() => onValueChange(type, undefined), [onValueChange, type]);\n return (\n <>\n {layout !== 'inline' && <Form.Label label={label} />}\n <HuePicker value={getValue()} onChange={handleChange} onReset={handleReset} />\n </>\n );\n },\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\n// A minimal, read-only schema-driven viewer. Walks an Effect Schema and a\n// matching value and produces a flat list of indented key/value rows -- one\n// per leaf field, with nested Struct fields contributing a header row plus\n// recursively-indented children, and arrays expanded as `[index]` rows.\n//\n// Designed to drive a hierarchical editor over schemas produced by\n// `@dxos/effect-proto` (e.g. the proto-generated `dxos.config.Config`\n// schema), but works for any Effect Struct schema.\n\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\nimport React, { type ReactElement, type ReactNode, type RefAttributes } from 'react';\n\nimport { composable, composableProps } from '@dxos/react-ui';\nimport { mx } from '@dxos/ui-theme';\nimport { type ComposableProps } from '@dxos/ui-types';\n\nexport type ObjectTreeProps<T> = {\n schema: Schema.Schema<T, any, never>;\n value: T;\n};\n\n/**\n * Render a value as a sequence of key/value rows whose shape and order are\n * driven by `schema`. Object-typed properties become a header row whose\n * children are indented under it; arrays expand element-by-element.\n *\n * Composable: spreads unknown props (incl. `className` / `classNames` /\n * `style` / `role`) onto its root `<div>` and forwards its ref, so it can\n * be slotted into themed parents like `Panel.Content`.\n */\nconst ObjectTreeImpl = composable<HTMLDivElement, ObjectTreeProps<any>>(({ schema, value, ...props }, forwardedRef) => (\n <div {...composableProps(props, { role: 'table', classNames: 'font-mono text-sm w-full' })} ref={forwardedRef}>\n <Node ast={schema.ast} value={value} label={null} depth={0} />\n </div>\n));\n\nObjectTreeImpl.displayName = 'ObjectTree';\n\n// `composable<HTMLDivElement, ObjectTreeProps<any>>` erases the `T` type\n// parameter inside the factory; the cast restores the generic signature for\n// consumers without changing the underlying component (the COMPOSABLE marker\n// stays attached). This is the pattern documented on `composable()` itself.\nexport const ObjectTree = ObjectTreeImpl as unknown as <T>(\n props: ComposableProps<ObjectTreeProps<T>> & RefAttributes<HTMLDivElement>,\n) => ReactElement | null;\n\n/**\n * Peel wrappers that don't affect the runtime shape: Refinements pass their\n * `from`, Suspends resolve via `f()`, and Transformations expose the encoded\n * (input) side. Repeated unwrapping handles chains like `Schema.suspend ->\n * Refinement -> TypeLiteral`.\n */\nconst unwrap = (ast: SchemaAST.AST): SchemaAST.AST => {\n if (SchemaAST.isRefinement(ast)) {\n return unwrap(ast.from);\n }\n if (SchemaAST.isSuspend(ast)) {\n return unwrap(ast.f());\n }\n if (SchemaAST.isTransformation(ast)) {\n return unwrap(ast.from);\n }\n return ast;\n};\n\n/**\n * Effect models `Schema.optional(X)` as a property whose type AST is\n * `Union(X, UndefinedKeyword)`. For walking purposes we want X -- the\n * undefined branch carries no schema information for the viewer.\n */\nconst stripOptional = (ast: SchemaAST.AST): SchemaAST.AST => {\n if (!SchemaAST.isUnion(ast)) {\n return ast;\n }\n const nonUndef = ast.types.filter((t) => !SchemaAST.isUndefinedKeyword(t));\n return nonUndef.length === 1 ? nonUndef[0] : ast;\n};\n\ntype NodeProps = {\n ast: SchemaAST.AST;\n value: unknown;\n /** Row label; `null` means render children directly without a header row. */\n label: ReactNode | null;\n depth: number;\n};\n\nconst Node = ({ ast, value, label, depth }: NodeProps) => {\n const inner = unwrap(stripOptional(ast));\n\n // Struct: header row + indented children. Skipping the header at depth 0\n // keeps the root flush-left.\n if (SchemaAST.isTypeLiteral(inner) && isPlainObject(value)) {\n const childDepth = label === null ? depth : depth + 1;\n return (\n <>\n {label !== null && <Row label={label} value={null} depth={depth} kind='group' />}\n {inner.propertySignatures.map((prop) => (\n <Node\n key={String(prop.name)}\n ast={prop.type}\n value={(value as Record<string, unknown>)[String(prop.name)]}\n label={String(prop.name)}\n depth={childDepth}\n />\n ))}\n </>\n );\n }\n\n // Array (`Schema.Array(X)` -> TupleType with single rest element).\n if (SchemaAST.isTupleType(inner) && Array.isArray(value)) {\n const elemType = inner.rest[0]?.type;\n return (\n <>\n {label !== null && <Row label={label} value={`Array(${value.length})`} depth={depth} kind='group' />}\n {value.map((item, index) => (\n <Node\n key={index}\n ast={elemType ?? SchemaAST.unknownKeyword}\n value={item}\n label={`[${index}]`}\n depth={depth + 1}\n />\n ))}\n </>\n );\n }\n\n // Leaf (scalars, unions of literals, unknown, etc.).\n return <Row label={label ?? ''} value={formatLeaf(value)} depth={depth} kind='leaf' />;\n};\n\ntype RowProps = {\n label: ReactNode;\n value: ReactNode;\n depth: number;\n kind: 'group' | 'leaf';\n};\n\nconst Row = ({ label, value, depth }: RowProps) => (\n <div role='row' className={mx('flex items-baseline gap-3 py-1')} style={{ paddingInlineStart: 8 + depth * 16 }}>\n <div role='cell' className='text-subdued'>\n {label}\n </div>\n <div role='cell' className={mx('break-all text-base-fg')}>\n {value}\n </div>\n </div>\n);\n\nconst isPlainObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\n/**\n * Format a leaf value for display. Strings are quoted so empty strings are\n * visible; missing values surface as an em-dash so the row stays present.\n */\nconst formatLeaf = (value: unknown): ReactNode => {\n if (value === undefined) {\n return null;\n }\n\n if (value === null) {\n return <span className='text-description'>null</span>;\n }\n\n switch (typeof value) {\n case 'string':\n // Quote strings so empty strings remain visible (`\"\"` rather than blank).\n return <span className='text-blue-text'>{JSON.stringify(value)}</span>;\n case 'number':\n case 'bigint':\n return <span className='text-green-text'>{String(value)}</span>;\n case 'boolean':\n return <span className='text-purple-text'>{String(value)}</span>;\n default:\n // Objects we couldn't expand via schema (e.g. `google.protobuf.Any` -> Unknown)\n // are rendered as compact JSON.\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n }\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { type Extension, Prec } from '@codemirror/state';\nimport { type EditorView } from '@codemirror/view';\nimport React, { forwardRef, useCallback, useEffect, useMemo, useRef } from 'react';\n\nimport { type Database, Filter, Obj, type Type } from '@dxos/echo';\nimport { useQuery } from '@dxos/react-client/echo';\nimport { type ThemedClassName, useThemeContext, useTranslation } from '@dxos/react-ui';\nimport {\n Editor,\n type EditorController,\n type EditorMenuProviderProps,\n type EditorViewProps,\n type UseEditorMenuProps,\n} from '@dxos/react-ui-editor';\nimport { createBasicExtensions, createThemeExtensions, insertAtCursor, keymap } from '@dxos/ui-editor';\nimport { getHashHue } from '@dxos/ui-theme';\n\nimport { translationKey } from '#translations';\n\nimport {\n EMAIL_REGEX,\n NAME_ADDR_REGEX,\n type RefEditorMode,\n type RefInfo,\n formatMailbox,\n refEditor,\n refEditorRedecorate,\n} from './ref-editor-extension';\n\nexport type RefEditorProps = ThemedClassName<\n {\n /** Database queried for objects of {@link RefEditorProps.type}. */\n db?: Database.Database;\n /** ECHO object type whose instances are offered in the typeahead and referenced as `@<id>`. */\n type: Type.AnyObj;\n value?: string;\n readonly?: boolean;\n /**\n * Content model:\n * - `'ref'` (default): the picker only matches existing objects; selection inserts an\n * `@<id>` reference (raw tokens accepted by `match` are also allowed).\n * - `'email'`: the picker shows one item per (object, value) pair and selection captures the\n * value; the content is an RFC 5322 mailbox list (`Name <email>, ...`) with the comma\n * separators hidden inside the tags.\n */\n mode?: RefEditorMode;\n /** Pluggable raw-token matcher (e.g. {@link EMAIL_REGEX}); matching tokens are accepted as values. */\n match?: RegExp;\n /** Display label for an object; defaults to `Obj.getLabel` falling back to the id. */\n getLabel?: (object: Obj.Unknown) => string;\n /** Values an object can be captured as in `'email'` mode (e.g. a person's email addresses). */\n getValues?: (object: Obj.Unknown) => readonly string[];\n /** Menu item icon. */\n icon?: string;\n /** Already-translated placeholder; defaults to a generic hint. */\n placeholder?: string;\n /** Open the typeahead while typing (the `@` trigger remains available but is not required). */\n activateOnTyping?: boolean;\n } & Omit<EditorViewProps, 'initialValue'> &\n Pick<EditorMenuProviderProps, 'numItems'>\n>;\n\n/**\n * Single-line input for a list of object references. Typing `@` (or any text, with\n * `activateOnTyping`) opens a typeahead menu matching objects of the given type by label (and\n * by their `getValues` values). The content model depends on {@link RefEditorProps.mode}.\n * Resolved entries render as atomic tags with the object's label; raw tokens accepted by the\n * pluggable `match` regexp render as neutral tags.\n */\nexport const RefEditor = forwardRef<EditorController, RefEditorProps>(\n (\n {\n db,\n type,\n value,\n readonly,\n mode = 'ref',\n match,\n getLabel,\n getValues,\n icon = 'ph--link--regular',\n placeholder: placeholderProp,\n activateOnTyping,\n numItems = 8,\n ...props\n },\n forwardedRef,\n ) => {\n const { t } = useTranslation(translationKey);\n const { themeMode } = useThemeContext();\n const getObjectLabel = useCallback(\n (object: Obj.Unknown) => getLabel?.(object) ?? Obj.getLabel(object) ?? object.id,\n [getLabel],\n );\n\n // Reads go through a ref so the decoration extension stays stable: recreating extensions\n // destroys and recreates the editor, which would blur the input on data changes.\n const filter = useMemo(() => Filter.type(type), [type]);\n const objects = useQuery(db, filter);\n const refs = useMemo(\n () =>\n new Map<string, RefInfo>(\n objects.map((object) => [object.id, { label: getObjectLabel(object), hue: getHashHue(object.id) }]),\n ),\n [objects, getObjectLabel],\n );\n const refsRef = useRef(refs);\n refsRef.current = refs;\n\n // Internal controller (merged with the forwarded ref) used to re-resolve reference\n // decorations when object data changes after the document was rendered.\n const controllerRef = useRef<EditorController | null>(null);\n const composedRef = useCallback(\n (controller: EditorController | null) => {\n controllerRef.current = controller;\n if (typeof forwardedRef === 'function') {\n forwardedRef(controller);\n } else if (forwardedRef) {\n forwardedRef.current = controller;\n }\n },\n [forwardedRef],\n );\n useEffect(() => {\n controllerRef.current?.view?.dispatch({ effects: refEditorRedecorate.of(null) });\n }, [refs]);\n\n const getMenu = useCallback<NonNullable<UseEditorMenuProps['getMenu']>>(\n async ({ text }) => {\n const query = (text ?? '').replace(/^@/, '').toLowerCase();\n const matchesQuery = (object: Obj.Unknown) =>\n !query ||\n getObjectLabel(object).toLowerCase().includes(query) ||\n (getValues?.(object) ?? []).some((entry) => entry.toLowerCase().includes(query));\n\n if (mode === 'email') {\n // One item per (object, value) pair; selection captures the value as an RFC 5322 mailbox.\n const mailboxes = objects\n .flatMap((object) => (getValues?.(object) ?? []).map((entry) => ({ object, entry })))\n .filter(\n ({ object, entry }) =>\n !query || getObjectLabel(object).toLowerCase().includes(query) || entry.toLowerCase().includes(query),\n );\n\n return [\n {\n id: 'mailboxes',\n items: mailboxes.slice(0, numItems * 2).map(({ object, entry }) => ({\n id: `${object.id}-${entry}`,\n label: `${getObjectLabel(object)} (${entry})`,\n icon,\n onSelect: ({ view, head }: { view: EditorView; head: number }) =>\n insertMailbox(view, head, formatMailbox(getObjectLabel(object), entry)),\n })),\n },\n ];\n }\n\n // 'ref' mode: only match existing objects.\n return [\n {\n id: 'refs',\n items: objects\n .filter(matchesQuery)\n .slice(0, numItems * 2)\n .map((object) => {\n const label = getObjectLabel(object);\n const detail = getValues?.(object)?.[0];\n return {\n id: object.id,\n label: detail && detail !== label ? `${label} (${detail})` : label,\n icon,\n onSelect: ({ view, head }: { view: EditorView; head: number }) =>\n insertAtCursor(view, head, `@${object.id} `),\n };\n }),\n },\n ];\n },\n [objects, numItems, mode, icon, getObjectLabel, getValues],\n );\n\n // NOTE: The placeholder is supplied via the popover (Editor.Root) so the trigger hint and the\n // empty-state hint are a single message; a second basic-extension placeholder would stack with it.\n // Must be referentially stable: the menu extension is memoized on it, and a new extension\n // identity destroys and recreates the editor on every keystroke.\n const placeholder = useMemo(\n () => ({\n content: placeholderProp ?? t(activateOnTyping ? 'ref-editor-auto.placeholder' : 'ref-editor.placeholder'),\n focusOnly: false,\n }),\n [t, placeholderProp, activateOnTyping],\n );\n\n const extensions = useMemo<Extension[]>(\n () => [\n createBasicExtensions({ readOnly: readonly, lineWrapping: false }),\n createThemeExtensions({ themeMode, slots: { scroller: { className: 'scrollbar-none' } } }),\n refEditor({ mode, match, getRef: (id) => refsRef.current.get(id) }),\n Prec.highest(\n keymap.of([\n {\n key: 'Enter',\n // Commit the in-progress token when it matches (insert the mode's separator, the\n // same gesture as typing it); always consume the key (single-line input).\n run: (view) => {\n const { head } = view.state.selection.main;\n const line = view.state.doc.lineAt(head);\n const before = line.text.slice(0, head - line.from);\n if (mode === 'email') {\n const segment = before.slice(before.lastIndexOf(',') + 1).trim();\n if (NAME_ADDR_REGEX.test(segment) || (match ?? EMAIL_REGEX).test(segment)) {\n insertAtCursor(view, head, ', ');\n }\n } else {\n const token = before.slice(before.search(/\\S+$/));\n if (token && match?.test(token)) {\n insertAtCursor(view, head, ' ');\n }\n }\n return true;\n },\n },\n ]),\n ),\n ],\n [readonly, themeMode, mode, match],\n );\n\n return (\n <Editor.Root\n extensions={extensions}\n numItems={numItems}\n trigger='@'\n activateOnTyping={activateOnTyping}\n placeholder={placeholder}\n // The menu owns its own matching (labels AND values); the built-in label filter would\n // drop value-matched objects whose label doesn't start with the query.\n filter={false}\n getMenu={getMenu}\n ref={composedRef}\n >\n <Editor.View\n // TOOD(burdon): Use same style as react-ui Input.\n classNames='border border-separator rounded-xs px-2'\n {...props}\n initialValue={value}\n selectionEnd\n />\n </Editor.Root>\n );\n },\n);\n\nRefEditor.displayName = 'RefEditor';\n\n/**\n * Insert an RFC 5322 mailbox, replacing the in-progress segment (anything typed after the last\n * comma — multi-word queries can leave words outside the popover's completion range).\n */\nconst insertMailbox = (view: EditorView, head: number, mailbox: string) => {\n const line = view.state.doc.lineAt(head);\n const before = line.text.slice(0, head - line.from);\n const lastComma = before.lastIndexOf(',');\n const from = line.from + (lastComma === -1 ? 0 : lastComma + 1);\n const insert = `${lastComma === -1 ? '' : ' '}${mailbox}, `;\n view.dispatch({\n changes: { from, to: head, insert },\n selection: { anchor: from + insert.length, head: from + insert.length },\n });\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { type EditorState, type Extension, RangeSetBuilder, StateEffect, StateField } from '@codemirror/state';\nimport { Decoration, type DecorationSet, EditorView, WidgetType } from '@codemirror/view';\n\nimport { Domino } from '@dxos/ui';\nimport { getHashHue, getStyles, mx } from '@dxos/ui-theme';\n\n/**\n * Display info for a resolved object reference.\n */\nexport type RefInfo = {\n label: string;\n hue?: string;\n};\n\n/**\n * Content model:\n * - `'ref'`: whitespace-separated tokens; `@<id>` references to existing objects (and raw tokens\n * accepted by the pluggable {@link RefEditorExtensionOptions.match} regexp).\n * - `'email'`: comma-separated RFC 5322 mailboxes (`Name <email>` or bare `email`); the comma\n * separators are consumed into the atomic tags so they are not visible.\n */\nexport type RefEditorMode = 'ref' | 'email';\n\nexport type RefEditorExtensionOptions = {\n mode?: RefEditorMode;\n /** Resolve an object id referenced as `@<id>` to display info. */\n getRef?: (id: string) => RefInfo | undefined;\n /** Pluggable raw-token matcher (e.g. {@link EMAIL_REGEX}); matching tokens render as neutral tags. */\n match?: RegExp;\n};\n\n/** Matches an object reference token (`@<object id>`). */\nexport const REF_REGEX = /^@([A-Za-z0-9]+)$/;\n\n/** Matches a well-formed email address token. */\nexport const EMAIL_REGEX = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$/;\n\n/** Matches an RFC 5322 name-addr (`Name <email>`); group 1 = display name, group 2 = addr-spec. */\nexport const NAME_ADDR_REGEX = /^(.*?)\\s*<([A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,})>$/;\n\n/** Formats an RFC 5322 mailbox (`Name <email>`). */\nexport const formatMailbox = (name: string | undefined, email: string): string => (name ? `${name} <${email}>` : email);\n\n/**\n * Effect dispatched when reference data changes out-of-band (e.g. objects finish loading) so that\n * already-rendered reference decorations re-resolve without a document change.\n */\nexport const refEditorRedecorate = StateEffect.define<null>();\n\n/**\n * CodeMirror extension rendering reference-editor tokens as tags. Tags are atomic: the cursor\n * cannot enter them and deletion removes the whole token.\n * - `'ref'` mode: `@<id>` references resolve to the object's label (via\n * {@link RefEditorExtensionOptions.getRef}); tokens accepted by the pluggable `match` regexp\n * render as neutral tags.\n * - `'email'` mode: RFC 5322 mailboxes render as tags labelled with the display name (falling\n * back to the address); the trailing comma separator is hidden inside the tag's atomic range.\n */\nexport const refEditor = ({ mode = 'ref', getRef, match }: RefEditorExtensionOptions = {}): Extension => {\n const buildRefDecorations = (state: EditorState) => {\n const deco = new RangeSetBuilder<Decoration>();\n const text = state.doc.toString();\n const tokenRegex = /\\S+/g;\n let tokenMatch: RegExpExecArray | null;\n while ((tokenMatch = tokenRegex.exec(text))) {\n const token = tokenMatch[0];\n const from = tokenMatch.index;\n const to = from + token.length;\n\n const refMatch = token.match(REF_REGEX);\n if (refMatch) {\n const ref = getRef?.(refMatch[1]);\n if (ref) {\n deco.add(\n from,\n to,\n Decoration.widget({\n widget: new RefWidget(ref.label, ref.hue ?? getHashHue(refMatch[1])),\n atomic: true,\n }),\n );\n }\n continue;\n }\n\n if (match?.test(token)) {\n deco.add(\n from,\n to,\n Decoration.widget({\n widget: new TokenWidget(token),\n atomic: true,\n }),\n );\n }\n }\n\n return deco.finish();\n };\n\n const buildEmailDecorations = (state: EditorState) => {\n const addrRegex = match ?? EMAIL_REGEX;\n const deco = new RangeSetBuilder<Decoration>();\n const text = state.doc.toString();\n // Segments are comma-separated; a segment's atomic range includes its trailing comma (and\n // following whitespace) so the separator never renders.\n const segmentRegex = /[^,]+(?:,\\s*)?|,\\s*/g;\n let segmentMatch: RegExpExecArray | null;\n while ((segmentMatch = segmentRegex.exec(text))) {\n const segment = segmentMatch[0];\n const commaIndex = segment.indexOf(',');\n const content = (commaIndex === -1 ? segment : segment.slice(0, commaIndex)).trim();\n if (!content) {\n continue;\n }\n const leading = segment.length - segment.trimStart().length;\n const from = segmentMatch.index + leading;\n const to = segmentMatch.index + segment.length;\n\n const nameAddr = content.match(NAME_ADDR_REGEX);\n if (nameAddr) {\n deco.add(\n from,\n to,\n Decoration.widget({\n widget: new RefWidget(nameAddr[1] || nameAddr[2], getHashHue(nameAddr[2])),\n atomic: true,\n }),\n );\n } else if (addrRegex.test(content)) {\n deco.add(\n from,\n to,\n Decoration.widget({\n widget: new TokenWidget(content),\n atomic: true,\n }),\n );\n }\n }\n\n return deco.finish();\n };\n\n const buildDecorations = mode === 'email' ? buildEmailDecorations : buildRefDecorations;\n\n return [\n styles,\n StateField.define<DecorationSet>({\n create: (state) => buildDecorations(state),\n update: (deco, tr) => {\n if (tr.docChanged || tr.effects.some((effect) => effect.is(refEditorRedecorate))) {\n return buildDecorations(tr.state);\n }\n\n return deco;\n },\n provide: (field) => [\n EditorView.decorations.from(field),\n EditorView.atomicRanges.of((view) => {\n const builder = new RangeSetBuilder<Decoration>();\n const cursor = view.state.field(field).iter();\n while (cursor.value) {\n if (cursor.value.spec.atomic) {\n builder.add(cursor.from, cursor.to, cursor.value);\n }\n cursor.next();\n }\n\n return builder.finish();\n }),\n ],\n }),\n ];\n};\n\nconst lineHeight = '30px';\n\n/**\n * NOTE: The outer container vertically aligns the inner text with content in the outer div.\n */\nconst container = (classNames: string, ...children: Domino<HTMLElement>[]) => {\n const inner = Domino.of('span')\n .classNames(mx('inline-flex h-[26px] border rounded-xs', classNames))\n .append(...children);\n return Domino.of('span').classNames('inline-flex h-[28px] align-middle').append(inner).root;\n};\n\n/**\n * Resolved reference (object reference or RFC 5322 mailbox), rendered as the object's label.\n */\nclass RefWidget extends WidgetType {\n constructor(\n private readonly _label: string,\n private readonly _hue: string,\n ) {\n super();\n }\n\n override eq(other: this) {\n return this._label === other._label && this._hue === other._hue;\n }\n\n override toDOM() {\n const { bg: fill, border, surface } = getStyles(this._hue);\n return container(\n border,\n Domino.of('span').classNames(mx('flex items-center px-1 text-black text-xs', fill)).text('@'),\n Domino.of('span')\n .classNames(mx('flex items-center px-1 text-subdued text-sm rounded-r-[3px]', surface))\n .text(this._label),\n );\n }\n}\n\n/**\n * Raw token accepted by the pluggable matcher (e.g. an email address).\n */\nclass TokenWidget extends WidgetType {\n constructor(private readonly _token: string) {\n super();\n }\n\n override eq(other: this) {\n return this._token === other._token;\n }\n\n override toDOM() {\n return container(\n 'border-separator',\n Domino.of('span').classNames('flex items-center px-1 text-subdued text-sm').text(this._token),\n );\n }\n}\n\nconst styles = EditorView.theme({\n '.cm-line': {\n lineHeight,\n },\n // Match the standard Input block size (md density): 2.5rem, 2rem on pointer-fine devices.\n '.cm-scroller': {\n alignItems: 'center',\n minHeight: '2.5rem',\n },\n '@media (pointer: fine)': {\n '.cm-scroller': {\n minHeight: '2rem',\n },\n },\n});\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { type PropsWithChildren } from 'react';\n\nimport { type Label, ScrollArea, type ThemedClassName, toLocalizedString, useTranslation } from '@dxos/react-ui';\nimport { composable, composableProps } from '@dxos/react-ui';\nimport { mx } from '@dxos/ui-theme';\n\nimport { translationKey } from '#translations';\n\nimport { SettingsFieldSet } from './SettingsFieldSet';\nimport { SettingsItem, SettingsPanel } from './SettingsItem';\n\nconst SETTINGS_ROOT_NAME = 'Settings.Root';\nconst SETTINGS_VIEWPORT_NAME = 'Settings.Viewport';\nconst SETTINGS_SECTION_NAME = 'Settings.Section';\n\n//\n// Root (headless — no styling, no scroll).\n//\n\ntype SettingsRootProps = ThemedClassName<PropsWithChildren>;\n\nconst SettingsRoot = ({ children, classNames }: SettingsRootProps) => {\n return <div className={mx('flex flex-col gap-2', classNames)}>{children}</div>;\n};\n\nSettingsRoot.displayName = SETTINGS_ROOT_NAME;\n\n//\n// Viewport (scroll area + padding + document layout).\n//\n\nconst SettingsViewport = composable<HTMLDivElement>(({ children, ...props }, forwardedRef) => {\n return (\n <ScrollArea.Root {...composableProps(props)} orientation='vertical' centered thin ref={forwardedRef}>\n <ScrollArea.Viewport classNames='px-4 pointer-coarse:px-2'>\n <div className='dx-document flex flex-col gap-2 py-4'>{children}</div>\n </ScrollArea.Viewport>\n </ScrollArea.Root>\n );\n});\n\nSettingsViewport.displayName = SETTINGS_VIEWPORT_NAME;\n\n//\n// Section (title + optional description + children with spacing).\n//\n\ntype SettingsSectionProps = PropsWithChildren<{\n title: Label;\n description?: Label;\n}>;\n\nconst SettingsSection = ({ title, description, children }: SettingsSectionProps) => {\n const { t } = useTranslation(translationKey);\n return (\n <>\n <h2 className='px-trim-md mt-trim-md text-xl'>{toLocalizedString(title, t)}</h2>\n {description && <p className='px-trim-md text-description'>{toLocalizedString(description, t)}</p>}\n <div className='w-full pt-trim-md space-y-trim-md'>{children}</div>\n </>\n );\n};\n\nSettingsSection.displayName = SETTINGS_SECTION_NAME;\n\n//\n// Settings\n//\n\nexport const Settings = {\n Root: SettingsRoot,\n Viewport: SettingsViewport,\n Section: SettingsSection,\n Panel: SettingsPanel,\n Item: SettingsItem,\n FieldSet: SettingsFieldSet,\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as SchemaAST from 'effect/SchemaAST';\nimport * as String from 'effect/String';\nimport React, { useCallback, useMemo } from 'react';\n\nimport { SchemaEx } from '@dxos/effect';\nimport { Input, Select } from '@dxos/react-ui';\n\nimport { getFormProperties, type SelectOption, detectFieldType, getSelectOptionsFromAst } from '../../util';\nimport { SettingsItem } from './SettingsItem';\n\n//\n// Types\n//\n\n/**\n * Props for a custom field renderer.\n * The renderer provides the control only; SettingsItem wrapper is handled by FieldSet.\n */\nexport type SettingsFieldProps<T = any> = {\n value: T;\n onChange: (value: T) => void;\n readonly?: boolean;\n};\n\n/**\n * Map of property names to either a custom field renderer or a nested field map for struct fields.\n * When a value type `T` is provided, the map shape is checked against the schema's value type.\n */\nexport type SettingsFieldMap<T extends Record<string, any> = Record<string, any>> = {\n [K in keyof T]?: NonNullable<T[K]> extends Record<string, any>\n ? SettingsFieldMap<NonNullable<T[K]>>\n : React.FC<SettingsFieldProps<T[K]>>;\n};\n\nexport type SettingsFieldSetProps<T extends Record<string, any> = Record<string, any>> = {\n /** Effect Schema for the settings object. */\n schema: { ast: SchemaAST.AST };\n\n /** Current settings values. */\n values: T;\n\n /** Callback when any value changes. Receives a new complete object. */\n onValuesChanged?: (values: T) => void;\n\n /** When true, all controls are disabled. */\n readonly?: boolean;\n\n /** Map of property names to custom field renderers. Nested objects map to struct sub-fields. */\n fieldMap?: SettingsFieldMap<T>;\n\n /** Control field visibility. Receives the dotted path (e.g. `'modelDefaults.edge'`) at every level. */\n visible?: (path: string, values: T) => boolean;\n\n /** Override the order of fields. Fields not listed are appended in schema order. Applied per scope. */\n sort?: string[];\n\n /** Internal: dot-path prefix used by recursive struct rendering. */\n pathPrefix?: string;\n};\n\n//\n// Component\n//\n\nexport const SettingsFieldSet = <T extends Record<string, any>>({\n schema,\n values,\n onValuesChanged,\n readonly,\n fieldMap,\n visible,\n sort,\n pathPrefix = '',\n}: SettingsFieldSetProps<T>) => {\n const properties = useMemo(() => {\n const props = getFormProperties(schema.ast);\n if (!sort) {\n return props;\n }\n const rank = (name: string) => {\n const idx = sort.indexOf(name);\n return idx === -1 ? Number.POSITIVE_INFINITY : idx;\n };\n return [...props].sort(({ name: a }, { name: b }) => rank(a.toString()) - rank(b.toString()));\n }, [schema, sort]);\n\n const handleChange = useCallback(\n (name: string, value: unknown) => {\n onValuesChanged?.({ ...values, [name]: value } as T);\n },\n [values, onValuesChanged],\n );\n\n return (\n <>\n {properties.map((property) => {\n const name = property.name.toString();\n const path = pathPrefix ? `${pathPrefix}.${name}` : name;\n if (visible && !visible(path, values)) {\n return null;\n }\n\n const entry = fieldMap?.[name as keyof typeof fieldMap] as\n | React.FC<SettingsFieldProps>\n | SettingsFieldMap\n | undefined;\n return (\n <SettingsFieldItem\n key={name}\n path={path}\n property={property}\n value={values[name]}\n onChange={(value) => handleChange(name, value)}\n readonly={readonly}\n customField={typeof entry === 'function' ? entry : undefined}\n nestedFieldMap={typeof entry === 'object' ? entry : undefined}\n visible={visible as (path: string, values: any) => boolean}\n sort={sort}\n />\n );\n })}\n </>\n );\n};\n\nSettingsFieldSet.displayName = 'Settings.FieldSet';\n\n//\n// Internal: render a single settings field.\n//\n\ntype SettingsFieldItemProps = {\n property: SchemaEx.SchemaProperty;\n path: string;\n value: any;\n onChange: (value: any) => void;\n readonly?: boolean;\n customField?: React.FC<SettingsFieldProps>;\n nestedFieldMap?: SettingsFieldMap;\n visible?: (path: string, values: any) => boolean;\n sort?: string[];\n};\n\nconst SettingsFieldItem = ({\n property,\n path,\n value,\n onChange,\n readonly,\n customField,\n nestedFieldMap,\n visible,\n sort,\n}: SettingsFieldItemProps) => {\n const { type } = property;\n const name = property.name.toString();\n const title = SchemaEx.getAnnotation<string>(SchemaAST.TitleAnnotationId)(type) ?? String.capitalize(name);\n const description = SchemaEx.getAnnotation<string>(SchemaAST.DescriptionAnnotationId)(type);\n\n // Custom field renderer.\n if (customField) {\n const CustomField = customField;\n return (\n <SettingsItem title={title} description={description}>\n <CustomField value={value} onChange={onChange} readonly={readonly} />\n </SettingsItem>\n );\n }\n\n const fieldType = detectFieldType(type);\n\n switch (fieldType) {\n case 'struct':\n return (\n <SettingsFieldSet\n schema={{ ast: type }}\n values={value ?? {}}\n onValuesChanged={onChange}\n readonly={readonly}\n fieldMap={nestedFieldMap}\n visible={visible}\n sort={sort}\n pathPrefix={path}\n />\n );\n\n case 'boolean':\n return (\n <SettingsItem title={title} description={description}>\n <Input.Switch disabled={readonly} checked={!!value} onCheckedChange={(checked) => onChange(!!checked)} />\n </SettingsItem>\n );\n\n case 'select': {\n const options = getSelectOptionsFromAst(type) ?? [];\n return (\n <SettingsItem title={title} description={description}>\n <Select.Root\n disabled={readonly}\n value={value == null ? '' : globalThis.String(value)}\n onValueChange={(selected) => {\n const matched = options.find((option) => globalThis.String(option.value) === selected);\n onChange(matched?.value ?? selected);\n }}\n >\n <Select.TriggerButton disabled={readonly} />\n <Select.Portal>\n <Select.Content>\n <Select.Viewport>\n {options.map((option: SelectOption) => (\n <Select.Option key={globalThis.String(option.value)} value={globalThis.String(option.value)}>\n {option.label ?? globalThis.String(option.value)}\n </Select.Option>\n ))}\n </Select.Viewport>\n <Select.Arrow />\n </Select.Content>\n </Select.Portal>\n </Select.Root>\n </SettingsItem>\n );\n }\n\n case 'string':\n return (\n <SettingsItem title={title} description={description}>\n <Input.TextInput disabled={readonly} value={value ?? ''} onChange={(event) => onChange(event.target.value)} />\n </SettingsItem>\n );\n\n case 'number':\n return (\n <SettingsItem title={title} description={description}>\n <Input.TextInput\n disabled={readonly}\n type='number'\n value={value ?? ''}\n onChange={(event) => {\n if (event.target.value === '') {\n onChange(undefined);\n return;\n }\n const parsed = Number(event.target.value);\n onChange(Number.isNaN(parsed) ? undefined : parsed);\n }}\n />\n </SettingsItem>\n );\n\n default:\n return null;\n }\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { type PropsWithChildren } from 'react';\n\nimport { Input, type Label, type ThemedClassName, toLocalizedString, useTranslation } from '@dxos/react-ui';\nimport { mx } from '@dxos/ui-theme';\n\nimport { translationKey } from '#translations';\n\nconst SETTINGS_PANEL_NAME = 'Settings.Panel';\nconst SETTINGS_ITEM_NAME = 'Settings.Item';\n\n//\n// Panel (bordered card container).\n//\n\ntype SettingsPanelProps = ThemedClassName<PropsWithChildren>;\n\nexport const SettingsPanel = ({ classNames, children }: SettingsPanelProps) => {\n return (\n <div className={mx('flex flex-col gap-3 p-trim-md border border-separator rounded-sm', classNames)}>{children}</div>\n );\n};\n\nSettingsPanel.displayName = SETTINGS_PANEL_NAME;\n\n//\n// Item (label + optional description + control, proper label semantics).\n//\n\ntype SettingsItemProps = PropsWithChildren<{\n title: Label;\n description?: Label;\n}>;\n\nexport const SettingsItem = ({ title, description = '', children }: SettingsItemProps) => {\n const { t } = useTranslation(translationKey);\n\n return (\n <Input.Root>\n <SettingsPanel classNames='grid grid-cols-1 md:grid-cols-[1fr_1fr] gap-x-trim-lg gap-y-0'>\n <Input.Label classNames='pb-trim-md text-base-fg text-lg md:col-span-2'>\n {toLocalizedString(title, t)}\n </Input.Label>\n <Input.DescriptionAndValidation>\n <Input.Description classNames='text-base text-description'>\n {toLocalizedString(description, t)}\n </Input.Description>\n </Input.DescriptionAndValidation>\n <div className='text-end py-1'>{children}</div>\n </SettingsPanel>\n </Input.Root>\n );\n};\n\nSettingsItem.displayName = SETTINGS_ITEM_NAME;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React from 'react';\n\nimport { Select } from '@dxos/react-ui';\n\nimport { type SettingsFieldProps } from './SettingsFieldSet';\n\nexport type SelectFieldOption = {\n value: string;\n label?: string;\n};\n\nexport type CreateSelectFieldOptions = {\n /** Options to display. Strings are used as both value and label. */\n options: ReadonlyArray<string | SelectFieldOption>;\n /** Label for the sentinel option that maps to `undefined`. Defaults to `'Default'`. Pass `null` to omit. */\n defaultLabel?: string | null;\n};\n\n/**\n * Factory for a `SettingsFieldSet` `fieldMap` entry that renders a Select control\n * over a fixed list of options, with an optional sentinel for `undefined`.\n */\nexport const createSelectField = ({\n options,\n defaultLabel = 'Default',\n}: CreateSelectFieldOptions): React.FC<SettingsFieldProps<string | undefined>> => {\n const normalized = options.map((option) => (typeof option === 'string' ? { value: option, label: option } : option));\n const hasDefault = defaultLabel !== null;\n // Per-instance sentinel avoids collisions with real option values; empty string when the\n // sentinel is omitted so `undefined` maps to a value Select.Root treats as \"no selection\".\n const sentinel = hasDefault ? `__default__${Math.random().toString(36).slice(2)}` : '';\n\n return ({ value, onChange, readonly }) => (\n <Select.Root\n disabled={readonly}\n value={value ?? sentinel}\n onValueChange={(next) => onChange(hasDefault && next === sentinel ? undefined : next)}\n >\n <Select.TriggerButton disabled={readonly} />\n <Select.Portal>\n <Select.Content>\n <Select.Viewport>\n {hasDefault && <Select.Option value={sentinel}>{defaultLabel}</Select.Option>}\n {normalized.map((option) => (\n <Select.Option key={option.value} value={option.value}>\n {option.label ?? option.value}\n </Select.Option>\n ))}\n </Select.Viewport>\n <Select.Arrow />\n </Select.Content>\n </Select.Portal>\n </Select.Root>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { RegistryContext } from '@effect-atom/atom-react';\nimport * as Match from 'effect/Match';\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\nimport React, { forwardRef, useCallback, useContext, useImperativeHandle, useMemo, useState } from 'react';\n\nimport {\n DXN,\n EID,\n Entity,\n Feed,\n Filter,\n Format,\n Obj,\n Query,\n QueryAST,\n Ref,\n type Registry,\n Type,\n View,\n} from '@dxos/echo';\nimport { SchemaEx } from '@dxos/effect';\nimport { invariant } from '@dxos/invariant';\nimport { useObject, useQuery } from '@dxos/react-client/echo';\nimport { IconButton, Input, Message, type ThemedClassName, useTranslation } from '@dxos/react-ui';\nimport { QueryForm, type QueryFormProps } from '@dxos/react-ui-components';\nimport { List } from '@dxos/react-ui-list';\nimport {\n ParentLabelAnnotation,\n ProjectionModel,\n VIEW_FIELD_LIMIT,\n createEchoChangeCallback,\n getTypeURIFromQuery,\n} from '@dxos/schema';\nimport { mx, osTranslations } from '@dxos/ui-theme';\n\nimport { translationKey } from '#translations';\n\nimport { FieldEditor } from '../FieldEditor';\nimport {\n Form,\n type FormFieldComponent,\n type FormFieldComponentProps,\n FormFieldLabel,\n type FormFieldMap,\n type FormRootProps,\n} from '../Form';\n\nexport type ViewEditorProps = ThemedClassName<\n {\n type?: Type.AnyEntity;\n view: View.View;\n mode?: 'schema' | 'tag';\n registry?: Registry.Registry;\n showHeading?: boolean;\n onQueryChanged?: (query: QueryAST.Query, target?: EID.EID) => void;\n onDelete?: (fieldId: string) => void;\n } & Pick<QueryFormProps, 'types' | 'tags'> &\n Pick<FormRootProps<any>, 'readonly' | 'db'>\n>;\n\n/**\n * Schema-based object form.\n */\nexport const ViewEditor = forwardRef<ProjectionModel | null, ViewEditorProps>(\n (\n {\n classNames,\n type,\n view,\n mode = 'schema',\n registry,\n db,\n readonly,\n showHeading = false,\n types,\n tags,\n onQueryChanged,\n onDelete,\n },\n forwardedRef,\n ) => {\n const atomRegistry = useContext(RegistryContext);\n const schemaReadonly = type == null || Type.getDatabase(type) == null;\n const { t } = useTranslation(translationKey);\n\n const projectionModel = useMemo(() => {\n if (!type) {\n return null;\n }\n const jsonSchema = type.jsonSchema;\n\n // Always use createEchoChangeCallback since the view is ECHO-backed.\n // Pass type only when mutable to allow schema mutations.\n const change = createEchoChangeCallback(view, Type.getDatabase(type) != null ? type : undefined);\n\n const model = new ProjectionModel({\n registry: atomRegistry,\n view,\n baseSchema: jsonSchema,\n change,\n });\n\n return model;\n }, [atomRegistry, type, view]);\n\n useImperativeHandle<ProjectionModel | null, ProjectionModel | null>(forwardedRef, () => projectionModel, [\n projectionModel,\n ]);\n\n const queueTarget = Match.value(view.query.ast).pipe(\n Match.when({ type: 'from' }, ({ from }) => {\n if (from._tag !== 'scope') {\n return undefined;\n }\n const feedScope = from.scopes.find((s) => s._tag === 'feed');\n return Option.fromNullable(feedScope).pipe(\n Option.map((s) => s.feedUri),\n Option.getOrUndefined,\n );\n }),\n Match.orElse(() => undefined),\n );\n\n const feeds = useQuery(db, Filter.type(Feed.Feed));\n\n const targetRef = useMemo(() => {\n if (!queueTarget) {\n return undefined;\n }\n const targetEid = EID.tryParse(queueTarget);\n const feed = feeds.find((feed) => {\n const feedEid = Feed.getQueueUri(feed);\n return feedEid != null && targetEid != null && EID.equals(feedEid, targetEid);\n });\n return feed ? Ref.fromURI(Entity.getURI(feed)) : undefined;\n }, [queueTarget, feeds]);\n\n const viewSchema = useMemo(() => {\n const base = Schema.Struct({\n query:\n mode === 'schema'\n ? Format.URL.annotations({ title: 'Record type' })\n : QueryAST.Query.annotations({ title: 'Query' }),\n });\n\n if (mode === 'tag') {\n return Schema.Struct({\n ...base.fields,\n // TODO(wittjosiah): Replace Type.Feed with Dataset.Dataset when Ref.Ref supports unions.\n target: Ref.Ref(Feed.Feed).pipe(\n Schema.annotations({ title: 'Target Feed' }),\n ParentLabelAnnotation.set(true),\n Schema.optional,\n ),\n }).pipe(Schema.mutable);\n }\n\n return base.pipe(Schema.mutable);\n }, [mode]);\n\n // TODO(burdon): Need to warn user of possible consequences of editing.\n // TODO(burdon): Settings should have domain name owned by user.\n const viewValues = useMemo(() => {\n // Schema mode edits a typename; show the version-less name of the type DXN.\n const typeUri = getTypeURIFromQuery(view.query.ast);\n const typeDxn = typeUri ? DXN.tryMake(typeUri) : undefined;\n return {\n query: mode === 'schema' ? (typeDxn ? DXN.getName(typeDxn) : (typeUri ?? '')) : view.query.ast,\n target: targetRef,\n };\n }, [mode, view.query.ast, targetRef]);\n\n const fieldMap = useMemo<FormFieldMap | undefined>(\n () => (mode === 'tag' ? customFields({ types, tags }) : undefined),\n [mode, types, tags],\n );\n\n const handleUpdate = useCallback(\n (values: any) => {\n const targetValue = values.target;\n let queueDxn: EID.EID | undefined;\n\n if (Ref.isRef(targetValue)) {\n const feedUri = targetValue.uri;\n const feed = feeds.find((feed) => Obj.getURI(feed) === feedUri);\n if (feed) {\n queueDxn = Feed.getQueueUri(feed);\n }\n }\n\n // TODO(wittjosiah): Deep-clone the AST to plain JS or ECHO proxy arrays become objects with numeric keys.\n // In schema mode, values.query is either a DXN name (static types) or a raw `echo:` EID\n // (db-backed types, which have no DXN). Preserve EIDs verbatim; wrap bare names as DXN.\n const query =\n mode === 'schema'\n ? Query.select(Filter.type(EID.isEID(values.query) ? (values.query as EID.EID) : DXN.make(values.query)))\n .ast\n : JSON.parse(JSON.stringify(values.query));\n onQueryChanged?.(query, queueDxn);\n },\n [onQueryChanged, mode, feeds],\n );\n\n const handleDelete = useCallback(\n (fieldId: string) => {\n invariant(!readonly);\n onDelete?.(fieldId);\n },\n [onDelete, readonly],\n );\n\n return (\n <div className={mx(classNames)}>\n {/* If readonly is set, then the callout is not needed. */}\n {schemaReadonly && !readonly && (\n <Message.Root valence='info' classNames='my-form-padding'>\n <Message.Title>{t('system-schema.description')}</Message.Title>\n </Message.Root>\n )}\n\n {/* TODO(burdon): Is the form read-only or just the schema? */}\n <Form.Root schema={viewSchema} values={viewValues} fieldMap={fieldMap} db={db} onValuesChanged={handleUpdate}>\n <Form.FieldSet />\n\n {type && (\n <>\n <FormFieldLabel label={t('fields.label')} asChild />\n <FieldList\n type={type}\n view={view}\n registry={registry}\n readonly={readonly}\n showHeading={showHeading}\n onDelete={handleDelete}\n />\n </>\n )}\n </Form.Root>\n </div>\n );\n },\n);\n\ntype FieldListProps = Omit<\n Pick<ViewEditorProps, 'type' | 'view' | 'registry' | 'readonly' | 'showHeading' | 'onDelete'>,\n 'type'\n> & {\n type: Type.AnyEntity;\n};\n\nconst FieldList = ({ type, view, registry, readonly, showHeading = false, onDelete }: FieldListProps) => {\n const atomRegistry = useContext(RegistryContext);\n const schemaReadonly = Type.getDatabase(type) == null;\n const { t } = useTranslation(translationKey);\n\n // Subscribe to view changes for reactivity.\n const [viewSnapshot] = useObject(view);\n\n const projectionModel = useMemo(() => {\n const jsonSchema = type.jsonSchema;\n\n // Always use createEchoChangeCallback since the view is ECHO-backed.\n // Pass type only when mutable to allow schema mutations.\n const change = createEchoChangeCallback(view, Type.getDatabase(type) != null ? type : undefined);\n\n const model = new ProjectionModel({\n registry: atomRegistry,\n view,\n baseSchema: jsonSchema,\n change,\n });\n\n return model;\n }, [atomRegistry, type, view]);\n\n const [expandedField, setExpandedField] = useState<View.FieldType['id']>();\n\n const handleAdd = useCallback(() => {\n invariant(!readonly);\n const field = projectionModel.createFieldProjection();\n setExpandedField(field.id);\n }, [projectionModel, readonly]);\n\n const handleToggleField = useCallback(\n (field: View.FieldType) => {\n setExpandedField((prevExpandedFieldId) => (prevExpandedFieldId === field.id ? undefined : field.id));\n },\n [readonly],\n );\n\n const handleDelete = useCallback(\n (fieldId: string) => {\n invariant(!readonly);\n if (fieldId === expandedField) {\n setExpandedField(undefined);\n }\n\n onDelete?.(fieldId);\n },\n [expandedField, onDelete, readonly],\n );\n\n const handleMove = useCallback(\n (fromIndex: number, toIndex: number) => {\n invariant(!readonly);\n Obj.update(view, (view) => {\n // NOTE(ZaymonFC): Using arrayMove here causes a race condition with the kanban model.\n const fields = [...view.projection.fields];\n const [moved] = fields.splice(fromIndex, 1);\n fields.splice(toIndex, 0, moved);\n view.projection.fields = fields;\n });\n },\n [view, readonly],\n );\n\n const handleClose = useCallback(() => setExpandedField(undefined), []);\n\n const handleHide = useCallback(\n (fieldId: string) => {\n setExpandedField(undefined);\n projectionModel.hideFieldProjection(fieldId);\n },\n [projectionModel],\n );\n\n const handleShow = useCallback(\n (property: string) => {\n setExpandedField(undefined);\n projectionModel.showFieldProjection(property as SchemaEx.JsonProp);\n },\n [projectionModel],\n );\n\n if (!viewSnapshot) {\n return null;\n }\n\n return (\n <List.Root<View.FieldType>\n items={viewSnapshot.projection.fields as View.FieldType[]}\n isItem={Schema.is(View.FieldSchema)}\n getId={(field) => field.id}\n onMove={readonly ? undefined : handleMove}\n readonly={readonly}\n >\n {({ items: fields }) => (\n <>\n {showHeading && <h3 className='text-sm'>{t('field-path.label')}</h3>}\n <div role='list' className='grid grid-cols-[min-content_1fr_min-content_min-content_min-content]'>\n {fields?.map((field) => {\n const hidden = field.visible === false;\n return (\n <List.Item<View.FieldType>\n key={field.id}\n item={field}\n classNames={'grid grid-cols-subgrid col-span-5'}\n aria-expanded={expandedField === field.id}\n >\n <div className='grid grid-cols-subgrid col-span-5 rounded-xs cursor-pointer min-h-10 dx-hover'>\n <List.ItemDragHandle disabled={readonly || schemaReadonly} />\n <List.ItemTitle classNames={hidden && 'text-subdued'} onClick={() => handleToggleField(field)}>\n {field.path}\n </List.ItemTitle>\n <List.ItemIconButton\n label={t(hidden ? 'show-field.label' : 'hide-field.label')}\n data-testid={hidden ? 'show-field-button' : 'hide-field-button'}\n icon={hidden ? 'ph--eye-closed--regular' : 'ph--eye--regular'}\n autoHide={false}\n disabled={readonly || (!hidden && projectionModel.getFields().length <= 1)}\n onClick={() => (hidden ? handleShow(field.path) : handleHide(field.id))}\n />\n {!readonly && (\n <>\n <List.ItemDeleteButton\n label={t('delete-field.label')}\n autoHide={false}\n disabled={readonly || schemaReadonly || viewSnapshot.projection.fields.length <= 1}\n onClick={() => handleDelete(field.id)}\n data-testid='field.delete'\n />\n <List.ItemIconButton\n iconOnly\n variant='ghost'\n label={t('toggle-expand.label', { ns: osTranslations })}\n icon={expandedField === field.id ? 'ph--caret-down--regular' : 'ph--caret-right--regular'}\n onClick={() => handleToggleField(field)}\n data-testid='field.toggle'\n />\n </>\n )}\n </div>\n {expandedField === field.id && !readonly && (\n <div className='col-span-full mt-1 mb-1 border border-separator rounded-md'>\n <FieldEditor\n readonly={readonly || schemaReadonly}\n registry={registry}\n projection={projectionModel}\n field={field}\n onSave={handleClose}\n />\n </div>\n )}\n </List.Item>\n );\n })}\n </div>\n {!readonly && !expandedField && (\n <div className='my-form-padding'>\n <IconButton\n icon='ph--plus--regular'\n label={t('add-property-button.label')}\n onClick={handleAdd}\n disabled={viewSnapshot.projection.fields.length >= VIEW_FIELD_LIMIT}\n classNames='w-full'\n />\n </div>\n )}\n </>\n )}\n </List.Root>\n );\n};\n\nconst customFields = ({\n types,\n tags,\n}: Pick<ViewEditorProps, 'types' | 'tags'>): Record<string, FormFieldComponent> => ({\n query: ({ type, readonly, label, getValue, onValueChange }: FormFieldComponentProps) => {\n const handleChange = useCallback<NonNullable<QueryFormProps['onChange']>>(\n (query) => onValueChange(type, query.ast),\n [onValueChange],\n );\n\n return (\n <Input.Root>\n <FormFieldLabel readonly={readonly} label={label} />\n <QueryForm initialQuery={getValue()} types={types} tags={tags} onChange={handleChange} />\n </Input.Root>\n );\n },\n});\n"],
5
- "mappings": ";AAIA,OAAOA,WAASC,eAAAA,eAAaC,aAAAA,YAAWC,WAAAA,WAASC,YAAAA,iBAAgB;AAEjE,SAASC,UAAAA,SAAQC,OAAAA,MAAoBC,QAAAA,aAAuB;AAC5D,SAASC,UAAAA,SAAQC,aAAaC,oBAAoB;AAElD,SAASC,OAAAA,YAAW;AACpB,SAASC,gBAAgBC,kBAAAA,wBAAsB;AAC/C,SAGEC,sCACAC,uBACK;AAEP,SAASC,kBAAAA,wBAAsB;;;ACd/B,SAASC,QAAQC,aAAaC,gBAAgB;AAevC,IAAMC,aAAa,CAAC,EAAEC,MAAMC,QAAQC,OAAA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OAAAA,EAAAA,2BAAkCpE;IAClCiE,SAAAA;;IAQhB,YAAA;EAEMe,CAAAA,CAAAA,CAAAA,CAAAA;;mBAKIC,CAAAA,EAAAA,OAAAA,KAAerC,OAAAA;UAElBsC,EAAAA,MAAAA,UAAAA,OAAAA,UAAAA,cAAAA,MAAAA;UAAc,eAAAtC,cAAA,CAAA,UAAA,cAAA,MAAA,MAAA,GAAA,GAAA;MAGjB;;WAE+CT,gBAAAA,QAAAA,cAAAA,QAAAA,MAAAA,MAAAA,gBAAAA,QAAAA,cAAAA,gBAAAA;;MAChCgD;QAAiCpE,gBAAAA,QAAAA,cAAAA,WAAAA;MAAOD,cAAMA,SAAAA;MAAMsE;;MAGrE,UAAA;IACF,CAAA,CAAA;;;",
6
- "names": ["React", "useCallback", "useEffect", "useMemo", "useState", "Filter", "Obj", "Type", "Format", "FormatEnums", "formatToType", "log", "useAsyncEffect", "useTranslation", "formatToAdditionalPropertyAttributes", "getFormatSchema", "translationKey", "Format", "GeoLocation", "TypeEnum", "parseValue", "type", "format", "value", "undefined", "parseScalar", "Boolean", "lowercaseValue", "toLowerCase", "Number", "cleaned", "replace", "num", "isNaN", "String", "Ref", "TypeFormat", "Percent", "Currency", "Markdown", "Error", "DateTime", "Date", "Time", "Timestamp", "date", "getTime", "GeoPoint", "parts", "split", "length", "lat", "parseFloat", "long", "toGeoPoint", "latitude", "longitude", "cellClassesForFieldType", "Duration", "JSON", "DID", "pathNotUniqueError", "path", "message", "SchemaAST", "SchemaEx", "detectFieldType", "ast", "isLiteralUnion", "isTypeLiteral", "_tag", "undefined", "getSelectOptionsFromAst", "types", "flatMap", "literalNode", "value", "literal", "title", "getAnnotation", "TitleAnnotationId", "label", "charAt", "toUpperCase", "slice", "String", "format", "formatDate", "Format", "GeoLocation", "TypeEnum", "formatForDisplay", "type", "value", "locale", "undefined", "formatScalar", "Boolean", "toLocaleString", "toUpperCase", "Number", "String", "Ref", "TypeFormat", "Percent", "Currency", "style", "currency", "minimumFractionDigits", "maximumFractionDigits", "Date", "error", "Time", "DateTime", "GeoPoint", "Array", "isArray", "length", "every", "isFinite", "latitude", "longitude", "fromGeoPoint", "formatForEditing", "date", "toISOString", "split", "Option", "SchemaAST", "Annotation", "SchemaEx", "unwrapOptional", "prop", "isOptional", "isUnion", "type", "defined", "types", "filter", "_tag", "length", "Union", "make", "annotations", "getRootFormProperties", "ast", "values", "isDiscriminatedUnion", "getFormProperties", "activeType", "getDiscriminatedType", "activeProps", "discriminators", "Set", "getDiscriminatingProps", "map", "name", "toString", "size", "fullType", "fullDiscriminatorProps", "has", "find", "candidate", "signatures", "getPropertySignatures", "rawByName", "Map", "hidden", "FormInputAnnotation", "getFromAst", "pipe", "getOrElse", "getProperties", "raw", "get", "isNestedType", "isArrayType", "Ref", "ReferenceAnnotationId", "SchemaEx", "getRefProps", "ast", "isArrayType", "elementType", "getArrayElementType", "isRefType", "typename", "findAnnotation", "isArray", "undefined", "Option", "SchemaAST", "React", "useCallback", "Ref", "SchemaEx", "useTranslation", "translationKey", "createContext", "Option", "Schema", "SchemaAST", "React", "useEffect", "useMemo", "useRef", "Annotation", "EchoAnnotation", "Type", "SchemaEx", "Column", "IconButton", "Input", "ScrollArea", "useMergeRefs", "useTranslation", "composable", "composableProps", "withColumn", "mx", "translationKey", "useControllableState", "useCallback", "useEffect", "useMemo", "useState", "SchemaEx", "log", "useDefaultValue", "validateSchema", "touched", "errors", "setErrors", "saving", "setSaving", "defaultValues", "defaultValuesProp", "values$", "setValues", "prop", "valuesProp", "defaultProp", "onChange", "setChanged", "setTouched", "validate", "values", "validatedValues", "onValidate", "flatMap", "valid", "schema", "setSchemaChanged", "schemaChanged", "onSave", "isValid", "changed", "onCancel", "error", "entries", "isTouched", "jsonPath", "undefined", "path", "value", "pathArray", "parsedValue", "newChanged", "prev", "onValuesChanged", "newValues", "Object", "length", "autoSave", "canSave", "getStatus", "onBlur", "onValueChange", "getValue", "head", "Array", "isArray", "obj", "copy", "fromEffectValidationPath", "result", "message", "useCallback", "useLayoutEffect", "addEventListener", "useKeyHandler", "elRef", "form", "handleKeyDown", "event", "key", "metaKey", "canSave", "onSave", "isValid", "autoSave", "el", "current", "format", "formatDate", "React", "Component", "Format", "Icon", "Input", "Tooltip", "inputTextLabel", "mx", "createContext", "useContext", "FormTooltipsContext", "useFormTooltips", "FormFieldLabel", "classNames", "label", "error", "readonly", "asChild", "path", "button", "onClick", "tooltips", "useFormTooltips", "Label", "Input", "labelNode", "className", "mx", "inputTextLabel", "div", "Tooltip", "Trigger", "content", "side", "Icon", "icon", "size", "span", "displayName", "formatStaticValue", "value", "format", "Format", "TypeFormat", "DateTime", "Date", "Time", "date", "Number", "isNaN", "getTime", "String", "pattern", "formatDate", "FormFieldWrapper", "props", "children", "layout", "jsonPath", "getStatus", "getValue", "status", "str", "Root", "validationValence", "p", "title", "DescriptionAndValidation", "Validation", "FormFieldErrorBoundary", "Component", "getDerivedStateFromError", "state", "undefined", "componentDidUpdate", "prevProps", "resetError", "render", "join", "setState", "Option", "React", "useMemo", "useState", "SchemaEx", "IconButton", "useTranslation", "mx", "translationKey", "Match", "Option", "Schema", "SchemaAST", "String", "React", "useMemo", "Annotation", "Format", "SchemaEx", "IconButton", "useTranslation", "mx", "translationKey", "FormField", "props", "type", "name", "path", "projection", "fieldMap", "fieldProvider", "readonly", "layout", "createTypename", "createOptionLabel", "createOptionIcon", "createInitialValuePath", "createFieldMap", "db", "useType", "schemaHook", "getOptions", "onCreate", "t", "useTranslation", "translationKey", "title", "SchemaEx", "getAnnotation", "TitleAnnotationId", "description", "DescriptionAnnotationId", "examples", "ExamplesAnnotationId", "label", "useMemo", "capitalize", "placeholder", "length", "fieldState", "useFormFieldState", "displayName", "jsonPath", "createJsonPath", "fieldProps", "format", "Format", "FormatAnnotation", "getFromAst", "pipe", "annotation", "getOrUndefined", "getValue", "CustomField", "React", "component", "schema", "make", "prop", "isArrayType", "ArrayField", "Field", "getFormField", "options", "getSelectOptions", "fieldProjections", "getFieldProjections", "fieldProjection", "find", "fp", "field", "selectOptions", "SelectField", "map", "option", "selectOption", "so", "id", "globalThis", "String", "value", "toString", "refProps", "getRefProps", "inline", "Annotation", "FormInlineAnnotation", "ast", "getOrElse", "isArray", "InlineRefField", "isCreateTarget", "typename", "RefField", "undefined", "isNestedType", "baseNode", "findNode", "isDiscriminatedUnion", "typeLiteral", "getDiscriminatedType", "isTypeLiteral", "FormFieldSet", "collapsible", "IconBlock", "div", "className", "mx", "IconButton", "variant", "density", "square", "iconOnly", "formatField", "withReturnType", "when", "TypeFormat", "Date", "DateField", "DateTime", "GeoPoint", "GeoPointField", "Markdown", "MarkdownField", "Text", "TextAreaField", "Time", "orElse", "_tag", "TextField", "NumberField", "BooleanField", "isLiteralUnion", "types", "literal", "filter", "v", "OptionsAnnotation", "createAnnotationHelper", "FormLayoutAnnotationId", "Symbol", "for", "FormLayoutAnnotation", "DEFAULT_LAYOUT_NAME", "Option", "Schema", "SchemaAST", "String", "React", "Fragment", "useMemo", "Annotation", "SchemaEx", "Input", "LayoutParseError", "Error", "_tag", "message", "position", "undefined", "TAG_RE", "ATTR_RE", "parseAttrs", "raw", "attrs", "lastIndex", "match", "exec", "key", "doubleQuoted", "singleQuoted", "bare", "tokenize", "input", "tokens", "cursor", "between", "slice", "index", "trim", "length", "JSON", "stringify", "slash", "name", "attrsRaw", "selfSlash", "push", "type", "selfClosing", "trailing", "requireAttr", "tag", "value", "parseInteger", "attr", "test", "Number", "parseInt", "parseLayout", "template", "parseNode", "token", "spanRaw", "span", "kind", "cols", "children", "closing", "root", "FORM_LAYOUT_NAME", "FormLayout", "schema", "template", "name", "DEFAULT_LAYOUT_NAME", "path", "readonly", "layout", "projection", "props", "annotated", "getOrUndefined", "FormLayoutAnnotation", "get", "source", "undefined", "LayoutParseError", "Object", "keys", "join", "tree", "useMemo", "parseLayout", "React", "RenderNode", "node", "basePath", "displayName", "kind", "div", "className", "style", "gridTemplateColumns", "cols", "children", "map", "child", "index", "Fragment", "key", "resolved", "resolveLayoutField", "type", "segments", "leafName", "title", "labelType", "span", "gridColumn", "FormFieldErrorBoundary", "LabelField", "make", "label", "capitalize", "FormField", "resolvePropertySignature", "ast", "length", "typeLiteral", "SchemaEx", "findNode", "isTypeLiteral", "prop", "getPropertySignatures", "find", "p", "globalThis", "String", "split", "baseType", "getBaseType", "annotations", "Reflect", "ownKeys", "getAnnotation", "TitleAnnotationId", "labelled", "isSome", "Annotation", "LabelAnnotation", "getFromAst", "getValue", "useFormFieldState", "value", "text", "getLabelWithSchema", "trim", "Input", "Root", "FormFieldLabel", "createJsonPath", "FORM_FIELDSET_NAME", "FormFieldSet", "label", "schema", "readonly", "path", "sort", "collapsible", "exclude", "projection", "layout", "layoutName", "DEFAULT_LAYOUT_NAME", "props", "t", "useTranslation", "translationKey", "values", "useFormValues", "properties", "useFormFieldSetProperties", "collapsed", "setCollapsed", "useState", "layouts", "getOrUndefined", "FormLayoutAnnotation", "get", "undefined", "body", "React", "FormLayout", "name", "map", "property", "toString", "FormFieldErrorBoundary", "key", "FormField", "type", "showBody", "content", "FormFieldLabel", "asChild", "classNames", "SchemaEx", "createJsonPath", "button", "IconButton", "variant", "density", "iconOnly", "icon", "iconClassNames", "mx", "onClick", "value", "div", "className", "displayName", "useMemo", "schemaProps", "getRootFormProperties", "ast", "filteredProps", "fieldProjections", "getFieldProjections", "hiddenProperties", "Set", "getHiddenProperties", "visibleProps", "filter", "prop", "has", "orderedProps", "fieldProjection", "fieldPath", "String", "field", "find", "push", "projectionPaths", "remainingProps", "a", "b", "indexOf", "omitId", "schemaOrType", "schema", "Type", "isType", "getSchema", "pipe", "omit", "omitHiddenFormFields", "properties", "getPropertySignatures", "ast", "hidden", "filter", "prop", "getOrElse", "EchoAnnotation", "FormInputAnnotation", "getFromAst", "type", "map", "name", "length", "FormContextProvider", "useFormContext", "createContext", "useFormValues", "componentName", "path", "defaultValue", "stablePath", "useMemo", "join", "undefined", "jsonPath", "SchemaEx", "createJsonPath", "form", "values", "onValueChange", "value", "getValue", "lastAppliedPathRef", "useRef", "useEffect", "current", "stringKeyword", "useFormFieldState", "Array", "isArray", "getStatus", "onBlur", "FormRoot", "children", "onSave", "onCancel", "props", "useFormHandler", "React", "FormTooltipsContext", "Provider", "tooltips", "displayName", "FORM_VIEWPORT_NAME", "FormViewport", "composable", "scroll", "gutter", "forwardedRef", "span", "Column", "Root", "classNames", "ScrollArea", "composableProps", "orientation", "centered", "padding", "thin", "ref", "Viewport", "FORM_CONTENT_NAME", "FormContent", "testId", "localRef", "mergedRef", "useMergeRefs", "useKeyHandler", "div", "role", "mx", "withColumn", "center", "data-testid", "FORM_FIELDSET_NAME", "FormFieldSet", "contextProps", "NaturalFormFieldSet", "FORM_LAYOUT_NAME", "FormLayout", "resolvedSchema", "NaturalFormLayout", "FORM_ACTIONS_NAME", "FormActions", "t", "useTranslation", "translationKey", "canSave", "readonly", "layout", "className", "IconButton", "icon", "iconEnd", "label", "onClick", "variant", "disabled", "FORM_SECTION_NAME", "FormSection", "description", "h2", "p", "FORM_SUBMIT_NAME", "FormSubmit", "FORM_ERROR_NAME", "FormError", "Input", "validationValence", "Validation", "Form", "Content", "Section", "FieldSet", "Layout", "Label", "FormFieldLabel", "Actions", "Submit", "Error", "ArrayField", "type", "path", "label", "readonly", "layout", "fieldProps", "inputProps", "props", "t", "useTranslation", "translationKey", "elementType", "SchemaEx", "getArrayElementType", "onValueChange", "values", "useFormValues", "displayName", "getDefaultObjectValue", "typeNode", "baseNode", "findNode", "isDiscriminatedUnion", "typeLiteral", "getDiscriminatedType", "isTypeLiteral", "Object", "fromEntries", "getFormProperties", "map", "prop", "defaultValue", "getDefaultAnnotation", "pipe", "annotation", "getOrUndefined", "name", "handleAdd", "useCallback", "isNestedType", "getDefaultValue", "handleDelete", "idx", "filter", "_", "i", "length", "renderItemAsObject", "Ref", "isRefType", "React", "div", "className", "FormFieldLabel", "createJsonPath", "asChild", "IconBlock", "inline", "icon", "onClick", "index", "isLast", "fieldField", "FormField", "autoFocus", "undefined", "key", "ast", "_tag", "f", "Error", "React", "useCallback", "Input", "BooleanField", "type", "readonly", "onValueChange", "props", "handleChange", "useCallback", "value", "React", "FormFieldWrapper", "Input", "Switch", "disabled", "checked", "onCheckedChange", "format", "formatDate", "React", "useCallback", "Format", "Input", "isoToLocalDateTime", "value", "date", "Date", "Number", "isNaN", "getTime", "formatDate", "localDateTimeToIso", "undefined", "toISOString", "DateField", "type", "format", "readonly", "placeholder", "_placeholder", "onValueChange", "onBlur", "_onBlur", "props", "handleSimpleChange", "useCallback", "next", "handleDateTimeChange", "iso", "React", "FormFieldWrapper", "Format", "TypeFormat", "div", "className", "Input", "classNames", "disabled", "TriggerIcon", "Time", "DateTime", "React", "useCallback", "useEffect", "useMemo", "useState", "GeoLocation", "Input", "useTranslation", "safeParseFloat", "translationKey", "GeoPointField", "type", "label", "jsonPath", "readonly", "layout", "getStatus", "getValue", "onValueChange", "onBlur", "t", "useTranslation", "translationKey", "status", "error", "geoPoint", "useMemo", "value", "GeoLocation", "fromGeoPoint", "longitudeText", "setLongitudeText", "useState", "longitude", "toString", "latitudeText", "setLatitudeText", "latitude", "useEffect", "location", "handleChange", "useCallback", "coordinateType", "setText", "event", "inputText", "target", "coord", "safeParseFloat", "undefined", "isNaN", "currentLocation", "newLocation", "newValue", "toGeoPoint", "React", "Input", "Root", "validationValence", "FormFieldLabel", "path", "asChild", "LatLng", "div", "className", "Label", "TextInput", "step", "min", "max", "disabled", "placeholder", "onChange", "latHem", "lngHem", "span", "Math", "abs", "toFixed", "useAtomValue", "React", "useCallback", "useMemo", "Obj", "Ref", "Type", "useType", "defaultUseType", "ReferenceAnnotationId", "SchemaEx", "DXN", "Button", "Icon", "Input", "useTranslation", "translationKey", "InlineRefField", "props", "type", "readonly", "label", "jsonPath", "layout", "db", "getValue", "onValueChange", "onCreate", "useType", "defaultUseType", "t", "useTranslation", "translationKey", "reference", "typename", "useMemo", "SchemaEx", "findAnnotation", "ReferenceAnnotationId", "undefined", "createType", "DXN", "make", "handleCreate", "useCallback", "newObject", "Ref", "React", "Input", "Root", "FormFieldLabel", "path", "InlineForm", "Button", "classNames", "disabled", "onClick", "Icon", "icon", "size", "span", "target", "useAtomValue", "atom", "typeUri", "Obj", "getTypeURI", "typeFromRegistry", "targetType", "getType", "formSchema", "omitId", "Type", "getSchema", "defaultValues", "handleChange", "values", "isValid", "changed", "changedPaths", "Object", "keys", "filter", "length", "update", "parts", "splitJsonPath", "setValue", "Form", "schema", "onValuesChanged", "Content", "FieldSet", "collapsible", "useAtomValue", "React", "useCallback", "useMemo", "Obj", "Ref", "createDocAccessor", "Button", "Icon", "Input", "useTranslation", "Editor", "useBasicMarkdownExtensions", "Text", "createDataExtensions", "translationKey", "editorClassNames", "MarkdownField", "type", "readonly", "label", "jsonPath", "placeholder", "layout", "db", "getStatus", "getValue", "onValueChange", "status", "error", "isRef", "Ref", "isRefType", "value", "renderEditor", "reference", "React", "RefMarkdownEditor", "CreateTextButton", "disabled", "onCreate", "ref", "StringMarkdownEditor", "onChange", "next", "renderStatic", "RefStaticText", "p", "className", "Input", "Root", "validationValence", "FormFieldLabel", "path", "Validation", "text", "useAtomValue", "useMemo", "atom", "content", "dataExtensions", "createDataExtensions", "id", "uri", "createDocAccessor", "extensions", "useBasicMarkdownExtensions", "Editor", "View", "classNames", "handleChange", "useCallback", "undefined", "t", "useTranslation", "translationKey", "handleClick", "add", "Obj", "make", "Text", "Button", "onClick", "Icon", "icon", "size", "span", "React", "useCallback", "useEffect", "useState", "Input", "safeParseFloat", "NumberField", "type", "readonly", "placeholder", "getValue", "onValueChange", "onBlur", "props", "raw", "setRaw", "useState", "v", "undefined", "String", "externalValue", "useEffect", "safeParseFloat", "handleChange", "useCallback", "event", "value", "target", "parsed", "handleBlur", "committed", "React", "FormFieldWrapper", "Input", "TextInput", "disabled", "onChange", "React", "useCallback", "useMemo", "useState", "Entity", "Filter", "Obj", "Query", "Ref", "Scope", "Type", "useQuery", "useType", "defaultUseType", "ANY_OBJECT_TYPENAME", "ReferenceAnnotationId", "SchemaEx", "DXN", "EID", "URI", "DxAnchor", "Button", "Icon", "Input", "useTranslation", "ParentLabelAnnotationId", "translationKey", "React", "forwardRef", "useCallback", "useState", "Popover", "useTranslation", "Combobox", "useSearchListResults", "translationKey", "ObjectPickerContent", "forwardRef", "options", "selectedIds", "createSchema", "createOptionLabel", "createOptionIcon", "createInitialValuePath", "createFieldMap", "onSelect", "onCreate", "props", "forwardedRef", "t", "useTranslation", "translationKey", "showForm", "setShowForm", "useState", "formInitialValue", "setFormInitialValue", "results", "query", "handleSearch", "useSearchListResults", "items", "handleFormSave", "useCallback", "values", "handleFormCancel", "handleKeyDown", "event", "key", "currentTarget", "querySelector", "stopPropagation", "preventDefault", "input", "currentQuery", "value", "React", "Combobox", "Content", "onKeyDownCapture", "ref", "Popover", "Viewport", "Form", "Root", "testId", "schema", "defaultValues", "fieldMap", "onSave", "onCancel", "FieldSet", "Actions", "Arrow", "Input", "placeholder", "autoFocus", "onValueChange", "List", "map", "option", "Item", "id", "label", "checked", "includes", "classNames", "CreateItem", "onCreateItemSelect", "ns", "text", "icon", "closeOnSelect", "displayName", "ObjectPicker", "Portal", "Trigger", "VirtualTrigger", "isRefSnapshot", "val", "findRefOption", "value", "options", "isRef", "Ref", "undefined", "valueEid", "EID", "tryParse", "uri", "valueSpaceId", "getSpaceId", "valueLocal", "toLocal", "find", "option", "optionEid", "id", "optionSpaceId", "equals", "defaultGetOptions", "results", "parentLabel", "getTypePlaceholder", "filter", "result", "Obj", "getParent", "map", "Entity", "getURI", "prefer", "parent", "labelEntity", "typename", "getTypename", "label", "getLabel", "defaultUseResults", "db", "useQuery", "Query", "select", "Filter", "nothing", "ANY_OBJECT_TYPENAME", "everything", "type", "DXN", "make", "from", "Scope", "space", "registry", "RefField", "props", "readonly", "jsonPath", "placeholder", "layout", "getStatus", "getValue", "createOptionLabel", "createOptionIcon", "createInitialValuePath", "createFieldMap", "useType", "defaultUseType", "useResults", "getOptions", "onCreate", "onValueChange", "t", "useTranslation", "translationKey", "status", "error", "useMemo", "SchemaEx", "findAnnotation", "ReferenceAnnotationId", "useCallback", "placeholderTypename", "segment", "split", "Boolean", "pop", "humanized", "charAt", "toUpperCase", "slice", "ns", "defaultValue", "ParentLabelAnnotationId", "handleGetValue", "item", "selectedIds", "createSchema", "open", "setOpen", "useState", "handleCreate", "values", "newObject", "handleUpdate", "ref", "fromURI", "URI", "handleSelect", "React", "Input", "Root", "validationValence", "FormFieldLabel", "path", "div", "p", "className", "DxAnchor", "key", "dxn", "rootclassname", "ObjectPicker", "onOpenChange", "Trigger", "asChild", "classNames", "TextInput", "readOnly", "Button", "span", "Icon", "size", "icon", "Portal", "Content", "omitHiddenFormFields", "omitId", "Type", "getSchema", "onSelect", "DescriptionAndValidation", "React", "useCallback", "Icon", "Input", "Select", "getStyles", "SelectField", "type", "readonly", "label", "jsonPath", "layout", "placeholder", "options", "getStatus", "getValue", "onValueChange", "status", "error", "value", "handleValueChange", "useCallback", "React", "Input", "Root", "validationValence", "FormFieldLabel", "path", "p", "find", "optionValue", "String", "Select", "TriggerButton", "classNames", "disabled", "Portal", "Content", "Viewport", "map", "secondaryLabel", "icon", "iconHue", "Option", "key", "span", "className", "Icon", "getIconHueStyles", "Arrow", "DescriptionAndValidation", "styles", "getStyles", "undefined", "fg", "React", "useCallback", "useEffect", "useRef", "useState", "PublicKey", "IconButton", "Input", "Tag", "useTranslation", "List", "HuePicker", "hues", "osTranslations", "translationKey", "SelectOptionField", "type", "readonly", "label", "jsonPath", "getStatus", "getValue", "onValueChange", "t", "useTranslation", "translationKey", "status", "error", "selected", "setSelectedId", "useState", "isNewOption", "setIsNewOption", "inputRef", "useRef", "options", "useEffect", "undefined", "randomHue", "usedHues", "Set", "map", "option", "color", "unusedHues", "hues", "filter", "hue", "has", "length", "Math", "floor", "random", "lastThree", "slice", "availableHues", "handleAdd", "useCallback", "newId", "PublicKey", "truncate", "newOption", "id", "title", "handleDelete", "newOptions", "handleMove", "from", "to", "removed", "splice", "handleClick", "current", "handleTitleChange", "e", "o", "target", "value", "handleKeyDown", "ev", "key", "handleColorChange", "focus", "React", "Input", "Root", "validationValence", "FormFieldLabel", "path", "div", "List", "items", "isItem", "_item", "onMove", "role", "className", "item", "Item", "classNames", "aria-expanded", "ItemDragHandle", "disabled", "ItemTitle", "onClick", "Tag", "palette", "IconButton", "iconOnly", "variant", "ns", "osTranslations", "icon", "Label", "TextInput", "placeholder", "ref", "onChange", "onKeyDown", "HuePicker", "React", "useCallback", "Input", "TextField", "type", "readonly", "placeholder", "onBlur", "onValueChange", "props", "handleChange", "useCallback", "event", "target", "value", "React", "FormFieldWrapper", "Input", "TextInput", "noAutoFill", "disabled", "onChange", "React", "useCallback", "Input", "TextAreaField", "type", "readonly", "placeholder", "onValueChange", "onBlur", "props", "handleChange", "useCallback", "event", "target", "value", "React", "FormFieldWrapper", "Input", "TextArea", "rows", "disabled", "onChange", "React", "Input", "mx", "safeParseFloat", "gridCols", "TupleField", "binding", "type", "readonly", "label", "jsonPath", "getStatus", "getValue", "onValueChange", "onBlur", "status", "error", "values", "React", "Input", "Root", "validationValence", "FormFieldLabel", "path", "div", "className", "mx", "length", "map", "prop", "TextInput", "key", "disabled", "value", "onChange", "event", "safeParseFloat", "target", "Schema", "Ref", "Tag", "META_TAGS_KEY", "withMetaTags", "schema", "omitId", "Struct", "Array", "Ref", "Tag", "pipe", "annotations", "title", "optional", "extend", "__dxlog_file", "props", "useState", "projection", "getFieldProjection", "field", "useEffect", "setProps", "useAsyncEffect", "registry", "Filter", "Type", "schemas", "subscription", "setReferenceSchema", "schema", "getTypename", "useMemo", "options", "React", "value", "Format", "TypeFormat", "label", "typename", "referenceSchema", "getFormProperties", "getSchema", "t", "useCallback", "setFieldSchema", "prev", "fieldSchema", "newSchema", "additionalProps", "type", "_props", "handleValidate", "view", "onSave", "requestAnimationFrame", "log", "fieldMap", "autoFocus", "readonly", "values", "exclude", "sort", "onValuesChanged", "onValidate", "handleSave", "onCancel", "handleCancel", "React", "useCallback", "useMemo", "Obj", "Ref", "Tag", "Type", "SchemaEx", "invariant", "HuePicker", "translationKey", "__dxlog_file", "createFieldMap", "handleChange", "onValueChange", "type", "React", "HuePicker", "value", "onReset", "handleReset", "meta", "getMeta", "object", "Obj", "tags", "values", "useMemo", "Type", "invariant", "isObject", "newObject", "db", "add", "make", "instanceOf", "Tag", "Ref", "useCallback", "hasTagsChange", "changedPaths", "path", "SchemaEx", "splitJsonPath", "nonTagPaths", "parts", "setValue", "createTypename", "createOptionIcon", "createOptionLabel", "translationKey", "createInitialValuePath", "onValuesChanged", "onCreate", "Function", "Option", "React", "useCallback", "useMemo", "Obj", "Tag", "Type", "useType", "SchemaEx", "invariant", "composable", "composableProps", "HuePicker", "FactoryAnnotation", "translationKey", "__dxlog_file", "meta", "object", "Obj", "tags", "values", "type", "getType", "typeFromRegistry", "formSchema", "useMemo", "Function", "Option", "invariant", "isObject", "factory", "getOrUndefined", "FactoryAnnotation", "get", "Type", "getSchema", "newObject", "db", "useCallback", "hasTagsChange", "changedPaths", "path", "SchemaEx", "splitJsonPath", "getMeta", "nonTagPaths", "parts", "value", "setValue", "createTypename", "createOptionIcon", "createOptionLabel", "Tag", "translationKey", "createInitialValuePath", "createFieldMap", "onValuesChanged", "onCreate", "composableProps", "forwardedRef", "React", "handleChange", "onValueChange", "HuePicker", "onReset", "handleReset", "SchemaAST", "React", "composable", "composableProps", "mx", "ObjectTreeImpl", "schema", "value", "props", "forwardedRef", "div", "role", "classNames", "ref", "Node", "ast", "label", "depth", "displayName", "ObjectTree", "unwrap", "isRefinement", "from", "isSuspend", "f", "isTransformation", "stripOptional", "isUnion", "nonUndef", "types", "filter", "t", "isUndefinedKeyword", "length", "inner", "isTypeLiteral", "isPlainObject", "childDepth", "Row", "kind", "propertySignatures", "map", "prop", "key", "String", "name", "type", "isTupleType", "Array", "isArray", "elemType", "rest", "item", "index", "unknownKeyword", "formatLeaf", "className", "style", "paddingInlineStart", "undefined", "span", "JSON", "stringify", "Prec", "React", "forwardRef", "useCallback", "useEffect", "useMemo", "useRef", "Filter", "Obj", "useQuery", "useThemeContext", "useTranslation", "Editor", "createBasicExtensions", "createThemeExtensions", "insertAtCursor", "keymap", "getHashHue", "translationKey", "RangeSetBuilder", "StateEffect", "StateField", "Decoration", "EditorView", "WidgetType", "Domino", "getHashHue", "getStyles", "mx", "REF_REGEX", "EMAIL_REGEX", "NAME_ADDR_REGEX", "formatMailbox", "name", "email", "refEditorRedecorate", "define", "refEditor", "mode", "getRef", "match", "buildRefDecorations", "state", "deco", "text", "doc", "toString", "tokenRegex", "tokenMatch", "exec", "token", "from", "index", "to", "length", "refMatch", "ref", "add", "widget", "RefWidget", "label", "hue", "atomic", "test", "TokenWidget", "finish", "buildEmailDecorations", "addrRegex", "segmentRegex", "segmentMatch", "segment", "commaIndex", "indexOf", "content", "slice", "trim", "leading", "trimStart", "nameAddr", "buildDecorations", "styles", "create", "update", "tr", "docChanged", "effects", "some", "effect", "is", "provide", "field", "decorations", "atomicRanges", "of", "view", "builder", "cursor", "iter", "value", "spec", "next", "lineHeight", "container", "classNames", "children", "inner", "append", "root", "_label", "_hue", "eq", "other", "toDOM", "bg", "fill", "border", "surface", "_token", "theme", "alignItems", "minHeight", "RefEditor", "forwardRef", "db", "type", "value", "readonly", "mode", "match", "getLabel", "getValues", "icon", "placeholder", "placeholderProp", "activateOnTyping", "numItems", "props", "forwardedRef", "t", "useTranslation", "translationKey", "themeMode", "useThemeContext", "getObjectLabel", "useCallback", "object", "Obj", "id", "filter", "useMemo", "Filter", "objects", "useQuery", "refs", "Map", "map", "label", "hue", "getHashHue", "refsRef", "useRef", "current", "controllerRef", "composedRef", "controller", "useEffect", "view", "dispatch", "effects", "refEditorRedecorate", "of", "getMenu", "text", "query", "replace", "toLowerCase", "matchesQuery", "includes", "some", "entry", "mailboxes", "flatMap", "items", "slice", "onSelect", "head", "insertMailbox", "formatMailbox", "detail", "insertAtCursor", "content", "focusOnly", "extensions", "createBasicExtensions", "readOnly", "lineWrapping", "createThemeExtensions", "slots", "scroller", "className", "refEditor", "getRef", "get", "Prec", "highest", "keymap", "key", "run", "state", "selection", "main", "line", "doc", "lineAt", "before", "from", "segment", "lastIndexOf", "trim", "NAME_ADDR_REGEX", "test", "EMAIL_REGEX", "token", "search", "React", "Editor", "Root", "trigger", "ref", "View", "classNames", "initialValue", "selectionEnd", "displayName", "mailbox", "lastComma", "insert", "changes", "to", "anchor", "length", "React", "ScrollArea", "toLocalizedString", "useTranslation", "composable", "composableProps", "mx", "translationKey", "SchemaAST", "String", "React", "useCallback", "useMemo", "SchemaEx", "Input", "Select", "React", "Input", "toLocalizedString", "useTranslation", "mx", "translationKey", "SETTINGS_PANEL_NAME", "SETTINGS_ITEM_NAME", "SettingsPanel", "classNames", "children", "div", "className", "displayName", "SettingsItem", "title", "description", "t", "Root", "Label", "DescriptionAndValidation", "Description", "SettingsFieldSet", "schema", "values", "onValuesChanged", "readonly", "fieldMap", "visible", "sort", "pathPrefix", "properties", "useMemo", "props", "getFormProperties", "ast", "rank", "name", "idx", "indexOf", "Number", "POSITIVE_INFINITY", "a", "b", "toString", "handleChange", "useCallback", "value", "React", "map", "property", "path", "entry", "SettingsFieldItem", "key", "onChange", "customField", "undefined", "nestedFieldMap", "displayName", "type", "title", "SchemaEx", "getAnnotation", "TitleAnnotationId", "capitalize", "description", "DescriptionAnnotationId", "CustomField", "SettingsItem", "fieldType", "detectFieldType", "Input", "Switch", "disabled", "checked", "onCheckedChange", "options", "getSelectOptionsFromAst", "Select", "Root", "globalThis", "String", "onValueChange", "selected", "matched", "find", "option", "TriggerButton", "Portal", "Content", "Viewport", "Option", "label", "Arrow", "TextInput", "event", "target", "parsed", "isNaN", "SETTINGS_ROOT_NAME", "SETTINGS_VIEWPORT_NAME", "SETTINGS_SECTION_NAME", "SettingsRoot", "children", "classNames", "React", "div", "className", "mx", "displayName", "SettingsViewport", "composable", "props", "forwardedRef", "ScrollArea", "Root", "composableProps", "orientation", "centered", "thin", "ref", "Viewport", "SettingsSection", "title", "description", "t", "useTranslation", "translationKey", "h2", "toLocalizedString", "p", "Settings", "Section", "Panel", "SettingsPanel", "Item", "SettingsItem", "FieldSet", "SettingsFieldSet", "React", "Select", "createSelectField", "options", "defaultLabel", "normalized", "map", "option", "value", "label", "hasDefault", "sentinel", "Math", "random", "toString", "slice", "onChange", "readonly", "Root", "disabled", "onValueChange", "next", "undefined", "TriggerButton", "Portal", "Content", "Viewport", "Option", "key", "Arrow", "RegistryContext", "Match", "Option", "Schema", "React", "forwardRef", "useCallback", "useContext", "useImperativeHandle", "useMemo", "useState", "DXN", "EID", "Entity", "Feed", "Filter", "Format", "Obj", "Query", "QueryAST", "Ref", "Type", "View", "invariant", "useObject", "useQuery", "IconButton", "Input", "Message", "useTranslation", "QueryForm", "List", "ParentLabelAnnotation", "ProjectionModel", "VIEW_FIELD_LIMIT", "createEchoChangeCallback", "getTypeURIFromQuery", "mx", "osTranslations", "translationKey", "__dxlog_file", "schemaReadonly", "Type", "getDatabase", "useTranslation", "translationKey", "projectionModel", "useMemo", "type", "jsonSchema", "registry", "atomRegistry", "view", "baseSchema", "change", "useImperativeHandle", "from", "undefined", "feedScope", "Match", "orElse", "useQuery", "Filter", "Feed", "targetRef", "queueTarget", "targetEid", "feedEid", "getQueueUri", "feed", "fromURI", "Entity", "mode", "QueryAST", "Query", "annotations", "title", "base", "fields", "target", "Ref", "ParentLabelAnnotation", "set", "Schema", "optional", "mutable", "typeUri", "getTypeURIFromQuery", "query", "DXN", "typeDxn", "getName", "tags", "types", "queueDxn", "targetValue", "find", "EID", "onQueryChanged", "feeds", "onDelete", "fieldId", "invariant", "React", "readonly", "valence", "mx", "schema", "viewSchema", "viewValues", "fieldMap", "db", "onValuesChanged", "label", "asChild", "showHeading", "FieldList", "viewSnapshot", "useObject", "createFieldProjection", "setExpandedField", "field", "useCallback", "expandedField", "Obj", "moved", "splice", "projection", "hideFieldProjection", "showFieldProjection", "property", "FieldSchema", "List", "getId", "onMove", "handleMove", "items", "div", "role", "className", "hidden", "key", "id", "classNames", "aria-expanded", "ItemDragHandle", "disabled", "handleToggleField", "data-testid", "icon", "autoHide", "onClick", "iconOnly", "osTranslations", "FieldEditor", "onSave", "handleClose", "IconButton", "customFields", "handleChange", "onValueChange", "initialQuery", "onChange"]
3
+ "sources": ["../../../src/annotations.ts", "../../../src/components/FieldEditor/FieldEditor.tsx", "../../../src/util/field.ts", "../../../src/util/formatting.ts", "../../../src/util/omit.ts", "../../../src/util/properties.ts", "../../../src/util/refs.ts", "../../../src/components/Form/meta-tags.ts", "../../../src/components/Form/FormControls.tsx", "../../../src/hooks/useAsyncFieldEffect.ts", "../../../src/hooks/useFormContext.ts", "../../../src/hooks/useFormHandler.ts", "../../../src/hooks/useKeyHandler.tsx", "../../../src/components/Form/Form.theme.ts", "../../../src/components/Form/FormFieldSet/FormFieldSet.tsx", "../../../src/components/Form/FormField/fields/ArrayField/ArrayField.tsx", "../../../src/components/Form/FormField/FormField.tsx", "../../../src/components/Form/FormField/FormFieldHeader.tsx", "../../../src/components/Form/FormField/FormRow.tsx", "../../../src/components/Form/FormField/presentation.tsx", "../../../src/components/Form/FormField/fields/AsyncSelectField/AsyncSelectField.tsx", "../../../src/components/Form/FormField/fields/SelectField/SelectField.tsx", "../../../src/components/Form/FormField/fields/AutofillField/AutofillField.tsx", "../../../src/components/Form/FormField/fields/TextField/TextField.tsx", "../../../src/components/Form/FormField/fields/BooleanField/BooleanField.tsx", "../../../src/components/Form/FormField/fields/ComboboxField/ComboboxField.tsx", "../../../src/components/Form/FormField/fields/DateField/DateField.tsx", "../../../src/components/Form/FormField/fields/GeoPointField/GeoPointField.tsx", "../../../src/components/Form/FormField/fields/MarkdownField/MarkdownField.tsx", "../../../src/components/Form/FormField/fields/NumberField/NumberField.tsx", "../../../src/components/Form/FormField/fields/PasswordField/PasswordField.tsx", "../../../src/components/Form/FormField/fields/RefField/RefField.tsx", "../../../src/components/ObjectPicker/ObjectPicker.tsx", "../../../src/components/Form/FormField/fields/RefField/InlineRefField.tsx", "../../../src/components/Form/FormField/fields/SelectOptionField/SelectOptionField.tsx", "../../../src/components/Form/FormField/fields/TextAreaField/TextAreaField.tsx", "../../../src/components/Form/FormField/fields/TupleField/TupleField.tsx", "../../../src/components/Form/FormLayout/FormLayout.tsx", "../../../src/components/Form/FormLayout/parser.ts", "../../../src/components/Form/FormFieldSet/FormFieldSetContainer.tsx", "../../../src/components/Form/Form.tsx", "../../../src/components/ObjectForm/ObjectForm.tsx", "../../../src/components/ObjectProperties/ObjectProperties.tsx", "../../../src/components/ObjectTree/ObjectTree.tsx", "../../../src/components/RefEditor/RefEditor.tsx", "../../../src/components/RefEditor/ref-editor-extension.ts", "../../../src/components/ViewEditor/ViewEditor.tsx"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Effect from 'effect/Effect';\n\nimport { createAnnotationHelper } from '@dxos/echo/internal';\n\n/** One selectable option produced by an {@link OptionsLookup}. */\nexport type OptionsLookupEntry = { value: string; label?: string; secondaryLabel?: string; icon?: string };\n\n/**\n * Loads a select field's options dynamically from a declared subset of the form values, so a select can\n * depend on a sibling field (e.g. publications for a typed handle). `deps` are the field names the loader\n * reads; the form re-runs it only when one of those values changes. The returned Effect must be\n * self-contained (`R = never`): it provides its own dependencies (network layer, etc.) in the closure.\n * Construct via {@link optionsLookup} for typed `deps`/`values`. Pass `{ combobox: true }` to render\n * an editable combobox (type-to-search) instead of a constrained select.\n */\nexport type OptionsLookup = {\n readonly deps: readonly string[];\n readonly load: (values: any) => Effect.Effect<readonly OptionsLookupEntry[], unknown>;\n readonly combobox?: boolean;\n};\n\nexport const OptionsLookupAnnotationId = Symbol.for('@dxos/schema/annotation/OptionsLookup');\nexport const OptionsLookupAnnotation = createAnnotationHelper<OptionsLookup>(OptionsLookupAnnotationId);\n\n/**\n * Builds an {@link OptionsLookup} typed against a schema's value type `Values`: `deps` is checked\n * against its field names, and `load` receives only those fields, narrowed. Pass `{ combobox: true }` to\n * render an editable combobox.\n */\nexport const optionsLookup =\n <Values>() =>\n <const Deps extends readonly (keyof Values & string)[]>(\n deps: Deps,\n load: (values: Pick<Values, Deps[number]>) => Effect.Effect<readonly OptionsLookupEntry[], unknown>,\n options?: { combobox?: boolean },\n ): OptionsLookup => ({ deps, load, combobox: options?.combobox });\n\n/**\n * Derives a (text) field's value from a declared subset of the form values, so a field can be pre-filled\n * from a sibling (e.g. a feed name fetched from a typed URL). `deps` are the field names the derivation\n * reads; the form re-runs it only when one of those changes. The returned Effect must be self-contained\n * (`R = never`); `undefined` means \"no value to fill\". The form pre-fills only while the user has not\n * typed their own value, so a manual edit is never clobbered. Construct via {@link autofill}.\n */\nexport type Autofill = {\n readonly deps: readonly string[];\n readonly derive: (values: any) => Effect.Effect<string | undefined, unknown>;\n};\n\nexport const AutofillAnnotationId = Symbol.for('@dxos/schema/annotation/Autofill');\nexport const AutofillAnnotation = createAnnotationHelper<Autofill>(AutofillAnnotationId);\n\n/** Builds an {@link Autofill} typed against a schema's value type `Values` (see {@link optionsLookup}). */\nexport const autofill =\n <Values>() =>\n <const Deps extends readonly (keyof Values & string)[]>(\n deps: Deps,\n derive: (values: Pick<Values, Deps[number]>) => Effect.Effect<string | undefined, unknown>,\n ): Autofill => ({ deps, derive });\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useCallback, useEffect, useMemo, useState } from 'react';\n\nimport { Filter, Obj, type Registry, Type, type View } from '@dxos/echo';\nimport { Format, FormatEnums, formatToType } from '@dxos/echo/Format';\nimport { SchemaEx } from '@dxos/effect';\nimport { log } from '@dxos/log';\nimport { useAsyncEffect, useTranslation } from '@dxos/react-ui';\nimport {\n type ProjectionModel,\n type PropertyType,\n formatToAdditionalPropertyAttributes,\n getFormatSchema,\n} from '@dxos/schema';\n\nimport { translationKey } from '#translations';\nimport { type FormFieldMap } from '#types';\n\nimport { getFormProperties } from '../../util';\nimport { Form, type FormRootProps, SelectField, SelectOptionField } from '../Form';\n\nexport type FieldEditorProps = Pick<FormRootProps<any>, 'readonly'> & {\n projection: ProjectionModel;\n field: View.FieldType;\n registry?: Registry.Registry;\n view?: Obj.Unknown;\n onSave: () => void;\n onCancel?: () => void;\n};\n\n/**\n * Displays a Form representing the metadata for a `Field` within a given `View`.\n */\nexport const FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCancel }: FieldEditorProps) => {\n const { t } = useTranslation(translationKey);\n const [props, setProps] = useState<PropertyType>(projection.getFieldProjection(field.id).props);\n useEffect(() => setProps(projection.getFieldProjection(field.id).props), [field, projection]);\n\n const [schemas, setSchemas] = useState<Type.Type[]>([]);\n useAsyncEffect(async () => {\n if (!registry) {\n return;\n }\n\n const subscription = registry\n .query(Filter.type(Type.Type))\n .subscribe((query) => setSchemas(query.results), { fire: true });\n\n // TODO(dmaretskyi): This shouldn't be needed.\n const schemas = await registry.query(Filter.type(Type.Type)).run();\n setSchemas(schemas);\n\n return () => subscription?.();\n }, [registry]);\n\n const [referenceSchema, setReferenceSchema] = useState<Type.Type>();\n useEffect(() => {\n // A React state setter invokes a function argument as an updater. A class-based `Type.Type` is\n // itself a function, so it must be stored via an updater lambda — passing it directly makes React\n // call it as `Organization(prev)`, throwing \"Class constructor … cannot be invoked without 'new'\".\n setReferenceSchema(() => schemas.find((schema) => Type.getTypename(schema) === props?.referenceSchema));\n }, [schemas, props?.referenceSchema]);\n\n // TODO(burdon): Need to wrap otherwise throws error:\n // Class constructor SchemaClass cannot be invoked without 'new'.\n const [{ fieldSchema }, setFieldSchema] = useState({ fieldSchema: getFormatSchema(props?.format) });\n\n const fieldMap = useMemo<FormFieldMap>(\n () => ({\n ['format' satisfies keyof PropertyType]: (props) => (\n <SelectField\n {...props}\n options={FormatEnums.filter((value) => value !== Format.TypeFormat.None).map((value) => ({\n value,\n label: t(`format.${value}.label`),\n }))}\n />\n ),\n ['referenceSchema' satisfies keyof PropertyType]: (props) => (\n <SelectField\n {...props}\n options={schemas\n .map((schema) => Type.getTypename(schema))\n .filter((typename): typename is string => typename != null)\n .map((typename) => ({\n value: typename,\n }))}\n />\n ),\n ['referencePath' satisfies keyof PropertyType]: (props) => (\n <SelectField\n {...props}\n options={\n referenceSchema\n ? getFormProperties(Type.getSchema(referenceSchema).ast)\n .sort((a, b) => a.name.toString().localeCompare(b.name.toString()))\n .map((p) => ({ value: p.name.toString() }))\n : []\n }\n />\n ),\n ['options' satisfies keyof PropertyType]: (props) => <SelectOptionField {...props} />,\n }),\n [t, schemas, referenceSchema],\n );\n\n const propIsNotType = useCallback(\n (props: SchemaEx.SchemaProperty[]) => props.filter((prop) => prop.name !== 'type'),\n [],\n );\n\n const handleValuesChanged = useCallback<NonNullable<FormRootProps<PropertyType>['onValuesChanged']>>(\n (_props) => {\n // TODO(Zaymon): Workout why old and new format values are the same sometimes even when selecting novel format values.\n setFieldSchema((prev) => {\n const fieldSchema = getFormatSchema(_props.format);\n if (prev.fieldSchema === fieldSchema) {\n return prev;\n }\n return { fieldSchema };\n });\n\n setReferenceSchema((prev) => {\n if (_props.referenceSchema !== (prev ? Type.getTypename(prev) : undefined)) {\n const newSchema = schemas.find((schema) => Type.getTypename(schema) === _props.referenceSchema);\n if (newSchema) {\n return newSchema;\n }\n }\n return prev;\n });\n\n setProps((props) => {\n const type = formatToType[_props.format as keyof typeof formatToType];\n const additionalProps =\n formatToAdditionalPropertyAttributes[_props.format as keyof typeof formatToAdditionalPropertyAttributes];\n if (props.type !== type) {\n return { ...props, ..._props, ...additionalProps, type } as PropertyType;\n }\n\n return _props as PropertyType;\n });\n },\n [schemas, props.format, props.referenceSchema],\n );\n\n const handleValidate = useCallback<NonNullable<FormRootProps<PropertyType>['onValidate']>>(\n ({ property }) => {\n if (property && projection.getFields().find((f) => f.path === property && f.path !== field.path)) {\n return [\n {\n path: 'property',\n message: `property is not unique: '${property}'`,\n },\n ];\n }\n },\n [projection.getFields(), field],\n );\n\n const handleSave = useCallback<NonNullable<FormRootProps<PropertyType>['onSave']>>(\n (props) => {\n if (view) {\n Obj.update(view, () => {\n projection.setFieldProjection({ field, props });\n });\n } else {\n projection.setFieldProjection({ field, props });\n }\n onSave();\n },\n [projection, field, view, onSave],\n );\n\n const handleCancel = useCallback<NonNullable<FormRootProps<PropertyType>['onCancel']>>(() => {\n onSave();\n // Need to defer to allow form to close.\n requestAnimationFrame(() => onCancel?.());\n }, [onSave]);\n\n if (!fieldSchema) {\n log.warn('invalid format', { props });\n return null;\n }\n\n return (\n <Form.Root<PropertyType>\n key={field.id}\n fieldMap={fieldMap}\n autoFocus\n readonly={readonly}\n schema={fieldSchema}\n values={props}\n filter={propIsNotType}\n sort={['property', 'format']}\n onValuesChanged={handleValuesChanged}\n onValidate={handleValidate}\n onSave={handleSave}\n onCancel={handleCancel}\n >\n <Form.Content>\n <Form.FieldSet />\n <Form.Actions />\n </Form.Content>\n </Form.Root>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { Format, GeoLocation, TypeEnum } from '@dxos/echo/Format';\nimport { type ValidationError } from '@dxos/schema';\n\n/**\n * Parse value by field value type.\n * Used by Table, Sheet, etc.\n * Handles various data types including booleans, numbers, dates, and strings.\n * Returns undefined for empty or null inputs.\n */\nexport type ParseProps = {\n type?: TypeEnum;\n format?: Format.TypeFormat;\n value: any;\n};\n\nexport const parseValue = ({ type, format, value }: ParseProps) => {\n if (value === undefined || value === null || value === '') {\n return undefined;\n }\n\n const parseScalar = (type?: TypeEnum) => {\n switch (type) {\n case TypeEnum.Boolean: {\n if (typeof value === 'string') {\n const lowercaseValue = value.toLowerCase();\n if (lowercaseValue === '0' || lowercaseValue === 'false') {\n return false;\n } else if (lowercaseValue === '1' || lowercaseValue === 'true') {\n return true;\n }\n }\n return Boolean(value);\n }\n\n case TypeEnum.Number: {\n const cleaned = typeof value === 'string' ? value.replace(/[^0-9.-]+/g, '') : value;\n const num = Number(cleaned);\n return Number.isNaN(num) ? null : num;\n }\n\n case TypeEnum.String:\n case TypeEnum.Ref:\n return String(value);\n\n default: {\n return value;\n }\n }\n };\n\n if (!format) {\n return parseScalar(type);\n }\n\n switch (format) {\n case Format.TypeFormat.Boolean:\n return parseScalar(TypeEnum.Boolean);\n\n case Format.TypeFormat.Number:\n case Format.TypeFormat.Percent:\n case Format.TypeFormat.Currency:\n return parseScalar(TypeEnum.Number);\n\n case Format.TypeFormat.String:\n case Format.TypeFormat.Markdown: {\n return parseScalar(TypeEnum.String);\n }\n\n case Format.TypeFormat.Ref:\n throw new Error(`unexpected format: ${Format.TypeFormat.Ref}`);\n\n case Format.TypeFormat.DateTime:\n case Format.TypeFormat.Date:\n case Format.TypeFormat.Time:\n case Format.TypeFormat.Timestamp: {\n const date = new Date(value as string | number);\n return isNaN(date.getTime()) ? null : date;\n }\n\n case Format.TypeFormat.GeoPoint: {\n // Parse string in format \"lat,long\" to GeoPoint [longitude, latitude].\n if (typeof value === 'string') {\n // Only keep digits, decimal points, minus signs, and commas.\n const cleaned = value.replace(/[^0-9.,-]+/g, '');\n const parts = cleaned.split(',');\n if (parts.length === 2) {\n const lat = parseFloat(parts[0]);\n const long = parseFloat(parts[1]);\n if (!isNaN(lat) && !isNaN(long)) {\n return GeoLocation.toGeoPoint({ latitude: lat, longitude: long });\n }\n }\n }\n\n return [0, 0];\n }\n\n default: {\n return value;\n }\n }\n};\n\n// TODO(burdon): Type and format.\nexport type CellClassesForFieldTypeProps = {\n type?: TypeEnum;\n format?: Format.TypeFormat;\n};\n\nexport const cellClassesForFieldType = ({ type, format }: CellClassesForFieldTypeProps): string[] | undefined => {\n switch (format || type) {\n case Format.TypeFormat.Markdown:\n return undefined;\n case Format.TypeFormat.Time:\n case Format.TypeFormat.Timestamp:\n case Format.TypeFormat.DateTime:\n case Format.TypeFormat.Date:\n case Format.TypeFormat.Duration:\n return ['font-mono', 'text-right'];\n case Format.TypeFormat.Currency:\n return ['text-right'];\n case Format.TypeFormat.JSON:\n case Format.TypeFormat.DID:\n return ['font-mono'];\n case TypeEnum.Number:\n case TypeEnum.Boolean:\n return ['text-right', 'font-mono'];\n case TypeEnum.String:\n return undefined;\n case TypeEnum.Ref:\n return undefined;\n default:\n return undefined;\n }\n};\n\n// TODO(ZaymonFC): How to do this with translations?\nexport const pathNotUniqueError = (path: string): ValidationError => ({\n path: 'path',\n message: `'${path}' is already present`,\n});\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { format as formatDate } from 'date-fns/format';\n\nimport { Format, GeoLocation, TypeEnum } from '@dxos/echo/Format';\n\ntype ValueFormatProps = {\n type: TypeEnum;\n format?: Format.TypeFormat | undefined;\n value: any;\n locale?: string | undefined;\n};\n\n/**\n * Format value by type.\n * Used by Table, Sheet, etc.\n */\n// TODO(burdon): Move to react-ui-form.\n// TODO(burdon): Formatting is different from kind format (e.g., percent is not a data format).\nexport const formatForDisplay = ({ type, format, value, locale = undefined }: ValueFormatProps): string => {\n const formatScalar = (type: TypeEnum) => {\n switch (type) {\n case TypeEnum.Boolean:\n return (value as boolean).toLocaleString().toUpperCase();\n case TypeEnum.Number:\n return value.toLocaleString(locale);\n case TypeEnum.String:\n case TypeEnum.Ref:\n return String(value);\n\n default: {\n return String(value);\n }\n }\n };\n\n if (!format) {\n return formatScalar(type);\n }\n\n switch (format) {\n case Format.TypeFormat.Boolean: {\n return formatScalar(TypeEnum.Boolean);\n }\n case Format.TypeFormat.Number: {\n return formatScalar(TypeEnum.Number);\n }\n case Format.TypeFormat.String:\n case Format.TypeFormat.Ref: {\n return formatScalar(TypeEnum.String);\n }\n case Format.TypeFormat.Percent: {\n return `${(value as number) * 100}%`;\n }\n case Format.TypeFormat.Currency: {\n // TODO(burdon): Get from property annotation.\n return (value as number).toLocaleString(locale, {\n style: 'currency',\n currency: 'USD',\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n });\n }\n case Format.TypeFormat.Date: {\n try {\n return formatDate(new Date(value as number), 'yyyy-MM-dd');\n } catch (error) {\n return 'Invalid Date';\n }\n }\n case Format.TypeFormat.Time: {\n try {\n return formatDate(new Date(value as number), 'HH:mm:ss');\n } catch (error) {\n return 'Invalid Time';\n }\n }\n case Format.TypeFormat.DateTime: {\n try {\n return formatDate(new Date(value as number), 'yyyy-MM-dd HH:mm:ss');\n } catch (error) {\n return 'Invalid DateTime';\n }\n }\n case Format.TypeFormat.GeoPoint: {\n if (value === null || value === undefined) {\n return '';\n }\n\n // For GeoPoint format [longitude, latitude].\n if (Array.isArray(value) && value.length >= 2 && value.every(Number.isFinite)) {\n const { latitude, longitude } = GeoLocation.fromGeoPoint(value as [number, number]);\n return `${latitude},${longitude}`;\n }\n\n return String(value);\n }\n default: {\n if (value === null || value === 'undefined') {\n return '';\n }\n return String(value);\n }\n }\n};\n\nexport const formatForEditing = ({ type, format, value, locale = undefined }: ValueFormatProps): string => {\n const formatScalar = (type: TypeEnum) => {\n switch (type) {\n case TypeEnum.Boolean:\n case TypeEnum.Number:\n case TypeEnum.String:\n case TypeEnum.Ref:\n return String(value);\n\n default:\n return String(value);\n }\n };\n\n if (!format) {\n return formatScalar(type);\n }\n\n switch (format) {\n case Format.TypeFormat.Boolean:\n case Format.TypeFormat.Number:\n case Format.TypeFormat.String:\n case Format.TypeFormat.Ref: {\n return formatScalar(type);\n }\n case Format.TypeFormat.Percent: {\n return String(value * 100);\n }\n case Format.TypeFormat.Currency: {\n return String(value);\n }\n case Format.TypeFormat.DateTime: {\n const date = new Date(value as number);\n return date.toISOString();\n }\n case Format.TypeFormat.Date: {\n const date = new Date(value as number);\n return date.toISOString().split('T')[0];\n }\n case Format.TypeFormat.Time: {\n const date = new Date(value as number);\n return date.toISOString().split('T')[1].split('.')[0];\n }\n case Format.TypeFormat.GeoPoint: {\n // Handle null or undefined\n if (value === null || value === undefined) {\n return '';\n }\n\n // For GeoPoint format [longitude, latitude].\n if (Array.isArray(value) && value.length >= 2 && value.every(Number.isFinite)) {\n const { latitude, longitude } = GeoLocation.fromGeoPoint(value as [number, number]);\n return `${latitude},${longitude}`;\n }\n\n return String(value);\n }\n\n default: {\n return String(value);\n }\n }\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { Annotation, Type } from '@dxos/echo';\n\n// TODO(burdon): Reconcile with @dxos/echo.\n// Distributive: applied per union member so `ExcludeId<A | B>` → `ExcludeId<A> | ExcludeId<B>` rather\n// than `Omit<InstanceType<A> | InstanceType<B>, 'id'>` (which would intersect away per-member narrowing).\nexport type ExcludeId<S extends Schema.Schema.AnyNoContext | Type.AnyEntity> = S extends Type.AnyEntity\n ? Omit<Type.InstanceType<S>, 'id'>\n : S extends Schema.Schema.AnyNoContext\n ? Omit<Schema.Schema.Type<S>, 'id'>\n : never;\n\n// TODO(burdon): Move to @dxos/schema (re-export here).\nexport const omitId = <S extends Schema.Schema.AnyNoContext | Type.AnyEntity>(\n schemaOrType: S,\n): Schema.Schema<ExcludeId<S>, ExcludeId<S>> => {\n const schema = Type.isType(schemaOrType)\n ? Type.getSchema(schemaOrType)\n : (schemaOrType as Schema.Schema.AnyNoContext);\n // Cast: `Schema.omit` cannot statically express the `ExcludeId<S>` result type, so the result is a\n // widened schema; the runtime shape matches the declared return type.\n return omitIdFromSchema(schema) as any;\n};\n\n/**\n * Removes the `id` field where present, preserving the schema's shape. Recurses into unions so a\n * discriminated (create) schema keeps its discriminant — `Schema.omit('id')` is a struct operation and\n * would otherwise flatten the union, breaking variant rendering. A no-op when there is no `id` (plain\n * create structs that never carried one).\n */\nconst omitIdFromSchema = (schema: Schema.Schema.AnyNoContext): Schema.Schema.AnyNoContext => {\n const ast = schema.ast;\n if (SchemaAST.isUnion(ast)) {\n return Schema.Union(...ast.types.map((type) => omitIdFromSchema(Schema.make(type))));\n }\n const hasId = SchemaAST.getPropertySignatures(ast).some((prop) => prop.name === 'id');\n return hasId ? schema.pipe(Schema.omit('id')) : schema;\n};\n\n/**\n * Drop fields annotated with `FormInputAnnotation.set(false)` from a schema so\n * the form's validator doesn't trip on required-but-hidden fields. Used by\n * the picker's inline create form, where a `FactoryAnnotation` typically\n * supplies the hidden values (e.g. a backing-object Ref) outside the form.\n */\nexport const omitHiddenFormFields = <S extends Schema.Schema.AnyNoContext>(schema: S): S => {\n const properties = SchemaAST.getPropertySignatures(schema.ast);\n const hidden = properties\n .filter((prop) => Option.getOrElse(Annotation.FormInputAnnotation.getFromAst(prop.type), () => true) === false)\n .map((prop) => prop.name as string);\n // Cast: omitting a dynamically-computed set of keys can't be expressed as the original `S`, but\n // the result is structurally a subset of `S` and callers treat it as `S`.\n return hidden.length === 0 ? schema : (schema.pipe(Schema.omit(...(hidden as [string, ...string[]]))) as any);\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Option from 'effect/Option';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { Annotation } from '@dxos/echo';\nimport { type AnyProperties } from '@dxos/echo/internal';\nimport { SchemaEx } from '@dxos/effect';\n\n/** The property's type with an optional `T | undefined` union unwrapped to its inner `T`. */\nconst unwrapOptional = (prop: SchemaAST.PropertySignature): SchemaAST.AST => {\n if (!prop.isOptional || !SchemaAST.isUnion(prop.type)) {\n return prop.type;\n }\n // Drop the `undefined` member, preserving the remaining union (don't collapse `A | B | undefined` to `A`).\n const defined = prop.type.types.filter((type) => type._tag !== 'UndefinedKeyword');\n if (defined.length === 0) {\n return prop.type;\n }\n return defined.length === 1 ? defined[0] : SchemaAST.Union.make(defined, prop.type.annotations);\n};\n\n/**\n * Resolve the properties to render for a field set's *root* schema, given the current form values.\n *\n * A top-level discriminated union is rendered flat: the fields of the member selected by the current\n * discriminator value, with the discriminator field keeping the union-wide set of literals so it stays\n * switchable. (`SchemaAST.getPropertySignatures` on a union returns only the common discriminator, so a\n * union root would otherwise render just that one field.) Non-union roots are unchanged. Nested unions are\n * unaffected — those are expanded per-field by `FormField`, which passes a single-member type literal here.\n */\nexport const getRootFormProperties = (\n ast: SchemaAST.AST,\n values: AnyProperties | undefined,\n): SchemaEx.SchemaProperty[] => {\n if (!SchemaEx.isDiscriminatedUnion(ast)) {\n return getFormProperties(ast);\n }\n\n const activeType = SchemaEx.getDiscriminatedType(ast, values ?? {});\n if (!activeType) {\n return getFormProperties(ast);\n }\n const activeProps = getFormProperties(activeType);\n\n const discriminators = new Set((SchemaEx.getDiscriminatingProps(ast) ?? []).map((name) => name.toString()));\n if (discriminators.size === 0) {\n return activeProps;\n }\n // The matched member types its discriminator as a single literal; swap in the union-wide literal so the\n // field renders as a full select rather than a fixed value.\n const fullType = SchemaEx.getDiscriminatedType(ast, {});\n const fullDiscriminatorProps = fullType ? getFormProperties(fullType) : activeProps;\n return activeProps.map((prop) =>\n discriminators.has(prop.name.toString())\n ? (fullDiscriminatorProps.find((candidate) => candidate.name === prop.name) ?? prop)\n : prop,\n );\n};\n\n/**\n * Get the property types of an AST and filter out properties that are not form inputs.\n *\n * The `FormInputAnnotation` is read from the raw property signature's AST (before\n * `encodedBoundAST` is applied by `SchemaEx.getProperties`), because `encodedBoundAST` strips\n * annotations from non-keyword inner types (e.g., `Schema.Struct`, `Schema.Array`).\n * Without this, fields like `Routine.input` (a JsonSchema struct) annotated\n * `FormInputAnnotation.set(false)` would still render in the form.\n *\n * For optional fields, `prop.type` is the union `T | undefined` — the annotation\n * lives on the inner `T`. Unwrap before reading so that the conventional pattern\n * `Schema.String.pipe(FormInputAnnotation.set(false), Schema.optional)` works.\n *\n * Container properties (nested structs, unions, arrays) keep their *raw* AST rather than\n * the `encodedBoundAST` produced by `SchemaEx.getProperties`. `encodedBoundAST` strips annotations\n * from non-keyword inner types, so a `FormInputAnnotation` nested beneath an encoded container\n * (e.g. `RouteLeg.geometry`, reached via `Segment → details → routes → Route → legs`) would\n * otherwise be lost by the time recursion reaches it. Leaf/transformation fields stay encoded\n * (e.g. a `DateTime` still renders as its encoded string input).\n */\nexport const getFormProperties = (ast: SchemaAST.AST): SchemaEx.SchemaProperty[] => {\n const signatures = SchemaAST.getPropertySignatures(ast);\n const rawByName = new Map<PropertyKey, SchemaAST.AST>(signatures.map((prop) => [prop.name, unwrapOptional(prop)]));\n const hidden = new Set(\n signatures\n .filter(\n (prop) =>\n Annotation.FormInputAnnotation.getFromAst(unwrapOptional(prop)).pipe(Option.getOrElse(() => true)) === false,\n )\n .map((prop) => prop.name),\n );\n return SchemaEx.getProperties(ast)\n .filter((prop) => !hidden.has(prop.name))\n .map((prop) => {\n const raw = rawByName.get(prop.name);\n return raw && (SchemaEx.isNestedType(raw) || SchemaEx.isArrayType(raw)) ? { ...prop, type: raw } : prop;\n });\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as SchemaAST from 'effect/SchemaAST';\n\nimport { Ref } from '@dxos/echo';\nimport { ReferenceAnnotationId, type ReferenceAnnotationValue } from '@dxos/echo/Annotation';\nimport { SchemaEx } from '@dxos/effect';\n\ntype RefProps = {\n ast: SchemaAST.AST;\n isArray: boolean;\n typename?: string;\n};\n\nexport const getRefProps = (ast: SchemaAST.AST): RefProps | undefined => {\n // Array of references.\n if (SchemaEx.isArrayType(ast)) {\n const elementType = SchemaEx.getArrayElementType(ast);\n if (elementType) {\n if (Ref.isRefType(elementType)) {\n const typename = SchemaEx.findAnnotation<ReferenceAnnotationValue>(\n elementType,\n ReferenceAnnotationId,\n )?.typename;\n return { ast: elementType, isArray: true, typename };\n }\n }\n }\n\n // Direct reference.\n if (Ref.isRefType(ast)) {\n const typename = SchemaEx.findAnnotation<ReferenceAnnotationValue>(ast, ReferenceAnnotationId)?.typename;\n return { ast, isArray: false, typename };\n }\n\n return undefined;\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Ref, Tag } from '@dxos/echo';\n\nimport { omitId } from '../../util';\n\n/**\n * Form-field key for the synthetic meta-tags array spliced into property/create forms.\n *\n * An object's tags live in `Obj.getMeta(obj).tags` (off-schema), so the form surfaces them as an\n * extra field rather than reading the schema. The key is underscore-prefixed so it never collides\n * with a `tags` field an object schema declares itself — e.g. a `TagIndex` record on a feed host,\n * whose `tags` is `Record<tagId, objectId[]>`, not an array. Extending such a schema with a `tags`\n * array threw \"overlapping types at path: [\\\"tags\\\"]\"; the disjoint `_tags` key avoids it. The\n * human-facing label is restored via the `title` annotation on {@link withMetaTags}.\n */\nexport const META_TAGS_KEY = '_tags';\n\n/**\n * Splices the synthetic meta-tags array (an object's `meta.tags`, surfaced as {@link Tag} refs) onto\n * a schema for editing and drops `id`. Keyed by {@link META_TAGS_KEY} so it never collides with a\n * `tags` field the schema declares itself.\n */\nexport const withMetaTags = (schema: Schema.Schema.AnyNoContext) =>\n omitId(\n Schema.Struct({\n [META_TAGS_KEY]: Schema.Array(Ref.Ref(Tag.Tag)).pipe(Schema.annotations({ title: 'Tags' }), Schema.optional),\n }).pipe(Schema.extend(schema)),\n );\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { type PropsWithChildren, useRef } from 'react';\n\nimport { type AnyProperties } from '@dxos/echo/internal';\nimport {\n Column,\n type ColumnRootProps,\n IconButton,\n type IconButtonProps,\n Input,\n ScrollArea,\n type ThemedClassName,\n composable,\n composableProps,\n useMergeRefs,\n useTranslation,\n withColumn,\n} from '@dxos/react-ui';\nimport { MarkdownView } from '@dxos/react-ui-markdown';\nimport { mx } from '@dxos/ui-theme';\nimport { type Merge } from '@dxos/util';\n\nimport { translationKey } from '#translations';\n\nimport {\n FormContextProvider,\n type FormContextValue,\n type FormHandlerProps,\n type FormUpdateMeta,\n useFormContext,\n useFormHandler,\n useKeyHandler,\n} from '../../hooks';\nimport { formTheme } from './Form.theme';\nimport { FormFieldSet, type FormFieldSetProps as NaturalFormFieldSetProps } from './FormFieldSet';\nimport { FormLayout, type FormLayoutProps as NaturalFormLayoutProps } from './FormLayout';\n\n//\n// Root\n//\n\nexport type FormRootProps<T extends AnyProperties = AnyProperties> = Merge<\n PropsWithChildren<{\n /**\n * Called when the form is submitted and passes validation.\n */\n onSave?: (values: T, meta: FormUpdateMeta<T>) => void;\n\n /**\n * Called when the form is canceled to abandon/undo any pending changes.\n */\n onCancel?: () => void;\n }>,\n Omit<FormContextValue<T>, 'form'>,\n Pick<FormHandlerProps<T>, 'schema' | 'autoSave' | 'values' | 'defaultValues' | 'onValidate' | 'onValuesChanged'>,\n Omit<NaturalFormFieldSetProps<T>, 'schema' | 'path'>\n>;\n\n// `variant` (from FormContextValue) flows through `...props` into the context for all parts to read.\nexport const FormRoot = <T extends AnyProperties = AnyProperties>({\n children,\n schema,\n values,\n onSave,\n onCancel,\n ...props\n}: FormRootProps<T>) => {\n const form = useFormHandler({ schema, values, onSave, onCancel, ...props });\n\n return (\n <FormContextProvider form={form} {...props}>\n {children}\n </FormContextProvider>\n );\n};\n\nFormRoot.displayName = 'Form.Root';\n\n//\n// Viewport\n//\n\nconst FORM_VIEWPORT_NAME = 'Form.Viewport';\n\nexport type FormViewportProps = {\n scroll?: boolean;\n gutter?: ColumnRootProps['gutter'];\n};\n\n// The viewing window: owns the gutter Column (chrome/side-padding).\n// Content-height by default; `scroll` makes it fill its parent and scroll (the gutter then hosts the scrollbar).\nexport const FormViewport = composable<HTMLDivElement, FormViewportProps>(\n ({ children, scroll, gutter = 'sm', ...props }, forwardedRef) => {\n const { variant = 'default' } = useFormContext(FORM_VIEWPORT_NAME);\n const styles = formTheme.styles({ variant });\n // Span the full width when nested inside another Column grid (e.g. Card.Root)\n // instead of landing in a single narrow track.\n const span = '[.dx-column-root_&]:col-span-full';\n if (scroll) {\n return (\n <Column.Root gutter={gutter} classNames={['dx-expander', span]}>\n <ScrollArea.Root\n {...composableProps(props, { classNames: styles.viewport() })}\n orientation='vertical'\n centered\n padding\n thin\n ref={forwardedRef}\n >\n <ScrollArea.Viewport>{children}</ScrollArea.Viewport>\n </ScrollArea.Root>\n </Column.Root>\n );\n }\n\n return (\n <Column.Root\n {...composableProps(props, { classNames: ['w-full min-w-0', span, styles.viewport()] })}\n gutter={gutter}\n ref={forwardedRef}\n >\n {children}\n </Column.Root>\n );\n },\n);\n\nFormViewport.displayName = FORM_VIEWPORT_NAME;\n\n//\n// Content\n//\n\nconst FORM_CONTENT_NAME = 'Form.Content';\n\nexport type FormContentProps = ThemedClassName<PropsWithChildren<{}>>;\n\n// The viewed body: centered in the viewport's gutter. Pure body — the gutter Column is owned by `Form.Viewport`.\nexport const FormContent = composable<HTMLDivElement, FormContentProps>(({ children, ...props }, forwardedRef) => {\n const { form, testId, variant = 'default' } = useFormContext(FORM_CONTENT_NAME);\n const styles = formTheme.styles({ variant });\n const localRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMergeRefs([forwardedRef, localRef]);\n useKeyHandler(localRef, form);\n\n return (\n <div\n {...composableProps(props, {\n role: 'form',\n classNames: mx(withColumn.center(), 'flex flex-col w-full dx-document', styles.content()),\n })}\n data-testid={testId}\n ref={mergedRef}\n >\n {children}\n </div>\n );\n});\n\nFormContent.displayName = FORM_CONTENT_NAME;\n\n//\n// FieldSet\n//\n\nconst FORM_FIELDSET_NAME = 'Form.FieldSet';\n\nexport type FormFieldSetControllerProps = ThemedClassName<NaturalFormFieldSetProps<any>>;\n\n/** Context-reading binding for `Form.FieldSet`: pulls the schema + field context off the form and delegates to {@link FormFieldSet}. */\nexport const FormFieldSetController = ({ classNames, ...props }: FormFieldSetControllerProps) => {\n const { form, variant = 'default', ...contextProps } = useFormContext(FORM_FIELDSET_NAME);\n const styles = formTheme.styles({ variant });\n return (\n <FormFieldSet\n schema={form.schema}\n classNames={styles.fieldSet({ class: classNames })}\n {...contextProps}\n {...props}\n />\n );\n};\n\nFormFieldSetController.displayName = FORM_FIELDSET_NAME;\n\n//\n// Layout\n//\n\nconst FORM_LAYOUT_NAME = 'Form.Layout';\n\nexport type FormLayoutProps = Omit<NaturalFormLayoutProps, 'schema'> & { schema?: NaturalFormLayoutProps['schema'] };\n\n/** Context-reading binding for `Form.Layout`: resolves the schema (prop or form) and delegates to {@link FormLayout}. */\nexport const FormLayoutController = ({ schema, ...props }: FormLayoutProps) => {\n const { form, ...contextProps } = useFormContext(FORM_LAYOUT_NAME);\n const resolvedSchema = schema ?? form.schema;\n if (!resolvedSchema) {\n return null;\n }\n\n return <FormLayout schema={resolvedSchema} {...contextProps} {...props} />;\n};\n\nFormLayoutController.displayName = FORM_LAYOUT_NAME;\n\n//\n// Actions\n//\n\nconst FORM_ACTIONS_NAME = 'Form.Actions';\n\nexport type FormActionsProps = ThemedClassName<{}>;\n\nexport const FormActions = ({ classNames }: FormActionsProps) => {\n const { t } = useTranslation(translationKey);\n const {\n form: { canSave, onSave, onCancel },\n readonly,\n layout,\n } = useFormContext(FORM_ACTIONS_NAME);\n\n if (readonly || layout === 'static') {\n return null;\n }\n\n // TODO(burdon): Currently onCancel is a no-op; implement \"revert values\".\n // Deprecate FormSubmit ans use FormActions without Cancel button if no callback is supplied.\n\n return (\n <div className={mx(withColumn.center(), formTheme.styles().actions(), classNames)}>\n {onCancel && (\n <IconButton\n icon='ph--x--regular'\n iconEnd\n label={t('cancel-button.label')}\n onClick={onCancel}\n data-testid='cancel-button'\n />\n )}\n {onSave && (\n <IconButton\n type='submit'\n variant='primary'\n disabled={!canSave}\n icon='ph--check--regular'\n iconEnd\n label={t('save-button.label')}\n onClick={onSave}\n data-testid='save-button'\n />\n )}\n </div>\n );\n};\n\nFormActions.displayName = FORM_ACTIONS_NAME;\n\n//\n// Section\n//\n\nconst FORM_SECTION_NAME = 'Form.Section';\n\nexport type FormSectionProps = ThemedClassName<{\n title?: string;\n description?: string;\n}>;\n\nexport const FormSection = composable<HTMLDivElement, FormSectionProps>(\n ({ children, title, description, ...props }, forwardedRef) => {\n const { variant = 'default' } = useFormContext(FORM_SECTION_NAME);\n const styles = formTheme.styles({ variant });\n return (\n <div {...composableProps(props, { classNames: styles.section() })} ref={forwardedRef}>\n {(title || description) && (\n <div className={styles.sectionHeader()}>\n {title && <h2 className={styles.sectionTitle()}>{title}</h2>}\n {description && <MarkdownView classNames={styles.sectionDescription()} content={description} />}\n </div>\n )}\n {children}\n </div>\n );\n },\n);\n\nFormSection.displayName = FORM_SECTION_NAME;\n\n//\n// Group\n//\n\nconst FORM_GROUP_NAME = 'Form.Group';\n\nexport type FormGroupProps = ThemedClassName<PropsWithChildren>;\n\n/**\n * A bordered card grouping related rows/controls (e.g. an entity card in a list).\n * Layout-only and context-free — unlike `Form.FieldSet` it is not schema-driven.\n */\nexport const FormGroup = composable<HTMLDivElement, FormGroupProps>(({ children, ...props }, forwardedRef) => {\n const { variant = 'default' } = useFormContext(FORM_SECTION_NAME);\n const styles = formTheme.styles({ variant });\n\n return (\n <div {...composableProps(props, { classNames: styles.group() })} ref={forwardedRef}>\n {children}\n </div>\n );\n});\n\nFormGroup.displayName = FORM_GROUP_NAME;\n\n//\n// Submit\n//\n\nconst FORM_SUBMIT_NAME = 'Form.Submit';\n\nexport type FormSubmitProps = ThemedClassName<Partial<Pick<IconButtonProps, 'icon' | 'label' | 'disabled'>>>;\n\nexport const FormSubmit = ({ classNames, label, icon, disabled }: FormSubmitProps) => {\n const { t } = useTranslation(translationKey);\n const {\n form: { canSave, onSave },\n readonly,\n layout,\n } = useFormContext(FORM_SUBMIT_NAME);\n\n if (readonly || layout === 'static') {\n return null;\n }\n\n return (\n <div className={mx(formTheme.styles().submit(), classNames)}>\n <IconButton\n classNames='w-full'\n type='submit'\n variant='primary'\n disabled={disabled ?? !canSave}\n icon={icon ?? 'ph--check--regular'}\n label={label ?? t('save-button.label')}\n onClick={onSave}\n data-testid='save-button'\n />\n </div>\n );\n};\n\nFormSubmit.displayName = FORM_SUBMIT_NAME;\n\n//\n// Error\n//\n\nconst FORM_ERROR_NAME = 'Form.Error';\n\nexport type FormErrorProps = ThemedClassName<PropsWithChildren>;\n\n/** Form-level error/validation message (e.g. a failed submit), styled via the error valence. */\nexport const FormError = ({ children, classNames }: FormErrorProps) => {\n if (!children) {\n return null;\n }\n\n return (\n <Input.Root validationValence='error'>\n <Input.Validation classNames={classNames}>{children}</Input.Validation>\n </Input.Root>\n );\n};\n\nFormError.displayName = FORM_ERROR_NAME;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Cause from 'effect/Cause';\nimport * as Effect from 'effect/Effect';\nimport * as Exit from 'effect/Exit';\nimport { useEffect, useRef, useState } from 'react';\n\nimport { type AnyProperties } from '@dxos/echo/internal';\n\n/** Picks the declared dependency fields from the form values — the subset a dynamic field subscribes to. */\nexport const pickValues = (values: AnyProperties | undefined, deps: readonly string[]): Record<string, unknown> => {\n const subset: Record<string, unknown> = {};\n for (const dep of deps) {\n subset[dep] = values?.[dep];\n }\n return subset;\n};\n\nexport type AsyncFieldEffectState<A> = {\n loading: boolean;\n error: unknown;\n data: A | undefined;\n};\n\nexport type UseAsyncFieldEffectOptions = {\n /** Debounce applied before running, so per-keystroke value changes coalesce into one run. */\n debounceMs?: number;\n /** When false, the effect is not run and prior data/error is cleared. */\n enabled?: boolean;\n};\n\n/**\n * Runs a self-contained Effect (`R = never`) whenever `key` changes, debounced and abortable. Used by\n * dynamic form fields to load select options, derive values, or validate against an external source from\n * the current form values. The latest `factory` is always used, but a run is only (re)triggered when\n * `key` changes — derive `key` from the inputs the factory actually reads. Re-running interrupts the\n * prior run (cancelling any in-flight request).\n */\nexport const useAsyncFieldEffect = <A>(\n factory: () => Effect.Effect<A, unknown>,\n key: string,\n { debounceMs = 400, enabled = true }: UseAsyncFieldEffectOptions = {},\n): AsyncFieldEffectState<A> => {\n const factoryRef = useRef(factory);\n factoryRef.current = factory;\n const [state, setState] = useState<AsyncFieldEffectState<A>>({ loading: false, error: undefined, data: undefined });\n\n useEffect(() => {\n if (!enabled) {\n setState({ loading: false, error: undefined, data: undefined });\n return;\n }\n\n let cancel: (() => void) | undefined;\n const timer = setTimeout(() => {\n setState((prev) => ({ ...prev, loading: true, error: undefined }));\n cancel = Effect.runCallback(factoryRef.current(), {\n onExit: (exit: Exit.Exit<A, unknown>) => {\n Exit.match(exit, {\n onSuccess: (data) => setState({ loading: false, error: undefined, data }),\n onFailure: (cause) => {\n // A superseding run interrupts this one; ignore the resulting interruption.\n if (!Cause.isInterruptedOnly(cause)) {\n setState((prev) => ({ loading: false, error: Cause.squash(cause), data: prev.data }));\n }\n },\n });\n },\n });\n }, debounceMs);\n\n return () => {\n clearTimeout(timer);\n cancel?.();\n };\n }, [key, enabled, debounceMs]);\n\n return state;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { createContext } from '@radix-ui/react-context';\nimport * as SchemaAST from 'effect/SchemaAST';\nimport { useEffect, useMemo, useRef } from 'react';\n\nimport { type AnyProperties } from '@dxos/echo/internal';\nimport { SchemaEx } from '@dxos/effect';\n\nimport { type FieldContext, type FormFieldStateProps } from '#types';\n\nimport { type FormVariant } from '../components/Form/Form.theme';\nimport { type FormHandler } from './useFormHandler';\n\n//\n// Context\n//\n\nexport type FormContextValue<T extends AnyProperties = any> = {\n /**\n * Form handler.\n */\n form: FormHandler<T>;\n\n /**\n * Testing.\n */\n testId?: string;\n\n /** Visual variant applied across the form's parts (see Form.theme). */\n variant?: FormVariant;\n} & FieldContext;\n\nexport const [FormContextProvider, useFormContext] = createContext<FormContextValue>('Form');\n\n/**\n * Get the current form values.\n */\nexport const useFormValues: {\n <T extends AnyProperties>(componentName: string, path?: (string | number)[]): T;\n <T extends AnyProperties>(\n componentName: string,\n path: (string | number)[] | undefined,\n defaultValue: () => T,\n ): T | undefined;\n} = (componentName: string, path?: (string | number)[], defaultValue?: () => any) => {\n const stablePath = useMemo(() => path ?? [], [path ? path.join('.') : undefined]);\n const jsonPath = SchemaEx.createJsonPath(stablePath);\n const {\n form: { values, onValueChange },\n } = useFormContext(componentName);\n\n const value = SchemaEx.getValue(values, jsonPath);\n\n // Apply default value once when the field has no value. lastAppliedPathRef prevents\n // re-applying on every render (e.g. when defaultValue() returns null) and ensures\n // we apply per path when the hook is used for different fields.\n const lastAppliedPathRef = useRef<string | null>(null);\n useEffect(() => {\n if (value == null && defaultValue && lastAppliedPathRef.current !== jsonPath) {\n lastAppliedPathRef.current = jsonPath;\n onValueChange(stablePath, SchemaAST.stringKeyword, defaultValue());\n }\n }, [value, defaultValue, onValueChange, stablePath, jsonPath]);\n\n return value;\n};\n\n/**\n * Get the state props for the given field.\n */\nexport const useFormFieldState = (componentName: string, path: (string | number)[] = []): FormFieldStateProps => {\n const stablePath = useMemo(() => path, [Array.isArray(path) ? path.join('.') : path]);\n const {\n form: { getStatus, getValue, onBlur, onValueChange },\n } = useFormContext(componentName);\n\n return useMemo(\n () => ({\n getStatus: () => getStatus(stablePath),\n getValue: () => getValue(stablePath),\n onBlur: () => onBlur(stablePath),\n onValueChange: (ast: SchemaAST.AST, value: any) => onValueChange(stablePath, ast, value),\n }),\n [getStatus, getValue, onBlur, onValueChange, stablePath],\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport type * as Schema from 'effect/Schema';\nimport type * as SchemaAST from 'effect/SchemaAST';\nimport { useCallback, useEffect, useMemo, useState } from 'react';\n\nimport { type AnyProperties } from '@dxos/echo/internal';\nimport { SchemaEx } from '@dxos/effect';\nimport { log } from '@dxos/log';\nimport { useDefaultValue } from '@dxos/react-ui';\nimport { type ValidationError, validateSchema } from '@dxos/schema';\nimport { type MaybePromise } from '@dxos/util';\n\nimport { type FormFieldStatus } from '#types';\n\n/**\n * Form properties.\n */\nexport interface FormHandlerProps<T extends AnyProperties> {\n /**\n * Effect schema (Type literal).\n */\n schema?: Schema.Schema<T, any>;\n\n /**\n * Values for the form if controlled.\n */\n values?: Partial<T>;\n\n /**\n * Default values for the form which will be used if values is not provided.\n */\n defaultValues?: Partial<T>;\n\n /**\n * Auto-save the form when the values change.\n */\n autoSave?: boolean;\n\n /**\n * Callback for value changes. Note: This is called even when values are invalid.\n * Sometimes the parent component may want to know about changes even if the form is\n * in an invalid state.\n */\n onValuesChanged?: (values: Partial<T>, meta: FormUpdateMeta<T>) => void;\n\n /**\n * Custom validation function that runs only after schema validation passes.\n * Use this for complex validation logic that can't be expressed in the schema.\n * @returns Array of validation errors, or undefined if validation passes\n */\n onValidate?: (values: T) => ValidationError[] | undefined;\n\n /**\n * Called when the form is submitted and passes validation.\n */\n onSave?: (values: T, meta: FormUpdateMeta<T>) => MaybePromise<void>;\n\n /**\n * Called when the form is canceled.\n */\n onCancel?: () => void;\n}\n\nexport type FormUpdateMeta<T extends AnyProperties> = {\n changed: FormHandler<T>['changed'];\n isValid: boolean;\n};\n\n/**\n * Form handler properties and methods.\n */\nexport type FormHandler<T extends AnyProperties> = Pick<FormHandlerProps<T>, 'schema' | 'autoSave'> & {\n /** Initial values (which may not pass validation). */\n values: Partial<T>;\n\n /** Fields whose value has been edited (set by `onValueChange`). Gates autosave-on-blur. */\n changed: Record<SchemaEx.JsonPath, boolean>;\n /** Fields the user has interacted with (set by `onBlur`). Gates error *visibility* — errors only surface once touched. */\n touched: Record<SchemaEx.JsonPath, boolean>;\n\n /** Map of error strings. */\n errors: Record<SchemaEx.JsonPath, string>;\n\n /** Whether the values pass validation (no errors at all). */\n isValid: boolean;\n /**\n * Whether the submit affordance should be enabled. Stricter than `isValid`: it also requires no save\n * in flight (`saving`) and only blocks on errors for *touched* fields, so a pristine form with\n * not-yet-touched required fields can still show an enabled control.\n */\n canSave: boolean;\n\n onSave: () => void;\n onCancel: () => void;\n\n //\n // Form field state management\n //\n\n getStatus: (path: string | (string | number)[]) => FormFieldStatus;\n getValue: <V>(path: (string | number)[]) => V | undefined;\n onBlur: (path: (string | number)[]) => void;\n onValueChange: <V>(path: (string | number)[], type: SchemaAST.AST, value: V) => void;\n};\n\n/**\n * Creates a hook for managing form state, including values, validation, and submission.\n * Deeply integrated with `@dxos/schema` for schema-based validation.\n */\nexport const useFormHandler = <T extends AnyProperties>({\n schema,\n autoSave,\n values: valuesProp,\n defaultValues: defaultValuesProp,\n onValuesChanged,\n onValidate,\n onSave,\n onCancel,\n ...props\n}: FormHandlerProps<T>): FormHandler<T> => {\n const [changed, setChanged] = useState<Record<SchemaEx.JsonPath, boolean>>({});\n const [touched, setTouched] = useState<Record<SchemaEx.JsonPath, boolean>>({});\n const [errors, setErrors] = useState<Record<SchemaEx.JsonPath, string>>({});\n const [saving, setSaving] = useState(false);\n const defaultValues = useDefaultValue<Partial<T>>(defaultValuesProp, () => ({}));\n const [values$, setValues] = useControllableState<Partial<T>>({\n prop: valuesProp,\n defaultProp: defaultValues,\n onChange: () => {\n // Only reset when controlled: parent passed new values.\n // Uncontrolled updates come from setValues in onValueChange.\n if (valuesProp !== undefined) {\n setValues(valuesProp ?? defaultValues);\n setChanged({});\n setTouched({});\n setErrors({});\n setSaving(false);\n }\n },\n });\n // TODO(wittjosiah): Upgrade @radix-ui/react-use-controllable-state.\n const values = values$ as Partial<T>;\n\n // Validate.\n const validate = useCallback(\n (values: Partial<T>): values is T => {\n if (!schema) {\n return false;\n }\n\n let errors: ValidationError[] = validateSchema(schema, values) ?? [];\n log('validate', { values, errors });\n if (errors.length === 0 && onValidate) {\n const validatedValues = values as T;\n errors = onValidate(validatedValues) ?? [];\n }\n\n setErrors(flatMap(errors));\n const valid = errors.length === 0;\n return valid;\n },\n [schema, onValidate],\n );\n\n // Validate on schema change.\n const [schemaChanged, setSchemaChanged] = useState(false);\n useEffect(() => setSchemaChanged(true), [schema]);\n useEffect(() => {\n if (schemaChanged) {\n validate(values);\n setSchemaChanged(false);\n }\n }, [validate, values, schemaChanged]);\n\n const isValid = useMemo(() => {\n return Object.keys(errors).length === 0;\n }, [errors]);\n\n /**\n * NOTE: We can submit if there is no touched field that has an error.\n * If there's a validation message visible in the form, submit should be disabled.\n */\n const canSave = useMemo(\n () =>\n !saving &&\n // Check if any error paths that are touched have errors.\n !Object.entries(touched).some(\n ([path, isTouched]) =>\n isTouched &&\n Object.keys(errors).some(\n (errorPath) => errorPath === path || errorPath.startsWith(`${path}.`) || errorPath.startsWith(`${path}[`),\n ),\n ),\n [touched, errors, saving],\n );\n\n const handleSave = useCallback(async () => {\n if (validate(values)) {\n setSaving(true);\n try {\n await onSave?.(values, { changed, isValid });\n } finally {\n setSaving(false);\n }\n }\n }, [values, validate, onSave, changed, isValid]);\n\n const handleCancel = useCallback(() => {\n onCancel?.();\n }, [onCancel]);\n\n //\n // Fields.\n //\n\n const getStatus = useCallback<FormHandler<T>['getStatus']>(\n (path) => {\n const jsonPath = Array.isArray(path) ? SchemaEx.createJsonPath(path) : path;\n const [_, error] =\n Object.entries(errors).find(\n ([errorPath]) =>\n errorPath === jsonPath || errorPath.startsWith(`${jsonPath}.`) || errorPath.startsWith(`${jsonPath}[`),\n ) ?? [];\n\n // Only show errors for touched fields.\n const isTouched = touched[jsonPath as SchemaEx.JsonPath];\n if (!isTouched) {\n return {\n status: undefined,\n error: undefined,\n };\n }\n\n return {\n status: error ? 'error' : undefined,\n error: error ? (error ?? undefined) : undefined,\n };\n },\n [errors, touched],\n );\n\n const getValue = useCallback<FormHandler<T>['getValue']>(\n (path) => {\n return SchemaEx.getValue(values, SchemaEx.createJsonPath(path));\n },\n [values],\n );\n\n const onValueChange = useCallback<FormHandler<T>['onValueChange']>(\n (path, type, value) => {\n log('onValueChange', { path, value });\n\n const jsonPath = SchemaEx.createJsonPath(path);\n const pathArray = path;\n let parsedValue = value as any;\n try {\n if (type._tag === 'NumberKeyword') {\n parsedValue = parseFloat(value as string) || 0;\n }\n } catch (err) {\n log.catch(err);\n parsedValue = undefined;\n }\n\n // Create merged values for validation and callback. Form never mutates; parent applies via onValuesChanged.\n const newValues = mergeAtPath(values, pathArray as (string | number)[], parsedValue) as Partial<T>;\n\n // TODO(burdon): Check value has changed from original.\n const newChanged = { [jsonPath]: true };\n setChanged((prev) => ({ ...prev, ...newChanged }));\n\n // Validate.\n const isValid = validate(newValues);\n\n // Notify parent; parent is responsible for applying the change.\n onValuesChanged?.(newValues, { isValid, changed: newChanged });\n\n // For uncontrolled mode, update internal state. Controlled mode relies on parent to pass new values.\n if (valuesProp === undefined) {\n setValues(newValues);\n }\n },\n [values, validate, onValuesChanged, valuesProp],\n );\n\n const onBlur = useCallback(\n async (path: (string | number)[]) => {\n const jsonPath = SchemaEx.createJsonPath(path);\n\n // TODO(burdon): Check value has changed from original.\n setTouched((touched) => ({ ...touched, [jsonPath]: true }));\n const isValid = validate(values);\n\n // Auto-save when a field is blurred and is valid.\n if (Object.keys(changed).length > 0 && isValid && autoSave) {\n await onSave?.(values as T, { changed, isValid });\n }\n },\n [validate, values, changed, autoSave, onSave],\n );\n\n return useMemo<FormHandler<T>>(\n () => ({\n // State.\n schema,\n values,\n errors,\n touched,\n changed,\n isValid,\n canSave,\n autoSave,\n\n // Actions.\n onSave: handleSave,\n onCancel: handleCancel,\n\n // Field utils.\n getStatus,\n getValue,\n onBlur,\n onValueChange,\n\n ...props,\n }),\n [\n schema,\n autoSave,\n values,\n errors,\n touched,\n changed,\n canSave,\n isValid,\n getStatus,\n getValue,\n onBlur,\n onValueChange,\n handleSave,\n handleCancel,\n ],\n );\n};\n\n/**\n * Creates a new object with value at path. Does not mutate source.\n * Preserves arrays when path segments are numeric indices.\n */\nconst mergeAtPath = (obj: any, path: readonly (string | number)[], value: any): any => {\n if (path.length === 0) {\n return value;\n }\n\n const [head, ...rest] = path;\n const child = rest.length === 0 ? value : mergeAtPath(obj?.[head], rest, value);\n\n if (Array.isArray(obj)) {\n const copy = [...obj];\n copy[head as number] = child;\n return copy;\n }\n\n return { ...obj, [head]: child };\n};\n\nconst flatMap = (errors: ValidationError[]) => {\n return errors.reduce(\n (result, { path, message }) => {\n // Convert the validation error path format to our SchemaEx.JsonPath format.\n const jsonPath = SchemaEx.fromEffectValidationPath(path);\n if (!(jsonPath in result)) {\n result[jsonPath] = message;\n }\n return result;\n },\n {} as Record<SchemaEx.JsonPath, string>,\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type RefObject, useCallback, useLayoutEffect } from 'react';\n\nimport { addEventListener } from '@dxos/async';\n\nimport { type FormHandler } from './useFormHandler';\n\n/**\n * Key handler.\n */\nexport const useKeyHandler = (elRef: RefObject<HTMLDivElement | null>, form: FormHandler<any>) => {\n const handleKeyDown = useCallback(\n (event: KeyboardEvent) => {\n switch (event.key) {\n case 'Enter': {\n if (event.metaKey && form.canSave) {\n form.onSave();\n }\n break;\n }\n }\n },\n [form.isValid, form.canSave, form.onSave, form.autoSave],\n );\n\n useLayoutEffect(() => {\n const el = elRef.current;\n if (!el) {\n return;\n }\n\n return addEventListener(el, 'keydown', handleKeyDown);\n }, [elRef, handleKeyDown]);\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { type VariantProps, mx, tv } from '@dxos/ui-theme';\n\n/** Visual variants for {@link Form}. `settings` is the bordered two-column settings-panel look. */\nexport type FormVariant = NonNullable<VariantProps<typeof formStyles>['variant']>;\n\n/** Non-className behavior flags, keyed by {@link FormVariant}. */\nexport type FormBehavior = { showDescription: boolean };\n\nconst formStyles = tv({\n slots: {\n viewport: '',\n content: '',\n section: 'flex flex-col py-form-section-gap first:pt-0',\n group: 'flex flex-col gap-3 p-trim-md border border-separator rounded-sm',\n sectionHeader: '',\n sectionTitle: 'text-lg',\n sectionDescription: 'text-description',\n fieldSet: '',\n field: '',\n fieldLabel: 'h-8 grid grid-cols-[1fr_auto_auto] items-center select-none',\n fieldLabelText: '',\n fieldDescription: 'text-description',\n fieldControl: '',\n fieldValidation: '',\n // Action bar (cancel/save), equal-width columns flowing horizontally.\n actions: 'grid grid-flow-col gap-form-gap auto-cols-fr py-form-padding',\n // Standalone submit row (full-width primary button).\n submit: 'flex w-full pt-form-padding',\n // Collapsible field-set body: indented column of sub-fields.\n fieldSetBody: 'flex flex-col gap-2 px-2 pb-2',\n // Bordered container wrapping a collapsible nested group, plus its top spacing.\n fieldSetBox: 'border border-subdued-separator rounded-sm',\n fieldSetBoxOuter: 'pt-trim-md',\n },\n variants: {\n variant: {\n default: {},\n settings: {\n content: 'dx-document',\n // Gap on the section spaces its direct children — section title/description and, for action\n // panels, the `Form.Row`s placed directly in the section (which have no `fieldSet` wrapper).\n section: 'py-form-section-gap! gap-trim-md',\n sectionHeader: 'pb-form-section-gap',\n sectionTitle: 'px-trim-md text-xl',\n sectionDescription: 'px-trim-md',\n // No top padding: the section gap already separates the field set from the title above it.\n fieldSet: 'flex flex-col gap-trim-md',\n field: mx(\n 'grid',\n 'grid-cols-1 [grid-template-areas:\"header\"\"description\"\"control\"\"validation\"]',\n 'md:grid-cols-2 md:[grid-template-areas:\"header_header\"\"description_control\"\"validation_validation\"]',\n 'gap-x-trim-lg gap-y-0 p-trim-md border border-input-separator rounded-md',\n ),\n fieldLabel: '[grid-area:header]',\n fieldLabelText: 'text-base-fg text-lg',\n fieldDescription: '[grid-area:description] pt-1 text-description',\n fieldControl: '[grid-area:control] flex justify-end items-start md:text-right pt-3 md:pt-0',\n fieldValidation: '[grid-area:validation]',\n },\n },\n },\n defaultVariants: {\n variant: 'default',\n },\n});\n\n/** {@link Form} theme template: a tailwind-variants recipe (`styles`) plus non-class `behavior`. */\nexport const formTheme = {\n styles: formStyles,\n behavior: {\n default: {\n showDescription: false,\n },\n settings: {\n showDescription: true,\n },\n } satisfies Record<FormVariant, FormBehavior>,\n};\n\n/** Slot names of {@link formTheme.styles}, for `bridgeTv` registration. */\n// Object.keys widens to string[]; the slot names are statically known.\nexport const formSlots = Object.keys(formTheme.styles()) as Array<keyof ReturnType<typeof formTheme.styles>>;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Option from 'effect/Option';\nimport React, { useMemo } from 'react';\n\nimport { DEFAULT_LAYOUT_NAME, FormLayoutAnnotation } from '@dxos/echo/Annotation';\nimport { type AnyProperties } from '@dxos/echo/internal';\nimport { SchemaEx } from '@dxos/effect';\nimport { type Merge } from '@dxos/util';\n\nimport { type FieldContext } from '#types';\n\nimport { type FormHandlerProps, useFormValues } from '../../../hooks';\nimport { getRootFormProperties } from '../../../util';\nimport { FormField, FormFieldErrorBoundary, type FormFieldProps, presentationFor } from '../FormField';\nimport { FormLayout } from '../FormLayout';\nimport { FormFieldSetContainer } from './FormFieldSetContainer';\n\nconst FORM_FIELDSET_NAME = 'Form.FieldSet';\n\nexport type FormFieldSetProps<T extends AnyProperties> = Merge<\n {\n /** Applied to the field set's container (the bordered box when collapsible). */\n classNames?: string;\n label?: string;\n sort?: string[];\n /**\n * When set, renders a toggle button at the end of the label row that\n * shows/hides the field set body. Used for nested objects.\n */\n collapsible?: boolean;\n filter?: (props: SchemaEx.SchemaProperty[]) => SchemaEx.SchemaProperty[];\n /**\n * Picks a named layout out of `FormLayoutAnnotation` when present.\n * Falls back to `'default'`. Ignored when the schema has no annotation\n * (linear rendering then takes over).\n */\n layoutName?: string;\n },\n Pick<FormHandlerProps<T>, 'schema'>,\n Pick<FormFieldProps, 'path' | 'autoFocus'>,\n FieldContext\n>;\n\n/**\n * Renders a set of form fields derived from a schema object.\n */\nexport const FormFieldSet = ({\n classNames,\n label,\n schema,\n readonly,\n path,\n sort,\n collapsible,\n filter,\n projection,\n layout,\n layoutName = DEFAULT_LAYOUT_NAME,\n ...props\n}: FormFieldSetProps<any>) => {\n const values = useFormValues(FORM_FIELDSET_NAME, path);\n const properties = useFormFieldSetProperties({ schema, values, filter, sort, projection });\n if ((readonly || layout === 'static') && values == null) {\n return null;\n }\n\n // If the schema carries a layout template, hand off to <Form.Layout/> which renders the DSL.\n // Linear rendering still runs when no annotation is present, so existing call sites are unchanged.\n const layouts = schema ? Option.getOrUndefined(FormLayoutAnnotation.get(schema)) : undefined;\n const body =\n layouts?.[layoutName] !== undefined && schema ? (\n <FormLayout\n schema={schema}\n name={layoutName}\n path={path}\n readonly={readonly}\n layout={layout}\n projection={projection}\n {...props}\n />\n ) : (\n properties.map((property) => {\n const name = property.name.toString();\n return (\n <FormFieldErrorBoundary key={name} path={[...(path ?? []), name]}>\n <FormField\n type={property.type}\n name={name}\n path={[...(path ?? []), name]}\n required={!property.isOptional}\n readonly={readonly}\n layout={layout}\n projection={projection}\n {...props}\n />\n </FormFieldErrorBoundary>\n );\n })\n );\n\n return (\n <FormFieldSetContainer\n classNames={classNames}\n label={label}\n path={SchemaEx.createJsonPath(path ?? [])}\n readonly={readonly}\n presentation={presentationFor(layout)}\n collapsible={collapsible}\n >\n {body}\n </FormFieldSetContainer>\n );\n};\n\nFormFieldSet.displayName = FORM_FIELDSET_NAME;\n\ntype UseFormFieldSetPropertiesParams = Pick<FormFieldSetProps<any>, 'schema' | 'filter' | 'projection' | 'sort'> & {\n values: AnyProperties | undefined;\n sort?: string[];\n};\n\n/**\n * Resolves ordered schema properties for a field set (projection order, filter, or sort).\n */\nconst useFormFieldSetProperties = ({\n schema,\n filter,\n projection,\n values,\n sort,\n}: UseFormFieldSetPropertiesParams): SchemaEx.SchemaProperty[] => {\n // TODO(burdon): Updates on every value change.\n // Remove values dep if can remove from getSchemaProperties.\n return useMemo(() => {\n if (!schema) {\n return [];\n }\n\n // TODO(wittjosiah): Reconcile FormInputAnnotation with projection hidden properties & filter function.\n const schemaProps = getRootFormProperties(schema.ast, values);\n const filteredProps = filter ? filter(schemaProps) : schemaProps;\n\n // Use projection-based field management when view and projection are available.\n if (projection) {\n const fieldProjections = projection.getFieldProjections();\n const hiddenProperties = new Set(projection.getHiddenProperties());\n\n // Filter properties to only include visible ones and order by projection.\n const visibleProps = filteredProps.filter((prop) => !hiddenProperties.has(prop.name.toString()));\n const orderedProps: SchemaEx.SchemaProperty[] = [];\n\n // Add properties in projection field order.\n for (const fieldProjection of fieldProjections) {\n const fieldPath = String(fieldProjection.field.path);\n const prop = visibleProps.find((prop) => prop.name === fieldPath);\n if (prop) {\n orderedProps.push(prop);\n }\n }\n\n // Add any remaining properties not in projection.\n const projectionPaths = new Set(fieldProjections.map((projection) => String(projection.field.path)));\n const remainingProps = visibleProps.filter((prop) => !projectionPaths.has(prop.name.toString()));\n orderedProps.push(...remainingProps);\n return orderedProps;\n }\n\n // Fallback to legacy filter/sort behavior.\n return sort\n ? [...filteredProps].sort(({ name: a }, { name: b }) => sort.indexOf(a.toString()) - sort.indexOf(b.toString()))\n : filteredProps;\n }, [schema, values, filter, sort, projection]);\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Option from 'effect/Option';\nimport * as SchemaAST from 'effect/SchemaAST';\nimport React, { type ReactNode, useCallback, useRef } from 'react';\n\nimport { Annotation, Ref } from '@dxos/echo';\nimport { useType as defaultUseType } from '@dxos/echo-react';\nimport { SchemaEx } from '@dxos/effect';\nimport { DXN } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { useTranslation } from '@dxos/react-ui';\nimport { OrderedList } from '@dxos/react-ui-list';\nimport { mx } from '@dxos/ui-theme';\nimport { arrayMove } from '@dxos/util';\n\nimport { translationKey } from '#translations';\nimport { type FormFieldStateProps } from '#types';\n\nimport { useFormValues } from '../../../../../hooks';\nimport { getFormProperties } from '../../../../../util';\nimport { CompactIconButton, FormField, type FormFieldProps } from '../../FormField';\nimport { FormFieldHeader } from '../../FormFieldHeader';\n\n// Synthetic id assigned to each row when rendering an ordered list. Plain form\n// values have no stable identity, so drag-and-drop (which requires a stable key\n// surviving the `onValuesChanged` round-trip) is given one here and kept in\n// lockstep with the array via the add/delete/move handlers.\nconst DND_ID = '__dndId';\n\ntype OrderedItem = {\n [DND_ID]: string;\n value: unknown;\n index: number;\n};\n\nconst isOrderedItem = (item: any): item is OrderedItem =>\n !!item && typeof item === 'object' && typeof item[DND_ID] === 'string';\n\nconst getOrderedId = (item: OrderedItem): string => item[DND_ID];\n\nexport type ArrayFieldProps = {\n label: string;\n fieldProps: FormFieldStateProps;\n} & FormFieldProps;\n\nexport const ArrayField = ({\n type,\n path,\n label,\n readonly,\n layout,\n fieldProps: inputProps,\n ...props\n}: ArrayFieldProps) => {\n const { t } = useTranslation(translationKey);\n const elementType = SchemaEx.getArrayElementType(type);\n const { onValueChange } = inputProps;\n const values = useFormValues(ArrayField.displayName, path, () => []);\n\n // Order is meaningful and user-controllable -> render as a drag-to-reorder list.\n const ordered = Annotation.FormOrderedAnnotation.getFromAst(type).pipe(Option.getOrElse(() => false));\n\n // Owned-ref array (`FormCreateAnnotation`): \"add\" creates a new target object of the annotation's typename,\n // and each row renders that target inline (no existing-object picker).\n const { db, onCreate, getCreateDefaults, useType = defaultUseType } = props;\n const createTypename = Annotation.FormCreateAnnotation.getFromAst(type).pipe(Option.getOrUndefined);\n const createSchema = useType(db, createTypename ? DXN.make(createTypename) : undefined);\n const createInline =\n !!createTypename && !!elementType && Ref.isRefType(elementType) && !readonly && layout !== 'static';\n\n // Synthetic identity map (see `DND_ID`). The counter only advances when the\n // array grows; reconciliation here covers the initial mount and any external\n // length change, while the handlers below keep ids aligned on mutation.\n const idsRef = useRef<string[]>([]);\n const counterRef = useRef(0);\n const nextId = useCallback(() => `${DND_ID}-${counterRef.current++}`, []);\n\n // Create a new owned target object and append its ref (see `createInline`).\n const handleAddCreate = useCallback(async () => {\n if (!createSchema || !onCreate) {\n return;\n }\n // Let the container pre-populate the new object (e.g. a back-reference to the parent).\n const defaults = getCreateDefaults?.({ jsonPath: SchemaEx.createJsonPath(path ?? []), schema: createSchema }) ?? {};\n const created = await onCreate(createSchema, defaults);\n if (!created) {\n return;\n }\n idsRef.current.push(nextId());\n onValueChange(type, [...(values ?? []), Ref.make(created)]);\n }, [createSchema, onCreate, getCreateDefaults, onValueChange, type, path, values, nextId]);\n\n const getDefaultObjectValue = (typeNode: SchemaAST.AST): any => {\n const baseNode = SchemaEx.findNode(typeNode, SchemaEx.isDiscriminatedUnion);\n const typeLiteral = baseNode\n ? SchemaEx.getDiscriminatedType(baseNode, {})\n : SchemaEx.findNode(typeNode, SchemaAST.isTypeLiteral);\n if (!typeLiteral) {\n return {};\n }\n\n return Object.fromEntries(\n getFormProperties(typeLiteral).map((prop) => {\n const defaultValue = SchemaAST.getDefaultAnnotation(prop.type).pipe((annotation) =>\n Option.getOrUndefined(annotation),\n );\n return [prop.name, defaultValue];\n }),\n );\n };\n\n const handleAdd = useCallback(() => {\n let defaultValue;\n try {\n defaultValue =\n elementType && SchemaEx.isNestedType(elementType)\n ? getDefaultObjectValue(elementType)\n : getDefaultValue(elementType);\n } catch (err) {\n // `getDefaultValue` throws on element types it can't seed (runs in this click handler, so an\n // unguarded throw would be uncaught). Skip the add rather than crash the form.\n log.catch(err);\n return;\n }\n idsRef.current.push(nextId());\n // `values` is `undefined` on first render for arrays whose parent path\n // hasn't been materialised in the form values yet (e.g. `package.repos`\n // when the form starts with no `package`). `useFormValues`'s default-\n // value effect would eventually backfill it to `[]`, but until then the\n // old `values && ...` guard silently swallowed the click. Treat a\n // missing array as empty so Add always produces `[defaultValue]`.\n onValueChange(type, [...(values ?? []), defaultValue]);\n }, [onValueChange, type, elementType, values, nextId]);\n\n const handleDelete = useCallback(\n (idx: number) => {\n idsRef.current.splice(idx, 1);\n onValueChange(\n type,\n values?.filter((_, i) => i !== idx),\n );\n },\n [onValueChange, type, values],\n );\n\n const handleMove = useCallback(\n (fromIndex: number, toIndex: number) => {\n const next = [...(values ?? [])];\n arrayMove(next, fromIndex, toIndex);\n arrayMove(idsRef.current, fromIndex, toIndex);\n onValueChange(type, next);\n },\n [onValueChange, type, values],\n );\n\n if (!elementType || ((readonly || layout === 'static') && values && values.length < 1)) {\n return null;\n }\n\n const renderItemAsObject = elementType && SchemaEx.isNestedType(elementType) && !Ref.isRefType(elementType);\n\n // Object items: a recursively-rendered FormField (multiple sub-rows for the\n // object's fields). Scalar items (refs, primitives): a single inline FormField.\n const renderField = (index: number, isLast: boolean): ReactNode => {\n const field = (\n <FormField\n {...props}\n autoFocus={isLast}\n type={elementType}\n // Suppress the per-item header for object items and owned-ref items (both render their own\n // sub-field labels). Scalar items (refs, primitives) take the array's resolved label (e.g. its\n // `title` annotation, `Tags`) so inline-layout children (e.g. RefField) have a real label to use\n // as a fallback placeholder, rather than re-deriving it from the raw array property name (`_tags`).\n {...(renderItemAsObject || createInline ? { name: null } : { label })}\n path={[...(path ?? []), index]}\n readonly={readonly || layout === 'static'}\n layout={renderItemAsObject ? (layout === 'static' ? 'static' : undefined) : 'inline'}\n refInline={createInline || undefined}\n />\n );\n\n // TODO(burdon): Hacky.\n // An owned inline object form must establish its own column context: otherwise it inherits the parent\n // form's `--dx-col` (center) placement and collapses into the array row's narrow second track.\n return createInline ? (\n <div role='none' className='w-full min-w-0 [--dx-col:auto]'>\n {field}\n </div>\n ) : (\n field\n );\n };\n\n const header = (layout !== 'static' || (values && values.length > 0)) && (\n <FormFieldHeader\n label={label}\n path={SchemaEx.createJsonPath(path ?? [])}\n readonly={readonly}\n add={\n layout !== 'static'\n ? { label: t('add-item.button'), onClick: createInline ? () => void handleAddCreate() : handleAdd }\n : undefined\n }\n />\n );\n\n //\n // Ordered (drag-to-reorder) list.\n //\n\n if (ordered && !readonly && layout !== 'static') {\n // Reconcile synthetic ids with the current values (initial mount / external change).\n const ids = idsRef.current;\n const count = values?.length ?? 0;\n while (ids.length < count) {\n ids.push(nextId());\n }\n if (ids.length > count) {\n ids.length = count;\n }\n\n const items: OrderedItem[] = (values ?? []).map((value, index) => ({ value, index, [DND_ID]: ids[index] }));\n\n return (\n <>\n {header}\n <OrderedList.Root<OrderedItem> items={items} isItem={isOrderedItem} getId={getOrderedId} onMove={handleMove}>\n {({ items }) => (\n <OrderedList.Content>\n {items.map((item) => (\n <OrderedList.Item<OrderedItem>\n key={getOrderedId(item)}\n id={getOrderedId(item)}\n item={item}\n classNames='grid grid-cols-[min-content_1fr_min-content] items-start gap-1 p-0 pb-1'\n >\n <OrderedList.DragHandle />\n {renderField(item.index, item.index === items.length - 1)}\n <CompactIconButton\n icon='ph--x--regular'\n label={t('remove-item.button')}\n onClick={() => handleDelete(item.index)}\n />\n </OrderedList.Item>\n ))}\n </OrderedList.Content>\n )}\n </OrderedList.Root>\n </>\n );\n }\n\n //\n // Static list.\n //\n\n return (\n <>\n {header}\n <div className='flex flex-col gap-2'>\n {values?.map((_, index) => {\n const isLast = index === values.length - 1;\n return (\n <div\n key={index}\n className={mx(\n 'grid grid-cols-[minmax(0,1fr)_min-content] gap-1',\n renderItemAsObject || createInline ? 'items-start' : 'items-center',\n )}\n >\n {renderField(index, isLast)}\n {!readonly && layout !== 'static' && (\n <CompactIconButton\n icon='ph--x--regular'\n label={t('remove-item.button')}\n onClick={() => handleDelete(index)}\n />\n )}\n </div>\n );\n })}\n </div>\n </>\n );\n};\n\nArrayField.displayName = 'Form.ArrayField';\n\n/**\n * Returns the default empty value for a given AST.\n * Used for initializing new array values etc.\n */\n// TODO(wittjosiah): Factor out?\nexport const getDefaultValue = (ast?: SchemaAST.AST): any => {\n switch (ast?._tag) {\n case 'StringKeyword': {\n return '';\n }\n case 'NumberKeyword': {\n return 0;\n }\n case 'BooleanKeyword': {\n return false;\n }\n case 'Suspend': {\n return getDefaultValue(ast.f());\n }\n case 'Refinement': {\n // Use minimum from JSON schema annotation (e.g. Schema.between(1, 31)) as the default\n // so new array items start within the valid range.\n const jsonSchema = Option.getOrUndefined(SchemaAST.getJSONSchemaAnnotation(ast));\n if (jsonSchema != null && 'minimum' in jsonSchema && typeof jsonSchema.minimum === 'number') {\n return jsonSchema.minimum;\n }\n return getDefaultValue(ast.from);\n }\n default: {\n if (ast && SchemaEx.isNestedType(ast)) {\n return {};\n } else {\n throw new Error(`Unsupported type: ${ast?._tag}`);\n }\n }\n }\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Match from 'effect/Match';\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\nimport * as String from 'effect/String';\nimport React, { useMemo } from 'react';\n\nimport { Annotation, Format } from '@dxos/echo';\nimport { SchemaEx } from '@dxos/effect';\nimport { IconButton, IconButtonProps, useTranslation } from '@dxos/react-ui';\n\nimport { translationKey } from '#translations';\nimport { type FieldContext, type FormFieldRenderer, type FormFieldRendererProps } from '#types';\n\nimport { AutofillAnnotation, OptionsLookupAnnotation } from '../../../annotations';\nimport { useFormFieldState } from '../../../hooks';\nimport { getRefProps } from '../../../util';\nimport { FormFieldSet } from '../FormFieldSet';\nimport {\n ArrayField,\n AsyncSelectField,\n AutofillField,\n BooleanField,\n ComboboxField,\n DateField,\n GeoPointField,\n InlineRefField,\n MarkdownField,\n NumberField,\n PasswordField,\n RefField,\n SelectField,\n TextAreaField,\n TextField,\n} from './fields';\n\nexport type FormFieldProps = {\n /**\n * AST of the property to render.\n */\n type: SchemaAST.AST;\n\n /**\n * Name of the property. Used to derive a default label\n * (`title ?? capitalize(name)`) and as the projection lookup key. Pass\n * `null` to suppress the header label entirely -- the form still renders\n * the field/struct, but `FormFieldSet`'s top-level `<FormFieldLabel>` is\n * skipped. Used by `ArrayField` for object-array items, where every item\n * would otherwise repeat the array's parent name.\n */\n name: string | null;\n\n /**\n * Explicit label, overriding the `title ?? capitalize(name)` derivation. Used by `ArrayField` to\n * give scalar/ref items the array's resolved title (e.g. `Tags`) rather than re-capitalizing the\n * raw array property name (e.g. `_tags`), since the element type carries no title of its own.\n */\n label?: string;\n\n /**\n * Path to the current object from the root. Used with nested forms.\n */\n path?: (string | number)[];\n autoFocus?: boolean;\n /** Whether the field is required (non-optional in the schema). Drives the label asterisk. */\n required?: boolean;\n /**\n * Force a `Ref` field to render its target inline (a nested form) instead of the picker.\n * Set by `ArrayField` for owned-ref arrays (`FormCreateAnnotation`); equivalent to\n * `FormInlineAnnotation` but driven by the parent array rather than the element's own AST.\n */\n refInline?: boolean;\n} & FieldContext;\n\nexport const FormField = (props: FormFieldProps) => {\n const {\n type,\n name,\n label: labelProp,\n path,\n required,\n projection,\n fieldMap,\n fieldProvider,\n readonly,\n layout,\n\n // RefFieldProps\n createTypename,\n createOptionLabel,\n createOptionIcon,\n createInitialValuePath,\n createFieldMap,\n db,\n useType,\n getOptions,\n onCreate,\n resolveCreateEntry,\n refInline,\n } = props;\n const { t } = useTranslation(translationKey);\n const title = SchemaEx.getAnnotation<string>(SchemaAST.TitleAnnotationId)(type);\n const description = SchemaEx.getAnnotation<string>(SchemaAST.DescriptionAnnotationId)(type);\n const examples = SchemaEx.getAnnotation<string[]>(SchemaAST.ExamplesAnnotationId)(type);\n\n const label = useMemo(\n () => labelProp ?? title ?? (name == null ? '' : String.capitalize(name)),\n [labelProp, title, name],\n );\n const placeholder = useMemo(\n () => (examples?.length ? `${t('example.placeholder')}: ${examples[0]}` : (description ?? label)),\n [examples, description, label, t],\n );\n\n // Build the schema for `fieldProvider` only when one is registered, memoized by `type` (the AST) so\n // we don't reconstruct it on every render.\n const providerSchema = useMemo(() => (fieldProvider ? Schema.make(type) : undefined), [fieldProvider, type]);\n\n const fieldState = useFormFieldState(FormField.displayName, path);\n const jsonPath = SchemaEx.createJsonPath(path ?? []);\n const fieldProps: FormFieldRendererProps = {\n type,\n format: Format.FormatAnnotation.getFromAst(type).pipe((annotation) => Option.getOrUndefined(annotation)),\n readonly,\n label,\n description,\n jsonPath,\n placeholder,\n presentation: layout,\n required,\n db,\n ...fieldState,\n };\n\n // Omit empty fields entirely in read-only mode -- an empty value has nothing\n // to display, so a labelled row with a blank input is just noise. This\n // mirrors what `FormRow` already does for `presentation === 'static'`, but\n // covers every field type (including those that bypass the wrapper:\n // RefField, SelectField, MarkdownField, ...). Container fields\n // (`ArrayField`, nested-struct -> `FormFieldSet`) keep their own\n // empty-value checks, but those branches only apply when the value is\n // actually a non-null array/object, so this check doesn't interfere.\n if (readonly && fieldState.getValue() == null) {\n return null;\n }\n\n //\n // Custom field.\n //\n\n const CustomField = fieldMap?.[jsonPath];\n if (CustomField) {\n return <CustomField {...fieldProps} />;\n }\n\n if (fieldProvider && providerSchema) {\n const component = fieldProvider({ schema: providerSchema, prop: name ?? '', fieldProps });\n if (component) {\n return component;\n }\n }\n\n //\n // Dynamic, value-driven fields (options/value/validation loaded via a self-contained Effect annotation).\n //\n\n const optionsLookup = Option.getOrUndefined(OptionsLookupAnnotation.getFromAst(type));\n if (optionsLookup) {\n return optionsLookup.combobox ? (\n <ComboboxField {...fieldProps} lookup={optionsLookup} />\n ) : (\n <AsyncSelectField {...fieldProps} lookup={optionsLookup} />\n );\n }\n\n const autofill = Option.getOrUndefined(AutofillAnnotation.getFromAst(type));\n if (autofill) {\n return <AutofillField {...fieldProps} autofill={autofill} />;\n }\n\n //\n // Array field.\n //\n\n if (SchemaEx.isArrayType(type)) {\n return <ArrayField fieldProps={fieldState} label={label} {...props} />;\n }\n\n //\n // Regular field.\n //\n\n const Field = getFormField(fieldProps);\n if (Field) {\n return <Field {...fieldProps} />;\n }\n\n //\n // Select field.\n //\n\n const options = getSelectOptions(type);\n if (options) {\n // Resolve labels from projection metadata when available.\n const fieldProjections = projection?.getFieldProjections();\n const fieldProjection = fieldProjections?.find((fp) => fp.field.path === name);\n const selectOptions = fieldProjection?.props.options;\n\n return (\n <SelectField\n {...fieldProps}\n options={options.map((option) => {\n const selectOption = selectOptions?.find((so) => so.id === globalThis.String(option));\n return {\n value: option,\n label: selectOption?.title ?? option.toString(),\n };\n })}\n />\n );\n }\n\n //\n // Ref field.\n //\n\n const refProps = getRefProps(type);\n if (refProps) {\n // Inline a single referenced object's own fields (nested form) instead of a picker. `refInline` lets a\n // parent (e.g. an owned-ref `ArrayField`) force this for elements whose own AST carries no annotation.\n const inline =\n refInline || Annotation.FormInlineAnnotation.getFromAst(refProps.ast).pipe(Option.getOrElse(() => false));\n if (inline && !refProps.isArray) {\n return (\n <InlineRefField\n {...fieldProps}\n {...refProps}\n db={db}\n useType={useType}\n onCreate={onCreate}\n resolveCreateEntry={resolveCreateEntry}\n />\n );\n }\n\n const isCreateTarget = !createTypename || refProps.typename === createTypename;\n return (\n <RefField\n {...fieldProps}\n {...refProps}\n createOptionLabel={isCreateTarget ? createOptionLabel : undefined}\n createOptionIcon={isCreateTarget ? createOptionIcon : undefined}\n createInitialValuePath={isCreateTarget ? createInitialValuePath : undefined}\n createFieldMap={isCreateTarget ? createFieldMap : undefined}\n db={db}\n useType={useType}\n getOptions={getOptions}\n onCreate={onCreate}\n resolveCreateEntry={resolveCreateEntry}\n />\n );\n }\n\n //\n // Nested Object field.\n //\n\n if (SchemaEx.isNestedType(type)) {\n const baseNode = SchemaEx.findNode(type, SchemaEx.isDiscriminatedUnion);\n const typeLiteral = baseNode\n ? SchemaEx.getDiscriminatedType(baseNode, fieldState.getValue() as any)\n : SchemaEx.findNode(type, SchemaAST.isTypeLiteral);\n\n if (typeLiteral) {\n const schema = Schema.make(typeLiteral);\n return (\n <FormFieldSet\n schema={schema}\n path={path}\n readonly={readonly}\n layout={layout}\n label={label}\n collapsible\n projection={projection}\n fieldMap={fieldMap}\n fieldProvider={fieldProvider}\n createOptionLabel={createOptionLabel}\n createOptionIcon={createOptionIcon}\n createInitialValuePath={createInitialValuePath}\n db={db}\n useType={useType}\n getOptions={getOptions}\n onCreate={onCreate}\n resolveCreateEntry={resolveCreateEntry}\n />\n );\n }\n }\n\n return null;\n};\n\nFormField.displayName = 'Form.FormField';\n\n//\n// Layout components\n//\n\nexport const CompactIconButton = (props: IconButtonProps) => {\n return <IconButton variant='ghost' iconOnly {...props} />;\n};\n\n/**\n * Get property input component.\n */\nconst getFormField = ({\n type,\n format,\n}: Pick<FormFieldRendererProps, 'type' | 'format'>): FormFieldRenderer | undefined => {\n // Unwrap refinements (e.g. Schema.Number.pipe(Schema.between(...))) to their base type.\n if (SchemaAST.isRefinement(type)) {\n return getFormField({ type: type.from, format });\n }\n\n //\n // Standard formats.\n //\n\n const formatField = Match.value(format).pipe(\n Match.withReturnType<FormFieldRenderer | undefined>(),\n Match.when(Format.TypeFormat.Date, () => DateField),\n Match.when(Format.TypeFormat.DateTime, () => DateField),\n Match.when(Format.TypeFormat.GeoPoint, () => GeoPointField),\n Match.when(Format.TypeFormat.Markdown, () => MarkdownField),\n Match.when(Format.TypeFormat.Password, () => PasswordField),\n Match.when(Format.TypeFormat.Text, () => TextAreaField),\n Match.when(Format.TypeFormat.Time, () => DateField),\n Match.orElse(() => undefined),\n );\n if (formatField) {\n return formatField;\n }\n\n //\n // Standard types.\n //\n\n switch (type._tag) {\n // TODO(wittjosiah): Schema.Any is currently used to represent template inputs.\n case 'AnyKeyword':\n case 'StringKeyword':\n return TextField;\n case 'NumberKeyword':\n return NumberField;\n case 'BooleanKeyword':\n return BooleanField;\n }\n\n return undefined;\n};\n\nconst getSelectOptions = (ast: SchemaAST.AST): Format.Options[] | undefined => {\n if (SchemaEx.isLiteralUnion(ast)) {\n return ast.types.map((type) => type.literal).filter((v): v is string | number => v !== null);\n }\n\n return Format.OptionsAnnotation.getFromAst(ast).pipe((annotation) => Option.getOrUndefined(annotation));\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport React, { type ReactNode } from 'react';\n\nimport { CompactIconButton } from './FormField';\nimport { FormFieldLabel } from './FormRow';\n\nexport type FormFieldHeaderProps = {\n label: string;\n /** JSON path forwarded to the label as field metadata. */\n path?: string;\n required?: boolean;\n readonly?: boolean;\n classNames?: string;\n /** Trailing inline add affordance; omit to hide it. */\n add?: { icon?: string; label: string; disabled?: boolean; onClick: () => void };\n /** Extra trailing controls placed after the add affordance (e.g. a collapse toggle). */\n actions?: ReactNode;\n /** Header row click (e.g. toggle collapse). The add affordance stops propagation so it doesn't trigger this. */\n onClick?: () => void;\n};\n\n/**\n * Header row for a labelled group or list: a label with optional trailing controls (an inline add\n * affordance and/or arbitrary `actions`). Shared by array/list fields ({@link ArrayField}, the view\n * editor) and {@link FormFieldSetContainer}'s collapse header, so all group/list headers render identically.\n */\nexport const FormFieldHeader = ({\n label,\n path,\n required,\n readonly,\n classNames,\n add,\n actions,\n onClick,\n}: FormFieldHeaderProps) => (\n <FormFieldLabel\n standalone\n classNames={classNames}\n label={label}\n required={required}\n readonly={readonly}\n path={path}\n button={\n (!readonly && add) || actions ? (\n <>\n {!readonly && add && (\n <CompactIconButton\n disabled={add.disabled}\n icon={add.icon ?? 'ph--plus--regular'}\n label={add.label}\n onClick={(event) => {\n // Don't let the add click bubble to the header's onClick (e.g. collapse toggle).\n event.stopPropagation();\n add.onClick();\n }}\n />\n )}\n {actions}\n </>\n ) : undefined\n }\n onClick={onClick}\n />\n);\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { format as formatDate } from 'date-fns';\nimport React, { Component, type PropsWithChildren, type ReactNode, type Ref } from 'react';\n\nimport { Format } from '@dxos/echo';\nimport { Icon, Input, type ThemedClassName, Tooltip } from '@dxos/react-ui';\nimport { mx } from '@dxos/ui-theme';\n\nimport { type FormFieldRendererProps } from '#types';\n\nimport { useFormContext } from '../../../hooks';\nimport { type FormVariant, formTheme } from '../Form.theme';\nimport { type FormFieldPresentation, presentationFor } from './presentation';\n\n//\n// FormFieldLabel\n//\n\nexport type FormFieldLabelProps = ThemedClassName<\n {\n /** Render a plain `<span>` instead of an input-associated `Input.Label`, for labels used outside an `Input.Root` (e.g. section/group headers). */\n standalone?: boolean;\n /** Class applied to the inner label text node, overriding the default size/color (e.g. `text-lg`). */\n labelClassName?: string;\n /** Form variant; selects the label's chrome (e.g. `settings` enlarges the text and places it in the field grid). */\n variant?: FormVariant;\n error?: string;\n /**\n * JSON path of the field this label describes (e.g. `runtime.client.storage.persistent`).\n * Field metadata; accepted by callers but not currently rendered.\n */\n path?: string;\n /**\n * Trailing button rendered at the end of the label row (third grid column).\n * Used by nested-object field sets to surface a collapse toggle.\n */\n button?: ReactNode;\n onClick?: () => void;\n } & Pick<FormFieldRendererProps, 'label' | 'readonly' | 'required'>\n>;\n\nexport const FormFieldLabel = ({\n classNames,\n labelClassName,\n variant = 'default',\n label,\n error,\n readonly,\n required,\n standalone,\n button,\n onClick,\n}: FormFieldLabelProps) => {\n const styles = formTheme.styles({ variant });\n // Render the required asterisk via a `::after` pseudo-element rather than a DOM node: it keeps the\n // label's `textContent` exactly `label`, so fields stay locatable by their exact label text\n // (`getByLabelText('Name')`), which the DOM-text-based query would otherwise miss as `Name *`.\n // The `fieldLabelText` slot is applied last so a variant/caller size/color (e.g. `text-lg`) wins over\n const labelClassNames = mx(\n 'text-sm text-description',\n required && \"after:content-['*'] after:ms-0.5 after:text-warning-text\",\n styles.fieldLabelText({ class: labelClassName }),\n );\n\n // `Input.Label` is a themed primitive that reads `classNames` (and ignores `className`), whereas the\n // plain `span` used for read-only/standalone labels reads `className`.\n const labelNode =\n readonly || standalone ? (\n <span className={labelClassNames}>{label}</span>\n ) : (\n <Input.Label classNames={labelClassNames}>{label}</Input.Label>\n );\n\n return (\n <div className={styles.fieldLabel({ class: mx(onClick && 'cursor-pointer', classNames) })} onClick={onClick}>\n {labelNode}\n {error ? (\n <Tooltip.Trigger asChild content={error} side='bottom'>\n <Icon icon='ph--warning--regular' size={4} classNames='text-error-text' />\n </Tooltip.Trigger>\n ) : (\n <span />\n )}\n {button}\n </div>\n );\n};\n\nFormFieldLabel.displayName = 'Form.FieldLabel';\n\n//\n// FormRow\n//\n\n/**\n * Formats a value for `static` (read-only, plain-DOM) presentation based on its\n * type `format`. Dates/times are rendered human-readable; everything else falls\n * back to `String(value)`.\n */\nconst formatStaticValue = (value: unknown, format?: Format.TypeFormat): string => {\n if (value == null) {\n return '';\n }\n\n switch (format) {\n case Format.TypeFormat.DateTime:\n case Format.TypeFormat.Date:\n case Format.TypeFormat.Time: {\n const date = new Date(value as string);\n if (Number.isNaN(date.getTime())) {\n return String(value);\n }\n const pattern = format === Format.TypeFormat.DateTime ? 'PPp' : format === Format.TypeFormat.Date ? 'PP' : 'p';\n return formatDate(date, pattern);\n }\n default:\n return String(value);\n }\n};\n\nconst FORM_ROW_NAME = 'Form.Row';\n\nexport type FormRowProps<T = any> = ThemedClassName<\n Pick<FormFieldRendererProps<T>, 'readonly' | 'label' | 'description' | 'presentation' | 'required'> &\n Partial<Pick<FormFieldRendererProps<T>, 'getStatus' | 'getValue' | 'jsonPath' | 'format'>> & {\n /**\n * Ref to the row's outer element. Enables measurement/positioning (e.g. a future virtualized\n * field set) without forwarding through the generic component.\n */\n rootRef?: Ref<HTMLDivElement>;\n /**\n * Render the label as a standalone `<span>` (group/multi-input fields with no single associated control).\n */\n standalone?: boolean;\n /**\n * Override the read-only/`static` rendering of the value. Fields whose value is not plain text\n * (refs, selects, markdown) supply this; the default formats scalars/dates via `formatStaticValue`.\n * Return `null` to render nothing (e.g. an empty/unresolved value).\n */\n renderStatic?: (value: T | undefined) => ReactNode;\n /**\n * Validation/error content rendered in the validation slot. Supplied directly in action mode; in\n * field mode it is derived from `getStatus`.\n */\n validation?: ReactNode;\n /**\n * The control. A render-prop binds to the form value (field mode: `Input.Root` validation, static\n * rendering, value via `getValue`). Plain nodes render an arbitrary control with no value wiring\n * (action mode, e.g. a button) — the labeled-card escape hatch for an arbitrary control.\n *\n * `value` is `T | undefined` because `getValue()` returns no value when the field is unset (optional\n * schema properties, freshly-added array items); renderers default it (e.g. `{ value = '' }`).\n */\n children?: ReactNode | ((props: { value: T | undefined; presentation: FormFieldPresentation }) => ReactNode);\n }\n>;\n\n/**\n * A labeled card row — the single shell behind both schema fields and free-form \"action\" rows. Field\n * renderers pass a render-prop `children` (field mode: bound to the form value, with validation and\n * static rendering); consumers pass plain `children` for an arbitrary control (action mode), the\n * affordance for an arbitrary labeled control (action rows, settings cards).\n */\nexport const FormRow = <T,>({\n classNames,\n children,\n readonly,\n presentation,\n label,\n description,\n jsonPath,\n format,\n required,\n standalone,\n renderStatic,\n validation,\n getStatus,\n getValue,\n rootRef,\n}: FormRowProps<T>) => {\n const { variant = 'default' } = useFormContext(FORM_ROW_NAME);\n const styles = formTheme.styles({ variant });\n const { showDescription } = formTheme.behavior[variant];\n const resolved = presentationFor(presentation);\n\n //\n // Field mode: a render-prop control bound to the form value.\n //\n if (typeof children === 'function' && getStatus && getValue) {\n const { status, error } = getStatus();\n const value: T | undefined = getValue();\n if (resolved.isStatic && value == null) {\n return null;\n }\n\n const control = resolved.isStatic\n ? (renderStatic?.(value) ?? <p className='truncate min-w-0'>{formatStaticValue(value, format)}</p>)\n : children({ value, presentation: resolved });\n\n return (\n <Input.Root validationValence={status}>\n <div className={styles.field({ class: classNames })} ref={rootRef}>\n {resolved.showLabel && (\n <FormFieldLabel\n variant={variant}\n error={error}\n readonly={readonly}\n required={required}\n standalone={standalone}\n label={label}\n path={jsonPath}\n />\n )}\n {showDescription && description && (\n <Input.Description classNames={styles.fieldDescription()}>{description}</Input.Description>\n )}\n <div className={styles.fieldControl()}>{control}</div>\n {resolved.showError && error && (\n <div className={styles.fieldValidation()}>\n <Input.DescriptionAndValidation>\n <Input.Validation>{error}</Input.Validation>\n </Input.DescriptionAndValidation>\n </div>\n )}\n </div>\n </Input.Root>\n );\n }\n\n //\n // Action mode: an arbitrary control with a standalone label; no value/`Input.Root` wiring.\n //\n return (\n <div ref={rootRef} className={styles.field({ class: classNames })}>\n {resolved.showLabel && label && (\n <FormFieldLabel\n variant={variant}\n readonly={readonly}\n required={required}\n standalone\n label={label}\n path={jsonPath}\n />\n )}\n {showDescription && description && <p className={styles.fieldDescription()}>{description}</p>}\n <div className={styles.fieldControl()}>{typeof children === 'function' ? null : children}</div>\n {validation && <div className={styles.fieldValidation()}>{validation}</div>}\n </div>\n );\n};\n\nFormRow.displayName = FORM_ROW_NAME;\n\n//\n// FormFieldErrorBoundary\n//\n\ntype FormFieldErrorState = {\n error: Error | undefined;\n};\n\ntype FormFieldErrorBoundaryProps = PropsWithChildren<{\n path?: (string | number)[];\n}>;\n\nexport class FormFieldErrorBoundary extends Component<FormFieldErrorBoundaryProps, FormFieldErrorState> {\n static getDerivedStateFromError(error: Error): { error: Error } {\n return { error };\n }\n\n override state = { error: undefined };\n\n override componentDidUpdate(prevProps: FormFieldErrorBoundaryProps) {\n if (prevProps.path !== this.props.path) {\n this.resetError();\n }\n }\n\n override render() {\n if (this.state.error) {\n return (\n <div className='flex gap-2 border border-error-border font-mono text-sm'>\n <span className='bg-error-bg text-base-fg px-1 font-thin'>ERROR</span>\n {String(this.props.path?.join('.'))}\n </div>\n );\n }\n\n return this.props.children;\n }\n\n private resetError() {\n this.setState({ error: undefined });\n }\n}\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { type FormPresentation } from '#types';\n\n/**\n * Resolved presentation strategy for a field — which parts render, derived from {@link FormPresentation}.\n * Visual chrome (borders, grid, spacing) is owned by the Form theme recipe, not here.\n */\nexport type FormFieldPresentation = {\n layout?: FormPresentation;\n /** Render the value as read-only plain DOM rather than an editable control. */\n isStatic: boolean;\n /** Render the field's label row. */\n showLabel: boolean;\n /** Render the inline validation/error block beneath the control. */\n showError: boolean;\n};\n\n/**\n * Derive the {@link FormFieldPresentation} for a layout.\n * - `static` renders read-only plain DOM.\n * - `inline` drops the label (the control stands alone, e.g. an array row).\n * - `full` adds the inline error block.\n */\nexport const presentationFor = (layout?: FormPresentation): FormFieldPresentation => ({\n layout,\n isStatic: layout === 'static',\n showLabel: layout !== 'inline',\n showError: layout === 'full',\n});\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { useEffect, useMemo, useRef } from 'react';\n\nimport { type AnyProperties } from '@dxos/echo/internal';\n\nimport { type FormFieldRendererProps } from '#types';\n\nimport { type OptionsLookup, type OptionsLookupEntry } from '../../../../../annotations';\nimport { pickValues, useAsyncFieldEffect, useFormValues } from '../../../../../hooks';\nimport { SelectField } from '../SelectField';\n\nexport type AsyncSelectFieldProps = FormFieldRendererProps<string> & {\n /** Loads the selectable options from the lookup's declared dependency fields. */\n lookup: OptionsLookup;\n};\n\n/**\n * A select whose options are loaded dynamically (debounced) from the fields the lookup declares in its\n * `deps`, via an {@link Annotation.OptionsLookup}. Re-runs only when one of those values changes.\n * Auto-selects the sole option when exactly one resolves and nothing is chosen yet.\n */\nexport const AsyncSelectField = ({ lookup, ...fieldProps }: AsyncSelectFieldProps) => {\n const values = useFormValues<AnyProperties>(AsyncSelectField.displayName);\n const subset = useMemo(() => pickValues(values, lookup.deps), [values, lookup.deps]);\n const key = useMemo(() => JSON.stringify(subset), [subset]);\n const { loading, data } = useAsyncFieldEffect<readonly OptionsLookupEntry[]>(() => lookup.load(subset), key);\n const options = data ?? [];\n\n const { type, placeholder } = fieldProps;\n const current = fieldProps.getValue();\n // `onValueChange` changes identity on every edit; hold it in a ref so auto-select depends only on the\n // resolved `data` and current value (avoids an effect-refire loop).\n const onValueChangeRef = useRef(fieldProps.onValueChange);\n onValueChangeRef.current = fieldProps.onValueChange;\n // Track which `data` reference has already been auto-selected so clearing the field does not trigger\n // repeated re-selection of the same single option.\n const autoSelectedDataRef = useRef<typeof data>(undefined);\n useEffect(() => {\n if ((current == null || current === '') && data?.length === 1 && data !== autoSelectedDataRef.current) {\n autoSelectedDataRef.current = data;\n onValueChangeRef.current(type, data[0].value);\n }\n }, [current, data, type]);\n\n const resolvedPlaceholder = loading ? 'Loading…' : options.length === 0 ? 'No options available' : placeholder;\n\n return (\n <SelectField\n {...fieldProps}\n placeholder={resolvedPlaceholder}\n options={options.map(({ value, label, secondaryLabel, icon }) => ({ value, label, secondaryLabel, icon }))}\n />\n );\n};\n\nAsyncSelectField.displayName = 'Form.AsyncSelectField';\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useCallback } from 'react';\n\nimport { invariant } from '@dxos/invariant';\nimport { Icon, Select, type SelectRootProps } from '@dxos/react-ui';\nimport { getStyles } from '@dxos/ui-theme';\n\nimport { type FormFieldRenderer, type FormFieldRendererProps } from '#types';\n\nimport { FormRow } from '../../FormRow';\n\nexport type SelectFieldOptions = FormFieldRendererProps & {\n options?: Array<{ value: string | number; label?: string; secondaryLabel?: string; icon?: string; iconHue?: string }>;\n};\n\nexport const SelectField = ({ type, readonly, placeholder, options, onValueChange, ...props }: SelectFieldOptions) => {\n const handleValueChange = useCallback<NonNullable<SelectRootProps['onValueChange']>>(\n (value) => onValueChange(type, value),\n [type, onValueChange],\n );\n\n return (\n <FormRow<string>\n readonly={readonly}\n renderStatic={(value) => (\n <p className='truncate min-w-0'>\n {options?.find(({ value: optionValue }) => optionValue === value)?.label ?? String(value)}\n </p>\n )}\n {...props}\n >\n {({ value }) => (\n <Select.Root value={value} onValueChange={handleValueChange}>\n <Select.TriggerButton classNames='w-full' disabled={!!readonly} placeholder={placeholder} />\n {options?.length !== 0 && (\n <Select.Portal>\n <Select.Content>\n <Select.Viewport>\n {options?.map(({ value, label, secondaryLabel, icon, iconHue }) => (\n // NOTE: Numeric values are converted to and from strings.\n <Select.Option key={String(value)} value={String(value)}>\n <span className='flex items-center flex-row gap-2'>\n {icon && <Icon icon={icon} classNames={getIconHueStyles(iconHue)} />}\n {label ?? String(value)}\n {secondaryLabel && <span className='text-subdued text-xs'>{secondaryLabel}</span>}\n </span>\n </Select.Option>\n ))}\n </Select.Viewport>\n <Select.Arrow />\n </Select.Content>\n </Select.Portal>\n )}\n </Select.Root>\n )}\n </FormRow>\n );\n};\n\nconst getIconHueStyles = (iconHue?: string): string | undefined => {\n const styles = iconHue ? getStyles(iconHue) : undefined;\n\n return styles?.fg;\n};\n\nexport type SelectFieldOption = {\n value: string;\n label?: string;\n};\n\nexport type CreateSelectFieldOptions = {\n /** Options to display. Strings are used as both value and label. */\n options: ReadonlyArray<string | SelectFieldOption>;\n /** Label for the sentinel option that maps to `undefined`. Defaults to `'Default'`. Pass `null` to omit. */\n defaultLabel?: string | null;\n};\n\n/**\n * Factory for a `fieldMap` entry (keyed by JSON path) that renders a Select over a fixed list of\n * options, with an optional sentinel mapping to `undefined`. Use for fields whose choices come from a\n * runtime list rather than the schema (e.g. available model ids).\n */\nexport const createSelectField = ({\n options,\n defaultLabel = 'Default',\n}: CreateSelectFieldOptions): FormFieldRenderer => {\n const normalized = options.map((option) => (typeof option === 'string' ? { value: option, label: option } : option));\n const hasDefault = defaultLabel !== null;\n // The sentinel maps to `undefined`. Radix forbids an empty-string `Select.Item` value, so use a\n // non-empty placeholder; reserved (a real option with this value would be unrepresentable).\n const sentinel = '__default__';\n invariant(\n !normalized.some((option) => option.value === sentinel),\n `createSelectField: option value '${sentinel}' is reserved.`,\n );\n\n return ({ type, readonly, onValueChange, ...props }: FormFieldRendererProps<string | undefined>) => (\n <FormRow<string>\n readonly={readonly}\n renderStatic={(value) => (\n <p className='truncate min-w-0'>\n {normalized.find((option) => option.value === value)?.label ?? String(value ?? '')}\n </p>\n )}\n {...props}\n >\n {({ value }) => (\n <Select.Root\n disabled={!!readonly}\n value={value ?? sentinel}\n onValueChange={(next) => onValueChange(type, hasDefault && next === sentinel ? undefined : next)}\n >\n <Select.TriggerButton classNames='w-full' disabled={!!readonly} />\n {normalized.length > 0 && (\n <Select.Portal>\n <Select.Content>\n <Select.Viewport>\n {hasDefault && <Select.Option value={sentinel}>{defaultLabel}</Select.Option>}\n {normalized.map((option) => (\n <Select.Option key={option.value} value={option.value}>\n {option.label ?? option.value}\n </Select.Option>\n ))}\n </Select.Viewport>\n <Select.Arrow />\n </Select.Content>\n </Select.Portal>\n )}\n </Select.Root>\n )}\n </FormRow>\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { useEffect, useMemo, useRef } from 'react';\n\nimport { type AnyProperties } from '@dxos/echo/internal';\n\nimport { type FormFieldRendererProps } from '#types';\n\nimport { type Autofill } from '../../../../../annotations';\nimport { pickValues, useAsyncFieldEffect, useFormValues } from '../../../../../hooks';\nimport { TextField } from '../TextField';\n\nexport type AutofillFieldProps = FormFieldRendererProps<string> & {\n /** Derives this field's value from the autofill's declared dependency fields (e.g. a sibling URL). */\n autofill: Autofill;\n};\n\n/**\n * An editable text field that pre-fills its value (debounced) from the fields the autofill declares in\n * its `deps`, via an {@link Autofill}. Re-runs only when one of those values changes. The\n * derived value is written only while the user has not typed their own (the field is empty or still\n * holds the last auto-filled value), so a manual edit is never clobbered.\n */\nexport const AutofillField = ({ autofill, ...fieldProps }: AutofillFieldProps) => {\n const values = useFormValues<AnyProperties>(AutofillField.displayName);\n const subset = useMemo(() => pickValues(values, autofill.deps), [values, autofill.deps]);\n const key = useMemo(() => JSON.stringify(subset), [subset]);\n const { data } = useAsyncFieldEffect<string | undefined>(() => autofill.derive(subset), key);\n\n // Read field state through refs so the write effect depends only on the derived `data` — `getValue`\n // and `onValueChange` change identity on every value edit, and depending on them would re-fire the\n // effect after it writes, re-applying the same value in an infinite loop.\n const { type } = fieldProps;\n const getValueRef = useRef(fieldProps.getValue);\n getValueRef.current = fieldProps.getValue;\n const onValueChangeRef = useRef(fieldProps.onValueChange);\n onValueChangeRef.current = fieldProps.onValueChange;\n const lastFilledRef = useRef<string | undefined>(undefined);\n\n useEffect(() => {\n const current = getValueRef.current();\n if (typeof data !== 'string' || data.length === 0) {\n // Derivation stopped returning a value — clear the field if it still holds our last fill so stale\n // auto-filled text doesn't persist after the source field is cleared.\n if (lastFilledRef.current != null && current === lastFilledRef.current) {\n lastFilledRef.current = undefined;\n onValueChangeRef.current(type, '');\n }\n return;\n }\n if (current === data) {\n lastFilledRef.current = data;\n return;\n }\n // Only fill while the user has not typed their own value (empty, or still our last fill).\n if (current == null || current === '' || current === lastFilledRef.current) {\n lastFilledRef.current = data;\n onValueChangeRef.current(type, data);\n }\n }, [data, type]);\n\n return <TextField {...fieldProps} />;\n};\n\nAutofillField.displayName = 'Form.AutofillField';\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useCallback } from 'react';\n\nimport { Input, type TextInputProps } from '@dxos/react-ui';\n\nimport { type FormFieldRendererProps } from '#types';\n\nimport { FormRow } from '../../FormRow';\n\nexport const TextField = ({\n type,\n readonly,\n placeholder,\n onBlur,\n onValueChange,\n ...props\n}: FormFieldRendererProps<string>) => {\n const handleChange = useCallback<NonNullable<TextInputProps['onChange']>>(\n (event) => onValueChange(type, event.target.value),\n [type, onValueChange],\n );\n\n return (\n <FormRow<string> readonly={readonly} {...props}>\n {({ value = '' }) => (\n <Input.TextInput\n noAutoFill\n disabled={!!readonly}\n placeholder={placeholder}\n value={value}\n onBlur={onBlur}\n onChange={handleChange}\n />\n )}\n </FormRow>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useCallback } from 'react';\n\nimport { Input, type SwitchProps } from '@dxos/react-ui';\n\nimport { type FormFieldRendererProps } from '#types';\n\nimport { FormRow } from '../../FormRow';\n\nexport const BooleanField = ({ type, readonly, onValueChange, ...props }: FormFieldRendererProps<boolean>) => {\n const handleChange = useCallback<NonNullable<SwitchProps['onCheckedChange']>>(\n (value) => onValueChange?.(type, value),\n [type, onValueChange],\n );\n\n return (\n <FormRow<boolean> readonly={readonly} {...props}>\n {({ value }) => (\n <Input.Block>\n <Input.Switch disabled={!!readonly} checked={value} onCheckedChange={handleChange} />\n </Input.Block>\n )}\n </FormRow>\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { useCallback, useMemo, useState } from 'react';\n\nimport { type AnyProperties } from '@dxos/echo/internal';\nimport { Combobox } from '@dxos/react-ui-list';\n\nimport { type FormFieldRendererProps } from '#types';\n\nimport { type OptionsLookup, type OptionsLookupEntry } from '../../../../../annotations';\nimport { pickValues, useAsyncFieldEffect, useFormValues } from '../../../../../hooks';\nimport { FormRow } from '../../FormRow';\n\nexport type ComboboxFieldProps = FormFieldRendererProps<string> & {\n /** Loads suggestions from the lookup's declared dependency fields (typically the field's own value). */\n lookup: OptionsLookup;\n};\n\n/**\n * An editable combobox built on the shared {@link Combobox} primitive (trigger + popover search list,\n * the same family as `ObjectPicker`/`SearchList`). The trigger shows the current value; opening it reveals\n * a search input that loads suggestions (debounced) via an {@link OptionsLookup} and filters\n * them as you type. The literal typed text is offered as a fallback option at the bottom (deduped), so a\n * value not among the suggestions can still be selected. No options are shown until something is typed.\n */\nexport const ComboboxField = ({ lookup, type, readonly, placeholder, onValueChange, ...props }: ComboboxFieldProps) => {\n const values = useFormValues<AnyProperties>(ComboboxField.displayName);\n const ownKey = props.jsonPath;\n const [query, setQuery] = useState('');\n\n // When the combobox searches on its own field (its name is among `deps`), feed the live query to the\n // loader so remote suggestions track typing; otherwise the loader reads the committed sibling values.\n const lookupValues = useMemo(() => {\n const subset = pickValues(values, lookup.deps);\n if (ownKey && lookup.deps.includes(ownKey)) {\n subset[ownKey] = query;\n }\n return subset;\n }, [values, lookup.deps, ownKey, query]);\n const key = useMemo(() => JSON.stringify(lookupValues), [lookupValues]);\n const { data } = useAsyncFieldEffect<readonly OptionsLookupEntry[]>(() => lookup.load(lookupValues), key);\n\n const trimmed = query.trim();\n const normalized = trimmed.toLowerCase();\n // No options until something is typed; then filter the loaded suggestions by the input text.\n const results = useMemo(\n () =>\n normalized.length === 0\n ? []\n : (data ?? []).filter((option) => (option.label ?? option.value).toLowerCase().includes(normalized)),\n [data, normalized],\n );\n const hasExact = results.some((option) => option.value === trimmed);\n\n const handleValueChange = useCallback((next: string) => onValueChange(type, next), [onValueChange, type]);\n const handleOpenChange = useCallback((open: boolean) => {\n if (!open) {\n setQuery('');\n }\n }, []);\n\n return (\n <FormRow<string>\n readonly={readonly}\n renderStatic={(value) => <p className='truncate min-w-0'>{value ?? ''}</p>}\n {...props}\n >\n {({ value = '' }) => (\n <Combobox.Root\n value={value}\n onValueChange={handleValueChange}\n onOpenChange={handleOpenChange}\n placeholder={placeholder}\n >\n {/* Full-width trigger (default renders value/placeholder + caret) to match the other fields. */}\n <Combobox.Trigger disabled={!!readonly} classNames='w-full' />\n <Combobox.Portal>\n {/* Keep the first result highlighted as the list changes while typing. */}\n <Combobox.Content resetSelectionOnChange>\n <Combobox.Input autoFocus value={query} onValueChange={setQuery} placeholder={placeholder} />\n <Combobox.List>\n {results.map((option) => (\n <Combobox.Item\n key={option.value}\n value={option.value}\n label={option.label ?? option.value}\n suffix={option.secondaryLabel}\n />\n ))}\n {/* The literal typed text as a fallback option at the bottom, unless a suggestion already is it. */}\n {normalized.length > 0 && !hasExact && <Combobox.Item value={trimmed} label={trimmed} />}\n </Combobox.List>\n <Combobox.Arrow />\n </Combobox.Content>\n </Combobox.Portal>\n </Combobox.Root>\n )}\n </FormRow>\n );\n};\n\nComboboxField.displayName = 'Form.ComboboxField';\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { format as formatDate } from 'date-fns';\nimport React, { useCallback } from 'react';\n\nimport { Format } from '@dxos/echo';\nimport { Input } from '@dxos/react-ui';\n\nimport { type FormFieldRendererProps } from '#types';\n\nimport { FormRow } from '../../FormRow';\n\n/**\n * Stored value shapes:\n * - `Format.DateTime` -> ISO 8601 (`2018-11-13T20:20:39.000Z`).\n * - `Format.Date` -> `YYYY-MM-DD`.\n * - `Format.Time` -> `HH:mm:ss`.\n *\n * Segmented input value shapes (react-aria-components-backed):\n * - `Input.DateTime` -> `YYYY-MM-DDTHH:mm` in local time.\n * - `Input.Date` -> `YYYY-MM-DD`.\n * - `Input.Time` -> `HH:mm`.\n */\n\n/** ISO 8601 → `YYYY-MM-DDTHH:mm` in the user's local timezone. */\nconst isoToLocalDateTime = (value: string | undefined): string => {\n if (!value) {\n return '';\n }\n const date = new Date(value);\n if (Number.isNaN(date.getTime())) {\n return '';\n }\n return formatDate(date, \"yyyy-MM-dd'T'HH:mm\");\n};\n\n/** `YYYY-MM-DDTHH:mm` (local) → ISO 8601 with timezone. */\nconst localDateTimeToIso = (value: string): string | undefined => {\n if (!value) {\n return undefined;\n }\n // Treat the input as local time. `new Date('YYYY-MM-DDTHH:mm')` parses as local.\n const date = new Date(value);\n return Number.isNaN(date.getTime()) ? undefined : date.toISOString();\n};\n\nexport const DateField = ({\n type,\n format,\n readonly,\n placeholder: _placeholder,\n onValueChange,\n onBlur: _onBlur,\n ...props\n}: FormFieldRendererProps<string>) => {\n const handleSimpleChange = useCallback((next: string) => onValueChange(type, next), [type, onValueChange]);\n\n const handleDateTimeChange = useCallback(\n (next: string) => {\n const iso = localDateTimeToIso(next);\n onValueChange(type, iso as string);\n },\n [type, onValueChange],\n );\n\n return (\n <FormRow<string> {...props} readonly={readonly} format={format}>\n {({ value }) => {\n switch (format) {\n case Format.TypeFormat.Date:\n return (\n <div className='grid grid-cols-[minmax(0,1fr)_min-content] gap-1 items-stretch'>\n <Input.Date\n classNames='min-w-0 overflow-hidden'\n disabled={readonly}\n value={value ?? ''}\n onValueChange={handleSimpleChange}\n />\n <Input.TriggerIcon />\n </div>\n );\n case Format.TypeFormat.Time:\n return <Input.Time disabled={!!readonly} value={value ?? ''} onValueChange={handleSimpleChange} />;\n case Format.TypeFormat.DateTime:\n default:\n return (\n <div className='grid grid-cols-[minmax(0,1fr)_min-content] gap-1 items-stretch'>\n <Input.DateTime\n classNames='min-w-0 overflow-hidden'\n disabled={readonly}\n value={isoToLocalDateTime(value)}\n onValueChange={handleDateTimeChange}\n />\n <Input.TriggerIcon />\n </div>\n );\n }\n }}\n </FormRow>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { type ChangeEvent, useCallback, useEffect, useMemo, useState } from 'react';\n\nimport { GeoLocation, type GeoPoint } from '@dxos/echo/Format';\nimport { Input, useTranslation } from '@dxos/react-ui';\nimport { safeParseFloat } from '@dxos/util';\n\nimport { translationKey } from '#translations';\nimport { type FormFieldRendererProps } from '#types';\n\nimport { FormRow } from '../../FormRow';\n\nexport const GeoPointField = ({\n type,\n readonly,\n getValue,\n onValueChange,\n onBlur,\n ...props\n}: FormFieldRendererProps<GeoPoint>) => {\n const { t } = useTranslation(translationKey);\n const geoPoint = useMemo<GeoPoint>(() => getValue() ?? [0, 0], [getValue]);\n const value = useMemo(() => GeoLocation.fromGeoPoint(geoPoint), [geoPoint]);\n\n const [longitudeText, setLongitudeText] = useState(value.longitude?.toString());\n const [latitudeText, setLatitudeText] = useState(value.latitude?.toString());\n useEffect(() => {\n const location = GeoLocation.fromGeoPoint(geoPoint);\n setLongitudeText(location.longitude?.toString());\n setLatitudeText(location.latitude?.toString());\n }, [geoPoint]);\n\n const handleChange = useCallback(\n (coordinateType: keyof Pick<GeoLocation, 'longitude' | 'latitude'>, setText: (text: string) => void) =>\n (event: ChangeEvent<HTMLInputElement>) => {\n const inputText = event.target.value;\n setText(inputText);\n if (inputText !== '' && inputText !== '-') {\n const coord = safeParseFloat(inputText);\n if (coord !== undefined && !isNaN(coord)) {\n const currentLocation = GeoLocation.fromGeoPoint(getValue() ?? [0, 0]);\n const newLocation = { ...currentLocation, [coordinateType]: coord };\n const newValue = GeoLocation.toGeoPoint(newLocation);\n onValueChange(type, newValue);\n }\n }\n },\n [type, getValue, onValueChange],\n );\n\n return (\n <FormRow<GeoPoint>\n readonly={readonly}\n getValue={getValue}\n standalone\n renderStatic={(point) => {\n const location = GeoLocation.fromGeoPoint(point ?? [0, 0]);\n // Treat a zero coordinate pair as empty (no meaningful location to display).\n return !location.latitude && !location.longitude ? null : <LatLng {...location} />;\n }}\n {...props}\n >\n {({ presentation }) => (\n <div className='grid grid-cols-2 gap-form-gap'>\n <div>\n <Input.Root>\n {presentation.showLabel && <Input.Label>{t('latitude.label')}</Input.Label>}\n <Input.TextInput\n type='number'\n step='0.00001'\n min='-90'\n max='90'\n disabled={!!readonly}\n placeholder={t('latitude.placeholder')}\n value={latitudeText ?? ''}\n onChange={handleChange('latitude', setLatitudeText)}\n onBlur={onBlur}\n />\n </Input.Root>\n </div>\n <div>\n <Input.Root>\n {presentation.showLabel && <Input.Label>{t('longitude.label')}</Input.Label>}\n <Input.TextInput\n type='number'\n step='0.00001'\n min='-180'\n max='180'\n disabled={!!readonly}\n placeholder={t('longitude.placeholder')}\n value={longitudeText ?? ''}\n onChange={handleChange('longitude', setLongitudeText)}\n onBlur={onBlur}\n />\n </Input.Root>\n </div>\n </div>\n )}\n </FormRow>\n );\n};\n\nconst LatLng = ({ latitude = 0, longitude = 0 }: GeoLocation) => {\n const latHem = latitude >= 0 ? 'N' : 'S';\n const lngHem = longitude >= 0 ? 'E' : 'W';\n\n return (\n <span className='inline-flex items-center gap-form-gap'>\n <span>\n <span>{Math.abs(latitude).toFixed(5)}</span>\n <span className='text-subdued'>°{latHem}</span>\n </span>\n <span>\n <span>{Math.abs(longitude).toFixed(5)}</span>\n <span className='text-subdued'>°{lngHem}</span>\n </span>\n </span>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { useAtomValue } from '@effect-atom/atom-react';\nimport React, { useCallback, useMemo } from 'react';\n\nimport { type Database, Ref } from '@dxos/echo';\nimport { Doc } from '@dxos/echo-doc';\nimport { IconButton, useTranslation } from '@dxos/react-ui';\nimport { Editor, useBasicMarkdownExtensions } from '@dxos/react-ui-editor';\nimport { Text } from '@dxos/schema';\nimport { createDataExtensions } from '@dxos/ui-editor';\n\nimport { translationKey } from '#translations';\nimport { type FormFieldRendererProps } from '#types';\n\nimport { FormRow } from '../../FormRow';\n\n// Mirror the focus treatment of `Input` (default variant): a `focus-ring-subtle` ring of `dx-focus-line`\n// width rather than a recolored 1px border, and suppress the editor wrapper's `accent-bg` border so a\n// second click never turns the outline blue. Keyed on `focus-within` because focus lands on the inner\n// CodeMirror contenteditable, not this wrapper.\nconst editorClassNames = [\n 'min-h-[6lh] transition-colors rounded-xs p-1 px-2 bg-input-surface border border-input-separator',\n 'focus:border-separator focus-within:border-separator focus-within:bg-focus-surface',\n 'focus-within:ring-2 focus-within:ring-offset-0 focus-within:ring-focus-ring-subtle focus-within:z-[1]',\n];\n\n/**\n * Form field that edits a markdown value in a CodeMirror editor.\n * Supports two backings:\n * - `Schema.String` annotated with `Format.TypeFormat.Markdown`: edited as plain text via `getValue`/`onValueChange`.\n * - `Ref<Text>` annotated with `Format.TypeFormat.Markdown`: edited in-place via an Automerge doc accessor.\n * When the ref is empty and a database is available, a create button is shown to allocate a new Text.\n */\nexport const MarkdownField = ({\n type,\n readonly,\n placeholder,\n db,\n getValue,\n onValueChange,\n ...props\n}: FormFieldRendererProps) => {\n const isRef = Ref.isRefType(type);\n\n // The field value is a runtime union the form's value type can't express: a `Ref<Text>` when the\n // property is a markdown ref, or a plain string when it is annotated markdown text. `isRef`\n // selects the branch, so the casts below narrow the opaque value accordingly.\n const renderStatic = (value: unknown) => {\n if (isRef) {\n const reference = value as Ref.Ref<any> | undefined;\n return reference ? <RefStaticText reference={reference} /> : null;\n }\n return <p className='whitespace-pre-wrap'>{(value as string | undefined) ?? ''}</p>;\n };\n\n const renderEditor = (value: unknown) => {\n if (isRef) {\n const reference = value as Ref.Ref<any> | undefined;\n if (reference) {\n return <RefMarkdownEditor reference={reference} placeholder={placeholder} readonly={!!readonly} />;\n }\n\n if (readonly) {\n return null;\n }\n\n return <CreateTextButton db={db} disabled={!db} onCreate={(ref) => onValueChange(type, ref)} />;\n }\n\n return (\n <StringMarkdownEditor\n value={(value as string | undefined) ?? ''}\n placeholder={placeholder}\n readonly={!!readonly}\n onChange={(next) => onValueChange(type, next)}\n />\n );\n };\n\n return (\n <FormRow readonly={readonly} getValue={getValue} renderStatic={renderStatic} {...props}>\n {({ value }) => renderEditor(value)}\n </FormRow>\n );\n};\n\n/** Read-only static rendering for a `Ref<Text>` value: resolve the ref and print its content. */\nconst RefStaticText = ({ reference }: { reference: Ref.Ref<any> }) => {\n const text = useAtomValue(useMemo(() => reference.atom, [reference]));\n if (!text?.content) {\n return null;\n }\n\n return <p className='whitespace-pre-wrap'>{text.content}</p>;\n};\n\ntype RefMarkdownEditorProps = {\n reference: Ref.Ref<any>;\n placeholder?: string;\n readonly?: boolean;\n};\n\nconst RefMarkdownEditor = ({ reference, placeholder, readonly }: RefMarkdownEditorProps) => {\n const text = useAtomValue(useMemo(() => reference.atom, [reference]));\n const dataExtensions = useMemo(\n () => (text ? [createDataExtensions({ id: reference.uri, text: Doc.createAccessor(text, ['content']) })] : []),\n [text, reference],\n );\n const extensions = useBasicMarkdownExtensions({ placeholder, readonly, extensions: dataExtensions });\n if (!text) {\n return null;\n }\n\n return (\n <Editor.Root>\n <Editor.View classNames={editorClassNames} extensions={extensions} />\n </Editor.Root>\n );\n};\n\ntype StringMarkdownEditorProps = {\n value: string;\n placeholder?: string;\n readonly?: boolean;\n onChange: (value: string) => void;\n};\n\nconst StringMarkdownEditor = ({ value, placeholder, readonly, onChange }: StringMarkdownEditorProps) => {\n const extensions = useBasicMarkdownExtensions({ placeholder, readonly });\n const handleChange = useCallback((next: string) => onChange(next), [onChange]);\n\n return (\n <Editor.Root>\n <Editor.View\n classNames={editorClassNames}\n extensions={extensions}\n value={value}\n onChange={readonly ? undefined : handleChange}\n />\n </Editor.Root>\n );\n};\n\ntype CreateTextButtonProps = {\n db?: Database.Database;\n disabled?: boolean;\n onCreate: (ref: Ref.Ref<Text.Text>) => void;\n};\n\nconst CreateTextButton = ({ db, disabled, onCreate }: CreateTextButtonProps) => {\n const { t } = useTranslation(translationKey);\n\n const handleClick = useCallback(() => {\n if (!db) {\n return;\n }\n\n onCreate(Ref.make(db.add(Text.make())));\n }, [db, onCreate]);\n\n return (\n <IconButton icon='ph--plus--regular' label={t('create-text.label')} onClick={handleClick} disabled={disabled} />\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Option from 'effect/Option';\nimport * as SchemaAST from 'effect/SchemaAST';\nimport React, { useCallback, useEffect, useState } from 'react';\n\nimport { Input, type TextInputProps } from '@dxos/react-ui';\nimport { safeParseFloat } from '@dxos/util';\n\nimport { type FormFieldRendererProps } from '#types';\n\nimport { FormRow } from '../../FormRow';\n\n/**\n * Extracts numeric constraints (`minimum`/`maximum` bounds and whether the value must be an integer)\n * by walking the chain of Refinement ASTs and reading each one's JSON schema annotation (e.g. produced\n * by `Schema.between` / `Schema.int`). Returns empty constraints when none are declared.\n */\nexport const getNumericConstraints = (ast: SchemaAST.AST): { min?: number; max?: number; integer: boolean } => {\n let node: SchemaAST.AST | undefined = ast;\n let min: number | undefined;\n let max: number | undefined;\n let integer = false;\n // Nested refinements (e.g. `Schema.int()` + `Schema.between()`) each carry their own JSON schema\n // fragment, so accumulate across the chain rather than reading only the outermost node.\n while (node && SchemaAST.isRefinement(node)) {\n const jsonSchema = Option.getOrUndefined(SchemaAST.getJSONSchemaAnnotation(node));\n if (jsonSchema != null) {\n // Stacked refinements intersect: keep the strictest bound (largest min, smallest max).\n if ('minimum' in jsonSchema && typeof jsonSchema.minimum === 'number') {\n min = min === undefined ? jsonSchema.minimum : Math.max(min, jsonSchema.minimum);\n }\n if ('maximum' in jsonSchema && typeof jsonSchema.maximum === 'number') {\n max = max === undefined ? jsonSchema.maximum : Math.min(max, jsonSchema.maximum);\n }\n if (\n ('type' in jsonSchema && jsonSchema.type === 'integer') ||\n ('multipleOf' in jsonSchema && jsonSchema.multipleOf === 1)\n ) {\n integer = true;\n }\n }\n node = node.from;\n }\n return { min, max, integer };\n};\n\nexport const NumberField = ({\n type,\n readonly,\n placeholder,\n getValue,\n onValueChange,\n onBlur,\n ...props\n}: FormFieldRendererProps<number>) => {\n const { min, max, integer } = getNumericConstraints(type);\n\n // Clamp to the declared bounds (and round when integer) so the committed value respects the schema's\n // natural limits — `<input type=\"number\">`'s min/max only constrain the spinner, not typed input.\n const clamp = useCallback(\n (n: number) => {\n let value = integer ? Math.round(n) : n;\n if (min !== undefined) {\n value = Math.max(min, value);\n }\n if (max !== undefined) {\n value = Math.min(max, value);\n }\n return value;\n },\n [min, max, integer],\n );\n\n // Track raw string input so the user can clear the field before typing a new number.\n // We only commit to onValueChange when the raw string parses to a valid number.\n const [raw, setRaw] = useState<string>(() => {\n const v = getValue();\n return v !== undefined ? String(v) : '';\n });\n\n // Sync display when an external change updates the committed value (e.g. reactive form\n // calculations). Only overwrite raw when the external value differs from what raw parses\n // to, preserving partial edits like \"1.\" which correctly parse to 1.\n const externalValue = getValue();\n useEffect(() => {\n if (externalValue !== safeParseFloat(raw)) {\n setRaw(externalValue !== undefined ? String(externalValue) : '');\n }\n }, [externalValue]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const handleChange = useCallback<NonNullable<TextInputProps['onChange']>>(\n (event) => {\n const value = event.target.value;\n setRaw(value);\n const parsed = safeParseFloat(value);\n if (parsed !== undefined) {\n onValueChange(type, clamp(parsed));\n }\n },\n [type, onValueChange, clamp],\n );\n\n const handleBlur = useCallback(\n (event: React.FocusEvent<HTMLElement>) => {\n const parsed = safeParseFloat(raw);\n if (parsed === undefined) {\n // The field was left empty or invalid; reset to the last committed value.\n const committed = getValue();\n setRaw(committed !== undefined ? String(committed) : '');\n } else {\n // Reflect the clamped value even when it equals the previously committed one (so `externalValue`\n // doesn't change), otherwise the input keeps showing the out-of-range text the user typed.\n setRaw(String(clamp(parsed)));\n }\n onBlur(event);\n },\n [raw, getValue, onBlur, clamp],\n );\n\n return (\n <FormRow<number> readonly={readonly} getValue={getValue} {...props}>\n {() => (\n <Input.TextInput\n type='number'\n disabled={!!readonly}\n placeholder={placeholder}\n value={raw}\n min={min}\n max={max}\n step={integer ? 1 : undefined}\n onChange={handleChange}\n onBlur={handleBlur}\n />\n )}\n </FormRow>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useCallback } from 'react';\n\nimport { Input, type TextInputProps } from '@dxos/react-ui';\n\nimport { type FormFieldRendererProps } from '#types';\n\nimport { FormRow } from '../../FormRow';\n\nexport const PasswordField = ({\n type,\n readonly,\n placeholder,\n onBlur,\n onValueChange,\n ...props\n}: FormFieldRendererProps<string>) => {\n const handleChange = useCallback<NonNullable<TextInputProps['onChange']>>(\n (event) => onValueChange(type, event.target.value),\n [type, onValueChange],\n );\n\n return (\n <FormRow<string> readonly={readonly} {...props}>\n {({ value = '' }) => (\n <Input.TextInput\n type='password'\n noAutoFill\n disabled={!!readonly}\n placeholder={placeholder}\n value={value}\n onBlur={onBlur}\n onChange={handleChange}\n />\n )}\n </FormRow>\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { useCallback, useMemo, useState } from 'react';\n\nimport '@dxos/lit-ui/dx-tag-picker.pcss';\nimport { Entity, Filter, Obj, Query, Ref, Scope, Type } from '@dxos/echo';\nimport { useType as defaultUseType, useQuery } from '@dxos/echo-react';\nimport { ANY_OBJECT_TYPENAME, ReferenceAnnotationId, type ReferenceAnnotationValue } from '@dxos/echo/internal';\nimport { SchemaEx } from '@dxos/effect';\nimport { DXN, EID, URI } from '@dxos/keys';\nimport { DxAnchor } from '@dxos/lit-ui/react';\nimport { Button, Icon, Input, useTranslation } from '@dxos/react-ui';\nimport { ParentLabelAnnotationId } from '@dxos/schema';\n\nimport { translationKey } from '#translations';\nimport { type CreateOptions, type FormFieldRendererProps, type RefFieldDataProps, type RefOption } from '#types';\n\nimport { omitHiddenFormFields, omitId } from '../../../../../util';\nimport { ObjectPicker } from '../../../../ObjectPicker';\nimport { FormFieldLabel } from '../../FormRow';\nimport { presentationFor } from '../../presentation';\n\n// TODO(burdon): Factor out.\nconst isRefSnapshot = (val: any): val is { '/': string } => {\n return typeof val === 'object' && typeof (val as any)?.['/'] === 'string';\n};\n\n/**\n * Find the option a ref-like form value points at. Matches on the local (entity-id) form so a bare local EID\n * (`echo:/<id>`, produced by `Ref.make`) still resolves against an option keyed by the entity's qualified\n * self URI (`echo://<space>/<id>`). Returns `undefined` when the value is not a ref or no option matches.\n *\n * Comparing by entity id is only sound within one space (ids are unique there, not globally). Two EIDs that\n * both carry a space authority must therefore agree on it: a qualified value and a qualified option from\n * different spaces never match, even when their entity ids coincide.\n */\nexport const findRefOption = (value: unknown, options: RefOption[]): RefOption | undefined => {\n const isRef = Ref.isRef(value);\n if (!isRef && !isRefSnapshot(value)) {\n return undefined;\n }\n const valueUri = isRef ? value.uri : value['/'];\n // Keyed/registry entities (skills, operations) are referenced by a named DXN rather than an\n // entity-id, so they carry no parseable EID; match those by direct URI equality against the option id.\n const directMatch = options.find((option) => option.id === valueUri);\n if (directMatch) {\n return directMatch;\n }\n const valueEid = EID.tryParse(valueUri);\n if (!valueEid) {\n return undefined;\n }\n const valueSpaceId = EID.getSpaceId(valueEid);\n const valueLocal = EID.toLocal(valueEid);\n return options.find((option) => {\n const optionEid = EID.tryParse(option.id);\n if (!optionEid) {\n return false;\n }\n const optionSpaceId = EID.getSpaceId(optionEid);\n if (valueSpaceId != null && optionSpaceId != null && valueSpaceId !== optionSpaceId) {\n return false;\n }\n return EID.equals(EID.toLocal(optionEid), valueLocal);\n });\n};\n\nconst defaultGetOptions: NonNullable<RefFieldProps['getOptions']> = (\n results,\n { parentLabel, getTypePlaceholder } = {},\n) =>\n results\n // When labeling by parent, only surface objects that actually have a parent — an unparented object\n // (e.g. a system feed) has no meaningful parent to label by.\n .filter((result) => !parentLabel || Obj.getParent(result as Obj.Unknown) != null)\n .map((result) => {\n const id = Entity.getURI(result, { prefer: 'named' });\n const parent = parentLabel ? Obj.getParent(result as Obj.Unknown) : undefined;\n const labelEntity = parent ?? result;\n const typename = Entity.getTypename(labelEntity);\n // Fall back to the entity's type placeholder when it has no label of its own — matching the\n // app-graph/navtree (`object-name.placeholder` in the entity's typename namespace).\n const label = Entity.getLabel(labelEntity) ?? (typename ? getTypePlaceholder?.(typename) : undefined) ?? id;\n return { id, label };\n });\n\nconst defaultUseResults: NonNullable<RefFieldProps['useResults']> = (db, typename) =>\n useQuery(\n db,\n !typename\n ? Query.select(Filter.nothing())\n : typename === ANY_OBJECT_TYPENAME\n ? // Untyped refs show space objects only; the registry is too broad for \"any\".\n Query.select(Filter.everything())\n : // Include registry scope so keyed entities (skills, operations) appear as options.\n Query.select(Filter.type(DXN.make(typename))).from(Scope.space(), Scope.registry()),\n );\n\nexport type RefFieldProps = FormFieldRendererProps & RefFieldDataProps & CreateOptions;\n\nexport const RefField = (props: RefFieldProps) => {\n const {\n type,\n readonly,\n label,\n jsonPath,\n placeholder,\n presentation,\n required,\n getStatus,\n getValue,\n createOptionLabel,\n createOptionIcon,\n createInitialValuePath,\n createFieldMap,\n db,\n useType = defaultUseType,\n useResults = defaultUseResults,\n getOptions = defaultGetOptions,\n onCreate,\n resolveCreateEntry,\n onValueChange,\n } = props;\n const { t } = useTranslation(translationKey);\n const { status, error } = getStatus();\n const resolved = presentationFor(presentation);\n\n const typename = useMemo(\n () => (type ? SchemaEx.findAnnotation<ReferenceAnnotationValue>(type, ReferenceAnnotationId)?.typename : undefined),\n [type],\n );\n\n // Resolve a type-based placeholder label for entities that have no label of their own — the entity's\n // `object-name.placeholder` in its own typename namespace, like the app-graph/navtree. Falls back to a\n // humanized typename segment so we never surface a raw DXN for a type that hasn't registered one.\n const getTypePlaceholder = useCallback(\n (placeholderTypename: string): string => {\n const segment = placeholderTypename.split(/[.:/]/).filter(Boolean).pop() ?? placeholderTypename;\n const humanized = segment.charAt(0).toUpperCase() + segment.slice(1);\n return t('object-name.placeholder', { ns: placeholderTypename, defaultValue: humanized });\n },\n [t],\n );\n\n const results = useResults(db, typename);\n const options = useMemo(() => {\n const parentLabel = type ? SchemaEx.findAnnotation<boolean>(type, ParentLabelAnnotationId) === true : false;\n return getOptions(results, { parentLabel, getTypePlaceholder });\n }, [results, getOptions, type, getTypePlaceholder]);\n\n const handleGetValue = useCallback(() => findRefOption(getValue(), options), [options, getValue]);\n\n const item = handleGetValue();\n const selectedIds = useMemo(() => (item ? [item.id] : []), [item]);\n const createSchema = useType(db, typename && typename !== ANY_OBJECT_TYPENAME ? DXN.make(typename) : undefined);\n\n // Per-typename override supplied by the caller (e.g. SpaceCapabilities.CreateObjectEntry).\n const createEntry = typename ? resolveCreateEntry?.(typename) : undefined;\n\n // Lift the popover open state so we can dismiss it after a successful create.\n const [open, setOpen] = useState(false);\n\n const handleCreate = useCallback(\n async (values: any) => {\n // Wire the newly-created object into this slot's form value. ArrayField\n // owns the array; this RefField represents a single slot, so writing a\n // Ref via `onValueChange` populates that slot.\n if (createEntry?.createObject && db) {\n const newObject = await createEntry.createObject(values, db);\n if (newObject) {\n onValueChange(type, Ref.make(newObject));\n }\n } else if (createSchema && onCreate) {\n const newObject = await onCreate(createSchema, values);\n if (newObject) {\n onValueChange(type, Ref.make(newObject));\n }\n }\n setOpen(false);\n },\n [createEntry, db, createSchema, onCreate, type, onValueChange],\n );\n\n const handleUpdate = useCallback(\n (id: string | undefined) => {\n const item = options.find((option) => option.id === id);\n const ref = item ? Ref.fromURI(URI.make(item.id)) : undefined;\n onValueChange(type, ref);\n },\n [options, type, onValueChange],\n );\n\n const handleSelect = useCallback(\n (id: string) => {\n if (item?.id === id) {\n handleUpdate(undefined);\n } else {\n handleUpdate(id);\n }\n },\n [item, handleUpdate],\n );\n\n if (!typename || ((readonly || resolved.isStatic) && !item)) {\n return null;\n }\n\n return (\n <Input.Root validationValence={status}>\n {resolved.showLabel && (\n <FormFieldLabel error={error} readonly={readonly} required={required} label={label} path={jsonPath} />\n )}\n <div>\n {readonly ? (\n !item ? (\n <p className='text-description mb-2'>{t('empty-readonly-ref-field.label')}</p>\n ) : (\n <DxAnchor key={item.id} dxn={item.id} rootclassname='me-1'>\n {item.label}\n </DxAnchor>\n )\n ) : (\n <ObjectPicker.Root open={open} onOpenChange={setOpen}>\n <ObjectPicker.Trigger asChild classNames='p-0'>\n {item ? (\n <div className='flex gap-form-gap w-full'>\n <Input.Root key={item.id}>\n <Input.TextInput value={item.label} readOnly classNames='w-full' />\n </Input.Root>\n </div>\n ) : (\n <Button classNames='w-full text-start gap-form-gap'>\n <div className='grow overflow-hidden'>\n <span className='truncate text-description'>\n {placeholder || label || t('ref-field.placeholder')}\n </span>\n </div>\n <Icon size={3} icon='ph--caret-down--bold' />\n </Button>\n )}\n </ObjectPicker.Trigger>\n <ObjectPicker.Portal>\n <ObjectPicker.Content\n classNames='dx-card-popover-width'\n options={options}\n selectedIds={selectedIds}\n // Prefer the plugin-registered inputSchema; fall back to stripping hidden fields\n // (`FormInputAnnotation.set(false)`) from the raw ECHO type schema so the form's\n // validator doesn't reject required-but-hidden fields such as backing-object refs\n // supplied by a `FactoryAnnotation`.\n createSchema={\n createEntry?.inputSchema ??\n (createSchema && omitHiddenFormFields(omitId(Type.getSchema(createSchema))))\n }\n createOptionLabel={createOptionLabel}\n createOptionIcon={createOptionIcon}\n createInitialValuePath={createInitialValuePath}\n createFieldMap={createFieldMap}\n // Offer inline create when the caller wired a handler OR a plugin-registered\n // createObject override is available. A resolvable `createSchema` alone is not\n // enough (e.g. operation refs, whose objects can't be created ad hoc).\n onCreate={onCreate || createEntry?.createObject ? handleCreate : undefined}\n onSelect={handleSelect}\n />\n </ObjectPicker.Portal>\n </ObjectPicker.Root>\n )}\n </div>\n {resolved.showError && <Input.DescriptionAndValidation>{error}</Input.DescriptionAndValidation>}\n </Input.Root>\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Schema from 'effect/Schema';\nimport React, { type KeyboardEvent, forwardRef, useCallback, useState } from 'react';\n\nimport { Popover, type ThemedClassName, useTranslation } from '@dxos/react-ui';\nimport { Combobox } from '@dxos/react-ui-list';\nimport { useSearchListResults } from '@dxos/react-ui-search';\n\nimport { translationKey } from '#translations';\nimport { type CreateOptions, type RefOption } from '#types';\n\nimport { Form } from '../Form';\n\nexport type ObjectPickerContentProps = ThemedClassName<\n CreateOptions & {\n options: RefOption[];\n selectedIds?: string[];\n createSchema?: Schema.Schema.AnyNoContext;\n /**\n * Persist a newly-created object given the form values. May be async (e.g.\n * to write to a database). The Promise is awaited before the inline create\n * form is collapsed back to the picker list, so consumers can complete\n * follow-up work (assign the new ref to a parent slot, close the popover)\n * before the picker UI re-renders.\n */\n onCreate?: (values: any) => unknown | Promise<unknown>;\n onSelect?: (id: string) => void;\n }\n>;\n\nconst ObjectPickerContent = forwardRef<HTMLDivElement, ObjectPickerContentProps>(\n (\n {\n options,\n selectedIds,\n createSchema,\n createOptionLabel,\n createOptionIcon,\n createInitialValuePath,\n createFieldMap,\n onSelect,\n onCreate,\n ...props\n },\n forwardedRef,\n ) => {\n const { t } = useTranslation(translationKey);\n const [showForm, setShowForm] = useState(false);\n const [formInitialValue, setFormInitialValue] = useState<string>('');\n\n const { results, query, handleSearch } = useSearchListResults({\n items: options,\n });\n\n const handleFormSave = useCallback(\n async (values: any) => {\n await onCreate?.(values);\n setShowForm(false);\n setFormInitialValue('');\n },\n [onCreate],\n );\n\n const handleFormCancel = useCallback(() => {\n setShowForm(false);\n setFormInitialValue('');\n }, []);\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (\n event.key === 'Enter' &&\n createSchema &&\n (event.currentTarget as HTMLElement).querySelector(\n '[role=\"option\"][aria-selected=\"true\"][data-value=\"__create__\"]',\n )\n ) {\n event.stopPropagation();\n event.preventDefault();\n // Get the current query from the input element\n const input = (event.currentTarget as HTMLElement).querySelector('input[type=\"text\"]') as HTMLInputElement;\n const currentQuery = input?.value || '';\n setFormInitialValue(currentQuery);\n setShowForm(true);\n }\n },\n [createSchema],\n );\n\n if (showForm && createSchema) {\n return (\n <Combobox.Content {...props} onKeyDownCapture={handleKeyDown} ref={forwardedRef}>\n <Popover.Viewport>\n <Form.Root\n testId='create-referenced-object-form'\n schema={createSchema}\n defaultValues={createInitialValuePath ? { [createInitialValuePath]: formInitialValue } : {}}\n fieldMap={createFieldMap}\n onSave={handleFormSave}\n onCancel={handleFormCancel}\n >\n <Form.Viewport>\n <Form.Content>\n <Form.FieldSet />\n <Form.Actions />\n </Form.Content>\n </Form.Viewport>\n </Form.Root>\n </Popover.Viewport>\n <Combobox.Arrow />\n </Combobox.Content>\n );\n }\n\n return (\n <Combobox.Content {...props} onKeyDownCapture={handleKeyDown} ref={forwardedRef}>\n <Combobox.Input\n placeholder={t('ref-field-combobox-input.placeholder')}\n autoFocus\n value={query}\n onValueChange={handleSearch}\n />\n <Combobox.List>\n {results.map((option) => (\n <Combobox.Item\n key={option.id}\n value={option.id}\n label={option.label}\n description={option.description}\n checked={selectedIds?.includes(option.id)}\n onSelect={() => onSelect?.(option.id)}\n classNames='flex items-center gap-2'\n />\n ))}\n {createSchema && onCreate && (\n <CreateItem\n query={query}\n createOptionLabel={createOptionLabel}\n createOptionIcon={createOptionIcon ?? 'ph--plus--regular'}\n onCreateItemSelect={(currentQuery: string) => {\n setFormInitialValue(currentQuery);\n setShowForm(true);\n }}\n />\n )}\n </Combobox.List>\n <Combobox.Arrow />\n </Combobox.Content>\n );\n },\n);\n\nconst CreateItem = ({\n query,\n createOptionLabel,\n createOptionIcon,\n onCreateItemSelect,\n}: {\n query: string;\n createOptionLabel?: [string, { ns: string | readonly string[] }];\n createOptionIcon: string;\n onCreateItemSelect: (query: string) => void;\n}) => {\n const { t } = useTranslation(translationKey);\n\n const label = createOptionLabel\n ? t(createOptionLabel[0], { ns: createOptionLabel[1].ns, text: query })\n : t('create-option.label');\n\n return (\n <Combobox.Item\n value='__create__'\n label={label}\n icon={createOptionIcon}\n classNames='flex items-center gap-2'\n closeOnSelect={false}\n onSelect={() => {\n onCreateItemSelect(query);\n }}\n />\n );\n};\n\nObjectPickerContent.displayName = 'ObjectPicker.Content';\n\nexport const ObjectPicker = {\n Root: Combobox.Root,\n Portal: Combobox.Portal,\n Trigger: Combobox.Trigger,\n VirtualTrigger: Combobox.VirtualTrigger,\n Content: ObjectPickerContent,\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useAtomValue } from '@effect-atom/atom-react';\nimport React, { useCallback, useMemo } from 'react';\n\nimport { type Database, Obj, Ref, Type } from '@dxos/echo';\nimport { useType as defaultUseType } from '@dxos/echo-react';\nimport { ReferenceAnnotationId, type ReferenceAnnotationValue } from '@dxos/echo/Annotation';\nimport { SchemaEx } from '@dxos/effect';\nimport { DXN, URI } from '@dxos/keys';\nimport { IconButton, Input, useTranslation } from '@dxos/react-ui';\n\nimport { translationKey } from '#translations';\n\nimport { omitId } from '../../../../../util';\nimport { FormContent, FormFieldSetController, FormRoot } from '../../../FormControls';\nimport { FormFieldLabel } from '../../FormRow';\nimport { presentationFor } from '../../presentation';\nimport { type RefFieldProps } from './RefField';\n\n/**\n * Renders a referenced object's own fields inline (a nested form bound to the\n * target) rather than the {@link RefField} picker. Activated by\n * `FormInlineAnnotation.set(true)` on the `Ref` property.\n *\n * The nested form edits the target object directly: each changed path is\n * written back via `Obj.setValue` within an `Obj.update`, mirroring\n * `ObjectProperties` (without the synthetic meta-tags row).\n */\nexport const InlineRefField = (props: RefFieldProps) => {\n const {\n type,\n readonly,\n label,\n jsonPath,\n presentation,\n required,\n db,\n getValue,\n onValueChange,\n onCreate,\n useType = defaultUseType,\n } = props;\n const { t } = useTranslation(translationKey);\n const resolved = presentationFor(presentation);\n\n const reference = getValue() as Ref.Ref<any> | undefined;\n const typename = useMemo(\n () => (type ? SchemaEx.findAnnotation<ReferenceAnnotationValue>(type, ReferenceAnnotationId)?.typename : undefined),\n [type],\n );\n\n // Empty ref: offer to create the referenced object so the inline form has a target.\n const createType = useType(db, typename ? DXN.make(typename) : undefined);\n const handleCreate = useCallback(async () => {\n if (!createType || !onCreate) {\n return;\n }\n const newObject = await onCreate(createType, {});\n if (newObject) {\n onValueChange(type, Ref.make(newObject));\n }\n }, [createType, onCreate, type, onValueChange]);\n\n if (readonly && !reference) {\n return null;\n }\n\n return (\n <Input.Root>\n {resolved.showLabel && <FormFieldLabel readonly={readonly} required={required} label={label} path={jsonPath} />}\n {reference ? (\n <InlineForm reference={reference} db={db} readonly={readonly} useType={useType} />\n ) : (\n !readonly &&\n onCreate && (\n <IconButton\n classNames='w-full gap-form-gap'\n disabled={!createType || !db}\n icon='ph--plus--regular'\n label={label || t('ref-field.placeholder')}\n onClick={() => void handleCreate()}\n />\n )\n )}\n </Input.Root>\n );\n};\n\ntype InlineFormProps = {\n reference: Ref.Ref<any>;\n db?: Database.Database;\n readonly?: boolean;\n // Accepts both the generic `defaultUseType` and `RefFieldProps['useType']`.\n useType?: (db?: Database.Database, typeUri?: URI.URI) => Type.AnyEntity | undefined;\n};\n\nconst InlineForm = ({ reference, db, readonly, useType = defaultUseType }: InlineFormProps) => {\n const target = useAtomValue(useMemo(() => reference.atom, [reference]));\n const typeUri = target ? Obj.getTypeURI(target) : undefined;\n const typeFromRegistry = useType(db, typeUri);\n const targetType = (target && Obj.getType(target)) || typeFromRegistry;\n // Drop the ECHO `id` property (mirrors `ObjectProperties` via `withMetaTags`);\n // otherwise the nested form renders an \"Id\" field. Hidden fields\n // (`FormInputAnnotation.set(false)`) are already filtered by the field set.\n const formSchema = useMemo(() => (targetType ? omitId(Type.getSchema(targetType)) : undefined), [targetType]);\n const defaultValues = useMemo(() => (target ? { ...target } : {}), [target]);\n\n // `formSchema` is resolved at runtime (the referenced object's schema), so the\n // form's value type is not statically known here — `any` at this form-value\n // boundary mirrors `ObjectProperties`. Each changed path is written back to the\n // live target via `Obj.setValue`.\n const handleChange = useCallback(\n (values: any, { isValid, changed }: { isValid: boolean; changed: Record<SchemaEx.JsonPath, boolean> }) => {\n if (!isValid || !target) {\n return;\n }\n const changedPaths = (Object.keys(changed) as SchemaEx.JsonPath[]).filter((path) => changed[path]);\n if (changedPaths.length === 0) {\n return;\n }\n Obj.update(target, () => {\n for (const path of changedPaths) {\n const parts = SchemaEx.splitJsonPath(path);\n Obj.setValue(target, parts, Obj.getValue(values, parts));\n }\n });\n },\n [target],\n );\n\n if (!target || !formSchema) {\n return null;\n }\n\n return (\n <FormRoot db={db} schema={formSchema} defaultValues={defaultValues as any} onValuesChanged={handleChange}>\n <FormContent>\n <FormFieldSetController collapsible readonly={readonly} />\n </FormContent>\n </FormRoot>\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { type ChangeEvent, type KeyboardEvent, useCallback, useEffect, useRef, useState } from 'react';\n\nimport { type SelectOption } from '@dxos/echo/Format';\nimport { PublicKey } from '@dxos/keys';\nimport { type ChromaticPalette, IconButton, Input, Tag, ToggleIconButton, useTranslation } from '@dxos/react-ui';\nimport { OrderedList } from '@dxos/react-ui-list';\nimport { HuePicker } from '@dxos/react-ui-pickers';\nimport { hues, osTranslations } from '@dxos/ui-theme';\n\nimport { translationKey } from '#translations';\nimport { type FormFieldRendererProps } from '#types';\n\nimport { FormFieldLabel } from '../../FormRow';\n\nexport const SelectOptionField = ({\n type,\n readonly,\n label,\n jsonPath,\n getStatus,\n getValue,\n onValueChange,\n}: FormFieldRendererProps<SelectOption[] | undefined>) => {\n const { t } = useTranslation(translationKey);\n const { status, error } = getStatus();\n const [selected, setSelectedId] = useState<string | null>(null);\n const [isNewOption, setIsNewOption] = useState(false);\n const inputRef = useRef<HTMLInputElement>(null);\n const options = getValue();\n\n // Initialization.\n useEffect(() => {\n if (options === undefined) {\n onValueChange(type, []);\n }\n }, [options, type, onValueChange]);\n\n const randomHue = () => {\n const usedHues = new Set(options?.map((option) => option.color) ?? []);\n // Pick a random unused option from hueTokenThemes.\n const unusedHues = hues.filter((hue) => !usedHues.has(hue));\n if (unusedHues.length > 0) {\n return unusedHues[Math.floor(Math.random() * unusedHues.length)];\n }\n\n // Pick a random one that hasn't been used in the last three options\n const lastThree = new Set(options?.slice(-3).map((option) => option.color) ?? []);\n const availableHues = hues.filter((hue) => !lastThree.has(hue));\n return (\n availableHues[Math.floor(Math.random() * availableHues.length)] ?? hues[Math.floor(Math.random() * hues.length)]\n );\n };\n\n const handleAdd = useCallback(() => {\n const newId = PublicKey.random().truncate();\n const newOption = { id: newId, title: '', color: randomHue() };\n onValueChange(type, [...(options ?? []), newOption]);\n setSelectedId(newId);\n setIsNewOption(true);\n }, [options, type, onValueChange]);\n\n const handleDelete = useCallback(\n (id: string) => {\n const newOptions = options?.filter((option) => option.id !== id) ?? [];\n onValueChange(type, newOptions);\n setSelectedId(null);\n },\n [options, type, onValueChange],\n );\n\n const handleMove = useCallback(\n (from: number, to: number) => {\n if (!options) {\n return;\n }\n\n const newOptions = [...options];\n const [removed] = newOptions.splice(from, 1);\n newOptions.splice(to, 0, removed);\n onValueChange(type, newOptions);\n },\n [options, type, onValueChange],\n );\n\n const handleClick = useCallback((id: string) => {\n setSelectedId((current) => (current === id ? null : id));\n }, []);\n\n const handleTitleChange = useCallback(\n (id: string) => (e: ChangeEvent<HTMLInputElement>) => {\n const newOptions = options?.map((o) => (o.id === id ? { ...o, title: e.target.value } : o));\n onValueChange(type, newOptions ?? []);\n },\n [options, type, onValueChange],\n );\n\n const handleKeyDown = useCallback((ev: KeyboardEvent<HTMLInputElement>) => {\n if (ev.key === 'Enter') {\n setSelectedId(null);\n }\n }, []);\n\n const handleColorChange = useCallback(\n (id: string) => (hue: string) => {\n const newOptions = options?.map((o) => (o.id === id ? { ...o, color: hue } : o));\n onValueChange(type, newOptions ?? []);\n },\n [options, type, onValueChange],\n );\n\n useEffect(() => {\n if (selected && isNewOption && inputRef.current) {\n inputRef.current.focus();\n setIsNewOption(false);\n }\n }, [selected, isNewOption]);\n\n return (\n <Input.Root validationValence={status}>\n <FormFieldLabel error={error} readonly={readonly} label={label} path={jsonPath} />\n <div>\n {options && (\n <OrderedList.Root<SelectOption>\n items={options}\n isItem={(_item) => true}\n getId={(option) => option.id}\n onMove={readonly ? undefined : handleMove}\n readonly={!!readonly}\n >\n {({ items }) => (\n <OrderedList.Content classNames='w-full overflow-auto'>\n {items?.map((item) => (\n <OrderedList.Item\n key={item.id}\n id={item.id}\n item={item}\n canDrag={!readonly}\n classNames='flex flex-col cursor-pointer rounded-xs dx-hover'\n >\n <div className='flex items-center'>\n <OrderedList.DragHandle />\n {/* TODO(ZaymonFC): Move spacer into Tag component. */}\n <div className='flex grow items-center truncate px-2' onClick={() => handleClick(item.id)}>\n <Tag hue={item.color as ChromaticPalette}>{item.title || '\\u200b'}</Tag>\n </div>\n <ToggleIconButton\n iconOnly\n variant='ghost'\n active={selected === item.id}\n icon='ph--caret-right--regular'\n label={t(selected === item.id ? 'collapse.label' : 'expand.label', { ns: osTranslations })}\n onClick={() => handleClick(item.id)}\n />\n </div>\n {selected === item.id && (\n <div className='flex flex-col p-form-padding gap-form-gap dx-density-md'>\n <Input.Label classNames='text-sm'>{t('select-option.label')}</Input.Label>\n <div className='grid grid-cols-[1fr_min-content_min-content] gap-form-gap'>\n <Input.TextInput\n disabled={!!readonly}\n placeholder={t('select-option-label.placeholder')}\n ref={selected === item.id ? inputRef : undefined}\n value={item.title}\n onChange={handleTitleChange(item.id)}\n onKeyDown={handleKeyDown}\n classNames='flex-1'\n />\n <HuePicker disabled={!!readonly} value={item.color} onChange={handleColorChange(item.id)} />\n <IconButton\n disabled={!!readonly}\n icon='ph--trash--fill'\n iconOnly\n label={t('select-option-delete.button')}\n onClick={() => handleDelete(item.id)}\n />\n </div>\n </div>\n )}\n </OrderedList.Item>\n ))}\n <IconButton\n classNames='w-full'\n variant='ghost'\n icon='ph--plus--regular'\n label={t('select-option-add.button')}\n onClick={handleAdd}\n disabled={!!readonly}\n />\n </OrderedList.Content>\n )}\n </OrderedList.Root>\n )}\n </div>\n </Input.Root>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useCallback } from 'react';\n\nimport { Input, type TextAreaProps } from '@dxos/react-ui';\n\nimport { type FormFieldRendererProps } from '#types';\n\nimport { FormRow } from '../../FormRow';\n\nexport const TextAreaField = ({\n type,\n readonly,\n placeholder,\n onValueChange,\n onBlur,\n ...props\n}: FormFieldRendererProps<string>) => {\n const handleChange = useCallback<NonNullable<TextAreaProps['onChange']>>(\n (event) => onValueChange(type, event.target.value),\n [type, onValueChange],\n );\n\n return (\n <FormRow<string> readonly={readonly} {...props}>\n {({ value = '' }) => (\n <Input.TextArea\n rows={5}\n disabled={!!readonly}\n placeholder={placeholder}\n value={value}\n onChange={handleChange}\n onBlur={onBlur}\n />\n )}\n </FormRow>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { Input } from '@dxos/react-ui';\nimport { mx } from '@dxos/ui-theme';\nimport { safeParseFloat } from '@dxos/util';\n\nimport { type FormFieldRendererProps } from '#types';\n\nimport { FormFieldLabel } from '../../FormRow';\n\nconst gridCols = ['grid-cols-1', 'grid-cols-2', 'grid-cols-3', 'grid-cols-4'];\n\nexport const TupleField = ({\n binding,\n type,\n readonly,\n label,\n jsonPath,\n getStatus,\n getValue,\n onValueChange,\n onBlur,\n}: FormFieldRendererProps<Record<string, number>> & {\n binding: string[];\n}) => {\n const { status, error } = getStatus();\n\n // TODO(burdon): Generalize number/float/string, etc.\n const values: Record<string, number> = getValue() ?? {};\n\n return (\n <Input.Root validationValence={status}>\n <FormFieldLabel error={error} readonly={readonly} label={label} path={jsonPath} />\n <div className={mx('grid gap-form-gap', gridCols[binding.length - 1])}>\n {binding.map((prop) => (\n <Input.TextInput\n key={prop}\n type='number'\n disabled={!!readonly}\n value={values[prop]}\n onChange={(event) => {\n onValueChange(type, {\n ...values,\n [prop]: safeParseFloat(event.target.value, 0),\n });\n }}\n onBlur={onBlur}\n />\n ))}\n </div>\n </Input.Root>\n );\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\nimport * as String from 'effect/String';\nimport React, { Fragment, useMemo } from 'react';\n\nimport { Annotation } from '@dxos/echo';\nimport { type AnyProperties } from '@dxos/echo/internal';\nimport { SchemaEx } from '@dxos/effect';\nimport { Input } from '@dxos/react-ui';\n\nimport { type FormPresentation } from '#types';\n\nimport { useFormContext, useFormFieldState } from '../../../hooks';\nimport { formTheme } from '../Form.theme';\nimport { FormField, FormFieldErrorBoundary, FormFieldLabel, type FormFieldProps, presentationFor } from '../FormField';\nimport { type LayoutNode, LayoutParseError, parseLayout } from './parser';\n\nconst FORM_LAYOUT_NAME = 'Form.Layout';\n\nexport type FormLayoutProps = {\n /**\n * Template string in the FormLayout DSL (`<grid cols=…><field name=…/></grid>`).\n * If omitted, the layout is read from the schema's `FormLayoutAnnotation` —\n * the entry named by `name` (default: `'default'`).\n */\n template?: string;\n /**\n * Picks a named layout out of `FormLayoutAnnotation`'s map when no\n * explicit `template` is supplied. Defaults to `'default'`.\n */\n name?: string;\n} & Pick<FormFieldSetSubset, 'schema' | 'path' | 'readonly' | 'layout' | 'projection' | 'fieldMap' | 'fieldProvider'>;\n\ntype FormFieldSetSubset = Pick<\n FormFieldProps,\n 'path' | 'readonly' | 'layout' | 'projection' | 'fieldMap' | 'fieldProvider'\n> & {\n schema: Schema.Schema<AnyProperties>;\n};\n\n/**\n * Lays out schema fields according to a `FormLayout` DSL template. The template\n * is either passed via the `template` prop or read from the schema's\n * `FormLayoutAnnotation`. Fields not referenced in the template are hidden —\n * the template controls exactly what renders.\n *\n * A `<field name=…/>` resolves against the schema:\n * - A dotted name (`origin.code`) drills into a nested struct and renders the leaf field.\n * - A name that resolves to a nested struct carrying a `LabelAnnotation` auto-converts\n * to the struct's computed label, rendered as a single read-only text (rather than\n * expanding the struct's sub-fields).\n */\nexport const FormLayout = ({\n schema,\n template,\n name = Annotation.DEFAULT_LAYOUT_NAME,\n path,\n readonly,\n layout,\n projection,\n ...props\n}: FormLayoutProps) => {\n const annotated = Option.getOrUndefined(Annotation.FormLayoutAnnotation.get(schema));\n const source = template ?? annotated?.[name];\n if (source === undefined) {\n throw new LayoutParseError(\n annotated\n ? `no layout named \"${name}\" on schema (available: ${Object.keys(annotated).join(', ') || '∅'})`\n : `no template provided and schema has no FormLayoutAnnotation`,\n );\n }\n\n const tree = useMemo(() => parseLayout(source), [source]);\n\n return (\n <RenderNode\n node={tree}\n schema={schema}\n basePath={path ?? []}\n readonly={readonly}\n layout={layout}\n projection={projection}\n {...props}\n />\n );\n};\n\nFormLayout.displayName = FORM_LAYOUT_NAME;\n\ntype RenderNodeProps = Omit<FormLayoutProps, 'template' | 'path'> & {\n node: LayoutNode;\n basePath: (string | number)[];\n};\n\nconst RenderNode = ({ node, schema, basePath, ...props }: RenderNodeProps) => {\n if (node.kind === 'grid') {\n return (\n <div className='grid gap-x-form-gap' style={{ gridTemplateColumns: `repeat(${node.cols}, minmax(0, 1fr))` }}>\n {node.children.map((child, index) => (\n <Fragment key={index}>\n <RenderNode node={child} schema={schema} basePath={basePath} {...props} />\n </Fragment>\n ))}\n </div>\n );\n }\n\n const resolved = resolveLayoutField(schema, node.name);\n if (!resolved) {\n throw new LayoutParseError(`field \"${node.name}\" not found on schema`);\n }\n\n const { type, segments, leafName, title, labelType, required } = resolved;\n const path = [...basePath, ...segments];\n const span = node.span ? { gridColumn: `span ${node.span} / span ${node.span}` } : undefined;\n\n return (\n <div className='min-w-0' style={span}>\n <FormFieldErrorBoundary path={path}>\n {labelType ? (\n <LabelField\n schema={Schema.make(labelType)}\n label={title ?? String.capitalize(leafName)}\n path={path}\n layout={props.layout}\n />\n ) : (\n <FormField type={type} name={leafName} path={path} required={required} {...props} />\n )}\n </FormFieldErrorBoundary>\n </div>\n );\n};\n\nexport type ResolvedLayoutField = {\n /** Resolved leaf AST node for the field. */\n type: SchemaAST.AST;\n /** Path segments (dotted names split on `.`). */\n segments: string[];\n /** Last path segment; used to derive the field label when there is no `title` annotation. */\n leafName: string;\n /** Resolved `title` annotation for the field, if any. */\n title?: string;\n /**\n * Set when the field resolves to a nested struct carrying a `LabelAnnotation` —\n * the type literal whose computed label should render in place of the struct's\n * sub-fields. Undefined for ordinary (non-auto-labelled) fields.\n */\n labelType?: SchemaAST.AST;\n /** Whether the resolved property is required (non-optional). */\n required: boolean;\n};\n\n/**\n * Walks a dotted path of property names through nested struct ASTs, returning the\n * leaf `PropertySignature` (or `undefined` if any segment is missing).\n */\nconst resolvePropertySignature = (ast: SchemaAST.AST, segments: string[]): SchemaAST.PropertySignature | undefined => {\n let node: SchemaAST.AST = ast;\n for (let index = 0; index < segments.length; index++) {\n const typeLiteral = SchemaEx.findNode(node, SchemaAST.isTypeLiteral);\n if (!typeLiteral) {\n return undefined;\n }\n const prop = SchemaAST.getPropertySignatures(typeLiteral).find(\n (p) => globalThis.String(p.name) === segments[index],\n );\n if (!prop) {\n return undefined;\n }\n if (index === segments.length - 1) {\n return prop;\n }\n node = prop.type;\n }\n\n return undefined;\n};\n\n/**\n * Resolves a (possibly dotted) layout field name against a schema.\n * - `origin.code` drills through nested structs to the leaf field.\n * - A name resolving to a nested struct with a `LabelAnnotation` is flagged via\n * `labelType` so the layout can auto-convert it to a single read-only label.\n * Returns `undefined` when the name does not resolve to a property.\n */\nexport const resolveLayoutField = (schema: Schema.Schema<any>, name: string): ResolvedLayoutField | undefined => {\n const segments = name.split('.');\n const prop = resolvePropertySignature(schema.ast, segments);\n if (!prop) {\n return undefined;\n }\n\n // Normalized leaf type (optional unwrapped, refinements stripped, signature-level\n // annotations merged) — matches how `getProperties` feeds `FormField`.\n const { type: baseType } = SchemaEx.getBaseType(prop);\n const type =\n prop.annotations && Reflect.ownKeys(prop.annotations).length > 0\n ? ({ ...baseType, annotations: { ...baseType.annotations, ...prop.annotations } } as SchemaAST.AST)\n : baseType;\n\n const title = SchemaEx.getAnnotation<string>(SchemaAST.TitleAnnotationId)(type);\n\n // Label detection reads the *raw* property type: `SchemaEx.getBaseType`'s `encodedBoundAST`\n // strips annotations from non-keyword inner types (e.g. nested structs), which would\n // drop the `LabelAnnotation` we rely on here.\n const labelType = SchemaEx.findNode(prop.type, SchemaAST.isTypeLiteral);\n const labelled = labelType != null && Option.isSome(Annotation.LabelAnnotation.getFromAst(labelType));\n\n return {\n type,\n segments,\n leafName: segments[segments.length - 1],\n title,\n labelType: labelled ? labelType : undefined,\n required: !prop.isOptional,\n };\n};\n\ntype LabelFieldProps = {\n schema: Schema.Schema<any>;\n label: string;\n path: (string | number)[];\n layout?: FormPresentation;\n};\n\n/**\n * Renders a nested struct value as its computed label (via `LabelAnnotation`),\n * as a single read-only text. Empty values are omitted, mirroring the static\n * presentation of regular fields.\n */\nconst LabelField = ({ schema, label, path, layout }: LabelFieldProps) => {\n const { variant = 'default' } = useFormContext(FORM_LAYOUT_NAME);\n const styles = formTheme.styles({ variant });\n const { getValue } = useFormFieldState(FORM_LAYOUT_NAME, path);\n const value = getValue();\n const text = value == null ? undefined : Annotation.getLabelWithSchema(schema, value);\n if (text == null || text.trim().length === 0) {\n return null;\n }\n\n const presentation = presentationFor(layout);\n return (\n <Input.Root>\n <div className={styles.field()}>\n {presentation.showLabel && (\n <FormFieldLabel variant={variant} readonly label={label} path={SchemaEx.createJsonPath(path)} />\n )}\n <div className={styles.fieldControl()}>\n <p className='truncate min-w-0' title={text}>\n {text}\n </p>\n </div>\n </div>\n </Input.Root>\n );\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\n/**\n * Minimal XML-style DSL for laying out schema fields in a grid.\n *\n * Grammar:\n * <grid cols=\"N\"> ...children... </grid>\n * <field name=\"x\" span=\"N\"/>\n *\n * - Attributes accept `\"…\"`, `'…'`, or unquoted integers.\n * - Whitespace between tags is ignored. Text content (between tags) is forbidden.\n * - Self-closing form (`<field … />`) is required for `field`; `grid` must use a closing tag.\n *\n * The parser is hand-rolled (no HTML parser) because the grammar is tiny.\n */\n\n/** Node type for the parsed layout tree. */\nexport type LayoutNode =\n | { readonly kind: 'grid'; readonly cols: number; readonly children: readonly LayoutNode[] }\n | { readonly kind: 'field'; readonly name: string; readonly span?: number };\n\nexport class LayoutParseError extends Error {\n readonly _tag = 'LayoutParseError';\n constructor(\n message: string,\n readonly position?: number,\n ) {\n super(position !== undefined ? `${message} (at position ${position})` : message);\n }\n}\n\nconst TAG_RE = /<\\s*(\\/?)\\s*(\\w+)([^>]*?)(\\/?)\\s*>/g;\nconst ATTR_RE = /([\\w-]+)\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|(\\d+))/g;\n\ntype Token =\n | { type: 'open'; name: string; attrs: Record<string, string>; selfClosing: boolean; position: number }\n | { type: 'close'; name: string; position: number };\n\nconst parseAttrs = (raw: string): Record<string, string> => {\n const attrs: Record<string, string> = {};\n ATTR_RE.lastIndex = 0;\n let match: RegExpExecArray | null;\n while ((match = ATTR_RE.exec(raw)) !== null) {\n const [, key, doubleQuoted, singleQuoted, bare] = match;\n attrs[key] = doubleQuoted ?? singleQuoted ?? bare;\n }\n return attrs;\n};\n\nconst tokenize = (input: string): Token[] => {\n const tokens: Token[] = [];\n TAG_RE.lastIndex = 0;\n let match: RegExpExecArray | null;\n let cursor = 0;\n while ((match = TAG_RE.exec(input)) !== null) {\n // Validate that any text between the previous tag and this one is whitespace-only.\n const between = input.slice(cursor, match.index);\n if (between.trim().length > 0) {\n throw new LayoutParseError(`unexpected text content: ${JSON.stringify(between.trim())}`, cursor);\n }\n const [, slash, name, attrsRaw, selfSlash] = match;\n if (slash) {\n tokens.push({ type: 'close', name, position: match.index });\n } else {\n tokens.push({\n type: 'open',\n name,\n attrs: parseAttrs(attrsRaw),\n selfClosing: selfSlash === '/',\n position: match.index,\n });\n }\n cursor = match.index + match[0].length;\n }\n // Any trailing text after the last tag must also be whitespace.\n const trailing = input.slice(cursor);\n if (trailing.trim().length > 0) {\n throw new LayoutParseError(`unexpected text content: ${JSON.stringify(trailing.trim())}`, cursor);\n }\n return tokens;\n};\n\nconst requireAttr = (attrs: Record<string, string>, key: string, tag: string, position: number): string => {\n const value = attrs[key];\n if (value === undefined) {\n throw new LayoutParseError(`<${tag}> missing required attribute \"${key}\"`, position);\n }\n return value;\n};\n\nconst parseInteger = (value: string, attr: string, tag: string, position: number): number => {\n if (!/^\\d+$/.test(value)) {\n throw new LayoutParseError(\n `<${tag}> attribute \"${attr}\" expects an integer, got ${JSON.stringify(value)}`,\n position,\n );\n }\n return Number.parseInt(value, 10);\n};\n\n/** Parses a layout template string into a single root node. The root must be `<grid>`. */\nexport const parseLayout = (template: string): LayoutNode => {\n const tokens = tokenize(template);\n if (tokens.length === 0) {\n throw new LayoutParseError('empty template');\n }\n\n let index = 0;\n\n const parseNode = (): LayoutNode => {\n const token = tokens[index];\n if (!token || token.type !== 'open') {\n throw new LayoutParseError(`expected an opening tag, got ${JSON.stringify(token)}`, token?.position);\n }\n\n if (token.name === 'field') {\n if (!token.selfClosing) {\n throw new LayoutParseError('<field> must be self-closing (e.g. <field name=\"x\"/>)', token.position);\n }\n const name = requireAttr(token.attrs, 'name', 'field', token.position);\n const spanRaw = token.attrs.span;\n const span = spanRaw !== undefined ? parseInteger(spanRaw, 'span', 'field', token.position) : undefined;\n index += 1;\n return { kind: 'field', name, span };\n }\n\n if (token.name === 'grid') {\n if (token.selfClosing) {\n throw new LayoutParseError('<grid> must wrap children (cannot self-close)', token.position);\n }\n const cols = parseInteger(\n requireAttr(token.attrs, 'cols', 'grid', token.position),\n 'cols',\n 'grid',\n token.position,\n );\n index += 1;\n const children: LayoutNode[] = [];\n while (index < tokens.length && !(tokens[index].type === 'close' && tokens[index].name === 'grid')) {\n children.push(parseNode());\n }\n const closing = tokens[index];\n if (!closing || closing.type !== 'close' || closing.name !== 'grid') {\n throw new LayoutParseError('<grid> not closed', token.position);\n }\n index += 1;\n return { kind: 'grid', cols, children };\n }\n\n throw new LayoutParseError(`unknown element <${token.name}>`, token.position);\n };\n\n const root = parseNode();\n if (index !== tokens.length) {\n const trailing = tokens[index];\n throw new LayoutParseError(\n `unexpected trailing tag <${trailing.type === 'open' ? '' : '/'}${trailing.name}>`,\n trailing.position,\n );\n }\n if (root.kind !== 'grid') {\n throw new LayoutParseError('root element must be <grid>');\n }\n return root;\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport React, { type PropsWithChildren, useState } from 'react';\n\nimport { type ThemedClassName, ToggleIconButton, useTranslation } from '@dxos/react-ui';\nimport { mx } from '@dxos/ui-theme';\n\nimport { translationKey } from '#translations';\n\nimport { formTheme } from '../Form.theme';\nimport { FormFieldHeader } from '../FormField/FormFieldHeader';\nimport { type FormFieldPresentation } from '../FormField/presentation';\n\nconst styles = formTheme.styles();\n\nexport type FormFieldSetContainerProps = ThemedClassName<\n PropsWithChildren<{\n label?: string;\n /** JSON path of the group, forwarded to the label as field metadata. */\n path?: string;\n readonly?: boolean;\n presentation: FormFieldPresentation;\n /**\n * Render a collapse toggle in the header and wrap the body in an indented, bordered box.\n * Used for nested objects (struct fields, object-array items, inline refs).\n */\n collapsible?: boolean;\n }>\n>;\n\n/**\n * Shared chrome for a labelled group of sub-fields: an optional header (label + collapse toggle) and,\n * when collapsible, an indented bordered container around the body. Nested structs, object-array items,\n * and inline refs all reach this via `FormFieldSet`, so their visual containment is identical.\n */\nexport const FormFieldSetContainer = ({\n classNames,\n label,\n path,\n readonly,\n presentation,\n collapsible,\n children,\n}: FormFieldSetContainerProps) => {\n const { t } = useTranslation(translationKey);\n // TODO(burdon): Generalize collapse state (cf. useSelection in react-ui-attention, plugin-markdown cursor state).\n const [collapsed, setCollapsed] = useState(false);\n const showBody = !(collapsible && collapsed);\n\n const content = (\n <>\n {presentation.showLabel && label && (\n <FormFieldHeader\n label={label}\n path={path}\n readonly={readonly}\n classNames='pl-2'\n actions={\n collapsible ? (\n <ToggleIconButton\n active={!collapsed}\n classNames='px-1 mr-0.5'\n variant='ghost'\n density='xs'\n iconOnly\n icon='ph--caret-right--regular'\n label={t(collapsed ? 'expand-fields.label' : 'collapse-fields.label')}\n />\n ) : undefined\n }\n onClick={collapsible ? () => setCollapsed((value) => !value) : undefined}\n />\n )}\n {showBody && (collapsible ? <div className={styles.fieldSetBody()}>{children}</div> : children)}\n </>\n );\n\n // Nested groups render inside an indented, bordered container with a collapse toggle. A non-collapsible\n // group only materializes a wrapper when `classNames` is supplied — otherwise the body flows straight\n // into the parent grid (the default, grid-transparent behavior).\n if (collapsible) {\n return (\n <div className={styles.fieldSetBoxOuter()}>\n <div className={styles.fieldSetBox({ class: mx(classNames) })}>{content}</div>\n </div>\n );\n }\n\n // Only materialize a wrapper when `classNames` is supplied; otherwise stay grid-transparent.\n return classNames ? <div className={mx(classNames)}>{content}</div> : <>{content}</>;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport {\n FormActions,\n type FormActionsProps,\n FormContent,\n type FormContentProps,\n FormError,\n FormFieldSetController,\n FormGroup,\n type FormGroupProps,\n FormLayoutController,\n type FormLayoutProps,\n FormRoot,\n type FormRootProps,\n FormSection,\n type FormSectionProps,\n FormSubmit,\n type FormSubmitProps,\n FormViewport,\n type FormViewportProps,\n} from './FormControls';\nimport { FormFieldLabel, FormRow, type FormRowProps } from './FormField';\n\nexport const Form = {\n Root: FormRoot,\n Viewport: FormViewport,\n Content: FormContent,\n Section: FormSection,\n Group: FormGroup,\n FieldSet: FormFieldSetController,\n Layout: FormLayoutController,\n Label: FormFieldLabel,\n Row: FormRow,\n Actions: FormActions,\n Submit: FormSubmit,\n Error: FormError,\n};\n\nexport type {\n FormActionsProps,\n FormContentProps,\n FormGroupProps,\n FormLayoutProps,\n FormRootProps,\n FormRowProps,\n FormSectionProps,\n FormSubmitProps,\n FormViewportProps,\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { useCallback, useMemo } from 'react';\n\nimport { Obj, Ref, Tag, Type } from '@dxos/echo';\nimport { SchemaEx } from '@dxos/effect';\nimport { invariant } from '@dxos/invariant';\nimport { HuePicker } from '@dxos/react-ui-pickers';\n\nimport { translationKey } from '#translations';\nimport { type FormFieldMap } from '#types';\n\nimport { Form, META_TAGS_KEY, withMetaTags } from '../Form';\n\nexport type ObjectFormProps = {\n type: Type.AnyEntity;\n object: Obj.Unknown;\n};\n\nexport const ObjectForm = ({ object, type }: ObjectFormProps) => {\n const db = Obj.getDatabase(object);\n const meta = Obj.getMeta(object);\n // `meta.tags` already holds `Ref<Tag>`s (materialized by the database handler).\n const tags = [...meta.tags];\n const values = useMemo(() => ({ [META_TAGS_KEY]: tags, ...object }), [object, tags]);\n const formSchema = useMemo(() => withMetaTags(Type.getSchema(type)), [type]);\n\n const handleCreate = useCallback((type: Type.AnyEntity, values: any) => {\n invariant(db);\n invariant(Type.isObject(type));\n const newObject = db.add(Obj.make(type, values));\n if (Obj.instanceOf(Tag.Tag, newObject)) {\n Obj.update(object, (object) => {\n Obj.getMeta(object).tags = [...Obj.getMeta(object).tags, Ref.make(newObject)];\n });\n }\n }, []);\n\n // TODO(wittjosiah): Use FormRootProps type.\n const handleChange = useCallback(\n (\n { [META_TAGS_KEY]: metaTags, ...values }: any,\n { isValid, changed }: { isValid: boolean; changed: Record<SchemaEx.JsonPath, boolean> },\n ) => {\n if (!isValid) {\n return;\n }\n\n const changedPaths = Object.keys(changed).filter(\n (path) => changed[path as SchemaEx.JsonPath],\n ) as SchemaEx.JsonPath[];\n\n // Handle meta-tags separately using Obj.update.\n const hasTagsChange = changedPaths.some((path) => SchemaEx.splitJsonPath(path)[0] === META_TAGS_KEY);\n if (hasTagsChange) {\n Obj.update(object, (object) => {\n // Copy so later in-place form mutations don't bypass the `Obj.update` boundary.\n Obj.getMeta(object).tags = Array.isArray(metaTags) ? [...(metaTags as Ref.Ref<Tag.Tag>[])] : [];\n });\n }\n\n // Handle other property changes.\n const nonTagPaths = changedPaths.filter((path) => SchemaEx.splitJsonPath(path)[0] !== META_TAGS_KEY);\n if (nonTagPaths.length > 0) {\n Obj.update(object, () => {\n for (const path of nonTagPaths) {\n const parts = SchemaEx.splitJsonPath(path);\n const value = Obj.getValue(values, parts);\n Obj.setValue(object, parts, value);\n }\n });\n }\n },\n [object],\n );\n\n return (\n <Form.Root\n schema={formSchema}\n defaultValues={values}\n createTypename={Type.getTypename(Tag.Tag)}\n createOptionIcon='ph--plus--regular'\n createOptionLabel={['add-tag.label', { ns: translationKey }]}\n createInitialValuePath='label'\n createFieldMap={createFieldMap}\n db={db}\n onValuesChanged={handleChange}\n onCreate={handleCreate}\n >\n <Form.Viewport>\n <Form.Content>\n <Form.FieldSet />\n </Form.Content>\n </Form.Viewport>\n </Form.Root>\n );\n};\n\nconst createFieldMap: FormFieldMap = {\n hue: ({ type, label, presentation, getValue, onValueChange }) => {\n const handleChange = useCallback((nextHue: string) => onValueChange(type, nextHue), [onValueChange, type]);\n const handleReset = useCallback(() => onValueChange(type, undefined), [onValueChange, type]);\n return (\n <>\n {presentation !== 'inline' && <Form.Label label={label} />}\n <HuePicker value={getValue()} onChange={handleChange} onReset={handleReset} />\n </>\n );\n },\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Function from 'effect/Function';\nimport * as Option from 'effect/Option';\nimport React, { type PropsWithChildren, useCallback, useMemo } from 'react';\n\nimport { Obj, Ref, Tag, Type } from '@dxos/echo';\nimport { useType } from '@dxos/echo-react';\nimport { SchemaEx } from '@dxos/effect';\nimport { invariant } from '@dxos/invariant';\nimport { composable, composableProps } from '@dxos/react-ui';\nimport { HuePicker } from '@dxos/react-ui-pickers';\nimport { FactoryAnnotation } from '@dxos/schema';\n\nimport { translationKey } from '#translations';\nimport { type FormFieldMap, type RefFieldDataProps } from '#types';\n\nimport { Form, META_TAGS_KEY, withMetaTags } from '../Form';\n\nexport type ObjectPropertiesProps = PropsWithChildren<\n { object: Obj.Unknown } & Pick<RefFieldDataProps, 'getCreateDefaults' | 'resolveCreateEntry'>\n>;\n\n// TODO(wittjosiah): Reconcile w/ ObjectForm.\nexport const ObjectProperties = composable<HTMLDivElement, ObjectPropertiesProps>(\n ({ children, object, getCreateDefaults, resolveCreateEntry, ...props }, forwardedRef) => {\n const db = Obj.getDatabase(object);\n const meta = Obj.getMeta(object);\n // `meta.tags` already holds `Ref<Tag>`s (materialized by the database handler).\n const tags = [...meta.tags];\n const values = useMemo(() => ({ [META_TAGS_KEY]: tags, ...object }), [object, tags]);\n\n // Obj.getType fails for database-registered (dynamic) schemas due to DXN mismatch;\n // useType queries by the object's stored type URI, resolving both static and dynamic schemas.\n const typeUri = Obj.getTypeURI(object);\n const typeFromRegistry = useType(db, typeUri);\n const type = Obj.getType(object) ?? typeFromRegistry;\n\n const formSchema = useMemo(() => {\n return Function.pipe(\n type,\n Option.fromNullable,\n Option.map((type) => Type.getSchema(type)),\n Option.map((schema) => withMetaTags(schema)),\n Option.getOrUndefined,\n );\n }, [type]);\n\n // Persist a newly-created object referenced by one of the form's ref\n // fields and return it. The calling RefField wires the new Ref into its\n // own slot's form value; for the synthetic `_tags` array, the resulting\n // form change is then synced back to `Obj.getMeta(object).tags` by\n // `handleChange` below — so Tag.Tag follows the same generic path as any\n // other ref-array field, no type-specific branching required here.\n //\n // Schemas whose required structure can't be produced by `Obj.make(schema,\n // values)` alone (e.g. types with a required ref to a backing object) can\n // declare a `FactoryAnnotation` to take over construction.\n const handleCreate = useCallback(\n (type: Type.AnyEntity, values: any): Obj.Unknown => {\n invariant(db);\n invariant(Type.isObject(type));\n const factory = Option.getOrUndefined(FactoryAnnotation.get(Type.getSchema(type)));\n const newObject = factory ? (factory(values) as Obj.Unknown) : Obj.make(type, values);\n return db.add(newObject) as Obj.Unknown;\n },\n [db],\n );\n\n // TODO(wittjosiah): Use FormRootProps type.\n const handleChange = useCallback(\n (\n { [META_TAGS_KEY]: metaTags, ...values }: any,\n { isValid, changed }: { isValid: boolean; changed: Record<SchemaEx.JsonPath, boolean> },\n ) => {\n if (!isValid) {\n return;\n }\n\n const changedPaths = Object.keys(changed).filter(\n (path) => changed[path as SchemaEx.JsonPath],\n ) as SchemaEx.JsonPath[];\n\n // Handle meta-tags separately using Obj.update.\n const hasTagsChange = changedPaths.some((path) => SchemaEx.splitJsonPath(path)[0] === META_TAGS_KEY);\n if (hasTagsChange) {\n Obj.update(object, (object) => {\n // Copy so later in-place form mutations don't bypass the `Obj.update` boundary.\n Obj.getMeta(object).tags = Array.isArray(metaTags) ? [...(metaTags as Ref.Ref<Tag.Tag>[])] : [];\n });\n }\n\n // Handle other property changes.\n const nonTagPaths = changedPaths.filter((path) => SchemaEx.splitJsonPath(path)[0] !== META_TAGS_KEY);\n if (nonTagPaths.length > 0) {\n Obj.update(object, () => {\n for (const path of nonTagPaths) {\n const parts = SchemaEx.splitJsonPath(path);\n const value = Obj.getValue(values as any, parts);\n Obj.setValue(object, parts, value);\n }\n });\n }\n },\n [object],\n );\n\n if (!formSchema) {\n return null;\n }\n\n return (\n <Form.Root\n db={db}\n schema={formSchema}\n defaultValues={values as any}\n createTypename={Type.getTypename(Tag.Tag)}\n createOptionIcon='ph--plus--regular'\n createOptionLabel={['add-tag.label', { ns: translationKey }]}\n createInitialValuePath='label'\n createFieldMap={createFieldMap}\n onValuesChanged={handleChange}\n onCreate={handleCreate}\n getCreateDefaults={getCreateDefaults}\n resolveCreateEntry={resolveCreateEntry}\n >\n <Form.Viewport {...composableProps(props)} scroll ref={forwardedRef}>\n <Form.Content>\n <Form.FieldSet />\n <Form.Section>{children}</Form.Section>\n </Form.Content>\n </Form.Viewport>\n </Form.Root>\n );\n },\n);\n\nconst createFieldMap: FormFieldMap = {\n hue: ({ type, label, presentation, getValue, onValueChange }) => {\n const handleChange = useCallback((nextHue: string) => onValueChange(type, nextHue), [onValueChange, type]);\n const handleReset = useCallback(() => onValueChange(type, undefined), [onValueChange, type]);\n return (\n <>\n {presentation !== 'inline' && <Form.Label label={label} />}\n <HuePicker value={getValue()} onChange={handleChange} onReset={handleReset} />\n </>\n );\n },\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\n// A minimal, read-only schema-driven viewer. Walks an Effect Schema and a\n// matching value and produces a flat list of indented key/value rows -- one\n// per leaf field, with nested Struct fields contributing a header row plus\n// recursively-indented children, and arrays expanded as `[index]` rows.\n//\n// Designed to drive a hierarchical editor over schemas produced by\n// `@dxos/effect-proto` (e.g. the proto-generated `dxos.config.Config`\n// schema), but works for any Effect Struct schema.\n\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\nimport React, { type ReactElement, type ReactNode, type RefAttributes } from 'react';\n\nimport { composable, composableProps } from '@dxos/react-ui';\nimport { mx } from '@dxos/ui-theme';\nimport { type ComposableProps } from '@dxos/ui-types';\n\nexport type ObjectTreeProps<T> = {\n schema: Schema.Schema<T, any, never>;\n value: T;\n};\n\n/**\n * Render a value as a sequence of key/value rows whose shape and order are\n * driven by `schema`. Object-typed properties become a header row whose\n * children are indented under it; arrays expand element-by-element.\n *\n * Composable: spreads unknown props (incl. `className` / `classNames` /\n * `style` / `role`) onto its root `<div>` and forwards its ref, so it can\n * be slotted into themed parents like `Panel.Content`.\n */\nconst ObjectTreeImpl = composable<HTMLDivElement, ObjectTreeProps<any>>(({ schema, value, ...props }, forwardedRef) => (\n <div {...composableProps(props, { role: 'table', classNames: 'font-mono text-sm w-full' })} ref={forwardedRef}>\n <Node ast={schema.ast} value={value} label={null} depth={0} />\n </div>\n));\n\nObjectTreeImpl.displayName = 'ObjectTree';\n\n// `composable<HTMLDivElement, ObjectTreeProps<any>>` erases the `T` type\n// parameter inside the factory; the cast restores the generic signature for\n// consumers without changing the underlying component (the COMPOSABLE marker\n// stays attached). This is the pattern documented on `composable()` itself.\nexport const ObjectTree = ObjectTreeImpl as unknown as <T>(\n props: ComposableProps<ObjectTreeProps<T>> & RefAttributes<HTMLDivElement>,\n) => ReactElement | null;\n\n/**\n * Peel wrappers that don't affect the runtime shape: Refinements pass their\n * `from`, Suspends resolve via `f()`, and Transformations expose the encoded\n * (input) side. Repeated unwrapping handles chains like `Schema.suspend ->\n * Refinement -> TypeLiteral`.\n */\nconst unwrap = (ast: SchemaAST.AST): SchemaAST.AST => {\n if (SchemaAST.isRefinement(ast)) {\n return unwrap(ast.from);\n }\n if (SchemaAST.isSuspend(ast)) {\n return unwrap(ast.f());\n }\n if (SchemaAST.isTransformation(ast)) {\n return unwrap(ast.from);\n }\n return ast;\n};\n\n/**\n * Effect models `Schema.optional(X)` as a property whose type AST is\n * `Union(X, UndefinedKeyword)`. For walking purposes we want X -- the\n * undefined branch carries no schema information for the viewer.\n */\nconst stripOptional = (ast: SchemaAST.AST): SchemaAST.AST => {\n if (!SchemaAST.isUnion(ast)) {\n return ast;\n }\n const nonUndef = ast.types.filter((t) => !SchemaAST.isUndefinedKeyword(t));\n return nonUndef.length === 1 ? nonUndef[0] : ast;\n};\n\ntype NodeProps = {\n ast: SchemaAST.AST;\n value: unknown;\n /** Row label; `null` means render children directly without a header row. */\n label: ReactNode | null;\n depth: number;\n};\n\nconst Node = ({ ast, value, label, depth }: NodeProps) => {\n const inner = unwrap(stripOptional(ast));\n\n // Struct: header row + indented children. Skipping the header at depth 0\n // keeps the root flush-left.\n if (SchemaAST.isTypeLiteral(inner) && isPlainObject(value)) {\n const childDepth = label === null ? depth : depth + 1;\n return (\n <>\n {label !== null && <Row label={label} value={null} depth={depth} kind='group' />}\n {inner.propertySignatures.map((prop) => (\n <Node\n key={String(prop.name)}\n ast={prop.type}\n value={(value as Record<string, unknown>)[String(prop.name)]}\n label={String(prop.name)}\n depth={childDepth}\n />\n ))}\n </>\n );\n }\n\n // Array (`Schema.Array(X)` -> TupleType with single rest element).\n if (SchemaAST.isTupleType(inner) && Array.isArray(value)) {\n const elemType = inner.rest[0]?.type;\n return (\n <>\n {label !== null && <Row label={label} value={`Array(${value.length})`} depth={depth} kind='group' />}\n {value.map((item, index) => (\n <Node\n key={index}\n ast={elemType ?? SchemaAST.unknownKeyword}\n value={item}\n label={`[${index}]`}\n depth={depth + 1}\n />\n ))}\n </>\n );\n }\n\n // Leaf (scalars, unions of literals, unknown, etc.).\n return <Row label={label ?? ''} value={formatLeaf(value)} depth={depth} kind='leaf' />;\n};\n\ntype RowProps = {\n label: ReactNode;\n value: ReactNode;\n depth: number;\n kind: 'group' | 'leaf';\n};\n\nconst Row = ({ label, value, depth }: RowProps) => (\n <div role='row' className={mx('flex items-baseline gap-3 py-1')} style={{ paddingInlineStart: 8 + depth * 16 }}>\n <div role='cell' className='text-subdued'>\n {label}\n </div>\n <div role='cell' className={mx('break-all text-base-fg')}>\n {value}\n </div>\n </div>\n);\n\nconst isPlainObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\n/**\n * Format a leaf value for display. Strings are quoted so empty strings are\n * visible; missing values surface as an em-dash so the row stays present.\n */\nconst formatLeaf = (value: unknown): ReactNode => {\n if (value === undefined) {\n return null;\n }\n\n if (value === null) {\n return <span className='text-description'>null</span>;\n }\n\n switch (typeof value) {\n case 'string':\n // Quote strings so empty strings remain visible (`\"\"` rather than blank).\n return <span className='text-blue-text'>{JSON.stringify(value)}</span>;\n case 'number':\n case 'bigint':\n return <span className='text-green-text'>{String(value)}</span>;\n case 'boolean':\n return <span className='text-purple-text'>{String(value)}</span>;\n default:\n // Objects we couldn't expand via schema (e.g. `google.protobuf.Any` -> Unknown)\n // are rendered as compact JSON.\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n }\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { type Extension, Prec } from '@codemirror/state';\nimport { type EditorView } from '@codemirror/view';\nimport React, { forwardRef, useCallback, useEffect, useMemo, useRef } from 'react';\n\nimport { type Database, Filter, Obj, type Type } from '@dxos/echo';\nimport { useQuery } from '@dxos/react-client/echo';\nimport { type ThemedClassName, useThemeContext, useTranslation } from '@dxos/react-ui';\nimport {\n Editor,\n type EditorController,\n type EditorMenuProviderProps,\n type EditorViewProps,\n type UseEditorMenuProps,\n} from '@dxos/react-ui-editor';\nimport { createBasicExtensions, createThemeExtensions, insertAtCursor, keymap } from '@dxos/ui-editor';\nimport { getHashHue } from '@dxos/ui-theme';\n\nimport { translationKey } from '#translations';\n\nimport {\n EMAIL_REGEX,\n NAME_ADDR_REGEX,\n type RefEditorMode,\n type RefInfo,\n formatMailbox,\n refEditor,\n refEditorRedecorate,\n} from './ref-editor-extension';\n\nexport type RefEditorProps = ThemedClassName<\n {\n /** Database queried for objects of {@link RefEditorProps.type}. */\n db?: Database.Database;\n /** ECHO object type whose instances are offered in the typeahead and referenced as `@<id>`. */\n type: Type.AnyObj;\n value?: string;\n readonly?: boolean;\n /**\n * Content model:\n * - `'ref'` (default): the picker only matches existing objects; selection inserts an\n * `@<id>` reference (raw tokens accepted by `match` are also allowed).\n * - `'email'`: the picker shows one item per (object, value) pair and selection captures the\n * value; the content is an RFC 5322 mailbox list (`Name <email>, ...`) with the comma\n * separators hidden inside the tags.\n */\n mode?: RefEditorMode;\n /** Pluggable raw-token matcher (e.g. {@link EMAIL_REGEX}); matching tokens are accepted as values. */\n match?: RegExp;\n /** Display label for an object; defaults to `Obj.getLabel` falling back to the id. */\n getLabel?: (object: Obj.Unknown) => string;\n /** Values an object can be captured as in `'email'` mode (e.g. a person's email addresses). */\n getValues?: (object: Obj.Unknown) => readonly string[];\n /** Menu item icon. */\n icon?: string;\n /** Already-translated placeholder; defaults to a generic hint. */\n placeholder?: string;\n /** Open the typeahead while typing (the `@` trigger remains available but is not required). */\n activateOnTyping?: boolean;\n } & Omit<EditorViewProps, 'initialValue'> &\n Pick<EditorMenuProviderProps, 'numItems'>\n>;\n\n/**\n * Single-line input for a list of object references. Typing `@` (or any text, with\n * `activateOnTyping`) opens a typeahead menu matching objects of the given type by label (and\n * by their `getValues` values). The content model depends on {@link RefEditorProps.mode}.\n * Resolved entries render as atomic tags with the object's label; raw tokens accepted by the\n * pluggable `match` regexp render as neutral tags.\n */\nexport const RefEditor = forwardRef<EditorController, RefEditorProps>(\n (\n {\n db,\n type,\n value,\n readonly,\n mode = 'ref',\n match,\n getLabel,\n getValues,\n icon = 'ph--link--regular',\n placeholder: placeholderProp,\n activateOnTyping,\n numItems = 8,\n ...props\n },\n forwardedRef,\n ) => {\n const { t } = useTranslation(translationKey);\n const { themeMode } = useThemeContext();\n const getObjectLabel = useCallback(\n (object: Obj.Unknown) => getLabel?.(object) ?? Obj.getLabel(object) ?? object.id,\n [getLabel],\n );\n\n // Reads go through a ref so the decoration extension stays stable: recreating extensions\n // destroys and recreates the editor, which would blur the input on data changes.\n const filter = useMemo(() => Filter.type(type), [type]);\n const objects = useQuery(db, filter);\n const refs = useMemo(\n () =>\n new Map<string, RefInfo>(\n objects.map((object) => [object.id, { label: getObjectLabel(object), hue: getHashHue(object.id) }]),\n ),\n [objects, getObjectLabel],\n );\n const refsRef = useRef(refs);\n refsRef.current = refs;\n\n // Internal controller (merged with the forwarded ref) used to re-resolve reference\n // decorations when object data changes after the document was rendered.\n const controllerRef = useRef<EditorController | null>(null);\n const composedRef = useCallback(\n (controller: EditorController | null) => {\n controllerRef.current = controller;\n if (typeof forwardedRef === 'function') {\n forwardedRef(controller);\n } else if (forwardedRef) {\n forwardedRef.current = controller;\n }\n },\n [forwardedRef],\n );\n useEffect(() => {\n controllerRef.current?.view?.dispatch({ effects: refEditorRedecorate.of(null) });\n }, [refs]);\n\n const getMenu = useCallback<NonNullable<UseEditorMenuProps['getMenu']>>(\n async ({ text }) => {\n const query = (text ?? '').replace(/^@/, '').toLowerCase();\n const matchesQuery = (object: Obj.Unknown) =>\n !query ||\n getObjectLabel(object).toLowerCase().includes(query) ||\n (getValues?.(object) ?? []).some((entry) => entry.toLowerCase().includes(query));\n\n if (mode === 'email') {\n // One item per (object, value) pair; selection captures the value as an RFC 5322 mailbox.\n const mailboxes = objects\n .flatMap((object) => (getValues?.(object) ?? []).map((entry) => ({ object, entry })))\n .filter(\n ({ object, entry }) =>\n !query || getObjectLabel(object).toLowerCase().includes(query) || entry.toLowerCase().includes(query),\n );\n\n return [\n {\n id: 'mailboxes',\n items: mailboxes.slice(0, numItems * 2).map(({ object, entry }) => ({\n id: `${object.id}-${entry}`,\n label: `${getObjectLabel(object)} (${entry})`,\n icon,\n onSelect: ({ view, head }: { view: EditorView; head: number }) =>\n insertMailbox(view, head, formatMailbox(getObjectLabel(object), entry)),\n })),\n },\n ];\n }\n\n // 'ref' mode: only match existing objects.\n return [\n {\n id: 'refs',\n items: objects\n .filter(matchesQuery)\n .slice(0, numItems * 2)\n .map((object) => {\n const label = getObjectLabel(object);\n const detail = getValues?.(object)?.[0];\n return {\n id: object.id,\n label: detail && detail !== label ? `${label} (${detail})` : label,\n icon,\n onSelect: ({ view, head }: { view: EditorView; head: number }) =>\n insertAtCursor(view, head, `@${object.id} `),\n };\n }),\n },\n ];\n },\n [objects, numItems, mode, icon, getObjectLabel, getValues],\n );\n\n // NOTE: The placeholder is supplied via the popover (Editor.Root) so the trigger hint and the\n // empty-state hint are a single message; a second basic-extension placeholder would stack with it.\n // Must be referentially stable: the menu extension is memoized on it, and a new extension\n // identity destroys and recreates the editor on every keystroke.\n const placeholder = useMemo(\n () => ({\n content: placeholderProp ?? t(activateOnTyping ? 'ref-editor-auto.placeholder' : 'ref-editor.placeholder'),\n focusOnly: false,\n }),\n [t, placeholderProp, activateOnTyping],\n );\n\n const extensions = useMemo<Extension[]>(\n () => [\n createBasicExtensions({ readOnly: readonly, lineWrapping: false }),\n createThemeExtensions({ themeMode, slots: { scroller: { className: 'scrollbar-none' } } }),\n refEditor({ mode, match, getRef: (id) => refsRef.current.get(id) }),\n Prec.highest(\n keymap.of([\n {\n key: 'Enter',\n // Commit the in-progress token when it matches (insert the mode's separator, the\n // same gesture as typing it); always consume the key (single-line input).\n run: (view) => {\n const { head } = view.state.selection.main;\n const line = view.state.doc.lineAt(head);\n const before = line.text.slice(0, head - line.from);\n if (mode === 'email') {\n const segment = before.slice(before.lastIndexOf(',') + 1).trim();\n if (NAME_ADDR_REGEX.test(segment) || (match ?? EMAIL_REGEX).test(segment)) {\n insertAtCursor(view, head, ', ');\n }\n } else {\n const token = before.slice(before.search(/\\S+$/));\n if (token && match?.test(token)) {\n insertAtCursor(view, head, ' ');\n }\n }\n return true;\n },\n },\n ]),\n ),\n ],\n [readonly, themeMode, mode, match],\n );\n\n return (\n <Editor.Root\n extensions={extensions}\n numItems={numItems}\n trigger='@'\n activateOnTyping={activateOnTyping}\n placeholder={placeholder}\n // The menu owns its own matching (labels AND values); the built-in label filter would\n // drop value-matched objects whose label doesn't start with the query.\n filter={false}\n getMenu={getMenu}\n ref={composedRef}\n >\n <Editor.View\n // TOOD(burdon): Use same style as react-ui Input.\n classNames='border border-input-separator rounded-xs px-2'\n {...props}\n initialValue={value}\n selectionEnd\n />\n </Editor.Root>\n );\n },\n);\n\nRefEditor.displayName = 'RefEditor';\n\n/**\n * Insert an RFC 5322 mailbox, replacing the in-progress segment (anything typed after the last\n * comma — multi-word queries can leave words outside the popover's completion range).\n */\nconst insertMailbox = (view: EditorView, head: number, mailbox: string) => {\n const line = view.state.doc.lineAt(head);\n const before = line.text.slice(0, head - line.from);\n const lastComma = before.lastIndexOf(',');\n const from = line.from + (lastComma === -1 ? 0 : lastComma + 1);\n const insert = `${lastComma === -1 ? '' : ' '}${mailbox}, `;\n view.dispatch({\n changes: { from, to: head, insert },\n selection: { anchor: from + insert.length, head: from + insert.length },\n });\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { type EditorState, type Extension, RangeSetBuilder, StateEffect, StateField } from '@codemirror/state';\nimport { Decoration, type DecorationSet, EditorView, WidgetType } from '@codemirror/view';\n\nimport { Domino } from '@dxos/ui';\nimport { getHashHue, getStyles, mx } from '@dxos/ui-theme';\n\n/**\n * Display info for a resolved object reference.\n */\nexport type RefInfo = {\n label: string;\n hue?: string;\n};\n\n/**\n * Content model:\n * - `'ref'`: whitespace-separated tokens; `@<id>` references to existing objects (and raw tokens\n * accepted by the pluggable {@link RefEditorExtensionOptions.match} regexp).\n * - `'email'`: comma-separated RFC 5322 mailboxes (`Name <email>` or bare `email`); the comma\n * separators are consumed into the atomic tags so they are not visible.\n */\nexport type RefEditorMode = 'ref' | 'email';\n\nexport type RefEditorExtensionOptions = {\n mode?: RefEditorMode;\n /** Resolve an object id referenced as `@<id>` to display info. */\n getRef?: (id: string) => RefInfo | undefined;\n /** Pluggable raw-token matcher (e.g. {@link EMAIL_REGEX}); matching tokens render as neutral tags. */\n match?: RegExp;\n};\n\n/** Matches an object reference token (`@<object id>`). */\nexport const REF_REGEX = /^@([A-Za-z0-9]+)$/;\n\n/** Matches a well-formed email address token. */\nexport const EMAIL_REGEX = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$/;\n\n/** Matches an RFC 5322 name-addr (`Name <email>`); group 1 = display name, group 2 = addr-spec. */\nexport const NAME_ADDR_REGEX = /^(.*?)\\s*<([A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,})>$/;\n\n/** Formats an RFC 5322 mailbox (`Name <email>`). */\nexport const formatMailbox = (name: string | undefined, email: string): string => (name ? `${name} <${email}>` : email);\n\n/**\n * Effect dispatched when reference data changes out-of-band (e.g. objects finish loading) so that\n * already-rendered reference decorations re-resolve without a document change.\n */\nexport const refEditorRedecorate = StateEffect.define<null>();\n\n/**\n * CodeMirror extension rendering reference-editor tokens as tags. Tags are atomic: the cursor\n * cannot enter them and deletion removes the whole token.\n * - `'ref'` mode: `@<id>` references resolve to the object's label (via\n * {@link RefEditorExtensionOptions.getRef}); tokens accepted by the pluggable `match` regexp\n * render as neutral tags.\n * - `'email'` mode: RFC 5322 mailboxes render as tags labelled with the display name (falling\n * back to the address); the trailing comma separator is hidden inside the tag's atomic range.\n */\nexport const refEditor = ({ mode = 'ref', getRef, match }: RefEditorExtensionOptions = {}): Extension => {\n const buildRefDecorations = (state: EditorState) => {\n const deco = new RangeSetBuilder<Decoration>();\n const text = state.doc.toString();\n const tokenRegex = /\\S+/g;\n let tokenMatch: RegExpExecArray | null;\n while ((tokenMatch = tokenRegex.exec(text))) {\n const token = tokenMatch[0];\n const from = tokenMatch.index;\n const to = from + token.length;\n\n const refMatch = token.match(REF_REGEX);\n if (refMatch) {\n const ref = getRef?.(refMatch[1]);\n if (ref) {\n deco.add(\n from,\n to,\n Decoration.widget({\n widget: new RefWidget(ref.label, ref.hue ?? getHashHue(refMatch[1])),\n atomic: true,\n }),\n );\n }\n continue;\n }\n\n if (match?.test(token)) {\n deco.add(\n from,\n to,\n Decoration.widget({\n widget: new TokenWidget(token),\n atomic: true,\n }),\n );\n }\n }\n\n return deco.finish();\n };\n\n const buildEmailDecorations = (state: EditorState) => {\n const addrRegex = match ?? EMAIL_REGEX;\n const deco = new RangeSetBuilder<Decoration>();\n const text = state.doc.toString();\n // Segments are comma-separated; a segment's atomic range includes its trailing comma (and\n // following whitespace) so the separator never renders.\n const segmentRegex = /[^,]+(?:,\\s*)?|,\\s*/g;\n let segmentMatch: RegExpExecArray | null;\n while ((segmentMatch = segmentRegex.exec(text))) {\n const segment = segmentMatch[0];\n const commaIndex = segment.indexOf(',');\n const content = (commaIndex === -1 ? segment : segment.slice(0, commaIndex)).trim();\n if (!content) {\n continue;\n }\n const leading = segment.length - segment.trimStart().length;\n const from = segmentMatch.index + leading;\n const to = segmentMatch.index + segment.length;\n\n const nameAddr = content.match(NAME_ADDR_REGEX);\n if (nameAddr) {\n deco.add(\n from,\n to,\n Decoration.widget({\n widget: new RefWidget(nameAddr[1] || nameAddr[2], getHashHue(nameAddr[2])),\n atomic: true,\n }),\n );\n } else if (addrRegex.test(content)) {\n deco.add(\n from,\n to,\n Decoration.widget({\n widget: new TokenWidget(content),\n atomic: true,\n }),\n );\n }\n }\n\n return deco.finish();\n };\n\n const buildDecorations = mode === 'email' ? buildEmailDecorations : buildRefDecorations;\n\n return [\n styles,\n StateField.define<DecorationSet>({\n create: (state) => buildDecorations(state),\n update: (deco, tr) => {\n if (tr.docChanged || tr.effects.some((effect) => effect.is(refEditorRedecorate))) {\n return buildDecorations(tr.state);\n }\n\n return deco;\n },\n provide: (field) => [\n EditorView.decorations.from(field),\n EditorView.atomicRanges.of((view) => {\n const builder = new RangeSetBuilder<Decoration>();\n const cursor = view.state.field(field).iter();\n while (cursor.value) {\n if (cursor.value.spec.atomic) {\n builder.add(cursor.from, cursor.to, cursor.value);\n }\n cursor.next();\n }\n\n return builder.finish();\n }),\n ],\n }),\n ];\n};\n\nconst lineHeight = '30px';\n\n/**\n * NOTE: The outer container vertically aligns the inner text with content in the outer div.\n */\nconst container = (classNames: string, ...children: Domino<HTMLElement>[]) => {\n const inner = Domino.of('span')\n .classNames(mx('inline-flex h-[26px] border rounded-xs', classNames))\n .append(...children);\n return Domino.of('span').classNames('inline-flex h-[28px] align-middle').append(inner).root;\n};\n\n/**\n * Resolved reference (object reference or RFC 5322 mailbox), rendered as the object's label.\n */\nclass RefWidget extends WidgetType {\n constructor(\n private readonly _label: string,\n private readonly _hue: string,\n ) {\n super();\n }\n\n override eq(other: this) {\n return this._label === other._label && this._hue === other._hue;\n }\n\n override toDOM() {\n const { bg: fill, border, surface } = getStyles(this._hue);\n return container(\n border,\n Domino.of('span').classNames(mx('flex items-center px-1 text-black text-xs', fill)).text('@'),\n Domino.of('span')\n .classNames(mx('flex items-center px-1 text-subdued text-sm rounded-r-[3px]', surface))\n .text(this._label),\n );\n }\n}\n\n/**\n * Raw token accepted by the pluggable matcher (e.g. an email address).\n */\nclass TokenWidget extends WidgetType {\n constructor(private readonly _token: string) {\n super();\n }\n\n override eq(other: this) {\n return this._token === other._token;\n }\n\n override toDOM() {\n return container(\n 'border-separator',\n Domino.of('span').classNames('flex items-center px-1 text-subdued text-sm').text(this._token),\n );\n }\n}\n\nconst styles = EditorView.theme({\n '.cm-line': {\n lineHeight,\n },\n // Match the standard Input block size (md density): 2.5rem, 2rem on pointer-fine devices.\n '.cm-scroller': {\n alignItems: 'center',\n minHeight: '2.5rem',\n },\n '@media (pointer: fine)': {\n '.cm-scroller': {\n minHeight: '2rem',\n },\n },\n});\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { RegistryContext } from '@effect-atom/atom-react';\nimport * as Match from 'effect/Match';\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\nimport React, { forwardRef, useCallback, useContext, useImperativeHandle, useMemo, useState } from 'react';\n\nimport {\n DXN,\n EID,\n Entity,\n Feed,\n Filter,\n Format,\n Obj,\n Query,\n QueryAST,\n Ref,\n type Registry,\n Type,\n View,\n} from '@dxos/echo';\nimport { SchemaEx } from '@dxos/effect';\nimport { invariant } from '@dxos/invariant';\nimport { useObject, useQuery } from '@dxos/react-client/echo';\nimport { Input, Message, type ThemedClassName, ToggleIconButton, useTranslation } from '@dxos/react-ui';\nimport { QueryForm, type QueryFormProps } from '@dxos/react-ui-components';\nimport { OrderedList } from '@dxos/react-ui-list';\nimport {\n ParentLabelAnnotation,\n ProjectionModel,\n VIEW_FIELD_LIMIT,\n createEchoChangeCallback,\n getTypeURIFromQuery,\n} from '@dxos/schema';\nimport { mx } from '@dxos/ui-theme';\n\nimport { translationKey } from '#translations';\nimport { type FormFieldMap, type FormFieldRenderer, type FormFieldRendererProps } from '#types';\n\nimport { FieldEditor } from '../FieldEditor';\nimport { CompactIconButton, Form, FormFieldHeader, FormFieldLabel, type FormRootProps } from '../Form';\n\nexport type ViewEditorProps = ThemedClassName<\n {\n type?: Type.AnyEntity;\n view: View.View;\n mode?: 'schema' | 'tag';\n registry?: Registry.Registry;\n showHeading?: boolean;\n onQueryChanged?: (query: QueryAST.Query, target?: EID.EID) => void;\n onDelete?: (fieldId: string) => void;\n } & Pick<QueryFormProps, 'types' | 'tags'> &\n Pick<FormRootProps<any>, 'readonly' | 'db'>\n>;\n\n/**\n * View editor form.\n */\nexport const ViewEditor = forwardRef<ProjectionModel | null, ViewEditorProps>(\n (\n {\n classNames,\n type,\n view,\n mode = 'schema',\n registry,\n db,\n readonly,\n showHeading = false,\n types,\n tags,\n onQueryChanged,\n onDelete,\n },\n forwardedRef,\n ) => {\n const atomRegistry = useContext(RegistryContext);\n const schemaReadonly = type == null || Type.getDatabase(type) == null;\n const { t } = useTranslation(translationKey);\n\n const projectionModel = useMemo(() => {\n if (!type) {\n return null;\n }\n\n const jsonSchema = type.jsonSchema;\n\n // Always use createEchoChangeCallback since the view is ECHO-backed.\n // Pass type only when mutable to allow schema mutations.\n const change = createEchoChangeCallback(view, Type.getDatabase(type) != null ? type : undefined);\n\n const model = new ProjectionModel({\n registry: atomRegistry,\n view,\n baseSchema: jsonSchema,\n change,\n });\n\n return model;\n }, [atomRegistry, type, view]);\n\n useImperativeHandle<ProjectionModel | null, ProjectionModel | null>(forwardedRef, () => projectionModel, [\n projectionModel,\n ]);\n\n const queueTarget = Match.value(view.query.ast).pipe(\n Match.when({ type: 'from' }, ({ from }) => {\n if (from._tag !== 'scope') {\n return undefined;\n }\n\n const feedScope = from.scopes.find((s) => s._tag === 'feed');\n return Option.fromNullable(feedScope).pipe(\n Option.map((s) => s.feedUri),\n Option.getOrUndefined,\n );\n }),\n Match.orElse(() => undefined),\n );\n\n const feeds = useQuery(db, Filter.type(Feed.Feed));\n\n const targetRef = useMemo(() => {\n if (!queueTarget) {\n return undefined;\n }\n const targetEid = EID.tryParse(queueTarget);\n const feed = feeds.find((feed) => {\n const feedEid = Feed.getQueueUri(feed);\n return feedEid != null && targetEid != null && EID.equals(feedEid, targetEid);\n });\n return feed ? Ref.fromURI(Entity.getURI(feed)) : undefined;\n }, [queueTarget, feeds]);\n\n const viewSchema = useMemo(() => {\n const base = Schema.Struct({\n query:\n mode === 'schema'\n ? Format.URL.annotations({ title: 'Record type' })\n : QueryAST.Query.annotations({ title: 'Query' }),\n });\n\n if (mode === 'tag') {\n return Schema.Struct({\n ...base.fields,\n // TODO(wittjosiah): Replace Type.Feed with Dataset.Dataset when Ref.Ref supports unions.\n target: Ref.Ref(Feed.Feed).pipe(\n Schema.annotations({ title: 'Target Feed' }),\n ParentLabelAnnotation.set(true),\n Schema.optional,\n ),\n }).pipe(Schema.mutable);\n }\n\n return base.pipe(Schema.mutable);\n }, [mode]);\n\n // TODO(burdon): Need to warn user of possible consequences of editing.\n // TODO(burdon): Settings should have domain name owned by user.\n const viewValues = useMemo(() => {\n // Schema mode edits a typename; show the version-less name of the type DXN.\n const typeUri = getTypeURIFromQuery(view.query.ast);\n const typeDxn = typeUri ? DXN.tryMake(typeUri) : undefined;\n return {\n query: mode === 'schema' ? (typeDxn ? DXN.getName(typeDxn) : (typeUri ?? '')) : view.query.ast,\n target: targetRef,\n };\n }, [mode, view.query.ast, targetRef]);\n\n const fieldMap = useMemo<FormFieldMap | undefined>(\n () => (mode === 'tag' ? customFields({ types, tags }) : undefined),\n [mode, types, tags],\n );\n\n const handleUpdate = useCallback(\n (values: any) => {\n const targetValue = values.target;\n let queueDxn: EID.EID | undefined;\n\n if (Ref.isRef(targetValue)) {\n const feedUri = targetValue.uri;\n const feed = feeds.find((feed) => Obj.getURI(feed) === feedUri);\n if (feed) {\n queueDxn = Feed.getQueueUri(feed);\n }\n }\n\n // TODO(wittjosiah): Deep-clone the AST to plain JS or ECHO proxy arrays become objects with numeric keys.\n // In schema mode, values.query is either a DXN name (static types) or a raw `echo:` EID\n // (db-backed types, which have no DXN). Preserve EIDs verbatim; wrap bare names as DXN.\n const query =\n mode === 'schema'\n ? Query.select(Filter.type(EID.isEID(values.query) ? (values.query as EID.EID) : DXN.make(values.query)))\n .ast\n : JSON.parse(JSON.stringify(values.query));\n onQueryChanged?.(query, queueDxn);\n },\n [onQueryChanged, mode, feeds],\n );\n\n const handleDelete = useCallback(\n (fieldId: string) => {\n invariant(!readonly);\n onDelete?.(fieldId);\n },\n [onDelete, readonly],\n );\n\n return (\n <div className={mx(classNames)}>\n {/* TODO(burdon): Is the form read-only or just the schema? */}\n <Form.Root schema={viewSchema} values={viewValues} fieldMap={fieldMap} db={db} onValuesChanged={handleUpdate}>\n <Form.Viewport>\n <Form.Content>\n {/* If readonly is set, then the callout is not needed. */}\n {schemaReadonly && !readonly && (\n <Message.Root valence='info' classNames='my-form-padding'>\n <Message.Title>{t('system-schema.description')}</Message.Title>\n </Message.Root>\n )}\n <Form.FieldSet />\n {type && (\n <FieldList\n type={type}\n view={view}\n registry={registry}\n readonly={readonly}\n showHeading={showHeading}\n onDelete={handleDelete}\n />\n )}\n </Form.Content>\n </Form.Viewport>\n </Form.Root>\n </div>\n );\n },\n);\n\nconst customFields = ({ types, tags }: Pick<ViewEditorProps, 'types' | 'tags'>): Record<string, FormFieldRenderer> => ({\n query: ({ type, readonly, label, getValue, onValueChange }: FormFieldRendererProps) => {\n const handleChange = useCallback<NonNullable<QueryFormProps['onChange']>>(\n (query) => onValueChange(type, query.ast),\n [onValueChange],\n );\n\n return (\n <Input.Root>\n <FormFieldLabel readonly={readonly} label={label} />\n <QueryForm initialQuery={getValue()} types={types} tags={tags} onChange={handleChange} />\n </Input.Root>\n );\n },\n});\n\ntype FieldListProps = {\n type: Type.AnyEntity;\n} & Pick<ViewEditorProps, 'view' | 'registry' | 'readonly' | 'showHeading' | 'onDelete'>;\n\nconst FieldList = ({ type, view, registry, readonly, showHeading = false, onDelete }: FieldListProps) => {\n const atomRegistry = useContext(RegistryContext);\n const schemaReadonly = Type.getDatabase(type) == null;\n const { t } = useTranslation(translationKey);\n\n // Subscribe to view changes for reactivity.\n const [viewSnapshot] = useObject(view);\n\n const projectionModel = useMemo(() => {\n const jsonSchema = type.jsonSchema;\n\n // Always use createEchoChangeCallback since the view is ECHO-backed.\n // Pass type only when mutable to allow schema mutations.\n const change = createEchoChangeCallback(view, Type.getDatabase(type) != null ? type : undefined);\n\n return new ProjectionModel({\n registry: atomRegistry,\n view,\n baseSchema: jsonSchema,\n change,\n });\n }, [atomRegistry, type, view]);\n\n const [expandedField, setExpandedField] = useState<View.FieldType['id']>();\n\n const handleAdd = useCallback(() => {\n invariant(!readonly);\n const field = projectionModel.createFieldProjection();\n setExpandedField(field.id);\n }, [projectionModel, readonly]);\n\n const handleDelete = useCallback(\n (fieldId: string) => {\n invariant(!readonly);\n if (fieldId === expandedField) {\n setExpandedField(undefined);\n }\n\n onDelete?.(fieldId);\n },\n [expandedField, onDelete, readonly],\n );\n\n const handleMove = useCallback(\n (fromIndex: number, toIndex: number) => {\n invariant(!readonly);\n Obj.update(view, (view) => {\n // NOTE(ZaymonFC): Using arrayMove here causes a race condition with the kanban model.\n const fields = [...view.projection.fields];\n const [moved] = fields.splice(fromIndex, 1);\n fields.splice(toIndex, 0, moved);\n view.projection.fields = fields;\n });\n },\n [view, readonly],\n );\n\n const handleClose = useCallback(() => setExpandedField(undefined), []);\n\n const handleHide = useCallback(\n (fieldId: string) => {\n setExpandedField(undefined);\n projectionModel.hideFieldProjection(fieldId);\n },\n [projectionModel],\n );\n\n const handleShow = useCallback(\n (property: string) => {\n setExpandedField(undefined);\n projectionModel.showFieldProjection(property as SchemaEx.JsonProp);\n },\n [projectionModel],\n );\n\n if (!viewSnapshot) {\n return null;\n }\n\n return (\n <OrderedList.Root<View.FieldType>\n items={viewSnapshot.projection.fields as View.FieldType[]}\n isItem={Schema.is(View.FieldSchema)}\n getId={(field) => field.id}\n onMove={readonly ? undefined : handleMove}\n readonly={readonly}\n expandedId={expandedField}\n onExpandedChange={setExpandedField}\n >\n {({ items: fields }) => (\n <>\n <FormFieldHeader\n label={t('fields.label')}\n readonly={readonly}\n add={{\n label: t('add-property-button.label'),\n disabled: viewSnapshot.projection.fields.length >= VIEW_FIELD_LIMIT,\n onClick: handleAdd,\n }}\n />\n {showHeading && <FormFieldLabel standalone classNames='py-1' label={t('field-path.label')} />}\n <OrderedList.Content>\n {fields.map((field) => {\n const hidden = field.visible === false;\n return (\n <OrderedList.DetailItem<View.FieldType>\n key={field.id}\n id={field.id}\n item={field}\n canDrag={!readonly && !schemaReadonly}\n expandable={!readonly}\n title={field.path}\n titleClassNames={hidden ? 'text-subdued' : undefined}\n actions={\n <ToggleIconButton\n iconOnly\n variant='ghost'\n active={hidden}\n icon='ph--eye--regular'\n activeIcon='ph--eye-closed--regular'\n label={t(hidden ? 'show-field.label' : 'hide-field.label')}\n data-testid={hidden ? 'show-field-button' : 'hide-field-button'}\n disabled={readonly || (!hidden && projectionModel.getFields().length <= 1)}\n onClick={() => (hidden ? handleShow(field.path) : handleHide(field.id))}\n />\n }\n trailing={\n !readonly && (\n <CompactIconButton\n icon='ph--x--regular'\n label={t('delete-field.label')}\n disabled={schemaReadonly || viewSnapshot.projection.fields.length <= 1}\n onClick={() => handleDelete(field.id)}\n data-testid='field.delete'\n />\n )\n }\n >\n <FieldEditor\n readonly={readonly || schemaReadonly}\n registry={registry}\n projection={projectionModel}\n field={field}\n onSave={handleClose}\n />\n </OrderedList.DetailItem>\n );\n })}\n </OrderedList.Content>\n </>\n )}\n </OrderedList.Root>\n );\n};\n"],
5
+ "mappings": ";AAMA,SAASA,8BAA8B;AAmBhC,IAAMC,4BAA4BC,uBAAOC,IAAI,uCAAA;AAC7C,IAAMC,0BAA0BJ,uBAAsCC,yBAAAA;AAOtE,IAAMI,gBACX,MACA,CACEC,MACAC,MACAC,aACmB;EAAEF;EAAMC;EAAME,UAAUD,SAASC;AAAS;AAc1D,IAAMC,uBAAuBR,uBAAOC,IAAI,kCAAA;AACxC,IAAMQ,qBAAqBX,uBAAiCU,oBAAAA;AAG5D,IAAME,WACX,MACA,CACEN,MACAO,YACc;EAAEP;EAAMO;AAAO;;;AC1DjC,OAAOC,WAASC,eAAAA,eAAaC,aAAAA,YAAWC,WAAAA,WAASC,YAAAA,kBAAgB;AAEjE,SAASC,UAAAA,SAAQC,OAAAA,MAAoBC,QAAAA,aAAuB;AAC5D,SAASC,UAAAA,SAAQC,aAAaC,oBAAoB;AAElD,SAASC,OAAAA,YAAW;AACpB,SAASC,gBAAgBC,kBAAAA,wBAAsB;AAC/C,SAGEC,sCACAC,uBACK;AAEP,SAASC,kBAAAA,wBAAsB;;;ACd/B,SAASC,QAAQC,aAAaC,gBAAgB;AAevC,IAAMC,aAAa,CAAC,EAAEC,MAAMC,QAAQC,OAAAA,OAAK,MAAc;AAC5D,MAAIA,WAAUC,UAAaD,WAAU,QAAQA,WAAU,IAAI;AACzD,WAAOC;EACT;AAEA,QAAMC,cAAc,CAACJ,UAAAA;AACnB,YAAQA,OAAAA;MACN,KAAKF,SAASO,SAAS;AACrB,YAAI,OAAOH,WAAU,UAAU;AAC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A,gBAAA;IAAOe,YAAS;;IAGlE,OAAM8B,EAAAA,kBAAeC;MACrB,gBAAA9C,QAAA,cACEiC,aAACA,SAAYc,MAAAA,OAAU,IAAA,CAAA,UAAA;UACrBC,SAAWC,MAAE,YAAA;WACD,gBAAAjD,QAAA,cAAAiC,aAAA,YAAA;MACZiB,KAAAA,MAAM3B;MACN4B,IAAAA,MAAU1C;MACV2C,MAAAA;MACA/E,SAAOkD,CAAAA,YAAU,CAAA;MACjB8B,YAAAA,CAAAA;MACAC,OAAAA,MAAAA;uBAEIC,SAAAA,iBAAAA;eACQ,gBAAAvD,QAAA,cAAAwD,mBAAA;QACRC,UAAQZ;QACRa,SAAK;QACLC,QAAAA;QACA5C,MAAAA;QACA6C,YAAAA;QACApB,OAAAA,EAAAA,SAAU/B,qBAAwBlE,kBAAgBsH;QAClDpB,eAAgBI,SAASiB,sBAAqB;;QAGlDC,SACGtD,MAAAA,SAAAA,WACC,MAAA,IAAA,IAAA,WAACuD,MAAAA,EAAAA;;gBAECjD,CAAOkD,YAAE,gBAAAjE,QAAA,cAAA,mBAAA;QACTwC,MAAAA;QACAC,OAAAA,EAAS,oBAAmBlB;QAC5BqC,UAAAA,kBAAY,aAAA,WAAA,OAAA,UAAA;;uBAKlB;MACEnD,CAAAA;OACU9D,gBAAAA,QAAAA,cAAAA,aAAAA;MACViF,UAAAA,YAAYrF;MACZgF;MACA2C,YAAQC;;MAIhB,QAAA;IAMZ,CAAA,CAAA;;;",
6
+ "names": ["createAnnotationHelper", "OptionsLookupAnnotationId", "Symbol", "for", "OptionsLookupAnnotation", "optionsLookup", "deps", "load", "options", "combobox", "AutofillAnnotationId", "AutofillAnnotation", "autofill", "derive", "React", "useCallback", "useEffect", "useMemo", "useState", "Filter", "Obj", "Type", "Format", "FormatEnums", "formatToType", "log", "useAsyncEffect", "useTranslation", "formatToAdditionalPropertyAttributes", "getFormatSchema", "translationKey", "Format", "GeoLocation", "TypeEnum", "parseValue", "type", "format", "value", "undefined", "parseScalar", "Boolean", "lowercaseValue", "toLowerCase", "Number", "cleaned", "replace", "num", "isNaN", "String", "Ref", "TypeFormat", "Percent", "Currency", "Markdown", "Error", "DateTime", "Date", "Time", "Timestamp", "date", "getTime", "GeoPoint", "parts", "split", "length", "lat", "parseFloat", "long", "toGeoPoint", "latitude", "longitude", "cellClassesForFieldType", "Duration", "JSON", "DID", "pathNotUniqueError", "path", "message", "format", "formatDate", "Format", "GeoLocation", "TypeEnum", "formatForDisplay", "type", "value", "locale", "undefined", "formatScalar", "Boolean", "toLocaleString", "toUpperCase", "Number", "String", "Ref", "TypeFormat", "Percent", "Currency", "style", "currency", "minimumFractionDigits", "maximumFractionDigits", "Date", "error", "Time", "DateTime", "GeoPoint", "Array", "isArray", "length", "every", "isFinite", "latitude", "longitude", "fromGeoPoint", "formatForEditing", "date", "toISOString", "split", "Option", "Schema", "SchemaAST", "Annotation", "Type", "omitId", "schemaOrType", "schema", "isType", "getSchema", "omitIdFromSchema", "ast", "isUnion", "Union", "types", "map", "type", "make", "hasId", "getPropertySignatures", "some", "prop", "name", "pipe", "omit", "omitHiddenFormFields", "properties", "hidden", "filter", "getOrElse", "FormInputAnnotation", "getFromAst", "length", "Option", "SchemaAST", "Annotation", "SchemaEx", "unwrapOptional", "prop", "isOptional", "isUnion", "type", "defined", "types", "filter", "_tag", "length", "Union", "make", "annotations", "getRootFormProperties", "ast", "values", "isDiscriminatedUnion", "getFormProperties", "activeType", "getDiscriminatedType", "activeProps", "discriminators", "Set", "getDiscriminatingProps", "map", "name", "toString", "size", "fullType", "fullDiscriminatorProps", "has", "find", "candidate", "signatures", "getPropertySignatures", "rawByName", "Map", "hidden", "FormInputAnnotation", "getFromAst", "pipe", "getOrElse", "getProperties", "raw", "get", "isNestedType", "isArrayType", "Ref", "ReferenceAnnotationId", "SchemaEx", "getRefProps", "ast", "isArrayType", "elementType", "getArrayElementType", "isRefType", "typename", "findAnnotation", "isArray", "undefined", "Schema", "Ref", "Tag", "META_TAGS_KEY", "withMetaTags", "schema", "omitId", "Struct", "Array", "Ref", "Tag", "pipe", "annotations", "title", "optional", "extend", "React", "useRef", "Column", "IconButton", "Input", "ScrollArea", "composable", "composableProps", "useMergeRefs", "useTranslation", "withColumn", "MarkdownView", "mx", "translationKey", "Cause", "Effect", "Exit", "useEffect", "useRef", "useState", "pickValues", "values", "deps", "subset", "dep", "useAsyncFieldEffect", "factory", "key", "debounceMs", "enabled", "factoryRef", "current", "state", "setState", "loading", "error", "undefined", "data", "cancel", "timer", "setTimeout", "prev", "runCallback", "onExit", "exit", "match", "onSuccess", "onFailure", "cause", "isInterruptedOnly", "squash", "clearTimeout", "createContext", "SchemaAST", "useEffect", "useMemo", "useRef", "SchemaEx", "FormContextProvider", "useFormContext", "useFormValues", "componentName", "path", "defaultValue", "stablePath", "join", "undefined", "jsonPath", "createJsonPath", "form", "values", "onValueChange", "value", "getValue", "lastAppliedPathRef", "current", "stringKeyword", "useFormFieldState", "Array", "isArray", "getStatus", "onBlur", "ast", "useControllableState", "useCallback", "useEffect", "useMemo", "useState", "SchemaEx", "log", "useDefaultValue", "validateSchema", "touched", "errors", "setErrors", "saving", "setSaving", "defaultValues", "defaultValuesProp", "values$", "setValues", "prop", "valuesProp", "defaultProp", "onChange", "setChanged", "setTouched", "validate", "values", "validatedValues", "onValidate", "flatMap", "valid", "schema", "setSchemaChanged", "schemaChanged", "onSave", "isValid", "changed", "onCancel", "error", "entries", "isTouched", "jsonPath", "undefined", "path", "value", "pathArray", "parsedValue", "newChanged", "prev", "onValuesChanged", "newValues", "Object", "length", "autoSave", "canSave", "getStatus", "onBlur", "onValueChange", "getValue", "handleSave", "handleCancel", "head", "Array", "isArray", "obj", "copy", "fromEffectValidationPath", "result", "message", "useCallback", "useLayoutEffect", "addEventListener", "useKeyHandler", "elRef", "form", "handleKeyDown", "event", "key", "metaKey", "canSave", "onSave", "isValid", "autoSave", "el", "current", "mx", "tv", "formStyles", "slots", "viewport", "content", "section", "group", "sectionHeader", "sectionTitle", "sectionDescription", "fieldSet", "field", "fieldLabel", "fieldLabelText", "fieldDescription", "fieldControl", "fieldValidation", "actions", "submit", "fieldSetBody", "fieldSetBox", "fieldSetBoxOuter", "variants", "variant", "default", "settings", "defaultVariants", "formTheme", "styles", "behavior", "showDescription", "formSlots", "Object", "keys", "Option", "React", "useMemo", "DEFAULT_LAYOUT_NAME", "FormLayoutAnnotation", "SchemaEx", "Option", "SchemaAST", "React", "useCallback", "useRef", "Annotation", "Ref", "useType", "defaultUseType", "SchemaEx", "DXN", "log", "useTranslation", "OrderedList", "mx", "arrayMove", "translationKey", "Match", "Option", "Schema", "SchemaAST", "String", "React", "useMemo", "Annotation", "Format", "SchemaEx", "IconButton", "useTranslation", "translationKey", "FormField", "props", "type", "name", "label", "labelProp", "path", "required", "projection", "fieldMap", "fieldProvider", "readonly", "layout", "createTypename", "createOptionLabel", "createOptionIcon", "createInitialValuePath", "createFieldMap", "db", "useType", "getOptions", "onCreate", "resolveCreateEntry", "refInline", "t", "useTranslation", "translationKey", "title", "SchemaEx", "getAnnotation", "TitleAnnotationId", "description", "DescriptionAnnotationId", "examples", "ExamplesAnnotationId", "useMemo", "capitalize", "placeholder", "length", "providerSchema", "make", "undefined", "fieldState", "useFormFieldState", "displayName", "jsonPath", "createJsonPath", "fieldProps", "format", "Format", "FormatAnnotation", "getFromAst", "pipe", "annotation", "getOrUndefined", "presentation", "getValue", "CustomField", "component", "schema", "prop", "optionsLookup", "OptionsLookupAnnotation", "combobox", "ComboboxField", "lookup", "AsyncSelectField", "autofill", "AutofillAnnotation", "AutofillField", "isArrayType", "ArrayField", "Field", "getFormField", "options", "getSelectOptions", "fieldProjections", "getFieldProjections", "fieldProjection", "find", "fp", "field", "selectOptions", "SelectField", "map", "option", "selectOption", "so", "id", "globalThis", "String", "value", "toString", "refProps", "getRefProps", "inline", "Annotation", "FormInlineAnnotation", "ast", "getOrElse", "isArray", "InlineRefField", "isCreateTarget", "typename", "RefField", "isNestedType", "baseNode", "findNode", "isDiscriminatedUnion", "typeLiteral", "getDiscriminatedType", "isTypeLiteral", "FormFieldSet", "collapsible", "CompactIconButton", "IconButton", "variant", "iconOnly", "isRefinement", "from", "formatField", "withReturnType", "when", "TypeFormat", "Date", "DateField", "DateTime", "GeoPoint", "GeoPointField", "Markdown", "MarkdownField", "Password", "PasswordField", "Text", "TextAreaField", "Time", "orElse", "_tag", "TextField", "NumberField", "BooleanField", "isLiteralUnion", "types", "literal", "filter", "v", "OptionsAnnotation", "React", "format", "formatDate", "React", "Component", "Format", "Icon", "Input", "Tooltip", "mx", "presentationFor", "layout", "isStatic", "showLabel", "showError", "FormFieldLabel", "classNames", "labelClassName", "variant", "label", "error", "readonly", "required", "standalone", "button", "onClick", "styles", "formTheme", "labelClassNames", "mx", "fieldLabelText", "class", "labelNode", "React", "span", "className", "Input", "Label", "div", "fieldLabel", "Tooltip", "Trigger", "asChild", "content", "side", "Icon", "icon", "size", "displayName", "formatStaticValue", "value", "format", "Format", "TypeFormat", "DateTime", "Date", "Time", "date", "Number", "isNaN", "getTime", "String", "pattern", "formatDate", "FORM_ROW_NAME", "FormRow", "children", "presentation", "description", "jsonPath", "renderStatic", "validation", "getStatus", "getValue", "rootRef", "useFormContext", "showDescription", "behavior", "resolved", "presentationFor", "status", "isStatic", "control", "p", "Root", "validationValence", "field", "ref", "showLabel", "path", "Description", "fieldDescription", "fieldControl", "showError", "fieldValidation", "DescriptionAndValidation", "Validation", "FormFieldErrorBoundary", "Component", "getDerivedStateFromError", "state", "undefined", "componentDidUpdate", "prevProps", "props", "resetError", "render", "join", "setState", "FormFieldHeader", "label", "path", "required", "readonly", "classNames", "add", "actions", "onClick", "React", "FormFieldLabel", "standalone", "button", "CompactIconButton", "disabled", "icon", "event", "stopPropagation", "undefined", "__dxlog_file", "getOrderedId", "ArrayField", "type", "fieldProps", "inputProps", "useTranslation", "translationKey", "elementType", "SchemaEx", "getArrayElementType", "onValueChange", "values", "useFormValues", "displayName", "path", "ordered", "FormOrderedAnnotation", "getFromAst", "Annotation", "createSchema", "useType", "createTypename", "DXN", "createInline", "isRefType", "readonly", "Ref", "nextId", "useCallback", "useRef", "handleAddCreate", "schema", "created", "idsRef", "getCreateDefaults", "baseNode", "typeLiteral", "Object", "prop", "defaultValue", "handleAdd", "log", "filter", "_", "arrayMove", "fromIndex", "next", "renderItemAsObject", "autoFocus", "isLast", "name", "label", "index", "layout", "refInline", "undefined", "className", "React", "field", "header", "createJsonPath", "add", "onClick", "ids", "current", "length", "count", "items", "value", "isOrderedItem", "getId", "onMove", "handleMove", "key", "id", "item", "classNames", "icon", "renderField", "mx", "minimum", "getDefaultValue", "React", "useEffect", "useMemo", "useRef", "React", "useCallback", "invariant", "Icon", "Select", "getStyles", "__dxlog_file", "SelectField", "type", "onValueChange", "value", "options", "optionValue", "Select", "handleValueChange", "classNames", "readonly", "placeholder", "length", "String", "className", "icon", "Icon", "getIconHueStyles", "iconHue", "label", "secondaryLabel", "Arrow", "fg", "styles", "option", "hasDefault", "renderStatic", "p", "normalized", "Root", "sentinel", "defaultLabel", "React", "key", "AsyncSelectField", "lookup", "fieldProps", "values", "useFormValues", "displayName", "subset", "useMemo", "pickValues", "deps", "key", "JSON", "stringify", "loading", "data", "useAsyncFieldEffect", "load", "options", "type", "placeholder", "current", "getValue", "onValueChangeRef", "useRef", "onValueChange", "autoSelectedDataRef", "undefined", "useEffect", "length", "value", "resolvedPlaceholder", "React", "SelectField", "map", "label", "secondaryLabel", "icon", "React", "useEffect", "useMemo", "useRef", "React", "useCallback", "Input", "TextField", "type", "readonly", "placeholder", "onBlur", "onValueChange", "props", "handleChange", "useCallback", "event", "target", "value", "React", "FormRow", "Input", "TextInput", "noAutoFill", "disabled", "onChange", "AutofillField", "autofill", "fieldProps", "values", "useFormValues", "displayName", "subset", "useMemo", "pickValues", "deps", "key", "JSON", "stringify", "data", "useAsyncFieldEffect", "derive", "type", "getValueRef", "useRef", "getValue", "current", "onValueChangeRef", "onValueChange", "lastFilledRef", "undefined", "useEffect", "length", "React", "TextField", "React", "useCallback", "Input", "BooleanField", "type", "readonly", "onValueChange", "props", "handleChange", "useCallback", "value", "React", "FormRow", "Input", "Block", "Switch", "disabled", "checked", "onCheckedChange", "React", "useCallback", "useMemo", "useState", "Combobox", "ComboboxField", "lookup", "type", "readonly", "placeholder", "onValueChange", "props", "values", "useFormValues", "displayName", "ownKey", "jsonPath", "query", "setQuery", "useState", "lookupValues", "useMemo", "subset", "pickValues", "deps", "includes", "key", "JSON", "stringify", "data", "useAsyncFieldEffect", "load", "trimmed", "trim", "normalized", "toLowerCase", "results", "length", "filter", "option", "label", "value", "hasExact", "some", "handleValueChange", "useCallback", "next", "handleOpenChange", "open", "React", "FormRow", "renderStatic", "p", "className", "Combobox", "Root", "onOpenChange", "Trigger", "disabled", "classNames", "Portal", "Content", "resetSelectionOnChange", "Input", "autoFocus", "List", "map", "Item", "suffix", "secondaryLabel", "Arrow", "format", "formatDate", "React", "useCallback", "Format", "Input", "isoToLocalDateTime", "value", "date", "Date", "Number", "isNaN", "getTime", "formatDate", "localDateTimeToIso", "undefined", "toISOString", "DateField", "type", "format", "readonly", "placeholder", "_placeholder", "onValueChange", "onBlur", "_onBlur", "props", "handleSimpleChange", "useCallback", "next", "handleDateTimeChange", "iso", "React", "FormRow", "Format", "TypeFormat", "div", "className", "Input", "classNames", "disabled", "TriggerIcon", "Time", "DateTime", "React", "useCallback", "useEffect", "useMemo", "useState", "GeoLocation", "Input", "useTranslation", "safeParseFloat", "translationKey", "GeoPointField", "type", "readonly", "getValue", "onValueChange", "onBlur", "props", "t", "useTranslation", "translationKey", "geoPoint", "useMemo", "value", "GeoLocation", "fromGeoPoint", "longitudeText", "setLongitudeText", "useState", "longitude", "toString", "latitudeText", "setLatitudeText", "latitude", "useEffect", "location", "handleChange", "useCallback", "coordinateType", "setText", "event", "inputText", "target", "coord", "safeParseFloat", "undefined", "isNaN", "currentLocation", "newLocation", "newValue", "toGeoPoint", "React", "FormRow", "standalone", "renderStatic", "point", "LatLng", "presentation", "div", "className", "Input", "Root", "showLabel", "Label", "TextInput", "step", "min", "max", "disabled", "placeholder", "onChange", "latHem", "lngHem", "span", "Math", "abs", "toFixed", "useAtomValue", "React", "useCallback", "useMemo", "Ref", "Doc", "IconButton", "useTranslation", "Editor", "useBasicMarkdownExtensions", "Text", "createDataExtensions", "translationKey", "editorClassNames", "MarkdownField", "type", "readonly", "placeholder", "db", "getValue", "onValueChange", "props", "isRef", "Ref", "isRefType", "renderStatic", "value", "reference", "React", "RefStaticText", "p", "className", "renderEditor", "RefMarkdownEditor", "CreateTextButton", "disabled", "onCreate", "ref", "StringMarkdownEditor", "onChange", "next", "FormRow", "text", "useAtomValue", "useMemo", "atom", "content", "dataExtensions", "createDataExtensions", "id", "uri", "Doc", "createAccessor", "extensions", "useBasicMarkdownExtensions", "Editor", "Root", "View", "classNames", "handleChange", "useCallback", "undefined", "t", "useTranslation", "translationKey", "handleClick", "make", "add", "Text", "IconButton", "icon", "label", "onClick", "Option", "SchemaAST", "React", "useCallback", "useEffect", "useState", "Input", "safeParseFloat", "getNumericConstraints", "ast", "node", "min", "max", "integer", "isRefinement", "jsonSchema", "getOrUndefined", "getJSONSchemaAnnotation", "minimum", "undefined", "Math", "maximum", "type", "multipleOf", "from", "NumberField", "readonly", "placeholder", "getValue", "onValueChange", "onBlur", "props", "clamp", "useCallback", "n", "value", "round", "raw", "setRaw", "useState", "v", "String", "externalValue", "useEffect", "safeParseFloat", "handleChange", "event", "target", "parsed", "handleBlur", "committed", "React", "FormRow", "Input", "TextInput", "disabled", "step", "onChange", "React", "useCallback", "Input", "PasswordField", "type", "readonly", "placeholder", "onBlur", "onValueChange", "props", "handleChange", "useCallback", "event", "target", "value", "React", "FormRow", "Input", "TextInput", "noAutoFill", "disabled", "onChange", "React", "useCallback", "useMemo", "useState", "Entity", "Filter", "Obj", "Query", "Ref", "Scope", "Type", "useType", "defaultUseType", "useQuery", "ANY_OBJECT_TYPENAME", "ReferenceAnnotationId", "SchemaEx", "DXN", "EID", "URI", "DxAnchor", "Button", "Icon", "Input", "useTranslation", "ParentLabelAnnotationId", "translationKey", "React", "forwardRef", "useCallback", "useState", "Popover", "useTranslation", "Combobox", "useSearchListResults", "translationKey", "ObjectPickerContent", "forwardRef", "options", "selectedIds", "createSchema", "createOptionLabel", "createOptionIcon", "createInitialValuePath", "createFieldMap", "onSelect", "onCreate", "props", "forwardedRef", "t", "useTranslation", "translationKey", "showForm", "setShowForm", "useState", "formInitialValue", "setFormInitialValue", "results", "query", "handleSearch", "useSearchListResults", "items", "handleFormSave", "useCallback", "values", "handleFormCancel", "handleKeyDown", "event", "key", "currentTarget", "querySelector", "stopPropagation", "preventDefault", "input", "currentQuery", "value", "React", "Combobox", "Content", "onKeyDownCapture", "ref", "Popover", "Viewport", "Form", "Root", "testId", "schema", "defaultValues", "fieldMap", "onSave", "onCancel", "FieldSet", "Actions", "Arrow", "Input", "placeholder", "autoFocus", "onValueChange", "List", "map", "option", "Item", "id", "label", "description", "checked", "includes", "classNames", "CreateItem", "onCreateItemSelect", "ns", "text", "icon", "closeOnSelect", "displayName", "ObjectPicker", "Portal", "Trigger", "VirtualTrigger", "isRefSnapshot", "val", "findRefOption", "value", "options", "isRef", "Ref", "undefined", "valueUri", "uri", "directMatch", "find", "option", "id", "valueEid", "EID", "tryParse", "valueSpaceId", "getSpaceId", "valueLocal", "toLocal", "optionEid", "optionSpaceId", "equals", "defaultGetOptions", "results", "parentLabel", "getTypePlaceholder", "filter", "result", "Obj", "getParent", "map", "Entity", "getURI", "prefer", "parent", "labelEntity", "typename", "getTypename", "label", "getLabel", "defaultUseResults", "db", "useQuery", "Query", "select", "Filter", "nothing", "ANY_OBJECT_TYPENAME", "everything", "type", "DXN", "make", "from", "Scope", "space", "registry", "RefField", "props", "readonly", "jsonPath", "placeholder", "presentation", "required", "getStatus", "getValue", "createOptionLabel", "createOptionIcon", "createInitialValuePath", "createFieldMap", "useType", "defaultUseType", "useResults", "getOptions", "onCreate", "resolveCreateEntry", "onValueChange", "t", "useTranslation", "translationKey", "status", "error", "resolved", "presentationFor", "useMemo", "SchemaEx", "findAnnotation", "ReferenceAnnotationId", "useCallback", "placeholderTypename", "segment", "split", "Boolean", "pop", "humanized", "charAt", "toUpperCase", "slice", "ns", "defaultValue", "ParentLabelAnnotationId", "handleGetValue", "item", "selectedIds", "createSchema", "createEntry", "open", "setOpen", "useState", "handleCreate", "values", "createObject", "newObject", "handleUpdate", "ref", "fromURI", "URI", "handleSelect", "isStatic", "React", "Input", "Root", "validationValence", "showLabel", "FormFieldLabel", "path", "div", "p", "className", "DxAnchor", "key", "dxn", "rootclassname", "ObjectPicker", "onOpenChange", "Trigger", "asChild", "classNames", "TextInput", "readOnly", "Button", "span", "Icon", "size", "icon", "Portal", "Content", "inputSchema", "omitHiddenFormFields", "omitId", "Type", "getSchema", "onSelect", "showError", "DescriptionAndValidation", "useAtomValue", "React", "useCallback", "useMemo", "Obj", "Ref", "Type", "useType", "defaultUseType", "ReferenceAnnotationId", "SchemaEx", "DXN", "IconButton", "Input", "useTranslation", "translationKey", "InlineRefField", "props", "type", "readonly", "label", "jsonPath", "presentation", "required", "db", "getValue", "onValueChange", "onCreate", "useType", "defaultUseType", "t", "useTranslation", "translationKey", "resolved", "presentationFor", "reference", "typename", "useMemo", "SchemaEx", "findAnnotation", "ReferenceAnnotationId", "undefined", "createType", "DXN", "make", "handleCreate", "useCallback", "newObject", "Ref", "React", "Input", "Root", "showLabel", "FormFieldLabel", "path", "InlineForm", "IconButton", "classNames", "disabled", "icon", "onClick", "target", "useAtomValue", "atom", "typeUri", "Obj", "getTypeURI", "typeFromRegistry", "targetType", "getType", "formSchema", "omitId", "Type", "getSchema", "defaultValues", "handleChange", "values", "isValid", "changed", "changedPaths", "Object", "keys", "filter", "length", "update", "parts", "splitJsonPath", "setValue", "FormRoot", "schema", "onValuesChanged", "FormContent", "FormFieldSetController", "collapsible", "React", "useCallback", "useEffect", "useRef", "useState", "PublicKey", "IconButton", "Input", "Tag", "ToggleIconButton", "useTranslation", "OrderedList", "HuePicker", "hues", "osTranslations", "translationKey", "SelectOptionField", "type", "readonly", "label", "jsonPath", "getStatus", "getValue", "onValueChange", "t", "useTranslation", "translationKey", "status", "error", "selected", "setSelectedId", "useState", "isNewOption", "setIsNewOption", "inputRef", "useRef", "options", "useEffect", "undefined", "randomHue", "usedHues", "Set", "map", "option", "color", "unusedHues", "hues", "filter", "hue", "has", "length", "Math", "floor", "random", "lastThree", "slice", "availableHues", "handleAdd", "useCallback", "newId", "PublicKey", "truncate", "newOption", "id", "title", "handleDelete", "newOptions", "handleMove", "from", "to", "removed", "splice", "handleClick", "current", "handleTitleChange", "e", "o", "target", "value", "handleKeyDown", "ev", "key", "handleColorChange", "focus", "React", "Input", "Root", "validationValence", "FormFieldLabel", "path", "div", "OrderedList", "items", "isItem", "_item", "getId", "onMove", "Content", "classNames", "item", "Item", "canDrag", "className", "DragHandle", "onClick", "Tag", "ToggleIconButton", "iconOnly", "variant", "active", "icon", "ns", "osTranslations", "Label", "TextInput", "disabled", "placeholder", "ref", "onChange", "onKeyDown", "HuePicker", "IconButton", "React", "useCallback", "Input", "TextAreaField", "type", "readonly", "placeholder", "onValueChange", "onBlur", "props", "handleChange", "useCallback", "event", "target", "value", "React", "FormRow", "Input", "TextArea", "rows", "disabled", "onChange", "React", "Input", "mx", "safeParseFloat", "gridCols", "TupleField", "binding", "type", "readonly", "label", "jsonPath", "getStatus", "getValue", "onValueChange", "onBlur", "status", "error", "values", "React", "Input", "Root", "validationValence", "FormFieldLabel", "path", "div", "className", "mx", "length", "map", "prop", "TextInput", "key", "disabled", "value", "onChange", "event", "safeParseFloat", "target", "Option", "Schema", "SchemaAST", "String", "React", "Fragment", "useMemo", "Annotation", "SchemaEx", "Input", "LayoutParseError", "Error", "_tag", "message", "position", "undefined", "TAG_RE", "ATTR_RE", "parseAttrs", "raw", "attrs", "lastIndex", "match", "exec", "key", "doubleQuoted", "singleQuoted", "bare", "tokenize", "input", "tokens", "cursor", "between", "slice", "index", "trim", "length", "JSON", "stringify", "slash", "name", "attrsRaw", "selfSlash", "push", "type", "selfClosing", "trailing", "requireAttr", "tag", "value", "parseInteger", "attr", "test", "Number", "parseInt", "parseLayout", "template", "parseNode", "token", "spanRaw", "span", "kind", "cols", "children", "closing", "root", "FORM_LAYOUT_NAME", "FormLayout", "schema", "template", "name", "Annotation", "DEFAULT_LAYOUT_NAME", "path", "readonly", "layout", "projection", "props", "annotated", "getOrUndefined", "FormLayoutAnnotation", "get", "source", "undefined", "LayoutParseError", "Object", "keys", "join", "tree", "useMemo", "parseLayout", "React", "RenderNode", "node", "basePath", "displayName", "kind", "div", "className", "style", "gridTemplateColumns", "cols", "children", "map", "child", "index", "Fragment", "key", "resolved", "resolveLayoutField", "type", "segments", "leafName", "title", "labelType", "required", "span", "gridColumn", "FormFieldErrorBoundary", "LabelField", "make", "label", "capitalize", "FormField", "resolvePropertySignature", "ast", "length", "typeLiteral", "SchemaEx", "findNode", "isTypeLiteral", "prop", "getPropertySignatures", "find", "p", "globalThis", "String", "split", "baseType", "getBaseType", "annotations", "Reflect", "ownKeys", "getAnnotation", "TitleAnnotationId", "labelled", "isSome", "LabelAnnotation", "getFromAst", "isOptional", "variant", "useFormContext", "styles", "formTheme", "getValue", "useFormFieldState", "value", "text", "getLabelWithSchema", "trim", "presentation", "presentationFor", "Input", "Root", "field", "showLabel", "FormFieldLabel", "createJsonPath", "fieldControl", "React", "useState", "ToggleIconButton", "useTranslation", "mx", "translationKey", "styles", "formTheme", "FormFieldSetContainer", "classNames", "label", "path", "readonly", "presentation", "collapsible", "children", "t", "useTranslation", "translationKey", "collapsed", "setCollapsed", "useState", "showBody", "content", "React", "showLabel", "FormFieldHeader", "actions", "ToggleIconButton", "active", "variant", "density", "iconOnly", "icon", "undefined", "onClick", "value", "div", "className", "fieldSetBody", "fieldSetBoxOuter", "fieldSetBox", "class", "mx", "FORM_FIELDSET_NAME", "FormFieldSet", "classNames", "label", "schema", "readonly", "path", "sort", "collapsible", "filter", "projection", "layout", "layoutName", "DEFAULT_LAYOUT_NAME", "props", "values", "useFormValues", "properties", "useFormFieldSetProperties", "layouts", "getOrUndefined", "FormLayoutAnnotation", "get", "undefined", "body", "React", "FormLayout", "name", "map", "property", "toString", "FormFieldErrorBoundary", "key", "FormField", "type", "required", "isOptional", "FormFieldSetContainer", "SchemaEx", "createJsonPath", "presentation", "presentationFor", "displayName", "useMemo", "schemaProps", "getRootFormProperties", "ast", "filteredProps", "fieldProjections", "getFieldProjections", "hiddenProperties", "Set", "getHiddenProperties", "visibleProps", "prop", "has", "orderedProps", "fieldProjection", "fieldPath", "String", "field", "find", "push", "projectionPaths", "remainingProps", "a", "b", "indexOf", "FormRoot", "children", "schema", "values", "onSave", "onCancel", "props", "form", "useFormHandler", "React", "FormContextProvider", "displayName", "FORM_VIEWPORT_NAME", "FormViewport", "composable", "scroll", "gutter", "forwardedRef", "variant", "useFormContext", "styles", "formTheme", "span", "Column", "Root", "classNames", "ScrollArea", "composableProps", "viewport", "orientation", "centered", "padding", "thin", "ref", "Viewport", "FORM_CONTENT_NAME", "FormContent", "testId", "localRef", "useRef", "mergedRef", "useMergeRefs", "useKeyHandler", "div", "role", "mx", "withColumn", "center", "content", "data-testid", "FORM_FIELDSET_NAME", "FormFieldSetController", "contextProps", "FormFieldSet", "fieldSet", "class", "FORM_LAYOUT_NAME", "FormLayoutController", "resolvedSchema", "FormLayout", "FORM_ACTIONS_NAME", "FormActions", "t", "useTranslation", "translationKey", "canSave", "readonly", "layout", "className", "actions", "IconButton", "icon", "iconEnd", "label", "onClick", "type", "disabled", "FORM_SECTION_NAME", "FormSection", "title", "description", "section", "sectionHeader", "h2", "sectionTitle", "MarkdownView", "sectionDescription", "FORM_GROUP_NAME", "FormGroup", "group", "FORM_SUBMIT_NAME", "FormSubmit", "submit", "FORM_ERROR_NAME", "FormError", "Input", "validationValence", "Validation", "Form", "Root", "FormRoot", "Viewport", "FormViewport", "Content", "FormContent", "Section", "FormSection", "Group", "FormGroup", "FieldSet", "FormFieldSetController", "Layout", "FormLayoutController", "Label", "FormFieldLabel", "Row", "FormRow", "Actions", "FormActions", "Submit", "FormSubmit", "Error", "FormError", "__dxlog_file", "props", "useState", "projection", "getFieldProjection", "field", "useEffect", "setProps", "useAsyncEffect", "registry", "Filter", "Type", "schemas", "subscription", "useMemo", "options", "React", "value", "Format", "TypeFormat", "label", "getTypename", "schema", "typename", "referenceSchema", "getFormProperties", "getSchema", "t", "useCallback", "setFieldSchema", "prev", "fieldSchema", "setReferenceSchema", "newSchema", "additionalProps", "type", "_props", "handleValidate", "view", "onSave", "requestAnimationFrame", "log", "fieldMap", "autoFocus", "readonly", "values", "filter", "propIsNotType", "sort", "onValuesChanged", "onValidate", "handleSave", "onCancel", "handleCancel", "React", "useCallback", "useMemo", "Obj", "Ref", "Tag", "Type", "SchemaEx", "invariant", "HuePicker", "translationKey", "__dxlog_file", "ObjectForm", "meta", "getMeta", "object", "Obj", "tags", "values", "useMemo", "Type", "invariant", "isObject", "type", "newObject", "db", "add", "make", "instanceOf", "Tag", "Ref", "useCallback", "hasTagsChange", "changedPaths", "path", "SchemaEx", "splitJsonPath", "nonTagPaths", "parts", "value", "setValue", "createTypename", "createOptionIcon", "createOptionLabel", "translationKey", "createInitialValuePath", "createFieldMap", "onValuesChanged", "onCreate", "React", "handleChange", "onValueChange", "HuePicker", "onReset", "handleReset", "Function", "Option", "React", "useCallback", "useMemo", "Obj", "Tag", "Type", "useType", "SchemaEx", "invariant", "composable", "composableProps", "HuePicker", "FactoryAnnotation", "translationKey", "__dxlog_file", "meta", "object", "Obj", "tags", "values", "type", "getType", "typeFromRegistry", "formSchema", "useMemo", "Function", "Option", "invariant", "isObject", "factory", "getOrUndefined", "FactoryAnnotation", "get", "Type", "getSchema", "newObject", "db", "useCallback", "hasTagsChange", "changedPaths", "path", "SchemaEx", "splitJsonPath", "getMeta", "nonTagPaths", "parts", "value", "setValue", "defaultValues", "createTypename", "createOptionIcon", "createOptionLabel", "Tag", "translationKey", "createInitialValuePath", "createFieldMap", "onValuesChanged", "handleChange", "onCreate", "handleCreate", "getCreateDefaults", "resolveCreateEntry", "scroll", "ref", "forwardedRef", "React", "onValueChange", "HuePicker", "onReset", "handleReset", "SchemaAST", "React", "composable", "composableProps", "mx", "ObjectTreeImpl", "schema", "value", "props", "forwardedRef", "div", "role", "classNames", "ref", "Node", "ast", "label", "depth", "displayName", "ObjectTree", "unwrap", "isRefinement", "from", "isSuspend", "f", "isTransformation", "stripOptional", "isUnion", "nonUndef", "types", "filter", "t", "isUndefinedKeyword", "length", "inner", "isTypeLiteral", "isPlainObject", "childDepth", "Row", "kind", "propertySignatures", "map", "prop", "key", "String", "name", "type", "isTupleType", "Array", "isArray", "elemType", "rest", "item", "index", "unknownKeyword", "formatLeaf", "className", "style", "paddingInlineStart", "undefined", "span", "JSON", "stringify", "Prec", "React", "forwardRef", "useCallback", "useEffect", "useMemo", "useRef", "Filter", "Obj", "useQuery", "useThemeContext", "useTranslation", "Editor", "createBasicExtensions", "createThemeExtensions", "insertAtCursor", "keymap", "getHashHue", "translationKey", "RangeSetBuilder", "StateEffect", "StateField", "Decoration", "EditorView", "WidgetType", "Domino", "getHashHue", "getStyles", "mx", "REF_REGEX", "EMAIL_REGEX", "NAME_ADDR_REGEX", "formatMailbox", "name", "email", "refEditorRedecorate", "define", "refEditor", "mode", "getRef", "match", "buildRefDecorations", "state", "deco", "text", "doc", "toString", "tokenRegex", "tokenMatch", "exec", "token", "from", "index", "to", "length", "refMatch", "ref", "add", "widget", "RefWidget", "label", "hue", "atomic", "test", "TokenWidget", "finish", "buildEmailDecorations", "addrRegex", "segmentRegex", "segmentMatch", "segment", "commaIndex", "indexOf", "content", "slice", "trim", "leading", "trimStart", "nameAddr", "buildDecorations", "styles", "create", "update", "tr", "docChanged", "effects", "some", "effect", "is", "provide", "field", "decorations", "atomicRanges", "of", "view", "builder", "cursor", "iter", "value", "spec", "next", "lineHeight", "container", "classNames", "children", "inner", "append", "root", "_label", "_hue", "eq", "other", "toDOM", "bg", "fill", "border", "surface", "_token", "theme", "alignItems", "minHeight", "RefEditor", "forwardRef", "db", "type", "value", "readonly", "mode", "match", "getLabel", "getValues", "icon", "placeholder", "placeholderProp", "activateOnTyping", "numItems", "props", "forwardedRef", "t", "useTranslation", "translationKey", "themeMode", "useThemeContext", "getObjectLabel", "useCallback", "object", "Obj", "id", "filter", "useMemo", "Filter", "objects", "useQuery", "refs", "Map", "map", "label", "hue", "getHashHue", "refsRef", "useRef", "current", "controllerRef", "composedRef", "controller", "useEffect", "view", "dispatch", "effects", "refEditorRedecorate", "of", "getMenu", "text", "query", "replace", "toLowerCase", "matchesQuery", "includes", "some", "entry", "mailboxes", "flatMap", "items", "slice", "onSelect", "head", "insertMailbox", "formatMailbox", "detail", "insertAtCursor", "content", "focusOnly", "extensions", "createBasicExtensions", "readOnly", "lineWrapping", "createThemeExtensions", "slots", "scroller", "className", "refEditor", "getRef", "get", "Prec", "highest", "keymap", "key", "run", "state", "selection", "main", "line", "doc", "lineAt", "before", "from", "segment", "lastIndexOf", "trim", "NAME_ADDR_REGEX", "test", "EMAIL_REGEX", "token", "search", "React", "Editor", "Root", "trigger", "ref", "View", "classNames", "initialValue", "selectionEnd", "displayName", "mailbox", "lastComma", "insert", "changes", "to", "anchor", "length", "RegistryContext", "Match", "Option", "Schema", "React", "forwardRef", "useCallback", "useContext", "useImperativeHandle", "useMemo", "useState", "DXN", "EID", "Entity", "Feed", "Filter", "Format", "Obj", "Query", "QueryAST", "Ref", "Type", "View", "invariant", "useObject", "useQuery", "Input", "Message", "ToggleIconButton", "useTranslation", "QueryForm", "OrderedList", "ParentLabelAnnotation", "ProjectionModel", "VIEW_FIELD_LIMIT", "createEchoChangeCallback", "getTypeURIFromQuery", "mx", "translationKey", "__dxlog_file", "schemaReadonly", "Type", "getDatabase", "useTranslation", "translationKey", "projectionModel", "useMemo", "type", "jsonSchema", "registry", "atomRegistry", "view", "baseSchema", "change", "useImperativeHandle", "from", "undefined", "feedScope", "Match", "orElse", "useQuery", "Filter", "Feed", "targetRef", "queueTarget", "targetEid", "feedEid", "getQueueUri", "feed", "fromURI", "Entity", "mode", "QueryAST", "Query", "annotations", "title", "base", "fields", "target", "Ref", "ParentLabelAnnotation", "set", "Schema", "optional", "mutable", "typeUri", "getTypeURIFromQuery", "query", "DXN", "typeDxn", "getName", "tags", "types", "queueDxn", "targetValue", "find", "EID", "onQueryChanged", "feeds", "onDelete", "fieldId", "invariant", "React", "Form", "schema", "viewSchema", "viewValues", "fieldMap", "db", "onValuesChanged", "valence", "readonly", "showHeading", "customFields", "handleChange", "useCallback", "onValueChange", "label", "initialQuery", "onChange", "FieldList", "viewSnapshot", "useObject", "createFieldProjection", "setExpandedField", "field", "expandedField", "Obj", "moved", "splice", "projection", "hideFieldProjection", "showFieldProjection", "property", "FieldSchema", "OrderedList", "getId", "onMove", "handleMove", "expandedId", "onExpandedChange", "add", "disabled", "onClick", "handleAdd", "standalone", "classNames", "hidden", "visible", "DetailItem", "key", "id", "item", "canDrag", "expandable", "titleClassNames", "actions", "iconOnly", "ToggleIconButton", "active", "icon", "activeIcon", "data-testid", "getFields", "handleShow", "trailing", "CompactIconButton", "t", "onSave", "handleClose"]
7
7
  }