@dxos/react-ui-form 0.8.4-main.d05539e30a → 0.8.4-main.d9fc60f731

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 (154) hide show
  1. package/dist/lib/browser/index.mjs +1335 -561
  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 +2 -1
  5. package/dist/lib/browser/translations.mjs.map +2 -2
  6. package/dist/lib/node-esm/index.mjs +1335 -561
  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 +2 -1
  10. package/dist/lib/node-esm/translations.mjs.map +2 -2
  11. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts +2 -2
  12. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
  13. package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts +2 -1
  14. package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts.map +1 -1
  15. package/dist/types/src/components/Form/Form.d.ts +35 -9
  16. package/dist/types/src/components/Form/Form.d.ts.map +1 -1
  17. package/dist/types/src/components/Form/Form.stories.d.ts +76 -16
  18. package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
  19. package/dist/types/src/components/Form/FormField.d.ts +14 -4
  20. package/dist/types/src/components/Form/FormField.d.ts.map +1 -1
  21. package/dist/types/src/components/Form/FormFieldComponent.d.ts +22 -10
  22. package/dist/types/src/components/Form/FormFieldComponent.d.ts.map +1 -1
  23. package/dist/types/src/components/Form/FormFieldSet.d.ts +8 -2
  24. package/dist/types/src/components/Form/FormFieldSet.d.ts.map +1 -1
  25. package/dist/types/src/components/Form/FormTooltipsContext.d.ts +19 -0
  26. package/dist/types/src/components/Form/FormTooltipsContext.d.ts.map +1 -0
  27. package/dist/types/src/components/Form/Layout/FormLayout.d.ts +50 -0
  28. package/dist/types/src/components/Form/Layout/FormLayout.d.ts.map +1 -0
  29. package/dist/types/src/components/Form/Layout/FormLayout.stories.d.ts +119 -0
  30. package/dist/types/src/components/Form/Layout/FormLayout.stories.d.ts.map +1 -0
  31. package/dist/types/src/components/Form/Layout/FormLayout.stories.test.d.ts +2 -0
  32. package/dist/types/src/components/Form/Layout/FormLayout.stories.test.d.ts.map +1 -0
  33. package/dist/types/src/components/Form/Layout/FormLayout.test.d.ts +2 -0
  34. package/dist/types/src/components/Form/Layout/FormLayout.test.d.ts.map +1 -0
  35. package/dist/types/src/components/Form/Layout/annotation.d.ts +30 -0
  36. package/dist/types/src/components/Form/Layout/annotation.d.ts.map +1 -0
  37. package/dist/types/src/components/Form/Layout/index.d.ts +4 -0
  38. package/dist/types/src/components/Form/Layout/index.d.ts.map +1 -0
  39. package/dist/types/src/components/Form/Layout/parser.d.ts +31 -0
  40. package/dist/types/src/components/Form/Layout/parser.d.ts.map +1 -0
  41. package/dist/types/src/components/Form/Layout/parser.test.d.ts +2 -0
  42. package/dist/types/src/components/Form/Layout/parser.test.d.ts.map +1 -0
  43. package/dist/types/src/components/Form/fields/ArrayField.d.ts.map +1 -1
  44. package/dist/types/src/components/Form/fields/DateField.d.ts +4 -0
  45. package/dist/types/src/components/Form/fields/DateField.d.ts.map +1 -0
  46. package/dist/types/src/components/Form/fields/GeoPointField.d.ts +1 -1
  47. package/dist/types/src/components/Form/fields/GeoPointField.d.ts.map +1 -1
  48. package/dist/types/src/components/Form/fields/InlineRefField.d.ts +13 -0
  49. package/dist/types/src/components/Form/fields/InlineRefField.d.ts.map +1 -0
  50. package/dist/types/src/components/Form/fields/MarkdownField.d.ts +1 -1
  51. package/dist/types/src/components/Form/fields/MarkdownField.d.ts.map +1 -1
  52. package/dist/types/src/components/Form/fields/MarkdownField.stories.d.ts +2 -1
  53. package/dist/types/src/components/Form/fields/MarkdownField.stories.d.ts.map +1 -1
  54. package/dist/types/src/components/Form/fields/RefField.d.ts +1 -1
  55. package/dist/types/src/components/Form/fields/RefField.d.ts.map +1 -1
  56. package/dist/types/src/components/Form/fields/SelectField.d.ts +4 -1
  57. package/dist/types/src/components/Form/fields/SelectField.d.ts.map +1 -1
  58. package/dist/types/src/components/Form/fields/SelectOptionField.d.ts +1 -1
  59. package/dist/types/src/components/Form/fields/SelectOptionField.d.ts.map +1 -1
  60. package/dist/types/src/components/Form/fields/SelectOptionField.stories.d.ts +2 -1
  61. package/dist/types/src/components/Form/fields/SelectOptionField.stories.d.ts.map +1 -1
  62. package/dist/types/src/components/Form/fields/TupleField.d.ts +1 -1
  63. package/dist/types/src/components/Form/fields/TupleField.d.ts.map +1 -1
  64. package/dist/types/src/components/Form/fields/index.d.ts +2 -0
  65. package/dist/types/src/components/Form/fields/index.d.ts.map +1 -1
  66. package/dist/types/src/components/Form/index.d.ts +3 -0
  67. package/dist/types/src/components/Form/index.d.ts.map +1 -1
  68. package/dist/types/src/components/Form/meta-tags.d.ts +30 -0
  69. package/dist/types/src/components/Form/meta-tags.d.ts.map +1 -0
  70. package/dist/types/src/components/Form/meta-tags.test.d.ts +2 -0
  71. package/dist/types/src/components/Form/meta-tags.test.d.ts.map +1 -0
  72. package/dist/types/src/components/ObjectForm/ObjectForm.d.ts +3 -4
  73. package/dist/types/src/components/ObjectForm/ObjectForm.d.ts.map +1 -1
  74. package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts +2 -2
  75. package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts.map +1 -1
  76. package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts +2 -1
  77. package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts.map +1 -1
  78. package/dist/types/src/components/ObjectProperties/ObjectProperties.d.ts.map +1 -1
  79. package/dist/types/src/components/ObjectProperties/ObjectProperties.stories.d.ts +2 -1
  80. package/dist/types/src/components/ObjectProperties/ObjectProperties.stories.d.ts.map +1 -1
  81. package/dist/types/src/components/ObjectTree/ObjectTree.d.ts +9 -0
  82. package/dist/types/src/components/ObjectTree/ObjectTree.d.ts.map +1 -0
  83. package/dist/types/src/components/ObjectTree/ObjectTree.stories.d.ts +87 -0
  84. package/dist/types/src/components/ObjectTree/ObjectTree.stories.d.ts.map +1 -0
  85. package/dist/types/src/components/ObjectTree/index.d.ts +2 -0
  86. package/dist/types/src/components/ObjectTree/index.d.ts.map +1 -0
  87. package/dist/types/src/components/Settings/Settings.d.ts.map +1 -1
  88. package/dist/types/src/components/Settings/Settings.stories.d.ts +2 -1
  89. package/dist/types/src/components/Settings/Settings.stories.d.ts.map +1 -1
  90. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +7 -8
  91. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
  92. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +4 -4
  93. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
  94. package/dist/types/src/components/index.d.ts +1 -0
  95. package/dist/types/src/components/index.d.ts.map +1 -1
  96. package/dist/types/src/components/testing.d.ts +9 -0
  97. package/dist/types/src/components/testing.d.ts.map +1 -1
  98. package/dist/types/src/translations.d.ts +2 -1
  99. package/dist/types/src/translations.d.ts.map +1 -1
  100. package/dist/types/src/util/properties.d.ts +11 -0
  101. package/dist/types/src/util/properties.d.ts.map +1 -1
  102. package/dist/types/tsconfig.tsbuildinfo +1 -1
  103. package/package.json +37 -32
  104. package/src/components/FieldEditor/FieldEditor.stories.tsx +2 -2
  105. package/src/components/FieldEditor/FieldEditor.test.tsx +4 -1
  106. package/src/components/FieldEditor/FieldEditor.tsx +19 -14
  107. package/src/components/Form/Form.stories.tsx +21 -27
  108. package/src/components/Form/Form.tsx +106 -19
  109. package/src/components/Form/FormField.tsx +85 -28
  110. package/src/components/Form/FormFieldComponent.tsx +75 -20
  111. package/src/components/Form/FormFieldSet.tsx +32 -3
  112. package/src/components/Form/FormTooltipsContext.ts +25 -0
  113. package/src/components/Form/Layout/FormLayout.stories.test.tsx +51 -0
  114. package/src/components/Form/Layout/FormLayout.stories.tsx +422 -0
  115. package/src/components/Form/Layout/FormLayout.test.ts +59 -0
  116. package/src/components/Form/Layout/FormLayout.tsx +251 -0
  117. package/src/components/Form/Layout/annotation.ts +38 -0
  118. package/src/components/Form/Layout/index.ts +7 -0
  119. package/src/components/Form/Layout/parser.test.ts +120 -0
  120. package/src/components/Form/Layout/parser.ts +167 -0
  121. package/src/components/Form/fields/ArrayField.tsx +61 -38
  122. package/src/components/Form/fields/DateField.tsx +101 -0
  123. package/src/components/Form/fields/GeoPointField.tsx +4 -1
  124. package/src/components/Form/fields/InlineRefField.tsx +146 -0
  125. package/src/components/Form/fields/MarkdownField.tsx +3 -3
  126. package/src/components/Form/fields/RefField.tsx +29 -23
  127. package/src/components/Form/fields/SelectField.tsx +17 -5
  128. package/src/components/Form/fields/SelectOptionField.tsx +4 -3
  129. package/src/components/Form/fields/TextAreaField.tsx +1 -1
  130. package/src/components/Form/fields/TupleField.tsx +2 -1
  131. package/src/components/Form/fields/index.ts +2 -0
  132. package/src/components/Form/index.ts +3 -0
  133. package/src/components/Form/meta-tags.test.ts +47 -0
  134. package/src/components/Form/meta-tags.ts +33 -0
  135. package/src/components/ObjectForm/ObjectForm.tsx +21 -26
  136. package/src/components/ObjectPicker/ObjectPicker.stories.tsx +2 -2
  137. package/src/components/ObjectPicker/ObjectPicker.tsx +2 -2
  138. package/src/components/ObjectProperties/ObjectProperties.stories.tsx +14 -26
  139. package/src/components/ObjectProperties/ObjectProperties.test.tsx +20 -10
  140. package/src/components/ObjectProperties/ObjectProperties.tsx +26 -30
  141. package/src/components/ObjectTree/ObjectTree.stories.tsx +134 -0
  142. package/src/components/ObjectTree/ObjectTree.tsx +190 -0
  143. package/src/components/ObjectTree/index.ts +5 -0
  144. package/src/components/Settings/Settings.tsx +2 -1
  145. package/src/components/Settings/SettingsItem.tsx +1 -1
  146. package/src/components/ViewEditor/ViewEditor.stories.tsx +35 -40
  147. package/src/components/ViewEditor/ViewEditor.test.tsx +11 -8
  148. package/src/components/ViewEditor/ViewEditor.tsx +29 -32
  149. package/src/components/index.ts +1 -0
  150. package/src/components/testing.tsx +4 -4
  151. package/src/translations.ts +2 -1
  152. package/src/util/properties.test.ts +67 -9
  153. package/src/util/properties.ts +36 -4
  154. package/src/vite-env.d.ts +10 -0
@@ -1,13 +1,13 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
 
3
3
  // src/components/FieldEditor/FieldEditor.tsx
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";
6
- import { Format as Format4, FormatEnums, formatToType } from "@dxos/echo/internal";
4
+ import React20, { useCallback as useCallback16, useEffect as useEffect5, useMemo as useMemo10, useState as useState6 } from "react";
5
+ import { Filter as Filter2, Obj as Obj4, Type as Type4 } from "@dxos/echo";
6
+ import { Format as Format6, FormatEnums, formatToType } from "@dxos/echo/internal";
7
7
  import { log as log2 } from "@dxos/log";
8
- import { useAsyncEffect, useTranslation as useTranslation9 } from "@dxos/react-ui";
8
+ import { useAsyncEffect, useTranslation as useTranslation10 } from "@dxos/react-ui";
9
9
  import { formatToAdditionalPropertyAttributes, getFormatSchema } from "@dxos/schema";
10
- import { translationKey as translationKey9 } from "#translations";
10
+ import { translationKey as translationKey10 } from "#translations";
11
11
 
12
12
  // src/util/field.ts
13
13
  import { Format, GeoLocation, TypeEnum } from "@dxos/echo/internal";
