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

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 (78) hide show
  1. package/dist/lib/browser/index.mjs +354 -306
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +354 -306
  5. package/dist/lib/node-esm/index.mjs.map +4 -4
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
  8. package/dist/types/src/components/Form/ArrayField.d.ts.map +1 -1
  9. package/dist/types/src/components/Form/Form.d.ts +2 -2
  10. package/dist/types/src/components/Form/Form.d.ts.map +1 -1
  11. package/dist/types/src/components/Form/Form.stories.d.ts +8 -8
  12. package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
  13. package/dist/types/src/components/Form/FormContent.d.ts +1 -1
  14. package/dist/types/src/components/Form/FormContent.d.ts.map +1 -1
  15. package/dist/types/src/components/Form/FormContext.d.ts +1 -1
  16. package/dist/types/src/components/Form/FormContext.d.ts.map +1 -1
  17. package/dist/types/src/components/Form/Input.d.ts +1 -1
  18. package/dist/types/src/components/Form/Input.d.ts.map +1 -1
  19. package/dist/types/src/components/Form/RefField.d.ts +4 -2
  20. package/dist/types/src/components/Form/RefField.d.ts.map +1 -1
  21. package/dist/types/src/components/Form/factory.d.ts +1 -1
  22. package/dist/types/src/components/Form/factory.d.ts.map +1 -1
  23. package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts +41 -0
  24. package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts.map +1 -0
  25. package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts +82 -0
  26. package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts.map +1 -0
  27. package/dist/types/src/components/ObjectPicker/index.d.ts +2 -0
  28. package/dist/types/src/components/ObjectPicker/index.d.ts.map +1 -0
  29. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +7 -5
  30. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
  31. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +2 -2
  32. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
  33. package/dist/types/src/components/index.d.ts +1 -0
  34. package/dist/types/src/components/index.d.ts.map +1 -1
  35. package/dist/types/src/hooks/useForm.d.ts +2 -2
  36. package/dist/types/src/hooks/useForm.d.ts.map +1 -1
  37. package/dist/types/src/hooks/useQueryRefOptions.d.ts +4 -3
  38. package/dist/types/src/hooks/useQueryRefOptions.d.ts.map +1 -1
  39. package/dist/types/src/hooks/useRefQueryLookupHandler.d.ts.map +1 -1
  40. package/dist/types/src/util/field.d.ts +1 -1
  41. package/dist/types/src/util/field.d.ts.map +1 -1
  42. package/dist/types/src/util/formatting.d.ts +1 -1
  43. package/dist/types/src/util/formatting.d.ts.map +1 -1
  44. package/dist/types/src/util/refs.d.ts +1 -1
  45. package/dist/types/src/util/refs.d.ts.map +1 -1
  46. package/dist/types/src/util/schema.d.ts +1 -1
  47. package/dist/types/src/util/schema.d.ts.map +1 -1
  48. package/dist/types/tsconfig.tsbuildinfo +1 -1
  49. package/package.json +32 -33
  50. package/src/components/ControlSection/ControlSection.tsx +1 -1
  51. package/src/components/FieldEditor/FieldEditor.stories.tsx +1 -1
  52. package/src/components/FieldEditor/FieldEditor.tsx +1 -1
  53. package/src/components/Form/ArrayField.tsx +4 -3
  54. package/src/components/Form/Form.stories.tsx +3 -3
  55. package/src/components/Form/Form.tsx +13 -5
  56. package/src/components/Form/FormContent.tsx +5 -3
  57. package/src/components/Form/FormContext.tsx +2 -2
  58. package/src/components/Form/Input.tsx +1 -1
  59. package/src/components/Form/RefField.tsx +35 -115
  60. package/src/components/Form/custom/GeoPointInput.tsx +1 -1
  61. package/src/components/Form/custom/SelectOptionsInput.stories.tsx +2 -2
  62. package/src/components/Form/custom/SelectOptionsInput.tsx +1 -1
  63. package/src/components/Form/factory.tsx +1 -1
  64. package/src/components/ObjectPicker/ObjectPicker.stories.tsx +207 -0
  65. package/src/components/ObjectPicker/ObjectPicker.tsx +161 -0
  66. package/src/components/ObjectPicker/index.ts +5 -0
  67. package/src/components/ViewEditor/ViewEditor.stories.tsx +41 -25
  68. package/src/components/ViewEditor/ViewEditor.test.tsx +3 -2
  69. package/src/components/ViewEditor/ViewEditor.tsx +45 -94
  70. package/src/components/index.ts +1 -0
  71. package/src/components/testing.tsx +2 -2
  72. package/src/hooks/useForm.ts +6 -4
  73. package/src/hooks/useQueryRefOptions.ts +9 -6
  74. package/src/hooks/useRefQueryLookupHandler.ts +3 -3
  75. package/src/util/field.ts +1 -1
  76. package/src/util/formatting.ts +1 -1
  77. package/src/util/refs.ts +2 -2
  78. package/src/util/schema.ts +2 -4
