@dxos/react-ui-form 0.8.4-main.ae835ea → 0.8.4-main.bc674ce

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 (177) hide show
  1. package/dist/lib/browser/index.mjs +2182 -2231
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +2182 -2231
  5. package/dist/lib/node-esm/index.mjs.map +4 -4
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/types/src/components/ControlSection/ControlSection.d.ts +2 -2
  8. package/dist/types/src/components/ControlSection/ControlSection.d.ts.map +1 -1
  9. package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts +11 -8
  10. package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts.map +1 -1
  11. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts +6 -5
  12. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
  13. package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts +13 -7
  14. package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts.map +1 -1
  15. package/dist/types/src/components/Form/Form-old.stories.d.ts +131 -0
  16. package/dist/types/src/components/Form/Form-old.stories.d.ts.map +1 -0
  17. package/dist/types/src/components/Form/Form.d.ts +81 -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 +59 -84
  20. package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
  21. package/dist/types/src/components/Form/FormField.d.ts +37 -0
  22. package/dist/types/src/components/Form/FormField.d.ts.map +1 -0
  23. package/dist/types/src/components/Form/FormFieldComponent.d.ts +78 -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 +19 -0
  28. package/dist/types/src/components/Form/FormFieldSet.d.ts.map +1 -0
  29. package/dist/types/src/components/Form/fields/ArrayField.d.ts +18 -0
  30. package/dist/types/src/components/Form/fields/ArrayField.d.ts.map +1 -0
  31. package/dist/types/src/components/Form/fields/BooleanField.d.ts +4 -0
  32. package/dist/types/src/components/Form/fields/BooleanField.d.ts.map +1 -0
  33. package/dist/types/src/components/Form/fields/GeoPointField.d.ts +5 -0
  34. package/dist/types/src/components/Form/fields/GeoPointField.d.ts.map +1 -0
  35. package/dist/types/src/components/Form/fields/MarkdownField.d.ts +4 -0
  36. package/dist/types/src/components/Form/fields/MarkdownField.d.ts.map +1 -0
  37. package/dist/types/src/components/Form/fields/NumberField.d.ts +4 -0
  38. package/dist/types/src/components/Form/fields/NumberField.d.ts.map +1 -0
  39. package/dist/types/src/components/Form/fields/RefField.d.ts +14 -0
  40. package/dist/types/src/components/Form/fields/RefField.d.ts.map +1 -0
  41. package/dist/types/src/components/Form/fields/SelectField.d.ts +10 -0
  42. package/dist/types/src/components/Form/fields/SelectField.d.ts.map +1 -0
  43. package/dist/types/src/components/Form/fields/SelectOptionField.d.ts +5 -0
  44. package/dist/types/src/components/Form/fields/SelectOptionField.d.ts.map +1 -0
  45. package/dist/types/src/components/Form/{custom/SelectOptionsInput.stories.d.ts → fields/SelectOptionField.stories.d.ts} +10 -7
  46. package/dist/types/src/components/Form/fields/SelectOptionField.stories.d.ts.map +1 -0
  47. package/dist/types/src/components/Form/fields/TextAreaField.d.ts +4 -0
  48. package/dist/types/src/components/Form/fields/TextAreaField.d.ts.map +1 -0
  49. package/dist/types/src/components/Form/fields/TextField.d.ts +4 -0
  50. package/dist/types/src/components/Form/fields/TextField.d.ts.map +1 -0
  51. package/dist/types/src/components/Form/fields/TupleField.d.ts +6 -0
  52. package/dist/types/src/components/Form/fields/TupleField.d.ts.map +1 -0
  53. package/dist/types/src/components/Form/fields/index.d.ts +12 -0
  54. package/dist/types/src/components/Form/fields/index.d.ts.map +1 -0
  55. package/dist/types/src/components/Form/index.d.ts +2 -4
  56. package/dist/types/src/components/Form/index.d.ts.map +1 -1
  57. package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts +14 -9
  58. package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts.map +1 -1
  59. package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts +9 -6
  60. package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts.map +1 -1
  61. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +11 -13
  62. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
  63. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +12 -9
  64. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
  65. package/dist/types/src/components/testing.d.ts +0 -2
  66. package/dist/types/src/components/testing.d.ts.map +1 -1
  67. package/dist/types/src/hooks/index.d.ts +2 -3
  68. package/dist/types/src/hooks/index.d.ts.map +1 -1
  69. package/dist/types/src/hooks/useFormHandler.d.ts +82 -0
  70. package/dist/types/src/hooks/useFormHandler.d.ts.map +1 -0
  71. package/dist/types/src/hooks/useKeyHandler.d.ts +6 -0
  72. package/dist/types/src/hooks/useKeyHandler.d.ts.map +1 -0
  73. package/dist/types/src/translations.d.ts +10 -7
  74. package/dist/types/src/translations.d.ts.map +1 -1
  75. package/dist/types/src/util/echo.d.ts +6 -0
  76. package/dist/types/src/util/echo.d.ts.map +1 -0
  77. package/dist/types/src/util/field.d.ts +3 -3
  78. package/dist/types/src/util/field.d.ts.map +1 -1
  79. package/dist/types/src/util/formatting.d.ts +2 -2
  80. package/dist/types/src/util/formatting.d.ts.map +1 -1
  81. package/dist/types/src/util/index.d.ts +2 -1
  82. package/dist/types/src/util/index.d.ts.map +1 -1
  83. package/dist/types/src/util/properties.d.ts +7 -0
  84. package/dist/types/src/util/properties.d.ts.map +1 -0
  85. package/dist/types/src/util/refs.d.ts +1 -2
  86. package/dist/types/src/util/refs.d.ts.map +1 -1
  87. package/dist/types/tsconfig.tsbuildinfo +1 -1
  88. package/package.json +49 -43
  89. package/src/components/ControlSection/ControlSection.stories.tsx +1 -1
  90. package/src/components/ControlSection/ControlSection.tsx +8 -8
  91. package/src/components/FieldEditor/FieldEditor.stories.tsx +42 -21
  92. package/src/components/FieldEditor/FieldEditor.tsx +73 -76
  93. package/src/components/Form/Form-old.stories.tsx +314 -0
  94. package/src/components/Form/Form.stories.tsx +148 -248
  95. package/src/components/Form/Form.tsx +320 -108
  96. package/src/components/Form/FormField.tsx +286 -0
  97. package/src/components/Form/FormFieldComponent.stories.tsx +65 -0
  98. package/src/components/Form/FormFieldComponent.tsx +174 -0
  99. package/src/components/Form/FormFieldSet.tsx +125 -0
  100. package/src/components/Form/README.md +3 -0
  101. package/src/components/Form/fields/ArrayField.tsx +151 -0
  102. package/src/components/Form/fields/BooleanField.tsx +22 -0
  103. package/src/components/Form/fields/GeoPointField.tsx +120 -0
  104. package/src/components/Form/fields/MarkdownField.tsx +78 -0
  105. package/src/components/Form/fields/NumberField.tsx +39 -0
  106. package/src/components/Form/fields/RefField.tsx +181 -0
  107. package/src/components/Form/fields/SelectField.tsx +65 -0
  108. package/src/components/Form/{custom/SelectOptionsInput.stories.tsx → fields/SelectOptionField.stories.tsx} +17 -14
  109. package/src/components/Form/{custom/SelectOptionsInput.tsx → fields/SelectOptionField.tsx} +21 -15
  110. package/src/components/Form/fields/TextAreaField.tsx +38 -0
  111. package/src/components/Form/fields/TextField.tsx +38 -0
  112. package/src/components/Form/{custom/TupleInput.tsx → fields/TupleField.tsx} +15 -8
  113. package/src/components/Form/fields/index.ts +15 -0
  114. package/src/components/Form/index.ts +3 -4
  115. package/src/components/ObjectPicker/ObjectPicker.stories.tsx +20 -13
  116. package/src/components/ObjectPicker/ObjectPicker.tsx +76 -62
  117. package/src/components/ViewEditor/ViewEditor.stories.tsx +42 -40
  118. package/src/components/ViewEditor/ViewEditor.test.tsx +8 -4
  119. package/src/components/ViewEditor/ViewEditor.tsx +233 -172
  120. package/src/components/testing.tsx +9 -7
  121. package/src/hooks/index.ts +2 -3
  122. package/src/hooks/useFormHandler.ts +362 -0
  123. package/src/hooks/useKeyHandler.tsx +37 -0
  124. package/src/translations.ts +12 -10
  125. package/src/util/echo.ts +25 -0
  126. package/src/util/field.ts +25 -25
  127. package/src/util/formatting.ts +22 -22
  128. package/src/util/index.ts +2 -1
  129. package/src/util/properties.ts +18 -0
  130. package/src/util/refs.ts +11 -17
  131. package/dist/types/src/components/Form/ArrayField.d.ts +0 -16
  132. package/dist/types/src/components/Form/ArrayField.d.ts.map +0 -1
  133. package/dist/types/src/components/Form/Defaults.d.ts +0 -14
  134. package/dist/types/src/components/Form/Defaults.d.ts.map +0 -1
  135. package/dist/types/src/components/Form/FormActions.d.ts +0 -9
  136. package/dist/types/src/components/Form/FormActions.d.ts.map +0 -1
  137. package/dist/types/src/components/Form/FormContent.d.ts +0 -63
  138. package/dist/types/src/components/Form/FormContent.d.ts.map +0 -1
  139. package/dist/types/src/components/Form/FormContext.d.ts +0 -23
  140. package/dist/types/src/components/Form/FormContext.d.ts.map +0 -1
  141. package/dist/types/src/components/Form/Input.d.ts +0 -29
  142. package/dist/types/src/components/Form/Input.d.ts.map +0 -1
  143. package/dist/types/src/components/Form/RefField.d.ts +0 -22
  144. package/dist/types/src/components/Form/RefField.d.ts.map +0 -1
  145. package/dist/types/src/components/Form/custom/GeoPointInput.d.ts +0 -4
  146. package/dist/types/src/components/Form/custom/GeoPointInput.d.ts.map +0 -1
  147. package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts +0 -4
  148. package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts.map +0 -1
  149. package/dist/types/src/components/Form/custom/SelectOptionsInput.stories.d.ts.map +0 -1
  150. package/dist/types/src/components/Form/custom/TupleInput.d.ts +0 -6
  151. package/dist/types/src/components/Form/custom/TupleInput.d.ts.map +0 -1
  152. package/dist/types/src/components/Form/custom/index.d.ts +0 -4
  153. package/dist/types/src/components/Form/custom/index.d.ts.map +0 -1
  154. package/dist/types/src/components/Form/factory.d.ts +0 -8
  155. package/dist/types/src/components/Form/factory.d.ts.map +0 -1
  156. package/dist/types/src/hooks/useForm.d.ts +0 -67
  157. package/dist/types/src/hooks/useForm.d.ts.map +0 -1
  158. package/dist/types/src/hooks/useQueryRefOptions.d.ts +0 -29
  159. package/dist/types/src/hooks/useQueryRefOptions.d.ts.map +0 -1
  160. package/dist/types/src/hooks/useRefQueryLookupHandler.d.ts +0 -8
  161. package/dist/types/src/hooks/useRefQueryLookupHandler.d.ts.map +0 -1
  162. package/dist/types/src/util/schema.d.ts +0 -3
  163. package/dist/types/src/util/schema.d.ts.map +0 -1
  164. package/src/components/Form/ArrayField.tsx +0 -125
  165. package/src/components/Form/Defaults.tsx +0 -205
  166. package/src/components/Form/FormActions.tsx +0 -54
  167. package/src/components/Form/FormContent.tsx +0 -322
  168. package/src/components/Form/FormContext.tsx +0 -110
  169. package/src/components/Form/Input.tsx +0 -54
  170. package/src/components/Form/RefField.tsx +0 -283
  171. package/src/components/Form/custom/GeoPointInput.tsx +0 -80
  172. package/src/components/Form/custom/index.ts +0 -7
  173. package/src/components/Form/factory.tsx +0 -31
  174. package/src/hooks/useForm.ts +0 -296
  175. package/src/hooks/useQueryRefOptions.ts +0 -62
  176. package/src/hooks/useRefQueryLookupHandler.ts +0 -39
  177. package/src/util/schema.ts +0 -12
