@dxos/react-ui-form 0.8.4-main.ead640a → 0.8.4-main.effb148878

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 (268) hide show
  1. package/LICENSE +102 -5
  2. package/README.md +0 -1
  3. package/dist/lib/browser/index.mjs +3252 -2315
  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 +83 -0
  7. package/dist/lib/browser/translations.mjs.map +7 -0
  8. package/dist/lib/node-esm/index.mjs +3252 -2315
  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 +85 -0
  12. package/dist/lib/node-esm/translations.mjs.map +7 -0
  13. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts +8 -7
  14. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
  15. package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts +69 -60
  16. package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts.map +1 -1
  17. package/dist/types/src/components/Form/Form.d.ts +123 -26
  18. package/dist/types/src/components/Form/Form.d.ts.map +1 -1
  19. package/dist/types/src/components/Form/Form.stories.d.ts +175 -138
  20. package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
  21. package/dist/types/src/components/Form/FormField.d.ts +48 -0
  22. package/dist/types/src/components/Form/FormField.d.ts.map +1 -0
  23. package/dist/types/src/components/Form/FormFieldComponent.d.ts +95 -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 +21 -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 +25 -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 +116 -0
  34. package/dist/types/src/components/Form/Layout/FormLayout.stories.d.ts.map +1 -0
  35. package/dist/types/src/components/Form/Layout/annotation.d.ts +30 -0
  36. package/dist/types/src/components/Form/Layout/annotation.d.ts.map +1 -0
  37. package/dist/types/src/components/Form/Layout/index.d.ts +4 -0
  38. package/dist/types/src/components/Form/Layout/index.d.ts.map +1 -0
  39. package/dist/types/src/components/Form/Layout/parser.d.ts +31 -0
  40. package/dist/types/src/components/Form/Layout/parser.d.ts.map +1 -0
  41. package/dist/types/src/components/Form/Layout/parser.test.d.ts +2 -0
  42. package/dist/types/src/components/Form/Layout/parser.test.d.ts.map +1 -0
  43. package/dist/types/src/components/Form/fields/ArrayField.d.ts +18 -0
  44. package/dist/types/src/components/Form/fields/ArrayField.d.ts.map +1 -0
  45. package/dist/types/src/components/Form/fields/BooleanField.d.ts +4 -0
  46. package/dist/types/src/components/Form/fields/BooleanField.d.ts.map +1 -0
  47. package/dist/types/src/components/Form/fields/DateField.d.ts +4 -0
  48. package/dist/types/src/components/Form/fields/DateField.d.ts.map +1 -0
  49. package/dist/types/src/components/Form/fields/GeoPointField.d.ts +5 -0
  50. package/dist/types/src/components/Form/fields/GeoPointField.d.ts.map +1 -0
  51. package/dist/types/src/components/Form/fields/MarkdownField.d.ts +11 -0
  52. package/dist/types/src/components/Form/fields/MarkdownField.d.ts.map +1 -0
  53. package/dist/types/src/components/Form/fields/MarkdownField.stories.d.ts +85 -0
  54. package/dist/types/src/components/Form/fields/MarkdownField.stories.d.ts.map +1 -0
  55. package/dist/types/src/components/Form/fields/NumberField.d.ts +4 -0
  56. package/dist/types/src/components/Form/fields/NumberField.d.ts.map +1 -0
  57. package/dist/types/src/components/Form/fields/RefField.d.ts +22 -0
  58. package/dist/types/src/components/Form/fields/RefField.d.ts.map +1 -0
  59. package/dist/types/src/components/Form/fields/SelectField.d.ts +13 -0
  60. package/dist/types/src/components/Form/fields/SelectField.d.ts.map +1 -0
  61. package/dist/types/src/components/Form/fields/SelectOptionField.d.ts +5 -0
  62. package/dist/types/src/components/Form/fields/SelectOptionField.d.ts.map +1 -0
  63. package/dist/types/src/components/Form/fields/SelectOptionField.stories.d.ts +85 -0
  64. package/dist/types/src/components/Form/fields/SelectOptionField.stories.d.ts.map +1 -0
  65. package/dist/types/src/components/Form/fields/TextAreaField.d.ts +4 -0
  66. package/dist/types/src/components/Form/fields/TextAreaField.d.ts.map +1 -0
  67. package/dist/types/src/components/Form/fields/TextField.d.ts +4 -0
  68. package/dist/types/src/components/Form/fields/TextField.d.ts.map +1 -0
  69. package/dist/types/src/components/Form/fields/TupleField.d.ts +6 -0
  70. package/dist/types/src/components/Form/fields/TupleField.d.ts.map +1 -0
  71. package/dist/types/src/components/Form/fields/index.d.ts +13 -0
  72. package/dist/types/src/components/Form/fields/index.d.ts.map +1 -0
  73. package/dist/types/src/components/Form/index.d.ts +4 -4
  74. package/dist/types/src/components/Form/index.d.ts.map +1 -1
  75. package/dist/types/src/components/ObjectForm/ObjectForm.d.ts +8 -0
  76. package/dist/types/src/components/ObjectForm/ObjectForm.d.ts.map +1 -0
  77. package/dist/types/src/components/ObjectForm/index.d.ts +2 -0
  78. package/dist/types/src/components/ObjectForm/index.d.ts.map +1 -0
  79. package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts +37 -10
  80. package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts.map +1 -1
  81. package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts +65 -59
  82. package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts.map +1 -1
  83. package/dist/types/src/components/ObjectProperties/ObjectProperties.d.ts +9 -0
  84. package/dist/types/src/components/ObjectProperties/ObjectProperties.d.ts.map +1 -0
  85. package/dist/types/src/components/ObjectProperties/ObjectProperties.stories.d.ts +128 -0
  86. package/dist/types/src/components/ObjectProperties/ObjectProperties.stories.d.ts.map +1 -0
  87. package/dist/types/src/components/ObjectProperties/ObjectProperties.test.d.ts +2 -0
  88. package/dist/types/src/components/ObjectProperties/ObjectProperties.test.d.ts.map +1 -0
  89. package/dist/types/src/components/ObjectProperties/index.d.ts +2 -0
  90. package/dist/types/src/components/ObjectProperties/index.d.ts.map +1 -0
  91. package/dist/types/src/components/ObjectTree/ObjectTree.d.ts +9 -0
  92. package/dist/types/src/components/ObjectTree/ObjectTree.d.ts.map +1 -0
  93. package/dist/types/src/components/ObjectTree/ObjectTree.stories.d.ts +87 -0
  94. package/dist/types/src/components/ObjectTree/ObjectTree.stories.d.ts.map +1 -0
  95. package/dist/types/src/components/ObjectTree/index.d.ts +2 -0
  96. package/dist/types/src/components/ObjectTree/index.d.ts.map +1 -0
  97. package/dist/types/src/components/Settings/Settings.d.ts +51 -0
  98. package/dist/types/src/components/Settings/Settings.d.ts.map +1 -0
  99. package/dist/types/src/components/Settings/Settings.stories.d.ts +85 -0
  100. package/dist/types/src/components/Settings/Settings.stories.d.ts.map +1 -0
  101. package/dist/types/src/components/Settings/SettingsFieldSet.d.ts +43 -0
  102. package/dist/types/src/components/Settings/SettingsFieldSet.d.ts.map +1 -0
  103. package/dist/types/src/components/Settings/SettingsItem.d.ts +16 -0
  104. package/dist/types/src/components/Settings/SettingsItem.d.ts.map +1 -0
  105. package/dist/types/src/components/Settings/SettingsSelectField.d.ts +18 -0
  106. package/dist/types/src/components/Settings/SettingsSelectField.d.ts.map +1 -0
  107. package/dist/types/src/components/Settings/index.d.ts +4 -0
  108. package/dist/types/src/components/Settings/index.d.ts.map +1 -0
  109. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +16 -20
  110. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
  111. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +72 -66
  112. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
  113. package/dist/types/src/components/index.d.ts +4 -1
  114. package/dist/types/src/components/index.d.ts.map +1 -1
  115. package/dist/types/src/components/testing.d.ts +13 -6
  116. package/dist/types/src/components/testing.d.ts.map +1 -1
  117. package/dist/types/src/hooks/index.d.ts +2 -3
  118. package/dist/types/src/hooks/index.d.ts.map +1 -1
  119. package/dist/types/src/hooks/useFormHandler.d.ts +82 -0
  120. package/dist/types/src/hooks/useFormHandler.d.ts.map +1 -0
  121. package/dist/types/src/hooks/useKeyHandler.d.ts +7 -0
  122. package/dist/types/src/hooks/useKeyHandler.d.ts.map +1 -0
  123. package/dist/types/src/index.d.ts +0 -2
  124. package/dist/types/src/index.d.ts.map +1 -1
  125. package/dist/types/src/translations.d.ts +66 -60
  126. package/dist/types/src/translations.d.ts.map +1 -1
  127. package/dist/types/src/util/field-type.d.ts +19 -0
  128. package/dist/types/src/util/field-type.d.ts.map +1 -0
  129. package/dist/types/src/util/field.d.ts +3 -3
  130. package/dist/types/src/util/field.d.ts.map +1 -1
  131. package/dist/types/src/util/formatting.d.ts +2 -2
  132. package/dist/types/src/util/formatting.d.ts.map +1 -1
  133. package/dist/types/src/util/index.d.ts +2 -1
  134. package/dist/types/src/util/index.d.ts.map +1 -1
  135. package/dist/types/src/util/properties.d.ts +17 -0
  136. package/dist/types/src/util/properties.d.ts.map +1 -0
  137. package/dist/types/src/util/properties.test.d.ts +2 -0
  138. package/dist/types/src/util/properties.test.d.ts.map +1 -0
  139. package/dist/types/src/util/refs.d.ts +2 -2
  140. package/dist/types/src/util/refs.d.ts.map +1 -1
  141. package/dist/types/tsconfig.tsbuildinfo +1 -1
  142. package/package.json +61 -51
  143. package/src/components/FieldEditor/FieldEditor.stories.tsx +44 -25
  144. package/src/components/FieldEditor/FieldEditor.test.tsx +0 -1
  145. package/src/components/FieldEditor/FieldEditor.tsx +84 -84
  146. package/src/components/Form/AUDIT.md +17 -0
  147. package/src/components/Form/Form.stories.tsx +134 -252
  148. package/src/components/Form/Form.tsx +417 -107
  149. package/src/components/Form/FormField.tsx +332 -0
  150. package/src/components/Form/FormFieldComponent.stories.tsx +65 -0
  151. package/src/components/Form/FormFieldComponent.tsx +206 -0
  152. package/src/components/Form/FormFieldSet.tsx +173 -0
  153. package/src/components/Form/FormTooltipsContext.ts +25 -0
  154. package/src/components/Form/Layout/FormLayout.stories.tsx +339 -0
  155. package/src/components/Form/Layout/FormLayout.tsx +123 -0
  156. package/src/components/Form/Layout/annotation.ts +38 -0
  157. package/src/components/Form/Layout/index.ts +7 -0
  158. package/src/components/Form/Layout/parser.test.ts +120 -0
  159. package/src/components/Form/Layout/parser.ts +167 -0
  160. package/src/components/Form/README.md +3 -0
  161. package/src/components/Form/fields/ArrayField.tsx +185 -0
  162. package/src/components/Form/fields/BooleanField.tsx +22 -0
  163. package/src/components/Form/fields/DateField.tsx +95 -0
  164. package/src/components/Form/fields/GeoPointField.tsx +124 -0
  165. package/src/components/Form/fields/MarkdownField.stories.tsx +206 -0
  166. package/src/components/Form/fields/MarkdownField.tsx +168 -0
  167. package/src/components/Form/fields/NumberField.tsx +39 -0
  168. package/src/components/Form/fields/RefField.tsx +232 -0
  169. package/src/components/Form/fields/SelectField.tsx +77 -0
  170. package/src/components/Form/{custom/SelectOptionsInput.stories.tsx → fields/SelectOptionField.stories.tsx} +23 -18
  171. package/src/components/Form/{custom/SelectOptionsInput.tsx → fields/SelectOptionField.tsx} +31 -24
  172. package/src/components/Form/fields/TextAreaField.tsx +38 -0
  173. package/src/components/Form/fields/TextField.tsx +38 -0
  174. package/src/components/Form/{custom/TupleInput.tsx → fields/TupleField.tsx} +17 -9
  175. package/src/components/Form/fields/index.ts +16 -0
  176. package/src/components/Form/index.ts +5 -4
  177. package/src/components/ObjectForm/ObjectForm.tsx +115 -0
  178. package/src/components/{ControlSection → ObjectForm}/index.ts +1 -1
  179. package/src/components/ObjectPicker/ObjectPicker.stories.tsx +30 -25
  180. package/src/components/ObjectPicker/ObjectPicker.tsx +122 -81
  181. package/src/components/ObjectProperties/ObjectProperties.stories.tsx +350 -0
  182. package/src/components/ObjectProperties/ObjectProperties.test.tsx +108 -0
  183. package/src/components/ObjectProperties/ObjectProperties.tsx +147 -0
  184. package/src/components/ObjectProperties/index.ts +5 -0
  185. package/src/components/ObjectTree/ObjectTree.stories.tsx +134 -0
  186. package/src/components/ObjectTree/ObjectTree.tsx +190 -0
  187. package/src/components/ObjectTree/index.ts +5 -0
  188. package/src/components/Settings/AUDIT.md +51 -0
  189. package/src/components/Settings/Settings.stories.tsx +104 -0
  190. package/src/components/Settings/Settings.tsx +81 -0
  191. package/src/components/Settings/SettingsFieldSet.tsx +257 -0
  192. package/src/components/Settings/SettingsItem.tsx +58 -0
  193. package/src/components/Settings/SettingsSelectField.tsx +59 -0
  194. package/src/components/Settings/index.ts +7 -0
  195. package/src/components/ViewEditor/ViewEditor.stories.tsx +65 -73
  196. package/src/components/ViewEditor/ViewEditor.test.tsx +11 -11
  197. package/src/components/ViewEditor/ViewEditor.tsx +308 -214
  198. package/src/components/index.ts +4 -1
  199. package/src/components/testing.tsx +24 -11
  200. package/src/hooks/index.ts +2 -3
  201. package/src/hooks/useFormHandler.ts +380 -0
  202. package/src/hooks/useKeyHandler.tsx +37 -0
  203. package/src/index.ts +0 -4
  204. package/src/translations.ts +71 -65
  205. package/src/util/field-type.ts +60 -0
  206. package/src/util/field.ts +25 -25
  207. package/src/util/formatting.ts +22 -22
  208. package/src/util/index.ts +2 -1
  209. package/src/util/properties.test.ts +78 -0
  210. package/src/util/properties.ts +38 -0
  211. package/src/util/refs.ts +16 -18
  212. package/src/vite-env.d.ts +10 -0
  213. package/dist/types/src/components/ControlSection/ControlSection.d.ts +0 -23
  214. package/dist/types/src/components/ControlSection/ControlSection.d.ts.map +0 -1
  215. package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts +0 -84
  216. package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts.map +0 -1
  217. package/dist/types/src/components/ControlSection/index.d.ts +0 -2
  218. package/dist/types/src/components/ControlSection/index.d.ts.map +0 -1
  219. package/dist/types/src/components/Form/ArrayField.d.ts +0 -16
  220. package/dist/types/src/components/Form/ArrayField.d.ts.map +0 -1
  221. package/dist/types/src/components/Form/Defaults.d.ts +0 -14
  222. package/dist/types/src/components/Form/Defaults.d.ts.map +0 -1
  223. package/dist/types/src/components/Form/FormActions.d.ts +0 -9
  224. package/dist/types/src/components/Form/FormActions.d.ts.map +0 -1
  225. package/dist/types/src/components/Form/FormContent.d.ts +0 -63
  226. package/dist/types/src/components/Form/FormContent.d.ts.map +0 -1
  227. package/dist/types/src/components/Form/FormContext.d.ts +0 -23
  228. package/dist/types/src/components/Form/FormContext.d.ts.map +0 -1
  229. package/dist/types/src/components/Form/Input.d.ts +0 -29
  230. package/dist/types/src/components/Form/Input.d.ts.map +0 -1
  231. package/dist/types/src/components/Form/RefField.d.ts +0 -22
  232. package/dist/types/src/components/Form/RefField.d.ts.map +0 -1
  233. package/dist/types/src/components/Form/custom/GeoPointInput.d.ts +0 -4
  234. package/dist/types/src/components/Form/custom/GeoPointInput.d.ts.map +0 -1
  235. package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts +0 -4
  236. package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts.map +0 -1
  237. package/dist/types/src/components/Form/custom/SelectOptionsInput.stories.d.ts +0 -79
  238. package/dist/types/src/components/Form/custom/SelectOptionsInput.stories.d.ts.map +0 -1
  239. package/dist/types/src/components/Form/custom/TupleInput.d.ts +0 -6
  240. package/dist/types/src/components/Form/custom/TupleInput.d.ts.map +0 -1
  241. package/dist/types/src/components/Form/custom/index.d.ts +0 -4
  242. package/dist/types/src/components/Form/custom/index.d.ts.map +0 -1
  243. package/dist/types/src/components/Form/factory.d.ts +0 -8
  244. package/dist/types/src/components/Form/factory.d.ts.map +0 -1
  245. package/dist/types/src/hooks/useForm.d.ts +0 -67
  246. package/dist/types/src/hooks/useForm.d.ts.map +0 -1
  247. package/dist/types/src/hooks/useQueryRefOptions.d.ts +0 -29
  248. package/dist/types/src/hooks/useQueryRefOptions.d.ts.map +0 -1
  249. package/dist/types/src/hooks/useRefQueryLookupHandler.d.ts +0 -8
  250. package/dist/types/src/hooks/useRefQueryLookupHandler.d.ts.map +0 -1
  251. package/dist/types/src/util/schema.d.ts +0 -3
  252. package/dist/types/src/util/schema.d.ts.map +0 -1
  253. package/src/components/ControlSection/ControlSection.stories.tsx +0 -38
  254. package/src/components/ControlSection/ControlSection.tsx +0 -153
  255. package/src/components/Form/ArrayField.tsx +0 -125
  256. package/src/components/Form/Defaults.tsx +0 -205
  257. package/src/components/Form/FormActions.tsx +0 -54
  258. package/src/components/Form/FormContent.tsx +0 -322
  259. package/src/components/Form/FormContext.tsx +0 -110
  260. package/src/components/Form/Input.tsx +0 -54
  261. package/src/components/Form/RefField.tsx +0 -283
  262. package/src/components/Form/custom/GeoPointInput.tsx +0 -80
  263. package/src/components/Form/custom/index.ts +0 -7
  264. package/src/components/Form/factory.tsx +0 -31
  265. package/src/hooks/useForm.ts +0 -296
  266. package/src/hooks/useQueryRefOptions.ts +0 -62
  267. package/src/hooks/useRefQueryLookupHandler.ts +0 -39
  268. package/src/util/schema.ts +0 -12
