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

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 (82) hide show
  1. package/README.md +0 -1
  2. package/dist/lib/browser/index.mjs +538 -458
  3. package/dist/lib/browser/index.mjs.map +4 -4
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/node-esm/index.mjs +538 -458
  6. package/dist/lib/node-esm/index.mjs.map +4 -4
  7. package/dist/lib/node-esm/meta.json +1 -1
  8. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts +3 -3
  9. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
  10. package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts.map +1 -1
  11. package/dist/types/src/components/Form/Form.d.ts +13 -13
  12. package/dist/types/src/components/Form/Form.d.ts.map +1 -1
  13. package/dist/types/src/components/Form/Form.stories.d.ts +3 -3
  14. package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
  15. package/dist/types/src/components/Form/FormField.d.ts.map +1 -1
  16. package/dist/types/src/components/Form/FormFieldComponent.d.ts +0 -1
  17. package/dist/types/src/components/Form/FormFieldComponent.d.ts.map +1 -1
  18. package/dist/types/src/components/Form/FormFieldComponent.stories.d.ts +2 -2
  19. package/dist/types/src/components/Form/FormFieldComponent.stories.d.ts.map +1 -1
  20. package/dist/types/src/components/Form/FormFieldSet.d.ts +9 -10
  21. package/dist/types/src/components/Form/FormFieldSet.d.ts.map +1 -1
  22. package/dist/types/src/components/Form/fields/ArrayField.d.ts.map +1 -1
  23. package/dist/types/src/components/Form/fields/RefField.d.ts +6 -4
  24. package/dist/types/src/components/Form/fields/RefField.d.ts.map +1 -1
  25. package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts.map +1 -1
  26. package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts.map +1 -1
  27. package/dist/types/src/components/Settings/Settings.d.ts +56 -0
  28. package/dist/types/src/components/Settings/Settings.d.ts.map +1 -0
  29. package/dist/types/src/components/{ControlSection/ControlSection.stories.d.ts → Settings/Settings.stories.d.ts} +2 -8
  30. package/dist/types/src/components/Settings/Settings.stories.d.ts.map +1 -0
  31. package/dist/types/src/components/Settings/index.d.ts +2 -0
  32. package/dist/types/src/components/Settings/index.d.ts.map +1 -0
  33. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +5 -5
  34. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
  35. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +2 -1
  36. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
  37. package/dist/types/src/components/index.d.ts +1 -1
  38. package/dist/types/src/components/index.d.ts.map +1 -1
  39. package/dist/types/src/components/testing.d.ts.map +1 -1
  40. package/dist/types/src/hooks/useFormHandler.d.ts.map +1 -1
  41. package/dist/types/src/util/index.d.ts +0 -1
  42. package/dist/types/src/util/index.d.ts.map +1 -1
  43. package/dist/types/tsconfig.tsbuildinfo +1 -1
  44. package/package.json +35 -37
  45. package/src/components/FieldEditor/FieldEditor.stories.tsx +4 -6
  46. package/src/components/FieldEditor/FieldEditor.tsx +2 -3
  47. package/src/components/Form/Form.stories.tsx +8 -7
  48. package/src/components/Form/Form.tsx +82 -55
  49. package/src/components/Form/FormField.tsx +12 -4
  50. package/src/components/Form/FormFieldComponent.stories.tsx +5 -5
  51. package/src/components/Form/FormFieldComponent.tsx +17 -20
  52. package/src/components/Form/FormFieldSet.tsx +106 -104
  53. package/src/components/Form/fields/ArrayField.tsx +6 -8
  54. package/src/components/Form/fields/MarkdownField.tsx +1 -1
  55. package/src/components/Form/fields/RefField.tsx +28 -15
  56. package/src/components/Form/fields/SelectField.tsx +1 -1
  57. package/src/components/Form/fields/SelectOptionField.stories.tsx +2 -2
  58. package/src/components/Form/fields/SelectOptionField.tsx +4 -4
  59. package/src/components/ObjectPicker/ObjectPicker.stories.tsx +9 -13
  60. package/src/components/Settings/Settings.stories.tsx +56 -0
  61. package/src/components/Settings/Settings.tsx +230 -0
  62. package/src/components/{ControlSection → Settings}/index.ts +1 -1
  63. package/src/components/ViewEditor/ViewEditor.stories.tsx +14 -12
  64. package/src/components/ViewEditor/ViewEditor.test.tsx +3 -6
  65. package/src/components/ViewEditor/ViewEditor.tsx +92 -63
  66. package/src/components/index.ts +1 -1
  67. package/src/components/testing.tsx +9 -6
  68. package/src/hooks/useFormHandler.ts +42 -24
  69. package/src/util/index.ts +0 -1
  70. package/dist/types/src/components/ControlSection/ControlSection.d.ts +0 -23
  71. package/dist/types/src/components/ControlSection/ControlSection.d.ts.map +0 -1
  72. package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts.map +0 -1
  73. package/dist/types/src/components/ControlSection/index.d.ts +0 -2
  74. package/dist/types/src/components/ControlSection/index.d.ts.map +0 -1
  75. package/dist/types/src/components/Form/Form-old.stories.d.ts +0 -131
  76. package/dist/types/src/components/Form/Form-old.stories.d.ts.map +0 -1
  77. package/dist/types/src/util/echo.d.ts +0 -6
  78. package/dist/types/src/util/echo.d.ts.map +0 -1
  79. package/src/components/ControlSection/ControlSection.stories.tsx +0 -38
  80. package/src/components/ControlSection/ControlSection.tsx +0 -153
  81. package/src/components/Form/Form-old.stories.tsx +0 -314
  82. package/src/util/echo.ts +0 -25
