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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +0 -1
  2. package/dist/lib/browser/index.mjs +538 -458
  3. package/dist/lib/browser/index.mjs.map +4 -4
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/node-esm/index.mjs +538 -458
  6. package/dist/lib/node-esm/index.mjs.map +4 -4
  7. package/dist/lib/node-esm/meta.json +1 -1
  8. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts +3 -3
  9. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
  10. package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts.map +1 -1
  11. package/dist/types/src/components/Form/Form.d.ts +13 -13
  12. package/dist/types/src/components/Form/Form.d.ts.map +1 -1
  13. package/dist/types/src/components/Form/Form.stories.d.ts +3 -3
  14. package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
  15. package/dist/types/src/components/Form/FormField.d.ts.map +1 -1
  16. package/dist/types/src/components/Form/FormFieldComponent.d.ts +0 -1
  17. package/dist/types/src/components/Form/FormFieldComponent.d.ts.map +1 -1
  18. package/dist/types/src/components/Form/FormFieldComponent.stories.d.ts +2 -2
  19. package/dist/types/src/components/Form/FormFieldComponent.stories.d.ts.map +1 -1
  20. package/dist/types/src/components/Form/FormFieldSet.d.ts +9 -10
  21. package/dist/types/src/components/Form/FormFieldSet.d.ts.map +1 -1
  22. package/dist/types/src/components/Form/fields/ArrayField.d.ts.map +1 -1
  23. package/dist/types/src/components/Form/fields/RefField.d.ts +6 -4
  24. package/dist/types/src/components/Form/fields/RefField.d.ts.map +1 -1
  25. package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts.map +1 -1
  26. package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts.map +1 -1
  27. package/dist/types/src/components/Settings/Settings.d.ts +56 -0
  28. package/dist/types/src/components/Settings/Settings.d.ts.map +1 -0
  29. package/dist/types/src/components/{ControlSection/ControlSection.stories.d.ts → Settings/Settings.stories.d.ts} +2 -8
  30. package/dist/types/src/components/Settings/Settings.stories.d.ts.map +1 -0
  31. package/dist/types/src/components/Settings/index.d.ts +2 -0
  32. package/dist/types/src/components/Settings/index.d.ts.map +1 -0
  33. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +5 -5
  34. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
  35. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +2 -1
  36. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
  37. package/dist/types/src/components/index.d.ts +1 -1
  38. package/dist/types/src/components/index.d.ts.map +1 -1
  39. package/dist/types/src/components/testing.d.ts.map +1 -1
  40. package/dist/types/src/hooks/useFormHandler.d.ts.map +1 -1
  41. package/dist/types/src/util/index.d.ts +0 -1
  42. package/dist/types/src/util/index.d.ts.map +1 -1
  43. package/dist/types/tsconfig.tsbuildinfo +1 -1
  44. package/package.json +35 -37
  45. package/src/components/FieldEditor/FieldEditor.stories.tsx +4 -6
  46. package/src/components/FieldEditor/FieldEditor.tsx +2 -3
  47. package/src/components/Form/Form.stories.tsx +8 -7
  48. package/src/components/Form/Form.tsx +82 -55
  49. package/src/components/Form/FormField.tsx +12 -4
  50. package/src/components/Form/FormFieldComponent.stories.tsx +5 -5
  51. package/src/components/Form/FormFieldComponent.tsx +17 -20
  52. package/src/components/Form/FormFieldSet.tsx +106 -104
  53. package/src/components/Form/fields/ArrayField.tsx +6 -8
  54. package/src/components/Form/fields/MarkdownField.tsx +1 -1
  55. package/src/components/Form/fields/RefField.tsx +28 -15
  56. package/src/components/Form/fields/SelectField.tsx +1 -1
  57. package/src/components/Form/fields/SelectOptionField.stories.tsx +2 -2
  58. package/src/components/Form/fields/SelectOptionField.tsx +4 -4
  59. package/src/components/ObjectPicker/ObjectPicker.stories.tsx +9 -13
  60. package/src/components/Settings/Settings.stories.tsx +56 -0
  61. package/src/components/Settings/Settings.tsx +230 -0
  62. package/src/components/{ControlSection → Settings}/index.ts +1 -1
  63. package/src/components/ViewEditor/ViewEditor.stories.tsx +14 -12
  64. package/src/components/ViewEditor/ViewEditor.test.tsx +3 -6
  65. package/src/components/ViewEditor/ViewEditor.tsx +92 -63
  66. package/src/components/index.ts +1 -1
  67. package/src/components/testing.tsx +9 -6
  68. package/src/hooks/useFormHandler.ts +42 -24
  69. package/src/util/index.ts +0 -1
  70. package/dist/types/src/components/ControlSection/ControlSection.d.ts +0 -23
  71. package/dist/types/src/components/ControlSection/ControlSection.d.ts.map +0 -1
  72. package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts.map +0 -1
  73. package/dist/types/src/components/ControlSection/index.d.ts +0 -2
  74. package/dist/types/src/components/ControlSection/index.d.ts.map +0 -1
  75. package/dist/types/src/components/Form/Form-old.stories.d.ts +0 -131
  76. package/dist/types/src/components/Form/Form-old.stories.d.ts.map +0 -1
  77. package/dist/types/src/util/echo.d.ts +0 -6
  78. package/dist/types/src/util/echo.d.ts.map +0 -1
  79. package/src/components/ControlSection/ControlSection.stories.tsx +0 -38
  80. package/src/components/ControlSection/ControlSection.tsx +0 -153
  81. package/src/components/Form/Form-old.stories.tsx +0 -314
  82. package/src/util/echo.ts +0 -25
@@ -77,117 +77,14 @@ var translations = [
77
77
  }
78
78
  ];
79
79
 
80
- // src/components/ControlSection/ControlSection.tsx
81
- import React from "react";
82
- import { Button, Input, toLocalizedString, useTranslation } from "@dxos/react-ui";
83
- import { Layout } from "@dxos/react-ui-mosaic";
84
- import { mx } from "@dxos/ui-theme";
85
- var ControlPage = ({ children, classNames, ...props }) => {
86
- return /* @__PURE__ */ React.createElement(Layout.Container, {
87
- scrollable: true,
88
- classNames: "[--control-spacing:var(--dx-trimMd)]"
89
- }, /* @__PURE__ */ React.createElement("div", {
90
- role: "none",
91
- className: mx("pli-cardSpacingInline pbe-trimMd", classNames),
92
- ...props
93
- }, children));
94
- };
95
- var ControlSection = ({ title, description, children }) => {
96
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ControlSectionHeading, {
97
- title,
98
- description
99
- }), children);
100
- };
101
- var ControlSectionHeading = ({ title, description }) => {
102
- const { t } = useTranslation(translationKey);
103
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("h2", {
104
- className: "pli-trimMd container-max-width text-xl mbs-trimMd mbe-trimMd"
105
- }, toLocalizedString(title, t)), description && /* @__PURE__ */ React.createElement("p", {
106
- className: "pli-trimMd mlb-trimMd container-max-width text-description"
107
- }, toLocalizedString(description, t)));
108
- };
109
- var ControlGroupButton = ({ classNames, ...props }) => {
110
- return /* @__PURE__ */ React.createElement(Button, {
111
- ...props,
112
- classNames: [
113
- "md:col-span-2",
114
- classNames
115
- ]
116
- });
117
- };
118
- var ControlGroup = ({ children, classNames }) => /* @__PURE__ */ React.createElement("div", {
119
- role: "none",
120
- className: mx("group container-max-width grid grid-cols-1 md:grid-cols-[1fr_min-content] gap-trimMd", "[--control-spacing:0px] [&_input]:justify-self-end [&_button]:justify-self-end", classNames)
121
- }, children);
122
- var ControlFrame = ({ children }) => /* @__PURE__ */ React.createElement("div", {
123
- role: "none",
124
- className: mx("container-max-width grid grid-cols-1 md:grid-cols-[1fr_1fr] gap-trimSm md:gap-trimMd p-trimMd", "border border-separator rounded-md")
125
- }, children);
126
- var controlItemClasses = mx([
127
- "container-max-width grid md:col-span-2 grid-cols-subgrid gap-trimSm items-center",
128
- // TODO(burdon): Use grid gap consistently or apply margins consistently?
129
- "mlb-[--control-spacing] *:first:!mbs-0 *:last:!mbe-0 pli-trimMd plb-trimMd",
130
- "border border-separator rounded-md"
131
- ]);
132
- var controlItemTitleClasses = "mbe-0 text-lg text-baseText font-normal";
133
- var controlItemDescriptionClasses = "mlb-trimSm md:mbe-0 text-base text-description";
134
- var ControlItem = ({ title, description, children }) => {
135
- const { t } = useTranslation(translationKey);
136
- return /* @__PURE__ */ React.createElement("div", {
137
- className: controlItemClasses
138
- }, /* @__PURE__ */ React.createElement("div", {
139
- role: "none"
140
- }, /* @__PURE__ */ React.createElement("h3", {
141
- className: controlItemTitleClasses
142
- }, toLocalizedString(title, t)), description && /* @__PURE__ */ React.createElement("p", {
143
- className: controlItemDescriptionClasses
144
- }, toLocalizedString(description, t))), children);
145
- };
146
- var ControlItemInput = ({ title, description, children }) => {
147
- const { t } = useTranslation(translationKey);
148
- return /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement("div", {
149
- className: controlItemClasses
150
- }, /* @__PURE__ */ React.createElement("div", {
151
- role: "none"
152
- }, /* @__PURE__ */ React.createElement(Input.Label, {
153
- classNames: controlItemTitleClasses
154
- }, toLocalizedString(title, t)), description && /* @__PURE__ */ React.createElement(Input.DescriptionAndValidation, null, /* @__PURE__ */ React.createElement(Input.Description, {
155
- classNames: controlItemDescriptionClasses
156
- }, toLocalizedString(description, t)))), children));
157
- };
158
- var ControlFrameItem = ({ title, description, children }) => {
159
- const { t } = useTranslation(translationKey);
160
- return /* @__PURE__ */ React.createElement("div", {
161
- role: "group",
162
- className: "min-is-0"
163
- }, /* @__PURE__ */ React.createElement("h3", {
164
- className: "text-lg mbe-2"
165
- }, toLocalizedString(title, t)), description && /* @__PURE__ */ React.createElement("p", {
166
- className: "mlb-trimSm md:mbe-0 text-description"
167
- }, toLocalizedString(description, t)), children);
168
- };
169
-
170
80
  // src/components/FieldEditor/FieldEditor.tsx
171
- import React18, { useCallback as useCallback14, useEffect as useEffect7, useMemo as useMemo7, useState as useState5 } from "react";
172
- import { Obj as Obj3 } from "@dxos/echo";
81
+ import React17, { useCallback as useCallback14, useEffect as useEffect7, useMemo as useMemo7, useState as useState5 } from "react";
82
+ import { Obj as Obj2 } from "@dxos/echo";
173
83
  import { Format as Format4, FormatEnums, formatToType } from "@dxos/echo/internal";
174
84
  import { log as log2 } from "@dxos/log";
175
- import { useAsyncEffect, useTranslation as useTranslation9 } from "@dxos/react-ui";
85
+ import { useAsyncEffect, useTranslation as useTranslation8 } from "@dxos/react-ui";
176
86
  import { formatToAdditionalPropertyAttributes, getFormatSchema } from "@dxos/schema";
177
87
 
178
- // src/util/echo.ts
179
- import { Obj } from "@dxos/echo";
180
- import { setValue as setValuePlain, splitJsonPath } from "@dxos/effect";
181
- var setValueEchoAware = (obj, path, value3) => {
182
- if (Obj.isObject(obj)) {
183
- Obj.change(obj, (mutableObj) => {
184
- Obj.setValue(mutableObj, splitJsonPath(path), value3);
185
- });
186
- return obj;
187
- }
188
- return setValuePlain(obj, path, value3);
189
- };
190
-
191
88
  // src/util/field.ts
192
89
  import { Format, GeoLocation, TypeEnum } from "@dxos/echo/internal";