package/src/util/index.ts CHANGED
@@ -2,7 +2,8 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
+ export * from './echo';
5
6
  export * from './field';
6
7
  export * from './formatting';
8
+ export * from './properties';
7
9
  export * from './refs';
8
- export * from './schema';
@@ -0,0 +1,18 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Option from 'effect/Option';
6
+ import type * as SchemaAST from 'effect/SchemaAST';
7
+
8
+ import { Annotation } from '@dxos/echo';
9
+ import { type SchemaProperty, getProperties } from '@dxos/effect';
10
+
11
+ /**
12
+ * Get the property types of an AST and filter out properties that are not form inputs.
13
+ */
14
+ export const getFormProperties = (ast: SchemaAST.AST): SchemaProperty[] => {
15
+ return getProperties(ast).filter((prop) =>
16
+ Annotation.FormInputAnnotation.getFromAst(prop.type).pipe(Option.getOrElse(() => true)),
17
+ );
18
+ };
package/src/util/refs.ts CHANGED
@@ -4,35 +4,29 @@
4
4
 
5
5
  import type * as SchemaAST from 'effect/SchemaAST';
6
6
 
7
- import { FormatEnum, ReferenceAnnotationId } from '@dxos/echo/internal';
8
- import { findAnnotation } from '@dxos/effect';
9
- import { type SchemaProperty } from '@dxos/schema';
10
-
11
- import { findArrayElementType } from './schema';
7
+ import { Ref } from '@dxos/echo';
8
+ import { getArrayElementType, isArrayType } from '@dxos/effect';
12
9
 
