@dxos/react-ui-form 0.7.5-feature-compute.4d9d99a → 0.7.5-labs.401163d

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 (70) hide show
  1. package/dist/lib/browser/index.mjs +881 -556
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node/index.cjs +910 -596
  5. package/dist/lib/node/index.cjs.map +4 -4
  6. package/dist/lib/node/meta.json +1 -1
  7. package/dist/lib/node-esm/index.mjs +881 -556
  8. package/dist/lib/node-esm/index.mjs.map +4 -4
  9. package/dist/lib/node-esm/meta.json +1 -1
  10. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
  11. package/dist/types/src/components/Form/ArrayField.d.ts +16 -0
  12. package/dist/types/src/components/Form/ArrayField.d.ts.map +1 -0
  13. package/dist/types/src/components/Form/Defaults.d.ts +6 -6
  14. package/dist/types/src/components/Form/Defaults.d.ts.map +1 -1
  15. package/dist/types/src/components/Form/Form.d.ts +12 -21
  16. package/dist/types/src/components/Form/Form.d.ts.map +1 -1
  17. package/dist/types/src/components/Form/Form.stories.d.ts +2 -1
  18. package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
  19. package/dist/types/src/components/Form/FormActions.d.ts +7 -0
  20. package/dist/types/src/components/Form/FormActions.d.ts.map +1 -0
  21. package/dist/types/src/components/Form/FormContent.d.ts +26 -0
  22. package/dist/types/src/components/Form/FormContent.d.ts.map +1 -0
  23. package/dist/types/src/components/Form/FormContext.d.ts +23 -0
  24. package/dist/types/src/components/Form/FormContext.d.ts.map +1 -0
  25. package/dist/types/src/components/Form/Input.d.ts +5 -6
  26. package/dist/types/src/components/Form/Input.d.ts.map +1 -1
  27. package/dist/types/src/components/Form/custom/GeoPointInput.d.ts +1 -2
  28. package/dist/types/src/components/Form/custom/GeoPointInput.d.ts.map +1 -1
  29. package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts +4 -0
  30. package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts.map +1 -0
  31. package/dist/types/src/components/Form/custom/SelectOptionsInput.stories.d.ts +7 -0
  32. package/dist/types/src/components/Form/custom/SelectOptionsInput.stories.d.ts.map +1 -0
  33. package/dist/types/src/components/Form/custom/TupleInput.d.ts +1 -2
  34. package/dist/types/src/components/Form/custom/TupleInput.d.ts.map +1 -1
  35. package/dist/types/src/components/Form/custom/index.d.ts +1 -0
  36. package/dist/types/src/components/Form/custom/index.d.ts.map +1 -1
  37. package/dist/types/src/components/Form/factory.d.ts +2 -2
  38. package/dist/types/src/components/Form/factory.d.ts.map +1 -1
  39. package/dist/types/src/components/Form/index.d.ts +2 -0
  40. package/dist/types/src/components/Form/index.d.ts.map +1 -1
  41. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
  42. package/dist/types/src/components/deprecated/FormInput.d.ts +5 -0
  43. package/dist/types/src/components/deprecated/FormInput.d.ts.map +1 -1
  44. package/dist/types/src/hooks/useForm.d.ts +10 -10
  45. package/dist/types/src/hooks/useForm.d.ts.map +1 -1
  46. package/dist/types/src/translations.d.ts +6 -0
  47. package/dist/types/src/translations.d.ts.map +1 -1
  48. package/dist/types/tsconfig.tsbuildinfo +1 -1
  49. package/package.json +25 -24
  50. package/src/components/FieldEditor/FieldEditor.stories.tsx +1 -1
  51. package/src/components/FieldEditor/FieldEditor.tsx +7 -6
  52. package/src/components/Form/ArrayField.tsx +111 -0
  53. package/src/components/Form/Defaults.tsx +78 -36
  54. package/src/components/Form/Form.stories.tsx +15 -5
  55. package/src/components/Form/Form.tsx +50 -355
  56. package/src/components/Form/FormActions.tsx +41 -0
  57. package/src/components/Form/FormContent.tsx +170 -0
  58. package/src/components/Form/FormContext.tsx +92 -0
  59. package/src/components/Form/Input.tsx +5 -6
  60. package/src/components/Form/custom/GeoPointInput.tsx +6 -15
  61. package/src/components/Form/custom/SelectOptionsInput.stories.tsx +58 -0
  62. package/src/components/Form/custom/SelectOptionsInput.tsx +190 -0
  63. package/src/components/Form/custom/TupleInput.tsx +5 -9
  64. package/src/components/Form/custom/index.ts +1 -0
  65. package/src/components/Form/factory.tsx +5 -6
  66. package/src/components/Form/index.ts +3 -0
  67. package/src/components/ViewEditor/ViewEditor.tsx +7 -4
  68. package/src/components/deprecated/FormInput.tsx +20 -7
  69. package/src/hooks/useForm.ts +60 -47
  70. package/src/translations.ts +8 -0
@@ -29,14 +29,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
29
  var node_exports = {};
