@dxos/react-ui-form 0.8.4-main.f9ba587 → 0.8.4-main.fd6878d

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 (63) hide show
  1. package/dist/lib/browser/index.mjs +184 -171
  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 +184 -171
  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.stories.d.ts.map +1 -1
  8. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts +4 -4
  9. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
  10. package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts +2 -2
  11. package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts.map +1 -1
  12. package/dist/types/src/components/Form/ArrayField.d.ts.map +1 -1
  13. package/dist/types/src/components/Form/Defaults.d.ts.map +1 -1
  14. package/dist/types/src/components/Form/Form.d.ts +2 -2
  15. package/dist/types/src/components/Form/Form.d.ts.map +1 -1
  16. package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
  17. package/dist/types/src/components/Form/FormActions.d.ts.map +1 -1
  18. package/dist/types/src/components/Form/FormContent.d.ts +1 -1
  19. package/dist/types/src/components/Form/FormContent.d.ts.map +1 -1
  20. package/dist/types/src/components/Form/FormContext.d.ts +1 -1
  21. package/dist/types/src/components/Form/FormContext.d.ts.map +1 -1
  22. package/dist/types/src/components/Form/RefField.d.ts +1 -1
  23. package/dist/types/src/components/Form/RefField.d.ts.map +1 -1
  24. package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts.map +1 -1
  25. package/dist/types/src/components/Form/custom/SelectOptionsInput.stories.d.ts.map +1 -1
  26. package/dist/types/src/components/Form/factory.d.ts.map +1 -1
  27. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +2 -2
  28. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
  29. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +3 -3
  30. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
  31. package/dist/types/src/components/deprecated/Form.d.ts +3 -3
  32. package/dist/types/src/components/deprecated/Form.d.ts.map +1 -1
  33. package/dist/types/src/components/deprecated/Form.stories.d.ts.map +1 -1
  34. package/dist/types/src/hooks/useForm.d.ts +1 -1
  35. package/dist/types/src/hooks/useForm.d.ts.map +1 -1
  36. package/dist/types/src/translations.d.ts +3 -2
  37. package/dist/types/src/translations.d.ts.map +1 -1
  38. package/dist/types/tsconfig.tsbuildinfo +1 -1
  39. package/package.json +30 -29
  40. package/src/components/ControlSection/ControlSection.stories.tsx +2 -1
  41. package/src/components/FieldEditor/FieldEditor.stories.tsx +16 -13
  42. package/src/components/FieldEditor/FieldEditor.test.tsx +14 -13
  43. package/src/components/FieldEditor/FieldEditor.tsx +11 -11
  44. package/src/components/Form/ArrayField.tsx +8 -7
  45. package/src/components/Form/Defaults.tsx +2 -1
  46. package/src/components/Form/Form.stories.tsx +4 -3
  47. package/src/components/Form/Form.tsx +4 -3
  48. package/src/components/Form/FormActions.tsx +2 -1
  49. package/src/components/Form/FormContent.tsx +6 -5
  50. package/src/components/Form/FormContext.tsx +5 -5
  51. package/src/components/Form/RefField.tsx +6 -5
  52. package/src/components/Form/custom/GeoPointInput.tsx +2 -2
  53. package/src/components/Form/custom/SelectOptionsInput.stories.tsx +3 -2
  54. package/src/components/Form/custom/SelectOptionsInput.tsx +28 -29
  55. package/src/components/Form/factory.tsx +1 -1
  56. package/src/components/ViewEditor/ViewEditor.stories.tsx +19 -12
  57. package/src/components/ViewEditor/ViewEditor.test.tsx +18 -15
  58. package/src/components/ViewEditor/ViewEditor.tsx +81 -81
  59. package/src/components/deprecated/Form.stories.tsx +6 -5
  60. package/src/components/deprecated/Form.tsx +6 -6
  61. package/src/hooks/useForm.ts +5 -3
  62. package/src/hooks/useRefQueryLookupHandler.ts +1 -1
  63. package/src/translations.ts +3 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-form",