@@ -0,0 +1,230 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React, { type PropsWithChildren } from 'react';
6
+
7
+ import {
8
+ Button,
9
+ type ButtonProps,
10
+ Input,
11
+ type Label,
12
+ ScrollArea,
13
+ type ThemedClassName,
14
+ toLocalizedString,
15
+ useTranslation,
16
+ } from '@dxos/react-ui';
17
+ import { mx } from '@dxos/ui-theme';
18
+
19
+ import { translationKey } from '../../translations';
20
+
21
+ const SETTINGS_ROOT_NAME = 'Settings.Root';
22
+ const SETTINGS_SECTION_NAME = 'Settings.Section';
23
+ const SETTINGS_SECTION_HEADING_NAME = 'Settings.SectionHeading';
24
+ const SETTINGS_GROUP_NAME = 'Settings.Group';
25
+ const SETTINGS_GROUP_BUTTON_NAME = 'Settings.GroupButton';
26
+ const SETTINGS_CONTAINER_NAME = 'Settings.Container';
27
+ const SETTINGS_FRAME_NAME = 'Settings.Frame';
28
+ const SETTINGS_FRAME_ITEM_NAME = 'Settings.FrameItem';
29
+ const SETTINGS_ITEM_NAME = 'Settings.Item';
30
+ const SETTINGS_ITEM_INPUT_NAME = 'Settings.ItemInput';
31
+
32
+ const styles = {
33
+ title: 'pb-trim-md text-base-surface-text text-lg',
34
+ description: 'text-base text-description',
35
+ grid: 'grid grid-cols-1 md:grid-cols-[1fr_1fr] gap-x-trim-lg',
36
+ };
37
+
38
+ //
39
+ // Root
40
+ //
41
+
42
+ type SettingsRootProps = PropsWithChildren;
43
+
44
+ const SettingsRoot = ({ children }: SettingsRootProps) => {
45
+ return (
46
+ <ScrollArea.Root className='dx-document' orientation='vertical' margin>
47
+ <ScrollArea.Viewport classNames='p-trim-md'>{children}</ScrollArea.Viewport>
48
+ </ScrollArea.Root>
49
+ );
50
+ };
51
+
52
+ SettingsRoot.displayName = SETTINGS_ROOT_NAME;
53
+
54
+ //
55
+ // Section
56
+ //
57
+
58
+ type SettingsSectionProps = PropsWithChildren<{
59
+ title: Label;
60
+ description?: Label;
61
+ }>;
62
+
63
+ const SettingsSection = ({ title, description, children }: SettingsSectionProps) => {
64
+ return (
65
+ <>
66
+ <SettingsSectionHeading title={title} description={description} />
67
+ <div className='w-full pt-trim-md space-y-trim-md'>{children}</div>
68
+ </>
69
+ );
70
+ };
71
+
72
+ SettingsSection.displayName = SETTINGS_SECTION_NAME;
73
+
74
+ //
75
+ // Section Heading
76
+ //
77
+
78
+ const SettingsSectionHeading = ({ title, description }: Omit<SettingsSectionProps, 'children'>) => {
79
+ const { t } = useTranslation(translationKey);
80
+ return (
81
+ <>
82
+ <h2 className='px-trim-md mt-trim-md mb-trim-md text-xl'>{toLocalizedString(title, t)}</h2>
83
+ {description && <p className='px-trim-md my-trim-md text-description'>{toLocalizedString(description, t)}</p>}
84
+ </>
85
+ );
86
+ };
87
+
88
+ SettingsSectionHeading.displayName = SETTINGS_SECTION_HEADING_NAME;
89
+
90
+ //
91
+ // Group Button
92
+ //
93
+
94
+ const SettingsGroupButton = ({ classNames, ...props }: ButtonProps) => {
95
+ return <Button {...props} classNames={['md:col-span-2', classNames]} />;
96
+ };
97
+
98
+ SettingsGroupButton.displayName = SETTINGS_GROUP_BUTTON_NAME;
99
+
100
+ //
101
+ // Group
102
+ //
103
+
104
+ type SettingsGroupProps = ThemedClassName<PropsWithChildren>;
105
+
106
+ const SettingsGroup = ({ children, classNames }: SettingsGroupProps) => (
107
+ <div role='none' className={mx('group space-y-trim-md', classNames)}>
108
+ {children}
109
+ </div>
110
+ );
111
+
112
+ SettingsGroup.displayName = SETTINGS_GROUP_NAME;
113
+
114
+ //
115
+ // Frame
116
+ //
117
+
118
+ const SettingsFrame = ({ children }: SettingsGroupProps) => (
119
+ <div role='none' className='p-trim-md border border-separator rounded-md'>
120
+ {children}
121
+ </div>
122
+ );
123
+
124
+ SettingsFrame.displayName = SETTINGS_FRAME_NAME;
125
+
126
+ //
127
+ // Frame Item
128
+ //
129
+
130
+ const SettingsFrameItem = ({ title, description, children }: SettingsItemProps) => {
131
+ const { t } = useTranslation(translationKey);
132
+
133
+ return (
134
+ <div role='group' className='min-w-0'>
135
+ <h3 className='text-lg mb-2'>{toLocalizedString(title, t)}</h3>
136
+ {description && <p className='my-trim-sm md:mb-0 text-description'>{toLocalizedString(description, t)}</p>}
137
+ {children}
138
+ </div>
139
+ );
140
+ };
141
+
142
+ SettingsFrameItem.displayName = SETTINGS_FRAME_ITEM_NAME;
143
+
144
+ //
145
+ // Container
146
+ //
147
+
148
+ const SettingsContainer = ({ classNames, children }: ThemedClassName<PropsWithChildren>) => {
149
+ return (
150
+ <div
151
+ role='none'
152
+ className={mx([
153
+ 'dx-document',
154
+ '*:first:mt-0! *:last:mb-0! px-trim-md py-trim-md',
155
+ 'border border-separator rounded-md',
156
+ classNames,
157
+ ])}
158
+ >
159
+ {children}
160
+ </div>
161
+ );
162
+ };
163
+
164
+ SettingsContainer.displayName = SETTINGS_CONTAINER_NAME;
165
+
166
+ //
167
+ // Item
168
+ //
169
+
170
+ type SettingsItemProps = PropsWithChildren<{
171
+ title: Label;
172
+ description?: Label;
173
+ }>;
174
+
175
+ const SettingsItem = ({ title, description = '', children }: SettingsItemProps) => {
176
+ const { t } = useTranslation(translationKey);
177
+
178
+ return (
179
+ <SettingsContainer classNames={styles.grid}>
180
+ <h3 className={mx(styles.title, 'md:col-span-2')}>{toLocalizedString(title, t)}</h3>
181
+ <p className={styles.description}>{toLocalizedString(description, t)}</p>
182
+ <div role='none' className='overflow-hidden text-end py-1'>
183
+ {children}
184
+ </div>
185
+ </SettingsContainer>
186
+ );
187
+ };
188
+
189
+ SettingsItem.displayName = SETTINGS_ITEM_NAME;
190
+
191
+ //
192
+ // Item Input
193
+ //
194
+
195
+ const SettingsItemInput = ({ title, description = '', children }: SettingsItemProps) => {
196
+ const { t } = useTranslation(translationKey);
197
+
198
+ return (
199
+ <Input.Root>
200
+ <SettingsContainer classNames={styles.grid}>
201
+ <Input.Label classNames={mx(styles.title, 'md:col-span-2')}>{toLocalizedString(title, t)}</Input.Label>
202
+ <Input.DescriptionAndValidation>
203
+ <Input.Description classNames={styles.description}>{toLocalizedString(description, t)}</Input.Description>
204
+ </Input.DescriptionAndValidation>
205
+ <div role='none' className='text-end py-1'>
206
+ {children}
207
+ </div>
208
+ </SettingsContainer>
209
+ </Input.Root>
210
+ );
211
+ };
212
+
213
+ SettingsItemInput.displayName = SETTINGS_ITEM_INPUT_NAME;
214
+
215
+ //
216
+ // Settings
217
+ //
218
+
219
+ export const Settings = {
220
+ Root: SettingsRoot,
221
+ Section: SettingsSection,
222
+ SectionHeading: SettingsSectionHeading,
223
+ Group: SettingsGroup,
224
+ GroupButton: SettingsGroupButton,
225
+ Container: SettingsContainer,
226
+ Frame: SettingsFrame,
227
+ FrameItem: SettingsFrameItem,
228
+ Item: SettingsItem,
229
+ ItemInput: SettingsItemInput,
230
+ };
@@ -2,4 +2,4 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- export * from './ControlSection';
5
+ export * from './Settings';
@@ -6,14 +6,15 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';
6
6
  import * as Schema from 'effect/Schema';
