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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/lib/browser/index.mjs +1445 -1245
  2. package/dist/lib/browser/index.mjs.map +3 -3
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node/index.cjs +1431 -1231
  5. package/dist/lib/node/index.cjs.map +3 -3
  6. package/dist/lib/node/meta.json +1 -1
  7. package/dist/lib/node-esm/index.mjs +1445 -1245
  8. package/dist/lib/node-esm/index.mjs.map +3 -3
  9. package/dist/lib/node-esm/meta.json +1 -1
  10. package/dist/types/src/components/ControlSection/ControlSection.d.ts +1 -1
  11. package/dist/types/src/components/ControlSection/ControlSection.d.ts.map +1 -1
  12. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
  13. package/dist/types/src/components/FieldEditor/FieldEditor.test.d.ts +2 -0
  14. package/dist/types/src/components/FieldEditor/FieldEditor.test.d.ts.map +1 -0
  15. package/dist/types/src/components/Form/ArrayField.d.ts.map +1 -1
  16. package/dist/types/src/components/Form/Defaults.d.ts +4 -4
  17. package/dist/types/src/components/Form/Defaults.d.ts.map +1 -1
  18. package/dist/types/src/components/Form/Form.d.ts.map +1 -1
  19. package/dist/types/src/components/Form/Form.stories.d.ts +1 -2
  20. package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
  21. package/dist/types/src/components/Form/FormActions.d.ts +1 -1
  22. package/dist/types/src/components/Form/FormActions.d.ts.map +1 -1
  23. package/dist/types/src/components/Form/FormContent.d.ts +6 -5
  24. package/dist/types/src/components/Form/FormContent.d.ts.map +1 -1
  25. package/dist/types/src/components/Form/FormContext.d.ts.map +1 -1
  26. package/dist/types/src/components/Form/RefField.d.ts.map +1 -1
  27. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
  28. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +5 -3
  29. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
  30. package/dist/types/src/components/testing.d.ts.map +1 -1
  31. package/dist/types/src/hooks/useRefQueryLookupHandler.d.ts.map +1 -1
  32. package/dist/types/src/translations.d.ts +5 -0
  33. package/dist/types/src/translations.d.ts.map +1 -1
  34. package/dist/types/src/vitest-setup.d.ts +2 -0
  35. package/dist/types/src/vitest-setup.d.ts.map +1 -0
  36. package/package.json +27 -25
  37. package/src/components/ControlSection/ControlSection.tsx +2 -2
  38. package/src/components/FieldEditor/FieldEditor.test.tsx +49 -0
  39. package/src/components/FieldEditor/FieldEditor.tsx +3 -2
  40. package/src/components/Form/ArrayField.tsx +51 -34
  41. package/src/components/Form/Defaults.tsx +74 -48
  42. package/src/components/Form/Form.stories.tsx +77 -101
  43. package/src/components/Form/Form.tsx +1 -2
  44. package/src/components/Form/FormActions.tsx +15 -18
  45. package/src/components/Form/FormContent.tsx +34 -35
  46. package/src/components/Form/FormContext.tsx +11 -7
  47. package/src/components/Form/Input.tsx +1 -1
  48. package/src/components/Form/RefField.tsx +30 -10
  49. package/src/components/ViewEditor/ViewEditor.stories.tsx +14 -5
  50. package/src/components/ViewEditor/ViewEditor.tsx +51 -24
  51. package/src/components/testing.tsx +5 -9
  52. package/src/hooks/useRefQueryLookupHandler.ts +1 -3
  53. package/src/translations.ts +9 -2
  54. package/src/vitest-setup.ts +11 -0
@@ -69,41 +69,51 @@ __export(node_exports, {
69
69
  useRefQueryLookupHandler: () => useRefQueryLookupHandler
70
70
  });
71
71
  module.exports = __toCommonJS(node_exports);
72
+ var import_tracking = require("@preact-signals/safe-react/tracking");
72
73
  var import_react = __toESM(require("react"));
73
74
  var import_react_ui = require("@dxos/react-ui");
74
75
  var import_react_ui_theme = require("@dxos/react-ui-theme");
76
+ var import_tracking2 = require("@preact-signals/safe-react/tracking");
75
77
  var import_react2 = __toESM(require("react"));
76
78
  var import_react_ui2 = require("@dxos/react-ui");
77
79
  var import_react_ui_theme2 = require("@dxos/react-ui-theme");
80
+ var import_tracking3 = require("@preact-signals/safe-react/tracking");
78
81
  var import_react3 = __toESM(require("react"));
79
82
  var import_echo_schema = require("@dxos/echo-schema");
80
83
  var import_log = require("@dxos/log");
81
84
  var import_react_ui3 = require("@dxos/react-ui");
82
85
  var import_schema = require("@dxos/schema");
86
+ var import_tracking4 = require("@preact-signals/safe-react/tracking");
83
87
  var import_react4 = __toESM(require("react"));
84
88
  var import_echo_schema2 = require("@dxos/echo-schema");
85
89
  var import_react_ui4 = require("@dxos/react-ui");
86
90
  var import_util = require("@dxos/util");
91
+ var import_tracking5 = require("@preact-signals/safe-react/tracking");
87
92
  var import_react5 = __toESM(require("react"));
88
93
  var import_react_ui5 = require("@dxos/react-ui");
89
94
  var import_react_ui_theme3 = require("@dxos/react-ui-theme");
95
+ var import_tracking6 = require("@preact-signals/safe-react/tracking");
90
96
  var import_react6 = __toESM(require("react"));
91
97
  var import_keys = require("@dxos/keys");
92
98
  var import_react_ui6 = require("@dxos/react-ui");
93
99
  var import_react_ui_list = require("@dxos/react-ui-list");
94
100
  var import_react_ui_pickers = require("@dxos/react-ui-pickers");
95
101
  var import_react_ui_theme4 = require("@dxos/react-ui-theme");
102
+ var import_tracking7 = require("@preact-signals/safe-react/tracking");
96
103
  var import_react7 = __toESM(require("react"));
97
104
  var import_react_ui7 = require("@dxos/react-ui");
98
105
  var import_react_ui_theme5 = require("@dxos/react-ui-theme");
99
106
  var import_util2 = require("@dxos/util");
107
+ var import_tracking8 = require("@preact-signals/safe-react/tracking");
100
108
  var import_react8 = __toESM(require("react"));
101
109
  var import_react_ui8 = require("@dxos/react-ui");
110
+ var import_tracking9 = require("@preact-signals/safe-react/tracking");
102
111
  var import_react9 = __toESM(require("react"));
103
112
  var import_react_ui_theme6 = require("@dxos/react-ui-theme");
113
+ var import_tracking10 = require("@preact-signals/safe-react/tracking");
104
114
  var import_react10 = __toESM(require("react"));
105
115
  var import_react_ui9 = require("@dxos/react-ui");
106
- var import_react_ui_theme7 = require("@dxos/react-ui-theme");
116
+ var import_tracking11 = require("@preact-signals/safe-react/tracking");
107
117
  var import_react11 = __toESM(require("react"));
108
118
  var import_debug = require("@dxos/debug");
109
119
  var import_echo_schema3 = require("@dxos/echo-schema");
@@ -121,20 +131,21 @@ var import_echo = require("@dxos/react-client/echo");
121
131
  var import_util3 = require("@dxos/util");
122
132
  var import_react14 = require("react");
123
133
  var import_log3 = require("@dxos/log");
134
+ var import_tracking12 = require("@preact-signals/safe-react/tracking");
124
135
  var import_effect4 = require("effect");
125
136
  var import_String = require("effect/String");
126
137
  var import_react15 = __toESM(require("react"));
127
138
  var import_effect5 = require("@dxos/effect");
128
- var import_react_ui_theme8 = require("@dxos/react-ui-theme");
139
+ var import_react_ui_theme7 = require("@dxos/react-ui-theme");
129
140
  var import_schema3 = require("@dxos/schema");
130
141
  var import_util4 = require("@dxos/util");
142
+ var import_tracking13 = require("@preact-signals/safe-react/tracking");
131
143
  var import_effect6 = require("effect");
132
144
  var import_String2 = require("effect/String");
133
145
  var import_react16 = __toESM(require("react"));
134
146
  var import_effect7 = require("@dxos/effect");
135
147
  var import_invariant2 = require("@dxos/invariant");
136
148
  var import_react_ui10 = require("@dxos/react-ui");
137
- var import_react_ui_theme9 = require("@dxos/react-ui-theme");
138
149
  var import_schema4 = require("@dxos/schema");
139
150
  var import_echo_schema6 = require("@dxos/echo-schema");
140
151
  var import_format = require("date-fns/format");
@@ -143,21 +154,25 @@ var import_echo_schema8 = require("@dxos/echo-schema");
143
154
  var import_effect8 = require("@dxos/effect");
144
155
  var import_effect9 = require("effect");
145
156
  var import_effect10 = require("@dxos/effect");
157
+ var import_tracking14 = require("@preact-signals/safe-react/tracking");
146
158
  var import_react17 = __toESM(require("react"));
147
159
  var import_echo_schema9 = require("@dxos/echo-schema");
148
160
  var import_effect11 = require("@dxos/effect");
149
161
  var import_keys2 = require("@dxos/keys");
162
+ var import_react18 = require("@dxos/lit-ui/react");
150
163
  var import_react_ui11 = require("@dxos/react-ui");
151
164
  var import_react_ui_tag_picker = require("@dxos/react-ui-tag-picker");
165
+ var import_react_ui_theme8 = require("@dxos/react-ui-theme");
152
166
  var import_util5 = require("@dxos/util");
153
167
  var import_echo_schema10 = require("@dxos/echo-schema");
168
+ var import_tracking15 = require("@preact-signals/safe-react/tracking");
154
169
  var import_effect12 = require("effect");
155
- var import_react18 = __toESM(require("react"));
170
+ var import_react19 = __toESM(require("react"));
156
171
  var import_echo_schema11 = require("@dxos/echo-schema");
157
172
  var import_invariant3 = require("@dxos/invariant");
158
173
  var import_react_ui12 = require("@dxos/react-ui");
159
174
  var import_react_ui_list2 = require("@dxos/react-ui-list");
160
- var import_react_ui_theme10 = require("@dxos/react-ui-theme");
175
+ var import_react_ui_theme9 = require("@dxos/react-ui-theme");
161
176
  var import_schema5 = require("@dxos/schema");
162
177
  var translationKey = "react-ui-form";
163
178
  var translations_default = [
@@ -166,6 +181,7 @@ var translations_default = [
166
181
  [translationKey]: {
167
182
  "fields label": "Fields",
168
183
  "hidden fields label": "Hidden Fields",
184
+ "empty readonly ref field label": "(none)",
169
185
  // TODO(burdon): Standardize field/property.
170
186
  "button add property": "Add property",
171
187
  "field property label": "Property",
@@ -175,6 +191,8 @@ var translations_default = [
175
191
  "add field": "Add field",
176
192
  "delete field": "Delete field",
177
193
  "field limit reached": "Maximum number of fields reached",
194
+ "boolean input true value": "Yes",
195
+ "boolean input false value": "No",
178
196
  // TODO(burdon): Factor out?
179
197
  "button cancel": "Cancel",
180
198
  "button save": "Save",
@@ -204,389 +222,466 @@ var translations_default = [
204
222
  "format number": "Number",
205
223
  "format uri": "URI",
206
224
  "format uuid": "UUID",
207
- // Placeholders
225
+ // Placeholders.
208
226
  "placeholder latitude": "Latitude",
209
227
  "placeholder longitude": "Longitude",
210
- // SelectOptionsInput
228
+ // SelectOptionsInput.
211
229
  "select option label": "Label",
212
230
  "select option label placeholder": "Option label",
213
231
  "select option color": "Color",
214
232
  "select option delete": "Delete",
215
- "select option add": "Add option"
233
+ "select option add": "Add option",
234
+ // System schema message.
235
+ "system schema title": "System Schema",
236
+ "system schema description": "This schema is managed by the system and cannot be modified."
216
237
  }
217
238
  }
218
239
  }
219
240
  ];
220
241
  var DeprecatedFormContainer = ({ children, classNames }) => {
221
- return /* @__PURE__ */ import_react.default.createElement("div", {
222
- role: "none",
223
- className: "container-max-width p-4 justify-center overflow-x-hidden overflow-y-auto"
224
- }, /* @__PURE__ */ import_react.default.createElement("div", {
225
- role: "form",
226
- className: (0, import_react_ui_theme.mx)("flex flex-col", import_react_ui_theme.textBlockWidth, classNames)
227
- }, children));
242
+ var _effect = (0, import_tracking.useSignals)();
243
+ try {
244
+ return /* @__PURE__ */ import_react.default.createElement("div", {
245
+ role: "none",
246
+ className: "container-max-width p-4 justify-center overflow-x-hidden overflow-y-auto"
247
+ }, /* @__PURE__ */ import_react.default.createElement("div", {
248
+ role: "form",
249
+ className: (0, import_react_ui_theme.mx)("flex flex-col", import_react_ui_theme.textBlockWidth, classNames)
250
+ }, children));
251
+ } finally {
252
+ _effect.f();
253
+ }
228
254
  };
229
255
  var DeprecatedFormInput = ({ label, description, secondary, children }) => {
230
- const primary = /* @__PURE__ */ import_react.default.createElement("div", {
231
- role: "none",
232
- className: "flex w-full gap-4 py-1"
233
- }, /* @__PURE__ */ import_react.default.createElement(import_react_ui.Input.Root, null, /* @__PURE__ */ import_react.default.createElement("div", {
234
- role: "none",
235
- className: "flex flex-col w-full"
236
- }, /* @__PURE__ */ import_react.default.createElement(import_react_ui.Input.Label, {
237
- classNames: "flex min-bs-[--rail-action] items-center",
238
- style: {
239
- fontSize: "unset"
240
- }
241
- }, label), description && /* @__PURE__ */ import_react.default.createElement(import_react_ui.Input.DescriptionAndValidation, {
242
- classNames: "mbs-0.5"
243
- }, /* @__PURE__ */ import_react.default.createElement(import_react_ui.Input.Description, null, description))), /* @__PURE__ */ import_react.default.createElement("div", {
244
- role: "none"
245
- }, /* @__PURE__ */ import_react.default.createElement("div", {
246
- role: "none",
247
- className: "flex min-bs-[--rail-action] items-center"
248
- }, children))));
249
- if (secondary) {
250
- return /* @__PURE__ */ import_react.default.createElement("div", {
256
+ var _effect = (0, import_tracking.useSignals)();
257
+ try {
258
+ const primary = /* @__PURE__ */ import_react.default.createElement("div", {
259
+ role: "none",
260
+ className: "flex w-full gap-4 py-1"
261
+ }, /* @__PURE__ */ import_react.default.createElement(import_react_ui.Input.Root, null, /* @__PURE__ */ import_react.default.createElement("div", {
262
+ role: "none",
263
+ className: "flex flex-col w-full"
264
+ }, /* @__PURE__ */ import_react.default.createElement(import_react_ui.Input.Label, {
265
+ classNames: "flex min-bs-[--rail-action] items-center",
266
+ style: {
267
+ fontSize: "unset"
268
+ }
269
+ }, label), description && /* @__PURE__ */ import_react.default.createElement(import_react_ui.Input.DescriptionAndValidation, {
270
+ classNames: "mbs-0.5"
271
+ }, /* @__PURE__ */ import_react.default.createElement(import_react_ui.Input.Description, null, description))), /* @__PURE__ */ import_react.default.createElement("div", {
251
272
  role: "none"
252
- }, primary, secondary);
273
+ }, /* @__PURE__ */ import_react.default.createElement("div", {
274
+ role: "none",
275
+ className: "flex min-bs-[--rail-action] items-center"
276
+ }, children))));
277
+ if (secondary) {
278
+ return /* @__PURE__ */ import_react.default.createElement("div", {
279
+ role: "none"
280
+ }, primary, secondary);
281
+ }
282
+ return primary;
283
+ } finally {
284
+ _effect.f();
253
285
  }
254
- return primary;
255
286
  };
256
287
  var ControlPage = ({ children, classNames, ...props }) => {
257
- return /* @__PURE__ */ import_react2.default.createElement("div", {
258
- role: "none",
259
- className: (0, import_react_ui_theme2.mx)("pli-2", classNames),
260
- ...props
261
- }, children);
288
+ var _effect = (0, import_tracking2.useSignals)();
289
+ try {
290
+ return /* @__PURE__ */ import_react2.default.createElement("div", {
291
+ role: "none",
292
+ className: (0, import_react_ui_theme2.mx)("pli-2", classNames),
293
+ ...props
294
+ }, children);
295
+ } finally {
296
+ _effect.f();
297
+ }
262
298
  };
263
299
  var ControlSection = ({ title, description, children }) => {
264
- return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement(ControlSectionHeading, {
265
- title,
266
- description
267
- }), children);
300
+ var _effect = (0, import_tracking2.useSignals)();
301
+ try {
302
+ return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement(ControlSectionHeading, {
303
+ title,
304
+ description
305
+ }), children);
306
+ } finally {
307
+ _effect.f();
308
+ }
268
309
  };