3
- "version": "0.8.4-main.f9ba587",
3
+ "version": "0.8.4-main.fd6878d",
4
4
  "description": "Data components.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -9,6 +9,7 @@
9
9
  "type": "module",
10
10
  "exports": {
11
11
  ".": {
12
+ "source": "./src/index.ts",
12
13
  "types": "./dist/types/src/index.d.ts",
13
14
  "browser": "./dist/lib/browser/index.mjs",
14
15
  "node": "./dist/lib/node-esm/index.mjs"
@@ -29,48 +30,48 @@
29
30
  "@radix-ui/react-context": "1.1.1",
30
31
  "date-fns": "^3.3.1",
31
32
  "jsonpath": "^1.1.1",
32
- "@dxos/async": "0.8.4-main.f9ba587",
33
- "@dxos/debug": "0.8.4-main.f9ba587",
34
- "@dxos/echo": "0.8.4-main.f9ba587",
35
- "@dxos/echo-db": "0.8.4-main.f9ba587",
36
- "@dxos/echo-schema": "0.8.4-main.f9ba587",
37
- "@dxos/effect": "0.8.4-main.f9ba587",
38
- "@dxos/invariant": "0.8.4-main.f9ba587",
39
- "@dxos/keys": "0.8.4-main.f9ba587",
40
- "@dxos/lit-ui": "0.8.4-main.f9ba587",
41
- "@dxos/live-object": "0.8.4-main.f9ba587",
42
- "@dxos/log": "0.8.4-main.f9ba587",
43
- "@dxos/react-client": "0.8.4-main.f9ba587",
44
- "@dxos/react-ui-list": "0.8.4-main.f9ba587",
45
- "@dxos/react-ui-stack": "0.8.4-main.f9ba587",
46
- "@dxos/react-ui-pickers": "0.8.4-main.f9ba587",
47
- "@dxos/react-ui-tag-picker": "0.8.4-main.f9ba587",
48
- "@dxos/react-ui-types": "0.8.4-main.f9ba587",
49
- "@dxos/schema": "0.8.4-main.f9ba587",
50
- "@dxos/util": "0.8.4-main.f9ba587"
33
+ "@dxos/async": "0.8.4-main.fd6878d",
34
+ "@dxos/echo": "0.8.4-main.fd6878d",
35
+ "@dxos/debug": "0.8.4-main.fd6878d",
36
+ "@dxos/echo-db": "0.8.4-main.fd6878d",
37
+ "@dxos/echo-schema": "0.8.4-main.fd6878d",
38
+ "@dxos/effect": "0.8.4-main.fd6878d",
39
+ "@dxos/lit-ui": "0.8.4-main.fd6878d",
40
+ "@dxos/invariant": "0.8.4-main.fd6878d",
41
+ "@dxos/keys": "0.8.4-main.fd6878d",
42
+ "@dxos/live-object": "0.8.4-main.fd6878d",
43
+ "@dxos/log": "0.8.4-main.fd6878d",
44
+ "@dxos/react-client": "0.8.4-main.fd6878d",
45
+ "@dxos/react-ui-list": "0.8.4-main.fd6878d",
46
+ "@dxos/react-ui-pickers": "0.8.4-main.fd6878d",
47
+ "@dxos/react-ui-tag-picker": "0.8.4-main.fd6878d",
48
+ "@dxos/react-ui-types": "0.8.4-main.fd6878d",
49
+ "@dxos/schema": "0.8.4-main.fd6878d",
50
+ "@dxos/util": "0.8.4-main.fd6878d",
51
+ "@dxos/react-ui-stack": "0.8.4-main.fd6878d"
51
52
  },
52
53
  "devDependencies": {
53
54
  "@types/jsonpath": "^0.2.4",
54
55
  "@types/react": "~18.2.0",
55
56
  "@types/react-dom": "~18.2.0",
56
- "effect": "3.16.13",
57
+ "effect": "3.17.7",
57
58
  "fast-check": "^3.19.0",
58
59
  "react": "~18.2.0",
59
60
  "react-dom": "~18.2.0",
60
61
  "vite": "5.4.7",
61
- "@dxos/echo-signals": "0.8.4-main.f9ba587",
62
- "@dxos/random": "0.8.4-main.f9ba587",
63
- "@dxos/react-ui": "0.8.4-main.f9ba587",
64
- "@dxos/react-ui-syntax-highlighter": "0.8.4-main.f9ba587",
65
- "@dxos/react-ui-theme": "0.8.4-main.f9ba587",
66
- "@dxos/storybook-utils": "0.8.4-main.f9ba587"
62
+ "@dxos/echo-signals": "0.8.4-main.fd6878d",
63
+ "@dxos/random": "0.8.4-main.fd6878d",
64
+ "@dxos/react-ui": "0.8.4-main.fd6878d",
65
+ "@dxos/react-ui-syntax-highlighter": "0.8.4-main.fd6878d",
66
+ "@dxos/storybook-utils": "0.8.4-main.fd6878d",
67
+ "@dxos/react-ui-theme": "0.8.4-main.fd6878d"
67
68
  },
68
69
  "peerDependencies": {
69
70
  "effect": "^3.13.3",
70
71
  "react": "~18.2.0",
71
72
  "react-dom": "~18.2.0",
72
- "@dxos/react-ui": "0.8.4-main.f9ba587",
73
- "@dxos/react-ui-theme": "0.8.4-main.f9ba587"
73
+ "@dxos/react-ui": "0.8.4-main.fd6878d",
74
+ "@dxos/react-ui-theme": "0.8.4-main.fd6878d"
74
75
  },
75
76
  "publishConfig": {
76
77
  "access": "public"
@@ -10,9 +10,10 @@ import React from 'react';
10
10
  import { StackItem } from '@dxos/react-ui-stack';
11
11
  import { withLayout, withTheme } from '@dxos/storybook-utils';
12
12
 
13
- import { ControlPage, ControlSection, type ControlSectionProps } from './ControlSection';
14
13
  import { translations } from '../../translations';
15
14
 
15
+ import { ControlPage, ControlSection, type ControlSectionProps } from './ControlSection';
16
+
16
17
  const meta: Meta<ControlSectionProps> = {
17
18
  title: 'ui/react-ui-form/ControlSection',
18
19
  component: ControlSection,
@@ -5,28 +5,28 @@
5
5
  import '@dxos-theme';
6
6
 
7
7
  import { type Meta, type StoryObj } from '@storybook/react-vite';
8
- import React, { useMemo, useEffect } from 'react';
8
+ import React, { useEffect, useMemo } from 'react';
9
9
 
10
10
  import { createEchoSchema } from '@dxos/live-object/testing';
11
11
  import { log } from '@dxos/log';
12
- import { ViewProjection } from '@dxos/schema';
12
+ import { ProjectionModel } from '@dxos/schema';
13
13
  import { TestSchema, testView } from '@dxos/schema/testing';
14
14
  import { withLayout, withTheme } from '@dxos/storybook-utils';
15
15
 
16
- import { FieldEditor, type FieldEditorProps } from './FieldEditor';
17
16
  import { translations } from '../../translations';
18
- import { TestLayout, TestPanel, FIELD_EDITOR_DEBUG_SYMBOL } from '../testing';
17
+ import { FIELD_EDITOR_DEBUG_SYMBOL, TestLayout, TestPanel } from '../testing';
18
+
19
+ import { FieldEditor, type FieldEditorProps } from './FieldEditor';
19
20
 
20
21
  // Type definition for debug objects exposed to tests.
21
22
  export type FieldEditorDebugObjects = {
22
23
  props: FieldEditorProps;
23
- projection: ViewProjection;
24
+ projection: ProjectionModel;
24
25
  };
25
26
 
26
27
  type StoryProps = FieldEditorProps;
27
28
 
28
29
  const DefaultStory = (props: FieldEditorProps) => {
29
- const projection = useMemo(() => new ViewProjection(createEchoSchema(TestSchema).jsonSchema, testView), []);
30
30
  const handleComplete: FieldEditorProps['onSave'] = () => {
31
31
  log.info('onClose', { props });
32
32
  };
@@ -34,20 +34,23 @@ const DefaultStory = (props: FieldEditorProps) => {
34
34
  // Expose objects on window for test access.
35
35
  useEffect(() => {
36
36
  if (typeof window !== 'undefined') {
37
- (window as any)[FIELD_EDITOR_DEBUG_SYMBOL] = { props, projection } satisfies FieldEditorDebugObjects;
37
+ (window as any)[FIELD_EDITOR_DEBUG_SYMBOL] = {
38
+ props,
39
+ projection: props.projection,
40
+ } satisfies FieldEditorDebugObjects;
38
41
  }
39
- }, [props, projection]);
42
+ }, [props, props.projection]);
40
43
 
41
44
  // NOTE(ZaymonFC): This looks awkward but it resolves an infinite parsing issue with sb.
42
45
  const json = useMemo(
43
- () => JSON.parse(JSON.stringify({ props, projection })),
44
- [JSON.stringify(props), JSON.stringify(projection)],
46
+ () => JSON.parse(JSON.stringify({ props, projection: props.projection })),
47
+ [JSON.stringify(props), JSON.stringify(props.projection)],
45
48
  );
46
49
 
47
50
  return (
48
51
  <TestLayout json={json}>
49
52
  <TestPanel>
50
- <FieldEditor {...props} projection={projection} onSave={handleComplete} />
53
+ <FieldEditor {...props} onSave={handleComplete} />
51
54
  </TestPanel>
52
55
  </TestLayout>
53
56
  );
@@ -69,8 +72,8 @@ type Story = StoryObj<StoryProps>;
69
72
 
70
73
  export const Default: Story = {
71
74
  args: {
72
- view: testView,
73
- field: testView.fields[0],
75
+ projection: new ProjectionModel(createEchoSchema(TestSchema).jsonSchema, testView.projection),
76
+ field: testView.projection.fields[0],
74
77
  },
75
78
  parameters: { controls: { disabled: true } },
76
79
  };
@@ -3,25 +3,18 @@
3
3
  //
4
4
 
5
5
  import { composeStories } from '@storybook/react';
6
- import { screen, cleanup, fireEvent, act } from '@testing-library/react';
6
+ import { act, cleanup, fireEvent, screen } from '@testing-library/react';
7
7
  import { afterEach, describe, expect, test } from 'vitest';
8
8
 
9
- import { ViewProjection } from '@dxos/schema';
9
+ import { ProjectionModel } from '@dxos/schema';
10
+
11
+ import { FIELD_EDITOR_DEBUG_SYMBOL } from '../testing';
10
12
 
11
13
  import * as stories from './FieldEditor.stories';
12
14
  import { type FieldEditorDebugObjects } from './FieldEditor.stories';
13
- import { FIELD_EDITOR_DEBUG_SYMBOL } from '../testing';
14
15
 
15
16
  const { Default } = composeStories(stories);
16
17
 
17
- const getFieldEditorDebugObjects = (): FieldEditorDebugObjects => {
18
- const debugObjects = (window as any)[FIELD_EDITOR_DEBUG_SYMBOL] as FieldEditorDebugObjects;
19
- expect(debugObjects).toBeDefined();
20
- expect(debugObjects.props).toBeInstanceOf(Object); // Props object
21
- expect(debugObjects.projection).toBeInstanceOf(ViewProjection);
22
- return debugObjects;
23
- };
24
-
25
18
  describe('FieldEditor', () => {
26
19
  afterEach(() => {
27
20
  cleanup();
@@ -33,7 +26,7 @@ describe('FieldEditor', () => {
33
26
  expect(screen.getByText('Type format')).toBeInTheDocument();
34
27
  expect(screen.getByText('String')).toBeInTheDocument();
35
28
 
36
- // Verify the initial field shows as String type
29
+ // Verify the initial field shows as String type.
37
30
  expect(screen.getByText('String')).toBeInTheDocument();
38
31
 
39
32
  fireEvent.click(screen.getByRole('combobox'));
@@ -49,9 +42,17 @@ describe('FieldEditor', () => {
49
42
  // Access the live objects directly from window using symbol.
50
43
  const debugObjects = getFieldEditorDebugObjects();
51
44
 
52
- const name = debugObjects.projection.schema.properties!.name;
45
+ const name = debugObjects.projection.baseSchema.properties!.name;
53
46
  expect(name.type).toBe('number');
54
47
  expect(name.format).toBe('number');
55
48
  expect(name.description).toBe('Full name.');
56
49
  });
57
50
  });
51
+
52
+ const getFieldEditorDebugObjects = (): FieldEditorDebugObjects => {
53
+ const debugObjects = (window as any)[FIELD_EDITOR_DEBUG_SYMBOL] as FieldEditorDebugObjects;
54
+ expect(debugObjects).toBeDefined();
55
+ expect(debugObjects.props).toBeInstanceOf(Object); // Props object
56
+ expect(debugObjects.projection).toBeInstanceOf(ProjectionModel);
57
+ return debugObjects;
58
+ };
@@ -5,26 +5,25 @@
5
5
  import React, { useCallback, useEffect, useMemo, useState } from 'react';
6
6
 
7
7
  import { type SchemaRegistry } from '@dxos/echo-db';
8
- import { FormatEnum, FormatEnums, formatToType, type EchoSchema } from '@dxos/echo-schema';
8
+ import { type EchoSchema, FormatEnum, FormatEnums, formatToType } from '@dxos/echo-schema';
9
9
  import { log } from '@dxos/log';
10
10
  import { useTranslation } from '@dxos/react-ui';
11
11
  import {
12
- getFormatSchema,
13
- getSchemaProperties,
14
- sortProperties,
15
12
  type FieldType,
13
+ type ProjectionModel,
16
14
  type PropertyType,
17
- type ViewType,
18
- type ViewProjection,
19
15
  type SchemaProperty,
16
+ getFormatSchema,
17
+ getSchemaProperties,
18
+ sortProperties,
20
19
  } from '@dxos/schema';
21
20
 
22
21
  import { translationKey } from '../../translations';
23
22
  import { Form, type FormProps, type InputComponent, SelectInput, SelectOptionInput } from '../Form';
24
23
 
25
24
  export type FieldEditorProps = {
26
- view: ViewType;
27
- projection: ViewProjection;
25
+ readonly?: boolean;
26
+ projection: ProjectionModel;
28
27
  field: FieldType;
29
28
  registry?: SchemaRegistry;
30
29
  onSave: () => void;
@@ -35,7 +34,7 @@ export type FieldEditorProps = {
35
34
  * Displays a Form representing the metadata for a given `Field` and `View`.
36
35
  */
37
36
  export const FieldEditor = ({
38
- view,
37
+ readonly,
39
38
  projection,
40
39
  field,
41
40
  registry,
@@ -112,7 +111,7 @@ export const FieldEditor = ({
112
111
 
113
112
  const handleValidate = useCallback<NonNullable<FormProps<PropertyType>['onValidate']>>(
114
113
  ({ property }) => {
115
- if (property && view.fields.find((f) => f.path === property && f.path !== field.path)) {
114
+ if (property && projection.fields.find((f) => f.path === property && f.path !== field.path)) {
116
115
  return [
117
116
  {
118
117
  path: 'property',
@@ -121,7 +120,7 @@ export const FieldEditor = ({
121
120
  ];
122
121
  }
123
122
  },
124
- [view.fields, field],
123
+ [projection.fields, field],
125
124
  );
126
125
 
127
126
  const handleSave = useCallback<NonNullable<FormProps<PropertyType>['onSave']>>(
@@ -188,6 +187,7 @@ export const FieldEditor = ({
188
187
  <Form<PropertyType>
189
188
  key={field.id}
190
189
  autoFocus
190
+ readonly={readonly}
191
191
  values={props}
192
192
  schema={fieldSchema}
193
193
  filter={propIsNotType}
@@ -6,18 +6,19 @@ import { SchemaAST, pipe } from 'effect';
6
6
  import { capitalize } from 'effect/String';
7
7
  import React, { Fragment, useCallback } from 'react';
8
8
 
9
- import { findNode, getDiscriminatedType, isDiscriminatedUnion, SimpleType } from '@dxos/effect';
9
+ import { SimpleType, findNode, getDiscriminatedType, isDiscriminatedUnion } from '@dxos/effect';
10
10
  import { invariant } from '@dxos/invariant';
11
11
  import { IconButton, useTranslation } from '@dxos/react-ui';
12
- import { getSchemaProperties, type SchemaProperty } from '@dxos/schema';
12
+ import { type SchemaProperty, getSchemaProperties } from '@dxos/schema';
13
13
 
14
- import { type ComponentLookup } from './Form';
15
- import { FormField } from './FormContent';
16
- import { useFormValues, type FormInputStateProps } from './FormContext';
17
- import { InputHeader, type InputComponent } from './Input';
18
14
  import { translationKey } from '../../translations';
19
15
  import { findArrayElementType } from '../../util';
20
16
 
17
+ import { type ComponentLookup } from './Form';
18
+ import { FormField } from './FormContent';
19
+ import { type FormInputStateProps, useFormValues } from './FormContext';
20
+ import { type InputComponent, InputHeader } from './Input';
21
+
21
22
  type ArrayFieldProps = {
22
23
  property: SchemaProperty<any>;
23
24
  readonly?: boolean;
@@ -113,7 +114,7 @@ export const ArrayField = ({ property, readonly, path, inputProps, Custom, looku
113
114
  </div>
114
115
  {!readonly && (
115
116
  <IconButton
116
- classNames='is-full mlb-1 flex'
117
+ classNames='is-full mlb-cardSpacingBlock flex'
117
118
  icon='ph--plus--regular'
118
119
  label={t('add field')}
119
120
  onClick={handleAdd}
@@ -6,9 +6,10 @@ import React, { useCallback, useEffect, useRef } from 'react';
6
6
 
7
7
  import { Input, Select, useTranslation } from '@dxos/react-ui';
8
8
 
9
- import { type InputProps, InputHeader } from './Input';
10
9
  import { translationKey } from '../../translations';
11
10
 
11
+ import { InputHeader, type InputProps } from './Input';
12
+
12
13
  export const TextInput = ({
13
14
  type,
14
15
  label,
@@ -9,17 +9,18 @@ import { Schema } from 'effect';
9
9
  import React, { useCallback, useState } from 'react';
10
10
 
11
11
  import { ContactType } from '@dxos/client/testing';
12
- import { type BaseObject, Expando, Format, getObjectDXN, Ref, type TypeAnnotation } from '@dxos/echo-schema';
12
+ import { type BaseObject, Expando, Format, Ref, type TypeAnnotation, getObjectDXN } from '@dxos/echo-schema';
13
13
  import { live } from '@dxos/live-object';
14
14
  import { withSurfaceVariantsLayout } from '@dxos/react-ui/testing';
15
15
  import { Testing } from '@dxos/schema/testing';
16
16
  import { withLayout, withTheme } from '@dxos/storybook-utils';
17
17
 
18
- import { SelectInput } from './Defaults';
19
- import { Form, type FormProps } from './Form';
20
18
  import { translations } from '../../translations';
21
19
  import { TestLayout, TestPanel } from '../testing';
22
20
 
21
+ import { SelectInput } from './Defaults';
22
+ import { Form, type FormProps } from './Form';
23
+
23
24
  const AddressSchema = Schema.Struct({
24
25
  street: Schema.optional(Schema.String.annotations({ title: 'Street' })),
25
26
  city: Schema.optional(Schema.String.annotations({ title: 'City' })),
@@ -10,11 +10,12 @@ import { type ThemedClassName } from '@dxos/react-ui';
10
10
  import { cardDialogOverflow, cardSpacing } from '@dxos/react-ui-stack';
11
11
  import { type SchemaProperty } from '@dxos/schema';
12
12
 
13
+ import { type FormOptions } from '../../hooks';
14
+
13
15
  import { FormActions, type FormOuterSpacing } from './FormActions';
14
16
  import { FormFields, type FormFieldsProps } from './FormContent';
15
17
  import { FormProvider } from './FormContext';
16
- import { type InputProps, type InputComponent } from './Input';
17
- import { type FormOptions } from '../../hooks';
18
+ import { type InputComponent, type InputProps } from './Input';
18
19
 
19
20
  export type PropsFilter<T extends BaseObject> = (props: SchemaProperty<T>[]) => SchemaProperty<T>[];
20
21
 
@@ -99,7 +100,7 @@ export const Form = <T extends BaseObject>({
99
100
  readonly={readonly}
100
101
  schema={schema}
101
102
  />
102
- {(onCancel || onSave) && !autoSave && (
103
+ {(onCancel || onSave) && !autoSave && !readonly && (
103
104
  <FormActions readonly={readonly} onCancel={onCancel} outerSpacing={outerSpacing} />
104
105
  )}
105
106
  </div>
@@ -8,9 +8,10 @@ import { IconButton, useTranslation } from '@dxos/react-ui';
8
8
  import { cardSpacing } from '@dxos/react-ui-stack';
9
9
  import { mx } from '@dxos/react-ui-theme';
10
10
 
11
- import { useFormContext } from './FormContext';
12
11
  import { translationKey } from '../../translations';
13
12
 
13
+ import { useFormContext } from './FormContext';
14
+
14
15
  export type FormOuterSpacing = boolean | 'blockStart-0' | 'scroll-fields';
15
16
 
16
17
  export type FormActionsProps = {
@@ -9,18 +9,19 @@ import React, { forwardRef, useMemo } from 'react';
9
9
  import { createJsonPath, findNode, getDiscriminatedType, isDiscriminatedUnion } from '@dxos/effect';
10
10
  import { type ThemedClassName } from '@dxos/react-ui';
11
11
  import { mx } from '@dxos/react-ui-theme';
12
- import { getSchemaProperties, type SchemaProperty } from '@dxos/schema';
12
+ import { type SchemaProperty, getSchemaProperties } from '@dxos/schema';
13
13
  import { isNotFalsy } from '@dxos/util';
14
14
 
15
+ import { type QueryRefOptions } from '../../hooks';
16
+ import { getRefProps } from '../../util';
17
+
15
18
  import { ArrayField } from './ArrayField';
16
19
  import { SelectInput } from './Defaults';
20
+ import { getInputComponent } from './factory';
17
21
  import { type ComponentLookup } from './Form';
18
- import { useInputProps, useFormValues } from './FormContext';
22
+ import { useFormValues, useInputProps } from './FormContext';
19
23
  import { type InputComponent } from './Input';
20
24
  import { RefField } from './RefField';
21
- import { getInputComponent } from './factory';
22
- import { type QueryRefOptions } from '../../hooks';
23
- import { getRefProps } from '../../util';
24
25
 
25
26
  export type FormFieldProps = {
26
27
  property: SchemaProperty<any>;
@@ -3,19 +3,19 @@
3
3
  //
4
4
 
5
5
  import React, {
6
- createContext,
6
+ type FocusEvent,
7
+ type PropsWithChildren,
7
8
  type RefObject,
9
+ createContext,
10
+ useCallback,
8
11
  useContext,
9
12
  useEffect,
10
13
  useMemo,
11
- type FocusEvent,
12
- type PropsWithChildren,
13
- useCallback,
14
14
  } from 'react';
15
15
 
16
16
  import { raise } from '@dxos/debug';
17
17
  import { type BaseObject, getValue } from '@dxos/echo-schema';
18
- import { createJsonPath, type SimpleType } from '@dxos/effect';
18
+ import { type SimpleType, createJsonPath } from '@dxos/effect';
19
19
 
20
20
  import { type FormHandler, type FormOptions, useForm } from '../../hooks';
21
21
 
@@ -3,28 +3,29 @@
3
3
  //
4
4
 
5
5
  import { type SchemaAST } from 'effect';
6
- import React, { useCallback, useMemo, type FocusEvent } from 'react';
6
+ import React, { type FocusEvent, useCallback, useMemo } from 'react';
7
7
 
8
8
  import {
9
9
  Expando,
10
- getTypeAnnotation,
11
10
  Ref,
12
11
  ReferenceAnnotationId,
13
12
  type ReferenceAnnotationValue,
13
+ getTypeAnnotation,
14
14
  } from '@dxos/echo-schema';
15
15
  import { findAnnotation } from '@dxos/effect';
16
16
  import { DXN } from '@dxos/keys';
17
17
  import { DxRefTag } from '@dxos/lit-ui/react';
18
18
  import { Input, useTranslation } from '@dxos/react-ui';
19
- import { TagPicker, type TagPickerMode, type TagPickerItemData } from '@dxos/react-ui-tag-picker';
19
+ import { TagPicker, type TagPickerItemData, type TagPickerMode } from '@dxos/react-ui-tag-picker';
20
20
  import { descriptionText, mx } from '@dxos/react-ui-theme';
21
21
  import { isNonNullable } from '@dxos/util';
22
22
 
23
- import { TextInput } from './Defaults';
24
- import { InputHeader, type InputProps } from './Input';
25
23
  import { type QueryRefOptions, useQueryRefOptions } from '../../hooks';
26
24
  import { translationKey } from '../../translations';
27
25
 
26
+ import { TextInput } from './Defaults';
27
+ import { InputHeader, type InputProps } from './Input';
28
+
28
29
  type RefFieldProps = InputProps & {
29
30
  ast?: SchemaAST.AST;
30
31
  array?: boolean;
@@ -2,9 +2,9 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import React, { useCallback, useState, useEffect, useMemo, type ChangeEvent } from 'react';
5
+ import React, { type ChangeEvent, useCallback, useEffect, useMemo, useState } from 'react';
6
6
 
7
- import { type GeoPoint, GeoLocation } from '@dxos/echo-schema';
7
+ import { GeoLocation, type GeoPoint } from '@dxos/echo-schema';
8
8
  import { Input, useTranslation } from '@dxos/react-ui';
9
9
  import { safeParseFloat } from '@dxos/util';
10
10
 
@@ -8,14 +8,15 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';
8
8
  import { Schema } from 'effect';
9
9
  import React, { useState } from 'react';
10
10
 
11
- import { SelectOptionSchema, type SelectOption } from '@dxos/echo-schema';
11
+ import { type SelectOption, SelectOptionSchema } from '@dxos/echo-schema';
12
12
  import { withLayout, withTheme } from '@dxos/storybook-utils';
13
13
 
14
- import { SelectOptionInput } from './SelectOptionsInput';
15
14
  import { translations } from '../../../translations';
16
15
  import { TestLayout, TestPanel } from '../../testing';
17
16
  import { Form } from '../Form';
18
17
 
18
+ import { SelectOptionInput } from './SelectOptionsInput';
19
+
19
20
  const schema = Schema.Struct({
20
21
  options: Schema.Array(SelectOptionSchema).pipe(Schema.mutable),
21
22
  }).pipe(Schema.mutable);