@dxos/react-ui-form 0.8.4-main.b97322e → 0.8.4-main.dedc0f3

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 (94) hide show
  1. package/dist/lib/browser/index.mjs +601 -528
  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 +601 -528
  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.d.ts +2 -2
  8. package/dist/types/src/components/ControlSection/ControlSection.d.ts.map +1 -1
  9. package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts +79 -4
  10. package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts.map +1 -1
  11. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts +2 -2
  12. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
  13. package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts +74 -4
  14. package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts.map +1 -1
  15. package/dist/types/src/components/Form/ArrayField.d.ts +2 -2
  16. package/dist/types/src/components/Form/ArrayField.d.ts.map +1 -1
  17. package/dist/types/src/components/Form/Defaults.d.ts +5 -5
  18. package/dist/types/src/components/Form/Defaults.d.ts.map +1 -1
  19. package/dist/types/src/components/Form/Form.d.ts +5 -4
  20. package/dist/types/src/components/Form/Form.d.ts.map +1 -1
  21. package/dist/types/src/components/Form/Form.stories.d.ts +126 -30
  22. package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
  23. package/dist/types/src/components/Form/FormActions.d.ts.map +1 -1
  24. package/dist/types/src/components/Form/FormContent.d.ts +16 -10
  25. package/dist/types/src/components/Form/FormContent.d.ts.map +1 -1
  26. package/dist/types/src/components/Form/FormContext.d.ts +1 -1
  27. package/dist/types/src/components/Form/FormContext.d.ts.map +1 -1
  28. package/dist/types/src/components/Form/Input.d.ts +4 -1
  29. package/dist/types/src/components/Form/Input.d.ts.map +1 -1
  30. package/dist/types/src/components/Form/RefField.d.ts +10 -4
  31. package/dist/types/src/components/Form/RefField.d.ts.map +1 -1
  32. package/dist/types/src/components/Form/custom/GeoPointInput.d.ts +1 -1
  33. package/dist/types/src/components/Form/custom/GeoPointInput.d.ts.map +1 -1
  34. package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts +1 -1
  35. package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts.map +1 -1
  36. package/dist/types/src/components/Form/custom/SelectOptionsInput.stories.d.ts +74 -3
  37. package/dist/types/src/components/Form/custom/SelectOptionsInput.stories.d.ts.map +1 -1
  38. package/dist/types/src/components/Form/custom/TupleInput.d.ts +1 -1
  39. package/dist/types/src/components/Form/factory.d.ts.map +1 -1
  40. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +3 -2
  41. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
  42. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +76 -5
  43. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
  44. package/dist/types/src/components/index.d.ts +0 -1
  45. package/dist/types/src/components/index.d.ts.map +1 -1
  46. package/dist/types/src/components/testing.d.ts +6 -3
  47. package/dist/types/src/components/testing.d.ts.map +1 -1
  48. package/dist/types/src/hooks/useForm.d.ts +1 -1
  49. package/dist/types/src/hooks/useForm.d.ts.map +1 -1
  50. package/dist/types/src/translations.d.ts +9 -4
  51. package/dist/types/src/translations.d.ts.map +1 -1
  52. package/dist/types/src/util/field.d.ts.map +1 -1
  53. package/dist/types/tsconfig.tsbuildinfo +1 -1
  54. package/package.json +35 -30
  55. package/src/components/ControlSection/ControlSection.stories.tsx +8 -10
  56. package/src/components/ControlSection/ControlSection.tsx +26 -12
  57. package/src/components/FieldEditor/FieldEditor.stories.tsx +8 -9
  58. package/src/components/FieldEditor/FieldEditor.test.tsx +3 -2
  59. package/src/components/FieldEditor/FieldEditor.tsx +22 -17
  60. package/src/components/Form/ArrayField.tsx +8 -8
  61. package/src/components/Form/Defaults.tsx +22 -20
  62. package/src/components/Form/Form.stories.tsx +129 -93
  63. package/src/components/Form/Form.tsx +16 -12
  64. package/src/components/Form/FormActions.tsx +2 -1
  65. package/src/components/Form/FormContent.tsx +96 -34
  66. package/src/components/Form/FormContext.tsx +5 -5
  67. package/src/components/Form/Input.tsx +4 -1
  68. package/src/components/Form/RefField.tsx +126 -40
  69. package/src/components/Form/custom/GeoPointInput.tsx +29 -21
  70. package/src/components/Form/custom/SelectOptionsInput.stories.tsx +7 -6
  71. package/src/components/Form/custom/SelectOptionsInput.tsx +29 -30
  72. package/src/components/Form/custom/TupleInput.tsx +2 -2
  73. package/src/components/Form/factory.tsx +1 -1
  74. package/src/components/ViewEditor/ViewEditor.stories.tsx +50 -23
  75. package/src/components/ViewEditor/ViewEditor.test.tsx +7 -10
  76. package/src/components/ViewEditor/ViewEditor.tsx +151 -132
  77. package/src/components/index.ts +0 -2
  78. package/src/components/testing.tsx +15 -9
  79. package/src/hooks/useForm.ts +5 -3
  80. package/src/hooks/useRefQueryLookupHandler.ts +1 -1
  81. package/src/translations.ts +11 -5
  82. package/src/util/field.ts +8 -18
  83. package/dist/types/src/components/deprecated/Form.d.ts +0 -15
  84. package/dist/types/src/components/deprecated/Form.d.ts.map +0 -1
  85. package/dist/types/src/components/deprecated/Form.stories.d.ts +0 -13
  86. package/dist/types/src/components/deprecated/Form.stories.d.ts.map +0 -1
  87. package/dist/types/src/components/deprecated/FormInput.d.ts +0 -16
  88. package/dist/types/src/components/deprecated/FormInput.d.ts.map +0 -1
  89. package/dist/types/src/components/deprecated/index.d.ts +0 -2
  90. package/dist/types/src/components/deprecated/index.d.ts.map +0 -1
  91. package/src/components/deprecated/Form.stories.tsx +0 -62
  92. package/src/components/deprecated/Form.tsx +0 -119
  93. package/src/components/deprecated/FormInput.tsx +0 -71
  94. package/src/components/deprecated/index.ts +0 -5
@@ -18,6 +18,11 @@ var translations = [
18
18
  "field limit reached": "Maximum number of fields reached",
19
19
  "boolean input true value": "Yes",
20
20
  "boolean input false value": "No",
21
+ "show field label": "Show field",
22
+ "hide field label": "Hide field",
23
+ "delete field label": "Delete field",
24
+ "ref field placeholder_one": "Select\u2026",
25
+ "ref field placeholder_other": "Select items\u2026",
21
26
  // TODO(burdon): Factor out?
22
27
  "button cancel": "Cancel",
23
28
  "button save": "Save",
@@ -50,9 +55,9 @@ var translations = [
50
55
  "format uri": "URI",
51
56
  "format url": "URL",
52
57
  "format uuid": "UUID",
53
- // Placeholders.
54
- "placeholder latitude": "Latitude",
55
- "placeholder longitude": "Longitude",
58
+ // GeoPointInput.
59
+ "latitude label": "Latitude",
60
+ "longitude label": "Longitude",
56
61
  // SelectOptionsInput.
57
62
  "select option label": "Label",
58
63
  "select option label placeholder": "Option label",
@@ -60,86 +65,37 @@ var translations = [
60
65
  "select option delete": "Delete",
61
66
  "select option add": "Add option",
62
67
  // System schema message.
63
- "system schema title": "System Schema",
64
- "system schema description": "This is a system schema and cannot be modified."
68
+ "system schema title": "System record type",
69
+ "system schema description": "This is a system record type and cannot be modified, though the view can still be configured."
65
70
  }
66
71
  }
67
72
  }
68
73
  ];
69
74
 
70
- // src/components/deprecated/FormInput.tsx
75
+ // src/components/ControlSection/ControlSection.tsx
71
76
  import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
72
77
  import React from "react";
73
- import { Input } from "@dxos/react-ui";
74
- import { mx, textBlockWidth } from "@dxos/react-ui-theme";
75
- var DeprecatedFormContainer = ({ children, classNames }) => {
76
- var _effect = _useSignals();
77
- try {
78
- return /* @__PURE__ */ React.createElement("div", {
79
- role: "none",
80
- className: "container-max-width p-4 justify-center overflow-x-hidden overflow-y-auto"
81
- }, /* @__PURE__ */ React.createElement("div", {
82
- role: "form",
83
- className: mx("flex flex-col", textBlockWidth, classNames)
84
- }, children));
85
- } finally {
86
- _effect.f();
87
- }
88
- };
89
- var DeprecatedFormInput = ({ label, description, secondary, children }) => {
78
+ import { Button, Input, toLocalizedString, useTranslation } from "@dxos/react-ui";
79
+ import { StackItem } from "@dxos/react-ui-stack";
80
+ import { mx } from "@dxos/react-ui-theme";
81
+ var ControlPage = ({ children, classNames, ...props }) => {
90
82
  var _effect = _useSignals();
91
83
  try {
92
- const primary = /* @__PURE__ */ React.createElement("div", {
93
- role: "none",
94
- className: "flex w-full gap-4 py-1"
95
- }, /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement("div", {
96
- role: "none",
97
- className: "flex flex-col w-full"
98
- }, /* @__PURE__ */ React.createElement(Input.Label, {
99
- classNames: "flex min-bs-[--rail-action] items-center",
100
- style: {
101
- fontSize: "unset"
102
- }
103
- }, label), description && /* @__PURE__ */ React.createElement(Input.DescriptionAndValidation, {
104
- classNames: "mbs-0.5"
105
- }, /* @__PURE__ */ React.createElement(Input.Description, null, description))), /* @__PURE__ */ React.createElement("div", {
106
- role: "none"
84
+ return /* @__PURE__ */ React.createElement(StackItem.Content, {
85
+ classNames: "block overflow-y-auto [--control-spacing:var(--dx-trimMd)]"
107
86
  }, /* @__PURE__ */ React.createElement("div", {
108
87
  role: "none",
109
- className: "flex min-bs-[--rail-action] items-center"
110
- }, children))));
111
- if (secondary) {
112
- return /* @__PURE__ */ React.createElement("div", {
113
- role: "none"
114
- }, primary, secondary);
115
- }
116
- return primary;
117
- } finally {
118
- _effect.f();
119
- }
120
- };
121
-
122
- // src/components/ControlSection/ControlSection.tsx
123
- import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
124
- import React2 from "react";
125
- import { Button, Input as Input2, toLocalizedString, useTranslation } from "@dxos/react-ui";
126
- import { mx as mx2 } from "@dxos/react-ui-theme";
127
- var ControlPage = ({ children, classNames, ...props }) => {
128
- var _effect = _useSignals2();
129
- try {
130
- return /* @__PURE__ */ React2.createElement("div", {
131
- role: "none",
132
- className: mx2("pli-cardSpacingInline", classNames),
88
+ className: mx("pli-cardSpacingInline pbe-trimLg", classNames),
133
89
  ...props
134
- }, children);
90
+ }, children));
135
91
  } finally {
136
92
  _effect.f();
137
93
  }
138
94
  };
