@dxos/react-ui-form 0.8.4-main.fd6878d → 0.8.4-staging.60fe92afc8

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 (318) hide show
  1. package/LICENSE +102 -5
  2. package/README.md +0 -1
  3. package/dist/lib/browser/index.mjs +4054 -2217
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/translations.mjs +87 -0
  7. package/dist/lib/browser/translations.mjs.map +7 -0
  8. package/dist/lib/node-esm/index.mjs +4054 -2217
  9. package/dist/lib/node-esm/index.mjs.map +4 -4
  10. package/dist/lib/node-esm/meta.json +1 -1
  11. package/dist/lib/node-esm/translations.mjs +89 -0
  12. package/dist/lib/node-esm/translations.mjs.map +7 -0
  13. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts +8 -8
  14. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
  15. package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts +89 -5
  16. package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts.map +1 -1
  17. package/dist/types/src/components/Form/Form.d.ts +135 -25
  18. package/dist/types/src/components/Form/Form.d.ts.map +1 -1
  19. package/dist/types/src/components/Form/Form.stories.d.ts +207 -56
  20. package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
  21. package/dist/types/src/components/Form/FormField.d.ts +52 -0
  22. package/dist/types/src/components/Form/FormField.d.ts.map +1 -0
  23. package/dist/types/src/components/Form/FormFieldComponent.d.ts +98 -0
  24. package/dist/types/src/components/Form/FormFieldComponent.d.ts.map +1 -0
  25. package/dist/types/src/components/Form/FormFieldComponent.stories.d.ts +9 -0
  26. package/dist/types/src/components/Form/FormFieldComponent.stories.d.ts.map +1 -0
  27. package/dist/types/src/components/Form/FormFieldSet.d.ts +26 -0
  28. package/dist/types/src/components/Form/FormFieldSet.d.ts.map +1 -0
  29. package/dist/types/src/components/Form/FormTooltipsContext.d.ts +19 -0
  30. package/dist/types/src/components/Form/FormTooltipsContext.d.ts.map +1 -0
  31. package/dist/types/src/components/Form/Layout/FormLayout.d.ts +50 -0
  32. package/dist/types/src/components/Form/Layout/FormLayout.d.ts.map +1 -0
  33. package/dist/types/src/components/Form/Layout/FormLayout.stories.d.ts +123 -0
  34. package/dist/types/src/components/Form/Layout/FormLayout.stories.d.ts.map +1 -0
  35. package/dist/types/src/components/Form/Layout/FormLayout.stories.test.d.ts +2 -0
  36. package/dist/types/src/components/Form/Layout/FormLayout.stories.test.d.ts.map +1 -0
  37. package/dist/types/src/components/Form/Layout/FormLayout.test.d.ts +2 -0
  38. package/dist/types/src/components/Form/Layout/FormLayout.test.d.ts.map +1 -0
  39. package/dist/types/src/components/Form/Layout/annotation.d.ts +30 -0
  40. package/dist/types/src/components/Form/Layout/annotation.d.ts.map +1 -0
  41. package/dist/types/src/components/Form/Layout/index.d.ts +4 -0
  42. package/dist/types/src/components/Form/Layout/index.d.ts.map +1 -0
  43. package/dist/types/src/components/Form/Layout/parser.d.ts +31 -0
  44. package/dist/types/src/components/Form/Layout/parser.d.ts.map +1 -0
  45. package/dist/types/src/components/Form/Layout/parser.test.d.ts +2 -0
  46. package/dist/types/src/components/Form/Layout/parser.test.d.ts.map +1 -0
  47. package/dist/types/src/components/Form/fields/ArrayField.d.ts +18 -0
  48. package/dist/types/src/components/Form/fields/ArrayField.d.ts.map +1 -0
  49. package/dist/types/src/components/Form/fields/BooleanField.d.ts +4 -0
  50. package/dist/types/src/components/Form/fields/BooleanField.d.ts.map +1 -0
  51. package/dist/types/src/components/Form/fields/DateField.d.ts +4 -0
  52. package/dist/types/src/components/Form/fields/DateField.d.ts.map +1 -0
  53. package/dist/types/src/components/Form/fields/GeoPointField.d.ts +5 -0
  54. package/dist/types/src/components/Form/fields/GeoPointField.d.ts.map +1 -0
  55. package/dist/types/src/components/Form/fields/InlineRefField.d.ts +13 -0
  56. package/dist/types/src/components/Form/fields/InlineRefField.d.ts.map +1 -0
  57. package/dist/types/src/components/Form/fields/MarkdownField.d.ts +11 -0
  58. package/dist/types/src/components/Form/fields/MarkdownField.d.ts.map +1 -0
  59. package/dist/types/src/components/Form/fields/MarkdownField.stories.d.ts +89 -0
  60. package/dist/types/src/components/Form/fields/MarkdownField.stories.d.ts.map +1 -0
  61. package/dist/types/src/components/Form/fields/NumberField.d.ts +4 -0
  62. package/dist/types/src/components/Form/fields/NumberField.d.ts.map +1 -0
  63. package/dist/types/src/components/Form/fields/RefField.d.ts +34 -0
  64. package/dist/types/src/components/Form/fields/RefField.d.ts.map +1 -0
  65. package/dist/types/src/components/Form/fields/RefField.test.d.ts +2 -0
  66. package/dist/types/src/components/Form/fields/RefField.test.d.ts.map +1 -0
  67. package/dist/types/src/components/Form/fields/SelectField.d.ts +13 -0
  68. package/dist/types/src/components/Form/fields/SelectField.d.ts.map +1 -0
  69. package/dist/types/src/components/Form/fields/SelectOptionField.d.ts +5 -0
  70. package/dist/types/src/components/Form/fields/SelectOptionField.d.ts.map +1 -0
  71. package/dist/types/src/components/Form/fields/SelectOptionField.stories.d.ts +89 -0
  72. package/dist/types/src/components/Form/fields/SelectOptionField.stories.d.ts.map +1 -0
  73. package/dist/types/src/components/Form/fields/TextAreaField.d.ts +4 -0
  74. package/dist/types/src/components/Form/fields/TextAreaField.d.ts.map +1 -0
  75. package/dist/types/src/components/Form/fields/TextField.d.ts +4 -0
  76. package/dist/types/src/components/Form/fields/TextField.d.ts.map +1 -0
  77. package/dist/types/src/components/Form/fields/TupleField.d.ts +6 -0
  78. package/dist/types/src/components/Form/fields/TupleField.d.ts.map +1 -0
  79. package/dist/types/src/components/Form/fields/index.d.ts +14 -0
  80. package/dist/types/src/components/Form/fields/index.d.ts.map +1 -0
  81. package/dist/types/src/components/Form/index.d.ts +5 -4
  82. package/dist/types/src/components/Form/index.d.ts.map +1 -1
  83. package/dist/types/src/components/Form/meta-tags.d.ts +30 -0
  84. package/dist/types/src/components/Form/meta-tags.d.ts.map +1 -0
  85. package/dist/types/src/components/Form/meta-tags.test.d.ts +2 -0
  86. package/dist/types/src/components/Form/meta-tags.test.d.ts.map +1 -0
  87. package/dist/types/src/components/ObjectForm/ObjectForm.d.ts +8 -0
  88. package/dist/types/src/components/ObjectForm/ObjectForm.d.ts.map +1 -0
  89. package/dist/types/src/components/ObjectForm/ObjectForm.stories.d.ts +87 -0
  90. package/dist/types/src/components/ObjectForm/ObjectForm.stories.d.ts.map +1 -0
  91. package/dist/types/src/components/ObjectForm/index.d.ts +2 -0
  92. package/dist/types/src/components/ObjectForm/index.d.ts.map +1 -0
  93. package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts +68 -0
  94. package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts.map +1 -0
  95. package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts +92 -0
  96. package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts.map +1 -0
  97. package/dist/types/src/components/ObjectPicker/index.d.ts +2 -0
  98. package/dist/types/src/components/ObjectPicker/index.d.ts.map +1 -0
  99. package/dist/types/src/components/ObjectProperties/ObjectProperties.d.ts +9 -0
  100. package/dist/types/src/components/ObjectProperties/ObjectProperties.d.ts.map +1 -0
  101. package/dist/types/src/components/ObjectProperties/ObjectProperties.stories.d.ts +132 -0
  102. package/dist/types/src/components/ObjectProperties/ObjectProperties.stories.d.ts.map +1 -0
  103. package/dist/types/src/components/ObjectProperties/ObjectProperties.test.d.ts +2 -0
  104. package/dist/types/src/components/ObjectProperties/ObjectProperties.test.d.ts.map +1 -0
  105. package/dist/types/src/components/ObjectProperties/index.d.ts +2 -0
  106. package/dist/types/src/components/ObjectProperties/index.d.ts.map +1 -0
  107. package/dist/types/src/components/ObjectTree/ObjectTree.d.ts +9 -0
  108. package/dist/types/src/components/ObjectTree/ObjectTree.d.ts.map +1 -0
  109. package/dist/types/src/components/ObjectTree/ObjectTree.stories.d.ts +91 -0
  110. package/dist/types/src/components/ObjectTree/ObjectTree.stories.d.ts.map +1 -0
  111. package/dist/types/src/components/ObjectTree/index.d.ts +2 -0
  112. package/dist/types/src/components/ObjectTree/index.d.ts.map +1 -0
  113. package/dist/types/src/components/RefEditor/RefEditor.d.ts +73 -0
  114. package/dist/types/src/components/RefEditor/RefEditor.d.ts.map +1 -0
  115. package/dist/types/src/components/RefEditor/RefEditor.stories.d.ts +92 -0
  116. package/dist/types/src/components/RefEditor/RefEditor.stories.d.ts.map +1 -0
  117. package/dist/types/src/components/RefEditor/index.d.ts +3 -0
  118. package/dist/types/src/components/RefEditor/index.d.ts.map +1 -0
  119. package/dist/types/src/components/RefEditor/ref-editor-extension.d.ts +47 -0
  120. package/dist/types/src/components/RefEditor/ref-editor-extension.d.ts.map +1 -0
  121. package/dist/types/src/components/Settings/Settings.d.ts +51 -0
  122. package/dist/types/src/components/Settings/Settings.d.ts.map +1 -0
  123. package/dist/types/src/components/Settings/Settings.stories.d.ts +89 -0
  124. package/dist/types/src/components/Settings/Settings.stories.d.ts.map +1 -0
  125. package/dist/types/src/components/Settings/SettingsFieldSet.d.ts +43 -0
  126. package/dist/types/src/components/Settings/SettingsFieldSet.d.ts.map +1 -0
  127. package/dist/types/src/components/Settings/SettingsItem.d.ts +16 -0
  128. package/dist/types/src/components/Settings/SettingsItem.d.ts.map +1 -0
  129. package/dist/types/src/components/Settings/SettingsSelectField.d.ts +18 -0
  130. package/dist/types/src/components/Settings/SettingsSelectField.d.ts.map +1 -0
  131. package/dist/types/src/components/Settings/index.d.ts +4 -0
  132. package/dist/types/src/components/Settings/index.d.ts.map +1 -0
  133. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +21 -11
  134. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
  135. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +91 -9
  136. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
  137. package/dist/types/src/components/index.d.ts +6 -2
  138. package/dist/types/src/components/index.d.ts.map +1 -1
  139. package/dist/types/src/components/testing.d.ts +14 -4
  140. package/dist/types/src/components/testing.d.ts.map +1 -1
  141. package/dist/types/src/hooks/index.d.ts +2 -3
  142. package/dist/types/src/hooks/index.d.ts.map +1 -1
  143. package/dist/types/src/hooks/useFormHandler.d.ts +82 -0
  144. package/dist/types/src/hooks/useFormHandler.d.ts.map +1 -0
  145. package/dist/types/src/hooks/useKeyHandler.d.ts +7 -0
  146. package/dist/types/src/hooks/useKeyHandler.d.ts.map +1 -0
  147. package/dist/types/src/index.d.ts +0 -2
  148. package/dist/types/src/index.d.ts.map +1 -1
  149. package/dist/types/src/translations.d.ts +70 -55
  150. package/dist/types/src/translations.d.ts.map +1 -1
  151. package/dist/types/src/util/field-type.d.ts +19 -0
  152. package/dist/types/src/util/field-type.d.ts.map +1 -0
  153. package/dist/types/src/util/field.d.ts +3 -3
  154. package/dist/types/src/util/field.d.ts.map +1 -1
  155. package/dist/types/src/util/formatting.d.ts +2 -2
  156. package/dist/types/src/util/formatting.d.ts.map +1 -1
  157. package/dist/types/src/util/index.d.ts +2 -1
  158. package/dist/types/src/util/index.d.ts.map +1 -1
  159. package/dist/types/src/util/properties.d.ts +35 -0
  160. package/dist/types/src/util/properties.d.ts.map +1 -0
  161. package/dist/types/src/util/properties.test.d.ts +2 -0
  162. package/dist/types/src/util/properties.test.d.ts.map +1 -0
  163. package/dist/types/src/util/refs.d.ts +3 -3
  164. package/dist/types/src/util/refs.d.ts.map +1 -1
  165. package/dist/types/tsconfig.tsbuildinfo +1 -1
  166. package/package.json +64 -47
  167. package/src/components/FieldEditor/FieldEditor.stories.tsx +49 -31
  168. package/src/components/FieldEditor/FieldEditor.test.tsx +4 -2
  169. package/src/components/FieldEditor/FieldEditor.tsx +100 -97
  170. package/src/components/Form/AUDIT.md +17 -0
  171. package/src/components/Form/Form.stories.tsx +151 -221
  172. package/src/components/Form/Form.tsx +461 -95
  173. package/src/components/Form/FormField.tsx +345 -0
  174. package/src/components/Form/FormFieldComponent.stories.tsx +65 -0
  175. package/src/components/Form/FormFieldComponent.tsx +253 -0
  176. package/src/components/Form/FormFieldSet.tsx +213 -0
  177. package/src/components/Form/FormTooltipsContext.ts +25 -0
  178. package/src/components/Form/Layout/FormLayout.stories.test.tsx +51 -0
  179. package/src/components/Form/Layout/FormLayout.stories.tsx +422 -0
  180. package/src/components/Form/Layout/FormLayout.test.ts +59 -0
  181. package/src/components/Form/Layout/FormLayout.tsx +251 -0
  182. package/src/components/Form/Layout/annotation.ts +38 -0
  183. package/src/components/Form/Layout/index.ts +7 -0
  184. package/src/components/Form/Layout/parser.test.ts +120 -0
  185. package/src/components/Form/Layout/parser.ts +167 -0
  186. package/src/components/Form/README.md +3 -0
  187. package/src/components/Form/fields/ArrayField.tsx +173 -0
  188. package/src/components/Form/fields/BooleanField.tsx +22 -0
  189. package/src/components/Form/fields/DateField.tsx +101 -0
  190. package/src/components/Form/fields/GeoPointField.tsx +124 -0
  191. package/src/components/Form/fields/InlineRefField.tsx +138 -0
  192. package/src/components/Form/fields/MarkdownField.stories.tsx +206 -0
  193. package/src/components/Form/fields/MarkdownField.tsx +167 -0
  194. package/src/components/Form/fields/NumberField.tsx +76 -0
  195. package/src/components/Form/fields/RefField.test.ts +45 -0
  196. package/src/components/Form/fields/RefField.tsx +266 -0
  197. package/src/components/Form/fields/SelectField.tsx +77 -0
  198. package/src/components/Form/fields/SelectOptionField.stories.tsx +66 -0
  199. package/src/components/Form/{custom/SelectOptionsInput.tsx → fields/SelectOptionField.tsx} +39 -32
  200. package/src/components/Form/fields/TextAreaField.tsx +38 -0
  201. package/src/components/Form/fields/TextField.tsx +38 -0
  202. package/src/components/Form/fields/TupleField.tsx +55 -0
  203. package/src/components/Form/fields/index.ts +17 -0
  204. package/src/components/Form/index.ts +6 -4
  205. package/src/components/Form/meta-tags.test.ts +47 -0
  206. package/src/components/Form/meta-tags.ts +33 -0
  207. package/src/components/ObjectForm/ObjectForm.stories.tsx +62 -0
  208. package/src/components/ObjectForm/ObjectForm.tsx +111 -0
  209. package/src/components/{ControlSection → ObjectForm}/index.ts +1 -1
  210. package/src/components/ObjectPicker/ObjectPicker.stories.tsx +212 -0
  211. package/src/components/ObjectPicker/ObjectPicker.tsx +202 -0
  212. package/src/components/ObjectPicker/index.ts +5 -0
  213. package/src/components/ObjectProperties/ObjectProperties.stories.tsx +350 -0
  214. package/src/components/ObjectProperties/ObjectProperties.test.tsx +111 -0
  215. package/src/components/ObjectProperties/ObjectProperties.tsx +146 -0
  216. package/src/components/ObjectProperties/index.ts +5 -0
  217. package/src/components/ObjectTree/ObjectTree.stories.tsx +134 -0
  218. package/src/components/ObjectTree/ObjectTree.tsx +190 -0
  219. package/src/components/ObjectTree/index.ts +5 -0
  220. package/src/components/RefEditor/RefEditor.stories.tsx +148 -0
  221. package/src/components/RefEditor/RefEditor.tsx +275 -0
  222. package/src/components/RefEditor/index.ts +6 -0
  223. package/src/components/RefEditor/ref-editor-extension.ts +254 -0
  224. package/src/components/Settings/AUDIT.md +51 -0
  225. package/src/components/Settings/Settings.stories.tsx +104 -0
  226. package/src/components/Settings/Settings.tsx +81 -0
  227. package/src/components/Settings/SettingsFieldSet.tsx +257 -0
  228. package/src/components/Settings/SettingsItem.tsx +58 -0
  229. package/src/components/Settings/SettingsSelectField.tsx +59 -0
  230. package/src/components/Settings/index.ts +7 -0
  231. package/src/components/ViewEditor/ViewEditor.stories.tsx +132 -64
  232. package/src/components/ViewEditor/ViewEditor.test.tsx +23 -22
  233. package/src/components/ViewEditor/ViewEditor.tsx +378 -216
  234. package/src/components/index.ts +6 -3
  235. package/src/components/testing.tsx +31 -12
  236. package/src/hooks/index.ts +2 -3
  237. package/src/hooks/useFormHandler.ts +380 -0
  238. package/src/hooks/useKeyHandler.tsx +37 -0
  239. package/src/index.ts +0 -4
  240. package/src/translations.ts +76 -59
  241. package/src/util/field-type.ts +60 -0
  242. package/src/util/field.ts +33 -43
  243. package/src/util/formatting.ts +22 -22
  244. package/src/util/index.ts +2 -1
  245. package/src/util/properties.test.ts +153 -0
  246. package/src/util/properties.ts +100 -0
  247. package/src/util/refs.ts +20 -19
  248. package/src/vite-env.d.ts +10 -0
  249. package/dist/types/src/components/ControlSection/ControlSection.d.ts +0 -23
  250. package/dist/types/src/components/ControlSection/ControlSection.d.ts.map +0 -1
  251. package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts +0 -8
  252. package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts.map +0 -1
  253. package/dist/types/src/components/ControlSection/index.d.ts +0 -2
  254. package/dist/types/src/components/ControlSection/index.d.ts.map +0 -1
  255. package/dist/types/src/components/Form/ArrayField.d.ts +0 -16
  256. package/dist/types/src/components/Form/ArrayField.d.ts.map +0 -1
  257. package/dist/types/src/components/Form/Defaults.d.ts +0 -14
  258. package/dist/types/src/components/Form/Defaults.d.ts.map +0 -1
  259. package/dist/types/src/components/Form/FormActions.d.ts +0 -9
  260. package/dist/types/src/components/Form/FormActions.d.ts.map +0 -1
  261. package/dist/types/src/components/Form/FormContent.d.ts +0 -57
  262. package/dist/types/src/components/Form/FormContent.d.ts.map +0 -1
  263. package/dist/types/src/components/Form/FormContext.d.ts +0 -23
  264. package/dist/types/src/components/Form/FormContext.d.ts.map +0 -1
  265. package/dist/types/src/components/Form/Input.d.ts +0 -26
  266. package/dist/types/src/components/Form/Input.d.ts.map +0 -1
  267. package/dist/types/src/components/Form/RefField.d.ts +0 -12
  268. package/dist/types/src/components/Form/RefField.d.ts.map +0 -1
  269. package/dist/types/src/components/Form/custom/GeoPointInput.d.ts +0 -4
  270. package/dist/types/src/components/Form/custom/GeoPointInput.d.ts.map +0 -1
  271. package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts +0 -4
  272. package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts.map +0 -1
  273. package/dist/types/src/components/Form/custom/SelectOptionsInput.stories.d.ts +0 -7
  274. package/dist/types/src/components/Form/custom/SelectOptionsInput.stories.d.ts.map +0 -1
  275. package/dist/types/src/components/Form/custom/TupleInput.d.ts +0 -6
  276. package/dist/types/src/components/Form/custom/TupleInput.d.ts.map +0 -1
  277. package/dist/types/src/components/Form/custom/index.d.ts +0 -4
  278. package/dist/types/src/components/Form/custom/index.d.ts.map +0 -1
  279. package/dist/types/src/components/Form/factory.d.ts +0 -8
  280. package/dist/types/src/components/Form/factory.d.ts.map +0 -1
  281. package/dist/types/src/components/deprecated/Form.d.ts +0 -15
  282. package/dist/types/src/components/deprecated/Form.d.ts.map +0 -1
  283. package/dist/types/src/components/deprecated/Form.stories.d.ts +0 -13
  284. package/dist/types/src/components/deprecated/Form.stories.d.ts.map +0 -1
  285. package/dist/types/src/components/deprecated/FormInput.d.ts +0 -16
  286. package/dist/types/src/components/deprecated/FormInput.d.ts.map +0 -1
  287. package/dist/types/src/components/deprecated/index.d.ts +0 -2
  288. package/dist/types/src/components/deprecated/index.d.ts.map +0 -1
  289. package/dist/types/src/hooks/useForm.d.ts +0 -67
  290. package/dist/types/src/hooks/useForm.d.ts.map +0 -1
  291. package/dist/types/src/hooks/useQueryRefOptions.d.ts +0 -23
  292. package/dist/types/src/hooks/useQueryRefOptions.d.ts.map +0 -1
  293. package/dist/types/src/hooks/useRefQueryLookupHandler.d.ts +0 -8
  294. package/dist/types/src/hooks/useRefQueryLookupHandler.d.ts.map +0 -1
  295. package/dist/types/src/util/schema.d.ts +0 -3
  296. package/dist/types/src/util/schema.d.ts.map +0 -1
  297. package/src/components/ControlSection/ControlSection.stories.tsx +0 -42
  298. package/src/components/ControlSection/ControlSection.tsx +0 -139
  299. package/src/components/Form/ArrayField.tsx +0 -125
  300. package/src/components/Form/Defaults.tsx +0 -204
  301. package/src/components/Form/FormActions.tsx +0 -54
  302. package/src/components/Form/FormContent.tsx +0 -241
  303. package/src/components/Form/FormContext.tsx +0 -110
  304. package/src/components/Form/Input.tsx +0 -51
  305. package/src/components/Form/RefField.tsx +0 -214
  306. package/src/components/Form/custom/GeoPointInput.tsx +0 -72
  307. package/src/components/Form/custom/SelectOptionsInput.stories.tsx +0 -62
  308. package/src/components/Form/custom/TupleInput.tsx +0 -47
  309. package/src/components/Form/custom/index.ts +0 -7
  310. package/src/components/Form/factory.tsx +0 -31
  311. package/src/components/deprecated/Form.stories.tsx +0 -63
  312. package/src/components/deprecated/Form.tsx +0 -119
  313. package/src/components/deprecated/FormInput.tsx +0 -71
  314. package/src/components/deprecated/index.ts +0 -5
  315. package/src/hooks/useForm.ts +0 -293
  316. package/src/hooks/useQueryRefOptions.ts +0 -53
  317. package/src/hooks/useRefQueryLookupHandler.ts +0 -39
  318. package/src/util/schema.ts +0 -14