@@ -85,7 +85,8 @@ var ControlPage = ({ children, classNames, ...props }) => {
85
85
  var _effect = _useSignals();
86
86
  try {
87
87
  return /* @__PURE__ */ React.createElement(StackItem.Content, {
88
- classNames: "block overflow-y-auto [--control-spacing:var(--dx-trimMd)]"
88
+ scrollable: true,
89
+ classNames: "[--control-spacing:var(--dx-trimMd)]"
89
90
  }, /* @__PURE__ */ React.createElement("div", {
90
91
  role: "none",
91
92
  className: mx("pli-cardSpacingInline pbe-trimLg", classNames),
@@ -215,17 +216,17 @@ var ControlFrameItem = ({ title, description, children }) => {
215
216
  };
216
217
 
217
218
  // src/components/FieldEditor/FieldEditor.tsx
218
- import { useSignals as _useSignals13 } from "@preact-signals/safe-react/tracking";
219
- import React13, { useCallback as useCallback9, useEffect as useEffect8, useMemo as useMemo7, useState as useState6 } from "react";
220
- import { FormatEnum as FormatEnum5, FormatEnums, formatToType } from "@dxos/echo-schema";
219
+ import { useSignals as _useSignals14 } from "@preact-signals/safe-react/tracking";
220
+ import React14, { useCallback as useCallback12, useEffect as useEffect8, useMemo as useMemo7, useState as useState6 } from "react";
221
+ import { FormatEnum as FormatEnum5, FormatEnums, formatToType } from "@dxos/echo/internal";
221
222
  import { log as log3 } from "@dxos/log";
222
- import { useAsyncEffect, useTranslation as useTranslation8 } from "@dxos/react-ui";
223
+ import { useAsyncEffect, useTranslation as useTranslation9 } from "@dxos/react-ui";
223
224
  import { formatToAdditionalPropertyAttributes, getFormatSchema, getSchemaProperties as getSchemaProperties3, sortProperties } from "@dxos/schema";
224
225
 
225
226
  // src/components/Form/custom/GeoPointInput.tsx
226
227
  import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
227
228
  import React3, { useCallback, useEffect, useMemo, useState } from "react";
228
- import { GeoLocation } from "@dxos/echo-schema";
229
+ import { GeoLocation } from "@dxos/echo/internal";
229
230
  import { Input as Input3, useTranslation as useTranslation2 } from "@dxos/react-ui";
230
231
  import { safeParseFloat } from "@dxos/util";
231
232
 
@@ -638,7 +639,7 @@ var BooleanInput = ({ type, label, inputOnly, getStatus, getValue: getValue3, on
638
639
  }), readonly === "static" ? /* @__PURE__ */ React6.createElement("p", null, t(checked ? "boolean input true value" : "boolean input false value")) : /* @__PURE__ */ React6.createElement(Input6.Switch, {
639
640
  disabled: !!readonly,
640
641
  checked,
641
- onCheckedChange: (value) => onValueChange(type, value)
642
+ onCheckedChange: (value2) => onValueChange(type, value2)
642
643
  }), inputOnly && /* @__PURE__ */ React6.createElement(Input6.DescriptionAndValidation, null, error));
643
644
  } finally {
644
645
  _effect.f();
@@ -648,29 +649,29 @@ var SelectInput = ({ type, label, inputOnly, readonly, placeholder, options, get
648
649
  var _effect = _useSignals6();
649
650
  try {
650
651
  const { status, error } = getStatus();
651
- const value = getValue3();
652
- const handleValueChange = useCallback3((value2) => onValueChange(type, value2), [
652
+ const value2 = getValue3();
653
+ const handleValueChange = useCallback3((value3) => onValueChange(type, value3), [
653
654
  type,
654
655
  onValueChange
655
656
  ]);
656
- return readonly && !value ? null : /* @__PURE__ */ React6.createElement(Input6.Root, {
657
+ return readonly && !value2 ? null : /* @__PURE__ */ React6.createElement(Input6.Root, {
657
658
  validationValence: status
658
659
  }, !inputOnly && /* @__PURE__ */ React6.createElement(InputHeader, {
659
660
  error,
660
661
  label
661
- }), readonly === "static" ? /* @__PURE__ */ React6.createElement("p", null, options?.find(({ value: optionValue }) => optionValue === value)?.label ?? String(value)) : /* @__PURE__ */ React6.createElement(Select.Root, {
662
- value,
662
+ }), readonly === "static" ? /* @__PURE__ */ React6.createElement("p", null, options?.find(({ value: optionValue }) => optionValue === value2)?.label ?? String(value2)) : /* @__PURE__ */ React6.createElement(Select.Root, {
663
+ value: value2,
663
664
  onValueChange: handleValueChange
664
665
  }, /* @__PURE__ */ React6.createElement(Select.TriggerButton, {
665
666
  classNames: "is-full",
666
667
  disabled: !!readonly,
667
668
  placeholder
668
- }), /* @__PURE__ */ React6.createElement(Select.Portal, null, /* @__PURE__ */ React6.createElement(Select.Content, null, /* @__PURE__ */ React6.createElement(Select.Viewport, null, options?.map(({ value: value2, label: label2 }) => (
669
+ }), /* @__PURE__ */ React6.createElement(Select.Portal, null, /* @__PURE__ */ React6.createElement(Select.Content, null, /* @__PURE__ */ React6.createElement(Select.Viewport, null, options?.map(({ value: value3, label: label2 }) => (
669
670
  // NOTE: Numeric values are converted to and from strings.
670
671
  /* @__PURE__ */ React6.createElement(Select.Option, {
671
- key: String(value2),
672
- value: String(value2)
673
- }, label2 ?? String(value2))
672
+ key: String(value3),
673
+ value: String(value3)
674
+ }, label2 ?? String(value3))
674
675
  ))), /* @__PURE__ */ React6.createElement(Select.Arrow, null)))), inputOnly && /* @__PURE__ */ React6.createElement(Input6.DescriptionAndValidation, null, error));
675
676
  } finally {
676
677
  _effect.f();
@@ -723,9 +724,9 @@ var MarkdownInput = ({ type, label, inputOnly, readonly, placeholder, getStatus,
723
724
  };
724
725
 
725
726
  // src/components/Form/Form.tsx
726
- import { useSignals as _useSignals12 } from "@preact-signals/safe-react/tracking";
727
+ import { useSignals as _useSignals13 } from "@preact-signals/safe-react/tracking";
727
728
  import { useFocusFinders } from "@fluentui/react-tabster";
728
- import React12, { useEffect as useEffect7, useMemo as useMemo6, useRef as useRef3 } from "react";
729
+ import React13, { useCallback as useCallback11, useEffect as useEffect7, useRef as useRef3 } from "react";
729
730
  import { cardDialogOverflow, cardSpacing as cardSpacing2 } from "@dxos/react-ui-stack";
730
731
 
731
732
  // src/components/Form/FormActions.tsx
@@ -737,15 +738,15 @@ import { mx as mx4 } from "@dxos/react-ui-theme";
737
738
 
738
739
  // src/components/Form/FormContext.tsx
739
740
  import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
740
- import React7, { createContext, useCallback as useCallback6, useContext, useEffect as useEffect6, useMemo as useMemo3 } from "react";
741
+ import React7, { createContext, useCallback as useCallback7, useContext, useEffect as useEffect6, useMemo as useMemo3 } from "react";
741
742
  import { raise } from "@dxos/debug";
742
- import { getValue as getValue2 } from "@dxos/echo-schema";
743
+ import { getValue as getValue2 } from "@dxos/echo/internal";
743
744
  import { createJsonPath as createJsonPath2 } from "@dxos/effect";
744
745
 
745
746
  // src/hooks/useForm.ts
746
- import { SchemaAST } from "effect";
747
+ import * as SchemaAST from "effect/SchemaAST";
747
748
  import { useCallback as useCallback4, useEffect as useEffect4, useMemo as useMemo2, useState as useState3 } from "react";
748
- import { getValue, setValue } from "@dxos/echo-schema";
749
+ import { getValue, setValue } from "@dxos/echo/internal";
749
750
  import { createJsonPath, fromEffectValidationPath } from "@dxos/effect";
750
751
  import { invariant } from "@dxos/invariant";
751
752
  import { log } from "@dxos/log";
@@ -754,7 +755,7 @@ var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-form/src/hooks/useForm.t
754
755
  var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, onSave }) => {
755
756
  invariant(SchemaAST.isTypeLiteral(schema.ast), void 0, {
756
757
  F: __dxlog_file,
757
- L: 95,
758
+ L: 96,
758
759
  S: void 0,
759
760
  A: [
760
761
  "SchemaAST.isTypeLiteral(schema.ast)",
@@ -848,17 +849,17 @@ var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, on
848
849
  }, [
849
850
  values
850
851
  ]);
851
- const onValueChange = useCallback4((path, type, value) => {
852
+ const onValueChange = useCallback4((path, type, value2) => {
852
853
  const jsonPath = createJsonPath(path);
853
- let parsedValue = value;
854
+ let parsedValue = value2;
854
855
  try {
855
856
  if (type === "number") {
856
- parsedValue = parseFloat(value) || 0;
857
+ parsedValue = parseFloat(value2) || 0;
857
858
  }
858
859
  } catch (err) {
859
860
  log.catch(err, void 0, {
860
861
  F: __dxlog_file,
861
- L: 216,
862
+ L: 217,
862
863
  S: void 0,
863
864
  C: (f, a) => f(...a)
864
865
  });
@@ -868,15 +869,16 @@ var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, on
868
869
  ...setValue(values, jsonPath, parsedValue)
869
870
  };
870
871
  setValues(newValues);
871
- setChanged((prev) => ({
872
- ...prev,
872
+ const newChanged = {
873
+ ...changed,
873
874
  [jsonPath]: true
874
- }));
875
+ };
876
+ setChanged(newChanged);
875
877
  onValuesChanged?.(newValues);
876
878
  const isValid = validate(newValues);
877
879
  if (isValid && onValid) {
878
880
  onValid(newValues, {
879
- changed
881
+ changed: newChanged
880
882
  });
881
883
  }
882
884
  }, [
@@ -926,10 +928,10 @@ var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, on
926
928
  onTouched
927
929
  ]);
928
930
  };
929
- var createKeySet = (obj, value) => {
931
+ var createKeySet = (obj, value2) => {
930
932
  invariant(obj, void 0, {
931
933
  F: __dxlog_file,
932
- L: 278,
934
+ L: 280,
933
935
  S: void 0,
934
936
  A: [
935
937
  "obj",
@@ -938,7 +940,7 @@ var createKeySet = (obj, value) => {
938
940
  });
939
941
  return Object.keys(obj).reduce((acc, key) => ({
940
942
  ...acc,
941
- [key]: value
943
+ [key]: value2
942
944
  }), {});
943
945
  };
944
946
  var flatMap = (errors) => {
@@ -953,7 +955,8 @@ var flatMap = (errors) => {
953
955
 
954
956
  // src/hooks/useRefQueryLookupHandler.ts
955
957
  import { useCallback as useCallback5 } from "react";
956
- import { getObjectDXN } from "@dxos/echo-schema";
958
+ import { Obj } from "@dxos/echo";
959
+ import { getObjectDXN } from "@dxos/echo/internal";
957
960
  import { Filter } from "@dxos/react-client/echo";
958
961
  import { isNonNullable } from "@dxos/util";
959
962
  var useRefQueryLookupHandler = ({ space }) => {
@@ -970,7 +973,7 @@ var useRefQueryLookupHandler = ({ space }) => {
970
973
  }
971
974
  const item = {
972
975
  dxn,
973
- label: object?.name ?? object?.id ?? ""
976
+ label: Obj.getLabel(object) ?? object?.id ?? ""
974
977
  };
975
978
  return item;
976
979
  }).filter(isNonNullable);
@@ -980,12 +983,14 @@ var useRefQueryLookupHandler = ({ space }) => {
980
983
  };
981
984
 
982
985
  // src/hooks/useQueryRefOptions.ts
983
- import { useEffect as useEffect5, useState as useState4 } from "react";
986
+ import { useCallback as useCallback6, useEffect as useEffect5, useState as useState4 } from "react";
984
987
  import { log as log2 } from "@dxos/log";
985
988
  var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/hooks/useQueryRefOptions.ts";
986
989
  var useQueryRefOptions = ({ refTypeInfo, onQueryRefOptions }) => {
987
990
  const [options, setOptions] = useState4([]);
988
991
  const [loading, setLoading] = useState4(false);
992
+ const [state, setState] = useState4({});
993
+ const update = useCallback6(() => setState({}), []);
989
994
  useEffect5(() => {
990
995
  if (!refTypeInfo || !onQueryRefOptions) {
991
996
  return;
@@ -1005,7 +1010,7 @@ var useQueryRefOptions = ({ refTypeInfo, onQueryRefOptions }) => {
1005
1010
  } catch (error) {
1006
1011
  log2.error("Failed to fetch ref options:", error, {
1007
1012
  F: __dxlog_file2,
1008
- L: 48,
1013
+ L: 51,
1009
1014
  S: void 0,
1010
1015
  C: (f, a) => f(...a)
1011
1016
  });
@@ -1017,10 +1022,12 @@ var useQueryRefOptions = ({ refTypeInfo, onQueryRefOptions }) => {
1017
1022
  void fetchOptions();
1018
1023
  }, [
1019
1024
  refTypeInfo,
1020
- onQueryRefOptions
1025
+ onQueryRefOptions,
1026
+ state
1021
1027
  ]);
1022
1028
  return {
1023
1029
  options,
1030
+ update,
1024
1031
  loading
1025
1032
  };
1026
1033
  };
@@ -1043,7 +1050,7 @@ var useInputProps = (path = []) => {
1043
1050
  return useMemo3(() => ({
1044
1051
  getStatus: () => getStatus(stablePath),
1045
1052
  getValue: () => getFormValue(stablePath),
1046
- onValueChange: (type, value) => onValueChange(stablePath, type, value),
1053
+ onValueChange: (type, value2) => onValueChange(stablePath, type, value2),
1047
1054
  onBlur: () => onTouched(stablePath)
1048
1055
  }), [
1049
1056
  getStatus,
@@ -1057,7 +1064,7 @@ var FormProvider = ({ children, formRef, autoSave, ...formOptions }) => {
1057
1064
  var _effect = _useSignals7();
1058
1065
  try {
1059
1066
  const form = useForm(formOptions);
1060
- const handleKeyDown = useCallback6((event) => {
1067
+ const handleKeyDown = useCallback7((event) => {
1061
1068
  const keyIsEnter = event.key === "Enter";
1062
1069
  const modifierUsed = event.ctrlKey || event.altKey || event.metaKey || event.shiftKey;
1063
1070
  const inputIsTextarea = event.target.tagName.toLowerCase() === "textarea";
@@ -1073,7 +1080,9 @@ var FormProvider = ({ children, formRef, autoSave, ...formOptions }) => {
1073
1080
  }
1074
1081
  }
1075
1082
  }, [
1076
- form,
1083
+ form.canSave,
1084
+ form.formIsValid,
1085
+ form.handleSave,
1077
1086
  autoSave
1078
1087
  ]);
1079
1088
  useEffect6(() => {
@@ -1126,44 +1135,46 @@ var FormActions = ({ readonly, onCancel, outerSpacing = true }) => {
1126
1135
  };
1127
1136
 
1128
1137
  // src/components/Form/FormContent.tsx
1129
- import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
1130
- import { Schema, SchemaAST as SchemaAST4, pipe as pipe2 } from "effect";
1131
- import { capitalize as capitalize2 } from "effect/String";
1132
- import React11, { forwardRef, useMemo as useMemo5 } from "react";
1138
+ import { useSignals as _useSignals12 } from "@preact-signals/safe-react/tracking";
1139
+ import * as Function2 from "effect/Function";
1140
+ import * as Schema from "effect/Schema";
1141
+ import * as SchemaAST4 from "effect/SchemaAST";
1142
+ import * as StringEffect from "effect/String";
1143
+ import React12, { forwardRef as forwardRef2, useMemo as useMemo6 } from "react";
1133
1144
  import { createJsonPath as createJsonPath3, findNode as findNode3, getDiscriminatedType as getDiscriminatedType2, isDiscriminatedUnion as isDiscriminatedUnion2 } from "@dxos/effect";
1134
1145
  import { mx as mx6 } from "@dxos/react-ui-theme";
1135
1146
  import { getSchemaProperties as getSchemaProperties2 } from "@dxos/schema";
1136
1147
  import { isTruthy } from "@dxos/util";
1137
1148
 
1138
1149
  // src/util/field.ts
1139
- import { FormatEnum, GeoLocation as GeoLocation2, TypeEnum } from "@dxos/echo-schema";
1140
- var parseValue = ({ type, format, value }) => {
1141
- if (value === void 0 || value === null || value === "") {
1150
+ import { FormatEnum, GeoLocation as GeoLocation2, TypeEnum } from "@dxos/echo/internal";
1151
+ var parseValue = ({ type, format, value: value2 }) => {
1152
+ if (value2 === void 0 || value2 === null || value2 === "") {
1142
1153
  return void 0;
1143
1154
  }
1144
1155
  const parseScalar = (type2) => {
1145
1156
  switch (type2) {
1146
1157
  case TypeEnum.Boolean: {
1147
- if (typeof value === "string") {
1148
- const lowercaseValue = value.toLowerCase();
1158
+ if (typeof value2 === "string") {
1159
+ const lowercaseValue = value2.toLowerCase();
1149
1160
  if (lowercaseValue === "0" || lowercaseValue === "false") {
1150
1161
  return false;
1151
1162
  } else if (lowercaseValue === "1" || lowercaseValue === "true") {
1152
1163
  return true;
1153
1164
  }
1154
1165
  }
1155
- return Boolean(value);
1166
+ return Boolean(value2);
1156
1167
  }
1157
1168
  case TypeEnum.Number: {
1158
- const cleaned = typeof value === "string" ? value.replace(/[^0-9.-]+/g, "") : value;
1169
+ const cleaned = typeof value2 === "string" ? value2.replace(/[^0-9.-]+/g, "") : value2;
1159
1170
  const num = Number(cleaned);
1160
1171
  return Number.isNaN(num) ? null : num;
1161
1172
  }
1162
1173
  case TypeEnum.String:
1163
1174
  case TypeEnum.Ref:
1164
- return String(value);
1175
+ return String(value2);
1165
1176
  default: {
1166
- return value;
1177
+ return value2;
1167
1178
  }
1168
1179
  }
1169
1180
  };
@@ -1187,12 +1198,12 @@ var parseValue = ({ type, format, value }) => {
1187
1198
  case FormatEnum.Date:
1188
1199
  case FormatEnum.Time:
1189
1200
  case FormatEnum.Timestamp: {
1190
- const date = new Date(value);
1201
+ const date = new Date(value2);
1191
1202
  return isNaN(date.getTime()) ? null : date;
1192
1203
  }
1193
1204
  case FormatEnum.GeoPoint: {
1194
- if (typeof value === "string") {
1195
- const cleaned = value.replace(/[^0-9.,-]+/g, "");
1205
+ if (typeof value2 === "string") {
1206
+ const cleaned = value2.replace(/[^0-9.,-]+/g, "");
1196
1207
  const parts = cleaned.split(",");
1197
1208
  if (parts.length === 2) {
1198
1209
  const lat = parseFloat(parts[0]);
@@ -1211,7 +1222,7 @@ var parseValue = ({ type, format, value }) => {
1211
1222
  ];
1212
1223
  }
1213
1224
  default: {
1214
- return value;
1225
+ return value2;
1215
1226
  }
1216
1227
  }
1217
1228
  };
@@ -1258,19 +1269,19 @@ var pathNotUniqueError = (path) => ({
1258
1269
 
1259
1270
  // src/util/formatting.ts
1260
1271
  import { format as formatDate } from "date-fns/format";
1261
- import { FormatEnum as FormatEnum2, GeoLocation as GeoLocation3, TypeEnum as TypeEnum2 } from "@dxos/echo-schema";
1262
- var formatForDisplay = ({ type, format, value, locale = void 0 }) => {
1272
+ import { FormatEnum as FormatEnum2, GeoLocation as GeoLocation3, TypeEnum as TypeEnum2 } from "@dxos/echo/internal";
1273
+ var formatForDisplay = ({ type, format, value: value2, locale = void 0 }) => {
1263
1274
  const formatScalar = (type2) => {
1264
1275
  switch (type2) {
1265
1276
  case TypeEnum2.Boolean:
1266
- return value.toLocaleString().toUpperCase();
1277
+ return value2.toLocaleString().toUpperCase();
1267
1278
  case TypeEnum2.Number:
1268
- return value.toLocaleString(locale);
1279
+ return value2.toLocaleString(locale);
1269
1280
  case TypeEnum2.String:
1270
1281
  case TypeEnum2.Ref:
1271
- return String(value);
1282
+ return String(value2);
1272
1283
  default: {
1273
- return String(value);
1284
+ return String(value2);
1274
1285
  }
1275
1286
  }
1276
1287
  };
@@ -1289,10 +1300,10 @@ var formatForDisplay = ({ type, format, value, locale = void 0 }) => {
1289
1300
  return formatScalar(TypeEnum2.String);
1290
1301
  }
1291
1302
  case FormatEnum2.Percent: {
1292
- return `${value * 100}%`;
1303
+ return `${value2 * 100}%`;
1293
1304
  }
1294
1305
  case FormatEnum2.Currency: {
1295
- return value.toLocaleString(locale, {
1306
+ return value2.toLocaleString(locale, {
1296
1307
  style: "currency",
1297
1308
  currency: "USD",
1298
1309
  minimumFractionDigits: 2,
@@ -1301,53 +1312,53 @@ var formatForDisplay = ({ type, format, value, locale = void 0 }) => {
1301
1312
  }
1302
1313
  case FormatEnum2.Date: {
1303
1314
  try {
1304
- return formatDate(new Date(value), "yyyy-MM-dd");
1315
+ return formatDate(new Date(value2), "yyyy-MM-dd");
1305
1316
  } catch (error) {
1306
1317
  return "Invalid Date";
1307
1318
  }
1308
1319
  }
1309
1320
  case FormatEnum2.Time: {
1310
1321
  try {
1311
- return formatDate(new Date(value), "HH:mm:ss");
1322
+ return formatDate(new Date(value2), "HH:mm:ss");
1312
1323
  } catch (error) {
1313
1324
  return "Invalid Time";
1314
1325
  }
1315
1326
  }
1316
1327
  case FormatEnum2.DateTime: {
1317
1328
  try {
1318
- return formatDate(new Date(value), "yyyy-MM-dd HH:mm:ss");
1329
+ return formatDate(new Date(value2), "yyyy-MM-dd HH:mm:ss");
1319
1330
  } catch (error) {
1320
1331
  return "Invalid DateTime";
1321
1332
  }
1322
1333
  }
1323
1334
  case FormatEnum2.GeoPoint: {
1324
- if (value === null || value === void 0) {
1335
+ if (value2 === null || value2 === void 0) {
1325
1336
  return "";
1326
1337
  }
1327
- if (Array.isArray(value) && value.length >= 2 && value.every(Number.isFinite)) {
1328
- const { latitude, longitude } = GeoLocation3.fromGeoPoint(value);
1338
+ if (Array.isArray(value2) && value2.length >= 2 && value2.every(Number.isFinite)) {
1339
+ const { latitude, longitude } = GeoLocation3.fromGeoPoint(value2);
1329
1340
  return `${latitude},${longitude}`;
1330
1341
  }
1331
- return String(value);
1342
+ return String(value2);
1332
1343
  }
1333
1344
  default: {
1334
- if (value === null || value === "undefined") {
1345
+ if (value2 === null || value2 === "undefined") {
1335
1346
  return "";
1336
1347
  }
1337
- return String(value);
1348
+ return String(value2);
1338
1349
  }
1339
1350
  }
1340
1351
  };
1341
- var formatForEditing = ({ type, format, value, locale = void 0 }) => {
1352
+ var formatForEditing = ({ type, format, value: value2, locale = void 0 }) => {
1342
1353
  const formatScalar = (type2) => {
1343
1354
  switch (type2) {
1344
1355
  case TypeEnum2.Boolean:
1345
1356
  case TypeEnum2.Number:
1346
1357
  case TypeEnum2.String:
1347
1358
  case TypeEnum2.Ref:
1348
- return String(value);
1359
+ return String(value2);
1349
1360
  default:
1350
- return String(value);
1361
+ return String(value2);
1351
1362
  }
1352
1363
  };
1353
1364
  if (!format) {
@@ -1361,50 +1372,49 @@ var formatForEditing = ({ type, format, value, locale = void 0 }) => {
1361
1372
  return formatScalar(type);
1362
1373
  }
1363
1374
  case FormatEnum2.Percent: {
1364
- return String(value * 100);
1375
+ return String(value2 * 100);
1365
1376
  }
1366
1377
  case FormatEnum2.Currency: {
1367
- return String(value);
1378
+ return String(value2);
1368
1379
  }
1369
1380
  case FormatEnum2.DateTime: {
1370
- const date = new Date(value);
1381
+ const date = new Date(value2);
1371
1382
  return date.toISOString();
1372
1383
  }
1373
1384
  case FormatEnum2.Date: {
1374
- const date = new Date(value);
1385
+ const date = new Date(value2);
1375
1386
  return date.toISOString().split("T")[0];
1376
1387
  }
1377
1388
  case FormatEnum2.Time: {
1378
- const date = new Date(value);
1389
+ const date = new Date(value2);
1379
1390
  return date.toISOString().split("T")[1].split(".")[0];
1380
1391
  }
1381
1392
  case FormatEnum2.GeoPoint: {
1382
- if (value === null || value === void 0) {
1393
+ if (value2 === null || value2 === void 0) {
1383
1394
  return "";
1384
1395
  }
1385
- if (Array.isArray(value) && value.length >= 2 && value.every(Number.isFinite)) {
1386
- const { latitude, longitude } = GeoLocation3.fromGeoPoint(value);
1396
+ if (Array.isArray(value2) && value2.length >= 2 && value2.every(Number.isFinite)) {
1397
+ const { latitude, longitude } = GeoLocation3.fromGeoPoint(value2);
1387
1398
  return `${latitude},${longitude}`;
1388
1399
  }
1389
- return String(value);
1400
+ return String(value2);
1390
1401
  }
1391
1402
  default: {
1392
- return String(value);
1403
+ return String(value2);
1393
1404
  }
1394
1405
  }
1395
1406
  };
1396
1407
 
1397
1408
  // src/util/refs.ts
1398
- import { FormatEnum as FormatEnum3, ReferenceAnnotationId } from "@dxos/echo-schema";
1409
+ import { FormatEnum as FormatEnum3, ReferenceAnnotationId } from "@dxos/echo/internal";
1399
1410
  import { findAnnotation } from "@dxos/effect";
1400
1411
 
1401
1412
  // src/util/schema.ts
1402
- import { SchemaAST as SchemaAST2 } from "effect";
1413
+ import * as SchemaAST2 from "effect/SchemaAST";
1403
1414
  import { findNode } from "@dxos/effect";
1404
1415
  var findArrayElementType = (ast) => {
1405
1416
  const tupleType = findNode(ast, SchemaAST2.isTupleType);
1406
- const elementType = tupleType?.rest[0]?.type;
1407
- return elementType;
1417
+ return tupleType?.rest[0]?.type;
1408
1418
  };
1409
1419
 
1410
1420
  // src/util/refs.ts
@@ -1433,9 +1443,10 @@ var getRefProps = (property) => {
1433
1443
 
1434
1444
  // src/components/Form/ArrayField.tsx
1435
1445
  import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
1436
- import { SchemaAST as SchemaAST3, pipe } from "effect";
1437
- import { capitalize } from "effect/String";
1438
- import React9, { Fragment, useCallback as useCallback7 } from "react";
1446
+ import * as Function from "effect/Function";
1447
+ import * as SchemaAST3 from "effect/SchemaAST";
1448
+ import * as String2 from "effect/String";
1449
+ import React9, { Fragment, useCallback as useCallback8 } from "react";
1439
1450
  import { SimpleType, findNode as findNode2, getDiscriminatedType, isDiscriminatedUnion } from "@dxos/effect";
1440
1451
  import { invariant as invariant2 } from "@dxos/invariant";
1441
1452
  import { IconButton as IconButton3, useTranslation as useTranslation6 } from "@dxos/react-ui";
@@ -1449,14 +1460,14 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
1449
1460
  const values = useFormValues(path ?? []) ?? [];
1450
1461
  invariant2(Array.isArray(values), `Values at path ${path?.join(".")} must be an array.`, {
1451
1462
  F: __dxlog_file3,
1452
- L: 36,
1463
+ L: 37,
1453
1464
  S: void 0,
1454
1465
  A: [
1455
1466
  "Array.isArray(values)",
1456
1467
  "`Values at path ${path?.join('.')} must be an array.`"
1457
1468
  ]
1458
1469
  });
1459
- const label = title ?? pipe(name, capitalize);
1470
+ const label = title ?? Function.pipe(name, String2.capitalize);
1460
1471
  const elementType = findArrayElementType(ast);
1461
1472
  const getDefaultObjectValue = (typeNode) => {
1462
1473
  const baseNode = findNode2(typeNode, isDiscriminatedUnion);
@@ -1470,7 +1481,7 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
1470
1481
  ]));
1471
1482
  };
1472
1483
  const getDefaultValue = () => type === "object" && elementType ? getDefaultObjectValue(elementType) : SimpleType.getDefaultValue(type);
1473
- const handleAdd = useCallback7(() => {
1484
+ const handleAdd = useCallback8(() => {
1474
1485
  inputProps.onValueChange(type, [
1475
1486
  ...values,
1476
1487
  getDefaultValue()
@@ -1481,7 +1492,7 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
1481
1492
  inputProps,
1482
1493
  values
1483
1494
  ]);
1484
- const handleRemove = useCallback7((index) => {
1495
+ const handleRemove = useCallback8((index) => {
1485
1496
  const newValues = values.filter((_, i) => i !== index);
1486
1497
  inputProps.onValueChange(type, newValues);
1487
1498
  }, [
@@ -1537,7 +1548,7 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
1537
1548
  };
1538
1549
 
1539
1550
  // src/components/Form/factory.tsx
1540
- import { FormatEnum as FormatEnum4 } from "@dxos/echo-schema";
1551
+ import { FormatEnum as FormatEnum4 } from "@dxos/echo/internal";
1541
1552
  var getInputComponent = (type, format) => {
1542
1553
  switch (format) {
1543
1554
  case FormatEnum4.GeoPoint:
@@ -1556,45 +1567,40 @@ var getInputComponent = (type, format) => {
1556
1567
  };
1557
1568
 
1558
1569
  // src/components/Form/RefField.tsx
1559
- import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
1560
- import React10, { useCallback as useCallback8, useMemo as useMemo4, useState as useState5 } from "react";
1561
- import { Expando, Ref, ReferenceAnnotationId as ReferenceAnnotationId2, getTypeAnnotation } from "@dxos/echo-schema";
1570
+ import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
1571
+ import "@dxos/lit-ui/dx-tag-picker.pcss";
1572
+ import React11, { useCallback as useCallback10, useMemo as useMemo5 } from "react";
1573
+ import { Expando, Ref, ReferenceAnnotationId as ReferenceAnnotationId2, getTypeAnnotation } from "@dxos/echo/internal";
1562
1574
  import { findAnnotation as findAnnotation2 } from "@dxos/effect";
1563
1575
  import { DXN } from "@dxos/keys";
1564
1576
  import { DxAnchor, DxTagPickerItem } from "@dxos/lit-ui/react";
1565
- import { Button as Button2, Icon as Icon2, Input as Input7, Popover, useTranslation as useTranslation7 } from "@dxos/react-ui";
1566
- import { PopoverCombobox } from "@dxos/react-ui-searchlist";
1577
+ import { Button as Button2, Icon as Icon3, Input as Input7, useTranslation as useTranslation8 } from "@dxos/react-ui";
1567
1578
  import { descriptionText, mx as mx5 } from "@dxos/react-ui-theme";
1568
1579
  import { isNonNullable as isNonNullable2 } from "@dxos/util";
1569
- var isRefSnapShot = (val) => {
1570
- return typeof val === "object" && typeof val?.["/"] === "string";
1571
- };
1572
- var RefField = ({ type, label, readonly, placeholder, inputOnly, array, ast, getValue: getValue3, createOptionLabel, createOptionIcon, onBlur, onCreate, createSchema, createInitialValuePath, onQueryRefOptions, onValueChange, ...restInputProps }) => {
1580
+
1581
+ // src/components/ObjectPicker/ObjectPicker.tsx
1582
+ import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
1583
+ import React10, { forwardRef, useCallback as useCallback9, useMemo as useMemo4, useState as useState5 } from "react";
1584
+ import { Icon as Icon2, Popover, useTranslation as useTranslation7 } from "@dxos/react-ui";
1585
+ import { Combobox } from "@dxos/react-ui-searchlist";
1586
+ var ObjectPickerContent = /* @__PURE__ */ forwardRef(({ options, selectedIds, createSchema, createOptionLabel, createOptionIcon, createInitialValuePath, onSelect, onCreate, ...props }, ref) => {
1573
1587
  var _effect = _useSignals10();
1574
1588
  try {
1575
1589
  const { t } = useTranslation7(translationKey);
1576
- const refTypeInfo = useMemo4(() => ast ? findAnnotation2(ast, ReferenceAnnotationId2) : void 0, [
1577
- ast
1578
- ]);
1579
- const { options: availableOptions, loading: _loading } = useQueryRefOptions({
1580
- refTypeInfo,
1581
- onQueryRefOptions
1582
- });
1583
- const [showForm, setShowForm] = useState5(false);
1584
1590
  const [searchString, setSearchString] = useState5("");
1585
- const handleFormSave = useCallback8((values) => {
1591
+ const [showForm, setShowForm] = useState5(false);
1592
+ const handleFormSave = useCallback9((values) => {
1586
1593
  onCreate?.(values);
1587
1594
  setShowForm(false);
1588
1595
  setSearchString("");
1589
1596
  }, [
1590
- refTypeInfo,
1591
1597
  onCreate
1592
1598
  ]);
1593
- const handleFormCancel = useCallback8(() => {
1599
+ const handleFormCancel = useCallback9(() => {
1594
1600
  setShowForm(false);
1595
1601
  setSearchString("");
1596
1602
  }, []);
1597
- const handleClick = useCallback8((event) => {
1603
+ const handleClick = useCallback9((event) => {
1598
1604
  if (createSchema && event.target.closest('[data-value="__create__"]')) {
1599
1605
  event.stopPropagation();
1600
1606
  event.preventDefault();
@@ -1603,7 +1609,7 @@ var RefField = ({ type, label, readonly, placeholder, inputOnly, array, ast, get
1603
1609
  }, [
1604
1610
  createSchema
1605
1611
  ]);
1606
- const handleKeyDown = useCallback8((event) => {
1612
+ const handleKeyDown = useCallback9((event) => {
1607
1613
  if (event.key === "Enter" && createSchema && event.currentTarget.querySelector('[role="option"][aria-selected="true"][data-value="__create__"]')) {
1608
1614
  event.stopPropagation();
1609
1615
  event.preventDefault();
@@ -1612,8 +1618,78 @@ var RefField = ({ type, label, readonly, placeholder, inputOnly, array, ast, get
1612
1618
  }, [
1613
1619
  createSchema
1614
1620
  ]);
1621
+ const labelById = useMemo4(() => options.reduce((acc, option) => {
1622
+ acc[option.id.toLowerCase()] = option.label.toLowerCase();
1623
+ return acc;
1624
+ }, {}), [
1625
+ options
1626
+ ]);
1627
+ return /* @__PURE__ */ React10.createElement(Combobox.Content, {
1628
+ ...props,
1629
+ ref,
1630
+ filter: (value2, search) => value2 === "__create__" || labelById[value2]?.includes(search.toLowerCase()) ? 1 : 0,
1631
+ onClickCapture: handleClick,
1632
+ onKeyDownCapture: handleKeyDown
1633
+ }, showForm && createSchema ? /* @__PURE__ */ React10.createElement(Popover.Viewport, null, /* @__PURE__ */ React10.createElement(Form, {
1634
+ schema: createSchema,
1635
+ values: createInitialValuePath ? {
1636
+ [createInitialValuePath]: searchString
1637
+ } : {},
1638
+ onSave: handleFormSave,
1639
+ onCancel: handleFormCancel,
1640
+ testId: "create-referenced-object-form"
1641
+ })) : /* @__PURE__ */ React10.createElement(React10.Fragment, null, /* @__PURE__ */ React10.createElement(Combobox.Input, {
1642
+ placeholder: t("ref field combobox input placeholder"),
1643
+ value: searchString,
1644
+ onValueChange: setSearchString,
1645
+ autoFocus: true
1646
+ }), /* @__PURE__ */ React10.createElement(Combobox.List, null, options.map((option) => /* @__PURE__ */ React10.createElement(Combobox.Item, {
1647
+ key: option.id,
1648
+ value: option.id,
1649
+ onSelect: () => onSelect(option.id),
1650
+ classNames: "flex items-center gap-2"
1651
+ }, /* @__PURE__ */ React10.createElement("span", {
1652
+ className: "grow"
1653
+ }, option.label), selectedIds?.includes(option.id) && /* @__PURE__ */ React10.createElement(Icon2, {
1654
+ icon: "ph--check--regular"
1655
+ }))), searchString.length > 0 && createOptionLabel && createOptionIcon && createSchema && onCreate && /* @__PURE__ */ React10.createElement(Combobox.Item, {
1656
+ value: "__create__",
1657
+ classNames: "flex items-center gap-2"
1658
+ }, /* @__PURE__ */ React10.createElement(Icon2, {
1659
+ icon: createOptionIcon
1660
+ }), t(createOptionLabel[0], {
1661
+ ns: createOptionLabel[1].ns,
1662
+ text: searchString
1663
+ })))), /* @__PURE__ */ React10.createElement(Combobox.Arrow, null));
1664
+ } finally {
1665
+ _effect.f();
1666
+ }
1667
+ });
1668
+ ObjectPickerContent.displayName = "ObjectPickerContent";
1669
+ var ObjectPicker = {
1670
+ Root: Combobox.Root,
1671
+ Trigger: Combobox.Trigger,
1672
+ VirtualTrigger: Combobox.VirtualTrigger,
1673
+ Content: ObjectPickerContent
1674
+ };
1675
+
1676
+ // src/components/Form/RefField.tsx
1677
+ var isRefSnapShot = (val) => {
1678
+ return typeof val === "object" && typeof val?.["/"] === "string";
1679
+ };
1680
+ var RefField = ({ type, label, readonly, placeholder, inputOnly, array, ast, getValue: getValue3, createOptionLabel, createOptionIcon, onBlur, onCreate, createSchema, createInitialValuePath, onQueryRefOptions, onValueChange, ...restInputProps }) => {
1681
+ var _effect = _useSignals11();
1682
+ try {
1683
+ const { t } = useTranslation8(translationKey);
1684
+ const refTypeInfo = useMemo5(() => ast ? findAnnotation2(ast, ReferenceAnnotationId2) : void 0, [
1685
+ ast
1686
+ ]);
1687
+ const { options: availableOptions, update: updateOptions, loading: _loading } = useQueryRefOptions({
1688
+ refTypeInfo,
1689
+ onQueryRefOptions
1690
+ });
1615
1691
  if (refTypeInfo && refTypeInfo?.typename === getTypeAnnotation(Expando)?.typename || !onQueryRefOptions) {
1616
- return /* @__PURE__ */ React10.createElement(RefFieldFallback, {
1692
+ return /* @__PURE__ */ React11.createElement(RefFieldFallback, {
1617
1693
  type,
1618
1694
  label,
1619
1695
  placeholder,
@@ -1625,7 +1701,7 @@ var RefField = ({ type, label, readonly, placeholder, inputOnly, array, ast, get
1625
1701
  ...restInputProps
1626
1702
  });
1627
1703
  }
1628
- const handleGetValue = useCallback8(() => {
1704
+ const handleGetValue = useCallback10(() => {
1629
1705
  const formValue = getValue3();
1630
1706
  const unknownToRefOption = (val) => {
1631
1707
  const isRef = Ref.isRef(val);
@@ -1653,7 +1729,7 @@ var RefField = ({ type, label, readonly, placeholder, inputOnly, array, ast, get
1653
1729
  availableOptions,
1654
1730
  array
1655
1731
  ]);
1656
- const handleUpdate = useCallback8((ids) => {
1732
+ const handleUpdate = useCallback10((ids) => {
1657
1733
  if (ids.length === 0) {
1658
1734
  onValueChange("object", void 0);
1659
1735
  return;
@@ -1676,21 +1752,22 @@ var RefField = ({ type, label, readonly, placeholder, inputOnly, array, ast, get
1676
1752
  array,
1677
1753
  onValueChange
1678
1754
  ]);
1755
+ const handleCreate = useCallback10((values) => {
1756
+ onCreate?.(values);
1757
+ updateOptions();
1758
+ }, [
1759
+ onCreate,
1760
+ updateOptions
1761
+ ]);
1679
1762
  if (!refTypeInfo) {
1680
1763
  return null;
1681
1764
  }
1682
1765
  const { status, error } = restInputProps.getStatus();
1683
1766
  const items = handleGetValue();
1684
- const selectedIds = useMemo4(() => items.map((i) => i.id), [
1767
+ const selectedIds = useMemo5(() => items.map((i) => i.id), [
1685
1768
  items
1686
1769
  ]);
1687
- const labelById = useMemo4(() => availableOptions.reduce((acc, option) => {
1688
- acc[option.id.toLowerCase()] = option.label.toLowerCase();
1689
- return acc;
1690
- }, {}), [
1691
- availableOptions
1692
- ]);
1693
- const toggleSelect = useCallback8((id) => {
1770
+ const toggleSelect = useCallback10((id) => {
1694
1771
  if (array) {
1695
1772
  const nextIds = selectedIds.includes(id) ? selectedIds.filter((x) => x !== id) : [
1696
1773
  ...selectedIds,
@@ -1711,28 +1788,28 @@ var RefField = ({ type, label, readonly, placeholder, inputOnly, array, ast, get
1711
1788
  selectedIds,
1712
1789
  handleUpdate
1713
1790
  ]);
1714
- return readonly && items.length < 1 ? null : /* @__PURE__ */ React10.createElement(Input7.Root, {
1791
+ return readonly && items.length < 1 ? null : /* @__PURE__ */ React11.createElement(Input7.Root, {
1715
1792
  validationValence: status
1716
- }, !inputOnly && /* @__PURE__ */ React10.createElement(InputHeader, {
1793
+ }, !inputOnly && /* @__PURE__ */ React11.createElement(InputHeader, {
1717
1794
  error,
1718
1795
  label
1719
- }), /* @__PURE__ */ React10.createElement("div", {
1796
+ }), /* @__PURE__ */ React11.createElement("div", {
1720
1797
  "data-no-submit": true
1721
- }, readonly ? items.length < 1 ? /* @__PURE__ */ React10.createElement("p", {
1798
+ }, readonly ? items.length < 1 ? /* @__PURE__ */ React11.createElement("p", {
1722
1799
  className: mx5(descriptionText, "mbe-2")
1723
- }, t("empty readonly ref field label")) : items.map((item) => /* @__PURE__ */ React10.createElement(DxAnchor, {
1800
+ }, t("empty readonly ref field label")) : items.map((item) => /* @__PURE__ */ React11.createElement(DxAnchor, {
1724
1801
  key: item.id,
1725
1802
  refid: item.id,
1726
1803
  rootclassname: "mie-1"
1727
- }, item.label)) : /* @__PURE__ */ React10.createElement(PopoverCombobox.Root, null, /* @__PURE__ */ React10.createElement(PopoverCombobox.Trigger, {
1804
+ }, item.label)) : /* @__PURE__ */ React11.createElement(ObjectPicker.Root, null, /* @__PURE__ */ React11.createElement(ObjectPicker.Trigger, {
1728
1805
  asChild: true
1729
- }, /* @__PURE__ */ React10.createElement(Button2, {
1806
+ }, /* @__PURE__ */ React11.createElement(Button2, {
1730
1807
  variant: "ghost",
1731
1808
  classNames: "is-full text-start gap-2"
1732
- }, /* @__PURE__ */ React10.createElement("div", {
1809
+ }, /* @__PURE__ */ React11.createElement("div", {
1733
1810
  role: "none",
1734
1811
  className: "grow"
1735
- }, items?.length ? items?.map((item) => /* @__PURE__ */ React10.createElement(DxTagPickerItem, {
1812
+ }, items?.length ? items?.map((item) => /* @__PURE__ */ React11.createElement(DxTagPickerItem, {
1736
1813
  key: item.id,
1737
1814
  itemId: item.id,
1738
1815
  label: item.label,
@@ -1745,54 +1822,29 @@ var RefField = ({ type, label, readonly, placeholder, inputOnly, array, ast, get
1745
1822
  toggleSelect(item.id);
1746
1823
  }
1747
1824
  }
1748
- })) : /* @__PURE__ */ React10.createElement("span", {
1825
+ })) : /* @__PURE__ */ React11.createElement("span", {
1749
1826
  className: "text-description"
1750
1827
  }, placeholder ?? t("ref field placeholder", {
1751
1828
  count: array ? 99 : 1
1752
- }))), /* @__PURE__ */ React10.createElement(Icon2, {
1829
+ }))), /* @__PURE__ */ React11.createElement(Icon3, {
1753
1830
  size: 3,
1754
1831
  icon: "ph--caret-down--bold"
1755
- }))), /* @__PURE__ */ React10.createElement(PopoverCombobox.Content, {
1756
- filter: (value, search) => value === "__create__" || labelById[value]?.includes(search.toLowerCase()) ? 1 : 0,
1757
- onClickCapture: handleClick,
1758
- onKeyDownCapture: handleKeyDown
1759
- }, showForm && createSchema ? /* @__PURE__ */ React10.createElement(Popover.Viewport, null, /* @__PURE__ */ React10.createElement(Form, {
1760
- schema: createSchema,
1761
- values: createInitialValuePath ? {
1762
- [createInitialValuePath]: searchString
1763
- } : {},
1764
- onSave: handleFormSave,
1765
- onCancel: handleFormCancel,
1766
- testId: "create-referenced-object-form"
1767
- })) : /* @__PURE__ */ React10.createElement(React10.Fragment, null, /* @__PURE__ */ React10.createElement(PopoverCombobox.Input, {
1768
- placeholder: t("ref field combobox input placeholder"),
1769
- value: searchString,
1770
- onValueChange: (v) => setSearchString(v),
1771
- autoFocus: true
1772
- }), /* @__PURE__ */ React10.createElement(PopoverCombobox.List, null, availableOptions.map((option) => /* @__PURE__ */ React10.createElement(PopoverCombobox.Item, {
1773
- key: option.id,
1774
- value: option.id,
1775
- onSelect: () => toggleSelect(option.id),
1776
- classNames: "flex items-center gap-2"
1777
- }, /* @__PURE__ */ React10.createElement("span", {
1778
- className: "grow"
1779
- }, option.label), selectedIds.includes(option.id) && /* @__PURE__ */ React10.createElement(Icon2, {
1780
- icon: "ph--check--regular"
1781
- }))), searchString.length > 0 && createOptionLabel && createOptionIcon && createSchema && /* @__PURE__ */ React10.createElement(PopoverCombobox.Item, {
1782
- value: "__create__",
1783
- classNames: "flex items-center gap-2"
1784
- }, /* @__PURE__ */ React10.createElement(Icon2, {
1785
- icon: createOptionIcon
1786
- }), t(createOptionLabel[0], {
1787
- ns: createOptionLabel[1].ns,
1788
- text: searchString
1789
- })))), /* @__PURE__ */ React10.createElement(PopoverCombobox.Arrow, null)))), inputOnly && /* @__PURE__ */ React10.createElement(Input7.DescriptionAndValidation, null, error));
1832
+ }))), /* @__PURE__ */ React11.createElement(ObjectPicker.Content, {
1833
+ options: availableOptions,
1834
+ selectedIds,
1835
+ onSelect: toggleSelect,
1836
+ createSchema,
1837
+ createOptionLabel,
1838
+ createOptionIcon,
1839
+ createInitialValuePath,
1840
+ onCreate: handleCreate
1841
+ }))), inputOnly && /* @__PURE__ */ React11.createElement(Input7.DescriptionAndValidation, null, error));
1790
1842
  } finally {
1791
1843
  _effect.f();
1792
1844
  }
1793
1845
  };
1794
1846
  var RefFieldFallback = ({ type, label, readonly, placeholder, inputOnly, getValue: getValue3, onValueChange, ...restInputProps }) => {
1795
- var _effect = _useSignals10();
1847
+ var _effect = _useSignals11();
1796
1848
  try {
1797
1849
  const handleOnValueChange = (_type, dxnString) => {
1798
1850
  const dxn = DXN.tryParse(dxnString);
@@ -1814,7 +1866,7 @@ var RefFieldFallback = ({ type, label, readonly, placeholder, inputOnly, getValu
1814
1866
  }
1815
1867
  return void 0;
1816
1868
  };
1817
- return /* @__PURE__ */ React10.createElement(TextInput, {
1869
+ return /* @__PURE__ */ React11.createElement(TextInput, {
1818
1870
  type,
1819
1871
  label,
1820
1872
  readonly,
@@ -1831,15 +1883,15 @@ var RefFieldFallback = ({ type, label, readonly, placeholder, inputOnly, getValu
1831
1883
 
1832
1884
  // src/components/Form/FormContent.tsx
1833
1885
  var FormField = ({ property, path, readonly, inline, projection, onQueryRefOptions, createOptionLabel, createOptionIcon, onCreate, createSchema, createInitialValuePath, lookupComponent, Custom }) => {
1834
- var _effect = _useSignals11();
1886
+ var _effect = _useSignals12();
1835
1887
  try {
1836
1888
  const { ast, name, type, format, title, description, options, examples, array } = property;
1837
1889
  const inputProps = useInputProps(path);
1838
- const label = useMemo5(() => title ?? pipe2(name, capitalize2), [
1890
+ const label = useMemo6(() => title ?? Function2.pipe(name, StringEffect.capitalize), [
1839
1891
  title,
1840
1892
  name
1841
1893
  ]);
1842
- const placeholder = useMemo5(() => examples?.length ? `Example: "${examples[0]}"` : description, [
1894
+ const placeholder = useMemo6(() => examples?.length ? `Example: "${examples[0]}"` : description, [
1843
1895
  examples,
1844
1896
  description
1845
1897
  ]);
@@ -1861,7 +1913,7 @@ var FormField = ({ property, path, readonly, inline, projection, onQueryRefOptio
1861
1913
  const jsonPath = createJsonPath3(path ?? []);
1862
1914
  const CustomComponent = Custom?.[jsonPath];
1863
1915
  if (CustomComponent) {
1864
- return /* @__PURE__ */ React11.createElement(CustomComponent, {
1916
+ return /* @__PURE__ */ React12.createElement(CustomComponent, {
1865
1917
  type,
1866
1918
  format,
1867
1919
  label,
@@ -1873,7 +1925,7 @@ var FormField = ({ property, path, readonly, inline, projection, onQueryRefOptio
1873
1925
  }
1874
1926
  const refProps = getRefProps(property);
1875
1927
  if (refProps) {
1876
- return /* @__PURE__ */ React11.createElement(RefField, {
1928
+ return /* @__PURE__ */ React12.createElement(RefField, {
1877
1929
  ast: refProps.ast,
1878
1930
  array: refProps.isArray,
1879
1931
  type,
@@ -1892,7 +1944,7 @@ var FormField = ({ property, path, readonly, inline, projection, onQueryRefOptio
1892
1944
  });
1893
1945
  }
1894
1946
  if (array) {
1895
- return /* @__PURE__ */ React11.createElement(ArrayField, {
1947
+ return /* @__PURE__ */ React12.createElement(ArrayField, {
1896
1948
  property,
1897
1949
  path,
1898
1950
  inputProps,
@@ -1902,7 +1954,7 @@ var FormField = ({ property, path, readonly, inline, projection, onQueryRefOptio
1902
1954
  }
1903
1955
  const InputComponent = getInputComponent(type, format);
1904
1956
  if (InputComponent) {
1905
- return /* @__PURE__ */ React11.createElement(InputComponent, {
1957
+ return /* @__PURE__ */ React12.createElement(InputComponent, {
1906
1958
  type,
1907
1959
  format,
1908
1960
  label,
@@ -1913,7 +1965,7 @@ var FormField = ({ property, path, readonly, inline, projection, onQueryRefOptio
1913
1965
  });
1914
1966
  }
1915
1967
  if (options) {
1916
- return /* @__PURE__ */ React11.createElement(SelectInput, {
1968
+ return /* @__PURE__ */ React12.createElement(SelectInput, {
1917
1969
  type,
1918
1970
  format,
1919
1971
  readonly,
@@ -1931,9 +1983,9 @@ var FormField = ({ property, path, readonly, inline, projection, onQueryRefOptio
1931
1983
  const baseNode = findNode3(ast, isDiscriminatedUnion2);
1932
1984
  const typeLiteral = baseNode ? getDiscriminatedType2(baseNode, inputProps.getValue()) : findNode3(ast, SchemaAST4.isTypeLiteral);
1933
1985
  if (typeLiteral) {
1934
- return /* @__PURE__ */ React11.createElement(React11.Fragment, null, !inline && /* @__PURE__ */ React11.createElement("h3", {
1986
+ return /* @__PURE__ */ React12.createElement(React12.Fragment, null, !inline && /* @__PURE__ */ React12.createElement("h3", {
1935
1987
  className: mx6("text-lg mlb-inputSpacingBlock first:mbs-0")
1936
- }, label), /* @__PURE__ */ React11.createElement(FormFields, {
1988
+ }, label), /* @__PURE__ */ React12.createElement(FormFields, {
1937
1989
  schema: Schema.make(typeLiteral),
1938
1990
  path,
1939
1991
  readonly,
@@ -1952,11 +2004,11 @@ var FormField = ({ property, path, readonly, inline, projection, onQueryRefOptio
1952
2004
  _effect.f();
1953
2005
  }
1954
2006
  };
1955
- var FormFields = /* @__PURE__ */ forwardRef(({ classNames, schema, path, filter, sort, projection, readonly, lookupComponent, Custom, onQueryRefOptions, ...props }, forwardRef3) => {
1956
- var _effect = _useSignals11();
2007
+ var FormFields = /* @__PURE__ */ forwardRef2(({ classNames, schema, path, filter, sort, projection, readonly, lookupComponent, Custom, onQueryRefOptions, ...props }, forwardRef4) => {
2008
+ var _effect = _useSignals12();
1957
2009
  try {
1958
2010
  const values = useFormValues(path);
1959
- const properties = useMemo5(() => {
2011
+ const properties = useMemo6(() => {
1960
2012
  const props2 = getSchemaProperties2(schema.ast, values);
1961
2013
  if (projection) {
1962
2014
  const fieldProjections = projection.getFieldProjections();
@@ -1984,12 +2036,12 @@ var FormFields = /* @__PURE__ */ forwardRef(({ classNames, schema, path, filter,
1984
2036
  sort,
1985
2037
  projection?.fields
1986
2038
  ]);
1987
- return /* @__PURE__ */ React11.createElement("div", {
2039
+ return /* @__PURE__ */ React12.createElement("div", {
1988
2040
  role: "form",
1989
2041
  className: mx6("is-full", classNames),
1990
- ref: forwardRef3
2042
+ ref: forwardRef4
1991
2043
  }, properties.map((property) => {
1992
- return /* @__PURE__ */ React11.createElement(FormField, {
2044
+ return /* @__PURE__ */ React12.createElement(FormField, {
1993
2045
  key: property.name,
1994
2046
  property,
1995
2047
  path: [
@@ -2011,7 +2063,7 @@ var FormFields = /* @__PURE__ */ forwardRef(({ classNames, schema, path, filter,
2011
2063
 
2012
2064
  // src/components/Form/Form.tsx
2013
2065
  var Form = ({ classNames, testId, values: initialValues, autoFocus, readonly, autoSave, outerSpacing = true, schema, onCancel, onValuesChanged, onValidate, onSave, ...props }) => {
2014
- var _effect = _useSignals12();
2066
+ var _effect = _useSignals13();
2015
2067
  try {
2016
2068
  const formRef = useRef3(null);
2017
2069
  const { findFirstFocusable } = useFocusFinders();
@@ -2025,11 +2077,15 @@ var Form = ({ classNames, testId, values: initialValues, autoFocus, readonly, au
2025
2077
  }, [
2026
2078
  autoFocus
2027
2079
  ]);
2028
- const handleValid = useMemo6(() => autoSave ? onSave : void 0, [
2080
+ const handleValid = useCallback11(async (values, meta) => {
2081
+ if (autoSave) {
2082
+ await onSave?.(values, meta);
2083
+ }
2084
+ }, [
2029
2085
  autoSave,
2030
2086
  onSave
2031
2087
  ]);
2032
- return /* @__PURE__ */ React12.createElement(FormProvider, {
2088
+ return /* @__PURE__ */ React13.createElement(FormProvider, {
2033
2089
  formRef,
2034
2090
  schema,
2035
2091
  autoSave,
@@ -2038,11 +2094,11 @@ var Form = ({ classNames, testId, values: initialValues, autoFocus, readonly, au
2038
2094
  onValidate,
2039
2095
  onValid: handleValid,
2040
2096
  onSave
2041
- }, /* @__PURE__ */ React12.createElement("div", {
2097
+ }, /* @__PURE__ */ React13.createElement("div", {
2042
2098
  role: "none",
2043
2099
  className: "contents",
2044
2100
  "data-testid": testId
2045
- }, /* @__PURE__ */ React12.createElement(FormFields, {
2101
+ }, /* @__PURE__ */ React13.createElement(FormFields, {
2046
2102
  ...props,
2047
2103
  ref: formRef,
2048
2104
  classNames: [
@@ -2052,7 +2108,7 @@ var Form = ({ classNames, testId, values: initialValues, autoFocus, readonly, au
2052
2108
  ],
2053
2109
  readonly,
2054
2110
  schema
2055
- }), (onCancel || onSave) && !autoSave && !readonly && /* @__PURE__ */ React12.createElement(FormActions, {
2111
+ }), (onCancel || onSave) && !autoSave && !readonly && /* @__PURE__ */ React13.createElement(FormActions, {
2056
2112
  readonly,
2057
2113
  onCancel,
2058
2114
  outerSpacing
@@ -2065,9 +2121,9 @@ var Form = ({ classNames, testId, values: initialValues, autoFocus, readonly, au
2065
2121
  // src/components/FieldEditor/FieldEditor.tsx
2066
2122
  var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx";
2067
2123
  var FieldEditor = ({ readonly, projection, field, registry, onSave, onCancel, outerSpacing }) => {
2068
- var _effect = _useSignals13();
2124
+ var _effect = _useSignals14();
2069
2125
  try {
2070
- const { t } = useTranslation8(translationKey);
2126
+ const { t } = useTranslation9(translationKey);
2071
2127
  const [props, setProps] = useState6(projection.getFieldProjection(field.id).props);
2072
2128
  useEffect8(() => setProps(projection.getFieldProjection(field.id).props), [
2073
2129
  field,
@@ -2097,7 +2153,7 @@ var FieldEditor = ({ readonly, projection, field, registry, onSave, onCancel, ou
2097
2153
  const [{ fieldSchema }, setFieldSchema] = useState6({
2098
2154
  fieldSchema: getFormatSchema(props?.format)
2099
2155
  });
2100
- const handleValuesChanged = useCallback9((_props) => {
2156
+ const handleValuesChanged = useCallback12((_props) => {
2101
2157
  setFieldSchema((prev) => {
2102
2158
  const fieldSchema2 = getFormatSchema(_props.format);
2103
2159
  if (prev.fieldSchema === fieldSchema2) {
@@ -2134,7 +2190,7 @@ var FieldEditor = ({ readonly, projection, field, registry, onSave, onCancel, ou
2134
2190
  props.format,
2135
2191
  props.referenceSchema
2136
2192
  ]);
2137
- const handleValidate = useCallback9(({ property }) => {
2193
+ const handleValidate = useCallback12(({ property }) => {
2138
2194
  if (property && projection.fields.find((f) => f.path === property && f.path !== field.path)) {
2139
2195
  return [
2140
2196
  {
@@ -2147,7 +2203,7 @@ var FieldEditor = ({ readonly, projection, field, registry, onSave, onCancel, ou
2147
2203
  projection.fields,
2148
2204
  field
2149
2205
  ]);
2150
- const handleSave = useCallback9((props2) => {
2206
+ const handleSave = useCallback12((props2) => {
2151
2207
  projection.setFieldProjection({
2152
2208
  field,
2153
2209
  props: props2
@@ -2158,39 +2214,39 @@ var FieldEditor = ({ readonly, projection, field, registry, onSave, onCancel, ou
2158
2214
  field,
2159
2215
  onSave
2160
2216
  ]);
2161
- const handleCancel = useCallback9(() => {
2217
+ const handleCancel = useCallback12(() => {
2162
2218
  requestAnimationFrame(() => onCancel?.());
2163
2219
  onSave();
2164
2220
  }, [
2165
2221
  onSave
2166
2222
  ]);
2167
2223
  const custom = useMemo7(() => ({
2168
- ["format"]: (props2) => /* @__PURE__ */ React13.createElement(SelectInput, {
2224
+ ["format"]: (props2) => /* @__PURE__ */ React14.createElement(SelectInput, {
2169
2225
  ...props2,
2170
- options: FormatEnums.filter((value) => value !== FormatEnum5.None).map((value) => ({
2171
- value,
2172
- label: t(`format ${value}`)
2226
+ options: FormatEnums.filter((value2) => value2 !== FormatEnum5.None).map((value2) => ({
2227
+ value: value2,
2228
+ label: t(`format ${value2}`)
2173
2229
  }))
2174
2230
  }),
2175
- ["referenceSchema"]: (props2) => /* @__PURE__ */ React13.createElement(SelectInput, {
2231
+ ["referenceSchema"]: (props2) => /* @__PURE__ */ React14.createElement(SelectInput, {
2176
2232
  ...props2,
2177
2233
  options: schemas.map((schema) => ({
2178
2234
  value: schema.typename
2179
2235
  }))
2180
2236
  }),
2181
- ["referencePath"]: (props2) => /* @__PURE__ */ React13.createElement(SelectInput, {
2237
+ ["referencePath"]: (props2) => /* @__PURE__ */ React14.createElement(SelectInput, {
2182
2238
  ...props2,
2183
2239
  options: referenceSchema ? getSchemaProperties3(referenceSchema.ast).sort(sortProperties).map((p) => ({
2184
2240
  value: p.name
2185
2241
  })) : []
2186
2242
  }),
2187
- ["options"]: (props2) => /* @__PURE__ */ React13.createElement(SelectOptionInput, props2)
2243
+ ["options"]: (props2) => /* @__PURE__ */ React14.createElement(SelectOptionInput, props2)
2188
2244
  }), [
2189
2245
  t,
2190
2246
  schemas,
2191
2247
  referenceSchema
2192
2248
  ]);
2193
- const propIsNotType = useCallback9((props2) => props2.filter((p) => p.name !== "type"), []);
2249
+ const propIsNotType = useCallback12((props2) => props2.filter((p) => p.name !== "type"), []);
2194
2250
  if (!fieldSchema) {
2195
2251
  log3.warn("invalid format", {
2196
2252
  props
@@ -2202,7 +2258,7 @@ var FieldEditor = ({ readonly, projection, field, registry, onSave, onCancel, ou
2202
2258
  });
2203
2259
  return null;
2204
2260
  }
2205
- return /* @__PURE__ */ React13.createElement(Form, {
2261
+ return /* @__PURE__ */ React14.createElement(Form, {
2206
2262
  key: field.id,
2207
2263
  autoFocus: true,
2208
2264
  readonly,
@@ -2226,26 +2282,30 @@ var FieldEditor = ({ readonly, projection, field, registry, onSave, onCancel, ou
2226
2282
  };
2227
2283
 
2228
2284
  // src/components/ViewEditor/ViewEditor.tsx
2229
- import { useSignals as _useSignals14 } from "@preact-signals/safe-react/tracking";
2230
- import { Array as Array2, Match, Option, Schema as Schema2 } from "effect";
2231
- import React14, { forwardRef as forwardRef2, useCallback as useCallback10, useImperativeHandle, useMemo as useMemo8, useState as useState7 } from "react";
2232
- import { EchoSchema, Format, isMutable, toJsonSchema } from "@dxos/echo-schema";
2285
+ import { useSignals as _useSignals15 } from "@preact-signals/safe-react/tracking";
2286
+ import * as Array2 from "effect/Array";
2287
+ import * as Match from "effect/Match";
2288
+ import * as Option from "effect/Option";
2289
+ import * as Schema2 from "effect/Schema";
2290
+ import React15, { forwardRef as forwardRef3, useCallback as useCallback13, useImperativeHandle, useMemo as useMemo8, useState as useState7 } from "react";
2291
+ import { QueryAST } from "@dxos/echo";
2292
+ import { EchoSchema, Format, isMutable, toJsonSchema } from "@dxos/echo/internal";
2293
+ import { Filter as Filter2, Query } from "@dxos/echo-db";
2233
2294
  import { invariant as invariant3 } from "@dxos/invariant";
2234
- import { Callout, IconButton as IconButton4, Input as Input8, useDensityContext, useElevationContext, useThemeContext, useTranslation as useTranslation9 } from "@dxos/react-ui";
2235
- import { Editor, createBasicExtensions, createThemeExtensions } from "@dxos/react-ui-editor";
2295
+ import { Callout, IconButton as IconButton4, Input as Input8, useTranslation as useTranslation10 } from "@dxos/react-ui";
2296
+ import { QueryForm } from "@dxos/react-ui-components";
2236
2297
  import { List as List2 } from "@dxos/react-ui-list";
2237
2298
  import { cardSpacing as cardSpacing3 } from "@dxos/react-ui-stack";
2238
- import { inputTheme } from "@dxos/react-ui-theme";
2239
2299
  import { inputTextLabel, mx as mx7, subtleHover as subtleHover2 } from "@dxos/react-ui-theme";
2240
- import { FieldSchema, ProjectionModel, VIEW_FIELD_LIMIT, typenameFromQuery } from "@dxos/schema";
2300
+ import { FieldSchema, ProjectionModel, VIEW_FIELD_LIMIT, getTypenameFromQuery } from "@dxos/schema";
2241
2301
  var __dxlog_file5 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx";
2242
2302
  var listGrid = "grid grid-cols-[min-content_1fr_min-content_min-content_min-content]";
2243
2303
  var listItemGrid = "grid grid-cols-subgrid col-span-5";
2244
- var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode = "schema", registry, readonly, showHeading = false, onQueryChanged, onDelete, outerSpacing = true }, forwardedRef) => {
2245
- var _effect = _useSignals14();
2304
+ var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode = "schema", registry, readonly, showHeading = false, types, tags, onQueryChanged, onDelete, outerSpacing = true }, forwardedRef) => {
2305
+ var _effect = _useSignals15();
2246
2306
  try {
2247
2307
  const schemaReadonly = !isMutable(schema);
2248
- const { t } = useTranslation9(translationKey);
2308
+ const { t } = useTranslation10(translationKey);
2249
2309
  const projectionModel = useMemo8(() => {
2250
2310
  const jsonSchema = schema instanceof EchoSchema ? schema.jsonSchema : toJsonSchema(schema);
2251
2311
  return new ProjectionModel(jsonSchema, view.projection);
@@ -2257,13 +2317,6 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
2257
2317
  projectionModel
2258
2318
  ]);
2259
2319
  const [expandedField, setExpandedField] = useState7();
2260
- const serializedQuery = Match.value(mode).pipe(Match.when("schema", () => typenameFromQuery(view.query.ast)), Match.when("query", () => {
2261
- if (view.query.string) {
2262
- return view.query.string;
2263
- } else {
2264
- return "Serializing query AST is not currently supported.";
2265
- }
2266
- }), Match.exhaustive);
2267
2320
  const queueTarget = Match.value(view.query.ast).pipe(Match.when({
2268
2321
  type: "options"
2269
2322
  }, ({ options }) => {
@@ -2273,7 +2326,7 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
2273
2326
  const base = Schema2.Struct({
2274
2327
  query: mode === "schema" ? Format.URL.annotations({
2275
2328
  title: "Record type"
2276
- }) : Schema2.String.annotations({
2329
+ }) : QueryAST.Query.annotations({
2277
2330
  title: "Query"
2278
2331
  })
2279
2332
  });
@@ -2294,22 +2347,23 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
2294
2347
  ]);
2295
2348
  const viewValues = useMemo8(() => ({
2296
2349
  name: view.name,
2297
- query: serializedQuery,
2350
+ query: mode === "schema" ? getTypenameFromQuery(view.query.ast) : view.query.ast,
2298
2351
  target: queueTarget
2299
2352
  }), [
2300
2353
  view.name,
2301
- serializedQuery,
2354
+ mode,
2355
+ view.query.ast,
2302
2356
  queueTarget
2303
2357
  ]);
2304
- const handleToggleField = useCallback10((field) => {
2358
+ const handleToggleField = useCallback13((field) => {
2305
2359
  setExpandedField((prevExpandedFieldId) => prevExpandedFieldId === field.id ? void 0 : field.id);
2306
2360
  }, [
2307
2361
  readonly
2308
2362
  ]);
2309
- const handleAdd = useCallback10(() => {
2363
+ const handleAdd = useCallback13(() => {
2310
2364
  invariant3(!readonly, void 0, {
2311
2365
  F: __dxlog_file5,
2312
- L: 141,
2366
+ L: 131,
2313
2367
  S: void 0,
2314
2368
  A: [
2315
2369
  "!readonly",
@@ -2323,10 +2377,10 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
2323
2377
  projectionModel,
2324
2378
  readonly
2325
2379
  ]);
2326
- const handleUpdate = useCallback10((values) => {
2380
+ const handleUpdate = useCallback13((values) => {
2327
2381
  invariant3(!readonly, void 0, {
2328
2382
  F: __dxlog_file5,
2329
- L: 148,
2383
+ L: 138,
2330
2384
  S: void 0,
2331
2385
  A: [
2332
2386
  "!readonly",
@@ -2336,25 +2390,22 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
2336
2390
  requestAnimationFrame(() => {
2337
2391
  if ("name" in values && view.name !== values.name) {
2338
2392
  view.name = values.name;
2393
+ return;
2339
2394
  }
2340
- const queryChanged = serializedQuery !== values.query;
2341
- const targetValue = "target" in values ? values.target : void 0;
2342
- const targetChanged = "target" in values && values.target && queueTarget !== targetValue;
2343
- if ((queryChanged || targetChanged) && !readonly) {
2344
- onQueryChanged?.(values.query, targetValue);
2345
- }
2395
+ const query = mode === "schema" ? Query.select(Filter2.typename(values.query)).ast : values.query;
2396
+ onQueryChanged?.(query, values.target);
2346
2397
  });
2347
2398
  }, [
2348
- serializedQuery,
2349
2399
  onQueryChanged,
2350
2400
  readonly,
2351
2401
  view,
2352
- queueTarget
2402
+ queueTarget,
2403
+ mode
2353
2404
  ]);
2354
- const handleDelete = useCallback10((fieldId) => {
2405
+ const handleDelete = useCallback13((fieldId) => {
2355
2406
  invariant3(!readonly, void 0, {
2356
2407
  F: __dxlog_file5,
2357
- L: 168,
2408
+ L: 154,
2358
2409
  S: void 0,
2359
2410
  A: [
2360
2411
  "!readonly",
@@ -2370,10 +2421,10 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
2370
2421
  onDelete,
2371
2422
  readonly
2372
2423
  ]);
2373
- const handleMove = useCallback10((fromIndex, toIndex) => {
2424
+ const handleMove = useCallback13((fromIndex, toIndex) => {
2374
2425
  invariant3(!readonly, void 0, {
2375
2426
  F: __dxlog_file5,
2376
- L: 180,
2427
+ L: 166,
2377
2428
  S: void 0,
2378
2429
  A: [
2379
2430
  "!readonly",
@@ -2390,56 +2441,37 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
2390
2441
  view.projection.fields,
2391
2442
  readonly
2392
2443
  ]);
2393
- const handleClose = useCallback10(() => setExpandedField(void 0), []);
2394
- const handleHide = useCallback10((fieldId) => {
2444
+ const handleClose = useCallback13(() => setExpandedField(void 0), []);
2445
+ const handleHide = useCallback13((fieldId) => {
2395
2446
  setExpandedField(void 0);
2396
2447
  projectionModel.hideFieldProjection(fieldId);
2397
2448
  }, [
2398
2449
  projectionModel
2399
2450
  ]);
2400
- const handleShow = useCallback10((property) => {
2451
+ const handleShow = useCallback13((property) => {
2401
2452
  setExpandedField(void 0);
2402
2453
  projectionModel.showFieldProjection(property);
2403
2454
  }, [
2404
2455
  projectionModel
2405
2456
  ]);
2406
- const custom = useMemo8(() => mode === "query" ? {
2407
- ["query"]: (props) => {
2408
- const { themeMode } = useThemeContext();
2409
- const density = useDensityContext();
2410
- const elevation = useElevationContext();
2411
- const handleChange = useCallback10((text) => props.onValueChange("string", text), []);
2412
- const extensions = useMemo8(() => [
2413
- createBasicExtensions({
2414
- placeholder: t("query placeholder")
2415
- }),
2416
- createThemeExtensions({
2417
- themeMode
2418
- })
2419
- ], []);
2420
- return /* @__PURE__ */ React14.createElement(Input8.Root, null, /* @__PURE__ */ React14.createElement(InputHeader, {
2421
- label: props.label
2422
- }), /* @__PURE__ */ React14.createElement(Editor, {
2423
- classNames: mx7(inputTheme.input({
2424
- density,
2425
- elevation
2426
- }), "flex items-center", "focus-within:bg-focusSurface focus-within:border-separator focus-within:hover:bg-focusSurface"),
2427
- extensions,
2428
- value: props.getValue(),
2429
- onChange: handleChange
2430
- }));
2431
- }
2432
- } : {}, []);
2433
- return /* @__PURE__ */ React14.createElement("div", {
2457
+ const custom = useMemo8(() => mode === "query" ? customFields({
2458
+ types,
2459
+ tags
2460
+ }) : void 0, [
2461
+ types,
2462
+ tags,
2463
+ mode
2464
+ ]);
2465
+ return /* @__PURE__ */ React15.createElement("div", {
2434
2466
  role: "none",
2435
2467
  className: mx7(classNames)
2436
- }, schemaReadonly && mode === "schema" && /* @__PURE__ */ React14.createElement(Callout.Root, {
2468
+ }, schemaReadonly && mode === "schema" && /* @__PURE__ */ React15.createElement(Callout.Root, {
2437
2469
  valence: "info",
2438
2470
  classNames: [
2439
2471
  "mlb-cardSpacingBlock",
2440
2472
  outerSpacing && "mli-cardSpacingInline"
2441
2473
  ]
2442
- }, /* @__PURE__ */ React14.createElement(Callout.Title, null, t("system schema description"))), /* @__PURE__ */ React14.createElement(Form, {
2474
+ }, /* @__PURE__ */ React15.createElement(Callout.Title, null, t("system schema description"))), /* @__PURE__ */ React15.createElement(Form, {
2443
2475
  autoSave: true,
2444
2476
  schema: viewSchema,
2445
2477
  values: viewValues,
@@ -2447,51 +2479,51 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
2447
2479
  onSave: handleUpdate,
2448
2480
  outerSpacing,
2449
2481
  Custom: custom
2450
- }), /* @__PURE__ */ React14.createElement("div", {
2482
+ }), /* @__PURE__ */ React15.createElement("div", {
2451
2483
  role: "none",
2452
2484
  className: outerSpacing ? cardSpacing3 : "mlb-cardSpacingBlock"
2453
- }, /* @__PURE__ */ React14.createElement("h2", {
2485
+ }, /* @__PURE__ */ React15.createElement("h2", {
2454
2486
  className: mx7(inputTextLabel)
2455
- }, t("fields label")), /* @__PURE__ */ React14.createElement(List2.Root, {
2487
+ }, t("fields label")), /* @__PURE__ */ React15.createElement(List2.Root, {
2456
2488
  items: view.projection.fields,
2457
2489
  isItem: Schema2.is(FieldSchema),
2458
2490
  getId: (field) => field.id,
2459
2491
  onMove: readonly ? void 0 : handleMove,
2460
2492
  readonly
2461
- }, ({ items: fields }) => /* @__PURE__ */ React14.createElement(React14.Fragment, null, showHeading && /* @__PURE__ */ React14.createElement("h3", {
2493
+ }, ({ items: fields }) => /* @__PURE__ */ React15.createElement(React15.Fragment, null, showHeading && /* @__PURE__ */ React15.createElement("h3", {
2462
2494
  className: "text-sm"
2463
- }, t("field path label")), /* @__PURE__ */ React14.createElement("div", {
2495
+ }, t("field path label")), /* @__PURE__ */ React15.createElement("div", {
2464
2496
  role: "list",
2465
2497
  className: listGrid
2466
2498
  }, fields?.map((field) => {
2467
2499
  const hidden = field.visible === false;
2468
- return /* @__PURE__ */ React14.createElement(List2.Item, {
2500
+ return /* @__PURE__ */ React15.createElement(List2.Item, {
2469
2501
  key: field.id,
2470
2502
  item: field,
2471
2503
  classNames: listItemGrid,
2472
2504
  "aria-expanded": expandedField === field.id
2473
- }, /* @__PURE__ */ React14.createElement("div", {
2505
+ }, /* @__PURE__ */ React15.createElement("div", {
2474
2506
  role: "none",
2475
2507
  className: mx7(subtleHover2, listItemGrid, "rounded-sm cursor-pointer min-bs-10")
2476
- }, /* @__PURE__ */ React14.createElement(List2.ItemDragHandle, {
2508
+ }, /* @__PURE__ */ React15.createElement(List2.ItemDragHandle, {
2477
2509
  disabled: readonly
2478
- }), /* @__PURE__ */ React14.createElement(List2.ItemTitle, {
2510
+ }), /* @__PURE__ */ React15.createElement(List2.ItemTitle, {
2479
2511
  classNames: hidden && "text-subdued",
2480
2512
  onClick: () => handleToggleField(field)
2481
- }, field.path), /* @__PURE__ */ React14.createElement(List2.ItemButton, {
2513
+ }, field.path), /* @__PURE__ */ React15.createElement(List2.ItemButton, {
2482
2514
  label: t(hidden ? "show field label" : "hide field label"),
2483
2515
  "data-testid": hidden ? "show-field-button" : "hide-field-button",
2484
2516
  icon: hidden ? "ph--eye-closed--regular" : "ph--eye--regular",
2485
2517
  autoHide: false,
2486
2518
  disabled: readonly || !hidden && projectionModel.fields.length <= 1,
2487
2519
  onClick: () => hidden ? handleShow(field.path) : handleHide(field.id)
2488
- }), mode === "schema" && /* @__PURE__ */ React14.createElement(React14.Fragment, null, /* @__PURE__ */ React14.createElement(List2.ItemDeleteButton, {
2520
+ }), mode === "schema" && /* @__PURE__ */ React15.createElement(React15.Fragment, null, /* @__PURE__ */ React15.createElement(List2.ItemDeleteButton, {
2489
2521
  label: t("delete field label"),
2490
2522
  autoHide: false,
2491
2523
  disabled: readonly || schemaReadonly || view.projection.fields.length <= 1,
2492
2524
  onClick: () => handleDelete(field.id),
2493
2525
  "data-testid": "field.delete"
2494
- }), /* @__PURE__ */ React14.createElement(IconButton4, {
2526
+ }), /* @__PURE__ */ React15.createElement(IconButton4, {
2495
2527
  iconOnly: true,
2496
2528
  variant: "ghost",
2497
2529
  label: t("toggle expand label", {
@@ -2499,20 +2531,20 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
2499
2531
  }),
2500
2532
  icon: expandedField === field.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
2501
2533
  onClick: () => handleToggleField(field)
2502
- }))), expandedField === field.id && mode === "schema" && /* @__PURE__ */ React14.createElement("div", {
2534
+ }))), expandedField === field.id && mode === "schema" && /* @__PURE__ */ React15.createElement("div", {
2503
2535
  role: "none",
2504
2536
  className: "col-span-5 mbs-1 mbe-1 border border-separator rounded-md"
2505
- }, /* @__PURE__ */ React14.createElement(FieldEditor, {
2537
+ }, /* @__PURE__ */ React15.createElement(FieldEditor, {
2506
2538
  readonly: readonly || schemaReadonly ? "disabled-input" : false,
2507
2539
  projection: projectionModel,
2508
2540
  field,
2509
2541
  registry,
2510
2542
  onSave: handleClose
2511
2543
  })));
2512
- }))))), !readonly && !expandedField && mode === "schema" && /* @__PURE__ */ React14.createElement("div", {
2544
+ }))))), !readonly && !expandedField && mode === "schema" && /* @__PURE__ */ React15.createElement("div", {
2513
2545
  role: "none",
2514
2546
  className: outerSpacing ? cardSpacing3 : "mlb-cardSpacingBlock"
2515
- }, /* @__PURE__ */ React14.createElement(IconButton4, {
2547
+ }, /* @__PURE__ */ React15.createElement(IconButton4, {
2516
2548
  icon: "ph--plus--regular",
2517
2549
  label: t("button add property"),
2518
2550
  onClick: readonly ? void 0 : handleAdd,
@@ -2524,6 +2556,21 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
2524
2556
  _effect.f();
2525
2557
  }
2526
2558
  });
2559
+ var customFields = ({ types, tags }) => ({
2560
+ query: (props) => {
2561
+ const handleChange = useCallback13((query) => props.onValueChange("object", query.ast), [
2562
+ props.onValueChange
2563
+ ]);
2564
+ return /* @__PURE__ */ React15.createElement(Input8.Root, null, /* @__PURE__ */ React15.createElement(InputHeader, {
2565
+ label: props.label
2566
+ }), /* @__PURE__ */ React15.createElement(QueryForm, {
2567
+ initialQuery: props.getValue(),
2568
+ types,
2569
+ tags,
2570
+ onChange: handleChange
2571
+ }));
2572
+ }
2573
+ });
2527
2574
  export {
2528
2575
  BooleanInput,
2529
2576
  ControlFrame,
@@ -2542,6 +2589,7 @@ export {
2542
2589
  InputHeader,
2543
2590
  MarkdownInput,
2544
2591
  NumberInput,
2592
+ ObjectPicker,
2545
2593
  SelectInput,
2546
2594
  SelectOptionInput,
2547
2595
  TextInput,