@dxos/react-ui-form 0.8.4-main.f9ba587 → 0.8.4-main.fd6878d

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 (63) hide show
  1. package/dist/lib/browser/index.mjs +184 -171
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +184 -171
  5. package/dist/lib/node-esm/index.mjs.map +4 -4
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts.map +1 -1
  8. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts +4 -4
  9. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
  10. package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts +2 -2
  11. package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts.map +1 -1
  12. package/dist/types/src/components/Form/ArrayField.d.ts.map +1 -1
  13. package/dist/types/src/components/Form/Defaults.d.ts.map +1 -1
  14. package/dist/types/src/components/Form/Form.d.ts +2 -2
  15. package/dist/types/src/components/Form/Form.d.ts.map +1 -1
  16. package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
  17. package/dist/types/src/components/Form/FormActions.d.ts.map +1 -1
  18. package/dist/types/src/components/Form/FormContent.d.ts +1 -1
  19. package/dist/types/src/components/Form/FormContent.d.ts.map +1 -1
  20. package/dist/types/src/components/Form/FormContext.d.ts +1 -1
  21. package/dist/types/src/components/Form/FormContext.d.ts.map +1 -1
  22. package/dist/types/src/components/Form/RefField.d.ts +1 -1
  23. package/dist/types/src/components/Form/RefField.d.ts.map +1 -1
  24. package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts.map +1 -1
  25. package/dist/types/src/components/Form/custom/SelectOptionsInput.stories.d.ts.map +1 -1
  26. package/dist/types/src/components/Form/factory.d.ts.map +1 -1
  27. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +2 -2
  28. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
  29. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +3 -3
  30. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
  31. package/dist/types/src/components/deprecated/Form.d.ts +3 -3
  32. package/dist/types/src/components/deprecated/Form.d.ts.map +1 -1
  33. package/dist/types/src/components/deprecated/Form.stories.d.ts.map +1 -1
  34. package/dist/types/src/hooks/useForm.d.ts +1 -1
  35. package/dist/types/src/hooks/useForm.d.ts.map +1 -1
  36. package/dist/types/src/translations.d.ts +3 -2
  37. package/dist/types/src/translations.d.ts.map +1 -1
  38. package/dist/types/tsconfig.tsbuildinfo +1 -1
  39. package/package.json +30 -29
  40. package/src/components/ControlSection/ControlSection.stories.tsx +2 -1
  41. package/src/components/FieldEditor/FieldEditor.stories.tsx +16 -13
  42. package/src/components/FieldEditor/FieldEditor.test.tsx +14 -13
  43. package/src/components/FieldEditor/FieldEditor.tsx +11 -11
  44. package/src/components/Form/ArrayField.tsx +8 -7
  45. package/src/components/Form/Defaults.tsx +2 -1
  46. package/src/components/Form/Form.stories.tsx +4 -3
  47. package/src/components/Form/Form.tsx +4 -3
  48. package/src/components/Form/FormActions.tsx +2 -1
  49. package/src/components/Form/FormContent.tsx +6 -5
  50. package/src/components/Form/FormContext.tsx +5 -5
  51. package/src/components/Form/RefField.tsx +6 -5
  52. package/src/components/Form/custom/GeoPointInput.tsx +2 -2
  53. package/src/components/Form/custom/SelectOptionsInput.stories.tsx +3 -2
  54. package/src/components/Form/custom/SelectOptionsInput.tsx +28 -29
  55. package/src/components/Form/factory.tsx +1 -1
  56. package/src/components/ViewEditor/ViewEditor.stories.tsx +19 -12
  57. package/src/components/ViewEditor/ViewEditor.test.tsx +18 -15
  58. package/src/components/ViewEditor/ViewEditor.tsx +81 -81
  59. package/src/components/deprecated/Form.stories.tsx +6 -5
  60. package/src/components/deprecated/Form.tsx +6 -6
  61. package/src/hooks/useForm.ts +5 -3
  62. package/src/hooks/useRefQueryLookupHandler.ts +1 -1
  63. package/src/translations.ts +3 -2
@@ -20,6 +20,7 @@ var translations = [
20
20
  "field limit reached": "Maximum number of fields reached",
21
21
  "boolean input true value": "Yes",
22
22
  "boolean input false value": "No",
23
+ "delete field label": "Delete field",
23
24
  // TODO(burdon): Factor out?
24
25
  "button cancel": "Cancel",
25
26
  "button save": "Save",
@@ -62,8 +63,8 @@ var translations = [
62
63
  "select option delete": "Delete",
63
64
  "select option add": "Add option",
64
65
  // System schema message.
65
- "system schema title": "System Schema",
66
- "system schema description": "This is a system schema and cannot be modified."
66
+ "system schema title": "System record type",
67
+ "system schema description": "This is a system record type and cannot be modified."
67
68
  }
68
69
  }
69
70
  }
