@dxos/react-ui-form 0.8.2-main.fbd8ed0 → 0.8.2-staging.42af850

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 (54) hide show
  1. package/dist/lib/browser/index.mjs +1445 -1245
  2. package/dist/lib/browser/index.mjs.map +3 -3
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node/index.cjs +1431 -1231
  5. package/dist/lib/node/index.cjs.map +3 -3
  6. package/dist/lib/node/meta.json +1 -1
  7. package/dist/lib/node-esm/index.mjs +1445 -1245
  8. package/dist/lib/node-esm/index.mjs.map +3 -3
  9. package/dist/lib/node-esm/meta.json +1 -1
  10. package/dist/types/src/components/ControlSection/ControlSection.d.ts +1 -1
  11. package/dist/types/src/components/ControlSection/ControlSection.d.ts.map +1 -1
  12. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
  13. package/dist/types/src/components/FieldEditor/FieldEditor.test.d.ts +2 -0
  14. package/dist/types/src/components/FieldEditor/FieldEditor.test.d.ts.map +1 -0
  15. package/dist/types/src/components/Form/ArrayField.d.ts.map +1 -1
  16. package/dist/types/src/components/Form/Defaults.d.ts +4 -4
  17. package/dist/types/src/components/Form/Defaults.d.ts.map +1 -1
  18. package/dist/types/src/components/Form/Form.d.ts.map +1 -1
  19. package/dist/types/src/components/Form/Form.stories.d.ts +1 -2
  20. package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
  21. package/dist/types/src/components/Form/FormActions.d.ts +1 -1
  22. package/dist/types/src/components/Form/FormActions.d.ts.map +1 -1
  23. package/dist/types/src/components/Form/FormContent.d.ts +6 -5
  24. package/dist/types/src/components/Form/FormContent.d.ts.map +1 -1
  25. package/dist/types/src/components/Form/FormContext.d.ts.map +1 -1
  26. package/dist/types/src/components/Form/RefField.d.ts.map +1 -1
  27. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
  28. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +5 -3
  29. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
  30. package/dist/types/src/components/testing.d.ts.map +1 -1
  31. package/dist/types/src/hooks/useRefQueryLookupHandler.d.ts.map +1 -1
  32. package/dist/types/src/translations.d.ts +5 -0
  33. package/dist/types/src/translations.d.ts.map +1 -1
  34. package/dist/types/src/vitest-setup.d.ts +2 -0
  35. package/dist/types/src/vitest-setup.d.ts.map +1 -0
  36. package/package.json +27 -25
  37. package/src/components/ControlSection/ControlSection.tsx +2 -2
  38. package/src/components/FieldEditor/FieldEditor.test.tsx +49 -0
  39. package/src/components/FieldEditor/FieldEditor.tsx +3 -2
  40. package/src/components/Form/ArrayField.tsx +51 -34
  41. package/src/components/Form/Defaults.tsx +74 -48
  42. package/src/components/Form/Form.stories.tsx +77 -101
  43. package/src/components/Form/Form.tsx +1 -2
  44. package/src/components/Form/FormActions.tsx +15 -18
  45. package/src/components/Form/FormContent.tsx +34 -35
  46. package/src/components/Form/FormContext.tsx +11 -7
  47. package/src/components/Form/Input.tsx +1 -1
  48. package/src/components/Form/RefField.tsx +30 -10
  49. package/src/components/ViewEditor/ViewEditor.stories.tsx +14 -5
  50. package/src/components/ViewEditor/ViewEditor.tsx +51 -24
  51. package/src/components/testing.tsx +5 -9
  52. package/src/hooks/useRefQueryLookupHandler.ts +1 -3
  53. package/src/translations.ts +9 -2
  54. package/src/vitest-setup.ts +11 -0
@@ -6,6 +6,7 @@ var translations_default = [
6
6
  [translationKey]: {
7
7
  "fields label": "Fields",
8
8
  "hidden fields label": "Hidden Fields",
9
+ "empty readonly ref field label": "(none)",
9
10
  // TODO(burdon): Standardize field/property.
10
11
  "button add property": "Add property",
11
12
  "field property label": "Property",
@@ -15,6 +16,8 @@ var translations_default = [
15
16
  "add field": "Add field",
16
17
  "delete field": "Delete field",
17
18
  "field limit reached": "Maximum number of fields reached",
19
+ "boolean input true value": "Yes",
20
+ "boolean input false value": "No",
18
21
  // TODO(burdon): Factor out?
19
22
  "button cancel": "Cancel",
20
23
  "button save": "Save",
@@ -44,246 +47,324 @@ var translations_default = [
44
47
  "format number": "Number",
45
48
  "format uri": "URI",
46
49
  "format uuid": "UUID",
47
- // Placeholders
50
+ // Placeholders.
48
51
  "placeholder latitude": "Latitude",
49
52
  "placeholder longitude": "Longitude",
50
- // SelectOptionsInput
53
+ // SelectOptionsInput.
51
54
  "select option label": "Label",
52
55
  "select option label placeholder": "Option label",
53
56
  "select option color": "Color",
54
57
  "select option delete": "Delete",
55
- "select option add": "Add option"
58
+ "select option add": "Add option",
59
+ // System schema message.
60
+ "system schema title": "System Schema",
61
+ "system schema description": "This schema is managed by the system and cannot be modified."
56
62
  }
57
63
  }
58
64
  }
59
65
  ];
60
66
 
61
67
  // packages/ui/react-ui-form/src/components/deprecated/FormInput.tsx
68
+ import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
62
69
  import React from "react";
63
70
  import { Input } from "@dxos/react-ui";
64
71
  import { mx, textBlockWidth } from "@dxos/react-ui-theme";
65
72
  var DeprecatedFormContainer = ({ children, classNames }) => {
66
- return /* @__PURE__ */ React.createElement("div", {
67
- role: "none",
68
- className: "container-max-width p-4 justify-center overflow-x-hidden overflow-y-auto"
69
- }, /* @__PURE__ */ React.createElement("div", {
70
- role: "form",
71
- className: mx("flex flex-col", textBlockWidth, classNames)
72
- }, children));
73
+ var _effect = _useSignals();
74
+ try {
75
+ return /* @__PURE__ */ React.createElement("div", {
76
+ role: "none",
77
+ className: "container-max-width p-4 justify-center overflow-x-hidden overflow-y-auto"
78
+ }, /* @__PURE__ */ React.createElement("div", {
79
+ role: "form",
80
+ className: mx("flex flex-col", textBlockWidth, classNames)
81
+ }, children));
82
+ } finally {
83
+ _effect.f();
84
+ }
73
85
  };
74
86
  var DeprecatedFormInput = ({ label, description, secondary, children }) => {
75
- const primary = /* @__PURE__ */ React.createElement("div", {
76
- role: "none",
77
- className: "flex w-full gap-4 py-1"
78
- }, /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement("div", {
79
- role: "none",
80
- className: "flex flex-col w-full"
81
- }, /* @__PURE__ */ React.createElement(Input.Label, {
82
- classNames: "flex min-bs-[--rail-action] items-center",
83
- style: {
84
- fontSize: "unset"
85
- }
86
- }, label), description && /* @__PURE__ */ React.createElement(Input.DescriptionAndValidation, {
87
- classNames: "mbs-0.5"
88
- }, /* @__PURE__ */ React.createElement(Input.Description, null, description))), /* @__PURE__ */ React.createElement("div", {
89
- role: "none"
90
- }, /* @__PURE__ */ React.createElement("div", {
91
- role: "none",
92
- className: "flex min-bs-[--rail-action] items-center"
93
- }, children))));
94
- if (secondary) {
95
- return /* @__PURE__ */ React.createElement("div", {
87
+ var _effect = _useSignals();
88
+ try {
89
+ const primary = /* @__PURE__ */ React.createElement("div", {
90
+ role: "none",
91
+ className: "flex w-full gap-4 py-1"
92
+ }, /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement("div", {
93
+ role: "none",
94
+ className: "flex flex-col w-full"
95
+ }, /* @__PURE__ */ React.createElement(Input.Label, {
96
+ classNames: "flex min-bs-[--rail-action] items-center",
97
+ style: {
98
+ fontSize: "unset"
99
+ }
100
+ }, label), description && /* @__PURE__ */ React.createElement(Input.DescriptionAndValidation, {
101
+ classNames: "mbs-0.5"
102
+ }, /* @__PURE__ */ React.createElement(Input.Description, null, description))), /* @__PURE__ */ React.createElement("div", {
96
103
  role: "none"
97
- }, primary, secondary);
104
+ }, /* @__PURE__ */ React.createElement("div", {
105
+ role: "none",
106
+ className: "flex min-bs-[--rail-action] items-center"
107
+ }, children))));
108
+ if (secondary) {
109
+ return /* @__PURE__ */ React.createElement("div", {
110
+ role: "none"
111
+ }, primary, secondary);
112
+ }
113
+ return primary;
114
+ } finally {
115
+ _effect.f();
98
116
  }
99
- return primary;
100
117
  };
101
118
 
102
119
  // packages/ui/react-ui-form/src/components/ControlSection/ControlSection.tsx
120
+ import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
103
121
  import React2 from "react";
104
122
  import { Button, Input as Input2, toLocalizedString, useTranslation } from "@dxos/react-ui";
105
123
  import { mx as mx2 } from "@dxos/react-ui-theme";
106
124
  var ControlPage = ({ children, classNames, ...props }) => {
107
- return /* @__PURE__ */ React2.createElement("div", {
108
- role: "none",
109
- className: mx2("pli-2", classNames),
110
- ...props
111
- }, children);
125
+ var _effect = _useSignals2();
126
+ try {
127
+ return /* @__PURE__ */ React2.createElement("div", {
128
+ role: "none",
129
+ className: mx2("pli-2", classNames),
130
+ ...props
131
+ }, children);
132
+ } finally {
133
+ _effect.f();
134
+ }
112
135
  };
113
136
  var ControlSection = ({ title, description, children }) => {
114
- return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(ControlSectionHeading, {
115
- title,
116
- description
117
- }), children);
137
+ var _effect = _useSignals2();
138
+ try {
139
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(ControlSectionHeading, {
140
+ title,
141
+ description
142
+ }), children);
143
+ } finally {
144
+ _effect.f();
145
+ }
118
146
  };
119
147
  var ControlSectionHeading = ({ title, description }) => {
120
- const { t } = useTranslation(translationKey);
121
- return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("h2", {
122
- className: "pli-4 container-max-width text-xl mbs-6 mbe-4"
123
- }, toLocalizedString(title, t)), description && /* @__PURE__ */ React2.createElement("p", {
124
- className: "pli-4 mlb-4 container-max-width text-description"
125
- }, toLocalizedString(description, t)));
148
+ var _effect = _useSignals2();
149
+ try {
150
+ const { t } = useTranslation(translationKey);
151
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("h2", {
152
+ className: "pli-4 container-max-width text-xl mbs-6 mbe-4"
153
+ }, toLocalizedString(title, t)), description && /* @__PURE__ */ React2.createElement("p", {
154
+ className: "pli-4 mlb-4 container-max-width text-description"
155
+ }, toLocalizedString(description, t)));
156
+ } finally {
157
+ _effect.f();
158
+ }
126
159
  };
127
160
  var ControlGroupButton = ({ classNames, ...props }) => {
128
- return /* @__PURE__ */ React2.createElement(Button, {
129
- ...props,
130
- classNames: [
131
- "md:col-span-2",
132
- classNames
133
- ]
134
- });
161
+ var _effect = _useSignals2();
162
+ try {
163
+ return /* @__PURE__ */ React2.createElement(Button, {
164
+ ...props,
165
+ classNames: [
166
+ "md:col-span-2",
167
+ classNames
168
+ ]
169
+ });
170
+ } finally {
171
+ _effect.f();
172
+ }
135
173
  };
136
- var ControlGroup = ({ children, classNames }) => /* @__PURE__ */ React2.createElement("div", {
137
- role: "none",
138
- className: mx2("group container-max-width grid grid-cols-1 md:grid-cols-[1fr_min-content] gap-4", classNames)
139
- }, children);
140
- var ControlFrame = ({ children }) => /* @__PURE__ */ React2.createElement("div", {
141
- role: "none",
142
- className: "p-4 border border-separator rounded-lg container-max-width grid grid-cols-1 md:grid-cols-[1fr_1fr] gap-2 md:gap-8"
143
- }, children);
144
- var controlItemClasses = "p-4 border border-separator rounded-lg container-max-width grid md:col-span-2 grid-cols-subgrid items-center";
145
- var controlItemTitleClasses = "text-lg font-normal mbe-2";
174
+ var ControlGroup = ({ children, classNames }) => {
175
+ var _effect = _useSignals2();
176
+ try {
177
+ return /* @__PURE__ */ React2.createElement("div", {
178
+ role: "none",
179
+ className: mx2("group container-max-width grid grid-cols-1 md:grid-cols-[1fr_min-content] gap-4", classNames)
180
+ }, children);
181
+ } finally {
182
+ _effect.f();
183
+ }
184
+ };
185
+ var ControlFrame = ({ children }) => {
186
+ var _effect = _useSignals2();
187
+ try {
188
+ return /* @__PURE__ */ React2.createElement("div", {
189
+ role: "none",
190
+ className: "p-4 border border-separator rounded-lg container-max-width grid grid-cols-1 md:grid-cols-[1fr_1fr] gap-2 md:gap-8"
191
+ }, children);
192
+ } finally {
193
+ _effect.f();
194
+ }
195
+ };
196
+ var controlItemClasses = "p-4 border border-separator rounded-lg container-max-width grid md:col-span-2 grid-cols-subgrid items-center gap-2";
197
+ var controlItemTitleClasses = "text-lg font-normal";
146
198
  var controlItemDescriptionClasses = "text-base mlb-2 md:mbe-0 text-description";
147
199
  var ControlItem = ({ title, description, children }) => {
148
- const { t } = useTranslation(translationKey);
149
- return /* @__PURE__ */ React2.createElement("div", {
150
- className: controlItemClasses
151
- }, /* @__PURE__ */ React2.createElement("div", {
152
- role: "none"
153
- }, /* @__PURE__ */ React2.createElement("h3", {
154
- className: controlItemTitleClasses
155
- }, toLocalizedString(title, t)), description && /* @__PURE__ */ React2.createElement("p", {
156
- className: controlItemDescriptionClasses
157
- }, toLocalizedString(description, t))), children);
200
+ var _effect = _useSignals2();
201
+ try {
202
+ const { t } = useTranslation(translationKey);
203
+ return /* @__PURE__ */ React2.createElement("div", {
204
+ className: controlItemClasses
205
+ }, /* @__PURE__ */ React2.createElement("div", {
206
+ role: "none"
207
+ }, /* @__PURE__ */ React2.createElement("h3", {
208
+ className: controlItemTitleClasses
209
+ }, toLocalizedString(title, t)), description && /* @__PURE__ */ React2.createElement("p", {
210
+ className: controlItemDescriptionClasses
211
+ }, toLocalizedString(description, t))), children);
212
+ } finally {
213
+ _effect.f();
214
+ }
158
215
  };
159
216
  var ControlItemInput = ({ title, description, children }) => {
160
- const { t } = useTranslation(translationKey);
161
- return /* @__PURE__ */ React2.createElement(Input2.Root, null, /* @__PURE__ */ React2.createElement("div", {
162
- className: controlItemClasses
163
- }, /* @__PURE__ */ React2.createElement("div", {
164
- role: "none"
165
- }, /* @__PURE__ */ React2.createElement(Input2.Label, {
166
- classNames: controlItemTitleClasses
167
- }, toLocalizedString(title, t)), description && /* @__PURE__ */ React2.createElement(Input2.DescriptionAndValidation, null, /* @__PURE__ */ React2.createElement(Input2.Description, {
168
- classNames: controlItemDescriptionClasses
169
- }, toLocalizedString(description, t)))), children));
217
+ var _effect = _useSignals2();
218
+ try {
219
+ const { t } = useTranslation(translationKey);
220
+ return /* @__PURE__ */ React2.createElement(Input2.Root, null, /* @__PURE__ */ React2.createElement("div", {
221
+ className: controlItemClasses
222
+ }, /* @__PURE__ */ React2.createElement("div", {
223
+ role: "none"
224
+ }, /* @__PURE__ */ React2.createElement(Input2.Label, {
225
+ classNames: controlItemTitleClasses
226
+ }, toLocalizedString(title, t)), description && /* @__PURE__ */ React2.createElement(Input2.DescriptionAndValidation, null, /* @__PURE__ */ React2.createElement(Input2.Description, {
227
+ classNames: controlItemDescriptionClasses
228
+ }, toLocalizedString(description, t)))), children));
229
+ } finally {
230
+ _effect.f();
231
+ }
170
232
  };
