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