@overmap-ai/forms 1.0.5 → 1.0.6

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.
package/dist/forms.js CHANGED
@@ -1472,16 +1472,23 @@ const validateForm = async (schema, form) => {
1472
1472
  };
1473
1473
  const uncontrolledValues = [null, void 0];
1474
1474
  const initialFormValues = (fields, values) => {
1475
- return fields.reduce((acc, field) => {
1476
- if (field instanceof FieldSection) {
1477
- return { ...acc, ...initialFormValues(field.fields, values) };
1478
- }
1479
- const copy = cloneDeep(acc);
1480
- if (uncontrolledValues.includes(get(copy, field.getId()))) {
1481
- set(copy, field.getId(), "");
1482
- }
1483
- return copy;
1484
- }, values);
1475
+ return fields.reduce(
1476
+ (acc, field) => {
1477
+ if (field instanceof FieldSection) {
1478
+ return { ...acc, ...initialFormValues(field.fields, values) };
1479
+ }
1480
+ if (uncontrolledValues.includes(get(acc, field.getId()))) {
1481
+ set(acc, field.getId(), "");
1482
+ }
1483
+ return acc;
1484
+ },
1485
+ // TODO: Had to do this because of this error:
1486
+ // > Uncaught TypeError: can't define property "description":
1487
+ // > Object is not extensible"
1488
+ // This means that we can't mutate `acc` because it's frozen for some
1489
+ // unknown reason.
1490
+ cloneDeep(values)
1491
+ );
1485
1492
  };
1486
1493
  const defaultHandleSubmit = () => {
1487
1494
  throw new Error("onSubmit must be provided if form is not readonly.");