@@ -1,27 +1,137 @@
1
- import { type Schema } from 'effect';
2
- import React, { type ReactElement } from 'react';
3
- import { type BaseObject, type PropertyKey } from '@dxos/echo-schema';
4
- import { type ThemedClassName } from '@dxos/react-ui';
5
- import { type SchemaProperty } from '@dxos/schema';
6
- import { type FormOptions } from '../../hooks';
7
- import { type FormOuterSpacing } from './FormActions';
8
- import { type FormFieldsProps } from './FormContent';
9
- import { type InputComponent, type InputProps } from './Input';
10
- export type PropsFilter<T extends BaseObject> = (props: SchemaProperty<T>[]) => SchemaProperty<T>[];
11
- export type ComponentLookup = (args: {
12
- prop: string;
13
- schema: Schema.Schema<any>;
14
- inputProps: InputProps;
15
- }) => ReactElement | undefined;
16
- export type CustomInputMap = Partial<Record<string, InputComponent>>;
17
- export type FormProps<T extends BaseObject> = ThemedClassName<{
18
- values: Partial<T>;
19
- autoFocus?: boolean;
20
- filter?: PropsFilter<T>;
21
- sort?: PropertyKey<T>[];
22
- autoSave?: boolean;
23
- outerSpacing?: FormOuterSpacing;
1
+ import * as Schema from 'effect/Schema';
2
+ import React, { type PropsWithChildren } from 'react';
3
+ import { Type } from '@dxos/echo';
4
+ import { type AnyProperties } from '@dxos/echo/internal';
5
+ import { type ColumnRootProps, type IconButtonProps, type ThemedClassName } from '@dxos/react-ui';
6
+ import { type FormHandler, type FormHandlerProps, type FormUpdateMeta } from '../../hooks';
7
+ import { type FormFieldLabelProps, type FormFieldStateProps } from './FormFieldComponent';
8
+ import { type FormFieldSetProps as NaturalFormFieldSetProps } from './FormFieldSet';
9
+ import { type FormLayoutProps as NaturalFormLayoutProps } from './Layout/FormLayout';
10
+ export type ExcludeId<S extends Schema.Schema.AnyNoContext | Type.AnyEntity> = Omit<S extends Type.AnyEntity ? Type.InstanceType<S> : S extends Schema.Schema.AnyNoContext ? Schema.Schema.Type<S> : never, 'id'>;
11
+ export declare const omitId: <S extends Schema.Schema.AnyNoContext | Type.AnyEntity>(schemaOrType: S) => Schema.Schema<ExcludeId<S>, ExcludeId<S>>;
12
+ /**
13
+ * Drop fields annotated with `FormInputAnnotation.set(false)` from a schema so
14
+ * the form's validator doesn't trip on required-but-hidden fields. Used by
15
+ * the picker's inline create form, where a `FactoryAnnotation` typically
16
+ * supplies the hidden values (e.g. a backing-object Ref) outside the form.
17
+ */
18
+ export declare const omitHiddenFormFields: <S extends Schema.Schema.AnyNoContext>(schema: S) => S;
19
+ type FormContextValue<T extends AnyProperties = any> = {
20
+ /**
21
+ * Form handler.
22
+ */
23
+ form: FormHandler<T>;
24
+ /**
25
+ * Show field tooltips (currently: JSON path on each label). Defaults to
26
+ * `true`; pass `false` to suppress.
27
+ */
28
+ tooltips?: boolean;
29
+ /**
30
+ * Testing.
31
+ */
32
+ testId?: string;
33
+ } & Pick<NaturalFormFieldSetProps<T>, 'readonly' | 'layout' | 'fieldMap' | 'fieldProvider' | 'projection' | 'createTypename' | 'createFieldMap' | 'db'>;
34
+ declare const useFormContext: (consumerName: string) => FormContextValue<any>;
35
+ /**
36
+ * Get the current form values.
37
+ */
38
+ declare const useFormValues: {
39
+ <T extends AnyProperties>(componentName: string, path?: (string | number)[]): T;
40
+ <T extends AnyProperties>(componentName: string, path: (string | number)[] | undefined, defaultValue: () => T): T | undefined;
41
+ };
42
+ /**
43
+ * Get the state props for the given field.
44
+ */
45
+ declare const useFormFieldState: (componentName: string, path?: (string | number)[]) => FormFieldStateProps;
46
+ type FormRootProps<T extends AnyProperties = AnyProperties> = PropsWithChildren<{
47
+ /**
48
+ * Called when the form is submitted and passes validation.
49
+ */
50
+ onSave?: (values: T, meta: FormUpdateMeta<T>) => void;
51
+ /**
52
+ * Called when the form is canceled to abandon/undo any pending changes.
53
+ */
24
54
  onCancel?: () => void;
25
- }> & Pick<FormOptions<T>, 'schema' | 'onValuesChanged' | 'onValidate' | 'onSave'> & FormFieldsProps;
26
- export declare const Form: <T extends BaseObject>({ classNames, testId, values: initialValues, autoFocus, readonly, autoSave, outerSpacing, onCancel, schema, onValuesChanged, onValidate, onSave, ...props }: FormProps<T>) => React.JSX.Element;
55
+ } & Omit<FormContextValue<T>, 'form'> & Pick<FormHandlerProps<T>, 'schema' | 'autoSave' | 'values' | 'defaultValues' | 'onValidate' | 'onValuesChanged'> & Omit<NaturalFormFieldSetProps<T>, 'schema' | 'path'>>;
56
+ declare function FormRoot<T extends AnyProperties = AnyProperties>({ children, schema, values, onSave, onCancel, ...props }: FormRootProps<T>): React.JSX.Element;
57
+ declare namespace FormRoot {
58
+ var displayName: string;
59
+ }
60
+ type FormViewportProps = {
61
+ scroll?: boolean;
62
+ gutter?: ColumnRootProps['gutter'];
63
+ };
64
+ type FormContentProps = ThemedClassName<PropsWithChildren<{}>>;
65
+ type FormFieldSetProps = ThemedClassName<NaturalFormFieldSetProps<any>>;
66
+ declare function FormFieldSet(props: FormFieldSetProps): React.JSX.Element;
67
+ declare namespace FormFieldSet {
68
+ var displayName: string;
69
+ }
70
+ type FormLayoutProps = Omit<NaturalFormLayoutProps, 'schema'> & {
71
+ schema?: NaturalFormLayoutProps['schema'];
72
+ };
73
+ declare function FormLayout({ schema, ...props }: FormLayoutProps): React.JSX.Element | null;
74
+ declare namespace FormLayout {
75
+ var displayName: string;
76
+ }
77
+ type FormActionsProps = ThemedClassName<{}>;
78
+ declare function FormActions({ classNames }: FormActionsProps): React.JSX.Element | null;
79
+ declare namespace FormActions {
80
+ var displayName: string;
81
+ }
82
+ type FormSectionProps = ThemedClassName<{
83
+ label?: string;
84
+ description?: string;
85
+ }>;
86
+ type FormSubmitProps = ThemedClassName<Partial<Pick<IconButtonProps, 'icon' | 'label' | 'disabled'>>>;
87
+ declare function FormSubmit({ classNames, label, icon, disabled }: FormSubmitProps): React.JSX.Element | null;
88
+ declare namespace FormSubmit {
89
+ var displayName: string;
90
+ }
91
+ type FormErrorProps = ThemedClassName<PropsWithChildren>;
92
+ declare function FormError({ children, classNames }: FormErrorProps): React.JSX.Element | null;
93
+ declare namespace FormError {
94
+ var displayName: string;
95
+ }
96
+ export declare const Form: {
97
+ Root: {
98
+ <T extends AnyProperties = AnyProperties>({ children, schema, values, onSave, onCancel, ...props }: FormRootProps<T>): React.JSX.Element;
99
+ displayName: string;
100
+ };
101
+ Viewport: React.ForwardRefExoticComponent<Omit<FormViewportProps, "className"> & {
102
+ classNames?: import("@dxos/ui-types").ClassNameValue;
103
+ } & Pick<React.HTMLAttributes<Element>, "children" | "className" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>;
104
+ Content: React.ForwardRefExoticComponent<Omit<FormContentProps, "className"> & {
105
+ classNames?: import("@dxos/ui-types").ClassNameValue;
106
+ } & Pick<React.HTMLAttributes<Element>, "children" | "className" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>;
107
+ Section: React.ForwardRefExoticComponent<Omit<FormSectionProps, "className"> & {
108
+ classNames?: import("@dxos/ui-types").ClassNameValue;
109
+ } & Pick<React.HTMLAttributes<Element>, "children" | "className" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>;
110
+ FieldSet: {
111
+ (props: FormFieldSetProps): React.JSX.Element;
112
+ displayName: string;
113
+ };
114
+ Layout: {
115
+ ({ schema, ...props }: FormLayoutProps): React.JSX.Element | null;
116
+ displayName: string;
117
+ };
118
+ Label: {
119
+ ({ classNames, label, error, readonly, asChild, path, button, onClick, }: FormFieldLabelProps): React.JSX.Element;
120
+ displayName: string;
121
+ };
122
+ Actions: {
123
+ ({ classNames }: FormActionsProps): React.JSX.Element | null;
124
+ displayName: string;
125
+ };
126
+ Submit: {
127
+ ({ classNames, label, icon, disabled }: FormSubmitProps): React.JSX.Element | null;
128
+ displayName: string;
129
+ };
130
+ Error: {
131
+ ({ children, classNames }: FormErrorProps): React.JSX.Element | null;
132
+ displayName: string;
133
+ };
134
+ };
135
+ export { useFormContext, useFormValues, useFormFieldState };
136
+ export type { FormRootProps, FormViewportProps, FormContentProps, FormSectionProps, FormFieldSetProps, FormLayoutProps, FormFieldLabelProps, FormActionsProps, FormSubmitProps, };
27
137
  //# sourceMappingURL=Form.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../../../src/components/Form/Form.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,EAAE,KAAK,YAAY,EAA8B,MAAM,OAAO,CAAC;AAE7E,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAc,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAEjE,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAE/D,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,UAAU,IAAI,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,KAAK,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;AAEpG,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,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7QY,CAAC,SAAS,aAAa,4EAOtC,aAAa,CAAC,CAAC,CAAC;;;IAuQjB,QAAQ;;;IACR,OAAO;;;IACP,OAAO;;;IACP,QAAQ;gBAlLmB,iBAAiB;;;IAmL5C,MAAM;+BAnKkC,eAAe;;;IAoKvD,KAAK;;;;IACL,OAAO;yBAjJ4B,gBAAgB;;;IAkJnD,MAAM;gDAnEmD,eAAe;;;IAoExE,KAAK;mCA7BsC,cAAc;;;CA8B1D,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,iBAAiB,EAAE,CAAC;AAE5D,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,GAChB,CAAC"}