13
10
  type RefProps = {
14
11
  ast: SchemaAST.AST;
15
12
  isArray: boolean;
16
13
  };
17
14
 
18
- export const getRefProps = (property: SchemaProperty<any>): RefProps | undefined => {
19
- const { ast, format, array } = property;
20
-
21
- // Direct reference.
22
- if (format === FormatEnum.Ref) {
23
- return { ast, isArray: false };
24
- }
25
-
15
+ export const getRefProps = (ast: SchemaAST.AST): RefProps | undefined => {
26
16
  // Array of references.
27
- if (array) {
28
- const elementType = findArrayElementType(ast);
17
+ if (isArrayType(ast)) {
18
+ const elementType = getArrayElementType(ast);
29
19
  if (elementType) {
30
- const annotation = findAnnotation(elementType, ReferenceAnnotationId);
31
- if (annotation) {
20
+ if (Ref.isRefType(elementType)) {
32
21
  return { ast: elementType, isArray: true };
33
22
  }
34
23
  }
35
24
  }
36
25
 
26
+ // Direct reference.
27
+ if (Ref.isRefType(ast)) {
28
+ return { ast, isArray: false };
29
+ }
30
+
37
31
  return undefined;
38
32
  };
@@ -1,16 +0,0 @@
1
- import React from 'react';
2
- import { type SchemaProperty } from '@dxos/schema';
3
- import { type ComponentLookup } from './Form';
4
- import { type FormFieldProps } from './FormContent';
5
- import { type FormInputStateProps } from './FormContext';
6
- import { type InputComponent } from './Input';
7
- type ArrayFieldProps = {
8
- property: SchemaProperty<any>;
9
- inputProps: FormInputStateProps;
10
- path?: (string | number)[];
11
- Custom?: Partial<Record<string, InputComponent>>;
12
- lookupComponent?: ComponentLookup;
13
- } & Pick<FormFieldProps, 'readonly'>;
14
- export declare const ArrayField: ({ property, readonly, path, inputProps, Custom, lookupComponent }: ArrayFieldProps) => React.JSX.Element | null;
15
- export {};
16
- //# sourceMappingURL=ArrayField.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ArrayField.d.ts","sourceRoot":"","sources":["../../../../../src/components/Form/ArrayField.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAgC,MAAM,OAAO,CAAC;AAKrD,OAAO,EAAE,KAAK,cAAc,EAAuB,MAAM,cAAc,CAAC;AAKxE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,KAAK,mBAAmB,EAAiB,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,KAAK,cAAc,EAAe,MAAM,SAAS,CAAC;AAE3D,KAAK,eAAe,GAAG;IACrB,QAAQ,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;IAC9B,UAAU,EAAE,mBAAmB,CAAC;IAChC,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAC3B,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;IACjD,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC,GAAG,IAAI,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;AAErC,eAAO,MAAM,UAAU,GAAI,mEAAmE,eAAe,6BA8F5G,CAAC"}
@@ -1,14 +0,0 @@
1
- import React from 'react';
2
- import { type InputProps } from './Input';
3
- export declare const TextInput: ({ type, label, inputOnly, readonly, placeholder, getStatus, getValue, onValueChange, onBlur, }: InputProps) => React.JSX.Element | null;
4
- export declare const NumberInput: ({ type, label, inputOnly, readonly, placeholder, getStatus, getValue, onValueChange, onBlur, }: InputProps) => React.JSX.Element | null;
5
- export declare const BooleanInput: ({ type, label, inputOnly, getStatus, getValue, onValueChange, readonly }: InputProps) => React.JSX.Element;
6
- export type SelectInputOptions = InputProps & {
7
- options?: Array<{
8
- value: string | number;
9
- label?: string;
10
- }>;
11
- };
12
- export declare const SelectInput: ({ type, label, inputOnly, readonly, placeholder, options, getStatus, getValue, onValueChange, }: SelectInputOptions) => React.JSX.Element | null;
13
- export declare const MarkdownInput: ({ type, label, inputOnly, readonly, placeholder, getStatus, getValue, onValueChange, onBlur, }: InputProps) => React.JSX.Element;
14
- //# sourceMappingURL=Defaults.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Defaults.d.ts","sourceRoot":"","sources":["../../../../../src/components/Form/Defaults.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAM9D,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAEvD,eAAO,MAAM,SAAS,GAAI,gGAUvB,UAAU,6BAsBZ,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,gGAUzB,UAAU,6BAuBZ,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,0EAA0E,UAAU,sBAgBhH,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG;IAC5C,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC7D,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,iGAUzB,kBAAkB,6BAiCpB,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,gGAU3B,UAAU,sBA8CZ,CAAC"}
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- export type FormOuterSpacing = boolean | 'blockStart-0' | 'scroll-fields';
3
- export type FormActionsProps = {
4
- readonly?: boolean;
5
- onCancel?: () => void;
6
- outerSpacing?: FormOuterSpacing;
7
- };
8
- export declare const FormActions: ({ readonly, onCancel, outerSpacing }: FormActionsProps) => React.JSX.Element;
9
- //# sourceMappingURL=FormActions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormActions.d.ts","sourceRoot":"","sources":["../../../../../src/components/Form/FormActions.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,cAAc,GAAG,eAAe,CAAC;AAE1E,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,YAAY,CAAC,EAAE,gBAAgB,CAAC;CACjC,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,sCAA6C,gBAAgB,sBA+BxF,CAAC"}
@@ -1,63 +0,0 @@
1
- import * as Schema from 'effect/Schema';
2
- import React from 'react';
3
- import { type ThemedClassName } from '@dxos/react-ui';
4
- import { type ProjectionModel, type SchemaProperty } from '@dxos/schema';
5
- import { type QueryRefOptions } from '../../hooks';
6
- import { type ComponentLookup } from './Form';
7
- import { type InputComponent } from './Input';
8
- import { type RefFieldProps } from './RefField';
9
- export type FormFieldProps = {
10
- property: SchemaProperty<any>;
11
- path?: (string | number)[];
12
- /** Used to indicate if input should be presented inline (e.g. for array items). */
13
- inline?: boolean;
14
- projection?: ProjectionModel;
15
- lookupComponent?: ComponentLookup;
16
- Custom?: Partial<Record<string, InputComponent>>;
17
- } & Pick<RefFieldProps, 'readonly' | 'onQueryRefOptions' | 'createOptionLabel' | 'createOptionIcon' | 'onCreate' | 'createSchema' | 'createInitialValuePath'>;
18
- export declare const FormField: ({ property, path, readonly, inline, projection, onQueryRefOptions, createOptionLabel, createOptionIcon, onCreate, createSchema, createInitialValuePath, lookupComponent, Custom, }: FormFieldProps) => React.JSX.Element | null;
19
- export type FormFieldsProps = ThemedClassName<{
20
- testId?: string;
21
- schema: Schema.Schema.All;
22
- /**
23
- * Path to the current object from the root. Used with nested forms.
24
- */
25
- path?: (string | number)[];
26
- filter?: (props: SchemaProperty<any>[]) => SchemaProperty<any>[];
27
- sort?: string[];
28
- /**
29
- * Optional projection for projection-based field management
30
- */
31
- projection?: ProjectionModel;
32
- lookupComponent?: ComponentLookup;
33
- /**
34
- * Map of custom renderers for specific properties.
35
- * Prefer lookupComponent for plugin specific input surfaces.
36
- */
37
- Custom?: Partial<Record<string, InputComponent>>;
38
- onQueryRefOptions?: QueryRefOptions;
39
- } & Pick<FormFieldProps, 'readonly'> & Pick<RefFieldProps, 'onQueryRefOptions' | 'createOptionLabel' | 'createOptionIcon' | 'onCreate' | 'createSchema' | 'createInitialValuePath'>>;
40
- export declare const FormFields: React.ForwardRefExoticComponent<Omit<{
41
- testId?: string;
42
- schema: Schema.Schema.All;
43
- /**
44
- * Path to the current object from the root. Used with nested forms.
45
- */
46
- path?: (string | number)[];
47
- filter?: (props: SchemaProperty<any>[]) => SchemaProperty<any>[];
48
- sort?: string[];
49
- /**
50
- * Optional projection for projection-based field management
51
- */
52
- projection?: ProjectionModel;
53
- lookupComponent?: ComponentLookup;
54
- /**
55
- * Map of custom renderers for specific properties.
56
- * Prefer lookupComponent for plugin specific input surfaces.
57
- */
58
- Custom?: Partial<Record<string, InputComponent>>;
59
- onQueryRefOptions?: QueryRefOptions;
60
- } & Pick<FormFieldProps, "readonly"> & Pick<RefFieldProps, "onQueryRefOptions" | "createOptionLabel" | "createOptionIcon" | "onCreate" | "createSchema" | "createInitialValuePath">, "className"> & {
61
- classNames?: import("@dxos/react-ui-types").ClassNameValue;
62
- } & React.RefAttributes<HTMLDivElement>>;
63
- //# sourceMappingURL=FormContent.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormContent.d.ts","sourceRoot":"","sources":["../../../../../src/components/Form/FormContent.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,OAAO,KAA8B,MAAM,OAAO,CAAC;AAGnD,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EAAuB,MAAM,cAAc,CAAC;AAG9F,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAMnD,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAE1D,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAC3B,mFAAmF;IACnF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;CAClD,GAAG,IAAI,CACN,aAAa,EACX,UAAU,GACV,mBAAmB,GACnB,mBAAmB,GACnB,kBAAkB,GAClB,UAAU,GACV,cAAc,GACd,wBAAwB,CAC3B,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,oLAcvB,cAAc,6BAwJhB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,eAAe,CAC3C;IACE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;IAC1B;;OAEG;IACH,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAC3B,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,CAAC,GAAG,CAAC,EAAE,KAAK,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;IACjE,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB;;OAEG;IACH,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;IACjD,iBAAiB,CAAC,EAAE,eAAe,CAAC;CACrC,GAAG,IAAI,CAAC,cAAc,EAAE,UAAU,CAAC,GAClC,IAAI,CACF,aAAa,EACX,mBAAmB,GACnB,mBAAmB,GACnB,kBAAkB,GAClB,UAAU,GACV,cAAc,GACd,wBAAwB,CAC3B,CACJ,CAAC;AAEF,eAAO,MAAM,UAAU;aA/BV,MAAM;YACP,MAAM,CAAC,MAAM,CAAC,GAAG;IACzB;;OAEG;WACI,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE;aACjB,CAAC,KAAK,EAAE,cAAc,CAAC,GAAG,CAAC,EAAE,KAAK,cAAc,CAAC,GAAG,CAAC,EAAE;WACzD,MAAM,EAAE;IACf;;OAEG;iBACU,eAAe;sBACV,eAAe;IACjC;;;OAGG;aACM,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;wBAC5B,eAAe;;;wCAuFtC,CAAC"}
@@ -1,23 +0,0 @@
1
- import React, { type FocusEvent, type PropsWithChildren, type RefObject } from 'react';
2
- import { type BaseObject } from '@dxos/echo/internal';
3
- import { type SimpleType } from '@dxos/effect';
4
- import { type FormHandler, type FormOptions } from '../../hooks';
5
- type FormContextValue<T extends BaseObject> = FormHandler<T>;
6
- export declare const useFormContext: <T extends BaseObject>() => FormContextValue<T>;
7
- export declare const useFormValues: (path?: (string | number)[]) => any;
8
- export type FormInputStateProps = {
9
- getStatus: () => {
10
- status?: 'error';
11
- error?: string;
12
- };
13
- getValue: <V>() => V | undefined;
14
- onValueChange: (type: SimpleType, value: any) => void;
15
- onBlur: (event: FocusEvent<HTMLElement>) => void;
16
- };
17
- export declare const useInputProps: (path?: (string | number)[]) => FormInputStateProps;
18
- export declare const FormProvider: ({ children, formRef, autoSave, ...formOptions }: PropsWithChildren<FormOptions<any> & {
19
- formRef?: RefObject<HTMLDivElement | null>;
20
- autoSave?: boolean;
21
- }>) => React.JSX.Element;
22
- export {};
23
- //# sourceMappingURL=FormContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormContext.d.ts","sourceRoot":"","sources":["../../../../../src/components/Form/FormContext.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EACZ,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,SAAS,EAMf,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,KAAK,UAAU,EAAY,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,KAAK,UAAU,EAAkB,MAAM,cAAc,CAAC;AAE/D,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAW,MAAM,aAAa,CAAC;AAE1E,KAAK,gBAAgB,CAAC,CAAC,SAAS,UAAU,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;AAI7D,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,UAAU,OAAK,gBAAgB,CAAC,CAAC,CAEzE,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,OAAM,CAAC,MAAM,GAAG,MAAM,CAAC,EAAO,KAAG,GAI9D,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,MAAM;QAAE,MAAM,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACtD,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;IACjC,aAAa,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IACtD,MAAM,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;CAClD,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,OAAM,CAAC,MAAM,GAAG,MAAM,CAAC,EAAO,KAAG,mBAa9D,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,iDAK1B,iBAAiB,CAClB,WAAW,CAAC,GAAG,CAAC,GAAG;IACjB,OAAO,CAAC,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CACF,sBA0CA,CAAC"}
@@ -1,29 +0,0 @@
1
- import React, { type FC } from 'react';
2
- import { type FormatEnum } from '@dxos/echo/internal';
3
- import { type SimpleType } from '@dxos/effect';
4
- import { type FormInputStateProps } from './FormContext';
5
- /**
6
- * Props passed to input components.
7
- */
8
- export type InputProps = {
9
- type: SimpleType;
10
- format?: FormatEnum;
11
- label: string;
12
- placeholder?: string;
13
- inputOnly?: boolean;
14
- /**
15
- * Specifies the readonly variant: either disabled inputs, elements indicating they are usually editable but currently are not; or `static`, a field’s representation as regular content without signifiers that it is ever editable.
16
- */
17
- readonly?: 'disabled-input' | 'static' | false;
18
- } & FormInputStateProps;
19
- /**
20
- * Form input component.
21
- */
22
- export type InputComponent = FC<InputProps>;
23
- export type InputHeaderProps = {
24
- error?: string;
25
- label: string;
26
- readonly?: boolean;
27
- };
28
- export declare const InputHeader: ({ error, label, readonly }: InputHeaderProps) => React.JSX.Element;
29
- //# sourceMappingURL=Input.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../../../src/components/Form/Input.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAK/C,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEzD;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,QAAQ,CAAC,EAAE,gBAAgB,GAAG,QAAQ,GAAG,KAAK,CAAC;CAChD,GAAG,mBAAmB,CAAC;AAExB;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC;AAE5C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,4BAA4B,gBAAgB,sBAavE,CAAC"}
@@ -1,22 +0,0 @@
1
- import '@dxos/lit-ui/dx-tag-picker.pcss';
2
- import type * as Schema from 'effect/Schema';
3
- import type * as SchemaAST from 'effect/SchemaAST';
4
- import React from 'react';
5
- import { type EchoSchema } from '@dxos/echo/internal';
6
- import { type QueryRefOptions } from '../../hooks';
7
- import { type InputProps } from './Input';
8
- export type RefFieldProps = InputProps & {
9
- ast?: SchemaAST.AST;
10
- array?: boolean;
11
- createOptionLabel?: [string, {
12
- ns: string;
13
- }];
14
- createOptionIcon?: string;
15
- onCreate?: (values: any) => void;
16
- createSchema?: Schema.Schema.AnyNoContext;
17
- createInitialValuePath?: string;
18
- onQueryRefOptions?: QueryRefOptions;
19
- schema?: EchoSchema;
20
- };
21
- export declare const RefField: ({ type, label, readonly, placeholder, inputOnly, array, ast, getValue, createOptionLabel, createOptionIcon, onBlur, onCreate, createSchema, createInitialValuePath, onQueryRefOptions, onValueChange, ...restInputProps }: RefFieldProps) => React.JSX.Element | null;
22
- //# sourceMappingURL=RefField.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RefField.d.ts","sourceRoot":"","sources":["../../../../../src/components/Form/RefField.tsx"],"names":[],"mappings":"AAIA,OAAO,iCAAiC,CAAC;AAEzC,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,KAAK,SAAS,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAA+B,MAAM,OAAO,CAAC;AAEpD,OAAO,EACL,KAAK,UAAU,EAMhB,MAAM,qBAAqB,CAAC;AAS7B,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,aAAa,CAAC;AAKvE,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAEvD,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG;IACvC,GAAG,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC7C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC;IAC1C,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,iBAAiB,CAAC,EAAE,eAAe,CAAC;IACpC,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB,CAAC;AAOF,eAAO,MAAM,QAAQ,GAAI,2NAkBtB,aAAa,6BAuKf,CAAC"}
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import { type InputProps } from '../Input';
3
- export declare const GeoPointInput: ({ type, label, readonly, getStatus, getValue, onValueChange, onBlur }: InputProps) => React.JSX.Element;
4
- //# sourceMappingURL=GeoPointInput.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GeoPointInput.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Form/custom/GeoPointInput.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAsE,MAAM,OAAO,CAAC;AAO3F,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAExD,eAAO,MAAM,aAAa,GAAI,uEAAuE,UAAU,sBAkE9G,CAAC"}
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import { type InputProps } from '../Input';
3
- export declare const SelectOptionInput: ({ type, label, readonly, getStatus, getValue, onValueChange }: InputProps) => React.JSX.Element;
4
- //# sourceMappingURL=SelectOptionsInput.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SelectOptionsInput.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Form/custom/SelectOptionsInput.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAyF,MAAM,OAAO,CAAC;AAU9G,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAExD,eAAO,MAAM,iBAAiB,GAAI,+DAA+D,UAAU,sBA8K1G,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"SelectOptionsInput.stories.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Form/custom/SelectOptionsInput.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,KAAmB,MAAM,OAAO,CAAC;AAuCxC,QAAA,MAAM,IAAI;;eAEwB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAOA,CAAC;AAEtC,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAAU,CAAC"}
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- import { type InputProps } from '../Input';
3
- export declare const TupleInput: ({ binding, type, label, readonly, getStatus, getValue, onValueChange, onBlur, }: InputProps & {
4
- binding: string[];
5
- }) => React.JSX.Element;
6
- //# sourceMappingURL=TupleInput.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TupleInput.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Form/custom/TupleInput.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAIxD,eAAO,MAAM,UAAU,GAAI,iFASxB,UAAU,GAAG;IAAE,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,sBAuBpC,CAAC"}
@@ -1,4 +0,0 @@
1
- export * from './GeoPointInput';
2
- export * from './SelectOptionsInput';
3
- export * from './TupleInput';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Form/custom/index.ts"],"names":[],"mappings":"AAIA,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC"}
@@ -1,8 +0,0 @@
1
- import { FormatEnum } from '@dxos/echo/internal';
2
- import { type SimpleType } from '@dxos/effect';
3
- import { type InputComponent } from './Input';
4
- /**
5
- * Get property input component.
6
- */
7
- export declare const getInputComponent: (type: SimpleType, format?: FormatEnum | string) => InputComponent | undefined;
8
- //# sourceMappingURL=factory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../../../src/components/Form/factory.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAI/C,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,UAAU,EAAE,SAAS,UAAU,GAAG,MAAM,KAAG,cAAc,GAAG,SAgBnG,CAAC"}
@@ -1,67 +0,0 @@
1
- import type * as Schema from 'effect/Schema';
2
- import { type BaseObject } from '@dxos/echo/internal';
3
- import { type JsonPath, type SimpleType } from '@dxos/effect';
4
- import { type ValidationError } from '@dxos/schema';
5
- import { type MaybePromise } from '@dxos/util';
6
- /**
7
- * Return type from `useForm` hook.
8
- */
9
- export type FormHandler<T extends BaseObject> = {
10
- values: Partial<T>;
11
- errors: Record<JsonPath, string>;
12
- touched: Record<JsonPath, boolean>;
13
- changed: Record<JsonPath, boolean>;
14
- canSave: boolean;
15
- formIsValid: boolean;
16
- handleSave: () => void;
17
- getStatus: (path: string | (string | number)[]) => {
18
- status?: 'error';
19
- error?: string;
20
- };
21
- getValue: <V>(path: (string | number)[]) => V | undefined;
22
- onValueChange: <V>(path: (string | number)[], type: SimpleType, value: V) => void;
23
- onTouched: (path: (string | number)[]) => void;
24
- };
25
- /**
26
- * Hook options.
27
- */
28
- export interface FormOptions<T extends BaseObject> {
29
- /**
30
- * Effect schema (Type literal).
31
- */
32
- schema: Schema.Schema<T, any>;
33
- /**
34
- * Initial values (which may not pass validation).
35
- */
36
- initialValues: Partial<T>;
37
- /**
38
- * Callback for value changes. Note: This is called even when values are invalid.
39
- * Sometimes the parent component may want to know about changes even if the form is
40
- * in an invalid state.
41
- */
42
- onValuesChanged?: (values: Partial<T>) => void;
43
- /**
44
- * Custom validation function that runs only after schema validation passes.
45
- * Use this for complex validation logic that can't be expressed in the schema.
46
- * @returns Array of validation errors, or undefined if validation passes
47
- */
48
- onValidate?: (values: T) => ValidationError[] | undefined;
49
- /**
50
- * Called when the form is valid.
51
- */
52
- onValid?: (values: T, meta: {
53
- changed: FormHandler<T>['changed'];
54
- }) => void;
55
- /**
56
- * Called when the form is submitted and passes validation.
57
- */
58
- onSave?: (values: T, meta: {
59
- changed: FormHandler<T>['changed'];
60
- }) => MaybePromise<void>;
61
- }
62
- /**
63
- * Creates a hook for managing form state, including values, validation, and submission.
64
- * Deeply integrated with `@dxos/schema` for schema-based validation.
65
- */
66
- export declare const useForm: <T extends BaseObject>({ schema, initialValues, onValuesChanged, onValidate, onValid, onSave, }: FormOptions<T>) => FormHandler<T>;
67
- //# sourceMappingURL=useForm.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useForm.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useForm.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAI7C,OAAO,EAAE,KAAK,UAAU,EAAsB,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,UAAU,EAA4C,MAAM,cAAc,CAAC;AAGxG,OAAO,EAAE,KAAK,eAAe,EAAkB,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,UAAU,IAAI;IAK9C,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACnC,OAAO,EAAE,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IAGrB,UAAU,EAAE,MAAM,IAAI,CAAC;IAMvB,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,KAAK;QAAE,MAAM,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACxF,QAAQ,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,KAAK,CAAC,GAAG,SAAS,CAAC;IAC1D,aAAa,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAClF,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,KAAK,IAAI,CAAC;CAChD,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,UAAU;IAC/C;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAE9B;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAE1B;;;;OAIG;IACH,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAE/C;;;;OAIG;IAEH,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,eAAe,EAAE,GAAG,SAAS,CAAC;IAE1D;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE;QAAE,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;KAAE,KAAK,IAAI,CAAC;IAE5E;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE;QAAE,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;KAAE,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;CAC1F;AAED;;;GAGG;AACH,eAAO,MAAM,OAAO,GAAI,CAAC,SAAS,UAAU,EAAE,0EAO3C,WAAW,CAAC,CAAC,CAAC,KAAG,WAAW,CAAC,CAAC,CAsLhC,CAAC"}
@@ -1,29 +0,0 @@
1
- import { type TypeAnnotation } from '@dxos/echo/internal';
2
- import { type DXN } from '@dxos/keys';
3
- import { type Palette } from '@dxos/react-ui-types';
4
- import { type MaybePromise } from '@dxos/util';
5
- export type RefOption = {
6
- dxn: DXN;
7
- label?: string;
8
- };
9
- export type QueryRefOptions = (type: TypeAnnotation) => MaybePromise<RefOption[]>;
10
- export type QueryTag = {
11
- id: string;
12
- label: string;
13
- hue?: Palette;
14
- };
15
- type UseQueryRefOptionsProps = {
16
- refTypeInfo: TypeAnnotation | undefined;
17
- onQueryRefOptions?: QueryRefOptions;
18
- };
19
- /**
20
- * Hook to query reference options based on type information.
21
- * Used internally within forms to fetch and format reference options for reference fields.
22
- */
23
- export declare const useQueryRefOptions: ({ refTypeInfo, onQueryRefOptions }: UseQueryRefOptionsProps) => {
24
- options: QueryTag[];
25
- update: () => void;
26
- loading: boolean;
27
- };
28
- export {};
29
- //# sourceMappingURL=useQueryRefOptions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useQueryRefOptions.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useQueryRefOptions.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,MAAM,SAAS,GAAG;IAAE,GAAG,EAAE,GAAG,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AACrD,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,cAAc,KAAK,YAAY,CAAC,SAAS,EAAE,CAAC,CAAC;AAElF,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,KAAK,uBAAuB,GAAG;IAAE,WAAW,EAAE,cAAc,GAAG,SAAS,CAAC;IAAC,iBAAiB,CAAC,EAAE,eAAe,CAAA;CAAE,CAAC;AAEhH;;;GAGG;AAEH,eAAO,MAAM,kBAAkB,GAAI,oCAAoC,uBAAuB;;;;CAiC7F,CAAC"}
@@ -1,8 +0,0 @@
1
- import { type Space } from '@dxos/react-client/echo';
2
- import { type QueryRefOptions } from './useQueryRefOptions';
3
- type UseRefQueryLookupProps = {
4
- space?: Space;
5
- };
6
- export declare const useRefQueryLookupHandler: ({ space }: UseRefQueryLookupProps) => QueryRefOptions;
7
- export {};
8
- //# sourceMappingURL=useRefQueryLookupHandler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useRefQueryLookupHandler.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useRefQueryLookupHandler.ts"],"names":[],"mappings":"AAQA,OAAO,EAAU,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,KAAK,sBAAsB,GAAG;IAAE,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAEhD,eAAO,MAAM,wBAAwB,GAAI,WAAW,sBAAsB,KAAG,eAuB5E,CAAC"}
@@ -1,3 +0,0 @@
1
- import * as SchemaAST from 'effect/SchemaAST';
2
- export declare const findArrayElementType: (ast: SchemaAST.AST) => SchemaAST.AST | undefined;
3
- //# sourceMappingURL=schema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/util/schema.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAC;AAI9C,eAAO,MAAM,oBAAoB,GAAI,KAAK,SAAS,CAAC,GAAG,8BAGtD,CAAC"}
@@ -1,125 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import * as Function from 'effect/Function';
6
- import * as SchemaAST from 'effect/SchemaAST';
7
- import * as String from 'effect/String';
8
- import React, { Fragment, useCallback } from 'react';
9
-
10
- import { SimpleType, findNode, getDiscriminatedType, isDiscriminatedUnion } from '@dxos/effect';
11
- import { invariant } from '@dxos/invariant';
12
- import { IconButton, useTranslation } from '@dxos/react-ui';
13
- import { type SchemaProperty, getSchemaProperties } from '@dxos/schema';
14
-
15
- import { translationKey } from '../../translations';
16
- import { findArrayElementType } from '../../util';
17
-
18
- import { type ComponentLookup } from './Form';
19
- import { FormField, type FormFieldProps } from './FormContent';
20
- import { type FormInputStateProps, useFormValues } from './FormContext';
21
- import { type InputComponent, InputHeader } from './Input';
22
-
23
- type ArrayFieldProps = {
24
- property: SchemaProperty<any>;
25
- inputProps: FormInputStateProps;
26
- path?: (string | number)[];
27
- Custom?: Partial<Record<string, InputComponent>>;
28
- lookupComponent?: ComponentLookup;
29
- } & Pick<FormFieldProps, 'readonly'>;
30
-
31
- export const ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponent }: ArrayFieldProps) => {
32
- const { t } = useTranslation(translationKey);
33
- const { ast, name, type, title } = property;
34
- // TODO(wittjosiah): The fallback to an empty array stops the form from crashing but isn't immediately live.
35
- // It doesn't become live until another field is touched, but that's better than the whole form crashing.
36
- const values = (useFormValues(path ?? []) ?? []) as any[];
37
- invariant(Array.isArray(values), `Values at path ${path?.join('.')} must be an array.`);
38
- const label = title ?? Function.pipe(name, String.capitalize);
39
-
40
- const elementType = findArrayElementType(ast);
41
-
42
- const getDefaultObjectValue = (typeNode: SchemaAST.AST): any => {
43
- const baseNode = findNode(typeNode, isDiscriminatedUnion);
44
- const typeLiteral = baseNode ? getDiscriminatedType(baseNode, {}) : findNode(typeNode, SchemaAST.isTypeLiteral);
45
- if (!typeLiteral) {
46
- return {};
47
- }
48
-
49
- return Object.fromEntries(getSchemaProperties(typeLiteral, {}).map((prop) => [prop.name, prop.defaultValue]));
50
- };
51
-
52
- const getDefaultValue = () =>
53
- type === 'object' && elementType ? getDefaultObjectValue(elementType) : SimpleType.getDefaultValue(type);
54
-
55
- const handleAdd = useCallback(() => {
56
- inputProps.onValueChange(type, [...values, getDefaultValue()]);
57
- }, [type, elementType, inputProps, values]);
58
-
59
- const handleRemove = useCallback(
60
- (index: number) => {
61
- const newValues = values.filter((_, i) => i !== index);
62
- inputProps.onValueChange(type, newValues);
63
- },
64
- [type, inputProps, values],
65
- );
66
-
67
- if (!elementType) {
68
- return null;
69
- }
70
-
71
- return readonly && values.length < 1 ? null : (
72
- <>
73
- <InputHeader readonly label={label} />
74
- <div
75
- role='none'
76
- className={
77
- readonly
78
- ? 'flex flex-wrap gap-1 mlb-1'
79
- : values.length > 0
80
- ? 'grid gap-1 grid-cols-[1fr_min-content] mlb-1'
81
- : 'hidden'
82
- }
83
- >
84
- {values.map((_value, index) => {
85
- const field = (
86
- <FormField
87
- property={{
88
- ...property,
89
- array: false, // NOTE(ZaymonFC): This breaks arrays of arrays but ¯\_(ツ)_/¯. Ping me if you need that.
90
- ast: elementType,
91
- }}
92
- path={[...(path ?? []), index]}
93
- readonly={readonly}
94
- inline
95
- Custom={Custom}
96
- lookupComponent={lookupComponent}
97
- />
98
- );
99
- return readonly ? (
100
- field
101
- ) : (
102
- <Fragment key={index}>
103
- <div role='none'>{field}</div>
104
- <IconButton
105
- icon='ph--trash--regular'
106
- iconOnly
107
- label={t('button remove')}
108
- onClick={() => handleRemove(index)}
109
- classNames='self-center'
110
- />
111
- </Fragment>
112
- );
113
- })}
114
- </div>
115
- {!readonly && (
116
- <IconButton
117
- classNames='is-full mlb-cardSpacingBlock flex'
118
- icon='ph--plus--regular'
119
- label={t('add field')}
120
- onClick={handleAdd}
121
- />
122
- )}
123
- </>
124
- );
125
- };