193
90
  var parseValue = ({ type, format, value: value3 }) => {
@@ -481,24 +378,24 @@ var getRefProps = (ast) => {
481
378
 
482
379
  // src/components/Form/fields/ArrayField.tsx
483
380
  import * as Option3 from "effect/Option";
484
- import * as SchemaAST2 from "effect/SchemaAST";
485
- import React6, { useCallback as useCallback3 } from "react";
381
+ import * as SchemaAST3 from "effect/SchemaAST";
382
+ import React5, { useCallback as useCallback3 } from "react";
486
383
  import { findNode as findNode2, getArrayElementType as getArrayElementType2, getDiscriminatedType as getDiscriminatedType2, isDiscriminatedUnion as isDiscriminatedUnion2, isNestedType as isNestedType2 } from "@dxos/effect";
487
- import { IconButton as IconButton2, useTranslation as useTranslation4 } from "@dxos/react-ui";
384
+ import { IconButton as IconButton2, useTranslation as useTranslation3 } from "@dxos/react-ui";
488
385
 
489
386
  // src/components/Form/Form.tsx
490
387
  import { createContext } from "@radix-ui/react-context";
491
388
  import * as Schema2 from "effect/Schema";
492
- import React5, { useEffect as useEffect3, useMemo as useMemo4, useRef } from "react";
389
+ import * as SchemaAST2 from "effect/SchemaAST";
390
+ import React4, { useEffect as useEffect3, useMemo as useMemo4, useRef } from "react";
493
391
  import { createJsonPath as createJsonPath3, getValue as getValue$2 } from "@dxos/effect";
494
- import { IconButton, ScrollArea, useTranslation as useTranslation3 } from "@dxos/react-ui";
495
- import { mx as mx4 } from "@dxos/ui-theme";
392
+ import { IconButton, ScrollArea, useTranslation as useTranslation2 } from "@dxos/react-ui";
393
+ import { mx } from "@dxos/ui-theme";
496
394
 
497
395
  // src/hooks/useFormHandler.ts
498
396
  import { useControllableState } from "@radix-ui/react-use-controllable-state";
499
397
  import { useCallback, useEffect, useMemo, useState } from "react";
500
- import { Obj as Obj2 } from "@dxos/echo";
501
- import { createJsonPath, fromEffectValidationPath, getValue as getValue$, setValue as setValue$ } from "@dxos/effect";
398
+ import { createJsonPath, fromEffectValidationPath, getValue as getValue$ } from "@dxos/effect";
502
399
  import { log } from "@dxos/log";
503
400
  import { useDefaultValue } from "@dxos/react-ui";
504
401
  import { validateSchema } from "@dxos/schema";
@@ -513,11 +410,13 @@ var useFormHandler = ({ schema, autoSave, values: valuesProp, defaultValues: def
513
410
  prop: valuesProp,
514
411
  defaultProp: defaultValues,
515
412
  onChange: () => {
516
- setValues(valuesProp ?? defaultValues);
517
- setChanged({});
518
- setTouched({});
519
- setErrors({});
520
- setSaving(false);
413
+ if (valuesProp !== void 0) {
414
+ setValues(valuesProp ?? defaultValues);
415
+ setChanged({});
416
+ setTouched({});
417
+ setErrors({});
418
+ setSaving(false);
419
+ }
521
420
  }
522
421
  });
523
422
  const values = values$;
@@ -531,7 +430,7 @@ var useFormHandler = ({ schema, autoSave, values: valuesProp, defaultValues: def
531
430
  errors: errors2
532
431
  }, {
533
432
  F: __dxlog_file,
534
- L: 160,
433
+ L: 155,
535
434
  S: void 0,
536
435
  C: (f, a) => f(...a)
537
436
  });
@@ -624,11 +523,12 @@ var useFormHandler = ({ schema, autoSave, values: valuesProp, defaultValues: def
624
523
  value: value3
625
524
  }, {
626
525
  F: __dxlog_file,
627
- L: 259,
526
+ L: 254,
628
527
  S: void 0,
629
528
  C: (f, a) => f(...a)
630
529
  });
631
530
  const jsonPath = createJsonPath(path);
531
+ const pathArray = path;
632
532
  let parsedValue = value3;
633
533
  try {
634
534
  if (type._tag === "NumberKeyword") {
@@ -637,33 +537,33 @@ var useFormHandler = ({ schema, autoSave, values: valuesProp, defaultValues: def
637
537
  } catch (err) {
638
538
  log.catch(err, void 0, {
639
539
  F: __dxlog_file,
640
- L: 268,
540
+ L: 264,
641
541
  S: void 0,
642
542
  C: (f, a) => f(...a)
643
543
  });
644
544
  parsedValue = void 0;
645
545
  }
646
- const newValues = Obj2.isObject(values) ? (setValueEchoAware(values, jsonPath, parsedValue), values) : {
647
- ...setValue$(values, jsonPath, parsedValue)
648
- };
649
- setValues(newValues);
546
+ const newValues = mergeAtPath(values, pathArray, parsedValue);
650
547
  const newChanged = {
651
548
  [jsonPath]: true
652
549
  };
653
- setChanged({
654
- ...changed,
550
+ setChanged((prev) => ({
551
+ ...prev,
655
552
  ...newChanged
656
- });
553
+ }));
657
554
  const isValid2 = validate(newValues);
658
555
  onValuesChanged?.(newValues, {
659
556
  isValid: isValid2,
660
557
  changed: newChanged
661
558
  });
559
+ if (valuesProp === void 0) {
560
+ setValues(newValues);
561
+ }
662
562
  }, [
663
563
  values,
664
- changed,
665
564
  validate,
666
- onValuesChanged
565
+ onValuesChanged,
566
+ valuesProp
667
567
  ]);
668
568
  const onBlur = useCallback(async (path) => {
669
569
  const jsonPath = createJsonPath(path);
@@ -720,6 +620,24 @@ var useFormHandler = ({ schema, autoSave, values: valuesProp, defaultValues: def
720
620
  onCancel
721
621
  ]);
722
622
  };
623
+ var mergeAtPath = (obj, path, value3) => {
624
+ if (path.length === 0) {
625
+ return value3;
626
+ }
627
+ const [head2, ...rest] = path;
628
+ const child = rest.length === 0 ? value3 : mergeAtPath(obj?.[head2], rest, value3);
629
+ if (Array.isArray(obj)) {
630
+ const copy = [
631
+ ...obj
632
+ ];
633
+ copy[head2] = child;
634
+ return copy;
635
+ }
636
+ return {
637
+ ...obj,
638
+ [head2]: child
639
+ };
640
+ };
723
641
  var flatMap = (errors) => {
724
642
  return errors.reduce((result, { path, message }) => {
725
643
  const jsonPath = fromEffectValidationPath(path);
@@ -761,28 +679,24 @@ var useKeyHandler = (formElement, form) => {
761
679
  };
762
680
 
763
681
  // src/components/Form/FormFieldComponent.tsx
764
- import React2, { Component } from "react";
765
- import { Icon, Input as Input2, Tooltip } from "@dxos/react-ui";
766
- import { errorText, mx as mx2 } from "@dxos/ui-theme";
767
- var labelSpacing = "mbs-inputSpacingBlock mbe-labelSpacingBlock";
682
+ import React, { Component } from "react";
683
+ import { Icon, Input, Tooltip } from "@dxos/react-ui";
684
+ import { inputTextLabel } from "@dxos/ui-theme";
768
685
  var FormFieldLabel = ({ label, error, readonly, asChild }) => {
769
- const Label = readonly || asChild ? "span" : Input2.Label;
770
- const labelProps = readonly || asChild ? {
771
- className: "text-description text-sm"
772
- } : {
773
- classNames: "!mlb-0 text-sm"
774
- };
775
- return /* @__PURE__ */ React2.createElement("div", {
686
+ const Label = readonly || asChild ? "span" : Input.Label;
687
+ return /* @__PURE__ */ React.createElement("div", {
776
688
  role: "none",
777
- className: mx2("flex justify-between items-center", labelSpacing)
778
- }, /* @__PURE__ */ React2.createElement(Label, labelProps, label), error && /* @__PURE__ */ React2.createElement(Tooltip.Trigger, {
689
+ className: "flex items-center justify-between"
690
+ }, /* @__PURE__ */ React.createElement(Label, {
691
+ className: inputTextLabel
692
+ }, label), error && /* @__PURE__ */ React.createElement(Tooltip.Trigger, {
779
693
  asChild: true,
780
694
  content: error,
781
695
  side: "bottom"
782
- }, /* @__PURE__ */ React2.createElement(Icon, {
696
+ }, /* @__PURE__ */ React.createElement(Icon, {
783
697
  icon: "ph--warning--regular",
784
698
  size: 4,
785
- classNames: errorText
699
+ classNames: "text-error-text"
786
700
  })));
787
701
  };
788
702
  FormFieldLabel.displayName = "Form.FieldLabel";
@@ -794,15 +708,18 @@ var FormFieldWrapper = (props) => {
794
708
  return null;
795
709
  }
796
710
  const str = String(value3 ?? "");
797
- return /* @__PURE__ */ React2.createElement(Input2.Root, {
711
+ return /* @__PURE__ */ React.createElement("div", {
712
+ role: "none",
713
+ className: "contents"
714
+ }, /* @__PURE__ */ React.createElement(Input.Root, {
798
715
  validationValence: status
799
- }, layout !== "inline" && /* @__PURE__ */ React2.createElement(FormFieldLabel, {
716
+ }, layout !== "inline" && /* @__PURE__ */ React.createElement(FormFieldLabel, {
800
717
  error,
801
718
  readonly,
802
719
  label
803
- }), layout === "static" ? /* @__PURE__ */ React2.createElement("p", null, str) : children ? children({
720
+ }), layout === "static" ? /* @__PURE__ */ React.createElement("p", null, str) : children ? children({
804
721
  value: value3
805
- }) : null, layout === "full" && /* @__PURE__ */ React2.createElement(Input2.DescriptionAndValidation, null, /* @__PURE__ */ React2.createElement(Input2.Validation, null, error)));
722
+ }) : null, layout === "full" && /* @__PURE__ */ React.createElement(Input.DescriptionAndValidation, null, /* @__PURE__ */ React.createElement(Input.Validation, null, error))));
806
723
  };
807
724
  var FormFieldErrorBoundary = class extends Component {
808
725
  static getDerivedStateFromError(error) {
@@ -820,10 +737,10 @@ var FormFieldErrorBoundary = class extends Component {
820
737
  }
821
738
  render() {
822
739
  if (this.state.error) {
823
- return /* @__PURE__ */ React2.createElement("div", {
824
- className: "flex gap-2 border border-roseFill font-mono text-sm"
825
- }, /* @__PURE__ */ React2.createElement("span", {
826
- className: "bg-roseFill text-surfaceText pli-1 font-thin"
740
+ return /* @__PURE__ */ React.createElement("div", {
741
+ className: "flex gap-2 border border-rose-fill font-mono text-sm"
742
+ }, /* @__PURE__ */ React.createElement("span", {
743
+ className: "bg-rose-fill text-surface-text px-1 font-thin"
827
744
  }, "ERROR"), String(this.props.path?.join(".")));
828
745
  }
829
746
  return this.props.children;
@@ -836,9 +753,7 @@ var FormFieldErrorBoundary = class extends Component {
836
753
  };
837
754
 
838
755
  // src/components/Form/FormFieldSet.tsx
839
- import React4, { forwardRef, useMemo as useMemo3 } from "react";
840
- import { mx as mx3 } from "@dxos/ui-theme";
841
- import { isTruthy } from "@dxos/util";
756
+ import React3, { useMemo as useMemo3 } from "react";
842
757
 
843
758
  // src/components/Form/FormField.tsx
844
759
  import * as Match from "effect/Match";
@@ -846,10 +761,10 @@ import * as Option2 from "effect/Option";
846
761
  import * as Schema from "effect/Schema";
847
762
  import * as SchemaAST from "effect/SchemaAST";
848
763
  import * as String2 from "effect/String";
849
- import React3, { useMemo as useMemo2 } from "react";
764
+ import React2, { useMemo as useMemo2 } from "react";
850
765
  import { Format as Format3 } from "@dxos/echo";
851
766
  import { createJsonPath as createJsonPath2, findNode, getAnnotation, getDiscriminatedType, isArrayType as isArrayType2, isDiscriminatedUnion, isLiteralUnion, isNestedType } from "@dxos/effect";
852
- import { useTranslation as useTranslation2 } from "@dxos/react-ui";
767
+ import { useTranslation } from "@dxos/react-ui";
853
768
  var FormField = (props) => {
854
769
  const {
855
770
  type,
@@ -869,7 +784,7 @@ var FormField = (props) => {
869
784
  getOptions: getRefOptions,
870
785
  onCreate
871
786
  } = props;
872
- const { t } = useTranslation2(translationKey);
787
+ const { t } = useTranslation(translationKey);
873
788
  const title = getAnnotation(SchemaAST.TitleAnnotationId)(type);
874
789
  const description = getAnnotation(SchemaAST.DescriptionAnnotationId)(type);
875
790
  const examples = getAnnotation(SchemaAST.ExamplesAnnotationId)(type);
@@ -895,7 +810,7 @@ var FormField = (props) => {
895
810
  const jsonPath = createJsonPath2(path ?? []);
896
811
  const CustomField = fieldMap?.[jsonPath];
897
812
  if (CustomField) {
898
- return /* @__PURE__ */ React3.createElement(CustomField, fieldProps);
813
+ return /* @__PURE__ */ React2.createElement(CustomField, fieldProps);
899
814
  }
900
815
  const component = fieldProvider?.({
901
816
  schema: Schema.make(type),
@@ -906,7 +821,7 @@ var FormField = (props) => {
906
821
  return component;
907
822
  }
908
823
  if (isArrayType2(type)) {
909
- return /* @__PURE__ */ React3.createElement(ArrayField, {
824
+ return /* @__PURE__ */ React2.createElement(ArrayField, {
910
825
  fieldProps: fieldState,
911
826
  label,
912
827
  ...props
@@ -914,21 +829,27 @@ var FormField = (props) => {
914
829
  }
915
830
  const Field = getFormField(fieldProps);
916
831
  if (Field) {
917
- return /* @__PURE__ */ React3.createElement(Field, fieldProps);
832
+ return /* @__PURE__ */ React2.createElement(Field, fieldProps);
918
833
  }
919
834
  const options = getOptions(type);
920
835
  if (options) {
921
- return /* @__PURE__ */ React3.createElement(SelectField, {
836
+ const fieldProjections = projection?.getFieldProjections();
837
+ const fieldProjection = fieldProjections?.find((fp) => fp.field.path === name);
838
+ const selectOptions = fieldProjection?.props.options;
839
+ return /* @__PURE__ */ React2.createElement(SelectField, {
922
840
  ...fieldProps,
923
- options: options.map((option) => ({
924
- value: option,
925
- label: option.toString()
926
- }))
841
+ options: options.map((option) => {
842
+ const selectOption = selectOptions?.find((so) => so.id === globalThis.String(option));
843
+ return {
844
+ value: option,
845
+ label: selectOption?.title ?? option.toString()
846
+ };
847
+ })
927
848
  });
928
849
  }
929
850
  const refProps = getRefProps(type);
930
851
  if (refProps) {
931
- return /* @__PURE__ */ React3.createElement(RefField, {
852
+ return /* @__PURE__ */ React2.createElement(RefField, {
932
853
  ...fieldProps,
933
854
  ...refProps,
934
855
  createOptionLabel,
@@ -945,7 +866,7 @@ var FormField = (props) => {
945
866
  const typeLiteral = baseNode ? getDiscriminatedType(baseNode, fieldState.getValue()) : findNode(type, SchemaAST.isTypeLiteral);
946
867
  if (typeLiteral) {
947
868
  const schema = Schema.make(typeLiteral);
948
- return /* @__PURE__ */ React3.createElement(FormFieldSet, {
869
+ return /* @__PURE__ */ React2.createElement(FormFieldSet, {
949
870
  schema,
950
871
  path,
951
872
  readonly,
@@ -991,17 +912,19 @@ var getOptions = (ast) => {
991
912
  };
992
913
 
993
914
  // src/components/Form/FormFieldSet.tsx
994
- var FormFieldSet = /* @__PURE__ */ forwardRef(({ classNames, label, schema, readonly, path, exclude, sort, projection, layout, ...props }, forwardRef4) => {
995
- const values = useFormValues(FormFieldSet.displayName, path);
915
+ var FORM_FIELDSET_NAME = "Form.FieldSet";
916
+ var FormFieldSet = ({ label, schema, readonly, path, sort, exclude, projection, layout, ...props }) => {
917
+ const values = useFormValues(FORM_FIELDSET_NAME, path);
996
918
  const properties = useMemo3(() => {
997
919
  if (!schema) {
998
920
  return [];
999
921
  }
1000
- const props2 = getFormProperties(schema.ast);
922
+ const schemaProps = getFormProperties(schema.ast);
923
+ const filteredProps = exclude ? exclude(schemaProps) : schemaProps;
1001
924
  if (projection) {
1002
925
  const fieldProjections = projection.getFieldProjections();
1003
926
  const hiddenProperties = new Set(projection.getHiddenProperties());
1004
- const visibleProps = props2.filter((prop) => !hiddenProperties.has(prop.name.toString()));
927
+ const visibleProps = filteredProps.filter((prop) => !hiddenProperties.has(prop.name.toString()));
1005
928
  const orderedProps = [];
1006
929
  for (const fieldProjection of fieldProjections) {
1007
930
  const fieldPath = String(fieldProjection.field.path);
@@ -1015,34 +938,31 @@ var FormFieldSet = /* @__PURE__ */ forwardRef(({ classNames, label, schema, read
1015
938
  orderedProps.push(...remainingProps);
1016
939
  return orderedProps;
1017
940
  }
1018
- const filtered = exclude ? exclude(props2) : props2;
1019
- return sort ? filtered.sort(({ name: a }, { name: b }) => sort.indexOf(a.toString()) - sort.indexOf(b.toString())) : filtered;
941
+ return sort ? [
942
+ ...filteredProps
943
+ ].sort(({ name: a }, { name: b }) => sort.indexOf(a.toString()) - sort.indexOf(b.toString())) : filteredProps;
1020
944
  }, [
1021
945
  schema,
1022
946
  values,
1023
947
  exclude,
1024
948
  sort,
1025
- projection?.fields
949
+ projection
1026
950
  ]);
1027
951
  if ((readonly || layout === "static") && values == null) {
1028
952
  return null;
1029
953
  }
1030
- return /* @__PURE__ */ React4.createElement("div", {
1031
- role: "form",
1032
- className: mx3("is-full", layout === "inline" && "flex flex-col gap-2", classNames),
1033
- ref: forwardRef4
1034
- }, layout !== "inline" && label && /* @__PURE__ */ React4.createElement(FormFieldLabel, {
954
+ return /* @__PURE__ */ React3.createElement(React3.Fragment, null, layout !== "inline" && label && /* @__PURE__ */ React3.createElement(FormFieldLabel, {
1035
955
  label,
1036
956
  asChild: true
1037
957
  }), properties.map((property) => {
1038
958
  const name = property.name.toString();
1039
- return /* @__PURE__ */ React4.createElement(FormFieldErrorBoundary, {
959
+ return /* @__PURE__ */ React3.createElement(FormFieldErrorBoundary, {
1040
960
  key: name,
1041
961
  path: [
1042
962
  ...path ?? [],
1043
963
  name
1044
964
  ]
1045
- }, /* @__PURE__ */ React4.createElement(FormField, {
965
+ }, /* @__PURE__ */ React3.createElement(FormField, {
1046
966
  type: property.type,
1047
967
  name,
1048
968
  path: [
@@ -1054,24 +974,32 @@ var FormFieldSet = /* @__PURE__ */ forwardRef(({ classNames, label, schema, read
1054
974
  projection,
1055
975
  ...props
1056
976
  }));
1057
- }).filter(isTruthy));
1058
- });
1059
- FormFieldSet.displayName = "Form.Fields";
977
+ }));
978
+ };
979
+ FormFieldSet.displayName = FORM_FIELDSET_NAME;
1060
980
 
1061
981
  // src/components/Form/Form.tsx
1062
982
  var omitId = (schema) => schema.pipe(Schema2.omit("id"));
1063
983
  var [FormContextProvider, useFormContext] = createContext("Form");
1064
- var useFormValues = (componentName, path = [], defaultValue) => {
1065
- const jsonPath = createJsonPath3(path);
1066
- const { form: { values } } = useFormContext(componentName);
984
+ var useFormValues = (componentName, path, defaultValue) => {
985
+ const stablePath = useMemo4(() => path ?? [], [
986
+ path ? path.join(".") : void 0
987
+ ]);
988
+ const jsonPath = createJsonPath3(stablePath);
989
+ const { form: { values, onValueChange } } = useFormContext(componentName);
1067
990
  const value3 = getValue$2(values, jsonPath);
991
+ const lastAppliedPathRef = useRef(null);
1068
992
  useEffect3(() => {
1069
- if (!value3 && defaultValue) {
1070
- setValueEchoAware(values, jsonPath, defaultValue());
993
+ if (value3 == null && defaultValue && lastAppliedPathRef.current !== jsonPath) {
994
+ lastAppliedPathRef.current = jsonPath;
995
+ onValueChange(stablePath, SchemaAST2.stringKeyword, defaultValue());
1071
996
  }
1072
997
  }, [
1073
998
  value3,
1074
- defaultValue
999
+ defaultValue,
1000
+ onValueChange,
1001
+ stablePath,
1002
+ jsonPath
1075
1003
  ]);
1076
1004
  return value3;
1077
1005
  };
@@ -1101,60 +1029,64 @@ var FormRoot = ({ children, schema, values, onSave, onCancel, ...props }) => {
1101
1029
  onCancel,
1102
1030
  ...props
1103
1031
  });
1104
- return /* @__PURE__ */ React5.createElement(FormContextProvider, {
1032
+ return /* @__PURE__ */ React4.createElement(FormContextProvider, {
1105
1033
  form,
1106
1034
  ...props
1107
1035
  }, children);
1108
1036
  };
1109
1037
  FormRoot.displayName = "Form.Root";
1110
- var FormViewport = ({ classNames, children }) => {
1111
- return /* @__PURE__ */ React5.createElement(ScrollArea.Root, null, /* @__PURE__ */ React5.createElement(ScrollArea.Viewport, {
1112
- classNames: [
1113
- "plb-cardSpacingBlock",
1114
- classNames
1115
- ]
1116
- }, children), /* @__PURE__ */ React5.createElement(ScrollArea.Scrollbar, {
1117
- orientation: "vertical"
1118
- }, /* @__PURE__ */ React5.createElement(ScrollArea.Thumb, null)));
1038
+ var FORM_VIEWPORT_NAME = "Form.Viewport";
1039
+ var FormViewport = ({ children, classNames, margin = true, padding = true, thin = true, ...props }) => {
1040
+ return /* @__PURE__ */ React4.createElement(ScrollArea.Root, {
1041
+ orientation: "vertical",
1042
+ classNames,
1043
+ margin,
1044
+ padding,
1045
+ thin,
1046
+ ...props
1047
+ }, /* @__PURE__ */ React4.createElement(ScrollArea.Viewport, null, children));
1119
1048
  };
1120
- FormViewport.displayName = "Form.Viewport";
1049
+ FormViewport.displayName = FORM_VIEWPORT_NAME;
1050
+ var FORM_CONTENT_NAME = "Form.Content";
1121
1051
  var FormContent = ({ classNames, children }) => {
1122
- const { form, testId } = useFormContext(FormContent.displayName);
1052
+ const { form, testId } = useFormContext(FORM_CONTENT_NAME);
1123
1053
  const ref = useRef(null);
1124
1054
  useKeyHandler(ref.current, form);
1125
- return /* @__PURE__ */ React5.createElement("div", {
1055
+ return /* @__PURE__ */ React4.createElement("div", {
1126
1056
  ref,
1127
1057
  role: "form",
1128
- className: mx4("flex flex-col is-full pli-cardSpacingInline density-fine", classNames),
1058
+ className: mx("w-full flex flex-col gap-form-padding", classNames),
1129
1059
  "data-testid": testId
1130
1060
  }, children);
1131
1061
  };
1132
- FormContent.displayName = "Form.Content";
1133
- var FormFieldSet2 = ({ classNames }) => {
1134
- const { form, ...props } = useFormContext(FormFieldSet2.displayName);
1135
- return /* @__PURE__ */ React5.createElement(FormFieldSet, {
1136
- classNames,
1062
+ FormContent.displayName = FORM_CONTENT_NAME;
1063
+ var FORM_FIELDSET_NAME2 = "Form.FieldSet";
1064
+ var FormFieldSet2 = (props) => {
1065
+ const { form, ...contextProps } = useFormContext(FORM_FIELDSET_NAME2);
1066
+ return /* @__PURE__ */ React4.createElement(FormFieldSet, {
1137
1067
  schema: form.schema,
1068
+ ...contextProps,
1138
1069
  ...props
1139
1070
  });
1140
1071
  };
1141
- FormFieldSet2.displayName = "Form.FieldSet";
1072
+ FormFieldSet2.displayName = FORM_FIELDSET_NAME2;
1073
+ var FORM_ACTIONS_NAME = "Form.Actions";
1142
1074
  var FormActions = ({ classNames }) => {
1143
- const { t } = useTranslation3(translationKey);
1144
- const { form: { canSave, onSave, onCancel }, readonly, layout } = useFormContext(FormActions.displayName);
1075
+ const { t } = useTranslation2(translationKey);
1076
+ const { form: { canSave, onSave, onCancel }, readonly, layout } = useFormContext(FORM_ACTIONS_NAME);
1145
1077
  if (readonly || layout === "static") {
1146
1078
  return null;
1147
1079
  }
1148
- return /* @__PURE__ */ React5.createElement("div", {
1080
+ return /* @__PURE__ */ React4.createElement("div", {
1149
1081
  role: "none",
1150
- className: mx4("grid grid-flow-col auto-cols-fr gap-2 pbs-cardSpacingBlock", classNames)
1151
- }, onCancel && /* @__PURE__ */ React5.createElement(IconButton, {
1082
+ className: mx("grid grid-flow-col gap-2 auto-cols-fr py-form-padding", classNames)
1083
+ }, onCancel && /* @__PURE__ */ React4.createElement(IconButton, {
1152
1084
  icon: "ph--x--regular",
1153
1085
  iconEnd: true,
1154
1086
  label: t("cancel button label"),
1155
1087
  onClick: onCancel,
1156
1088
  "data-testid": "cancel-button"
1157
- }), onSave && /* @__PURE__ */ React5.createElement(IconButton, {
1089
+ }), onSave && /* @__PURE__ */ React4.createElement(IconButton, {
1158
1090
  type: "submit",
1159
1091
  variant: "primary",
1160
1092
  disabled: !canSave,
@@ -1165,52 +1097,53 @@ var FormActions = ({ classNames }) => {
1165
1097
  "data-testid": "save-button"
1166
1098
  }));
1167
1099
  };
1168
- FormActions.displayName = "Form.Actions";
1169
- var FormSubmit = ({ classNames, label, icon }) => {
1170
- const { t } = useTranslation3(translationKey);
1171
- const { form: { canSave, onSave }, readonly, layout } = useFormContext(FormSubmit.displayName);
1100
+ FormActions.displayName = FORM_ACTIONS_NAME;
1101
+ var FORM_SUBMIT_NAME = "Form.Submit";
1102
+ var FormSubmit = ({ classNames, label, icon, disabled }) => {
1103
+ const { t } = useTranslation2(translationKey);
1104
+ const { form: { canSave, onSave }, readonly, layout } = useFormContext(FORM_SUBMIT_NAME);
1172
1105
  if (readonly || layout === "static") {
1173
1106
  return null;
1174
1107
  }
1175
- return /* @__PURE__ */ React5.createElement("div", {
1108
+ return /* @__PURE__ */ React4.createElement("div", {
1176
1109
  role: "none",
1177
- className: mx4("flex is-full pbs-cardSpacingBlock", classNames)
1178
- }, /* @__PURE__ */ React5.createElement(IconButton, {
1179
- classNames: "is-full",
1110
+ className: mx("flex w-full pt-form-padding", classNames)
1111
+ }, /* @__PURE__ */ React4.createElement(IconButton, {
1112
+ classNames: "w-full",
1180
1113
  type: "submit",
1181
1114
  variant: "primary",
1182
- disabled: !canSave,
1115
+ disabled: disabled ?? !canSave,
1183
1116
  icon: icon ?? "ph--check--regular",
1184
1117
  label: label ?? t("save button label"),
1185
1118
  onClick: onSave,
1186
1119
  "data-testid": "save-button"
1187
1120
  }));
1188
1121
  };
1189
- FormSubmit.displayName = "Form.Submit";
1122
+ FormSubmit.displayName = FORM_SUBMIT_NAME;
1190
1123
  var Form = {
1191
1124
  Root: FormRoot,
1192
1125
  Viewport: FormViewport,
1193
1126
  Content: FormContent,
1194
1127
  FieldSet: FormFieldSet2,
1128
+ Label: FormFieldLabel,
1195
1129
  Actions: FormActions,
1196
- Submit: FormSubmit,
1197
- Label: FormFieldLabel
1130
+ Submit: FormSubmit
1198
1131
  };
1199
1132
 
1200
1133
  // src/components/Form/fields/ArrayField.tsx
1201
1134
  var ArrayField = ({ type, path, label, readonly, layout, fieldProps: inputProps, ...props }) => {
1202
- const { t } = useTranslation4(translationKey);
1135
+ const { t } = useTranslation3(translationKey);
1203
1136
  const elementType = getArrayElementType2(type);
1204
1137
  const { onValueChange } = inputProps;
1205
1138
  const values = useFormValues(ArrayField.displayName, path, () => []);
1206
1139
  const getDefaultObjectValue = (typeNode) => {
1207
1140
  const baseNode = findNode2(typeNode, isDiscriminatedUnion2);
1208
- const typeLiteral = baseNode ? getDiscriminatedType2(baseNode, {}) : findNode2(typeNode, SchemaAST2.isTypeLiteral);
1141
+ const typeLiteral = baseNode ? getDiscriminatedType2(baseNode, {}) : findNode2(typeNode, SchemaAST3.isTypeLiteral);
1209
1142
  if (!typeLiteral) {
1210
1143
  return {};
1211
1144
  }
1212
1145
  return Object.fromEntries(getFormProperties(typeLiteral).map((prop) => {
1213
- const defaultValue = SchemaAST2.getDefaultAnnotation(prop.type).pipe((annotation) => Option3.getOrUndefined(annotation));
1146
+ const defaultValue = SchemaAST3.getDefaultAnnotation(prop.type).pipe((annotation) => Option3.getOrUndefined(annotation));
1214
1147
  return [
1215
1148
  prop.name,
1216
1149
  defaultValue
@@ -1239,19 +1172,19 @@ var ArrayField = ({ type, path, label, readonly, layout, fieldProps: inputProps,
1239
1172
  if (!elementType || (readonly || layout === "static") && values && values.length < 1) {
1240
1173
  return null;
1241
1174
  }
1242
- return /* @__PURE__ */ React6.createElement(React6.Fragment, null, (layout !== "static" || values && values.length > 0) && /* @__PURE__ */ React6.createElement(FormFieldLabel, {
1175
+ return /* @__PURE__ */ React5.createElement(React5.Fragment, null, (layout !== "static" || values && values.length > 0) && /* @__PURE__ */ React5.createElement(FormFieldLabel, {
1243
1176
  readonly,
1244
1177
  label,
1245
1178
  asChild: true
1246
- }), /* @__PURE__ */ React6.createElement("div", {
1179
+ }), /* @__PURE__ */ React5.createElement("div", {
1247
1180
  role: "none",
1248
1181
  className: "flex flex-col gap-2"
1249
1182
  }, values?.map((_, index) => {
1250
- return /* @__PURE__ */ React6.createElement("div", {
1183
+ return /* @__PURE__ */ React5.createElement("div", {
1251
1184
  role: "none",
1252
1185
  key: index,
1253
1186
  className: "grid grid-cols-[1fr_min-content] gap-2 last:mb-3"
1254
- }, /* @__PURE__ */ React6.createElement(FormField, {
1187
+ }, /* @__PURE__ */ React5.createElement(FormField, {
1255
1188
  autoFocus: index === values.length - 1,
1256
1189
  type: elementType,
1257
1190
  path: [
@@ -1261,21 +1194,21 @@ var ArrayField = ({ type, path, label, readonly, layout, fieldProps: inputProps,
1261
1194
  readonly: readonly || layout === "static",
1262
1195
  layout: "inline",
1263
1196
  ...props
1264
- }), !readonly && layout !== "static" && /* @__PURE__ */ React6.createElement("div", {
1197
+ }), !readonly && layout !== "static" && /* @__PURE__ */ React5.createElement("div", {
1265
1198
  role: "none",
1266
- className: "flex flex-col bs-full justify-end"
1267
- }, /* @__PURE__ */ React6.createElement("div", {
1199
+ className: "flex flex-col h-full justify-end"
1200
+ }, /* @__PURE__ */ React5.createElement("div", {
1268
1201
  role: "none",
1269
- className: "flex items-center bs-[var(--line-height)]"
1270
- }, /* @__PURE__ */ React6.createElement(IconButton2, {
1202
+ className: "flex items-center h-[2rem]"
1203
+ }, /* @__PURE__ */ React5.createElement(IconButton2, {
1271
1204
  icon: "ph--x--regular",
1272
1205
  iconOnly: true,
1273
1206
  label: t("button remove"),
1274
1207
  onClick: () => handleDelete(index),
1275
1208
  classNames: "self-center"
1276
1209
  }))));
1277
- })), !readonly && layout !== "static" && /* @__PURE__ */ React6.createElement(IconButton2, {
1278
- classNames: "flex is-full _mlb-cardSpacingBlock",
1210
+ })), !readonly && layout !== "static" && /* @__PURE__ */ React5.createElement(IconButton2, {
1211
+ classNames: "flex w-full",
1279
1212
  icon: "ph--plus--regular",
1280
1213
  label: t("add field"),
1281
1214
  onClick: handleAdd
@@ -1293,6 +1226,9 @@ var getDefaultValue = (ast) => {
1293
1226
  case "BooleanKeyword": {
1294
1227
  return false;
1295
1228
  }
1229
+ case "Suspend": {
1230
+ return getDefaultValue(ast.f());
1231
+ }
1296
1232
  default: {
1297
1233
  if (ast && isNestedType2(ast)) {
1298
1234
  return {};
@@ -1304,17 +1240,17 @@ var getDefaultValue = (ast) => {
1304
1240
  };
1305
1241
 
1306
1242
  // src/components/Form/fields/BooleanField.tsx
1307
- import React7, { useCallback as useCallback4 } from "react";
1308
- import { Input as Input3 } from "@dxos/react-ui";
1243
+ import React6, { useCallback as useCallback4 } from "react";
1244
+ import { Input as Input2 } from "@dxos/react-ui";
1309
1245
  var BooleanField = ({ type, readonly, onValueChange, ...props }) => {
1310
1246
  const handleChange = useCallback4((value3) => onValueChange?.(type, value3), [
1311
1247
  type,
1312
1248
  onValueChange
1313
1249
  ]);
1314
- return /* @__PURE__ */ React7.createElement(FormFieldWrapper, {
1250
+ return /* @__PURE__ */ React6.createElement(FormFieldWrapper, {
1315
1251
  readonly,
1316
1252
  ...props
1317
- }, ({ value: value3 }) => /* @__PURE__ */ React7.createElement(Input3.Switch, {
1253
+ }, ({ value: value3 }) => /* @__PURE__ */ React6.createElement(Input2.Switch, {
1318
1254
  disabled: !!readonly,
1319
1255
  checked: value3,
1320
1256
  onCheckedChange: handleChange
@@ -1322,12 +1258,12 @@ var BooleanField = ({ type, readonly, onValueChange, ...props }) => {
1322
1258
  };
1323
1259
 
1324
1260
  // src/components/Form/fields/GeoPointField.tsx
1325
- import React8, { useCallback as useCallback5, useEffect as useEffect4, useMemo as useMemo5, useState as useState2 } from "react";
1261
+ import React7, { useCallback as useCallback5, useEffect as useEffect4, useMemo as useMemo5, useState as useState2 } from "react";
1326
1262
  import { GeoLocation as GeoLocation3 } from "@dxos/echo/internal";
1327
- import { Input as Input4, useTranslation as useTranslation5 } from "@dxos/react-ui";
1263
+ import { Input as Input3, useTranslation as useTranslation4 } from "@dxos/react-ui";
1328
1264
  import { safeParseFloat } from "@dxos/util";
1329
1265
  var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onValueChange, onBlur }) => {
1330
- const { t } = useTranslation5(translationKey);
1266
+ const { t } = useTranslation4(translationKey);
1331
1267
  const { status, error } = getStatus();
1332
1268
  const geoPoint = useMemo5(() => getValue() ?? [
1333
1269
  0,
@@ -1373,17 +1309,17 @@ var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onVal
1373
1309
  if ((readonly || layout === "static") && !value3?.latitude && !value3?.longitude) {
1374
1310
  return null;
1375
1311
  }
1376
- return /* @__PURE__ */ React8.createElement(Input4.Root, {
1312
+ return /* @__PURE__ */ React7.createElement(Input3.Root, {
1377
1313
  validationValence: status
1378
- }, layout !== "inline" && /* @__PURE__ */ React8.createElement(FormFieldLabel, {
1314
+ }, layout !== "inline" && /* @__PURE__ */ React7.createElement(FormFieldLabel, {
1379
1315
  error,
1380
1316
  readonly,
1381
1317
  label,
1382
1318
  asChild: true
1383
- }), layout === "static" ? /* @__PURE__ */ React8.createElement(LatLng, value3) : /* @__PURE__ */ React8.createElement("div", {
1319
+ }), layout === "static" ? /* @__PURE__ */ React7.createElement(LatLng, value3) : /* @__PURE__ */ React7.createElement("div", {
1384
1320
  role: "none",
1385
1321
  className: "grid grid-cols-2 gap-2"
1386
- }, /* @__PURE__ */ React8.createElement("div", null, /* @__PURE__ */ React8.createElement(Input4.Root, null, layout !== "inline" && /* @__PURE__ */ React8.createElement(Input4.Label, null, t("latitude label")), /* @__PURE__ */ React8.createElement(Input4.TextInput, {
1322
+ }, /* @__PURE__ */ React7.createElement("div", null, /* @__PURE__ */ React7.createElement(Input3.Root, null, layout !== "inline" && /* @__PURE__ */ React7.createElement(Input3.Label, null, t("latitude label")), /* @__PURE__ */ React7.createElement(Input3.TextInput, {
1387
1323
  type: "number",
1388
1324
  step: "0.00001",
1389
1325
  min: "-90",
@@ -1393,7 +1329,7 @@ var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onVal
1393
1329
  value: latitudeText ?? "",
1394
1330
  onChange: handleChange("latitude", setLatitudeText),
1395
1331
  onBlur
1396
- }))), /* @__PURE__ */ React8.createElement("div", null, /* @__PURE__ */ React8.createElement(Input4.Root, null, layout !== "inline" && /* @__PURE__ */ React8.createElement(Input4.Label, null, t("longitude label")), /* @__PURE__ */ React8.createElement(Input4.TextInput, {
1332
+ }))), /* @__PURE__ */ React7.createElement("div", null, /* @__PURE__ */ React7.createElement(Input3.Root, null, layout !== "inline" && /* @__PURE__ */ React7.createElement(Input3.Label, null, t("longitude label")), /* @__PURE__ */ React7.createElement(Input3.TextInput, {
1397
1333
  type: "number",
1398
1334
  step: "0.00001",
1399
1335
  min: "-180",
@@ -1408,18 +1344,18 @@ var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onVal
1408
1344
  var LatLng = ({ latitude = 0, longitude = 0 }) => {
1409
1345
  const latHem = latitude >= 0 ? "N" : "S";
1410
1346
  const lngHem = longitude >= 0 ? "E" : "W";
1411
- return /* @__PURE__ */ React8.createElement("span", {
1347
+ return /* @__PURE__ */ React7.createElement("span", {
1412
1348
  className: "inline-flex items-center gap-1"
1413
- }, /* @__PURE__ */ React8.createElement("span", null, /* @__PURE__ */ React8.createElement("span", null, Math.abs(latitude).toFixed(5)), /* @__PURE__ */ React8.createElement("span", {
1349
+ }, /* @__PURE__ */ React7.createElement("span", null, /* @__PURE__ */ React7.createElement("span", null, Math.abs(latitude).toFixed(5)), /* @__PURE__ */ React7.createElement("span", {
1414
1350
  className: "text-subdued"
1415
- }, "\xB0", latHem)), /* @__PURE__ */ React8.createElement("span", null, /* @__PURE__ */ React8.createElement("span", null, Math.abs(longitude).toFixed(5)), /* @__PURE__ */ React8.createElement("span", {
1351
+ }, "\xB0", latHem)), /* @__PURE__ */ React7.createElement("span", null, /* @__PURE__ */ React7.createElement("span", null, Math.abs(longitude).toFixed(5)), /* @__PURE__ */ React7.createElement("span", {
1416
1352
  className: "text-subdued"
1417
1353
  }, "\xB0", lngHem)));
1418
1354
  };
1419
1355
 
1420
1356
  // src/components/Form/fields/MarkdownField.tsx
1421
- import React9, { useCallback as useCallback6, useEffect as useEffect5, useRef as useRef2 } from "react";
1422
- import { Input as Input5 } from "@dxos/react-ui";
1357
+ import React8, { useCallback as useCallback6, useEffect as useEffect5, useRef as useRef2 } from "react";
1358
+ import { Input as Input4 } from "@dxos/react-ui";
1423
1359
  var MarkdownField = ({ type, readonly, label, placeholder, layout, getStatus, getValue, onValueChange, onBlur }) => {
1424
1360
  const { status, error } = getStatus();
1425
1361
  const textareaRef = useRef2(null);
@@ -1449,40 +1385,40 @@ var MarkdownField = ({ type, readonly, label, placeholder, layout, getStatus, ge
1449
1385
  if ((readonly || layout === "static") && !value3) {
1450
1386
  return null;
1451
1387
  }
1452
- return /* @__PURE__ */ React9.createElement(Input5.Root, {
1388
+ return /* @__PURE__ */ React8.createElement(Input4.Root, {
1453
1389
  validationValence: status
1454
- }, layout !== "inline" && /* @__PURE__ */ React9.createElement(FormFieldLabel, {
1390
+ }, layout !== "inline" && /* @__PURE__ */ React8.createElement(FormFieldLabel, {
1455
1391
  error,
1456
1392
  readonly,
1457
1393
  label
1458
- }), layout === "static" ? /* @__PURE__ */ React9.createElement("p", null, value3) : /* @__PURE__ */ React9.createElement(Input5.TextArea, {
1394
+ }), layout === "static" ? /* @__PURE__ */ React8.createElement("p", null, value3) : /* @__PURE__ */ React8.createElement(Input4.TextArea, {
1459
1395
  ref: textareaRef,
1460
1396
  disabled: !!readonly,
1461
1397
  placeholder,
1462
1398
  value: value3 ?? "",
1463
- classNames: "min-bs-auto max-bs-40 overflow-auto",
1399
+ classNames: "min-h-auto max-h-40 overflow-auto",
1464
1400
  onChange: handleChange,
1465
1401
  onBlur,
1466
1402
  style: {
1467
1403
  resize: "none"
1468
1404
  },
1469
1405
  spellCheck: false
1470
- }), layout === "full" && /* @__PURE__ */ React9.createElement(Input5.Validation, null, error));
1406
+ }), layout === "full" && /* @__PURE__ */ React8.createElement(Input4.Validation, null, error));
1471
1407
  };
1472
1408
 
1473
1409
  // src/components/Form/fields/NumberField.tsx
1474
- import React10, { useCallback as useCallback7 } from "react";
1475
- import { Input as Input6 } from "@dxos/react-ui";
1410
+ import React9, { useCallback as useCallback7 } from "react";
1411
+ import { Input as Input5 } from "@dxos/react-ui";
1476
1412
  import { safeParseFloat as safeParseFloat2 } from "@dxos/util";
1477
1413
  var NumberField = ({ type, readonly, placeholder, onValueChange, onBlur, ...props }) => {
1478
1414
  const handleChange = useCallback7((event) => onValueChange(type, safeParseFloat2(event.target.value) || 0), [
1479
1415
  type,
1480
1416
  onValueChange
1481
1417
  ]);
1482
- return /* @__PURE__ */ React10.createElement(FormFieldWrapper, {
1418
+ return /* @__PURE__ */ React9.createElement(FormFieldWrapper, {
1483
1419
  readonly,
1484
1420
  ...props
1485
- }, ({ value: value3 = "" }) => /* @__PURE__ */ React10.createElement(Input6.TextInput, {
1421
+ }, ({ value: value3 = "" }) => /* @__PURE__ */ React9.createElement(Input5.TextInput, {
1486
1422
  type: "number",
1487
1423
  disabled: !!readonly,
1488
1424
  placeholder,
@@ -1494,24 +1430,25 @@ var NumberField = ({ type, readonly, placeholder, onValueChange, onBlur, ...prop
1494
1430
 
1495
1431
  // src/components/Form/fields/RefField.tsx
1496
1432
  import "@dxos/lit-ui/dx-tag-picker.pcss";
1497
- import React12, { useCallback as useCallback9, useMemo as useMemo6 } from "react";
1498
- import { Entity, Filter, Ref as Ref2 } from "@dxos/echo";
1433
+ import React11, { useCallback as useCallback9, useMemo as useMemo6 } from "react";
1434
+ import { Entity, Filter, Obj, Ref as Ref2, Type } from "@dxos/echo";
1499
1435
  import { ReferenceAnnotationId } from "@dxos/echo/internal";
1500
1436
  import { useQuery, useSchema as useSchema$ } from "@dxos/echo-react";
1501
1437
  import { findAnnotation } from "@dxos/effect";
1502
1438
  import { DXN } from "@dxos/keys";
1503
1439
  import { DxAnchor } from "@dxos/lit-ui/react";
1504
- import { Button as Button2, Icon as Icon2, Input as Input7, useTranslation as useTranslation7 } from "@dxos/react-ui";
1505
- import { descriptionText, mx as mx5 } from "@dxos/ui-theme";
1440
+ import { Button, Icon as Icon2, Input as Input6, useTranslation as useTranslation6 } from "@dxos/react-ui";
1441
+ import { ParentLabelAnnotationId } from "@dxos/schema";
1442
+ import { mx as mx2 } from "@dxos/ui-theme";
1506
1443
 
1507
1444
  // src/components/ObjectPicker/ObjectPicker.tsx
1508
- import React11, { forwardRef as forwardRef2, useCallback as useCallback8, useState as useState3 } from "react";
1509
- import { Popover, useTranslation as useTranslation6 } from "@dxos/react-ui";
1445
+ import React10, { forwardRef, useCallback as useCallback8, useState as useState3 } from "react";
1446
+ import { Popover, useTranslation as useTranslation5 } from "@dxos/react-ui";
1510
1447
  import { Combobox, useSearchListInput, useSearchListResults } from "@dxos/react-ui-searchlist";
1511
1448
  var CreateItem = ({ createOptionLabel, createOptionIcon, onCreateItemSelect }) => {
1512
- const { t } = useTranslation6(translationKey);
1449
+ const { t } = useTranslation5(translationKey);
1513
1450
  const { query } = useSearchListInput();
1514
- return /* @__PURE__ */ React11.createElement(Combobox.Item, {
1451
+ return /* @__PURE__ */ React10.createElement(Combobox.Item, {
1515
1452
  value: "__create__",
1516
1453
  label: t(createOptionLabel[0], {
1517
1454
  ns: createOptionLabel[1].ns,
@@ -1525,8 +1462,8 @@ var CreateItem = ({ createOptionLabel, createOptionIcon, onCreateItemSelect }) =
1525
1462
  }
1526
1463
  });
1527
1464
  };
1528
- var ObjectPickerContent = /* @__PURE__ */ forwardRef2(({ options, selectedIds, createSchema, createOptionLabel, createOptionIcon, createInitialValuePath, onSelect, onCreate, ...props }, ref) => {
1529
- const { t } = useTranslation6(translationKey);
1465
+ var ObjectPickerContent = /* @__PURE__ */ forwardRef(({ options, selectedIds, createSchema, createOptionLabel, createOptionIcon, createInitialValuePath, onSelect, onCreate, ...props }, ref) => {
1466
+ const { t } = useTranslation5(translationKey);
1530
1467
  const [showForm, setShowForm] = useState3(false);
1531
1468
  const [formInitialValue, setFormInitialValue] = useState3("");
1532
1469
  const { results, handleSearch } = useSearchListResults({
@@ -1555,12 +1492,12 @@ var ObjectPickerContent = /* @__PURE__ */ forwardRef2(({ options, selectedIds, c
1555
1492
  }, [
1556
1493
  createSchema
1557
1494
  ]);
1558
- return /* @__PURE__ */ React11.createElement(Combobox.Content, {
1495
+ return /* @__PURE__ */ React10.createElement(Combobox.Content, {
1559
1496
  ...props,
1560
1497
  ref,
1561
1498
  onSearch: handleSearch,
1562
1499
  onKeyDownCapture: handleKeyDown
1563
- }, showForm && createSchema ? /* @__PURE__ */ React11.createElement(Popover.Viewport, null, /* @__PURE__ */ React11.createElement(Form.Root, {
1500
+ }, showForm && createSchema ? /* @__PURE__ */ React10.createElement(Popover.Viewport, null, /* @__PURE__ */ React10.createElement(Form.Root, {
1564
1501
  testId: "create-referenced-object-form",
1565
1502
  schema: createSchema,
1566
1503
  values: createInitialValuePath ? {
@@ -1568,24 +1505,24 @@ var ObjectPickerContent = /* @__PURE__ */ forwardRef2(({ options, selectedIds, c
1568
1505
  } : {},
1569
1506
  onSave: handleFormSave,
1570
1507
  onCancel: handleFormCancel
1571
- }, /* @__PURE__ */ React11.createElement(Form.Viewport, null, /* @__PURE__ */ React11.createElement(Form.Content, null, /* @__PURE__ */ React11.createElement(Form.FieldSet, null), /* @__PURE__ */ React11.createElement(Form.Actions, null))))) : /* @__PURE__ */ React11.createElement(React11.Fragment, null, /* @__PURE__ */ React11.createElement(Combobox.Input, {
1508
+ }, /* @__PURE__ */ React10.createElement(Form.Viewport, null, /* @__PURE__ */ React10.createElement(Form.Content, null, /* @__PURE__ */ React10.createElement(Form.FieldSet, null), /* @__PURE__ */ React10.createElement(Form.Actions, null))))) : /* @__PURE__ */ React10.createElement(React10.Fragment, null, /* @__PURE__ */ React10.createElement(Combobox.Input, {
1572
1509
  placeholder: t("ref field combobox input placeholder"),
1573
1510
  autoFocus: true
1574
- }), /* @__PURE__ */ React11.createElement(Combobox.List, null, results.map((option) => /* @__PURE__ */ React11.createElement(Combobox.Item, {
1511
+ }), /* @__PURE__ */ React10.createElement(Combobox.List, null, results.map((option) => /* @__PURE__ */ React10.createElement(Combobox.Item, {
1575
1512
  key: option.id,
1576
1513
  value: option.id,
1577
1514
  label: option.label,
1578
1515
  checked: selectedIds?.includes(option.id),
1579
1516
  onSelect: () => onSelect(option.id),
1580
1517
  classNames: "flex items-center gap-2"
1581
- })), createOptionLabel && createOptionIcon && createSchema && onCreate && /* @__PURE__ */ React11.createElement(CreateItem, {
1518
+ })), createOptionLabel && createOptionIcon && createSchema && onCreate && /* @__PURE__ */ React10.createElement(CreateItem, {
1582
1519
  createOptionLabel,
1583
1520
  createOptionIcon,
1584
1521
  onCreateItemSelect: (query) => {
1585
1522
  setFormInitialValue(query);
1586
1523
  setShowForm(true);
1587
1524
  }
1588
- }))), /* @__PURE__ */ React11.createElement(Combobox.Arrow, null));
1525
+ }))), /* @__PURE__ */ React10.createElement(Combobox.Arrow, null));
1589
1526
  });
1590
1527
  ObjectPickerContent.displayName = "ObjectPickerContent";
1591
1528
  var ObjectPicker = {
@@ -1600,26 +1537,33 @@ var ObjectPicker = {
1600
1537
  var isRefSnapshot = (val) => {
1601
1538
  return typeof val === "object" && typeof val?.["/"] === "string";
1602
1539
  };
1603
- var defaultGetOptions = (results) => results.map((result) => {
1540
+ var defaultGetOptions = (results, { parentLabel } = {}) => results.map((result) => {
1604
1541
  const id = Entity.getDXN(result).toString();
1605
- const label = Entity.getLabel(result);
1542
+ const parent = parentLabel ? Obj.getParent(result) : void 0;
1543
+ const label = parent ? Entity.getLabel(parent) : Entity.getLabel(result);
1606
1544
  return {
1607
1545
  id,
1608
1546
  label: label ?? id
1609
1547
  };
1610
1548
  });
1611
- var defaultResultsHook = (db, typename) => useQuery(db, typename ? Filter.typename(typename) : Filter.nothing());
1549
+ var defaultResultsHook = (db, typename) => useQuery(db, typename ? typename === Type.getTypename(Obj.Unknown) ? Filter.everything() : Filter.typename(typename) : Filter.nothing());
1612
1550
  var RefField = (props) => {
1613
1551
  const { type, readonly, label, placeholder, layout, getStatus, getValue, createOptionLabel, createOptionIcon, createInitialValuePath, db, resultsHook: useResults = defaultResultsHook, schemaHook: useSchema = useSchema$, getOptions: getOptions2 = defaultGetOptions, onCreate, onValueChange } = props;
1614
- const { t } = useTranslation7(translationKey);
1552
+ const { t } = useTranslation6(translationKey);
1615
1553
  const { status, error } = getStatus();
1616
1554
  const typename = useMemo6(() => type ? findAnnotation(type, ReferenceAnnotationId)?.typename : void 0, [
1617
1555
  type
1618
1556
  ]);
1619
1557
  const results = useResults(db, typename);
1620
- const options = useMemo6(() => getOptions2(results), [
1558
+ const options = useMemo6(() => {
1559
+ const parentLabel = type ? findAnnotation(type, ParentLabelAnnotationId) === true : false;
1560
+ return getOptions2(results, {
1561
+ parentLabel
1562
+ });
1563
+ }, [
1621
1564
  results,
1622
- getOptions2
1565
+ getOptions2,
1566
+ type
1623
1567
  ]);
1624
1568
  const handleGetValue = useCallback9(() => {
1625
1569
  const formValue = getValue();
@@ -1676,41 +1620,41 @@ var RefField = (props) => {
1676
1620
  if (!typename || (readonly || layout === "static") && !item) {
1677
1621
  return null;
1678
1622
  }
1679
- return /* @__PURE__ */ React12.createElement(Input7.Root, {
1623
+ return /* @__PURE__ */ React11.createElement(Input6.Root, {
1680
1624
  validationValence: status
1681
- }, layout !== "inline" && /* @__PURE__ */ React12.createElement(FormFieldLabel, {
1625
+ }, layout !== "inline" && /* @__PURE__ */ React11.createElement(FormFieldLabel, {
1682
1626
  error,
1683
1627
  readonly,
1684
1628
  label
1685
- }), /* @__PURE__ */ React12.createElement("div", null, readonly ? !item ? /* @__PURE__ */ React12.createElement("p", {
1686
- className: mx5(descriptionText, "mbe-2")
1687
- }, t("empty readonly ref field label")) : /* @__PURE__ */ React12.createElement(DxAnchor, {
1629
+ }), /* @__PURE__ */ React11.createElement("div", null, readonly ? !item ? /* @__PURE__ */ React11.createElement("p", {
1630
+ className: mx2("text-description", "mb-2")
1631
+ }, t("empty readonly ref field label")) : /* @__PURE__ */ React11.createElement(DxAnchor, {
1688
1632
  key: item.id,
1689
- refid: item.id,
1690
- rootclassname: "mie-1"
1691
- }, item.label) : /* @__PURE__ */ React12.createElement(ObjectPicker.Root, null, /* @__PURE__ */ React12.createElement(ObjectPicker.Trigger, {
1633
+ dxn: item.id,
1634
+ rootclassname: "me-1"
1635
+ }, item.label) : /* @__PURE__ */ React11.createElement(ObjectPicker.Root, null, /* @__PURE__ */ React11.createElement(ObjectPicker.Trigger, {
1692
1636
  asChild: true,
1693
1637
  classNames: "p-0"
1694
- }, item ? /* @__PURE__ */ React12.createElement("div", {
1695
- className: "flex gap-2 is-full"
1696
- }, /* @__PURE__ */ React12.createElement(Input7.Root, {
1638
+ }, item ? /* @__PURE__ */ React11.createElement("div", {
1639
+ className: "flex gap-2 w-full"
1640
+ }, /* @__PURE__ */ React11.createElement(Input6.Root, {
1697
1641
  key: item.id
1698
- }, /* @__PURE__ */ React12.createElement(Input7.TextInput, {
1642
+ }, /* @__PURE__ */ React11.createElement(Input6.TextInput, {
1699
1643
  value: item.label,
1700
1644
  readOnly: true,
1701
- classNames: "is-full"
1702
- }))) : /* @__PURE__ */ React12.createElement(Button2, {
1703
- classNames: "is-full text-start gap-2"
1704
- }, /* @__PURE__ */ React12.createElement("div", {
1645
+ classNames: "w-full"
1646
+ }))) : /* @__PURE__ */ React11.createElement(Button, {
1647
+ classNames: "w-full text-start gap-2"
1648
+ }, /* @__PURE__ */ React11.createElement("div", {
1705
1649
  role: "none",
1706
1650
  className: "grow overflow-hidden"
1707
- }, /* @__PURE__ */ React12.createElement("span", {
1651
+ }, /* @__PURE__ */ React11.createElement("span", {
1708
1652
  className: "flex truncate text-description"
1709
- }, placeholder ?? t("ref field placeholder"))), /* @__PURE__ */ React12.createElement(Icon2, {
1653
+ }, placeholder ?? t("ref field placeholder"))), /* @__PURE__ */ React11.createElement(Icon2, {
1710
1654
  size: 3,
1711
1655
  icon: "ph--caret-down--bold"
1712
- }))), /* @__PURE__ */ React12.createElement(ObjectPicker.Portal, null, /* @__PURE__ */ React12.createElement(ObjectPicker.Content, {
1713
- classNames: "popover-card-width",
1656
+ }))), /* @__PURE__ */ React11.createElement(ObjectPicker.Portal, null, /* @__PURE__ */ React11.createElement(ObjectPicker.Content, {
1657
+ classNames: "dx-card-popover-width",
1714
1658
  options,
1715
1659
  selectedIds,
1716
1660
  createSchema: createSchema && omitId(createSchema),
@@ -1719,12 +1663,12 @@ var RefField = (props) => {
1719
1663
  createInitialValuePath,
1720
1664
  onCreate: handleCreate,
1721
1665
  onSelect: handleSelect
1722
- })))), layout === "full" && /* @__PURE__ */ React12.createElement(Input7.DescriptionAndValidation, null, error));
1666
+ })))), layout === "full" && /* @__PURE__ */ React11.createElement(Input6.DescriptionAndValidation, null, error));
1723
1667
  };
1724
1668
 
1725
1669
  // src/components/Form/fields/SelectField.tsx
1726
- import React13, { useCallback as useCallback10 } from "react";
1727
- import { Input as Input8, Select } from "@dxos/react-ui";
1670
+ import React12, { useCallback as useCallback10 } from "react";
1671
+ import { Input as Input7, Select } from "@dxos/react-ui";
1728
1672
  var SelectField = ({ type, readonly, label, layout, placeholder, options, getStatus, getValue, onValueChange }) => {
1729
1673
  const { status, error } = getStatus();
1730
1674
  const value3 = getValue();
@@ -1735,37 +1679,37 @@ var SelectField = ({ type, readonly, label, layout, placeholder, options, getSta
1735
1679
  if ((readonly || layout === "static") && value3 == null) {
1736
1680
  return null;
1737
1681
  }
1738
- return /* @__PURE__ */ React13.createElement(Input8.Root, {
1682
+ return /* @__PURE__ */ React12.createElement(Input7.Root, {
1739
1683
  validationValence: status
1740
- }, layout !== "inline" && /* @__PURE__ */ React13.createElement(FormFieldLabel, {
1684
+ }, layout !== "inline" && /* @__PURE__ */ React12.createElement(FormFieldLabel, {
1741
1685
  error,
1742
1686
  readonly,
1743
1687
  label
1744
- }), layout === "static" ? /* @__PURE__ */ React13.createElement("p", null, options?.find(({ value: optionValue }) => optionValue === value3)?.label ?? String(value3)) : /* @__PURE__ */ React13.createElement(Select.Root, {
1688
+ }), layout === "static" ? /* @__PURE__ */ React12.createElement("p", null, options?.find(({ value: optionValue }) => optionValue === value3)?.label ?? String(value3)) : /* @__PURE__ */ React12.createElement(Select.Root, {
1745
1689
  value: value3,
1746
1690
  onValueChange: handleValueChange
1747
- }, /* @__PURE__ */ React13.createElement(Select.TriggerButton, {
1748
- classNames: "is-full",
1691
+ }, /* @__PURE__ */ React12.createElement(Select.TriggerButton, {
1692
+ classNames: "w-full",
1749
1693
  disabled: !!readonly,
1750
1694
  placeholder
1751
- }), /* @__PURE__ */ React13.createElement(Select.Portal, null, /* @__PURE__ */ React13.createElement(Select.Content, null, /* @__PURE__ */ React13.createElement(Select.Viewport, null, options?.map(({ value: value4, label: label2 }) => (
1695
+ }), /* @__PURE__ */ React12.createElement(Select.Portal, null, /* @__PURE__ */ React12.createElement(Select.Content, null, /* @__PURE__ */ React12.createElement(Select.Viewport, null, options?.map(({ value: value4, label: label2 }) => (
1752
1696
  // NOTE: Numeric values are converted to and from strings.
1753
- /* @__PURE__ */ React13.createElement(Select.Option, {
1697
+ /* @__PURE__ */ React12.createElement(Select.Option, {
1754
1698
  key: String(value4),
1755
1699
  value: String(value4)
1756
1700
  }, label2 ?? String(value4))
1757
- ))), /* @__PURE__ */ React13.createElement(Select.Arrow, null)))), layout === "full" && /* @__PURE__ */ React13.createElement(Input8.DescriptionAndValidation, null, error));
1701
+ ))), /* @__PURE__ */ React12.createElement(Select.Arrow, null)))), layout === "full" && /* @__PURE__ */ React12.createElement(Input7.DescriptionAndValidation, null, error));
1758
1702
  };
1759
1703
 
1760
1704
  // src/components/Form/fields/SelectOptionField.tsx
1761
- import React14, { useCallback as useCallback11, useEffect as useEffect6, useRef as useRef3, useState as useState4 } from "react";
1705
+ import React13, { useCallback as useCallback11, useEffect as useEffect6, useRef as useRef3, useState as useState4 } from "react";
1762
1706
  import { PublicKey } from "@dxos/keys";
1763
- import { IconButton as IconButton3, Input as Input9, Tag, useTranslation as useTranslation8 } from "@dxos/react-ui";
1707
+ import { IconButton as IconButton3, Input as Input8, Tag, useTranslation as useTranslation7 } from "@dxos/react-ui";
1764
1708
  import { List } from "@dxos/react-ui-list";
1765
1709
  import { HuePicker } from "@dxos/react-ui-pickers";
1766
1710
  import { hues, osTranslations, subtleHover } from "@dxos/ui-theme";
1767
1711
  var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueChange }) => {
1768
- const { t } = useTranslation8(translationKey);
1712
+ const { t } = useTranslation7(translationKey);
1769
1713
  const { status, error } = getStatus();
1770
1714
  const [selected, setSelectedId] = useState4(null);
1771
1715
  const [isNewOption, setIsNewOption] = useState4(false);
@@ -1871,42 +1815,42 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
1871
1815
  selected,
1872
1816
  isNewOption
1873
1817
  ]);
1874
- return /* @__PURE__ */ React14.createElement(Input9.Root, {
1818
+ return /* @__PURE__ */ React13.createElement(Input8.Root, {
1875
1819
  validationValence: status
1876
- }, /* @__PURE__ */ React14.createElement(FormFieldLabel, {
1820
+ }, /* @__PURE__ */ React13.createElement(FormFieldLabel, {
1877
1821
  error,
1878
1822
  readonly,
1879
1823
  label
1880
- }), /* @__PURE__ */ React14.createElement("div", {
1824
+ }), /* @__PURE__ */ React13.createElement("div", {
1881
1825
  role: "none"
1882
- }, options && /* @__PURE__ */ React14.createElement(List.Root, {
1826
+ }, options && /* @__PURE__ */ React13.createElement(List.Root, {
1883
1827
  items: options,
1884
1828
  isItem: (_item) => true,
1885
1829
  onMove: readonly ? void 0 : handleMove,
1886
1830
  readonly: !!readonly
1887
- }, ({ items }) => /* @__PURE__ */ React14.createElement("div", {
1831
+ }, ({ items }) => /* @__PURE__ */ React13.createElement("div", {
1888
1832
  role: "list",
1889
- className: "is-full overflow-auto"
1890
- }, items?.map((item) => /* @__PURE__ */ React14.createElement("div", {
1833
+ className: "w-full overflow-auto"
1834
+ }, items?.map((item) => /* @__PURE__ */ React13.createElement("div", {
1891
1835
  key: item.id
1892
- }, /* @__PURE__ */ React14.createElement(List.Item, {
1836
+ }, /* @__PURE__ */ React13.createElement(List.Item, {
1893
1837
  role: "button",
1894
1838
  item,
1895
1839
  classNames: [
1896
1840
  subtleHover,
1897
- "flex flex-col cursor-pointer rounded-sm"
1841
+ "flex flex-col cursor-pointer rounded-xs"
1898
1842
  ],
1899
1843
  "aria-expanded": selected === item.id
1900
- }, /* @__PURE__ */ React14.createElement("div", {
1844
+ }, /* @__PURE__ */ React13.createElement("div", {
1901
1845
  className: "flex items-center"
1902
- }, /* @__PURE__ */ React14.createElement(List.ItemDragHandle, {
1846
+ }, /* @__PURE__ */ React13.createElement(List.ItemDragHandle, {
1903
1847
  disabled: !!readonly
1904
- }), /* @__PURE__ */ React14.createElement(List.ItemTitle, {
1848
+ }), /* @__PURE__ */ React13.createElement(List.ItemTitle, {
1905
1849
  onClick: () => handleClick(item.id),
1906
1850
  classNames: "flex-1"
1907
- }, /* @__PURE__ */ React14.createElement(Tag, {
1851
+ }, /* @__PURE__ */ React13.createElement(Tag, {
1908
1852
  palette: item.color
1909
- }, item.title || "\u200B")), /* @__PURE__ */ React14.createElement(IconButton3, {
1853
+ }, item.title || "\u200B")), /* @__PURE__ */ React13.createElement(IconButton3, {
1910
1854
  iconOnly: true,
1911
1855
  variant: "ghost",
1912
1856
  label: t(selected === item.id ? "collapse label" : "expand label", {
@@ -1914,13 +1858,13 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
1914
1858
  }),
1915
1859
  icon: selected === item.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
1916
1860
  onClick: () => handleClick(item.id)
1917
- })), selected === item.id && /* @__PURE__ */ React14.createElement("div", {
1918
- className: "pli-cardSpacingInline plb-cardSpacingBlock flex flex-col gap-1 density-fine"
1919
- }, /* @__PURE__ */ React14.createElement(Input9.Label, {
1861
+ })), selected === item.id && /* @__PURE__ */ React13.createElement("div", {
1862
+ className: "flex flex-col p-form-padding gap-1 dx-density-fine"
1863
+ }, /* @__PURE__ */ React13.createElement(Input8.Label, {
1920
1864
  classNames: "text-xs"
1921
- }, t("select option label")), /* @__PURE__ */ React14.createElement("div", {
1865
+ }, t("select option label")), /* @__PURE__ */ React13.createElement("div", {
1922
1866
  className: "grid grid-cols-[1fr_min-content_min-content] gap-1"
1923
- }, /* @__PURE__ */ React14.createElement(Input9.TextInput, {
1867
+ }, /* @__PURE__ */ React13.createElement(Input8.TextInput, {
1924
1868
  disabled: !!readonly,
1925
1869
  placeholder: t("select option label placeholder"),
1926
1870
  ref: selected === item.id ? inputRef : void 0,
@@ -1928,38 +1872,38 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
1928
1872
  onChange: handleTitleChange(item.id),
1929
1873
  onKeyDown: handleKeyDown,
1930
1874
  classNames: "flex-1"
1931
- }), /* @__PURE__ */ React14.createElement(HuePicker, {
1875
+ }), /* @__PURE__ */ React13.createElement(HuePicker, {
1932
1876
  disabled: !!readonly,
1933
1877
  value: item.color,
1934
1878
  onChange: handleColorChange(item.id)
1935
- }), /* @__PURE__ */ React14.createElement(IconButton3, {
1879
+ }), /* @__PURE__ */ React13.createElement(IconButton3, {
1936
1880
  disabled: !!readonly,
1937
1881
  icon: "ph--trash--fill",
1938
1882
  iconOnly: true,
1939
1883
  label: t("select option delete"),
1940
1884
  onClick: () => handleDelete(item.id)
1941
- })))))), /* @__PURE__ */ React14.createElement(IconButton3, {
1885
+ })))))), /* @__PURE__ */ React13.createElement(IconButton3, {
1942
1886
  variant: "ghost",
1943
1887
  icon: "ph--plus--regular",
1944
1888
  label: t("select option add"),
1945
1889
  onClick: handleAdd,
1946
1890
  disabled: !!readonly,
1947
- classNames: "is-full"
1891
+ classNames: "w-full"
1948
1892
  })))));
1949
1893
  };
1950
1894
 
1951
1895
  // src/components/Form/fields/TextField.tsx
1952
- import React15, { useCallback as useCallback12 } from "react";
1953
- import { Input as Input10 } from "@dxos/react-ui";
1896
+ import React14, { useCallback as useCallback12 } from "react";
1897
+ import { Input as Input9 } from "@dxos/react-ui";
1954
1898
  var TextField = ({ type, readonly, placeholder, onValueChange, onBlur, ...props }) => {
1955
1899
  const handleChange = useCallback12((event) => onValueChange(type, event.target.value), [
1956
1900
  type,
1957
1901
  onValueChange
1958
1902
  ]);
1959
- return /* @__PURE__ */ React15.createElement(FormFieldWrapper, {
1903
+ return /* @__PURE__ */ React14.createElement(FormFieldWrapper, {
1960
1904
  readonly,
1961
1905
  ...props
1962
- }, ({ value: value3 = "" }) => /* @__PURE__ */ React15.createElement(Input10.TextInput, {
1906
+ }, ({ value: value3 = "" }) => /* @__PURE__ */ React14.createElement(Input9.TextInput, {
1963
1907
  noAutoFill: true,
1964
1908
  disabled: !!readonly,
1965
1909
  placeholder,
@@ -1970,17 +1914,17 @@ var TextField = ({ type, readonly, placeholder, onValueChange, onBlur, ...props
1970
1914
  };
1971
1915
 
1972
1916
  // src/components/Form/fields/TextAreaField.tsx
1973
- import React16, { useCallback as useCallback13 } from "react";
1974
- import { Input as Input11 } from "@dxos/react-ui";
1917
+ import React15, { useCallback as useCallback13 } from "react";
1918
+ import { Input as Input10 } from "@dxos/react-ui";
1975
1919
  var TextAreaField = ({ type, readonly, placeholder, onValueChange, onBlur, ...props }) => {
1976
1920
  const handleChange = useCallback13((event) => onValueChange(type, event.target.value), [
1977
1921
  type,
1978
1922
  onValueChange
1979
1923
  ]);
1980
- return /* @__PURE__ */ React16.createElement(FormFieldWrapper, {
1924
+ return /* @__PURE__ */ React15.createElement(FormFieldWrapper, {
1981
1925
  readonly,
1982
1926
  ...props
1983
- }, ({ value: value3 = "" }) => /* @__PURE__ */ React16.createElement(Input11.TextArea, {
1927
+ }, ({ value: value3 = "" }) => /* @__PURE__ */ React15.createElement(Input10.TextArea, {
1984
1928
  rows: 3,
1985
1929
  disabled: !!readonly,
1986
1930
  placeholder,
@@ -1991,9 +1935,9 @@ var TextAreaField = ({ type, readonly, placeholder, onValueChange, onBlur, ...pr
1991
1935
  };
1992
1936
 
1993
1937
  // src/components/Form/fields/TupleField.tsx
1994
- import React17 from "react";
1995
- import { Input as Input12 } from "@dxos/react-ui";
1996
- import { mx as mx6 } from "@dxos/ui-theme";
1938
+ import React16 from "react";
1939
+ import { Input as Input11 } from "@dxos/react-ui";
1940
+ import { mx as mx3 } from "@dxos/ui-theme";
1997
1941
  import { safeParseFloat as safeParseFloat3 } from "@dxos/util";
1998
1942
  var gridCols = [
1999
1943
  "grid-cols-1",
@@ -2004,15 +1948,15 @@ var gridCols = [
2004
1948
  var TupleField = ({ binding, type, readonly, label, getStatus, getValue, onValueChange, onBlur }) => {
2005
1949
  const { status, error } = getStatus();
2006
1950
  const values = getValue() ?? {};
2007
- return /* @__PURE__ */ React17.createElement(Input12.Root, {
1951
+ return /* @__PURE__ */ React16.createElement(Input11.Root, {
2008
1952
  validationValence: status
2009
- }, /* @__PURE__ */ React17.createElement(FormFieldLabel, {
1953
+ }, /* @__PURE__ */ React16.createElement(FormFieldLabel, {
2010
1954
  error,
2011
1955
  readonly,
2012
1956
  label
2013
- }), /* @__PURE__ */ React17.createElement("div", {
2014
- className: mx6("grid gap-2", gridCols[binding.length - 1])
2015
- }, binding.map((prop) => /* @__PURE__ */ React17.createElement(Input12.TextInput, {
1957
+ }), /* @__PURE__ */ React16.createElement("div", {
1958
+ className: mx3("grid gap-2", gridCols[binding.length - 1])
1959
+ }, binding.map((prop) => /* @__PURE__ */ React16.createElement(Input11.TextInput, {
2016
1960
  key: prop,
2017
1961
  type: "number",
2018
1962
  disabled: !!readonly,
@@ -2030,7 +1974,7 @@ var TupleField = ({ binding, type, readonly, label, getStatus, getValue, onValue
2030
1974
  // src/components/FieldEditor/FieldEditor.tsx
2031
1975
  var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx";
2032
1976
  var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCancel }) => {
2033
- const { t } = useTranslation9(translationKey);
1977
+ const { t } = useTranslation8(translationKey);
2034
1978
  const [props, setProps] = useState5(projection.getFieldProjection(field.id).props);
2035
1979
  useEffect7(() => setProps(projection.getFieldProjection(field.id).props), [
2036
1980
  field,
@@ -2061,26 +2005,26 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
2061
2005
  fieldSchema: getFormatSchema(props?.format)
2062
2006
  });
2063
2007
  const fieldMap = useMemo7(() => ({
2064
- ["format"]: (props2) => /* @__PURE__ */ React18.createElement(SelectField, {
2008
+ ["format"]: (props2) => /* @__PURE__ */ React17.createElement(SelectField, {
2065
2009
  ...props2,
2066
2010
  options: FormatEnums.filter((value3) => value3 !== Format4.TypeFormat.None).map((value3) => ({
2067
2011
  value: value3,
2068
2012
  label: t(`format ${value3}`)
2069
2013
  }))
2070
2014
  }),
2071
- ["referenceSchema"]: (props2) => /* @__PURE__ */ React18.createElement(SelectField, {
2015
+ ["referenceSchema"]: (props2) => /* @__PURE__ */ React17.createElement(SelectField, {
2072
2016
  ...props2,
2073
2017
  options: schemas.map((schema) => ({
2074
2018
  value: schema.typename
2075
2019
  }))
2076
2020
  }),
2077
- ["referencePath"]: (props2) => /* @__PURE__ */ React18.createElement(SelectField, {
2021
+ ["referencePath"]: (props2) => /* @__PURE__ */ React17.createElement(SelectField, {
2078
2022
  ...props2,
2079
2023
  options: referenceSchema ? getFormProperties(referenceSchema.ast).sort((a, b) => a.name.toString().localeCompare(b.name.toString())).map((p) => ({
2080
2024
  value: p.name.toString()
2081
2025
  })) : []
2082
2026
  }),
2083
- ["options"]: (props2) => /* @__PURE__ */ React18.createElement(SelectOptionField, props2)
2027
+ ["options"]: (props2) => /* @__PURE__ */ React17.createElement(SelectOptionField, props2)
2084
2028
  }), [
2085
2029
  t,
2086
2030
  schemas,
@@ -2139,7 +2083,7 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
2139
2083
  ]);
2140
2084
  const handleSave = useCallback14((props2) => {
2141
2085
  if (view) {
2142
- Obj3.change(view, () => {
2086
+ Obj2.change(view, () => {
2143
2087
  projection.setFieldProjection({
2144
2088
  field,
2145
2089
  props: props2
@@ -2169,13 +2113,13 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
2169
2113
  props
2170
2114
  }, {
2171
2115
  F: __dxlog_file2,
2172
- L: 173,
2116
+ L: 172,
2173
2117
  S: void 0,
2174
2118
  C: (f, a) => f(...a)
2175
2119
  });
2176
2120
  return null;
2177
2121
  }
2178
- return /* @__PURE__ */ React18.createElement(Form.Root, {
2122
+ return /* @__PURE__ */ React17.createElement(Form.Root, {
2179
2123
  key: field.id,
2180
2124
  fieldMap,
2181
2125
  autoFocus: true,
@@ -2191,7 +2135,139 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
2191
2135
  onValidate: handleValidate,
2192
2136
  onSave: handleSave,
2193
2137
  onCancel: handleCancel
2194
- }, /* @__PURE__ */ React18.createElement(Form.Content, null, /* @__PURE__ */ React18.createElement(Form.FieldSet, null), /* @__PURE__ */ React18.createElement(Form.Actions, null)));
2138
+ }, /* @__PURE__ */ React17.createElement(Form.Content, null, /* @__PURE__ */ React17.createElement(Form.FieldSet, null), /* @__PURE__ */ React17.createElement(Form.Actions, null)));
2139
+ };
2140
+
2141
+ // src/components/Settings/Settings.tsx
2142
+ import React18 from "react";
2143
+ import { Button as Button2, Input as Input12, ScrollArea as ScrollArea2, toLocalizedString, useTranslation as useTranslation9 } from "@dxos/react-ui";
2144
+ import { mx as mx4 } from "@dxos/ui-theme";
2145
+ var SETTINGS_ROOT_NAME = "Settings.Root";
2146
+ var SETTINGS_SECTION_NAME = "Settings.Section";
2147
+ var SETTINGS_SECTION_HEADING_NAME = "Settings.SectionHeading";
2148
+ var SETTINGS_GROUP_NAME = "Settings.Group";
2149
+ var SETTINGS_GROUP_BUTTON_NAME = "Settings.GroupButton";
2150
+ var SETTINGS_CONTAINER_NAME = "Settings.Container";
2151
+ var SETTINGS_FRAME_NAME = "Settings.Frame";
2152
+ var SETTINGS_FRAME_ITEM_NAME = "Settings.FrameItem";
2153
+ var SETTINGS_ITEM_NAME = "Settings.Item";
2154
+ var SETTINGS_ITEM_INPUT_NAME = "Settings.ItemInput";
2155
+ var styles = {
2156
+ title: "pb-trim-md text-base-surface-text text-lg",
2157
+ description: "text-base text-description",
2158
+ grid: "grid grid-cols-1 md:grid-cols-[1fr_1fr] gap-x-trim-lg"
2159
+ };
2160
+ var SettingsRoot = ({ children }) => {
2161
+ return /* @__PURE__ */ React18.createElement(ScrollArea2.Root, {
2162
+ className: "dx-document",
2163
+ orientation: "vertical",
2164
+ margin: true
2165
+ }, /* @__PURE__ */ React18.createElement(ScrollArea2.Viewport, {
2166
+ classNames: "p-trim-md"
2167
+ }, children));
2168
+ };
2169
+ SettingsRoot.displayName = SETTINGS_ROOT_NAME;
2170
+ var SettingsSection = ({ title, description, children }) => {
2171
+ return /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement(SettingsSectionHeading, {
2172
+ title,
2173
+ description
2174
+ }), /* @__PURE__ */ React18.createElement("div", {
2175
+ className: "w-full pt-trim-md space-y-trim-md"
2176
+ }, children));
2177
+ };
2178
+ SettingsSection.displayName = SETTINGS_SECTION_NAME;
2179
+ var SettingsSectionHeading = ({ title, description }) => {
2180
+ const { t } = useTranslation9(translationKey);
2181
+ return /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement("h2", {
2182
+ className: "px-trim-md mt-trim-md mb-trim-md text-xl"
2183
+ }, toLocalizedString(title, t)), description && /* @__PURE__ */ React18.createElement("p", {
2184
+ className: "px-trim-md my-trim-md text-description"
2185
+ }, toLocalizedString(description, t)));
2186
+ };
2187
+ SettingsSectionHeading.displayName = SETTINGS_SECTION_HEADING_NAME;
2188
+ var SettingsGroupButton = ({ classNames, ...props }) => {
2189
+ return /* @__PURE__ */ React18.createElement(Button2, {
2190
+ ...props,
2191
+ classNames: [
2192
+ "md:col-span-2",
2193
+ classNames
2194
+ ]
2195
+ });
2196
+ };
2197
+ SettingsGroupButton.displayName = SETTINGS_GROUP_BUTTON_NAME;
2198
+ var SettingsGroup = ({ children, classNames }) => /* @__PURE__ */ React18.createElement("div", {
2199
+ role: "none",
2200
+ className: mx4("group space-y-trim-md", classNames)
2201
+ }, children);
2202
+ SettingsGroup.displayName = SETTINGS_GROUP_NAME;
2203
+ var SettingsFrame = ({ children }) => /* @__PURE__ */ React18.createElement("div", {
2204
+ role: "none",
2205
+ className: "p-trim-md border border-separator rounded-md"
2206
+ }, children);
2207
+ SettingsFrame.displayName = SETTINGS_FRAME_NAME;
2208
+ var SettingsFrameItem = ({ title, description, children }) => {
2209
+ const { t } = useTranslation9(translationKey);
2210
+ return /* @__PURE__ */ React18.createElement("div", {
2211
+ role: "group",
2212
+ className: "min-w-0"
2213
+ }, /* @__PURE__ */ React18.createElement("h3", {
2214
+ className: "text-lg mb-2"
2215
+ }, toLocalizedString(title, t)), description && /* @__PURE__ */ React18.createElement("p", {
2216
+ className: "my-trim-sm md:mb-0 text-description"
2217
+ }, toLocalizedString(description, t)), children);
2218
+ };
2219
+ SettingsFrameItem.displayName = SETTINGS_FRAME_ITEM_NAME;
2220
+ var SettingsContainer = ({ classNames, children }) => {
2221
+ return /* @__PURE__ */ React18.createElement("div", {
2222
+ role: "none",
2223
+ className: mx4([
2224
+ "dx-document",
2225
+ "*:first:mt-0! *:last:mb-0! px-trim-md py-trim-md",
2226
+ "border border-separator rounded-md",
2227
+ classNames
2228
+ ])
2229
+ }, children);
2230
+ };
2231
+ SettingsContainer.displayName = SETTINGS_CONTAINER_NAME;
2232
+ var SettingsItem = ({ title, description = "", children }) => {
2233
+ const { t } = useTranslation9(translationKey);
2234
+ return /* @__PURE__ */ React18.createElement(SettingsContainer, {
2235
+ classNames: styles.grid
2236
+ }, /* @__PURE__ */ React18.createElement("h3", {
2237
+ className: mx4(styles.title, "md:col-span-2")
2238
+ }, toLocalizedString(title, t)), /* @__PURE__ */ React18.createElement("p", {
2239
+ className: styles.description
2240
+ }, toLocalizedString(description, t)), /* @__PURE__ */ React18.createElement("div", {
2241
+ role: "none",
2242
+ className: "overflow-hidden text-end py-1"
2243
+ }, children));
2244
+ };
2245
+ SettingsItem.displayName = SETTINGS_ITEM_NAME;
2246
+ var SettingsItemInput = ({ title, description = "", children }) => {
2247
+ const { t } = useTranslation9(translationKey);
2248
+ return /* @__PURE__ */ React18.createElement(Input12.Root, null, /* @__PURE__ */ React18.createElement(SettingsContainer, {
2249
+ classNames: styles.grid
2250
+ }, /* @__PURE__ */ React18.createElement(Input12.Label, {
2251
+ classNames: mx4(styles.title, "md:col-span-2")
2252
+ }, toLocalizedString(title, t)), /* @__PURE__ */ React18.createElement(Input12.DescriptionAndValidation, null, /* @__PURE__ */ React18.createElement(Input12.Description, {
2253
+ classNames: styles.description
2254
+ }, toLocalizedString(description, t))), /* @__PURE__ */ React18.createElement("div", {
2255
+ role: "none",
2256
+ className: "text-end py-1"
2257
+ }, children)));
2258
+ };
2259
+ SettingsItemInput.displayName = SETTINGS_ITEM_INPUT_NAME;
2260
+ var Settings = {
2261
+ Root: SettingsRoot,
2262
+ Section: SettingsSection,
2263
+ SectionHeading: SettingsSectionHeading,
2264
+ Group: SettingsGroup,
2265
+ GroupButton: SettingsGroupButton,
2266
+ Container: SettingsContainer,
2267
+ Frame: SettingsFrame,
2268
+ FrameItem: SettingsFrameItem,
2269
+ Item: SettingsItem,
2270
+ ItemInput: SettingsItemInput
2195
2271
  };
2196
2272
 
2197
2273
  // src/components/ViewEditor/ViewEditor.tsx
@@ -2200,20 +2276,19 @@ import * as Array2 from "effect/Array";
2200
2276
  import * as Match2 from "effect/Match";
2201
2277
  import * as Option4 from "effect/Option";
2202
2278
  import * as Schema3 from "effect/Schema";
2203
- import React19, { forwardRef as forwardRef3, useCallback as useCallback15, useContext, useImperativeHandle, useMemo as useMemo8, useState as useState6 } from "react";
2204
- import { Filter as Filter2, Format as Format5, Obj as Obj4, Query, QueryAST } from "@dxos/echo";
2279
+ import React19, { forwardRef as forwardRef2, useCallback as useCallback15, useContext, useImperativeHandle, useMemo as useMemo8, useState as useState6 } from "react";
2280
+ import { Entity as Entity2, Feed, Filter as Filter2, Format as Format5, Obj as Obj3, Query, QueryAST, Ref as Ref3 } from "@dxos/echo";
2281
+ import { View } from "@dxos/echo";
2205
2282
  import { EchoSchema, isMutable, toJsonSchema } from "@dxos/echo/internal";
2206
2283
  import { invariant } from "@dxos/invariant";
2207
- import { useObject } from "@dxos/react-client/echo";
2208
- import { Callout, IconButton as IconButton4, Input as Input13, useTranslation as useTranslation10 } from "@dxos/react-ui";
2284
+ import { useObject, useQuery as useQuery2 } from "@dxos/react-client/echo";
2285
+ import { IconButton as IconButton4, Input as Input13, Message, useTranslation as useTranslation10 } from "@dxos/react-ui";
2209
2286
  import { QueryForm } from "@dxos/react-ui-components";
2210
2287
  import { List as List2 } from "@dxos/react-ui-list";
2211
- import { FieldSchema, ProjectionModel, VIEW_FIELD_LIMIT, createEchoChangeCallback, getTypenameFromQuery } from "@dxos/schema";
2212
- import { mx as mx7, osTranslations as osTranslations2, subtleHover as subtleHover2 } from "@dxos/ui-theme";
2288
+ import { ParentLabelAnnotation, ProjectionModel, VIEW_FIELD_LIMIT, createEchoChangeCallback, getTypenameFromQuery } from "@dxos/schema";
2289
+ import { mx as mx5, osTranslations as osTranslations2, subtleHover as subtleHover2 } from "@dxos/ui-theme";
2213
2290
  var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx";
2214
- var listGrid = "grid grid-cols-[min-content_1fr_min-content_min-content_min-content]";
2215
- var listItemGrid = "grid grid-cols-subgrid col-span-5";
2216
- var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode = "schema", registry, readonly, showHeading = false, types, tags, onQueryChanged, onDelete }, forwardedRef) => {
2291
+ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode = "schema", registry, db, readonly, showHeading = false, types, tags, onQueryChanged, onDelete }, forwardedRef) => {
2217
2292
  const atomRegistry = useContext(RegistryContext);
2218
2293
  const schemaReadonly = !isMutable(schema);
2219
2294
  const { t } = useTranslation10(translationKey);
@@ -2235,12 +2310,25 @@ var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode =
2235
2310
  useImperativeHandle(forwardedRef, () => projectionModel, [
2236
2311
  projectionModel
2237
2312
  ]);
2238
- const [expandedField, setExpandedField] = useState6();
2239
2313
  const queueTarget = Match2.value(view.query.ast).pipe(Match2.when({
2240
- type: "options"
2241
- }, ({ options }) => {
2242
- return Option4.fromNullable(options.queues).pipe(Option4.flatMap((queues) => Array2.head(queues)), Option4.getOrUndefined);
2314
+ type: "from"
2315
+ }, ({ from }) => {
2316
+ if (from._tag !== "scope") {
2317
+ return void 0;
2318
+ }
2319
+ return Option4.fromNullable(from.scope.queues).pipe(Option4.flatMap((queues) => Array2.head(queues)), Option4.map(String), Option4.getOrUndefined);
2243
2320
  }), Match2.orElse(() => void 0));
2321
+ const feeds = useQuery2(db, Filter2.type(Feed.Feed));
2322
+ const targetRef = useMemo8(() => {
2323
+ if (!queueTarget) {
2324
+ return void 0;
2325
+ }
2326
+ const feed = feeds.find((feed2) => Feed.getQueueDxn(feed2)?.toString() === queueTarget);
2327
+ return feed ? Ref3.fromDXN(Entity2.getDXN(feed)) : void 0;
2328
+ }, [
2329
+ queueTarget,
2330
+ feeds
2331
+ ]);
2244
2332
  const viewSchema = useMemo8(() => {
2245
2333
  const base = Schema3.Struct({
2246
2334
  query: mode === "schema" ? Format5.URL.annotations({
@@ -2252,9 +2340,10 @@ var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode =
2252
2340
  if (mode === "tag") {
2253
2341
  return Schema3.Struct({
2254
2342
  ...base.fields,
2255
- target: Schema3.optional(Schema3.String.annotations({
2256
- title: "Target Queue"
2257
- }))
2343
+ // TODO(wittjosiah): Replace Type.Feed with Dataset.Dataset when Ref.Ref supports unions.
2344
+ target: Ref3.Ref(Feed.Feed).pipe(Schema3.annotations({
2345
+ title: "Target Feed"
2346
+ }), ParentLabelAnnotation.set(true), Schema3.optional)
2258
2347
  }).pipe(Schema3.mutable);
2259
2348
  }
2260
2349
  return base.pipe(Schema3.mutable);
@@ -2263,11 +2352,11 @@ var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode =
2263
2352
  ]);
2264
2353
  const viewValues = useMemo8(() => ({
2265
2354
  query: mode === "schema" ? getTypenameFromQuery(view.query.ast) : view.query.ast,
2266
- target: queueTarget
2355
+ target: targetRef
2267
2356
  }), [
2268
2357
  mode,
2269
2358
  view.query.ast,
2270
- queueTarget
2359
+ targetRef
2271
2360
  ]);
2272
2361
  const fieldMap = useMemo8(() => mode === "tag" ? customFields({
2273
2362
  types,
@@ -2277,64 +2366,50 @@ var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode =
2277
2366
  types,
2278
2367
  tags
2279
2368
  ]);
2280
- const handleAdd = useCallback15(() => {
2281
- invariant(!readonly, void 0, {
2282
- F: __dxlog_file3,
2283
- L: 146,
2284
- S: void 0,
2285
- A: [
2286
- "!readonly",
2287
- ""
2288
- ]
2289
- });
2290
- const field = projectionModel.createFieldProjection();
2291
- setExpandedField(field.id);
2292
- }, [
2293
- projectionModel,
2294
- readonly
2295
- ]);
2296
2369
  const handleUpdate = useCallback15((values) => {
2297
- requestAnimationFrame(() => {
2298
- const query = mode === "schema" ? Query.select(Filter2.typename(values.query)).ast : values.query;
2299
- onQueryChanged?.(query, values.target);
2300
- });
2370
+ const targetValue = values.target;
2371
+ let queueDxn;
2372
+ if (Ref3.isRef(targetValue)) {
2373
+ const feedDxn = targetValue.dxn.toString();
2374
+ const feed = feeds.find((feed2) => Obj3.getDXN(feed2).toString() === feedDxn);
2375
+ if (feed) {
2376
+ queueDxn = Feed.getQueueDxn(feed)?.toString();
2377
+ }
2378
+ }
2379
+ const query = mode === "schema" ? Query.select(Filter2.typename(values.query)).ast : JSON.parse(JSON.stringify(values.query));
2380
+ onQueryChanged?.(query, queueDxn);
2301
2381
  }, [
2302
2382
  onQueryChanged,
2303
- view,
2304
- queueTarget,
2305
- mode
2383
+ mode,
2384
+ feeds
2306
2385
  ]);
2307
2386
  const handleDelete = useCallback15((fieldId) => {
2308
2387
  invariant(!readonly, void 0, {
2309
2388
  F: __dxlog_file3,
2310
- L: 163,
2389
+ L: 185,
2311
2390
  S: void 0,
2312
2391
  A: [
2313
2392
  "!readonly",
2314
2393
  ""
2315
2394
  ]
2316
2395
  });
2317
- if (fieldId === expandedField) {
2318
- setExpandedField(void 0);
2319
- }
2320
2396
  onDelete?.(fieldId);
2321
2397
  }, [
2322
- expandedField,
2323
2398
  onDelete,
2324
2399
  readonly
2325
2400
  ]);
2326
2401
  return /* @__PURE__ */ React19.createElement("div", {
2327
2402
  role: "none",
2328
- className: mx7(classNames)
2329
- }, schemaReadonly && !readonly && /* @__PURE__ */ React19.createElement(Callout.Root, {
2403
+ className: mx5(classNames)
2404
+ }, schemaReadonly && !readonly && /* @__PURE__ */ React19.createElement(Message.Root, {
2330
2405
  valence: "info",
2331
- classNames: "mlb-cardSpacingBlock"
2332
- }, /* @__PURE__ */ React19.createElement(Callout.Title, null, t("system schema description"))), /* @__PURE__ */ React19.createElement(Form.Root, {
2406
+ classNames: "my-form-padding"
2407
+ }, /* @__PURE__ */ React19.createElement(Message.Title, null, t("system schema description"))), /* @__PURE__ */ React19.createElement(Form.Root, {
2333
2408
  schema: viewSchema,
2334
2409
  values: viewValues,
2335
2410
  fieldMap,
2336
- autoSave: true,
2337
- onSave: handleUpdate
2411
+ db,
2412
+ onValuesChanged: handleUpdate
2338
2413
  }, /* @__PURE__ */ React19.createElement(Form.FieldSet, null), /* @__PURE__ */ React19.createElement(FormFieldLabel, {
2339
2414
  label: t("fields label"),
2340
2415
  asChild: true
@@ -2345,16 +2420,6 @@ var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode =
2345
2420
  readonly,
2346
2421
  showHeading,
2347
2422
  onDelete: handleDelete
2348
- })), !readonly && !expandedField && /* @__PURE__ */ React19.createElement("div", {
2349
- role: "none",
2350
- className: "mlb-cardSpacingBlock"
2351
- }, /* @__PURE__ */ React19.createElement(IconButton4, {
2352
- icon: "ph--plus--regular",
2353
- label: t("add property button label"),
2354
- onClick: readonly ? void 0 : handleAdd,
2355
- // TODO(burdon): Show field limit in ux (not tooltip).
2356
- disabled: view.projection.fields.length >= VIEW_FIELD_LIMIT,
2357
- classNames: "is-full"
2358
2423
  })));
2359
2424
  });
2360
2425
  var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDelete }) => {
@@ -2378,6 +2443,22 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
2378
2443
  view
2379
2444
  ]);
2380
2445
  const [expandedField, setExpandedField] = useState6();
2446
+ const handleAdd = useCallback15(() => {
2447
+ invariant(!readonly, void 0, {
2448
+ F: __dxlog_file3,
2449
+ L: 250,
2450
+ S: void 0,
2451
+ A: [
2452
+ "!readonly",
2453
+ ""
2454
+ ]
2455
+ });
2456
+ const field = projectionModel.createFieldProjection();
2457
+ setExpandedField(field.id);
2458
+ }, [
2459
+ projectionModel,
2460
+ readonly
2461
+ ]);
2381
2462
  const handleToggleField = useCallback15((field) => {
2382
2463
  setExpandedField((prevExpandedFieldId) => prevExpandedFieldId === field.id ? void 0 : field.id);
2383
2464
  }, [
@@ -2386,7 +2467,7 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
2386
2467
  const handleDelete = useCallback15((fieldId) => {
2387
2468
  invariant(!readonly, void 0, {
2388
2469
  F: __dxlog_file3,
2389
- L: 253,
2470
+ L: 264,
2390
2471
  S: void 0,
2391
2472
  A: [
2392
2473
  "!readonly",
@@ -2405,14 +2486,14 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
2405
2486
  const handleMove = useCallback15((fromIndex, toIndex) => {
2406
2487
  invariant(!readonly, void 0, {
2407
2488
  F: __dxlog_file3,
2408
- L: 265,
2489
+ L: 276,
2409
2490
  S: void 0,
2410
2491
  A: [
2411
2492
  "!readonly",
2412
2493
  ""
2413
2494
  ]
2414
2495
  });
2415
- Obj4.change(view, (v) => {
2496
+ Obj3.change(view, (v) => {
2416
2497
  const fields = [
2417
2498
  ...v.projection.fields
2418
2499
  ];
@@ -2442,7 +2523,7 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
2442
2523
  }
2443
2524
  return /* @__PURE__ */ React19.createElement(List2.Root, {
2444
2525
  items: viewSnapshot.projection.fields,
2445
- isItem: Schema3.is(FieldSchema),
2526
+ isItem: Schema3.is(View.FieldSchema),
2446
2527
  getId: (field) => field.id,
2447
2528
  onMove: readonly ? void 0 : handleMove,
2448
2529
  readonly
@@ -2450,23 +2531,23 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
2450
2531
  className: "text-sm"
2451
2532
  }, t("field path label")), /* @__PURE__ */ React19.createElement("div", {
2452
2533
  role: "list",
2453
- className: listGrid
2534
+ className: "grid grid-cols-[min-content_1fr_min-content_min-content_min-content]"
2454
2535
  }, fields?.map((field) => {
2455
2536
  const hidden = field.visible === false;
2456
2537
  return /* @__PURE__ */ React19.createElement(List2.Item, {
2457
2538
  key: field.id,
2458
2539
  item: field,
2459
- classNames: listItemGrid,
2540
+ classNames: "grid grid-cols-subgrid col-span-5",
2460
2541
  "aria-expanded": expandedField === field.id
2461
2542
  }, /* @__PURE__ */ React19.createElement("div", {
2462
2543
  role: "none",
2463
- className: mx7(subtleHover2, listItemGrid, "rounded-sm cursor-pointer min-bs-10")
2544
+ className: mx5(subtleHover2, "grid grid-cols-subgrid col-span-5", "rounded-xs cursor-pointer min-h-10")
2464
2545
  }, /* @__PURE__ */ React19.createElement(List2.ItemDragHandle, {
2465
2546
  disabled: readonly || schemaReadonly
2466
2547
  }), /* @__PURE__ */ React19.createElement(List2.ItemTitle, {
2467
2548
  classNames: hidden && "text-subdued",
2468
2549
  onClick: () => handleToggleField(field)
2469
- }, field.path), /* @__PURE__ */ React19.createElement(List2.ItemButton, {
2550
+ }, field.path), /* @__PURE__ */ React19.createElement(List2.ItemIconButton, {
2470
2551
  label: t(hidden ? "show field label" : "hide field label"),
2471
2552
  "data-testid": hidden ? "show-field-button" : "hide-field-button",
2472
2553
  icon: hidden ? "ph--eye-closed--regular" : "ph--eye--regular",
@@ -2479,7 +2560,7 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
2479
2560
  disabled: readonly || schemaReadonly || viewSnapshot.projection.fields.length <= 1,
2480
2561
  onClick: () => handleDelete(field.id),
2481
2562
  "data-testid": "field.delete"
2482
- }), /* @__PURE__ */ React19.createElement(IconButton4, {
2563
+ }), /* @__PURE__ */ React19.createElement(List2.ItemIconButton, {
2483
2564
  iconOnly: true,
2484
2565
  variant: "ghost",
2485
2566
  label: t("toggle expand label", {
@@ -2490,7 +2571,7 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
2490
2571
  "data-testid": "field.toggle"
2491
2572
  }))), expandedField === field.id && !readonly && /* @__PURE__ */ React19.createElement("div", {
2492
2573
  role: "none",
2493
- className: "col-span-5 mbs-1 mbe-1 border border-separator rounded-md"
2574
+ className: "col-span-5 mt-1 mb-1 border border-separator rounded-md"
2494
2575
  }, /* @__PURE__ */ React19.createElement(FieldEditor, {
2495
2576
  readonly: readonly || schemaReadonly,
2496
2577
  registry,
@@ -2498,6 +2579,15 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
2498
2579
  field,
2499
2580
  onSave: handleClose
2500
2581
  })));
2582
+ })), !readonly && !expandedField && /* @__PURE__ */ React19.createElement("div", {
2583
+ role: "none",
2584
+ className: "my-form-padding"
2585
+ }, /* @__PURE__ */ React19.createElement(IconButton4, {
2586
+ icon: "ph--plus--regular",
2587
+ label: t("add property button label"),
2588
+ onClick: handleAdd,
2589
+ disabled: viewSnapshot.projection.fields.length >= VIEW_FIELD_LIMIT,
2590
+ classNames: "w-full"
2501
2591
  }))));
2502
2592
  };
2503
2593
  var customFields = ({ types, tags }) => ({
@@ -2519,15 +2609,6 @@ var customFields = ({ types, tags }) => ({
2519
2609
  export {
2520
2610
  ArrayField,
2521
2611
  BooleanField,
2522
- ControlFrame,
2523
- ControlFrameItem,
2524
- ControlGroup,
2525
- ControlGroupButton,
2526
- ControlItem,
2527
- ControlItemInput,
2528
- ControlPage,
2529
- ControlSection,
2530
- ControlSectionHeading,
2531
2612
  FieldEditor,
2532
2613
  Form,
2533
2614
  FormFieldErrorBoundary,
@@ -2540,12 +2621,12 @@ export {
2540
2621
  RefField,
2541
2622
  SelectField,
2542
2623
  SelectOptionField,
2624
+ Settings,
2543
2625
  TextAreaField,
2544
2626
  TextField,
2545
2627
  TupleField,
2546
2628
  ViewEditor,
2547
2629
  cellClassesForFieldType,
2548
- controlItemClasses,
2549
2630
  formatForDisplay,
2550
2631
  formatForEditing,
2551
2632
  getDefaultValue,
@@ -2554,7 +2635,6 @@ export {
2554
2635
  omitId,
2555
2636
  parseValue,
2556
2637
  pathNotUniqueError,
2557
- setValueEchoAware,
2558
2638
  translations,
2559
2639
  useFormContext,
2560
2640
  useFormFieldState,