139
95
  var ControlSection = ({ title, description, children }) => {
140
- var _effect = _useSignals2();
96
+ var _effect = _useSignals();
141
97
  try {
142
- return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(ControlSectionHeading, {
98
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ControlSectionHeading, {
143
99
  title,
144
100
  description
145
101
  }), children);
@@ -148,12 +104,12 @@ var ControlSection = ({ title, description, children }) => {
148
104
  }
149
105
  };
150
106
  var ControlSectionHeading = ({ title, description }) => {
151
- var _effect = _useSignals2();
107
+ var _effect = _useSignals();
152
108
  try {
153
109
  const { t } = useTranslation(translationKey);
154
- return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("h2", {
110
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("h2", {
155
111
  className: "pli-trimMd container-max-width text-xl mbs-trimLg mbe-trimMd"
156
- }, toLocalizedString(title, t)), description && /* @__PURE__ */ React2.createElement("p", {
112
+ }, toLocalizedString(title, t)), description && /* @__PURE__ */ React.createElement("p", {
157
113
  className: "pli-trimMd mlb-trimMd container-max-width text-description"
158
114
  }, toLocalizedString(description, t)));
159
115
  } finally {
@@ -161,9 +117,9 @@ var ControlSectionHeading = ({ title, description }) => {
161
117
  }
162
118
  };
163
119
  var ControlGroupButton = ({ classNames, ...props }) => {
164
- var _effect = _useSignals2();
120
+ var _effect = _useSignals();
165
121
  try {
166
- return /* @__PURE__ */ React2.createElement(Button, {
122
+ return /* @__PURE__ */ React.createElement(Button, {
167
123
  ...props,
168
124
  classNames: [
169
125
  "md:col-span-2",
@@ -175,41 +131,46 @@ var ControlGroupButton = ({ classNames, ...props }) => {
175
131
  }
176
132
  };
177
133
  var ControlGroup = ({ children, classNames }) => {
178
- var _effect = _useSignals2();
134
+ var _effect = _useSignals();
179
135
  try {
180
- return /* @__PURE__ */ React2.createElement("div", {
136
+ return /* @__PURE__ */ React.createElement("div", {
181
137
  role: "none",
182
- className: mx2("group container-max-width grid grid-cols-1 md:grid-cols-[1fr_min-content] gap-trimMd", classNames)
138
+ 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)
183
139
  }, children);
184
140
  } finally {
185
141
  _effect.f();
186
142
  }
187
143
  };
188
144
  var ControlFrame = ({ children }) => {
189
- var _effect = _useSignals2();
145
+ var _effect = _useSignals();
190
146
  try {
191
- return /* @__PURE__ */ React2.createElement("div", {
147
+ return /* @__PURE__ */ React.createElement("div", {
192
148
  role: "none",
193
- className: "p-trimMd container-max-width grid grid-cols-1 md:grid-cols-[1fr_1fr] gap-trimSm md:gap-trimMd border border-separator rounded-md"
149
+ 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")
194
150
  }, children);
195
151
  } finally {
196
152
  _effect.f();
197
153
  }
198
154
  };
199
- var controlItemClasses = "pli-trimMd plb-trimMd container-max-width grid md:col-span-2 grid-cols-subgrid items-center gap-trimSm border border-separator rounded-md *:first:!mbs-0 *:last:!mbe-0";
200
- var controlItemTitleClasses = "text-lg font-normal";
201
- var controlItemDescriptionClasses = "text-base mlb-trimSm md:mbe-0 text-description";
155
+ var controlItemClasses = mx([
156
+ "container-max-width grid md:col-span-2 grid-cols-subgrid gap-trimSm items-center",
157
+ // TODO(burdon): Use grid gap consistently or apply margins consistently?
158
+ "mlb-[--control-spacing] *:first:!mbs-0 *:last:!mbe-0 pli-trimMd plb-trimMd",
159
+ "border border-separator rounded-md"
160
+ ]);
161
+ var controlItemTitleClasses = "mbe-0 text-lg text-baseText font-normal";
162
+ var controlItemDescriptionClasses = "mlb-trimSm md:mbe-0 text-base text-description";
202
163
  var ControlItem = ({ title, description, children }) => {
203
- var _effect = _useSignals2();
164
+ var _effect = _useSignals();
204
165
  try {
205
166
  const { t } = useTranslation(translationKey);
206
- return /* @__PURE__ */ React2.createElement("div", {
167
+ return /* @__PURE__ */ React.createElement("div", {
207
168
  className: controlItemClasses
208
- }, /* @__PURE__ */ React2.createElement("div", {
169
+ }, /* @__PURE__ */ React.createElement("div", {
209
170
  role: "none"
210
- }, /* @__PURE__ */ React2.createElement("h3", {
171
+ }, /* @__PURE__ */ React.createElement("h3", {
211
172
  className: controlItemTitleClasses
212
- }, toLocalizedString(title, t)), description && /* @__PURE__ */ React2.createElement("p", {
173
+ }, toLocalizedString(title, t)), description && /* @__PURE__ */ React.createElement("p", {
213
174
  className: controlItemDescriptionClasses
214
175
  }, toLocalizedString(description, t))), children);
215
176
  } finally {
@@ -217,16 +178,16 @@ var ControlItem = ({ title, description, children }) => {
217
178
  }
218
179
  };
219
180
  var ControlItemInput = ({ title, description, children }) => {
220
- var _effect = _useSignals2();
181
+ var _effect = _useSignals();
221
182
  try {
222
183
  const { t } = useTranslation(translationKey);
223
- return /* @__PURE__ */ React2.createElement(Input2.Root, null, /* @__PURE__ */ React2.createElement("div", {
184
+ return /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement("div", {
224
185
  className: controlItemClasses
225
- }, /* @__PURE__ */ React2.createElement("div", {
186
+ }, /* @__PURE__ */ React.createElement("div", {
226
187
  role: "none"
227
- }, /* @__PURE__ */ React2.createElement(Input2.Label, {
188
+ }, /* @__PURE__ */ React.createElement(Input.Label, {
228
189
  classNames: controlItemTitleClasses
229
- }, toLocalizedString(title, t)), description && /* @__PURE__ */ React2.createElement(Input2.DescriptionAndValidation, null, /* @__PURE__ */ React2.createElement(Input2.Description, {
190
+ }, toLocalizedString(title, t)), description && /* @__PURE__ */ React.createElement(Input.DescriptionAndValidation, null, /* @__PURE__ */ React.createElement(Input.Description, {
230
191
  classNames: controlItemDescriptionClasses
231
192
  }, toLocalizedString(description, t)))), children));
232
193
  } finally {
@@ -234,15 +195,15 @@ var ControlItemInput = ({ title, description, children }) => {
234
195
  }
235
196
  };
236
197
  var ControlFrameItem = ({ title, description, children }) => {
237
- var _effect = _useSignals2();
198
+ var _effect = _useSignals();
238
199
  try {
239
200
  const { t } = useTranslation(translationKey);
240
- return /* @__PURE__ */ React2.createElement("div", {
201
+ return /* @__PURE__ */ React.createElement("div", {
241
202
  role: "group",
242
203
  className: "min-is-0"
243
- }, /* @__PURE__ */ React2.createElement("h3", {
204
+ }, /* @__PURE__ */ React.createElement("h3", {
244
205
  className: "text-lg mbe-2"
245
- }, toLocalizedString(title, t)), description && /* @__PURE__ */ React2.createElement("p", {
206
+ }, toLocalizedString(title, t)), description && /* @__PURE__ */ React.createElement("p", {
246
207
  className: "mlb-trimSm md:mbe-0 text-description"
247
208
  }, toLocalizedString(description, t)), children);
248
209
  } finally {
@@ -251,41 +212,41 @@ var ControlFrameItem = ({ title, description, children }) => {
251
212
  };
252
213
 
253
214
  // src/components/FieldEditor/FieldEditor.tsx
254
- import { useSignals as _useSignals14 } from "@preact-signals/safe-react/tracking";
255
- import React14, { useCallback as useCallback9, useEffect as useEffect8, useMemo as useMemo7, useState as useState5 } from "react";
215
+ import { useSignals as _useSignals13 } from "@preact-signals/safe-react/tracking";
216
+ import React13, { useCallback as useCallback9, useEffect as useEffect8, useMemo as useMemo7, useState as useState6 } from "react";
256
217
  import { FormatEnum as FormatEnum5, FormatEnums, formatToType } from "@dxos/echo-schema";
257
218
  import { log as log3 } from "@dxos/log";
258
- import { useTranslation as useTranslation8 } from "@dxos/react-ui";
219
+ import { useAsyncEffect, useTranslation as useTranslation8 } from "@dxos/react-ui";
259
220
  import { getFormatSchema, getSchemaProperties as getSchemaProperties3, sortProperties } from "@dxos/schema";
260
221
 
261
222
  // src/components/Form/custom/GeoPointInput.tsx
262
- import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
263
- import React4, { useCallback, useState, useEffect, useMemo } from "react";
223
+ import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
224
+ import React3, { useCallback, useEffect, useMemo, useState } from "react";
264
225
  import { GeoLocation } from "@dxos/echo-schema";
265
- import { Input as Input4, useTranslation as useTranslation2 } from "@dxos/react-ui";
226
+ import { Input as Input3, useTranslation as useTranslation2 } from "@dxos/react-ui";
266
227
  import { safeParseFloat } from "@dxos/util";
267
228
 
268
229
  // src/components/Form/Input.tsx
269
- import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
270
- import React3 from "react";
271
- import { Icon, Input as Input3, Tooltip } from "@dxos/react-ui";
230
+ import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
231
+ import React2 from "react";
232
+ import { Icon, Input as Input2, Tooltip } from "@dxos/react-ui";
272
233
  import { labelSpacing } from "@dxos/react-ui-stack";
273
- import { errorText, mx as mx3 } from "@dxos/react-ui-theme";
234
+ import { errorText, mx as mx2 } from "@dxos/react-ui-theme";
274
235
  var InputHeader = ({ error, label, readonly }) => {
275
- var _effect = _useSignals3();
236
+ var _effect = _useSignals2();
276
237
  try {
277
- const Label = readonly ? "span" : Input3.Label;
238
+ const Label = readonly ? "span" : Input2.Label;
278
239
  const labelProps = readonly ? {} : {
279
240
  classNames: "!mlb-0"
280
241
  };
281
- return /* @__PURE__ */ React3.createElement("div", {
242
+ return /* @__PURE__ */ React2.createElement("div", {
282
243
  role: "none",
283
- className: mx3("flex justify-between items-center", labelSpacing)
284
- }, /* @__PURE__ */ React3.createElement(Label, labelProps, label), error && /* @__PURE__ */ React3.createElement(Tooltip.Trigger, {
244
+ className: mx2("flex justify-between items-center", labelSpacing)
245
+ }, /* @__PURE__ */ React2.createElement(Label, labelProps, label), error && /* @__PURE__ */ React2.createElement(Tooltip.Trigger, {
285
246
  asChild: true,
286
247
  content: error,
287
248
  side: "bottom"
288
- }, /* @__PURE__ */ React3.createElement(Icon, {
249
+ }, /* @__PURE__ */ React2.createElement(Icon, {
289
250
  icon: "ph--warning--regular",
290
251
  size: 4,
291
252
  classNames: errorText
@@ -296,8 +257,8 @@ var InputHeader = ({ error, label, readonly }) => {
296
257
  };
297
258
 
298
259
  // src/components/Form/custom/GeoPointInput.tsx
299
- var GeoPointInput = ({ type, label, disabled, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
300
- var _effect = _useSignals4();
260
+ var GeoPointInput = ({ type, label, readonly, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
261
+ var _effect = _useSignals3();
301
262
  try {
302
263
  const { t } = useTranslation2(translationKey);
303
264
  const { status, error } = getStatus();
@@ -342,46 +303,52 @@ var GeoPointInput = ({ type, label, disabled, getStatus, getValue: getValue3, on
342
303
  onValueChange,
343
304
  type
344
305
  ]);
345
- return /* @__PURE__ */ React4.createElement(Input4.Root, {
306
+ return /* @__PURE__ */ React3.createElement(Input3.Root, {
346
307
  validationValence: status
347
- }, /* @__PURE__ */ React4.createElement(InputHeader, {
308
+ }, /* @__PURE__ */ React3.createElement(InputHeader, {
348
309
  error,
349
310
  label
350
- }), /* @__PURE__ */ React4.createElement("div", {
311
+ }), /* @__PURE__ */ React3.createElement("div", {
351
312
  role: "none",
352
313
  className: "grid grid-cols-2 gap-2"
353
- }, /* @__PURE__ */ React4.createElement(Input4.TextInput, {
354
- type: "text",
355
- pattern: "^-?[0-9]*\\.?[0-9]*$",
356
- disabled,
357
- placeholder: t("placeholder latitude"),
314
+ }, /* @__PURE__ */ React3.createElement("div", {
315
+ role: "none"
316
+ }, /* @__PURE__ */ React3.createElement(Input3.Label, null, t("latitude label")), /* @__PURE__ */ React3.createElement(Input3.TextInput, {
317
+ type: "number",
318
+ step: "0.00001",
319
+ min: "-90",
320
+ max: "90",
321
+ disabled: !!readonly,
358
322
  value: latitudeText,
359
323
  onChange: handleCoordinateChange("latitude", setLatitudeText),
360
324
  onBlur
361
- }), /* @__PURE__ */ React4.createElement(Input4.TextInput, {
362
- type: "text",
363
- pattern: "^-?[0-9]*\\.?[0-9]*$",
364
- disabled,
365
- placeholder: t("placeholder longitude"),
325
+ })), /* @__PURE__ */ React3.createElement("div", {
326
+ role: "none"
327
+ }, /* @__PURE__ */ React3.createElement(Input3.Label, null, t("longitude label")), /* @__PURE__ */ React3.createElement(Input3.TextInput, {
328
+ type: "number",
329
+ step: "0.00001",
330
+ min: "-180",
331
+ max: "180",
332
+ disabled: !!readonly,
366
333
  value: longitudeText,
367
334
  onChange: handleCoordinateChange("longitude", setLongitudeText),
368
335
  onBlur
369
- })));
336
+ }))));
370
337
  } finally {
371
338
  _effect.f();
372
339
  }
373
340
  };
374
341
 
375
342
  // src/components/Form/custom/SelectOptionsInput.tsx
376
- import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
377
- import React5, { useCallback as useCallback2, useEffect as useEffect2, useState as useState2, useRef } from "react";
343
+ import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
344
+ import React4, { useCallback as useCallback2, useEffect as useEffect2, useRef, useState as useState2 } from "react";
378
345
  import { PublicKey } from "@dxos/keys";
379
- import { Icon as Icon2, IconButton, Input as Input5, Tag, Toolbar, useTranslation as useTranslation3 } from "@dxos/react-ui";
346
+ import { IconButton, Input as Input4, Tag, useTranslation as useTranslation3 } from "@dxos/react-ui";
380
347
  import { List } from "@dxos/react-ui-list";
381
348
  import { HuePicker } from "@dxos/react-ui-pickers";
382
- import { hues, mx as mx4 } from "@dxos/react-ui-theme";
383
- var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3, onValueChange }) => {
384
- var _effect = _useSignals5();
349
+ import { hues, subtleHover } from "@dxos/react-ui-theme";
350
+ var SelectOptionInput = ({ type, label, readonly, getStatus, getValue: getValue3, onValueChange }) => {
351
+ var _effect = _useSignals4();
385
352
  try {
386
353
  const [selected, setSelectedId] = useState2(null);
387
354
  const [isNewOption, setIsNewOption] = useState2(false);
@@ -489,49 +456,56 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
489
456
  selected,
490
457
  isNewOption
491
458
  ]);
492
- return /* @__PURE__ */ React5.createElement(Input5.Root, {
459
+ return /* @__PURE__ */ React4.createElement(Input4.Root, {
493
460
  validationValence: status
494
- }, /* @__PURE__ */ React5.createElement(InputHeader, {
461
+ }, /* @__PURE__ */ React4.createElement(InputHeader, {
495
462
  error,
496
463
  label
497
- }), /* @__PURE__ */ React5.createElement("div", {
464
+ }), /* @__PURE__ */ React4.createElement("div", {
498
465
  role: "none"
499
- }, options && /* @__PURE__ */ React5.createElement(List.Root, {
466
+ }, options && /* @__PURE__ */ React4.createElement(List.Root, {
500
467
  items: options,
501
468
  isItem: (item) => true,
502
- onMove: handleMove
503
- }, ({ items }) => /* @__PURE__ */ React5.createElement("div", {
469
+ onMove: readonly ? void 0 : handleMove,
470
+ readonly: !!readonly
471
+ }, ({ items }) => /* @__PURE__ */ React4.createElement("div", {
504
472
  role: "list",
505
473
  className: "w-full overflow-auto"
506
- }, items?.map((item) => /* @__PURE__ */ React5.createElement("div", {
474
+ }, items?.map((item) => /* @__PURE__ */ React4.createElement("div", {
507
475
  key: item.id
508
- }, /* @__PURE__ */ React5.createElement(List.Item, {
476
+ }, /* @__PURE__ */ React4.createElement(List.Item, {
509
477
  role: "button",
510
478
  item,
511
479
  classNames: [
512
- "p-1 plb-2",
513
- "flex flex-col",
514
- "cursor-pointer",
515
- "hover:bg-hoverOverlay"
480
+ subtleHover,
481
+ "flex flex-col cursor-pointer rounded-sm"
516
482
  ],
517
483
  "aria-expanded": selected === item.id
518
- }, /* @__PURE__ */ React5.createElement("div", {
484
+ }, /* @__PURE__ */ React4.createElement("div", {
519
485
  className: "flex items-center"
520
- }, /* @__PURE__ */ React5.createElement(List.ItemDragHandle, null), /* @__PURE__ */ React5.createElement(List.ItemTitle, {
486
+ }, /* @__PURE__ */ React4.createElement(List.ItemDragHandle, {
487
+ disabled: !!readonly
488
+ }), /* @__PURE__ */ React4.createElement(List.ItemTitle, {
521
489
  onClick: () => handleClick(item.id),
522
490
  classNames: "flex-1"
523
- }, /* @__PURE__ */ React5.createElement(Tag, {
491
+ }, /* @__PURE__ */ React4.createElement(Tag, {
524
492
  palette: item.color
525
- }, item.title || "\u200B")), /* @__PURE__ */ React5.createElement(Icon2, {
493
+ }, item.title || "\u200B")), /* @__PURE__ */ React4.createElement(IconButton, {
494
+ iconOnly: true,
495
+ variant: "ghost",
496
+ label: t(selected === item.id ? "collapse label" : "expand label", {
497
+ ns: "os"
498
+ }),
526
499
  icon: selected === item.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
527
500
  onClick: () => handleClick(item.id)
528
- })), selected === item.id && /* @__PURE__ */ React5.createElement("div", {
529
- className: "mis-4 mbs-2 flex flex-col gap-1"
530
- }, /* @__PURE__ */ React5.createElement(Input5.Label, {
501
+ })), selected === item.id && /* @__PURE__ */ React4.createElement("div", {
502
+ className: "pli-cardSpacingInline plb-cardSpacingBlock flex flex-col gap-1 density-fine"
503
+ }, /* @__PURE__ */ React4.createElement(Input4.Label, {
531
504
  classNames: "text-xs"
532
- }, t("select option label")), /* @__PURE__ */ React5.createElement("div", {
533
- className: "flex flex-row items-center gap-1"
534
- }, /* @__PURE__ */ React5.createElement(Input5.TextInput, {
505
+ }, t("select option label")), /* @__PURE__ */ React4.createElement("div", {
506
+ className: "grid grid-cols-[1fr_min-content_min-content] gap-1"
507
+ }, /* @__PURE__ */ React4.createElement(Input4.TextInput, {
508
+ disabled: !!readonly,
535
509
  placeholder: t("select option label placeholder"),
536
510
  ref: selected === item.id ? inputRef : void 0,
537
511
  value: item.title,
@@ -539,40 +513,34 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
539
513
  onKeyDown: handleKeyDown,
540
514
  classNames: "flex-1",
541
515
  "data-no-submit": true
542
- }), /* @__PURE__ */ React5.createElement(Toolbar.Root, {
543
- classNames: "p-0 m-0 !is-auto"
544
- }, /* @__PURE__ */ React5.createElement(HuePicker, {
516
+ }), /* @__PURE__ */ React4.createElement(HuePicker, {
517
+ disabled: !!readonly,
545
518
  value: item.color,
546
- onChange: handleColorChange(item.id),
547
- rootVariant: "toolbar-button"
548
- })), /* @__PURE__ */ React5.createElement(IconButton, {
519
+ onChange: handleColorChange(item.id)
520
+ }), /* @__PURE__ */ React4.createElement(IconButton, {
521
+ disabled: !!readonly,
549
522
  icon: "ph--trash--fill",
550
523
  iconOnly: true,
551
524
  label: t("select option delete"),
552
525
  onClick: () => handleDelete(item.id)
553
- })))))), /* @__PURE__ */ React5.createElement("div", {
554
- role: "listitem"
555
- }, /* @__PURE__ */ React5.createElement("div", {
556
- role: "button",
557
- className: mx4("p-1 plb-2", "flex flex-col", "cursor-pointer", "hover:bg-hoverOverlay"),
558
- onClick: handleAdd
559
- }, /* @__PURE__ */ React5.createElement("div", {
560
- className: "flex items-center gap-1"
561
- }, /* @__PURE__ */ React5.createElement(Icon2, {
562
- icon: "ph--plus--regular"
563
- }), /* @__PURE__ */ React5.createElement("span", {
564
- className: "text-sm"
565
- }, t("select option add")))))))));
526
+ })))))), /* @__PURE__ */ React4.createElement(IconButton, {
527
+ variant: "ghost",
528
+ icon: "ph--plus--regular",
529
+ label: t("select option add"),
530
+ onClick: handleAdd,
531
+ disabled: !!readonly,
532
+ classNames: "is-full"
533
+ })))));
566
534
  } finally {
567
535
  _effect.f();
568
536
  }
569
537
  };
570
538
 
571
539
  // src/components/Form/custom/TupleInput.tsx
572
- import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
573
- import React6 from "react";
574
- import { Input as Input6 } from "@dxos/react-ui";
575
- import { mx as mx5 } from "@dxos/react-ui-theme";
540
+ import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
541
+ import React5 from "react";
542
+ import { Input as Input5 } from "@dxos/react-ui";
543
+ import { mx as mx3 } from "@dxos/react-ui-theme";
576
544
  import { safeParseFloat as safeParseFloat2 } from "@dxos/util";
577
545
  var gridCols = [
578
546
  "grid-cols-1",
@@ -580,22 +548,22 @@ var gridCols = [
580
548
  "grid-cols-3",
581
549
  "grid-cols-4"
582
550
  ];
583
- var TupleInput = ({ binding, type, label, disabled, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
584
- var _effect = _useSignals6();
551
+ var TupleInput = ({ binding, type, label, readonly, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
552
+ var _effect = _useSignals5();
585
553
  try {
586
554
  const { status, error } = getStatus();
587
555
  const values = getValue3() ?? {};
588
- return /* @__PURE__ */ React6.createElement(Input6.Root, {
556
+ return /* @__PURE__ */ React5.createElement(Input5.Root, {
589
557
  validationValence: status
590
- }, /* @__PURE__ */ React6.createElement(InputHeader, {
558
+ }, /* @__PURE__ */ React5.createElement(InputHeader, {
591
559
  error,
592
560
  label
593
- }), /* @__PURE__ */ React6.createElement("div", {
594
- className: mx5("grid gap-2", gridCols[binding.length - 1])
595
- }, binding.map((prop) => /* @__PURE__ */ React6.createElement(Input6.TextInput, {
561
+ }), /* @__PURE__ */ React5.createElement("div", {
562
+ className: mx3("grid gap-2", gridCols[binding.length - 1])
563
+ }, binding.map((prop) => /* @__PURE__ */ React5.createElement(Input5.TextInput, {
596
564
  key: prop,
597
565
  type: "number",
598
- disabled,
566
+ disabled: !!readonly,
599
567
  value: values[prop],
600
568
  onChange: (event) => onValueChange(type, {
601
569
  ...values,
@@ -609,71 +577,72 @@ var TupleInput = ({ binding, type, label, disabled, getStatus, getValue: getValu
609
577
  };
610
578
 
611
579
  // src/components/Form/Defaults.tsx
612
- import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
613
- import React7, { useCallback as useCallback3, useEffect as useEffect3, useRef as useRef2 } from "react";
614
- import { Input as Input7, Select, useTranslation as useTranslation4 } from "@dxos/react-ui";
615
- var TextInput = ({ type, label, inputOnly, disabled, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
616
- var _effect = _useSignals7();
580
+ import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
581
+ import React6, { useCallback as useCallback3, useEffect as useEffect3, useRef as useRef2 } from "react";
582
+ import { Input as Input6, Select, useTranslation as useTranslation4 } from "@dxos/react-ui";
583
+ var TextInput = ({ type, label, inputOnly, readonly, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
584
+ var _effect = _useSignals6();
617
585
  try {
618
586
  const { status, error } = getStatus();
619
- return disabled && !getValue3() ? null : disabled && inputOnly ? /* @__PURE__ */ React7.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React7.createElement(Input7.Root, {
587
+ return readonly && !getValue3() ? null : readonly === "static" && inputOnly ? /* @__PURE__ */ React6.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React6.createElement(Input6.Root, {
620
588
  validationValence: status
621
- }, !inputOnly && /* @__PURE__ */ React7.createElement(InputHeader, {
589
+ }, !inputOnly && /* @__PURE__ */ React6.createElement(InputHeader, {
622
590
  error,
623
591
  label
624
- }), disabled ? /* @__PURE__ */ React7.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React7.createElement(Input7.TextInput, {
625
- disabled,
592
+ }), readonly === "static" ? /* @__PURE__ */ React6.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React6.createElement(Input6.TextInput, {
593
+ disabled: !!readonly,
626
594
  placeholder,
627
595
  value: getValue3() ?? "",
628
596
  onChange: (event) => onValueChange(type, event.target.value),
629
597
  onBlur
630
- }), inputOnly && /* @__PURE__ */ React7.createElement(Input7.Validation, null, error));
598
+ }), inputOnly && /* @__PURE__ */ React6.createElement(Input6.Validation, null, error));
631
599
  } finally {
632
600
  _effect.f();
633
601
  }
634
602
  };
635
- var NumberInput = ({ type, label, inputOnly, disabled, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
636
- var _effect = _useSignals7();
603
+ var NumberInput = ({ type, label, inputOnly, readonly, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
604
+ var _effect = _useSignals6();
637
605
  try {
638
606
  const { status, error } = getStatus();
639
- return disabled && !getValue3() ? null : disabled && inputOnly ? /* @__PURE__ */ React7.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React7.createElement(Input7.Root, {
607
+ return readonly && !getValue3() ? null : readonly === "static" && inputOnly ? /* @__PURE__ */ React6.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React6.createElement(Input6.Root, {
640
608
  validationValence: status
641
- }, !inputOnly && /* @__PURE__ */ React7.createElement(InputHeader, {
609
+ }, !inputOnly && /* @__PURE__ */ React6.createElement(InputHeader, {
642
610
  error,
643
611
  label
644
- }), disabled ? /* @__PURE__ */ React7.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React7.createElement(Input7.TextInput, {
612
+ }), readonly === "static" ? /* @__PURE__ */ React6.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React6.createElement(Input6.TextInput, {
645
613
  type: "number",
646
- disabled,
614
+ disabled: !!readonly,
647
615
  placeholder,
648
- value: getValue3() ?? 0,
616
+ value: getValue3(),
649
617
  onChange: (event) => onValueChange(type, event.target.value),
650
618
  onBlur
651
- }), inputOnly && /* @__PURE__ */ React7.createElement(Input7.DescriptionAndValidation, null, error));
619
+ }), inputOnly && /* @__PURE__ */ React6.createElement(Input6.DescriptionAndValidation, null, error));
652
620
  } finally {
653
621
  _effect.f();
654
622
  }
655
623
  };
656
- var BooleanInput = ({ type, label, inputOnly, getStatus, getValue: getValue3, onValueChange, disabled }) => {
657
- var _effect = _useSignals7();
624
+ var BooleanInput = ({ type, label, inputOnly, getStatus, getValue: getValue3, onValueChange, readonly }) => {
625
+ var _effect = _useSignals6();
658
626
  try {
659
627
  const { status, error } = getStatus();
660
628
  const checked = Boolean(getValue3());
661
629
  const { t } = useTranslation4(translationKey);
662
- return /* @__PURE__ */ React7.createElement(Input7.Root, {
630
+ return /* @__PURE__ */ React6.createElement(Input6.Root, {
663
631
  validationValence: status
664
- }, !inputOnly && /* @__PURE__ */ React7.createElement(InputHeader, {
632
+ }, !inputOnly && /* @__PURE__ */ React6.createElement(InputHeader, {
665
633
  error,
666
634
  label
667
- }), disabled ? /* @__PURE__ */ React7.createElement("p", null, t(checked ? "boolean input true value" : "boolean input false value")) : /* @__PURE__ */ React7.createElement(Input7.Switch, {
635
+ }), readonly === "static" ? /* @__PURE__ */ React6.createElement("p", null, t(checked ? "boolean input true value" : "boolean input false value")) : /* @__PURE__ */ React6.createElement(Input6.Switch, {
636
+ disabled: !!readonly,
668
637
  checked,
669
638
  onCheckedChange: (value) => onValueChange(type, value)
670
- }), inputOnly && /* @__PURE__ */ React7.createElement(Input7.DescriptionAndValidation, null, error));
639
+ }), inputOnly && /* @__PURE__ */ React6.createElement(Input6.DescriptionAndValidation, null, error));
671
640
  } finally {
672
641
  _effect.f();
673
642
  }
674
643
  };
675
- var SelectInput = ({ type, label, inputOnly, disabled, placeholder, options, getStatus, getValue: getValue3, onValueChange }) => {
676
- var _effect = _useSignals7();
644
+ var SelectInput = ({ type, label, inputOnly, readonly, placeholder, options, getStatus, getValue: getValue3, onValueChange }) => {
645
+ var _effect = _useSignals6();
677
646
  try {
678
647
  const { status, error } = getStatus();
679
648
  const value = getValue3();
@@ -681,31 +650,31 @@ var SelectInput = ({ type, label, inputOnly, disabled, placeholder, options, get
681
650
  type,
682
651
  onValueChange
683
652
  ]);
684
- return disabled && !value ? null : /* @__PURE__ */ React7.createElement(Input7.Root, {
653
+ return readonly && !value ? null : /* @__PURE__ */ React6.createElement(Input6.Root, {
685
654
  validationValence: status
686
- }, !inputOnly && /* @__PURE__ */ React7.createElement(InputHeader, {
655
+ }, !inputOnly && /* @__PURE__ */ React6.createElement(InputHeader, {
687
656
  error,
688
657
  label
689
- }), disabled ? /* @__PURE__ */ React7.createElement("p", null, options?.find(({ value: optionValue }) => optionValue === value)?.label ?? String(value)) : /* @__PURE__ */ React7.createElement(Select.Root, {
658
+ }), readonly === "static" ? /* @__PURE__ */ React6.createElement("p", null, options?.find(({ value: optionValue }) => optionValue === value)?.label ?? String(value)) : /* @__PURE__ */ React6.createElement(Select.Root, {
690
659
  value,
691
660
  onValueChange: handleValueChange
692
- }, /* @__PURE__ */ React7.createElement(Select.TriggerButton, {
661
+ }, /* @__PURE__ */ React6.createElement(Select.TriggerButton, {
693
662
  classNames: "is-full",
694
- disabled,
663
+ disabled: !!readonly,
695
664
  placeholder
696
- }), /* @__PURE__ */ React7.createElement(Select.Portal, null, /* @__PURE__ */ React7.createElement(Select.Content, null, /* @__PURE__ */ React7.createElement(Select.Viewport, null, options?.map(({ value: value2, label: label2 }) => (
665
+ }), /* @__PURE__ */ React6.createElement(Select.Portal, null, /* @__PURE__ */ React6.createElement(Select.Content, null, /* @__PURE__ */ React6.createElement(Select.Viewport, null, options?.map(({ value: value2, label: label2 }) => (
697
666
  // NOTE: Numeric values are converted to and from strings.
698
- /* @__PURE__ */ React7.createElement(Select.Option, {
667
+ /* @__PURE__ */ React6.createElement(Select.Option, {
699
668
  key: String(value2),
700
669
  value: String(value2)
701
670
  }, label2 ?? String(value2))
702
- )))))), inputOnly && /* @__PURE__ */ React7.createElement(Input7.DescriptionAndValidation, null, error));
671
+ ))), /* @__PURE__ */ React6.createElement(Select.Arrow, null)))), inputOnly && /* @__PURE__ */ React6.createElement(Input6.DescriptionAndValidation, null, error));
703
672
  } finally {
704
673
  _effect.f();
705
674
  }
706
675
  };
707
- var MarkdownInput = ({ type, label, inputOnly, disabled, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
708
- var _effect = _useSignals7();
676
+ var MarkdownInput = ({ type, label, inputOnly, readonly, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
677
+ var _effect = _useSignals6();
709
678
  try {
710
679
  const { status, error } = getStatus();
711
680
  const textareaRef = useRef2(null);
@@ -727,14 +696,14 @@ var MarkdownInput = ({ type, label, inputOnly, disabled, placeholder, getStatus,
727
696
  getValue3(),
728
697
  adjustHeight
729
698
  ]);
730
- return /* @__PURE__ */ React7.createElement(Input7.Root, {
699
+ return /* @__PURE__ */ React6.createElement(Input6.Root, {
731
700
  validationValence: status
732
- }, !inputOnly && /* @__PURE__ */ React7.createElement(InputHeader, {
701
+ }, !inputOnly && /* @__PURE__ */ React6.createElement(InputHeader, {
733
702
  error,
734
703
  label
735
- }), disabled ? /* @__PURE__ */ React7.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React7.createElement(Input7.TextArea, {
704
+ }), readonly === "static" ? /* @__PURE__ */ React6.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React6.createElement(Input6.TextArea, {
736
705
  ref: textareaRef,
737
- disabled,
706
+ disabled: !!readonly,
738
707
  placeholder,
739
708
  value: getValue3() ?? "",
740
709
  classNames: "min-bs-auto max-h-40 overflow-auto",
@@ -744,27 +713,28 @@ var MarkdownInput = ({ type, label, inputOnly, disabled, placeholder, getStatus,
744
713
  resize: "none"
745
714
  },
746
715
  spellCheck: false
747
- }), inputOnly && /* @__PURE__ */ React7.createElement(Input7.Validation, null, error));
716
+ }), inputOnly && /* @__PURE__ */ React6.createElement(Input6.Validation, null, error));
748
717
  } finally {
749
718
  _effect.f();
750
719
  }
751
720
  };
752
721
 
753
722
  // src/components/Form/Form.tsx
754
- import { useSignals as _useSignals13 } from "@preact-signals/safe-react/tracking";
755
- import React13, { useEffect as useEffect7, useMemo as useMemo6, useRef as useRef3 } from "react";
723
+ import { useSignals as _useSignals12 } from "@preact-signals/safe-react/tracking";
724
+ import { useFocusFinders } from "@fluentui/react-tabster";
725
+ import React12, { useEffect as useEffect7, useMemo as useMemo6, useRef as useRef3 } from "react";
756
726
  import { cardDialogOverflow, cardSpacing as cardSpacing2 } from "@dxos/react-ui-stack";
757
727
 
758
728
  // src/components/Form/FormActions.tsx
759
- import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
760
- import React9 from "react";
729
+ import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
730
+ import React8 from "react";
761
731
  import { IconButton as IconButton2, useTranslation as useTranslation5 } from "@dxos/react-ui";
762
732
  import { cardSpacing } from "@dxos/react-ui-stack";
763
- import { mx as mx6 } from "@dxos/react-ui-theme";
733
+ import { mx as mx4 } from "@dxos/react-ui-theme";
764
734
 
765
735
  // src/components/Form/FormContext.tsx
766
- import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
767
- import React8, { createContext, useContext, useEffect as useEffect6, useMemo as useMemo3, useCallback as useCallback6 } from "react";
736
+ import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
737
+ import React7, { createContext, useCallback as useCallback6, useContext, useEffect as useEffect6, useMemo as useMemo3 } from "react";
768
738
  import { raise } from "@dxos/debug";
769
739
  import { getValue as getValue2 } from "@dxos/echo-schema";
770
740
  import { createJsonPath as createJsonPath2 } from "@dxos/effect";
@@ -781,7 +751,7 @@ var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-form/src/hooks/useForm.t
781
751
  var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, onSave }) => {
782
752
  invariant(SchemaAST.isTypeLiteral(schema.ast), void 0, {
783
753
  F: __dxlog_file,
784
- L: 93,
754
+ L: 95,
785
755
  S: void 0,
786
756
  A: [
787
757
  "SchemaAST.isTypeLiteral(schema.ast)",
@@ -885,7 +855,7 @@ var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, on
885
855
  } catch (err) {
886
856
  log.catch(err, void 0, {
887
857
  F: __dxlog_file,
888
- L: 213,
858
+ L: 215,
889
859
  S: void 0,
890
860
  C: (f, a) => f(...a)
891
861
  });
@@ -956,7 +926,7 @@ var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, on
956
926
  var createKeySet = (obj, value) => {
957
927
  invariant(obj, void 0, {
958
928
  F: __dxlog_file,
959
- L: 275,
929
+ L: 277,
960
930
  S: void 0,
961
931
  A: [
962
932
  "obj",
@@ -1081,7 +1051,7 @@ var useInputProps = (path = []) => {
1081
1051
  ]);
1082
1052
  };
1083
1053
  var FormProvider = ({ children, formRef, autoSave, ...formOptions }) => {
1084
- var _effect = _useSignals8();
1054
+ var _effect = _useSignals7();
1085
1055
  try {
1086
1056
  const form = useForm(formOptions);
1087
1057
  const handleKeyDown = useCallback6((event) => {
@@ -1117,7 +1087,7 @@ var FormProvider = ({ children, formRef, autoSave, ...formOptions }) => {
1117
1087
  form.handleSave,
1118
1088
  autoSave
1119
1089
  ]);
1120
- return /* @__PURE__ */ React8.createElement(FormContext.Provider, {
1090
+ return /* @__PURE__ */ React7.createElement(FormContext.Provider, {
1121
1091
  value: form
1122
1092
  }, children);
1123
1093
  } finally {
@@ -1127,19 +1097,19 @@ var FormProvider = ({ children, formRef, autoSave, ...formOptions }) => {
1127
1097
 
1128
1098
  // src/components/Form/FormActions.tsx
1129
1099
  var FormActions = ({ readonly, onCancel, outerSpacing = true }) => {
1130
- var _effect = _useSignals9();
1100
+ var _effect = _useSignals8();
1131
1101
  try {
1132
1102
  const { t } = useTranslation5(translationKey);
1133
1103
  const { canSave, handleSave } = useFormContext();
1134
- return /* @__PURE__ */ React9.createElement("div", {
1104
+ return /* @__PURE__ */ React8.createElement("div", {
1135
1105
  role: "none",
1136
- className: mx6(outerSpacing === "scroll-fields" ? "pli-cardSpacingInline mbe-cardSpacingBlock" : outerSpacing ? cardSpacing : "mbs-cardSpacingBlock", "flex [&_button]:grow gap-1 first:mbs-0")
1137
- }, onCancel && !readonly && /* @__PURE__ */ React9.createElement(IconButton2, {
1106
+ className: mx4(outerSpacing === "scroll-fields" ? "pli-cardSpacingInline mbe-cardSpacingBlock" : outerSpacing ? cardSpacing : "mbs-cardSpacingBlock", "flex [&_button]:grow gap-1 first:mbs-0")
1107
+ }, onCancel && !readonly && /* @__PURE__ */ React8.createElement(IconButton2, {
1138
1108
  "data-testid": "cancel-button",
1139
1109
  icon: "ph--x--regular",
1140
1110
  label: t("button cancel"),
1141
1111
  onClick: onCancel
1142
- }), handleSave && /* @__PURE__ */ React9.createElement(IconButton2, {
1112
+ }), handleSave && /* @__PURE__ */ React8.createElement(IconButton2, {
1143
1113
  type: "submit",
1144
1114
  "data-testid": "save-button",
1145
1115
  disabled: !canSave,
@@ -1153,25 +1123,15 @@ var FormActions = ({ readonly, onCancel, outerSpacing = true }) => {
1153
1123
  };
1154
1124
 
1155
1125
  // src/components/Form/FormContent.tsx
1156
- import { useSignals as _useSignals12 } from "@preact-signals/safe-react/tracking";
1126
+ import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
1157
1127
  import { Schema, SchemaAST as SchemaAST4, pipe as pipe2 } from "effect";
1158
1128
  import { capitalize as capitalize2 } from "effect/String";
1159
- import React12, { forwardRef, useMemo as useMemo5 } from "react";
1129
+ import React11, { forwardRef, useMemo as useMemo5 } from "react";
1160
1130
  import { createJsonPath as createJsonPath3, findNode as findNode3, getDiscriminatedType as getDiscriminatedType2, isDiscriminatedUnion as isDiscriminatedUnion2 } from "@dxos/effect";
1161
- import { mx as mx8 } from "@dxos/react-ui-theme";
1131
+ import { mx as mx6 } from "@dxos/react-ui-theme";
1162
1132
  import { getSchemaProperties as getSchemaProperties2 } from "@dxos/schema";
1163
1133
  import { isNotFalsy } from "@dxos/util";
1164
1134
 
1165
- // src/components/Form/ArrayField.tsx
1166
- import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
1167
- import { SchemaAST as SchemaAST3, pipe } from "effect";
1168
- import { capitalize } from "effect/String";
1169
- import React10, { Fragment, useCallback as useCallback7 } from "react";
1170
- import { findNode as findNode2, getDiscriminatedType, isDiscriminatedUnion, SimpleType } from "@dxos/effect";
1171
- import { invariant as invariant2 } from "@dxos/invariant";
1172
- import { IconButton as IconButton3, useTranslation as useTranslation6 } from "@dxos/react-ui";
1173
- import { getSchemaProperties } from "@dxos/schema";
1174
-
1175
1135
  // src/util/field.ts
1176
1136
  import { FormatEnum, GeoLocation as GeoLocation2, TypeEnum } from "@dxos/echo-schema";
1177
1137
  var parseValue = ({ type, format, value }) => {
@@ -1253,28 +1213,7 @@ var parseValue = ({ type, format, value }) => {
1253
1213
  }
1254
1214
  };
1255
1215
  var cellClassesForFieldType = ({ type, format }) => {
1256
- if (!format) {
1257
- switch (type) {
1258
- case TypeEnum.Number:
1259
- return [
1260
- "text-right",
1261
- "font-mono"
1262
- ];
1263
- case TypeEnum.Boolean:
1264
- return [
1265
- "text-right",
1266
- "font-mono"
1267
- ];
1268
- case TypeEnum.String:
1269
- return void 0;
1270
- case TypeEnum.Ref:
1271
- return void 0;
1272
- default: {
1273
- return void 0;
1274
- }
1275
- }
1276
- }
1277
- switch (format) {
1216
+ switch (format || type) {
1278
1217
  case FormatEnum.Markdown:
1279
1218
  return void 0;
1280
1219
  case FormatEnum.Time:
@@ -1295,6 +1234,16 @@ var cellClassesForFieldType = ({ type, format }) => {
1295
1234
  return [
1296
1235
  "font-mono"
1297
1236
  ];
1237
+ case TypeEnum.Number:
1238
+ case TypeEnum.Boolean:
1239
+ return [
1240
+ "text-right",
1241
+ "font-mono"
1242
+ ];
1243
+ case TypeEnum.String:
1244
+ return void 0;
1245
+ case TypeEnum.Ref:
1246
+ return void 0;
1298
1247
  default:
1299
1248
  return void 0;
1300
1249
  }
@@ -1480,9 +1429,17 @@ var getRefProps = (property) => {
1480
1429
  };
1481
1430
 
1482
1431
  // src/components/Form/ArrayField.tsx
1432
+ import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
1433
+ import { SchemaAST as SchemaAST3, pipe } from "effect";
1434
+ import { capitalize } from "effect/String";
1435
+ import React9, { Fragment, useCallback as useCallback7 } from "react";
1436
+ import { SimpleType, findNode as findNode2, getDiscriminatedType, isDiscriminatedUnion } from "@dxos/effect";
1437
+ import { invariant as invariant2 } from "@dxos/invariant";
1438
+ import { IconButton as IconButton3, useTranslation as useTranslation6 } from "@dxos/react-ui";
1439
+ import { getSchemaProperties } from "@dxos/schema";
1483
1440
  var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/Form/ArrayField.tsx";
1484
1441
  var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponent }) => {
1485
- var _effect = _useSignals10();
1442
+ var _effect = _useSignals9();
1486
1443
  try {
1487
1444
  const { t } = useTranslation6(translationKey);
1488
1445
  const { ast, name, type, title } = property;
@@ -1532,14 +1489,14 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
1532
1489
  if (!elementType) {
1533
1490
  return null;
1534
1491
  }
1535
- return readonly && values.length < 1 ? null : /* @__PURE__ */ React10.createElement(React10.Fragment, null, /* @__PURE__ */ React10.createElement(InputHeader, {
1492
+ return readonly && values.length < 1 ? null : /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(InputHeader, {
1536
1493
  readonly: true,
1537
1494
  label
1538
- }), /* @__PURE__ */ React10.createElement("div", {
1495
+ }), /* @__PURE__ */ React9.createElement("div", {
1539
1496
  role: "none",
1540
1497
  className: readonly ? "flex flex-wrap gap-1 mlb-1" : values.length > 0 ? "grid gap-1 grid-cols-[1fr_min-content] mlb-1" : "hidden"
1541
1498
  }, values.map((_value, index) => {
1542
- const field = /* @__PURE__ */ React10.createElement(FormField, {
1499
+ const field = /* @__PURE__ */ React9.createElement(FormField, {
1543
1500
  property: {
1544
1501
  ...property,
1545
1502
  array: false,
@@ -1554,18 +1511,18 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
1554
1511
  Custom,
1555
1512
  lookupComponent
1556
1513
  });
1557
- return readonly ? field : /* @__PURE__ */ React10.createElement(Fragment, {
1514
+ return readonly ? field : /* @__PURE__ */ React9.createElement(Fragment, {
1558
1515
  key: index
1559
- }, /* @__PURE__ */ React10.createElement("div", {
1516
+ }, /* @__PURE__ */ React9.createElement("div", {
1560
1517
  role: "none"
1561
- }, field), /* @__PURE__ */ React10.createElement(IconButton3, {
1518
+ }, field), /* @__PURE__ */ React9.createElement(IconButton3, {
1562
1519
  icon: "ph--trash--regular",
1563
1520
  iconOnly: true,
1564
1521
  label: t("button remove"),
1565
1522
  onClick: () => handleRemove(index),
1566
1523
  classNames: "self-center"
1567
1524
  }));
1568
- })), !readonly && /* @__PURE__ */ React10.createElement(IconButton3, {
1525
+ })), !readonly && /* @__PURE__ */ React9.createElement(IconButton3, {
1569
1526
  classNames: "is-full mlb-cardSpacingBlock flex",
1570
1527
  icon: "ph--plus--regular",
1571
1528
  label: t("add field"),
@@ -1576,19 +1533,42 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
1576
1533
  }
1577
1534
  };
1578
1535
 
1536
+ // src/components/Form/factory.tsx
1537
+ import { FormatEnum as FormatEnum4 } from "@dxos/echo-schema";
1538
+ var getInputComponent = (type, format) => {
1539
+ switch (format) {
1540
+ case FormatEnum4.GeoPoint:
1541
+ return GeoPointInput;
1542
+ case FormatEnum4.Markdown:
1543
+ return MarkdownInput;
1544
+ }
1545
+ switch (type) {
1546
+ case "string":
1547
+ return TextInput;
1548
+ case "number":
1549
+ return NumberInput;
1550
+ case "boolean":
1551
+ return BooleanInput;
1552
+ }
1553
+ };
1554
+
1579
1555
  // src/components/Form/RefField.tsx
1580
- import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
1581
- import React11, { useCallback as useCallback8, useMemo as useMemo4 } from "react";
1582
- import { Expando, getTypeAnnotation, Ref, ReferenceAnnotationId as ReferenceAnnotationId2 } from "@dxos/echo-schema";
1556
+ import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
1557
+ import React10, { useCallback as useCallback8, useMemo as useMemo4, useState as useState5 } from "react";
1558
+ import { Expando, Ref, ReferenceAnnotationId as ReferenceAnnotationId2, getTypeAnnotation } from "@dxos/echo-schema";
1583
1559
  import { findAnnotation as findAnnotation2 } from "@dxos/effect";
1584
1560
  import { DXN } from "@dxos/keys";
1585
- import { DxRefTag } from "@dxos/lit-ui/react";
1586
- import { Input as Input8, useTranslation as useTranslation7 } from "@dxos/react-ui";
1587
- import { TagPicker } from "@dxos/react-ui-tag-picker";
1588
- import { descriptionText, mx as mx7 } from "@dxos/react-ui-theme";
1561
+ import { DxAnchor } from "@dxos/lit-ui/react";
1562
+ import { Button as Button2, Icon as Icon2, Input as Input7, useTranslation as useTranslation7 } from "@dxos/react-ui";
1563
+ import { PopoverCombobox } from "@dxos/react-ui-searchlist";
1564
+ import { TagPickerItem } from "@dxos/react-ui-tag-picker";
1565
+ import { descriptionText, mx as mx5 } from "@dxos/react-ui-theme";
1589
1566
  import { isNonNullable as isNonNullable2 } from "@dxos/util";
1590
- var RefField = ({ type, label, disabled, placeholder, inputOnly, array, ast, getValue: getValue3, onBlur, onQueryRefOptions, onValueChange, ...restInputProps }) => {
1591
- var _effect = _useSignals11();
1567
+ var isRefSnapShot = (val) => {
1568
+ return typeof val === "object" && typeof val?.["/"] === "string";
1569
+ };
1570
+ var RefField = ({ type, label, readonly, placeholder, inputOnly, array, ast, getValue: getValue3, onBlur, onQueryRefOptions, createOptionLabel, createOptionIcon, onCreateFromQuery, onValueChange, ...restInputProps }) => {
1571
+ var _effect = _useSignals10();
1592
1572
  try {
1593
1573
  const { t } = useTranslation7(translationKey);
1594
1574
  const refTypeInfo = useMemo4(() => ast ? findAnnotation2(ast, ReferenceAnnotationId2) : void 0, [
@@ -1599,11 +1579,11 @@ var RefField = ({ type, label, disabled, placeholder, inputOnly, array, ast, get
1599
1579
  onQueryRefOptions
1600
1580
  });
1601
1581
  if (refTypeInfo && refTypeInfo?.typename === getTypeAnnotation(Expando)?.typename || !onQueryRefOptions) {
1602
- return /* @__PURE__ */ React11.createElement(RefFieldFallback, {
1582
+ return /* @__PURE__ */ React10.createElement(RefFieldFallback, {
1603
1583
  type,
1604
1584
  label,
1605
1585
  placeholder,
1606
- disabled,
1586
+ readonly,
1607
1587
  inputOnly,
1608
1588
  getValue: getValue3,
1609
1589
  onBlur,
@@ -1614,8 +1594,9 @@ var RefField = ({ type, label, disabled, placeholder, inputOnly, array, ast, get
1614
1594
  const handleGetValue = useCallback8(() => {
1615
1595
  const formValue = getValue3();
1616
1596
  const unknownToRefOption = (val) => {
1617
- if (Ref.isRef(val)) {
1618
- const dxnString = val.dxn.toString();
1597
+ const isRef = Ref.isRef(val);
1598
+ if (isRef || isRefSnapShot(val)) {
1599
+ const dxnString = isRef ? val.dxn.toString() : val["/"];
1619
1600
  const matchingOption = availableOptions.find((option2) => option2.id === dxnString);
1620
1601
  if (matchingOption) {
1621
1602
  return matchingOption;
@@ -1638,13 +1619,6 @@ var RefField = ({ type, label, disabled, placeholder, inputOnly, array, ast, get
1638
1619
  availableOptions,
1639
1620
  array
1640
1621
  ]);
1641
- const handleSearch = useCallback8((text, ids) => availableOptions.filter((option) => !ids.includes(option.id)).filter((option) => option.label.toLowerCase().includes(text.toLowerCase())).map((option) => ({
1642
- id: option.id,
1643
- label: option.label,
1644
- hue: option.hue
1645
- })), [
1646
- availableOptions
1647
- ]);
1648
1622
  const handleUpdate = useCallback8((ids) => {
1649
1623
  if (ids.length === 0) {
1650
1624
  onValueChange("object", void 0);
@@ -1668,45 +1642,115 @@ var RefField = ({ type, label, disabled, placeholder, inputOnly, array, ast, get
1668
1642
  array,
1669
1643
  onValueChange
1670
1644
  ]);
1671
- const tagPickerMode = useMemo4(() => array ? "multi-select" : "single-select", [
1672
- array
1673
- ]);
1674
1645
  if (!refTypeInfo) {
1675
1646
  return null;
1676
1647
  }
1677
1648
  const { status, error } = restInputProps.getStatus();
1678
1649
  const items = handleGetValue();
1679
- return disabled && items.length < 1 ? null : /* @__PURE__ */ React11.createElement(Input8.Root, {
1650
+ const selectedIds = useMemo4(() => items.map((i) => i.id), [
1651
+ items
1652
+ ]);
1653
+ const labelById = useMemo4(() => availableOptions.reduce((acc, option) => {
1654
+ acc[option.id.toLowerCase()] = option.label.toLowerCase();
1655
+ return acc;
1656
+ }, {}), [
1657
+ availableOptions
1658
+ ]);
1659
+ const [query, setQuery] = useState5("");
1660
+ const toggleSelect = useCallback8((id) => {
1661
+ if (array) {
1662
+ const nextIds = selectedIds.includes(id) ? selectedIds.filter((x) => x !== id) : [
1663
+ ...selectedIds,
1664
+ id
1665
+ ];
1666
+ handleUpdate(nextIds);
1667
+ } else {
1668
+ if (selectedIds[0] === id) {
1669
+ handleUpdate([]);
1670
+ } else {
1671
+ handleUpdate([
1672
+ id
1673
+ ]);
1674
+ }
1675
+ }
1676
+ }, [
1677
+ array,
1678
+ selectedIds,
1679
+ handleUpdate
1680
+ ]);
1681
+ return readonly && items.length < 1 ? null : /* @__PURE__ */ React10.createElement(Input7.Root, {
1680
1682
  validationValence: status
1681
- }, !inputOnly && /* @__PURE__ */ React11.createElement(InputHeader, {
1683
+ }, !inputOnly && /* @__PURE__ */ React10.createElement(InputHeader, {
1682
1684
  error,
1683
1685
  label
1684
- }), /* @__PURE__ */ React11.createElement("div", {
1686
+ }), /* @__PURE__ */ React10.createElement("div", {
1685
1687
  "data-no-submit": true
1686
- }, disabled ? items.length < 1 ? /* @__PURE__ */ React11.createElement("p", {
1687
- className: mx7(descriptionText, "mbe-2")
1688
- }, t("empty readonly ref field label")) : items.map((item) => /* @__PURE__ */ React11.createElement(DxRefTag, {
1688
+ }, readonly ? items.length < 1 ? /* @__PURE__ */ React10.createElement("p", {
1689
+ className: mx5(descriptionText, "mbe-2")
1690
+ }, t("empty readonly ref field label")) : items.map((item) => /* @__PURE__ */ React10.createElement(DxAnchor, {
1689
1691
  key: item.id,
1690
1692
  refid: item.id,
1691
- rootclassname: "mie-1",
1692
- style: {
1693
- marginInlineEnd: ".25rem"
1693
+ rootclassname: "mie-1"
1694
+ }, item.label)) : /* @__PURE__ */ React10.createElement(PopoverCombobox.Root, null, /* @__PURE__ */ React10.createElement(PopoverCombobox.Trigger, {
1695
+ asChild: true
1696
+ }, /* @__PURE__ */ React10.createElement(Button2, {
1697
+ variant: "ghost",
1698
+ classNames: "is-full text-start gap-2"
1699
+ }, /* @__PURE__ */ React10.createElement("div", {
1700
+ role: "none",
1701
+ className: "grow"
1702
+ }, items?.length ? items?.map((item) => /* @__PURE__ */ React10.createElement(TagPickerItem, {
1703
+ key: item.id,
1704
+ itemId: item.id,
1705
+ label: item.label,
1706
+ ...item.hue ? {
1707
+ hue: item.hue
1708
+ } : {},
1709
+ removeLabel: t("remove item label"),
1710
+ onItemClick: (event) => {
1711
+ if (event.action === "remove") {
1712
+ toggleSelect(item.id);
1713
+ }
1694
1714
  }
1695
- }, item.label)) : /* @__PURE__ */ React11.createElement(TagPicker, {
1696
- readonly: disabled,
1697
- items,
1698
- mode: tagPickerMode,
1699
- onBlur: (event) => onBlur(event),
1700
- onUpdate: handleUpdate,
1701
- onSearch: handleSearch,
1702
- classNames: "bg-inputSurface p-1.5 rounded-sm"
1703
- })), inputOnly && /* @__PURE__ */ React11.createElement(Input8.DescriptionAndValidation, null, error));
1715
+ })) : /* @__PURE__ */ React10.createElement("span", {
1716
+ className: "text-description"
1717
+ }, placeholder ?? t("ref field placeholder", {
1718
+ count: array ? 99 : 1
1719
+ }))), /* @__PURE__ */ React10.createElement(Icon2, {
1720
+ size: 3,
1721
+ icon: "ph--caret-down--bold"
1722
+ }))), /* @__PURE__ */ React10.createElement(PopoverCombobox.Content, {
1723
+ filter: (value, search) => value === "__create__" || labelById[value]?.includes(search.toLowerCase()) ? 1 : 0
1724
+ }, /* @__PURE__ */ React10.createElement(PopoverCombobox.Input, {
1725
+ placeholder: "Search...",
1726
+ value: query,
1727
+ onValueChange: (v) => setQuery(v),
1728
+ autoFocus: true
1729
+ }), /* @__PURE__ */ React10.createElement(PopoverCombobox.List, null, availableOptions.map((option) => /* @__PURE__ */ React10.createElement(PopoverCombobox.Item, {
1730
+ key: option.id,
1731
+ value: option.id,
1732
+ onSelect: () => toggleSelect(option.id),
1733
+ classNames: "flex items-center gap-2"
1734
+ }, /* @__PURE__ */ React10.createElement("span", {
1735
+ className: "grow"
1736
+ }, option.label), selectedIds.includes(option.id) && /* @__PURE__ */ React10.createElement(Icon2, {
1737
+ icon: "ph--check--regular"
1738
+ }))), query.length > 0 && createOptionLabel && createOptionIcon && onCreateFromQuery && /* @__PURE__ */ React10.createElement(PopoverCombobox.Item, {
1739
+ value: "__create__",
1740
+ onSelect: () => onCreateFromQuery?.(refTypeInfo, query),
1741
+ classNames: "flex items-center gap-2"
1742
+ }, /* @__PURE__ */ React10.createElement(Icon2, {
1743
+ icon: createOptionIcon
1744
+ }), t(createOptionLabel[0], {
1745
+ ns: createOptionLabel[1].ns,
1746
+ text: query
1747
+ }))), /* @__PURE__ */ React10.createElement(PopoverCombobox.Arrow, null)))), inputOnly && /* @__PURE__ */ React10.createElement(Input7.DescriptionAndValidation, null, error));
1704
1748
  } finally {
1705
1749
  _effect.f();
1706
1750
  }
1707
1751
  };
1708
- var RefFieldFallback = ({ type, label, disabled, placeholder, inputOnly, getValue: getValue3, onValueChange, ...restInputProps }) => {
1709
- var _effect = _useSignals11();
1752
+ var RefFieldFallback = ({ type, label, readonly, placeholder, inputOnly, getValue: getValue3, onValueChange, ...restInputProps }) => {
1753
+ var _effect = _useSignals10();
1710
1754
  try {
1711
1755
  const handleOnValueChange = (_type, dxnString) => {
1712
1756
  const dxn = DXN.tryParse(dxnString);
@@ -1728,10 +1772,10 @@ var RefFieldFallback = ({ type, label, disabled, placeholder, inputOnly, getValu
1728
1772
  }
1729
1773
  return void 0;
1730
1774
  };
1731
- return /* @__PURE__ */ React11.createElement(TextInput, {
1775
+ return /* @__PURE__ */ React10.createElement(TextInput, {
1732
1776
  type,
1733
1777
  label,
1734
- disabled,
1778
+ readonly,
1735
1779
  placeholder,
1736
1780
  inputOnly,
1737
1781
  getValue: handleGetValue,
@@ -1743,28 +1787,9 @@ var RefFieldFallback = ({ type, label, disabled, placeholder, inputOnly, getValu
1743
1787
  }
1744
1788
  };
1745
1789
 
1746
- // src/components/Form/factory.tsx
1747
- import { FormatEnum as FormatEnum4 } from "@dxos/echo-schema";
1748
- var getInputComponent = (type, format) => {
1749
- switch (format) {
1750
- case FormatEnum4.GeoPoint:
1751
- return GeoPointInput;
1752
- case FormatEnum4.Markdown:
1753
- return MarkdownInput;
1754
- }
1755
- switch (type) {
1756
- case "string":
1757
- return TextInput;
1758
- case "number":
1759
- return NumberInput;
1760
- case "boolean":
1761
- return BooleanInput;
1762
- }
1763
- };
1764
-
1765
1790
  // src/components/Form/FormContent.tsx
1766
- var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupComponent, Custom }) => {
1767
- var _effect = _useSignals12();
1791
+ var FormField = ({ property, path, readonly, inline, projection, onQueryRefOptions, createOptionLabel, createOptionIcon, onCreateFromQuery, lookupComponent, Custom }) => {
1792
+ var _effect = _useSignals11();
1768
1793
  try {
1769
1794
  const { ast, name, type, format, title, description, options, examples, array } = property;
1770
1795
  const inputProps = useInputProps(path);
@@ -1783,7 +1808,7 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
1783
1808
  type,
1784
1809
  format,
1785
1810
  label,
1786
- disabled: readonly,
1811
+ readonly,
1787
1812
  placeholder,
1788
1813
  ...inputProps
1789
1814
  }
@@ -1794,33 +1819,36 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
1794
1819
  const jsonPath = createJsonPath3(path ?? []);
1795
1820
  const CustomComponent = Custom?.[jsonPath];
1796
1821
  if (CustomComponent) {
1797
- return /* @__PURE__ */ React12.createElement(CustomComponent, {
1822
+ return /* @__PURE__ */ React11.createElement(CustomComponent, {
1798
1823
  type,
1799
1824
  format,
1800
1825
  label,
1801
1826
  inputOnly: inline,
1802
1827
  placeholder,
1803
- disabled: readonly,
1828
+ readonly,
1804
1829
  ...inputProps
1805
1830
  });
1806
1831
  }
1807
1832
  const refProps = getRefProps(property);
1808
1833
  if (refProps) {
1809
- return /* @__PURE__ */ React12.createElement(RefField, {
1834
+ return /* @__PURE__ */ React11.createElement(RefField, {
1810
1835
  ast: refProps.ast,
1811
1836
  array: refProps.isArray,
1812
1837
  type,
1813
1838
  format,
1814
1839
  label,
1815
1840
  placeholder,
1816
- disabled: readonly,
1841
+ readonly,
1817
1842
  inputOnly: inline,
1818
1843
  onQueryRefOptions,
1844
+ createOptionLabel,
1845
+ createOptionIcon,
1846
+ onCreateFromQuery,
1819
1847
  ...inputProps
1820
1848
  });
1821
1849
  }
1822
1850
  if (array) {
1823
- return /* @__PURE__ */ React12.createElement(ArrayField, {
1851
+ return /* @__PURE__ */ React11.createElement(ArrayField, {
1824
1852
  property,
1825
1853
  path,
1826
1854
  inputProps,
@@ -1830,21 +1858,21 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
1830
1858
  }
1831
1859
  const InputComponent = getInputComponent(type, format);
1832
1860
  if (InputComponent) {
1833
- return /* @__PURE__ */ React12.createElement(InputComponent, {
1861
+ return /* @__PURE__ */ React11.createElement(InputComponent, {
1834
1862
  type,
1835
1863
  format,
1836
1864
  label,
1837
1865
  inputOnly: inline,
1838
1866
  placeholder,
1839
- disabled: readonly,
1867
+ readonly,
1840
1868
  ...inputProps
1841
1869
  });
1842
1870
  }
1843
1871
  if (options) {
1844
- return /* @__PURE__ */ React12.createElement(SelectInput, {
1872
+ return /* @__PURE__ */ React11.createElement(SelectInput, {
1845
1873
  type,
1846
1874
  format,
1847
- disabled: readonly,
1875
+ readonly,
1848
1876
  inputOnly: inline,
1849
1877
  label,
1850
1878
  options: options.map((option) => ({
@@ -1859,13 +1887,17 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
1859
1887
  const baseNode = findNode3(ast, isDiscriminatedUnion2);
1860
1888
  const typeLiteral = baseNode ? getDiscriminatedType2(baseNode, inputProps.getValue()) : findNode3(ast, SchemaAST4.isTypeLiteral);
1861
1889
  if (typeLiteral) {
1862
- return /* @__PURE__ */ React12.createElement(React12.Fragment, null, !inline && /* @__PURE__ */ React12.createElement("h3", {
1863
- className: mx8("text-lg mlb-inputSpacingBlock first:mbs-0")
1864
- }, label), /* @__PURE__ */ React12.createElement(FormFields, {
1890
+ return /* @__PURE__ */ React11.createElement(React11.Fragment, null, !inline && /* @__PURE__ */ React11.createElement("h3", {
1891
+ className: mx6("text-lg mlb-inputSpacingBlock first:mbs-0")
1892
+ }, label), /* @__PURE__ */ React11.createElement(FormFields, {
1865
1893
  schema: Schema.make(typeLiteral),
1866
1894
  path,
1867
1895
  readonly,
1896
+ projection,
1868
1897
  onQueryRefOptions,
1898
+ createOptionLabel,
1899
+ createOptionIcon,
1900
+ onCreateFromQuery,
1869
1901
  Custom,
1870
1902
  lookupComponent
1871
1903
  }));
@@ -1876,26 +1908,44 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
1876
1908
  _effect.f();
1877
1909
  }
1878
1910
  };
1879
- var FormFields = /* @__PURE__ */ forwardRef(({ classNames, testId, schema, path, filter, sort, readonly, lookupComponent, Custom, onQueryRefOptions }, forwardRef2) => {
1880
- var _effect = _useSignals12();
1911
+ var FormFields = /* @__PURE__ */ forwardRef(({ classNames, schema, path, filter, sort, projection, readonly, lookupComponent, Custom, onQueryRefOptions, ...props }, forwardRef2) => {
1912
+ var _effect = _useSignals11();
1881
1913
  try {
1882
1914
  const values = useFormValues(path);
1883
1915
  const properties = useMemo5(() => {
1884
- const props = getSchemaProperties2(schema.ast, values);
1885
- const filtered = filter ? filter(props) : props;
1916
+ const props2 = getSchemaProperties2(schema.ast, values);
1917
+ if (projection) {
1918
+ const fieldProjections = projection.getFieldProjections();
1919
+ const hiddenProperties = new Set(projection.getHiddenProperties());
1920
+ const visibleProps = props2.filter((prop) => !hiddenProperties.has(prop.name));
1921
+ const orderedProps = [];
1922
+ for (const fieldProjection of fieldProjections) {
1923
+ const fieldPath = String(fieldProjection.field.path);
1924
+ const prop = visibleProps.find((p) => p.name === fieldPath);
1925
+ if (prop) {
1926
+ orderedProps.push(prop);
1927
+ }
1928
+ }
1929
+ const projectionPaths = new Set(fieldProjections.map((fp) => String(fp.field.path)));
1930
+ const remainingProps = visibleProps.filter((prop) => !projectionPaths.has(prop.name));
1931
+ orderedProps.push(...remainingProps);
1932
+ return orderedProps;
1933
+ }
1934
+ const filtered = filter ? filter(props2) : props2;
1886
1935
  return sort ? filtered.sort((a, b) => sort.indexOf(a.name) - sort.indexOf(b.name)) : filtered;
1887
1936
  }, [
1888
1937
  schema,
1889
1938
  values,
1890
1939
  filter,
1891
- sort
1940
+ sort,
1941
+ projection?.fields
1892
1942
  ]);
1893
- return /* @__PURE__ */ React12.createElement("div", {
1943
+ return /* @__PURE__ */ React11.createElement("div", {
1894
1944
  role: "form",
1895
- className: mx8("is-full", classNames),
1945
+ className: mx6("is-full", classNames),
1896
1946
  ref: forwardRef2
1897
1947
  }, properties.map((property) => {
1898
- return /* @__PURE__ */ React12.createElement(FormField, {
1948
+ return /* @__PURE__ */ React11.createElement(FormField, {
1899
1949
  key: property.name,
1900
1950
  property,
1901
1951
  path: [
@@ -1903,9 +1953,11 @@ var FormFields = /* @__PURE__ */ forwardRef(({ classNames, testId, schema, path,
1903
1953
  property.name
1904
1954
  ],
1905
1955
  readonly,
1956
+ projection,
1906
1957
  onQueryRefOptions,
1907
1958
  lookupComponent,
1908
- Custom
1959
+ Custom,
1960
+ ...props
1909
1961
  });
1910
1962
  }).filter(isNotFalsy));
1911
1963
  } finally {
@@ -1914,25 +1966,26 @@ var FormFields = /* @__PURE__ */ forwardRef(({ classNames, testId, schema, path,
1914
1966
  });
1915
1967
 
1916
1968
  // src/components/Form/Form.tsx
1917
- var Form = ({ classNames, testId, values: initialValues, autoFocus, readonly, autoSave, outerSpacing = true, onCancel, schema, onValuesChanged, onValidate, onSave, ...props }) => {
1918
- var _effect = _useSignals13();
1969
+ var Form = ({ classNames, testId, values: initialValues, autoFocus, readonly, autoSave, outerSpacing = true, schema, onCancel, onValuesChanged, onValidate, onSave, ...props }) => {
1970
+ var _effect = _useSignals12();
1919
1971
  try {
1920
1972
  const formRef = useRef3(null);
1921
- const handleValid = useMemo6(() => autoSave ? onSave : void 0, [
1922
- autoSave,
1923
- onSave
1924
- ]);
1973
+ const { findFirstFocusable } = useFocusFinders();
1925
1974
  useEffect7(() => {
1926
1975
  if (autoFocus && formRef.current) {
1927
- const input = formRef.current.querySelector("input");
1928
- if (input) {
1929
- input.focus();
1976
+ const firstFocusable = findFirstFocusable(formRef.current);
1977
+ if (firstFocusable) {
1978
+ firstFocusable.focus();
1930
1979
  }
1931
1980
  }
1932
1981
  }, [
1933
1982
  autoFocus
1934
1983
  ]);
1935
- return /* @__PURE__ */ React13.createElement(FormProvider, {
1984
+ const handleValid = useMemo6(() => autoSave ? onSave : void 0, [
1985
+ autoSave,
1986
+ onSave
1987
+ ]);
1988
+ return /* @__PURE__ */ React12.createElement(FormProvider, {
1936
1989
  formRef,
1937
1990
  schema,
1938
1991
  autoSave,
@@ -1941,11 +1994,11 @@ var Form = ({ classNames, testId, values: initialValues, autoFocus, readonly, au
1941
1994
  onValidate,
1942
1995
  onValid: handleValid,
1943
1996
  onSave
1944
- }, /* @__PURE__ */ React13.createElement("div", {
1997
+ }, /* @__PURE__ */ React12.createElement("div", {
1945
1998
  role: "none",
1946
1999
  className: "contents",
1947
2000
  "data-testid": testId
1948
- }, /* @__PURE__ */ React13.createElement(FormFields, {
2001
+ }, /* @__PURE__ */ React12.createElement(FormFields, {
1949
2002
  ...props,
1950
2003
  ref: formRef,
1951
2004
  classNames: [
@@ -1955,7 +2008,7 @@ var Form = ({ classNames, testId, values: initialValues, autoFocus, readonly, au
1955
2008
  ],
1956
2009
  readonly,
1957
2010
  schema
1958
- }), (onCancel || onSave) && !autoSave && /* @__PURE__ */ React13.createElement(FormActions, {
2011
+ }), (onCancel || onSave) && !autoSave && !readonly && /* @__PURE__ */ React12.createElement(FormActions, {
1959
2012
  readonly,
1960
2013
  onCancel,
1961
2014
  outerSpacing
@@ -1967,42 +2020,37 @@ var Form = ({ classNames, testId, values: initialValues, autoFocus, readonly, au
1967
2020
 
1968
2021
  // src/components/FieldEditor/FieldEditor.tsx
1969
2022
  var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx";
1970
- var FieldEditor = ({ projection, field, registry, onSave, onCancel, outerSpacing }) => {
1971
- var _effect = _useSignals14();
2023
+ var FieldEditor = ({ readonly, projection, field, registry, onSave, onCancel, outerSpacing }) => {
2024
+ var _effect = _useSignals13();
1972
2025
  try {
1973
2026
  const { t } = useTranslation8(translationKey);
1974
- const [props, setProps] = useState5(projection.getFieldProjection(field.id).props);
2027
+ const [props, setProps] = useState6(projection.getFieldProjection(field.id).props);
1975
2028
  useEffect8(() => setProps(projection.getFieldProjection(field.id).props), [
1976
2029
  field,
1977
2030
  projection
1978
2031
  ]);
1979
- const [schemas, setSchemas] = useState5([]);
1980
- useEffect8(() => {
2032
+ const [schemas, setSchemas] = useState6([]);
2033
+ useAsyncEffect(async () => {
1981
2034
  if (!registry) {
1982
2035
  return;
1983
2036
  }
1984
2037
  const subscription = registry.query().subscribe((query) => setSchemas(query.results), {
1985
2038
  fire: true
1986
2039
  });
1987
- const t2 = setTimeout(async () => {
1988
- const schemas2 = await registry.query().run();
1989
- setSchemas(schemas2);
1990
- });
1991
- return () => {
1992
- clearTimeout(t2);
1993
- subscription?.();
1994
- };
2040
+ const schemas2 = await registry.query().run();
2041
+ setSchemas(schemas2);
2042
+ return () => subscription?.();
1995
2043
  }, [
1996
2044
  registry
1997
2045
  ]);
1998
- const [referenceSchema, setReferenceSchema] = useState5();
2046
+ const [referenceSchema, setReferenceSchema] = useState6();
1999
2047
  useEffect8(() => {
2000
2048
  setReferenceSchema(schemas.find((schema) => schema.typename === props?.referenceSchema));
2001
2049
  }, [
2002
2050
  schemas,
2003
2051
  props?.referenceSchema
2004
2052
  ]);
2005
- const [{ fieldSchema }, setFieldSchema] = useState5({
2053
+ const [{ fieldSchema }, setFieldSchema] = useState6({
2006
2054
  fieldSchema: getFormatSchema(props?.format)
2007
2055
  });
2008
2056
  const handleValuesChanged = useCallback9((_props) => {
@@ -2071,26 +2119,26 @@ var FieldEditor = ({ projection, field, registry, onSave, onCancel, outerSpacing
2071
2119
  onSave
2072
2120
  ]);
2073
2121
  const custom = useMemo7(() => ({
2074
- ["format"]: (props2) => /* @__PURE__ */ React14.createElement(SelectInput, {
2122
+ ["format"]: (props2) => /* @__PURE__ */ React13.createElement(SelectInput, {
2075
2123
  ...props2,
2076
2124
  options: FormatEnums.filter((value) => value !== FormatEnum5.None).map((value) => ({
2077
2125
  value,
2078
2126
  label: t(`format ${value}`)
2079
2127
  }))
2080
2128
  }),
2081
- ["referenceSchema"]: (props2) => /* @__PURE__ */ React14.createElement(SelectInput, {
2129
+ ["referenceSchema"]: (props2) => /* @__PURE__ */ React13.createElement(SelectInput, {
2082
2130
  ...props2,
2083
2131
  options: schemas.map((schema) => ({
2084
2132
  value: schema.typename
2085
2133
  }))
2086
2134
  }),
2087
- ["referencePath"]: (props2) => /* @__PURE__ */ React14.createElement(SelectInput, {
2135
+ ["referencePath"]: (props2) => /* @__PURE__ */ React13.createElement(SelectInput, {
2088
2136
  ...props2,
2089
2137
  options: referenceSchema ? getSchemaProperties3(referenceSchema.ast).sort(sortProperties).map((p) => ({
2090
2138
  value: p.name
2091
2139
  })) : []
2092
2140
  }),
2093
- ["options"]: (props2) => /* @__PURE__ */ React14.createElement(SelectOptionInput, props2)
2141
+ ["options"]: (props2) => /* @__PURE__ */ React13.createElement(SelectOptionInput, props2)
2094
2142
  }), [
2095
2143
  t,
2096
2144
  schemas,
@@ -2102,15 +2150,16 @@ var FieldEditor = ({ projection, field, registry, onSave, onCancel, outerSpacing
2102
2150
  props
2103
2151
  }, {
2104
2152
  F: __dxlog_file4,
2105
- L: 173,
2153
+ L: 177,
2106
2154
  S: void 0,
2107
2155
  C: (f, a) => f(...a)
2108
2156
  });
2109
2157
  return null;
2110
2158
  }
2111
- return /* @__PURE__ */ React14.createElement(Form, {
2159
+ return /* @__PURE__ */ React13.createElement(Form, {
2112
2160
  key: field.id,
2113
2161
  autoFocus: true,
2162
+ readonly,
2114
2163
  values: props,
2115
2164
  schema: fieldSchema,
2116
2165
  filter: propIsNotType,
@@ -2131,74 +2180,84 @@ var FieldEditor = ({ projection, field, registry, onSave, onCancel, outerSpacing
2131
2180
  };
2132
2181
 
2133
2182
  // src/components/ViewEditor/ViewEditor.tsx
2134
- import { useSignals as _useSignals15 } from "@preact-signals/safe-react/tracking";
2135
- import { Schema as Schema2 } from "effect";
2136
- import React15, { useCallback as useCallback10, useMemo as useMemo8, useState as useState6 } from "react";
2183
+ import { useSignals as _useSignals14 } from "@preact-signals/safe-react/tracking";
2184
+ import { Match, Schema as Schema2 } from "effect";
2185
+ import React14, { useCallback as useCallback10, useMemo as useMemo8, useState as useState7 } from "react";
2137
2186
  import { EchoSchema, Format, isMutable, toJsonSchema } from "@dxos/echo-schema";
2138
2187
  import { invariant as invariant3 } from "@dxos/invariant";
2188
+ import { getSpace } from "@dxos/react-client/echo";
2139
2189
  import { Callout, IconButton as IconButton4, useTranslation as useTranslation9 } from "@dxos/react-ui";
2190
+ import { QueryEditor, QuerySerializer, createExpression } from "@dxos/react-ui-components";
2140
2191
  import { List as List2 } from "@dxos/react-ui-list";
2141
2192
  import { cardSpacing as cardSpacing3 } from "@dxos/react-ui-stack";
2142
- import { ghostHover, inputTextLabel, mx as mx9 } from "@dxos/react-ui-theme";
2143
- import { FieldSchema, VIEW_FIELD_LIMIT, ProjectionModel } from "@dxos/schema";
2193
+ import { inputTextLabel, mx as mx7, subtleHover as subtleHover2 } from "@dxos/react-ui-theme";
2194
+ import { FieldSchema, ProjectionModel, VIEW_FIELD_LIMIT, typenameFromQuery } from "@dxos/schema";
2144
2195
  var __dxlog_file5 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx";
2145
- var grid = "grid grid-cols-[32px_1fr_32px_32px] min-bs-[2.5rem]";
2146
- var ViewMetaSchema = Schema2.Struct({
2147
- typename: Format.URL.annotations({
2148
- title: "Typename"
2149
- })
2150
- }).pipe(Schema2.mutable);
2151
- var ViewEditor = ({ classNames, schema, view, registry, readonly: _readonly, showHeading = false, onTypenameChanged, onDelete, outerSpacing = true }) => {
2152
- var _effect = _useSignals15();
2196
+ var listGrid = "grid grid-cols-[min-content_1fr_min-content_min-content_min-content]";
2197
+ var listItemGrid = "grid grid-cols-subgrid col-span-5";
2198
+ var ViewEditor = ({ classNames, schema, view, kind = "basic", registry, readonly, showHeading = false, onQueryChanged, onDelete, outerSpacing = true }) => {
2199
+ var _effect = _useSignals14();
2153
2200
  try {
2201
+ const space = getSpace(view);
2202
+ const schemaReadonly = !isMutable(schema);
2154
2203
  const { t } = useTranslation9(translationKey);
2155
- const projection = useMemo8(() => {
2204
+ const projectionModel = useMemo8(() => {
2156
2205
  const jsonSchema = schema instanceof EchoSchema ? schema.jsonSchema : toJsonSchema(schema);
2157
2206
  return new ProjectionModel(jsonSchema, view.projection);
2158
2207
  }, [
2159
2208
  schema,
2160
2209
  view.projection
2161
2210
  ]);
2162
- const [field, setField] = useState6();
2163
- const readonly = _readonly || !isMutable(schema);
2164
- const viewValues = useMemo8(() => {
2165
- return {
2166
- // TODO(burdon): Need to warn user of possible consequences of editing.
2167
- // TODO(burdon): Settings should have domain name owned by user.
2168
- typename: view.query.typename
2169
- };
2211
+ const [expandedField, setExpandedField] = useState7();
2212
+ const serializedQuery = Match.value(kind).pipe(Match.when("basic", () => typenameFromQuery(view.query)), Match.when("advanced", () => {
2213
+ if (view.query.type !== "select") {
2214
+ return "";
2215
+ }
2216
+ const serializer = new QuerySerializer();
2217
+ return serializer.serialize(createExpression(view.query.filter));
2218
+ }), Match.exhaustive);
2219
+ const viewSchema = useMemo8(() => {
2220
+ return Schema2.Struct({
2221
+ query: kind === "basic" ? Format.URL.annotations({
2222
+ title: "Record type"
2223
+ }) : Schema2.String.annotations({
2224
+ title: "Query"
2225
+ })
2226
+ }).pipe(Schema2.mutable);
2170
2227
  }, [
2171
- view.query.typename
2228
+ kind
2172
2229
  ]);
2173
- const handleSelect = useCallback10((field2) => {
2174
- if (readonly) {
2175
- return;
2176
- }
2177
- setField((f) => f === field2 ? void 0 : field2);
2230
+ const viewValues = useMemo8(() => ({
2231
+ query: serializedQuery
2232
+ }), [
2233
+ serializedQuery
2234
+ ]);
2235
+ const handleToggleField = useCallback10((field) => {
2236
+ setExpandedField((prevExpandedFieldId) => prevExpandedFieldId === field.id ? void 0 : field.id);
2178
2237
  }, [
2179
2238
  readonly
2180
2239
  ]);
2181
2240
  const handleAdd = useCallback10(() => {
2182
2241
  invariant3(!readonly, void 0, {
2183
2242
  F: __dxlog_file5,
2184
- L: 88,
2243
+ L: 106,
2185
2244
  S: void 0,
2186
2245
  A: [
2187
2246
  "!readonly",
2188
2247
  ""
2189
2248
  ]
2190
2249
  });
2191
- const field2 = projection.createFieldProjection();
2192
- setField(field2);
2250
+ const field = projectionModel.createFieldProjection();
2251
+ setExpandedField(field.id);
2193
2252
  }, [
2194
2253
  schema,
2195
- projection,
2254
+ projectionModel,
2196
2255
  readonly
2197
2256
  ]);
2198
- const handleUpdate = useCallback10(({ typename }) => {
2257
+ const handleUpdate = useCallback10(({ query }) => {
2199
2258
  invariant3(!readonly, void 0, {
2200
2259
  F: __dxlog_file5,
2201
- L: 95,
2260
+ L: 113,
2202
2261
  S: void 0,
2203
2262
  A: [
2204
2263
  "!readonly",
@@ -2206,38 +2265,38 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly: _readonly, sho
2206
2265
  ]
2207
2266
  });
2208
2267
  requestAnimationFrame(() => {
2209
- if (view.query.typename !== typename && !readonly) {
2210
- onTypenameChanged?.(typename);
2268
+ if (serializedQuery !== query && !readonly) {
2269
+ onQueryChanged?.(query);
2211
2270
  }
2212
2271
  });
2213
2272
  }, [
2214
- view.query.typename,
2215
- onTypenameChanged,
2273
+ serializedQuery,
2274
+ onQueryChanged,
2216
2275
  readonly
2217
2276
  ]);
2218
2277
  const handleDelete = useCallback10((fieldId) => {
2219
2278
  invariant3(!readonly, void 0, {
2220
2279
  F: __dxlog_file5,
2221
- L: 107,
2280
+ L: 125,
2222
2281
  S: void 0,
2223
2282
  A: [
2224
2283
  "!readonly",
2225
2284
  ""
2226
2285
  ]
2227
2286
  });
2228
- if (fieldId === field?.id) {
2229
- setField(void 0);
2287
+ if (fieldId === expandedField) {
2288
+ setExpandedField(void 0);
2230
2289
  }
2231
2290
  onDelete?.(fieldId);
2232
2291
  }, [
2233
- field,
2292
+ expandedField,
2234
2293
  onDelete,
2235
2294
  readonly
2236
2295
  ]);
2237
2296
  const handleMove = useCallback10((fromIndex, toIndex) => {
2238
2297
  invariant3(!readonly, void 0, {
2239
2298
  F: __dxlog_file5,
2240
- L: 119,
2299
+ L: 137,
2241
2300
  S: void 0,
2242
2301
  A: [
2243
2302
  "!readonly",
@@ -2254,104 +2313,120 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly: _readonly, sho
2254
2313
  view.projection.fields,
2255
2314
  readonly
2256
2315
  ]);
2257
- const handleClose = useCallback10(() => setField(void 0), []);
2258
- const hiddenProperties = projection.getHiddenProperties();
2316
+ const handleClose = useCallback10(() => setExpandedField(void 0), []);
2259
2317
  const handleHide = useCallback10((fieldId) => {
2260
- setField(void 0);
2261
- projection.hideFieldProjection(fieldId);
2318
+ setExpandedField(void 0);
2319
+ projectionModel.hideFieldProjection(fieldId);
2262
2320
  }, [
2263
- projection
2321
+ projectionModel
2264
2322
  ]);
2265
2323
  const handleShow = useCallback10((property) => {
2266
- setField(void 0);
2267
- projection.showFieldProjection(property);
2324
+ setExpandedField(void 0);
2325
+ projectionModel.showFieldProjection(property);
2268
2326
  }, [
2269
- projection
2327
+ projectionModel
2270
2328
  ]);
2271
- return /* @__PURE__ */ React15.createElement("div", {
2272
- role: "none",
2273
- className: mx9(classNames)
2274
- }, readonly && /* @__PURE__ */ React15.createElement("div", {
2329
+ const custom = useMemo8(() => kind === "advanced" ? {
2330
+ ["query"]: (props) => {
2331
+ const handleChange = useCallback10((text) => props.onValueChange("string", text), [
2332
+ props.onValueChange
2333
+ ]);
2334
+ return /* @__PURE__ */ React14.createElement(QueryEditor, {
2335
+ space,
2336
+ initialValue: props.getValue(),
2337
+ onChange: handleChange
2338
+ });
2339
+ }
2340
+ } : {}, []);
2341
+ return /* @__PURE__ */ React14.createElement("div", {
2275
2342
  role: "none",
2276
- className: mx9("is-full", outerSpacing && "plb-cardSpacingBlock pli-cardSpacingInline")
2277
- }, /* @__PURE__ */ React15.createElement(Callout.Root, {
2278
- valence: "info"
2279
- }, /* @__PURE__ */ React15.createElement(Callout.Title, null, t("system schema description")))), /* @__PURE__ */ React15.createElement(Form, {
2343
+ className: mx7(classNames)
2344
+ }, schemaReadonly && /* @__PURE__ */ React14.createElement(Callout.Root, {
2345
+ valence: "info",
2346
+ classNames: [
2347
+ "mlb-cardSpacingBlock",
2348
+ outerSpacing && "mli-cardSpacingInline"
2349
+ ]
2350
+ }, /* @__PURE__ */ React14.createElement(Callout.Title, null, t("system schema description"))), /* @__PURE__ */ React14.createElement(Form, {
2280
2351
  autoSave: true,
2281
- schema: ViewMetaSchema,
2352
+ schema: viewSchema,
2282
2353
  values: viewValues,
2283
- readonly,
2354
+ readonly: readonly ? "disabled-input" : false,
2284
2355
  onSave: handleUpdate,
2285
- outerSpacing
2286
- }), /* @__PURE__ */ React15.createElement("div", {
2356
+ outerSpacing,
2357
+ Custom: custom
2358
+ }), /* @__PURE__ */ React14.createElement("div", {
2287
2359
  role: "none",
2288
2360
  className: outerSpacing ? cardSpacing3 : "mlb-cardSpacingBlock"
2289
- }, /* @__PURE__ */ React15.createElement("label", {
2290
- className: mx9(inputTextLabel)
2291
- }, t("fields label")), /* @__PURE__ */ React15.createElement(List2.Root, {
2361
+ }, /* @__PURE__ */ React14.createElement("h2", {
2362
+ className: mx7(inputTextLabel)
2363
+ }, t("fields label")), /* @__PURE__ */ React14.createElement(List2.Root, {
2292
2364
  items: view.projection.fields,
2293
2365
  isItem: Schema2.is(FieldSchema),
2294
- getId: (field2) => field2.id,
2295
- readonly,
2296
- onMove: readonly ? void 0 : handleMove
2297
- }, ({ items: fields }) => /* @__PURE__ */ React15.createElement(React15.Fragment, null, showHeading && /* @__PURE__ */ React15.createElement("div", {
2298
- role: "heading",
2299
- className: grid
2300
- }, /* @__PURE__ */ React15.createElement("div", null), /* @__PURE__ */ React15.createElement("div", {
2301
- className: "flex items-center text-sm"
2302
- }, t("field path label"))), /* @__PURE__ */ React15.createElement("div", {
2303
- role: "list",
2304
- className: "flex flex-col is-full"
2305
- }, fields?.map((field2) => /* @__PURE__ */ React15.createElement(List2.Item, {
2306
- key: field2.id,
2307
- item: field2,
2308
- classNames: mx9(grid, ghostHover, "overflow-hidden", !readonly && "cursor-pointer")
2309
- }, /* @__PURE__ */ React15.createElement(List2.ItemDragHandle, null), /* @__PURE__ */ React15.createElement(List2.ItemTitle, {
2310
- onClick: () => handleSelect(field2)
2311
- }, field2.path), /* @__PURE__ */ React15.createElement(List2.ItemButton, {
2312
- "data-testid": "hide-field-button",
2313
- icon: "ph--eye-slash--regular",
2314
- // TDOO(burdon): Is this the correct test?
2315
- disabled: view.projection.fields.length <= 1,
2316
- onClick: () => handleHide(field2.id)
2317
- }), !readonly && /* @__PURE__ */ React15.createElement(List2.ItemDeleteButton, {
2318
- disabled: view.projection.fields.length <= 1,
2319
- onClick: () => handleDelete(field2.id)
2320
- })))))), hiddenProperties.length > 0 && /* @__PURE__ */ React15.createElement(React15.Fragment, null, /* @__PURE__ */ React15.createElement("label", {
2321
- className: mx9(inputTextLabel)
2322
- }, t("hidden fields label")), /* @__PURE__ */ React15.createElement(List2.Root, {
2323
- items: hiddenProperties,
2324
- isItem: (item) => typeof item === "string",
2325
- getId: (property) => property
2326
- }, ({ items: properties }) => /* @__PURE__ */ React15.createElement("div", {
2366
+ getId: (field) => field.id,
2367
+ onMove: readonly ? void 0 : handleMove,
2368
+ readonly
2369
+ }, ({ items: fields }) => /* @__PURE__ */ React14.createElement(React14.Fragment, null, showHeading && /* @__PURE__ */ React14.createElement("h3", {
2370
+ className: "text-sm"
2371
+ }, t("field path label")), /* @__PURE__ */ React14.createElement("div", {
2327
2372
  role: "list",
2328
- className: "flex flex-col is-full"
2329
- }, properties?.map((property) => /* @__PURE__ */ React15.createElement(List2.Item, {
2330
- key: property,
2331
- item: property,
2332
- classNames: mx9(grid, ghostHover, !readonly && "cursor-pointer")
2333
- }, /* @__PURE__ */ React15.createElement(List2.ItemDragHandle, {
2334
- disabled: true
2335
- }), /* @__PURE__ */ React15.createElement(List2.ItemTitle, null, property), /* @__PURE__ */ React15.createElement(List2.ItemButton, {
2336
- icon: "ph--eye--regular",
2337
- onClick: () => handleShow(property),
2338
- "data-testid": "show-field-button"
2339
- }))))))), field && /* @__PURE__ */ React15.createElement(FieldEditor, {
2340
- key: field.id,
2341
- projection,
2342
- field,
2343
- registry,
2344
- onSave: handleClose
2345
- }), !readonly && !field && /* @__PURE__ */ React15.createElement("div", {
2373
+ className: listGrid
2374
+ }, fields?.map((field) => {
2375
+ const hidden = field.visible === false;
2376
+ return /* @__PURE__ */ React14.createElement(List2.Item, {
2377
+ key: field.id,
2378
+ item: field,
2379
+ classNames: listItemGrid,
2380
+ "aria-expanded": expandedField === field.id
2381
+ }, /* @__PURE__ */ React14.createElement("div", {
2382
+ role: "none",
2383
+ className: mx7(subtleHover2, listItemGrid, "rounded-sm cursor-pointer min-bs-10")
2384
+ }, /* @__PURE__ */ React14.createElement(List2.ItemDragHandle, {
2385
+ disabled: readonly
2386
+ }), /* @__PURE__ */ React14.createElement(List2.ItemTitle, {
2387
+ classNames: hidden && "text-subdued",
2388
+ onClick: () => handleToggleField(field)
2389
+ }, field.path), /* @__PURE__ */ React14.createElement(List2.ItemButton, {
2390
+ label: t(hidden ? "show field label" : "hide field label"),
2391
+ "data-testid": hidden ? "show-field-button" : "hide-field-button",
2392
+ icon: hidden ? "ph--eye-closed--regular" : "ph--eye--regular",
2393
+ autoHide: false,
2394
+ disabled: readonly || !hidden && projectionModel.fields.length <= 1,
2395
+ onClick: () => hidden ? handleShow(field.path) : handleHide(field.id)
2396
+ }), /* @__PURE__ */ React14.createElement(List2.ItemDeleteButton, {
2397
+ label: t("delete field label"),
2398
+ autoHide: false,
2399
+ disabled: readonly || schemaReadonly || view.projection.fields.length <= 1,
2400
+ onClick: () => handleDelete(field.id),
2401
+ "data-testid": "field.delete"
2402
+ }), /* @__PURE__ */ React14.createElement(IconButton4, {
2403
+ iconOnly: true,
2404
+ variant: "ghost",
2405
+ label: t("toggle expand label", {
2406
+ ns: "os"
2407
+ }),
2408
+ icon: expandedField === field.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
2409
+ onClick: () => handleToggleField(field)
2410
+ })), expandedField === field.id && /* @__PURE__ */ React14.createElement("div", {
2411
+ role: "none",
2412
+ className: "col-span-5 mbs-1 mbe-1 border border-separator rounded-md"
2413
+ }, /* @__PURE__ */ React14.createElement(FieldEditor, {
2414
+ readonly: readonly || schemaReadonly ? "disabled-input" : false,
2415
+ projection: projectionModel,
2416
+ field,
2417
+ registry,
2418
+ onSave: handleClose
2419
+ })));
2420
+ }))))), !readonly && !expandedField && /* @__PURE__ */ React14.createElement("div", {
2346
2421
  role: "none",
2347
2422
  className: outerSpacing ? cardSpacing3 : "mlb-cardSpacingBlock"
2348
- }, /* @__PURE__ */ React15.createElement(IconButton4, {
2423
+ }, /* @__PURE__ */ React14.createElement(IconButton4, {
2349
2424
  icon: "ph--plus--regular",
2350
2425
  label: t("button add property"),
2351
2426
  onClick: readonly ? void 0 : handleAdd,
2352
2427
  // TODO(burdon): Show field limit in ux (not tooltip).
2353
2428
  disabled: view.projection.fields.length >= VIEW_FIELD_LIMIT,
2354
- classNames: "flex is-full"
2429
+ classNames: "is-full"
2355
2430
  })));
2356
2431
  } finally {
2357
2432
  _effect.f();
@@ -2368,8 +2443,6 @@ export {
2368
2443
  ControlPage,
2369
2444
  ControlSection,
2370
2445
  ControlSectionHeading,
2371
- DeprecatedFormContainer,
2372
- DeprecatedFormInput,
2373
2446
  FieldEditor,
2374
2447
  Form,
2375
2448
  FormProvider,