269
310
  var ControlSectionHeading = ({ title, description }) => {
270
- const { t } = (0, import_react_ui2.useTranslation)(translationKey);
271
- return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement("h2", {
272
- className: "pli-4 container-max-width text-xl mbs-6 mbe-4"
273
- }, (0, import_react_ui2.toLocalizedString)(title, t)), description && /* @__PURE__ */ import_react2.default.createElement("p", {
274
- className: "pli-4 mlb-4 container-max-width text-description"
275
- }, (0, import_react_ui2.toLocalizedString)(description, t)));
311
+ var _effect = (0, import_tracking2.useSignals)();
312
+ try {
313
+ const { t } = (0, import_react_ui2.useTranslation)(translationKey);
314
+ return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement("h2", {
315
+ className: "pli-4 container-max-width text-xl mbs-6 mbe-4"
316
+ }, (0, import_react_ui2.toLocalizedString)(title, t)), description && /* @__PURE__ */ import_react2.default.createElement("p", {
317
+ className: "pli-4 mlb-4 container-max-width text-description"
318
+ }, (0, import_react_ui2.toLocalizedString)(description, t)));
319
+ } finally {
320
+ _effect.f();
321
+ }
276
322
  };
277
323
  var ControlGroupButton = ({ classNames, ...props }) => {
278
- return /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.Button, {
279
- ...props,
280
- classNames: [
281
- "md:col-span-2",
282
- classNames
283
- ]
284
- });
324
+ var _effect = (0, import_tracking2.useSignals)();
325
+ try {
326
+ return /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.Button, {
327
+ ...props,
328
+ classNames: [
329
+ "md:col-span-2",
330
+ classNames
331
+ ]
332
+ });
333
+ } finally {
334
+ _effect.f();
335
+ }
336
+ };
337
+ var ControlGroup = ({ children, classNames }) => {
338
+ var _effect = (0, import_tracking2.useSignals)();
339
+ try {
340
+ return /* @__PURE__ */ import_react2.default.createElement("div", {
341
+ role: "none",
342
+ className: (0, import_react_ui_theme2.mx)("group container-max-width grid grid-cols-1 md:grid-cols-[1fr_min-content] gap-4", classNames)
343
+ }, children);
344
+ } finally {
345
+ _effect.f();
346
+ }
347
+ };
348
+ var ControlFrame = ({ children }) => {
349
+ var _effect = (0, import_tracking2.useSignals)();
350
+ try {
351
+ return /* @__PURE__ */ import_react2.default.createElement("div", {
352
+ role: "none",
353
+ 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"
354
+ }, children);
355
+ } finally {
356
+ _effect.f();
357
+ }
285
358
  };
286
- var ControlGroup = ({ children, classNames }) => /* @__PURE__ */ import_react2.default.createElement("div", {
287
- role: "none",
288
- className: (0, import_react_ui_theme2.mx)("group container-max-width grid grid-cols-1 md:grid-cols-[1fr_min-content] gap-4", classNames)
289
- }, children);
290
- var ControlFrame = ({ children }) => /* @__PURE__ */ import_react2.default.createElement("div", {
291
- role: "none",
292
- 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"
293
- }, children);
294
- var controlItemClasses = "p-4 border border-separator rounded-lg container-max-width grid md:col-span-2 grid-cols-subgrid items-center";
295
- var controlItemTitleClasses = "text-lg font-normal mbe-2";
359
+ var controlItemClasses = "p-4 border border-separator rounded-lg container-max-width grid md:col-span-2 grid-cols-subgrid items-center gap-2";
360
+ var controlItemTitleClasses = "text-lg font-normal";
296
361
  var controlItemDescriptionClasses = "text-base mlb-2 md:mbe-0 text-description";
297
362
  var ControlItem = ({ title, description, children }) => {
298
- const { t } = (0, import_react_ui2.useTranslation)(translationKey);
299
- return /* @__PURE__ */ import_react2.default.createElement("div", {
300
- className: controlItemClasses
301
- }, /* @__PURE__ */ import_react2.default.createElement("div", {
302
- role: "none"
303
- }, /* @__PURE__ */ import_react2.default.createElement("h3", {
304
- className: controlItemTitleClasses
305
- }, (0, import_react_ui2.toLocalizedString)(title, t)), description && /* @__PURE__ */ import_react2.default.createElement("p", {
306
- className: controlItemDescriptionClasses
307
- }, (0, import_react_ui2.toLocalizedString)(description, t))), children);
363
+ var _effect = (0, import_tracking2.useSignals)();
364
+ try {
365
+ const { t } = (0, import_react_ui2.useTranslation)(translationKey);
366
+ return /* @__PURE__ */ import_react2.default.createElement("div", {
367
+ className: controlItemClasses
368
+ }, /* @__PURE__ */ import_react2.default.createElement("div", {
369
+ role: "none"
370
+ }, /* @__PURE__ */ import_react2.default.createElement("h3", {
371
+ className: controlItemTitleClasses
372
+ }, (0, import_react_ui2.toLocalizedString)(title, t)), description && /* @__PURE__ */ import_react2.default.createElement("p", {
373
+ className: controlItemDescriptionClasses
374
+ }, (0, import_react_ui2.toLocalizedString)(description, t))), children);
375
+ } finally {
376
+ _effect.f();
377
+ }
308
378
  };
309
379
  var ControlItemInput = ({ title, description, children }) => {
310
- const { t } = (0, import_react_ui2.useTranslation)(translationKey);
311
- return /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.Input.Root, null, /* @__PURE__ */ import_react2.default.createElement("div", {
312
- className: controlItemClasses
313
- }, /* @__PURE__ */ import_react2.default.createElement("div", {
314
- role: "none"
315
- }, /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.Input.Label, {
316
- classNames: controlItemTitleClasses
317
- }, (0, import_react_ui2.toLocalizedString)(title, t)), description && /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.Input.DescriptionAndValidation, null, /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.Input.Description, {
318
- classNames: controlItemDescriptionClasses
319
- }, (0, import_react_ui2.toLocalizedString)(description, t)))), children));
380
+ var _effect = (0, import_tracking2.useSignals)();
381
+ try {
382
+ const { t } = (0, import_react_ui2.useTranslation)(translationKey);
383
+ return /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.Input.Root, null, /* @__PURE__ */ import_react2.default.createElement("div", {
384
+ className: controlItemClasses
385
+ }, /* @__PURE__ */ import_react2.default.createElement("div", {
386
+ role: "none"
387
+ }, /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.Input.Label, {
388
+ classNames: controlItemTitleClasses
389
+ }, (0, import_react_ui2.toLocalizedString)(title, t)), description && /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.Input.DescriptionAndValidation, null, /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.Input.Description, {
390
+ classNames: controlItemDescriptionClasses
391
+ }, (0, import_react_ui2.toLocalizedString)(description, t)))), children));
392
+ } finally {
393
+ _effect.f();
394
+ }
320
395
  };
321
396
  var ControlFrameItem = ({ title, description, children }) => {
322
- const { t } = (0, import_react_ui2.useTranslation)(translationKey);
323
- return /* @__PURE__ */ import_react2.default.createElement("div", {
324
- role: "group",
325
- className: "min-is-0"
326
- }, /* @__PURE__ */ import_react2.default.createElement("h3", {
327
- className: "text-lg mbe-2"
328
- }, (0, import_react_ui2.toLocalizedString)(title, t)), description && /* @__PURE__ */ import_react2.default.createElement("p", {
329
- className: "mlb-2 md:mbe-0 text-description"
330
- }, (0, import_react_ui2.toLocalizedString)(description, t)), children);
397
+ var _effect = (0, import_tracking2.useSignals)();
398
+ try {
399
+ const { t } = (0, import_react_ui2.useTranslation)(translationKey);
400
+ return /* @__PURE__ */ import_react2.default.createElement("div", {
401
+ role: "group",
402
+ className: "min-is-0"
403
+ }, /* @__PURE__ */ import_react2.default.createElement("h3", {
404
+ className: "text-lg mbe-2"
405
+ }, (0, import_react_ui2.toLocalizedString)(title, t)), description && /* @__PURE__ */ import_react2.default.createElement("p", {
406
+ className: "mlb-2 md:mbe-0 text-description"
407
+ }, (0, import_react_ui2.toLocalizedString)(description, t)), children);
408
+ } finally {
409
+ _effect.f();
410
+ }
331
411
  };
332
412
  var InputHeader = ({ children, error }) => {
333
- return /* @__PURE__ */ import_react5.default.createElement("div", {
334
- role: "none",
335
- className: "flex justify-between items-center mb-1"
336
- }, children, error && /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Tooltip.Trigger, {
337
- asChild: true,
338
- content: error,
339
- side: "bottom"
340
- }, /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Icon, {
341
- icon: "ph--warning--regular",
342
- size: 4,
343
- classNames: import_react_ui_theme3.errorText
344
- })));
413
+ var _effect = (0, import_tracking5.useSignals)();
414
+ try {
415
+ return /* @__PURE__ */ import_react5.default.createElement("div", {
416
+ role: "none",
417
+ className: "flex justify-between items-center mbs-2 mbe-1 first:mbs-0"
418
+ }, children, error && /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Tooltip.Trigger, {
419
+ asChild: true,
420
+ content: error,
421
+ side: "bottom"
422
+ }, /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Icon, {
423
+ icon: "ph--warning--regular",
424
+ size: 4,
425
+ classNames: import_react_ui_theme3.errorText
426
+ })));
427
+ } finally {
428
+ _effect.f();
429
+ }
345
430
  };
346
431
  var GeoPointInput = ({ type, label, disabled, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
347
- const { t } = (0, import_react_ui4.useTranslation)(translationKey);
348
- const { status, error } = getStatus();
349
- const geoPoint = (0, import_react4.useMemo)(() => getValue3() ?? [
350
- 0,
351
- 0
352
- ], [
353
- getValue3
354
- ]);
355
- const geoLocation = (0, import_react4.useMemo)(() => import_echo_schema2.GeoLocation.fromGeoPoint(geoPoint), [
356
- geoPoint
357
- ]);
358
- const [longitudeText, setLongitudeText] = (0, import_react4.useState)(geoLocation.longitude?.toString());
359
- const [latitudeText, setLatitudeText] = (0, import_react4.useState)(geoLocation.latitude?.toString());
360
- (0, import_react4.useEffect)(() => {
361
- const location = import_echo_schema2.GeoLocation.fromGeoPoint(geoPoint);
362
- setLongitudeText(location.longitude.toString());
363
- setLatitudeText(location.latitude.toString());
364
- }, [
365
- geoPoint
366
- ]);
367
- const handleCoordinateChange = (0, import_react4.useCallback)((coordinateType, setText) => (event) => {
368
- const inputText = event.target.value;
369
- setText(inputText);
370
- if (inputText !== "" && inputText !== "-") {
371
- const coord = (0, import_util.safeParseFloat)(inputText);
372
- if (coord !== void 0 && !isNaN(coord)) {
373
- const currentLocation = import_echo_schema2.GeoLocation.fromGeoPoint(getValue3() ?? [
374
- 0,
375
- 0
376
- ]);
377
- const newLocation = {
378
- ...currentLocation,
379
- [coordinateType]: coord
380
- };
381
- const newValue = import_echo_schema2.GeoLocation.toGeoPoint(newLocation);
382
- onValueChange(type, newValue);
432
+ var _effect = (0, import_tracking4.useSignals)();
433
+ try {
434
+ const { t } = (0, import_react_ui4.useTranslation)(translationKey);
435
+ const { status, error } = getStatus();
436
+ const geoPoint = (0, import_react4.useMemo)(() => getValue3() ?? [
437
+ 0,
438
+ 0
439
+ ], [
440
+ getValue3
441
+ ]);
442
+ const geoLocation = (0, import_react4.useMemo)(() => import_echo_schema2.GeoLocation.fromGeoPoint(geoPoint), [
443
+ geoPoint
444
+ ]);
445
+ const [longitudeText, setLongitudeText] = (0, import_react4.useState)(geoLocation.longitude?.toString());
446
+ const [latitudeText, setLatitudeText] = (0, import_react4.useState)(geoLocation.latitude?.toString());
447
+ (0, import_react4.useEffect)(() => {
448
+ const location = import_echo_schema2.GeoLocation.fromGeoPoint(geoPoint);
449
+ setLongitudeText(location.longitude.toString());
450
+ setLatitudeText(location.latitude.toString());
451
+ }, [
452
+ geoPoint
453
+ ]);
454
+ const handleCoordinateChange = (0, import_react4.useCallback)((coordinateType, setText) => (event) => {
455
+ const inputText = event.target.value;
456
+ setText(inputText);
457
+ if (inputText !== "" && inputText !== "-") {
458
+ const coord = (0, import_util.safeParseFloat)(inputText);
459
+ if (coord !== void 0 && !isNaN(coord)) {
460
+ const currentLocation = import_echo_schema2.GeoLocation.fromGeoPoint(getValue3() ?? [
461
+ 0,
462
+ 0
463
+ ]);
464
+ const newLocation = {
465
+ ...currentLocation,
466
+ [coordinateType]: coord
467
+ };
468
+ const newValue = import_echo_schema2.GeoLocation.toGeoPoint(newLocation);
469
+ onValueChange(type, newValue);
470
+ }
383
471
  }
384
- }
385
- }, [
386
- getValue3,
387
- onValueChange,
388
- type
389
- ]);
390
- return /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Input.Root, {
391
- validationValence: status
392
- }, /* @__PURE__ */ import_react4.default.createElement(InputHeader, {
393
- error
394
- }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Input.Label, null, label)), /* @__PURE__ */ import_react4.default.createElement("div", {
395
- role: "none",
396
- className: "grid grid-cols-2 gap-2"
397
- }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Input.TextInput, {
398
- type: "text",
399
- pattern: "^-?[0-9]*\\.?[0-9]*$",
400
- disabled,
401
- placeholder: t("placeholder latitude"),
402
- value: latitudeText,
403
- onChange: handleCoordinateChange("latitude", setLatitudeText),
404
- onBlur
405
- }), /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Input.TextInput, {
406
- type: "text",
407
- pattern: "^-?[0-9]*\\.?[0-9]*$",
408
- disabled,
409
- placeholder: t("placeholder longitude"),
410
- value: longitudeText,
411
- onChange: handleCoordinateChange("longitude", setLongitudeText),
412
- onBlur
413
- })));
472
+ }, [
473
+ getValue3,
474
+ onValueChange,
475
+ type
476
+ ]);
477
+ return /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Input.Root, {
478
+ validationValence: status
479
+ }, /* @__PURE__ */ import_react4.default.createElement(InputHeader, {
480
+ error
481
+ }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Input.Label, null, label)), /* @__PURE__ */ import_react4.default.createElement("div", {
482
+ role: "none",
483
+ className: "grid grid-cols-2 gap-2"
484
+ }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Input.TextInput, {
485
+ type: "text",
486
+ pattern: "^-?[0-9]*\\.?[0-9]*$",
487
+ disabled,
488
+ placeholder: t("placeholder latitude"),
489
+ value: latitudeText,
490
+ onChange: handleCoordinateChange("latitude", setLatitudeText),
491
+ onBlur
492
+ }), /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Input.TextInput, {
493
+ type: "text",
494
+ pattern: "^-?[0-9]*\\.?[0-9]*$",
495
+ disabled,
496
+ placeholder: t("placeholder longitude"),
497
+ value: longitudeText,
498
+ onChange: handleCoordinateChange("longitude", setLongitudeText),
499
+ onBlur
500
+ })));
501
+ } finally {
502
+ _effect.f();
503
+ }
414
504
  };