@@ -312,18 +312,39 @@ var formatForEditing = ({ type, format, value: value3, locale = void 0 }) => {
312
312
  import * as Option from "effect/Option";
313
313
  import * as SchemaAST2 from "effect/SchemaAST";
314
314
  import { Annotation } from "@dxos/echo";
315
- import { getProperties } from "@dxos/effect";
315
+ import { getProperties, isArrayType, isNestedType } from "@dxos/effect";
316
+ var unwrapOptional = (prop) => {
317
+ if (!prop.isOptional || !SchemaAST2.isUnion(prop.type)) {
318
+ return prop.type;
319
+ }
320
+ const defined = prop.type.types.filter((type) => type._tag !== "UndefinedKeyword");
321
+ if (defined.length === 0) {
322
+ return prop.type;
323
+ }
324
+ return defined.length === 1 ? defined[0] : SchemaAST2.Union.make(defined, prop.type.annotations);
325
+ };
316
326
  var getFormProperties = (ast) => {
317
- const hidden = new Set(SchemaAST2.getPropertySignatures(ast).filter((prop) => Annotation.FormInputAnnotation.getFromAst(prop.type).pipe(Option.getOrElse(() => true)) === false).map((prop) => prop.name));
318
- return getProperties(ast).filter((prop) => !hidden.has(prop.name));
327
+ const signatures = SchemaAST2.getPropertySignatures(ast);
328
+ const rawByName = new Map(signatures.map((prop) => [
329
+ prop.name,
330
+ unwrapOptional(prop)
331
+ ]));
332
+ const hidden = new Set(signatures.filter((prop) => Annotation.FormInputAnnotation.getFromAst(unwrapOptional(prop)).pipe(Option.getOrElse(() => true)) === false).map((prop) => prop.name));
333
+ return getProperties(ast).filter((prop) => !hidden.has(prop.name)).map((prop) => {
334
+ const raw = rawByName.get(prop.name);
335
+ return raw && (isNestedType(raw) || isArrayType(raw)) ? {
336
+ ...prop,
337
+ type: raw
338
+ } : prop;
339
+ });
319
340
  };
320
341
 
321
342
  // src/util/refs.ts
322
343
  import { Ref } from "@dxos/echo";
323
344
  import { ReferenceAnnotationId } from "@dxos/echo/internal";
324
- import { findAnnotation, getArrayElementType, isArrayType } from "@dxos/effect";
345
+ import { findAnnotation, getArrayElementType, isArrayType as isArrayType2 } from "@dxos/effect";
325
346
  var getRefProps = (ast) => {
326
- if (isArrayType(ast)) {
347
+ if (isArrayType2(ast)) {
327
348
  const elementType = getArrayElementType(ast);
328
349
  if (elementType) {
329
350
  if (Ref.isRefType(elementType)) {
@@ -348,23 +369,25 @@ var getRefProps = (ast) => {
348
369
  };
349
370
 
350
371
  // src/components/Form/fields/ArrayField.tsx
351
- import * as Option4 from "effect/Option";
352
- import * as SchemaAST5 from "effect/SchemaAST";
353
- import React5, { useCallback as useCallback3 } from "react";
354
- import { findNode as findNode2, getArrayElementType as getArrayElementType2, getDiscriminatedType as getDiscriminatedType2, isDiscriminatedUnion as isDiscriminatedUnion2, isNestedType as isNestedType2 } from "@dxos/effect";
355
- import { IconButton as IconButton2, useTranslation as useTranslation3 } from "@dxos/react-ui";
372
+ import * as Option6 from "effect/Option";
373
+ import * as SchemaAST6 from "effect/SchemaAST";
374
+ import React6, { useCallback as useCallback3 } from "react";
375
+ import { Ref as Ref2 } from "@dxos/echo";
376
+ import { createJsonPath as createJsonPath6, findNode as findNode3, getArrayElementType as getArrayElementType2, getDiscriminatedType as getDiscriminatedType2, isDiscriminatedUnion as isDiscriminatedUnion2, isNestedType as isNestedType3 } from "@dxos/effect";
377
+ import { useTranslation as useTranslation3 } from "@dxos/react-ui";
356
378
  import { translationKey as translationKey3 } from "#translations";
357
379
 
358
380
  // src/components/Form/Form.tsx
359
- import { createContext } from "@radix-ui/react-context";
360
- import * as Option3 from "effect/Option";
361
- import * as Schema2 from "effect/Schema";
362
- import * as SchemaAST4 from "effect/SchemaAST";
363
- import React4, { useEffect as useEffect2, useMemo as useMemo4, useRef } from "react";
364
- import { Annotation as EchoAnnotation } from "@dxos/echo";
365
- import { createJsonPath as createJsonPath3, getValue as getValue$2 } from "@dxos/effect";
366
- import { IconButton, ScrollArea, useMergeRefs, useTranslation as useTranslation2 } from "@dxos/react-ui";
367
- import { composable, composableProps, mx, withColumn } from "@dxos/ui-theme";
381
+ import { createContext as createContext2 } from "@radix-ui/react-context";
382
+ import * as Option5 from "effect/Option";
383
+ import * as Schema3 from "effect/Schema";
384
+ import * as SchemaAST5 from "effect/SchemaAST";
385
+ import React5, { useEffect as useEffect2, useMemo as useMemo5, useRef } from "react";
386
+ import { Annotation as EchoAnnotation, Type } from "@dxos/echo";
387
+ import { createJsonPath as createJsonPath5, getValue as getValue$2 } from "@dxos/effect";
388
+ import { Column, IconButton as IconButton2, Input as Input3, ScrollArea, useMergeRefs, useTranslation as useTranslation2 } from "@dxos/react-ui";
389
+ import { composable, composableProps, withColumn } from "@dxos/react-ui";
390
+ import { mx as mx3 } from "@dxos/ui-theme";
368
391
  import { translationKey as translationKey2 } from "#translations";
369
392
 
370
393
  // src/hooks/useFormHandler.ts
@@ -584,18 +607,18 @@ var mergeAtPath = (obj, path, value3) => {
584
607
  if (path.length === 0) {
585
608
  return value3;
586
609
  }
587
- const [head2, ...rest] = path;
588
- const child = rest.length === 0 ? value3 : mergeAtPath(obj?.[head2], rest, value3);
610
+ const [head, ...rest] = path;
611
+ const child = rest.length === 0 ? value3 : mergeAtPath(obj?.[head], rest, value3);
589
612
  if (Array.isArray(obj)) {
590
613
  const copy = [
591
614
  ...obj
592
615
  ];
593
- copy[head2] = child;
616
+ copy[head] = child;
594
617
  return copy;
595
618
  }
596
619
  return {
597
620
  ...obj,
598
- [head2]: child
621
+ [head]: child
599
622
  };
600
623
  };
601
624
  var flatMap = (errors) => {
@@ -640,16 +663,32 @@ var useKeyHandler = (elRef, form) => {
640
663
  };
641
664
 
642
665
  // src/components/Form/FormFieldComponent.tsx
666
+ import { format as formatDate2 } from "date-fns";
643
667
  import React, { Component } from "react";
668
+ import { Format as Format3 } from "@dxos/echo";
644
669
  import { Icon, Input, Tooltip } from "@dxos/react-ui";
645
- import { inputTextLabel } from "@dxos/ui-theme";
646
- var FormFieldLabel = ({ label, error, readonly, asChild }) => {
670
+ import { inputTextLabel } from "@dxos/react-ui";
671
+ import { mx } from "@dxos/ui-theme";
672
+
673
+ // src/components/Form/FormTooltipsContext.ts
674
+ import { createContext, useContext } from "react";
675
+ var FormTooltipsContext = createContext(true);
676
+ var useFormTooltips = () => useContext(FormTooltipsContext);
677
+
678
+ // src/components/Form/FormFieldComponent.tsx
679
+ var FormFieldLabel = ({ label, error, readonly, asChild, path }) => {
680
+ const tooltips = useFormTooltips();
647
681
  const Label = readonly || asChild ? "span" : Input.Label;
682
+ const labelNode = /* @__PURE__ */ React.createElement(Label, {
683
+ className: mx(inputTextLabel, "text-sm")
684
+ }, label);
648
685
  return /* @__PURE__ */ React.createElement("div", {
649
686
  className: "flex items-center justify-between"
650
- }, /* @__PURE__ */ React.createElement(Label, {
651
- className: inputTextLabel
652
- }, label), error && /* @__PURE__ */ React.createElement(Tooltip.Trigger, {
687
+ }, tooltips && path ? /* @__PURE__ */ React.createElement(Tooltip.Trigger, {
688
+ asChild: true,
689
+ content: path,
690
+ side: "bottom"
691
+ }, labelNode) : labelNode, error && /* @__PURE__ */ React.createElement(Tooltip.Trigger, {
653
692
  asChild: true,
654
693
  content: error,
655
694
  side: "bottom"
@@ -660,14 +699,33 @@ var FormFieldLabel = ({ label, error, readonly, asChild }) => {
660
699
  })));
661
700
  };
662
701
  FormFieldLabel.displayName = "Form.FieldLabel";
702
+ var formatStaticValue = (value3, format) => {
703
+ if (value3 == null) {
704
+ return "";
705
+ }
706
+ switch (format) {
707
+ case Format3.TypeFormat.DateTime:
708
+ case Format3.TypeFormat.Date:
709
+ case Format3.TypeFormat.Time: {
710
+ const date = new Date(value3);
711
+ if (Number.isNaN(date.getTime())) {
712
+ return String(value3);
713
+ }
714
+ const pattern = format === Format3.TypeFormat.DateTime ? "PPp" : format === Format3.TypeFormat.Date ? "PP" : "p";
715
+ return formatDate2(date, pattern);
716
+ }
717
+ default:
718
+ return String(value3);
719
+ }
720
+ };
663
721
  var FormFieldWrapper = (props) => {
664
- const { children, readonly, layout, label, getStatus, getValue } = props;
722
+ const { children, readonly, layout, label, jsonPath, format, getStatus, getValue } = props;
665
723
  const { status, error } = getStatus();
666
724
  const value3 = getValue();
667
725
  if (layout === "static" && value3 == null) {
668
726
  return null;
669
727
  }
670
- const str = String(value3 ?? "");
728
+ const str = formatStaticValue(value3, format);
671
729
  return /* @__PURE__ */ React.createElement("div", {
672
730
  className: "contents"
673
731
  }, /* @__PURE__ */ React.createElement(Input.Root, {
@@ -675,10 +733,14 @@ var FormFieldWrapper = (props) => {
675
733
  }, layout !== "inline" && /* @__PURE__ */ React.createElement(FormFieldLabel, {
676
734
  error,
677
735
  readonly,
678
- label
679
- }), layout === "static" ? /* @__PURE__ */ React.createElement("p", null, str) : children ? children({
736
+ label,
737
+ path: jsonPath
738
+ }), layout === "static" ? /* @__PURE__ */ React.createElement("p", {
739
+ className: "truncate min-w-0",
740
+ title: str
741
+ }, str) : children ? children({
680
742
  value: value3
681
- }) : null, layout === "full" && /* @__PURE__ */ React.createElement(Input.DescriptionAndValidation, null, /* @__PURE__ */ React.createElement(Input.Validation, null, error))));
743
+ }) : null, layout === "full" && error && /* @__PURE__ */ React.createElement(Input.DescriptionAndValidation, null, /* @__PURE__ */ React.createElement(Input.Validation, null, error))));
682
744
  };
683
745
  var FormFieldErrorBoundary = class extends Component {
684
746
  static getDerivedStateFromError(error) {
@@ -697,9 +759,9 @@ var FormFieldErrorBoundary = class extends Component {
697
759
  render() {
698
760
  if (this.state.error) {
699
761
  return /* @__PURE__ */ React.createElement("div", {
700
- className: "flex gap-2 border border-rose-fill font-mono text-sm"
762
+ className: "flex gap-2 border border-rose-bg font-mono text-sm"
701
763
  }, /* @__PURE__ */ React.createElement("span", {
702
- className: "bg-rose-fill text-base-foreground px-1 font-thin"
764
+ className: "bg-rose-bg text-base-fg px-1 font-thin"
703
765
  }, "ERROR"), String(this.props.path?.join(".")));
704
766
  }
705
767
  return this.props.children;
@@ -712,7 +774,9 @@ var FormFieldErrorBoundary = class extends Component {
712
774
  };
713
775
 
714
776
  // src/components/Form/FormFieldSet.tsx
715
- import React3, { useMemo as useMemo3 } from "react";
777
+ import * as Option4 from "effect/Option";
778
+ import React4, { useMemo as useMemo4 } from "react";
779
+ import { createJsonPath as createJsonPath4 } from "@dxos/effect";
716
780
 
717
781
  // src/components/Form/FormField.tsx
718
782
  import * as Match from "effect/Match";
@@ -721,9 +785,10 @@ import * as Schema from "effect/Schema";
721
785
  import * as SchemaAST3 from "effect/SchemaAST";
722
786
  import * as String2 from "effect/String";
723
787
  import React2, { useMemo as useMemo2 } from "react";
724
- import { Format as Format3 } from "@dxos/echo";
725
- import { createJsonPath as createJsonPath2, findNode, getAnnotation as getAnnotation2, getDiscriminatedType, isArrayType as isArrayType2, isDiscriminatedUnion, isLiteralUnion as isLiteralUnion2, isNestedType } from "@dxos/effect";
726
- import { useTranslation } from "@dxos/react-ui";
788
+ import { Annotation as Annotation2, Format as Format4 } from "@dxos/echo";
789
+ import { createJsonPath as createJsonPath2, findNode, getAnnotation as getAnnotation2, getDiscriminatedType, isArrayType as isArrayType3, isDiscriminatedUnion, isLiteralUnion as isLiteralUnion2, isNestedType as isNestedType2 } from "@dxos/effect";
790
+ import { IconButton, useTranslation } from "@dxos/react-ui";
791
+ import { mx as mx2 } from "@dxos/ui-theme";
727
792
  import { translationKey } from "#translations";
728
793
  var FormField = (props) => {
729
794
  const {
@@ -742,7 +807,7 @@ var FormField = (props) => {
742
807
  createInitialValuePath,
743
808
  createFieldMap: createFieldMap3,
744
809
  db,
745
- useSchema: schemaHook,
810
+ useType: schemaHook,
746
811
  getOptions,
747
812
  onCreate
748
813
  } = props;
@@ -750,7 +815,7 @@ var FormField = (props) => {
750
815
  const title = getAnnotation2(SchemaAST3.TitleAnnotationId)(type);
751
816
  const description = getAnnotation2(SchemaAST3.DescriptionAnnotationId)(type);
752
817
  const examples = getAnnotation2(SchemaAST3.ExamplesAnnotationId)(type);
753
- const label = useMemo2(() => title ?? String2.capitalize(name), [
818
+ const label = useMemo2(() => title ?? (name == null ? "" : String2.capitalize(name)), [
754
819
  title,
755
820
  name
756
821
  ]);
@@ -760,30 +825,34 @@ var FormField = (props) => {
760
825
  label
761
826
  ]);
762
827
  const fieldState = useFormFieldState(FormField.displayName, path);
828
+ const jsonPath = createJsonPath2(path ?? []);
763
829
  const fieldProps = {
764
830
  type,
765
- format: Format3.FormatAnnotation.getFromAst(type).pipe((annotation) => Option2.getOrUndefined(annotation)),
831
+ format: Format4.FormatAnnotation.getFromAst(type).pipe((annotation) => Option2.getOrUndefined(annotation)),
766
832
  readonly,
767
833
  label,
834
+ jsonPath,
768
835
  placeholder,
769
836
  layout,
770
837
  db,
771
838
  ...fieldState
772
839
  };
773
- const jsonPath = createJsonPath2(path ?? []);
840
+ if (readonly && fieldState.getValue() == null) {
841
+ return null;
842
+ }
774
843
  const CustomField = fieldMap?.[jsonPath];
775
844
  if (CustomField) {
776
845
  return /* @__PURE__ */ React2.createElement(CustomField, fieldProps);
777
846
  }
778
847
  const component = fieldProvider?.({
779
848
  schema: Schema.make(type),
780
- prop: name,
849
+ prop: name ?? "",
781
850
  fieldProps
782
851
  });
783
852
  if (component) {
784
853
  return component;
785
854
  }
786
- if (isArrayType2(type)) {
855
+ if (isArrayType3(type)) {
787
856
  return /* @__PURE__ */ React2.createElement(ArrayField, {
788
857
  fieldProps: fieldState,
789
858
  label,
@@ -812,6 +881,16 @@ var FormField = (props) => {
812
881
  }
813
882
  const refProps = getRefProps(type);
814
883
  if (refProps) {
884
+ const inline = Annotation2.FormInlineAnnotation.getFromAst(refProps.ast).pipe(Option2.getOrElse(() => false));
885
+ if (inline && !refProps.isArray) {
886
+ return /* @__PURE__ */ React2.createElement(InlineRefField, {
887
+ ...fieldProps,
888
+ ...refProps,
889
+ db,
890
+ useType: schemaHook,
891
+ onCreate
892
+ });
893
+ }
815
894
  const isCreateTarget = !createTypename || refProps.typename === createTypename;
816
895
  return /* @__PURE__ */ React2.createElement(RefField, {
817
896
  ...fieldProps,
@@ -821,17 +900,17 @@ var FormField = (props) => {
821
900
  createInitialValuePath: isCreateTarget ? createInitialValuePath : void 0,
822
901
  createFieldMap: isCreateTarget ? createFieldMap3 : void 0,
823
902
  db,
824
- useSchema: schemaHook,
903
+ useType: schemaHook,
825
904
  getOptions,
826
905
  onCreate
827
906
  });
828
907
  }
829
- if (isNestedType(type)) {
908
+ if (isNestedType2(type)) {
830
909
  const baseNode = findNode(type, isDiscriminatedUnion);
831
910
  const typeLiteral = baseNode ? getDiscriminatedType(baseNode, fieldState.getValue()) : findNode(type, SchemaAST3.isTypeLiteral);
832
911
  if (typeLiteral) {
833
912
  const schema = Schema.make(typeLiteral);
834
- return /* @__PURE__ */ React2.createElement(FormFieldSet, {
913
+ return /* @__PURE__ */ React2.createElement(Nesting, null, /* @__PURE__ */ React2.createElement(FormFieldSet, {
835
914
  schema,
836
915
  path,
837
916
  readonly,
@@ -844,17 +923,33 @@ var FormField = (props) => {
844
923
  createOptionIcon,
845
924
  createInitialValuePath,
846
925
  db,
847
- useSchema: schemaHook,
926
+ useType: schemaHook,
848
927
  getOptions,
849
928
  onCreate
850
- });
929
+ }));
851
930
  }
852
931
  }
853
932
  return null;
854
933
  };
855
934
  FormField.displayName = "Form.FormField";
935
+ var Nesting = ({ children }) => /* @__PURE__ */ React2.createElement("div", {
936
+ className: "px-2 border border-subdued-separator rounded-sm mt-2"
937
+ }, /* @__PURE__ */ React2.createElement("div", {
938
+ className: "pb-2"
939
+ }, children));
940
+ var IconBlock = ({ inline, ...props }) => {
941
+ return /* @__PURE__ */ React2.createElement("div", {
942
+ className: mx2("h-full flex px-1", inline ? "items-center" : "flex-col pt-2.5")
943
+ }, /* @__PURE__ */ React2.createElement(IconButton, {
944
+ variant: "ghost",
945
+ density: "xs",
946
+ square: true,
947
+ iconOnly: true,
948
+ ...props
949
+ }));
950
+ };
856
951
  var getFormField = ({ type, format }) => {
857
- const formatField = Match.value(format).pipe(Match.withReturnType(), Match.when(Format3.TypeFormat.GeoPoint, () => GeoPointField), Match.when(Format3.TypeFormat.Markdown, () => MarkdownField), Match.when(Format3.TypeFormat.Text, () => TextAreaField), Match.orElse(() => void 0));
952
+ const formatField = Match.value(format).pipe(Match.withReturnType(), Match.when(Format4.TypeFormat.Date, () => DateField), Match.when(Format4.TypeFormat.DateTime, () => DateField), Match.when(Format4.TypeFormat.GeoPoint, () => GeoPointField), Match.when(Format4.TypeFormat.Markdown, () => MarkdownField), Match.when(Format4.TypeFormat.Text, () => TextAreaField), Match.when(Format4.TypeFormat.Time, () => DateField), Match.orElse(() => void 0));
858
953
  if (formatField) {
859
954
  return formatField;
860
955
  }
@@ -873,12 +968,283 @@ var getSelectOptions = (ast) => {
873
968
  if (isLiteralUnion2(ast)) {
874
969
  return ast.types.map((type) => type.literal).filter((v) => v !== null);
875
970
  }
876
- return Format3.OptionsAnnotation.getFromAst(ast).pipe((annotation) => Option2.getOrUndefined(annotation));
971
+ return Format4.OptionsAnnotation.getFromAst(ast).pipe((annotation) => Option2.getOrUndefined(annotation));
972
+ };
973
+
974
+ // src/components/Form/Layout/annotation.ts
975
+ import { createAnnotationHelper } from "@dxos/echo/internal";
976
+ var FormLayoutAnnotationId = /* @__PURE__ */ Symbol.for("@dxos/react-ui-form/annotation/Layout");
977
+ var FormLayoutAnnotation = createAnnotationHelper(FormLayoutAnnotationId);
978
+ var DEFAULT_LAYOUT_NAME = "default";
979
+
980
+ // src/components/Form/Layout/FormLayout.tsx
981
+ import * as Option3 from "effect/Option";
982
+ import * as Schema2 from "effect/Schema";
983
+ import * as SchemaAST4 from "effect/SchemaAST";
984
+ import * as String3 from "effect/String";
985
+ import React3, { Fragment, useMemo as useMemo3 } from "react";
986
+ import { Annotation as Annotation3 } from "@dxos/echo";
987
+ import { createJsonPath as createJsonPath3, findNode as findNode2, getAnnotation as getAnnotation3, getBaseType } from "@dxos/effect";
988
+ import { Input as Input2 } from "@dxos/react-ui";
989
+
990
+ // src/components/Form/Layout/parser.ts
991
+ var LayoutParseError = class extends Error {
992
+ position;
993
+ _tag = "LayoutParseError";
994
+ constructor(message, position) {
995
+ super(position !== void 0 ? `${message} (at position ${position})` : message), this.position = position;
996
+ }
997
+ };
998
+ var TAG_RE = /<\s*(\/?)\s*(\w+)([^>]*?)(\/?)\s*>/g;
999
+ var ATTR_RE = /([\w-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\d+))/g;
1000
+ var parseAttrs = (raw) => {
1001
+ const attrs = {};
1002
+ ATTR_RE.lastIndex = 0;
1003
+ let match;
1004
+ while ((match = ATTR_RE.exec(raw)) !== null) {
1005
+ const [, key, doubleQuoted, singleQuoted, bare] = match;
1006
+ attrs[key] = doubleQuoted ?? singleQuoted ?? bare;
1007
+ }
1008
+ return attrs;
1009
+ };
1010
+ var tokenize = (input) => {
1011
+ const tokens = [];
1012
+ TAG_RE.lastIndex = 0;
1013
+ let match;
1014
+ let cursor = 0;
1015
+ while ((match = TAG_RE.exec(input)) !== null) {
1016
+ const between = input.slice(cursor, match.index);
1017
+ if (between.trim().length > 0) {
1018
+ throw new LayoutParseError(`unexpected text content: ${JSON.stringify(between.trim())}`, cursor);
1019
+ }
1020
+ const [, slash, name, attrsRaw, selfSlash] = match;
1021
+ if (slash) {
1022
+ tokens.push({
1023
+ type: "close",
1024
+ name,
1025
+ position: match.index
1026
+ });
1027
+ } else {
1028
+ tokens.push({
1029
+ type: "open",
1030
+ name,
1031
+ attrs: parseAttrs(attrsRaw),
1032
+ selfClosing: selfSlash === "/",
1033
+ position: match.index
1034
+ });
1035
+ }
1036
+ cursor = match.index + match[0].length;
1037
+ }
1038
+ const trailing = input.slice(cursor);
1039
+ if (trailing.trim().length > 0) {
1040
+ throw new LayoutParseError(`unexpected text content: ${JSON.stringify(trailing.trim())}`, cursor);
1041
+ }
1042
+ return tokens;
1043
+ };
1044
+ var requireAttr = (attrs, key, tag, position) => {
1045
+ const value3 = attrs[key];
1046
+ if (value3 === void 0) {
1047
+ throw new LayoutParseError(`<${tag}> missing required attribute "${key}"`, position);
1048
+ }
1049
+ return value3;
1050
+ };
1051
+ var parseInteger = (value3, attr, tag, position) => {
1052
+ if (!/^\d+$/.test(value3)) {
1053
+ throw new LayoutParseError(`<${tag}> attribute "${attr}" expects an integer, got ${JSON.stringify(value3)}`, position);
1054
+ }
1055
+ return Number.parseInt(value3, 10);
1056
+ };
1057
+ var parseLayout = (template) => {
1058
+ const tokens = tokenize(template);
1059
+ if (tokens.length === 0) {
1060
+ throw new LayoutParseError("empty template");
1061
+ }
1062
+ let index = 0;
1063
+ const parseNode = () => {
1064
+ const token = tokens[index];
1065
+ if (!token || token.type !== "open") {
1066
+ throw new LayoutParseError(`expected an opening tag, got ${JSON.stringify(token)}`, token?.position);
1067
+ }
1068
+ if (token.name === "field") {
1069
+ if (!token.selfClosing) {
1070
+ throw new LayoutParseError('<field> must be self-closing (e.g. <field name="x"/>)', token.position);
1071
+ }
1072
+ const name = requireAttr(token.attrs, "name", "field", token.position);
1073
+ const spanRaw = token.attrs.span;
1074
+ const span = spanRaw !== void 0 ? parseInteger(spanRaw, "span", "field", token.position) : void 0;
1075
+ index += 1;
1076
+ return {
1077
+ kind: "field",
1078
+ name,
1079
+ span
1080
+ };
1081
+ }
1082
+ if (token.name === "grid") {
1083
+ if (token.selfClosing) {
1084
+ throw new LayoutParseError("<grid> must wrap children (cannot self-close)", token.position);
1085
+ }
1086
+ const cols = parseInteger(requireAttr(token.attrs, "cols", "grid", token.position), "cols", "grid", token.position);
1087
+ index += 1;
1088
+ const children = [];
1089
+ while (index < tokens.length && !(tokens[index].type === "close" && tokens[index].name === "grid")) {
1090
+ children.push(parseNode());
1091
+ }
1092
+ const closing = tokens[index];
1093
+ if (!closing || closing.type !== "close" || closing.name !== "grid") {
1094
+ throw new LayoutParseError("<grid> not closed", token.position);
1095
+ }
1096
+ index += 1;
1097
+ return {
1098
+ kind: "grid",
1099
+ cols,
1100
+ children
1101
+ };
1102
+ }
1103
+ throw new LayoutParseError(`unknown element <${token.name}>`, token.position);
1104
+ };
1105
+ const root = parseNode();
1106
+ if (index !== tokens.length) {
1107
+ const trailing = tokens[index];
1108
+ throw new LayoutParseError(`unexpected trailing tag <${trailing.type === "open" ? "" : "/"}${trailing.name}>`, trailing.position);
1109
+ }
1110
+ if (root.kind !== "grid") {
1111
+ throw new LayoutParseError("root element must be <grid>");
1112
+ }
1113
+ return root;
1114
+ };
1115
+
1116
+ // src/components/Form/Layout/FormLayout.tsx
1117
+ var FORM_LAYOUT_NAME = "Form.Layout";
1118
+ var FormLayout = ({ schema, template, name = DEFAULT_LAYOUT_NAME, path, readonly, layout, projection, ...props }) => {
1119
+ const annotated = Option3.getOrUndefined(FormLayoutAnnotation.get(schema));
1120
+ const source = template ?? annotated?.[name];
1121
+ if (source === void 0) {
1122
+ throw new LayoutParseError(annotated ? `no layout named "${name}" on schema (available: ${Object.keys(annotated).join(", ") || "\u2205"})` : `no template provided and schema has no FormLayoutAnnotation`);
1123
+ }
1124
+ const tree = useMemo3(() => parseLayout(source), [
1125
+ source
1126
+ ]);
1127
+ return /* @__PURE__ */ React3.createElement(RenderNode, {
1128
+ node: tree,
1129
+ schema,
1130
+ basePath: path ?? [],
1131
+ readonly,
1132
+ layout,
1133
+ projection,
1134
+ ...props
1135
+ });
1136
+ };
1137
+ FormLayout.displayName = FORM_LAYOUT_NAME;
1138
+ var RenderNode = ({ node, schema, basePath, ...props }) => {
1139
+ if (node.kind === "grid") {
1140
+ return /* @__PURE__ */ React3.createElement("div", {
1141
+ className: "grid gap-x-form-gap",
1142
+ style: {
1143
+ gridTemplateColumns: `repeat(${node.cols}, minmax(0, 1fr))`
1144
+ }
1145
+ }, node.children.map((child, index) => /* @__PURE__ */ React3.createElement(Fragment, {
1146
+ key: index
1147
+ }, /* @__PURE__ */ React3.createElement(RenderNode, {
1148
+ node: child,
1149
+ schema,
1150
+ basePath,
1151
+ ...props
1152
+ }))));
1153
+ }
1154
+ const resolved = resolveLayoutField(schema, node.name);
1155
+ if (!resolved) {
1156
+ throw new LayoutParseError(`field "${node.name}" not found on schema`);
1157
+ }
1158
+ const { type, segments, leafName, title, labelType } = resolved;
1159
+ const path = [
1160
+ ...basePath,
1161
+ ...segments
1162
+ ];
1163
+ const span = node.span ? {
1164
+ gridColumn: `span ${node.span} / span ${node.span}`
1165
+ } : void 0;
1166
+ return /* @__PURE__ */ React3.createElement("div", {
1167
+ className: "min-w-0",
1168
+ style: span
1169
+ }, /* @__PURE__ */ React3.createElement(FormFieldErrorBoundary, {
1170
+ path
1171
+ }, labelType ? /* @__PURE__ */ React3.createElement(LabelField, {
1172
+ schema: Schema2.make(labelType),
1173
+ label: title ?? String3.capitalize(leafName),
1174
+ path,
1175
+ layout: props.layout
1176
+ }) : /* @__PURE__ */ React3.createElement(FormField, {
1177
+ type,
1178
+ name: leafName,
1179
+ path,
1180
+ ...props
1181
+ })));
1182
+ };
1183
+ var resolvePropertySignature = (ast, segments) => {
1184
+ let node = ast;
1185
+ for (let index = 0; index < segments.length; index++) {
1186
+ const typeLiteral = findNode2(node, SchemaAST4.isTypeLiteral);
1187
+ if (!typeLiteral) {
1188
+ return void 0;
1189
+ }
1190
+ const prop = SchemaAST4.getPropertySignatures(typeLiteral).find((p) => globalThis.String(p.name) === segments[index]);
1191
+ if (!prop) {
1192
+ return void 0;
1193
+ }
1194
+ if (index === segments.length - 1) {
1195
+ return prop;
1196
+ }
1197
+ node = prop.type;
1198
+ }
1199
+ return void 0;
1200
+ };
1201
+ var resolveLayoutField = (schema, name) => {
1202
+ const segments = name.split(".");
1203
+ const prop = resolvePropertySignature(schema.ast, segments);
1204
+ if (!prop) {
1205
+ return void 0;
1206
+ }
1207
+ const { type: baseType } = getBaseType(prop);
1208
+ const type = prop.annotations && Reflect.ownKeys(prop.annotations).length > 0 ? {
1209
+ ...baseType,
1210
+ annotations: {
1211
+ ...baseType.annotations,
1212
+ ...prop.annotations
1213
+ }
1214
+ } : baseType;
1215
+ const title = getAnnotation3(SchemaAST4.TitleAnnotationId)(type);
1216
+ const labelType = findNode2(prop.type, SchemaAST4.isTypeLiteral);
1217
+ const labelled = labelType != null && Option3.isSome(Annotation3.LabelAnnotation.getFromAst(labelType));
1218
+ return {
1219
+ type,
1220
+ segments,
1221
+ leafName: segments[segments.length - 1],
1222
+ title,
1223
+ labelType: labelled ? labelType : void 0
1224
+ };
1225
+ };
1226
+ var LabelField = ({ schema, label, path, layout }) => {
1227
+ const { getValue } = useFormFieldState(FORM_LAYOUT_NAME, path);
1228
+ const value3 = getValue();
1229
+ const text = value3 == null ? void 0 : Annotation3.getLabelWithSchema(schema, value3);
1230
+ if (text == null || text.trim().length === 0) {
1231
+ return null;
1232
+ }
1233
+ return /* @__PURE__ */ React3.createElement("div", {
1234
+ className: "contents"
1235
+ }, /* @__PURE__ */ React3.createElement(Input2.Root, null, layout !== "inline" && /* @__PURE__ */ React3.createElement(FormFieldLabel, {
1236
+ readonly: true,
1237
+ label,
1238
+ path: createJsonPath3(path)
1239
+ }), /* @__PURE__ */ React3.createElement("p", {
1240
+ className: "truncate min-w-0",
1241
+ title: text
1242
+ }, text)));
877
1243
  };
878
1244
 
879
1245
  // src/components/Form/FormFieldSet.tsx
880
1246
  var FORM_FIELDSET_NAME = "Form.FieldSet";
881
- var FormFieldSet = ({ label, schema, readonly, path, sort, exclude, projection, layout, ...props }) => {
1247
+ var FormFieldSet = ({ label, schema, readonly, path, sort, exclude, projection, layout, layoutName = DEFAULT_LAYOUT_NAME, ...props }) => {
882
1248
  const values = useFormValues(FORM_FIELDSET_NAME, path);
883
1249
  const properties = useFormFieldSetProperties({
884
1250
  schema,
@@ -890,18 +1256,35 @@ var FormFieldSet = ({ label, schema, readonly, path, sort, exclude, projection,
890
1256
  if ((readonly || layout === "static") && values == null) {
891
1257
  return null;
892
1258
  }
893
- return /* @__PURE__ */ React3.createElement(React3.Fragment, null, layout !== "inline" && label && /* @__PURE__ */ React3.createElement(FormFieldLabel, {
1259
+ const layouts = schema ? Option4.getOrUndefined(FormLayoutAnnotation.get(schema)) : void 0;
1260
+ if (layouts?.[layoutName] !== void 0 && schema) {
1261
+ return /* @__PURE__ */ React4.createElement(React4.Fragment, null, layout !== "inline" && label && /* @__PURE__ */ React4.createElement(FormFieldLabel, {
1262
+ label,
1263
+ path: createJsonPath4(path ?? []),
1264
+ asChild: true
1265
+ }), /* @__PURE__ */ React4.createElement(FormLayout, {
1266
+ schema,
1267
+ name: layoutName,
1268
+ path,
1269
+ readonly,
1270
+ layout,
1271
+ projection,
1272
+ ...props
1273
+ }));
1274
+ }
1275
+ return /* @__PURE__ */ React4.createElement(React4.Fragment, null, layout !== "inline" && label && /* @__PURE__ */ React4.createElement(FormFieldLabel, {
894
1276
  label,
1277
+ path: createJsonPath4(path ?? []),
895
1278
  asChild: true
896
1279
  }), properties.map((property) => {
897
1280
  const name = property.name.toString();
898
- return /* @__PURE__ */ React3.createElement(FormFieldErrorBoundary, {
1281
+ return /* @__PURE__ */ React4.createElement(FormFieldErrorBoundary, {
899
1282
  key: name,
900
1283
  path: [
901
1284
  ...path ?? [],
902
1285
  name
903
1286
  ]
904
- }, /* @__PURE__ */ React3.createElement(FormField, {
1287
+ }, /* @__PURE__ */ React4.createElement(FormField, {
905
1288
  type: property.type,
906
1289
  name,
907
1290
  path: [
@@ -917,7 +1300,7 @@ var FormFieldSet = ({ label, schema, readonly, path, sort, exclude, projection,
917
1300
  };
918
1301
  FormFieldSet.displayName = FORM_FIELDSET_NAME;
919
1302
  var useFormFieldSetProperties = ({ schema, exclude, projection, values, sort }) => {
920
- return useMemo3(() => {
1303
+ return useMemo4(() => {
921
1304
  if (!schema) {
922
1305
  return [];
923
1306
  }
@@ -953,25 +1336,28 @@ var useFormFieldSetProperties = ({ schema, exclude, projection, values, sort })
953
1336
  };
954
1337
 
955
1338
  // src/components/Form/Form.tsx
956
- var omitId = (schema) => schema.pipe(Schema2.omit("id"));
1339
+ var omitId = (schemaOrType) => {
1340
+ const schema = Type.isType(schemaOrType) ? Type.getSchema(schemaOrType) : schemaOrType;
1341
+ return schema.pipe(Schema3.omit("id"));
1342
+ };
957
1343
  var omitHiddenFormFields = (schema) => {
958
- const properties = SchemaAST4.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));
1344
+ const properties = SchemaAST5.getPropertySignatures(schema.ast);
1345
+ const hidden = properties.filter((prop) => Option5.getOrElse(EchoAnnotation.FormInputAnnotation.getFromAst(prop.type), () => true) === false).map((prop) => prop.name);
1346
+ return hidden.length === 0 ? schema : schema.pipe(Schema3.omit(...hidden));
961
1347
  };
962
- var [FormContextProvider, useFormContext] = createContext("Form");
1348
+ var [FormContextProvider, useFormContext] = createContext2("Form");
963
1349
  var useFormValues = (componentName, path, defaultValue) => {
964
- const stablePath = useMemo4(() => path ?? [], [
1350
+ const stablePath = useMemo5(() => path ?? [], [
965
1351
  path ? path.join(".") : void 0
966
1352
  ]);
967
- const jsonPath = createJsonPath3(stablePath);
1353
+ const jsonPath = createJsonPath5(stablePath);
968
1354
  const { form: { values, onValueChange } } = useFormContext(componentName);
969
1355
  const value3 = getValue$2(values, jsonPath);
970
1356
  const lastAppliedPathRef = useRef(null);
971
1357
  useEffect2(() => {
972
1358
  if (value3 == null && defaultValue && lastAppliedPathRef.current !== jsonPath) {
973
1359
  lastAppliedPathRef.current = jsonPath;
974
- onValueChange(stablePath, SchemaAST4.stringKeyword, defaultValue());
1360
+ onValueChange(stablePath, SchemaAST5.stringKeyword, defaultValue());
975
1361
  }
976
1362
  }, [
977
1363
  value3,
@@ -983,11 +1369,11 @@ var useFormValues = (componentName, path, defaultValue) => {
983
1369
  return value3;
984
1370
  };
985
1371
  var useFormFieldState = (componentName, path = []) => {
986
- const stablePath = useMemo4(() => path, [
1372
+ const stablePath = useMemo5(() => path, [
987
1373
  Array.isArray(path) ? path.join(".") : path
988
1374
  ]);
989
1375
  const { form: { getStatus, getValue, onBlur, onValueChange } } = useFormContext(componentName);
990
- return useMemo4(() => ({
1376
+ return useMemo5(() => ({
991
1377
  getStatus: () => getStatus(stablePath),
992
1378
  getValue: () => getValue(stablePath),
993
1379
  onBlur: () => onBlur(stablePath),
@@ -1008,22 +1394,42 @@ var FormRoot = ({ children, schema, values, onSave, onCancel, ...props }) => {
1008
1394
  onCancel,
1009
1395
  ...props
1010
1396
  });
1011
- return /* @__PURE__ */ React4.createElement(FormContextProvider, {
1397
+ return /* @__PURE__ */ React5.createElement(FormTooltipsContext.Provider, {
1398
+ value: props.tooltips ?? true
1399
+ }, /* @__PURE__ */ React5.createElement(FormContextProvider, {
1012
1400
  form,
1013
1401
  ...props
1014
- }, children);
1402
+ }, children));
1015
1403
  };
1016
1404
  FormRoot.displayName = "Form.Root";
1017
1405
  var FORM_VIEWPORT_NAME = "Form.Viewport";
1018
- var FormViewport = composable(({ children, ...props }, forwardedRef) => {
1019
- return /* @__PURE__ */ React4.createElement(ScrollArea.Root, {
1406
+ var FormViewport = composable(({ children, scroll, gutter = "sm", ...props }, forwardedRef) => {
1407
+ const span = "[.dx-column-root_&]:col-span-full";
1408
+ if (scroll) {
1409
+ return /* @__PURE__ */ React5.createElement(Column.Root, {
1410
+ gutter,
1411
+ classNames: [
1412
+ "dx-expander",
1413
+ span
1414
+ ]
1415
+ }, /* @__PURE__ */ React5.createElement(ScrollArea.Root, {
1416
+ ...composableProps(props),
1417
+ orientation: "vertical",
1418
+ centered: true,
1419
+ padding: true,
1420
+ thin: true,
1421
+ ref: forwardedRef
1422
+ }, /* @__PURE__ */ React5.createElement(ScrollArea.Viewport, null, children)));
1423
+ }
1424
+ return /* @__PURE__ */ React5.createElement(Column.Root, {
1020
1425
  ...composableProps(props),
1021
- orientation: "vertical",
1022
- centered: true,
1023
- padding: true,
1024
- thin: true,
1426
+ gutter,
1427
+ classNames: [
1428
+ "w-full min-w-0",
1429
+ span
1430
+ ],
1025
1431
  ref: forwardedRef
1026
- }, /* @__PURE__ */ React4.createElement(ScrollArea.Viewport, null, children));
1432
+ }, children);
1027
1433
  });
1028
1434
  FormViewport.displayName = FORM_VIEWPORT_NAME;
1029
1435
  var FORM_CONTENT_NAME = "Form.Content";
@@ -1035,10 +1441,10 @@ var FormContent = composable(({ children, ...props }, forwardedRef) => {
1035
1441
  localRef
1036
1442
  ]);
1037
1443
  useKeyHandler(localRef, form);
1038
- return /* @__PURE__ */ React4.createElement("div", {
1444
+ return /* @__PURE__ */ React5.createElement("div", {
1039
1445
  ...composableProps(props, {
1040
1446
  role: "form",
1041
- classNames: mx(withColumn.center(), "flex flex-col w-full pb-form-gap")
1447
+ classNames: mx3(withColumn.center(), "flex flex-col w-full")
1042
1448
  }),
1043
1449
  "data-testid": testId,
1044
1450
  ref: mergedRef
@@ -1048,13 +1454,27 @@ FormContent.displayName = FORM_CONTENT_NAME;
1048
1454
  var FORM_FIELDSET_NAME2 = "Form.FieldSet";
1049
1455
  var FormFieldSet2 = (props) => {
1050
1456
  const { form, ...contextProps } = useFormContext(FORM_FIELDSET_NAME2);
1051
- return /* @__PURE__ */ React4.createElement(FormFieldSet, {
1457
+ return /* @__PURE__ */ React5.createElement(FormFieldSet, {
1052
1458
  schema: form.schema,
1053
1459
  ...contextProps,
1054
1460
  ...props
1055
1461
  });
1056
1462
  };
1057
1463
  FormFieldSet2.displayName = FORM_FIELDSET_NAME2;
1464
+ var FORM_LAYOUT_NAME2 = "Form.Layout";
1465
+ var FormLayout2 = ({ schema, ...props }) => {
1466
+ const { form, ...contextProps } = useFormContext(FORM_LAYOUT_NAME2);
1467
+ const resolvedSchema = schema ?? form.schema;
1468
+ if (!resolvedSchema) {
1469
+ return null;
1470
+ }
1471
+ return /* @__PURE__ */ React5.createElement(FormLayout, {
1472
+ schema: resolvedSchema,
1473
+ ...contextProps,
1474
+ ...props
1475
+ });
1476
+ };
1477
+ FormLayout2.displayName = FORM_LAYOUT_NAME2;
1058
1478
  var FORM_ACTIONS_NAME = "Form.Actions";
1059
1479
  var FormActions = ({ classNames }) => {
1060
1480
  const { t } = useTranslation2(translationKey2);
@@ -1062,15 +1482,15 @@ var FormActions = ({ classNames }) => {
1062
1482
  if (readonly || layout === "static") {
1063
1483
  return null;
1064
1484
  }
1065
- return /* @__PURE__ */ React4.createElement("div", {
1066
- className: mx(withColumn.center(), "grid grid-flow-col gap-form-gap auto-cols-fr py-form-padding", classNames)
1067
- }, onCancel && /* @__PURE__ */ React4.createElement(IconButton, {
1485
+ return /* @__PURE__ */ React5.createElement("div", {
1486
+ className: mx3(withColumn.center(), "grid grid-flow-col gap-form-gap auto-cols-fr py-form-padding", classNames)
1487
+ }, onCancel && /* @__PURE__ */ React5.createElement(IconButton2, {
1068
1488
  icon: "ph--x--regular",
1069
1489
  iconEnd: true,
1070
1490
  label: t("cancel-button.label"),
1071
1491
  onClick: onCancel,
1072
1492
  "data-testid": "cancel-button"
1073
- }), onSave && /* @__PURE__ */ React4.createElement(IconButton, {
1493
+ }), onSave && /* @__PURE__ */ React5.createElement(IconButton2, {
1074
1494
  type: "submit",
1075
1495
  variant: "primary",
1076
1496
  disabled: !canSave,
@@ -1084,14 +1504,14 @@ var FormActions = ({ classNames }) => {
1084
1504
  FormActions.displayName = FORM_ACTIONS_NAME;
1085
1505
  var FORM_SECTION_NAME = "Form.Section";
1086
1506
  var FormSection = composable(({ children, label, description, ...props }, forwardedRef) => {
1087
- return /* @__PURE__ */ React4.createElement("div", {
1507
+ return /* @__PURE__ */ React5.createElement("div", {
1088
1508
  ...composableProps(props, {
1089
1509
  classNames: "flex flex-col pt-form-section-gap first:pt-0"
1090
1510
  }),
1091
1511
  ref: forwardedRef
1092
- }, label && /* @__PURE__ */ React4.createElement("h2", {
1512
+ }, label && /* @__PURE__ */ React5.createElement("h2", {
1093
1513
  className: "text-lg"
1094
- }, label), description && /* @__PURE__ */ React4.createElement("p", {
1514
+ }, label), description && /* @__PURE__ */ React5.createElement("p", {
1095
1515
  className: "text-description"
1096
1516
  }, description), children);
1097
1517
  });
@@ -1103,9 +1523,9 @@ var FormSubmit = ({ classNames, label, icon, disabled }) => {
1103
1523
  if (readonly || layout === "static") {
1104
1524
  return null;
1105
1525
  }
1106
- return /* @__PURE__ */ React4.createElement("div", {
1107
- className: mx("flex w-full pt-form-padding", classNames)
1108
- }, /* @__PURE__ */ React4.createElement(IconButton, {
1526
+ return /* @__PURE__ */ React5.createElement("div", {
1527
+ className: mx3("flex w-full pt-form-padding", classNames)
1528
+ }, /* @__PURE__ */ React5.createElement(IconButton2, {
1109
1529
  classNames: "w-full",
1110
1530
  type: "submit",
1111
1531
  variant: "primary",
@@ -1117,15 +1537,29 @@ var FormSubmit = ({ classNames, label, icon, disabled }) => {
1117
1537
  }));
1118
1538
  };
1119
1539
  FormSubmit.displayName = FORM_SUBMIT_NAME;
1540
+ var FORM_ERROR_NAME = "Form.Error";
1541
+ var FormError = ({ children, classNames }) => {
1542
+ if (!children) {
1543
+ return null;
1544
+ }
1545
+ return /* @__PURE__ */ React5.createElement(Input3.Root, {
1546
+ validationValence: "error"
1547
+ }, /* @__PURE__ */ React5.createElement(Input3.Validation, {
1548
+ classNames
1549
+ }, children));
1550
+ };
1551
+ FormError.displayName = FORM_ERROR_NAME;
1120
1552
  var Form = {
1121
1553
  Root: FormRoot,
1122
1554
  Viewport: FormViewport,
1123
1555
  Content: FormContent,
1124
1556
  Section: FormSection,
1125
1557
  FieldSet: FormFieldSet2,
1558
+ Layout: FormLayout2,
1126
1559
  Label: FormFieldLabel,
1127
1560
  Actions: FormActions,
1128
- Submit: FormSubmit
1561
+ Submit: FormSubmit,
1562
+ Error: FormError
1129
1563
  };
1130
1564
 
1131
1565
  // src/components/Form/fields/ArrayField.tsx
@@ -1135,13 +1569,13 @@ var ArrayField = ({ type, path, label, readonly, layout, fieldProps: inputProps,
1135
1569
  const { onValueChange } = inputProps;
1136
1570
  const values = useFormValues(ArrayField.displayName, path, () => []);
1137
1571
  const getDefaultObjectValue = (typeNode) => {
1138
- const baseNode = findNode2(typeNode, isDiscriminatedUnion2);
1139
- const typeLiteral = baseNode ? getDiscriminatedType2(baseNode, {}) : findNode2(typeNode, SchemaAST5.isTypeLiteral);
1572
+ const baseNode = findNode3(typeNode, isDiscriminatedUnion2);
1573
+ const typeLiteral = baseNode ? getDiscriminatedType2(baseNode, {}) : findNode3(typeNode, SchemaAST6.isTypeLiteral);
1140
1574
  if (!typeLiteral) {
1141
1575
  return {};
1142
1576
  }
1143
1577
  return Object.fromEntries(getFormProperties(typeLiteral).map((prop) => {
1144
- const defaultValue = SchemaAST5.getDefaultAnnotation(prop.type).pipe((annotation) => Option4.getOrUndefined(annotation));
1578
+ const defaultValue = SchemaAST6.getDefaultAnnotation(prop.type).pipe((annotation) => Option6.getOrUndefined(annotation));
1145
1579
  return [
1146
1580
  prop.name,
1147
1581
  defaultValue
@@ -1149,9 +1583,9 @@ var ArrayField = ({ type, path, label, readonly, layout, fieldProps: inputProps,
1149
1583
  }));
1150
1584
  };
1151
1585
  const handleAdd = useCallback3(() => {
1152
- const defaultValue = isNestedType2(type) && elementType ? getDefaultObjectValue(elementType) : getDefaultValue(elementType);
1153
- values && onValueChange(type, [
1154
- ...values,
1586
+ const defaultValue = isNestedType3(type) && elementType ? getDefaultObjectValue(elementType) : getDefaultValue(elementType);
1587
+ onValueChange(type, [
1588
+ ...values ?? [],
1155
1589
  defaultValue
1156
1590
  ]);
1157
1591
  }, [
@@ -1170,43 +1604,49 @@ var ArrayField = ({ type, path, label, readonly, layout, fieldProps: inputProps,
1170
1604
  if (!elementType || (readonly || layout === "static") && values && values.length < 1) {
1171
1605
  return null;
1172
1606
  }
1173
- return /* @__PURE__ */ React5.createElement(React5.Fragment, null, (layout !== "static" || values && values.length > 0) && /* @__PURE__ */ React5.createElement(FormFieldLabel, {
1607
+ const renderItemAsObject = elementType && isNestedType3(elementType) && !Ref2.isRefType(elementType);
1608
+ return /* @__PURE__ */ React6.createElement(React6.Fragment, null, (layout !== "static" || values && values.length > 0) && /* @__PURE__ */ React6.createElement("div", {
1609
+ className: "flex items-center gap-2"
1610
+ }, /* @__PURE__ */ React6.createElement("div", {
1611
+ className: "flex-1 min-w-0"
1612
+ }, /* @__PURE__ */ React6.createElement(FormFieldLabel, {
1174
1613
  readonly,
1175
1614
  label,
1615
+ path: createJsonPath6(path ?? []),
1176
1616
  asChild: true
1177
- }), /* @__PURE__ */ React5.createElement("div", {
1178
- className: "flex flex-col gap-form-gap"
1617
+ })), !readonly && layout !== "static" && /* @__PURE__ */ React6.createElement(IconBlock, {
1618
+ inline: true,
1619
+ icon: "ph--plus--regular",
1620
+ label: t("add-item.button"),
1621
+ onClick: handleAdd
1622
+ })), /* @__PURE__ */ React6.createElement("div", {
1623
+ className: "flex flex-col"
1179
1624
  }, values?.map((_, index) => {
1180
- return /* @__PURE__ */ React5.createElement("div", {
1181
- key: index,
1182
- className: "grid grid-cols-[1fr_min-content] gap-form-gap last:mb-form-gap items-center"
1183
- }, /* @__PURE__ */ React5.createElement(FormField, {
1184
- autoFocus: index === values.length - 1,
1625
+ const isLast = index === values.length - 1;
1626
+ const fieldField = /* @__PURE__ */ React6.createElement(FormField, {
1627
+ ...props,
1628
+ autoFocus: isLast,
1185
1629
  type: elementType,
1630
+ ...renderItemAsObject && {
1631
+ name: null
1632
+ },
1186
1633
  path: [
1187
1634
  ...path ?? [],
1188
1635
  index
1189
1636
  ],
1190
1637
  readonly: readonly || layout === "static",
1191
- layout: "inline",
1192
- ...props
1193
- }), !readonly && layout !== "static" && /* @__PURE__ */ React5.createElement("div", {
1194
- className: "flex flex-col h-full justify-end"
1195
- }, /* @__PURE__ */ React5.createElement("div", {
1196
- className: "flex items-center h-[2rem]"
1197
- }, /* @__PURE__ */ React5.createElement(IconButton2, {
1638
+ layout: renderItemAsObject ? layout === "static" ? "static" : void 0 : "inline"
1639
+ });
1640
+ return /* @__PURE__ */ React6.createElement("div", {
1641
+ key: index,
1642
+ className: "grid grid-cols-[1fr_min-content] items-center mb-1 last:mb-form-gap"
1643
+ }, fieldField, !readonly && layout !== "static" && /* @__PURE__ */ React6.createElement(IconBlock, {
1644
+ inline: !renderItemAsObject,
1198
1645
  icon: "ph--x--regular",
1199
- iconOnly: true,
1200
- label: t("remove.button"),
1201
- onClick: () => handleDelete(index),
1202
- classNames: "self-center"
1203
- }))));
1204
- })), !readonly && layout !== "static" && /* @__PURE__ */ React5.createElement(IconButton2, {
1205
- classNames: "flex w-full",
1206
- icon: "ph--plus--regular",
1207
- label: t("add-item.button"),
1208
- onClick: handleAdd
1209
- }));
1646
+ label: t("remove-item.button"),
1647
+ onClick: () => handleDelete(index)
1648
+ }));
1649
+ })));
1210
1650
  };
1211
1651
  ArrayField.displayName = "Form.ArrayField";
1212
1652
  var getDefaultValue = (ast) => {
@@ -1224,7 +1664,7 @@ var getDefaultValue = (ast) => {
1224
1664
  return getDefaultValue(ast.f());
1225
1665
  }
1226
1666
  default: {
1227
- if (ast && isNestedType2(ast)) {
1667
+ if (ast && isNestedType3(ast)) {
1228
1668
  return {};
1229
1669
  } else {
1230
1670
  throw new Error(`Unsupported type: ${ast?._tag}`);
@@ -1234,39 +1674,112 @@ var getDefaultValue = (ast) => {
1234
1674
  };
1235
1675
 
1236
1676
  // src/components/Form/fields/BooleanField.tsx
1237
- import React6, { useCallback as useCallback4 } from "react";
1238
- import { Input as Input2 } from "@dxos/react-ui";
1677
+ import React7, { useCallback as useCallback4 } from "react";
1678
+ import { Input as Input4 } from "@dxos/react-ui";
1239
1679
  var BooleanField = ({ type, readonly, onValueChange, ...props }) => {
1240
1680
  const handleChange = useCallback4((value3) => onValueChange?.(type, value3), [
1241
1681
  type,
1242
1682
  onValueChange
1243
1683
  ]);
1244
- return /* @__PURE__ */ React6.createElement(FormFieldWrapper, {
1684
+ return /* @__PURE__ */ React7.createElement(FormFieldWrapper, {
1245
1685
  readonly,
1246
1686
  ...props
1247
- }, ({ value: value3 }) => /* @__PURE__ */ React6.createElement(Input2.Switch, {
1687
+ }, ({ value: value3 }) => /* @__PURE__ */ React7.createElement(Input4.Switch, {
1248
1688
  disabled: !!readonly,
1249
1689
  checked: value3,
1250
1690
  onCheckedChange: handleChange
1251
1691
  }));
1252
1692
  };
1253
1693
 
1694
+ // src/components/Form/fields/DateField.tsx
1695
+ import { format as formatDate3 } from "date-fns";
1696
+ import React8, { useCallback as useCallback5 } from "react";
1697
+ import { Format as Format5 } from "@dxos/echo";
1698
+ import { Input as Input5 } from "@dxos/react-ui";
1699
+ var isoToLocalDateTime = (value3) => {
1700
+ if (!value3) {
1701
+ return "";
1702
+ }
1703
+ const date = new Date(value3);
1704
+ if (Number.isNaN(date.getTime())) {
1705
+ return "";
1706
+ }
1707
+ return formatDate3(date, "yyyy-MM-dd'T'HH:mm");
1708
+ };
1709
+ var localDateTimeToIso = (value3) => {
1710
+ if (!value3) {
1711
+ return void 0;
1712
+ }
1713
+ const date = new Date(value3);
1714
+ return Number.isNaN(date.getTime()) ? void 0 : date.toISOString();
1715
+ };
1716
+ var DateField = ({ type, format, readonly, placeholder: _placeholder, onValueChange, onBlur: _onBlur, ...props }) => {
1717
+ const handleSimpleChange = useCallback5((next) => onValueChange(type, next), [
1718
+ type,
1719
+ onValueChange
1720
+ ]);
1721
+ const handleDateTimeChange = useCallback5((next) => {
1722
+ const iso = localDateTimeToIso(next);
1723
+ onValueChange(type, iso);
1724
+ }, [
1725
+ type,
1726
+ onValueChange
1727
+ ]);
1728
+ return /* @__PURE__ */ React8.createElement(FormFieldWrapper, {
1729
+ readonly,
1730
+ format,
1731
+ ...props
1732
+ }, ({ value: value3 }) => {
1733
+ switch (format) {
1734
+ case Format5.TypeFormat.Date:
1735
+ return /* @__PURE__ */ React8.createElement("div", {
1736
+ className: "grid grid-cols-[minmax(0,1fr)_min-content] items-stretch gap-1"
1737
+ }, /* @__PURE__ */ React8.createElement(Input5.Date, {
1738
+ classNames: "min-w-0 overflow-hidden",
1739
+ disabled: !!readonly,
1740
+ value: value3 ?? "",
1741
+ onValueChange: handleSimpleChange
1742
+ }), /* @__PURE__ */ React8.createElement(Input5.TriggerIcon, {
1743
+ classNames: "h-full"
1744
+ }));
1745
+ case Format5.TypeFormat.Time:
1746
+ return /* @__PURE__ */ React8.createElement(Input5.Time, {
1747
+ disabled: !!readonly,
1748
+ value: value3 ?? "",
1749
+ onValueChange: handleSimpleChange
1750
+ });
1751
+ case Format5.TypeFormat.DateTime:
1752
+ default:
1753
+ return /* @__PURE__ */ React8.createElement("div", {
1754
+ className: "grid grid-cols-[minmax(0,1fr)_min-content] items-stretch gap-1"
1755
+ }, /* @__PURE__ */ React8.createElement(Input5.DateTime, {
1756
+ classNames: "min-w-0 overflow-hidden",
1757
+ disabled: !!readonly,
1758
+ value: isoToLocalDateTime(value3),
1759
+ onValueChange: handleDateTimeChange
1760
+ }), /* @__PURE__ */ React8.createElement(Input5.TriggerIcon, {
1761
+ classNames: "h-full"
1762
+ }));
1763
+ }
1764
+ });
1765
+ };
1766
+
1254
1767
  // src/components/Form/fields/GeoPointField.tsx
1255
- import React7, { useCallback as useCallback5, useEffect as useEffect3, useMemo as useMemo5, useState as useState2 } from "react";
1768
+ import React9, { useCallback as useCallback6, useEffect as useEffect3, useMemo as useMemo6, useState as useState2 } from "react";
1256
1769
  import { GeoLocation as GeoLocation3 } from "@dxos/echo/internal";
1257
- import { Input as Input3, useTranslation as useTranslation4 } from "@dxos/react-ui";
1770
+ import { Input as Input6, useTranslation as useTranslation4 } from "@dxos/react-ui";
1258
1771
  import { safeParseFloat } from "@dxos/util";
1259
1772
  import { translationKey as translationKey4 } from "#translations";
1260
- var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onValueChange, onBlur }) => {
1773
+ var GeoPointField = ({ type, label, jsonPath, readonly, layout, getStatus, getValue, onValueChange, onBlur }) => {
1261
1774
  const { t } = useTranslation4(translationKey4);
1262
1775
  const { status, error } = getStatus();
1263
- const geoPoint = useMemo5(() => getValue() ?? [
1776
+ const geoPoint = useMemo6(() => getValue() ?? [
1264
1777
  0,
1265
1778
  0
1266
1779
  ], [
1267
1780
  getValue
1268
1781
  ]);
1269
- const value3 = useMemo5(() => GeoLocation3.fromGeoPoint(geoPoint), [
1782
+ const value3 = useMemo6(() => GeoLocation3.fromGeoPoint(geoPoint), [
1270
1783
  geoPoint
1271
1784
  ]);
1272
1785
  const [longitudeText, setLongitudeText] = useState2(value3.longitude?.toString());
@@ -1278,7 +1791,7 @@ var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onVal
1278
1791
  }, [
1279
1792
  geoPoint
1280
1793
  ]);
1281
- const handleChange = useCallback5((coordinateType, setText) => (event) => {
1794
+ const handleChange = useCallback6((coordinateType, setText) => (event) => {
1282
1795
  const inputText = event.target.value;
1283
1796
  setText(inputText);
1284
1797
  if (inputText !== "" && inputText !== "-") {
@@ -1304,16 +1817,17 @@ var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onVal
1304
1817
  if ((readonly || layout === "static") && !value3?.latitude && !value3?.longitude) {
1305
1818
  return null;
1306
1819
  }
1307
- return /* @__PURE__ */ React7.createElement(Input3.Root, {
1820
+ return /* @__PURE__ */ React9.createElement(Input6.Root, {
1308
1821
  validationValence: status
1309
- }, layout !== "inline" && /* @__PURE__ */ React7.createElement(FormFieldLabel, {
1822
+ }, layout !== "inline" && /* @__PURE__ */ React9.createElement(FormFieldLabel, {
1310
1823
  error,
1311
1824
  readonly,
1312
1825
  label,
1826
+ path: jsonPath,
1313
1827
  asChild: true
1314
- }), layout === "static" ? /* @__PURE__ */ React7.createElement(LatLng, value3) : /* @__PURE__ */ React7.createElement("div", {
1828
+ }), layout === "static" ? /* @__PURE__ */ React9.createElement(LatLng, value3) : /* @__PURE__ */ React9.createElement("div", {
1315
1829
  className: "grid grid-cols-2 gap-form-gap"
1316
- }, /* @__PURE__ */ React7.createElement("div", null, /* @__PURE__ */ React7.createElement(Input3.Root, null, layout !== "inline" && /* @__PURE__ */ React7.createElement(Input3.Label, null, t("latitude.label")), /* @__PURE__ */ React7.createElement(Input3.TextInput, {
1830
+ }, /* @__PURE__ */ React9.createElement("div", null, /* @__PURE__ */ React9.createElement(Input6.Root, null, layout !== "inline" && /* @__PURE__ */ React9.createElement(Input6.Label, null, t("latitude.label")), /* @__PURE__ */ React9.createElement(Input6.TextInput, {
1317
1831
  type: "number",
1318
1832
  step: "0.00001",
1319
1833
  min: "-90",
@@ -1323,7 +1837,7 @@ var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onVal
1323
1837
  value: latitudeText ?? "",
1324
1838
  onChange: handleChange("latitude", setLatitudeText),
1325
1839
  onBlur
1326
- }))), /* @__PURE__ */ React7.createElement("div", null, /* @__PURE__ */ React7.createElement(Input3.Root, null, layout !== "inline" && /* @__PURE__ */ React7.createElement(Input3.Label, null, t("longitude.label")), /* @__PURE__ */ React7.createElement(Input3.TextInput, {
1840
+ }))), /* @__PURE__ */ React9.createElement("div", null, /* @__PURE__ */ React9.createElement(Input6.Root, null, layout !== "inline" && /* @__PURE__ */ React9.createElement(Input6.Label, null, t("longitude.label")), /* @__PURE__ */ React9.createElement(Input6.TextInput, {
1327
1841
  type: "number",
1328
1842
  step: "0.00001",
1329
1843
  min: "-180",
@@ -1338,30 +1852,128 @@ var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onVal
1338
1852
  var LatLng = ({ latitude = 0, longitude = 0 }) => {
1339
1853
  const latHem = latitude >= 0 ? "N" : "S";
1340
1854
  const lngHem = longitude >= 0 ? "E" : "W";
1341
- return /* @__PURE__ */ React7.createElement("span", {
1855
+ return /* @__PURE__ */ React9.createElement("span", {
1342
1856
  className: "inline-flex items-center gap-form-gap"
1343
- }, /* @__PURE__ */ React7.createElement("span", null, /* @__PURE__ */ React7.createElement("span", null, Math.abs(latitude).toFixed(5)), /* @__PURE__ */ React7.createElement("span", {
1857
+ }, /* @__PURE__ */ React9.createElement("span", null, /* @__PURE__ */ React9.createElement("span", null, Math.abs(latitude).toFixed(5)), /* @__PURE__ */ React9.createElement("span", {
1344
1858
  className: "text-subdued"
1345
- }, "\xB0", latHem)), /* @__PURE__ */ React7.createElement("span", null, /* @__PURE__ */ React7.createElement("span", null, Math.abs(longitude).toFixed(5)), /* @__PURE__ */ React7.createElement("span", {
1859
+ }, "\xB0", latHem)), /* @__PURE__ */ React9.createElement("span", null, /* @__PURE__ */ React9.createElement("span", null, Math.abs(longitude).toFixed(5)), /* @__PURE__ */ React9.createElement("span", {
1346
1860
  className: "text-subdued"
1347
1861
  }, "\xB0", lngHem)));
1348
1862
  };
1349
1863
 
1350
- // src/components/Form/fields/MarkdownField.tsx
1864
+ // src/components/Form/fields/InlineRefField.tsx
1351
1865
  import { useAtomValue } from "@effect-atom/atom-react";
1352
- import React8, { useCallback as useCallback6, useMemo as useMemo6 } from "react";
1353
- import { Obj, Ref as Ref2 } from "@dxos/echo";
1866
+ import React10, { useCallback as useCallback7, useMemo as useMemo7 } from "react";
1867
+ import { Obj, Ref as Ref3, Type as Type2 } from "@dxos/echo";
1354
1868
  import { AtomRef } from "@dxos/echo-atom";
1869
+ import { useType as defaultUseType } from "@dxos/echo-react";
1870
+ import { ReferenceAnnotationId as ReferenceAnnotationId2, splitJsonPath } from "@dxos/echo/internal";
1871
+ import { findAnnotation as findAnnotation2 } from "@dxos/effect";
1872
+ import { Button, Icon as Icon2, Input as Input7, useTranslation as useTranslation5 } from "@dxos/react-ui";
1873
+ import { translationKey as translationKey5 } from "#translations";
1874
+ var InlineRefField = (props) => {
1875
+ const { type, readonly, label, jsonPath, layout, db, getValue, onValueChange, onCreate, useType: useType2 = defaultUseType } = props;
1876
+ const { t } = useTranslation5(translationKey5);
1877
+ const reference = getValue();
1878
+ const typename = useMemo7(() => type ? findAnnotation2(type, ReferenceAnnotationId2)?.typename : void 0, [
1879
+ type
1880
+ ]);
1881
+ const createType = useType2(db, typename);
1882
+ const handleCreate = useCallback7(async () => {
1883
+ if (!createType || !onCreate) {
1884
+ return;
1885
+ }
1886
+ const newObject = await onCreate(createType, {});
1887
+ if (newObject) {
1888
+ onValueChange(type, Ref3.make(newObject));
1889
+ }
1890
+ }, [
1891
+ createType,
1892
+ onCreate,
1893
+ type,
1894
+ onValueChange
1895
+ ]);
1896
+ if (readonly && !reference) {
1897
+ return null;
1898
+ }
1899
+ return /* @__PURE__ */ React10.createElement(Input7.Root, null, layout !== "inline" && /* @__PURE__ */ React10.createElement(FormFieldLabel, {
1900
+ readonly,
1901
+ label,
1902
+ path: jsonPath
1903
+ }), reference ? /* @__PURE__ */ React10.createElement(InlineForm, {
1904
+ reference,
1905
+ db,
1906
+ readonly,
1907
+ useType: useType2
1908
+ }) : !readonly && onCreate && /* @__PURE__ */ React10.createElement(Button, {
1909
+ classNames: "w-full gap-form-gap",
1910
+ disabled: !createType || !db,
1911
+ onClick: () => void handleCreate()
1912
+ }, /* @__PURE__ */ React10.createElement(Icon2, {
1913
+ icon: "ph--plus--regular",
1914
+ size: 4
1915
+ }), /* @__PURE__ */ React10.createElement("span", null, label || t("ref-field.placeholder"))));
1916
+ };
1917
+ var InlineForm = ({ reference, db, readonly, useType: useType2 = defaultUseType }) => {
1918
+ const target = useAtomValue(useMemo7(() => AtomRef.make(reference), [
1919
+ reference
1920
+ ]));
1921
+ const typename = target ? Obj.getTypename(target) ?? void 0 : void 0;
1922
+ const typeFromRegistry = useType2(db, typename);
1923
+ const targetType = target && Obj.getType(target) || typeFromRegistry;
1924
+ const formSchema = useMemo7(() => targetType ? omitId(Type2.getSchema(targetType)) : void 0, [
1925
+ targetType
1926
+ ]);
1927
+ const defaultValues = useMemo7(() => target ? {
1928
+ ...target
1929
+ } : {}, [
1930
+ target
1931
+ ]);
1932
+ const handleChange = useCallback7((values, { isValid, changed }) => {
1933
+ if (!isValid || !target) {
1934
+ return;
1935
+ }
1936
+ const changedPaths = Object.keys(changed).filter((path) => changed[path]);
1937
+ if (changedPaths.length === 0) {
1938
+ return;
1939
+ }
1940
+ Obj.update(target, () => {
1941
+ for (const path of changedPaths) {
1942
+ const parts = splitJsonPath(path);
1943
+ Obj.setValue(target, parts, Obj.getValue(values, parts));
1944
+ }
1945
+ });
1946
+ }, [
1947
+ target
1948
+ ]);
1949
+ if (!target || !formSchema) {
1950
+ return null;
1951
+ }
1952
+ return /* @__PURE__ */ React10.createElement(Nesting, null, /* @__PURE__ */ React10.createElement(Form.Root, {
1953
+ schema: formSchema,
1954
+ defaultValues,
1955
+ db,
1956
+ onValuesChanged: handleChange
1957
+ }, /* @__PURE__ */ React10.createElement(Form.Content, null, /* @__PURE__ */ React10.createElement(Form.FieldSet, {
1958
+ readonly
1959
+ }))));
1960
+ };
1961
+
1962
+ // src/components/Form/fields/MarkdownField.tsx
1963
+ import { useAtomValue as useAtomValue2 } from "@effect-atom/atom-react";
1964
+ import React11, { useCallback as useCallback8, useMemo as useMemo8 } from "react";
1965
+ import { Obj as Obj2, Ref as Ref4 } from "@dxos/echo";
1966
+ import { AtomRef as AtomRef2 } from "@dxos/echo-atom";
1355
1967
  import { createDocAccessor } from "@dxos/echo-db";
1356
- import { Button, Icon as Icon2, Input as Input4, useTranslation as useTranslation5 } from "@dxos/react-ui";
1968
+ import { Button as Button2, Icon as Icon3, Input as Input8, useTranslation as useTranslation6 } from "@dxos/react-ui";
1357
1969
  import { Editor, useBasicMarkdownExtensions } from "@dxos/react-ui-editor";
1358
1970
  import { Text } from "@dxos/schema";
1359
1971
  import { createDataExtensions } from "@dxos/ui-editor";
1360
- import { translationKey as translationKey5 } from "#translations";
1972
+ import { translationKey as translationKey6 } from "#translations";
1361
1973
  var editorClassNames = "transition-colors bg-input-surface focus-within:bg-focus-surface border border-separator rounded-xs p-1 px-2";
1362
- var MarkdownField = ({ type, readonly, label, placeholder, layout, db, getStatus, getValue, onValueChange }) => {
1974
+ var MarkdownField = ({ type, readonly, label, jsonPath, placeholder, layout, db, getStatus, getValue, onValueChange }) => {
1363
1975
  const { status, error } = getStatus();
1364
- const isRef = Ref2.isRefType(type);
1976
+ const isRef = Ref4.isRefType(type);
1365
1977
  const value3 = getValue();
1366
1978
  if ((readonly || layout === "static") && value3 == null) {
1367
1979
  return null;
@@ -1370,7 +1982,7 @@ var MarkdownField = ({ type, readonly, label, placeholder, layout, db, getStatus
1370
1982
  if (isRef) {
1371
1983
  const reference = value3;
1372
1984
  if (reference) {
1373
- return /* @__PURE__ */ React8.createElement(RefMarkdownEditor, {
1985
+ return /* @__PURE__ */ React11.createElement(RefMarkdownEditor, {
1374
1986
  reference,
1375
1987
  placeholder
1376
1988
  });
@@ -1378,13 +1990,13 @@ var MarkdownField = ({ type, readonly, label, placeholder, layout, db, getStatus
1378
1990
  if (readonly) {
1379
1991
  return null;
1380
1992
  }
1381
- return /* @__PURE__ */ React8.createElement(CreateTextButton, {
1993
+ return /* @__PURE__ */ React11.createElement(CreateTextButton, {
1382
1994
  db,
1383
1995
  disabled: !db,
1384
1996
  onCreate: (ref) => onValueChange(type, ref)
1385
1997
  });
1386
1998
  }
1387
- return /* @__PURE__ */ React8.createElement(StringMarkdownEditor, {
1999
+ return /* @__PURE__ */ React11.createElement(StringMarkdownEditor, {
1388
2000
  value: value3 ?? "",
1389
2001
  placeholder,
1390
2002
  readonly: !!readonly,
@@ -1394,40 +2006,41 @@ var MarkdownField = ({ type, readonly, label, placeholder, layout, db, getStatus
1394
2006
  const renderStatic = () => {
1395
2007
  if (isRef) {
1396
2008
  const reference = value3;
1397
- return reference ? /* @__PURE__ */ React8.createElement(RefStaticText, {
2009
+ return reference ? /* @__PURE__ */ React11.createElement(RefStaticText, {
1398
2010
  reference
1399
2011
  }) : null;
1400
2012
  }
1401
- return /* @__PURE__ */ React8.createElement("p", {
2013
+ return /* @__PURE__ */ React11.createElement("p", {
1402
2014
  className: "whitespace-pre-wrap"
1403
2015
  }, value3 ?? "");
1404
2016
  };
1405
- return /* @__PURE__ */ React8.createElement(Input4.Root, {
2017
+ return /* @__PURE__ */ React11.createElement(Input8.Root, {
1406
2018
  validationValence: status
1407
- }, layout !== "inline" && /* @__PURE__ */ React8.createElement(FormFieldLabel, {
2019
+ }, layout !== "inline" && /* @__PURE__ */ React11.createElement(FormFieldLabel, {
1408
2020
  error,
1409
2021
  readonly,
1410
- label
1411
- }), layout === "static" ? renderStatic() : renderEditor(), layout === "full" && /* @__PURE__ */ React8.createElement(Input4.Validation, null, error));
2022
+ label,
2023
+ path: jsonPath
2024
+ }), layout === "static" ? renderStatic() : renderEditor(), layout === "full" && /* @__PURE__ */ React11.createElement(Input8.Validation, null, error));
1412
2025
  };
1413
2026
  var RefStaticText = ({ reference }) => {
1414
- const text = useAtomValue(useMemo6(() => AtomRef.make(reference), [
2027
+ const text = useAtomValue2(useMemo8(() => AtomRef2.make(reference), [
1415
2028
  reference
1416
2029
  ]));
1417
2030
  if (!text?.content) {
1418
2031
  return null;
1419
2032
  }
1420
- return /* @__PURE__ */ React8.createElement("p", {
2033
+ return /* @__PURE__ */ React11.createElement("p", {
1421
2034
  className: "whitespace-pre-wrap"
1422
2035
  }, text.content);
1423
2036
  };
1424
2037
  var RefMarkdownEditor = ({ reference, placeholder }) => {
1425
- const text = useAtomValue(useMemo6(() => AtomRef.make(reference), [
2038
+ const text = useAtomValue2(useMemo8(() => AtomRef2.make(reference), [
1426
2039
  reference
1427
2040
  ]));
1428
- const dataExtensions = useMemo6(() => text ? [
2041
+ const dataExtensions = useMemo8(() => text ? [
1429
2042
  createDataExtensions({
1430
- id: reference.dxn.toString(),
2043
+ id: reference.uri,
1431
2044
  text: createDocAccessor(text, [
1432
2045
  "content"
1433
2046
  ])
@@ -1443,7 +2056,7 @@ var RefMarkdownEditor = ({ reference, placeholder }) => {
1443
2056
  if (!text) {
1444
2057
  return null;
1445
2058
  }
1446
- return /* @__PURE__ */ React8.createElement(Editor.Root, null, /* @__PURE__ */ React8.createElement(Editor.View, {
2059
+ return /* @__PURE__ */ React11.createElement(Editor.Root, null, /* @__PURE__ */ React11.createElement(Editor.View, {
1447
2060
  classNames: editorClassNames,
1448
2061
  extensions
1449
2062
  }));
@@ -1452,10 +2065,10 @@ var StringMarkdownEditor = ({ value: value3, placeholder, readonly, onChange })
1452
2065
  const extensions = useBasicMarkdownExtensions({
1453
2066
  placeholder
1454
2067
  });
1455
- const handleChange = useCallback6((next) => onChange(next), [
2068
+ const handleChange = useCallback8((next) => onChange(next), [
1456
2069
  onChange
1457
2070
  ]);
1458
- return /* @__PURE__ */ React8.createElement(Editor.Root, null, /* @__PURE__ */ React8.createElement(Editor.View, {
2071
+ return /* @__PURE__ */ React11.createElement(Editor.Root, null, /* @__PURE__ */ React11.createElement(Editor.View, {
1459
2072
  classNames: editorClassNames,
1460
2073
  extensions,
1461
2074
  value: value3,
@@ -1463,41 +2076,41 @@ var StringMarkdownEditor = ({ value: value3, placeholder, readonly, onChange })
1463
2076
  }));
1464
2077
  };
1465
2078
  var CreateTextButton = ({ db, disabled, onCreate }) => {
1466
- const { t } = useTranslation5(translationKey5);
1467
- const handleClick = useCallback6(() => {
2079
+ const { t } = useTranslation6(translationKey6);
2080
+ const handleClick = useCallback8(() => {
1468
2081
  if (!db) {
1469
2082
  return;
1470
2083
  }
1471
- const text = db.add(Obj.make(Text.Text, {
2084
+ const text = db.add(Obj2.make(Text.Text, {
1472
2085
  content: ""
1473
2086
  }));
1474
- onCreate(Ref2.make(text));
2087
+ onCreate(Ref4.make(text));
1475
2088
  }, [
1476
2089
  db,
1477
2090
  onCreate
1478
2091
  ]);
1479
- return /* @__PURE__ */ React8.createElement(Button, {
2092
+ return /* @__PURE__ */ React11.createElement(Button2, {
1480
2093
  onClick: handleClick,
1481
2094
  disabled
1482
- }, /* @__PURE__ */ React8.createElement(Icon2, {
2095
+ }, /* @__PURE__ */ React11.createElement(Icon3, {
1483
2096
  icon: "ph--plus--regular",
1484
2097
  size: 4
1485
- }), /* @__PURE__ */ React8.createElement("span", null, t("create-text.label")));
2098
+ }), /* @__PURE__ */ React11.createElement("span", null, t("create-text.label")));
1486
2099
  };
1487
2100
 
1488
2101
  // src/components/Form/fields/NumberField.tsx
1489
- import React9, { useCallback as useCallback7 } from "react";
1490
- import { Input as Input5 } from "@dxos/react-ui";
2102
+ import React12, { useCallback as useCallback9 } from "react";
2103
+ import { Input as Input9 } from "@dxos/react-ui";
1491
2104
  import { safeParseFloat as safeParseFloat2 } from "@dxos/util";
1492
2105
  var NumberField = ({ type, readonly, placeholder, onValueChange, onBlur, ...props }) => {
1493
- const handleChange = useCallback7((event) => onValueChange(type, safeParseFloat2(event.target.value) || 0), [
2106
+ const handleChange = useCallback9((event) => onValueChange(type, safeParseFloat2(event.target.value) || 0), [
1494
2107
  type,
1495
2108
  onValueChange
1496
2109
  ]);
1497
- return /* @__PURE__ */ React9.createElement(FormFieldWrapper, {
2110
+ return /* @__PURE__ */ React12.createElement(FormFieldWrapper, {
1498
2111
  readonly,
1499
2112
  ...props
1500
- }, ({ value: value3 = "" }) => /* @__PURE__ */ React9.createElement(Input5.TextInput, {
2113
+ }, ({ value: value3 = "" }) => /* @__PURE__ */ React12.createElement(Input9.TextInput, {
1501
2114
  type: "number",
1502
2115
  disabled: !!readonly,
1503
2116
  placeholder,
@@ -1508,43 +2121,43 @@ var NumberField = ({ type, readonly, placeholder, onValueChange, onBlur, ...prop
1508
2121
  };
1509
2122
 
1510
2123
  // src/components/Form/fields/RefField.tsx
1511
- import React11, { useCallback as useCallback9, useMemo as useMemo7, useState as useState4 } from "react";
2124
+ import React14, { useCallback as useCallback11, useMemo as useMemo9, useState as useState4 } from "react";
1512
2125
  import "@dxos/lit-ui/dx-tag-picker.pcss";
1513
- import { Entity, Filter, Obj as Obj2, Ref as Ref3, Type } from "@dxos/echo";
1514
- import { useQuery, useSchema as defaultUseSchema } from "@dxos/echo-react";
1515
- import { ReferenceAnnotationId as ReferenceAnnotationId2 } from "@dxos/echo/internal";
1516
- import { findAnnotation as findAnnotation2 } from "@dxos/effect";
1517
- import { DXN } from "@dxos/keys";
2126
+ import { Entity, Filter, Obj as Obj3, Ref as Ref5, Type as Type3 } from "@dxos/echo";
2127
+ import { useQuery, useType as defaultUseType2 } from "@dxos/echo-react";
2128
+ import { ANY_OBJECT_TYPENAME, ReferenceAnnotationId as ReferenceAnnotationId3 } from "@dxos/echo/internal";
2129
+ import { findAnnotation as findAnnotation3 } from "@dxos/effect";
2130
+ import { URI } from "@dxos/keys";
1518
2131
  import { DxAnchor } from "@dxos/lit-ui/react";
1519
- import { Button as Button2, Icon as Icon3, Input as Input6, useTranslation as useTranslation7 } from "@dxos/react-ui";
2132
+ import { Button as Button3, Icon as Icon4, Input as Input10, useTranslation as useTranslation8 } from "@dxos/react-ui";
1520
2133
  import { ParentLabelAnnotationId } from "@dxos/schema";
1521
- import { translationKey as translationKey7 } from "#translations";
2134
+ import { translationKey as translationKey8 } from "#translations";
1522
2135
 
1523
2136
  // src/components/ObjectPicker/ObjectPicker.tsx
1524
- import React10, { forwardRef, useCallback as useCallback8, useState as useState3 } from "react";
1525
- import { Popover, useTranslation as useTranslation6 } from "@dxos/react-ui";
2137
+ import React13, { forwardRef, useCallback as useCallback10, useState as useState3 } from "react";
2138
+ import { Popover, useTranslation as useTranslation7 } from "@dxos/react-ui";
1526
2139
  import { Combobox } from "@dxos/react-ui-list";
1527
2140
  import { useSearchListResults } from "@dxos/react-ui-search";
1528
- import { translationKey as translationKey6 } from "#translations";
2141
+ import { translationKey as translationKey7 } from "#translations";
1529
2142
  var ObjectPickerContent = /* @__PURE__ */ forwardRef(({ options, selectedIds, createSchema, createOptionLabel, createOptionIcon, createInitialValuePath, createFieldMap: createFieldMap3, onSelect, onCreate, ...props }, forwardedRef) => {
1530
- const { t } = useTranslation6(translationKey6);
2143
+ const { t } = useTranslation7(translationKey7);
1531
2144
  const [showForm, setShowForm] = useState3(false);
1532
2145
  const [formInitialValue, setFormInitialValue] = useState3("");
1533
2146
  const { results, query, handleSearch } = useSearchListResults({
1534
2147
  items: options
1535
2148
  });
1536
- const handleFormSave = useCallback8(async (values) => {
2149
+ const handleFormSave = useCallback10(async (values) => {
1537
2150
  await onCreate?.(values);
1538
2151
  setShowForm(false);
1539
2152
  setFormInitialValue("");
1540
2153
  }, [
1541
2154
  onCreate
1542
2155
  ]);
1543
- const handleFormCancel = useCallback8(() => {
2156
+ const handleFormCancel = useCallback10(() => {
1544
2157
  setShowForm(false);
1545
2158
  setFormInitialValue("");
1546
2159
  }, []);
1547
- const handleKeyDown = useCallback8((event) => {
2160
+ const handleKeyDown = useCallback10((event) => {
1548
2161
  if (event.key === "Enter" && createSchema && event.currentTarget.querySelector('[role="option"][aria-selected="true"][data-value="__create__"]')) {
1549
2162
  event.stopPropagation();
1550
2163
  event.preventDefault();
@@ -1557,11 +2170,11 @@ var ObjectPickerContent = /* @__PURE__ */ forwardRef(({ options, selectedIds, cr
1557
2170
  createSchema
1558
2171
  ]);
1559
2172
  if (showForm && createSchema) {
1560
- return /* @__PURE__ */ React10.createElement(Combobox.Content, {
2173
+ return /* @__PURE__ */ React13.createElement(Combobox.Content, {
1561
2174
  ...props,
1562
2175
  onKeyDownCapture: handleKeyDown,
1563
2176
  ref: forwardedRef
1564
- }, /* @__PURE__ */ React10.createElement(Popover.Viewport, null, /* @__PURE__ */ React10.createElement(Form.Root, {
2177
+ }, /* @__PURE__ */ React13.createElement(Popover.Viewport, null, /* @__PURE__ */ React13.createElement(Form.Root, {
1565
2178
  testId: "create-referenced-object-form",
1566
2179
  schema: createSchema,
1567
2180
  defaultValues: createInitialValuePath ? {
@@ -1570,25 +2183,25 @@ var ObjectPickerContent = /* @__PURE__ */ forwardRef(({ options, selectedIds, cr
1570
2183
  fieldMap: createFieldMap3,
1571
2184
  onSave: handleFormSave,
1572
2185
  onCancel: handleFormCancel
1573
- }, /* @__PURE__ */ React10.createElement(Form.Viewport, null, /* @__PURE__ */ React10.createElement(Form.Content, null, /* @__PURE__ */ React10.createElement(Form.FieldSet, null), /* @__PURE__ */ React10.createElement(Form.Actions, null))))), /* @__PURE__ */ React10.createElement(Combobox.Arrow, null));
2186
+ }, /* @__PURE__ */ React13.createElement(Form.Viewport, null, /* @__PURE__ */ React13.createElement(Form.Content, null, /* @__PURE__ */ React13.createElement(Form.FieldSet, null), /* @__PURE__ */ React13.createElement(Form.Actions, null))))), /* @__PURE__ */ React13.createElement(Combobox.Arrow, null));
1574
2187
  }
1575
- return /* @__PURE__ */ React10.createElement(Combobox.Content, {
2188
+ return /* @__PURE__ */ React13.createElement(Combobox.Content, {
1576
2189
  ...props,
1577
2190
  onKeyDownCapture: handleKeyDown,
1578
2191
  ref: forwardedRef
1579
- }, /* @__PURE__ */ React10.createElement(Combobox.Input, {
2192
+ }, /* @__PURE__ */ React13.createElement(Combobox.Input, {
1580
2193
  placeholder: t("ref-field-combobox-input.placeholder"),
1581
2194
  autoFocus: true,
1582
2195
  value: query,
1583
2196
  onValueChange: handleSearch
1584
- }), /* @__PURE__ */ React10.createElement(Combobox.List, null, results.map((option) => /* @__PURE__ */ React10.createElement(Combobox.Item, {
2197
+ }), /* @__PURE__ */ React13.createElement(Combobox.List, null, results.map((option) => /* @__PURE__ */ React13.createElement(Combobox.Item, {
1585
2198
  key: option.id,
1586
2199
  value: option.id,
1587
2200
  label: option.label,
1588
2201
  checked: selectedIds?.includes(option.id),
1589
2202
  onSelect: () => onSelect(option.id),
1590
2203
  classNames: "flex items-center gap-2"
1591
- })), createSchema && onCreate && /* @__PURE__ */ React10.createElement(CreateItem, {
2204
+ })), createSchema && onCreate && /* @__PURE__ */ React13.createElement(CreateItem, {
1592
2205
  query,
1593
2206
  createOptionLabel,
1594
2207
  createOptionIcon: createOptionIcon ?? "ph--plus--regular",
@@ -1596,15 +2209,15 @@ var ObjectPickerContent = /* @__PURE__ */ forwardRef(({ options, selectedIds, cr
1596
2209
  setFormInitialValue(currentQuery);
1597
2210
  setShowForm(true);
1598
2211
  }
1599
- })), /* @__PURE__ */ React10.createElement(Combobox.Arrow, null));
2212
+ })), /* @__PURE__ */ React13.createElement(Combobox.Arrow, null));
1600
2213
  });
1601
2214
  var CreateItem = ({ query, createOptionLabel, createOptionIcon, onCreateItemSelect }) => {
1602
- const { t } = useTranslation6(translationKey6);
2215
+ const { t } = useTranslation7(translationKey7);
1603
2216
  const label = createOptionLabel ? t(createOptionLabel[0], {
1604
2217
  ns: createOptionLabel[1].ns,
1605
2218
  text: query
1606
2219
  }) : t("create-option.label");
1607
- return /* @__PURE__ */ React10.createElement(Combobox.Item, {
2220
+ return /* @__PURE__ */ React13.createElement(Combobox.Item, {
1608
2221
  value: "__create__",
1609
2222
  label,
1610
2223
  icon: createOptionIcon,
@@ -1629,25 +2242,25 @@ var isRefSnapshot = (val) => {
1629
2242
  return typeof val === "object" && typeof val?.["/"] === "string";
1630
2243
  };
1631
2244
  var defaultGetOptions = (results, { parentLabel } = {}) => results.map((result) => {
1632
- const id = Entity.getDXN(result).toString();
1633
- const parent = parentLabel ? Obj2.getParent(result) : void 0;
2245
+ const id = Entity.getURI(result);
2246
+ const parent = parentLabel ? Obj3.getParent(result) : void 0;
1634
2247
  const label = parent ? Entity.getLabel(parent) : Entity.getLabel(result);
1635
2248
  return {
1636
2249
  id,
1637
2250
  label: label ?? id
1638
2251
  };
1639
2252
  });
1640
- var defaultUseResults = (db, typename) => useQuery(db, typename ? typename === Type.getTypename(Obj2.Unknown) ? Filter.everything() : Filter.typename(typename) : Filter.nothing());
2253
+ var defaultUseResults = (db, typename) => useQuery(db, typename ? typename === ANY_OBJECT_TYPENAME ? Filter.everything() : Filter.typename(typename) : Filter.nothing());
1641
2254
  var RefField = (props) => {
1642
- const { type, readonly, label, placeholder, layout, getStatus, getValue, createOptionLabel, createOptionIcon, createInitialValuePath, createFieldMap: createFieldMap3, db, useSchema: useSchema2 = defaultUseSchema, useResults = defaultUseResults, getOptions = defaultGetOptions, onCreate, onValueChange } = props;
1643
- const { t } = useTranslation7(translationKey7);
2255
+ const { type, readonly, label, jsonPath, placeholder, layout, getStatus, getValue, createOptionLabel, createOptionIcon, createInitialValuePath, createFieldMap: createFieldMap3, db, useType: useType2 = defaultUseType2, useResults = defaultUseResults, getOptions = defaultGetOptions, onCreate, onValueChange } = props;
2256
+ const { t } = useTranslation8(translationKey8);
1644
2257
  const { status, error } = getStatus();
1645
- const typename = useMemo7(() => type ? findAnnotation2(type, ReferenceAnnotationId2)?.typename : void 0, [
2258
+ const typename = useMemo9(() => type ? findAnnotation3(type, ReferenceAnnotationId3)?.typename : void 0, [
1646
2259
  type
1647
2260
  ]);
1648
2261
  const results = useResults(db, typename);
1649
- const options = useMemo7(() => {
1650
- const parentLabel = type ? findAnnotation2(type, ParentLabelAnnotationId) === true : false;
2262
+ const options = useMemo9(() => {
2263
+ const parentLabel = type ? findAnnotation3(type, ParentLabelAnnotationId) === true : false;
1651
2264
  return getOptions(results, {
1652
2265
  parentLabel
1653
2266
  });
@@ -1656,15 +2269,15 @@ var RefField = (props) => {
1656
2269
  getOptions,
1657
2270
  type
1658
2271
  ]);
1659
- const handleGetValue = useCallback9(() => {
2272
+ const handleGetValue = useCallback11(() => {
1660
2273
  const formValue = getValue();
1661
- const dxnToObjectId = (dxn) => dxn.split(":").pop() ?? dxn;
2274
+ const dxnToEntityId = (dxn) => dxn.split(/[:/]/).filter(Boolean).pop() ?? dxn;
1662
2275
  const unknownToRefOption = (value3) => {
1663
- const isRef = Ref3.isRef(value3);
2276
+ const isRef = Ref5.isRef(value3);
1664
2277
  if (isRef || isRefSnapshot(value3)) {
1665
- const dxnString = isRef ? value3.dxn.toString() : value3["/"];
1666
- const objectId = dxnToObjectId(dxnString);
1667
- const matchingOption = options.find((option) => dxnToObjectId(option.id) === objectId);
2278
+ const dxnString = isRef ? value3.uri : value3["/"];
2279
+ const objectId = dxnToEntityId(dxnString);
2280
+ const matchingOption = options.find((option) => dxnToEntityId(option.id) === objectId);
1668
2281
  if (matchingOption) {
1669
2282
  return matchingOption;
1670
2283
  }
@@ -1677,20 +2290,20 @@ var RefField = (props) => {
1677
2290
  getValue
1678
2291
  ]);
1679
2292
  const item = handleGetValue();
1680
- const selectedIds = useMemo7(() => item ? [
2293
+ const selectedIds = useMemo9(() => item ? [
1681
2294
  item.id
1682
2295
  ] : [], [
1683
2296
  item
1684
2297
  ]);
1685
- const createSchema = useSchema2(db, typename);
2298
+ const createSchema = useType2(db, typename);
1686
2299
  const [open, setOpen] = useState4(false);
1687
- const handleCreate = useCallback9(async (values) => {
2300
+ const handleCreate = useCallback11(async (values) => {
1688
2301
  if (!createSchema || !onCreate) {
1689
2302
  return;
1690
2303
  }
1691
2304
  const newObject = await onCreate(createSchema, values);
1692
2305
  if (newObject) {
1693
- onValueChange(type, Ref3.make(newObject));
2306
+ onValueChange(type, Ref5.make(newObject));
1694
2307
  }
1695
2308
  setOpen(false);
1696
2309
  }, [
@@ -1699,16 +2312,16 @@ var RefField = (props) => {
1699
2312
  type,
1700
2313
  onValueChange
1701
2314
  ]);
1702
- const handleUpdate = useCallback9((id) => {
2315
+ const handleUpdate = useCallback11((id) => {
1703
2316
  const item2 = options.find((option) => option.id === id);
1704
- const ref = item2 ? Ref3.fromDXN(DXN.parse(item2.id)) : void 0;
2317
+ const ref = item2 ? Ref5.fromURI(URI.make(item2.id)) : void 0;
1705
2318
  onValueChange(type, ref);
1706
2319
  }, [
1707
2320
  options,
1708
2321
  type,
1709
2322
  onValueChange
1710
2323
  ]);
1711
- const handleSelect = useCallback9((id) => {
2324
+ const handleSelect = useCallback11((id) => {
1712
2325
  if (item?.id === id) {
1713
2326
  handleUpdate(void 0);
1714
2327
  } else {
@@ -1721,103 +2334,117 @@ var RefField = (props) => {
1721
2334
  if (!typename || (readonly || layout === "static") && !item) {
1722
2335
  return null;
1723
2336
  }
1724
- return /* @__PURE__ */ React11.createElement(Input6.Root, {
2337
+ return /* @__PURE__ */ React14.createElement(Input10.Root, {
1725
2338
  validationValence: status
1726
- }, layout !== "inline" && /* @__PURE__ */ React11.createElement(FormFieldLabel, {
2339
+ }, layout !== "inline" && /* @__PURE__ */ React14.createElement(FormFieldLabel, {
1727
2340
  error,
1728
2341
  readonly,
1729
- label
1730
- }), /* @__PURE__ */ React11.createElement("div", null, readonly ? !item ? /* @__PURE__ */ React11.createElement("p", {
2342
+ label,
2343
+ path: jsonPath
2344
+ }), /* @__PURE__ */ React14.createElement("div", null, readonly ? !item ? /* @__PURE__ */ React14.createElement("p", {
1731
2345
  className: "text-description mb-2"
1732
- }, t("empty-readonly-ref-field.label")) : /* @__PURE__ */ React11.createElement(DxAnchor, {
2346
+ }, t("empty-readonly-ref-field.label")) : /* @__PURE__ */ React14.createElement(DxAnchor, {
1733
2347
  key: item.id,
1734
2348
  dxn: item.id,
1735
2349
  rootclassname: "me-1"
1736
- }, item.label) : /* @__PURE__ */ React11.createElement(ObjectPicker.Root, {
2350
+ }, item.label) : /* @__PURE__ */ React14.createElement(ObjectPicker.Root, {
1737
2351
  open,
1738
2352
  onOpenChange: setOpen
1739
- }, /* @__PURE__ */ React11.createElement(ObjectPicker.Trigger, {
2353
+ }, /* @__PURE__ */ React14.createElement(ObjectPicker.Trigger, {
1740
2354
  asChild: true,
1741
2355
  classNames: "p-0"
1742
- }, item ? /* @__PURE__ */ React11.createElement("div", {
2356
+ }, item ? /* @__PURE__ */ React14.createElement("div", {
1743
2357
  className: "flex gap-form-gap w-full"
1744
- }, /* @__PURE__ */ React11.createElement(Input6.Root, {
2358
+ }, /* @__PURE__ */ React14.createElement(Input10.Root, {
1745
2359
  key: item.id
1746
- }, /* @__PURE__ */ React11.createElement(Input6.TextInput, {
2360
+ }, /* @__PURE__ */ React14.createElement(Input10.TextInput, {
1747
2361
  value: item.label,
1748
2362
  readOnly: true,
1749
2363
  classNames: "w-full"
1750
- }))) : /* @__PURE__ */ React11.createElement(Button2, {
2364
+ }))) : /* @__PURE__ */ React14.createElement(Button3, {
1751
2365
  classNames: "w-full text-start gap-form-gap"
1752
- }, /* @__PURE__ */ React11.createElement("div", {
2366
+ }, /* @__PURE__ */ React14.createElement("div", {
1753
2367
  className: "grow overflow-hidden"
1754
- }, /* @__PURE__ */ React11.createElement("span", {
2368
+ }, /* @__PURE__ */ React14.createElement("span", {
1755
2369
  className: "truncate text-description"
1756
- }, placeholder ?? t("ref-field.placeholder"))), /* @__PURE__ */ React11.createElement(Icon3, {
2370
+ }, placeholder || label || t("ref-field.placeholder"))), /* @__PURE__ */ React14.createElement(Icon4, {
1757
2371
  size: 3,
1758
2372
  icon: "ph--caret-down--bold"
1759
- }))), /* @__PURE__ */ React11.createElement(ObjectPicker.Portal, null, /* @__PURE__ */ React11.createElement(ObjectPicker.Content, {
2373
+ }))), /* @__PURE__ */ React14.createElement(ObjectPicker.Portal, null, /* @__PURE__ */ React14.createElement(ObjectPicker.Content, {
1760
2374
  classNames: "dx-card-popover-width",
1761
2375
  options,
1762
2376
  selectedIds,
1763
2377
  // Strip hidden (`FormInputAnnotation.set(false)`) fields so the
1764
2378
  // form's validator doesn't reject required-but-hidden fields
1765
2379
  // such as backing-object refs supplied by a `FactoryAnnotation`.
1766
- createSchema: createSchema && omitHiddenFormFields(omitId(createSchema)),
2380
+ createSchema: createSchema && omitHiddenFormFields(omitId(Type3.getSchema(createSchema))),
1767
2381
  createOptionLabel,
1768
2382
  createOptionIcon,
1769
2383
  createInitialValuePath,
1770
2384
  createFieldMap: createFieldMap3,
1771
2385
  onCreate: handleCreate,
1772
2386
  onSelect: handleSelect
1773
- })))), layout === "full" && /* @__PURE__ */ React11.createElement(Input6.DescriptionAndValidation, null, error));
2387
+ })))), layout === "full" && /* @__PURE__ */ React14.createElement(Input10.DescriptionAndValidation, null, error));
1774
2388
  };
1775
2389
 
1776
2390
  // src/components/Form/fields/SelectField.tsx
1777
- import React12, { useCallback as useCallback10 } from "react";
1778
- import { Input as Input7, Select } from "@dxos/react-ui";
1779
- var SelectField = ({ type, readonly, label, layout, placeholder, options, getStatus, getValue, onValueChange }) => {
2391
+ import React15, { useCallback as useCallback12 } from "react";
2392
+ import { Icon as Icon5, Input as Input11, Select } from "@dxos/react-ui";
2393
+ import { getStyles } from "@dxos/ui-theme";
2394
+ var SelectField = ({ type, readonly, label, jsonPath, layout, placeholder, options, getStatus, getValue, onValueChange }) => {
1780
2395
  const { status, error } = getStatus();
1781
2396
  const value3 = getValue();
1782
- const handleValueChange = useCallback10((value4) => onValueChange(type, value4), [
2397
+ const handleValueChange = useCallback12((value4) => onValueChange(type, value4), [
1783
2398
  type,
1784
2399
  onValueChange
1785
2400
  ]);
1786
2401
  if ((readonly || layout === "static") && value3 == null) {
1787
2402
  return null;
1788
2403
  }
1789
- return /* @__PURE__ */ React12.createElement(Input7.Root, {
2404
+ return /* @__PURE__ */ React15.createElement(Input11.Root, {
1790
2405
  validationValence: status
1791
- }, layout !== "inline" && /* @__PURE__ */ React12.createElement(FormFieldLabel, {
2406
+ }, layout !== "inline" && /* @__PURE__ */ React15.createElement(FormFieldLabel, {
1792
2407
  error,
1793
2408
  readonly,
1794
- label
1795
- }), layout === "static" ? /* @__PURE__ */ React12.createElement("p", null, options?.find(({ value: optionValue }) => optionValue === value3)?.label ?? String(value3)) : /* @__PURE__ */ React12.createElement(Select.Root, {
2409
+ label,
2410
+ path: jsonPath
2411
+ }), layout === "static" ? /* @__PURE__ */ React15.createElement("p", null, options?.find(({ value: optionValue }) => optionValue === value3)?.label ?? String(value3)) : /* @__PURE__ */ React15.createElement(Select.Root, {
1796
2412
  value: value3,
1797
2413
  onValueChange: handleValueChange
1798
- }, /* @__PURE__ */ React12.createElement(Select.TriggerButton, {
2414
+ }, /* @__PURE__ */ React15.createElement(Select.TriggerButton, {
1799
2415
  classNames: "w-full",
1800
2416
  disabled: !!readonly,
1801
2417
  placeholder
1802
- }), /* @__PURE__ */ React12.createElement(Select.Portal, null, /* @__PURE__ */ React12.createElement(Select.Content, null, /* @__PURE__ */ React12.createElement(Select.Viewport, null, options?.map(({ value: value4, label: label2 }) => (
2418
+ }), /* @__PURE__ */ React15.createElement(Select.Portal, null, /* @__PURE__ */ React15.createElement(Select.Content, null, /* @__PURE__ */ React15.createElement(Select.Viewport, null, options?.map(({ value: value4, label: label2, secondaryLabel, icon, iconHue }) => (
1803
2419
  // NOTE: Numeric values are converted to and from strings.
1804
- /* @__PURE__ */ React12.createElement(Select.Option, {
2420
+ /* @__PURE__ */ React15.createElement(Select.Option, {
1805
2421
  key: String(value4),
1806
2422
  value: String(value4)
1807
- }, label2 ?? String(value4))
1808
- ))), /* @__PURE__ */ React12.createElement(Select.Arrow, null)))), layout === "full" && /* @__PURE__ */ React12.createElement(Input7.DescriptionAndValidation, null, error));
2423
+ }, /* @__PURE__ */ React15.createElement("span", {
2424
+ className: "flex items-center flex-row gap-2"
2425
+ }, icon && /* @__PURE__ */ React15.createElement(Icon5, {
2426
+ icon,
2427
+ classNames: getIconHueStyles(iconHue)
2428
+ }), label2 ?? String(value4), secondaryLabel && /* @__PURE__ */ React15.createElement("span", {
2429
+ className: "text-subdued text-xs"
2430
+ }, secondaryLabel)))
2431
+ ))), /* @__PURE__ */ React15.createElement(Select.Arrow, null)))), layout === "full" && /* @__PURE__ */ React15.createElement(Input11.DescriptionAndValidation, null, error));
2432
+ };
2433
+ var getIconHueStyles = (iconHue) => {
2434
+ const styles = iconHue ? getStyles(iconHue) : void 0;
2435
+ return styles?.fg;
1809
2436
  };
1810
2437
 
1811
2438
  // src/components/Form/fields/SelectOptionField.tsx
1812
- import React13, { useCallback as useCallback11, useEffect as useEffect4, useRef as useRef2, useState as useState5 } from "react";
2439
+ import React16, { useCallback as useCallback13, useEffect as useEffect4, useRef as useRef2, useState as useState5 } from "react";
1813
2440
  import { PublicKey } from "@dxos/keys";
1814
- import { IconButton as IconButton3, Input as Input8, Tag, useTranslation as useTranslation8 } from "@dxos/react-ui";
2441
+ import { IconButton as IconButton3, Input as Input12, Tag, useTranslation as useTranslation9 } from "@dxos/react-ui";
1815
2442
  import { List } from "@dxos/react-ui-list";
1816
2443
  import { HuePicker } from "@dxos/react-ui-pickers";
1817
2444
  import { hues, osTranslations } from "@dxos/ui-theme";
1818
- import { translationKey as translationKey8 } from "#translations";
1819
- var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueChange }) => {
1820
- const { t } = useTranslation8(translationKey8);
2445
+ import { translationKey as translationKey9 } from "#translations";
2446
+ var SelectOptionField = ({ type, readonly, label, jsonPath, getStatus, getValue, onValueChange }) => {
2447
+ const { t } = useTranslation9(translationKey9);
1821
2448
  const { status, error } = getStatus();
1822
2449
  const [selected, setSelectedId] = useState5(null);
1823
2450
  const [isNewOption, setIsNewOption] = useState5(false);
@@ -1842,7 +2469,7 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
1842
2469
  const availableHues = hues.filter((hue) => !lastThree.has(hue));
1843
2470
  return availableHues[Math.floor(Math.random() * availableHues.length)] ?? hues[Math.floor(Math.random() * hues.length)];
1844
2471
  };
1845
- const handleAdd = useCallback11(() => {
2472
+ const handleAdd = useCallback13(() => {
1846
2473
  const newId = PublicKey.random().truncate();
1847
2474
  const newOption = {
1848
2475
  id: newId,
@@ -1860,7 +2487,7 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
1860
2487
  type,
1861
2488
  onValueChange
1862
2489
  ]);
1863
- const handleDelete = useCallback11((id) => {
2490
+ const handleDelete = useCallback13((id) => {
1864
2491
  const newOptions = options?.filter((option) => option.id !== id) ?? [];
1865
2492
  onValueChange(type, newOptions);
1866
2493
  setSelectedId(null);
@@ -1869,7 +2496,7 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
1869
2496
  type,
1870
2497
  onValueChange
1871
2498
  ]);
1872
- const handleMove = useCallback11((from, to) => {
2499
+ const handleMove = useCallback13((from, to) => {
1873
2500
  if (!options) {
1874
2501
  return;
1875
2502
  }
@@ -1884,10 +2511,10 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
1884
2511
  type,
1885
2512
  onValueChange
1886
2513
  ]);
1887
- const handleClick = useCallback11((id) => {
2514
+ const handleClick = useCallback13((id) => {
1888
2515
  setSelectedId((current) => current === id ? null : id);
1889
2516
  }, []);
1890
- const handleTitleChange = useCallback11((id) => (e) => {
2517
+ const handleTitleChange = useCallback13((id) => (e) => {
1891
2518
  const newOptions = options?.map((o) => o.id === id ? {
1892
2519
  ...o,
1893
2520
  title: e.target.value
@@ -1898,12 +2525,12 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
1898
2525
  type,
1899
2526
  onValueChange
1900
2527
  ]);
1901
- const handleKeyDown = useCallback11((ev) => {
2528
+ const handleKeyDown = useCallback13((ev) => {
1902
2529
  if (ev.key === "Enter") {
1903
2530
  setSelectedId(null);
1904
2531
  }
1905
2532
  }, []);
1906
- const handleColorChange = useCallback11((id) => (hue) => {
2533
+ const handleColorChange = useCallback13((id) => (hue) => {
1907
2534
  const newOptions = options?.map((o) => o.id === id ? {
1908
2535
  ...o,
1909
2536
  color: hue
@@ -1923,37 +2550,38 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
1923
2550
  selected,
1924
2551
  isNewOption
1925
2552
  ]);
1926
- return /* @__PURE__ */ React13.createElement(Input8.Root, {
2553
+ return /* @__PURE__ */ React16.createElement(Input12.Root, {
1927
2554
  validationValence: status
1928
- }, /* @__PURE__ */ React13.createElement(FormFieldLabel, {
2555
+ }, /* @__PURE__ */ React16.createElement(FormFieldLabel, {
1929
2556
  error,
1930
2557
  readonly,
1931
- label
1932
- }), /* @__PURE__ */ React13.createElement("div", null, options && /* @__PURE__ */ React13.createElement(List.Root, {
2558
+ label,
2559
+ path: jsonPath
2560
+ }), /* @__PURE__ */ React16.createElement("div", null, options && /* @__PURE__ */ React16.createElement(List.Root, {
1933
2561
  items: options,
1934
2562
  isItem: (_item) => true,
1935
2563
  onMove: readonly ? void 0 : handleMove,
1936
2564
  readonly: !!readonly
1937
- }, ({ items }) => /* @__PURE__ */ React13.createElement("div", {
2565
+ }, ({ items }) => /* @__PURE__ */ React16.createElement("div", {
1938
2566
  role: "list",
1939
2567
  className: "w-full overflow-auto"
1940
- }, items?.map((item) => /* @__PURE__ */ React13.createElement("div", {
2568
+ }, items?.map((item) => /* @__PURE__ */ React16.createElement("div", {
1941
2569
  key: item.id
1942
- }, /* @__PURE__ */ React13.createElement(List.Item, {
2570
+ }, /* @__PURE__ */ React16.createElement(List.Item, {
1943
2571
  role: "button",
1944
2572
  item,
1945
2573
  classNames: "flex flex-col cursor-pointer rounded-xs dx-hover",
1946
2574
  "aria-expanded": selected === item.id
1947
- }, /* @__PURE__ */ React13.createElement("div", {
2575
+ }, /* @__PURE__ */ React16.createElement("div", {
1948
2576
  className: "flex items-center"
1949
- }, /* @__PURE__ */ React13.createElement(List.ItemDragHandle, {
2577
+ }, /* @__PURE__ */ React16.createElement(List.ItemDragHandle, {
1950
2578
  disabled: !!readonly
1951
- }), /* @__PURE__ */ React13.createElement(List.ItemTitle, {
2579
+ }), /* @__PURE__ */ React16.createElement(List.ItemTitle, {
1952
2580
  onClick: () => handleClick(item.id),
1953
2581
  classNames: "flex-1"
1954
- }, /* @__PURE__ */ React13.createElement(Tag, {
2582
+ }, /* @__PURE__ */ React16.createElement(Tag, {
1955
2583
  palette: item.color
1956
- }, item.title || "\u200B")), /* @__PURE__ */ React13.createElement(IconButton3, {
2584
+ }, item.title || "\u200B")), /* @__PURE__ */ React16.createElement(IconButton3, {
1957
2585
  iconOnly: true,
1958
2586
  variant: "ghost",
1959
2587
  label: t(selected === item.id ? "collapse.label" : "expand.label", {
@@ -1961,13 +2589,13 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
1961
2589
  }),
1962
2590
  icon: selected === item.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
1963
2591
  onClick: () => handleClick(item.id)
1964
- })), selected === item.id && /* @__PURE__ */ React13.createElement("div", {
1965
- className: "flex flex-col p-form-padding gap-form-gap dx-density-fine"
1966
- }, /* @__PURE__ */ React13.createElement(Input8.Label, {
1967
- classNames: "text-xs"
1968
- }, t("select-option.label")), /* @__PURE__ */ React13.createElement("div", {
2592
+ })), selected === item.id && /* @__PURE__ */ React16.createElement("div", {
2593
+ className: "flex flex-col p-form-padding gap-form-gap dx-density-md"
2594
+ }, /* @__PURE__ */ React16.createElement(Input12.Label, {
2595
+ classNames: "text-sm"
2596
+ }, t("select-option.label")), /* @__PURE__ */ React16.createElement("div", {
1969
2597
  className: "grid grid-cols-[1fr_min-content_min-content] gap-form-gap"
1970
- }, /* @__PURE__ */ React13.createElement(Input8.TextInput, {
2598
+ }, /* @__PURE__ */ React16.createElement(Input12.TextInput, {
1971
2599
  disabled: !!readonly,
1972
2600
  placeholder: t("select-option-label.placeholder"),
1973
2601
  ref: selected === item.id ? inputRef : void 0,
@@ -1975,17 +2603,17 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
1975
2603
  onChange: handleTitleChange(item.id),
1976
2604
  onKeyDown: handleKeyDown,
1977
2605
  classNames: "flex-1"
1978
- }), /* @__PURE__ */ React13.createElement(HuePicker, {
2606
+ }), /* @__PURE__ */ React16.createElement(HuePicker, {
1979
2607
  disabled: !!readonly,
1980
2608
  value: item.color,
1981
2609
  onChange: handleColorChange(item.id)
1982
- }), /* @__PURE__ */ React13.createElement(IconButton3, {
2610
+ }), /* @__PURE__ */ React16.createElement(IconButton3, {
1983
2611
  disabled: !!readonly,
1984
2612
  icon: "ph--trash--fill",
1985
2613
  iconOnly: true,
1986
2614
  label: t("select-option-delete.button"),
1987
2615
  onClick: () => handleDelete(item.id)
1988
- })))))), /* @__PURE__ */ React13.createElement(IconButton3, {
2616
+ })))))), /* @__PURE__ */ React16.createElement(IconButton3, {
1989
2617
  variant: "ghost",
1990
2618
  icon: "ph--plus--regular",
1991
2619
  label: t("select-option-add.button"),
@@ -1996,17 +2624,17 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
1996
2624
  };
1997
2625
 
1998
2626
  // src/components/Form/fields/TextField.tsx
1999
- import React14, { useCallback as useCallback12 } from "react";
2000
- import { Input as Input9 } from "@dxos/react-ui";
2627
+ import React17, { useCallback as useCallback14 } from "react";
2628
+ import { Input as Input13 } from "@dxos/react-ui";
2001
2629
  var TextField = ({ type, readonly, placeholder, onBlur, onValueChange, ...props }) => {
2002
- const handleChange = useCallback12((event) => onValueChange(type, event.target.value), [
2630
+ const handleChange = useCallback14((event) => onValueChange(type, event.target.value), [
2003
2631
  type,
2004
2632
  onValueChange
2005
2633
  ]);
2006
- return /* @__PURE__ */ React14.createElement(FormFieldWrapper, {
2634
+ return /* @__PURE__ */ React17.createElement(FormFieldWrapper, {
2007
2635
  readonly,
2008
2636
  ...props
2009
- }, ({ value: value3 = "" }) => /* @__PURE__ */ React14.createElement(Input9.TextInput, {
2637
+ }, ({ value: value3 = "" }) => /* @__PURE__ */ React17.createElement(Input13.TextInput, {
2010
2638
  noAutoFill: true,
2011
2639
  disabled: !!readonly,
2012
2640
  placeholder,
@@ -2017,18 +2645,18 @@ var TextField = ({ type, readonly, placeholder, onBlur, onValueChange, ...props
2017
2645
  };
2018
2646
 
2019
2647
  // src/components/Form/fields/TextAreaField.tsx
2020
- import React15, { useCallback as useCallback13 } from "react";
2021
- import { Input as Input10 } from "@dxos/react-ui";
2648
+ import React18, { useCallback as useCallback15 } from "react";
2649
+ import { Input as Input14 } from "@dxos/react-ui";
2022
2650
  var TextAreaField = ({ type, readonly, placeholder, onValueChange, onBlur, ...props }) => {
2023
- const handleChange = useCallback13((event) => onValueChange(type, event.target.value), [
2651
+ const handleChange = useCallback15((event) => onValueChange(type, event.target.value), [
2024
2652
  type,
2025
2653
  onValueChange
2026
2654
  ]);
2027
- return /* @__PURE__ */ React15.createElement(FormFieldWrapper, {
2655
+ return /* @__PURE__ */ React18.createElement(FormFieldWrapper, {
2028
2656
  readonly,
2029
2657
  ...props
2030
- }, ({ value: value3 = "" }) => /* @__PURE__ */ React15.createElement(Input10.TextArea, {
2031
- rows: 3,
2658
+ }, ({ value: value3 = "" }) => /* @__PURE__ */ React18.createElement(Input14.TextArea, {
2659
+ rows: 5,
2032
2660
  disabled: !!readonly,
2033
2661
  placeholder,
2034
2662
  value: value3,
@@ -2038,9 +2666,9 @@ var TextAreaField = ({ type, readonly, placeholder, onValueChange, onBlur, ...pr
2038
2666
  };
2039
2667
 
2040
2668
  // src/components/Form/fields/TupleField.tsx
2041
- import React16 from "react";
2042
- import { Input as Input11 } from "@dxos/react-ui";
2043
- import { mx as mx2 } from "@dxos/ui-theme";
2669
+ import React19 from "react";
2670
+ import { Input as Input15 } from "@dxos/react-ui";
2671
+ import { mx as mx4 } from "@dxos/ui-theme";
2044
2672
  import { safeParseFloat as safeParseFloat3 } from "@dxos/util";
2045
2673
  var gridCols = [
2046
2674
  "grid-cols-1",
@@ -2048,18 +2676,19 @@ var gridCols = [
2048
2676
  "grid-cols-3",
2049
2677
  "grid-cols-4"
2050
2678
  ];
2051
- var TupleField = ({ binding, type, readonly, label, getStatus, getValue, onValueChange, onBlur }) => {
2679
+ var TupleField = ({ binding, type, readonly, label, jsonPath, getStatus, getValue, onValueChange, onBlur }) => {
2052
2680
  const { status, error } = getStatus();
2053
2681
  const values = getValue() ?? {};
2054
- return /* @__PURE__ */ React16.createElement(Input11.Root, {
2682
+ return /* @__PURE__ */ React19.createElement(Input15.Root, {
2055
2683
  validationValence: status
2056
- }, /* @__PURE__ */ React16.createElement(FormFieldLabel, {
2684
+ }, /* @__PURE__ */ React19.createElement(FormFieldLabel, {
2057
2685
  error,
2058
2686
  readonly,
2059
- label
2060
- }), /* @__PURE__ */ React16.createElement("div", {
2061
- className: mx2("grid gap-form-gap", gridCols[binding.length - 1])
2062
- }, binding.map((prop) => /* @__PURE__ */ React16.createElement(Input11.TextInput, {
2687
+ label,
2688
+ path: jsonPath
2689
+ }), /* @__PURE__ */ React19.createElement("div", {
2690
+ className: mx4("grid gap-form-gap", gridCols[binding.length - 1])
2691
+ }, binding.map((prop) => /* @__PURE__ */ React19.createElement(Input15.TextInput, {
2063
2692
  key: prop,
2064
2693
  type: "number",
2065
2694
  disabled: !!readonly,
@@ -2074,10 +2703,20 @@ var TupleField = ({ binding, type, readonly, label, getStatus, getValue, onValue
2074
2703
  }))));
2075
2704
  };
2076
2705
 
2706
+ // src/components/Form/meta-tags.ts
2707
+ import * as Schema4 from "effect/Schema";
2708
+ import { Ref as Ref6, Tag as Tag2 } from "@dxos/echo";
2709
+ var META_TAGS_KEY = "_tags";
2710
+ var withMetaTags = (schema) => omitId(Schema4.Struct({
2711
+ [META_TAGS_KEY]: Schema4.Array(Ref6.Ref(Tag2.Tag)).pipe(Schema4.annotations({
2712
+ title: "Tags"
2713
+ }), Schema4.optional)
2714
+ }).pipe(Schema4.extend(schema)));
2715
+
2077
2716
  // src/components/FieldEditor/FieldEditor.tsx
2078
2717
  var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx";
2079
2718
  var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCancel }) => {
2080
- const { t } = useTranslation9(translationKey9);
2719
+ const { t } = useTranslation10(translationKey10);
2081
2720
  const [props, setProps] = useState6(projection.getFieldProjection(field.id).props);
2082
2721
  useEffect5(() => setProps(projection.getFieldProjection(field.id).props), [
2083
2722
  field,
@@ -2088,10 +2727,10 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
2088
2727
  if (!registry) {
2089
2728
  return;
2090
2729
  }
2091
- const subscription = registry.query().subscribe((query) => setSchemas(query.results), {
2730
+ const subscription = registry.query(Filter2.type(Type4.Type)).subscribe((query) => setSchemas(query.results), {
2092
2731
  fire: true
2093
2732
  });
2094
- const schemas2 = await registry.query().run();
2733
+ const schemas2 = await registry.query(Filter2.type(Type4.Type)).run();
2095
2734
  setSchemas(schemas2);
2096
2735
  return () => subscription?.();
2097
2736
  }, [
@@ -2099,7 +2738,7 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
2099
2738
  ]);
2100
2739
  const [referenceSchema, setReferenceSchema] = useState6();
2101
2740
  useEffect5(() => {
2102
- setReferenceSchema(schemas.find((schema) => schema.typename === props?.referenceSchema));
2741
+ setReferenceSchema(schemas.find((schema) => Type4.getTypename(schema) === props?.referenceSchema));
2103
2742
  }, [
2104
2743
  schemas,
2105
2744
  props?.referenceSchema
@@ -2107,34 +2746,34 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
2107
2746
  const [{ fieldSchema }, setFieldSchema] = useState6({
2108
2747
  fieldSchema: getFormatSchema(props?.format)
2109
2748
  });
2110
- const fieldMap = useMemo8(() => ({
2111
- ["format"]: (props2) => /* @__PURE__ */ React17.createElement(SelectField, {
2749
+ const fieldMap = useMemo10(() => ({
2750
+ ["format"]: (props2) => /* @__PURE__ */ React20.createElement(SelectField, {
2112
2751
  ...props2,
2113
- options: FormatEnums.filter((value3) => value3 !== Format4.TypeFormat.None).map((value3) => ({
2752
+ options: FormatEnums.filter((value3) => value3 !== Format6.TypeFormat.None).map((value3) => ({
2114
2753
  value: value3,
2115
2754
  label: t(`format.${value3}.label`)
2116
2755
  }))
2117
2756
  }),
2118
- ["referenceSchema"]: (props2) => /* @__PURE__ */ React17.createElement(SelectField, {
2757
+ ["referenceSchema"]: (props2) => /* @__PURE__ */ React20.createElement(SelectField, {
2119
2758
  ...props2,
2120
- options: schemas.map((schema) => ({
2121
- value: schema.typename
2759
+ options: schemas.map((schema) => Type4.getTypename(schema)).filter((typename) => typename != null).map((typename) => ({
2760
+ value: typename
2122
2761
  }))
2123
2762
  }),
2124
- ["referencePath"]: (props2) => /* @__PURE__ */ React17.createElement(SelectField, {
2763
+ ["referencePath"]: (props2) => /* @__PURE__ */ React20.createElement(SelectField, {
2125
2764
  ...props2,
2126
- options: referenceSchema ? getFormProperties(referenceSchema.ast).sort((a, b) => a.name.toString().localeCompare(b.name.toString())).map((p) => ({
2765
+ options: referenceSchema ? getFormProperties(Type4.getSchema(referenceSchema).ast).sort((a, b) => a.name.toString().localeCompare(b.name.toString())).map((p) => ({
2127
2766
  value: p.name.toString()
2128
2767
  })) : []
2129
2768
  }),
2130
- ["options"]: (props2) => /* @__PURE__ */ React17.createElement(SelectOptionField, props2)
2769
+ ["options"]: (props2) => /* @__PURE__ */ React20.createElement(SelectOptionField, props2)
2131
2770
  }), [
2132
2771
  t,
2133
2772
  schemas,
2134
2773
  referenceSchema
2135
2774
  ]);
2136
- const propIsNotType = useCallback14((props2) => props2.filter((prop) => prop.name !== "type"), []);
2137
- const handleValuesChanged = useCallback14((_props) => {
2775
+ const propIsNotType = useCallback16((props2) => props2.filter((prop) => prop.name !== "type"), []);
2776
+ const handleValuesChanged = useCallback16((_props) => {
2138
2777
  setFieldSchema((prev) => {
2139
2778
  const fieldSchema2 = getFormatSchema(_props.format);
2140
2779
  if (prev.fieldSchema === fieldSchema2) {
@@ -2145,8 +2784,8 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
2145
2784
  };
2146
2785
  });
2147
2786
  setReferenceSchema((prev) => {
2148
- if (_props.referenceSchema !== prev?.typename) {
2149
- const newSchema = schemas.find((schema) => schema.typename === _props.referenceSchema);
2787
+ if (_props.referenceSchema !== (prev ? Type4.getTypename(prev) : void 0)) {
2788
+ const newSchema = schemas.find((schema) => Type4.getTypename(schema) === _props.referenceSchema);
2150
2789
  if (newSchema) {
2151
2790
  return newSchema;
2152
2791
  }
@@ -2171,7 +2810,7 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
2171
2810
  props.format,
2172
2811
  props.referenceSchema
2173
2812
  ]);
2174
- const handleValidate = useCallback14(({ property }) => {
2813
+ const handleValidate = useCallback16(({ property }) => {
2175
2814
  if (property && projection.getFields().find((f) => f.path === property && f.path !== field.path)) {
2176
2815
  return [
2177
2816
  {
@@ -2184,9 +2823,9 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
2184
2823
  projection.getFields(),
2185
2824
  field
2186
2825
  ]);
2187
- const handleSave = useCallback14((props2) => {
2826
+ const handleSave = useCallback16((props2) => {
2188
2827
  if (view) {
2189
- Obj3.update(view, () => {
2828
+ Obj4.update(view, () => {
2190
2829
  projection.setFieldProjection({
2191
2830
  field,
2192
2831
  props: props2
@@ -2205,7 +2844,7 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
2205
2844
  view,
2206
2845
  onSave
2207
2846
  ]);
2208
- const handleCancel = useCallback14(() => {
2847
+ const handleCancel = useCallback16(() => {
2209
2848
  onSave();
2210
2849
  requestAnimationFrame(() => onCancel?.());
2211
2850
  }, [
@@ -2217,7 +2856,7 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
2217
2856
  }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 156, S: void 0 });
2218
2857
  return null;
2219
2858
  }
2220
- return /* @__PURE__ */ React17.createElement(Form.Root, {
2859
+ return /* @__PURE__ */ React20.createElement(Form.Root, {
2221
2860
  key: field.id,
2222
2861
  fieldMap,
2223
2862
  autoFocus: true,
@@ -2233,100 +2872,100 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
2233
2872
  onValidate: handleValidate,
2234
2873
  onSave: handleSave,
2235
2874
  onCancel: handleCancel
2236
- }, /* @__PURE__ */ React17.createElement(Form.Content, null, /* @__PURE__ */ React17.createElement(Form.FieldSet, null), /* @__PURE__ */ React17.createElement(Form.Actions, null)));
2875
+ }, /* @__PURE__ */ React20.createElement(Form.Content, null, /* @__PURE__ */ React20.createElement(Form.FieldSet, null), /* @__PURE__ */ React20.createElement(Form.Actions, null)));
2237
2876
  };
2238
2877
 
2239
2878
  // src/components/ObjectForm/ObjectForm.tsx
2240
- import * as Schema3 from "effect/Schema";
2241
- import React18, { useCallback as useCallback15, useMemo as useMemo9 } from "react";
2242
- import { DXN as DXN2, Obj as Obj4, Ref as Ref4, Tag as Tag2, Type as Type2 } from "@dxos/echo";
2243
- import { splitJsonPath } from "@dxos/echo/internal";
2879
+ import React21, { useCallback as useCallback17, useMemo as useMemo11 } from "react";
2880
+ import { Obj as Obj5, Ref as Ref7, Tag as Tag3, Type as Type5 } from "@dxos/echo";
2881
+ import { splitJsonPath as splitJsonPath2 } from "@dxos/echo/internal";
2244
2882
  import { invariant } from "@dxos/invariant";
2245
2883
  import { HuePicker as HuePicker2 } from "@dxos/react-ui-pickers";
2246
- import { isNonNullable } from "@dxos/util";
2247
- import { translationKey as translationKey10 } from "#translations";
2884
+ import { translationKey as translationKey11 } from "#translations";
2248
2885
  var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/ObjectForm/ObjectForm.tsx";
2249
2886
  var createFieldMap = {
2250
2887
  hue: ({ type, label, layout, getValue, onValueChange }) => {
2251
- const handleChange = useCallback15((nextHue) => onValueChange(type, nextHue), [
2888
+ const handleChange = useCallback17((nextHue) => onValueChange(type, nextHue), [
2252
2889
  onValueChange,
2253
2890
  type
2254
2891
  ]);
2255
- const handleReset = useCallback15(() => onValueChange(type, void 0), [
2892
+ const handleReset = useCallback17(() => onValueChange(type, void 0), [
2256
2893
  onValueChange,
2257
2894
  type
2258
2895
  ]);
2259
- return /* @__PURE__ */ React18.createElement(React18.Fragment, null, layout !== "inline" && /* @__PURE__ */ React18.createElement(Form.Label, {
2896
+ return /* @__PURE__ */ React21.createElement(React21.Fragment, null, layout !== "inline" && /* @__PURE__ */ React21.createElement(Form.Label, {
2260
2897
  label
2261
- }), /* @__PURE__ */ React18.createElement(HuePicker2, {
2898
+ }), /* @__PURE__ */ React21.createElement(HuePicker2, {
2262
2899
  value: getValue(),
2263
2900
  onChange: handleChange,
2264
2901
  onReset: handleReset
2265
2902
  }));
2266
2903
  }
2267
2904
  };
2268
- var ObjectForm = ({ object, schema }) => {
2269
- const db = Obj4.getDatabase(object);
2270
- const meta = Obj4.getMeta(object);
2271
- const tags = (meta.tags ?? []).map((tag) => db?.makeRef(DXN2.parse(tag))).filter(isNonNullable);
2272
- const values = useMemo9(() => ({
2273
- tags,
2905
+ var ObjectForm = ({ object, type }) => {
2906
+ const db = Obj5.getDatabase(object);
2907
+ const meta = Obj5.getMeta(object);
2908
+ const tags = [
2909
+ ...meta.tags
2910
+ ];
2911
+ const values = useMemo11(() => ({
2912
+ [META_TAGS_KEY]: tags,
2274
2913
  ...object
2275
2914
  }), [
2276
2915
  object,
2277
2916
  tags
2278
2917
  ]);
2279
- const formSchema = useMemo9(() => omitId(Schema3.Struct({
2280
- tags: Schema3.Array(Ref4.Ref(Tag2.Tag)).pipe(Schema3.optional)
2281
- }).pipe(Schema3.extend(schema))), [
2282
- schema
2918
+ const formSchema = useMemo11(() => withMetaTags(Type5.getSchema(type)), [
2919
+ type
2283
2920
  ]);
2284
- const handleCreate = useCallback15((schema2, values2) => {
2285
- invariant(db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 49, S: void 0, A: ["db", ""] });
2286
- invariant(Type2.isObjectSchema(schema2), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 50, S: void 0, A: ["Type.isObjectSchema(schema)", ""] });
2287
- const newObject = db.add(Obj4.make(schema2, values2));
2288
- if (Obj4.instanceOf(Tag2.Tag, newObject)) {
2289
- Obj4.update(object, (object2) => {
2290
- Obj4.getMeta(object2).tags = [
2291
- ...Obj4.getMeta(object2).tags ?? [],
2292
- Obj4.getDXN(newObject).toString()
2921
+ const handleCreate = useCallback17((type2, values2) => {
2922
+ invariant(db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 48, S: void 0, A: ["db", ""] });
2923
+ invariant(Type5.isObject(type2), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 49, S: void 0, A: ["Type.isObject(type)", ""] });
2924
+ const newObject = db.add(Obj5.make(type2, values2));
2925
+ if (Obj5.instanceOf(Tag3.Tag, newObject)) {
2926
+ Obj5.update(object, (object2) => {
2927
+ Obj5.getMeta(object2).tags = [
2928
+ ...Obj5.getMeta(object2).tags,
2929
+ Ref7.make(newObject)
2293
2930
  ];
2294
2931
  });
2295
2932
  }
2296
2933
  }, []);
2297
- const handleChange = useCallback15(({ tags: tags2, ...values2 }, { isValid, changed }) => {
2934
+ const handleChange = useCallback17(({ [META_TAGS_KEY]: metaTags, ...values2 }, { isValid, changed }) => {
2298
2935
  if (!isValid) {
2299
2936
  return;
2300
2937
  }
2301
2938
  const changedPaths = Object.keys(changed).filter((path) => changed[path]);
2302
- const hasTagsChange = changedPaths.some((path) => splitJsonPath(path)[0] === "tags");
2939
+ const hasTagsChange = changedPaths.some((path) => splitJsonPath2(path)[0] === META_TAGS_KEY);
2303
2940
  if (hasTagsChange) {
2304
- Obj4.update(object, (object2) => {
2305
- Obj4.getMeta(object2).tags = tags2?.map((tag) => tag.dxn.toString()) ?? [];
2941
+ Obj5.update(object, (object2) => {
2942
+ Obj5.getMeta(object2).tags = Array.isArray(metaTags) ? [
2943
+ ...metaTags
2944
+ ] : [];
2306
2945
  });
2307
2946
  }
2308
- const nonTagPaths = changedPaths.filter((path) => splitJsonPath(path)[0] !== "tags");
2947
+ const nonTagPaths = changedPaths.filter((path) => splitJsonPath2(path)[0] !== META_TAGS_KEY);
2309
2948
  if (nonTagPaths.length > 0) {
2310
- Obj4.update(object, () => {
2949
+ Obj5.update(object, () => {
2311
2950
  for (const path of nonTagPaths) {
2312
- const parts = splitJsonPath(path);
2313
- const value3 = Obj4.getValue(values2, parts);
2314
- Obj4.setValue(object, parts, value3);
2951
+ const parts = splitJsonPath2(path);
2952
+ const value3 = Obj5.getValue(values2, parts);
2953
+ Obj5.setValue(object, parts, value3);
2315
2954
  }
2316
2955
  });
2317
2956
  }
2318
2957
  }, [
2319
2958
  object
2320
2959
  ]);
2321
- return /* @__PURE__ */ React18.createElement(Form.Root, {
2960
+ return /* @__PURE__ */ React21.createElement(Form.Root, {
2322
2961
  schema: formSchema,
2323
2962
  defaultValues: values,
2324
- createTypename: Type2.getTypename(Tag2.Tag),
2963
+ createTypename: Type5.getTypename(Tag3.Tag),
2325
2964
  createOptionIcon: "ph--plus--regular",
2326
2965
  createOptionLabel: [
2327
2966
  "add-tag.label",
2328
2967
  {
2329
- ns: translationKey10
2968
+ ns: translationKey11
2330
2969
  }
2331
2970
  ],
2332
2971
  createInitialValuePath: "label",
@@ -2334,70 +2973,72 @@ var ObjectForm = ({ object, schema }) => {
2334
2973
  db,
2335
2974
  onValuesChanged: handleChange,
2336
2975
  onCreate: handleCreate
2337
- }, /* @__PURE__ */ React18.createElement(Form.Viewport, null, /* @__PURE__ */ React18.createElement(Form.Content, null, /* @__PURE__ */ React18.createElement(Form.FieldSet, null))));
2976
+ }, /* @__PURE__ */ React21.createElement(Form.Viewport, null, /* @__PURE__ */ React21.createElement(Form.Content, null, /* @__PURE__ */ React21.createElement(Form.FieldSet, null))));
2338
2977
  };
2339
2978
 
2340
2979
  // src/components/ObjectProperties/ObjectProperties.tsx
2341
2980
  import * as Function from "effect/Function";
2342
- import * as Option5 from "effect/Option";
2343
- import * as Schema4 from "effect/Schema";
2344
- import React19, { useCallback as useCallback16, useMemo as useMemo10 } from "react";
2345
- import { DXN as DXN3, Obj as Obj5, Ref as Ref5, Tag as Tag3, Type as Type3 } from "@dxos/echo";
2346
- import { useSchema } from "@dxos/echo-react";
2347
- import { splitJsonPath as splitJsonPath2 } from "@dxos/echo/internal";
2981
+ import * as Option7 from "effect/Option";
2982
+ import React22, { useCallback as useCallback18, useMemo as useMemo12 } from "react";
2983
+ import { Obj as Obj6, Tag as Tag4, Type as Type6 } from "@dxos/echo";
2984
+ import { useType } from "@dxos/echo-react";
2985
+ import { splitJsonPath as splitJsonPath3 } from "@dxos/echo/internal";
2348
2986
  import { invariant as invariant2 } from "@dxos/invariant";
2987
+ import { composable as composable2, composableProps as composableProps2 } from "@dxos/react-ui";
2349
2988
  import { HuePicker as HuePicker3 } from "@dxos/react-ui-pickers";
2350
2989
  import { FactoryAnnotation } from "@dxos/schema";
2351
- import { composable as composable2, composableProps as composableProps2 } from "@dxos/ui-theme";
2352
- import { isNonNullable as isNonNullable2 } from "@dxos/util";
2353
- import { translationKey as translationKey11 } from "#translations";
2990
+ import { translationKey as translationKey12 } from "#translations";
2354
2991
  var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/ObjectProperties/ObjectProperties.tsx";
2355
2992
  var ObjectProperties = composable2(({ children, object, ...props }, forwardedRef) => {
2356
- const db = Obj5.getDatabase(object);
2357
- const meta = Obj5.getMeta(object);
2358
- const tags = (meta.tags ?? []).map((tag) => db?.makeRef(DXN3.parse(tag))).filter(isNonNullable2);
2359
- const values = useMemo10(() => ({
2360
- tags,
2993
+ const db = Obj6.getDatabase(object);
2994
+ const meta = Obj6.getMeta(object);
2995
+ const tags = [
2996
+ ...meta.tags
2997
+ ];
2998
+ const values = useMemo12(() => ({
2999
+ [META_TAGS_KEY]: tags,
2361
3000
  ...object
2362
3001
  }), [
2363
3002
  object,
2364
3003
  tags
2365
3004
  ]);
2366
- const typename = Obj5.getTypename(object) ?? void 0;
2367
- const schemaFromRegistry = useSchema(db, typename);
2368
- const rawSchema = Obj5.getSchema(object) ?? schemaFromRegistry;
2369
- const formSchema = useMemo10(() => {
2370
- return Function.pipe(rawSchema, Option5.fromNullable, Option5.map((schema) => omitId(BaseSchema.pipe(Schema4.extend(schema)))), Option5.getOrUndefined);
3005
+ const typename = Obj6.getTypename(object) ?? void 0;
3006
+ const typeFromRegistry = useType(db, typename);
3007
+ const type = Obj6.getType(object) ?? typeFromRegistry;
3008
+ const formSchema = useMemo12(() => {
3009
+ return Function.pipe(type, Option7.fromNullable, Option7.map((type2) => Type6.getSchema(type2)), Option7.map((schema) => withMetaTags(schema)), Option7.getOrUndefined);
2371
3010
  }, [
2372
- rawSchema
3011
+ type
2373
3012
  ]);
2374
- const handleCreate = useCallback16((schema, values2) => {
2375
- invariant2(db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 51, S: void 0, A: ["db", ""] });
2376
- invariant2(Type3.isObjectSchema(schema), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 52, S: void 0, A: ["Type.isObjectSchema(schema)", ""] });
2377
- const factory = Option5.getOrUndefined(FactoryAnnotation.get(schema));
2378
- const newObject = factory ? factory(values2) : Obj5.make(schema, values2);
3013
+ const handleCreate = useCallback18((type2, values2) => {
3014
+ invariant2(db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 52, S: void 0, A: ["db", ""] });
3015
+ invariant2(Type6.isObject(type2), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 53, S: void 0, A: ["Type.isObject(type)", ""] });
3016
+ const factory = Option7.getOrUndefined(FactoryAnnotation.get(Type6.getSchema(type2)));
3017
+ const newObject = factory ? factory(values2) : Obj6.make(type2, values2);
2379
3018
  return db.add(newObject);
2380
3019
  }, [
2381
3020
  db
2382
3021
  ]);
2383
- const handleChange = useCallback16(({ tags: tags2, ...values2 }, { isValid, changed }) => {
3022
+ const handleChange = useCallback18(({ [META_TAGS_KEY]: metaTags, ...values2 }, { isValid, changed }) => {
2384
3023
  if (!isValid) {
2385
3024
  return;
2386
3025
  }
2387
3026
  const changedPaths = Object.keys(changed).filter((path) => changed[path]);
2388
- const hasTagsChange = changedPaths.some((path) => splitJsonPath2(path)[0] === "tags");
3027
+ const hasTagsChange = changedPaths.some((path) => splitJsonPath3(path)[0] === META_TAGS_KEY);
2389
3028
  if (hasTagsChange) {
2390
- Obj5.update(object, (object2) => {
2391
- Obj5.getMeta(object2).tags = tags2?.map((tag) => tag.dxn.toString()) ?? [];
3029
+ Obj6.update(object, (object2) => {
3030
+ Obj6.getMeta(object2).tags = Array.isArray(metaTags) ? [
3031
+ ...metaTags
3032
+ ] : [];
2392
3033
  });
2393
3034
  }
2394
- const nonTagPaths = changedPaths.filter((path) => splitJsonPath2(path)[0] !== "tags");
3035
+ const nonTagPaths = changedPaths.filter((path) => splitJsonPath3(path)[0] !== META_TAGS_KEY);
2395
3036
  if (nonTagPaths.length > 0) {
2396
- Obj5.update(object, () => {
3037
+ Obj6.update(object, () => {
2397
3038
  for (const path of nonTagPaths) {
2398
- const parts = splitJsonPath2(path);
2399
- const value3 = Obj5.getValue(values2, parts);
2400
- Obj5.setValue(object, parts, value3);
3039
+ const parts = splitJsonPath3(path);
3040
+ const value3 = Obj6.getValue(values2, parts);
3041
+ Obj6.setValue(object, parts, value3);
2401
3042
  }
2402
3043
  });
2403
3044
  }
@@ -2407,15 +3048,15 @@ var ObjectProperties = composable2(({ children, object, ...props }, forwardedRef
2407
3048
  if (!formSchema) {
2408
3049
  return null;
2409
3050
  }
2410
- return /* @__PURE__ */ React19.createElement(Form.Root, {
3051
+ return /* @__PURE__ */ React22.createElement(Form.Root, {
2411
3052
  schema: formSchema,
2412
3053
  defaultValues: values,
2413
- createTypename: Type3.getTypename(Tag3.Tag),
3054
+ createTypename: Type6.getTypename(Tag4.Tag),
2414
3055
  createOptionIcon: "ph--plus--regular",
2415
3056
  createOptionLabel: [
2416
3057
  "add-tag.label",
2417
3058
  {
2418
- ns: translationKey11
3059
+ ns: translationKey12
2419
3060
  }
2420
3061
  ],
2421
3062
  createInitialValuePath: "label",
@@ -2423,69 +3064,190 @@ var ObjectProperties = composable2(({ children, object, ...props }, forwardedRef
2423
3064
  db,
2424
3065
  onValuesChanged: handleChange,
2425
3066
  onCreate: handleCreate
2426
- }, /* @__PURE__ */ React19.createElement(Form.Viewport, {
3067
+ }, /* @__PURE__ */ React22.createElement(Form.Viewport, {
2427
3068
  ...composableProps2(props),
2428
3069
  ref: forwardedRef
2429
- }, /* @__PURE__ */ React19.createElement(Form.Content, null, /* @__PURE__ */ React19.createElement(Form.FieldSet, null), children)));
3070
+ }, /* @__PURE__ */ React22.createElement(Form.Content, null, /* @__PURE__ */ React22.createElement(Form.FieldSet, null), children)));
2430
3071
  });
2431
3072
  var createFieldMap2 = {
2432
3073
  hue: ({ type, label, layout, getValue, onValueChange }) => {
2433
- const handleChange = useCallback16((nextHue) => onValueChange(type, nextHue), [
3074
+ const handleChange = useCallback18((nextHue) => onValueChange(type, nextHue), [
2434
3075
  onValueChange,
2435
3076
  type
2436
3077
  ]);
2437
- const handleReset = useCallback16(() => onValueChange(type, void 0), [
3078
+ const handleReset = useCallback18(() => onValueChange(type, void 0), [
2438
3079
  onValueChange,
2439
3080
  type
2440
3081
  ]);
2441
- return /* @__PURE__ */ React19.createElement(React19.Fragment, null, layout !== "inline" && /* @__PURE__ */ React19.createElement(Form.Label, {
3082
+ return /* @__PURE__ */ React22.createElement(React22.Fragment, null, layout !== "inline" && /* @__PURE__ */ React22.createElement(Form.Label, {
2442
3083
  label
2443
- }), /* @__PURE__ */ React19.createElement(HuePicker3, {
3084
+ }), /* @__PURE__ */ React22.createElement(HuePicker3, {
2444
3085
  value: getValue(),
2445
3086
  onChange: handleChange,
2446
3087
  onReset: handleReset
2447
3088
  }));
2448
3089
  }
2449
3090
  };
2450
- var BaseSchema = Schema4.Struct({
2451
- tags: Schema4.Array(Ref5.Ref(Tag3.Tag)).pipe(Schema4.optional)
2452
- });
3091
+
3092
+ // src/components/ObjectTree/ObjectTree.tsx
3093
+ import * as SchemaAST7 from "effect/SchemaAST";
3094
+ import React23 from "react";
3095
+ import { composable as composable3, composableProps as composableProps3 } from "@dxos/react-ui";
3096
+ import { mx as mx5 } from "@dxos/ui-theme";
3097
+ var ObjectTreeImpl = composable3(({ schema, value: value3, ...props }, forwardedRef) => /* @__PURE__ */ React23.createElement("div", {
3098
+ ...composableProps3(props, {
3099
+ role: "table",
3100
+ classNames: "font-mono text-sm w-full"
3101
+ }),
3102
+ ref: forwardedRef
3103
+ }, /* @__PURE__ */ React23.createElement(Node, {
3104
+ ast: schema.ast,
3105
+ value: value3,
3106
+ label: null,
3107
+ depth: 0
3108
+ })));
3109
+ ObjectTreeImpl.displayName = "ObjectTree";
3110
+ var ObjectTree = ObjectTreeImpl;
3111
+ var unwrap = (ast) => {
3112
+ if (SchemaAST7.isRefinement(ast)) {
3113
+ return unwrap(ast.from);
3114
+ }
3115
+ if (SchemaAST7.isSuspend(ast)) {
3116
+ return unwrap(ast.f());
3117
+ }
3118
+ if (SchemaAST7.isTransformation(ast)) {
3119
+ return unwrap(ast.from);
3120
+ }
3121
+ return ast;
3122
+ };
3123
+ var stripOptional = (ast) => {
3124
+ if (!SchemaAST7.isUnion(ast)) {
3125
+ return ast;
3126
+ }
3127
+ const nonUndef = ast.types.filter((t) => !SchemaAST7.isUndefinedKeyword(t));
3128
+ return nonUndef.length === 1 ? nonUndef[0] : ast;
3129
+ };
3130
+ var Node = ({ ast, value: value3, label, depth }) => {
3131
+ const inner = unwrap(stripOptional(ast));
3132
+ if (SchemaAST7.isTypeLiteral(inner) && isPlainObject(value3)) {
3133
+ const childDepth = label === null ? depth : depth + 1;
3134
+ return /* @__PURE__ */ React23.createElement(React23.Fragment, null, label !== null && /* @__PURE__ */ React23.createElement(Row, {
3135
+ label,
3136
+ value: null,
3137
+ depth,
3138
+ kind: "group"
3139
+ }), inner.propertySignatures.map((prop) => /* @__PURE__ */ React23.createElement(Node, {
3140
+ key: String(prop.name),
3141
+ ast: prop.type,
3142
+ value: value3[String(prop.name)],
3143
+ label: String(prop.name),
3144
+ depth: childDepth
3145
+ })));
3146
+ }
3147
+ if (SchemaAST7.isTupleType(inner) && Array.isArray(value3)) {
3148
+ const elemType = inner.rest[0]?.type;
3149
+ return /* @__PURE__ */ React23.createElement(React23.Fragment, null, label !== null && /* @__PURE__ */ React23.createElement(Row, {
3150
+ label,
3151
+ value: `Array(${value3.length})`,
3152
+ depth,
3153
+ kind: "group"
3154
+ }), value3.map((item, index) => /* @__PURE__ */ React23.createElement(Node, {
3155
+ key: index,
3156
+ ast: elemType ?? SchemaAST7.unknownKeyword,
3157
+ value: item,
3158
+ label: `[${index}]`,
3159
+ depth: depth + 1
3160
+ })));
3161
+ }
3162
+ return /* @__PURE__ */ React23.createElement(Row, {
3163
+ label: label ?? "",
3164
+ value: formatLeaf(value3),
3165
+ depth,
3166
+ kind: "leaf"
3167
+ });
3168
+ };
3169
+ var Row = ({ label, value: value3, depth }) => /* @__PURE__ */ React23.createElement("div", {
3170
+ role: "row",
3171
+ className: mx5("flex items-baseline gap-3 py-1"),
3172
+ style: {
3173
+ paddingInlineStart: 8 + depth * 16
3174
+ }
3175
+ }, /* @__PURE__ */ React23.createElement("div", {
3176
+ role: "cell",
3177
+ className: "text-subdued"
3178
+ }, label), /* @__PURE__ */ React23.createElement("div", {
3179
+ role: "cell",
3180
+ className: mx5("break-all text-base-fg")
3181
+ }, value3));
3182
+ var isPlainObject = (value3) => typeof value3 === "object" && value3 !== null && !Array.isArray(value3);
3183
+ var formatLeaf = (value3) => {
3184
+ if (value3 === void 0) {
3185
+ return null;
3186
+ }
3187
+ if (value3 === null) {
3188
+ return /* @__PURE__ */ React23.createElement("span", {
3189
+ className: "text-description"
3190
+ }, "null");
3191
+ }
3192
+ switch (typeof value3) {
3193
+ case "string":
3194
+ return /* @__PURE__ */ React23.createElement("span", {
3195
+ className: "text-blue-text"
3196
+ }, JSON.stringify(value3));
3197
+ case "number":
3198
+ case "bigint":
3199
+ return /* @__PURE__ */ React23.createElement("span", {
3200
+ className: "text-green-text"
3201
+ }, String(value3));
3202
+ case "boolean":
3203
+ return /* @__PURE__ */ React23.createElement("span", {
3204
+ className: "text-purple-text"
3205
+ }, String(value3));
3206
+ default:
3207
+ try {
3208
+ return JSON.stringify(value3);
3209
+ } catch {
3210
+ return String(value3);
3211
+ }
3212
+ }
3213
+ };
2453
3214
 
2454
3215
  // src/components/Settings/Settings.tsx
2455
- import React22 from "react";
2456
- import { ScrollArea as ScrollArea2, toLocalizedString as toLocalizedString2, useTranslation as useTranslation11 } from "@dxos/react-ui";
2457
- import { composable as composable3, composableProps as composableProps3, mx as mx4 } from "@dxos/ui-theme";
2458
- import { translationKey as translationKey13 } from "#translations";
3216
+ import React26 from "react";
3217
+ import { ScrollArea as ScrollArea2, toLocalizedString as toLocalizedString2, useTranslation as useTranslation12 } from "@dxos/react-ui";
3218
+ import { composable as composable4, composableProps as composableProps4 } from "@dxos/react-ui";
3219
+ import { mx as mx7 } from "@dxos/ui-theme";
3220
+ import { translationKey as translationKey14 } from "#translations";
2459
3221
 
2460
3222
  // src/components/Settings/SettingsFieldSet.tsx
2461
- import * as SchemaAST6 from "effect/SchemaAST";
2462
- import * as String3 from "effect/String";
2463
- import React21, { useCallback as useCallback17, useMemo as useMemo11 } from "react";
2464
- import { getAnnotation as getAnnotation3 } from "@dxos/effect";
2465
- import { Input as Input13, Select as Select2 } from "@dxos/react-ui";
3223
+ import * as SchemaAST8 from "effect/SchemaAST";
3224
+ import * as String4 from "effect/String";
3225
+ import React25, { useCallback as useCallback19, useMemo as useMemo13 } from "react";
3226
+ import { getAnnotation as getAnnotation4 } from "@dxos/effect";
3227
+ import { Input as Input17, Select as Select2 } from "@dxos/react-ui";
2466
3228
 
2467
3229
  // src/components/Settings/SettingsItem.tsx
2468
- import React20 from "react";
2469
- import { Input as Input12, toLocalizedString, useTranslation as useTranslation10 } from "@dxos/react-ui";
2470
- import { mx as mx3 } from "@dxos/ui-theme";
2471
- import { translationKey as translationKey12 } from "#translations";
3230
+ import React24 from "react";
3231
+ import { Input as Input16, toLocalizedString, useTranslation as useTranslation11 } from "@dxos/react-ui";
3232
+ import { mx as mx6 } from "@dxos/ui-theme";
3233
+ import { translationKey as translationKey13 } from "#translations";
2472
3234
  var SETTINGS_PANEL_NAME = "Settings.Panel";
2473
3235
  var SETTINGS_ITEM_NAME = "Settings.Item";
2474
3236
  var SettingsPanel = ({ classNames, children }) => {
2475
- return /* @__PURE__ */ React20.createElement("div", {
2476
- className: mx3("flex flex-col gap-3 p-trim-md border border-separator rounded-sm", classNames)
3237
+ return /* @__PURE__ */ React24.createElement("div", {
3238
+ className: mx6("flex flex-col gap-3 p-trim-md border border-separator rounded-sm", classNames)
2477
3239
  }, children);
2478
3240
  };
2479
3241
  SettingsPanel.displayName = SETTINGS_PANEL_NAME;
2480
3242
  var SettingsItem = ({ title, description = "", children }) => {
2481
- const { t } = useTranslation10(translationKey12);
2482
- return /* @__PURE__ */ React20.createElement(Input12.Root, null, /* @__PURE__ */ React20.createElement(SettingsPanel, {
3243
+ const { t } = useTranslation11(translationKey13);
3244
+ return /* @__PURE__ */ React24.createElement(Input16.Root, null, /* @__PURE__ */ React24.createElement(SettingsPanel, {
2483
3245
  classNames: "grid grid-cols-1 md:grid-cols-[1fr_1fr] gap-x-trim-lg gap-y-0"
2484
- }, /* @__PURE__ */ React20.createElement(Input12.Label, {
2485
- classNames: "pb-trim-md text-base-foreground text-lg md:col-span-2"
2486
- }, toLocalizedString(title, t)), /* @__PURE__ */ React20.createElement(Input12.DescriptionAndValidation, null, /* @__PURE__ */ React20.createElement(Input12.Description, {
3246
+ }, /* @__PURE__ */ React24.createElement(Input16.Label, {
3247
+ classNames: "pb-trim-md text-base-fg text-lg md:col-span-2"
3248
+ }, toLocalizedString(title, t)), /* @__PURE__ */ React24.createElement(Input16.DescriptionAndValidation, null, /* @__PURE__ */ React24.createElement(Input16.Description, {
2487
3249
  classNames: "text-base text-description"
2488
- }, toLocalizedString(description, t))), /* @__PURE__ */ React20.createElement("div", {
3250
+ }, toLocalizedString(description, t))), /* @__PURE__ */ React24.createElement("div", {
2489
3251
  className: "text-end py-1"
2490
3252
  }, children)));
2491
3253
  };
@@ -2493,7 +3255,7 @@ SettingsItem.displayName = SETTINGS_ITEM_NAME;
2493
3255
 
2494
3256
  // src/components/Settings/SettingsFieldSet.tsx
2495
3257
  var SettingsFieldSet = ({ schema, values, onValuesChanged, readonly, fieldMap, visible, sort, pathPrefix = "" }) => {
2496
- const properties = useMemo11(() => {
3258
+ const properties = useMemo13(() => {
2497
3259
  const props = getFormProperties(schema.ast);
2498
3260
  if (!sort) {
2499
3261
  return props;
@@ -2509,7 +3271,7 @@ var SettingsFieldSet = ({ schema, values, onValuesChanged, readonly, fieldMap, v
2509
3271
  schema,
2510
3272
  sort
2511
3273
  ]);
2512
- const handleChange = useCallback17((name, value3) => {
3274
+ const handleChange = useCallback19((name, value3) => {
2513
3275
  onValuesChanged?.({
2514
3276
  ...values,
2515
3277
  [name]: value3
@@ -2518,14 +3280,14 @@ var SettingsFieldSet = ({ schema, values, onValuesChanged, readonly, fieldMap, v
2518
3280
  values,
2519
3281
  onValuesChanged
2520
3282
  ]);
2521
- return /* @__PURE__ */ React21.createElement(React21.Fragment, null, properties.map((property) => {
3283
+ return /* @__PURE__ */ React25.createElement(React25.Fragment, null, properties.map((property) => {
2522
3284
  const name = property.name.toString();
2523
3285
  const path = pathPrefix ? `${pathPrefix}.${name}` : name;
2524
3286
  if (visible && !visible(path, values)) {
2525
3287
  return null;
2526
3288
  }
2527
3289
  const entry = fieldMap?.[name];
2528
- return /* @__PURE__ */ React21.createElement(SettingsFieldItem, {
3290
+ return /* @__PURE__ */ React25.createElement(SettingsFieldItem, {
2529
3291
  key: name,
2530
3292
  path,
2531
3293
  property,
@@ -2543,14 +3305,14 @@ SettingsFieldSet.displayName = "Settings.FieldSet";
2543
3305
  var SettingsFieldItem = ({ property, path, value: value3, onChange, readonly, customField, nestedFieldMap, visible, sort }) => {
2544
3306
  const { type } = property;
2545
3307
  const name = property.name.toString();
2546
- const title = getAnnotation3(SchemaAST6.TitleAnnotationId)(type) ?? String3.capitalize(name);
2547
- const description = getAnnotation3(SchemaAST6.DescriptionAnnotationId)(type);
3308
+ const title = getAnnotation4(SchemaAST8.TitleAnnotationId)(type) ?? String4.capitalize(name);
3309
+ const description = getAnnotation4(SchemaAST8.DescriptionAnnotationId)(type);
2548
3310
  if (customField) {
2549
3311
  const CustomField = customField;
2550
- return /* @__PURE__ */ React21.createElement(SettingsItem, {
3312
+ return /* @__PURE__ */ React25.createElement(SettingsItem, {
2551
3313
  title,
2552
3314
  description
2553
- }, /* @__PURE__ */ React21.createElement(CustomField, {
3315
+ }, /* @__PURE__ */ React25.createElement(CustomField, {
2554
3316
  value: value3,
2555
3317
  onChange,
2556
3318
  readonly
@@ -2559,7 +3321,7 @@ var SettingsFieldItem = ({ property, path, value: value3, onChange, readonly, cu
2559
3321
  const fieldType = detectFieldType(type);
2560
3322
  switch (fieldType) {
2561
3323
  case "struct":
2562
- return /* @__PURE__ */ React21.createElement(SettingsFieldSet, {
3324
+ return /* @__PURE__ */ React25.createElement(SettingsFieldSet, {
2563
3325
  schema: {
2564
3326
  ast: type
2565
3327
  },
@@ -2572,47 +3334,47 @@ var SettingsFieldItem = ({ property, path, value: value3, onChange, readonly, cu
2572
3334
  pathPrefix: path
2573
3335
  });
2574
3336
  case "boolean":
2575
- return /* @__PURE__ */ React21.createElement(SettingsItem, {
3337
+ return /* @__PURE__ */ React25.createElement(SettingsItem, {
2576
3338
  title,
2577
3339
  description
2578
- }, /* @__PURE__ */ React21.createElement(Input13.Switch, {
3340
+ }, /* @__PURE__ */ React25.createElement(Input17.Switch, {
2579
3341
  disabled: readonly,
2580
3342
  checked: !!value3,
2581
3343
  onCheckedChange: (checked) => onChange(!!checked)
2582
3344
  }));
2583
3345
  case "select": {
2584
3346
  const options = getSelectOptionsFromAst(type) ?? [];
2585
- return /* @__PURE__ */ React21.createElement(SettingsItem, {
3347
+ return /* @__PURE__ */ React25.createElement(SettingsItem, {
2586
3348
  title,
2587
3349
  description
2588
- }, /* @__PURE__ */ React21.createElement(Select2.Root, {
3350
+ }, /* @__PURE__ */ React25.createElement(Select2.Root, {
2589
3351
  disabled: readonly,
2590
3352
  value: value3 == null ? "" : globalThis.String(value3),
2591
3353
  onValueChange: (selected) => {
2592
3354
  const matched = options.find((option) => globalThis.String(option.value) === selected);
2593
3355
  onChange(matched?.value ?? selected);
2594
3356
  }
2595
- }, /* @__PURE__ */ React21.createElement(Select2.TriggerButton, {
3357
+ }, /* @__PURE__ */ React25.createElement(Select2.TriggerButton, {
2596
3358
  disabled: readonly
2597
- }), /* @__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, {
3359
+ }), /* @__PURE__ */ React25.createElement(Select2.Portal, null, /* @__PURE__ */ React25.createElement(Select2.Content, null, /* @__PURE__ */ React25.createElement(Select2.Viewport, null, options.map((option) => /* @__PURE__ */ React25.createElement(Select2.Option, {
2598
3360
  key: globalThis.String(option.value),
2599
3361
  value: globalThis.String(option.value)
2600
- }, option.label ?? globalThis.String(option.value)))), /* @__PURE__ */ React21.createElement(Select2.Arrow, null)))));
3362
+ }, option.label ?? globalThis.String(option.value)))), /* @__PURE__ */ React25.createElement(Select2.Arrow, null)))));
2601
3363
  }
2602
3364
  case "string":
2603
- return /* @__PURE__ */ React21.createElement(SettingsItem, {
3365
+ return /* @__PURE__ */ React25.createElement(SettingsItem, {
2604
3366
  title,
2605
3367
  description
2606
- }, /* @__PURE__ */ React21.createElement(Input13.TextInput, {
3368
+ }, /* @__PURE__ */ React25.createElement(Input17.TextInput, {
2607
3369
  disabled: readonly,
2608
3370
  value: value3 ?? "",
2609
3371
  onChange: (event) => onChange(event.target.value)
2610
3372
  }));
2611
3373
  case "number":
2612
- return /* @__PURE__ */ React21.createElement(SettingsItem, {
3374
+ return /* @__PURE__ */ React25.createElement(SettingsItem, {
2613
3375
  title,
2614
3376
  description
2615
- }, /* @__PURE__ */ React21.createElement(Input13.TextInput, {
3377
+ }, /* @__PURE__ */ React25.createElement(Input17.TextInput, {
2616
3378
  disabled: readonly,
2617
3379
  type: "number",
2618
3380
  value: value3 ?? "",
@@ -2635,32 +3397,32 @@ var SETTINGS_ROOT_NAME = "Settings.Root";
2635
3397
  var SETTINGS_VIEWPORT_NAME = "Settings.Viewport";
2636
3398
  var SETTINGS_SECTION_NAME = "Settings.Section";
2637
3399
  var SettingsRoot = ({ children, classNames }) => {
2638
- return /* @__PURE__ */ React22.createElement("div", {
2639
- className: mx4("flex flex-col gap-2", classNames)
3400
+ return /* @__PURE__ */ React26.createElement("div", {
3401
+ className: mx7("flex flex-col gap-2", classNames)
2640
3402
  }, children);
2641
3403
  };
2642
3404
  SettingsRoot.displayName = SETTINGS_ROOT_NAME;
2643
- var SettingsViewport = composable3(({ children, ...props }, forwardedRef) => {
2644
- return /* @__PURE__ */ React22.createElement(ScrollArea2.Root, {
2645
- ...composableProps3(props),
3405
+ var SettingsViewport = composable4(({ children, ...props }, forwardedRef) => {
3406
+ return /* @__PURE__ */ React26.createElement(ScrollArea2.Root, {
3407
+ ...composableProps4(props),
2646
3408
  orientation: "vertical",
2647
3409
  centered: true,
2648
3410
  thin: true,
2649
3411
  ref: forwardedRef
2650
- }, /* @__PURE__ */ React22.createElement(ScrollArea2.Viewport, {
3412
+ }, /* @__PURE__ */ React26.createElement(ScrollArea2.Viewport, {
2651
3413
  classNames: "px-4 pointer-coarse:px-2"
2652
- }, /* @__PURE__ */ React22.createElement("div", {
3414
+ }, /* @__PURE__ */ React26.createElement("div", {
2653
3415
  className: "dx-document flex flex-col gap-2 py-4"
2654
3416
  }, children)));
2655
3417
  });
2656
3418
  SettingsViewport.displayName = SETTINGS_VIEWPORT_NAME;
2657
3419
  var SettingsSection = ({ title, description, children }) => {
2658
- const { t } = useTranslation11(translationKey13);
2659
- return /* @__PURE__ */ React22.createElement(React22.Fragment, null, /* @__PURE__ */ React22.createElement("h2", {
3420
+ const { t } = useTranslation12(translationKey14);
3421
+ return /* @__PURE__ */ React26.createElement(React26.Fragment, null, /* @__PURE__ */ React26.createElement("h2", {
2660
3422
  className: "px-trim-md mt-trim-md text-xl"
2661
- }, toLocalizedString2(title, t)), description && /* @__PURE__ */ React22.createElement("p", {
3423
+ }, toLocalizedString2(title, t)), description && /* @__PURE__ */ React26.createElement("p", {
2662
3424
  className: "px-trim-md text-description"
2663
- }, toLocalizedString2(description, t)), /* @__PURE__ */ React22.createElement("div", {
3425
+ }, toLocalizedString2(description, t)), /* @__PURE__ */ React26.createElement("div", {
2664
3426
  className: "w-full pt-trim-md space-y-trim-md"
2665
3427
  }, children));
2666
3428
  };
@@ -2675,7 +3437,7 @@ var Settings = {
2675
3437
  };
2676
3438
 
2677
3439
  // src/components/Settings/SettingsSelectField.tsx
2678
- import React23 from "react";
3440
+ import React27 from "react";
2679
3441
  import { Select as Select3 } from "@dxos/react-ui";
2680
3442
  var createSelectField = ({ options, defaultLabel = "Default" }) => {
2681
3443
  const normalized = options.map((option) => typeof option === "string" ? {
@@ -2684,45 +3446,43 @@ var createSelectField = ({ options, defaultLabel = "Default" }) => {
2684
3446
  } : option);
2685
3447
  const hasDefault = defaultLabel !== null;
2686
3448
  const sentinel = hasDefault ? `__default__${Math.random().toString(36).slice(2)}` : "";
2687
- return ({ value: value3, onChange, readonly }) => /* @__PURE__ */ React23.createElement(Select3.Root, {
3449
+ return ({ value: value3, onChange, readonly }) => /* @__PURE__ */ React27.createElement(Select3.Root, {
2688
3450
  disabled: readonly,
2689
3451
  value: value3 ?? sentinel,
2690
3452
  onValueChange: (next) => onChange(hasDefault && next === sentinel ? void 0 : next)
2691
- }, /* @__PURE__ */ React23.createElement(Select3.TriggerButton, {
3453
+ }, /* @__PURE__ */ React27.createElement(Select3.TriggerButton, {
2692
3454
  disabled: readonly
2693
- }), /* @__PURE__ */ React23.createElement(Select3.Portal, null, /* @__PURE__ */ React23.createElement(Select3.Content, null, /* @__PURE__ */ React23.createElement(Select3.Viewport, null, hasDefault && /* @__PURE__ */ React23.createElement(Select3.Option, {
3455
+ }), /* @__PURE__ */ React27.createElement(Select3.Portal, null, /* @__PURE__ */ React27.createElement(Select3.Content, null, /* @__PURE__ */ React27.createElement(Select3.Viewport, null, hasDefault && /* @__PURE__ */ React27.createElement(Select3.Option, {
2694
3456
  value: sentinel
2695
- }, defaultLabel), normalized.map((option) => /* @__PURE__ */ React23.createElement(Select3.Option, {
3457
+ }, defaultLabel), normalized.map((option) => /* @__PURE__ */ React27.createElement(Select3.Option, {
2696
3458
  key: option.value,
2697
3459
  value: option.value
2698
- }, option.label ?? option.value))), /* @__PURE__ */ React23.createElement(Select3.Arrow, null))));
3460
+ }, option.label ?? option.value))), /* @__PURE__ */ React27.createElement(Select3.Arrow, null))));
2699
3461
  };
2700
3462
 
2701
3463
  // src/components/ViewEditor/ViewEditor.tsx
2702
3464
  import { RegistryContext } from "@effect-atom/atom-react";
2703
- import * as Array4 from "effect/Array";
2704
3465
  import * as Match2 from "effect/Match";
2705
- import * as Option6 from "effect/Option";
3466
+ import * as Option8 from "effect/Option";
2706
3467
  import * as Schema5 from "effect/Schema";
2707
- import React24, { forwardRef as forwardRef2, useCallback as useCallback18, useContext, useImperativeHandle, useMemo as useMemo12, useState as useState7 } from "react";
2708
- import { Entity as Entity2, Feed, Filter as Filter2, Format as Format5, Obj as Obj6, Query, QueryAST, Ref as Ref6, View } from "@dxos/echo";
2709
- import { EchoSchema, isMutable, toJsonSchema } from "@dxos/echo/internal";
3468
+ import React28, { forwardRef as forwardRef2, useCallback as useCallback20, useContext as useContext2, useImperativeHandle, useMemo as useMemo14, useState as useState7 } from "react";
3469
+ import { Entity as Entity2, Feed, Filter as Filter3, Format as Format7, Obj as Obj7, Query, QueryAST, Ref as Ref8, Type as Type7, View } from "@dxos/echo";
2710
3470
  import { invariant as invariant3 } from "@dxos/invariant";
2711
3471
  import { useObject, useQuery as useQuery2 } from "@dxos/react-client/echo";
2712
- import { IconButton as IconButton4, Input as Input14, Message, useTranslation as useTranslation12 } from "@dxos/react-ui";
3472
+ import { IconButton as IconButton4, Input as Input18, Message, useTranslation as useTranslation13 } from "@dxos/react-ui";
2713
3473
  import { QueryForm } from "@dxos/react-ui-components";
2714
3474
  import { List as List2 } from "@dxos/react-ui-list";
2715
3475
  import { ParentLabelAnnotation, ProjectionModel, VIEW_FIELD_LIMIT, createEchoChangeCallback, getTypenameFromQuery } from "@dxos/schema";
2716
- import { mx as mx5, osTranslations as osTranslations2 } from "@dxos/ui-theme";
2717
- import { translationKey as translationKey14 } from "#translations";
3476
+ import { mx as mx8, osTranslations as osTranslations2 } from "@dxos/ui-theme";
3477
+ import { translationKey as translationKey15 } from "#translations";
2718
3478
  var __dxlog_file5 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx";
2719
- var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode = "schema", registry, db, readonly, showHeading = false, types, tags, onQueryChanged, onDelete }, forwardedRef) => {
2720
- const atomRegistry = useContext(RegistryContext);
2721
- const schemaReadonly = !isMutable(schema);
2722
- const { t } = useTranslation12(translationKey14);
2723
- const projectionModel = useMemo12(() => {
2724
- const jsonSchema = schema instanceof EchoSchema ? schema.jsonSchema : toJsonSchema(schema);
2725
- const change = createEchoChangeCallback(view, schema instanceof EchoSchema ? schema : void 0);
3479
+ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, type, view, mode = "schema", registry, db, readonly, showHeading = false, types, tags, onQueryChanged, onDelete }, forwardedRef) => {
3480
+ const atomRegistry = useContext2(RegistryContext);
3481
+ const schemaReadonly = Type7.getDatabase(type) == null;
3482
+ const { t } = useTranslation13(translationKey15);
3483
+ const projectionModel = useMemo14(() => {
3484
+ const jsonSchema = type.jsonSchema;
3485
+ const change = createEchoChangeCallback(view, Type7.getDatabase(type) != null ? type : void 0);
2726
3486
  const model = new ProjectionModel({
2727
3487
  registry: atomRegistry,
2728
3488
  view,
@@ -2732,7 +3492,7 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
2732
3492
  return model;
2733
3493
  }, [
2734
3494
  atomRegistry,
2735
- schema,
3495
+ type,
2736
3496
  view
2737
3497
  ]);
2738
3498
  useImperativeHandle(forwardedRef, () => projectionModel, [
@@ -2744,22 +3504,23 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
2744
3504
  if (from._tag !== "scope") {
2745
3505
  return void 0;
2746
3506
  }
2747
- return Option6.fromNullable(from.scope.feeds).pipe(Option6.flatMap((feeds2) => Array4.head(feeds2)), Option6.map(String), Option6.getOrUndefined);
3507
+ const feedScope = from.scopes.find((s) => s._tag === "feed");
3508
+ return Option8.fromNullable(feedScope).pipe(Option8.map((s) => s.feedUri), Option8.getOrUndefined);
2748
3509
  }), Match2.orElse(() => void 0));
2749
- const feeds = useQuery2(db, Filter2.type(Feed.Feed));
2750
- const targetRef = useMemo12(() => {
3510
+ const feeds = useQuery2(db, Filter3.type(Feed.Feed));
3511
+ const targetRef = useMemo14(() => {
2751
3512
  if (!queueTarget) {
2752
3513
  return void 0;
2753
3514
  }
2754
- const feed = feeds.find((feed2) => Feed.getQueueDxn(feed2)?.toString() === queueTarget);
2755
- return feed ? Ref6.fromDXN(Entity2.getDXN(feed)) : void 0;
3515
+ const feed = feeds.find((feed2) => Feed.getQueueUri(feed2)?.toString() === queueTarget);
3516
+ return feed ? Ref8.fromURI(Entity2.getURI(feed)) : void 0;
2756
3517
  }, [
2757
3518
  queueTarget,
2758
3519
  feeds
2759
3520
  ]);
2760
- const viewSchema = useMemo12(() => {
3521
+ const viewSchema = useMemo14(() => {
2761
3522
  const base = Schema5.Struct({
2762
- query: mode === "schema" ? Format5.URL.annotations({
3523
+ query: mode === "schema" ? Format7.URL.annotations({
2763
3524
  title: "Record type"
2764
3525
  }) : QueryAST.Query.annotations({
2765
3526
  title: "Query"
@@ -2769,7 +3530,7 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
2769
3530
  return Schema5.Struct({
2770
3531
  ...base.fields,
2771
3532
  // TODO(wittjosiah): Replace Type.Feed with Dataset.Dataset when Ref.Ref supports unions.
2772
- target: Ref6.Ref(Feed.Feed).pipe(Schema5.annotations({
3533
+ target: Ref8.Ref(Feed.Feed).pipe(Schema5.annotations({
2773
3534
  title: "Target Feed"
2774
3535
  }), ParentLabelAnnotation.set(true), Schema5.optional)
2775
3536
  }).pipe(Schema5.mutable);
@@ -2778,7 +3539,7 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
2778
3539
  }, [
2779
3540
  mode
2780
3541
  ]);
2781
- const viewValues = useMemo12(() => ({
3542
+ const viewValues = useMemo14(() => ({
2782
3543
  query: mode === "schema" ? getTypenameFromQuery(view.query.ast) : view.query.ast,
2783
3544
  target: targetRef
2784
3545
  }), [
@@ -2786,7 +3547,7 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
2786
3547
  view.query.ast,
2787
3548
  targetRef
2788
3549
  ]);
2789
- const fieldMap = useMemo12(() => mode === "tag" ? customFields({
3550
+ const fieldMap = useMemo14(() => mode === "tag" ? customFields({
2790
3551
  types,
2791
3552
  tags
2792
3553
  }) : void 0, [
@@ -2794,46 +3555,46 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
2794
3555
  types,
2795
3556
  tags
2796
3557
  ]);
2797
- const handleUpdate = useCallback18((values) => {
3558
+ const handleUpdate = useCallback20((values) => {
2798
3559
  const targetValue = values.target;
2799
- let feedDXN;
2800
- if (Ref6.isRef(targetValue)) {
2801
- const targetDXN = targetValue.dxn.toString();
2802
- const feed = feeds.find((feed2) => Obj6.getDXN(feed2).toString() === targetDXN);
3560
+ let queueDxn;
3561
+ if (Ref8.isRef(targetValue)) {
3562
+ const feedUri = targetValue.uri;
3563
+ const feed = feeds.find((feed2) => Obj7.getURI(feed2) === feedUri);
2803
3564
  if (feed) {
2804
- feedDXN = Feed.getQueueDxn(feed)?.toString();
3565
+ queueDxn = Feed.getQueueUri(feed);
2805
3566
  }
2806
3567
  }
2807
- const query = mode === "schema" ? Query.select(Filter2.typename(values.query)).ast : JSON.parse(JSON.stringify(values.query));
2808
- onQueryChanged?.(query, feedDXN);
3568
+ const query = mode === "schema" ? Query.select(Filter3.typename(values.query)).ast : JSON.parse(JSON.stringify(values.query));
3569
+ onQueryChanged?.(query, queueDxn);
2809
3570
  }, [
2810
3571
  onQueryChanged,
2811
3572
  mode,
2812
3573
  feeds
2813
3574
  ]);
2814
- const handleDelete = useCallback18((fieldId) => {
2815
- invariant3(!readonly, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 126, S: void 0, A: ["!readonly", ""] });
3575
+ const handleDelete = useCallback20((fieldId) => {
3576
+ invariant3(!readonly, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 124, S: void 0, A: ["!readonly", ""] });
2816
3577
  onDelete?.(fieldId);
2817
3578
  }, [
2818
3579
  onDelete,
2819
3580
  readonly
2820
3581
  ]);
2821
- return /* @__PURE__ */ React24.createElement("div", {
2822
- className: mx5(classNames)
2823
- }, schemaReadonly && !readonly && /* @__PURE__ */ React24.createElement(Message.Root, {
3582
+ return /* @__PURE__ */ React28.createElement("div", {
3583
+ className: mx8(classNames)
3584
+ }, schemaReadonly && !readonly && /* @__PURE__ */ React28.createElement(Message.Root, {
2824
3585
  valence: "info",
2825
3586
  classNames: "my-form-padding"
2826
- }, /* @__PURE__ */ React24.createElement(Message.Title, null, t("system-schema.description"))), /* @__PURE__ */ React24.createElement(Form.Root, {
3587
+ }, /* @__PURE__ */ React28.createElement(Message.Title, null, t("system-schema.description"))), /* @__PURE__ */ React28.createElement(Form.Root, {
2827
3588
  schema: viewSchema,
2828
3589
  values: viewValues,
2829
3590
  fieldMap,
2830
3591
  db,
2831
3592
  onValuesChanged: handleUpdate
2832
- }, /* @__PURE__ */ React24.createElement(Form.FieldSet, null), /* @__PURE__ */ React24.createElement(FormFieldLabel, {
3593
+ }, /* @__PURE__ */ React28.createElement(Form.FieldSet, null), /* @__PURE__ */ React28.createElement(FormFieldLabel, {
2833
3594
  label: t("fields.label"),
2834
3595
  asChild: true
2835
- }), /* @__PURE__ */ React24.createElement(FieldList, {
2836
- schema,
3596
+ }), /* @__PURE__ */ React28.createElement(FieldList, {
3597
+ type,
2837
3598
  view,
2838
3599
  registry,
2839
3600
  readonly,
@@ -2841,14 +3602,14 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
2841
3602
  onDelete: handleDelete
2842
3603
  })));
2843
3604
  });
2844
- var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDelete }) => {
2845
- const atomRegistry = useContext(RegistryContext);
2846
- const schemaReadonly = !isMutable(schema);
2847
- const { t } = useTranslation12(translationKey14);
3605
+ var FieldList = ({ type, view, registry, readonly, showHeading = false, onDelete }) => {
3606
+ const atomRegistry = useContext2(RegistryContext);
3607
+ const schemaReadonly = Type7.getDatabase(type) == null;
3608
+ const { t } = useTranslation13(translationKey15);
2848
3609
  const [viewSnapshot] = useObject(view);
2849
- const projectionModel = useMemo12(() => {
2850
- const jsonSchema = schema instanceof EchoSchema ? schema.jsonSchema : toJsonSchema(schema);
2851
- const change = createEchoChangeCallback(view, schema instanceof EchoSchema ? schema : void 0);
3610
+ const projectionModel = useMemo14(() => {
3611
+ const jsonSchema = type.jsonSchema;
3612
+ const change = createEchoChangeCallback(view, Type7.getDatabase(type) != null ? type : void 0);
2852
3613
  const model = new ProjectionModel({
2853
3614
  registry: atomRegistry,
2854
3615
  view,
@@ -2858,25 +3619,25 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
2858
3619
  return model;
2859
3620
  }, [
2860
3621
  atomRegistry,
2861
- schema,
3622
+ type,
2862
3623
  view
2863
3624
  ]);
2864
3625
  const [expandedField, setExpandedField] = useState7();
2865
- const handleAdd = useCallback18(() => {
2866
- invariant3(!readonly, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 181, S: void 0, A: ["!readonly", ""] });
3626
+ const handleAdd = useCallback20(() => {
3627
+ invariant3(!readonly, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 178, S: void 0, A: ["!readonly", ""] });
2867
3628
  const field = projectionModel.createFieldProjection();
2868
3629
  setExpandedField(field.id);
2869
3630
  }, [
2870
3631
  projectionModel,
2871
3632
  readonly
2872
3633
  ]);
2873
- const handleToggleField = useCallback18((field) => {
3634
+ const handleToggleField = useCallback20((field) => {
2874
3635
  setExpandedField((prevExpandedFieldId) => prevExpandedFieldId === field.id ? void 0 : field.id);
2875
3636
  }, [
2876
3637
  readonly
2877
3638
  ]);
2878
- const handleDelete = useCallback18((fieldId) => {
2879
- invariant3(!readonly, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 194, S: void 0, A: ["!readonly", ""] });
3639
+ const handleDelete = useCallback20((fieldId) => {
3640
+ invariant3(!readonly, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 191, S: void 0, A: ["!readonly", ""] });
2880
3641
  if (fieldId === expandedField) {
2881
3642
  setExpandedField(void 0);
2882
3643
  }
@@ -2886,9 +3647,9 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
2886
3647
  onDelete,
2887
3648
  readonly
2888
3649
  ]);
2889
- const handleMove = useCallback18((fromIndex, toIndex) => {
2890
- invariant3(!readonly, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 205, S: void 0, A: ["!readonly", ""] });
2891
- Obj6.update(view, (view2) => {
3650
+ const handleMove = useCallback20((fromIndex, toIndex) => {
3651
+ invariant3(!readonly, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 202, S: void 0, A: ["!readonly", ""] });
3652
+ Obj7.update(view, (view2) => {
2892
3653
  const fields = [
2893
3654
  ...view2.projection.fields
2894
3655
  ];
@@ -2900,14 +3661,14 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
2900
3661
  view,
2901
3662
  readonly
2902
3663
  ]);
2903
- const handleClose = useCallback18(() => setExpandedField(void 0), []);
2904
- const handleHide = useCallback18((fieldId) => {
3664
+ const handleClose = useCallback20(() => setExpandedField(void 0), []);
3665
+ const handleHide = useCallback20((fieldId) => {
2905
3666
  setExpandedField(void 0);
2906
3667
  projectionModel.hideFieldProjection(fieldId);
2907
3668
  }, [
2908
3669
  projectionModel
2909
3670
  ]);
2910
- const handleShow = useCallback18((property) => {
3671
+ const handleShow = useCallback20((property) => {
2911
3672
  setExpandedField(void 0);
2912
3673
  projectionModel.showFieldProjection(property);
2913
3674
  }, [
@@ -2916,45 +3677,45 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
2916
3677
  if (!viewSnapshot) {
2917
3678
  return null;
2918
3679
  }
2919
- return /* @__PURE__ */ React24.createElement(List2.Root, {
3680
+ return /* @__PURE__ */ React28.createElement(List2.Root, {
2920
3681
  items: viewSnapshot.projection.fields,
2921
3682
  isItem: Schema5.is(View.FieldSchema),
2922
3683
  getId: (field) => field.id,
2923
3684
  onMove: readonly ? void 0 : handleMove,
2924
3685
  readonly
2925
- }, ({ items: fields }) => /* @__PURE__ */ React24.createElement(React24.Fragment, null, showHeading && /* @__PURE__ */ React24.createElement("h3", {
3686
+ }, ({ items: fields }) => /* @__PURE__ */ React28.createElement(React28.Fragment, null, showHeading && /* @__PURE__ */ React28.createElement("h3", {
2926
3687
  className: "text-sm"
2927
- }, t("field-path.label")), /* @__PURE__ */ React24.createElement("div", {
3688
+ }, t("field-path.label")), /* @__PURE__ */ React28.createElement("div", {
2928
3689
  role: "list",
2929
3690
  className: "grid grid-cols-[min-content_1fr_min-content_min-content_min-content]"
2930
3691
  }, fields?.map((field) => {
2931
3692
  const hidden = field.visible === false;
2932
- return /* @__PURE__ */ React24.createElement(List2.Item, {
3693
+ return /* @__PURE__ */ React28.createElement(List2.Item, {
2933
3694
  key: field.id,
2934
3695
  item: field,
2935
3696
  classNames: "grid grid-cols-subgrid col-span-5",
2936
3697
  "aria-expanded": expandedField === field.id
2937
- }, /* @__PURE__ */ React24.createElement("div", {
3698
+ }, /* @__PURE__ */ React28.createElement("div", {
2938
3699
  className: "grid grid-cols-subgrid col-span-5 rounded-xs cursor-pointer min-h-10 dx-hover"
2939
- }, /* @__PURE__ */ React24.createElement(List2.ItemDragHandle, {
3700
+ }, /* @__PURE__ */ React28.createElement(List2.ItemDragHandle, {
2940
3701
  disabled: readonly || schemaReadonly
2941
- }), /* @__PURE__ */ React24.createElement(List2.ItemTitle, {
3702
+ }), /* @__PURE__ */ React28.createElement(List2.ItemTitle, {
2942
3703
  classNames: hidden && "text-subdued",
2943
3704
  onClick: () => handleToggleField(field)
2944
- }, field.path), /* @__PURE__ */ React24.createElement(List2.ItemIconButton, {
3705
+ }, field.path), /* @__PURE__ */ React28.createElement(List2.ItemIconButton, {
2945
3706
  label: t(hidden ? "show-field.label" : "hide-field.label"),
2946
3707
  "data-testid": hidden ? "show-field-button" : "hide-field-button",
2947
3708
  icon: hidden ? "ph--eye-closed--regular" : "ph--eye--regular",
2948
3709
  autoHide: false,
2949
3710
  disabled: readonly || !hidden && projectionModel.getFields().length <= 1,
2950
3711
  onClick: () => hidden ? handleShow(field.path) : handleHide(field.id)
2951
- }), !readonly && /* @__PURE__ */ React24.createElement(React24.Fragment, null, /* @__PURE__ */ React24.createElement(List2.ItemDeleteButton, {
3712
+ }), !readonly && /* @__PURE__ */ React28.createElement(React28.Fragment, null, /* @__PURE__ */ React28.createElement(List2.ItemDeleteButton, {
2952
3713
  label: t("delete-field.label"),
2953
3714
  autoHide: false,
2954
3715
  disabled: readonly || schemaReadonly || viewSnapshot.projection.fields.length <= 1,
2955
3716
  onClick: () => handleDelete(field.id),
2956
3717
  "data-testid": "field.delete"
2957
- }), /* @__PURE__ */ React24.createElement(List2.ItemIconButton, {
3718
+ }), /* @__PURE__ */ React28.createElement(List2.ItemIconButton, {
2958
3719
  iconOnly: true,
2959
3720
  variant: "ghost",
2960
3721
  label: t("toggle-expand.label", {
@@ -2963,18 +3724,18 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
2963
3724
  icon: expandedField === field.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
2964
3725
  onClick: () => handleToggleField(field),
2965
3726
  "data-testid": "field.toggle"
2966
- }))), expandedField === field.id && !readonly && /* @__PURE__ */ React24.createElement("div", {
3727
+ }))), expandedField === field.id && !readonly && /* @__PURE__ */ React28.createElement("div", {
2967
3728
  className: "col-span-full mt-1 mb-1 border border-separator rounded-md"
2968
- }, /* @__PURE__ */ React24.createElement(FieldEditor, {
3729
+ }, /* @__PURE__ */ React28.createElement(FieldEditor, {
2969
3730
  readonly: readonly || schemaReadonly,
2970
3731
  registry,
2971
3732
  projection: projectionModel,
2972
3733
  field,
2973
3734
  onSave: handleClose
2974
3735
  })));
2975
- })), !readonly && !expandedField && /* @__PURE__ */ React24.createElement("div", {
3736
+ })), !readonly && !expandedField && /* @__PURE__ */ React28.createElement("div", {
2976
3737
  className: "my-form-padding"
2977
- }, /* @__PURE__ */ React24.createElement(IconButton4, {
3738
+ }, /* @__PURE__ */ React28.createElement(IconButton4, {
2978
3739
  icon: "ph--plus--regular",
2979
3740
  label: t("add-property-button.label"),
2980
3741
  onClick: handleAdd,
@@ -2984,13 +3745,13 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
2984
3745
  };
2985
3746
  var customFields = ({ types, tags }) => ({
2986
3747
  query: ({ type, readonly, label, getValue, onValueChange }) => {
2987
- const handleChange = useCallback18((query) => onValueChange(type, query.ast), [
3748
+ const handleChange = useCallback20((query) => onValueChange(type, query.ast), [
2988
3749
  onValueChange
2989
3750
  ]);
2990
- return /* @__PURE__ */ React24.createElement(Input14.Root, null, /* @__PURE__ */ React24.createElement(FormFieldLabel, {
3751
+ return /* @__PURE__ */ React28.createElement(Input18.Root, null, /* @__PURE__ */ React28.createElement(FormFieldLabel, {
2991
3752
  readonly,
2992
3753
  label
2993
- }), /* @__PURE__ */ React24.createElement(QueryForm, {
3754
+ }), /* @__PURE__ */ React28.createElement(QueryForm, {
2994
3755
  initialQuery: getValue(),
2995
3756
  types,
2996
3757
  tags,
@@ -3001,17 +3762,27 @@ var customFields = ({ types, tags }) => ({
3001
3762
  export {
3002
3763
  ArrayField,
3003
3764
  BooleanField,
3765
+ DEFAULT_LAYOUT_NAME,
3766
+ DateField,
3004
3767
  FieldEditor,
3005
3768
  Form,
3006
3769
  FormFieldErrorBoundary,
3007
3770
  FormFieldLabel,
3008
3771
  FormFieldWrapper,
3772
+ FormLayout,
3773
+ FormLayoutAnnotation,
3774
+ FormLayoutAnnotationId,
3775
+ FormTooltipsContext,
3009
3776
  GeoPointField,
3777
+ InlineRefField,
3778
+ LayoutParseError,
3779
+ META_TAGS_KEY,
3010
3780
  MarkdownField,
3011
3781
  NumberField,
3012
3782
  ObjectForm,
3013
3783
  ObjectPicker,
3014
3784
  ObjectProperties,
3785
+ ObjectTree,
3015
3786
  RefField,
3016
3787
  SelectField,
3017
3788
  SelectOptionField,
@@ -3031,12 +3802,15 @@ export {
3031
3802
  getSelectOptionsFromAst,
3032
3803
  omitHiddenFormFields,
3033
3804
  omitId,
3805
+ parseLayout,
3034
3806
  parseValue,
3035
3807
  pathNotUniqueError,
3036
3808
  useFormContext,
3037
3809
  useFormFieldState,
3038
3810
  useFormHandler,
3811
+ useFormTooltips,
3039
3812
  useFormValues,
3040
- useKeyHandler
3813
+ useKeyHandler,
3814
+ withMetaTags
3041
3815
  };
3042
3816
  //# sourceMappingURL=index.mjs.map