171
233
  var ControlFrameItem = ({ title, description, children }) => {
172
- const { t } = useTranslation(translationKey);
173
- return /* @__PURE__ */ React2.createElement("div", {
174
- role: "group",
175
- className: "min-is-0"
176
- }, /* @__PURE__ */ React2.createElement("h3", {
177
- className: "text-lg mbe-2"
178
- }, toLocalizedString(title, t)), description && /* @__PURE__ */ React2.createElement("p", {
179
- className: "mlb-2 md:mbe-0 text-description"
180
- }, toLocalizedString(description, t)), children);
234
+ var _effect = _useSignals2();
235
+ try {
236
+ const { t } = useTranslation(translationKey);
237
+ return /* @__PURE__ */ React2.createElement("div", {
238
+ role: "group",
239
+ className: "min-is-0"
240
+ }, /* @__PURE__ */ React2.createElement("h3", {
241
+ className: "text-lg mbe-2"
242
+ }, toLocalizedString(title, t)), description && /* @__PURE__ */ React2.createElement("p", {
243
+ className: "mlb-2 md:mbe-0 text-description"
244
+ }, toLocalizedString(description, t)), children);
245
+ } finally {
246
+ _effect.f();
247
+ }
181
248
  };
182
249
 
183
250
  // packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx
184
- import React14, { useCallback as useCallback8, useEffect as useEffect8, useMemo as useMemo7, useState as useState5 } from "react";
251
+ import { useSignals as _useSignals14 } from "@preact-signals/safe-react/tracking";
252
+ import React14, { useCallback as useCallback9, useEffect as useEffect8, useMemo as useMemo7, useState as useState5 } from "react";
185
253
  import { FormatEnum as FormatEnum5, FormatEnums, formatToType } from "@dxos/echo-schema";
186
254
  import { log as log3 } from "@dxos/log";
187
- import { useTranslation as useTranslation6 } from "@dxos/react-ui";
255
+ import { useTranslation as useTranslation8 } from "@dxos/react-ui";
188
256
  import { getFormatSchema, getSchemaProperties as getSchemaProperties3, sortProperties } from "@dxos/schema";
189
257
 
190
258
  // packages/ui/react-ui-form/src/components/Form/custom/GeoPointInput.tsx
259
+ import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
191
260
  import React4, { useCallback, useState, useEffect, useMemo } from "react";
192
261
  import { GeoLocation } from "@dxos/echo-schema";
193
262
  import { Input as Input3, useTranslation as useTranslation2 } from "@dxos/react-ui";
194
263
  import { safeParseFloat } from "@dxos/util";
195
264
 
196
265
  // packages/ui/react-ui-form/src/components/Form/Input.tsx
266
+ import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
197
267
  import React3 from "react";
198
268
  import { Icon, Tooltip } from "@dxos/react-ui";
199
269
  import { errorText } from "@dxos/react-ui-theme";
200
270
  var InputHeader = ({ children, error }) => {
201
- return /* @__PURE__ */ React3.createElement("div", {
202
- role: "none",
203
- className: "flex justify-between items-center mb-1"
204
- }, children, error && /* @__PURE__ */ React3.createElement(Tooltip.Trigger, {
205
- asChild: true,
206
- content: error,
207
- side: "bottom"
208
- }, /* @__PURE__ */ React3.createElement(Icon, {
209
- icon: "ph--warning--regular",
210
- size: 4,
211
- classNames: errorText
212
- })));
271
+ var _effect = _useSignals3();
272
+ try {
273
+ return /* @__PURE__ */ React3.createElement("div", {
274
+ role: "none",
275
+ className: "flex justify-between items-center mbs-2 mbe-1 first:mbs-0"
276
+ }, children, error && /* @__PURE__ */ React3.createElement(Tooltip.Trigger, {
277
+ asChild: true,
278
+ content: error,
279
+ side: "bottom"
280
+ }, /* @__PURE__ */ React3.createElement(Icon, {
281
+ icon: "ph--warning--regular",
282
+ size: 4,
283
+ classNames: errorText
284
+ })));
285
+ } finally {
286
+ _effect.f();
287
+ }
213
288
  };
214
289
 
215
290
  // packages/ui/react-ui-form/src/components/Form/custom/GeoPointInput.tsx