415
505
  var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3, onValueChange }) => {
416
- const [selected, setSelectedId] = (0, import_react6.useState)(null);
417
- const [isNewOption, setIsNewOption] = (0, import_react6.useState)(false);
418
- const inputRef = (0, import_react6.useRef)(null);
419
- const { t } = (0, import_react_ui6.useTranslation)(translationKey);
420
- const { status, error } = getStatus();
421
- const options = getValue3();
422
- (0, import_react6.useEffect)(() => {
423
- if (options === void 0) {
424
- onValueChange(type, []);
425
- }
426
- }, [
427
- options,
428
- onValueChange,
429
- type
430
- ]);
431
- const randomHue = () => {
432
- const usedHues = new Set(options?.map((option) => option.color) ?? []);
433
- const unusedHues = import_react_ui_theme4.hues.filter((hue) => !usedHues.has(hue));
434
- if (unusedHues.length > 0) {
435
- return unusedHues[Math.floor(Math.random() * unusedHues.length)];
436
- }
437
- const lastThree = new Set(options?.slice(-3).map((option) => option.color) ?? []);
438
- const availableHues = import_react_ui_theme4.hues.filter((hue) => !lastThree.has(hue));
439
- return availableHues[Math.floor(Math.random() * availableHues.length)] ?? import_react_ui_theme4.hues[Math.floor(Math.random() * import_react_ui_theme4.hues.length)];
440
- };
441
- const handleAdd = (0, import_react6.useCallback)(() => {
442
- const newId = import_keys.PublicKey.random().truncate();
443
- const newOption = {
444
- id: newId,
445
- title: "",
446
- color: randomHue()
506
+ var _effect = (0, import_tracking6.useSignals)();
507
+ try {
508
+ const [selected, setSelectedId] = (0, import_react6.useState)(null);
509
+ const [isNewOption, setIsNewOption] = (0, import_react6.useState)(false);
510
+ const inputRef = (0, import_react6.useRef)(null);
511
+ const { t } = (0, import_react_ui6.useTranslation)(translationKey);
512
+ const { status, error } = getStatus();
513
+ const options = getValue3();
514
+ (0, import_react6.useEffect)(() => {
515
+ if (options === void 0) {
516
+ onValueChange(type, []);
517
+ }
518
+ }, [
519
+ options,
520
+ onValueChange,
521
+ type
522
+ ]);
523
+ const randomHue = () => {
524
+ const usedHues = new Set(options?.map((option) => option.color) ?? []);
525
+ const unusedHues = import_react_ui_theme4.hues.filter((hue) => !usedHues.has(hue));
526
+ if (unusedHues.length > 0) {
527
+ return unusedHues[Math.floor(Math.random() * unusedHues.length)];
528
+ }
529
+ const lastThree = new Set(options?.slice(-3).map((option) => option.color) ?? []);
530
+ const availableHues = import_react_ui_theme4.hues.filter((hue) => !lastThree.has(hue));
531
+ return availableHues[Math.floor(Math.random() * availableHues.length)] ?? import_react_ui_theme4.hues[Math.floor(Math.random() * import_react_ui_theme4.hues.length)];
447
532
  };
448
- onValueChange(type, [
449
- ...options ?? [],
450
- newOption
533
+ const handleAdd = (0, import_react6.useCallback)(() => {
534
+ const newId = import_keys.PublicKey.random().truncate();
535
+ const newOption = {
536
+ id: newId,
537
+ title: "",
538
+ color: randomHue()
539
+ };
540
+ onValueChange(type, [
541
+ ...options ?? [],
542
+ newOption
543
+ ]);
544
+ setSelectedId(newId);
545
+ setIsNewOption(true);
546
+ }, [
547
+ options,
548
+ type,
549
+ onValueChange
451
550
  ]);
452
- setSelectedId(newId);
453
- setIsNewOption(true);
454
- }, [
455
- options,
456
- type,
457
- onValueChange
458
- ]);
459
- const handleDelete = (0, import_react6.useCallback)((id) => {
460
- const newOptions = options?.filter((option) => option.id !== id) ?? [];
461
- onValueChange(type, newOptions);
462
- setSelectedId(null);
463
- }, [
464
- options,
465
- type,
466
- onValueChange
467
- ]);
468
- const handleMove = (0, import_react6.useCallback)((from, to) => {
469
- if (!options) {
470
- return;
471
- }
472
- const newOptions = [
473
- ...options
474
- ];
475
- const [removed] = newOptions.splice(from, 1);
476
- newOptions.splice(to, 0, removed);
477
- onValueChange(type, newOptions);
478
- }, [
479
- options,
480
- type,
481
- onValueChange
482
- ]);
483
- const handleClick = (0, import_react6.useCallback)((id) => {
484
- setSelectedId((current) => current === id ? null : id);
485
- }, []);
486
- const handleTitleChange = (0, import_react6.useCallback)((id) => (e) => {
487
- const newOptions = options?.map((o) => o.id === id ? {
488
- ...o,
489
- title: e.target.value
490
- } : o);
491
- onValueChange(type, newOptions ?? []);
492
- }, [
493
- options,
494
- type,
495
- onValueChange
496
- ]);
497
- const handleKeyDown = (0, import_react6.useCallback)((e) => {
498
- if (e.key === "Enter") {
551
+ const handleDelete = (0, import_react6.useCallback)((id) => {
552
+ const newOptions = options?.filter((option) => option.id !== id) ?? [];
553
+ onValueChange(type, newOptions);
499
554
  setSelectedId(null);
500
- }
501
- }, []);
502
- const handleColorChange = (0, import_react6.useCallback)((id) => (hue) => {
503
- const newOptions = options?.map((o) => o.id === id ? {
504
- ...o,
505
- color: hue
506
- } : o);
507
- onValueChange(type, newOptions ?? []);
508
- }, [
509
- options,
510
- type,
511
- onValueChange
512
- ]);
513
- (0, import_react6.useEffect)(() => {
514
- if (selected && isNewOption && inputRef.current) {
515
- inputRef.current.focus();
516
- setIsNewOption(false);
517
- }
518
- }, [
519
- selected,
520
- isNewOption
521
- ]);
522
- return /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Input.Root, {
523
- validationValence: status
524
- }, /* @__PURE__ */ import_react6.default.createElement(InputHeader, {
525
- error
526
- }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Input.Label, null, label)), /* @__PURE__ */ import_react6.default.createElement("div", {
527
- role: "none"
528
- }, options && /* @__PURE__ */ import_react6.default.createElement(import_react_ui_list.List.Root, {
529
- items: options,
530
- isItem: (item) => true,
531
- onMove: handleMove
532
- }, ({ items }) => /* @__PURE__ */ import_react6.default.createElement("div", {
533
- role: "list",
534
- className: "w-full overflow-auto"
535
- }, items?.map((item) => /* @__PURE__ */ import_react6.default.createElement("div", {
536
- key: item.id
537
- }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui_list.List.Item, {
538
- role: "button",
539
- item,
540
- classNames: (0, import_react_ui_theme4.mx)("p-1 plb-2", "flex flex-col", "cursor-pointer", "hover:bg-hoverOverlay"),
541
- "aria-expanded": selected === item.id
542
- }, /* @__PURE__ */ import_react6.default.createElement("div", {
543
- className: "flex items-center"
544
- }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui_list.List.ItemDragHandle, null), /* @__PURE__ */ import_react6.default.createElement(import_react_ui_list.List.ItemTitle, {
545
- onClick: () => handleClick(item.id),
546
- classNames: "flex-1"
547
- }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Tag, {
548
- palette: item.color
549
- }, item.title || "\u200B")), /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Icon, {
550
- icon: selected === item.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
551
- onClick: () => handleClick(item.id)
552
- })), selected === item.id && /* @__PURE__ */ import_react6.default.createElement("div", {
553
- className: "mis-4 mbs-2 flex flex-col gap-1"
554
- }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Input.Label, {
555
- classNames: "text-xs"
556
- }, t("select option label")), /* @__PURE__ */ import_react6.default.createElement("div", {
557
- className: "flex flex-row items-center gap-1"
558
- }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Input.TextInput, {
559
- placeholder: t("select option label placeholder"),
560
- ref: selected === item.id ? inputRef : void 0,
561
- value: item.title,
562
- onChange: handleTitleChange(item.id),
563
- onKeyDown: handleKeyDown,
564
- classNames: "flex-1",
565
- "data-no-submit": true
566
- }), /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Toolbar.Root, {
567
- classNames: "p-0 m-0 !is-auto"
568
- }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui_pickers.HuePicker, {
569
- value: item.color,
570
- onChange: handleColorChange(item.id),
571
- rootVariant: "toolbar-button"
572
- })), /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.IconButton, {
573
- icon: "ph--trash--fill",
574
- iconOnly: true,
575
- label: t("select option delete"),
576
- onClick: () => handleDelete(item.id)
577
- })))))), /* @__PURE__ */ import_react6.default.createElement("div", {
578
- role: "listitem"
579
- }, /* @__PURE__ */ import_react6.default.createElement("div", {
580
- role: "button",
581
- className: (0, import_react_ui_theme4.mx)("p-1 plb-2", "flex flex-col", "cursor-pointer", "hover:bg-hoverOverlay"),
582
- onClick: handleAdd
583
- }, /* @__PURE__ */ import_react6.default.createElement("div", {
584
- className: "flex items-center gap-1"
585
- }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Icon, {
586
- icon: "ph--plus--regular"
587
- }), /* @__PURE__ */ import_react6.default.createElement("span", {
588
- className: "text-sm"
589
- }, t("select option add")))))))));
555
+ }, [
556
+ options,
557
+ type,
558
+ onValueChange
559
+ ]);
560
+ const handleMove = (0, import_react6.useCallback)((from, to) => {
561
+ if (!options) {
562
+ return;
563
+ }
564
+ const newOptions = [
565
+ ...options
566
+ ];
567
+ const [removed] = newOptions.splice(from, 1);
568
+ newOptions.splice(to, 0, removed);
569
+ onValueChange(type, newOptions);
570
+ }, [
571
+ options,
572
+ type,
573
+ onValueChange
574
+ ]);
575
+ const handleClick = (0, import_react6.useCallback)((id) => {
576
+ setSelectedId((current) => current === id ? null : id);
577
+ }, []);
578
+ const handleTitleChange = (0, import_react6.useCallback)((id) => (e) => {
579
+ const newOptions = options?.map((o) => o.id === id ? {
580
+ ...o,
581
+ title: e.target.value
582
+ } : o);
583
+ onValueChange(type, newOptions ?? []);
584
+ }, [
585
+ options,
586
+ type,
587
+ onValueChange
588
+ ]);
589
+ const handleKeyDown = (0, import_react6.useCallback)((e) => {
590
+ if (e.key === "Enter") {
591
+ setSelectedId(null);
592
+ }
593
+ }, []);
594
+ const handleColorChange = (0, import_react6.useCallback)((id) => (hue) => {
595
+ const newOptions = options?.map((o) => o.id === id ? {
596
+ ...o,
597
+ color: hue
598
+ } : o);
599
+ onValueChange(type, newOptions ?? []);
600
+ }, [
601
+ options,
602
+ type,
603
+ onValueChange
604
+ ]);
605
+ (0, import_react6.useEffect)(() => {
606
+ if (selected && isNewOption && inputRef.current) {
607
+ inputRef.current.focus();
608
+ setIsNewOption(false);
609
+ }
610
+ }, [
611
+ selected,
612
+ isNewOption
613
+ ]);
614
+ return /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Input.Root, {
615
+ validationValence: status
616
+ }, /* @__PURE__ */ import_react6.default.createElement(InputHeader, {
617
+ error
618
+ }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Input.Label, null, label)), /* @__PURE__ */ import_react6.default.createElement("div", {
619
+ role: "none"
620
+ }, options && /* @__PURE__ */ import_react6.default.createElement(import_react_ui_list.List.Root, {
621
+ items: options,
622
+ isItem: (item) => true,
623
+ onMove: handleMove
624
+ }, ({ items }) => /* @__PURE__ */ import_react6.default.createElement("div", {
625
+ role: "list",
626
+ className: "w-full overflow-auto"
627
+ }, items?.map((item) => /* @__PURE__ */ import_react6.default.createElement("div", {
628
+ key: item.id
629
+ }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui_list.List.Item, {
630
+ role: "button",
631
+ item,
632
+ classNames: (0, import_react_ui_theme4.mx)("p-1 plb-2", "flex flex-col", "cursor-pointer", "hover:bg-hoverOverlay"),
633
+ "aria-expanded": selected === item.id
634
+ }, /* @__PURE__ */ import_react6.default.createElement("div", {
635
+ className: "flex items-center"
636
+ }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui_list.List.ItemDragHandle, null), /* @__PURE__ */ import_react6.default.createElement(import_react_ui_list.List.ItemTitle, {
637
+ onClick: () => handleClick(item.id),
638
+ classNames: "flex-1"
639
+ }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Tag, {
640
+ palette: item.color
641
+ }, item.title || "\u200B")), /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Icon, {
642
+ icon: selected === item.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
643
+ onClick: () => handleClick(item.id)
644
+ })), selected === item.id && /* @__PURE__ */ import_react6.default.createElement("div", {
645
+ className: "mis-4 mbs-2 flex flex-col gap-1"
646
+ }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Input.Label, {
647
+ classNames: "text-xs"
648
+ }, t("select option label")), /* @__PURE__ */ import_react6.default.createElement("div", {
649
+ className: "flex flex-row items-center gap-1"
650
+ }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Input.TextInput, {
651
+ placeholder: t("select option label placeholder"),
652
+ ref: selected === item.id ? inputRef : void 0,
653
+ value: item.title,
654
+ onChange: handleTitleChange(item.id),
655
+ onKeyDown: handleKeyDown,
656
+ classNames: "flex-1",
657
+ "data-no-submit": true
658
+ }), /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Toolbar.Root, {
659
+ classNames: "p-0 m-0 !is-auto"
660
+ }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui_pickers.HuePicker, {
661
+ value: item.color,
662
+ onChange: handleColorChange(item.id),
663
+ rootVariant: "toolbar-button"
664
+ })), /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.IconButton, {
665
+ icon: "ph--trash--fill",
666
+ iconOnly: true,
667
+ label: t("select option delete"),
668
+ onClick: () => handleDelete(item.id)
669
+ })))))), /* @__PURE__ */ import_react6.default.createElement("div", {
670
+ role: "listitem"
671
+ }, /* @__PURE__ */ import_react6.default.createElement("div", {
672
+ role: "button",
673
+ className: (0, import_react_ui_theme4.mx)("p-1 plb-2", "flex flex-col", "cursor-pointer", "hover:bg-hoverOverlay"),
674
+ onClick: handleAdd
675
+ }, /* @__PURE__ */ import_react6.default.createElement("div", {
676
+ className: "flex items-center gap-1"
677
+ }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Icon, {
678
+ icon: "ph--plus--regular"
679
+ }), /* @__PURE__ */ import_react6.default.createElement("span", {
680
+ className: "text-sm"
681
+ }, t("select option add")))))))));
682
+ } finally {
683
+ _effect.f();
684
+ }
590
685
  };
591
686
  var gridCols = [
592
687
  "grid-cols-1",
@@ -595,131 +690,162 @@ var gridCols = [
595
690
  "grid-cols-4"
596
691
  ];
597
692
  var TupleInput = ({ binding, type, label, disabled, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
598
- const { status, error } = getStatus();
599
- const values = getValue3() ?? {};
600
- return /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Input.Root, {
601
- validationValence: status
602
- }, /* @__PURE__ */ import_react7.default.createElement(InputHeader, {
603
- error
604
- }, /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Input.Label, null, label)), /* @__PURE__ */ import_react7.default.createElement("div", {
605
- className: (0, import_react_ui_theme5.mx)("grid gap-2", gridCols[binding.length - 1])
606
- }, binding.map((prop) => /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Input.TextInput, {
607
- key: prop,
608
- type: "number",
609
- disabled,
610
- value: values[prop],
611
- onChange: (event) => onValueChange(type, {
612
- ...values,
613
- [prop]: (0, import_util2.safeParseFloat)(event.target.value, 0)
614
- }),
615
- onBlur
616
- }))));
693
+ var _effect = (0, import_tracking7.useSignals)();
694
+ try {
695
+ const { status, error } = getStatus();
696
+ const values = getValue3() ?? {};
697
+ return /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Input.Root, {
698
+ validationValence: status
699
+ }, /* @__PURE__ */ import_react7.default.createElement(InputHeader, {
700
+ error
701
+ }, /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Input.Label, null, label)), /* @__PURE__ */ import_react7.default.createElement("div", {
702
+ className: (0, import_react_ui_theme5.mx)("grid gap-2", gridCols[binding.length - 1])
703
+ }, binding.map((prop) => /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Input.TextInput, {
704
+ key: prop,
705
+ type: "number",
706
+ disabled,
707
+ value: values[prop],
708
+ onChange: (event) => onValueChange(type, {
709
+ ...values,
710
+ [prop]: (0, import_util2.safeParseFloat)(event.target.value, 0)
711
+ }),
712
+ onBlur
713
+ }))));
714
+ } finally {
715
+ _effect.f();
716
+ }
617
717
  };
618
718
  var TextInput = ({ type, label, inputOnly, disabled, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
619
- const { status, error } = getStatus();
620
- return /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Root, {
621
- validationValence: status
622
- }, !inputOnly && /* @__PURE__ */ import_react8.default.createElement(InputHeader, {
623
- error
624
- }, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Label, null, label)), /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.TextInput, {
625
- disabled,
626
- placeholder,
627
- value: getValue3() ?? "",
628
- onChange: (event) => onValueChange(type, event.target.value),
629
- onBlur
630
- }), inputOnly && /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Validation, null, error));
719
+ var _effect = (0, import_tracking8.useSignals)();
720
+ try {
721
+ const { status, error } = getStatus();
722
+ return disabled && !getValue3() ? null : disabled && inputOnly ? /* @__PURE__ */ import_react8.default.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Root, {
723
+ validationValence: status
724
+ }, !inputOnly && /* @__PURE__ */ import_react8.default.createElement(InputHeader, {
725
+ error
726
+ }, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Label, null, label)), disabled ? /* @__PURE__ */ import_react8.default.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.TextInput, {
727
+ disabled,
728
+ placeholder,
729
+ value: getValue3() ?? "",
730
+ onChange: (event) => onValueChange(type, event.target.value),
731
+ onBlur
732
+ }), inputOnly && /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Validation, null, error));
733
+ } finally {
734
+ _effect.f();
735
+ }
631
736
  };