@@ -1,58 +1,209 @@
1
- import '@dxos-theme';
2
- import { type Meta, type StoryObj } from '@storybook/react-vite';
3
- import { Schema } from 'effect';
4
- import { ContactType } from '@dxos/client/testing';
5
- import { type BaseObject } from '@dxos/echo-schema';
6
- import { Testing } from '@dxos/schema/testing';
7
- import { type FormProps } from './Form';
8
- declare const TestSchema: Schema.mutable<Schema.Struct<{
9
- name: Schema.optional<Schema.SchemaClass<string, string, never>>;
10
- active: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
11
- rank: Schema.optional<Schema.SchemaClass<number, number, never>>;
12
- website: Schema.optional<Schema.refine<string, typeof Schema.String>>;
13
- address: Schema.optional<Schema.Struct<{
14
- street: Schema.optional<Schema.SchemaClass<string, string, never>>;
15
- city: Schema.optional<Schema.SchemaClass<string, string, never>>;
16
- zip: Schema.optional<Schema.refine<string, typeof Schema.String>>;
17
- location: Schema.optional<Schema.Tuple<[Schema.refine<number, Schema.transform<typeof Schema.Number, Schema.filter<Schema.SchemaClass<number, number, never>>>>, Schema.refine<number, Schema.transform<typeof Schema.Number, Schema.filter<Schema.SchemaClass<number, number, never>>>>, Schema.Element<typeof Schema.Number, "?">]>>;
18
- }>>;
19
- }>>;
20
- type TestType = Schema.Schema.Type<typeof TestSchema>;
21
- type StoryProps<T extends BaseObject> = {
22
- schema: Schema.Schema<T>;
23
- } & FormProps<T>;
24
- declare const meta: Meta<StoryProps<any>>;
1
+ import { type StoryObj } from '@storybook/react-vite';
2
+ import * as Schema from 'effect/Schema';
3
+ import React from 'react';
4
+ import { Obj, Type } from '@dxos/echo';
5
+ import { type AnyProperties } from '@dxos/echo/internal';
6
+ import { type ExcludeId, type FormRootProps } from './Form';
7
+ declare const Organization: Type.Obj<{
8
+ readonly name: string;
9
+ }, Schema.Struct.Fields>;
10
+ export type Organization = Type.InstanceType<typeof Organization>;
11
+ declare const Person: Type.Obj<{
12
+ readonly name: string;
13
+ readonly ignore?: string | undefined;
14
+ readonly active?: boolean | undefined;
15
+ readonly address?: {
16
+ readonly street: string;
17
+ readonly city: string;
18
+ readonly state: string;
19
+ readonly zip: number;
20
+ } | undefined;
21
+ readonly employer?: import("@dxos/echo/internal").Ref<{
22
+ readonly name: string;
23
+ } & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown> | undefined;
24
+ readonly tags?: readonly import("@dxos/echo/internal").Ref<{
25
+ readonly label: string;
26
+ readonly hue?: string | undefined;
27
+ } & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown>[] | undefined;
28
+ readonly status?: "active" | "inactive" | undefined;
29
+ readonly notes?: string | undefined;
30
+ readonly location?: readonly [number, number, (number | undefined)?] | undefined;
31
+ readonly birthday?: string | undefined;
32
+ readonly meetingAt?: string | undefined;
33
+ readonly reminderAt?: string | undefined;
34
+ readonly tasks?: readonly string[] | undefined;
35
+ readonly locations?: readonly (readonly [number, number, (number | undefined)?])[] | undefined;
36
+ readonly identities?: readonly {
37
+ readonly type: string;
38
+ readonly value: string;
39
+ }[] | undefined;
40
+ }, Schema.Struct.Fields>;
41
+ export type Person = Type.InstanceType<typeof Person>;
42
+ type DefaultStoryProps<T extends AnyProperties> = {
43
+ schema?: Schema.Schema<T>;
44
+ } & FormRootProps<T>;
45
+ declare const meta: {
46
+ title: string;
47
+ component: {
48
+ <T extends AnyProperties = AnyProperties>({ children, schema, values, onSave, onCancel, ...props }: FormRootProps<T>): React.JSX.Element;
49
+ displayName: string;
50
+ };
51
+ render: <T extends AnyProperties = AnyProperties>({ schema, values: valuesProp, ...props }: DefaultStoryProps<T>) => React.JSX.Element;
52
+ decorators: import("@storybook/react").Decorator[];
53
+ parameters: {
54
+ layout: string;
55
+ translations: [{
56
+ readonly 'en-US': {
57
+ readonly "@dxos/react-ui-form": {
58
+ readonly 'ref-editor.placeholder': "Type '@' to add a reference, or enter a value";
59
+ readonly 'ref-editor-auto.placeholder': 'Search by name, or enter a value';
60
+ readonly 'fields.label': 'Fields';
61
+ readonly 'hidden-fields.label': 'Hidden Fields';
62
+ readonly 'empty-readonly-ref-field.label': '(none)';
63
+ readonly 'field-property.label': 'Property';
64
+ readonly 'field-property.placeholder': 'Property name';
65
+ readonly 'field-format.label': 'Type';
66
+ readonly 'field-path.label': 'Field path';
67
+ readonly 'remove-item.button': 'Delete item';
68
+ readonly 'add-item.button': 'Add item';
69
+ readonly 'add-property-button.label': 'Add property';
70
+ readonly 'boolean-input-true.value': 'Yes';
71
+ readonly 'boolean-input-false.value': 'No';
72
+ readonly 'show-field.label': 'Show field';
73
+ readonly 'hide-field.label': 'Hide field';
74
+ readonly 'expand-fields.label': 'Expand';
75
+ readonly 'collapse-fields.label': 'Collapse';
76
+ readonly 'delete-field.label': 'Delete field';
77
+ readonly 'create-option.label': 'Create';
78
+ readonly 'add-tag.label': 'Add tag';
79
+ readonly 'ref-field-combobox-input.placeholder': 'Search\u2026';
80
+ readonly 'ref-field.placeholder': 'Select\u2026';
81
+ readonly 'ref-field.placeholder_one': 'Select\u2026';
82
+ readonly 'ref-field.placeholder_other': 'Select items\u2026';
83
+ readonly 'example.placeholder': 'Example';
84
+ readonly 'latitude.placeholder': 'Latitude (e.g., 40.7128)';
85
+ readonly 'longitude.placeholder': 'Longitude (e.g., -74.0060)';
86
+ readonly 'cancel-button.label': 'Cancel';
87
+ readonly 'save-button.label': 'Save';
88
+ readonly 'create-text.label': 'Create text';
89
+ readonly 'format.boolean.label': 'Boolean';
90
+ readonly 'format.currency.label': 'Currency';
91
+ readonly 'format.date.label': 'Date';
92
+ readonly 'format.date-time.label': 'DateTime';
93
+ readonly 'format.did.label': 'DID';
94
+ readonly 'format.duration.label': 'Duration';
95
+ readonly 'format.dxn.label': 'DXN';
96
+ readonly 'format.email.label': 'Email';
97
+ readonly 'format.formula.label': 'Formula';
98
+ readonly 'format.hostname.label': 'Hostname';
99
+ readonly 'format.integer.label': 'Integer';
100
+ readonly 'format.json.label': 'JSON';
101
+ readonly 'format.lnglat.label': 'Geopoint';
102
+ readonly 'format.markdown.label': 'Markdown';
103
+ readonly 'format.percent.label': 'Percent';
104
+ readonly 'format.ref.label': 'Reference';
105
+ readonly 'format.regex.label': 'RegExp';
106
+ readonly 'format.string.label': 'String';
107
+ readonly 'format.single-select.label': 'Select';
108
+ readonly 'format.multi-select.label': 'Multi-select';
109
+ readonly 'format.text.label': 'Long text';
110
+ readonly 'format.time.label': 'Time';
111
+ readonly 'format.timestamp.label': 'Timestamp';
112
+ readonly 'format.user.label': 'User';
113
+ readonly 'format.number.label': 'Number';
114
+ readonly 'format.uri.label': 'URI';
115
+ readonly 'format.url.label': 'URL';
116
+ readonly 'format.uuid.label': 'UUID';
117
+ readonly 'latitude.label': 'Latitude';
118
+ readonly 'longitude.label': 'Longitude';
119
+ readonly 'select-option.label': 'Label';
120
+ readonly 'select-option-label.placeholder': 'Option label';
121
+ readonly 'select-option-delete.button': 'Delete';
122
+ readonly 'select-option-add.button': 'Add option';
123
+ readonly 'system-schema.title': 'System type';
124
+ readonly 'system-schema.description': 'System type: cannot add or remove fields.';
125
+ readonly 'remove.button': 'Delete';
126
+ };
127
+ };
128
+ }];
129
+ };
130
+ };
25
131
  export default meta;