7
7
  import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
8
8
 
9
- import { DXN, Filter, Obj, Query, type QueryAST, Tag, Type } from '@dxos/echo';
9
+ import { DXN, Filter, JsonSchema, Obj, Query, type QueryAST, Tag, Type } from '@dxos/echo';
10
+ import { type View } from '@dxos/echo';
10
11
  import { type EchoSchema, Format, type Mutable } from '@dxos/echo/internal';
11
12
  import { useQuery } from '@dxos/react-client/echo';
12
13
  import { useClientStory, withClientProvider } from '@dxos/react-client/testing';
13
14
  import { useAsyncEffect } from '@dxos/react-ui';
14
- import { withTheme } from '@dxos/react-ui/testing';
15
- import { type ProjectionModel, View, getTypenameFromQuery } from '@dxos/schema';
16
- import { Employer, Organization, Person, Project } from '@dxos/types';
15
+ import { withLayout, withTheme } from '@dxos/react-ui/testing';
16
+ import { type ProjectionModel, ViewModel, getTypenameFromQuery } from '@dxos/schema';
17
+ import { Employer, Organization, Person, Pipeline } from '@dxos/types';
17
18
 
18
19
  import { translations } from '../../translations';
19
20
  import { TestLayout, VIEW_EDITOR_DEBUG_SYMBOL } from '../testing';