@@ -1,28 +1,125 @@
1
- import type * as Schema from 'effect/Schema';
2
- import React, { type ReactElement } from 'react';
3
- import { type BaseObject, type PropertyKey } from '@dxos/echo/internal';
4
- import { type ThemedClassName } from '@dxos/react-ui';
5
- import { type ProjectionModel, 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
- projection?: ProjectionModel;
23
- autoSave?: boolean;
24
- 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 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
+ */
25
54
  onCancel?: () => void;
26
- }> & Pick<FormOptions<T>, 'schema' | 'onValuesChanged' | 'onValidate' | 'onSave'> & FormFieldsProps;
27
- export declare const Form: <T extends BaseObject>({ classNames, testId, values: initialValues, autoFocus, readonly, autoSave, outerSpacing, schema, onCancel, 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
+ type FormContentProps = ThemedClassName<PropsWithChildren<{}>>;
62
+ type FormFieldSetProps = ThemedClassName<NaturalFormFieldSetProps<any>>;
63
+ declare function FormFieldSet(props: FormFieldSetProps): React.JSX.Element;
64
+ declare namespace FormFieldSet {
65
+ var displayName: string;
66
+ }
67
+ type FormLayoutProps = Omit<NaturalFormLayoutProps, 'schema'> & {
68
+ schema?: NaturalFormLayoutProps['schema'];
69
+ };
70
+ declare function FormLayout({ schema, ...props }: FormLayoutProps): React.JSX.Element | null;
71
+ declare namespace FormLayout {
72
+ var displayName: string;
73
+ }
74
+ type FormActionsProps = ThemedClassName<{}>;
75
+ declare function FormActions({ classNames }: FormActionsProps): React.JSX.Element | null;
76
+ declare namespace FormActions {
77
+ var displayName: string;
78
+ }
79
+ type FormSectionProps = ThemedClassName<{
80
+ label?: string;
81
+ description?: string;
82
+ }>;
83
+ type FormSubmitProps = ThemedClassName<Partial<Pick<IconButtonProps, 'icon' | 'label' | 'disabled'>>>;
84
+ declare function FormSubmit({ classNames, label, icon, disabled }: FormSubmitProps): React.JSX.Element | null;
85
+ declare namespace FormSubmit {
86
+ var displayName: string;
87
+ }
88
+ export declare const Form: {
89
+ Root: {
90
+ <T extends AnyProperties = AnyProperties>({ children, schema, values, onSave, onCancel, ...props }: FormRootProps<T>): React.JSX.Element;
91
+ displayName: string;
92
+ };
93
+ Viewport: React.ForwardRefExoticComponent<Omit<{}, "className"> & {
94
+ classNames?: import("@dxos/ui-types").ClassNameValue;
95
+ } & Pick<React.HTMLAttributes<Element>, "children" | "className" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>;
96
+ Content: React.ForwardRefExoticComponent<Omit<FormContentProps, "className"> & {
97
+ classNames?: import("@dxos/ui-types").ClassNameValue;
98
+ } & Pick<React.HTMLAttributes<Element>, "children" | "className" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>;
99
+ Section: React.ForwardRefExoticComponent<Omit<FormSectionProps, "className"> & {
100
+ classNames?: import("@dxos/ui-types").ClassNameValue;
101
+ } & Pick<React.HTMLAttributes<Element>, "children" | "className" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>;
102
+ FieldSet: {
103
+ (props: FormFieldSetProps): React.JSX.Element;
104
+ displayName: string;
105
+ };
106
+ Layout: {
107
+ ({ schema, ...props }: FormLayoutProps): React.JSX.Element | null;
108
+ displayName: string;
109
+ };
110
+ Label: {
111
+ ({ label, error, readonly, asChild, path }: FormFieldLabelProps): React.JSX.Element;
112
+ displayName: string;
113
+ };
114
+ Actions: {
115
+ ({ classNames }: FormActionsProps): React.JSX.Element | null;
116
+ displayName: string;
117
+ };
118
+ Submit: {
119
+ ({ classNames, label, icon, disabled }: FormSubmitProps): React.JSX.Element | null;
120
+ displayName: string;
121
+ };
122
+ };
123
+ export { useFormContext, useFormValues, useFormFieldState };
124
+ export type { FormRootProps, FormViewportProps, FormContentProps, FormSectionProps, FormFieldSetProps, FormLayoutProps, FormFieldLabelProps, FormActionsProps, FormSubmitProps, };
28
125
  //# sourceMappingURL=Form.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../../../src/components/Form/Form.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,EAAE,KAAK,YAAY,EAAkC,MAAM,OAAO,CAAC;AAEjF,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAEzE,OAAO,EAAoB,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAEjE,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,CA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AI;IACf,IAAI;SApOY,CAAC,SAAS,aAAa,4EAOtC,aAAa,CAAC,CAAC,CAAC;;;IA8NjB,QAAQ;;;IACR,OAAO;;;IACP,OAAO;;;IACP,QAAQ;gBA3JmB,iBAAiB;;;IA4J5C,MAAM;+BA5IkC,eAAe;;;IA6IvD,KAAK;;;;IACL,OAAO;yBA1H4B,gBAAgB;;;IA2HnD,MAAM;gDA5CmD,eAAe;;;CA6CzE,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,155 +1,192 @@
1
1
  import { type StoryObj } from '@storybook/react-vite';
2
2
  import * as Schema from 'effect/Schema';
3
3
  import React from 'react';
4
- import { type Type } from '@dxos/echo';
5
- import { type BaseObject, Expando, Ref } from '@dxos/echo/internal';
6
- import { type FormProps } from './Form';
7
- type StoryProps<T extends BaseObject> = {
8
- debug?: boolean;
9
- schema: Type.Obj.Any;
10
- } & FormProps<T>;
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>;
11
45
  declare const meta: {
12
46
  title: string;
13
- component: any;
14
- render: <T extends BaseObject = any>({ debug, schema, values: initialValues, ...props }: StoryProps<T>) => React.JSX.Element;
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;
15
52
  decorators: import("@storybook/react").Decorator[];
16
53
  parameters: {
17
54
  layout: string;
18
55
  translations: [{
19
56
  readonly 'en-US': {
20
- readonly "react-ui-form": {
21
- readonly 'fields label': "Fields";
22
- readonly 'hidden fields label': "Hidden Fields";
23
- readonly 'empty readonly ref field label': "(none)";
24
- readonly 'button add property': "Add property";
25
- readonly 'field property label': "Property";
26
- readonly 'field property placeholder': "Property name";
27
- readonly 'field format label': "Type";
28
- readonly 'field path label': "Field path";
29
- readonly 'add field': "Add field";
30
- readonly 'delete field': "Delete field";
31
- readonly 'field limit reached': "Maximum number of fields reached";
32
- readonly 'boolean input true value': "Yes";
33
- readonly 'boolean input false value': "No";
34
- readonly 'show field label': "Show field";
35
- readonly 'hide field label': "Hide field";
36
- readonly 'delete field label': "Delete field";
37
- readonly 'ref field combobox input placeholder': "Search…";
38
- readonly 'ref field placeholder_one': "Select…";
39
- readonly 'ref field placeholder_other': "Select items…";
40
- readonly 'button cancel': "Cancel";
41
- readonly 'button save': "Save";
42
- readonly 'format boolean': "Boolean";
43
- readonly 'format currency': "Currency";
44
- readonly 'format date': "Date";
45
- readonly 'format date-time': "DateTime";
46
- readonly 'format did': "DID";
47
- readonly 'format duration': "Duration";
48
- readonly 'format dxn': "DXN";
49
- readonly 'format email': "Email";
50
- readonly 'format formula': "Formula";
51
- readonly 'format hostname': "Hostname";
52
- readonly 'format integer': "Integer";
53
- readonly 'format json': "JSON";
54
- readonly 'format lnglat': "Geopoint";
55
- readonly 'format markdown': "Markdown";
56
- readonly 'format percent': "Percent";
57
- readonly 'format ref': "Reference";
58
- readonly 'format regex': "RegExp";
59
- readonly 'format string': "String";
60
- readonly 'format single-select': "Select";
61
- readonly 'format multi-select': "Multi-select";
62
- readonly 'format text': "Long text";
63
- readonly 'format time': "Time";
64
- readonly 'format timestamp': "Timestamp";
65
- readonly 'format user': "User";
66
- readonly 'format number': "Number";
67
- readonly 'format uri': "URI";
68
- readonly 'format url': "URL";
69
- readonly 'format uuid': "UUID";
70
- readonly 'latitude label': "Latitude";
71
- readonly 'longitude label': "Longitude";
72
- readonly 'select option label': "Label";
73
- readonly 'select option label placeholder': "Option label";
74
- readonly 'select option color': "Color";
75
- readonly 'select option delete': "Delete";
76
- readonly 'select option add': "Add option";
77
- readonly 'system schema title': "System record type";
78
- readonly 'system schema description': "This is a system record type and cannot be modified, though the view can still be configured.";
57
+ readonly "@dxos/react-ui-form": {
58
+ readonly 'fields.label': 'Fields';
59
+ readonly 'hidden-fields.label': 'Hidden Fields';
60
+ readonly 'empty-readonly-ref-field.label': '(none)';
61
+ readonly 'field-property.label': 'Property';
62
+ readonly 'field-property.placeholder': 'Property name';
63
+ readonly 'field-format.label': 'Type';
64
+ readonly 'field-path.label': 'Field path';
65
+ readonly 'remove-item.button': 'Delete item';
66
+ readonly 'add-item.button': 'Add item';
67
+ readonly 'add-property-button.label': 'Add property';
68
+ readonly 'boolean-input-true.value': 'Yes';
69
+ readonly 'boolean-input-false.value': 'No';
70
+ readonly 'show-field.label': 'Show field';
71
+ readonly 'hide-field.label': 'Hide field';
72
+ readonly 'delete-field.label': 'Delete field';
73
+ readonly 'create-option.label': 'Create';
74
+ readonly 'add-tag.label': 'Add tag';
75
+ readonly 'ref-field-combobox-input.placeholder': 'Search\u2026';
76
+ readonly 'ref-field.placeholder': 'Select\u2026';
77
+ readonly 'ref-field.placeholder_one': 'Select\u2026';
78
+ readonly 'ref-field.placeholder_other': 'Select items\u2026';
79
+ readonly 'example.placeholder': 'Example';
80
+ readonly 'latitude.placeholder': 'Latitude (e.g., 40.7128)';
81
+ readonly 'longitude.placeholder': 'Longitude (e.g., -74.0060)';
82
+ readonly 'cancel-button.label': 'Cancel';
83
+ readonly 'save-button.label': 'Save';
84
+ readonly 'create-text.label': 'Create text';
85
+ readonly 'format.boolean.label': 'Boolean';
86
+ readonly 'format.currency.label': 'Currency';
87
+ readonly 'format.date.label': 'Date';
88
+ readonly 'format.date-time.label': 'DateTime';
89
+ readonly 'format.did.label': 'DID';
90
+ readonly 'format.duration.label': 'Duration';
91
+ readonly 'format.dxn.label': 'DXN';
92
+ readonly 'format.email.label': 'Email';
93
+ readonly 'format.formula.label': 'Formula';
94
+ readonly 'format.hostname.label': 'Hostname';
95
+ readonly 'format.integer.label': 'Integer';
96
+ readonly 'format.json.label': 'JSON';
97
+ readonly 'format.lnglat.label': 'Geopoint';
98
+ readonly 'format.markdown.label': 'Markdown';
99
+ readonly 'format.percent.label': 'Percent';
100
+ readonly 'format.ref.label': 'Reference';
101
+ readonly 'format.regex.label': 'RegExp';
102
+ readonly 'format.string.label': 'String';
103
+ readonly 'format.single-select.label': 'Select';
104
+ readonly 'format.multi-select.label': 'Multi-select';
105
+ readonly 'format.text.label': 'Long text';
106
+ readonly 'format.time.label': 'Time';
107
+ readonly 'format.timestamp.label': 'Timestamp';
108
+ readonly 'format.user.label': 'User';
109
+ readonly 'format.number.label': 'Number';
110
+ readonly 'format.uri.label': 'URI';
111
+ readonly 'format.url.label': 'URL';
112
+ readonly 'format.uuid.label': 'UUID';
113
+ readonly 'latitude.label': 'Latitude';
114
+ readonly 'longitude.label': 'Longitude';
115
+ readonly 'select-option.label': 'Label';
116
+ readonly 'select-option-label.placeholder': 'Option label';
117
+ readonly 'select-option-delete.button': 'Delete';
118
+ readonly 'select-option-add.button': 'Add option';
119
+ readonly 'system-schema.title': 'System type';
120
+ readonly 'system-schema.description': 'System type: cannot add or remove fields.';
121
+ readonly 'remove.button': 'Delete';
79
122
  };
80
123
  };
81
124
  }];
82
125
  };
83
- argTypes: {
84
- readonly: {
85
- control: "boolean";
86
- description: string;
87
- };
88
- };
89
126
  };
90
127
  export default meta;
91
- type Story = StoryObj<typeof meta>;
92
- export declare const Default: Story;
93
- export declare const Organization: Story;
94
- export declare const OrganizationAutoSave: Story;
95
- export declare const Contact: Story;
96
- declare const ShapeSchema: Schema.mutable<Schema.Struct<{
97
- shape: Schema.optional<Schema.Union<[Schema.Struct<{
98
- type: Schema.Literal<["circle"]>;
99
- radius: Schema.optional<Schema.SchemaClass<number, number, never>>;
100
- }>, Schema.Struct<{
101
- type: Schema.Literal<["square"]>;
102
- size: Schema.optional<Schema.refine<number, typeof Schema.Number>>;
103
- }>]>>;
104
- }>>;
105
- type ShapeSchema = Schema.Schema.Type<typeof ShapeSchema>;
106
- export declare const DiscriminatedShape: StoryObj<StoryProps<ShapeSchema>>;
107
- declare const ArraysSchema: Schema.mutable<Schema.Struct<{
108
- names: Schema.Array$<Schema.filter<typeof Schema.String>>;
109
- addresses: Schema.Array$<Schema.Struct<{
110
- street: Schema.optional<Schema.SchemaClass<string, string, never>>;
111
- city: Schema.optional<Schema.SchemaClass<string, string, never>>;
112
- zip: Schema.optional<Schema.refine<string, typeof Schema.String>>;
113
- location: Schema.optional<Schema.Tuple<[Schema.filter<Schema.transform<Schema.SchemaClass<number, number, never>, Schema.filter<Schema.SchemaClass<number, number, never>>>>, Schema.filter<Schema.transform<Schema.SchemaClass<number, number, never>, Schema.filter<Schema.SchemaClass<number, number, never>>>>, Schema.Element<typeof Schema.Number, "?">]>>;
114
- }>>;
115
- }>>;
116
- type ArraysSchema = Schema.Schema.Type<typeof ArraysSchema>;
117
- export declare const Arrays: StoryObj<StoryProps<ArraysSchema>>;
118
- declare const TupleSchema: Schema.mutable<Schema.Struct<{
119
- tuple: Schema.Tuple<[typeof Schema.Number, typeof Schema.String, typeof Schema.Boolean]>;
120
- geopoint: Schema.Tuple<[Schema.filter<Schema.transform<Schema.SchemaClass<number, number, never>, Schema.filter<Schema.SchemaClass<number, number, never>>>>, Schema.filter<Schema.transform<Schema.SchemaClass<number, number, never>, Schema.filter<Schema.SchemaClass<number, number, never>>>>, Schema.Element<typeof Schema.Number, "?">]>;
121
- }>>;
122
- type TupleSchema = Schema.Schema.Type<typeof TupleSchema>;
123
- export declare const Tuple: StoryObj<StoryProps<TupleSchema>>;
124
- declare const ColorSchema: Schema.mutable<Schema.Struct<{
125
- color: Schema.Union<[Schema.Literal<["red"]>, Schema.Literal<["green"]>, Schema.Literal<["blue"]>]>;
126
- }>>;
127
- type ColorType = Schema.Schema.Type<typeof ColorSchema>;
128
- export declare const Enum: StoryObj<StoryProps<ColorType>>;
129
- declare const RefSchema: Schema.Struct<{
130
- contact: Schema.SchemaClass<Ref<import("@dxos/echo/internal").TypedObjectFields<{
131
- name: Schema.optional<typeof Schema.String>;
132
- identifiers: Schema.mutable<Schema.Array$<Schema.Struct<{
133
- type: typeof Schema.String;
134
- value: typeof Schema.String;
135
- }>>>;
136
- }, import("@dxos/echo/internal").TypedObjectOptions>>, import("@dxos/echo-protocol").EncodedReference, never>;
137
- optionalContact: Schema.optional<Schema.SchemaClass<Ref<import("@dxos/echo/internal").TypedObjectFields<{
138
- name: Schema.optional<typeof Schema.String>;
139
- identifiers: Schema.mutable<Schema.Array$<Schema.Struct<{
140
- type: typeof Schema.String;
141
- value: typeof Schema.String;
142
- }>>>;
143
- }, import("@dxos/echo/internal").TypedObjectOptions>>, import("@dxos/echo-protocol").EncodedReference, never>>;
144
- refArray: Schema.optional<Schema.Array$<import("@dxos/echo/internal").Ref$<import("@dxos/echo/internal").TypedObjectFields<{
145
- name: Schema.optional<typeof Schema.String>;
146
- identifiers: Schema.mutable<Schema.Array$<Schema.Struct<{
147
- type: typeof Schema.String;
148
- value: typeof Schema.String;
149
- }>>>;
150
- }, import("@dxos/echo/internal").TypedObjectOptions>>>>;
151
- unknownExpando: Schema.optional<Schema.SchemaClass<Ref<Expando>, import("@dxos/echo-protocol").EncodedReference, never>>;
152
- }>;
153
- type RefSchema = Schema.Schema.Type<typeof RefSchema>;
154
- export declare const Refs: StoryObj<StoryProps<RefSchema>>;
128
+ type Story<T extends AnyProperties> = StoryObj<DefaultStoryProps<T>>;
129
+ declare const PersonSchema: Schema.Schema<{
130
+ readonly name: string;
131
+ readonly ignore?: string | undefined;
132
+ readonly active?: boolean | undefined;
133
+ readonly address?: {
134
+ readonly street: string;
135
+ readonly city: string;
136
+ readonly state: string;
137
+ readonly zip: number;
138
+ } | undefined;
139
+ readonly employer?: import("@dxos/echo/internal").Ref<{
140
+ readonly name: string;
141
+ } & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown> | undefined;
142
+ readonly tags?: readonly import("@dxos/echo/internal").Ref<{
143
+ readonly label: string;
144
+ readonly hue?: string | undefined;
145
+ } & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown>[] | undefined;
146
+ readonly status?: "active" | "inactive" | undefined;
147
+ readonly notes?: string | undefined;
148
+ readonly location?: readonly [number, number, (number | undefined)?] | undefined;
149
+ readonly birthday?: string | undefined;
150
+ readonly meetingAt?: string | undefined;
151
+ readonly reminderAt?: string | undefined;
152
+ readonly tasks?: readonly string[] | undefined;
153
+ readonly locations?: readonly (readonly [number, number, (number | undefined)?])[] | undefined;
154
+ readonly identities?: readonly {
155
+ readonly type: string;
156
+ readonly value: string;
157
+ }[] | undefined;
158
+ } & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object>, {
159
+ readonly name: string;
160
+ readonly ignore?: string | undefined;
161
+ readonly active?: boolean | undefined;
162
+ readonly address?: {
163
+ readonly street: string;
164
+ readonly city: string;
165
+ readonly state: string;
166
+ readonly zip: number;
167
+ } | undefined;
168
+ readonly employer?: import("@dxos/echo/internal").Ref<{
169
+ readonly name: string;
170
+ } & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown> | undefined;
171
+ readonly tags?: readonly import("@dxos/echo/internal").Ref<{
172
+ readonly label: string;
173
+ readonly hue?: string | undefined;
174
+ } & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown>[] | undefined;
175
+ readonly status?: "active" | "inactive" | undefined;
176
+ readonly notes?: string | undefined;
177
+ readonly location?: readonly [number, number, (number | undefined)?] | undefined;
178
+ readonly birthday?: string | undefined;
179
+ readonly meetingAt?: string | undefined;
180
+ readonly reminderAt?: string | undefined;
181
+ readonly tasks?: readonly string[] | undefined;
182
+ readonly locations?: readonly (readonly [number, number, (number | undefined)?])[] | undefined;
183
+ readonly identities?: readonly {
184
+ readonly type: string;
185
+ readonly value: string;
186
+ }[] | undefined;
187
+ } & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object>, never>;
188
+ export declare const Default: Story<ExcludeId<typeof PersonSchema>>;
189
+ export declare const Readonly: Story<ExcludeId<typeof PersonSchema>>;
190
+ export declare const Static: Story<ExcludeId<typeof PersonSchema>>;
191
+ export declare const Empty: Story<ExcludeId<typeof PersonSchema>>;
155
192
  //# 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,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAgC,MAAM,OAAO,CAAC;AAGrD,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,KAAK,UAAU,EAAE,OAAO,EAAU,GAAG,EAAqC,MAAM,qBAAqB,CAAC;AAU/G,OAAO,EAAQ,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AAE9C,KAAK,UAAU,CAAC,CAAC,SAAS,UAAU,IAAI;IACtC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;CACtB,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AA6DjB,QAAA,MAAM,IAAI;;eAEW,GAAG;aA7DF,CAAC,SAAS,UAAU,4DAKvC,UAAU,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqEiB,CAAC;AAElC,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAYrB,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAU1B,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,KAWlC,CAAC;AAKF,eAAO,MAAM,OAAO,EAAE,KAQrB,CAAC;AAMF,QAAA,MAAM,WAAW;;;;;;;;GAaM,CAAC;AAExB,KAAK,WAAW,GAAG,MAAM,CAAC,MAA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AAS,CAAC,OAAO,YAAY,CAAC,CAMxD,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,YAAY,CAAC,CAEvD,CAAC"}
@@ -0,0 +1,48 @@
1
+ import * as SchemaAST from 'effect/SchemaAST';
2
+ import React from 'react';
3
+ import { type ProjectionModel } from '@dxos/schema';
4
+ import { type RefFieldProps } from './fields';
5
+ import { type FormFieldComponentProps, type FormFieldMap, type FormFieldProvider } from './FormFieldComponent';
6
+ export type FormFieldProps = {
7
+ /**
8
+ * AST of the property to render.
9
+ */
10
+ type: SchemaAST.AST;
11
+ /**
12
+ * Name of the property. Used to derive a default label
13
+ * (`title ?? capitalize(name)`) and as the projection lookup key. Pass
14
+ * `null` to suppress the header label entirely -- the form still renders
15
+ * the field/struct, but `FormFieldSet`'s top-level `<FormFieldLabel>` is
16
+ * skipped. Used by `ArrayField` for object-array items, where every item
17
+ * would otherwise repeat the array's parent name.
18
+ */
19
+ name: string | null;
20
+ /**
21
+ * Path to the current object from the root. Used with nested forms.
22
+ */
23
+ path?: (string | number)[];
24
+ /**
25
+ * Optional projection for projection-based field management.
26
+ */
27
+ projection?: ProjectionModel;
28
+ /**
29
+ * Map of custom renderers for specific properties.
30
+ * Prefer fieldProvider for plugin specific input surfaces.
31
+ */
32
+ fieldMap?: FormFieldMap;
33
+ /**
34
+ * Function to lookup custom renderers for specific properties.
35
+ */
36
+ fieldProvider?: FormFieldProvider;
37
+ /**
38
+ * Typename of the ref type that the create props apply to.
39
+ * When set, createOptionLabel/createOptionIcon/createInitialValuePath/createFieldMap/onCreate
40
+ * are only passed to ref fields whose typename matches.
41
+ */
42
+ createTypename?: string;
43
+ } & Pick<FormFieldComponentProps, 'autoFocus' | 'readonly' | 'layout'> & Pick<RefFieldProps, 'createOptionLabel' | 'createOptionIcon' | 'createInitialValuePath' | 'createFieldMap' | 'db' | 'useType' | 'getOptions' | 'onCreate'>;
44
+ export declare function FormField(props: FormFieldProps): React.JSX.Element | null;
45
+ export declare namespace FormField {
46
+ var displayName: string;
47
+ }
48
+ //# 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;AAcvC,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAKpD,OAAO,EAQL,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;IAClC;;;;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"}