216
291
  var GeoPointInput = ({ type, label, disabled, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
217
- const { t } = useTranslation2(translationKey);
218
- const { status, error } = getStatus();
219
- const geoPoint = useMemo(() => getValue3() ?? [
220
- 0,
221
- 0
222
- ], [
223
- getValue3
224
- ]);
225
- const geoLocation = useMemo(() => GeoLocation.fromGeoPoint(geoPoint), [
226
- geoPoint
227
- ]);
228
- const [longitudeText, setLongitudeText] = useState(geoLocation.longitude?.toString());
229
- const [latitudeText, setLatitudeText] = useState(geoLocation.latitude?.toString());
230
- useEffect(() => {
231
- const location = GeoLocation.fromGeoPoint(geoPoint);
232
- setLongitudeText(location.longitude.toString());
233
- setLatitudeText(location.latitude.toString());
234
- }, [
235
- geoPoint
236
- ]);
237
- const handleCoordinateChange = useCallback((coordinateType, setText) => (event) => {
238
- const inputText = event.target.value;
239
- setText(inputText);
240
- if (inputText !== "" && inputText !== "-") {
241
- const coord = safeParseFloat(inputText);
242
- if (coord !== void 0 && !isNaN(coord)) {
243
- const currentLocation = GeoLocation.fromGeoPoint(getValue3() ?? [
244
- 0,
245
- 0
246
- ]);
247
- const newLocation = {
248
- ...currentLocation,
249
- [coordinateType]: coord
250
- };
251
- const newValue = GeoLocation.toGeoPoint(newLocation);
252
- onValueChange(type, newValue);
292
+ var _effect = _useSignals4();
293
+ try {
294
+ const { t } = useTranslation2(translationKey);
295
+ const { status, error } = getStatus();
296
+ const geoPoint = useMemo(() => getValue3() ?? [
297
+ 0,
298
+ 0
299
+ ], [
300
+ getValue3
301
+ ]);
302
+ const geoLocation = useMemo(() => GeoLocation.fromGeoPoint(geoPoint), [
303
+ geoPoint
304
+ ]);
305
+ const [longitudeText, setLongitudeText] = useState(geoLocation.longitude?.toString());
306
+ const [latitudeText, setLatitudeText] = useState(geoLocation.latitude?.toString());
307
+ useEffect(() => {
308
+ const location = GeoLocation.fromGeoPoint(geoPoint);
309
+ setLongitudeText(location.longitude.toString());
310
+ setLatitudeText(location.latitude.toString());
311
+ }, [
312
+ geoPoint
313
+ ]);
314
+ const handleCoordinateChange = useCallback((coordinateType, setText) => (event) => {
315
+ const inputText = event.target.value;
316
+ setText(inputText);
317
+ if (inputText !== "" && inputText !== "-") {
318
+ const coord = safeParseFloat(inputText);
319
+ if (coord !== void 0 && !isNaN(coord)) {
320
+ const currentLocation = GeoLocation.fromGeoPoint(getValue3() ?? [
321
+ 0,
322
+ 0
323
+ ]);
324
+ const newLocation = {
325
+ ...currentLocation,
326
+ [coordinateType]: coord
327
+ };
328
+ const newValue = GeoLocation.toGeoPoint(newLocation);
329
+ onValueChange(type, newValue);
330
+ }
253
331
  }
254
- }
255
- }, [
256
- getValue3,
257
- onValueChange,
258
- type
259
- ]);
260
- return /* @__PURE__ */ React4.createElement(Input3.Root, {
261
- validationValence: status
262
- }, /* @__PURE__ */ React4.createElement(InputHeader, {
263
- error
264
- }, /* @__PURE__ */ React4.createElement(Input3.Label, null, label)), /* @__PURE__ */ React4.createElement("div", {
265
- role: "none",
266
- className: "grid grid-cols-2 gap-2"
267
- }, /* @__PURE__ */ React4.createElement(Input3.TextInput, {
268
- type: "text",
269
- pattern: "^-?[0-9]*\\.?[0-9]*$",
270
- disabled,
271
- placeholder: t("placeholder latitude"),
272
- value: latitudeText,
273
- onChange: handleCoordinateChange("latitude", setLatitudeText),
274
- onBlur
275
- }), /* @__PURE__ */ React4.createElement(Input3.TextInput, {
276
- type: "text",
277
- pattern: "^-?[0-9]*\\.?[0-9]*$",
278
- disabled,
279
- placeholder: t("placeholder longitude"),
280
- value: longitudeText,
281
- onChange: handleCoordinateChange("longitude", setLongitudeText),
282
- onBlur
283
- })));
332
+ }, [
333
+ getValue3,
334
+ onValueChange,
335
+ type
336
+ ]);
337
+ return /* @__PURE__ */ React4.createElement(Input3.Root, {
338
+ validationValence: status
339
+ }, /* @__PURE__ */ React4.createElement(InputHeader, {
340
+ error
341
+ }, /* @__PURE__ */ React4.createElement(Input3.Label, null, label)), /* @__PURE__ */ React4.createElement("div", {
342
+ role: "none",
343
+ className: "grid grid-cols-2 gap-2"
344
+ }, /* @__PURE__ */ React4.createElement(Input3.TextInput, {
345
+ type: "text",
346
+ pattern: "^-?[0-9]*\\.?[0-9]*$",
347
+ disabled,
348
+ placeholder: t("placeholder latitude"),
349
+ value: latitudeText,
350
+ onChange: handleCoordinateChange("latitude", setLatitudeText),
351
+ onBlur
352
+ }), /* @__PURE__ */ React4.createElement(Input3.TextInput, {
353
+ type: "text",
354
+ pattern: "^-?[0-9]*\\.?[0-9]*$",
355
+ disabled,
356
+ placeholder: t("placeholder longitude"),
357
+ value: longitudeText,
358
+ onChange: handleCoordinateChange("longitude", setLongitudeText),
359
+ onBlur
360
+ })));
361
+ } finally {
362
+ _effect.f();
363
+ }
284
364
  };
285
365
 
286
366
  // packages/ui/react-ui-form/src/components/Form/custom/SelectOptionsInput.tsx
367
+ import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
287
368
  import React5, { useCallback as useCallback2, useEffect as useEffect2, useState as useState2, useRef } from "react";
288
369
  import { PublicKey } from "@dxos/keys";
289
370
  import { Icon as Icon2, IconButton, Input as Input4, Tag, Toolbar, useTranslation as useTranslation3 } from "@dxos/react-ui";
@@ -291,183 +372,189 @@ import { List } from "@dxos/react-ui-list";
291
372
  import { HuePicker } from "@dxos/react-ui-pickers";
292
373
  import { hues, mx as mx3 } from "@dxos/react-ui-theme";
293
374
  var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3, onValueChange }) => {
294
- const [selected, setSelectedId] = useState2(null);
295
- const [isNewOption, setIsNewOption] = useState2(false);
296
- const inputRef = useRef(null);
297
- const { t } = useTranslation3(translationKey);
298
- const { status, error } = getStatus();
299
- const options = getValue3();
300
- useEffect2(() => {
301
- if (options === void 0) {
302
- onValueChange(type, []);
303
- }
304
- }, [
305
- options,
306
- onValueChange,
307
- type
308
- ]);
309
- const randomHue = () => {
310
- const usedHues = new Set(options?.map((option) => option.color) ?? []);
311
- const unusedHues = hues.filter((hue) => !usedHues.has(hue));
312
- if (unusedHues.length > 0) {
313
- return unusedHues[Math.floor(Math.random() * unusedHues.length)];
314
- }
315
- const lastThree = new Set(options?.slice(-3).map((option) => option.color) ?? []);
316
- const availableHues = hues.filter((hue) => !lastThree.has(hue));
317
- return availableHues[Math.floor(Math.random() * availableHues.length)] ?? hues[Math.floor(Math.random() * hues.length)];
318
- };
319
- const handleAdd = useCallback2(() => {
320
- const newId = PublicKey.random().truncate();
321
- const newOption = {
322
- id: newId,
323
- title: "",
324
- color: randomHue()
375
+ var _effect = _useSignals5();
376
+ try {
377
+ const [selected, setSelectedId] = useState2(null);
378
+ const [isNewOption, setIsNewOption] = useState2(false);
379
+ const inputRef = useRef(null);
380
+ const { t } = useTranslation3(translationKey);
381
+ const { status, error } = getStatus();
382
+ const options = getValue3();
383
+ useEffect2(() => {
384
+ if (options === void 0) {
385
+ onValueChange(type, []);
386
+ }
387
+ }, [
388
+ options,
389
+ onValueChange,
390
+ type
391
+ ]);
392
+ const randomHue = () => {
393
+ const usedHues = new Set(options?.map((option) => option.color) ?? []);
394
+ const unusedHues = hues.filter((hue) => !usedHues.has(hue));
395
+ if (unusedHues.length > 0) {
396
+ return unusedHues[Math.floor(Math.random() * unusedHues.length)];
397
+ }
398
+ const lastThree = new Set(options?.slice(-3).map((option) => option.color) ?? []);
399
+ const availableHues = hues.filter((hue) => !lastThree.has(hue));
400
+ return availableHues[Math.floor(Math.random() * availableHues.length)] ?? hues[Math.floor(Math.random() * hues.length)];
325
401
  };
326
- onValueChange(type, [
327
- ...options ?? [],
328
- newOption
402
+ const handleAdd = useCallback2(() => {
403
+ const newId = PublicKey.random().truncate();
404
+ const newOption = {
405
+ id: newId,
406
+ title: "",
407
+ color: randomHue()
408
+ };
409
+ onValueChange(type, [
410
+ ...options ?? [],
411
+ newOption
412
+ ]);
413
+ setSelectedId(newId);
414
+ setIsNewOption(true);
415
+ }, [
416
+ options,
417
+ type,
418
+ onValueChange
329
419
  ]);
330
- setSelectedId(newId);
331
- setIsNewOption(true);
332
- }, [
333
- options,
334
- type,
335
- onValueChange
336
- ]);
337
- const handleDelete = useCallback2((id) => {
338
- const newOptions = options?.filter((option) => option.id !== id) ?? [];
339
- onValueChange(type, newOptions);
340
- setSelectedId(null);
341
- }, [
342
- options,
343
- type,
344
- onValueChange
345
- ]);
346
- const handleMove = useCallback2((from, to) => {
347
- if (!options) {
348
- return;
349
- }
350
- const newOptions = [
351
- ...options
352
- ];
353
- const [removed] = newOptions.splice(from, 1);
354
- newOptions.splice(to, 0, removed);
355
- onValueChange(type, newOptions);
356
- }, [
357
- options,
358
- type,
359
- onValueChange
360
- ]);
361
- const handleClick = useCallback2((id) => {
362
- setSelectedId((current) => current === id ? null : id);
363
- }, []);
364
- const handleTitleChange = useCallback2((id) => (e) => {
365
- const newOptions = options?.map((o) => o.id === id ? {
366
- ...o,
367
- title: e.target.value
368
- } : o);
369
- onValueChange(type, newOptions ?? []);
370
- }, [
371
- options,
372
- type,
373
- onValueChange
374
- ]);
375
- const handleKeyDown = useCallback2((e) => {
376
- if (e.key === "Enter") {
420
+ const handleDelete = useCallback2((id) => {
421
+ const newOptions = options?.filter((option) => option.id !== id) ?? [];
422
+ onValueChange(type, newOptions);
377
423
  setSelectedId(null);
378
- }
379
- }, []);
380
- const handleColorChange = useCallback2((id) => (hue) => {
381
- const newOptions = options?.map((o) => o.id === id ? {
382
- ...o,
383
- color: hue
384
- } : o);
385
- onValueChange(type, newOptions ?? []);
386
- }, [
387
- options,
388
- type,
389
- onValueChange
390
- ]);
391
- useEffect2(() => {
392
- if (selected && isNewOption && inputRef.current) {
393
- inputRef.current.focus();
394
- setIsNewOption(false);
395
- }
396
- }, [
397
- selected,
398
- isNewOption
399
- ]);
400
- return /* @__PURE__ */ React5.createElement(Input4.Root, {
401
- validationValence: status
402
- }, /* @__PURE__ */ React5.createElement(InputHeader, {
403
- error
404
- }, /* @__PURE__ */ React5.createElement(Input4.Label, null, label)), /* @__PURE__ */ React5.createElement("div", {
405
- role: "none"
406
- }, options && /* @__PURE__ */ React5.createElement(List.Root, {
407
- items: options,
408
- isItem: (item) => true,
409
- onMove: handleMove
410
- }, ({ items }) => /* @__PURE__ */ React5.createElement("div", {
411
- role: "list",
412
- className: "w-full overflow-auto"
413
- }, items?.map((item) => /* @__PURE__ */ React5.createElement("div", {
414
- key: item.id
415
- }, /* @__PURE__ */ React5.createElement(List.Item, {
416
- role: "button",
417
- item,
418
- classNames: mx3("p-1 plb-2", "flex flex-col", "cursor-pointer", "hover:bg-hoverOverlay"),
419
- "aria-expanded": selected === item.id
420
- }, /* @__PURE__ */ React5.createElement("div", {
421
- className: "flex items-center"
422
- }, /* @__PURE__ */ React5.createElement(List.ItemDragHandle, null), /* @__PURE__ */ React5.createElement(List.ItemTitle, {
423
- onClick: () => handleClick(item.id),
424
- classNames: "flex-1"
425
- }, /* @__PURE__ */ React5.createElement(Tag, {
426
- palette: item.color
427
- }, item.title || "\u200B")), /* @__PURE__ */ React5.createElement(Icon2, {
428
- icon: selected === item.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
429
- onClick: () => handleClick(item.id)
430
- })), selected === item.id && /* @__PURE__ */ React5.createElement("div", {
431
- className: "mis-4 mbs-2 flex flex-col gap-1"
432
- }, /* @__PURE__ */ React5.createElement(Input4.Label, {
433
- classNames: "text-xs"
434
- }, t("select option label")), /* @__PURE__ */ React5.createElement("div", {
435
- className: "flex flex-row items-center gap-1"
436
- }, /* @__PURE__ */ React5.createElement(Input4.TextInput, {
437
- placeholder: t("select option label placeholder"),
438
- ref: selected === item.id ? inputRef : void 0,
439
- value: item.title,
440
- onChange: handleTitleChange(item.id),
441
- onKeyDown: handleKeyDown,
442
- classNames: "flex-1",
443
- "data-no-submit": true
444
- }), /* @__PURE__ */ React5.createElement(Toolbar.Root, {
445
- classNames: "p-0 m-0 !is-auto"
446
- }, /* @__PURE__ */ React5.createElement(HuePicker, {
447
- value: item.color,
448
- onChange: handleColorChange(item.id),
449
- rootVariant: "toolbar-button"
450
- })), /* @__PURE__ */ React5.createElement(IconButton, {
451
- icon: "ph--trash--fill",
452
- iconOnly: true,
453
- label: t("select option delete"),
454
- onClick: () => handleDelete(item.id)
455
- })))))), /* @__PURE__ */ React5.createElement("div", {
456
- role: "listitem"
457
- }, /* @__PURE__ */ React5.createElement("div", {
458
- role: "button",
459
- className: mx3("p-1 plb-2", "flex flex-col", "cursor-pointer", "hover:bg-hoverOverlay"),
460
- onClick: handleAdd
461
- }, /* @__PURE__ */ React5.createElement("div", {
462
- className: "flex items-center gap-1"
463
- }, /* @__PURE__ */ React5.createElement(Icon2, {
464
- icon: "ph--plus--regular"
465
- }), /* @__PURE__ */ React5.createElement("span", {
466
- className: "text-sm"
467
- }, t("select option add")))))))));
424
+ }, [
425
+ options,
426
+ type,
427
+ onValueChange
428
+ ]);
429
+ const handleMove = useCallback2((from, to) => {
430
+ if (!options) {
431
+ return;
432
+ }
433
+ const newOptions = [
434
+ ...options
435
+ ];
436
+ const [removed] = newOptions.splice(from, 1);
437
+ newOptions.splice(to, 0, removed);
438
+ onValueChange(type, newOptions);
439
+ }, [
440
+ options,
441
+ type,
442
+ onValueChange
443
+ ]);
444
+ const handleClick = useCallback2((id) => {
445
+ setSelectedId((current) => current === id ? null : id);
446
+ }, []);
447
+ const handleTitleChange = useCallback2((id) => (e) => {
448
+ const newOptions = options?.map((o) => o.id === id ? {
449
+ ...o,
450
+ title: e.target.value
451
+ } : o);
452
+ onValueChange(type, newOptions ?? []);
453
+ }, [
454
+ options,
455
+ type,
456
+ onValueChange
457
+ ]);
458
+ const handleKeyDown = useCallback2((e) => {
459
+ if (e.key === "Enter") {
460
+ setSelectedId(null);
461
+ }
462
+ }, []);
463
+ const handleColorChange = useCallback2((id) => (hue) => {
464
+ const newOptions = options?.map((o) => o.id === id ? {
465
+ ...o,
466
+ color: hue
467
+ } : o);
468
+ onValueChange(type, newOptions ?? []);
469
+ }, [
470
+ options,
471
+ type,
472
+ onValueChange
473
+ ]);
474
+ useEffect2(() => {
475
+ if (selected && isNewOption && inputRef.current) {
476
+ inputRef.current.focus();
477
+ setIsNewOption(false);
478
+ }
479
+ }, [
480
+ selected,
481
+ isNewOption
482
+ ]);
483
+ return /* @__PURE__ */ React5.createElement(Input4.Root, {
484
+ validationValence: status
485
+ }, /* @__PURE__ */ React5.createElement(InputHeader, {
486
+ error
487
+ }, /* @__PURE__ */ React5.createElement(Input4.Label, null, label)), /* @__PURE__ */ React5.createElement("div", {
488
+ role: "none"
489
+ }, options && /* @__PURE__ */ React5.createElement(List.Root, {
490
+ items: options,
491
+ isItem: (item) => true,
492
+ onMove: handleMove
493
+ }, ({ items }) => /* @__PURE__ */ React5.createElement("div", {
494
+ role: "list",
495
+ className: "w-full overflow-auto"
496
+ }, items?.map((item) => /* @__PURE__ */ React5.createElement("div", {
497
+ key: item.id
498
+ }, /* @__PURE__ */ React5.createElement(List.Item, {
499
+ role: "button",
500
+ item,
501
+ classNames: mx3("p-1 plb-2", "flex flex-col", "cursor-pointer", "hover:bg-hoverOverlay"),
502
+ "aria-expanded": selected === item.id
503
+ }, /* @__PURE__ */ React5.createElement("div", {
504
+ className: "flex items-center"
505
+ }, /* @__PURE__ */ React5.createElement(List.ItemDragHandle, null), /* @__PURE__ */ React5.createElement(List.ItemTitle, {
506
+ onClick: () => handleClick(item.id),
507
+ classNames: "flex-1"
508
+ }, /* @__PURE__ */ React5.createElement(Tag, {
509
+ palette: item.color
510
+ }, item.title || "\u200B")), /* @__PURE__ */ React5.createElement(Icon2, {
511
+ icon: selected === item.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
512
+ onClick: () => handleClick(item.id)
513
+ })), selected === item.id && /* @__PURE__ */ React5.createElement("div", {
514
+ className: "mis-4 mbs-2 flex flex-col gap-1"
515
+ }, /* @__PURE__ */ React5.createElement(Input4.Label, {
516
+ classNames: "text-xs"
517
+ }, t("select option label")), /* @__PURE__ */ React5.createElement("div", {
518
+ className: "flex flex-row items-center gap-1"
519
+ }, /* @__PURE__ */ React5.createElement(Input4.TextInput, {
520
+ placeholder: t("select option label placeholder"),
521
+ ref: selected === item.id ? inputRef : void 0,
522
+ value: item.title,
523
+ onChange: handleTitleChange(item.id),
524
+ onKeyDown: handleKeyDown,
525
+ classNames: "flex-1",
526
+ "data-no-submit": true
527
+ }), /* @__PURE__ */ React5.createElement(Toolbar.Root, {
528
+ classNames: "p-0 m-0 !is-auto"
529
+ }, /* @__PURE__ */ React5.createElement(HuePicker, {
530
+ value: item.color,
531
+ onChange: handleColorChange(item.id),
532
+ rootVariant: "toolbar-button"
533
+ })), /* @__PURE__ */ React5.createElement(IconButton, {
534
+ icon: "ph--trash--fill",
535
+ iconOnly: true,
536
+ label: t("select option delete"),
537
+ onClick: () => handleDelete(item.id)
538
+ })))))), /* @__PURE__ */ React5.createElement("div", {
539
+ role: "listitem"
540
+ }, /* @__PURE__ */ React5.createElement("div", {
541
+ role: "button",
542
+ className: mx3("p-1 plb-2", "flex flex-col", "cursor-pointer", "hover:bg-hoverOverlay"),
543
+ onClick: handleAdd
544
+ }, /* @__PURE__ */ React5.createElement("div", {
545
+ className: "flex items-center gap-1"
546
+ }, /* @__PURE__ */ React5.createElement(Icon2, {
547
+ icon: "ph--plus--regular"
548
+ }), /* @__PURE__ */ React5.createElement("span", {
549
+ className: "text-sm"
550
+ }, t("select option add")))))))));
551
+ } finally {
552
+ _effect.f();
553
+ }
468
554
  };
469
555
 
470
556
  // packages/ui/react-ui-form/src/components/Form/custom/TupleInput.tsx
557
+ import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
471
558
  import React6 from "react";
472
559
  import { Input as Input5 } from "@dxos/react-ui";
473
560
  import { mx as mx4 } from "@dxos/react-ui-theme";
@@ -479,148 +566,182 @@ var gridCols = [
479
566
  "grid-cols-4"
480
567
  ];
481
568
  var TupleInput = ({ binding, type, label, disabled, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
482
- const { status, error } = getStatus();
483
- const values = getValue3() ?? {};
484
- return /* @__PURE__ */ React6.createElement(Input5.Root, {
485
- validationValence: status
486
- }, /* @__PURE__ */ React6.createElement(InputHeader, {
487
- error
488
- }, /* @__PURE__ */ React6.createElement(Input5.Label, null, label)), /* @__PURE__ */ React6.createElement("div", {
489
- className: mx4("grid gap-2", gridCols[binding.length - 1])
490
- }, binding.map((prop) => /* @__PURE__ */ React6.createElement(Input5.TextInput, {
491
- key: prop,
492
- type: "number",
493
- disabled,
494
- value: values[prop],
495
- onChange: (event) => onValueChange(type, {
496
- ...values,
497
- [prop]: safeParseFloat2(event.target.value, 0)
498
- }),
499
- onBlur
500
- }))));
569
+ var _effect = _useSignals6();
570
+ try {
571
+ const { status, error } = getStatus();
572
+ const values = getValue3() ?? {};
573
+ return /* @__PURE__ */ React6.createElement(Input5.Root, {
574
+ validationValence: status
575
+ }, /* @__PURE__ */ React6.createElement(InputHeader, {
576
+ error
577
+ }, /* @__PURE__ */ React6.createElement(Input5.Label, null, label)), /* @__PURE__ */ React6.createElement("div", {
578
+ className: mx4("grid gap-2", gridCols[binding.length - 1])
579
+ }, binding.map((prop) => /* @__PURE__ */ React6.createElement(Input5.TextInput, {
580
+ key: prop,
581
+ type: "number",
582
+ disabled,
583
+ value: values[prop],
584
+ onChange: (event) => onValueChange(type, {
585
+ ...values,
586
+ [prop]: safeParseFloat2(event.target.value, 0)
587
+ }),
588
+ onBlur
589
+ }))));
590
+ } finally {
591
+ _effect.f();
592
+ }
501
593
  };
502
594
 
503
595
  // packages/ui/react-ui-form/src/components/Form/Defaults.tsx
596
+ import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
504
597
  import React7, { useCallback as useCallback3, useEffect as useEffect3, useRef as useRef2 } from "react";
505
- import { Input as Input6, Select } from "@dxos/react-ui";
598
+ import { Input as Input6, Select, useTranslation as useTranslation4 } from "@dxos/react-ui";
506
599
  var TextInput = ({ type, label, inputOnly, disabled, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
507
- const { status, error } = getStatus();
508
- return /* @__PURE__ */ React7.createElement(Input6.Root, {
509
- validationValence: status
510
- }, !inputOnly && /* @__PURE__ */ React7.createElement(InputHeader, {
511
- error
512
- }, /* @__PURE__ */ React7.createElement(Input6.Label, null, label)), /* @__PURE__ */ React7.createElement(Input6.TextInput, {
513
- disabled,
514
- placeholder,
515
- value: getValue3() ?? "",
516
- onChange: (event) => onValueChange(type, event.target.value),
517
- onBlur
518
- }), inputOnly && /* @__PURE__ */ React7.createElement(Input6.Validation, null, error));
600
+ var _effect = _useSignals7();
601
+ try {
602
+ const { status, error } = getStatus();
603
+ return disabled && !getValue3() ? null : disabled && inputOnly ? /* @__PURE__ */ React7.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React7.createElement(Input6.Root, {
604
+ validationValence: status
605
+ }, !inputOnly && /* @__PURE__ */ React7.createElement(InputHeader, {
606
+ error
607
+ }, /* @__PURE__ */ React7.createElement(Input6.Label, null, label)), disabled ? /* @__PURE__ */ React7.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React7.createElement(Input6.TextInput, {
608
+ disabled,
609
+ placeholder,
610
+ value: getValue3() ?? "",
611
+ onChange: (event) => onValueChange(type, event.target.value),
612
+ onBlur
613
+ }), inputOnly && /* @__PURE__ */ React7.createElement(Input6.Validation, null, error));
614
+ } finally {
615
+ _effect.f();
616
+ }
519
617
  };
520
618
  var NumberInput = ({ type, label, inputOnly, disabled, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
521
- const { status, error } = getStatus();
522
- return /* @__PURE__ */ React7.createElement(Input6.Root, {
523
- validationValence: status
524
- }, !inputOnly && /* @__PURE__ */ React7.createElement(InputHeader, {
525
- error
526
- }, /* @__PURE__ */ React7.createElement(Input6.Label, null, label)), /* @__PURE__ */ React7.createElement(Input6.TextInput, {
527
- type: "number",
528
- disabled,
529
- placeholder,
530
- value: getValue3() ?? 0,
531
- onChange: (event) => onValueChange(type, event.target.value),
532
- onBlur
533
- }), inputOnly && /* @__PURE__ */ React7.createElement(Input6.DescriptionAndValidation, null, error));
619
+ var _effect = _useSignals7();
620
+ try {
621
+ const { status, error } = getStatus();
622
+ return disabled && !getValue3() ? null : disabled && inputOnly ? /* @__PURE__ */ React7.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React7.createElement(Input6.Root, {
623
+ validationValence: status
624
+ }, !inputOnly && /* @__PURE__ */ React7.createElement(InputHeader, {
625
+ error
626
+ }, /* @__PURE__ */ React7.createElement(Input6.Label, null, label)), disabled ? /* @__PURE__ */ React7.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React7.createElement(Input6.TextInput, {
627
+ type: "number",
628
+ disabled,
629
+ placeholder,
630
+ value: getValue3() ?? 0,
631
+ onChange: (event) => onValueChange(type, event.target.value),
632
+ onBlur
633
+ }), inputOnly && /* @__PURE__ */ React7.createElement(Input6.DescriptionAndValidation, null, error));
634
+ } finally {
635
+ _effect.f();
636
+ }
534
637
  };
535
- var BooleanInput = ({ type, label, inputOnly, getStatus, getValue: getValue3, onValueChange }) => {
536
- const { status, error } = getStatus();
537
- const checked = Boolean(getValue3());
538
- return /* @__PURE__ */ React7.createElement(Input6.Root, {
539
- validationValence: status
540
- }, !inputOnly && /* @__PURE__ */ React7.createElement(InputHeader, {
541
- error
542
- }, /* @__PURE__ */ React7.createElement(Input6.Label, null, label)), /* @__PURE__ */ React7.createElement(Input6.Switch, {
543
- checked,
544
- onCheckedChange: (value) => onValueChange(type, value)
545
- }), inputOnly && /* @__PURE__ */ React7.createElement(Input6.DescriptionAndValidation, null, error));
638
+ var BooleanInput = ({ type, label, inputOnly, getStatus, getValue: getValue3, onValueChange, disabled }) => {
639
+ var _effect = _useSignals7();
640
+ try {
641
+ const { status, error } = getStatus();
642
+ const checked = Boolean(getValue3());
643
+ const { t } = useTranslation4(translationKey);
644
+ return /* @__PURE__ */ React7.createElement(Input6.Root, {
645
+ validationValence: status
646
+ }, !inputOnly && /* @__PURE__ */ React7.createElement(InputHeader, {
647
+ error
648
+ }, /* @__PURE__ */ React7.createElement(Input6.Label, null, label)), disabled ? /* @__PURE__ */ React7.createElement("p", null, t(checked ? "boolean input true value" : "boolean input false value")) : /* @__PURE__ */ React7.createElement(Input6.Switch, {
649
+ checked,
650
+ onCheckedChange: (value) => onValueChange(type, value)
651
+ }), inputOnly && /* @__PURE__ */ React7.createElement(Input6.DescriptionAndValidation, null, error));
652
+ } finally {
653
+ _effect.f();
654
+ }
546
655
  };
547
656
  var SelectInput = ({ type, label, inputOnly, disabled, placeholder, options, getStatus, getValue: getValue3, onValueChange }) => {
548
- const { status, error } = getStatus();
549
- const value = getValue3();
550
- const handleValueChange = useCallback3((value2) => onValueChange(type, value2), [
551
- type,
552
- onValueChange
553
- ]);
554
- return /* @__PURE__ */ React7.createElement(Input6.Root, {
555
- validationValence: status
556
- }, !inputOnly && /* @__PURE__ */ React7.createElement(InputHeader, {
557
- error
558
- }, /* @__PURE__ */ React7.createElement(Input6.Label, null, label)), /* @__PURE__ */ React7.createElement(Select.Root, {
559
- value,
560
- onValueChange: handleValueChange
561
- }, /* @__PURE__ */ React7.createElement(Select.TriggerButton, {
562
- classNames: "is-full",
563
- disabled,
564
- placeholder
565
- }), /* @__PURE__ */ React7.createElement(Select.Portal, null, /* @__PURE__ */ React7.createElement(Select.Content, null, /* @__PURE__ */ React7.createElement(Select.Viewport, null, options?.map(({ value: value2, label: label2 }) => (
566
- // NOTE: Numeric values are converted to and from strings.
567
- /* @__PURE__ */ React7.createElement(Select.Option, {
568
- key: String(value2),
569
- value: String(value2)
570
- }, label2 ?? String(value2))
571
- )))))), inputOnly && /* @__PURE__ */ React7.createElement(Input6.DescriptionAndValidation, null, error));
657
+ var _effect = _useSignals7();
658
+ try {
659
+ const { status, error } = getStatus();
660
+ const value = getValue3();
661
+ const handleValueChange = useCallback3((value2) => onValueChange(type, value2), [
662
+ type,
663
+ onValueChange
664
+ ]);
665
+ return disabled && !value ? null : /* @__PURE__ */ React7.createElement(Input6.Root, {
666
+ validationValence: status
667
+ }, !inputOnly && /* @__PURE__ */ React7.createElement(InputHeader, {
668
+ error
669
+ }, /* @__PURE__ */ React7.createElement(Input6.Label, null, label)), disabled ? /* @__PURE__ */ React7.createElement("p", null, options?.find(({ value: optionValue }) => optionValue === value)?.label ?? String(value)) : /* @__PURE__ */ React7.createElement(Select.Root, {
670
+ value,
671
+ onValueChange: handleValueChange
672
+ }, /* @__PURE__ */ React7.createElement(Select.TriggerButton, {
673
+ classNames: "is-full",
674
+ disabled,
675
+ placeholder
676
+ }), /* @__PURE__ */ React7.createElement(Select.Portal, null, /* @__PURE__ */ React7.createElement(Select.Content, null, /* @__PURE__ */ React7.createElement(Select.Viewport, null, options?.map(({ value: value2, label: label2 }) => (
677
+ // NOTE: Numeric values are converted to and from strings.
678
+ /* @__PURE__ */ React7.createElement(Select.Option, {
679
+ key: String(value2),
680
+ value: String(value2)
681
+ }, label2 ?? String(value2))
682
+ )))))), inputOnly && /* @__PURE__ */ React7.createElement(Input6.DescriptionAndValidation, null, error));
683
+ } finally {
684
+ _effect.f();
685
+ }
572
686
  };
573
687
  var MarkdownInput = ({ type, label, inputOnly, disabled, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
574
- const { status, error } = getStatus();
575
- const textareaRef = useRef2(null);
576
- const adjustHeight = useCallback3(() => {
577
- const textarea = textareaRef.current;
578
- if (textarea) {
579
- textarea.style.blockSize = "auto";
580
- textarea.style.blockSize = `${textarea.scrollHeight + 2}px`;
581
- }
582
- }, []);
583
- useEffect3(() => {
584
- adjustHeight();
585
- }, [
586
- adjustHeight
587
- ]);
588
- useEffect3(() => {
589
- adjustHeight();
590
- }, [
591
- getValue3(),
592
- adjustHeight
593
- ]);
594
- return /* @__PURE__ */ React7.createElement(Input6.Root, {
595
- validationValence: status
596
- }, !inputOnly && /* @__PURE__ */ React7.createElement(InputHeader, {
597
- error
598
- }, /* @__PURE__ */ React7.createElement(Input6.Label, null, label)), /* @__PURE__ */ React7.createElement(Input6.TextArea, {
599
- ref: textareaRef,
600
- disabled,
601
- placeholder,
602
- value: getValue3() ?? "",
603
- classNames: "min-bs-auto max-h-40 overflow-auto",
604
- onChange: (event) => onValueChange(type, event.target.value),
605
- onBlur,
606
- style: {
607
- resize: "none"
608
- },
609
- spellCheck: false
610
- }), inputOnly && /* @__PURE__ */ React7.createElement(Input6.Validation, null, error));
688
+ var _effect = _useSignals7();
689
+ try {
690
+ const { status, error } = getStatus();
691
+ const textareaRef = useRef2(null);
692
+ const adjustHeight = useCallback3(() => {
693
+ const textarea = textareaRef.current;
694
+ if (textarea) {
695
+ textarea.style.blockSize = "auto";
696
+ textarea.style.blockSize = `${textarea.scrollHeight + 2}px`;
697
+ }
698
+ }, []);
699
+ useEffect3(() => {
700
+ adjustHeight();
701
+ }, [
702
+ adjustHeight
703
+ ]);
704
+ useEffect3(() => {
705
+ adjustHeight();
706
+ }, [
707
+ getValue3(),
708
+ adjustHeight
709
+ ]);
710
+ return /* @__PURE__ */ React7.createElement(Input6.Root, {
711
+ validationValence: status
712
+ }, !inputOnly && /* @__PURE__ */ React7.createElement(InputHeader, {
713
+ error
714
+ }, /* @__PURE__ */ React7.createElement(Input6.Label, null, label)), disabled ? /* @__PURE__ */ React7.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React7.createElement(Input6.TextArea, {
715
+ ref: textareaRef,
716
+ disabled,
717
+ placeholder,
718
+ value: getValue3() ?? "",
719
+ classNames: "min-bs-auto max-h-40 overflow-auto",
720
+ onChange: (event) => onValueChange(type, event.target.value),
721
+ onBlur,
722
+ style: {
723
+ resize: "none"
724
+ },
725
+ spellCheck: false
726
+ }), inputOnly && /* @__PURE__ */ React7.createElement(Input6.Validation, null, error));
727
+ } finally {
728
+ _effect.f();
729
+ }
611
730
  };
612
731
 
613
732
  // packages/ui/react-ui-form/src/components/Form/Form.tsx
733
+ import { useSignals as _useSignals13 } from "@preact-signals/safe-react/tracking";
614
734
  import React13, { useEffect as useEffect7, useMemo as useMemo6, useRef as useRef3 } from "react";
615
- import { mx as mx8 } from "@dxos/react-ui-theme";
735
+ import { mx as mx7 } from "@dxos/react-ui-theme";
616
736
 
617
737
  // packages/ui/react-ui-form/src/components/Form/FormActions.tsx
738
+ import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
618
739
  import React9 from "react";
619
- import { IconButton as IconButton2, useTranslation as useTranslation4 } from "@dxos/react-ui";
620
- import { mx as mx5 } from "@dxos/react-ui-theme";
740
+ import { IconButton as IconButton2, useTranslation as useTranslation5 } from "@dxos/react-ui";
621
741
 
622
742
  // packages/ui/react-ui-form/src/components/Form/FormContext.tsx
623
- import React8, { createContext, useContext, useEffect as useEffect6, useMemo as useMemo3 } from "react";
743
+ import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
744
+ import React8, { createContext, useContext, useEffect as useEffect6, useMemo as useMemo3, useCallback as useCallback6 } from "react";
624
745
  import { raise } from "@dxos/debug";
625
746
  import { getValue as getValue2 } from "@dxos/echo-schema";
626
747
  import { createJsonPath as createJsonPath2 } from "@dxos/effect";
@@ -840,7 +961,7 @@ import { getDXN } from "@dxos/echo-schema";
840
961
  import { Filter } from "@dxos/react-client/echo";
841
962
  import { isNonNullable } from "@dxos/util";
842
963
  var useRefQueryLookupHandler = ({ space }) => {
843
- const handleRefQueryLookup = useCallback5(async (typeInfo) => {
964
+ return useCallback5(async (typeInfo) => {
844
965
  if (!space) {
845
966
  return [];
846
967
  }
@@ -860,7 +981,6 @@ var useRefQueryLookupHandler = ({ space }) => {
860
981
  }, [
861
982
  space
862
983
  ]);
863
- return handleRefQueryLookup;
864
984
  };
865
985
 
866
986
  // packages/ui/react-ui-form/src/hooks/useQueryRefOptions.ts
@@ -938,12 +1058,10 @@ var useInputProps = (path = []) => {
938
1058
  ]);
939
1059
  };
940
1060
  var FormProvider = ({ children, formRef, autoSave, ...formOptions }) => {
941
- const form = useForm(formOptions);
942
- useEffect6(() => {
943
- if (!formRef?.current) {
944
- return;
945
- }
946
- const handleKeyDown = (event) => {
1061
+ var _effect = _useSignals8();
1062
+ try {
1063
+ const form = useForm(formOptions);
1064
+ const handleKeyDown = useCallback6((event) => {
947
1065
  const keyIsEnter = event.key === "Enter";
948
1066
  const modifierUsed = event.ctrlKey || event.altKey || event.metaKey || event.shiftKey;
949
1067
  const inputIsTextarea = event.target.tagName.toLowerCase() === "textarea";
@@ -958,64 +1076,77 @@ var FormProvider = ({ children, formRef, autoSave, ...formOptions }) => {
958
1076
  event.target.blur();
959
1077
  }
960
1078
  }
961
- };
962
- const formElement = formRef.current;
963
- formElement.addEventListener("keydown", handleKeyDown);
964
- return () => formElement.removeEventListener("keydown", handleKeyDown);
965
- }, [
966
- formRef,
967
- form.canSave,
968
- form.formIsValid,
969
- form.handleSave,
970
- autoSave
971
- ]);
972
- return /* @__PURE__ */ React8.createElement(FormContext.Provider, {
973
- value: form
974
- }, children);
1079
+ }, [
1080
+ form,
1081
+ autoSave
1082
+ ]);
1083
+ useEffect6(() => {
1084
+ if (!formRef?.current) {
1085
+ return;
1086
+ }
1087
+ const formElement = formRef.current;
1088
+ formElement.addEventListener("keydown", handleKeyDown);
1089
+ return () => formElement.removeEventListener("keydown", handleKeyDown);
1090
+ }, [
1091
+ formRef,
1092
+ form.canSave,
1093
+ form.formIsValid,
1094
+ form.handleSave,
1095
+ autoSave
1096
+ ]);
1097
+ return /* @__PURE__ */ React8.createElement(FormContext.Provider, {
1098
+ value: form
1099
+ }, children);
1100
+ } finally {
1101
+ _effect.f();
1102
+ }
975
1103
  };
976
1104
 
977
1105
  // packages/ui/react-ui-form/src/components/Form/FormActions.tsx
978
- var FormActions = ({ onCancel, readonly }) => {
979
- const { t } = useTranslation4(translationKey);
980
- const { canSave, handleSave } = useFormContext();
981
- return /* @__PURE__ */ React9.createElement("div", {
982
- role: "none",
983
- className: "mt-2 flex justify-center"
984
- }, /* @__PURE__ */ React9.createElement("div", {
985
- role: "none",
986
- className: mx5(onCancel && !readonly && "grid grid-cols-2 gap-2")
987
- }, onCancel && !readonly && /* @__PURE__ */ React9.createElement(IconButton2, {
988
- "data-testid": "cancel-button",
989
- icon: "ph--x--regular",
990
- label: t("button cancel"),
991
- onClick: onCancel
992
- }), handleSave && /* @__PURE__ */ React9.createElement(IconButton2, {
993
- type: "submit",
994
- "data-testid": "save-button",
995
- disabled: !canSave,
996
- icon: "ph--check--regular",
997
- label: t("button save"),
998
- onClick: handleSave
999
- })));
1106
+ var FormActions = ({ readonly, onCancel }) => {
1107
+ var _effect = _useSignals9();
1108
+ try {
1109
+ const { t } = useTranslation5(translationKey);
1110
+ const { canSave, handleSave } = useFormContext();
1111
+ return /* @__PURE__ */ React9.createElement("div", {
1112
+ role: "none",
1113
+ className: "flex [&_button]:grow gap-1"
1114
+ }, onCancel && !readonly && /* @__PURE__ */ React9.createElement(IconButton2, {
1115
+ "data-testid": "cancel-button",
1116
+ icon: "ph--x--regular",
1117
+ label: t("button cancel"),
1118
+ onClick: onCancel
1119
+ }), handleSave && /* @__PURE__ */ React9.createElement(IconButton2, {
1120
+ type: "submit",
1121
+ "data-testid": "save-button",
1122
+ disabled: !canSave,
1123
+ icon: "ph--check--regular",
1124
+ label: t("button save"),
1125
+ onClick: handleSave
1126
+ }));
1127
+ } finally {
1128
+ _effect.f();
1129
+ }
1000
1130
  };
1001
1131
 
1002
1132
  // packages/ui/react-ui-form/src/components/Form/FormContent.tsx
1133
+ import { useSignals as _useSignals12 } from "@preact-signals/safe-react/tracking";
1003
1134
  import { Schema, SchemaAST as SchemaAST4, pipe as pipe2 } from "effect";
1004
1135
  import { capitalize as capitalize2 } from "effect/String";
1005
1136
  import React12, { useMemo as useMemo5 } from "react";
1006
1137
  import { createJsonPath as createJsonPath3, findNode as findNode3, getDiscriminatedType as getDiscriminatedType2, isDiscriminatedUnion as isDiscriminatedUnion2 } from "@dxos/effect";
1007
- import { mx as mx7 } from "@dxos/react-ui-theme";
1138
+ import { mx as mx6 } from "@dxos/react-ui-theme";
1008
1139
  import { getSchemaProperties as getSchemaProperties2 } from "@dxos/schema";
1009
1140
  import { isNotFalsy } from "@dxos/util";
1010
1141
 
1011
1142
  // packages/ui/react-ui-form/src/components/Form/ArrayField.tsx
1143
+ import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
1012
1144
  import { SchemaAST as SchemaAST3, pipe } from "effect";
1013
1145
  import { capitalize } from "effect/String";
1014
- import React10, { useCallback as useCallback6 } from "react";
1146
+ import React10, { Fragment, useCallback as useCallback7 } from "react";
1015
1147
  import { findNode as findNode2, getDiscriminatedType, isDiscriminatedUnion, SimpleType } from "@dxos/effect";
1016
1148
  import { invariant as invariant2 } from "@dxos/invariant";
1017
- import { IconButton as IconButton3, useTranslation as useTranslation5 } from "@dxos/react-ui";
1018
- import { mx as mx6 } from "@dxos/react-ui-theme";
1149
+ import { IconButton as IconButton3, useTranslation as useTranslation6 } from "@dxos/react-ui";
1019
1150
  import { getSchemaProperties } from "@dxos/schema";
1020
1151
 
1021
1152
  // packages/ui/react-ui-form/src/util/field.ts
@@ -1327,238 +1458,262 @@ var getRefProps = (property) => {
1327
1458
 
1328
1459
  // packages/ui/react-ui-form/src/components/Form/ArrayField.tsx
1329
1460
  var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/Form/ArrayField.tsx";
1330
- var padding = "px-2";
1331
1461
  var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponent }) => {
1332
- const { t } = useTranslation5(translationKey);
1333
- const { ast, name, type, title } = property;
1334
- const values = useFormValues(path ?? []) ?? [];
1335
- invariant2(Array.isArray(values), `Values at path ${path?.join(".")} must be an array.`, {
1336
- F: __dxlog_file3,
1337
- L: 39,
1338
- S: void 0,
1339
- A: [
1340
- "Array.isArray(values)",
1341
- "`Values at path ${path?.join('.')} must be an array.`"
1342
- ]
1343
- });
1344
- const label = title ?? pipe(name, capitalize);
1345
- const elementType = findArrayElementType(ast);
1346
- const getDefaultObjectValue = (typeNode) => {
1347
- const baseNode = findNode2(typeNode, isDiscriminatedUnion);
1348
- const typeLiteral = baseNode ? getDiscriminatedType(baseNode, {}) : findNode2(typeNode, SchemaAST3.isTypeLiteral);
1349
- if (!typeLiteral) {
1350
- return {};
1351
- }
1352
- return Object.fromEntries(getSchemaProperties(typeLiteral, {}).map((prop) => [
1353
- prop.name,
1354
- prop.defaultValue
1355
- ]));
1356
- };
1357
- const getDefaultValue = () => type === "object" && elementType ? getDefaultObjectValue(elementType) : SimpleType.getDefaultValue(type);
1358
- const handleAdd = useCallback6(() => {
1359
- inputProps.onValueChange(type, [
1360
- ...values,
1361
- getDefaultValue()
1462
+ var _effect = _useSignals10();
1463
+ try {
1464
+ const { t } = useTranslation6(translationKey);
1465
+ const { ast, name, type, title } = property;
1466
+ const values = useFormValues(path ?? []) ?? [];
1467
+ invariant2(Array.isArray(values), `Values at path ${path?.join(".")} must be an array.`, {
1468
+ F: __dxlog_file3,
1469
+ L: 36,
1470
+ S: void 0,
1471
+ A: [
1472
+ "Array.isArray(values)",
1473
+ "`Values at path ${path?.join('.')} must be an array.`"
1474
+ ]
1475
+ });
1476
+ const label = title ?? pipe(name, capitalize);
1477
+ const elementType = findArrayElementType(ast);
1478
+ const getDefaultObjectValue = (typeNode) => {
1479
+ const baseNode = findNode2(typeNode, isDiscriminatedUnion);
1480
+ const typeLiteral = baseNode ? getDiscriminatedType(baseNode, {}) : findNode2(typeNode, SchemaAST3.isTypeLiteral);
1481
+ if (!typeLiteral) {
1482
+ return {};
1483
+ }
1484
+ return Object.fromEntries(getSchemaProperties(typeLiteral, {}).map((prop) => [
1485
+ prop.name,
1486
+ prop.defaultValue
1487
+ ]));
1488
+ };
1489
+ const getDefaultValue = () => type === "object" && elementType ? getDefaultObjectValue(elementType) : SimpleType.getDefaultValue(type);
1490
+ const handleAdd = useCallback7(() => {
1491
+ inputProps.onValueChange(type, [
1492
+ ...values,
1493
+ getDefaultValue()
1494
+ ]);
1495
+ }, [
1496
+ type,
1497
+ elementType,
1498
+ inputProps,
1499
+ values
1362
1500
  ]);
1363
- }, [
1364
- type,
1365
- elementType,
1366
- inputProps,
1367
- values
1368
- ]);
1369
- const handleRemove = useCallback6((index) => {
1370
- const newValues = values.filter((_, i) => i !== index);
1371
- inputProps.onValueChange(type, newValues);
1372
- }, [
1373
- type,
1374
- inputProps,
1375
- values
1376
- ]);
1377
- if (!elementType) {
1378
- return null;
1501
+ const handleRemove = useCallback7((index) => {
1502
+ const newValues = values.filter((_, i) => i !== index);
1503
+ inputProps.onValueChange(type, newValues);
1504
+ }, [
1505
+ type,
1506
+ inputProps,
1507
+ values
1508
+ ]);
1509
+ if (!elementType) {
1510
+ return null;
1511
+ }
1512
+ return readonly && values.length < 1 ? null : /* @__PURE__ */ React10.createElement(React10.Fragment, null, /* @__PURE__ */ React10.createElement(InputHeader, null, label), /* @__PURE__ */ React10.createElement("div", {
1513
+ role: "none",
1514
+ className: readonly ? "flex flex-wrap gap-1 mlb-1" : values.length > 0 ? "grid gap-1 grid-cols-[1fr_min-content] mlb-1" : "hidden"
1515
+ }, values.map((_value, index) => {
1516
+ const field = /* @__PURE__ */ React10.createElement(FormField, {
1517
+ property: {
1518
+ ...property,
1519
+ array: false,
1520
+ ast: elementType
1521
+ },
1522
+ path: [
1523
+ ...path ?? [],
1524
+ index
1525
+ ],
1526
+ readonly,
1527
+ inline: true,
1528
+ Custom,
1529
+ lookupComponent
1530
+ });
1531
+ return readonly ? field : /* @__PURE__ */ React10.createElement(Fragment, {
1532
+ key: index
1533
+ }, /* @__PURE__ */ React10.createElement("div", {
1534
+ role: "none"
1535
+ }, field), /* @__PURE__ */ React10.createElement(IconButton3, {
1536
+ icon: "ph--trash--regular",
1537
+ iconOnly: true,
1538
+ label: t("button remove"),
1539
+ onClick: () => handleRemove(index),
1540
+ classNames: "self-center"
1541
+ }));
1542
+ })), !readonly && /* @__PURE__ */ React10.createElement(IconButton3, {
1543
+ classNames: "is-full mlb-1 flex",
1544
+ icon: "ph--plus--regular",
1545
+ label: t("add field"),
1546
+ onClick: handleAdd
1547
+ }));
1548
+ } finally {
1549
+ _effect.f();
1379
1550
  }
1380
- return /* @__PURE__ */ React10.createElement("div", {
1381
- role: "none",
1382
- className: mx6(padding)
1383
- }, /* @__PURE__ */ React10.createElement(InputHeader, null, label), /* @__PURE__ */ React10.createElement("div", {
1384
- role: "none",
1385
- className: "flex flex-col gap-1"
1386
- }, values.map((_value, index) => /* @__PURE__ */ React10.createElement("div", {
1387
- key: index,
1388
- role: "none",
1389
- className: "flex items-center gap-1"
1390
- }, /* @__PURE__ */ React10.createElement("div", {
1391
- role: "none",
1392
- className: "flex-1"
1393
- }, /* @__PURE__ */ React10.createElement(FormField, {
1394
- property: {
1395
- ...property,
1396
- array: false,
1397
- ast: elementType
1398
- },
1399
- path: [
1400
- ...path ?? [],
1401
- index
1402
- ],
1403
- readonly,
1404
- inline: true,
1405
- Custom,
1406
- lookupComponent
1407
- })), /* @__PURE__ */ React10.createElement(IconButton3, {
1408
- icon: "ph--trash--regular",
1409
- iconOnly: true,
1410
- label: t("button remove"),
1411
- onClick: () => handleRemove(index)
1412
- })))), /* @__PURE__ */ React10.createElement("div", {
1413
- role: "none",
1414
- className: "flex justify-between items-center plb-1"
1415
- }, /* @__PURE__ */ React10.createElement(IconButton3, {
1416
- icon: "ph--plus--regular",
1417
- iconOnly: true,
1418
- label: t("button add"),
1419
- onClick: handleAdd
1420
- })));
1421
1551
  };
1422
1552
 
1423
1553
  // packages/ui/react-ui-form/src/components/Form/RefField.tsx
1424
- import React11, { useCallback as useCallback7, useMemo as useMemo4 } from "react";
1554
+ import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
1555
+ import React11, { useCallback as useCallback8, useMemo as useMemo4 } from "react";
1425
1556
  import { Expando, getTypeAnnotation, Ref, ReferenceAnnotationId as ReferenceAnnotationId2 } from "@dxos/echo-schema";
1426
1557
  import { findAnnotation as findAnnotation2 } from "@dxos/effect";
1427
1558
  import { DXN } from "@dxos/keys";
1428
- import { Input as Input7 } from "@dxos/react-ui";
1559
+ import { DxRefTag } from "@dxos/lit-ui/react";
1560
+ import { Input as Input7, useTranslation as useTranslation7 } from "@dxos/react-ui";
1429
1561
  import { TagPicker } from "@dxos/react-ui-tag-picker";
1562
+ import { descriptionText, mx as mx5 } from "@dxos/react-ui-theme";
1430
1563
  import { isNonNullable as isNonNullable2 } from "@dxos/util";
1431
1564
  var RefField = ({ type, label, disabled, placeholder, inputOnly, array, ast, getValue: getValue3, onBlur, onQueryRefOptions, onValueChange, ...restInputProps }) => {
1432
- const refTypeInfo = useMemo4(() => ast ? findAnnotation2(ast, ReferenceAnnotationId2) : void 0, [
1433
- ast
1434
- ]);
1435
- const { options: availableOptions, loading: _loading } = useQueryRefOptions({
1436
- refTypeInfo,
1437
- onQueryRefOptions
1438
- });
1439
- if (refTypeInfo && refTypeInfo?.typename === getTypeAnnotation(Expando)?.typename || !onQueryRefOptions) {
1440
- return /* @__PURE__ */ React11.createElement(RefFieldFallback, {
1441
- type,
1442
- label,
1443
- placeholder,
1444
- disabled,
1445
- inputOnly,
1446
- getValue: getValue3,
1447
- onBlur,
1448
- onValueChange,
1449
- ...restInputProps
1565
+ var _effect = _useSignals11();
1566
+ try {
1567
+ const { t } = useTranslation7(translationKey);
1568
+ const refTypeInfo = useMemo4(() => ast ? findAnnotation2(ast, ReferenceAnnotationId2) : void 0, [
1569
+ ast
1570
+ ]);
1571
+ const { options: availableOptions, loading: _loading } = useQueryRefOptions({
1572
+ refTypeInfo,
1573
+ onQueryRefOptions
1450
1574
  });
1451
- }
1452
- const handleGetValue = useCallback7(() => {
1453
- const formValue = getValue3();
1454
- const unknownToRefOption = (val) => {
1455
- if (Ref.isRef(val)) {
1456
- const dxnString = val.dxn.toString();
1457
- const matchingOption = availableOptions.find((option2) => option2.id === dxnString);
1458
- if (matchingOption) {
1459
- return matchingOption;
1575
+ if (refTypeInfo && refTypeInfo?.typename === getTypeAnnotation(Expando)?.typename || !onQueryRefOptions) {
1576
+ return /* @__PURE__ */ React11.createElement(RefFieldFallback, {
1577
+ type,
1578
+ label,
1579
+ placeholder,
1580
+ disabled,
1581
+ inputOnly,
1582
+ getValue: getValue3,
1583
+ onBlur,
1584
+ onValueChange,
1585
+ ...restInputProps
1586
+ });
1587
+ }
1588
+ const handleGetValue = useCallback8(() => {
1589
+ const formValue = getValue3();
1590
+ const unknownToRefOption = (val) => {
1591
+ if (Ref.isRef(val)) {
1592
+ const dxnString = val.dxn.toString();
1593
+ const matchingOption = availableOptions.find((option2) => option2.id === dxnString);
1594
+ if (matchingOption) {
1595
+ return matchingOption;
1596
+ }
1460
1597
  }
1598
+ return void 0;
1599
+ };
1600
+ if (array && Array.isArray(formValue)) {
1601
+ return formValue.map(unknownToRefOption).filter(isNonNullable2) ?? [];
1461
1602
  }
1462
- return void 0;
1463
- };
1464
- if (array && Array.isArray(formValue)) {
1465
- return formValue.map(unknownToRefOption).filter(isNonNullable2) ?? [];
1466
- }
1467
- const option = unknownToRefOption(formValue);
1468
- if (option) {
1469
- return [
1470
- option
1471
- ];
1472
- }
1473
- return [];
1474
- }, [
1475
- getValue3,
1476
- availableOptions,
1477
- array
1478
- ]);
1479
- const handleSearch = useCallback7((text, ids) => availableOptions.filter((option) => !ids.includes(option.id)).filter((option) => option.label.toLowerCase().includes(text.toLowerCase())).map((option) => ({
1480
- id: option.id,
1481
- label: option.label,
1482
- hue: option.hue
1483
- })), [
1484
- availableOptions
1485
- ]);
1486
- const handleUpdate = useCallback7((ids) => {
1487
- if (ids.length === 0) {
1488
- onValueChange("object", void 0);
1489
- return;
1490
- }
1491
- const refs = ids.map((id) => {
1492
- const item = availableOptions.find((option) => option.id === id);
1493
- if (item) {
1494
- const dxn = DXN.parse(item.id);
1495
- return Ref.fromDXN(dxn);
1603
+ const option = unknownToRefOption(formValue);
1604
+ if (option) {
1605
+ return [
1606
+ option
1607
+ ];
1496
1608
  }
1609
+ return [];
1610
+ }, [
1611
+ getValue3,
1612
+ availableOptions,
1613
+ array
1614
+ ]);
1615
+ const handleSearch = useCallback8((text, ids) => availableOptions.filter((option) => !ids.includes(option.id)).filter((option) => option.label.toLowerCase().includes(text.toLowerCase())).map((option) => ({
1616
+ id: option.id,
1617
+ label: option.label,
1618
+ hue: option.hue
1619
+ })), [
1620
+ availableOptions
1621
+ ]);
1622
+ const handleUpdate = useCallback8((ids) => {
1623
+ if (ids.length === 0) {
1624
+ onValueChange("object", void 0);
1625
+ return;
1626
+ }
1627
+ const refs = ids.map((id) => {
1628
+ const item = availableOptions.find((option) => option.id === id);
1629
+ if (item) {
1630
+ const dxn = DXN.parse(item.id);
1631
+ return Ref.fromDXN(dxn);
1632
+ }
1633
+ return null;
1634
+ }).filter(isNonNullable2);
1635
+ if (array) {
1636
+ onValueChange("object", refs);
1637
+ } else {
1638
+ onValueChange("object", refs[0]);
1639
+ }
1640
+ }, [
1641
+ availableOptions,
1642
+ array,
1643
+ onValueChange
1644
+ ]);
1645
+ const tagPickerMode = useMemo4(() => array ? "multi-select" : "single-select", [
1646
+ array
1647
+ ]);
1648
+ if (!refTypeInfo) {
1497
1649
  return null;
1498
- }).filter(isNonNullable2);
1499
- if (array) {
1500
- onValueChange("object", refs);
1501
- } else {
1502
- onValueChange("object", refs[0]);
1503
1650
  }
1504
- }, [
1505
- availableOptions,
1506
- array,
1507
- onValueChange
1508
- ]);
1509
- const tagPickerMode = useMemo4(() => array ? "multi-select" : "single-select", [
1510
- array
1511
- ]);
1512
- if (!refTypeInfo) {
1513
- return null;
1651
+ const { status, error } = restInputProps.getStatus();
1652
+ const items = handleGetValue();
1653
+ return disabled && items.length < 1 ? null : /* @__PURE__ */ React11.createElement(Input7.Root, {
1654
+ validationValence: status
1655
+ }, !inputOnly && /* @__PURE__ */ React11.createElement(InputHeader, {
1656
+ error
1657
+ }, /* @__PURE__ */ React11.createElement(Input7.Label, null, label)), /* @__PURE__ */ React11.createElement("div", {
1658
+ "data-no-submit": true
1659
+ }, disabled ? items.length < 1 ? /* @__PURE__ */ React11.createElement("p", {
1660
+ className: mx5(descriptionText, "mbe-2")
1661
+ }, t("empty readonly ref field label")) : items.map((item) => /* @__PURE__ */ React11.createElement(DxRefTag, {
1662
+ key: item.id,
1663
+ refid: item.id,
1664
+ rootclassname: "mie-1",
1665
+ style: {
1666
+ marginInlineEnd: ".25rem"
1667
+ }
1668
+ }, item.label)) : /* @__PURE__ */ React11.createElement(TagPicker, {
1669
+ readonly: disabled,
1670
+ items,
1671
+ mode: tagPickerMode,
1672
+ onBlur: (event) => onBlur(event),
1673
+ onUpdate: handleUpdate,
1674
+ onSearch: handleSearch,
1675
+ classNames: "rounded-sm bg-inputSurface p-1.5"
1676
+ })), inputOnly && /* @__PURE__ */ React11.createElement(Input7.DescriptionAndValidation, null, error));
1677
+ } finally {
1678
+ _effect.f();
1514
1679
  }
1515
- const { status, error } = restInputProps.getStatus();
1516
- return /* @__PURE__ */ React11.createElement(Input7.Root, {
1517
- validationValence: status
1518
- }, !inputOnly && /* @__PURE__ */ React11.createElement(InputHeader, {
1519
- error
1520
- }, /* @__PURE__ */ React11.createElement(Input7.Label, null, label)), /* @__PURE__ */ React11.createElement("div", {
1521
- "data-no-submit": true
1522
- }, /* @__PURE__ */ React11.createElement(TagPicker, {
1523
- items: handleGetValue(),
1524
- mode: tagPickerMode,
1525
- onBlur: (event) => onBlur(event),
1526
- onUpdate: handleUpdate,
1527
- onSearch: handleSearch,
1528
- classNames: "rounded-sm bg-input p-1.5"
1529
- })), inputOnly && /* @__PURE__ */ React11.createElement(Input7.DescriptionAndValidation, null, error));
1530
1680
  };
1531
1681
  var RefFieldFallback = ({ type, label, disabled, placeholder, inputOnly, getValue: getValue3, onValueChange, ...restInputProps }) => {
1532
- const handleOnValueChange = (_type, dxnString) => {
1533
- const dxn = DXN.tryParse(dxnString);
1534
- if (dxn) {
1535
- onValueChange?.("object", Ref.fromDXN(dxn));
1536
- } else if (dxnString === "") {
1537
- onValueChange?.("object", void 0);
1538
- } else {
1539
- onValueChange?.("string", dxnString);
1540
- }
1541
- };
1542
- const handleGetValue = () => {
1543
- const formValue = getValue3();
1544
- if (typeof formValue === "string") {
1545
- return formValue;
1546
- }
1547
- if (Ref.isRef(formValue)) {
1548
- return formValue.dxn.toString();
1549
- }
1550
- return void 0;
1551
- };
1552
- return /* @__PURE__ */ React11.createElement(TextInput, {
1553
- type,
1554
- label,
1555
- disabled,
1556
- placeholder,
1557
- inputOnly,
1558
- getValue: handleGetValue,
1559
- onValueChange: handleOnValueChange,
1560
- ...restInputProps
1561
- });
1682
+ var _effect = _useSignals11();
1683
+ try {
1684
+ const handleOnValueChange = (_type, dxnString) => {
1685
+ const dxn = DXN.tryParse(dxnString);
1686
+ if (dxn) {
1687
+ onValueChange?.("object", Ref.fromDXN(dxn));
1688
+ } else if (dxnString === "") {
1689
+ onValueChange?.("object", void 0);
1690
+ } else {
1691
+ onValueChange?.("string", dxnString);
1692
+ }
1693
+ };
1694
+ const handleGetValue = () => {
1695
+ const formValue = getValue3();
1696
+ if (typeof formValue === "string") {
1697
+ return formValue;
1698
+ }
1699
+ if (Ref.isRef(formValue)) {
1700
+ return formValue.dxn.toString();
1701
+ }
1702
+ return void 0;
1703
+ };
1704
+ return /* @__PURE__ */ React11.createElement(TextInput, {
1705
+ type,
1706
+ label,
1707
+ disabled,
1708
+ placeholder,
1709
+ inputOnly,
1710
+ getValue: handleGetValue,
1711
+ onValueChange: handleOnValueChange,
1712
+ ...restInputProps
1713
+ });
1714
+ } finally {
1715
+ _effect.f();
1716
+ }
1562
1717
  };
1563
1718
 
1564
1719
  // packages/ui/react-ui-form/src/components/Form/factory.tsx
@@ -1582,570 +1737,615 @@ var getInputComponent = (type, format) => {
1582
1737
 
1583
1738
  // packages/ui/react-ui-form/src/components/Form/FormContent.tsx
1584
1739
  var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupComponent, Custom }) => {
1585
- const inputProps = useInputProps(path);
1586
- const { ast, name, type, format, title, description, options, examples, array } = property;
1587
- const label = useMemo5(() => title ?? pipe2(name, capitalize2), [
1588
- title,
1589
- name
1590
- ]);
1591
- const placeholder = useMemo5(() => examples?.length ? `Example: "${examples[0]}"` : description, [
1592
- examples,
1593
- description
1594
- ]);
1595
- const FoundComponent = lookupComponent?.({
1596
- prop: name,
1597
- schema: Schema.make(ast),
1598
- inputProps: {
1599
- type,
1600
- format,
1601
- label,
1602
- disabled: readonly,
1603
- placeholder,
1604
- ...inputProps
1605
- }
1606
- });
1607
- if (FoundComponent) {
1608
- return /* @__PURE__ */ React12.createElement("div", {
1609
- role: "none"
1610
- }, FoundComponent);
1611
- }
1612
- const jsonPath = createJsonPath3(path ?? []);
1613
- const CustomComponent = Custom?.[jsonPath];
1614
- if (CustomComponent) {
1615
- return /* @__PURE__ */ React12.createElement(CustomComponent, {
1616
- type,
1617
- format,
1618
- label,
1619
- inputOnly: inline,
1620
- placeholder,
1621
- disabled: readonly,
1622
- ...inputProps
1623
- });
1624
- }
1625
- const refProps = getRefProps(property);
1626
- if (refProps) {
1627
- return /* @__PURE__ */ React12.createElement(RefField, {
1628
- ast: refProps.ast,
1629
- array: refProps.isArray,
1630
- type,
1631
- format,
1632
- label,
1633
- placeholder,
1634
- disabled: readonly,
1635
- inputOnly: inline,
1636
- onQueryRefOptions,
1637
- ...inputProps
1638
- });
1639
- }
1640
- if (array) {
1641
- return /* @__PURE__ */ React12.createElement(ArrayField, {
1642
- property,
1643
- path,
1644
- inputProps,
1645
- readonly,
1646
- Custom
1740
+ var _effect = _useSignals12();
1741
+ try {
1742
+ const inputProps = useInputProps(path);
1743
+ const { ast, name, type, format, title, description, options, examples, array } = property;
1744
+ const label = useMemo5(() => title ?? pipe2(name, capitalize2), [
1745
+ title,
1746
+ name
1747
+ ]);
1748
+ const placeholder = useMemo5(() => examples?.length ? `Example: "${examples[0]}"` : description, [
1749
+ examples,
1750
+ description
1751
+ ]);
1752
+ const FoundComponent = lookupComponent?.({
1753
+ prop: name,
1754
+ schema: Schema.make(ast),
1755
+ inputProps: {
1756
+ type,
1757
+ format,
1758
+ label,
1759
+ disabled: readonly,
1760
+ placeholder,
1761
+ ...inputProps
1762
+ }
1647
1763
  });
1648
- }
1649
- const InputComponent = getInputComponent(type, format);
1650
- if (InputComponent) {
1651
- return /* @__PURE__ */ React12.createElement("div", {
1652
- role: "none"
1653
- }, /* @__PURE__ */ React12.createElement(InputComponent, {
1654
- type,
1655
- format,
1656
- label,
1657
- inputOnly: inline,
1658
- placeholder,
1659
- disabled: readonly,
1660
- ...inputProps
1661
- }));
1662
- }
1663
- if (options) {
1664
- return /* @__PURE__ */ React12.createElement("div", {
1665
- role: "none"
1666
- }, /* @__PURE__ */ React12.createElement(SelectInput, {
1667
- type,
1668
- format,
1669
- disabled: readonly,
1670
- inputOnly: inline,
1671
- label,
1672
- options: options.map((option) => ({
1673
- value: option,
1674
- label: String(option)
1675
- })),
1676
- placeholder,
1677
- ...inputProps
1678
- }));
1679
- }
1680
- if (type === "object") {
1681
- const baseNode = findNode3(ast, isDiscriminatedUnion2);
1682
- const typeLiteral = baseNode ? getDiscriminatedType2(baseNode, inputProps.getValue()) : findNode3(ast, SchemaAST4.isTypeLiteral);
1683
- if (typeLiteral) {
1684
- return /* @__PURE__ */ React12.createElement("div", {
1685
- role: "none"
1686
- }, !inline && /* @__PURE__ */ React12.createElement("h3", {
1687
- className: "text-lg mbs-2 mbe-1"
1688
- }, label), /* @__PURE__ */ React12.createElement(FormFields, {
1689
- schema: Schema.make(typeLiteral),
1764
+ if (FoundComponent) {
1765
+ return FoundComponent;
1766
+ }
1767
+ const jsonPath = createJsonPath3(path ?? []);
1768
+ const CustomComponent = Custom?.[jsonPath];
1769
+ if (CustomComponent) {
1770
+ return /* @__PURE__ */ React12.createElement(CustomComponent, {
1771
+ type,
1772
+ format,
1773
+ label,
1774
+ inputOnly: inline,
1775
+ placeholder,
1776
+ disabled: readonly,
1777
+ ...inputProps
1778
+ });
1779
+ }
1780
+ const refProps = getRefProps(property);
1781
+ if (refProps) {
1782
+ return /* @__PURE__ */ React12.createElement(RefField, {
1783
+ ast: refProps.ast,
1784
+ array: refProps.isArray,
1785
+ type,
1786
+ format,
1787
+ label,
1788
+ placeholder,
1789
+ disabled: readonly,
1790
+ inputOnly: inline,
1791
+ onQueryRefOptions,
1792
+ ...inputProps
1793
+ });
1794
+ }
1795
+ if (array) {
1796
+ return /* @__PURE__ */ React12.createElement(ArrayField, {
1797
+ property,
1690
1798
  path,
1799
+ inputProps,
1691
1800
  readonly,
1692
- onQueryRefOptions,
1693
- Custom,
1694
- lookupComponent
1695
- }));
1801
+ Custom
1802
+ });
1803
+ }
1804
+ const InputComponent = getInputComponent(type, format);
1805
+ if (InputComponent) {
1806
+ return /* @__PURE__ */ React12.createElement(InputComponent, {
1807
+ type,
1808
+ format,
1809
+ label,
1810
+ inputOnly: inline,
1811
+ placeholder,
1812
+ disabled: readonly,
1813
+ ...inputProps
1814
+ });
1696
1815
  }
1816
+ if (options) {
1817
+ return /* @__PURE__ */ React12.createElement(SelectInput, {
1818
+ type,
1819
+ format,
1820
+ disabled: readonly,
1821
+ inputOnly: inline,
1822
+ label,
1823
+ options: options.map((option) => ({
1824
+ value: option,
1825
+ label: String(option)
1826
+ })),
1827
+ placeholder,
1828
+ ...inputProps
1829
+ });
1830
+ }
1831
+ if (type === "object") {
1832
+ const baseNode = findNode3(ast, isDiscriminatedUnion2);
1833
+ const typeLiteral = baseNode ? getDiscriminatedType2(baseNode, inputProps.getValue()) : findNode3(ast, SchemaAST4.isTypeLiteral);
1834
+ if (typeLiteral) {
1835
+ return /* @__PURE__ */ React12.createElement(React12.Fragment, null, !inline && /* @__PURE__ */ React12.createElement("h3", {
1836
+ className: "text-lg mbs-2 mbe-1 first:mbs-0"
1837
+ }, label), /* @__PURE__ */ React12.createElement(FormFields, {
1838
+ schema: Schema.make(typeLiteral),
1839
+ path,
1840
+ readonly,
1841
+ onQueryRefOptions,
1842
+ Custom,
1843
+ lookupComponent
1844
+ }));
1845
+ }
1846
+ }
1847
+ return null;
1848
+ } finally {
1849
+ _effect.f();
1697
1850
  }
1698
- return null;
1699
1851
  };
1700
- var FormFields = ({ schema, path, filter, sort, readonly, onQueryRefOptions, lookupComponent, Custom }) => {
1701
- const values = useFormValues(path);
1702
- const properties = useMemo5(() => {
1703
- const props = getSchemaProperties2(schema.ast, values);
1704
- const filtered = filter ? filter(props) : props;
1705
- return sort ? filtered.sort((a, b) => sort.indexOf(a.name) - sort.indexOf(b.name)) : filtered;
1706
- }, [
1707
- schema,
1708
- values,
1709
- filter,
1710
- sort
1711
- ]);
1712
- return /* @__PURE__ */ React12.createElement("div", {
1713
- role: "form",
1714
- className: mx7("flex flex-col w-full gap-2")
1715
- }, properties.map((property) => {
1716
- return /* @__PURE__ */ React12.createElement(FormField, {
1717
- key: property.name,
1718
- property,
1719
- path: [
1720
- ...path ?? [],
1721
- property.name
1722
- ],
1723
- readonly,
1724
- onQueryRefOptions,
1725
- lookupComponent,
1726
- Custom
1727
- });
1728
- }).filter(isNotFalsy));
1852
+ var FormFields = ({ classNames, Custom, schema, path, filter, sort, readonly, lookupComponent, onQueryRefOptions }) => {
1853
+ var _effect = _useSignals12();
1854
+ try {
1855
+ const values = useFormValues(path);
1856
+ const properties = useMemo5(() => {
1857
+ const props = getSchemaProperties2(schema.ast, values);
1858
+ const filtered = filter ? filter(props) : props;
1859
+ return sort ? filtered.sort((a, b) => sort.indexOf(a.name) - sort.indexOf(b.name)) : filtered;
1860
+ }, [
1861
+ schema,
1862
+ values,
1863
+ filter,
1864
+ sort
1865
+ ]);
1866
+ return (
1867
+ // TODO(burdon): Consistent padding (with composite forms).
1868
+ /* @__PURE__ */ React12.createElement("div", {
1869
+ role: "form",
1870
+ className: mx6("p-2 is-full", classNames)
1871
+ }, properties.map((property) => {
1872
+ return /* @__PURE__ */ React12.createElement(FormField, {
1873
+ key: property.name,
1874
+ property,
1875
+ path: [
1876
+ ...path ?? [],
1877
+ property.name
1878
+ ],
1879
+ readonly,
1880
+ onQueryRefOptions,
1881
+ lookupComponent,
1882
+ Custom
1883
+ });
1884
+ }).filter(isNotFalsy))
1885
+ );
1886
+ } finally {
1887
+ _effect.f();
1888
+ }
1729
1889
  };
1730
1890
 
1731
1891
  // packages/ui/react-ui-form/src/components/Form/Form.tsx
1732
1892
  var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, readonly, filter, sort, autoSave, testId, onValuesChanged, onValidate, onSave, onCancel, onQueryRefOptions, lookupComponent, Custom }) => {
1733
- const formRef = useRef3(null);
1734
- const onValid = useMemo6(() => autoSave ? onSave : void 0, [
1735
- autoSave,
1736
- onSave
1737
- ]);
1738
- useEffect7(() => {
1739
- if (autoFocus && formRef.current) {
1740
- const input = formRef.current.querySelector("input");
1741
- if (input) {
1742
- input.focus();
1893
+ var _effect = _useSignals13();
1894
+ try {
1895
+ const formRef = useRef3(null);
1896
+ const onValid = useMemo6(() => autoSave ? onSave : void 0, [
1897
+ autoSave,
1898
+ onSave
1899
+ ]);
1900
+ useEffect7(() => {
1901
+ if (autoFocus && formRef.current) {
1902
+ const input = formRef.current.querySelector("input");
1903
+ if (input) {
1904
+ input.focus();
1905
+ }
1743
1906
  }
1744
- }
1745
- }, [
1746
- autoFocus
1747
- ]);
1748
- return /* @__PURE__ */ React13.createElement(FormProvider, {
1749
- formRef,
1750
- schema,
1751
- autoSave,
1752
- initialValues,
1753
- onValuesChanged,
1754
- onValidate,
1755
- onValid,
1756
- onSave
1757
- }, /* @__PURE__ */ React13.createElement("div", {
1758
- ref: formRef,
1759
- role: "none",
1760
- className: mx8("p-2", classNames),
1761
- "data-testid": testId
1762
- }, /* @__PURE__ */ React13.createElement(FormFields, {
1763
- schema,
1764
- path,
1765
- readonly,
1766
- filter,
1767
- sort,
1768
- onQueryRefOptions,
1769
- lookupComponent,
1770
- Custom
1771
- }), (onCancel || onSave) && !autoSave && /* @__PURE__ */ React13.createElement(FormActions, {
1772
- onCancel,
1773
- readonly
1774
- })));
1907
+ }, [
1908
+ autoFocus
1909
+ ]);
1910
+ return /* @__PURE__ */ React13.createElement(FormProvider, {
1911
+ formRef,
1912
+ schema,
1913
+ autoSave,
1914
+ initialValues,
1915
+ onValuesChanged,
1916
+ onValidate,
1917
+ onValid,
1918
+ onSave
1919
+ }, /* @__PURE__ */ React13.createElement("div", {
1920
+ ref: formRef,
1921
+ role: "none",
1922
+ className: mx7("flex flex-col gap-4", classNames),
1923
+ "data-testid": testId
1924
+ }, /* @__PURE__ */ React13.createElement(FormFields, {
1925
+ schema,
1926
+ path,
1927
+ readonly,
1928
+ filter,
1929
+ sort,
1930
+ onQueryRefOptions,
1931
+ lookupComponent,
1932
+ Custom
1933
+ }), (onCancel || onSave) && !autoSave && /* @__PURE__ */ React13.createElement(FormActions, {
1934
+ onCancel,
1935
+ readonly
1936
+ })));
1937
+ } finally {
1938
+ _effect.f();
1939
+ }
1775
1940
  };
1776
1941
 
1777
1942
  // packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx
1778
1943
  var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx";
1779
1944
  var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
1780
- const { t } = useTranslation6(translationKey);
1781
- const [props, setProps] = useState5(projection.getFieldProjection(field.id).props);
1782
- useEffect8(() => setProps(projection.getFieldProjection(field.id).props), [
1783
- field,
1784
- projection
1785
- ]);
1786
- const [schemas, setSchemas] = useState5([]);
1787
- useEffect8(() => {
1788
- if (!registry) {
1789
- return;
1790
- }
1791
- const subscription = registry.query().subscribe((query) => setSchemas(query.results), {
1792
- fire: true
1793
- });
1794
- const t2 = setTimeout(async () => {
1795
- const schemas2 = await registry.query().run();
1796
- setSchemas(schemas2);
1797
- });
1798
- return () => {
1799
- clearTimeout(t2);
1800
- subscription?.();
1801
- };
1802
- }, [
1803
- registry
1804
- ]);
1805
- const [referenceSchema, setReferenceSchema] = useState5();
1806
- useEffect8(() => {
1807
- setReferenceSchema(schemas.find((schema) => schema.typename === props?.referenceSchema));
1808
- }, [
1809
- schemas,
1810
- props?.referenceSchema
1811
- ]);
1812
- const [{ fieldSchema }, setFieldSchema] = useState5({
1813
- fieldSchema: getFormatSchema(props?.format)
1814
- });
1815
- const handleValuesChanged = useCallback8((_props) => {
1816
- setFieldSchema((prev) => {
1817
- const fieldSchema2 = getFormatSchema(_props.format);
1818
- if (prev.fieldSchema === fieldSchema2) {
1819
- return prev;
1945
+ var _effect = _useSignals14();
1946
+ try {
1947
+ const { t } = useTranslation8(translationKey);
1948
+ const [props, setProps] = useState5(projection.getFieldProjection(field.id).props);
1949
+ useEffect8(() => setProps(projection.getFieldProjection(field.id).props), [
1950
+ field,
1951
+ projection
1952
+ ]);
1953
+ const [schemas, setSchemas] = useState5([]);
1954
+ useEffect8(() => {
1955
+ if (!registry) {
1956
+ return;
1820
1957
  }
1821
- return {
1822
- fieldSchema: fieldSchema2
1958
+ const subscription = registry.query().subscribe((query) => setSchemas(query.results), {
1959
+ fire: true
1960
+ });
1961
+ const t2 = setTimeout(async () => {
1962
+ const schemas2 = await registry.query().run();
1963
+ setSchemas(schemas2);
1964
+ });
1965
+ return () => {
1966
+ clearTimeout(t2);
1967
+ subscription?.();
1823
1968
  };
1969
+ }, [
1970
+ registry
1971
+ ]);
1972
+ const [referenceSchema, setReferenceSchema] = useState5();
1973
+ useEffect8(() => {
1974
+ setReferenceSchema(schemas.find((schema) => schema.typename === props?.referenceSchema));
1975
+ }, [
1976
+ schemas,
1977
+ props?.referenceSchema
1978
+ ]);
1979
+ const [{ fieldSchema }, setFieldSchema] = useState5({
1980
+ fieldSchema: getFormatSchema(props?.format)
1824
1981
  });
1825
- setReferenceSchema((prev) => {
1826
- if (_props.referenceSchema !== prev?.typename) {
1827
- const newSchema = schemas.find((schema) => schema.typename === _props.referenceSchema);
1828
- if (newSchema) {
1829
- return newSchema;
1982
+ const handleValuesChanged = useCallback9((_props) => {
1983
+ setFieldSchema((prev) => {
1984
+ const fieldSchema2 = getFormatSchema(_props.format);
1985
+ if (prev.fieldSchema === fieldSchema2) {
1986
+ return prev;
1830
1987
  }
1831
- }
1832
- return prev;
1833
- });
1834
- setProps((props2) => {
1835
- const type = formatToType[_props.format];
1836
- if (props2.type !== type) {
1837
1988
  return {
1838
- ...props2,
1839
- ..._props,
1840
- type
1989
+ fieldSchema: fieldSchema2
1841
1990
  };
1842
- }
1843
- return _props;
1844
- });
1845
- }, [
1846
- schemas,
1847
- props.format,
1848
- props.referenceSchema
1849
- ]);
1850
- const handleValidate = useCallback8(({ property }) => {
1851
- if (property && view.fields.find((f) => f.path === property && f.path !== field.path)) {
1852
- return [
1853
- {
1854
- path: "property",
1855
- message: `property is not unique: '${property}'`
1991
+ });
1992
+ setReferenceSchema((prev) => {
1993
+ if (_props.referenceSchema !== prev?.typename) {
1994
+ const newSchema = schemas.find((schema) => schema.typename === _props.referenceSchema);
1995
+ if (newSchema) {
1996
+ return newSchema;
1997
+ }
1856
1998
  }
1857
- ];
1858
- }
1859
- }, [
1860
- view.fields,
1861
- field
1862
- ]);
1863
- const handleSave = useCallback8((props2) => {
1864
- projection.setFieldProjection({
1999
+ return prev;
2000
+ });
2001
+ setProps((props2) => {
2002
+ const type = formatToType[_props.format];
2003
+ if (props2.type !== type) {
2004
+ return {
2005
+ ...props2,
2006
+ ..._props,
2007
+ type
2008
+ };
2009
+ }
2010
+ return _props;
2011
+ });
2012
+ }, [
2013
+ schemas,
2014
+ props.format,
2015
+ props.referenceSchema
2016
+ ]);
2017
+ const handleValidate = useCallback9(({ property }) => {
2018
+ if (property && view.fields.find((f) => f.path === property && f.path !== field.path)) {
2019
+ return [
2020
+ {
2021
+ path: "property",
2022
+ message: `property is not unique: '${property}'`
2023
+ }
2024
+ ];
2025
+ }
2026
+ }, [
2027
+ view.fields,
2028
+ field
2029
+ ]);
2030
+ const handleSave = useCallback9((props2) => {
2031
+ projection.setFieldProjection({
2032
+ field,
2033
+ props: props2
2034
+ });
2035
+ onSave();
2036
+ }, [
2037
+ projection,
1865
2038
  field,
1866
- props: props2
1867
- });
1868
- onSave();
1869
- }, [
1870
- projection,
1871
- field,
1872
- onSave
1873
- ]);
1874
- const handleCancel = useCallback8(() => {
1875
- requestAnimationFrame(() => onCancel?.());
1876
- onSave();
1877
- }, [
1878
- onSave
1879
- ]);
1880
- const Custom = useMemo7(() => ({
1881
- ["format"]: (props2) => /* @__PURE__ */ React14.createElement(SelectInput, {
1882
- ...props2,
1883
- options: FormatEnums.filter((value) => value !== FormatEnum5.None).map((value) => ({
1884
- value,
1885
- label: t(`format ${value}`)
1886
- }))
1887
- }),
1888
- ["referenceSchema"]: (props2) => /* @__PURE__ */ React14.createElement(SelectInput, {
1889
- ...props2,
1890
- options: schemas.map((schema) => ({
1891
- value: schema.typename
1892
- }))
1893
- }),
1894
- ["referencePath"]: (props2) => /* @__PURE__ */ React14.createElement(SelectInput, {
1895
- ...props2,
1896
- options: referenceSchema ? getSchemaProperties3(referenceSchema.ast).sort(sortProperties).map((p) => ({
1897
- value: p.name
1898
- })) : []
1899
- }),
1900
- ["options"]: (props2) => /* @__PURE__ */ React14.createElement(SelectOptionInput, props2)
1901
- }), [
1902
- t,
1903
- schemas,
1904
- referenceSchema
1905
- ]);
1906
- const propIsNotType = useCallback8((props2) => props2.filter((p) => p.name !== "type"), []);
1907
- if (!fieldSchema) {
1908
- log3.warn("invalid format", {
1909
- props
1910
- }, {
1911
- F: __dxlog_file4,
1912
- L: 174,
1913
- S: void 0,
1914
- C: (f, a) => f(...a)
2039
+ onSave
2040
+ ]);
2041
+ const handleCancel = useCallback9(() => {
2042
+ requestAnimationFrame(() => onCancel?.());
2043
+ onSave();
2044
+ }, [
2045
+ onSave
2046
+ ]);
2047
+ const custom = useMemo7(() => ({
2048
+ ["format"]: (props2) => /* @__PURE__ */ React14.createElement(SelectInput, {
2049
+ ...props2,
2050
+ options: FormatEnums.filter((value) => value !== FormatEnum5.None).map((value) => ({
2051
+ value,
2052
+ label: t(`format ${value}`)
2053
+ }))
2054
+ }),
2055
+ ["referenceSchema"]: (props2) => /* @__PURE__ */ React14.createElement(SelectInput, {
2056
+ ...props2,
2057
+ options: schemas.map((schema) => ({
2058
+ value: schema.typename
2059
+ }))
2060
+ }),
2061
+ ["referencePath"]: (props2) => /* @__PURE__ */ React14.createElement(SelectInput, {
2062
+ ...props2,
2063
+ options: referenceSchema ? getSchemaProperties3(referenceSchema.ast).sort(sortProperties).map((p) => ({
2064
+ value: p.name
2065
+ })) : []
2066
+ }),
2067
+ ["options"]: (props2) => /* @__PURE__ */ React14.createElement(SelectOptionInput, props2)
2068
+ }), [
2069
+ t,
2070
+ schemas,
2071
+ referenceSchema
2072
+ ]);
2073
+ const propIsNotType = useCallback9((props2) => props2.filter((p) => p.name !== "type"), []);
2074
+ if (!fieldSchema) {
2075
+ log3.warn("invalid format", {
2076
+ props
2077
+ }, {
2078
+ F: __dxlog_file4,
2079
+ L: 175,
2080
+ S: void 0,
2081
+ C: (f, a) => f(...a)
2082
+ });
2083
+ return null;
2084
+ }
2085
+ return /* @__PURE__ */ React14.createElement(Form, {
2086
+ key: field.id,
2087
+ autoFocus: true,
2088
+ values: props,
2089
+ schema: fieldSchema,
2090
+ filter: propIsNotType,
2091
+ sort: [
2092
+ "property",
2093
+ "format"
2094
+ ],
2095
+ onValuesChanged: handleValuesChanged,
2096
+ onValidate: handleValidate,
2097
+ onSave: handleSave,
2098
+ onCancel: handleCancel,
2099
+ Custom: custom
1915
2100
  });
1916
- return null;
2101
+ } finally {
2102
+ _effect.f();
1917
2103
  }
1918
- return /* @__PURE__ */ React14.createElement(Form, {
1919
- key: field.id,
1920
- autoFocus: true,
1921
- values: props,
1922
- schema: fieldSchema,
1923
- filter: propIsNotType,
1924
- sort: [
1925
- "property",
1926
- "format"
1927
- ],
1928
- onValuesChanged: handleValuesChanged,
1929
- onValidate: handleValidate,
1930
- onSave: handleSave,
1931
- onCancel: handleCancel,
1932
- Custom
1933
- });
1934
2104
  };
1935
2105
 
1936
2106
  // packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx
1937
- import { Schema as Schema2, SchemaAST as SchemaAST5 } from "effect";
1938
- import React15, { useCallback as useCallback9, useMemo as useMemo8, useState as useState6 } from "react";
1939
- import { Format, isMutable, toJsonSchema } from "@dxos/echo-schema";
2107
+ import { useSignals as _useSignals15 } from "@preact-signals/safe-react/tracking";
2108
+ import { Schema as Schema2 } from "effect";
2109
+ import React15, { useCallback as useCallback10, useMemo as useMemo8, useState as useState6 } from "react";
2110
+ import { EchoSchema, Format, isMutable, toJsonSchema } from "@dxos/echo-schema";
1940
2111
  import { invariant as invariant3 } from "@dxos/invariant";
1941
- import { IconButton as IconButton4, useTranslation as useTranslation7 } from "@dxos/react-ui";
2112
+ import { Icon as Icon3, IconButton as IconButton4, Message, useTranslation as useTranslation9 } from "@dxos/react-ui";
1942
2113
  import { List as List2 } from "@dxos/react-ui-list";
1943
- import { ghostHover, inputTextLabel, mx as mx9 } from "@dxos/react-ui-theme";
2114
+ import { ghostHover, inputTextLabel, mx as mx8 } from "@dxos/react-ui-theme";
1944
2115
  import { FieldSchema, ViewProjection, VIEW_FIELD_LIMIT } from "@dxos/schema";
1945
2116
  var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx";
1946
2117
  var grid = "grid grid-cols-[32px_1fr_32px] min-bs-[2.5rem]";
1947
2118
  var ViewMetaSchema = Schema2.Struct({
1948
2119
  name: Schema2.String.annotations({
1949
- [SchemaAST5.TitleAnnotationId]: "View"
2120
+ title: "View"
1950
2121
  }),
1951
2122
  typename: Format.URL.annotations({
1952
- [SchemaAST5.TitleAnnotationId]: "Typename"
2123
+ title: "Typename"
1953
2124
  })
1954
2125
  }).pipe(Schema2.mutable);
1955
2126
  var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading = false, onTypenameChanged, onDelete }) => {
1956
- const { t } = useTranslation7(translationKey);
1957
- const projection = useMemo8(() => new ViewProjection(toJsonSchema(schema), view), [
1958
- schema,
1959
- view
1960
- ]);
1961
- const [field, setField] = useState6();
1962
- const immutable = readonly || !isMutable(schema);
1963
- const viewValues = useMemo8(() => {
1964
- return {
1965
- name: view.name,
1966
- // TODO(burdon): Need to warn user of possible consequences of editing.
1967
- // TODO(burdon): Settings should have domain name owned by user.
1968
- typename: view.query.typename
1969
- };
1970
- }, [
1971
- view
1972
- ]);
1973
- const handleSelect = useCallback9((field2) => {
1974
- setField((f) => f === field2 ? void 0 : field2);
1975
- }, []);
1976
- const handleAdd = useCallback9(() => {
1977
- invariant3(!immutable, void 0, {
1978
- F: __dxlog_file5,
1979
- L: 78,
1980
- S: void 0,
1981
- A: [
1982
- "!immutable",
1983
- ""
1984
- ]
1985
- });
1986
- const field2 = projection.createFieldProjection();
1987
- setField(field2);
1988
- }, [
1989
- schema,
1990
- view
1991
- ]);
1992
- const handleUpdate = useCallback9(({ name, typename }) => {
1993
- invariant3(!immutable, void 0, {
1994
- F: __dxlog_file5,
1995
- L: 85,
1996
- S: void 0,
1997
- A: [
1998
- "!immutable",
1999
- ""
2000
- ]
2001
- });
2002
- requestAnimationFrame(() => {
2003
- if (view.name !== name) {
2004
- view.name = name;
2127
+ var _effect = _useSignals15();
2128
+ try {
2129
+ const { t } = useTranslation9(translationKey);
2130
+ const projection = useMemo8(() => {
2131
+ const jsonSchema = schema instanceof EchoSchema ? schema.jsonSchema : toJsonSchema(schema);
2132
+ return new ViewProjection(jsonSchema, view);
2133
+ }, [
2134
+ schema,
2135
+ view
2136
+ ]);
2137
+ const [field, setField] = useState6();
2138
+ const immutable = readonly || !isMutable(schema);
2139
+ const viewValues = useMemo8(() => {
2140
+ return {
2141
+ name: view.name,
2142
+ // TODO(burdon): Need to warn user of possible consequences of editing.
2143
+ // TODO(burdon): Settings should have domain name owned by user.
2144
+ typename: view.query.typename
2145
+ };
2146
+ }, [
2147
+ view
2148
+ ]);
2149
+ const handleSelect = useCallback10((field2) => {
2150
+ if (immutable) {
2151
+ return;
2005
2152
  }
2006
- if (view.query.typename !== typename) {
2007
- onTypenameChanged?.(typename);
2153
+ setField((f) => f === field2 ? void 0 : field2);
2154
+ }, [
2155
+ immutable
2156
+ ]);
2157
+ const handleAdd = useCallback10(() => {
2158
+ invariant3(!immutable, void 0, {
2159
+ F: __dxlog_file5,
2160
+ L: 88,
2161
+ S: void 0,
2162
+ A: [
2163
+ "!immutable",
2164
+ ""
2165
+ ]
2166
+ });
2167
+ const field2 = projection.createFieldProjection();
2168
+ setField(field2);
2169
+ }, [
2170
+ schema,
2171
+ view
2172
+ ]);
2173
+ const handleUpdate = useCallback10(({ name, typename }) => {
2174
+ invariant3(!immutable, void 0, {
2175
+ F: __dxlog_file5,
2176
+ L: 95,
2177
+ S: void 0,
2178
+ A: [
2179
+ "!immutable",
2180
+ ""
2181
+ ]
2182
+ });
2183
+ requestAnimationFrame(() => {
2184
+ if (view.name !== name) {
2185
+ view.name = name;
2186
+ }
2187
+ if (view.query.typename !== typename && !immutable) {
2188
+ onTypenameChanged?.(typename);
2189
+ }
2190
+ });
2191
+ }, [
2192
+ schema,
2193
+ view,
2194
+ onTypenameChanged,
2195
+ immutable
2196
+ ]);
2197
+ const handleDelete = useCallback10((fieldId) => {
2198
+ invariant3(!immutable, void 0, {
2199
+ F: __dxlog_file5,
2200
+ L: 111,
2201
+ S: void 0,
2202
+ A: [
2203
+ "!immutable",
2204
+ ""
2205
+ ]
2206
+ });
2207
+ if (fieldId === field?.id) {
2208
+ setField(void 0);
2008
2209
  }
2009
- });
2010
- }, [
2011
- schema,
2012
- view,
2013
- onTypenameChanged
2014
- ]);
2015
- const handleDelete = useCallback9((fieldId) => {
2016
- invariant3(!immutable, void 0, {
2017
- F: __dxlog_file5,
2018
- L: 101,
2019
- S: void 0,
2020
- A: [
2021
- "!immutable",
2022
- ""
2023
- ]
2024
- });
2025
- if (fieldId === field?.id) {
2210
+ onDelete?.(fieldId);
2211
+ }, [
2212
+ schema,
2213
+ field,
2214
+ onDelete
2215
+ ]);
2216
+ const handleMove = useCallback10((fromIndex, toIndex) => {
2217
+ invariant3(!immutable, void 0, {
2218
+ F: __dxlog_file5,
2219
+ L: 123,
2220
+ S: void 0,
2221
+ A: [
2222
+ "!immutable",
2223
+ ""
2224
+ ]
2225
+ });
2226
+ const fields = [
2227
+ ...view.fields
2228
+ ];
2229
+ const [moved] = fields.splice(fromIndex, 1);
2230
+ fields.splice(toIndex, 0, moved);
2231
+ view.fields = fields;
2232
+ }, [
2233
+ schema,
2234
+ view.fields
2235
+ ]);
2236
+ const handleClose = useCallback10(() => setField(void 0), []);
2237
+ const hiddenProperties = projection.getHiddenProperties();
2238
+ const handleHide = useCallback10((fieldId) => {
2026
2239
  setField(void 0);
2027
- }
2028
- onDelete?.(fieldId);
2029
- }, [
2030
- schema,
2031
- field,
2032
- onDelete
2033
- ]);
2034
- const handleMove = useCallback9((fromIndex, toIndex) => {
2035
- invariant3(!immutable, void 0, {
2036
- F: __dxlog_file5,
2037
- L: 113,
2038
- S: void 0,
2039
- A: [
2040
- "!immutable",
2041
- ""
2042
- ]
2043
- });
2044
- const fields = [
2045
- ...view.fields
2046
- ];
2047
- const [moved] = fields.splice(fromIndex, 1);
2048
- fields.splice(toIndex, 0, moved);
2049
- view.fields = fields;
2050
- }, [
2051
- schema,
2052
- view.fields
2053
- ]);
2054
- const handleClose = useCallback9(() => setField(void 0), []);
2055
- const hiddenProperties = projection.getHiddenProperties();
2056
- const handleHide = useCallback9((fieldId) => {
2057
- setField(void 0);
2058
- projection.hideFieldProjection(fieldId);
2059
- }, [
2060
- projection
2061
- ]);
2062
- const handleShow = useCallback9((property) => {
2063
- setField(void 0);
2064
- projection.showFieldProjection(property);
2065
- }, [
2066
- projection
2067
- ]);
2068
- return /* @__PURE__ */ React15.createElement("div", {
2069
- role: "none",
2070
- className: mx9("grid grid-rows-[1fr_1fr] min-bs-0", classNames)
2071
- }, /* @__PURE__ */ React15.createElement(Form, {
2072
- autoSave: true,
2073
- schema: ViewMetaSchema,
2074
- values: viewValues,
2075
- onSave: immutable ? void 0 : handleUpdate,
2076
- classNames: "min-bs-0 overflow-y-auto"
2077
- }), /* @__PURE__ */ React15.createElement("div", {
2078
- role: "none",
2079
- className: "border-bs border-separator min-bs-0 overflow-y-auto"
2080
- }, /* @__PURE__ */ React15.createElement("div", {
2081
- role: "none",
2082
- className: "p-2"
2083
- }, /* @__PURE__ */ React15.createElement("label", {
2084
- className: mx9(inputTextLabel)
2085
- }, t("fields label"))), /* @__PURE__ */ React15.createElement(List2.Root, {
2086
- items: view.fields,
2087
- isItem: Schema2.is(FieldSchema),
2088
- getId: (field2) => field2.id,
2089
- onMove: immutable ? void 0 : handleMove
2090
- }, ({ items: fields }) => /* @__PURE__ */ React15.createElement(React15.Fragment, null, showHeading && /* @__PURE__ */ React15.createElement("div", {
2091
- role: "heading",
2092
- className: grid
2093
- }, /* @__PURE__ */ React15.createElement("div", null), /* @__PURE__ */ React15.createElement("div", {
2094
- className: "flex items-center text-sm"
2095
- }, t("field path label"))), /* @__PURE__ */ React15.createElement("div", {
2096
- role: "list",
2097
- className: "flex flex-col w-full"
2098
- }, fields?.map((field2) => /* @__PURE__ */ React15.createElement(List2.Item, {
2099
- key: field2.id,
2100
- item: field2,
2101
- classNames: mx9(grid, ghostHover, "cursor-pointer")
2102
- }, /* @__PURE__ */ React15.createElement(List2.ItemDragHandle, null), /* @__PURE__ */ React15.createElement(List2.ItemTitle, {
2103
- onClick: () => handleSelect(field2)
2104
- }, field2.path), /* @__PURE__ */ React15.createElement("div", {
2105
- className: "flex items-center gap-2 -ml-4"
2106
- }, /* @__PURE__ */ React15.createElement(List2.ItemButton, {
2107
- icon: "ph--eye-slash--regular",
2108
- disabled: view.fields.length <= 1,
2109
- onClick: () => handleHide(field2.id)
2110
- }), !immutable && /* @__PURE__ */ React15.createElement(List2.ItemDeleteButton, {
2111
- icon: "ph--trash--regular",
2112
- disabled: view.fields.length <= 1,
2113
- onClick: () => handleDelete(field2.id)
2114
- }))))))), hiddenProperties.length > 0 && /* @__PURE__ */ React15.createElement("div", null, /* @__PURE__ */ React15.createElement("div", {
2115
- role: "none",
2116
- className: "p-2"
2117
- }, /* @__PURE__ */ React15.createElement("label", {
2118
- className: mx9(inputTextLabel)
2119
- }, t("hidden fields label"))), /* @__PURE__ */ React15.createElement(List2.Root, {
2120
- items: hiddenProperties,
2121
- isItem: (item) => typeof item === "string",
2122
- getId: (property) => property
2123
- }, ({ items: properties }) => /* @__PURE__ */ React15.createElement("div", {
2124
- role: "list",
2125
- className: "flex flex-col w-full"
2126
- }, properties?.map((property) => /* @__PURE__ */ React15.createElement(List2.Item, {
2127
- key: property,
2128
- item: property,
2129
- classNames: mx9(grid, ghostHover, "cursor-pointer")
2130
- }, /* @__PURE__ */ React15.createElement("div", null), /* @__PURE__ */ React15.createElement(List2.ItemTitle, null, property), /* @__PURE__ */ React15.createElement(List2.ItemButton, {
2131
- icon: "ph--eye--regular",
2132
- onClick: () => handleShow(property)
2133
- }))))))), field && /* @__PURE__ */ React15.createElement(FieldEditor, {
2134
- key: field.id,
2135
- view,
2136
- projection,
2137
- field,
2138
- registry,
2139
- onSave: handleClose
2140
- }), !readonly && !field && /* @__PURE__ */ React15.createElement("div", {
2141
- className: "flex p-2 justify-center"
2142
- }, /* @__PURE__ */ React15.createElement(IconButton4, {
2143
- icon: "ph--plus--regular",
2144
- label: t("button add property"),
2145
- onClick: immutable ? void 0 : handleAdd,
2146
- // TODO(burdon): Show field limit in ux (not tooltip).
2147
- disabled: view.fields.length >= VIEW_FIELD_LIMIT
2148
- })));
2240
+ projection.hideFieldProjection(fieldId);
2241
+ }, [
2242
+ projection
2243
+ ]);
2244
+ const handleShow = useCallback10((property) => {
2245
+ setField(void 0);
2246
+ projection.showFieldProjection(property);
2247
+ }, [
2248
+ projection
2249
+ ]);
2250
+ return /* @__PURE__ */ React15.createElement("div", {
2251
+ role: "none",
2252
+ className: mx8("overflow-y-auto", classNames)
2253
+ }, /* @__PURE__ */ React15.createElement("div", {
2254
+ role: "none",
2255
+ className: "p-2"
2256
+ }, /* @__PURE__ */ React15.createElement("div", {
2257
+ role: "none",
2258
+ className: "mbe-2"
2259
+ }, immutable && /* @__PURE__ */ React15.createElement(Message.Root, {
2260
+ valence: "neutral",
2261
+ className: "rounded"
2262
+ }, /* @__PURE__ */ React15.createElement(Message.Title, null, /* @__PURE__ */ React15.createElement(Icon3, {
2263
+ icon: "ph--info--regular",
2264
+ size: 5,
2265
+ classNames: "inline"
2266
+ }), " ", t("system schema title")), /* @__PURE__ */ React15.createElement(Message.Body, null, t("system schema description")))), /* @__PURE__ */ React15.createElement(Form, {
2267
+ autoSave: true,
2268
+ schema: ViewMetaSchema,
2269
+ values: viewValues,
2270
+ onSave: handleUpdate,
2271
+ classNames: "min-bs-0 overflow-y-auto"
2272
+ })), /* @__PURE__ */ React15.createElement("div", {
2273
+ role: "none",
2274
+ className: "min-bs-0 overflow-y-auto"
2275
+ }, /* @__PURE__ */ React15.createElement("div", {
2276
+ role: "none",
2277
+ className: "p-2"
2278
+ }, /* @__PURE__ */ React15.createElement("label", {
2279
+ className: mx8(inputTextLabel)
2280
+ }, t("fields label"))), /* @__PURE__ */ React15.createElement(List2.Root, {
2281
+ items: view.fields,
2282
+ isItem: Schema2.is(FieldSchema),
2283
+ getId: (field2) => field2.id,
2284
+ onMove: immutable ? void 0 : handleMove
2285
+ }, ({ items: fields }) => /* @__PURE__ */ React15.createElement(React15.Fragment, null, showHeading && /* @__PURE__ */ React15.createElement("div", {
2286
+ role: "heading",
2287
+ className: grid
2288
+ }, /* @__PURE__ */ React15.createElement("div", null), /* @__PURE__ */ React15.createElement("div", {
2289
+ className: "flex items-center text-sm"
2290
+ }, t("field path label"))), /* @__PURE__ */ React15.createElement("div", {
2291
+ role: "list",
2292
+ className: "flex flex-col w-full"
2293
+ }, fields?.map((field2) => /* @__PURE__ */ React15.createElement(List2.Item, {
2294
+ key: field2.id,
2295
+ item: field2,
2296
+ classNames: mx8(grid, ghostHover, !immutable && "cursor-pointer")
2297
+ }, /* @__PURE__ */ React15.createElement(List2.ItemDragHandle, null), /* @__PURE__ */ React15.createElement(List2.ItemTitle, {
2298
+ onClick: () => handleSelect(field2)
2299
+ }, field2.path), /* @__PURE__ */ React15.createElement("div", {
2300
+ className: "flex items-center gap-2 -ml-4"
2301
+ }, /* @__PURE__ */ React15.createElement(List2.ItemButton, {
2302
+ icon: "ph--eye-slash--regular",
2303
+ disabled: view.fields.length <= 1,
2304
+ onClick: () => handleHide(field2.id)
2305
+ }), !immutable && /* @__PURE__ */ React15.createElement(List2.ItemDeleteButton, {
2306
+ icon: "ph--trash--regular",
2307
+ disabled: view.fields.length <= 1,
2308
+ onClick: () => handleDelete(field2.id)
2309
+ }))))))), hiddenProperties.length > 0 && /* @__PURE__ */ React15.createElement("div", null, /* @__PURE__ */ React15.createElement("div", {
2310
+ role: "none",
2311
+ className: "p-2"
2312
+ }, /* @__PURE__ */ React15.createElement("label", {
2313
+ className: mx8(inputTextLabel)
2314
+ }, t("hidden fields label"))), /* @__PURE__ */ React15.createElement(List2.Root, {
2315
+ items: hiddenProperties,
2316
+ isItem: (item) => typeof item === "string",
2317
+ getId: (property) => property
2318
+ }, ({ items: properties }) => /* @__PURE__ */ React15.createElement("div", {
2319
+ role: "list",
2320
+ className: "flex flex-col w-full"
2321
+ }, properties?.map((property) => /* @__PURE__ */ React15.createElement(List2.Item, {
2322
+ key: property,
2323
+ item: property,
2324
+ classNames: mx8(grid, ghostHover, !immutable && "cursor-pointer")
2325
+ }, /* @__PURE__ */ React15.createElement("div", null), /* @__PURE__ */ React15.createElement(List2.ItemTitle, null, property), /* @__PURE__ */ React15.createElement(List2.ItemButton, {
2326
+ icon: "ph--eye--regular",
2327
+ onClick: () => handleShow(property)
2328
+ }))))))), field && /* @__PURE__ */ React15.createElement(FieldEditor, {
2329
+ key: field.id,
2330
+ view,
2331
+ projection,
2332
+ field,
2333
+ registry,
2334
+ onSave: handleClose
2335
+ }), !readonly && !field && /* @__PURE__ */ React15.createElement("div", {
2336
+ role: "none",
2337
+ className: "p-2"
2338
+ }, /* @__PURE__ */ React15.createElement(IconButton4, {
2339
+ icon: "ph--plus--regular",
2340
+ label: t("button add property"),
2341
+ onClick: immutable ? void 0 : handleAdd,
2342
+ // TODO(burdon): Show field limit in ux (not tooltip).
2343
+ disabled: view.fields.length >= VIEW_FIELD_LIMIT,
2344
+ classNames: "flex is-full"
2345
+ })));
2346
+ } finally {
2347
+ _effect.f();
2348
+ }
2149
2349
  };
2150
2350
  export {
2151
2351
  BooleanInput,