632
737
  var NumberInput = ({ type, label, inputOnly, disabled, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
633
- const { status, error } = getStatus();
634
- return /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Root, {
635
- validationValence: status
636
- }, !inputOnly && /* @__PURE__ */ import_react8.default.createElement(InputHeader, {
637
- error
638
- }, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Label, null, label)), /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.TextInput, {
639
- type: "number",
640
- disabled,
641
- placeholder,
642
- value: getValue3() ?? 0,
643
- onChange: (event) => onValueChange(type, event.target.value),
644
- onBlur
645
- }), inputOnly && /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.DescriptionAndValidation, null, error));
738
+ var _effect = (0, import_tracking8.useSignals)();
739
+ try {
740
+ const { status, error } = getStatus();
741
+ return disabled && !getValue3() ? null : disabled && inputOnly ? /* @__PURE__ */ import_react8.default.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Root, {
742
+ validationValence: status
743
+ }, !inputOnly && /* @__PURE__ */ import_react8.default.createElement(InputHeader, {
744
+ error
745
+ }, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Label, null, label)), disabled ? /* @__PURE__ */ import_react8.default.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.TextInput, {
746
+ type: "number",
747
+ disabled,
748
+ placeholder,
749
+ value: getValue3() ?? 0,
750
+ onChange: (event) => onValueChange(type, event.target.value),
751
+ onBlur
752
+ }), inputOnly && /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.DescriptionAndValidation, null, error));
753
+ } finally {
754
+ _effect.f();
755
+ }
646
756
  };
647
- var BooleanInput = ({ type, label, inputOnly, getStatus, getValue: getValue3, onValueChange }) => {
648
- const { status, error } = getStatus();
649
- const checked = Boolean(getValue3());
650
- return /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Root, {
651
- validationValence: status
652
- }, !inputOnly && /* @__PURE__ */ import_react8.default.createElement(InputHeader, {
653
- error
654
- }, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Label, null, label)), /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Switch, {
655
- checked,
656
- onCheckedChange: (value) => onValueChange(type, value)
657
- }), inputOnly && /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.DescriptionAndValidation, null, error));
757
+ var BooleanInput = ({ type, label, inputOnly, getStatus, getValue: getValue3, onValueChange, disabled }) => {
758
+ var _effect = (0, import_tracking8.useSignals)();
759
+ try {
760
+ const { status, error } = getStatus();
761
+ const checked = Boolean(getValue3());
762
+ const { t } = (0, import_react_ui8.useTranslation)(translationKey);
763
+ return /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Root, {
764
+ validationValence: status
765
+ }, !inputOnly && /* @__PURE__ */ import_react8.default.createElement(InputHeader, {
766
+ error
767
+ }, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Label, null, label)), disabled ? /* @__PURE__ */ import_react8.default.createElement("p", null, t(checked ? "boolean input true value" : "boolean input false value")) : /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Switch, {
768
+ checked,
769
+ onCheckedChange: (value) => onValueChange(type, value)
770
+ }), inputOnly && /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.DescriptionAndValidation, null, error));
771
+ } finally {
772
+ _effect.f();
773
+ }
658
774
  };
659
775
  var SelectInput = ({ type, label, inputOnly, disabled, placeholder, options, getStatus, getValue: getValue3, onValueChange }) => {
660
- const { status, error } = getStatus();
661
- const value = getValue3();
662
- const handleValueChange = (0, import_react8.useCallback)((value2) => onValueChange(type, value2), [
663
- type,
664
- onValueChange
665
- ]);
666
- return /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Root, {
667
- validationValence: status
668
- }, !inputOnly && /* @__PURE__ */ import_react8.default.createElement(InputHeader, {
669
- error
670
- }, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Label, null, label)), /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.Root, {
671
- value,
672
- onValueChange: handleValueChange
673
- }, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.TriggerButton, {
674
- classNames: "is-full",
675
- disabled,
676
- placeholder
677
- }), /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.Portal, null, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.Content, null, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.Viewport, null, options?.map(({ value: value2, label: label2 }) => (
678
- // NOTE: Numeric values are converted to and from strings.
679
- /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.Option, {
680
- key: String(value2),
681
- value: String(value2)
682
- }, label2 ?? String(value2))
683
- )))))), inputOnly && /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.DescriptionAndValidation, null, error));
776
+ var _effect = (0, import_tracking8.useSignals)();
777
+ try {
778
+ const { status, error } = getStatus();
779
+ const value = getValue3();
780
+ const handleValueChange = (0, import_react8.useCallback)((value2) => onValueChange(type, value2), [
781
+ type,
782
+ onValueChange
783
+ ]);
784
+ return disabled && !value ? null : /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Root, {
785
+ validationValence: status
786
+ }, !inputOnly && /* @__PURE__ */ import_react8.default.createElement(InputHeader, {
787
+ error
788
+ }, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Label, null, label)), disabled ? /* @__PURE__ */ import_react8.default.createElement("p", null, options?.find(({ value: optionValue }) => optionValue === value)?.label ?? String(value)) : /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.Root, {
789
+ value,
790
+ onValueChange: handleValueChange
791
+ }, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.TriggerButton, {
792
+ classNames: "is-full",
793
+ disabled,
794
+ placeholder
795
+ }), /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.Portal, null, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.Content, null, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.Viewport, null, options?.map(({ value: value2, label: label2 }) => (
796
+ // NOTE: Numeric values are converted to and from strings.
797
+ /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.Option, {
798
+ key: String(value2),
799
+ value: String(value2)
800
+ }, label2 ?? String(value2))
801
+ )))))), inputOnly && /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.DescriptionAndValidation, null, error));
802
+ } finally {
803
+ _effect.f();
804
+ }
684
805
  };
685
806
  var MarkdownInput = ({ type, label, inputOnly, disabled, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
686
- const { status, error } = getStatus();
687
- const textareaRef = (0, import_react8.useRef)(null);
688
- const adjustHeight = (0, import_react8.useCallback)(() => {
689
- const textarea = textareaRef.current;
690
- if (textarea) {
691
- textarea.style.blockSize = "auto";
692
- textarea.style.blockSize = `${textarea.scrollHeight + 2}px`;
693
- }
694
- }, []);
695
- (0, import_react8.useEffect)(() => {
696
- adjustHeight();
697
- }, [
698
- adjustHeight
699
- ]);
700
- (0, import_react8.useEffect)(() => {
701
- adjustHeight();
702
- }, [
703
- getValue3(),
704
- adjustHeight
705
- ]);
706
- return /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Root, {
707
- validationValence: status
708
- }, !inputOnly && /* @__PURE__ */ import_react8.default.createElement(InputHeader, {
709
- error
710
- }, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Label, null, label)), /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.TextArea, {
711
- ref: textareaRef,
712
- disabled,
713
- placeholder,
714
- value: getValue3() ?? "",
715
- classNames: "min-bs-auto max-h-40 overflow-auto",
716
- onChange: (event) => onValueChange(type, event.target.value),
717
- onBlur,
718
- style: {
719
- resize: "none"
720
- },
721
- spellCheck: false
722
- }), inputOnly && /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Validation, null, error));
807
+ var _effect = (0, import_tracking8.useSignals)();
808
+ try {
809
+ const { status, error } = getStatus();
810
+ const textareaRef = (0, import_react8.useRef)(null);
811
+ const adjustHeight = (0, import_react8.useCallback)(() => {
812
+ const textarea = textareaRef.current;
813
+ if (textarea) {
814
+ textarea.style.blockSize = "auto";
815
+ textarea.style.blockSize = `${textarea.scrollHeight + 2}px`;
816
+ }
817
+ }, []);
818
+ (0, import_react8.useEffect)(() => {
819
+ adjustHeight();
820
+ }, [
821
+ adjustHeight
822
+ ]);
823
+ (0, import_react8.useEffect)(() => {
824
+ adjustHeight();
825
+ }, [
826
+ getValue3(),
827
+ adjustHeight
828
+ ]);
829
+ return /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Root, {
830
+ validationValence: status
831
+ }, !inputOnly && /* @__PURE__ */ import_react8.default.createElement(InputHeader, {
832
+ error
833
+ }, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Label, null, label)), disabled ? /* @__PURE__ */ import_react8.default.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.TextArea, {
834
+ ref: textareaRef,
835
+ disabled,
836
+ placeholder,
837
+ value: getValue3() ?? "",
838
+ classNames: "min-bs-auto max-h-40 overflow-auto",
839
+ onChange: (event) => onValueChange(type, event.target.value),
840
+ onBlur,
841
+ style: {
842
+ resize: "none"
843
+ },
844
+ spellCheck: false
845
+ }), inputOnly && /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Validation, null, error));
846
+ } finally {
847
+ _effect.f();
848
+ }
723
849
  };
724
850
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/hooks/useForm.ts";
725
851
  var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, onSave }) => {
@@ -922,7 +1048,7 @@ var flatMap = (errors) => {
922
1048
  }, {});
923
1049
  };