@@ -24,7 +25,7 @@ const types = [
24
25
  // TODO(burdon): Get label from annotation.
25
26
  { value: Organization.Organization.typename, label: 'Organization' },
26
27
  { value: Person.Person.typename, label: 'Person' },
27
- { value: Project.Project.typename, label: 'Project' },
28
+ { value: Pipeline.Pipeline.typename, label: 'Project' },
28
29
  { value: Employer.Employer.typename, label: 'Employer' },
29
30
  ];
30
31
 
@@ -53,7 +54,7 @@ const DefaultStory = (props: StoryProps) => {
53
54
  salary: Format.Currency(),
54
55
  }).pipe(
55
56
  Type.object({
56
- typename: 'example.com/type/Test',
57
+ typename: 'com.example.type.test',
57
58
  version: '0.1.0',
58
59
  }),
59
60
  );
@@ -64,16 +65,16 @@ const DefaultStory = (props: StoryProps) => {
64
65
  completed: Schema.Boolean,
65
66
  }).pipe(
66
67
  Type.object({
67
- typename: 'example.com/type/Alternate',
68
+ typename: 'com.example.type.alternate',
68
69
  version: '0.1.0',
69
70
  }),
70
71
  );
71
72
 
72
73
  const [testSchema] = await space.db.schemaRegistry.register([TestSchema, AlternateSchema]);
