@dxos/react-ui-form 0.8.2-main.fbd8ed0 → 0.8.2-staging.4d6ad0f

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