924
1050
  var useRefQueryLookupHandler = ({ space }) => {
925
- const handleRefQueryLookup = (0, import_react13.useCallback)(async (typeInfo) => {
1051
+ return (0, import_react13.useCallback)(async (typeInfo) => {
926
1052
  if (!space) {
927
1053
  return [];
928
1054
  }
@@ -942,7 +1068,6 @@ var useRefQueryLookupHandler = ({ space }) => {
942
1068
  }, [
943
1069
  space
944
1070
  ]);
945
- return handleRefQueryLookup;
946
1071
  };
947
1072
  var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/hooks/useQueryRefOptions.ts";
948
1073
  var useQueryRefOptions = ({ refTypeInfo, onQueryRefOptions }) => {
@@ -1014,12 +1139,10 @@ var useInputProps = (path = []) => {
1014
1139
  ]);
1015
1140
  };
1016
1141
  var FormProvider = ({ children, formRef, autoSave, ...formOptions }) => {
1017
- const form = useForm(formOptions);
1018
- (0, import_react11.useEffect)(() => {
1019
- if (!formRef?.current) {
1020
- return;
1021
- }
1022
- const handleKeyDown = (event) => {
1142
+ var _effect = (0, import_tracking11.useSignals)();
1143
+ try {
1144
+ const form = useForm(formOptions);
1145
+ const handleKeyDown = (0, import_react11.useCallback)((event) => {
1023
1146
  const keyIsEnter = event.key === "Enter";
1024
1147
  const modifierUsed = event.ctrlKey || event.altKey || event.metaKey || event.shiftKey;
1025
1148
  const inputIsTextarea = event.target.tagName.toLowerCase() === "textarea";
@@ -1034,43 +1157,55 @@ var FormProvider = ({ children, formRef, autoSave, ...formOptions }) => {
1034
1157
  event.target.blur();
1035
1158
  }
1036
1159
  }
1037
- };
1038
- const formElement = formRef.current;
1039
- formElement.addEventListener("keydown", handleKeyDown);
1040
- return () => formElement.removeEventListener("keydown", handleKeyDown);
1041
- }, [
1042
- formRef,
1043
- form.canSave,
1044
- form.formIsValid,
1045
- form.handleSave,
1046
- autoSave
1047
- ]);
1048
- return /* @__PURE__ */ import_react11.default.createElement(FormContext.Provider, {
1049
- value: form
1050
- }, children);
1160
+ }, [
1161
+ form,
1162
+ autoSave
1163
+ ]);
1164
+ (0, import_react11.useEffect)(() => {
1165
+ if (!formRef?.current) {
1166
+ return;
1167
+ }
1168
+ const formElement = formRef.current;
1169
+ formElement.addEventListener("keydown", handleKeyDown);
1170
+ return () => formElement.removeEventListener("keydown", handleKeyDown);
1171
+ }, [
1172
+ formRef,
1173
+ form.canSave,
1174
+ form.formIsValid,
1175
+ form.handleSave,
1176
+ autoSave
1177
+ ]);
1178
+ return /* @__PURE__ */ import_react11.default.createElement(FormContext.Provider, {
1179
+ value: form
1180
+ }, children);
1181
+ } finally {
1182
+ _effect.f();
1183
+ }
1051
1184
  };
1052
- var FormActions = ({ onCancel, readonly }) => {
1053
- const { t } = (0, import_react_ui9.useTranslation)(translationKey);
1054
- const { canSave, handleSave } = useFormContext();
1055
- return /* @__PURE__ */ import_react10.default.createElement("div", {
1056
- role: "none",
1057
- className: "mt-2 flex justify-center"
1058
- }, /* @__PURE__ */ import_react10.default.createElement("div", {
1059
- role: "none",
1060
- className: (0, import_react_ui_theme7.mx)(onCancel && !readonly && "grid grid-cols-2 gap-2")
1061
- }, onCancel && !readonly && /* @__PURE__ */ import_react10.default.createElement(import_react_ui9.IconButton, {
1062
- "data-testid": "cancel-button",
1063
- icon: "ph--x--regular",
1064
- label: t("button cancel"),
1065
- onClick: onCancel
1066
- }), handleSave && /* @__PURE__ */ import_react10.default.createElement(import_react_ui9.IconButton, {
1067
- type: "submit",
1068
- "data-testid": "save-button",
1069
- disabled: !canSave,
1070
- icon: "ph--check--regular",
1071
- label: t("button save"),
1072
- onClick: handleSave
1073
- })));
1185
+ var FormActions = ({ readonly, onCancel }) => {
1186
+ var _effect = (0, import_tracking10.useSignals)();
1187
+ try {
1188
+ const { t } = (0, import_react_ui9.useTranslation)(translationKey);
1189
+ const { canSave, handleSave } = useFormContext();
1190
+ return /* @__PURE__ */ import_react10.default.createElement("div", {
1191
+ role: "none",
1192
+ className: "flex [&_button]:grow gap-1"
1193
+ }, onCancel && !readonly && /* @__PURE__ */ import_react10.default.createElement(import_react_ui9.IconButton, {
1194
+ "data-testid": "cancel-button",
1195
+ icon: "ph--x--regular",
1196
+ label: t("button cancel"),
1197
+ onClick: onCancel
1198
+ }), handleSave && /* @__PURE__ */ import_react10.default.createElement(import_react_ui9.IconButton, {
1199
+ type: "submit",
1200
+ "data-testid": "save-button",
1201
+ disabled: !canSave,
1202
+ icon: "ph--check--regular",
1203
+ label: t("button save"),
1204
+ onClick: handleSave
1205
+ }));
1206
+ } finally {
1207
+ _effect.f();
1208
+ }
1074
1209
  };
1075
1210
  var parseValue = ({ type, format, value }) => {
1076
1211
  if (value === void 0 || value === null || value === "") {
@@ -1363,229 +1498,250 @@ var getRefProps = (property) => {
1363
1498
  return void 0;
1364
1499
  };
1365
1500
  var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/Form/ArrayField.tsx";
1366
- var padding = "px-2";
1367
1501
  var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponent }) => {
1368
- const { t } = (0, import_react_ui10.useTranslation)(translationKey);
1369
- const { ast, name, type, title } = property;
1370
- const values = useFormValues(path ?? []) ?? [];
1371
- (0, import_invariant2.invariant)(Array.isArray(values), `Values at path ${path?.join(".")} must be an array.`, {
1372
- F: __dxlog_file3,
1373
- L: 39,
1374
- S: void 0,
1375
- A: [
1376
- "Array.isArray(values)",
1377
- "`Values at path ${path?.join('.')} must be an array.`"
1378
- ]
1379
- });
1380
- const label = title ?? (0, import_effect6.pipe)(name, import_String2.capitalize);
1381
- const elementType = findArrayElementType(ast);
1382
- const getDefaultObjectValue = (typeNode) => {
1383
- const baseNode = (0, import_effect7.findNode)(typeNode, import_effect7.isDiscriminatedUnion);
1384
- const typeLiteral = baseNode ? (0, import_effect7.getDiscriminatedType)(baseNode, {}) : (0, import_effect7.findNode)(typeNode, import_effect6.SchemaAST.isTypeLiteral);
1385
- if (!typeLiteral) {
1386
- return {};
1387
- }
1388
- return Object.fromEntries((0, import_schema4.getSchemaProperties)(typeLiteral, {}).map((prop) => [
1389
- prop.name,
1390
- prop.defaultValue
1391
- ]));
1392
- };
1393
- const getDefaultValue = () => type === "object" && elementType ? getDefaultObjectValue(elementType) : import_effect7.SimpleType.getDefaultValue(type);
1394
- const handleAdd = (0, import_react16.useCallback)(() => {
1395
- inputProps.onValueChange(type, [
1396
- ...values,
1397
- getDefaultValue()
1502
+ var _effect = (0, import_tracking13.useSignals)();
1503
+ try {
1504
+ const { t } = (0, import_react_ui10.useTranslation)(translationKey);
1505
+ const { ast, name, type, title } = property;
1506
+ const values = useFormValues(path ?? []) ?? [];
1507
+ (0, import_invariant2.invariant)(Array.isArray(values), `Values at path ${path?.join(".")} must be an array.`, {
1508
+ F: __dxlog_file3,
1509
+ L: 36,
1510
+ S: void 0,
1511
+ A: [
1512
+ "Array.isArray(values)",
1513
+ "`Values at path ${path?.join('.')} must be an array.`"
1514
+ ]
1515
+ });
1516
+ const label = title ?? (0, import_effect6.pipe)(name, import_String2.capitalize);
1517
+ const elementType = findArrayElementType(ast);
1518
+ const getDefaultObjectValue = (typeNode) => {
1519
+ const baseNode = (0, import_effect7.findNode)(typeNode, import_effect7.isDiscriminatedUnion);
1520
+ const typeLiteral = baseNode ? (0, import_effect7.getDiscriminatedType)(baseNode, {}) : (0, import_effect7.findNode)(typeNode, import_effect6.SchemaAST.isTypeLiteral);
1521
+ if (!typeLiteral) {
1522
+ return {};
1523
+ }
1524
+ return Object.fromEntries((0, import_schema4.getSchemaProperties)(typeLiteral, {}).map((prop) => [
1525
+ prop.name,
1526
+ prop.defaultValue
1527
+ ]));
1528
+ };
1529
+ const getDefaultValue = () => type === "object" && elementType ? getDefaultObjectValue(elementType) : import_effect7.SimpleType.getDefaultValue(type);
1530
+ const handleAdd = (0, import_react16.useCallback)(() => {
1531
+ inputProps.onValueChange(type, [
1532
+ ...values,
1533
+ getDefaultValue()
1534
+ ]);
1535
+ }, [
1536
+ type,
1537
+ elementType,
1538
+ inputProps,
1539
+ values
1398
1540
  ]);
1399
- }, [
1400
- type,
1401
- elementType,
1402
- inputProps,
1403
- values
1404
- ]);
1405
- const handleRemove = (0, import_react16.useCallback)((index) => {
1406
- const newValues = values.filter((_, i) => i !== index);
1407
- inputProps.onValueChange(type, newValues);
1408
- }, [
1409
- type,
1410
- inputProps,
1411
- values
1412
- ]);
1413
- if (!elementType) {
1414
- return null;
1541
+ const handleRemove = (0, import_react16.useCallback)((index) => {
1542
+ const newValues = values.filter((_, i) => i !== index);
1543
+ inputProps.onValueChange(type, newValues);
1544
+ }, [
1545
+ type,
1546
+ inputProps,
1547
+ values
1548
+ ]);
1549
+ if (!elementType) {
1550
+ return null;
1551
+ }
1552
+ return readonly && values.length < 1 ? null : /* @__PURE__ */ import_react16.default.createElement(import_react16.default.Fragment, null, /* @__PURE__ */ import_react16.default.createElement(InputHeader, null, label), /* @__PURE__ */ import_react16.default.createElement("div", {
1553
+ role: "none",
1554
+ className: readonly ? "flex flex-wrap gap-1 mlb-1" : values.length > 0 ? "grid gap-1 grid-cols-[1fr_min-content] mlb-1" : "hidden"
1555
+ }, values.map((_value, index) => {
1556
+ const field = /* @__PURE__ */ import_react16.default.createElement(FormField, {
1557
+ property: {
1558
+ ...property,
1559
+ array: false,
1560
+ ast: elementType
1561
+ },
1562
+ path: [
1563
+ ...path ?? [],
1564
+ index
1565
+ ],
1566
+ readonly,
1567
+ inline: true,
1568
+ Custom,
1569
+ lookupComponent
1570
+ });
1571
+ return readonly ? field : /* @__PURE__ */ import_react16.default.createElement(import_react16.Fragment, {
1572
+ key: index
1573
+ }, /* @__PURE__ */ import_react16.default.createElement("div", {
1574
+ role: "none"
1575
+ }, field), /* @__PURE__ */ import_react16.default.createElement(import_react_ui10.IconButton, {
1576
+ icon: "ph--trash--regular",
1577
+ iconOnly: true,
1578
+ label: t("button remove"),
1579
+ onClick: () => handleRemove(index),
1580
+ classNames: "self-center"
1581
+ }));
1582
+ })), !readonly && /* @__PURE__ */ import_react16.default.createElement(import_react_ui10.IconButton, {
1583
+ classNames: "is-full mlb-1 flex",
1584
+ icon: "ph--plus--regular",
1585
+ label: t("add field"),
1586
+ onClick: handleAdd
1587
+ }));
1588
+ } finally {
1589
+ _effect.f();
1415
1590
  }
1416
- return /* @__PURE__ */ import_react16.default.createElement("div", {
1417
- role: "none",
1418
- className: (0, import_react_ui_theme9.mx)(padding)
1419
- }, /* @__PURE__ */ import_react16.default.createElement(InputHeader, null, label), /* @__PURE__ */ import_react16.default.createElement("div", {
1420
- role: "none",
1421
- className: "flex flex-col gap-1"
1422
- }, values.map((_value, index) => /* @__PURE__ */ import_react16.default.createElement("div", {
1423
- key: index,
1424
- role: "none",
1425
- className: "flex items-center gap-1"
1426
- }, /* @__PURE__ */ import_react16.default.createElement("div", {
1427
- role: "none",
1428
- className: "flex-1"
1429
- }, /* @__PURE__ */ import_react16.default.createElement(FormField, {
1430
- property: {
1431
- ...property,
1432
- array: false,
1433
- ast: elementType
1434
- },
1435
- path: [
1436
- ...path ?? [],
1437
- index
1438
- ],
1439
- readonly,
1440
- inline: true,
1441
- Custom,
1442
- lookupComponent
1443
- })), /* @__PURE__ */ import_react16.default.createElement(import_react_ui10.IconButton, {
1444
- icon: "ph--trash--regular",
1445
- iconOnly: true,
1446
- label: t("button remove"),
1447
- onClick: () => handleRemove(index)
1448
- })))), /* @__PURE__ */ import_react16.default.createElement("div", {
1449
- role: "none",
1450
- className: "flex justify-between items-center plb-1"
1451
- }, /* @__PURE__ */ import_react16.default.createElement(import_react_ui10.IconButton, {
1452
- icon: "ph--plus--regular",
1453
- iconOnly: true,
1454
- label: t("button add"),
1455
- onClick: handleAdd
1456
- })));
1457
1591
  };
1458
1592
  var RefField = ({ type, label, disabled, placeholder, inputOnly, array, ast, getValue: getValue3, onBlur, onQueryRefOptions, onValueChange, ...restInputProps }) => {
1459
- const refTypeInfo = (0, import_react17.useMemo)(() => ast ? (0, import_effect11.findAnnotation)(ast, import_echo_schema9.ReferenceAnnotationId) : void 0, [
1460
- ast
1461
- ]);
1462
- const { options: availableOptions, loading: _loading } = useQueryRefOptions({
1463
- refTypeInfo,
1464
- onQueryRefOptions
1465
- });
1466
- if (refTypeInfo && refTypeInfo?.typename === (0, import_echo_schema9.getTypeAnnotation)(import_echo_schema9.Expando)?.typename || !onQueryRefOptions) {
1467
- return /* @__PURE__ */ import_react17.default.createElement(RefFieldFallback, {
1468
- type,
1469
- label,
1470
- placeholder,
1471
- disabled,
1472
- inputOnly,
1473
- getValue: getValue3,
1474
- onBlur,
1475
- onValueChange,
1476
- ...restInputProps
1593
+ var _effect = (0, import_tracking14.useSignals)();
1594
+ try {
1595
+ const { t } = (0, import_react_ui11.useTranslation)(translationKey);
1596
+ const refTypeInfo = (0, import_react17.useMemo)(() => ast ? (0, import_effect11.findAnnotation)(ast, import_echo_schema9.ReferenceAnnotationId) : void 0, [
1597
+ ast
1598
+ ]);
1599
+ const { options: availableOptions, loading: _loading } = useQueryRefOptions({
1600
+ refTypeInfo,
1601
+ onQueryRefOptions
1477
1602
  });
1478
- }
1479
- const handleGetValue = (0, import_react17.useCallback)(() => {
1480
- const formValue = getValue3();
1481
- const unknownToRefOption = (val) => {
1482
- if (import_echo_schema9.Ref.isRef(val)) {
1483
- const dxnString = val.dxn.toString();
1484
- const matchingOption = availableOptions.find((option2) => option2.id === dxnString);
1485
- if (matchingOption) {
1486
- return matchingOption;
1603
+ if (refTypeInfo && refTypeInfo?.typename === (0, import_echo_schema9.getTypeAnnotation)(import_echo_schema9.Expando)?.typename || !onQueryRefOptions) {
1604
+ return /* @__PURE__ */ import_react17.default.createElement(RefFieldFallback, {
1605
+ type,
1606
+ label,
1607
+ placeholder,
1608
+ disabled,
1609
+ inputOnly,
1610
+ getValue: getValue3,
1611
+ onBlur,
1612
+ onValueChange,
1613
+ ...restInputProps
1614
+ });
1615
+ }
1616
+ const handleGetValue = (0, import_react17.useCallback)(() => {
1617
+ const formValue = getValue3();
1618
+ const unknownToRefOption = (val) => {
1619
+ if (import_echo_schema9.Ref.isRef(val)) {
1620
+ const dxnString = val.dxn.toString();
1621
+ const matchingOption = availableOptions.find((option2) => option2.id === dxnString);
1622
+ if (matchingOption) {
1623
+ return matchingOption;
1624
+ }
1487
1625
  }
1626
+ return void 0;
1627
+ };
1628
+ if (array && Array.isArray(formValue)) {
1629
+ return formValue.map(unknownToRefOption).filter(import_util5.isNonNullable) ?? [];
1488
1630
  }
1489
- return void 0;
1490
- };
1491
- if (array && Array.isArray(formValue)) {
1492
- return formValue.map(unknownToRefOption).filter(import_util5.isNonNullable) ?? [];
1493
- }
1494
- const option = unknownToRefOption(formValue);
1495
- if (option) {
1496
- return [
1497
- option
1498
- ];
1499
- }
1500
- return [];
1501
- }, [
1502
- getValue3,
1503
- availableOptions,
1504
- array
1505
- ]);
1506
- const handleSearch = (0, import_react17.useCallback)((text, ids) => availableOptions.filter((option) => !ids.includes(option.id)).filter((option) => option.label.toLowerCase().includes(text.toLowerCase())).map((option) => ({
1507
- id: option.id,
1508
- label: option.label,
1509
- hue: option.hue
1510
- })), [
1511
- availableOptions
1512
- ]);
1513
- const handleUpdate = (0, import_react17.useCallback)((ids) => {
1514
- if (ids.length === 0) {
1515
- onValueChange("object", void 0);
1516
- return;
1517
- }
1518
- const refs = ids.map((id) => {
1519
- const item = availableOptions.find((option) => option.id === id);
1520
- if (item) {
1521
- const dxn = import_keys2.DXN.parse(item.id);
1522
- return import_echo_schema9.Ref.fromDXN(dxn);
1631
+ const option = unknownToRefOption(formValue);
1632
+ if (option) {
1633
+ return [
1634
+ option
1635
+ ];
1636
+ }
1637
+ return [];
1638
+ }, [
1639
+ getValue3,
1640
+ availableOptions,
1641
+ array
1642
+ ]);
1643
+ const handleSearch = (0, import_react17.useCallback)((text, ids) => availableOptions.filter((option) => !ids.includes(option.id)).filter((option) => option.label.toLowerCase().includes(text.toLowerCase())).map((option) => ({
1644
+ id: option.id,
1645
+ label: option.label,
1646
+ hue: option.hue
1647
+ })), [
1648
+ availableOptions
1649
+ ]);
1650
+ const handleUpdate = (0, import_react17.useCallback)((ids) => {
1651
+ if (ids.length === 0) {
1652
+ onValueChange("object", void 0);
1653
+ return;
1654
+ }
1655
+ const refs = ids.map((id) => {
1656
+ const item = availableOptions.find((option) => option.id === id);
1657
+ if (item) {
1658
+ const dxn = import_keys2.DXN.parse(item.id);
1659
+ return import_echo_schema9.Ref.fromDXN(dxn);
1660
+ }
1661
+ return null;
1662
+ }).filter(import_util5.isNonNullable);
1663
+ if (array) {
1664
+ onValueChange("object", refs);
1665
+ } else {
1666
+ onValueChange("object", refs[0]);
1523
1667
  }
1668
+ }, [
1669
+ availableOptions,
1670
+ array,
1671
+ onValueChange
1672
+ ]);
1673
+ const tagPickerMode = (0, import_react17.useMemo)(() => array ? "multi-select" : "single-select", [
1674
+ array
1675
+ ]);
1676
+ if (!refTypeInfo) {
1524
1677
  return null;
1525
- }).filter(import_util5.isNonNullable);
1526
- if (array) {
1527
- onValueChange("object", refs);
1528
- } else {
1529
- onValueChange("object", refs[0]);
1530
1678
  }
1531
- }, [
1532
- availableOptions,
1533
- array,
1534
- onValueChange
1535
- ]);
1536
- const tagPickerMode = (0, import_react17.useMemo)(() => array ? "multi-select" : "single-select", [
1537
- array
1538
- ]);
1539
- if (!refTypeInfo) {
1540
- return null;
1679
+ const { status, error } = restInputProps.getStatus();
1680
+ const items = handleGetValue();
1681
+ return disabled && items.length < 1 ? null : /* @__PURE__ */ import_react17.default.createElement(import_react_ui11.Input.Root, {
1682
+ validationValence: status
1683
+ }, !inputOnly && /* @__PURE__ */ import_react17.default.createElement(InputHeader, {
1684
+ error
1685
+ }, /* @__PURE__ */ import_react17.default.createElement(import_react_ui11.Input.Label, null, label)), /* @__PURE__ */ import_react17.default.createElement("div", {
1686
+ "data-no-submit": true
1687
+ }, disabled ? items.length < 1 ? /* @__PURE__ */ import_react17.default.createElement("p", {
1688
+ className: (0, import_react_ui_theme8.mx)(import_react_ui_theme8.descriptionText, "mbe-2")
1689
+ }, t("empty readonly ref field label")) : items.map((item) => /* @__PURE__ */ import_react17.default.createElement(import_react18.DxRefTag, {
1690
+ key: item.id,
1691
+ refid: item.id,
1692
+ rootclassname: "mie-1",
1693
+ style: {
1694
+ marginInlineEnd: ".25rem"
1695
+ }
1696
+ }, item.label)) : /* @__PURE__ */ import_react17.default.createElement(import_react_ui_tag_picker.TagPicker, {
1697
+ readonly: disabled,
1698
+ items,
1699
+ mode: tagPickerMode,
1700
+ onBlur: (event) => onBlur(event),
1701
+ onUpdate: handleUpdate,
1702
+ onSearch: handleSearch,
1703
+ classNames: "rounded-sm bg-inputSurface p-1.5"
1704
+ })), inputOnly && /* @__PURE__ */ import_react17.default.createElement(import_react_ui11.Input.DescriptionAndValidation, null, error));
1705
+ } finally {
1706
+ _effect.f();
1541
1707
  }
1542
- const { status, error } = restInputProps.getStatus();
1543
- return /* @__PURE__ */ import_react17.default.createElement(import_react_ui11.Input.Root, {
1544
- validationValence: status
1545
- }, !inputOnly && /* @__PURE__ */ import_react17.default.createElement(InputHeader, {
1546
- error
1547
- }, /* @__PURE__ */ import_react17.default.createElement(import_react_ui11.Input.Label, null, label)), /* @__PURE__ */ import_react17.default.createElement("div", {
1548
- "data-no-submit": true
1549
- }, /* @__PURE__ */ import_react17.default.createElement(import_react_ui_tag_picker.TagPicker, {
1550
- items: handleGetValue(),
1551
- mode: tagPickerMode,
1552
- onBlur: (event) => onBlur(event),
1553
- onUpdate: handleUpdate,
1554
- onSearch: handleSearch,
1555
- classNames: "rounded-sm bg-input p-1.5"
1556
- })), inputOnly && /* @__PURE__ */ import_react17.default.createElement(import_react_ui11.Input.DescriptionAndValidation, null, error));
1557
1708
  };
1558
1709
  var RefFieldFallback = ({ type, label, disabled, placeholder, inputOnly, getValue: getValue3, onValueChange, ...restInputProps }) => {
1559
- const handleOnValueChange = (_type, dxnString) => {
1560
- const dxn = import_keys2.DXN.tryParse(dxnString);
1561
- if (dxn) {
1562
- onValueChange?.("object", import_echo_schema9.Ref.fromDXN(dxn));
1563
- } else if (dxnString === "") {
1564
- onValueChange?.("object", void 0);
1565
- } else {
1566
- onValueChange?.("string", dxnString);
1567
- }
1568
- };
1569
- const handleGetValue = () => {
1570
- const formValue = getValue3();
1571
- if (typeof formValue === "string") {
1572
- return formValue;
1573
- }
1574
- if (import_echo_schema9.Ref.isRef(formValue)) {
1575
- return formValue.dxn.toString();
1576
- }
1577
- return void 0;
1578
- };
1579
- return /* @__PURE__ */ import_react17.default.createElement(TextInput, {
1580
- type,
1581
- label,
1582
- disabled,
1583
- placeholder,
1584
- inputOnly,
1585
- getValue: handleGetValue,
1586
- onValueChange: handleOnValueChange,
1587
- ...restInputProps
1588
- });
1710
+ var _effect = (0, import_tracking14.useSignals)();
1711
+ try {
1712
+ const handleOnValueChange = (_type, dxnString) => {
1713
+ const dxn = import_keys2.DXN.tryParse(dxnString);
1714
+ if (dxn) {
1715
+ onValueChange?.("object", import_echo_schema9.Ref.fromDXN(dxn));
1716
+ } else if (dxnString === "") {
1717
+ onValueChange?.("object", void 0);
1718
+ } else {
1719
+ onValueChange?.("string", dxnString);
1720
+ }
1721
+ };
1722
+ const handleGetValue = () => {
1723
+ const formValue = getValue3();
1724
+ if (typeof formValue === "string") {
1725
+ return formValue;
1726
+ }
1727
+ if (import_echo_schema9.Ref.isRef(formValue)) {
1728
+ return formValue.dxn.toString();
1729
+ }
1730
+ return void 0;
1731
+ };
1732
+ return /* @__PURE__ */ import_react17.default.createElement(TextInput, {
1733
+ type,
1734
+ label,
1735
+ disabled,
1736
+ placeholder,
1737
+ inputOnly,
1738
+ getValue: handleGetValue,
1739
+ onValueChange: handleOnValueChange,
1740
+ ...restInputProps
1741
+ });
1742
+ } finally {
1743
+ _effect.f();
1744
+ }
1589
1745
  };
1590
1746
  var getInputComponent = (type, format) => {
1591
1747
  switch (format) {
@@ -1604,556 +1760,600 @@ var getInputComponent = (type, format) => {
1604
1760
  }
1605
1761
  };
1606
1762
  var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupComponent, Custom }) => {
1607
- const inputProps = useInputProps(path);
1608
- const { ast, name, type, format, title, description, options, examples, array } = property;
1609
- const label = (0, import_react15.useMemo)(() => title ?? (0, import_effect4.pipe)(name, import_String.capitalize), [
1610
- title,
1611
- name
1612
- ]);
1613
- const placeholder = (0, import_react15.useMemo)(() => examples?.length ? `Example: "${examples[0]}"` : description, [
1614
- examples,
1615
- description
1616
- ]);
1617
- const FoundComponent = lookupComponent?.({
1618
- prop: name,
1619
- schema: import_effect4.Schema.make(ast),
1620
- inputProps: {
1621
- type,
1622
- format,
1623
- label,
1624
- disabled: readonly,
1625
- placeholder,
1626
- ...inputProps
1627
- }
1628
- });
1629
- if (FoundComponent) {
1630
- return /* @__PURE__ */ import_react15.default.createElement("div", {
1631
- role: "none"
1632
- }, FoundComponent);
1633
- }
1634
- const jsonPath = (0, import_effect5.createJsonPath)(path ?? []);
1635
- const CustomComponent = Custom?.[jsonPath];
1636
- if (CustomComponent) {
1637
- return /* @__PURE__ */ import_react15.default.createElement(CustomComponent, {
1638
- type,
1639
- format,
1640
- label,
1641
- inputOnly: inline,
1642
- placeholder,
1643
- disabled: readonly,
1644
- ...inputProps
1645
- });
1646
- }
1647
- const refProps = getRefProps(property);
1648
- if (refProps) {
1649
- return /* @__PURE__ */ import_react15.default.createElement(RefField, {
1650
- ast: refProps.ast,
1651
- array: refProps.isArray,
1652
- type,
1653
- format,
1654
- label,
1655
- placeholder,
1656
- disabled: readonly,
1657
- inputOnly: inline,
1658
- onQueryRefOptions,
1659
- ...inputProps
1660
- });
1661
- }
1662
- if (array) {
1663
- return /* @__PURE__ */ import_react15.default.createElement(ArrayField, {
1664
- property,
1665
- path,
1666
- inputProps,
1667
- readonly,
1668
- Custom
1763
+ var _effect = (0, import_tracking12.useSignals)();
1764
+ try {
1765
+ const inputProps = useInputProps(path);
1766
+ const { ast, name, type, format, title, description, options, examples, array } = property;
1767
+ const label = (0, import_react15.useMemo)(() => title ?? (0, import_effect4.pipe)(name, import_String.capitalize), [
1768
+ title,
1769
+ name
1770
+ ]);
1771
+ const placeholder = (0, import_react15.useMemo)(() => examples?.length ? `Example: "${examples[0]}"` : description, [
1772
+ examples,
1773
+ description
1774
+ ]);
1775
+ const FoundComponent = lookupComponent?.({
1776
+ prop: name,
1777
+ schema: import_effect4.Schema.make(ast),
1778
+ inputProps: {
1779
+ type,
1780
+ format,
1781
+ label,
1782
+ disabled: readonly,
1783
+ placeholder,
1784
+ ...inputProps
1785
+ }
1669
1786
  });
1670
- }
1671
- const InputComponent = getInputComponent(type, format);
1672
- if (InputComponent) {
1673
- return /* @__PURE__ */ import_react15.default.createElement("div", {
1674
- role: "none"
1675
- }, /* @__PURE__ */ import_react15.default.createElement(InputComponent, {
1676
- type,
1677
- format,
1678
- label,
1679
- inputOnly: inline,
1680
- placeholder,
1681
- disabled: readonly,
1682
- ...inputProps
1683
- }));
1684
- }
1685
- if (options) {
1686
- return /* @__PURE__ */ import_react15.default.createElement("div", {
1687
- role: "none"
1688
- }, /* @__PURE__ */ import_react15.default.createElement(SelectInput, {
1689
- type,
1690
- format,
1691
- disabled: readonly,
1692
- inputOnly: inline,
1693
- label,
1694
- options: options.map((option) => ({
1695
- value: option,
1696
- label: String(option)
1697
- })),
1698
- placeholder,
1699
- ...inputProps
1700
- }));
1701
- }
1702
- if (type === "object") {
1703
- const baseNode = (0, import_effect5.findNode)(ast, import_effect5.isDiscriminatedUnion);
1704
- const typeLiteral = baseNode ? (0, import_effect5.getDiscriminatedType)(baseNode, inputProps.getValue()) : (0, import_effect5.findNode)(ast, import_effect4.SchemaAST.isTypeLiteral);
1705
- if (typeLiteral) {
1706
- return /* @__PURE__ */ import_react15.default.createElement("div", {
1707
- role: "none"
1708
- }, !inline && /* @__PURE__ */ import_react15.default.createElement("h3", {
1709
- className: "text-lg mbs-2 mbe-1"
1710
- }, label), /* @__PURE__ */ import_react15.default.createElement(FormFields, {
1711
- schema: import_effect4.Schema.make(typeLiteral),
1787
+ if (FoundComponent) {
1788
+ return FoundComponent;
1789
+ }
1790
+ const jsonPath = (0, import_effect5.createJsonPath)(path ?? []);
1791
+ const CustomComponent = Custom?.[jsonPath];
1792
+ if (CustomComponent) {
1793
+ return /* @__PURE__ */ import_react15.default.createElement(CustomComponent, {
1794
+ type,
1795
+ format,
1796
+ label,
1797
+ inputOnly: inline,
1798
+ placeholder,
1799
+ disabled: readonly,
1800
+ ...inputProps
1801
+ });
1802
+ }
1803
+ const refProps = getRefProps(property);
1804
+ if (refProps) {
1805
+ return /* @__PURE__ */ import_react15.default.createElement(RefField, {
1806
+ ast: refProps.ast,
1807
+ array: refProps.isArray,
1808
+ type,
1809
+ format,
1810
+ label,
1811
+ placeholder,
1812
+ disabled: readonly,
1813
+ inputOnly: inline,
1814
+ onQueryRefOptions,
1815
+ ...inputProps
1816
+ });
1817
+ }
1818
+ if (array) {
1819
+ return /* @__PURE__ */ import_react15.default.createElement(ArrayField, {
1820
+ property,
1712
1821
  path,
1822
+ inputProps,
1713
1823
  readonly,
1714
- onQueryRefOptions,
1715
- Custom,
1716
- lookupComponent
1717
- }));
1824
+ Custom
1825
+ });
1826
+ }
1827
+ const InputComponent = getInputComponent(type, format);
1828
+ if (InputComponent) {
1829
+ return /* @__PURE__ */ import_react15.default.createElement(InputComponent, {
1830
+ type,
1831
+ format,
1832
+ label,
1833
+ inputOnly: inline,
1834
+ placeholder,
1835
+ disabled: readonly,
1836
+ ...inputProps
1837
+ });
1838
+ }
1839
+ if (options) {
1840
+ return /* @__PURE__ */ import_react15.default.createElement(SelectInput, {
1841
+ type,
1842
+ format,
1843
+ disabled: readonly,
1844
+ inputOnly: inline,
1845
+ label,
1846
+ options: options.map((option) => ({
1847
+ value: option,
1848
+ label: String(option)
1849
+ })),
1850
+ placeholder,
1851
+ ...inputProps
1852
+ });
1718
1853
  }
1854
+ if (type === "object") {
1855
+ const baseNode = (0, import_effect5.findNode)(ast, import_effect5.isDiscriminatedUnion);
1856
+ const typeLiteral = baseNode ? (0, import_effect5.getDiscriminatedType)(baseNode, inputProps.getValue()) : (0, import_effect5.findNode)(ast, import_effect4.SchemaAST.isTypeLiteral);
1857
+ if (typeLiteral) {
1858
+ return /* @__PURE__ */ import_react15.default.createElement(import_react15.default.Fragment, null, !inline && /* @__PURE__ */ import_react15.default.createElement("h3", {
1859
+ className: "text-lg mbs-2 mbe-1 first:mbs-0"
1860
+ }, label), /* @__PURE__ */ import_react15.default.createElement(FormFields, {
1861
+ schema: import_effect4.Schema.make(typeLiteral),
1862
+ path,
1863
+ readonly,
1864
+ onQueryRefOptions,
1865
+ Custom,
1866
+ lookupComponent
1867
+ }));
1868
+ }
1869
+ }
1870
+ return null;
1871
+ } finally {
1872
+ _effect.f();
1719
1873
  }
1720
- return null;
1721
1874
  };
1722
- var FormFields = ({ schema, path, filter, sort, readonly, onQueryRefOptions, lookupComponent, Custom }) => {
1723
- const values = useFormValues(path);
1724
- const properties = (0, import_react15.useMemo)(() => {
1725
- const props = (0, import_schema3.getSchemaProperties)(schema.ast, values);
1726
- const filtered = filter ? filter(props) : props;
1727
- return sort ? filtered.sort((a, b) => sort.indexOf(a.name) - sort.indexOf(b.name)) : filtered;
1728
- }, [
1729
- schema,
1730
- values,
1731
- filter,
1732
- sort
1733
- ]);
1734
- return /* @__PURE__ */ import_react15.default.createElement("div", {
1735
- role: "form",
1736
- className: (0, import_react_ui_theme8.mx)("flex flex-col w-full gap-2")
1737
- }, properties.map((property) => {
1738
- return /* @__PURE__ */ import_react15.default.createElement(FormField, {
1739
- key: property.name,
1740
- property,
1741
- path: [
1742
- ...path ?? [],
1743
- property.name
1744
- ],
1875
+ var FormFields = ({ classNames, Custom, schema, path, filter, sort, readonly, lookupComponent, onQueryRefOptions }) => {
1876
+ var _effect = (0, import_tracking12.useSignals)();
1877
+ try {
1878
+ const values = useFormValues(path);
1879
+ const properties = (0, import_react15.useMemo)(() => {
1880
+ const props = (0, import_schema3.getSchemaProperties)(schema.ast, values);
1881
+ const filtered = filter ? filter(props) : props;
1882
+ return sort ? filtered.sort((a, b) => sort.indexOf(a.name) - sort.indexOf(b.name)) : filtered;
1883
+ }, [
1884
+ schema,
1885
+ values,
1886
+ filter,
1887
+ sort
1888
+ ]);
1889
+ return (
1890
+ // TODO(burdon): Consistent padding (with composite forms).
1891
+ /* @__PURE__ */ import_react15.default.createElement("div", {
1892
+ role: "form",
1893
+ className: (0, import_react_ui_theme7.mx)("p-2 is-full", classNames)
1894
+ }, properties.map((property) => {
1895
+ return /* @__PURE__ */ import_react15.default.createElement(FormField, {
1896
+ key: property.name,
1897
+ property,
1898
+ path: [
1899
+ ...path ?? [],
1900
+ property.name
1901
+ ],
1902
+ readonly,
1903
+ onQueryRefOptions,
1904
+ lookupComponent,
1905
+ Custom
1906
+ });
1907
+ }).filter(import_util4.isNotFalsy))
1908
+ );
1909
+ } finally {
1910
+ _effect.f();
1911
+ }
1912
+ };
1913
+ var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, readonly, filter, sort, autoSave, testId, onValuesChanged, onValidate, onSave, onCancel, onQueryRefOptions, lookupComponent, Custom }) => {
1914
+ var _effect = (0, import_tracking9.useSignals)();
1915
+ try {
1916
+ const formRef = (0, import_react9.useRef)(null);
1917
+ const onValid = (0, import_react9.useMemo)(() => autoSave ? onSave : void 0, [
1918
+ autoSave,
1919
+ onSave
1920
+ ]);
1921
+ (0, import_react9.useEffect)(() => {
1922
+ if (autoFocus && formRef.current) {
1923
+ const input = formRef.current.querySelector("input");
1924
+ if (input) {
1925
+ input.focus();
1926
+ }
1927
+ }
1928
+ }, [
1929
+ autoFocus
1930
+ ]);
1931
+ return /* @__PURE__ */ import_react9.default.createElement(FormProvider, {
1932
+ formRef,
1933
+ schema,
1934
+ autoSave,
1935
+ initialValues,
1936
+ onValuesChanged,
1937
+ onValidate,
1938
+ onValid,
1939
+ onSave
1940
+ }, /* @__PURE__ */ import_react9.default.createElement("div", {
1941
+ ref: formRef,
1942
+ role: "none",
1943
+ className: (0, import_react_ui_theme6.mx)("flex flex-col gap-4", classNames),
1944
+ "data-testid": testId
1945
+ }, /* @__PURE__ */ import_react9.default.createElement(FormFields, {
1946
+ schema,
1947
+ path,
1745
1948
  readonly,
1949
+ filter,
1950
+ sort,
1746
1951
  onQueryRefOptions,
1747
1952
  lookupComponent,
1748
1953
  Custom
1749
- });
1750
- }).filter(import_util4.isNotFalsy));
1751
- };
1752
- var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, readonly, filter, sort, autoSave, testId, onValuesChanged, onValidate, onSave, onCancel, onQueryRefOptions, lookupComponent, Custom }) => {
1753
- const formRef = (0, import_react9.useRef)(null);
1754
- const onValid = (0, import_react9.useMemo)(() => autoSave ? onSave : void 0, [
1755
- autoSave,
1756
- onSave
1757
- ]);
1758
- (0, import_react9.useEffect)(() => {
1759
- if (autoFocus && formRef.current) {
1760
- const input = formRef.current.querySelector("input");
1761
- if (input) {
1762
- input.focus();
1763
- }
1764
- }
1765
- }, [
1766
- autoFocus
1767
- ]);
1768
- return /* @__PURE__ */ import_react9.default.createElement(FormProvider, {
1769
- formRef,
1770
- schema,
1771
- autoSave,
1772
- initialValues,
1773
- onValuesChanged,
1774
- onValidate,
1775
- onValid,
1776
- onSave
1777
- }, /* @__PURE__ */ import_react9.default.createElement("div", {
1778
- ref: formRef,
1779
- role: "none",
1780
- className: (0, import_react_ui_theme6.mx)("p-2", classNames),
1781
- "data-testid": testId
1782
- }, /* @__PURE__ */ import_react9.default.createElement(FormFields, {
1783
- schema,
1784
- path,
1785
- readonly,
1786
- filter,
1787
- sort,
1788
- onQueryRefOptions,
1789
- lookupComponent,
1790
- Custom
1791
- }), (onCancel || onSave) && !autoSave && /* @__PURE__ */ import_react9.default.createElement(FormActions, {
1792
- onCancel,
1793
- readonly
1794
- })));
1954
+ }), (onCancel || onSave) && !autoSave && /* @__PURE__ */ import_react9.default.createElement(FormActions, {
1955
+ onCancel,
1956
+ readonly
1957
+ })));
1958
+ } finally {
1959
+ _effect.f();
1960
+ }
1795
1961
  };
1796
1962
  var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx";
1797
1963
  var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
1798
- const { t } = (0, import_react_ui3.useTranslation)(translationKey);
1799
- const [props, setProps] = (0, import_react3.useState)(projection.getFieldProjection(field.id).props);
1800
- (0, import_react3.useEffect)(() => setProps(projection.getFieldProjection(field.id).props), [
1801
- field,
1802
- projection
1803
- ]);
1804
- const [schemas, setSchemas] = (0, import_react3.useState)([]);
1805
- (0, import_react3.useEffect)(() => {
1806
- if (!registry) {
1807
- return;
1808
- }
1809
- const subscription = registry.query().subscribe((query) => setSchemas(query.results), {
1810
- fire: true
1811
- });
1812
- const t2 = setTimeout(async () => {
1813
- const schemas2 = await registry.query().run();
1814
- setSchemas(schemas2);
1815
- });
1816
- return () => {
1817
- clearTimeout(t2);
1818
- subscription?.();
1819
- };
1820
- }, [
1821
- registry
1822
- ]);
1823
- const [referenceSchema, setReferenceSchema] = (0, import_react3.useState)();
1824
- (0, import_react3.useEffect)(() => {
1825
- setReferenceSchema(schemas.find((schema) => schema.typename === props?.referenceSchema));
1826
- }, [
1827
- schemas,
1828
- props?.referenceSchema
1829
- ]);
1830
- const [{ fieldSchema }, setFieldSchema] = (0, import_react3.useState)({
1831
- fieldSchema: (0, import_schema.getFormatSchema)(props?.format)
1832
- });
1833
- const handleValuesChanged = (0, import_react3.useCallback)((_props) => {
1834
- setFieldSchema((prev) => {
1835
- const fieldSchema2 = (0, import_schema.getFormatSchema)(_props.format);
1836
- if (prev.fieldSchema === fieldSchema2) {
1837
- return prev;
1964
+ var _effect = (0, import_tracking3.useSignals)();
1965
+ try {
1966
+ const { t } = (0, import_react_ui3.useTranslation)(translationKey);
1967
+ const [props, setProps] = (0, import_react3.useState)(projection.getFieldProjection(field.id).props);
1968
+ (0, import_react3.useEffect)(() => setProps(projection.getFieldProjection(field.id).props), [
1969
+ field,
1970
+ projection
1971
+ ]);
1972
+ const [schemas, setSchemas] = (0, import_react3.useState)([]);
1973
+ (0, import_react3.useEffect)(() => {
1974
+ if (!registry) {
1975
+ return;
1838
1976
  }
1839
- return {
1840
- fieldSchema: fieldSchema2
1977
+ const subscription = registry.query().subscribe((query) => setSchemas(query.results), {
1978
+ fire: true
1979
+ });
1980
+ const t2 = setTimeout(async () => {
1981
+ const schemas2 = await registry.query().run();
1982
+ setSchemas(schemas2);
1983
+ });
1984
+ return () => {
1985
+ clearTimeout(t2);
1986
+ subscription?.();
1841
1987
  };
1988
+ }, [
1989
+ registry
1990
+ ]);
1991
+ const [referenceSchema, setReferenceSchema] = (0, import_react3.useState)();
1992
+ (0, import_react3.useEffect)(() => {
1993
+ setReferenceSchema(schemas.find((schema) => schema.typename === props?.referenceSchema));
1994
+ }, [
1995
+ schemas,
1996
+ props?.referenceSchema
1997
+ ]);
1998
+ const [{ fieldSchema }, setFieldSchema] = (0, import_react3.useState)({
1999
+ fieldSchema: (0, import_schema.getFormatSchema)(props?.format)
1842
2000
  });
1843
- setReferenceSchema((prev) => {
1844
- if (_props.referenceSchema !== prev?.typename) {
1845
- const newSchema = schemas.find((schema) => schema.typename === _props.referenceSchema);
1846
- if (newSchema) {
1847
- return newSchema;
2001
+ const handleValuesChanged = (0, import_react3.useCallback)((_props) => {
2002
+ setFieldSchema((prev) => {
2003
+ const fieldSchema2 = (0, import_schema.getFormatSchema)(_props.format);
2004
+ if (prev.fieldSchema === fieldSchema2) {
2005
+ return prev;
1848
2006
  }
1849
- }
1850
- return prev;
1851
- });
1852
- setProps((props2) => {
1853
- const type = import_echo_schema.formatToType[_props.format];
1854
- if (props2.type !== type) {
1855
2007
  return {
1856
- ...props2,
1857
- ..._props,
1858
- type
2008
+ fieldSchema: fieldSchema2
1859
2009
  };
1860
- }
1861
- return _props;
1862
- });
1863
- }, [
1864
- schemas,
1865
- props.format,
1866
- props.referenceSchema
1867
- ]);
1868
- const handleValidate = (0, import_react3.useCallback)(({ property }) => {
1869
- if (property && view.fields.find((f) => f.path === property && f.path !== field.path)) {
1870
- return [
1871
- {
1872
- path: "property",
1873
- message: `property is not unique: '${property}'`
2010
+ });
2011
+ setReferenceSchema((prev) => {
2012
+ if (_props.referenceSchema !== prev?.typename) {
2013
+ const newSchema = schemas.find((schema) => schema.typename === _props.referenceSchema);
2014
+ if (newSchema) {
2015
+ return newSchema;
2016
+ }
1874
2017
  }
1875
- ];
1876
- }
1877
- }, [
1878
- view.fields,
1879
- field
1880
- ]);
1881
- const handleSave = (0, import_react3.useCallback)((props2) => {
1882
- projection.setFieldProjection({
2018
+ return prev;
2019
+ });
2020
+ setProps((props2) => {
2021
+ const type = import_echo_schema.formatToType[_props.format];
2022
+ if (props2.type !== type) {
2023
+ return {
2024
+ ...props2,
2025
+ ..._props,
2026
+ type
2027
+ };
2028
+ }
2029
+ return _props;
2030
+ });
2031
+ }, [
2032
+ schemas,
2033
+ props.format,
2034
+ props.referenceSchema
2035
+ ]);
2036
+ const handleValidate = (0, import_react3.useCallback)(({ property }) => {
2037
+ if (property && view.fields.find((f) => f.path === property && f.path !== field.path)) {
2038
+ return [
2039
+ {
2040
+ path: "property",
2041
+ message: `property is not unique: '${property}'`
2042
+ }
2043
+ ];
2044
+ }
2045
+ }, [
2046
+ view.fields,
2047
+ field
2048
+ ]);
2049
+ const handleSave = (0, import_react3.useCallback)((props2) => {
2050
+ projection.setFieldProjection({
2051
+ field,
2052
+ props: props2
2053
+ });
2054
+ onSave();
2055
+ }, [
2056
+ projection,
1883
2057
  field,
1884
- props: props2
1885
- });
1886
- onSave();
1887
- }, [
1888
- projection,
1889
- field,
1890
- onSave
1891
- ]);
1892
- const handleCancel = (0, import_react3.useCallback)(() => {
1893
- requestAnimationFrame(() => onCancel?.());
1894
- onSave();
1895
- }, [
1896
- onSave
1897
- ]);
1898
- const Custom = (0, import_react3.useMemo)(() => ({
1899
- ["format"]: (props2) => /* @__PURE__ */ import_react3.default.createElement(SelectInput, {
1900
- ...props2,
1901
- options: import_echo_schema.FormatEnums.filter((value) => value !== import_echo_schema.FormatEnum.None).map((value) => ({
1902
- value,
1903
- label: t(`format ${value}`)
1904
- }))
1905
- }),
1906
- ["referenceSchema"]: (props2) => /* @__PURE__ */ import_react3.default.createElement(SelectInput, {
1907
- ...props2,
1908
- options: schemas.map((schema) => ({
1909
- value: schema.typename
1910
- }))
1911
- }),
1912
- ["referencePath"]: (props2) => /* @__PURE__ */ import_react3.default.createElement(SelectInput, {
1913
- ...props2,
1914
- options: referenceSchema ? (0, import_schema.getSchemaProperties)(referenceSchema.ast).sort(import_schema.sortProperties).map((p) => ({
1915
- value: p.name
1916
- })) : []
1917
- }),
1918
- ["options"]: (props2) => /* @__PURE__ */ import_react3.default.createElement(SelectOptionInput, props2)
1919
- }), [
1920
- t,
1921
- schemas,
1922
- referenceSchema
1923
- ]);
1924
- const propIsNotType = (0, import_react3.useCallback)((props2) => props2.filter((p) => p.name !== "type"), []);
1925
- if (!fieldSchema) {
1926
- import_log.log.warn("invalid format", {
1927
- props
1928
- }, {
1929
- F: __dxlog_file4,
1930
- L: 174,
1931
- S: void 0,
1932
- C: (f, a) => f(...a)
2058
+ onSave
2059
+ ]);
2060
+ const handleCancel = (0, import_react3.useCallback)(() => {
2061
+ requestAnimationFrame(() => onCancel?.());
2062
+ onSave();
2063
+ }, [
2064
+ onSave
2065
+ ]);
2066
+ const custom = (0, import_react3.useMemo)(() => ({
2067
+ ["format"]: (props2) => /* @__PURE__ */ import_react3.default.createElement(SelectInput, {
2068
+ ...props2,
2069
+ options: import_echo_schema.FormatEnums.filter((value) => value !== import_echo_schema.FormatEnum.None).map((value) => ({
2070
+ value,
2071
+ label: t(`format ${value}`)
2072
+ }))
2073
+ }),
2074
+ ["referenceSchema"]: (props2) => /* @__PURE__ */ import_react3.default.createElement(SelectInput, {
2075
+ ...props2,
2076
+ options: schemas.map((schema) => ({
2077
+ value: schema.typename
2078
+ }))
2079
+ }),
2080
+ ["referencePath"]: (props2) => /* @__PURE__ */ import_react3.default.createElement(SelectInput, {
2081
+ ...props2,
2082
+ options: referenceSchema ? (0, import_schema.getSchemaProperties)(referenceSchema.ast).sort(import_schema.sortProperties).map((p) => ({
2083
+ value: p.name
2084
+ })) : []
2085
+ }),
2086
+ ["options"]: (props2) => /* @__PURE__ */ import_react3.default.createElement(SelectOptionInput, props2)
2087
+ }), [
2088
+ t,
2089
+ schemas,
2090
+ referenceSchema
2091
+ ]);
2092
+ const propIsNotType = (0, import_react3.useCallback)((props2) => props2.filter((p) => p.name !== "type"), []);
2093
+ if (!fieldSchema) {
2094
+ import_log.log.warn("invalid format", {
2095
+ props
2096
+ }, {
2097
+ F: __dxlog_file4,
2098
+ L: 175,
2099
+ S: void 0,
2100
+ C: (f, a) => f(...a)
2101
+ });
2102
+ return null;
2103
+ }
2104
+ return /* @__PURE__ */ import_react3.default.createElement(Form, {
2105
+ key: field.id,
2106
+ autoFocus: true,
2107
+ values: props,
2108
+ schema: fieldSchema,
2109
+ filter: propIsNotType,
2110
+ sort: [
2111
+ "property",
2112
+ "format"
2113
+ ],
2114
+ onValuesChanged: handleValuesChanged,
2115
+ onValidate: handleValidate,
2116
+ onSave: handleSave,
2117
+ onCancel: handleCancel,
2118
+ Custom: custom
1933
2119
  });
1934
- return null;
2120
+ } finally {
2121
+ _effect.f();
1935
2122
  }
1936
- return /* @__PURE__ */ import_react3.default.createElement(Form, {
1937
- key: field.id,
1938
- autoFocus: true,
1939
- values: props,
1940
- schema: fieldSchema,
1941
- filter: propIsNotType,
1942
- sort: [
1943
- "property",
1944
- "format"
1945
- ],
1946
- onValuesChanged: handleValuesChanged,
1947
- onValidate: handleValidate,
1948
- onSave: handleSave,
1949
- onCancel: handleCancel,
1950
- Custom
1951
- });
1952
2123
  };
1953
2124
  var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx";
1954
2125
  var grid = "grid grid-cols-[32px_1fr_32px] min-bs-[2.5rem]";
1955
2126
  var ViewMetaSchema = import_effect12.Schema.Struct({
1956
2127
  name: import_effect12.Schema.String.annotations({
1957
- [import_effect12.SchemaAST.TitleAnnotationId]: "View"
2128
+ title: "View"
1958
2129
  }),
1959
2130
  typename: import_echo_schema11.Format.URL.annotations({
1960
- [import_effect12.SchemaAST.TitleAnnotationId]: "Typename"
2131
+ title: "Typename"
1961
2132
  })
1962
2133
  }).pipe(import_effect12.Schema.mutable);
1963
2134
  var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading = false, onTypenameChanged, onDelete }) => {
1964
- const { t } = (0, import_react_ui12.useTranslation)(translationKey);
1965
- const projection = (0, import_react18.useMemo)(() => new import_schema5.ViewProjection((0, import_echo_schema11.toJsonSchema)(schema), view), [
1966
- schema,
1967
- view
1968
- ]);
1969
- const [field, setField] = (0, import_react18.useState)();
1970
- const immutable = readonly || !(0, import_echo_schema11.isMutable)(schema);
1971
- const viewValues = (0, import_react18.useMemo)(() => {
1972
- return {
1973
- name: view.name,
1974
- // TODO(burdon): Need to warn user of possible consequences of editing.
1975
- // TODO(burdon): Settings should have domain name owned by user.
1976
- typename: view.query.typename
1977
- };
1978
- }, [
1979
- view
1980
- ]);
1981
- const handleSelect = (0, import_react18.useCallback)((field2) => {
1982
- setField((f) => f === field2 ? void 0 : field2);
1983
- }, []);
1984
- const handleAdd = (0, import_react18.useCallback)(() => {
1985
- (0, import_invariant3.invariant)(!immutable, void 0, {
1986
- F: __dxlog_file5,
1987
- L: 78,
1988
- S: void 0,
1989
- A: [
1990
- "!immutable",
1991
- ""
1992
- ]
1993
- });
1994
- const field2 = projection.createFieldProjection();
1995
- setField(field2);
1996
- }, [
1997
- schema,
1998
- view
1999
- ]);
2000
- const handleUpdate = (0, import_react18.useCallback)(({ name, typename }) => {
2001
- (0, import_invariant3.invariant)(!immutable, void 0, {
2002
- F: __dxlog_file5,
2003
- L: 85,
2004
- S: void 0,
2005
- A: [
2006
- "!immutable",
2007
- ""
2008
- ]
2009
- });
2010
- requestAnimationFrame(() => {
2011
- if (view.name !== name) {
2012
- view.name = name;
2135
+ var _effect = (0, import_tracking15.useSignals)();
2136
+ try {
2137
+ const { t } = (0, import_react_ui12.useTranslation)(translationKey);
2138
+ const projection = (0, import_react19.useMemo)(() => {
2139
+ const jsonSchema = schema instanceof import_echo_schema11.EchoSchema ? schema.jsonSchema : (0, import_echo_schema11.toJsonSchema)(schema);
2140
+ return new import_schema5.ViewProjection(jsonSchema, view);
2141
+ }, [
2142
+ schema,
2143
+ view
2144
+ ]);
2145
+ const [field, setField] = (0, import_react19.useState)();
2146
+ const immutable = readonly || !(0, import_echo_schema11.isMutable)(schema);
2147
+ const viewValues = (0, import_react19.useMemo)(() => {
2148
+ return {
2149
+ name: view.name,
2150
+ // TODO(burdon): Need to warn user of possible consequences of editing.
2151
+ // TODO(burdon): Settings should have domain name owned by user.
2152
+ typename: view.query.typename
2153
+ };
2154
+ }, [
2155
+ view
2156
+ ]);
2157
+ const handleSelect = (0, import_react19.useCallback)((field2) => {
2158
+ if (immutable) {
2159
+ return;
2013
2160
  }
2014
- if (view.query.typename !== typename) {
2015
- onTypenameChanged?.(typename);
2161
+ setField((f) => f === field2 ? void 0 : field2);
2162
+ }, [
2163
+ immutable
2164
+ ]);
2165
+ const handleAdd = (0, import_react19.useCallback)(() => {
2166
+ (0, import_invariant3.invariant)(!immutable, void 0, {
2167
+ F: __dxlog_file5,
2168
+ L: 88,
2169
+ S: void 0,
2170
+ A: [
2171
+ "!immutable",
2172
+ ""
2173
+ ]
2174
+ });
2175
+ const field2 = projection.createFieldProjection();
2176
+ setField(field2);
2177
+ }, [
2178
+ schema,
2179
+ view
2180
+ ]);
2181
+ const handleUpdate = (0, import_react19.useCallback)(({ name, typename }) => {
2182
+ (0, import_invariant3.invariant)(!immutable, void 0, {
2183
+ F: __dxlog_file5,
2184
+ L: 95,
2185
+ S: void 0,
2186
+ A: [
2187
+ "!immutable",
2188
+ ""
2189
+ ]
2190
+ });
2191
+ requestAnimationFrame(() => {
2192
+ if (view.name !== name) {
2193
+ view.name = name;
2194
+ }
2195
+ if (view.query.typename !== typename && !immutable) {
2196
+ onTypenameChanged?.(typename);
2197
+ }
2198
+ });
2199
+ }, [
2200
+ schema,
2201
+ view,
2202
+ onTypenameChanged,
2203
+ immutable
2204
+ ]);
2205
+ const handleDelete = (0, import_react19.useCallback)((fieldId) => {
2206
+ (0, import_invariant3.invariant)(!immutable, void 0, {
2207
+ F: __dxlog_file5,
2208
+ L: 111,
2209
+ S: void 0,
2210
+ A: [
2211
+ "!immutable",
2212
+ ""
2213
+ ]
2214
+ });
2215
+ if (fieldId === field?.id) {
2216
+ setField(void 0);
2016
2217
  }
2017
- });
2018
- }, [
2019
- schema,
2020
- view,
2021
- onTypenameChanged
2022
- ]);
2023
- const handleDelete = (0, import_react18.useCallback)((fieldId) => {
2024
- (0, import_invariant3.invariant)(!immutable, void 0, {
2025
- F: __dxlog_file5,
2026
- L: 101,
2027
- S: void 0,
2028
- A: [
2029
- "!immutable",
2030
- ""
2031
- ]
2032
- });
2033
- if (fieldId === field?.id) {
2218
+ onDelete?.(fieldId);
2219
+ }, [
2220
+ schema,
2221
+ field,
2222
+ onDelete
2223
+ ]);
2224
+ const handleMove = (0, import_react19.useCallback)((fromIndex, toIndex) => {
2225
+ (0, import_invariant3.invariant)(!immutable, void 0, {
2226
+ F: __dxlog_file5,
2227
+ L: 123,
2228
+ S: void 0,
2229
+ A: [
2230
+ "!immutable",
2231
+ ""
2232
+ ]
2233
+ });
2234
+ const fields = [
2235
+ ...view.fields
2236
+ ];
2237
+ const [moved] = fields.splice(fromIndex, 1);
2238
+ fields.splice(toIndex, 0, moved);
2239
+ view.fields = fields;
2240
+ }, [
2241
+ schema,
2242
+ view.fields
2243
+ ]);
2244
+ const handleClose = (0, import_react19.useCallback)(() => setField(void 0), []);
2245
+ const hiddenProperties = projection.getHiddenProperties();
2246
+ const handleHide = (0, import_react19.useCallback)((fieldId) => {
2034
2247
  setField(void 0);
2035
- }
2036
- onDelete?.(fieldId);
2037
- }, [
2038
- schema,
2039
- field,
2040
- onDelete
2041
- ]);
2042
- const handleMove = (0, import_react18.useCallback)((fromIndex, toIndex) => {
2043
- (0, import_invariant3.invariant)(!immutable, void 0, {
2044
- F: __dxlog_file5,
2045
- L: 113,
2046
- S: void 0,
2047
- A: [
2048
- "!immutable",
2049
- ""
2050
- ]
2051
- });
2052
- const fields = [
2053
- ...view.fields
2054
- ];
2055
- const [moved] = fields.splice(fromIndex, 1);
2056
- fields.splice(toIndex, 0, moved);
2057
- view.fields = fields;
2058
- }, [
2059
- schema,
2060
- view.fields
2061
- ]);
2062
- const handleClose = (0, import_react18.useCallback)(() => setField(void 0), []);
2063
- const hiddenProperties = projection.getHiddenProperties();
2064
- const handleHide = (0, import_react18.useCallback)((fieldId) => {
2065
- setField(void 0);
2066
- projection.hideFieldProjection(fieldId);
2067
- }, [
2068
- projection
2069
- ]);
2070
- const handleShow = (0, import_react18.useCallback)((property) => {
2071
- setField(void 0);
2072
- projection.showFieldProjection(property);
2073
- }, [
2074
- projection
2075
- ]);
2076
- return /* @__PURE__ */ import_react18.default.createElement("div", {
2077
- role: "none",
2078
- className: (0, import_react_ui_theme10.mx)("grid grid-rows-[1fr_1fr] min-bs-0", classNames)
2079
- }, /* @__PURE__ */ import_react18.default.createElement(Form, {
2080
- autoSave: true,
2081
- schema: ViewMetaSchema,
2082
- values: viewValues,
2083
- onSave: immutable ? void 0 : handleUpdate,
2084
- classNames: "min-bs-0 overflow-y-auto"
2085
- }), /* @__PURE__ */ import_react18.default.createElement("div", {
2086
- role: "none",
2087
- className: "border-bs border-separator min-bs-0 overflow-y-auto"
2088
- }, /* @__PURE__ */ import_react18.default.createElement("div", {
2089
- role: "none",
2090
- className: "p-2"
2091
- }, /* @__PURE__ */ import_react18.default.createElement("label", {
2092
- className: (0, import_react_ui_theme10.mx)(import_react_ui_theme10.inputTextLabel)
2093
- }, t("fields label"))), /* @__PURE__ */ import_react18.default.createElement(import_react_ui_list2.List.Root, {
2094
- items: view.fields,
2095
- isItem: import_effect12.Schema.is(import_schema5.FieldSchema),
2096
- getId: (field2) => field2.id,
2097
- onMove: immutable ? void 0 : handleMove
2098
- }, ({ items: fields }) => /* @__PURE__ */ import_react18.default.createElement(import_react18.default.Fragment, null, showHeading && /* @__PURE__ */ import_react18.default.createElement("div", {
2099
- role: "heading",
2100
- className: grid
2101
- }, /* @__PURE__ */ import_react18.default.createElement("div", null), /* @__PURE__ */ import_react18.default.createElement("div", {
2102
- className: "flex items-center text-sm"
2103
- }, t("field path label"))), /* @__PURE__ */ import_react18.default.createElement("div", {
2104
- role: "list",
2105
- className: "flex flex-col w-full"
2106
- }, fields?.map((field2) => /* @__PURE__ */ import_react18.default.createElement(import_react_ui_list2.List.Item, {
2107
- key: field2.id,
2108
- item: field2,
2109
- classNames: (0, import_react_ui_theme10.mx)(grid, import_react_ui_theme10.ghostHover, "cursor-pointer")
2110
- }, /* @__PURE__ */ import_react18.default.createElement(import_react_ui_list2.List.ItemDragHandle, null), /* @__PURE__ */ import_react18.default.createElement(import_react_ui_list2.List.ItemTitle, {
2111
- onClick: () => handleSelect(field2)
2112
- }, field2.path), /* @__PURE__ */ import_react18.default.createElement("div", {
2113
- className: "flex items-center gap-2 -ml-4"
2114
- }, /* @__PURE__ */ import_react18.default.createElement(import_react_ui_list2.List.ItemButton, {
2115
- icon: "ph--eye-slash--regular",
2116
- disabled: view.fields.length <= 1,
2117
- onClick: () => handleHide(field2.id)
2118
- }), !immutable && /* @__PURE__ */ import_react18.default.createElement(import_react_ui_list2.List.ItemDeleteButton, {
2119
- icon: "ph--trash--regular",
2120
- disabled: view.fields.length <= 1,
2121
- onClick: () => handleDelete(field2.id)
2122
- }))))))), hiddenProperties.length > 0 && /* @__PURE__ */ import_react18.default.createElement("div", null, /* @__PURE__ */ import_react18.default.createElement("div", {
2123
- role: "none",
2124
- className: "p-2"
2125
- }, /* @__PURE__ */ import_react18.default.createElement("label", {
2126
- className: (0, import_react_ui_theme10.mx)(import_react_ui_theme10.inputTextLabel)
2127
- }, t("hidden fields label"))), /* @__PURE__ */ import_react18.default.createElement(import_react_ui_list2.List.Root, {
2128
- items: hiddenProperties,
2129
- isItem: (item) => typeof item === "string",
2130
- getId: (property) => property
2131
- }, ({ items: properties }) => /* @__PURE__ */ import_react18.default.createElement("div", {
2132
- role: "list",
2133
- className: "flex flex-col w-full"
2134
- }, properties?.map((property) => /* @__PURE__ */ import_react18.default.createElement(import_react_ui_list2.List.Item, {
2135
- key: property,
2136
- item: property,
2137
- classNames: (0, import_react_ui_theme10.mx)(grid, import_react_ui_theme10.ghostHover, "cursor-pointer")
2138
- }, /* @__PURE__ */ import_react18.default.createElement("div", null), /* @__PURE__ */ import_react18.default.createElement(import_react_ui_list2.List.ItemTitle, null, property), /* @__PURE__ */ import_react18.default.createElement(import_react_ui_list2.List.ItemButton, {
2139
- icon: "ph--eye--regular",
2140
- onClick: () => handleShow(property)
2141
- }))))))), field && /* @__PURE__ */ import_react18.default.createElement(FieldEditor, {
2142
- key: field.id,
2143
- view,
2144
- projection,
2145
- field,
2146
- registry,
2147
- onSave: handleClose
2148
- }), !readonly && !field && /* @__PURE__ */ import_react18.default.createElement("div", {
2149
- className: "flex p-2 justify-center"
2150
- }, /* @__PURE__ */ import_react18.default.createElement(import_react_ui12.IconButton, {
2151
- icon: "ph--plus--regular",
2152
- label: t("button add property"),
2153
- onClick: immutable ? void 0 : handleAdd,
2154
- // TODO(burdon): Show field limit in ux (not tooltip).
2155
- disabled: view.fields.length >= import_schema5.VIEW_FIELD_LIMIT
2156
- })));
2248
+ projection.hideFieldProjection(fieldId);
2249
+ }, [
2250
+ projection
2251
+ ]);
2252
+ const handleShow = (0, import_react19.useCallback)((property) => {
2253
+ setField(void 0);
2254
+ projection.showFieldProjection(property);
2255
+ }, [
2256
+ projection
2257
+ ]);
2258
+ return /* @__PURE__ */ import_react19.default.createElement("div", {
2259
+ role: "none",
2260
+ className: (0, import_react_ui_theme9.mx)("overflow-y-auto", classNames)
2261
+ }, /* @__PURE__ */ import_react19.default.createElement("div", {
2262
+ role: "none",
2263
+ className: "p-2"
2264
+ }, /* @__PURE__ */ import_react19.default.createElement("div", {
2265
+ role: "none",
2266
+ className: "mbe-2"
2267
+ }, immutable && /* @__PURE__ */ import_react19.default.createElement(import_react_ui12.Message.Root, {
2268
+ valence: "neutral",
2269
+ className: "rounded"
2270
+ }, /* @__PURE__ */ import_react19.default.createElement(import_react_ui12.Message.Title, null, /* @__PURE__ */ import_react19.default.createElement(import_react_ui12.Icon, {
2271
+ icon: "ph--info--regular",
2272
+ size: 5,
2273
+ classNames: "inline"
2274
+ }), " ", t("system schema title")), /* @__PURE__ */ import_react19.default.createElement(import_react_ui12.Message.Body, null, t("system schema description")))), /* @__PURE__ */ import_react19.default.createElement(Form, {
2275
+ autoSave: true,
2276
+ schema: ViewMetaSchema,
2277
+ values: viewValues,
2278
+ onSave: handleUpdate,
2279
+ classNames: "min-bs-0 overflow-y-auto"
2280
+ })), /* @__PURE__ */ import_react19.default.createElement("div", {
2281
+ role: "none",
2282
+ className: "min-bs-0 overflow-y-auto"
2283
+ }, /* @__PURE__ */ import_react19.default.createElement("div", {
2284
+ role: "none",
2285
+ className: "p-2"
2286
+ }, /* @__PURE__ */ import_react19.default.createElement("label", {
2287
+ className: (0, import_react_ui_theme9.mx)(import_react_ui_theme9.inputTextLabel)
2288
+ }, t("fields label"))), /* @__PURE__ */ import_react19.default.createElement(import_react_ui_list2.List.Root, {
2289
+ items: view.fields,
2290
+ isItem: import_effect12.Schema.is(import_schema5.FieldSchema),
2291
+ getId: (field2) => field2.id,
2292
+ onMove: immutable ? void 0 : handleMove
2293
+ }, ({ items: fields }) => /* @__PURE__ */ import_react19.default.createElement(import_react19.default.Fragment, null, showHeading && /* @__PURE__ */ import_react19.default.createElement("div", {
2294
+ role: "heading",
2295
+ className: grid
2296
+ }, /* @__PURE__ */ import_react19.default.createElement("div", null), /* @__PURE__ */ import_react19.default.createElement("div", {
2297
+ className: "flex items-center text-sm"
2298
+ }, t("field path label"))), /* @__PURE__ */ import_react19.default.createElement("div", {
2299
+ role: "list",
2300
+ className: "flex flex-col w-full"
2301
+ }, fields?.map((field2) => /* @__PURE__ */ import_react19.default.createElement(import_react_ui_list2.List.Item, {
2302
+ key: field2.id,
2303
+ item: field2,
2304
+ classNames: (0, import_react_ui_theme9.mx)(grid, import_react_ui_theme9.ghostHover, !immutable && "cursor-pointer")
2305
+ }, /* @__PURE__ */ import_react19.default.createElement(import_react_ui_list2.List.ItemDragHandle, null), /* @__PURE__ */ import_react19.default.createElement(import_react_ui_list2.List.ItemTitle, {
2306
+ onClick: () => handleSelect(field2)
2307
+ }, field2.path), /* @__PURE__ */ import_react19.default.createElement("div", {
2308
+ className: "flex items-center gap-2 -ml-4"
2309
+ }, /* @__PURE__ */ import_react19.default.createElement(import_react_ui_list2.List.ItemButton, {
2310
+ icon: "ph--eye-slash--regular",
2311
+ disabled: view.fields.length <= 1,
2312
+ onClick: () => handleHide(field2.id)
2313
+ }), !immutable && /* @__PURE__ */ import_react19.default.createElement(import_react_ui_list2.List.ItemDeleteButton, {
2314
+ icon: "ph--trash--regular",
2315
+ disabled: view.fields.length <= 1,
2316
+ onClick: () => handleDelete(field2.id)
2317
+ }))))))), hiddenProperties.length > 0 && /* @__PURE__ */ import_react19.default.createElement("div", null, /* @__PURE__ */ import_react19.default.createElement("div", {
2318
+ role: "none",
2319
+ className: "p-2"
2320
+ }, /* @__PURE__ */ import_react19.default.createElement("label", {
2321
+ className: (0, import_react_ui_theme9.mx)(import_react_ui_theme9.inputTextLabel)
2322
+ }, t("hidden fields label"))), /* @__PURE__ */ import_react19.default.createElement(import_react_ui_list2.List.Root, {
2323
+ items: hiddenProperties,
2324
+ isItem: (item) => typeof item === "string",
2325
+ getId: (property) => property
2326
+ }, ({ items: properties }) => /* @__PURE__ */ import_react19.default.createElement("div", {
2327
+ role: "list",
2328
+ className: "flex flex-col w-full"
2329
+ }, properties?.map((property) => /* @__PURE__ */ import_react19.default.createElement(import_react_ui_list2.List.Item, {
2330
+ key: property,
2331
+ item: property,
2332
+ classNames: (0, import_react_ui_theme9.mx)(grid, import_react_ui_theme9.ghostHover, !immutable && "cursor-pointer")
2333
+ }, /* @__PURE__ */ import_react19.default.createElement("div", null), /* @__PURE__ */ import_react19.default.createElement(import_react_ui_list2.List.ItemTitle, null, property), /* @__PURE__ */ import_react19.default.createElement(import_react_ui_list2.List.ItemButton, {
2334
+ icon: "ph--eye--regular",
2335
+ onClick: () => handleShow(property)
2336
+ }))))))), field && /* @__PURE__ */ import_react19.default.createElement(FieldEditor, {
2337
+ key: field.id,
2338
+ view,
2339
+ projection,
2340
+ field,
2341
+ registry,
2342
+ onSave: handleClose
2343
+ }), !readonly && !field && /* @__PURE__ */ import_react19.default.createElement("div", {
2344
+ role: "none",
2345
+ className: "p-2"
2346
+ }, /* @__PURE__ */ import_react19.default.createElement(import_react_ui12.IconButton, {
2347
+ icon: "ph--plus--regular",
2348
+ label: t("button add property"),
2349
+ onClick: immutable ? void 0 : handleAdd,
2350
+ // TODO(burdon): Show field limit in ux (not tooltip).
2351
+ disabled: view.fields.length >= import_schema5.VIEW_FIELD_LIMIT,
2352
+ classNames: "flex is-full"
2353
+ })));
2354
+ } finally {
2355
+ _effect.f();
2356
+ }
2157
2357
  };
2158
2358
  // Annotate the CommonJS export names for ESM import in node:
2159
2359
  0 && (module.exports = {