73
- const view = View.make({
74
+ const view = ViewModel.make({
74
75
  name: 'Test',
75
76
  query: Query.select(Filter.type(TestSchema)),
76
- jsonSchema: Type.toJsonSchema(TestSchema),
77
+ jsonSchema: JsonSchema.toJsonSchema(TestSchema),
77
78
  });
78
79
 
79
80
  setSchema(testSchema);
@@ -89,7 +90,7 @@ const DefaultStory = (props: StoryProps) => {
89
90
 
90
91
  if (props.mode === 'tag') {
91
92
  const queue = target && DXN.tryParse(target) ? target : undefined;
92
- const query = queue ? Query.fromAst(newQuery).options({ queues: [queue] }) : Query.fromAst(newQuery);
93
+ const query = queue ? Query.fromAst(newQuery).from({ queues: [queue] }) : Query.fromAst(newQuery);
93
94
  Obj.change(view, (v) => {
94
95
  v.query.ast = query.ast as Mutable<typeof query.ast>;
95
96
  });
@@ -100,7 +101,7 @@ const DefaultStory = (props: StoryProps) => {
100
101
  return;
101
102
  }
102
103
 
103
- const newView = View.make({
104
+ const newView = ViewModel.make({
104
105
  query,
105
106
  jsonSchema: newSchema.jsonSchema,
106
107
  });
@@ -175,7 +176,8 @@ const meta = {
175
176
  space.db.add(Tag.make({ label: 'New' }));
176
177
  },
177
178
  }),
178
- withTheme,
179
+ withTheme(),
180
+ withLayout({ layout: 'fullscreen' }),
179
181
  ],
180
182
  parameters: {
181
183
  layout: 'fullscreen',
@@ -6,8 +6,9 @@ import { composeStories } from '@storybook/react';
6
6
  import { cleanup, fireEvent, screen, waitFor } from '@testing-library/react';
7
7
  import { afterEach, describe, expect, test } from 'vitest';
8
8
 
9
+ import { View } from '@dxos/echo';
9
10
  import { EchoSchema, isInstanceOf } from '@dxos/echo/internal';
10
- import { ProjectionModel, View } from '@dxos/schema';
11
+ import { ProjectionModel } from '@dxos/schema';
11
12
 
12
13
  import { VIEW_EDITOR_DEBUG_SYMBOL } from '../testing';
13
14
 
@@ -89,14 +90,10 @@ describe('ViewEditor', () => {
89
90
  await Default.run();
90
91
  await waitForViewEditor();
91
92
 
92
- // Click the add property button.
93
+ // Click the add property button. The new field is auto-expanded by handleAdd.
93
94
  const addButton = screen.getByText('Add property');
94
95
  fireEvent.click(addButton);
95
96
 
96
- // Open the last field.
97
- const buttons = screen.getAllByTestId('field.toggle');
98
- fireEvent.click(buttons.at(-1)!);
99
-
100
97
  // Fill out the property field.
101
98
  const fieldInput = screen.getByPlaceholderText('Property name');
102
99
  fireEvent.change(fieldInput, { target: { value: 'added_property' } });
@@ -9,19 +9,18 @@ import * as Option from 'effect/Option';
9
9
  import * as Schema from 'effect/Schema';
10
10
  import React, { forwardRef, useCallback, useContext, useImperativeHandle, useMemo, useState } from 'react';
11
11
 
12
- import { Filter, Format, Obj, Query, QueryAST, type SchemaRegistry } from '@dxos/echo';
12
+ import { Entity, Feed, Filter, Format, Obj, Query, QueryAST, Ref, type SchemaRegistry } from '@dxos/echo';
13
+ import { View } from '@dxos/echo';
13
14
  import { EchoSchema, type JsonProp, isMutable, toJsonSchema } from '@dxos/echo/internal';
14
15
  import { invariant } from '@dxos/invariant';
15
- import { useObject } from '@dxos/react-client/echo';
16
- import { Callout, IconButton, Input, type ThemedClassName, useTranslation } from '@dxos/react-ui';
16
+ import { useObject, useQuery } from '@dxos/react-client/echo';
17
+ import { IconButton, Input, Message, type ThemedClassName, useTranslation } from '@dxos/react-ui';
17
18
  import { QueryForm, type QueryFormProps } from '@dxos/react-ui-components';
18
19
  import { List } from '@dxos/react-ui-list';
19
20
  import {
20
- FieldSchema,
21
- type FieldType,
21
+ ParentLabelAnnotation,
22
22
  ProjectionModel,
23
23
  VIEW_FIELD_LIMIT,
24
- type View,
25
24
  createEchoChangeCallback,
26
25
  getTypenameFromQuery,
27
26
  } from '@dxos/schema';
@@ -35,22 +34,20 @@ import {
35
34
  type FormFieldComponentProps,
36
35
  FormFieldLabel,
37
36
  type FormFieldMap,
37
+ type FormRootProps,
38
38
  } from '../Form';
39
39
 
40
- const listGrid = 'grid grid-cols-[min-content_1fr_min-content_min-content_min-content]';
41
- const listItemGrid = 'grid grid-cols-subgrid col-span-5';
42
-
43
40
  export type ViewEditorProps = ThemedClassName<
44
41
  {
45
42
  schema: Schema.Schema.AnyNoContext;
46
43
  view: View.View;
47
44
  mode?: 'schema' | 'tag';
48
45
  registry?: SchemaRegistry.SchemaRegistry;
49
- readonly?: boolean;
50
46
  showHeading?: boolean;
51
47
  onQueryChanged?: (query: QueryAST.Query, target?: string) => void;
52
48
  onDelete?: (fieldId: string) => void;
53
- } & Pick<QueryFormProps, 'types' | 'tags'>
49
+ } & Pick<QueryFormProps, 'types' | 'tags'> &
50
+ Pick<FormRootProps<any>, 'readonly' | 'db'>
54
51
  >;
55
52
 
56
53
  /**
@@ -64,6 +61,7 @@ export const ViewEditor = forwardRef<ProjectionModel, ViewEditorProps>(
64
61
  view,
65
62
  mode = 'schema',
66
63
  registry,
64
+ db,
67
65
  readonly,
68
66
  showHeading = false,
69
67
  types,
@@ -96,18 +94,31 @@ export const ViewEditor = forwardRef<ProjectionModel, ViewEditorProps>(
96
94
  }, [atomRegistry, schema, view]);
97
95
 
98
96
  useImperativeHandle(forwardedRef, () => projectionModel, [projectionModel]);
99
- const [expandedField, setExpandedField] = useState<FieldType['id']>();
100
97
 
101
98
  const queueTarget = Match.value(view.query.ast).pipe(
102
- Match.when({ type: 'options' }, ({ options }) => {
103
- return Option.fromNullable(options.queues).pipe(
99
+ Match.when({ type: 'from' }, ({ from }) => {
100
+ if (from._tag !== 'scope') {
101
+ return undefined;
102
+ }
103
+ return Option.fromNullable(from.scope.queues).pipe(
104
104
  Option.flatMap((queues) => Array.head(queues)),
105
+ Option.map(String),
105
106
  Option.getOrUndefined,
106
107
  );
107
108
  }),
108
109
  Match.orElse(() => undefined),
109
110
  );
110
111
 
112
+ const feeds = useQuery(db, Filter.type(Feed.Feed));
113
+
114
+ const targetRef = useMemo(() => {
115
+ if (!queueTarget) {
116
+ return undefined;
117
+ }
118
+ const feed = feeds.find((feed) => Feed.getQueueDxn(feed)?.toString() === queueTarget);
119
+ return feed ? Ref.fromDXN(Entity.getDXN(feed)) : undefined;
120
+ }, [queueTarget, feeds]);
121
+
111
122
  const viewSchema = useMemo(() => {
112
123
  const base = Schema.Struct({
113
124
  query:
@@ -119,7 +130,12 @@ export const ViewEditor = forwardRef<ProjectionModel, ViewEditorProps>(
119
130
  if (mode === 'tag') {
120
131
  return Schema.Struct({
121
132
  ...base.fields,
122
- target: Schema.optional(Schema.String.annotations({ title: 'Target Queue' })),
133
+ // TODO(wittjosiah): Replace Type.Feed with Dataset.Dataset when Ref.Ref supports unions.
134
+ target: Ref.Ref(Feed.Feed).pipe(
135
+ Schema.annotations({ title: 'Target Feed' }),
136
+ ParentLabelAnnotation.set(true),
137
+ Schema.optional,
138
+ ),
123
139
  }).pipe(Schema.mutable);
124
140
  }
125
141
 
@@ -131,9 +147,9 @@ export const ViewEditor = forwardRef<ProjectionModel, ViewEditorProps>(
131
147
  const viewValues = useMemo(
132
148
  () => ({
133
149
  query: mode === 'schema' ? getTypenameFromQuery(view.query.ast) : view.query.ast,
134
- target: queueTarget,
150
+ target: targetRef,
135
151
  }),
136
- [mode, view.query.ast, queueTarget],
152
+ [mode, view.query.ast, targetRef],
137
153
  );
138
154
 
139
155
  const fieldMap = useMemo<FormFieldMap | undefined>(
@@ -141,46 +157,48 @@ export const ViewEditor = forwardRef<ProjectionModel, ViewEditorProps>(
141
157
  [mode, types, tags],
142
158
  );
143
159
 
144
- // TODO(burdon): Check if mutable.
145
- const handleAdd = useCallback(() => {
146
- invariant(!readonly);
147
- const field = projectionModel.createFieldProjection();
148
- setExpandedField(field.id);
149
- }, [projectionModel, readonly]);
150
-
151
160
  const handleUpdate = useCallback(
152
161
  (values: any) => {
153
- requestAnimationFrame(() => {
154
- const query = mode === 'schema' ? Query.select(Filter.typename(values.query)).ast : values.query;
155
- onQueryChanged?.(query, values.target);
156
- });
162
+ const targetValue = values.target;
163
+ let queueDxn: string | undefined;
164
+
165
+ if (Ref.isRef(targetValue)) {
166
+ const feedDxn = targetValue.dxn.toString();
167
+ const feed = feeds.find((feed) => Obj.getDXN(feed).toString() === feedDxn);
168
+ if (feed) {
169
+ queueDxn = Feed.getQueueDxn(feed)?.toString();
170
+ }
171
+ }
172
+
173
+ // TODO(wittjosiah): Deep-clone the AST to plain JS or ECHO proxy arrays become objects with numeric keys.
174
+ const query =
175
+ mode === 'schema'
176
+ ? Query.select(Filter.typename(values.query)).ast
177
+ : JSON.parse(JSON.stringify(values.query));
178
+ onQueryChanged?.(query, queueDxn);
157
179
  },
158
- [onQueryChanged, view, queueTarget, mode],
180
+ [onQueryChanged, mode, feeds],
159
181
  );
160
182
 
161
183
  const handleDelete = useCallback(
162
184
  (fieldId: string) => {
163
185
  invariant(!readonly);
164
- if (fieldId === expandedField) {
165
- setExpandedField(undefined);
166
- }
167
-
168
186
  onDelete?.(fieldId);
169
187
  },
170
- [expandedField, onDelete, readonly],
188
+ [onDelete, readonly],
171
189
  );
172
190
 
173
191
  return (
174
192
  <div role='none' className={mx(classNames)}>
175
193
  {/* If readonly is set, then the callout is not needed. */}
176
194
  {schemaReadonly && !readonly && (
177
- <Callout.Root valence='info' classNames='mlb-cardSpacingBlock'>
178
- <Callout.Title>{t('system schema description')}</Callout.Title>
179
- </Callout.Root>
195
+ <Message.Root valence='info' classNames='my-form-padding'>
196
+ <Message.Title>{t('system schema description')}</Message.Title>
197
+ </Message.Root>
180
198
  )}
181
199
 
182
200
  {/* TODO(burdon): Is the form read-only or just the schema? */}
183
- <Form.Root schema={viewSchema} values={viewValues} fieldMap={fieldMap} autoSave onSave={handleUpdate}>
201
+ <Form.Root schema={viewSchema} values={viewValues} fieldMap={fieldMap} db={db} onValuesChanged={handleUpdate}>
184
202
  <Form.FieldSet />
185
203
 
186
204
  <FormFieldLabel label={t('fields label')} asChild />
@@ -193,19 +211,6 @@ export const ViewEditor = forwardRef<ProjectionModel, ViewEditorProps>(
193
211
  onDelete={handleDelete}
194
212
  />
195
213
  </Form.Root>
196
-
197
- {!readonly && !expandedField && (
198
- <div role='none' className='mlb-cardSpacingBlock'>
199
- <IconButton
200
- icon='ph--plus--regular'
201
- label={t('add property button label')}
202
- onClick={readonly ? undefined : handleAdd}
203
- // TODO(burdon): Show field limit in ux (not tooltip).
204
- disabled={view.projection.fields.length >= VIEW_FIELD_LIMIT}
205
- classNames='is-full'
206
- />
207
- </div>
208
- )}
209
214
  </div>
210
215
  );
211
216
  },
@@ -239,10 +244,16 @@ const FieldList = ({ schema, view, registry, readonly, showHeading = false, onDe
239
244
  return model;
240
245
  }, [atomRegistry, schema, view]);
241
246
 
242
- const [expandedField, setExpandedField] = useState<FieldType['id']>();
247
+ const [expandedField, setExpandedField] = useState<View.FieldType['id']>();
248
+
249
+ const handleAdd = useCallback(() => {
250
+ invariant(!readonly);
251
+ const field = projectionModel.createFieldProjection();
252
+ setExpandedField(field.id);
253
+ }, [projectionModel, readonly]);
243
254
 
244
255
  const handleToggleField = useCallback(
245
- (field: FieldType) => {
256
+ (field: View.FieldType) => {
246
257
  setExpandedField((prevExpandedFieldId) => (prevExpandedFieldId === field.id ? undefined : field.id));
247
258
  },
248
259
  [readonly],
@@ -297,9 +308,9 @@ const FieldList = ({ schema, view, registry, readonly, showHeading = false, onDe
297
308
  }
298
309
 
299
310
  return (
300
- <List.Root<FieldType>
301
- items={viewSnapshot.projection.fields as FieldType[]}
302
- isItem={Schema.is(FieldSchema)}
311
+ <List.Root<View.FieldType>
312
+ items={viewSnapshot.projection.fields as View.FieldType[]}
313
+ isItem={Schema.is(View.FieldSchema)}
303
314
  getId={(field) => field.id}
304
315
  onMove={readonly ? undefined : handleMove}
305
316
  readonly={readonly}
@@ -307,22 +318,29 @@ const FieldList = ({ schema, view, registry, readonly, showHeading = false, onDe
307
318
  {({ items: fields }) => (
308
319
  <>
309
320
  {showHeading && <h3 className='text-sm'>{t('field path label')}</h3>}
310
- <div role='list' className={listGrid}>
321
+ <div role='list' className='grid grid-cols-[min-content_1fr_min-content_min-content_min-content]'>
311
322
  {fields?.map((field) => {
312
323
  const hidden = field.visible === false;
313
324
  return (
314
- <List.Item<FieldType>
325
+ <List.Item<View.FieldType>
315
326
  key={field.id}
316
327
  item={field}
317
- classNames={listItemGrid}
328
+ classNames={'grid grid-cols-subgrid col-span-5'}
318
329
  aria-expanded={expandedField === field.id}
319
330
  >
320
- <div role='none' className={mx(subtleHover, listItemGrid, 'rounded-sm cursor-pointer min-bs-10')}>
331
+ <div
332
+ role='none'
333
+ className={mx(
334
+ subtleHover,
335
+ 'grid grid-cols-subgrid col-span-5',
336
+ 'rounded-xs cursor-pointer min-h-10',
337
+ )}
338
+ >
321
339
  <List.ItemDragHandle disabled={readonly || schemaReadonly} />
322
340
  <List.ItemTitle classNames={hidden && 'text-subdued'} onClick={() => handleToggleField(field)}>
323
341
  {field.path}
324
342
  </List.ItemTitle>
325
- <List.ItemButton
343
+ <List.ItemIconButton
326
344
  label={t(hidden ? 'show field label' : 'hide field label')}
327
345
  data-testid={hidden ? 'show-field-button' : 'hide-field-button'}
328
346
  icon={hidden ? 'ph--eye-closed--regular' : 'ph--eye--regular'}
@@ -339,7 +357,7 @@ const FieldList = ({ schema, view, registry, readonly, showHeading = false, onDe
339
357
  onClick={() => handleDelete(field.id)}
340
358
  data-testid='field.delete'
341
359
  />
342
- <IconButton
360
+ <List.ItemIconButton
343
361
  iconOnly
344
362
  variant='ghost'
345
363
  label={t('toggle expand label', { ns: osTranslations })}
@@ -351,7 +369,7 @@ const FieldList = ({ schema, view, registry, readonly, showHeading = false, onDe
351
369
  )}
352
370
  </div>
353
371
  {expandedField === field.id && !readonly && (
354
- <div role='none' className='col-span-5 mbs-1 mbe-1 border border-separator rounded-md'>
372
+ <div role='none' className='col-span-5 mt-1 mb-1 border border-separator rounded-md'>
355
373
  <FieldEditor
356
374
  readonly={readonly || schemaReadonly}
357
375
  registry={registry}
@@ -365,6 +383,17 @@ const FieldList = ({ schema, view, registry, readonly, showHeading = false, onDe
365
383
  );
366
384
  })}
367
385
  </div>
386
+ {!readonly && !expandedField && (
387
+ <div role='none' className='my-form-padding'>
388
+ <IconButton
389
+ icon='ph--plus--regular'
390
+ label={t('add property button label')}
391
+ onClick={handleAdd}
392
+ disabled={viewSnapshot.projection.fields.length >= VIEW_FIELD_LIMIT}
393
+ classNames='w-full'
394
+ />
395
+ </div>
396
+ )}
368
397
  </>
369
398
  )}
370
399
  </List.Root>
@@ -2,8 +2,8 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- export * from './ControlSection';
6
5
  export * from './FieldEditor';
7
6
  export * from './Form';
8
7
  export * from './ObjectPicker';
8
+ export * from './Settings';
9
9
  export * from './ViewEditor';