26
- type Story<T extends BaseObject> = StoryObj<StoryProps<T>>;
27
- export declare const Default: Story<TestType>;
28
- export declare const Organization: Story<Schema.Schema.Type<typeof Testing.OrganizationSchema>>;
29
- export declare const OrganizationAutoSave: Story<Schema.Schema.Type<typeof Testing.OrganizationSchema>>;
30
- declare const ShapeSchema: Schema.mutable<Schema.Struct<{
31
- shape: Schema.optional<Schema.Union<[Schema.Struct<{
32
- type: Schema.Literal<["circle"]>;
33
- radius: Schema.optional<Schema.SchemaClass<number, number, never>>;
34
- }>, Schema.Struct<{
35
- type: Schema.Literal<["square"]>;
36
- size: Schema.optional<Schema.refine<number, typeof Schema.Number>>;
37
- }>]>>;
38
- }>>;
39
- type ShapeType = Schema.Schema.Type<typeof ShapeSchema>;
40
- export declare const DiscriminatedShape: Story<ShapeType>;
41
- declare const ArraysSchema: Schema.mutable<Schema.Struct<{
42
- names: Schema.Array$<Schema.filter<typeof Schema.String>>;
43
- addresses: Schema.Array$<Schema.Struct<{
44
- street: Schema.optional<Schema.SchemaClass<string, string, never>>;
45
- city: Schema.optional<Schema.SchemaClass<string, string, never>>;
46
- zip: Schema.optional<Schema.refine<string, typeof Schema.String>>;
47
- location: Schema.optional<Schema.Tuple<[Schema.refine<number, Schema.transform<typeof Schema.Number, Schema.filter<Schema.SchemaClass<number, number, never>>>>, Schema.refine<number, Schema.transform<typeof Schema.Number, Schema.filter<Schema.SchemaClass<number, number, never>>>>, Schema.Element<typeof Schema.Number, "?">]>>;
48
- }>>;
49
- }>>;
50
- type ArraysType = Schema.Schema.Type<typeof ArraysSchema>;
51
- export declare const Arrays: StoryObj<FormProps<ArraysType>>;
52
- declare const ColorSchema: Schema.mutable<Schema.Struct<{
53
- color: Schema.Union<[Schema.Literal<["red"]>, Schema.Literal<["green"]>, Schema.Literal<["blue"]>]>;
54
- }>>;
55
- type ColorType = Schema.Schema.Type<typeof ColorSchema>;
56
- export declare const Enum: StoryObj<FormProps<ColorType>>;
57
- export declare const Refs: StoryObj<FormProps<ContactType>>;
132
+ type Story<T extends AnyProperties> = StoryObj<DefaultStoryProps<T>>;
133
+ declare const PersonSchema: Schema.Schema<{
134
+ readonly name: string;
135
+ readonly ignore?: string | undefined;
136
+ readonly active?: boolean | undefined;
137
+ readonly address?: {
138
+ readonly street: string;
139
+ readonly city: string;
140
+ readonly state: string;
141
+ readonly zip: number;
142
+ } | undefined;
143
+ readonly employer?: import("@dxos/echo/internal").Ref<{
144
+ readonly name: string;
145
+ } & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown> | undefined;
146
+ readonly tags?: readonly import("@dxos/echo/internal").Ref<{
147
+ readonly label: string;
148
+ readonly hue?: string | undefined;
149
+ } & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown>[] | undefined;
150
+ readonly status?: "active" | "inactive" | undefined;
151
+ readonly notes?: string | undefined;
152
+ readonly location?: readonly [number, number, (number | undefined)?] | undefined;
153
+ readonly birthday?: string | undefined;
154
+ readonly meetingAt?: string | undefined;
155
+ readonly reminderAt?: string | undefined;
156
+ readonly tasks?: readonly string[] | undefined;
157
+ readonly locations?: readonly (readonly [number, number, (number | undefined)?])[] | undefined;
158
+ readonly identities?: readonly {
159
+ readonly type: string;
160
+ readonly value: string;
161
+ }[] | undefined;
162
+ } & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object>, {
163
+ readonly name: string;
164
+ readonly ignore?: string | undefined;
165
+ readonly active?: boolean | undefined;
166
+ readonly address?: {
167
+ readonly street: string;
168
+ readonly city: string;
169
+ readonly state: string;
170
+ readonly zip: number;
171
+ } | undefined;
172
+ readonly employer?: import("@dxos/echo/internal").Ref<{
173
+ readonly name: string;
174
+ } & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown> | undefined;
175
+ readonly tags?: readonly import("@dxos/echo/internal").Ref<{
176
+ readonly label: string;
177
+ readonly hue?: string | undefined;
178
+ } & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown>[] | undefined;
179
+ readonly status?: "active" | "inactive" | undefined;
180
+ readonly notes?: string | undefined;
181
+ readonly location?: readonly [number, number, (number | undefined)?] | undefined;
182
+ readonly birthday?: string | undefined;
183
+ readonly meetingAt?: string | undefined;
184
+ readonly reminderAt?: string | undefined;
185
+ readonly tasks?: readonly string[] | undefined;
186
+ readonly locations?: readonly (readonly [number, number, (number | undefined)?])[] | undefined;
187
+ readonly identities?: readonly {
188
+ readonly type: string;
189
+ readonly value: string;
190
+ }[] | undefined;
191
+ } & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object>, never>;
192
+ /**
193
+ * Build a data-entry surface by handing an Effect schema to `Form.Root` — the form derives its fields,
194
+ * types, validation, and selects from the schema, so you don't hand-wire one control per property.
195
+ * Customize individual fields with `fieldMap` (keyed by JSON path), render discriminated unions
196
+ * conditionally via the discriminator, and label ref-picker options by their parent object with
197
+ * `ParentLabelAnnotation`.
198
+ *
199
+ * @idiom org.dxos.react-ui-form.schemaForm
200
+ * applies: Any data-entry section bound to an Effect schema — settings, object/article editors, create dialogs
201
+ * instead-of: Hand-wiring Input/Select/Switch controls per field in bespoke React
202
+ * uses: {@link Form.Root}, {@link Form.FieldSet}
203
+ * related: org.dxos.react-ui-menu.toolbarMenu
204
+ */
205
+ export declare const Default: Story<ExcludeId<typeof PersonSchema>>;
206
+ export declare const Readonly: Story<ExcludeId<typeof PersonSchema>>;
207
+ export declare const Static: Story<ExcludeId<typeof PersonSchema>>;
208
+ export declare const Empty: Story<ExcludeId<typeof PersonSchema>>;
58
209
  //# sourceMappingURL=Form.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Form.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Form/Form.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,Q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AAO,MAAM,CAAC,CAAC;AAEtD,KAAK,iBAAiB,CAAC,CAAC,SAAS,aAAa,IAAI;IAChD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;CAC3B,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;AAgDrB,QAAA,MAAM,IAAI;;;;;;aA9CY,CAAC,SAAS,aAAa,4DAI1C,iBAAiB,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiEiB,CAAC;eAE1B,IAAI;AAEnB,KAAK,KAAK,CAAC,CAAC,SAAS,aAAa,IAAI,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;AAErE,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+FAAyB,CAAC;AAW5C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,YAAY,CAAC,CAMzD,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,YAAY,CAAC,CAM1D,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,YAAY,CAAC,CAMxD,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,YAAY,CAAC,CAEvD,CAAC"}
