@dxos/react-ui-form 0.8.4-main.9be5663bfe → 0.8.4-main.abd8ff62ef

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 (123) hide show
  1. package/dist/lib/browser/index.mjs +620 -440
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/browser/translations.mjs +82 -0
  5. package/dist/lib/browser/translations.mjs.map +7 -0
  6. package/dist/lib/node-esm/index.mjs +620 -440
  7. package/dist/lib/node-esm/index.mjs.map +4 -4
  8. package/dist/lib/node-esm/meta.json +1 -1
  9. package/dist/lib/node-esm/translations.mjs +84 -0
  10. package/dist/lib/node-esm/translations.mjs.map +7 -0
  11. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
  12. package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts +63 -62
  13. package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts.map +1 -1
  14. package/dist/types/src/components/Form/Form.d.ts +27 -4
  15. package/dist/types/src/components/Form/Form.d.ts.map +1 -1
  16. package/dist/types/src/components/Form/Form.stories.d.ts +73 -72
  17. package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
  18. package/dist/types/src/components/Form/FormField.d.ts +5 -5
  19. package/dist/types/src/components/Form/FormField.d.ts.map +1 -1
  20. package/dist/types/src/components/Form/FormFieldComponent.d.ts +8 -6
  21. package/dist/types/src/components/Form/FormFieldComponent.d.ts.map +1 -1
  22. package/dist/types/src/components/Form/FormFieldComponent.stories.d.ts.map +1 -1
  23. package/dist/types/src/components/Form/FormFieldSet.d.ts +5 -8
  24. package/dist/types/src/components/Form/FormFieldSet.d.ts.map +1 -1
  25. package/dist/types/src/components/Form/fields/ArrayField.d.ts +4 -4
  26. package/dist/types/src/components/Form/fields/ArrayField.d.ts.map +1 -1
  27. package/dist/types/src/components/Form/fields/BooleanField.d.ts.map +1 -1
  28. package/dist/types/src/components/Form/fields/GeoPointField.d.ts.map +1 -1
  29. package/dist/types/src/components/Form/fields/MarkdownField.d.ts +8 -1
  30. package/dist/types/src/components/Form/fields/MarkdownField.d.ts.map +1 -1
  31. package/dist/types/src/components/Form/fields/MarkdownField.stories.d.ts +84 -0
  32. package/dist/types/src/components/Form/fields/MarkdownField.stories.d.ts.map +1 -0
  33. package/dist/types/src/components/Form/fields/NumberField.d.ts.map +1 -1
  34. package/dist/types/src/components/Form/fields/RefField.d.ts +10 -4
  35. package/dist/types/src/components/Form/fields/RefField.d.ts.map +1 -1
  36. package/dist/types/src/components/Form/fields/SelectField.d.ts.map +1 -1
  37. package/dist/types/src/components/Form/fields/SelectOptionField.d.ts.map +1 -1
  38. package/dist/types/src/components/Form/fields/SelectOptionField.stories.d.ts +63 -62
  39. package/dist/types/src/components/Form/fields/SelectOptionField.stories.d.ts.map +1 -1
  40. package/dist/types/src/components/Form/fields/TextAreaField.d.ts.map +1 -1
  41. package/dist/types/src/components/Form/fields/TextField.d.ts +1 -1
  42. package/dist/types/src/components/Form/fields/TextField.d.ts.map +1 -1
  43. package/dist/types/src/components/Form/fields/TupleField.d.ts.map +1 -1
  44. package/dist/types/src/components/ObjectForm/ObjectForm.d.ts.map +1 -1
  45. package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts +17 -3
  46. package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts.map +1 -1
  47. package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts +63 -62
  48. package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts.map +1 -1
  49. package/dist/types/src/components/ObjectProperties/ObjectProperties.d.ts +1 -1
  50. package/dist/types/src/components/ObjectProperties/ObjectProperties.d.ts.map +1 -1
  51. package/dist/types/src/components/ObjectProperties/ObjectProperties.stories.d.ts +108 -64
  52. package/dist/types/src/components/ObjectProperties/ObjectProperties.stories.d.ts.map +1 -1
  53. package/dist/types/src/components/ObjectProperties/ObjectProperties.test.d.ts +2 -0
  54. package/dist/types/src/components/ObjectProperties/ObjectProperties.test.d.ts.map +1 -0
  55. package/dist/types/src/components/Settings/Settings.d.ts +24 -8
  56. package/dist/types/src/components/Settings/Settings.d.ts.map +1 -1
  57. package/dist/types/src/components/Settings/Settings.stories.d.ts +64 -62
  58. package/dist/types/src/components/Settings/Settings.stories.d.ts.map +1 -1
  59. package/dist/types/src/components/Settings/SettingsFieldSet.d.ts +43 -0
  60. package/dist/types/src/components/Settings/SettingsFieldSet.d.ts.map +1 -0
  61. package/dist/types/src/components/Settings/SettingsItem.d.ts +16 -0
  62. package/dist/types/src/components/Settings/SettingsItem.d.ts.map +1 -0
  63. package/dist/types/src/components/Settings/SettingsSelectField.d.ts +18 -0
  64. package/dist/types/src/components/Settings/SettingsSelectField.d.ts.map +1 -0
  65. package/dist/types/src/components/Settings/index.d.ts +2 -0
  66. package/dist/types/src/components/Settings/index.d.ts.map +1 -1
  67. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +2 -2
  68. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
  69. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +63 -62
  70. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
  71. package/dist/types/src/components/testing.d.ts +4 -4
  72. package/dist/types/src/components/testing.d.ts.map +1 -1
  73. package/dist/types/src/hooks/useFormHandler.d.ts.map +1 -1
  74. package/dist/types/src/hooks/useKeyHandler.d.ts.map +1 -1
  75. package/dist/types/src/index.d.ts +0 -2
  76. package/dist/types/src/index.d.ts.map +1 -1
  77. package/dist/types/src/translations.d.ts +63 -62
  78. package/dist/types/src/translations.d.ts.map +1 -1
  79. package/dist/types/src/util/field-type.d.ts +19 -0
  80. package/dist/types/src/util/field-type.d.ts.map +1 -0
  81. package/dist/types/src/util/field.d.ts.map +1 -1
  82. package/dist/types/src/util/formatting.d.ts.map +1 -1
  83. package/dist/types/src/util/index.d.ts +1 -0
  84. package/dist/types/src/util/index.d.ts.map +1 -1
  85. package/dist/types/src/util/properties.d.ts.map +1 -1
  86. package/dist/types/src/util/refs.d.ts.map +1 -1
  87. package/dist/types/tsconfig.tsbuildinfo +1 -1
  88. package/package.json +39 -38
  89. package/src/components/FieldEditor/FieldEditor.stories.tsx +3 -4
  90. package/src/components/FieldEditor/FieldEditor.tsx +3 -2
  91. package/src/components/Form/Form.stories.tsx +5 -16
  92. package/src/components/Form/Form.tsx +30 -7
  93. package/src/components/Form/FormField.tsx +7 -5
  94. package/src/components/Form/FormFieldComponent.tsx +3 -0
  95. package/src/components/Form/FormFieldSet.tsx +1 -3
  96. package/src/components/Form/fields/ArrayField.tsx +8 -3
  97. package/src/components/Form/fields/GeoPointField.tsx +2 -1
  98. package/src/components/Form/fields/MarkdownField.stories.tsx +206 -0
  99. package/src/components/Form/fields/MarkdownField.tsx +135 -45
  100. package/src/components/Form/fields/RefField.tsx +61 -30
  101. package/src/components/Form/fields/SelectOptionField.stories.tsx +8 -5
  102. package/src/components/Form/fields/SelectOptionField.tsx +3 -2
  103. package/src/components/Form/fields/TextField.tsx +2 -2
  104. package/src/components/ObjectForm/ObjectForm.tsx +6 -5
  105. package/src/components/ObjectPicker/ObjectPicker.stories.tsx +5 -2
  106. package/src/components/ObjectPicker/ObjectPicker.tsx +28 -12
  107. package/src/components/ObjectProperties/ObjectProperties.stories.tsx +321 -22
  108. package/src/components/ObjectProperties/ObjectProperties.test.tsx +101 -0
  109. package/src/components/ObjectProperties/ObjectProperties.tsx +26 -14
  110. package/src/components/Settings/AUDIT.md +52 -0
  111. package/src/components/Settings/Settings.stories.tsx +50 -1
  112. package/src/components/Settings/Settings.tsx +6 -53
  113. package/src/components/Settings/SettingsFieldSet.tsx +257 -0
  114. package/src/components/Settings/SettingsItem.tsx +62 -0
  115. package/src/components/Settings/SettingsSelectField.tsx +59 -0
  116. package/src/components/Settings/index.ts +2 -0
  117. package/src/components/ViewEditor/ViewEditor.stories.tsx +17 -18
  118. package/src/components/ViewEditor/ViewEditor.tsx +4 -3
  119. package/src/components/testing.tsx +20 -21
  120. package/src/index.ts +0 -4
  121. package/src/translations.ts +7 -4
  122. package/src/util/field-type.ts +60 -0
  123. package/src/util/index.ts +1 -0
@@ -1,89 +1,13 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
 
3
- // src/translations.ts
4
- var translationKey = "@dxos/react-ui-form";
5
- var translations = [
6
- {
7
- "en-US": {
8
- [translationKey]: {
9
- "fields.label": "Fields",
10
- "hidden-fields.label": "Hidden Fields",
11
- "empty-readonly-ref-field.label": "(none)",
12
- "add-property-button.label": "Add property",
13
- "field-property.label": "Property",
14
- "field-property.placeholder": "Property name",
15
- "field-format.label": "Type",
16
- "field-path.label": "Field path",
17
- "add-field.button": "Add field",
18
- "boolean-input-true.value": "Yes",
19
- "boolean-input-false.value": "No",
20
- "show-field.label": "Show field",
21
- "hide-field.label": "Hide field",
22
- "delete-field.label": "Delete field",
23
- "ref-field-combobox-input.placeholder": "Search\u2026",
24
- "ref-field.placeholder": "Select\u2026",
25
- "ref-field.placeholder_one": "Select\u2026",
26
- "ref-field.placeholder_other": "Select items\u2026",
27
- "create-option.label": "Create",
28
- "add-tag.label": "Add tag",
29
- "example.placeholder": "Example",
30
- "latitude.placeholder": "Latitude (e.g., 40.7128)",
31
- "longitude.placeholder": "Longitude (e.g., -74.0060)",
32
- "cancel-button.label": "Cancel",
33
- "save-button.label": "Save",
34
- // TypeFormat
35
- "format.boolean.label": "Boolean",
36
- "format.currency.label": "Currency",
37
- "format.date.label": "Date",
38
- "format.date-time.label": "DateTime",
39
- "format.did.label": "DID",
40
- "format.duration.label": "Duration",
41
- "format.dxn.label": "DXN",
42
- "format.email.label": "Email",
43
- "format.formula.label": "Formula",
44
- "format.hostname.label": "Hostname",
45
- "format.integer.label": "Integer",
46
- "format.json.label": "JSON",
47
- "format.lnglat.label": "Geopoint",
48
- "format.markdown.label": "Markdown",
49
- "format.percent.label": "Percent",
50
- "format.ref.label": "Reference",
51
- "format.regex.label": "RegExp",
52
- "format.string.label": "String",
53
- "format.single-select.label": "Select",
54
- "format.multi-select.label": "Multi-select",
55
- "format.text.label": "Long text",
56
- "format.time.label": "Time",
57
- "format.timestamp.label": "Timestamp",
58
- "format.user.label": "User",
59
- "format.number.label": "Number",
60
- "format.uri.label": "URI",
61
- "format.url.label": "URL",
62
- "format.uuid.label": "UUID",
63
- // GeoPointField.
64
- "latitude.label": "Latitude",
65
- "longitude.label": "Longitude",
66
- // SelectOptionsField.
67
- "select-option.label": "Label",
68
- "select-option-label.placeholder": "Option label",
69
- "select-option-delete.button": "Delete",
70
- "select-option-add.button": "Add option",
71
- // System schema message.
72
- "system-schema.title": "System type",
73
- "system-schema.description": "System type: cannot add or remove fields.",
74
- "remove.button": "Remove"
75
- }
76
- }
77
- }
78
- ];
79
-
80
3
  // src/components/FieldEditor/FieldEditor.tsx
81
- import React17, { useCallback as useCallback14, useEffect as useEffect6, useMemo as useMemo7, useState as useState5 } from "react";
82
- import { Obj as Obj2 } from "@dxos/echo";
4
+ import React17, { useCallback as useCallback14, useEffect as useEffect5, useMemo as useMemo8, useState as useState6 } from "react";
5
+ import { Obj as Obj3 } from "@dxos/echo";
83
6
  import { Format as Format4, FormatEnums, formatToType } from "@dxos/echo/internal";
84
7
  import { log as log2 } from "@dxos/log";
85
- import { useAsyncEffect, useTranslation as useTranslation8 } from "@dxos/react-ui";
8
+ import { useAsyncEffect, useTranslation as useTranslation9 } from "@dxos/react-ui";
86
9
  import { formatToAdditionalPropertyAttributes, getFormatSchema } from "@dxos/schema";
10
+ import { translationKey as translationKey9 } from "#translations";
87
11
 
88
12
  // src/util/field.ts
89
13
  import { Format, GeoLocation, TypeEnum } from "@dxos/echo/internal";
@@ -206,6 +130,46 @@ var pathNotUniqueError = (path) => ({
206
130
  message: `'${path}' is already present`
207
131
  });
208
132
 