@@ -262,7 +263,7 @@ import { getFormatSchema, getSchemaProperties as getSchemaProperties3, sortPrope
262
263
 
263
264
  // src/components/Form/custom/GeoPointInput.tsx
264
265
  import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
265
- import React4, { useCallback, useState, useEffect, useMemo } from "react";
266
+ import React4, { useCallback, useEffect, useMemo, useState } from "react";
266
267
  import { GeoLocation } from "@dxos/echo-schema";
267
268
  import { Input as Input4, useTranslation as useTranslation2 } from "@dxos/react-ui";
268
269
  import { safeParseFloat } from "@dxos/util";
@@ -376,12 +377,12 @@ var GeoPointInput = ({ type, label, disabled, getStatus, getValue: getValue3, on
376
377
 
377
378
  // src/components/Form/custom/SelectOptionsInput.tsx
378
379
  import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
379
- import React5, { useCallback as useCallback2, useEffect as useEffect2, useState as useState2, useRef } from "react";
380
+ import React5, { useCallback as useCallback2, useEffect as useEffect2, useRef, useState as useState2 } from "react";
380
381
  import { PublicKey } from "@dxos/keys";
381
- import { Icon as Icon2, IconButton, Input as Input5, Tag, Toolbar, useTranslation as useTranslation3 } from "@dxos/react-ui";
382
+ import { IconButton, Input as Input5, Tag, useTranslation as useTranslation3 } from "@dxos/react-ui";
382
383
  import { List } from "@dxos/react-ui-list";
383
384
  import { HuePicker } from "@dxos/react-ui-pickers";
384
- import { hues, mx as mx4 } from "@dxos/react-ui-theme";
385
+ import { hues, subtleHover } from "@dxos/react-ui-theme";
385
386
  var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3, onValueChange }) => {
386
387
  var _effect = _useSignals5();
387
388
  try {
@@ -501,7 +502,8 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
501
502
  }, options && /* @__PURE__ */ React5.createElement(List.Root, {
502
503
  items: options,
503
504
  isItem: (item) => true,
504
- onMove: handleMove
505
+ onMove: disabled ? void 0 : handleMove,
506
+ readonly: disabled
505
507
  }, ({ items }) => /* @__PURE__ */ React5.createElement("div", {
506
508
  role: "list",
507
509
  className: "w-full overflow-auto"
@@ -510,25 +512,36 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
510
512
  }, /* @__PURE__ */ React5.createElement(List.Item, {
511
513
  role: "button",
512
514
  item,
513
- classNames: mx4("p-1 plb-2", "flex flex-col", "cursor-pointer", "hover:bg-hoverOverlay"),
515
+ classNames: [
516
+ subtleHover,
517
+ "flex flex-col cursor-pointer rounded-sm"
518
+ ],
514
519
  "aria-expanded": selected === item.id
515
520
  }, /* @__PURE__ */ React5.createElement("div", {
516
521
  className: "flex items-center"
517
- }, /* @__PURE__ */ React5.createElement(List.ItemDragHandle, null), /* @__PURE__ */ React5.createElement(List.ItemTitle, {
522
+ }, /* @__PURE__ */ React5.createElement(List.ItemDragHandle, {
523
+ disabled
524
+ }), /* @__PURE__ */ React5.createElement(List.ItemTitle, {
518
525
  onClick: () => handleClick(item.id),
519
526
  classNames: "flex-1"
520
527
  }, /* @__PURE__ */ React5.createElement(Tag, {
521
528
  palette: item.color
522
- }, item.title || "\u200B")), /* @__PURE__ */ React5.createElement(Icon2, {
529
+ }, item.title || "\u200B")), /* @__PURE__ */ React5.createElement(IconButton, {
530
+ iconOnly: true,
531
+ variant: "ghost",
532
+ label: t(selected === item.id ? "collapse label" : "expand label", {
533
+ ns: "os"
534
+ }),
523
535
  icon: selected === item.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
524
536
  onClick: () => handleClick(item.id)
525
537
  })), selected === item.id && /* @__PURE__ */ React5.createElement("div", {
526
- className: "mis-4 mbs-2 flex flex-col gap-1"
538
+ className: "pli-cardSpacingInline plb-cardSpacingBlock flex flex-col gap-1 density-fine"
527
539
  }, /* @__PURE__ */ React5.createElement(Input5.Label, {
528
540
  classNames: "text-xs"
529
541
  }, t("select option label")), /* @__PURE__ */ React5.createElement("div", {
530
- className: "flex flex-row items-center gap-1"
542
+ className: "grid grid-cols-[1fr_min-content_min-content] gap-1"
531
543
  }, /* @__PURE__ */ React5.createElement(Input5.TextInput, {
544
+ disabled,
532
545
  placeholder: t("select option label placeholder"),
533
546
  ref: selected === item.id ? inputRef : void 0,
534
547
  value: item.title,
@@ -536,30 +549,24 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
536
549
  onKeyDown: handleKeyDown,
537
550
  classNames: "flex-1",
538
551
  "data-no-submit": true
539
- }), /* @__PURE__ */ React5.createElement(Toolbar.Root, {
540
- classNames: "p-0 m-0 !is-auto"
541
- }, /* @__PURE__ */ React5.createElement(HuePicker, {
552
+ }), /* @__PURE__ */ React5.createElement(HuePicker, {
553
+ disabled,
542
554
  value: item.color,
543
- onChange: handleColorChange(item.id),
544
- rootVariant: "toolbar-button"
545
- })), /* @__PURE__ */ React5.createElement(IconButton, {
555
+ onChange: handleColorChange(item.id)
556
+ }), /* @__PURE__ */ React5.createElement(IconButton, {
557
+ disabled,
546
558
  icon: "ph--trash--fill",
547
559
  iconOnly: true,
548
560
  label: t("select option delete"),
549
561
  onClick: () => handleDelete(item.id)
550
- })))))), /* @__PURE__ */ React5.createElement("div", {
551
- role: "listitem"
552
- }, /* @__PURE__ */ React5.createElement("div", {
553
- role: "button",
554
- className: mx4("p-1 plb-2", "flex flex-col", "cursor-pointer", "hover:bg-hoverOverlay"),
555
- onClick: handleAdd
556
- }, /* @__PURE__ */ React5.createElement("div", {
557
- className: "flex items-center gap-1"
558
- }, /* @__PURE__ */ React5.createElement(Icon2, {
559
- icon: "ph--plus--regular"
560
- }), /* @__PURE__ */ React5.createElement("span", {
561
- className: "text-sm"
562
- }, t("select option add")))))))));
562
+ })))))), /* @__PURE__ */ React5.createElement(IconButton, {
563
+ variant: "ghost",
564
+ icon: "ph--plus--regular",
565
+ label: t("select option add"),
566
+ onClick: handleAdd,
567
+ disabled,
568
+ classNames: "is-full"
569
+ })))));
563
570
  } finally {
564
571
  _effect.f();
565
572
  }
