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

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