133
+ // src/util/field-type.ts
134
+ import * as SchemaAST from "effect/SchemaAST";
135
+ import { getAnnotation, isLiteralUnion } from "@dxos/effect";
136
+ var detectFieldType = (ast) => {
137
+ if (isLiteralUnion(ast)) {
138
+ return "select";
139
+ }
140
+ if (SchemaAST.isTypeLiteral(ast)) {
141
+ return "struct";
142
+ }
143
+ switch (ast._tag) {
144
+ case "BooleanKeyword":
145
+ return "boolean";
146
+ case "StringKeyword":
147
+ return "string";
148
+ case "NumberKeyword":
149
+ return "number";
150
+ }
151
+ return void 0;
152
+ };
153
+ var getSelectOptionsFromAst = (ast) => {
154
+ if (!isLiteralUnion(ast)) {
155
+ return void 0;
156
+ }
157
+ return ast.types.flatMap((literalNode) => {
158
+ const value3 = literalNode.literal;
159
+ if (typeof value3 !== "string" && typeof value3 !== "number") {
160
+ return [];
161
+ }
162
+ const title = getAnnotation(SchemaAST.TitleAnnotationId, false)(literalNode);
163
+ const label = title ?? (typeof value3 === "string" ? value3.charAt(0).toUpperCase() + value3.slice(1) : String(value3));
164
+ return [
165
+ {
166
+ value: value3,
167
+ label
168
+ }
169
+ ];
170
+ });
171
+ };
172
+
209
173
  // src/util/formatting.ts
210
174
  import { format as formatDate } from "date-fns/format";
211
175
  import { Format as Format2, GeoLocation as GeoLocation2, TypeEnum as TypeEnum2 } from "@dxos/echo/internal";
@@ -382,20 +346,24 @@ var getRefProps = (ast) => {
382
346
  };
383
347
 
384
348
  // src/components/Form/fields/ArrayField.tsx
385
- import * as Option3 from "effect/Option";
386
- import * as SchemaAST3 from "effect/SchemaAST";
349
+ import * as Option4 from "effect/Option";
350
+ import * as SchemaAST4 from "effect/SchemaAST";
387
351
  import React5, { useCallback as useCallback3 } from "react";
388
352
  import { findNode as findNode2, getArrayElementType as getArrayElementType2, getDiscriminatedType as getDiscriminatedType2, isDiscriminatedUnion as isDiscriminatedUnion2, isNestedType as isNestedType2 } from "@dxos/effect";
389
353
  import { IconButton as IconButton2, useTranslation as useTranslation3 } from "@dxos/react-ui";
354
+ import { translationKey as translationKey3 } from "#translations";
390
355
 
391
356
  // src/components/Form/Form.tsx
392
357
  import { createContext } from "@radix-ui/react-context";
358
+ import * as Option3 from "effect/Option";
393
359
  import * as Schema2 from "effect/Schema";
394
- import * as SchemaAST2 from "effect/SchemaAST";
360
+ import * as SchemaAST3 from "effect/SchemaAST";
395
361
  import React4, { useEffect as useEffect2, useMemo as useMemo4, useRef } from "react";
362
+ import { Annotation as EchoAnnotation } from "@dxos/echo";
396
363
  import { createJsonPath as createJsonPath3, getValue as getValue$2 } from "@dxos/effect";
397
364
  import { IconButton, ScrollArea, useMergeRefs, useTranslation as useTranslation2 } from "@dxos/react-ui";
398
- import { composable, composableProps, mx } from "@dxos/ui-theme";
365
+ import { composable, composableProps, mx, withColumn } from "@dxos/ui-theme";
366
+ import { translationKey as translationKey2 } from "#translations";
399
367
 
400
368
  // src/hooks/useFormHandler.ts
401
369
  import { useControllableState } from "@radix-ui/react-use-controllable-state";
@@ -433,12 +401,7 @@ var useFormHandler = ({ schema, autoSave, values: valuesProp, defaultValues: def
433
401
  log("validate", {
434
402
  values: values2,
435
403
  errors: errors2
436
- }, {
437
- F: __dxlog_file,
438
- L: 155,
439
- S: void 0,
440
- C: (f, a) => f(...a)
441
- });
404
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 42, S: void 0 });
442
405
  if (errors2.length === 0 && onValidate) {
443
406
  const validatedValues = values2;
444
407
  errors2 = onValidate(validatedValues) ?? [];
@@ -526,12 +489,7 @@ var useFormHandler = ({ schema, autoSave, values: valuesProp, defaultValues: def
526
489
  log("onValueChange", {
527
490
  path,
528
491
  value: value3
529
- }, {
530
- F: __dxlog_file,
531
- L: 254,
532
- S: void 0,
533
- C: (f, a) => f(...a)
534
- });
492
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 138, S: void 0 });
535
493
  const jsonPath = createJsonPath(path);
536
494
  const pathArray = path;
537
495
  let parsedValue = value3;
@@ -540,12 +498,7 @@ var useFormHandler = ({ schema, autoSave, values: valuesProp, defaultValues: def
540
498
  parsedValue = parseFloat(value3) || 0;
541
499
  }
542
500
  } catch (err) {
543
- log.catch(err, void 0, {
544
- F: __dxlog_file,
545
- L: 264,
546
- S: void 0,
547
- C: (f, a) => f(...a)
548
- });
501
+ log.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 150, S: void 0 });
549
502
  parsedValue = void 0;
550
503
  }
551
504
  const newValues = mergeAtPath(values, pathArray, parsedValue);
@@ -765,12 +718,13 @@ import React3, { useMemo as useMemo3 } from "react";
765
718
  import * as Match from "effect/Match";
766
719
  import * as Option2 from "effect/Option";
767
720
  import * as Schema from "effect/Schema";
768
- import * as SchemaAST from "effect/SchemaAST";
721
+ import * as SchemaAST2 from "effect/SchemaAST";
769
722
  import * as String2 from "effect/String";
770
723
  import React2, { useMemo as useMemo2 } from "react";
771
724
  import { Format as Format3 } from "@dxos/echo";
772
- import { createJsonPath as createJsonPath2, findNode, getAnnotation, getDiscriminatedType, isArrayType as isArrayType2, isDiscriminatedUnion, isLiteralUnion, isNestedType } from "@dxos/effect";
725
+ import { createJsonPath as createJsonPath2, findNode, getAnnotation as getAnnotation2, getDiscriminatedType, isArrayType as isArrayType2, isDiscriminatedUnion, isLiteralUnion as isLiteralUnion2, isNestedType } from "@dxos/effect";
773
726
  import { useTranslation } from "@dxos/react-ui";