30
30
  __export(node_exports, {
31
31
  BooleanInput: () => BooleanInput,
32
+ DeprecatedFormContainer: () => DeprecatedFormContainer,
32
33
  DeprecatedFormInput: () => DeprecatedFormInput,
33
34
  FieldEditor: () => FieldEditor,
34
35
  Form: () => Form,
35
- FormActions: () => FormActions,
36
36
  GeoPointInput: () => GeoPointInput,
37
37
  InputHeader: () => InputHeader,
38
+ MarkdownInput: () => MarkdownInput,
38
39
  NumberInput: () => NumberInput,
39
40
  SelectInput: () => SelectInput,
41
+ SelectOptionInput: () => SelectOptionInput,
40
42
  TextInput: () => TextInput,
41
43
  TupleInput: () => TupleInput,
42
44
  ViewEditor: () => ViewEditor,
@@ -47,54 +49,77 @@ __export(node_exports, {
47
49
  parseValue: () => parseValue,
48
50
  pathNotUniqueError: () => pathNotUniqueError,
49
51
  translations: () => translations_default,
50
- useForm: () => useForm
52
+ useForm: () => useForm,
53
+ useFormValues: () => useFormValues
51
54
  });
52
55
  module.exports = __toCommonJS(node_exports);
53
56
  var import_react = __toESM(require("react"));
54
57
  var import_react_ui = require("@dxos/react-ui");
58
+ var import_react_ui_theme = require("@dxos/react-ui-theme");
55
59
  var import_react2 = __toESM(require("react"));
56
60
  var import_echo_schema = require("@dxos/echo-schema");
57
61
  var import_log = require("@dxos/log");
58
62
  var import_react_ui2 = require("@dxos/react-ui");
59
63
  var import_schema = require("@dxos/schema");
60
64
  var import_react3 = __toESM(require("react"));
65
+ var import_debug = require("@dxos/debug");
66
+ var import_echo_schema2 = require("@dxos/echo-schema");
67
+ var import_effect = require("@dxos/effect");
68
+ var import_react4 = require("react");
69
+ var import_echo_schema3 = require("@dxos/echo-schema");
70
+ var import_effect2 = require("@dxos/effect");
71
+ var import_invariant = require("@dxos/invariant");
72
+ var import_log2 = require("@dxos/log");
73
+ var import_schema2 = require("@dxos/schema");
74
+ var import_react5 = __toESM(require("react"));
61
75
  var import_react_ui3 = require("@dxos/react-ui");
62
76
  var import_util = require("@dxos/util");
63
- var import_react4 = __toESM(require("react"));
77
+ var import_react6 = __toESM(require("react"));
64
78
  var import_react_ui4 = require("@dxos/react-ui");
65
- var import_react_ui_theme = require("@dxos/react-ui-theme");
66
- var import_react5 = __toESM(require("react"));
67
- var import_react_ui5 = require("@dxos/react-ui");
68
79
  var import_react_ui_theme2 = require("@dxos/react-ui-theme");
69
- var import_util2 = require("@dxos/util");
70
- var import_react6 = __toESM(require("react"));
71
- var import_react_ui6 = require("@dxos/react-ui");
72
- var import_effect = require("effect");
73
- var import_String = require("effect/String");
74
80
  var import_react7 = __toESM(require("react"));
75
- var import_echo_schema2 = require("@dxos/echo-schema");
76
- var import_effect2 = require("@dxos/effect");
77
- var import_log2 = require("@dxos/log");
78
- var import_react_ui7 = require("@dxos/react-ui");
81
+ var import_keys = require("@dxos/keys");
82
+ var import_react_ui5 = require("@dxos/react-ui");
83
+ var import_react_ui_list = require("@dxos/react-ui-list");
84
+ var import_react_ui_pickers = require("@dxos/react-ui-pickers");
79
85
  var import_react_ui_theme3 = require("@dxos/react-ui-theme");
80
- var import_schema2 = require("@dxos/schema");
81
- var import_util3 = require("@dxos/util");
82
- var import_echo_schema3 = require("@dxos/echo-schema");
83
- var import_react8 = require("react");
86
+ var import_react8 = __toESM(require("react"));
87
+ var import_react_ui6 = require("@dxos/react-ui");
88
+ var import_react_ui_theme4 = require("@dxos/react-ui-theme");
89
+ var import_util2 = require("@dxos/util");
90
+ var import_react9 = __toESM(require("react"));
91
+ var import_react_ui7 = require("@dxos/react-ui");
92
+ var import_react10 = __toESM(require("react"));
93
+ var import_react_ui_theme5 = require("@dxos/react-ui-theme");
94
+ var import_react11 = __toESM(require("react"));
95
+ var import_react_ui8 = require("@dxos/react-ui");
96
+ var import_react_ui_theme6 = require("@dxos/react-ui-theme");
97
+ var import_effect3 = require("effect");
98
+ var import_String = require("effect/String");
99
+ var import_react12 = __toESM(require("react"));
84
100
  var import_echo_schema4 = require("@dxos/echo-schema");
85
- var import_effect3 = require("@dxos/effect");
86
- var import_invariant = require("@dxos/invariant");
87
- var import_log3 = require("@dxos/log");
101
+ var import_effect4 = require("@dxos/effect");
102
+ var import_react_ui_theme7 = require("@dxos/react-ui-theme");
88
103
  var import_schema3 = require("@dxos/schema");
89
- var import_react9 = __toESM(require("react"));
104
+ var import_util3 = require("@dxos/util");
105
+ var import_effect5 = require("effect");
106
+ var import_String2 = require("effect/String");
107
+ var import_react13 = __toESM(require("react"));
90
108
  var import_echo_schema5 = require("@dxos/echo-schema");
91
- var import_react_ui8 = require("@dxos/react-ui");
92
- var import_react_ui_list = require("@dxos/react-ui-list");
93
- var import_react_ui_theme4 = require("@dxos/react-ui-theme");
109
+ var import_effect6 = require("@dxos/effect");
110
+ var import_invariant2 = require("@dxos/invariant");
111
+ var import_react_ui9 = require("@dxos/react-ui");
112
+ var import_react_ui_theme8 = require("@dxos/react-ui-theme");
94
113
  var import_schema4 = require("@dxos/schema");
95
- var import_util4 = require("@dxos/util");
96
114
  var import_echo_schema6 = require("@dxos/echo-schema");
115
+ var import_react14 = __toESM(require("react"));
97
116
  var import_echo_schema7 = require("@dxos/echo-schema");
117
+ var import_react_ui10 = require("@dxos/react-ui");
118
+ var import_react_ui_list2 = require("@dxos/react-ui-list");
119
+ var import_react_ui_theme9 = require("@dxos/react-ui-theme");
120
+ var import_schema5 = require("@dxos/schema");
121
+ var import_echo_schema8 = require("@dxos/echo-schema");
122
+ var import_echo_schema9 = require("@dxos/echo-schema");
98
123
  var translationKey = "react-ui-form";
99
124
  var translations_default = [
100
125
  {
@@ -131,6 +156,7 @@ var translations_default = [
131
156
  "format ref": "Reference",
132
157
  "format regex": "RegExp",
133
158
  "format string": "String",
159
+ "format single-select": "Select",
134
160
  "format text": "Long text",
135
161
  "format time": "Time",
136
162
  "format timestamp": "Timestamp",
@@ -140,11 +166,26 @@ var translations_default = [
140
166
  "format uuid": "UUID",
141
167
  // Placeholders
142
168
  "placeholder latitude": "Latitude",
143
- "placeholder longitude": "Longitude"
169
+ "placeholder longitude": "Longitude",
170
+ // SelectOptionsInput
171
+ "select option label": "Label",
172
+ "select option label placeholder": "Option label",
173
+ "select option color": "Color",
174
+ "select option delete": "Delete",
175
+ "select option add": "Add option"
144
176
  }
145
177
  }
146
178
  }
147
179
  ];
180
+ var DeprecatedFormContainer = ({ children, classNames }) => {
181
+ return /* @__PURE__ */ import_react.default.createElement("div", {
182
+ role: "none",
183
+ className: "w-full p-4 justify-center overflow-x-hidden overflow-y-auto"
184
+ }, /* @__PURE__ */ import_react.default.createElement("div", {
185
+ role: "form",
186
+ className: (0, import_react_ui_theme.mx)("flex flex-col", import_react_ui_theme.textBlockWidth, classNames)
187
+ }, children));
188
+ };
148
189
  var DeprecatedFormInput = ({ label, description, secondary, children }) => {
149
190
  const primary = /* @__PURE__ */ import_react.default.createElement("div", {
150
191
  role: "none",
@@ -153,194 +194,48 @@ var DeprecatedFormInput = ({ label, description, secondary, children }) => {
153
194
  role: "none",
154
195
  className: "flex flex-col w-full"
155
196
  }, /* @__PURE__ */ import_react.default.createElement(import_react_ui.Input.Label, {
156
- classNames: "flex min-h-[40px] items-center"
197
+ classNames: "flex min-bs-[--rail-action] items-center",
198
+ style: {
199
+ fontSize: "unset"
200
+ }
157
201
  }, label), description && /* @__PURE__ */ import_react.default.createElement(import_react_ui.Input.DescriptionAndValidation, {
158
202
  classNames: "mbs-0.5"
159
203
  }, /* @__PURE__ */ import_react.default.createElement(import_react_ui.Input.Description, null, description))), /* @__PURE__ */ import_react.default.createElement("div", {
160
204
  role: "none"
161
205
  }, /* @__PURE__ */ import_react.default.createElement("div", {
162
206
  role: "none",
163
- className: "flex min-h-[40px] items-center"
207
+ className: "flex min-bs-[--rail-action] items-center"
164
208
  }, children))));
165
209
  if (secondary) {
166
210
  return /* @__PURE__ */ import_react.default.createElement("div", {
167
- role: "none",
168
- className: "flex flex-col w-full"
211
+ role: "none"
169
212
  }, primary, secondary);
170
213
  }
171
214
  return primary;
172
215
  };
173
- var InputHeader = ({ children, error }) => {
174
- return /* @__PURE__ */ import_react4.default.createElement("div", {
175
- role: "none",
176
- className: "flex justify-between items-center mb-1"
177
- }, children, error && /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Tooltip.Root, null, /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Tooltip.Trigger, {
178
- asChild: true
179
- }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Icon, {
180
- icon: "ph--warning--regular",
181
- size: 4,
182
- classNames: import_react_ui_theme.errorText
183
- })), /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Tooltip.Content, {
184
- side: "bottom"
185
- }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Tooltip.Arrow, null), error)));
186
- };
187
- var GeoPointInput = ({ property, type, label, disabled, getStatus, getValue: getValue2, onValueChange, onBlur }) => {
188
- const { t } = (0, import_react_ui3.useTranslation)(translationKey);
189
- const { status, error } = getStatus?.(property);
190
- const [lng = 0, lat = 0] = getValue2(property) ?? [];
191
- return /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.Input.Root, {
192
- validationValence: status
193
- }, /* @__PURE__ */ import_react3.default.createElement(InputHeader, {
194
- error
195
- }, /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.Input.Label, null, label)), /* @__PURE__ */ import_react3.default.createElement("div", {
196
- className: "grid grid-cols-2 gap-2"
197
- }, /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.Input.TextInput, {
198
- type: "number",
199
- disabled,
200
- placeholder: t("placeholder longitude"),
201
- value: lng,
202
- onChange: (event) => onValueChange(property, type, [
203
- lat,
204
- (0, import_util.safeParseFloat)(event.target.value, 0)
205
- ]),
206
- onBlur
207
- }), /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.Input.TextInput, {
208
- type: "number",
209
- disabled,
210
- placeholder: t("placeholder latitude"),
211
- value: lat,
212
- onChange: (event) => onValueChange(property, type, [
213
- (0, import_util.safeParseFloat)(event.target.value, 0),
214
- lng
215
- ]),
216
- onBlur
217
- })));
218
- };
219
- var gridCols = [
220
- "grid-cols-1",
221
- "grid-cols-2",
222
- "grid-cols-3",
223
- "grid-cols-4"
224
- ];
225
- var TupleInput = ({ binding, property, type, label, disabled, getStatus, getValue: getValue2, onValueChange, onBlur }) => {
226
- const { status, error } = getStatus?.(property);
227
- const values = getValue2(property) ?? {};
228
- return /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Input.Root, {
229
- validationValence: status
230
- }, /* @__PURE__ */ import_react5.default.createElement(InputHeader, {
231
- error
232
- }, /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Input.Label, null, label)), /* @__PURE__ */ import_react5.default.createElement("div", {
233
- className: (0, import_react_ui_theme2.mx)("grid gap-2", gridCols[binding.length - 1])
234
- }, binding.map((prop) => /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Input.TextInput, {
235
- key: prop,
236
- type: "number",
237
- disabled,
238
- value: values[prop],
239
- onChange: (event) => onValueChange(property, type, {
240
- ...values,
241
- [prop]: (0, import_util2.safeParseFloat)(event.target.value, 0)
242
- }),
243
- onBlur
244
- }))));
245
- };
246
- var TextInput = ({ property, type, label, inputOnly, disabled, placeholder, getStatus, getValue: getValue2, onValueChange, onBlur }) => {
247
- const { status, error } = getStatus?.(property);
248
- return /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Input.Root, {
249
- validationValence: status
250
- }, !inputOnly && /* @__PURE__ */ import_react6.default.createElement(InputHeader, {
251
- error
252
- }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Input.Label, null, label)), /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Input.TextInput, {
253
- disabled,
254
- placeholder,
255
- value: getValue2(property) ?? "",
256
- onChange: (event) => onValueChange(property, type, event.target.value),
257
- onBlur
258
- }), inputOnly && /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Input.Validation, null, error));
259
- };
260
- var NumberInput = ({ property, type, label, inputOnly, disabled, placeholder, getStatus, getValue: getValue2, onValueChange, onBlur }) => {
261
- const { status, error } = getStatus?.(property);
262
- return /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Input.Root, {
263
- validationValence: status
264
- }, !inputOnly && /* @__PURE__ */ import_react6.default.createElement(InputHeader, {
265
- error
266
- }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Input.Label, null, label)), /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Input.TextInput, {
267
- type: "number",
268
- disabled,
269
- placeholder,
270
- value: getValue2(property) ?? 0,
271
- onChange: (event) => onValueChange(property, type, event.target.value),
272
- onBlur
273
- }), inputOnly && /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Input.DescriptionAndValidation, null, error));
274
- };
275
- var BooleanInput = ({ property, type, label, inputOnly, getStatus, getValue: getValue2, onValueChange }) => {
276
- const { status, error } = getStatus?.(property);
277
- return /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Input.Root, {
278
- validationValence: status
279
- }, !inputOnly && /* @__PURE__ */ import_react6.default.createElement(InputHeader, {
280
- error
281
- }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Input.Label, null, label)), /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Input.Switch, {
282
- checked: getValue2(property),
283
- onCheckedChange: (value) => onValueChange(property, type, value)
284
- }), inputOnly && /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Input.DescriptionAndValidation, null, error));
285
- };
286
- var SelectInput = ({ property, type, label, inputOnly, disabled, placeholder, options, getStatus, getValue: getValue2, onValueChange }) => {
287
- const { status, error } = getStatus?.(property);
288
- return /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Input.Root, {
289
- validationValence: status
290
- }, !inputOnly && /* @__PURE__ */ import_react6.default.createElement(InputHeader, {
291
- error
292
- }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Input.Label, null, label)), /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Select.Root, {
293
- value: getValue2(property),
294
- onValueChange: (value) => onValueChange(property, type, value)
295
- }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Select.TriggerButton, {
296
- classNames: "is-full",
297
- disabled,
298
- placeholder
299
- }), /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Select.Portal, null, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Select.Content, null, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Select.Viewport, null, options?.map(({ value, label: label2 }) => (
300
- // NOTE: Numeric values are converted to and from strings.
301
- /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Select.Option, {
302
- key: String(value),
303
- value: String(value)
304
- }, label2 ?? String(value))
305
- )))))), inputOnly && /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Input.DescriptionAndValidation, null, error));
306
- };
307
- var getInputComponent = (type, format) => {
308
- switch (format) {
309
- case import_echo_schema3.FormatEnum.LatLng:
310
- return GeoPointInput;
311
- }
312
- switch (type) {
313
- case "string":
314
- return TextInput;
315
- case "number":
316
- return NumberInput;
317
- case "boolean":
318
- return BooleanInput;
319
- }
320
- };
321
216
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/hooks/useForm.ts";
322
217
  var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, onSave }) => {
323
- (0, import_invariant.invariant)(import_effect3.AST.isTypeLiteral(schema.ast), void 0, {
218
+ (0, import_invariant.invariant)(import_effect2.AST.isTypeLiteral(schema.ast), void 0, {
324
219
  F: __dxlog_file,
325
- L: 91,
220
+ L: 92,
326
221
  S: void 0,
327
222
  A: [
328
223
  "AST.isTypeLiteral(schema.ast)",
329
224
  ""
330
225
  ]
331
226
  });
332
- const [values, setValues] = (0, import_react8.useState)(initialValues);
333
- (0, import_react8.useEffect)(() => {
227
+ const [values, setValues] = (0, import_react4.useState)(initialValues);
228
+ (0, import_react4.useEffect)(() => {
334
229
  setValues(initialValues);
335
230
  }, [
336
231
  initialValues
337
232
  ]);
338
- const [touched, setTouched] = (0, import_react8.useState)(createKeySet(initialValues, false));
339
- const [changed, setChanged] = (0, import_react8.useState)(createKeySet(initialValues, false));
340
- const [errors, setErrors] = (0, import_react8.useState)({});
341
- const [saving, setSaving] = (0, import_react8.useState)(false);
342
- const validate = (0, import_react8.useCallback)((values2) => {
343
- let errors2 = (0, import_schema3.validateSchema)(schema, values2) ?? [];
233
+ const [touched, setTouched] = (0, import_react4.useState)(createKeySet(initialValues, false));
234
+ const [changed, setChanged] = (0, import_react4.useState)(createKeySet(initialValues, false));
235
+ const [errors, setErrors] = (0, import_react4.useState)({});
236
+ const [saving, setSaving] = (0, import_react4.useState)(false);
237
+ const validate = (0, import_react4.useCallback)((values2) => {
238
+ let errors2 = (0, import_schema2.validateSchema)(schema, values2) ?? [];
344
239
  if (errors2.length === 0 && onValidate) {
345
240
  const validatedValues = values2;
346
241
  errors2 = onValidate(validatedValues) ?? [];
@@ -352,11 +247,11 @@ var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, on
352
247
  schema,
353
248
  onValidate
354
249
  ]);
355
- const [schemaDirty, setSchemaDirty] = (0, import_react8.useState)(false);
356
- (0, import_react8.useEffect)(() => setSchemaDirty(true), [
250
+ const [schemaDirty, setSchemaDirty] = (0, import_react4.useState)(false);
251
+ (0, import_react4.useEffect)(() => setSchemaDirty(true), [
357
252
  schema
358
253
  ]);
359
- (0, import_react8.useEffect)(() => {
254
+ (0, import_react4.useEffect)(() => {
360
255
  if (schemaDirty) {
361
256
  validate(values);
362
257
  setSchemaDirty(false);
@@ -365,13 +260,18 @@ var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, on
365
260
  values,
366
261
  schemaDirty
367
262
  ]);
368
- const canSave = (0, import_react8.useMemo)(() => !saving && Object.keys(values).every((property) => touched[property] === false || !errors[property]), [
369
- values,
263
+ const formIsValid = (0, import_react4.useMemo)(() => {
264
+ return Object.keys(errors).length === 0;
265
+ }, [
266
+ errors
267
+ ]);
268
+ const canSave = (0, import_react4.useMemo)(() => !saving && // Check if any error paths that are touched have errors
269
+ !Object.entries(touched).some(([path, isTouched]) => isTouched && Object.keys(errors).some((errorPath) => errorPath === path || errorPath.startsWith(`${path}.`) || errorPath.startsWith(`${path}[`))), [
370
270
  touched,
371
271
  errors,
372
272
  saving
373
273
  ]);
374
- const handleSave = (0, import_react8.useCallback)(async () => {
274
+ const handleSave = (0, import_react4.useCallback)(async () => {
375
275
  if (validate(values)) {
376
276
  setSaving(true);
377
277
  try {
@@ -388,38 +288,42 @@ var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, on
388
288
  onSave,
389
289
  changed
390
290
  ]);
391
- const getStatus = (0, import_react8.useCallback)((property) => ({
392
- status: errors[property] ? "error" : void 0,
393
- error: errors[property] ? errors[property] : void 0
394
- }), [
395
- touched,
291
+ const getStatus = (0, import_react4.useCallback)((path) => {
292
+ const jsonPath = Array.isArray(path) ? (0, import_effect2.createJsonPath)(path) : path;
293
+ const matchingError = Object.entries(errors).find(([errorPath]) => errorPath === jsonPath || errorPath.startsWith(`${jsonPath}.`) || errorPath.startsWith(`${jsonPath}[`));
294
+ return {
295
+ status: matchingError ? "error" : void 0,
296
+ error: matchingError ? matchingError[1] : void 0
297
+ };
298
+ }, [
396
299
  errors
397
300
  ]);
398
- const getFormValue = (property) => {
399
- return (0, import_echo_schema4.getValue)(values, property);
301
+ const getFormValue = (path) => {
302
+ return (0, import_echo_schema3.getValue)(values, (0, import_effect2.createJsonPath)(path));
400
303
  };
401
- const onValueChange = (property, type, value) => {
304
+ const onValueChange = (path, type, value) => {
305
+ const jsonPath = (0, import_effect2.createJsonPath)(path);
402
306
  let parsedValue = value;
403
307
  try {
404
308
  if (type === "number") {
405
309
  parsedValue = parseFloat(value) || 0;
406
310
  }
407
311
  } catch (err) {
408
- import_log3.log.catch(err, void 0, {
312
+ import_log2.log.catch(err, void 0, {
409
313
  F: __dxlog_file,
410
- L: 179,
314
+ L: 198,
411
315
  S: void 0,
412
316
  C: (f, a) => f(...a)
413
317
  });
414
318
  parsedValue = void 0;
415
319
  }
416
320
  const newValues = {
417
- ...(0, import_echo_schema4.setValue)(values, property, parsedValue)
321
+ ...(0, import_echo_schema3.setValue)(values, jsonPath, parsedValue)
418
322
  };
419
323
  setValues(newValues);
420
324
  setChanged((prev) => ({
421
325
  ...prev,
422
- [property]: true
326
+ [jsonPath]: true
423
327
  }));
424
328
  onValuesChanged?.(newValues);
425
329
  const isValid = validate(newValues);
@@ -429,15 +333,12 @@ var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, on
429
333
  });
430
334
  }
431
335
  };
432
- const onBlur = (0, import_react8.useCallback)((event) => {
433
- const { name } = event.target;
336
+ const onTouched = (0, import_react4.useCallback)((path) => {
337
+ const jsonPath = (0, import_effect2.createJsonPath)(path);
434
338
  setTouched((touched2) => ({
435
339
  ...touched2,
436
- [name]: true
340
+ [jsonPath]: true
437
341
  }));
438
- if (event.relatedTarget?.getAttribute("type") === "submit") {
439
- setTouched(createKeySet(values, true));
440
- }
441
342
  validate(values);
442
343
  }, [
443
344
  validate,
@@ -451,17 +352,18 @@ var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, on
451
352
  changed,
452
353
  canSave,
453
354
  handleSave,
355
+ formIsValid,
454
356
  // Field utils.
455
357
  getStatus,
456
358
  getValue: getFormValue,
457
359
  onValueChange,
458
- onBlur
360
+ onTouched
459
361
  };
460
362
  };
461
363
  var createKeySet = (obj, value) => {
462
364
  (0, import_invariant.invariant)(obj, void 0, {
463
365
  F: __dxlog_file,
464
- L: 230,
366
+ L: 241,
465
367
  S: void 0,
466
368
  A: [
467
369
  "obj",
@@ -475,322 +377,726 @@ var createKeySet = (obj, value) => {
475
377
  };
476
378
  var flatMap = (errors) => {
477
379
  return errors.reduce((result, { path, message }) => {
478
- if (!(path in result)) {
479
- result[path] = message;
380
+ const jsonPath = (0, import_effect2.fromEffectValidationPath)(path);
381
+ if (!(jsonPath in result)) {
382
+ result[jsonPath] = message;
480
383
  }
481
384
  return result;
482
385
  }, {});
483
386
  };
484
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/Form/Form.tsx";
485
- var padding = "px-2";
486
- var Form = ({ classNames, schema, values: initialValues, path = [], readonly, filter, sort, autoSave, testId, onValuesChanged, onValidate, onSave, onCancel, lookupComponent, Custom }) => {
487
- const onValid = (0, import_react7.useMemo)(() => autoSave ? onSave : void 0, [
488
- autoSave,
489
- onSave
490
- ]);
491
- const { canSave, values, errors, handleSave, ...inputProps } = useForm({
492
- schema,
493
- initialValues,
494
- onValuesChanged,
495
- onValidate,
496
- onValid,
497
- onSave
498
- });
499
- const properties = (0, import_react7.useMemo)(() => {
500
- const props = (0, import_schema2.getSchemaProperties)(schema.ast, values);
501
- const filtered = filter ? filter(props) : props;
502
- const findIndex = (props2, prop) => {
503
- const idx = props2.findIndex((p) => p === prop);
504
- return idx === -1 ? Infinity : idx;
387
+ var FormContext = /* @__PURE__ */ (0, import_react3.createContext)(void 0);
388
+ var useFormContext = () => {
389
+ return (0, import_react3.useContext)(FormContext) ?? (0, import_debug.raise)(new Error("Missing FormContext"));
390
+ };
391
+ var useFormValues = (path = []) => {
392
+ const { values: formValues } = useFormContext();
393
+ const jsonPath = (0, import_effect.createJsonPath)(path);
394
+ return (0, import_echo_schema2.getValue)(formValues, jsonPath);
395
+ };
396
+ var useInputProps = (path = []) => {
397
+ const { getStatus, getValue: getFormValue, onValueChange, onTouched } = useFormContext();
398
+ return {
399
+ getStatus: () => getStatus(path),
400
+ getValue: () => getFormValue(path),
401
+ onValueChange: (type, value) => onValueChange(path, type, value),
402
+ onBlur: () => onTouched(path)
403
+ };
404
+ };
405
+ var FormProvider = ({ children, formRef, autoSave, ...formOptions }) => {
406
+ const form = useForm(formOptions);
407
+ (0, import_react3.useEffect)(() => {
408
+ if (!formRef?.current) {
409
+ return;
410
+ }
411
+ const handleKeyDown = (event) => {
412
+ const keyIsEnter = event.key === "Enter";
413
+ const modifierUsed = event.ctrlKey || event.altKey || event.metaKey || event.shiftKey;
414
+ const inputIsTextarea = event.target.tagName.toLowerCase() === "textarea";
415
+ const inputOptOut = event.target.hasAttribute("data-no-submit");
416
+ const shouldSubmitRegularInput = !inputIsTextarea && keyIsEnter && !modifierUsed;
417
+ const shouldSubmitTextarea = inputIsTextarea && keyIsEnter && event.metaKey;
418
+ if ((shouldSubmitRegularInput || shouldSubmitTextarea) && !inputOptOut) {
419
+ if (!autoSave && form.canSave) {
420
+ form.handleSave();
421
+ }
422
+ if (autoSave && form.formIsValid) {
423
+ event.target.blur();
424
+ }
425
+ }
505
426
  };
506
- return sort ? filtered.sort(({ name: a }, { name: b }) => findIndex(sort, a) - findIndex(sort, b)) : filtered;
427
+ const formElement = formRef.current;
428
+ formElement.addEventListener("keydown", handleKeyDown);
429
+ return () => formElement.removeEventListener("keydown", handleKeyDown);
507
430
  }, [
508
- schema,
509
- filter,
510
- values
431
+ formRef,
432
+ form.canSave,
433
+ form.formIsValid,
434
+ form.handleSave,
435
+ autoSave
511
436
  ]);
437
+ return /* @__PURE__ */ import_react3.default.createElement(FormContext.Provider, {
438
+ value: form
439
+ }, children);
440
+ };
441
+ var InputHeader = ({ children, error }) => {
442
+ return /* @__PURE__ */ import_react6.default.createElement("div", {
443
+ role: "none",
444
+ className: "flex justify-between items-center mb-1"
445
+ }, children, error && /* @__PURE__ */ import_react6.default.createElement(import_react_ui4.Tooltip.Root, null, /* @__PURE__ */ import_react6.default.createElement(import_react_ui4.Tooltip.Trigger, {
446
+ asChild: true
447
+ }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui4.Icon, {
448
+ icon: "ph--warning--regular",
449
+ size: 4,
450
+ classNames: import_react_ui_theme2.errorText
451
+ })), /* @__PURE__ */ import_react6.default.createElement(import_react_ui4.Tooltip.Content, {
452
+ side: "bottom"
453
+ }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui4.Tooltip.Arrow, null), error)));
454
+ };
455
+ var GeoPointInput = ({ type, label, disabled, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
456
+ const { t } = (0, import_react_ui3.useTranslation)(translationKey);
457
+ const { status, error } = getStatus();
458
+ const [lng = 0, lat = 0] = getValue3() ?? [];
459
+ return /* @__PURE__ */ import_react5.default.createElement(import_react_ui3.Input.Root, {
460
+ validationValence: status
461
+ }, /* @__PURE__ */ import_react5.default.createElement(InputHeader, {
462
+ error
463
+ }, /* @__PURE__ */ import_react5.default.createElement(import_react_ui3.Input.Label, null, label)), /* @__PURE__ */ import_react5.default.createElement("div", {
464
+ className: "grid grid-cols-2 gap-2"
465
+ }, /* @__PURE__ */ import_react5.default.createElement(import_react_ui3.Input.TextInput, {
466
+ type: "number",
467
+ disabled,
468
+ placeholder: t("placeholder longitude"),
469
+ value: lng,
470
+ onChange: (event) => onValueChange(type, [
471
+ lat,
472
+ (0, import_util.safeParseFloat)(event.target.value, 0)
473
+ ]),
474
+ onBlur
475
+ }), /* @__PURE__ */ import_react5.default.createElement(import_react_ui3.Input.TextInput, {
476
+ type: "number",
477
+ disabled,
478
+ placeholder: t("placeholder latitude"),
479
+ value: lat,
480
+ onChange: (event) => onValueChange(type, [
481
+ (0, import_util.safeParseFloat)(event.target.value, 0),
482
+ lng
483
+ ]),
484
+ onBlur
485
+ })));
486
+ };
487
+ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3, onValueChange }) => {
488
+ const [selected, setSelectedId] = (0, import_react7.useState)(null);
489
+ const [isNewOption, setIsNewOption] = (0, import_react7.useState)(false);
490
+ const inputRef = (0, import_react7.useRef)(null);
491
+ const { t } = (0, import_react_ui5.useTranslation)(translationKey);
492
+ const { status, error } = getStatus();
493
+ const options = getValue3();
512
494
  (0, import_react7.useEffect)(() => {
513
- if (errors && Object.keys(errors).length) {
514
- import_log2.log.warn("validation", {
515
- errors
516
- }, {
517
- F: __dxlog_file2,
518
- L: 106,
519
- S: void 0,
520
- C: (f, a) => f(...a)
521
- });
495
+ if (options === void 0) {
496
+ onValueChange(type, []);
522
497
  }
523
498
  }, [
524
- errors
499
+ options,
500
+ onValueChange,
501
+ type
525
502
  ]);
526
- return /* @__PURE__ */ import_react7.default.createElement("div", {
527
- role: "form",
528
- className: (0, import_react_ui_theme3.mx)("flex flex-col w-full gap-2 py-2", classNames),
529
- "data-testid": testId
530
- }, properties.map((property) => {
531
- const { ast, name, type, format, title, description, examples, options, array } = property;
532
- const key = [
533
- ...path,
534
- name
503
+ const randomHue = () => {
504
+ const usedHues = new Set(options?.map((option) => option.color) ?? []);
505
+ const unusedHues = import_react_ui_theme3.hues.filter((hue) => !usedHues.has(hue));
506
+ if (unusedHues.length > 0) {
507
+ return unusedHues[Math.floor(Math.random() * unusedHues.length)];
508
+ }
509
+ const lastThree = new Set(options?.slice(-3).map((option) => option.color) ?? []);
510
+ const availableHues = import_react_ui_theme3.hues.filter((hue) => !lastThree.has(hue));
511
+ return availableHues[Math.floor(Math.random() * availableHues.length)] ?? import_react_ui_theme3.hues[Math.floor(Math.random() * import_react_ui_theme3.hues.length)];
512
+ };
513
+ const handleAdd = (0, import_react7.useCallback)(() => {
514
+ const newId = import_keys.PublicKey.random().truncate();
515
+ const newOption = {
516
+ id: newId,
517
+ title: "",
518
+ color: randomHue()
519
+ };
520
+ onValueChange(type, [
521
+ ...options ?? [],
522
+ newOption
523
+ ]);
524
+ setSelectedId(newId);
525
+ setIsNewOption(true);
526
+ }, [
527
+ options,
528
+ type,
529
+ onValueChange
530
+ ]);
531
+ const handleDelete = (0, import_react7.useCallback)((id) => {
532
+ const newOptions = options?.filter((option) => option.id !== id) ?? [];
533
+ onValueChange(type, newOptions);
534
+ setSelectedId(null);
535
+ }, [
536
+ options,
537
+ type,
538
+ onValueChange
539
+ ]);
540
+ const handleMove = (0, import_react7.useCallback)((from, to) => {
541
+ if (!options) {
542
+ return;
543
+ }
544
+ const newOptions = [
545
+ ...options
535
546
  ];
536
- const label = title ?? (0, import_effect.pipe)(name, import_String.capitalize);
537
- const placeholder = examples?.length ? `Example: "${examples[0]}"` : description;
538
- const FoundComponent = lookupComponent?.({
539
- prop: name,
540
- schema: import_echo_schema2.S.make(ast),
541
- inputProps: {
542
- property: name,
543
- type,
544
- format,
545
- label,
546
- disabled: readonly,
547
- placeholder,
548
- ...inputProps
549
- }
550
- });
551
- if (FoundComponent) {
552
- return /* @__PURE__ */ import_react7.default.createElement("div", {
553
- key: name,
554
- role: "none",
555
- className: padding
556
- }, FoundComponent);
547
+ const [removed] = newOptions.splice(from, 1);
548
+ newOptions.splice(to, 0, removed);
549
+ onValueChange(type, newOptions);
550
+ }, [
551
+ options,
552
+ type,
553
+ onValueChange
554
+ ]);
555
+ const handleClick = (0, import_react7.useCallback)((id) => {
556
+ setSelectedId((current) => current === id ? null : id);
557
+ }, []);
558
+ const handleTitleChange = (0, import_react7.useCallback)((id) => (e) => {
559
+ const newOptions = options?.map((o) => o.id === id ? {
560
+ ...o,
561
+ title: e.target.value
562
+ } : o);
563
+ onValueChange(type, newOptions ?? []);
564
+ }, [
565
+ options,
566
+ type,
567
+ onValueChange
568
+ ]);
569
+ const handleKeyDown = (0, import_react7.useCallback)((e) => {
570
+ if (e.key === "Enter") {
571
+ setSelectedId(null);
557
572
  }
558
- let InputComponent = Custom?.[key.join(".")];
559
- if (!InputComponent) {
560
- if (options) {
561
- return /* @__PURE__ */ import_react7.default.createElement("div", {
562
- key: name,
563
- role: "none",
564
- className: padding
565
- }, /* @__PURE__ */ import_react7.default.createElement(SelectInput, {
566
- type,
567
- format,
568
- property: name,
569
- disabled: readonly,
570
- label,
571
- options: options.map((option) => ({
572
- value: option,
573
- label: String(option)
574
- })),
575
- placeholder,
576
- ...inputProps
577
- }));
578
- }
579
- InputComponent = getInputComponent(type, format);
580
- if (array) {
581
- return /* @__PURE__ */ import_react7.default.createElement(ArrayField, {
582
- key: name,
583
- name,
584
- type,
585
- array: true,
586
- label,
587
- ast,
588
- values,
589
- format,
590
- readonly,
591
- placeholder,
592
- inputProps,
593
- Custom
594
- });
595
- }
573
+ }, []);
574
+ const handleColorChange = (0, import_react7.useCallback)((id) => (hue) => {
575
+ const newOptions = options?.map((o) => o.id === id ? {
576
+ ...o,
577
+ color: hue
578
+ } : o);
579
+ onValueChange(type, newOptions ?? []);
580
+ }, [
581
+ options,
582
+ type,
583
+ onValueChange
584
+ ]);
585
+ (0, import_react7.useEffect)(() => {
586
+ if (selected && isNewOption && inputRef.current) {
587
+ inputRef.current.focus();
588
+ setIsNewOption(false);
596
589
  }
597
- if (!InputComponent) {
598
- if (type === "object") {
599
- const baseNode = (0, import_effect2.findNode)(ast, import_effect2.isDiscriminatedUnion);
600
- const typeLiteral = baseNode ? (0, import_effect2.getDiscriminatedType)(baseNode, values[name]) : (0, import_effect2.findNode)(ast, import_echo_schema2.AST.isTypeLiteral);
601
- if (typeLiteral) {
602
- const schema2 = import_echo_schema2.S.make(typeLiteral);
603
- return /* @__PURE__ */ import_react7.default.createElement("div", {
604
- key: name,
605
- role: "none"
606
- }, /* @__PURE__ */ import_react7.default.createElement("div", {
607
- className: padding
608
- }, label), /* @__PURE__ */ import_react7.default.createElement(Form, {
609
- schema: schema2,
610
- path: key,
611
- values: values[name] ?? {},
612
- onValuesChanged: (childValues) => {
613
- inputProps.onValueChange(name, "object", childValues);
614
- },
615
- Custom
616
- }));
617
- }
618
- }
619
- (0, import_log2.log)("no renderer for property", {
620
- name,
621
- type
622
- }, {
623
- F: __dxlog_file2,
624
- L: 213,
625
- S: void 0,
626
- C: (f, a) => f(...a)
627
- });
628
- return null;
590
+ }, [
591
+ selected,
592
+ isNewOption
593
+ ]);
594
+ return /* @__PURE__ */ import_react7.default.createElement(import_react_ui5.Input.Root, {
595
+ validationValence: status
596
+ }, /* @__PURE__ */ import_react7.default.createElement(InputHeader, {
597
+ error
598
+ }, /* @__PURE__ */ import_react7.default.createElement(import_react_ui5.Input.Label, null, label)), /* @__PURE__ */ import_react7.default.createElement("div", {
599
+ role: "none"
600
+ }, options && /* @__PURE__ */ import_react7.default.createElement(import_react_ui_list.List.Root, {
601
+ items: options,
602
+ isItem: (item) => true,
603
+ onMove: handleMove
604
+ }, ({ items }) => /* @__PURE__ */ import_react7.default.createElement("div", {
605
+ role: "list",
606
+ className: "w-full overflow-auto"
607
+ }, items?.map((item) => /* @__PURE__ */ import_react7.default.createElement("div", {
608
+ key: item.id
609
+ }, /* @__PURE__ */ import_react7.default.createElement(import_react_ui_list.List.Item, {
610
+ role: "button",
611
+ item,
612
+ classNames: (0, import_react_ui_theme3.mx)("p-1 plb-2", "flex flex-col", "cursor-pointer", "hover:bg-hoverOverlay"),
613
+ "aria-expanded": selected === item.id
614
+ }, /* @__PURE__ */ import_react7.default.createElement("div", {
615
+ className: "flex items-center"
616
+ }, /* @__PURE__ */ import_react7.default.createElement(import_react_ui_list.List.ItemDragHandle, null), /* @__PURE__ */ import_react7.default.createElement(import_react_ui_list.List.ItemTitle, {
617
+ onClick: () => handleClick(item.id),
618
+ classNames: "flex-1"
619
+ }, /* @__PURE__ */ import_react7.default.createElement(import_react_ui5.Tag, {
620
+ palette: item.color
621
+ }, item.title || "\u200B")), /* @__PURE__ */ import_react7.default.createElement(import_react_ui5.Icon, {
622
+ icon: selected === item.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
623
+ onClick: () => handleClick(item.id)
624
+ })), selected === item.id && /* @__PURE__ */ import_react7.default.createElement("div", {
625
+ className: "mis-4 mbs-2 flex flex-col gap-1"
626
+ }, /* @__PURE__ */ import_react7.default.createElement(import_react_ui5.Input.Label, {
627
+ classNames: "text-xs"
628
+ }, t("select option label")), /* @__PURE__ */ import_react7.default.createElement("div", {
629
+ className: "flex flex-row items-center gap-1"
630
+ }, /* @__PURE__ */ import_react7.default.createElement(import_react_ui5.Input.TextInput, {
631
+ placeholder: t("select option label placeholder"),
632
+ ref: selected === item.id ? inputRef : void 0,
633
+ value: item.title,
634
+ onChange: handleTitleChange(item.id),
635
+ onKeyDown: handleKeyDown,
636
+ classNames: "flex-1",
637
+ "data-no-submit": true
638
+ }), /* @__PURE__ */ import_react7.default.createElement(import_react_ui5.Toolbar.Root, {
639
+ classNames: "p-0 m-0 !is-auto"
640
+ }, /* @__PURE__ */ import_react7.default.createElement(import_react_ui_pickers.HuePickerToolbarButton, {
641
+ hue: item.color,
642
+ onChangeHue: handleColorChange(item.id)
643
+ })), /* @__PURE__ */ import_react7.default.createElement(import_react_ui5.IconButton, {
644
+ icon: "ph--trash--fill",
645
+ iconOnly: true,
646
+ label: t("select option delete"),
647
+ onClick: () => handleDelete(item.id)
648
+ })))))), /* @__PURE__ */ import_react7.default.createElement("div", {
649
+ role: "listitem"
650
+ }, /* @__PURE__ */ import_react7.default.createElement("div", {
651
+ role: "button",
652
+ className: (0, import_react_ui_theme3.mx)("p-1 plb-2", "flex flex-col", "cursor-pointer", "hover:bg-hoverOverlay"),
653
+ onClick: handleAdd
654
+ }, /* @__PURE__ */ import_react7.default.createElement("div", {
655
+ className: "flex items-center gap-1"
656
+ }, /* @__PURE__ */ import_react7.default.createElement(import_react_ui5.Icon, {
657
+ icon: "ph--plus--regular"
658
+ }), /* @__PURE__ */ import_react7.default.createElement("span", {
659
+ className: "text-sm"
660
+ }, t("select option add")))))))));
661
+ };
662
+ var gridCols = [
663
+ "grid-cols-1",
664
+ "grid-cols-2",
665
+ "grid-cols-3",
666
+ "grid-cols-4"
667
+ ];
668
+ var TupleInput = ({ binding, type, label, disabled, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
669
+ const { status, error } = getStatus();
670
+ const values = getValue3() ?? {};
671
+ return /* @__PURE__ */ import_react8.default.createElement(import_react_ui6.Input.Root, {
672
+ validationValence: status
673
+ }, /* @__PURE__ */ import_react8.default.createElement(InputHeader, {
674
+ error
675
+ }, /* @__PURE__ */ import_react8.default.createElement(import_react_ui6.Input.Label, null, label)), /* @__PURE__ */ import_react8.default.createElement("div", {
676
+ className: (0, import_react_ui_theme4.mx)("grid gap-2", gridCols[binding.length - 1])
677
+ }, binding.map((prop) => /* @__PURE__ */ import_react8.default.createElement(import_react_ui6.Input.TextInput, {
678
+ key: prop,
679
+ type: "number",
680
+ disabled,
681
+ value: values[prop],
682
+ onChange: (event) => onValueChange(type, {
683
+ ...values,
684
+ [prop]: (0, import_util2.safeParseFloat)(event.target.value, 0)
685
+ }),
686
+ onBlur
687
+ }))));
688
+ };
689
+ var TextInput = ({ type, label, inputOnly, disabled, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
690
+ const { status, error } = getStatus();
691
+ return /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Input.Root, {
692
+ validationValence: status
693
+ }, !inputOnly && /* @__PURE__ */ import_react9.default.createElement(InputHeader, {
694
+ error
695
+ }, /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Input.Label, null, label)), /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Input.TextInput, {
696
+ disabled,
697
+ placeholder,
698
+ value: getValue3() ?? "",
699
+ onChange: (event) => onValueChange(type, event.target.value),
700
+ onBlur
701
+ }), inputOnly && /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Input.Validation, null, error));
702
+ };
703
+ var NumberInput = ({ type, label, inputOnly, disabled, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
704
+ const { status, error } = getStatus();
705
+ return /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Input.Root, {
706
+ validationValence: status
707
+ }, !inputOnly && /* @__PURE__ */ import_react9.default.createElement(InputHeader, {
708
+ error
709
+ }, /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Input.Label, null, label)), /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Input.TextInput, {
710
+ type: "number",
711
+ disabled,
712
+ placeholder,
713
+ value: getValue3() ?? 0,
714
+ onChange: (event) => onValueChange(type, event.target.value),
715
+ onBlur
716
+ }), inputOnly && /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Input.DescriptionAndValidation, null, error));
717
+ };
718
+ var BooleanInput = ({ type, label, inputOnly, getStatus, getValue: getValue3, onValueChange }) => {
719
+ const { status, error } = getStatus();
720
+ const checked = Boolean(getValue3());
721
+ return /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Input.Root, {
722
+ validationValence: status
723
+ }, !inputOnly && /* @__PURE__ */ import_react9.default.createElement(InputHeader, {
724
+ error
725
+ }, /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Input.Label, null, label)), /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Input.Switch, {
726
+ checked,
727
+ onCheckedChange: (value) => onValueChange(type, value)
728
+ }), inputOnly && /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Input.DescriptionAndValidation, null, error));
729
+ };
730
+ var SelectInput = ({ type, label, inputOnly, disabled, placeholder, options, getStatus, getValue: getValue3, onValueChange }) => {
731
+ const { status, error } = getStatus();
732
+ return /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Input.Root, {
733
+ validationValence: status
734
+ }, !inputOnly && /* @__PURE__ */ import_react9.default.createElement(InputHeader, {
735
+ error
736
+ }, /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Input.Label, null, label)), /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Select.Root, {
737
+ value: getValue3(),
738
+ onValueChange: (value) => onValueChange(type, value)
739
+ }, /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Select.TriggerButton, {
740
+ classNames: "is-full",
741
+ disabled,
742
+ placeholder
743
+ }), /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Select.Portal, null, /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Select.Content, null, /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Select.Viewport, null, options?.map(({ value, label: label2 }) => (
744
+ // NOTE: Numeric values are converted to and from strings.
745
+ /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Select.Option, {
746
+ key: String(value),
747
+ value: String(value)
748
+ }, label2 ?? String(value))
749
+ )))))), inputOnly && /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Input.DescriptionAndValidation, null, error));
750
+ };
751
+ var MarkdownInput = ({ type, label, inputOnly, disabled, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
752
+ const { status, error } = getStatus();
753
+ const textareaRef = (0, import_react9.useRef)(null);
754
+ const adjustHeight = (0, import_react9.useCallback)(() => {
755
+ const textarea = textareaRef.current;
756
+ if (textarea) {
757
+ textarea.style.blockSize = "auto";
758
+ textarea.style.blockSize = `${textarea.scrollHeight + 2}px`;
629
759
  }
630
- return /* @__PURE__ */ import_react7.default.createElement("div", {
631
- key: name,
632
- role: "none",
633
- className: padding
634
- }, /* @__PURE__ */ import_react7.default.createElement(InputComponent, {
635
- type,
636
- format,
637
- property: name,
638
- disabled: readonly,
639
- label,
640
- placeholder,
641
- ...inputProps
642
- }));
643
- }).filter(import_util3.isNotFalsy), (onCancel || onSave) && !autoSave && /* @__PURE__ */ import_react7.default.createElement(FormActions, {
644
- onCancel,
645
- onSubmit: handleSave,
646
- canSubmit: canSave,
647
- readonly
648
- }));
760
+ }, []);
761
+ (0, import_react9.useEffect)(() => {
762
+ adjustHeight();
763
+ }, [
764
+ adjustHeight
765
+ ]);
766
+ (0, import_react9.useEffect)(() => {
767
+ adjustHeight();
768
+ }, [
769
+ getValue3(),
770
+ adjustHeight
771
+ ]);
772
+ return /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Input.Root, {
773
+ validationValence: status
774
+ }, !inputOnly && /* @__PURE__ */ import_react9.default.createElement(InputHeader, {
775
+ error
776
+ }, /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Input.Label, null, label)), /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Input.TextArea, {
777
+ ref: textareaRef,
778
+ disabled,
779
+ placeholder,
780
+ value: getValue3() ?? "",
781
+ classNames: "min-bs-auto overflow-hidden",
782
+ onChange: (event) => onValueChange(type, event.target.value),
783
+ onBlur,
784
+ style: {
785
+ resize: "none"
786
+ },
787
+ spellCheck: false
788
+ }), inputOnly && /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Input.Validation, null, error));
649
789
  };
650
- var ArrayField = ({ name, type, label, ast, values, format, readonly, placeholder, inputProps, Custom }) => {
651
- const { t } = (0, import_react_ui7.useTranslation)(translationKey);
652
- const arrayValues = values[name] ?? [];
653
- const key = [
654
- name
655
- ];
656
- const tupleType = (0, import_effect2.findNode)(ast, import_echo_schema2.AST.isTupleType);
790
+ var FormActions = ({ onCancel, readonly }) => {
791
+ const { t } = (0, import_react_ui8.useTranslation)(translationKey);
792
+ const { canSave, handleSave } = useFormContext();
793
+ return /* @__PURE__ */ import_react11.default.createElement("div", {
794
+ role: "none",
795
+ className: "mt-2 flex justify-center"
796
+ }, /* @__PURE__ */ import_react11.default.createElement("div", {
797
+ role: "none",
798
+ className: (0, import_react_ui_theme6.mx)(onCancel && !readonly && "grid grid-cols-2 gap-2")
799
+ }, onCancel && !readonly && /* @__PURE__ */ import_react11.default.createElement(import_react_ui8.IconButton, {
800
+ "data-testid": "cancel-button",
801
+ icon: "ph--x--regular",
802
+ label: t("button cancel"),
803
+ onClick: onCancel
804
+ }), handleSave && /* @__PURE__ */ import_react11.default.createElement(import_react_ui8.IconButton, {
805
+ type: "submit",
806
+ "data-testid": "save-button",
807
+ disabled: !canSave,
808
+ icon: "ph--check--regular",
809
+ label: t("button save"),
810
+ onClick: handleSave
811
+ })));
812
+ };
813
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/Form/ArrayField.tsx";
814
+ var padding = "px-2";
815
+ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponent }) => {
816
+ const { t } = (0, import_react_ui9.useTranslation)(translationKey);
817
+ const { ast, name, type, title } = property;
818
+ const values = useFormValues(path ?? []);
819
+ (0, import_invariant2.invariant)(Array.isArray(values), `Values at path ${path?.join(".")} must be an array.`, {
820
+ F: __dxlog_file2,
821
+ L: 37,
822
+ S: void 0,
823
+ A: [
824
+ "Array.isArray(values)",
825
+ "`Values at path ${path?.join('.')} must be an array.`"
826
+ ]
827
+ });
828
+ const label = title ?? (0, import_effect5.pipe)(name, import_String2.capitalize);
829
+ const tupleType = (0, import_effect6.findNode)(ast, import_echo_schema5.AST.isTupleType);
657
830
  const elementType = tupleType?.rest[0]?.type;
658
- if (type === "object" && elementType) {
659
- const baseNode = (0, import_effect2.findNode)(elementType, import_effect2.isDiscriminatedUnion);
660
- const typeLiteral = baseNode ? (0, import_effect2.getDiscriminatedType)(baseNode, values[name]) : (0, import_effect2.findNode)(elementType, import_echo_schema2.AST.isTypeLiteral);
661
- if (typeLiteral) {
662
- const schema = import_echo_schema2.S.make(typeLiteral);
663
- return /* @__PURE__ */ import_react7.default.createElement("div", {
664
- key: name,
665
- role: "none",
666
- className: (0, import_react_ui_theme3.mx)(padding)
667
- }, /* @__PURE__ */ import_react7.default.createElement(InputHeader, null, label), /* @__PURE__ */ import_react7.default.createElement("div", {
668
- role: "none",
669
- className: "flex flex-col gap-1"
670
- }, arrayValues.map((value, index) => {
671
- return /* @__PURE__ */ import_react7.default.createElement("div", {
672
- key: index,
673
- role: "none",
674
- className: "flex items-center gap-1"
675
- }, /* @__PURE__ */ import_react7.default.createElement("div", {
676
- role: "none",
677
- className: "flex-1"
678
- }, /* @__PURE__ */ import_react7.default.createElement(Form, {
679
- schema,
680
- path: [
681
- ...key,
682
- `[${index}]`
683
- ],
684
- values: value,
685
- onValuesChanged: (childValues) => {
686
- const newValues = [
687
- ...arrayValues
688
- ];
689
- newValues[index] = childValues;
690
- inputProps.onValueChange(name, "object", newValues);
691
- },
692
- Custom
693
- })), /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.IconButton, {
694
- icon: "ph--trash--regular",
695
- iconOnly: true,
696
- label: t("button remove"),
697
- onClick: () => {
698
- const newValues = arrayValues.filter((_, i) => i !== index);
699
- inputProps.onValueChange(name, type, newValues);
700
- }
701
- }));
702
- })), /* @__PURE__ */ import_react7.default.createElement("div", {
703
- role: "none",
704
- className: "flex justify-between items-center plb-1"
705
- }, /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.IconButton, {
706
- icon: "ph--plus--regular",
707
- iconOnly: true,
708
- label: t("button add"),
709
- onClick: () => {
710
- const newValues = [
711
- ...arrayValues,
712
- {}
713
- ];
714
- inputProps.onValueChange(name, type, newValues);
715
- }
716
- })));
831
+ const getDefaultObjectValue = (typeNode) => {
832
+ const baseNode = (0, import_effect6.findNode)(typeNode, import_effect6.isDiscriminatedUnion);
833
+ const typeLiteral = baseNode ? (0, import_effect6.getDiscriminatedType)(baseNode, {}) : (0, import_effect6.findNode)(typeNode, import_echo_schema5.AST.isTypeLiteral);
834
+ if (!typeLiteral) {
835
+ return {};
717
836
  }
718
- return /* @__PURE__ */ import_react7.default.createElement("div", {
719
- key: name,
720
- role: "none"
721
- }, "Nested form not supported in arrays, yet.");
722
- }
723
- const InputComponent = getInputComponent(type, format);
724
- if (!InputComponent) {
837
+ return Object.fromEntries((0, import_schema4.getSchemaProperties)(typeLiteral, {}).map((prop) => [
838
+ prop.name,
839
+ prop.defaultValue
840
+ ]));
841
+ };
842
+ const newValue = (0, import_react13.useMemo)(() => {
843
+ if (type === "object" && elementType) {
844
+ return getDefaultObjectValue(elementType);
845
+ } else {
846
+ return import_effect6.SimpleType.getDefaultValue(type);
847
+ }
848
+ }, [
849
+ type,
850
+ elementType
851
+ ]);
852
+ const handleAdd = (0, import_react13.useCallback)(() => {
853
+ inputProps.onValueChange(type, [
854
+ ...values,
855
+ newValue
856
+ ]);
857
+ }, [
858
+ type,
859
+ elementType,
860
+ inputProps,
861
+ newValue,
862
+ values
863
+ ]);
864
+ const handleRemove = (0, import_react13.useCallback)((index) => {
865
+ const newValues = values.filter((_, i) => i !== index);
866
+ inputProps.onValueChange(type, newValues);
867
+ }, [
868
+ type,
869
+ inputProps,
870
+ values
871
+ ]);
872
+ if (!elementType) {
725
873
  return null;
726
874
  }
727
- return /* @__PURE__ */ import_react7.default.createElement("div", {
875
+ return /* @__PURE__ */ import_react13.default.createElement("div", {
728
876
  role: "none",
729
- key: "meta-input",
730
- className: (0, import_react_ui_theme3.mx)(padding)
731
- }, /* @__PURE__ */ import_react7.default.createElement(InputHeader, null, label), /* @__PURE__ */ import_react7.default.createElement("div", {
877
+ className: (0, import_react_ui_theme8.mx)(padding)
878
+ }, /* @__PURE__ */ import_react13.default.createElement(InputHeader, null, label), /* @__PURE__ */ import_react13.default.createElement("div", {
732
879
  role: "none",
733
880
  className: "flex flex-col gap-1"
734
- }, arrayValues.map((_, index) => /* @__PURE__ */ import_react7.default.createElement("div", {
881
+ }, values.map((_value, index) => /* @__PURE__ */ import_react13.default.createElement("div", {
735
882
  key: index,
736
883
  role: "none",
737
- className: "flex items-start gap-1"
738
- }, /* @__PURE__ */ import_react7.default.createElement("div", {
884
+ className: "flex items-center gap-1"
885
+ }, /* @__PURE__ */ import_react13.default.createElement("div", {
739
886
  role: "none",
740
887
  className: "flex-1"
741
- }, /* @__PURE__ */ import_react7.default.createElement(InputComponent, {
742
- type,
743
- format,
744
- label,
745
- inputOnly: true,
746
- property: `${name}[${index}]`,
747
- disabled: readonly,
748
- placeholder,
749
- ...inputProps
750
- })), /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.IconButton, {
888
+ }, /* @__PURE__ */ import_react13.default.createElement(FormField, {
889
+ property: {
890
+ ...property,
891
+ array: false,
892
+ ast: elementType
893
+ },
894
+ path: [
895
+ ...path ?? [],
896
+ index
897
+ ],
898
+ readonly,
899
+ inline: true,
900
+ Custom,
901
+ lookupComponent
902
+ })), /* @__PURE__ */ import_react13.default.createElement(import_react_ui9.IconButton, {
751
903
  icon: "ph--trash--regular",
752
904
  iconOnly: true,
753
905
  label: t("button remove"),
754
- onClick: () => {
755
- const newValues = arrayValues.filter((_2, i) => i !== index);
756
- inputProps.onValueChange(name, type, newValues);
757
- }
758
- })))), /* @__PURE__ */ import_react7.default.createElement("div", {
906
+ onClick: () => handleRemove(index)
907
+ })))), /* @__PURE__ */ import_react13.default.createElement("div", {
759
908
  role: "none",
760
909
  className: "flex justify-between items-center plb-1"
761
- }, /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.IconButton, {
910
+ }, /* @__PURE__ */ import_react13.default.createElement(import_react_ui9.IconButton, {
762
911
  icon: "ph--plus--regular",
763
912
  iconOnly: true,
764
913
  label: t("button add"),
765
- onClick: () => {
766
- const newValues = [
767
- ...arrayValues,
768
- import_effect2.SimpleType.getDefaultValue(type)
769
- ];
770
- inputProps.onValueChange(name, type, newValues);
771
- }
914
+ onClick: handleAdd
772
915
  })));
773
916
  };
774
- var FormActions = ({ onCancel, onSubmit, canSubmit, readonly }) => {
775
- const { t } = (0, import_react_ui7.useTranslation)(translationKey);
776
- return /* @__PURE__ */ import_react7.default.createElement("div", {
777
- role: "none",
778
- className: "flex justify-center"
779
- }, /* @__PURE__ */ import_react7.default.createElement("div", {
917
+ var getInputComponent = (type, format) => {
918
+ switch (format) {
919
+ case import_echo_schema6.FormatEnum.LatLng:
920
+ return GeoPointInput;
921
+ case import_echo_schema6.FormatEnum.Markdown:
922
+ return MarkdownInput;
923
+ }
924
+ switch (type) {
925
+ case "string":
926
+ return TextInput;
927
+ case "number":
928
+ return NumberInput;
929
+ case "boolean":
930
+ return BooleanInput;
931
+ }
932
+ };
933
+ var FormField = ({ property, path, readonly, inline, lookupComponent, Custom }) => {
934
+ const inputProps = useInputProps(path);
935
+ const { ast, name, type, format, title, description, options, examples, array } = property;
936
+ const label = (0, import_react12.useMemo)(() => title ?? (0, import_effect3.pipe)(name, import_String.capitalize), [
937
+ title,
938
+ name
939
+ ]);
940
+ const placeholder = (0, import_react12.useMemo)(() => examples?.length ? `Example: "${examples[0]}"` : description, [
941
+ examples,
942
+ description
943
+ ]);
944
+ const FoundComponent = lookupComponent?.({
945
+ prop: name,
946
+ schema: import_echo_schema4.S.make(ast),
947
+ inputProps: {
948
+ type,
949
+ format,
950
+ label,
951
+ disabled: readonly,
952
+ placeholder,
953
+ ...inputProps
954
+ }
955
+ });
956
+ if (FoundComponent) {
957
+ return /* @__PURE__ */ import_react12.default.createElement("div", {
958
+ role: "none"
959
+ }, FoundComponent);
960
+ }
961
+ const jsonPath = (0, import_effect4.createJsonPath)(path ?? []);
962
+ const CustomComponent = Custom?.[jsonPath];
963
+ if (CustomComponent) {
964
+ return /* @__PURE__ */ import_react12.default.createElement(CustomComponent, {
965
+ type,
966
+ format,
967
+ label,
968
+ inputOnly: inline,
969
+ placeholder,
970
+ disabled: readonly,
971
+ ...inputProps
972
+ });
973
+ }
974
+ if (array) {
975
+ return /* @__PURE__ */ import_react12.default.createElement(ArrayField, {
976
+ property,
977
+ path,
978
+ inputProps,
979
+ readonly,
980
+ Custom
981
+ });
982
+ }
983
+ const InputComponent = getInputComponent(type, format);
984
+ if (InputComponent) {
985
+ return /* @__PURE__ */ import_react12.default.createElement("div", {
986
+ role: "none"
987
+ }, /* @__PURE__ */ import_react12.default.createElement(InputComponent, {
988
+ type,
989
+ format,
990
+ label,
991
+ inputOnly: inline,
992
+ placeholder,
993
+ disabled: readonly,
994
+ ...inputProps
995
+ }));
996
+ }
997
+ if (options) {
998
+ return /* @__PURE__ */ import_react12.default.createElement("div", {
999
+ role: "none"
1000
+ }, /* @__PURE__ */ import_react12.default.createElement(SelectInput, {
1001
+ type,
1002
+ format,
1003
+ disabled: readonly,
1004
+ inputOnly: inline,
1005
+ label,
1006
+ options: options.map((option) => ({
1007
+ value: option,
1008
+ label: String(option)
1009
+ })),
1010
+ placeholder,
1011
+ ...inputProps
1012
+ }));
1013
+ }
1014
+ if (type === "object") {
1015
+ const baseNode = (0, import_effect4.findNode)(ast, import_effect4.isDiscriminatedUnion);
1016
+ const typeLiteral = baseNode ? (0, import_effect4.getDiscriminatedType)(baseNode, inputProps.getValue()) : (0, import_effect4.findNode)(ast, import_echo_schema4.AST.isTypeLiteral);
1017
+ if (typeLiteral) {
1018
+ return /* @__PURE__ */ import_react12.default.createElement("div", {
1019
+ role: "none"
1020
+ }, !inline && /* @__PURE__ */ import_react12.default.createElement("div", null, label), /* @__PURE__ */ import_react12.default.createElement(FormFields, {
1021
+ schema: import_echo_schema4.S.make(typeLiteral),
1022
+ path,
1023
+ readonly,
1024
+ Custom
1025
+ }));
1026
+ }
1027
+ }
1028
+ return null;
1029
+ };
1030
+ var FormFields = ({ schema, path, filter, sort, readonly, lookupComponent, Custom }) => {
1031
+ const values = useFormValues(path);
1032
+ const properties = (0, import_react12.useMemo)(() => {
1033
+ const props = (0, import_schema3.getSchemaProperties)(schema.ast, values);
1034
+ const filtered = filter ? filter(props) : props;
1035
+ return sort ? filtered.sort((a, b) => sort.indexOf(a.name) - sort.indexOf(b.name)) : filtered;
1036
+ }, [
1037
+ schema,
1038
+ values,
1039
+ filter,
1040
+ sort
1041
+ ]);
1042
+ return /* @__PURE__ */ import_react12.default.createElement("div", {
1043
+ role: "form",
1044
+ className: (0, import_react_ui_theme7.mx)("flex flex-col w-full gap-2")
1045
+ }, properties.map((property) => {
1046
+ return /* @__PURE__ */ import_react12.default.createElement(FormField, {
1047
+ key: property.name,
1048
+ property,
1049
+ path: [
1050
+ ...path ?? [],
1051
+ property.name
1052
+ ],
1053
+ readonly,
1054
+ lookupComponent,
1055
+ Custom
1056
+ });
1057
+ }).filter(import_util3.isNotFalsy));
1058
+ };
1059
+ var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, readonly, filter, sort, autoSave, testId, onValuesChanged, onValidate, onSave, onCancel, lookupComponent, Custom }) => {
1060
+ const formRef = (0, import_react10.useRef)(null);
1061
+ const onValid = (0, import_react10.useMemo)(() => autoSave ? onSave : void 0, [
1062
+ autoSave,
1063
+ onSave
1064
+ ]);
1065
+ (0, import_react10.useEffect)(() => {
1066
+ if (autoFocus && formRef.current) {
1067
+ const input = formRef.current.querySelector("input");
1068
+ if (input) {
1069
+ input.focus();
1070
+ }
1071
+ }
1072
+ }, [
1073
+ autoFocus
1074
+ ]);
1075
+ return /* @__PURE__ */ import_react10.default.createElement(FormProvider, {
1076
+ formRef,
1077
+ schema,
1078
+ autoSave,
1079
+ initialValues,
1080
+ onValuesChanged,
1081
+ onValidate,
1082
+ onValid,
1083
+ onSave
1084
+ }, /* @__PURE__ */ import_react10.default.createElement("div", {
1085
+ ref: formRef,
780
1086
  role: "none",
781
- className: (0, import_react_ui_theme3.mx)(onCancel && !readonly && "grid grid-cols-2 gap-2")
782
- }, onCancel && !readonly && /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.IconButton, {
783
- "data-testid": "cancel-button",
784
- icon: "ph--x--regular",
785
- label: t("button cancel"),
786
- onClick: onCancel
787
- }), onSubmit && /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.IconButton, {
788
- type: "submit",
789
- "data-testid": "save-button",
790
- disabled: !canSubmit,
791
- icon: "ph--check--regular",
792
- label: t("button save"),
793
- onClick: onSubmit
1087
+ className: (0, import_react_ui_theme5.mx)("p-2", classNames),
1088
+ "data-testid": testId
1089
+ }, /* @__PURE__ */ import_react10.default.createElement(FormFields, {
1090
+ schema,
1091
+ path,
1092
+ readonly,
1093
+ filter,
1094
+ sort,
1095
+ lookupComponent,
1096
+ Custom
1097
+ }), (onCancel || onSave) && !autoSave && /* @__PURE__ */ import_react10.default.createElement(FormActions, {
1098
+ onCancel,
1099
+ readonly
794
1100
  })));
795
1101
  };
796
1102
  var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx";
@@ -858,7 +1164,7 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
858
1164
  type
859
1165
  };
860
1166
  }
861
- return props2;
1167
+ return _props;
862
1168
  });
863
1169
  }, [
864
1170
  schemas,
@@ -914,7 +1220,8 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
914
1220
  options: referenceSchema ? (0, import_schema.getSchemaProperties)(referenceSchema.ast).sort(import_schema.sortProperties).map((p) => ({
915
1221
  value: p.name
916
1222
  })) : []
917
- })
1223
+ }),
1224
+ ["options"]: (props2) => /* @__PURE__ */ import_react2.default.createElement(SelectOptionInput, props2)
918
1225
  }), [
919
1226
  t,
920
1227
  schemas,
@@ -926,7 +1233,7 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
926
1233
  props
927
1234
  }, {
928
1235
  F: __dxlog_file3,
929
- L: 173,
1236
+ L: 174,
930
1237
  S: void 0,
931
1238
  C: (f, a) => f(...a)
932
1239
  });
@@ -950,22 +1257,22 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
950
1257
  });
951
1258
  };
952
1259
  var grid = "grid grid-cols-[32px_1fr_32px] min-bs-[2.5rem]";
953
- var ViewMetaSchema = import_echo_schema5.S.Struct({
954
- name: import_echo_schema5.S.String.annotations({
955
- [import_echo_schema5.AST.TitleAnnotationId]: "View"
1260
+ var ViewMetaSchema = import_echo_schema7.S.Struct({
1261
+ name: import_echo_schema7.S.String.annotations({
1262
+ [import_echo_schema7.AST.TitleAnnotationId]: "View"
956
1263
  }),
957
- typename: import_echo_schema5.Format.DXN.annotations({
958
- [import_echo_schema5.AST.TitleAnnotationId]: "Typename"
1264
+ typename: import_echo_schema7.Format.URL.annotations({
1265
+ [import_echo_schema7.AST.TitleAnnotationId]: "Typename"
959
1266
  })
960
- }).pipe(import_echo_schema5.S.mutable);
1267
+ }).pipe(import_echo_schema7.S.mutable);
961
1268
  var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading = false, onTypenameChanged, onDelete }) => {
962
- const { t } = (0, import_react_ui8.useTranslation)(translationKey);
963
- const projection = (0, import_react9.useMemo)(() => new import_schema4.ViewProjection(schema, view), [
1269
+ const { t } = (0, import_react_ui10.useTranslation)(translationKey);
1270
+ const projection = (0, import_react14.useMemo)(() => new import_schema5.ViewProjection(schema, view), [
964
1271
  schema,
965
1272
  view
966
1273
  ]);
967
- const [field, setField] = (0, import_react9.useState)();
968
- const viewValues = (0, import_react9.useMemo)(() => {
1274
+ const [field, setField] = (0, import_react14.useState)();
1275
+ const viewValues = (0, import_react14.useMemo)(() => {
969
1276
  return {
970
1277
  name: view.name,
971
1278
  // TODO(burdon): Need to warn user of possible consequences of editing.
@@ -975,7 +1282,7 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
975
1282
  }, [
976
1283
  view
977
1284
  ]);
978
- const handleViewUpdate = (0, import_react9.useCallback)(({ name, typename }) => {
1285
+ const handleViewUpdate = (0, import_react14.useCallback)(({ name, typename }) => {
979
1286
  requestAnimationFrame(() => {
980
1287
  if (view.name !== name) {
981
1288
  view.name = name;
@@ -989,72 +1296,76 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
989
1296
  schema,
990
1297
  onTypenameChanged
991
1298
  ]);
992
- const handleSelect = (0, import_react9.useCallback)((field2) => {
1299
+ const handleSelect = (0, import_react14.useCallback)((field2) => {
993
1300
  setField((f) => f === field2 ? void 0 : field2);
994
1301
  }, []);
995
- const handleAdd = (0, import_react9.useCallback)(() => {
1302
+ const handleAdd = (0, import_react14.useCallback)(() => {
996
1303
  const field2 = projection.createFieldProjection();
997
1304
  setField(field2);
998
1305
  }, [
999
1306
  view
1000
1307
  ]);
1001
- const handleMove = (0, import_react9.useCallback)((fromIndex, toIndex) => {
1002
- (0, import_util4.arrayMove)(view.fields, fromIndex, toIndex);
1308
+ const handleMove = (0, import_react14.useCallback)((fromIndex, toIndex) => {
1309
+ const fields = [
1310
+ ...view.fields
1311
+ ];
1312
+ const [moved] = fields.splice(fromIndex, 1);
1313
+ fields.splice(toIndex, 0, moved);
1314
+ view.fields = fields;
1003
1315
  }, [
1004
1316
  view.fields
1005
1317
  ]);
1006
- const handleClose = (0, import_react9.useCallback)(() => setField(void 0), []);
1007
- return /* @__PURE__ */ import_react9.default.createElement("div", {
1318
+ const handleClose = (0, import_react14.useCallback)(() => setField(void 0), []);
1319
+ return /* @__PURE__ */ import_react14.default.createElement("div", {
1008
1320
  role: "none",
1009
- className: (0, import_react_ui_theme4.mx)("flex flex-col w-full divide-y divide-separator", classNames)
1010
- }, /* @__PURE__ */ import_react9.default.createElement(Form, {
1011
- autoFocus: true,
1321
+ className: (0, import_react_ui_theme9.mx)("flex flex-col w-full divide-y divide-separator", classNames)
1322
+ }, /* @__PURE__ */ import_react14.default.createElement(Form, {
1012
1323
  autoSave: true,
1013
1324
  schema: ViewMetaSchema,
1014
1325
  values: viewValues,
1015
1326
  onSave: handleViewUpdate
1016
- }), /* @__PURE__ */ import_react9.default.createElement("div", null, /* @__PURE__ */ import_react9.default.createElement("div", {
1327
+ }), /* @__PURE__ */ import_react14.default.createElement("div", null, /* @__PURE__ */ import_react14.default.createElement("div", {
1017
1328
  role: "none",
1018
1329
  className: "p-2"
1019
- }, /* @__PURE__ */ import_react9.default.createElement("label", {
1020
- className: (0, import_react_ui_theme4.mx)(import_react_ui_theme4.inputTextLabel)
1021
- }, t("fields label"))), /* @__PURE__ */ import_react9.default.createElement(import_react_ui_list.List.Root, {
1330
+ }, /* @__PURE__ */ import_react14.default.createElement("label", {
1331
+ className: (0, import_react_ui_theme9.mx)(import_react_ui_theme9.inputTextLabel)
1332
+ }, t("fields label"))), /* @__PURE__ */ import_react14.default.createElement(import_react_ui_list2.List.Root, {
1022
1333
  items: view.fields,
1023
- isItem: import_echo_schema5.S.is(import_schema4.FieldSchema),
1334
+ isItem: import_echo_schema7.S.is(import_schema5.FieldSchema),
1024
1335
  getId: (field2) => field2.id,
1025
1336
  onMove: handleMove
1026
- }, ({ items: fields }) => /* @__PURE__ */ import_react9.default.createElement(import_react9.default.Fragment, null, showHeading && /* @__PURE__ */ import_react9.default.createElement("div", {
1337
+ }, ({ items: fields }) => /* @__PURE__ */ import_react14.default.createElement(import_react14.default.Fragment, null, showHeading && /* @__PURE__ */ import_react14.default.createElement("div", {
1027
1338
  role: "heading",
1028
1339
  className: grid
1029
- }, /* @__PURE__ */ import_react9.default.createElement("div", null), /* @__PURE__ */ import_react9.default.createElement("div", {
1340
+ }, /* @__PURE__ */ import_react14.default.createElement("div", null), /* @__PURE__ */ import_react14.default.createElement("div", {
1030
1341
  className: "flex items-center text-sm"
1031
- }, t("field path label"))), /* @__PURE__ */ import_react9.default.createElement("div", {
1342
+ }, t("field path label"))), /* @__PURE__ */ import_react14.default.createElement("div", {
1032
1343
  role: "list",
1033
1344
  className: "flex flex-col w-full"
1034
- }, fields?.map((field2) => /* @__PURE__ */ import_react9.default.createElement(import_react_ui_list.List.Item, {
1345
+ }, fields?.map((field2) => /* @__PURE__ */ import_react14.default.createElement(import_react_ui_list2.List.Item, {
1035
1346
  key: field2.id,
1036
1347
  item: field2,
1037
- classNames: (0, import_react_ui_theme4.mx)(grid, import_react_ui_theme4.ghostHover, "cursor-pointer")
1038
- }, /* @__PURE__ */ import_react9.default.createElement(import_react_ui_list.List.ItemDragHandle, null), /* @__PURE__ */ import_react9.default.createElement(import_react_ui_list.List.ItemTitle, {
1348
+ classNames: (0, import_react_ui_theme9.mx)(grid, import_react_ui_theme9.ghostHover, "cursor-pointer")
1349
+ }, /* @__PURE__ */ import_react14.default.createElement(import_react_ui_list2.List.ItemDragHandle, null), /* @__PURE__ */ import_react14.default.createElement(import_react_ui_list2.List.ItemTitle, {
1039
1350
  onClick: () => handleSelect(field2)
1040
- }, field2.path), /* @__PURE__ */ import_react9.default.createElement(import_react_ui_list.List.ItemDeleteButton, {
1351
+ }, field2.path), /* @__PURE__ */ import_react14.default.createElement(import_react_ui_list2.List.ItemDeleteButton, {
1041
1352
  disabled: view.fields.length <= 1,
1042
1353
  onClick: () => onDelete(field2.id)
1043
- }))))))), field && /* @__PURE__ */ import_react9.default.createElement(FieldEditor, {
1354
+ }))))))), field && /* @__PURE__ */ import_react14.default.createElement(FieldEditor, {
1044
1355
  key: field.id,
1045
1356
  view,
1046
1357
  projection,
1047
1358
  field,
1048
1359
  registry,
1049
1360
  onSave: handleClose
1050
- }), !readonly && !field && /* @__PURE__ */ import_react9.default.createElement("div", {
1361
+ }), !readonly && !field && /* @__PURE__ */ import_react14.default.createElement("div", {
1051
1362
  className: "flex p-2 justify-center"
1052
- }, /* @__PURE__ */ import_react9.default.createElement(import_react_ui8.IconButton, {
1363
+ }, /* @__PURE__ */ import_react14.default.createElement(import_react_ui10.IconButton, {
1053
1364
  icon: "ph--plus--regular",
1054
1365
  label: t("button add property"),
1055
1366
  onClick: handleAdd,
1056
1367
  // TODO(burdon): Show field limit in ux (not tooltip).
1057
- disabled: view.fields.length >= import_schema4.VIEW_FIELD_LIMIT
1368
+ disabled: view.fields.length >= import_schema5.VIEW_FIELD_LIMIT
1058
1369
  })));
1059
1370
  };
1060
1371
  var parseValue = ({ type, format, value }) => {
@@ -1063,7 +1374,7 @@ var parseValue = ({ type, format, value }) => {
1063
1374
  }
1064
1375
  const parseScalar = (type2) => {
1065
1376
  switch (type2) {
1066
- case import_echo_schema6.TypeEnum.Boolean: {
1377
+ case import_echo_schema8.TypeEnum.Boolean: {
1067
1378
  if (typeof value === "string") {
1068
1379
  const lowercaseValue = value.toLowerCase();
1069
1380
  if (lowercaseValue === "0" || lowercaseValue === "false") {
@@ -1074,13 +1385,13 @@ var parseValue = ({ type, format, value }) => {
1074
1385
  }
1075
1386
  return Boolean(value);
1076
1387
  }
1077
- case import_echo_schema6.TypeEnum.Number: {
1388
+ case import_echo_schema8.TypeEnum.Number: {
1078
1389
  const cleaned = typeof value === "string" ? value.replace(/[^0-9.-]+/g, "") : value;
1079
1390
  const num = Number(cleaned);
1080
1391
  return Number.isNaN(num) ? null : num;
1081
1392
  }
1082
- case import_echo_schema6.TypeEnum.String:
1083
- case import_echo_schema6.TypeEnum.Ref:
1393
+ case import_echo_schema8.TypeEnum.String:
1394
+ case import_echo_schema8.TypeEnum.Ref:
1084
1395
  return String(value);
1085
1396
  default: {
1086
1397
  return value;
@@ -1091,22 +1402,22 @@ var parseValue = ({ type, format, value }) => {
1091
1402
  return parseScalar(type);
1092
1403
  }
1093
1404
  switch (format) {
1094
- case import_echo_schema6.FormatEnum.Boolean:
1095
- return parseScalar(import_echo_schema6.TypeEnum.Boolean);
1096
- case import_echo_schema6.FormatEnum.Number:
1097
- case import_echo_schema6.FormatEnum.Percent:
1098
- case import_echo_schema6.FormatEnum.Currency:
1099
- return parseScalar(import_echo_schema6.TypeEnum.Number);
1100
- case import_echo_schema6.FormatEnum.String:
1101
- case import_echo_schema6.FormatEnum.Markdown: {
1102
- return parseScalar(import_echo_schema6.TypeEnum.String);
1405
+ case import_echo_schema8.FormatEnum.Boolean:
1406
+ return parseScalar(import_echo_schema8.TypeEnum.Boolean);
1407
+ case import_echo_schema8.FormatEnum.Number:
1408
+ case import_echo_schema8.FormatEnum.Percent:
1409
+ case import_echo_schema8.FormatEnum.Currency:
1410
+ return parseScalar(import_echo_schema8.TypeEnum.Number);
1411
+ case import_echo_schema8.FormatEnum.String:
1412
+ case import_echo_schema8.FormatEnum.Markdown: {
1413
+ return parseScalar(import_echo_schema8.TypeEnum.String);
1103
1414
  }
1104
- case import_echo_schema6.FormatEnum.Ref:
1105
- throw new Error(`unexpected format: ${import_echo_schema6.FormatEnum.Ref}`);
1106
- case import_echo_schema6.FormatEnum.DateTime:
1107
- case import_echo_schema6.FormatEnum.Date:
1108
- case import_echo_schema6.FormatEnum.Time:
1109
- case import_echo_schema6.FormatEnum.Timestamp: {
1415
+ case import_echo_schema8.FormatEnum.Ref:
1416
+ throw new Error(`unexpected format: ${import_echo_schema8.FormatEnum.Ref}`);
1417
+ case import_echo_schema8.FormatEnum.DateTime:
1418
+ case import_echo_schema8.FormatEnum.Date:
1419
+ case import_echo_schema8.FormatEnum.Time:
1420
+ case import_echo_schema8.FormatEnum.Timestamp: {
1110
1421
  const date = new Date(value);
1111
1422
  return isNaN(date.getTime()) ? null : date;
1112
1423
  }
@@ -1118,19 +1429,19 @@ var parseValue = ({ type, format, value }) => {
1118
1429
  var cellClassesForFieldType = ({ type, format }) => {
1119
1430
  if (!format) {
1120
1431
  switch (type) {
1121
- case import_echo_schema6.TypeEnum.Number:
1432
+ case import_echo_schema8.TypeEnum.Number:
1122
1433
  return [
1123
1434
  "text-right",
1124
1435
  "font-mono"
1125
1436
  ];
1126
- case import_echo_schema6.TypeEnum.Boolean:
1437
+ case import_echo_schema8.TypeEnum.Boolean:
1127
1438
  return [
1128
1439
  "text-right",
1129
1440
  "font-mono"
1130
1441
  ];
1131
- case import_echo_schema6.TypeEnum.String:
1442
+ case import_echo_schema8.TypeEnum.String:
1132
1443
  return void 0;
1133
- case import_echo_schema6.TypeEnum.Ref:
1444
+ case import_echo_schema8.TypeEnum.Ref:
1134
1445
  return void 0;
1135
1446
  default: {
1136
1447
  return void 0;
@@ -1138,20 +1449,20 @@ var cellClassesForFieldType = ({ type, format }) => {
1138
1449
  }
1139
1450
  }
1140
1451
  switch (format) {
1141
- case import_echo_schema6.FormatEnum.Markdown:
1452
+ case import_echo_schema8.FormatEnum.Markdown:
1142
1453
  return void 0;
1143
- case import_echo_schema6.FormatEnum.Timestamp:
1144
- case import_echo_schema6.FormatEnum.DateTime:
1145
- case import_echo_schema6.FormatEnum.Date:
1146
- case import_echo_schema6.FormatEnum.Time:
1454
+ case import_echo_schema8.FormatEnum.Timestamp:
1455
+ case import_echo_schema8.FormatEnum.DateTime:
1456
+ case import_echo_schema8.FormatEnum.Date:
1457
+ case import_echo_schema8.FormatEnum.Time:
1147
1458
  return [
1148
1459
  "font-mono"
1149
1460
  ];
1150
- case import_echo_schema6.FormatEnum.Currency:
1461
+ case import_echo_schema8.FormatEnum.Currency:
1151
1462
  return [
1152
1463
  "text-right"
1153
1464
  ];
1154
- case import_echo_schema6.FormatEnum.JSON:
1465
+ case import_echo_schema8.FormatEnum.JSON:
1155
1466
  return [
1156
1467
  "font-mono"
1157
1468
  ];
@@ -1169,12 +1480,12 @@ var pathNotUniqueError = (path) => ({
1169
1480
  var formatForDisplay = ({ type, format, value, locale = void 0 }) => {
1170
1481
  const formatScalar = (type2) => {
1171
1482
  switch (type2) {
1172
- case import_echo_schema7.TypeEnum.Boolean:
1483
+ case import_echo_schema9.TypeEnum.Boolean:
1173
1484
  return value.toLocaleString().toUpperCase();
1174
- case import_echo_schema7.TypeEnum.Number:
1485
+ case import_echo_schema9.TypeEnum.Number:
1175
1486
  return value.toLocaleString(locale);
1176
- case import_echo_schema7.TypeEnum.String:
1177
- case import_echo_schema7.TypeEnum.Ref:
1487
+ case import_echo_schema9.TypeEnum.String:
1488
+ case import_echo_schema9.TypeEnum.Ref:
1178
1489
  return String(value);
1179
1490
  default: {
1180
1491
  return String(value);
@@ -1185,20 +1496,20 @@ var formatForDisplay = ({ type, format, value, locale = void 0 }) => {
1185
1496
  return formatScalar(type);
1186
1497
  }
1187
1498
  switch (format) {
1188
- case import_echo_schema7.FormatEnum.Boolean: {
1189
- return formatScalar(import_echo_schema7.TypeEnum.Boolean);
1499
+ case import_echo_schema9.FormatEnum.Boolean: {
1500
+ return formatScalar(import_echo_schema9.TypeEnum.Boolean);
1190
1501
  }
1191
- case import_echo_schema7.FormatEnum.Number: {
1192
- return formatScalar(import_echo_schema7.TypeEnum.Number);
1502
+ case import_echo_schema9.FormatEnum.Number: {
1503
+ return formatScalar(import_echo_schema9.TypeEnum.Number);
1193
1504
  }
1194
- case import_echo_schema7.FormatEnum.String:
1195
- case import_echo_schema7.FormatEnum.Ref: {
1196
- return formatScalar(import_echo_schema7.TypeEnum.String);
1505
+ case import_echo_schema9.FormatEnum.String:
1506
+ case import_echo_schema9.FormatEnum.Ref: {
1507
+ return formatScalar(import_echo_schema9.TypeEnum.String);
1197
1508
  }
1198
- case import_echo_schema7.FormatEnum.Percent: {
1509
+ case import_echo_schema9.FormatEnum.Percent: {
1199
1510
  return `${value * 100}%`;
1200
1511
  }
1201
- case import_echo_schema7.FormatEnum.Currency: {
1512
+ case import_echo_schema9.FormatEnum.Currency: {
1202
1513
  return value.toLocaleString(locale, {
1203
1514
  style: "currency",
1204
1515
  currency: "USD",
@@ -1206,13 +1517,13 @@ var formatForDisplay = ({ type, format, value, locale = void 0 }) => {
1206
1517
  maximumFractionDigits: 2
1207
1518
  });
1208
1519
  }
1209
- case import_echo_schema7.FormatEnum.DateTime:
1210
- case import_echo_schema7.FormatEnum.Date:
1211
- case import_echo_schema7.FormatEnum.Time: {
1520
+ case import_echo_schema9.FormatEnum.DateTime:
1521
+ case import_echo_schema9.FormatEnum.Date:
1522
+ case import_echo_schema9.FormatEnum.Time: {
1212
1523
  const date = new Date(value);
1213
- if (format === import_echo_schema7.FormatEnum.DateTime) {
1524
+ if (format === import_echo_schema9.FormatEnum.DateTime) {
1214
1525
  return date.toLocaleString(locale);
1215
- } else if (format === import_echo_schema7.FormatEnum.Date) {
1526
+ } else if (format === import_echo_schema9.FormatEnum.Date) {
1216
1527
  return date.toLocaleDateString(locale);
1217
1528
  } else {
1218
1529
  return date.toLocaleTimeString(locale);
@@ -1229,10 +1540,10 @@ var formatForDisplay = ({ type, format, value, locale = void 0 }) => {
1229
1540
  var formatForEditing = ({ type, format, value, locale = void 0 }) => {
1230
1541
  const formatScalar = (type2) => {
1231
1542
  switch (type2) {
1232
- case import_echo_schema7.TypeEnum.Boolean:
1233
- case import_echo_schema7.TypeEnum.Number:
1234
- case import_echo_schema7.TypeEnum.String:
1235
- case import_echo_schema7.TypeEnum.Ref:
1543
+ case import_echo_schema9.TypeEnum.Boolean:
1544
+ case import_echo_schema9.TypeEnum.Number:
1545
+ case import_echo_schema9.TypeEnum.String:
1546
+ case import_echo_schema9.TypeEnum.Ref:
1236
1547
  return String(value);
1237
1548
  default:
1238
1549
  return String(value);
@@ -1242,27 +1553,27 @@ var formatForEditing = ({ type, format, value, locale = void 0 }) => {
1242
1553
  return formatScalar(type);
1243
1554
  }
1244
1555
  switch (format) {
1245
- case import_echo_schema7.FormatEnum.Boolean:
1246
- case import_echo_schema7.FormatEnum.Number:
1247
- case import_echo_schema7.FormatEnum.String:
1248
- case import_echo_schema7.FormatEnum.Ref: {
1556
+ case import_echo_schema9.FormatEnum.Boolean:
1557
+ case import_echo_schema9.FormatEnum.Number:
1558
+ case import_echo_schema9.FormatEnum.String:
1559
+ case import_echo_schema9.FormatEnum.Ref: {
1249
1560
  return formatScalar(type);
1250
1561
  }
1251
- case import_echo_schema7.FormatEnum.Percent: {
1562
+ case import_echo_schema9.FormatEnum.Percent: {
1252
1563
  return String(value * 100);
1253
1564
  }
1254
- case import_echo_schema7.FormatEnum.Currency: {
1565
+ case import_echo_schema9.FormatEnum.Currency: {
1255
1566
  return String(value);
1256
1567
  }
1257
- case import_echo_schema7.FormatEnum.DateTime: {
1568
+ case import_echo_schema9.FormatEnum.DateTime: {
1258
1569
  const date = new Date(value);
1259
1570
  return date.toISOString();
1260
1571
  }
1261
- case import_echo_schema7.FormatEnum.Date: {
1572
+ case import_echo_schema9.FormatEnum.Date: {
1262
1573
  const date = new Date(value);
1263
1574
  return date.toISOString().split("T")[0];
1264
1575
  }
1265
- case import_echo_schema7.FormatEnum.Time: {
1576
+ case import_echo_schema9.FormatEnum.Time: {
1266
1577
  const date = new Date(value);
1267
1578
  return date.toISOString().split("T")[1].split(".")[0];
1268
1579
  }
@@ -1274,14 +1585,16 @@ var formatForEditing = ({ type, format, value, locale = void 0 }) => {
1274
1585
  // Annotate the CommonJS export names for ESM import in node:
1275
1586
  0 && (module.exports = {
1276
1587
  BooleanInput,
1588
+ DeprecatedFormContainer,
1277
1589
  DeprecatedFormInput,
1278
1590
  FieldEditor,
1279
1591
  Form,
1280
- FormActions,
1281
1592
  GeoPointInput,
1282
1593
  InputHeader,
1594
+ MarkdownInput,
1283
1595
  NumberInput,
1284
1596
  SelectInput,
1597
+ SelectOptionInput,
1285
1598
  TextInput,
1286
1599
  TupleInput,
1287
1600
  ViewEditor,
@@ -1292,6 +1605,7 @@ var formatForEditing = ({ type, format, value, locale = void 0 }) => {
1292
1605
  parseValue,
1293
1606
  pathNotUniqueError,
1294
1607
  translations,
1295
- useForm
1608
+ useForm,
1609
+ useFormValues
1296
1610
  });
1297
1611
  //# sourceMappingURL=index.cjs.map