@@ -0,0 +1,52 @@
1
+ import * as SchemaAST from 'effect/SchemaAST';
2
+ import React from 'react';
3
+ import { IconButtonProps } from '@dxos/react-ui';
4
+ import { type ProjectionModel } from '@dxos/schema';
5
+ import { type RefFieldProps } from './fields';
6
+ import { type FormFieldComponentProps, type FormFieldMap, type FormFieldProvider } from './FormFieldComponent';
7
+ export type FormFieldProps = {
8
+ /**
9
+ * AST of the property to render.
10
+ */
11
+ type: SchemaAST.AST;
12
+ /**
13
+ * Name of the property. Used to derive a default label
14
+ * (`title ?? capitalize(name)`) and as the projection lookup key. Pass
15
+ * `null` to suppress the header label entirely -- the form still renders
16
+ * the field/struct, but `FormFieldSet`'s top-level `<FormFieldLabel>` is
17
+ * skipped. Used by `ArrayField` for object-array items, where every item
18
+ * would otherwise repeat the array's parent name.
19
+ */
20
+ name: string | null;
21
+ /**
22
+ * Path to the current object from the root. Used with nested forms.
23
+ */
24
+ path?: (string | number)[];
25
+ /**
26
+ * Optional projection for projection-based field management.
27
+ */
28
+ projection?: ProjectionModel;
29
+ /**
30
+ * Map of custom renderers for specific properties.
31
+ * Prefer fieldProvider for plugin specific input surfaces.
32
+ */
33
+ fieldMap?: FormFieldMap;
34
+ /**
35
+ * Function to lookup custom renderers for specific properties.
36
+ */
37
+ fieldProvider?: FormFieldProvider;
38
+ /**
39
+ * Typename of the ref type that the create props apply to.
40
+ * When set, createOptionLabel/createOptionIcon/createInitialValuePath/createFieldMap/onCreate
41
+ * are only passed to ref fields whose typename matches.
42
+ */
43
+ createTypename?: string;
44
+ } & Pick<FormFieldComponentProps, 'autoFocus' | 'readonly' | 'layout'> & Pick<RefFieldProps, 'createOptionLabel' | 'createOptionIcon' | 'createInitialValuePath' | 'createFieldMap' | 'db' | 'useType' | 'getOptions' | 'onCreate'>;
45
+ export declare function FormField(props: FormFieldProps): React.JSX.Element | null;
46
+ export declare namespace FormField {
47
+ var displayName: string;
48
+ }
49
+ export declare const IconBlock: ({ inline, ...props }: IconButtonProps & {
50
+ inline?: boolean;
51
+ }) => React.JSX.Element;
52
+ //# sourceMappingURL=FormField.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormField.d.ts","sourceRoot":"","sources":["../../../../../src/components/Form/FormField.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAC;AAE9C,OAAO,KAAkB,MAAM,OAAO,CAAC;AAIvC,OAAO,EAAc,eAAe,EAAkB,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAMpD,OAAO,EASL,KAAK,aAAa,EAInB,MAAM,UAAU,CAAC;AAElB,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAC;AAG9B,MAAM,MAAM,cAAc,GAAG;IAC3B;;OAEG;IACH,IAAI,EAAE,SAAS,CAAC,GAAG,CAAC;IAEpB;;;;;;;OAOG;IACH,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAEpB;;OAEG;IACH,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAE3B;;OAEG;IACH,UAAU,CAAC,EAAE,eAAe,CAAC;IAE7B;;;OAGG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAC;IAExB;;OAEG;IACH,aAAa,CAAC,EAAE,iBAAiB,CAAC;IAElC;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,GAAG,IAAI,CAAC,uBAAuB,EAAE,WAAW,GAAG,UAAU,GAAG,QAAQ,CAAC,GACpE,IAAI,CACF,aAAa,EACX,mBAAmB,GACnB,kBAAkB,GAClB,wBAAwB,GACxB,gBAAgB,GAChB,IAAI,GACJ,SAAS,GACT,YAAY,GACZ,UAAU,CACb,CAAC;kCAEsB,KAAK,EAAE,cAAc;;;;AAiM/C,eAAO,MAAM,SAAS,yBAA0B,eAAe,GAAG;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,sBAMrF,CAAC"}
@@ -0,0 +1,98 @@
1
+ import type * as Schema from 'effect/Schema';
2
+ import type * as SchemaAST from 'effect/SchemaAST';
3
+ import React, { Component, type FC, type FocusEvent, type PropsWithChildren, type ReactElement, type ReactNode } from 'react';
4
+ import { type Database, Format } from '@dxos/echo';
5
+ import { ThemedClassName } from '@dxos/react-ui';
6
+ import { type FormFieldStatus } from '../../hooks';
7
+ /**
8
+ * Dynamic props passed to input components.
9
+ */
10
+ export type FormFieldStateProps<T = any> = {
11
+ getStatus: () => FormFieldStatus;
12
+ getValue: () => T | undefined;
13
+ onBlur: (event: FocusEvent<HTMLElement>) => void;
14
+ onValueChange: (type: SchemaAST.AST, value: T) => void;
15
+ };
16
+ /**
17
+ * Presentation mode.
18
+ * - full: Show label, control, and status.
19
+ * - compact: Show label and control.
20
+ * - inline: Control only.
21
+ * - static: Plain DOM; omit all undefined values.
22
+ */
23
+ export type Presentation = 'full' | 'compact' | 'inline' | 'static';
24
+ /**
25
+ * Props passed to input components.
26
+ */
27
+ export type FormFieldComponentProps<T = any> = {
28
+ /** Database the form is editing against; populated for fields whose value is an ECHO object/Ref. */
29
+ db?: Database.Database;
30
+ type: SchemaAST.AST;
31
+ format?: Format.TypeFormat;
32
+ readonly?: boolean;
33
+ label: string;
34
+ /**
35
+ * Dotted JSON path of this field within the form values (e.g.
36
+ * `runtime.client.storage.persistent`). Forwarded to `FormFieldLabel` so
37
+ * that it can render the path as a debug hint when the enclosing
38
+ * `Form.Root` has `debug` enabled.
39
+ */
40
+ jsonPath?: string;
41
+ placeholder?: string;
42
+ autoFocus?: boolean;
43
+ layout?: Presentation;
44
+ } & FormFieldStateProps<T>;
45
+ export type FormFieldComponent = FC<FormFieldComponentProps>;
46
+ export type FormFieldMap = Record<string, FormFieldComponent>;
47
+ export type FormFieldProvider = (props: {
48
+ prop: string;
49
+ schema: Schema.Schema<any>;
50
+ fieldProps: FormFieldComponentProps;
51
+ }) => ReactElement | null | undefined;
52
+ export type FormFieldLabelProps = ThemedClassName<{
53
+ asChild?: boolean;
54
+ error?: string;
55
+ /**
56
+ * JSON path of the field this label describes (e.g. `runtime.client.storage.persistent`).
57
+ * Surfaced as a hover tooltip on the label when the enclosing `Form.Root`
58
+ * has `tooltips` enabled (the default) -- useful for spotting which field
59
+ * maps to which path when authoring schemas or filing bugs against a form.
60
+ * Callers can supply the path unconditionally; the label suppresses the
61
+ * tooltip when `Form.Root tooltips={false}`.
62
+ */
63
+ path?: string;
64
+ /**
65
+ * Trailing button rendered at the end of the label row (third grid column).
66
+ * Used by nested-object field sets to surface a collapse toggle.
67
+ */
68
+ button?: ReactNode;
69
+ onClick?: () => void;
70
+ } & Pick<FormFieldComponentProps, 'label' | 'readonly'>>;
71
+ export declare function FormFieldLabel({ classNames, label, error, readonly, asChild, path, button, onClick }: FormFieldLabelProps): React.JSX.Element;
72
+ export declare namespace FormFieldLabel {
73
+ var displayName: string;
74
+ }
75
+ export type FormFieldWrapperProps<T = any> = Pick<FormFieldComponentProps, 'readonly' | 'label' | 'layout' | 'getStatus' | 'getValue' | 'jsonPath' | 'format'> & {
76
+ children?: (props: {
77
+ value: T;
78
+ }) => ReactNode;
79
+ };
80
+ export declare const FormFieldWrapper: <T>(props: FormFieldWrapperProps<T>) => React.JSX.Element | null;
81
+ type FormFieldErrorState = {
82
+ error: Error | undefined;
83
+ };
84
+ type FormFieldErrorBoundaryProps = PropsWithChildren<{
85
+ path?: (string | number)[];
86
+ }>;
87
+ export declare class FormFieldErrorBoundary extends Component<FormFieldErrorBoundaryProps, FormFieldErrorState> {
88
+ static getDerivedStateFromError(error: Error): {
89
+ error: Error;
90
+ };
91
+ state: {
92
+ error: undefined;
93
+ };
94
+ componentDidUpdate(prevProps: FormFieldErrorBoundaryProps): void;
95
+ render(): string | number | bigint | boolean | React.JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | Iterable<ReactNode> | ReactElement<unknown, string | React.JSXElementConstructor<any>> | React.ReactPortal | null | undefined> | null | undefined;
96
+ private resetError;
97
+ }
98
+ //# sourceMappingURL=FormFieldComponent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormFieldComponent.d.ts","sourceRoot":"","sources":["../../../../../src/components/Form/FormFieldComponent.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,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