@@ -569,7 +576,7 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
569
576
  import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
570
577
  import React6 from "react";
571
578
  import { Input as Input6 } from "@dxos/react-ui";
572
- import { mx as mx5 } from "@dxos/react-ui-theme";
579
+ import { mx as mx4 } from "@dxos/react-ui-theme";
573
580
  import { safeParseFloat as safeParseFloat2 } from "@dxos/util";
574
581
  var gridCols = [
575
582
  "grid-cols-1",
@@ -588,7 +595,7 @@ var TupleInput = ({ binding, type, label, disabled, getStatus, getValue: getValu
588
595
  error,
589
596
  label
590
597
  }), /* @__PURE__ */ React6.createElement("div", {
591
- className: mx5("grid gap-2", gridCols[binding.length - 1])
598
+ className: mx4("grid gap-2", gridCols[binding.length - 1])
592
599
  }, binding.map((prop) => /* @__PURE__ */ React6.createElement(Input6.TextInput, {
593
600
  key: prop,
594
601
  type: "number",
@@ -757,11 +764,11 @@ import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking"
757
764
  import React9 from "react";
758
765
  import { IconButton as IconButton2, useTranslation as useTranslation5 } from "@dxos/react-ui";
759
766
  import { cardSpacing } from "@dxos/react-ui-stack";
760
- import { mx as mx6 } from "@dxos/react-ui-theme";
767
+ import { mx as mx5 } from "@dxos/react-ui-theme";
761
768
 
762
769
  // src/components/Form/FormContext.tsx
763
770
  import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
764
- import React8, { createContext, useContext, useEffect as useEffect6, useMemo as useMemo3, useCallback as useCallback6 } from "react";
771
+ import React8, { createContext, useCallback as useCallback6, useContext, useEffect as useEffect6, useMemo as useMemo3 } from "react";
765
772
  import { raise } from "@dxos/debug";
766
773
  import { getValue as getValue2 } from "@dxos/echo-schema";
767
774
  import { createJsonPath as createJsonPath2 } from "@dxos/effect";
@@ -778,7 +785,7 @@ var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-form/src/hooks/useForm.t
778
785
  var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, onSave }) => {
779
786
  invariant(SchemaAST.isTypeLiteral(schema.ast), void 0, {
780
787
  F: __dxlog_file,
781
- L: 93,
788
+ L: 95,
782
789
  S: void 0,
783
790
  A: [
784
791
  "SchemaAST.isTypeLiteral(schema.ast)",
@@ -882,7 +889,7 @@ var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, on
882
889
  } catch (err) {
883
890
  log.catch(err, void 0, {
884
891
  F: __dxlog_file,
885
- L: 213,
892
+ L: 215,
886
893
  S: void 0,
887
894
  C: (f, a) => f(...a)
888
895
  });
@@ -953,7 +960,7 @@ var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, on
953
960
  var createKeySet = (obj, value) => {
954
961
  invariant(obj, void 0, {
955
962
  F: __dxlog_file,
956
- L: 275,
963
+ L: 277,
957
964
  S: void 0,
958
965
  A: [
959
966
  "obj",
@@ -1130,7 +1137,7 @@ var FormActions = ({ readonly, onCancel, outerSpacing = true }) => {
1130
1137
  const { canSave, handleSave } = useFormContext();
1131
1138
  return /* @__PURE__ */ React9.createElement("div", {
1132
1139
  role: "none",
1133
- className: mx6(outerSpacing === "scroll-fields" ? "pli-cardSpacingInline mbe-cardSpacingBlock" : outerSpacing ? cardSpacing : "mbs-cardSpacingBlock", "flex [&_button]:grow gap-1 first:mbs-0")
1140
+ className: mx5(outerSpacing === "scroll-fields" ? "pli-cardSpacingInline mbe-cardSpacingBlock" : outerSpacing ? cardSpacing : "mbs-cardSpacingBlock", "flex [&_button]:grow gap-1 first:mbs-0")
1134
1141
  }, onCancel && !readonly && /* @__PURE__ */ React9.createElement(IconButton2, {
1135
1142
  "data-testid": "cancel-button",
1136
1143
  icon: "ph--x--regular",
@@ -1155,20 +1162,10 @@ import { Schema, SchemaAST as SchemaAST4, pipe as pipe2 } from "effect";
1155
1162
  import { capitalize as capitalize2 } from "effect/String";
1156
1163
  import React12, { forwardRef, useMemo as useMemo5 } from "react";
1157
1164
  import { createJsonPath as createJsonPath3, findNode as findNode3, getDiscriminatedType as getDiscriminatedType2, isDiscriminatedUnion as isDiscriminatedUnion2 } from "@dxos/effect";
1158
- import { mx as mx8 } from "@dxos/react-ui-theme";
1165
+ import { mx as mx7 } from "@dxos/react-ui-theme";
1159
1166
  import { getSchemaProperties as getSchemaProperties2 } from "@dxos/schema";
1160
1167
  import { isNotFalsy } from "@dxos/util";
1161
1168
 
1162
- // src/components/Form/ArrayField.tsx
1163
- import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
1164
- import { SchemaAST as SchemaAST3, pipe } from "effect";
1165
- import { capitalize } from "effect/String";
1166
- import React10, { Fragment, useCallback as useCallback7 } from "react";
1167
- import { findNode as findNode2, getDiscriminatedType, isDiscriminatedUnion, SimpleType } from "@dxos/effect";
1168
- import { invariant as invariant2 } from "@dxos/invariant";
1169
- import { IconButton as IconButton3, useTranslation as useTranslation6 } from "@dxos/react-ui";
1170
- import { getSchemaProperties } from "@dxos/schema";
1171
-
1172
1169
  // src/util/field.ts
1173
1170
  import { FormatEnum, GeoLocation as GeoLocation2, TypeEnum } from "@dxos/echo-schema";
1174
1171
  var parseValue = ({ type, format, value }) => {
@@ -1477,6 +1474,14 @@ var getRefProps = (property) => {
1477
1474
  };
1478
1475
 
1479
1476
  // src/components/Form/ArrayField.tsx
1477
+ import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
1478
+ import { SchemaAST as SchemaAST3, pipe } from "effect";
1479
+ import { capitalize } from "effect/String";
1480
+ import React10, { Fragment, useCallback as useCallback7 } from "react";
1481
+ import { SimpleType, findNode as findNode2, getDiscriminatedType, isDiscriminatedUnion } from "@dxos/effect";
1482
+ import { invariant as invariant2 } from "@dxos/invariant";
1483
+ import { IconButton as IconButton3, useTranslation as useTranslation6 } from "@dxos/react-ui";
1484
+ import { getSchemaProperties } from "@dxos/schema";
1480
1485
  var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/Form/ArrayField.tsx";
1481
1486
  var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponent }) => {
1482
1487
  var _effect = _useSignals10();
@@ -1486,7 +1491,7 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
1486
1491
  const values = useFormValues(path ?? []) ?? [];
1487
1492
  invariant2(Array.isArray(values), `Values at path ${path?.join(".")} must be an array.`, {
1488
1493
  F: __dxlog_file3,
1489
- L: 36,
1494
+ L: 37,
1490
1495
  S: void 0,
1491
1496
  A: [
1492
1497
  "Array.isArray(values)",
@@ -1563,7 +1568,7 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
1563
1568
  classNames: "self-center"
1564
1569
  }));
1565
1570
  })), !readonly && /* @__PURE__ */ React10.createElement(IconButton3, {
1566
- classNames: "is-full mlb-1 flex",
1571
+ classNames: "is-full mlb-cardSpacingBlock flex",
1567
1572
  icon: "ph--plus--regular",
1568
1573
  label: t("add field"),
1569
1574
  onClick: handleAdd
@@ -1573,16 +1578,35 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
1573
1578
  }
1574
1579
  };
1575
1580
 
1581
+ // src/components/Form/factory.tsx
1582
+ import { FormatEnum as FormatEnum4 } from "@dxos/echo-schema";
1583
+ var getInputComponent = (type, format) => {
1584
+ switch (format) {
1585
+ case FormatEnum4.GeoPoint:
1586
+ return GeoPointInput;
1587
+ case FormatEnum4.Markdown:
1588
+ return MarkdownInput;
1589
+ }
1590
+ switch (type) {
1591
+ case "string":
1592
+ return TextInput;
1593
+ case "number":
1594
+ return NumberInput;
1595
+ case "boolean":
1596
+ return BooleanInput;
1597
+ }
1598
+ };
1599
+
1576
1600
  // src/components/Form/RefField.tsx
1577
1601
  import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
1578
1602
  import React11, { useCallback as useCallback8, useMemo as useMemo4 } from "react";
1579
- import { Expando, getTypeAnnotation, Ref, ReferenceAnnotationId as ReferenceAnnotationId2 } from "@dxos/echo-schema";
1603
+ import { Expando, Ref, ReferenceAnnotationId as ReferenceAnnotationId2, getTypeAnnotation } from "@dxos/echo-schema";
1580
1604
  import { findAnnotation as findAnnotation2 } from "@dxos/effect";
1581
1605
  import { DXN } from "@dxos/keys";
1582
1606
  import { DxRefTag } from "@dxos/lit-ui/react";
1583
1607
  import { Input as Input8, useTranslation as useTranslation7 } from "@dxos/react-ui";
1584
1608
  import { TagPicker } from "@dxos/react-ui-tag-picker";
1585
- import { descriptionText, mx as mx7 } from "@dxos/react-ui-theme";
1609
+ import { descriptionText, mx as mx6 } from "@dxos/react-ui-theme";
1586
1610
  import { isNonNullable as isNonNullable2 } from "@dxos/util";
1587
1611
  var RefField = ({ type, label, disabled, placeholder, inputOnly, array, ast, getValue: getValue3, onBlur, onQueryRefOptions, onValueChange, ...restInputProps }) => {
1588
1612
  var _effect = _useSignals11();
@@ -1681,7 +1705,7 @@ var RefField = ({ type, label, disabled, placeholder, inputOnly, array, ast, get
1681
1705
  }), /* @__PURE__ */ React11.createElement("div", {
1682
1706
  "data-no-submit": true
1683
1707
  }, disabled ? items.length < 1 ? /* @__PURE__ */ React11.createElement("p", {
1684
- className: mx7(descriptionText, "mbe-2")
1708
+ className: mx6(descriptionText, "mbe-2")
1685
1709
  }, t("empty readonly ref field label")) : items.map((item) => /* @__PURE__ */ React11.createElement(DxRefTag, {
1686
1710
  key: item.id,
1687
1711
  refid: item.id,
@@ -1740,25 +1764,6 @@ var RefFieldFallback = ({ type, label, disabled, placeholder, inputOnly, getValu
1740
1764
  }
1741
1765
  };
1742
1766
 
1743
- // src/components/Form/factory.tsx
1744
- import { FormatEnum as FormatEnum4 } from "@dxos/echo-schema";
1745
- var getInputComponent = (type, format) => {
1746
- switch (format) {
1747
- case FormatEnum4.GeoPoint:
1748
- return GeoPointInput;
1749
- case FormatEnum4.Markdown:
1750
- return MarkdownInput;
1751
- }
1752
- switch (type) {
1753
- case "string":
1754
- return TextInput;
1755
- case "number":
1756
- return NumberInput;
1757
- case "boolean":
1758
- return BooleanInput;
1759
- }
1760
- };
1761
-
1762
1767
  // src/components/Form/FormContent.tsx
1763
1768
  var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupComponent, Custom }) => {
1764
1769
  var _effect = _useSignals12();
@@ -1857,7 +1862,7 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
1857
1862
  const typeLiteral = baseNode ? getDiscriminatedType2(baseNode, inputProps.getValue()) : findNode3(ast, SchemaAST4.isTypeLiteral);
1858
1863
  if (typeLiteral) {
1859
1864
  return /* @__PURE__ */ React12.createElement(React12.Fragment, null, !inline && /* @__PURE__ */ React12.createElement("h3", {
1860
- className: mx8("text-lg mlb-inputSpacingBlock first:mbs-0")
1865
+ className: mx7("text-lg mlb-inputSpacingBlock first:mbs-0")
1861
1866
  }, label), /* @__PURE__ */ React12.createElement(FormFields, {
1862
1867
  schema: Schema.make(typeLiteral),
1863
1868
  path,
@@ -1889,7 +1894,7 @@ var FormFields = /* @__PURE__ */ forwardRef(({ classNames, testId, schema, path,
1889
1894
  ]);
1890
1895
  return /* @__PURE__ */ React12.createElement("div", {
1891
1896
  role: "form",
1892
- className: mx8("is-full", classNames),
1897
+ className: mx7("is-full", classNames),
1893
1898
  ref: forwardRef2
1894
1899
  }, properties.map((property) => {
1895
1900
  return /* @__PURE__ */ React12.createElement(FormField, {
@@ -1952,7 +1957,7 @@ var Form = ({ classNames, testId, values: initialValues, autoFocus, readonly, au
1952
1957
  ],
1953
1958
  readonly,
1954
1959
  schema
1955
- }), (onCancel || onSave) && !autoSave && /* @__PURE__ */ React13.createElement(FormActions, {
1960
+ }), (onCancel || onSave) && !autoSave && !readonly && /* @__PURE__ */ React13.createElement(FormActions, {
1956
1961
  readonly,
1957
1962
  onCancel,
1958
1963
  outerSpacing
@@ -1964,7 +1969,7 @@ var Form = ({ classNames, testId, values: initialValues, autoFocus, readonly, au
1964
1969
 
1965
1970
  // src/components/FieldEditor/FieldEditor.tsx
1966
1971
  var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx";
1967
- var FieldEditor = ({ view, projection, field, registry, onSave, onCancel, outerSpacing }) => {
1972
+ var FieldEditor = ({ readonly, projection, field, registry, onSave, onCancel, outerSpacing }) => {
1968
1973
  var _effect = _useSignals14();
1969
1974
  try {
1970
1975
  const { t } = useTranslation8(translationKey);
@@ -2038,7 +2043,7 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel, outerS
2038
2043
  props.referenceSchema
2039
2044
  ]);
2040
2045
  const handleValidate = useCallback9(({ property }) => {
2041
- if (property && view.fields.find((f) => f.path === property && f.path !== field.path)) {
2046
+ if (property && projection.fields.find((f) => f.path === property && f.path !== field.path)) {
2042
2047
  return [
2043
2048
  {
2044
2049
  path: "property",
@@ -2047,7 +2052,7 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel, outerS
2047
2052
  ];
2048
2053
  }
2049
2054
  }, [
2050
- view.fields,
2055
+ projection.fields,
2051
2056
  field
2052
2057
  ]);
2053
2058
  const handleSave = useCallback9((props2) => {
@@ -2099,7 +2104,7 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel, outerS
2099
2104
  props
2100
2105
  }, {
2101
2106
  F: __dxlog_file4,
2102
- L: 183,
2107
+ L: 182,
2103
2108
  S: void 0,
2104
2109
  C: (f, a) => f(...a)
2105
2110
  });
@@ -2108,6 +2113,7 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel, outerS
2108
2113
  return /* @__PURE__ */ React14.createElement(Form, {
2109
2114
  key: field.id,
2110
2115
  autoFocus: true,
2116
+ readonly,
2111
2117
  values: props,
2112
2118
  schema: fieldSchema,
2113
2119
  filter: propIsNotType,
@@ -2136,16 +2142,14 @@ import { invariant as invariant3 } from "@dxos/invariant";
2136
2142
  import { Callout, IconButton as IconButton4, useTranslation as useTranslation9 } from "@dxos/react-ui";
2137
2143
  import { List as List2 } from "@dxos/react-ui-list";
2138
2144
  import { cardSpacing as cardSpacing3 } from "@dxos/react-ui-stack";
2139
- import { ghostHover, inputTextLabel, mx as mx9 } from "@dxos/react-ui-theme";
2140
- import { FieldSchema, ViewProjection, VIEW_FIELD_LIMIT } from "@dxos/schema";
2145
+ import { inputTextLabel, mx as mx8, subtleHover as subtleHover2 } from "@dxos/react-ui-theme";
2146
+ import { FieldSchema, ProjectionModel, VIEW_FIELD_LIMIT } from "@dxos/schema";
2141
2147
  var __dxlog_file5 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx";
2142
- var grid = "grid grid-cols-[32px_1fr_32px_32px] min-bs-[2.5rem]";
2148
+ var listGrid = "grid grid-cols-[min-content_1fr_min-content_min-content_min-content]";
2149
+ var listItemGrid = "grid grid-cols-subgrid col-span-5";
2143
2150
  var ViewMetaSchema = Schema2.Struct({
2144
- name: Schema2.String.annotations({
2145
- title: "View"
2146
- }),
2147
2151
  typename: Format.URL.annotations({
2148
- title: "Typename"
2152
+ title: "Record type"
2149
2153
  })
2150
2154
  }).pipe(Schema2.mutable);
2151
2155
  var ViewEditor = ({ classNames, schema, view, registry, readonly: _readonly, showHeading = false, onTypenameChanged, onDelete, outerSpacing = true }) => {
@@ -2154,52 +2158,48 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly: _readonly, sho
2154
2158
  const { t } = useTranslation9(translationKey);
2155
2159
  const projection = useMemo8(() => {
2156
2160
  const jsonSchema = schema instanceof EchoSchema ? schema.jsonSchema : toJsonSchema(schema);
2157
- return new ViewProjection(jsonSchema, view);
2161
+ return new ProjectionModel(jsonSchema, view.projection);
2158
2162
  }, [
2159
2163
  schema,
2160
- view
2164
+ view.projection
2161
2165
  ]);
2162
- const [field, setField] = useState6();
2166
+ const [expandedField, setExpandedField] = useState6();
2163
2167
  const readonly = _readonly || !isMutable(schema);
2164
2168
  const viewValues = useMemo8(() => {
2165
2169
  return {
2166
- name: view.name,
2167
2170
  // TODO(burdon): Need to warn user of possible consequences of editing.
2168
2171
  // TODO(burdon): Settings should have domain name owned by user.
2169
2172
  typename: view.query.typename
2170
2173
  };
2171
2174
  }, [
2172
- view
2175
+ view.query.typename
2173
2176
  ]);
2174
- const handleSelect = useCallback10((field2) => {
2175
- if (readonly) {
2176
- return;
2177
- }
2178
- setField((f) => f === field2 ? void 0 : field2);
2177
+ const handleToggleField = useCallback10((field) => {
2178
+ setExpandedField((prevExpandedFieldId) => prevExpandedFieldId === field.id ? void 0 : field.id);
2179
2179
  }, [
2180
2180
  readonly
2181
2181
  ]);
2182
2182
  const handleAdd = useCallback10(() => {
2183
2183
  invariant3(!readonly, void 0, {
2184
2184
  F: __dxlog_file5,
2185
- L: 92,
2185
+ L: 86,
2186
2186
  S: void 0,
2187
2187
  A: [
2188
2188
  "!readonly",
2189
2189
  ""
2190
2190
  ]
2191
2191
  });
2192
- const field2 = projection.createFieldProjection();
2193
- setField(field2);
2192
+ const field = projection.createFieldProjection();
2193
+ setExpandedField(field.id);
2194
2194
  }, [
2195
2195
  schema,
2196
- view,
2196
+ projection,
2197
2197
  readonly
2198
2198
  ]);
2199
- const handleUpdate = useCallback10(({ name, typename }) => {
2199
+ const handleUpdate = useCallback10(({ typename }) => {
2200
2200
  invariant3(!readonly, void 0, {
2201
2201
  F: __dxlog_file5,
2202
- L: 99,
2202
+ L: 93,
2203
2203
  S: void 0,
2204
2204
  A: [
2205
2205
  "!readonly",
@@ -2207,43 +2207,38 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly: _readonly, sho
2207
2207
  ]
2208
2208
  });
2209
2209
  requestAnimationFrame(() => {
2210
- if (view.name !== name) {
2211
- view.name = name;
2212
- }
2213
2210
  if (view.query.typename !== typename && !readonly) {
2214
2211
  onTypenameChanged?.(typename);
2215
2212
  }
2216
2213
  });
2217
2214
  }, [
2218
- schema,
2219
- view,
2215
+ view.query.typename,
2220
2216
  onTypenameChanged,
2221
2217
  readonly
2222
2218
  ]);
2223
2219
  const handleDelete = useCallback10((fieldId) => {
2224
2220
  invariant3(!readonly, void 0, {
2225
2221
  F: __dxlog_file5,
2226
- L: 115,
2222
+ L: 105,
2227
2223
  S: void 0,
2228
2224
  A: [
2229
2225
  "!readonly",
2230
2226
  ""
2231
2227
  ]
2232
2228
  });
2233
- if (fieldId === field?.id) {
2234
- setField(void 0);
2229
+ if (fieldId === expandedField) {
2230
+ setExpandedField(void 0);
2235
2231
  }
2236
2232
  onDelete?.(fieldId);
2237
2233
  }, [
2238
- schema,
2239
- field,
2234
+ expandedField,
2240
2235
  onDelete,
2241
2236
  readonly
2242
2237
  ]);
2243
2238
  const handleMove = useCallback10((fromIndex, toIndex) => {
2244
2239
  invariant3(!readonly, void 0, {
2245
2240
  F: __dxlog_file5,
2246
- L: 127,
2241
+ L: 117,
2247
2242
  S: void 0,
2248
2243
  A: [
2249
2244
  "!readonly",
@@ -2251,39 +2246,39 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly: _readonly, sho
2251
2246
  ]
2252
2247
  });
2253
2248
  const fields = [
2254
- ...view.fields
2249
+ ...view.projection.fields
2255
2250
  ];
2256
2251
  const [moved] = fields.splice(fromIndex, 1);
2257
2252
  fields.splice(toIndex, 0, moved);
2258
- view.fields = fields;
2253
+ view.projection.fields = fields;
2259
2254
  }, [
2260
- schema,
2261
- view.fields,
2255
+ view.projection.fields,
2262
2256
  readonly
2263
2257
  ]);
2264
- const handleClose = useCallback10(() => setField(void 0), []);
2258
+ const handleClose = useCallback10(() => setExpandedField(void 0), []);
2265
2259
  const hiddenProperties = projection.getHiddenProperties();
2266
2260
  const handleHide = useCallback10((fieldId) => {
2267
- setField(void 0);
2261
+ setExpandedField(void 0);
2268
2262
  projection.hideFieldProjection(fieldId);
2269
2263
  }, [
2270
2264
  projection
2271
2265
  ]);
2272
2266
  const handleShow = useCallback10((property) => {
2273
- setField(void 0);
2267
+ setExpandedField(void 0);
2274
2268
  projection.showFieldProjection(property);
2275
2269
  }, [
2276
2270
  projection
2277
2271
  ]);
2278
2272
  return /* @__PURE__ */ React15.createElement("div", {
2279
2273
  role: "none",
2280
- className: mx9(classNames)
2281
- }, readonly && /* @__PURE__ */ React15.createElement("div", {
2282
- role: "none",
2283
- className: mx9("is-full", outerSpacing && "plb-cardSpacingBlock pli-cardSpacingInline")
2284
- }, /* @__PURE__ */ React15.createElement(Callout.Root, {
2285
- valence: "info"
2286
- }, /* @__PURE__ */ React15.createElement(Callout.Title, null, t("system schema description")))), /* @__PURE__ */ React15.createElement(Form, {
2274
+ className: mx8(classNames)
2275
+ }, readonly && /* @__PURE__ */ React15.createElement(Callout.Root, {
2276
+ valence: "info",
2277
+ classNames: [
2278
+ "is-full mlb-cardSpacingBlock",
2279
+ outerSpacing && "mli-cardSpacingInline"
2280
+ ]
2281
+ }, /* @__PURE__ */ React15.createElement(Callout.Title, null, t("system schema description"))), /* @__PURE__ */ React15.createElement(Form, {
2287
2282
  autoSave: true,
2288
2283
  schema: ViewMetaSchema,
2289
2284
  values: viewValues,
@@ -2293,64 +2288,82 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly: _readonly, sho
2293
2288
  }), /* @__PURE__ */ React15.createElement("div", {
2294
2289
  role: "none",
2295
2290
  className: outerSpacing ? cardSpacing3 : "mlb-cardSpacingBlock"
2296
- }, /* @__PURE__ */ React15.createElement("label", {
2297
- className: mx9(inputTextLabel)
2291
+ }, /* @__PURE__ */ React15.createElement("h2", {
2292
+ className: mx8(inputTextLabel)
2298
2293
  }, t("fields label")), /* @__PURE__ */ React15.createElement(List2.Root, {
2299
- items: view.fields,
2294
+ items: view.projection.fields,
2300
2295
  isItem: Schema2.is(FieldSchema),
2301
- getId: (field2) => field2.id,
2302
- readonly,
2303
- onMove: readonly ? void 0 : handleMove
2304
- }, ({ items: fields }) => /* @__PURE__ */ React15.createElement(React15.Fragment, null, showHeading && /* @__PURE__ */ React15.createElement("div", {
2305
- role: "heading",
2306
- className: grid
2307
- }, /* @__PURE__ */ React15.createElement("div", null), /* @__PURE__ */ React15.createElement("div", {
2308
- className: "flex items-center text-sm"
2309
- }, t("field path label"))), /* @__PURE__ */ React15.createElement("div", {
2296
+ getId: (field) => field.id,
2297
+ onMove: readonly ? void 0 : handleMove,
2298
+ readonly
2299
+ }, ({ items: fields }) => /* @__PURE__ */ React15.createElement(React15.Fragment, null, showHeading && /* @__PURE__ */ React15.createElement("h3", {
2300
+ className: "text-sm"
2301
+ }, t("field path label")), /* @__PURE__ */ React15.createElement("div", {
2310
2302
  role: "list",
2311
- className: "flex flex-col is-full"
2312
- }, fields?.map((field2) => /* @__PURE__ */ React15.createElement(List2.Item, {
2313
- key: field2.id,
2314
- item: field2,
2315
- classNames: mx9(grid, ghostHover, "overflow-hidden", !readonly && "cursor-pointer")
2316
- }, /* @__PURE__ */ React15.createElement(List2.ItemDragHandle, null), /* @__PURE__ */ React15.createElement(List2.ItemTitle, {
2317
- onClick: () => handleSelect(field2)
2318
- }, field2.path), /* @__PURE__ */ React15.createElement(List2.ItemButton, {
2303
+ className: listGrid
2304
+ }, fields?.map((field) => /* @__PURE__ */ React15.createElement(List2.Item, {
2305
+ key: field.id,
2306
+ item: field,
2307
+ classNames: listItemGrid,
2308
+ "aria-expanded": expandedField === field.id
2309
+ }, /* @__PURE__ */ React15.createElement("div", {
2310
+ role: "none",
2311
+ className: mx8(subtleHover2, listItemGrid, "rounded-sm cursor-pointer min-bs-10")
2312
+ }, /* @__PURE__ */ React15.createElement(List2.ItemDragHandle, {
2313
+ disabled: readonly
2314
+ }), /* @__PURE__ */ React15.createElement(List2.ItemTitle, {
2315
+ onClick: () => handleToggleField(field)
2316
+ }, field.path), /* @__PURE__ */ React15.createElement(List2.ItemButton, {
2317
+ label: t("hide field label"),
2319
2318
  "data-testid": "hide-field-button",
2320
2319
  icon: "ph--eye-slash--regular",
2320
+ autoHide: false,
2321
2321
  // TDOO(burdon): Is this the correct test?
2322
- disabled: view.fields.length <= 1,
2323
- onClick: () => handleHide(field2.id)
2324
- }), !readonly && /* @__PURE__ */ React15.createElement(List2.ItemDeleteButton, {
2325
- disabled: view.fields.length <= 1,
2326
- onClick: () => handleDelete(field2.id)
2327
- })))))), hiddenProperties.length > 0 && /* @__PURE__ */ React15.createElement(React15.Fragment, null, /* @__PURE__ */ React15.createElement("label", {
2328
- className: mx9(inputTextLabel)
2322
+ disabled: readonly || view.projection.fields.length <= 1,
2323
+ onClick: () => handleHide(field.id)
2324
+ }), /* @__PURE__ */ React15.createElement(List2.ItemDeleteButton, {
2325
+ label: t("delete field label"),
2326
+ autoHide: false,
2327
+ disabled: readonly || view.projection.fields.length <= 1,
2328
+ onClick: () => handleDelete(field.id),
2329
+ "data-testid": "field.delete"
2330
+ }), /* @__PURE__ */ React15.createElement(IconButton4, {
2331
+ iconOnly: true,
2332
+ variant: "ghost",
2333
+ label: t("toggle expand label", {
2334
+ ns: "os"
2335
+ }),
2336
+ icon: expandedField === field.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
2337
+ onClick: () => handleToggleField(field)
2338
+ })), expandedField === field.id && /* @__PURE__ */ React15.createElement("div", {
2339
+ role: "none",
2340
+ className: "col-span-5"
2341
+ }, /* @__PURE__ */ React15.createElement(FieldEditor, {
2342
+ readonly,
2343
+ projection,
2344
+ field,
2345
+ registry,
2346
+ onSave: handleClose
2347
+ }))))))), hiddenProperties.length > 0 && /* @__PURE__ */ React15.createElement(React15.Fragment, null, /* @__PURE__ */ React15.createElement("h2", {
2348
+ className: mx8(inputTextLabel)
2329
2349
  }, t("hidden fields label")), /* @__PURE__ */ React15.createElement(List2.Root, {
2330
2350
  items: hiddenProperties,
2331
2351
  isItem: (item) => typeof item === "string",
2332
2352
  getId: (property) => property
2333
2353
  }, ({ items: properties }) => /* @__PURE__ */ React15.createElement("div", {
2334
2354
  role: "list",
2335
- className: "flex flex-col is-full"
2355
+ className: "grid grid-cols-[1fr_min-content]"
2336
2356
  }, properties?.map((property) => /* @__PURE__ */ React15.createElement(List2.Item, {
2337
2357
  key: property,
2338
2358
  item: property,
2339
- classNames: mx9(grid, ghostHover, !readonly && "cursor-pointer")
2340
- }, /* @__PURE__ */ React15.createElement(List2.ItemDragHandle, {
2341
- disabled: true
2342
- }), /* @__PURE__ */ React15.createElement(List2.ItemTitle, null, property), /* @__PURE__ */ React15.createElement(List2.ItemButton, {
2359
+ classNames: mx8("grid grid-cols-subgrid col-span-2 rounded-sm", subtleHover2)
2360
+ }, /* @__PURE__ */ React15.createElement(List2.ItemTitle, null, property), /* @__PURE__ */ React15.createElement(List2.ItemButton, {
2361
+ label: t("show field label"),
2362
+ disabled: readonly,
2343
2363
  icon: "ph--eye--regular",
2344
2364
  onClick: () => handleShow(property),
2345
2365
  "data-testid": "show-field-button"
2346
- }))))))), field && /* @__PURE__ */ React15.createElement(FieldEditor, {
2347
- key: field.id,
2348
- view,
2349
- projection,
2350
- field,
2351
- registry,
2352
- onSave: handleClose
2353
- }), !readonly && !field && /* @__PURE__ */ React15.createElement("div", {
2366
+ }))))))), !readonly && !expandedField && /* @__PURE__ */ React15.createElement("div", {
2354
2367
  role: "none",
2355
2368
  className: outerSpacing ? cardSpacing3 : "mlb-cardSpacingBlock"
2356
2369
  }, /* @__PURE__ */ React15.createElement(IconButton4, {
@@ -2358,8 +2371,8 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly: _readonly, sho
2358
2371
  label: t("button add property"),
2359
2372
  onClick: readonly ? void 0 : handleAdd,
2360
2373
  // TODO(burdon): Show field limit in ux (not tooltip).
2361
- disabled: view.fields.length >= VIEW_FIELD_LIMIT,
2362
- classNames: "flex is-full"
2374
+ disabled: view.projection.fields.length >= VIEW_FIELD_LIMIT,
2375
+ classNames: "is-full"
2363
2376
  })));
2364
2377
  } finally {
2365
2378
  _effect.f();