727
+ import { translationKey } from "#translations";
774
728
  var FormField = (props) => {
775
729
  const {
776
730
  type,
@@ -788,14 +742,14 @@ var FormField = (props) => {
788
742
  createInitialValuePath,
789
743
  createFieldMap: createFieldMap3,
790
744
  db,
791
- schemaHook,
745
+ useSchema: schemaHook,
792
746
  getOptions,
793
747
  onCreate
794
748
  } = props;
795
749
  const { t } = useTranslation(translationKey);
796
- const title = getAnnotation(SchemaAST.TitleAnnotationId)(type);
797
- const description = getAnnotation(SchemaAST.DescriptionAnnotationId)(type);
798
- const examples = getAnnotation(SchemaAST.ExamplesAnnotationId)(type);
750
+ const title = getAnnotation2(SchemaAST2.TitleAnnotationId)(type);
751
+ const description = getAnnotation2(SchemaAST2.DescriptionAnnotationId)(type);
752
+ const examples = getAnnotation2(SchemaAST2.ExamplesAnnotationId)(type);
799
753
  const label = useMemo2(() => title ?? String2.capitalize(name), [
800
754
  title,
801
755
  name
@@ -813,6 +767,7 @@ var FormField = (props) => {
813
767
  label,
814
768
  placeholder,
815
769
  layout,
770
+ db,
816
771
  ...fieldState
817
772
  };
818
773
  const jsonPath = createJsonPath2(path ?? []);
@@ -866,14 +821,14 @@ var FormField = (props) => {
866
821
  createInitialValuePath: isCreateTarget ? createInitialValuePath : void 0,
867
822
  createFieldMap: isCreateTarget ? createFieldMap3 : void 0,
868
823
  db,
869
- schemaHook,
824
+ useSchema: schemaHook,
870
825
  getOptions,
871
826
  onCreate
872
827
  });
873
828
  }
874
829
  if (isNestedType(type)) {
875
830
  const baseNode = findNode(type, isDiscriminatedUnion);
876
- const typeLiteral = baseNode ? getDiscriminatedType(baseNode, fieldState.getValue()) : findNode(type, SchemaAST.isTypeLiteral);
831
+ const typeLiteral = baseNode ? getDiscriminatedType(baseNode, fieldState.getValue()) : findNode(type, SchemaAST2.isTypeLiteral);
877
832
  if (typeLiteral) {
878
833
  const schema = Schema.make(typeLiteral);
879
834
  return /* @__PURE__ */ React2.createElement(FormFieldSet, {
@@ -889,7 +844,7 @@ var FormField = (props) => {
889
844
  createOptionIcon,
890
845
  createInitialValuePath,
891
846
  db,
892
- schemaHook,
847
+ useSchema: schemaHook,
893
848
  getOptions,
894
849
  onCreate
895
850
  });
@@ -915,7 +870,7 @@ var getFormField = ({ type, format }) => {
915
870
  }
916
871
  };
917
872
  var getSelectOptions = (ast) => {
918
- if (isLiteralUnion(ast)) {
873
+ if (isLiteralUnion2(ast)) {
919
874
  return ast.types.map((type) => type.literal).filter((v) => v !== null);
920
875
  }
921
876
  return Format3.OptionsAnnotation.getFromAst(ast).pipe((annotation) => Option2.getOrUndefined(annotation));
@@ -999,6 +954,11 @@ var useFormFieldSetProperties = ({ schema, exclude, projection, values, sort })
999
954
 
1000
955
  // src/components/Form/Form.tsx
1001
956
  var omitId = (schema) => schema.pipe(Schema2.omit("id"));
957
+ var omitHiddenFormFields = (schema) => {
958
+ const properties = SchemaAST3.getPropertySignatures(schema.ast);
959
+ const hidden = properties.filter((prop) => Option3.getOrElse(EchoAnnotation.FormInputAnnotation.getFromAst(prop.type), () => true) === false).map((prop) => prop.name);
960
+ return hidden.length === 0 ? schema : schema.pipe(Schema2.omit(...hidden));
961
+ };
1002
962
  var [FormContextProvider, useFormContext] = createContext("Form");
1003
963
  var useFormValues = (componentName, path, defaultValue) => {
1004
964
  const stablePath = useMemo4(() => path ?? [], [
@@ -1011,7 +971,7 @@ var useFormValues = (componentName, path, defaultValue) => {
1011
971
  useEffect2(() => {
1012
972
  if (value3 == null && defaultValue && lastAppliedPathRef.current !== jsonPath) {
1013
973
  lastAppliedPathRef.current = jsonPath;
1014
- onValueChange(stablePath, SchemaAST2.stringKeyword, defaultValue());
974
+ onValueChange(stablePath, SchemaAST3.stringKeyword, defaultValue());
1015
975
  }
1016
976
  }, [
1017
977
  value3,
@@ -1078,7 +1038,7 @@ var FormContent = composable(({ children, ...props }, forwardedRef) => {
1078
1038
  return /* @__PURE__ */ React4.createElement("div", {
1079
1039
  ...composableProps(props, {
1080
1040
  role: "form",
1081
- classNames: "flex flex-col w-full pb-form-gap"
1041
+ classNames: mx(withColumn.center(), "flex flex-col w-full pb-form-gap")
1082
1042
  }),
1083
1043
  "data-testid": testId,
1084
1044
  ref: mergedRef
@@ -1097,14 +1057,14 @@ var FormFieldSet2 = (props) => {
1097
1057
  FormFieldSet2.displayName = FORM_FIELDSET_NAME2;
1098
1058
  var FORM_ACTIONS_NAME = "Form.Actions";
1099
1059
  var FormActions = ({ classNames }) => {
1100
- const { t } = useTranslation2(translationKey);
1060
+ const { t } = useTranslation2(translationKey2);
1101
1061
  const { form: { canSave, onSave, onCancel }, readonly, layout } = useFormContext(FORM_ACTIONS_NAME);
1102
1062
  if (readonly || layout === "static") {
1103
1063
  return null;
1104
1064
  }
1105
1065
  return /* @__PURE__ */ React4.createElement("div", {
1106
1066
  role: "none",
1107
- className: mx("grid grid-flow-col gap-form-gap auto-cols-fr py-form-padding", classNames)
1067
+ className: mx(withColumn.center(), "grid grid-flow-col gap-form-gap auto-cols-fr py-form-padding", classNames)
1108
1068
  }, onCancel && /* @__PURE__ */ React4.createElement(IconButton, {
1109
1069
  icon: "ph--x--regular",
1110
1070
  iconEnd: true,
@@ -1139,7 +1099,7 @@ var FormSection = composable(({ children, label, description, ...props }, forwar
1139
1099
  FormSection.displayName = FORM_SECTION_NAME;
1140
1100
  var FORM_SUBMIT_NAME = "Form.Submit";
1141
1101
  var FormSubmit = ({ classNames, label, icon, disabled }) => {
1142
- const { t } = useTranslation2(translationKey);
1102
+ const { t } = useTranslation2(translationKey2);
1143
1103
  const { form: { canSave, onSave }, readonly, layout } = useFormContext(FORM_SUBMIT_NAME);
1144
1104
  if (readonly || layout === "static") {
1145
1105
  return null;
@@ -1172,18 +1132,18 @@ var Form = {
1172
1132
 
1173
1133
  // src/components/Form/fields/ArrayField.tsx
1174
1134
  var ArrayField = ({ type, path, label, readonly, layout, fieldProps: inputProps, ...props }) => {
1175
- const { t } = useTranslation3(translationKey);
1135
+ const { t } = useTranslation3(translationKey3);
1176
1136
  const elementType = getArrayElementType2(type);
1177
1137
  const { onValueChange } = inputProps;
1178
1138
  const values = useFormValues(ArrayField.displayName, path, () => []);
1179
1139
  const getDefaultObjectValue = (typeNode) => {
1180
1140
  const baseNode = findNode2(typeNode, isDiscriminatedUnion2);
1181
- const typeLiteral = baseNode ? getDiscriminatedType2(baseNode, {}) : findNode2(typeNode, SchemaAST3.isTypeLiteral);
1141
+ const typeLiteral = baseNode ? getDiscriminatedType2(baseNode, {}) : findNode2(typeNode, SchemaAST4.isTypeLiteral);
1182
1142
  if (!typeLiteral) {
1183
1143
  return {};
1184
1144
  }
1185
1145
  return Object.fromEntries(getFormProperties(typeLiteral).map((prop) => {
1186
- const defaultValue = SchemaAST3.getDefaultAnnotation(prop.type).pipe((annotation) => Option3.getOrUndefined(annotation));
1146
+ const defaultValue = SchemaAST4.getDefaultAnnotation(prop.type).pipe((annotation) => Option4.getOrUndefined(annotation));
1187
1147
  return [
1188
1148
  prop.name,
1189
1149
  defaultValue
@@ -1223,7 +1183,7 @@ var ArrayField = ({ type, path, label, readonly, layout, fieldProps: inputProps,
1223
1183
  return /* @__PURE__ */ React5.createElement("div", {
1224
1184
  role: "none",
1225
1185
  key: index,
1226
- className: "flex gap-form-gap last:mb-form-gap items-center"
1186
+ className: "grid grid-cols-[1fr_min-content] gap-form-gap last:mb-form-gap items-center"
1227
1187
  }, /* @__PURE__ */ React5.createElement(FormField, {
1228
1188
  autoFocus: index === values.length - 1,
1229
1189
  type: elementType,
@@ -1250,7 +1210,7 @@ var ArrayField = ({ type, path, label, readonly, layout, fieldProps: inputProps,
1250
1210
  })), !readonly && layout !== "static" && /* @__PURE__ */ React5.createElement(IconButton2, {
1251
1211
  classNames: "flex w-full",
1252
1212
  icon: "ph--plus--regular",
1253
- label: t("add-field.button"),
1213
+ label: t("add-item.button"),
1254
1214
  onClick: handleAdd
1255
1215
  }));
1256
1216
  };
@@ -1302,8 +1262,9 @@ import React7, { useCallback as useCallback5, useEffect as useEffect3, useMemo a
1302
1262
  import { GeoLocation as GeoLocation3 } from "@dxos/echo/internal";
1303
1263
  import { Input as Input3, useTranslation as useTranslation4 } from "@dxos/react-ui";
1304
1264
  import { safeParseFloat } from "@dxos/util";
1265
+ import { translationKey as translationKey4 } from "#translations";
1305
1266
  var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onValueChange, onBlur }) => {
1306
- const { t } = useTranslation4(translationKey);
1267
+ const { t } = useTranslation4(translationKey4);
1307
1268
  const { status, error } = getStatus();
1308
1269
  const geoPoint = useMemo5(() => getValue() ?? [
1309
1270
  0,
@@ -1394,56 +1355,141 @@ var LatLng = ({ latitude = 0, longitude = 0 }) => {
1394
1355
  };
1395
1356
 
1396
1357
  // src/components/Form/fields/MarkdownField.tsx
1397
- import React8, { useCallback as useCallback6, useEffect as useEffect4, useRef as useRef2 } from "react";
1398
- import { Input as Input4 } from "@dxos/react-ui";
1399
- var MarkdownField = ({ type, readonly, label, placeholder, layout, getStatus, getValue, onValueChange, onBlur }) => {
1358
+ import { useAtomValue } from "@effect-atom/atom-react";
1359
+ import React8, { useCallback as useCallback6, useMemo as useMemo6 } from "react";
1360
+ import { Obj, Ref as Ref2 } from "@dxos/echo";
1361
+ import { AtomRef } from "@dxos/echo-atom";
1362
+ import { createDocAccessor } from "@dxos/echo-db";
1363
+ import { Button, Icon as Icon2, Input as Input4, useTranslation as useTranslation5 } from "@dxos/react-ui";
1364
+ import { Editor, useBasicMarkdownExtensions } from "@dxos/react-ui-editor";
1365
+ import { Text } from "@dxos/schema";
1366
+ import { createDataExtensions } from "@dxos/ui-editor";
1367
+ import { translationKey as translationKey5 } from "#translations";
1368
+ var editorClassNames = "transition-colors bg-input-surface focus-within:bg-focus-surface border border-separator rounded-xs p-1 px-2";
1369
+ var MarkdownField = ({ type, readonly, label, placeholder, layout, db, getStatus, getValue, onValueChange }) => {
1400
1370
  const { status, error } = getStatus();
1401
- const textareaRef = useRef2(null);
1402
- const adjustHeight = useCallback6(() => {
1403
- const textarea = textareaRef.current;
1404
- if (textarea) {
1405
- textarea.style.blockSize = "auto";
1406
- textarea.style.blockSize = `${textarea.scrollHeight + 2}px`;
1407
- }
1408
- }, []);
1409
- useEffect4(() => {
1410
- adjustHeight();
1411
- }, [
1412
- adjustHeight
1413
- ]);
1414
- useEffect4(() => {
1415
- adjustHeight();
1416
- }, [
1417
- getValue(),
1418
- adjustHeight
1419
- ]);
1420
- const handleChange = useCallback6((event) => onValueChange(type, event.target.value), [
1421
- type,
1422
- onValueChange
1423
- ]);
1371
+ const isRef = Ref2.isRefType(type);
1424
1372
  const value3 = getValue();
1425
- if ((readonly || layout === "static") && !value3) {
1373
+ if ((readonly || layout === "static") && value3 == null) {
1426
1374
  return null;
1427
1375
  }
1376
+ const renderEditor = () => {
1377
+ if (isRef) {
1378
+ const reference = value3;
1379
+ if (reference) {
1380
+ return /* @__PURE__ */ React8.createElement(RefMarkdownEditor, {
1381
+ reference,
1382
+ placeholder
1383
+ });
1384
+ }
1385
+ if (readonly) {
1386
+ return null;
1387
+ }
1388
+ return /* @__PURE__ */ React8.createElement(CreateTextButton, {
1389
+ db,
1390
+ disabled: !db,
1391
+ onCreate: (ref) => onValueChange(type, ref)
1392
+ });
1393
+ }
1394
+ return /* @__PURE__ */ React8.createElement(StringMarkdownEditor, {
1395
+ value: value3 ?? "",
1396
+ placeholder,
1397
+ readonly: !!readonly,
1398
+ onChange: (next) => onValueChange(type, next)
1399
+ });
1400
+ };
1401
+ const renderStatic = () => {
1402
+ if (isRef) {
1403
+ const reference = value3;
1404
+ return reference ? /* @__PURE__ */ React8.createElement(RefStaticText, {
1405
+ reference
1406
+ }) : null;
1407
+ }
1408
+ return /* @__PURE__ */ React8.createElement("p", {
1409
+ className: "whitespace-pre-wrap"
1410
+ }, value3 ?? "");
1411
+ };
1428
1412
  return /* @__PURE__ */ React8.createElement(Input4.Root, {
1429
1413
  validationValence: status
1430
1414
  }, layout !== "inline" && /* @__PURE__ */ React8.createElement(FormFieldLabel, {
1431
1415
  error,
1432
1416
  readonly,
1433
1417
  label
1434
- }), layout === "static" ? /* @__PURE__ */ React8.createElement("p", null, value3) : /* @__PURE__ */ React8.createElement(Input4.TextArea, {
1435
- ref: textareaRef,
1436
- disabled: !!readonly,
1418
+ }), layout === "static" ? renderStatic() : renderEditor(), layout === "full" && /* @__PURE__ */ React8.createElement(Input4.Validation, null, error));
1419
+ };
1420
+ var RefStaticText = ({ reference }) => {
1421
+ const text = useAtomValue(useMemo6(() => AtomRef.make(reference), [
1422
+ reference
1423
+ ]));
1424
+ if (!text?.content) {
1425
+ return null;
1426
+ }
1427
+ return /* @__PURE__ */ React8.createElement("p", {
1428
+ className: "whitespace-pre-wrap"
1429
+ }, text.content);
1430
+ };
1431
+ var RefMarkdownEditor = ({ reference, placeholder }) => {
1432
+ const text = useAtomValue(useMemo6(() => AtomRef.make(reference), [
1433
+ reference
1434
+ ]));
1435
+ const dataExtensions = useMemo6(() => text ? [
1436
+ createDataExtensions({
1437
+ id: reference.dxn.toString(),
1438
+ text: createDocAccessor(text, [
1439
+ "content"
1440
+ ])
1441
+ })
1442
+ ] : [], [
1443
+ text,
1444
+ reference
1445
+ ]);
1446
+ const extensions = useBasicMarkdownExtensions({
1437
1447
  placeholder,
1438
- value: value3 ?? "",
1439
- classNames: "min-h-auto max-h-40 overflow-auto",
1440
- onChange: handleChange,
1441
- onBlur,
1442
- style: {
1443
- resize: "none"
1444
- },
1445
- spellCheck: false
1446
- }), layout === "full" && /* @__PURE__ */ React8.createElement(Input4.Validation, null, error));
1448
+ extensions: dataExtensions
1449
+ });
1450
+ if (!text) {
1451
+ return null;
1452
+ }
1453
+ return /* @__PURE__ */ React8.createElement(Editor.Root, null, /* @__PURE__ */ React8.createElement(Editor.View, {
1454
+ classNames: editorClassNames,
1455
+ extensions
1456
+ }));
1457
+ };
1458
+ var StringMarkdownEditor = ({ value: value3, placeholder, readonly, onChange }) => {
1459
+ const extensions = useBasicMarkdownExtensions({
1460
+ placeholder
1461
+ });
1462
+ const handleChange = useCallback6((next) => onChange(next), [
1463
+ onChange
1464
+ ]);
1465
+ return /* @__PURE__ */ React8.createElement(Editor.Root, null, /* @__PURE__ */ React8.createElement(Editor.View, {
1466
+ classNames: editorClassNames,
1467
+ extensions,
1468
+ value: value3,
1469
+ onChange: readonly ? void 0 : handleChange
1470
+ }));
1471
+ };
1472
+ var CreateTextButton = ({ db, disabled, onCreate }) => {
1473
+ const { t } = useTranslation5(translationKey5);
1474
+ const handleClick = useCallback6(() => {
1475
+ if (!db) {
1476
+ return;
1477
+ }
1478
+ const text = db.add(Obj.make(Text.Text, {
1479
+ content: ""
1480
+ }));
1481
+ onCreate(Ref2.make(text));
1482
+ }, [
1483
+ db,
1484
+ onCreate
1485
+ ]);
1486
+ return /* @__PURE__ */ React8.createElement(Button, {
1487
+ onClick: handleClick,
1488
+ disabled
1489
+ }, /* @__PURE__ */ React8.createElement(Icon2, {
1490
+ icon: "ph--plus--regular",
1491
+ size: 4
1492
+ }), /* @__PURE__ */ React8.createElement("span", null, t("create-text.label")));
1447
1493
  };
1448
1494
 
1449
1495
  // src/components/Form/fields/NumberField.tsx
@@ -1469,31 +1515,33 @@ var NumberField = ({ type, readonly, placeholder, onValueChange, onBlur, ...prop
1469
1515
  };
1470
1516
 
1471
1517
  // src/components/Form/fields/RefField.tsx
1472
- import React11, { useCallback as useCallback9, useMemo as useMemo6 } from "react";
1518
+ import React11, { useCallback as useCallback9, useMemo as useMemo7, useState as useState4 } from "react";
1473
1519
  import "@dxos/lit-ui/dx-tag-picker.pcss";
1474
- import { Entity, Filter, Obj, Ref as Ref2, Type } from "@dxos/echo";
1475
- import { useQuery, useSchema as useSchema$ } from "@dxos/echo-react";
1520
+ import { Entity, Filter, Obj as Obj2, Ref as Ref3, Type } from "@dxos/echo";
1521
+ import { useQuery, useSchema as defaultUseSchema } from "@dxos/echo-react";
1476
1522
  import { ReferenceAnnotationId as ReferenceAnnotationId2 } from "@dxos/echo/internal";
1477
1523
  import { findAnnotation as findAnnotation2 } from "@dxos/effect";
1478
1524
  import { DXN } from "@dxos/keys";
1479
1525
  import { DxAnchor } from "@dxos/lit-ui/react";
1480
- import { Button, Icon as Icon2, Input as Input6, useTranslation as useTranslation6 } from "@dxos/react-ui";
1526
+ import { Button as Button2, Icon as Icon3, Input as Input6, useTranslation as useTranslation7 } from "@dxos/react-ui";
1481
1527
  import { ParentLabelAnnotationId } from "@dxos/schema";
1482
- import { mx as mx2 } from "@dxos/ui-theme";
1528
+ import { translationKey as translationKey7 } from "#translations";
1483
1529
 
1484
1530
  // src/components/ObjectPicker/ObjectPicker.tsx
1485
1531
  import React10, { forwardRef, useCallback as useCallback8, useState as useState3 } from "react";
1486
- import { Popover, useTranslation as useTranslation5 } from "@dxos/react-ui";
1487
- import { Combobox, useSearchListInput, useSearchListResults } from "@dxos/react-ui-search";
1532
+ import { Popover, useTranslation as useTranslation6 } from "@dxos/react-ui";
1533
+ import { Combobox } from "@dxos/react-ui-list";
1534
+ import { useSearchListResults } from "@dxos/react-ui-search";
1535
+ import { translationKey as translationKey6 } from "#translations";
1488
1536
  var ObjectPickerContent = /* @__PURE__ */ forwardRef(({ options, selectedIds, createSchema, createOptionLabel, createOptionIcon, createInitialValuePath, createFieldMap: createFieldMap3, onSelect, onCreate, ...props }, forwardedRef) => {
1489
- const { t } = useTranslation5(translationKey);
1537
+ const { t } = useTranslation6(translationKey6);
1490
1538
  const [showForm, setShowForm] = useState3(false);
1491
1539
  const [formInitialValue, setFormInitialValue] = useState3("");
1492
- const { results, handleSearch } = useSearchListResults({
1540
+ const { results, query, handleSearch } = useSearchListResults({
1493
1541
  items: options
1494
1542
  });
1495
- const handleFormSave = useCallback8((values) => {
1496
- onCreate?.(values);
1543
+ const handleFormSave = useCallback8(async (values) => {
1544
+ await onCreate?.(values);
1497
1545
  setShowForm(false);
1498
1546
  setFormInitialValue("");
1499
1547
  }, [
@@ -1518,7 +1566,6 @@ var ObjectPickerContent = /* @__PURE__ */ forwardRef(({ options, selectedIds, cr
1518
1566
  if (showForm && createSchema) {
1519
1567
  return /* @__PURE__ */ React10.createElement(Combobox.Content, {
1520
1568
  ...props,
1521
- onSearch: handleSearch,
1522
1569
  onKeyDownCapture: handleKeyDown,
1523
1570
  ref: forwardedRef
1524
1571
  }, /* @__PURE__ */ React10.createElement(Popover.Viewport, null, /* @__PURE__ */ React10.createElement(Form.Root, {
@@ -1534,12 +1581,13 @@ var ObjectPickerContent = /* @__PURE__ */ forwardRef(({ options, selectedIds, cr
1534
1581
  }
1535
1582
  return /* @__PURE__ */ React10.createElement(Combobox.Content, {
1536
1583
  ...props,
1537
- onSearch: handleSearch,
1538
1584
  onKeyDownCapture: handleKeyDown,
1539
1585
  ref: forwardedRef
1540
1586
  }, /* @__PURE__ */ React10.createElement(Combobox.Input, {
1541
1587
  placeholder: t("ref-field-combobox-input.placeholder"),
1542
- autoFocus: true
1588
+ autoFocus: true,
1589
+ value: query,
1590
+ onValueChange: handleSearch
1543
1591
  }), /* @__PURE__ */ React10.createElement(Combobox.List, null, results.map((option) => /* @__PURE__ */ React10.createElement(Combobox.Item, {
1544
1592
  key: option.id,
1545
1593
  value: option.id,
@@ -1548,17 +1596,17 @@ var ObjectPickerContent = /* @__PURE__ */ forwardRef(({ options, selectedIds, cr
1548
1596
  onSelect: () => onSelect(option.id),
1549
1597
  classNames: "flex items-center gap-2"
1550
1598
  })), createSchema && onCreate && /* @__PURE__ */ React10.createElement(CreateItem, {
1599
+ query,
1551
1600
  createOptionLabel,
1552
1601
  createOptionIcon: createOptionIcon ?? "ph--plus--regular",
1553
- onCreateItemSelect: (query) => {
1554
- setFormInitialValue(query);
1602
+ onCreateItemSelect: (currentQuery) => {
1603
+ setFormInitialValue(currentQuery);
1555
1604
  setShowForm(true);
1556
1605
  }
1557
1606
  })), /* @__PURE__ */ React10.createElement(Combobox.Arrow, null));
1558
1607
  });
1559
- var CreateItem = ({ createOptionLabel, createOptionIcon, onCreateItemSelect }) => {
1560
- const { t } = useTranslation5(translationKey);
1561
- const { query } = useSearchListInput();
1608
+ var CreateItem = ({ query, createOptionLabel, createOptionIcon, onCreateItemSelect }) => {
1609
+ const { t } = useTranslation6(translationKey6);
1562
1610
  const label = createOptionLabel ? t(createOptionLabel[0], {
1563
1611
  ns: createOptionLabel[1].ns,
1564
1612
  text: query
@@ -1589,23 +1637,23 @@ var isRefSnapshot = (val) => {
1589
1637
  };
1590
1638
  var defaultGetOptions = (results, { parentLabel } = {}) => results.map((result) => {
1591
1639
  const id = Entity.getDXN(result).toString();
1592
- const parent = parentLabel ? Obj.getParent(result) : void 0;
1640
+ const parent = parentLabel ? Obj2.getParent(result) : void 0;
1593
1641
  const label = parent ? Entity.getLabel(parent) : Entity.getLabel(result);
1594
1642
  return {
1595
1643
  id,
1596
1644
  label: label ?? id
1597
1645
  };
1598
1646
  });
1599
- var defaultResultsHook = (db, typename) => useQuery(db, typename ? typename === Type.getTypename(Obj.Unknown) ? Filter.everything() : Filter.typename(typename) : Filter.nothing());
1647
+ var defaultUseResults = (db, typename) => useQuery(db, typename ? typename === Type.getTypename(Obj2.Unknown) ? Filter.everything() : Filter.typename(typename) : Filter.nothing());
1600
1648
  var RefField = (props) => {
1601
- const { type, readonly, label, placeholder, layout, getStatus, getValue, createOptionLabel, createOptionIcon, createInitialValuePath, createFieldMap: createFieldMap3, db, resultsHook: useResults = defaultResultsHook, schemaHook: useSchema = useSchema$, getOptions = defaultGetOptions, onCreate, onValueChange } = props;
1602
- const { t } = useTranslation6(translationKey);
1649
+ const { type, readonly, label, placeholder, layout, getStatus, getValue, createOptionLabel, createOptionIcon, createInitialValuePath, createFieldMap: createFieldMap3, db, useSchema = defaultUseSchema, useResults = defaultUseResults, getOptions = defaultGetOptions, onCreate, onValueChange } = props;
1650
+ const { t } = useTranslation7(translationKey7);
1603
1651
  const { status, error } = getStatus();
1604
- const typename = useMemo6(() => type ? findAnnotation2(type, ReferenceAnnotationId2)?.typename : void 0, [
1652
+ const typename = useMemo7(() => type ? findAnnotation2(type, ReferenceAnnotationId2)?.typename : void 0, [
1605
1653
  type
1606
1654
  ]);
1607
1655
  const results = useResults(db, typename);
1608
- const options = useMemo6(() => {
1656
+ const options = useMemo7(() => {
1609
1657
  const parentLabel = type ? findAnnotation2(type, ParentLabelAnnotationId) === true : false;
1610
1658
  return getOptions(results, {
1611
1659
  parentLabel
@@ -1617,11 +1665,13 @@ var RefField = (props) => {
1617
1665
  ]);
1618
1666
  const handleGetValue = useCallback9(() => {
1619
1667
  const formValue = getValue();
1668
+ const dxnToObjectId = (dxn) => dxn.split(":").pop() ?? dxn;
1620
1669
  const unknownToRefOption = (value3) => {
1621
- const isRef = Ref2.isRef(value3);
1670
+ const isRef = Ref3.isRef(value3);
1622
1671
  if (isRef || isRefSnapshot(value3)) {
1623
1672
  const dxnString = isRef ? value3.dxn.toString() : value3["/"];
1624
- const matchingOption = options.find((option) => option.id === dxnString);
1673
+ const objectId = dxnToObjectId(dxnString);
1674
+ const matchingOption = options.find((option) => dxnToObjectId(option.id) === objectId);
1625
1675
  if (matchingOption) {
1626
1676
  return matchingOption;
1627
1677
  }
@@ -1633,29 +1683,37 @@ var RefField = (props) => {
1633
1683
  options,
1634
1684
  getValue
1635
1685
  ]);
1636
- const handleUpdate = useCallback9((id) => {
1637
- const item2 = options.find((option) => option.id === id);
1638
- const ref = item2 ? Ref2.fromDXN(DXN.parse(item2.id)) : void 0;
1639
- onValueChange(type, ref);
1640
- }, [
1641
- options,
1642
- type,
1643
- onValueChange
1644
- ]);
1645
1686
  const item = handleGetValue();
1646
- const selectedIds = useMemo6(() => item ? [
1687
+ const selectedIds = useMemo7(() => item ? [
1647
1688
  item.id
1648
1689
  ] : [], [
1649
1690
  item
1650
1691
  ]);
1651
1692
  const createSchema = useSchema(db, typename);
1652
- const handleCreate = useCallback9((values) => {
1653
- if (createSchema && onCreate) {
1654
- onCreate(createSchema, values);
1693
+ const [open, setOpen] = useState4(false);
1694
+ const handleCreate = useCallback9(async (values) => {
1695
+ if (!createSchema || !onCreate) {
1696
+ return;
1655
1697
  }
1698
+ const newObject = await onCreate(createSchema, values);
1699
+ if (newObject) {
1700
+ onValueChange(type, Ref3.make(newObject));
1701
+ }
1702
+ setOpen(false);
1656
1703
  }, [
1657
1704
  createSchema,
1658
- onCreate
1705
+ onCreate,
1706
+ type,
1707
+ onValueChange
1708
+ ]);
1709
+ const handleUpdate = useCallback9((id) => {
1710
+ const item2 = options.find((option) => option.id === id);
1711
+ const ref = item2 ? Ref3.fromDXN(DXN.parse(item2.id)) : void 0;
1712
+ onValueChange(type, ref);
1713
+ }, [
1714
+ options,
1715
+ type,
1716
+ onValueChange
1659
1717
  ]);
1660
1718
  const handleSelect = useCallback9((id) => {
1661
1719
  if (item?.id === id) {
@@ -1677,15 +1735,19 @@ var RefField = (props) => {
1677
1735
  readonly,
1678
1736
  label
1679
1737
  }), /* @__PURE__ */ React11.createElement("div", null, readonly ? !item ? /* @__PURE__ */ React11.createElement("p", {
1680
- className: mx2("text-description", "mb-2")
1738
+ className: "text-description mb-2"
1681
1739
  }, t("empty-readonly-ref-field.label")) : /* @__PURE__ */ React11.createElement(DxAnchor, {
1682
1740
  key: item.id,
1683
1741
  dxn: item.id,
1684
1742
  rootclassname: "me-1"
1685
- }, item.label) : /* @__PURE__ */ React11.createElement(ObjectPicker.Root, null, /* @__PURE__ */ React11.createElement(ObjectPicker.Trigger, {
1743
+ }, item.label) : /* @__PURE__ */ React11.createElement(ObjectPicker.Root, {
1744
+ open,
1745
+ onOpenChange: setOpen
1746
+ }, /* @__PURE__ */ React11.createElement(ObjectPicker.Trigger, {
1686
1747
  asChild: true,
1687
1748
  classNames: "p-0"
1688
1749
  }, item ? /* @__PURE__ */ React11.createElement("div", {
1750
+ role: "none",
1689
1751
  className: "flex gap-form-gap w-full"
1690
1752
  }, /* @__PURE__ */ React11.createElement(Input6.Root, {
1691
1753
  key: item.id
@@ -1693,21 +1755,24 @@ var RefField = (props) => {
1693
1755
  value: item.label,
1694
1756
  readOnly: true,
1695
1757
  classNames: "w-full"
1696
- }))) : /* @__PURE__ */ React11.createElement(Button, {
1758
+ }))) : /* @__PURE__ */ React11.createElement(Button2, {
1697
1759
  classNames: "w-full text-start gap-form-gap"
1698
1760
  }, /* @__PURE__ */ React11.createElement("div", {
1699
1761
  role: "none",
1700
1762
  className: "grow overflow-hidden"
1701
1763
  }, /* @__PURE__ */ React11.createElement("span", {
1702
- className: "flex truncate text-description"
1703
- }, placeholder ?? t("ref-field.placeholder"))), /* @__PURE__ */ React11.createElement(Icon2, {
1764
+ className: "truncate text-description"
1765
+ }, placeholder ?? t("ref-field.placeholder"))), /* @__PURE__ */ React11.createElement(Icon3, {
1704
1766
  size: 3,
1705
1767
  icon: "ph--caret-down--bold"
1706
1768
  }))), /* @__PURE__ */ React11.createElement(ObjectPicker.Portal, null, /* @__PURE__ */ React11.createElement(ObjectPicker.Content, {
1707
1769
  classNames: "dx-card-popover-width",
1708
1770
  options,
1709
1771
  selectedIds,
1710
- createSchema: createSchema && omitId(createSchema),
1772
+ // Strip hidden (`FormInputAnnotation.set(false)`) fields so the
1773
+ // form's validator doesn't reject required-but-hidden fields
1774
+ // such as backing-object refs supplied by a `FactoryAnnotation`.
1775
+ createSchema: createSchema && omitHiddenFormFields(omitId(createSchema)),
1711
1776
  createOptionLabel,
1712
1777
  createOptionIcon,
1713
1778
  createInitialValuePath,
@@ -1753,20 +1818,21 @@ var SelectField = ({ type, readonly, label, layout, placeholder, options, getSta
1753
1818
  };
1754
1819
 
1755
1820
  // src/components/Form/fields/SelectOptionField.tsx
1756
- import React13, { useCallback as useCallback11, useEffect as useEffect5, useRef as useRef3, useState as useState4 } from "react";
1821
+ import React13, { useCallback as useCallback11, useEffect as useEffect4, useRef as useRef2, useState as useState5 } from "react";
1757
1822
  import { PublicKey } from "@dxos/keys";
1758
- import { IconButton as IconButton3, Input as Input8, Tag, useTranslation as useTranslation7 } from "@dxos/react-ui";
1823
+ import { IconButton as IconButton3, Input as Input8, Tag, useTranslation as useTranslation8 } from "@dxos/react-ui";
1759
1824
  import { List } from "@dxos/react-ui-list";
1760
1825
  import { HuePicker } from "@dxos/react-ui-pickers";
1761
1826
  import { hues, osTranslations, subtleHover } from "@dxos/ui-theme";
1827
+ import { translationKey as translationKey8 } from "#translations";
1762
1828
  var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueChange }) => {
1763
- const { t } = useTranslation7(translationKey);
1829
+ const { t } = useTranslation8(translationKey8);
1764
1830
  const { status, error } = getStatus();
1765
- const [selected, setSelectedId] = useState4(null);
1766
- const [isNewOption, setIsNewOption] = useState4(false);
1767
- const inputRef = useRef3(null);
1831
+ const [selected, setSelectedId] = useState5(null);
1832
+ const [isNewOption, setIsNewOption] = useState5(false);
1833
+ const inputRef = useRef2(null);
1768
1834
  const options = getValue();
1769
- useEffect5(() => {
1835
+ useEffect4(() => {
1770
1836
  if (options === void 0) {
1771
1837
  onValueChange(type, []);
1772
1838
  }
@@ -1857,7 +1923,7 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
1857
1923
  type,
1858
1924
  onValueChange
1859
1925
  ]);
1860
- useEffect5(() => {
1926
+ useEffect4(() => {
1861
1927
  if (selected && isNewOption && inputRef.current) {
1862
1928
  inputRef.current.focus();
1863
1929
  setIsNewOption(false);
@@ -1904,7 +1970,7 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
1904
1970
  }, item.title || "\u200B")), /* @__PURE__ */ React13.createElement(IconButton3, {
1905
1971
  iconOnly: true,
1906
1972
  variant: "ghost",
1907
- label: t(selected === item.id ? "collapse label" : "expand label", {
1973
+ label: t(selected === item.id ? "collapse.label" : "expand.label", {
1908
1974
  ns: osTranslations
1909
1975
  }),
1910
1976
  icon: selected === item.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
@@ -1946,7 +2012,7 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
1946
2012
  // src/components/Form/fields/TextField.tsx
1947
2013
  import React14, { useCallback as useCallback12 } from "react";
1948
2014
  import { Input as Input9 } from "@dxos/react-ui";
1949
- var TextField = ({ type, readonly, placeholder, onValueChange, onBlur, ...props }) => {
2015
+ var TextField = ({ type, readonly, placeholder, onBlur, onValueChange, ...props }) => {
1950
2016
  const handleChange = useCallback12((event) => onValueChange(type, event.target.value), [
1951
2017
  type,
1952
2018
  onValueChange
@@ -1959,8 +2025,8 @@ var TextField = ({ type, readonly, placeholder, onValueChange, onBlur, ...props
1959
2025
  disabled: !!readonly,
1960
2026
  placeholder,
1961
2027
  value: value3,
1962
- onChange: handleChange,
1963
- onBlur
2028
+ onBlur,
2029
+ onChange: handleChange
1964
2030
  }));
1965
2031
  };
1966
2032
 
@@ -1988,7 +2054,7 @@ var TextAreaField = ({ type, readonly, placeholder, onValueChange, onBlur, ...pr
1988
2054
  // src/components/Form/fields/TupleField.tsx
1989
2055
  import React16 from "react";
1990
2056
  import { Input as Input11 } from "@dxos/react-ui";
1991
- import { mx as mx3 } from "@dxos/ui-theme";
2057
+ import { mx as mx2 } from "@dxos/ui-theme";
1992
2058
  import { safeParseFloat as safeParseFloat3 } from "@dxos/util";
1993
2059
  var gridCols = [
1994
2060
  "grid-cols-1",
@@ -2006,7 +2072,7 @@ var TupleField = ({ binding, type, readonly, label, getStatus, getValue, onValue
2006
2072
  readonly,
2007
2073
  label
2008
2074
  }), /* @__PURE__ */ React16.createElement("div", {
2009
- className: mx3("grid gap-form-gap", gridCols[binding.length - 1])
2075
+ className: mx2("grid gap-form-gap", gridCols[binding.length - 1])
2010
2076
  }, binding.map((prop) => /* @__PURE__ */ React16.createElement(Input11.TextInput, {
2011
2077
  key: prop,
2012
2078
  type: "number",
@@ -2025,13 +2091,13 @@ var TupleField = ({ binding, type, readonly, label, getStatus, getValue, onValue
2025
2091
  // src/components/FieldEditor/FieldEditor.tsx
2026
2092
  var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx";
2027
2093
  var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCancel }) => {
2028
- const { t } = useTranslation8(translationKey);
2029
- const [props, setProps] = useState5(projection.getFieldProjection(field.id).props);
2030
- useEffect6(() => setProps(projection.getFieldProjection(field.id).props), [
2094
+ const { t } = useTranslation9(translationKey9);
2095
+ const [props, setProps] = useState6(projection.getFieldProjection(field.id).props);
2096
+ useEffect5(() => setProps(projection.getFieldProjection(field.id).props), [
2031
2097
  field,
2032
2098
  projection
2033
2099
  ]);
2034
- const [schemas, setSchemas] = useState5([]);
2100
+ const [schemas, setSchemas] = useState6([]);
2035
2101
  useAsyncEffect(async () => {
2036
2102
  if (!registry) {
2037
2103
  return;
@@ -2045,17 +2111,17 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
2045
2111
  }, [
2046
2112
  registry
2047
2113
  ]);
2048
- const [referenceSchema, setReferenceSchema] = useState5();
2049
- useEffect6(() => {
2114
+ const [referenceSchema, setReferenceSchema] = useState6();
2115
+ useEffect5(() => {
2050
2116
  setReferenceSchema(schemas.find((schema) => schema.typename === props?.referenceSchema));
2051
2117
  }, [
2052
2118
  schemas,
2053
2119
  props?.referenceSchema
2054
2120
  ]);
2055
- const [{ fieldSchema }, setFieldSchema] = useState5({
2121
+ const [{ fieldSchema }, setFieldSchema] = useState6({
2056
2122
  fieldSchema: getFormatSchema(props?.format)
2057
2123
  });
2058
- const fieldMap = useMemo7(() => ({
2124
+ const fieldMap = useMemo8(() => ({
2059
2125
  ["format"]: (props2) => /* @__PURE__ */ React17.createElement(SelectField, {
2060
2126
  ...props2,
2061
2127
  options: FormatEnums.filter((value3) => value3 !== Format4.TypeFormat.None).map((value3) => ({
@@ -2134,7 +2200,7 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
2134
2200
  ]);
2135
2201
  const handleSave = useCallback14((props2) => {
2136
2202
  if (view) {
2137
- Obj2.change(view, () => {
2203
+ Obj3.update(view, () => {
2138
2204
  projection.setFieldProjection({
2139
2205
  field,
2140
2206
  props: props2
@@ -2162,12 +2228,7 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
2162
2228
  if (!fieldSchema) {
2163
2229
  log2.warn("invalid format", {
2164
2230
  props
2165
- }, {
2166
- F: __dxlog_file2,
2167
- L: 172,
2168
- S: void 0,
2169
- C: (f, a) => f(...a)
2170
- });
2231
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 156, S: void 0 });
2171
2232
  return null;
2172
2233
  }
2173
2234
  return /* @__PURE__ */ React17.createElement(Form.Root, {
@@ -2191,12 +2252,13 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
2191
2252
 
2192
2253
  // src/components/ObjectForm/ObjectForm.tsx
2193
2254
  import * as Schema3 from "effect/Schema";
2194
- import React18, { useCallback as useCallback15, useMemo as useMemo8 } from "react";
2195
- import { DXN as DXN2, Obj as Obj3, Ref as Ref3, Tag as Tag2, Type as Type2 } from "@dxos/echo";
2255
+ import React18, { useCallback as useCallback15, useMemo as useMemo9 } from "react";
2256
+ import { DXN as DXN2, Obj as Obj4, Ref as Ref4, Tag as Tag2, Type as Type2 } from "@dxos/echo";
2196
2257
  import { splitJsonPath } from "@dxos/echo/internal";
2197
2258
  import { invariant } from "@dxos/invariant";
2198
2259
  import { HuePicker as HuePicker2 } from "@dxos/react-ui-pickers";
2199
2260
  import { isNonNullable } from "@dxos/util";
2261
+ import { translationKey as translationKey10 } from "#translations";
2200
2262
  var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/ObjectForm/ObjectForm.tsx";
2201
2263
  var createFieldMap = {
2202
2264
  hue: ({ type, label, layout, getValue, onValueChange }) => {
@@ -2218,46 +2280,30 @@ var createFieldMap = {
2218
2280
  }
2219
2281
  };
2220
2282
  var ObjectForm = ({ object, schema }) => {
2221
- const db = Obj3.getDatabase(object);
2222
- const meta = Obj3.getMeta(object);
2283
+ const db = Obj4.getDatabase(object);
2284
+ const meta = Obj4.getMeta(object);
2223
2285
  const tags = (meta.tags ?? []).map((tag) => db?.makeRef(DXN2.parse(tag))).filter(isNonNullable);
2224
- const values = useMemo8(() => ({
2286
+ const values = useMemo9(() => ({
2225
2287
  tags,
2226
2288
  ...object
2227
2289
  }), [
2228
2290
  object,
2229
2291
  tags
2230
2292
  ]);
2231
- const formSchema = useMemo8(() => omitId(Schema3.Struct({
2232
- tags: Schema3.Array(Ref3.Ref(Tag2.Tag)).pipe(Schema3.optional)
2293
+ const formSchema = useMemo9(() => omitId(Schema3.Struct({
2294
+ tags: Schema3.Array(Ref4.Ref(Tag2.Tag)).pipe(Schema3.optional)
2233
2295
  }).pipe(Schema3.extend(schema))), [
2234
2296
  schema
2235
2297
  ]);
2236
2298
  const handleCreate = useCallback15((schema2, values2) => {
2237
- invariant(db, void 0, {
2238
- F: __dxlog_file3,
2239
- L: 51,
2240
- S: void 0,
2241
- A: [
2242
- "db",
2243
- ""
2244
- ]
2245
- });
2246
- invariant(Type2.isObjectSchema(schema2), void 0, {
2247
- F: __dxlog_file3,
2248
- L: 52,
2249
- S: void 0,
2250
- A: [
2251
- "Type.isObjectSchema(schema)",
2252
- ""
2253
- ]
2254
- });
2255
- const newObject = db.add(Obj3.make(schema2, values2));
2256
- if (Obj3.instanceOf(Tag2.Tag, newObject)) {
2257
- Obj3.change(object, (object2) => {
2258
- Obj3.getMeta(object2).tags = [
2259
- ...Obj3.getMeta(object2).tags ?? [],
2260
- Obj3.getDXN(newObject).toString()
2299
+ invariant(db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 49, S: void 0, A: ["db", ""] });
2300
+ invariant(Type2.isObjectSchema(schema2), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 50, S: void 0, A: ["Type.isObjectSchema(schema)", ""] });
2301
+ const newObject = db.add(Obj4.make(schema2, values2));
2302
+ if (Obj4.instanceOf(Tag2.Tag, newObject)) {
2303
+ Obj4.update(object, (object2) => {
2304
+ Obj4.getMeta(object2).tags = [
2305
+ ...Obj4.getMeta(object2).tags ?? [],
2306
+ Obj4.getDXN(newObject).toString()
2261
2307
  ];
2262
2308
  });
2263
2309
  }
@@ -2269,17 +2315,17 @@ var ObjectForm = ({ object, schema }) => {
2269
2315
  const changedPaths = Object.keys(changed).filter((path) => changed[path]);
2270
2316
  const hasTagsChange = changedPaths.some((path) => splitJsonPath(path)[0] === "tags");
2271
2317
  if (hasTagsChange) {
2272
- Obj3.change(object, (object2) => {
2273
- Obj3.getMeta(object2).tags = tags2?.map((tag) => tag.dxn.toString()) ?? [];
2318
+ Obj4.update(object, (object2) => {
2319
+ Obj4.getMeta(object2).tags = tags2?.map((tag) => tag.dxn.toString()) ?? [];
2274
2320
  });
2275
2321
  }
2276
2322
  const nonTagPaths = changedPaths.filter((path) => splitJsonPath(path)[0] !== "tags");
2277
2323
  if (nonTagPaths.length > 0) {
2278
- Obj3.change(object, () => {
2324
+ Obj4.update(object, () => {
2279
2325
  for (const path of nonTagPaths) {
2280
2326
  const parts = splitJsonPath(path);
2281
- const value3 = Obj3.getValue(values2, parts);
2282
- Obj3.setValue(object, parts, value3);
2327
+ const value3 = Obj4.getValue(values2, parts);
2328
+ Obj4.setValue(object, parts, value3);
2283
2329
  }
2284
2330
  });
2285
2331
  }
@@ -2294,7 +2340,7 @@ var ObjectForm = ({ object, schema }) => {
2294
2340
  createOptionLabel: [
2295
2341
  "add-tag.label",
2296
2342
  {
2297
- ns: translationKey
2343
+ ns: translationKey10
2298
2344
  }
2299
2345
  ],
2300
2346
  createInitialValuePath: "label",
@@ -2307,61 +2353,43 @@ var ObjectForm = ({ object, schema }) => {
2307
2353
 
2308
2354
  // src/components/ObjectProperties/ObjectProperties.tsx
2309
2355
  import * as Function from "effect/Function";
2310
- import * as Option4 from "effect/Option";
2356
+ import * as Option5 from "effect/Option";
2311
2357
  import * as Schema4 from "effect/Schema";
2312
- import React19, { useCallback as useCallback16, useMemo as useMemo9 } from "react";
2313
- import { DXN as DXN3, Obj as Obj4, Ref as Ref4, Tag as Tag3, Type as Type3 } from "@dxos/echo";
2358
+ import React19, { useCallback as useCallback16, useMemo as useMemo10 } from "react";
2359
+ import { DXN as DXN3, Obj as Obj5, Ref as Ref5, Tag as Tag3, Type as Type3 } from "@dxos/echo";
2314
2360
  import { splitJsonPath as splitJsonPath2 } from "@dxos/echo/internal";
2315
2361
  import { invariant as invariant2 } from "@dxos/invariant";
2316
2362
  import { HuePicker as HuePicker3 } from "@dxos/react-ui-pickers";
2363
+ import { FactoryAnnotation } from "@dxos/schema";
2317
2364
  import { composable as composable2, composableProps as composableProps2 } from "@dxos/ui-theme";
2318
2365
  import { isNonNullable as isNonNullable2 } from "@dxos/util";
2366
+ import { translationKey as translationKey11 } from "#translations";
2319
2367
  var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/ObjectProperties/ObjectProperties.tsx";
2320
2368
  var ObjectProperties = composable2(({ children, object, ...props }, forwardedRef) => {
2321
- const db = Obj4.getDatabase(object);
2322
- const meta = Obj4.getMeta(object);
2369
+ const db = Obj5.getDatabase(object);
2370
+ const meta = Obj5.getMeta(object);
2323
2371
  const tags = (meta.tags ?? []).map((tag) => db?.makeRef(DXN3.parse(tag))).filter(isNonNullable2);
2324
- const values = useMemo9(() => ({
2372
+ const values = useMemo10(() => ({
2325
2373
  tags,
2326
2374
  ...object
2327
2375
  }), [
2328
2376
  object,
2329
2377
  tags
2330
2378
  ]);
2331
- const formSchema = useMemo9(() => {
2332
- return Function.pipe(Obj4.getSchema(object), Option4.fromNullable, Option4.map((schema) => omitId(BaseSchema.pipe(Schema4.extend(schema)))), Option4.getOrUndefined);
2379
+ const formSchema = useMemo10(() => {
2380
+ return Function.pipe(Obj5.getSchema(object), Option5.fromNullable, Option5.map((schema) => omitId(BaseSchema.pipe(Schema4.extend(schema)))), Option5.getOrUndefined);
2333
2381
  }, [
2334
2382
  object
2335
2383
  ]);
2336
2384
  const handleCreate = useCallback16((schema, values2) => {
2337
- invariant2(db, void 0, {
2338
- F: __dxlog_file4,
2339
- L: 40,
2340
- S: void 0,
2341
- A: [
2342
- "db",
2343
- ""
2344
- ]
2345
- });
2346
- invariant2(Type3.isObjectSchema(schema), void 0, {
2347
- F: __dxlog_file4,
2348
- L: 41,
2349
- S: void 0,
2350
- A: [
2351
- "Type.isObjectSchema(schema)",
2352
- ""
2353
- ]
2354
- });
2355
- const newObject = db.add(Obj4.make(schema, values2));
2356
- if (Obj4.instanceOf(Tag3.Tag, newObject)) {
2357
- Obj4.change(object, (object2) => {
2358
- Obj4.getMeta(object2).tags = [
2359
- ...Obj4.getMeta(object2).tags ?? [],
2360
- Obj4.getDXN(newObject).toString()
2361
- ];
2362
- });
2363
- }
2364
- }, []);
2385
+ invariant2(db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 45, S: void 0, A: ["db", ""] });
2386
+ invariant2(Type3.isObjectSchema(schema), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 46, S: void 0, A: ["Type.isObjectSchema(schema)", ""] });
2387
+ const factory = Option5.getOrUndefined(FactoryAnnotation.get(schema));
2388
+ const newObject = factory ? factory(values2) : Obj5.make(schema, values2);
2389
+ return db.add(newObject);
2390
+ }, [
2391
+ db
2392
+ ]);
2365
2393
  const handleChange = useCallback16(({ tags: tags2, ...values2 }, { isValid, changed }) => {
2366
2394
  if (!isValid) {
2367
2395
  return;
@@ -2369,17 +2397,17 @@ var ObjectProperties = composable2(({ children, object, ...props }, forwardedRef
2369
2397
  const changedPaths = Object.keys(changed).filter((path) => changed[path]);
2370
2398
  const hasTagsChange = changedPaths.some((path) => splitJsonPath2(path)[0] === "tags");
2371
2399
  if (hasTagsChange) {
2372
- Obj4.change(object, (object2) => {
2373
- Obj4.getMeta(object2).tags = tags2?.map((tag) => tag.dxn.toString()) ?? [];
2400
+ Obj5.update(object, (object2) => {
2401
+ Obj5.getMeta(object2).tags = tags2?.map((tag) => tag.dxn.toString()) ?? [];
2374
2402
  });
2375
2403
  }
2376
2404
  const nonTagPaths = changedPaths.filter((path) => splitJsonPath2(path)[0] !== "tags");
2377
2405
  if (nonTagPaths.length > 0) {
2378
- Obj4.change(object, () => {
2406
+ Obj5.update(object, () => {
2379
2407
  for (const path of nonTagPaths) {
2380
2408
  const parts = splitJsonPath2(path);
2381
- const value3 = Obj4.getValue(values2, parts);
2382
- Obj4.setValue(object, parts, value3);
2409
+ const value3 = Obj5.getValue(values2, parts);
2410
+ Obj5.setValue(object, parts, value3);
2383
2411
  }
2384
2412
  });
2385
2413
  }
@@ -2397,7 +2425,7 @@ var ObjectProperties = composable2(({ children, object, ...props }, forwardedRef
2397
2425
  createOptionLabel: [
2398
2426
  "add-tag.label",
2399
2427
  {
2400
- ns: translationKey
2428
+ ns: translationKey11
2401
2429
  }
2402
2430
  ],
2403
2431
  createInitialValuePath: "label",
@@ -2430,102 +2458,283 @@ var createFieldMap2 = {
2430
2458
  }
2431
2459
  };
2432
2460
  var BaseSchema = Schema4.Struct({
2433
- tags: Schema4.Array(Ref4.Ref(Tag3.Tag)).pipe(Schema4.optional)
2461
+ tags: Schema4.Array(Ref5.Ref(Tag3.Tag)).pipe(Schema4.optional)
2434
2462
  });
2435
2463
 
2436
2464
  // src/components/Settings/Settings.tsx
2437
- import React20 from "react";
2438
- import { Input as Input12, ScrollArea as ScrollArea2, toLocalizedString, useTranslation as useTranslation9 } from "@dxos/react-ui";
2465
+ import React22 from "react";
2466
+ import { ScrollArea as ScrollArea2, toLocalizedString as toLocalizedString2, useTranslation as useTranslation11 } from "@dxos/react-ui";
2439
2467
  import { composable as composable3, composableProps as composableProps3, mx as mx4 } from "@dxos/ui-theme";
2468
+ import { translationKey as translationKey13 } from "#translations";
2469
+
2470
+ // src/components/Settings/SettingsFieldSet.tsx
2471
+ import * as SchemaAST5 from "effect/SchemaAST";
2472
+ import * as String3 from "effect/String";
2473
+ import React21, { useCallback as useCallback17, useMemo as useMemo11 } from "react";
2474
+ import { getAnnotation as getAnnotation3 } from "@dxos/effect";
2475
+ import { Input as Input13, Select as Select2 } from "@dxos/react-ui";
2476
+
2477
+ // src/components/Settings/SettingsItem.tsx
2478
+ import React20 from "react";
2479
+ import { Input as Input12, toLocalizedString, useTranslation as useTranslation10 } from "@dxos/react-ui";
2480
+ import { mx as mx3 } from "@dxos/ui-theme";
2481
+ import { translationKey as translationKey12 } from "#translations";
2482
+ var SETTINGS_PANEL_NAME = "Settings.Panel";
2483
+ var SETTINGS_ITEM_NAME = "Settings.Item";
2484
+ var SettingsPanel = ({ classNames, children }) => {
2485
+ return /* @__PURE__ */ React20.createElement("div", {
2486
+ role: "none",
2487
+ className: mx3("flex flex-col gap-3 p-trim-md border border-separator rounded-sm", classNames)
2488
+ }, children);
2489
+ };
2490
+ SettingsPanel.displayName = SETTINGS_PANEL_NAME;
2491
+ var SettingsItem = ({ title, description = "", children }) => {
2492
+ const { t } = useTranslation10(translationKey12);
2493
+ return /* @__PURE__ */ React20.createElement(Input12.Root, null, /* @__PURE__ */ React20.createElement(SettingsPanel, {
2494
+ classNames: "grid grid-cols-1 md:grid-cols-[1fr_1fr] gap-x-trim-lg gap-y-0"
2495
+ }, /* @__PURE__ */ React20.createElement(Input12.Label, {
2496
+ classNames: "pb-trim-md text-base-surface-text text-lg md:col-span-2"
2497
+ }, toLocalizedString(title, t)), /* @__PURE__ */ React20.createElement(Input12.DescriptionAndValidation, null, /* @__PURE__ */ React20.createElement(Input12.Description, {
2498
+ classNames: "text-base text-description"
2499
+ }, toLocalizedString(description, t))), /* @__PURE__ */ React20.createElement("div", {
2500
+ role: "none",
2501
+ className: "text-end py-1"
2502
+ }, children)));
2503
+ };
2504
+ SettingsItem.displayName = SETTINGS_ITEM_NAME;
2505
+
2506
+ // src/components/Settings/SettingsFieldSet.tsx
2507
+ var SettingsFieldSet = ({ schema, values, onValuesChanged, readonly, fieldMap, visible, sort, pathPrefix = "" }) => {
2508
+ const properties = useMemo11(() => {
2509
+ const props = getFormProperties(schema.ast);
2510
+ if (!sort) {
2511
+ return props;
2512
+ }
2513
+ const rank = (name) => {
2514
+ const idx = sort.indexOf(name);
2515
+ return idx === -1 ? Number.POSITIVE_INFINITY : idx;
2516
+ };
2517
+ return [
2518
+ ...props
2519
+ ].sort(({ name: a }, { name: b }) => rank(a.toString()) - rank(b.toString()));
2520
+ }, [
2521
+ schema,
2522
+ sort
2523
+ ]);
2524
+ const handleChange = useCallback17((name, value3) => {
2525
+ onValuesChanged?.({
2526
+ ...values,
2527
+ [name]: value3
2528
+ });
2529
+ }, [
2530
+ values,
2531
+ onValuesChanged
2532
+ ]);
2533
+ return /* @__PURE__ */ React21.createElement(React21.Fragment, null, properties.map((property) => {
2534
+ const name = property.name.toString();
2535
+ const path = pathPrefix ? `${pathPrefix}.${name}` : name;
2536
+ if (visible && !visible(path, values)) {
2537
+ return null;
2538
+ }
2539
+ const entry = fieldMap?.[name];
2540
+ return /* @__PURE__ */ React21.createElement(SettingsFieldItem, {
2541
+ key: name,
2542
+ path,
2543
+ property,
2544
+ value: values[name],
2545
+ onChange: (value3) => handleChange(name, value3),
2546
+ readonly,
2547
+ customField: typeof entry === "function" ? entry : void 0,
2548
+ nestedFieldMap: typeof entry === "object" ? entry : void 0,
2549
+ visible,
2550
+ sort
2551
+ });
2552
+ }));
2553
+ };
2554
+ SettingsFieldSet.displayName = "Settings.FieldSet";
2555
+ var SettingsFieldItem = ({ property, path, value: value3, onChange, readonly, customField, nestedFieldMap, visible, sort }) => {
2556
+ const { type } = property;
2557
+ const name = property.name.toString();
2558
+ const title = getAnnotation3(SchemaAST5.TitleAnnotationId)(type) ?? String3.capitalize(name);
2559
+ const description = getAnnotation3(SchemaAST5.DescriptionAnnotationId)(type);
2560
+ if (customField) {
2561
+ const CustomField = customField;
2562
+ return /* @__PURE__ */ React21.createElement(SettingsItem, {
2563
+ title,
2564
+ description
2565
+ }, /* @__PURE__ */ React21.createElement(CustomField, {
2566
+ value: value3,
2567
+ onChange,
2568
+ readonly
2569
+ }));
2570
+ }
2571
+ const fieldType = detectFieldType(type);
2572
+ switch (fieldType) {
2573
+ case "struct":
2574
+ return /* @__PURE__ */ React21.createElement(SettingsFieldSet, {
2575
+ schema: {
2576
+ ast: type
2577
+ },
2578
+ values: value3 ?? {},
2579
+ onValuesChanged: onChange,
2580
+ readonly,
2581
+ fieldMap: nestedFieldMap,
2582
+ visible,
2583
+ sort,
2584
+ pathPrefix: path
2585
+ });
2586
+ case "boolean":
2587
+ return /* @__PURE__ */ React21.createElement(SettingsItem, {
2588
+ title,
2589
+ description
2590
+ }, /* @__PURE__ */ React21.createElement(Input13.Switch, {
2591
+ disabled: readonly,
2592
+ checked: !!value3,
2593
+ onCheckedChange: (checked) => onChange(!!checked)
2594
+ }));
2595
+ case "select": {
2596
+ const options = getSelectOptionsFromAst(type) ?? [];
2597
+ return /* @__PURE__ */ React21.createElement(SettingsItem, {
2598
+ title,
2599
+ description
2600
+ }, /* @__PURE__ */ React21.createElement(Select2.Root, {
2601
+ disabled: readonly,
2602
+ value: value3 == null ? "" : globalThis.String(value3),
2603
+ onValueChange: (selected) => {
2604
+ const matched = options.find((option) => globalThis.String(option.value) === selected);
2605
+ onChange(matched?.value ?? selected);
2606
+ }
2607
+ }, /* @__PURE__ */ React21.createElement(Select2.TriggerButton, {
2608
+ disabled: readonly
2609
+ }), /* @__PURE__ */ React21.createElement(Select2.Portal, null, /* @__PURE__ */ React21.createElement(Select2.Content, null, /* @__PURE__ */ React21.createElement(Select2.Viewport, null, options.map((option) => /* @__PURE__ */ React21.createElement(Select2.Option, {
2610
+ key: globalThis.String(option.value),
2611
+ value: globalThis.String(option.value)
2612
+ }, option.label ?? globalThis.String(option.value)))), /* @__PURE__ */ React21.createElement(Select2.Arrow, null)))));
2613
+ }
2614
+ case "string":
2615
+ return /* @__PURE__ */ React21.createElement(SettingsItem, {
2616
+ title,
2617
+ description
2618
+ }, /* @__PURE__ */ React21.createElement(Input13.TextInput, {
2619
+ disabled: readonly,
2620
+ value: value3 ?? "",
2621
+ onChange: (event) => onChange(event.target.value)
2622
+ }));
2623
+ case "number":
2624
+ return /* @__PURE__ */ React21.createElement(SettingsItem, {
2625
+ title,
2626
+ description
2627
+ }, /* @__PURE__ */ React21.createElement(Input13.TextInput, {
2628
+ disabled: readonly,
2629
+ type: "number",
2630
+ value: value3 ?? "",
2631
+ onChange: (event) => {
2632
+ if (event.target.value === "") {
2633
+ onChange(void 0);
2634
+ return;
2635
+ }
2636
+ const parsed = Number(event.target.value);
2637
+ onChange(Number.isNaN(parsed) ? void 0 : parsed);
2638
+ }
2639
+ }));
2640
+ default:
2641
+ return null;
2642
+ }
2643
+ };
2644
+
2645
+ // src/components/Settings/Settings.tsx
2440
2646
  var SETTINGS_ROOT_NAME = "Settings.Root";
2441
2647
  var SETTINGS_VIEWPORT_NAME = "Settings.Viewport";
2442
2648
  var SETTINGS_SECTION_NAME = "Settings.Section";
2443
- var SETTINGS_PANEL_NAME = "Settings.Panel";
2444
- var SETTINGS_ITEM_NAME = "Settings.Item";
2445
2649
  var SettingsRoot = ({ children, classNames }) => {
2446
- return /* @__PURE__ */ React20.createElement("div", {
2650
+ return /* @__PURE__ */ React22.createElement("div", {
2447
2651
  className: mx4("flex flex-col gap-2", classNames)
2448
2652
  }, children);
2449
2653
  };
2450
2654
  SettingsRoot.displayName = SETTINGS_ROOT_NAME;
2451
2655
  var SettingsViewport = composable3(({ children, ...props }, forwardedRef) => {
2452
- return /* @__PURE__ */ React20.createElement(ScrollArea2.Root, {
2656
+ return /* @__PURE__ */ React22.createElement(ScrollArea2.Root, {
2453
2657
  ...composableProps3(props),
2454
2658
  orientation: "vertical",
2455
2659
  centered: true,
2456
2660
  thin: true,
2457
2661
  ref: forwardedRef
2458
- }, /* @__PURE__ */ React20.createElement(ScrollArea2.Viewport, {
2662
+ }, /* @__PURE__ */ React22.createElement(ScrollArea2.Viewport, {
2459
2663
  classNames: "px-4 pointer-coarse:px-2"
2460
- }, /* @__PURE__ */ React20.createElement("div", {
2664
+ }, /* @__PURE__ */ React22.createElement("div", {
2461
2665
  role: "none",
2462
2666
  className: "dx-document flex flex-col gap-2 py-4"
2463
2667
  }, children)));
2464
2668
  });
2465
2669
  SettingsViewport.displayName = SETTINGS_VIEWPORT_NAME;
2466
2670
  var SettingsSection = ({ title, description, children }) => {
2467
- const { t } = useTranslation9(translationKey);
2468
- return /* @__PURE__ */ React20.createElement(React20.Fragment, null, /* @__PURE__ */ React20.createElement("h2", {
2671
+ const { t } = useTranslation11(translationKey13);
2672
+ return /* @__PURE__ */ React22.createElement(React22.Fragment, null, /* @__PURE__ */ React22.createElement("h2", {
2469
2673
  className: "px-trim-md mt-trim-md text-xl"
2470
- }, toLocalizedString(title, t)), description && /* @__PURE__ */ React20.createElement("p", {
2674
+ }, toLocalizedString2(title, t)), description && /* @__PURE__ */ React22.createElement("p", {
2471
2675
  className: "px-trim-md text-description"
2472
- }, toLocalizedString(description, t)), /* @__PURE__ */ React20.createElement("div", {
2676
+ }, toLocalizedString2(description, t)), /* @__PURE__ */ React22.createElement("div", {
2473
2677
  className: "w-full pt-trim-md space-y-trim-md"
2474
2678
  }, children));
2475
2679
  };
2476
2680
  SettingsSection.displayName = SETTINGS_SECTION_NAME;
2477
- var SettingsPanel = ({ classNames, children }) => {
2478
- return /* @__PURE__ */ React20.createElement("div", {
2479
- role: "none",
2480
- className: mx4("flex flex-col gap-3 p-trim-md border border-separator rounded-sm", classNames)
2481
- }, children);
2482
- };
2483
- SettingsPanel.displayName = SETTINGS_PANEL_NAME;
2484
- var SettingsItem = ({ title, description = "", children }) => {
2485
- const { t } = useTranslation9(translationKey);
2486
- return /* @__PURE__ */ React20.createElement(Input12.Root, null, /* @__PURE__ */ React20.createElement(SettingsPanel, {
2487
- classNames: "grid grid-cols-1 md:grid-cols-[1fr_1fr] gap-x-trim-lg gap-y-0"
2488
- }, /* @__PURE__ */ React20.createElement(Input12.Label, {
2489
- classNames: "pb-trim-md text-base-surface-text text-lg md:col-span-2"
2490
- }, toLocalizedString(title, t)), /* @__PURE__ */ React20.createElement(Input12.DescriptionAndValidation, null, /* @__PURE__ */ React20.createElement(Input12.Description, {
2491
- classNames: "text-base text-description"
2492
- }, toLocalizedString(description, t))), /* @__PURE__ */ React20.createElement("div", {
2493
- role: "none",
2494
- className: "text-end py-1"
2495
- }, children)));
2496
- };
2497
- SettingsItem.displayName = SETTINGS_ITEM_NAME;
2498
2681
  var Settings = {
2499
2682
  Root: SettingsRoot,
2500
2683
  Viewport: SettingsViewport,
2501
2684
  Section: SettingsSection,
2502
2685
  Panel: SettingsPanel,
2503
- Item: SettingsItem
2686
+ Item: SettingsItem,
2687
+ FieldSet: SettingsFieldSet
2688
+ };
2689
+
2690
+ // src/components/Settings/SettingsSelectField.tsx
2691
+ import React23 from "react";
2692
+ import { Select as Select3 } from "@dxos/react-ui";
2693
+ var createSelectField = ({ options, defaultLabel = "Default" }) => {
2694
+ const normalized = options.map((option) => typeof option === "string" ? {
2695
+ value: option,
2696
+ label: option
2697
+ } : option);
2698
+ const hasDefault = defaultLabel !== null;
2699
+ const sentinel = hasDefault ? `__default__${Math.random().toString(36).slice(2)}` : "";
2700
+ return ({ value: value3, onChange, readonly }) => /* @__PURE__ */ React23.createElement(Select3.Root, {
2701
+ disabled: readonly,
2702
+ value: value3 ?? sentinel,
2703
+ onValueChange: (next) => onChange(hasDefault && next === sentinel ? void 0 : next)
2704
+ }, /* @__PURE__ */ React23.createElement(Select3.TriggerButton, {
2705
+ disabled: readonly
2706
+ }), /* @__PURE__ */ React23.createElement(Select3.Portal, null, /* @__PURE__ */ React23.createElement(Select3.Content, null, /* @__PURE__ */ React23.createElement(Select3.Viewport, null, hasDefault && /* @__PURE__ */ React23.createElement(Select3.Option, {
2707
+ value: sentinel
2708
+ }, defaultLabel), normalized.map((option) => /* @__PURE__ */ React23.createElement(Select3.Option, {
2709
+ key: option.value,
2710
+ value: option.value
2711
+ }, option.label ?? option.value))), /* @__PURE__ */ React23.createElement(Select3.Arrow, null))));
2504
2712
  };
2505
2713
 
2506
2714
  // src/components/ViewEditor/ViewEditor.tsx
2507
2715
  import { RegistryContext } from "@effect-atom/atom-react";
2508
2716
  import * as Array4 from "effect/Array";
2509
2717
  import * as Match2 from "effect/Match";
2510
- import * as Option5 from "effect/Option";
2718
+ import * as Option6 from "effect/Option";
2511
2719
  import * as Schema5 from "effect/Schema";
2512
- import React21, { forwardRef as forwardRef2, useCallback as useCallback17, useContext, useImperativeHandle, useMemo as useMemo10, useState as useState6 } from "react";
2513
- import { Entity as Entity2, Feed, Filter as Filter2, Format as Format5, Obj as Obj5, Query, QueryAST, Ref as Ref5 } from "@dxos/echo";
2720
+ import React24, { forwardRef as forwardRef2, useCallback as useCallback18, useContext, useImperativeHandle, useMemo as useMemo12, useState as useState7 } from "react";
2721
+ import { Entity as Entity2, Feed, Filter as Filter2, Format as Format5, Obj as Obj6, Query, QueryAST, Ref as Ref6 } from "@dxos/echo";
2514
2722
  import { View } from "@dxos/echo";
2515
2723
  import { EchoSchema, isMutable, toJsonSchema } from "@dxos/echo/internal";
2516
2724
  import { invariant as invariant3 } from "@dxos/invariant";
2517
2725
  import { useObject, useQuery as useQuery2 } from "@dxos/react-client/echo";
2518
- import { IconButton as IconButton4, Input as Input13, Message, useTranslation as useTranslation10 } from "@dxos/react-ui";
2726
+ import { IconButton as IconButton4, Input as Input14, Message, useTranslation as useTranslation12 } from "@dxos/react-ui";
2519
2727
  import { QueryForm } from "@dxos/react-ui-components";
2520
2728
  import { List as List2 } from "@dxos/react-ui-list";
2521
2729
  import { ParentLabelAnnotation, ProjectionModel, VIEW_FIELD_LIMIT, createEchoChangeCallback, getTypenameFromQuery } from "@dxos/schema";
2522
2730
  import { mx as mx5, osTranslations as osTranslations2, subtleHover as subtleHover2 } from "@dxos/ui-theme";
2731
+ import { translationKey as translationKey14 } from "#translations";
2523
2732
  var __dxlog_file5 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx";
2524
2733
  var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode = "schema", registry, db, readonly, showHeading = false, types, tags, onQueryChanged, onDelete }, forwardedRef) => {
2525
2734
  const atomRegistry = useContext(RegistryContext);
2526
2735
  const schemaReadonly = !isMutable(schema);
2527
- const { t } = useTranslation10(translationKey);
2528
- const projectionModel = useMemo10(() => {
2736
+ const { t } = useTranslation12(translationKey14);
2737
+ const projectionModel = useMemo12(() => {
2529
2738
  const jsonSchema = schema instanceof EchoSchema ? schema.jsonSchema : toJsonSchema(schema);
2530
2739
  const change = createEchoChangeCallback(view, schema instanceof EchoSchema ? schema : void 0);
2531
2740
  const model = new ProjectionModel({
@@ -2549,20 +2758,20 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
2549
2758
  if (from._tag !== "scope") {
2550
2759
  return void 0;
2551
2760
  }
2552
- return Option5.fromNullable(from.scope.queues).pipe(Option5.flatMap((queues) => Array4.head(queues)), Option5.map(String), Option5.getOrUndefined);
2761
+ return Option6.fromNullable(from.scope.queues).pipe(Option6.flatMap((queues) => Array4.head(queues)), Option6.map(String), Option6.getOrUndefined);
2553
2762
  }), Match2.orElse(() => void 0));
2554
2763
  const feeds = useQuery2(db, Filter2.type(Feed.Feed));
2555
- const targetRef = useMemo10(() => {
2764
+ const targetRef = useMemo12(() => {
2556
2765
  if (!queueTarget) {
2557
2766
  return void 0;
2558
2767
  }
2559
2768
  const feed = feeds.find((feed2) => Feed.getQueueDxn(feed2)?.toString() === queueTarget);
2560
- return feed ? Ref5.fromDXN(Entity2.getDXN(feed)) : void 0;
2769
+ return feed ? Ref6.fromDXN(Entity2.getDXN(feed)) : void 0;
2561
2770
  }, [
2562
2771
  queueTarget,
2563
2772
  feeds
2564
2773
  ]);
2565
- const viewSchema = useMemo10(() => {
2774
+ const viewSchema = useMemo12(() => {
2566
2775
  const base = Schema5.Struct({
2567
2776
  query: mode === "schema" ? Format5.URL.annotations({
2568
2777
  title: "Record type"
@@ -2574,7 +2783,7 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
2574
2783
  return Schema5.Struct({
2575
2784
  ...base.fields,
2576
2785
  // TODO(wittjosiah): Replace Type.Feed with Dataset.Dataset when Ref.Ref supports unions.
2577
- target: Ref5.Ref(Feed.Feed).pipe(Schema5.annotations({
2786
+ target: Ref6.Ref(Feed.Feed).pipe(Schema5.annotations({
2578
2787
  title: "Target Feed"
2579
2788
  }), ParentLabelAnnotation.set(true), Schema5.optional)
2580
2789
  }).pipe(Schema5.mutable);
@@ -2583,7 +2792,7 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
2583
2792
  }, [
2584
2793
  mode
2585
2794
  ]);
2586
- const viewValues = useMemo10(() => ({
2795
+ const viewValues = useMemo12(() => ({
2587
2796
  query: mode === "schema" ? getTypenameFromQuery(view.query.ast) : view.query.ast,
2588
2797
  target: targetRef
2589
2798
  }), [
@@ -2591,7 +2800,7 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
2591
2800
  view.query.ast,
2592
2801
  targetRef
2593
2802
  ]);
2594
- const fieldMap = useMemo10(() => mode === "tag" ? customFields({
2803
+ const fieldMap = useMemo12(() => mode === "tag" ? customFields({
2595
2804
  types,
2596
2805
  tags
2597
2806
  }) : void 0, [
@@ -2599,12 +2808,12 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
2599
2808
  types,
2600
2809
  tags
2601
2810
  ]);
2602
- const handleUpdate = useCallback17((values) => {
2811
+ const handleUpdate = useCallback18((values) => {
2603
2812
  const targetValue = values.target;
2604
2813
  let queueDxn;
2605
- if (Ref5.isRef(targetValue)) {
2814
+ if (Ref6.isRef(targetValue)) {
2606
2815
  const feedDxn = targetValue.dxn.toString();
2607
- const feed = feeds.find((feed2) => Obj5.getDXN(feed2).toString() === feedDxn);
2816
+ const feed = feeds.find((feed2) => Obj6.getDXN(feed2).toString() === feedDxn);
2608
2817
  if (feed) {
2609
2818
  queueDxn = Feed.getQueueDxn(feed)?.toString();
2610
2819
  }
@@ -2616,37 +2825,29 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
2616
2825
  mode,
2617
2826
  feeds
2618
2827
  ]);
2619
- const handleDelete = useCallback17((fieldId) => {
2620
- invariant3(!readonly, void 0, {
2621
- F: __dxlog_file5,
2622
- L: 185,
2623
- S: void 0,
2624
- A: [
2625
- "!readonly",
2626
- ""
2627
- ]
2628
- });
2828
+ const handleDelete = useCallback18((fieldId) => {
2829
+ invariant3(!readonly, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 127, S: void 0, A: ["!readonly", ""] });
2629
2830
  onDelete?.(fieldId);
2630
2831
  }, [
2631
2832
  onDelete,
2632
2833
  readonly
2633
2834
  ]);
2634
- return /* @__PURE__ */ React21.createElement("div", {
2835
+ return /* @__PURE__ */ React24.createElement("div", {
2635
2836
  role: "none",
2636
2837
  className: mx5(classNames)
2637
- }, schemaReadonly && !readonly && /* @__PURE__ */ React21.createElement(Message.Root, {
2838
+ }, schemaReadonly && !readonly && /* @__PURE__ */ React24.createElement(Message.Root, {
2638
2839
  valence: "info",
2639
2840
  classNames: "my-form-padding"
2640
- }, /* @__PURE__ */ React21.createElement(Message.Title, null, t("system-schema.description"))), /* @__PURE__ */ React21.createElement(Form.Root, {
2841
+ }, /* @__PURE__ */ React24.createElement(Message.Title, null, t("system-schema.description"))), /* @__PURE__ */ React24.createElement(Form.Root, {
2641
2842
  schema: viewSchema,
2642
2843
  values: viewValues,
2643
2844
  fieldMap,
2644
2845
  db,
2645
2846
  onValuesChanged: handleUpdate
2646
- }, /* @__PURE__ */ React21.createElement(Form.FieldSet, null), /* @__PURE__ */ React21.createElement(FormFieldLabel, {
2847
+ }, /* @__PURE__ */ React24.createElement(Form.FieldSet, null), /* @__PURE__ */ React24.createElement(FormFieldLabel, {
2647
2848
  label: t("fields.label"),
2648
2849
  asChild: true
2649
- }), /* @__PURE__ */ React21.createElement(FieldList, {
2850
+ }), /* @__PURE__ */ React24.createElement(FieldList, {
2650
2851
  schema,
2651
2852
  view,
2652
2853
  registry,
@@ -2658,9 +2859,9 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
2658
2859
  var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDelete }) => {
2659
2860
  const atomRegistry = useContext(RegistryContext);
2660
2861
  const schemaReadonly = !isMutable(schema);
2661
- const { t } = useTranslation10(translationKey);
2862
+ const { t } = useTranslation12(translationKey14);
2662
2863
  const [viewSnapshot] = useObject(view);
2663
- const projectionModel = useMemo10(() => {
2864
+ const projectionModel = useMemo12(() => {
2664
2865
  const jsonSchema = schema instanceof EchoSchema ? schema.jsonSchema : toJsonSchema(schema);
2665
2866
  const change = createEchoChangeCallback(view, schema instanceof EchoSchema ? schema : void 0);
2666
2867
  const model = new ProjectionModel({
@@ -2675,38 +2876,22 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
2675
2876
  schema,
2676
2877
  view
2677
2878
  ]);
2678
- const [expandedField, setExpandedField] = useState6();
2679
- const handleAdd = useCallback17(() => {
2680
- invariant3(!readonly, void 0, {
2681
- F: __dxlog_file5,
2682
- L: 250,
2683
- S: void 0,
2684
- A: [
2685
- "!readonly",
2686
- ""
2687
- ]
2688
- });
2879
+ const [expandedField, setExpandedField] = useState7();
2880
+ const handleAdd = useCallback18(() => {
2881
+ invariant3(!readonly, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 183, S: void 0, A: ["!readonly", ""] });
2689
2882
  const field = projectionModel.createFieldProjection();
2690
2883
  setExpandedField(field.id);
2691
2884
  }, [
2692
2885
  projectionModel,
2693
2886
  readonly
2694
2887
  ]);
2695
- const handleToggleField = useCallback17((field) => {
2888
+ const handleToggleField = useCallback18((field) => {
2696
2889
  setExpandedField((prevExpandedFieldId) => prevExpandedFieldId === field.id ? void 0 : field.id);
2697
2890
  }, [
2698
2891
  readonly
2699
2892
  ]);
2700
- const handleDelete = useCallback17((fieldId) => {
2701
- invariant3(!readonly, void 0, {
2702
- F: __dxlog_file5,
2703
- L: 264,
2704
- S: void 0,
2705
- A: [
2706
- "!readonly",
2707
- ""
2708
- ]
2709
- });
2893
+ const handleDelete = useCallback18((fieldId) => {
2894
+ invariant3(!readonly, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 196, S: void 0, A: ["!readonly", ""] });
2710
2895
  if (fieldId === expandedField) {
2711
2896
  setExpandedField(void 0);
2712
2897
  }
@@ -2716,17 +2901,9 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
2716
2901
  onDelete,
2717
2902
  readonly
2718
2903
  ]);
2719
- const handleMove = useCallback17((fromIndex, toIndex) => {
2720
- invariant3(!readonly, void 0, {
2721
- F: __dxlog_file5,
2722
- L: 276,
2723
- S: void 0,
2724
- A: [
2725
- "!readonly",
2726
- ""
2727
- ]
2728
- });
2729
- Obj5.change(view, (view2) => {
2904
+ const handleMove = useCallback18((fromIndex, toIndex) => {
2905
+ invariant3(!readonly, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 207, S: void 0, A: ["!readonly", ""] });
2906
+ Obj6.update(view, (view2) => {
2730
2907
  const fields = [
2731
2908
  ...view2.projection.fields
2732
2909
  ];
@@ -2738,14 +2915,14 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
2738
2915
  view,
2739
2916
  readonly
2740
2917
  ]);
2741
- const handleClose = useCallback17(() => setExpandedField(void 0), []);
2742
- const handleHide = useCallback17((fieldId) => {
2918
+ const handleClose = useCallback18(() => setExpandedField(void 0), []);
2919
+ const handleHide = useCallback18((fieldId) => {
2743
2920
  setExpandedField(void 0);
2744
2921
  projectionModel.hideFieldProjection(fieldId);
2745
2922
  }, [
2746
2923
  projectionModel
2747
2924
  ]);
2748
- const handleShow = useCallback17((property) => {
2925
+ const handleShow = useCallback18((property) => {
2749
2926
  setExpandedField(void 0);
2750
2927
  projectionModel.showFieldProjection(property);
2751
2928
  }, [
@@ -2754,46 +2931,46 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
2754
2931
  if (!viewSnapshot) {
2755
2932
  return null;
2756
2933
  }
2757
- return /* @__PURE__ */ React21.createElement(List2.Root, {
2934
+ return /* @__PURE__ */ React24.createElement(List2.Root, {
2758
2935
  items: viewSnapshot.projection.fields,
2759
2936
  isItem: Schema5.is(View.FieldSchema),
2760
2937
  getId: (field) => field.id,
2761
2938
  onMove: readonly ? void 0 : handleMove,
2762
2939
  readonly
2763
- }, ({ items: fields }) => /* @__PURE__ */ React21.createElement(React21.Fragment, null, showHeading && /* @__PURE__ */ React21.createElement("h3", {
2940
+ }, ({ items: fields }) => /* @__PURE__ */ React24.createElement(React24.Fragment, null, showHeading && /* @__PURE__ */ React24.createElement("h3", {
2764
2941
  className: "text-sm"
2765
- }, t("field-path.label")), /* @__PURE__ */ React21.createElement("div", {
2942
+ }, t("field-path.label")), /* @__PURE__ */ React24.createElement("div", {
2766
2943
  role: "list",
2767
2944
  className: "grid grid-cols-[min-content_1fr_min-content_min-content_min-content]"
2768
2945
  }, fields?.map((field) => {
2769
2946
  const hidden = field.visible === false;
2770
- return /* @__PURE__ */ React21.createElement(List2.Item, {
2947
+ return /* @__PURE__ */ React24.createElement(List2.Item, {
2771
2948
  key: field.id,
2772
2949
  item: field,
2773
2950
  classNames: "grid grid-cols-subgrid col-span-5",
2774
2951
  "aria-expanded": expandedField === field.id
2775
- }, /* @__PURE__ */ React21.createElement("div", {
2952
+ }, /* @__PURE__ */ React24.createElement("div", {
2776
2953
  role: "none",
2777
2954
  className: mx5(subtleHover2, "grid grid-cols-subgrid col-span-5", "rounded-xs cursor-pointer min-h-10")
2778
- }, /* @__PURE__ */ React21.createElement(List2.ItemDragHandle, {
2955
+ }, /* @__PURE__ */ React24.createElement(List2.ItemDragHandle, {
2779
2956
  disabled: readonly || schemaReadonly
2780
- }), /* @__PURE__ */ React21.createElement(List2.ItemTitle, {
2957
+ }), /* @__PURE__ */ React24.createElement(List2.ItemTitle, {
2781
2958
  classNames: hidden && "text-subdued",
2782
2959
  onClick: () => handleToggleField(field)
2783
- }, field.path), /* @__PURE__ */ React21.createElement(List2.ItemIconButton, {
2784
- label: t(hidden ? "show field label" : "hide field label"),
2960
+ }, field.path), /* @__PURE__ */ React24.createElement(List2.ItemIconButton, {
2961
+ label: t(hidden ? "show-field.label" : "hide-field.label"),
2785
2962
  "data-testid": hidden ? "show-field-button" : "hide-field-button",
2786
2963
  icon: hidden ? "ph--eye-closed--regular" : "ph--eye--regular",
2787
2964
  autoHide: false,
2788
2965
  disabled: readonly || !hidden && projectionModel.getFields().length <= 1,
2789
2966
  onClick: () => hidden ? handleShow(field.path) : handleHide(field.id)
2790
- }), !readonly && /* @__PURE__ */ React21.createElement(React21.Fragment, null, /* @__PURE__ */ React21.createElement(List2.ItemDeleteButton, {
2967
+ }), !readonly && /* @__PURE__ */ React24.createElement(React24.Fragment, null, /* @__PURE__ */ React24.createElement(List2.ItemDeleteButton, {
2791
2968
  label: t("delete-field.label"),
2792
2969
  autoHide: false,
2793
2970
  disabled: readonly || schemaReadonly || viewSnapshot.projection.fields.length <= 1,
2794
2971
  onClick: () => handleDelete(field.id),
2795
2972
  "data-testid": "field.delete"
2796
- }), /* @__PURE__ */ React21.createElement(List2.ItemIconButton, {
2973
+ }), /* @__PURE__ */ React24.createElement(List2.ItemIconButton, {
2797
2974
  iconOnly: true,
2798
2975
  variant: "ghost",
2799
2976
  label: t("toggle-expand.label", {
@@ -2802,20 +2979,20 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
2802
2979
  icon: expandedField === field.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
2803
2980
  onClick: () => handleToggleField(field),
2804
2981
  "data-testid": "field.toggle"
2805
- }))), expandedField === field.id && !readonly && /* @__PURE__ */ React21.createElement("div", {
2982
+ }))), expandedField === field.id && !readonly && /* @__PURE__ */ React24.createElement("div", {
2806
2983
  role: "none",
2807
2984
  className: "col-span-full mt-1 mb-1 border border-separator rounded-md"
2808
- }, /* @__PURE__ */ React21.createElement(FieldEditor, {
2985
+ }, /* @__PURE__ */ React24.createElement(FieldEditor, {
2809
2986
  readonly: readonly || schemaReadonly,
2810
2987
  registry,
2811
2988
  projection: projectionModel,
2812
2989
  field,
2813
2990
  onSave: handleClose
2814
2991
  })));
2815
- })), !readonly && !expandedField && /* @__PURE__ */ React21.createElement("div", {
2992
+ })), !readonly && !expandedField && /* @__PURE__ */ React24.createElement("div", {
2816
2993
  role: "none",
2817
2994
  className: "my-form-padding"
2818
- }, /* @__PURE__ */ React21.createElement(IconButton4, {
2995
+ }, /* @__PURE__ */ React24.createElement(IconButton4, {
2819
2996
  icon: "ph--plus--regular",
2820
2997
  label: t("add-property-button.label"),
2821
2998
  onClick: handleAdd,
@@ -2825,13 +3002,13 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
2825
3002
  };
2826
3003
  var customFields = ({ types, tags }) => ({
2827
3004
  query: ({ type, readonly, label, getValue, onValueChange }) => {
2828
- const handleChange = useCallback17((query) => onValueChange(type, query.ast), [
3005
+ const handleChange = useCallback18((query) => onValueChange(type, query.ast), [
2829
3006
  onValueChange
2830
3007
  ]);
2831
- return /* @__PURE__ */ React21.createElement(Input13.Root, null, /* @__PURE__ */ React21.createElement(FormFieldLabel, {
3008
+ return /* @__PURE__ */ React24.createElement(Input14.Root, null, /* @__PURE__ */ React24.createElement(FormFieldLabel, {
2832
3009
  readonly,
2833
3010
  label
2834
- }), /* @__PURE__ */ React21.createElement(QueryForm, {
3011
+ }), /* @__PURE__ */ React24.createElement(QueryForm, {
2835
3012
  initialQuery: getValue(),
2836
3013
  types,
2837
3014
  tags,
@@ -2862,15 +3039,18 @@ export {
2862
3039
  TupleField,
2863
3040
  ViewEditor,
2864
3041
  cellClassesForFieldType,
3042
+ createSelectField,
3043
+ detectFieldType,
2865
3044
  formatForDisplay,
2866
3045
  formatForEditing,
2867
3046
  getDefaultValue,
2868
3047
  getFormProperties,
2869
3048
  getRefProps,
3049
+ getSelectOptionsFromAst,
3050
+ omitHiddenFormFields,
2870
3051
  omitId,
2871
3052
  parseValue,
2872
3053
  pathNotUniqueError,
2873
- translations,
2874
3054
  useFormContext,
2875
3055
  useFormFieldState,
2876
3056
  useFormHandler,