@overmap-ai/forms 1.0.32-react-flow-david-fixes.20 → 1.0.32-react-flow-david-fixes.22
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 +19 -17
- package/dist/forms.umd.cjs +19 -17
- package/package.json +1 -1
package/dist/forms.js
CHANGED
|
@@ -36241,19 +36241,10 @@ async function awaitPromisesFromFieldValues(values) {
|
|
|
36241
36241
|
}
|
|
36242
36242
|
return valuesWithoutFiles;
|
|
36243
36243
|
}
|
|
36244
|
-
const EXTRA_KEY = "__EXTRA_KEY__";
|
|
36245
|
-
const addExtraKey = (values) => {
|
|
36246
|
-
return { ...values, [EXTRA_KEY]: v4() };
|
|
36247
|
-
};
|
|
36248
|
-
const stripExtraKey = (values) => {
|
|
36249
|
-
const valuesCopy = { ...values };
|
|
36250
|
-
delete valuesCopy[EXTRA_KEY];
|
|
36251
|
-
return valuesCopy;
|
|
36252
|
-
};
|
|
36253
36244
|
const FormRenderer = memo(
|
|
36254
36245
|
forwardRef((props, ref) => {
|
|
36255
36246
|
const {
|
|
36256
|
-
schema,
|
|
36247
|
+
schema: schemaFromProps,
|
|
36257
36248
|
values = {},
|
|
36258
36249
|
onValuesChange,
|
|
36259
36250
|
onSubmit,
|
|
@@ -36263,18 +36254,22 @@ const FormRenderer = memo(
|
|
|
36263
36254
|
onDirty,
|
|
36264
36255
|
onDirtyChange,
|
|
36265
36256
|
// if the title isn't provided, hide it by default
|
|
36266
|
-
hideTitle = !
|
|
36257
|
+
hideTitle = !schemaFromProps.title,
|
|
36267
36258
|
hideDescription,
|
|
36268
36259
|
className,
|
|
36269
36260
|
buttonProps,
|
|
36270
36261
|
enableReinitialize = false,
|
|
36271
36262
|
excludeUnchangedFields = false
|
|
36272
36263
|
} = props;
|
|
36264
|
+
const [schema, setSchema] = useState(schemaFromProps);
|
|
36265
|
+
useLayoutEffect(() => {
|
|
36266
|
+
setSchema(schemaFromProps);
|
|
36267
|
+
}, [schemaFromProps]);
|
|
36273
36268
|
const { readonly } = schema.meta;
|
|
36274
36269
|
const formId2 = useId$1();
|
|
36275
36270
|
const initialValues = useMemo(() => {
|
|
36276
|
-
return
|
|
36277
|
-
}, [
|
|
36271
|
+
return initializeFieldValues(flattenFields(schemaFromProps.fields), values);
|
|
36272
|
+
}, [schemaFromProps.fields, values]);
|
|
36278
36273
|
const handleSubmit = useCallback(
|
|
36279
36274
|
(values2) => {
|
|
36280
36275
|
onSubmit == null ? void 0 : onSubmit(
|
|
@@ -36285,19 +36280,26 @@ const FormRenderer = memo(
|
|
|
36285
36280
|
);
|
|
36286
36281
|
const formik = useFormik({
|
|
36287
36282
|
initialValues,
|
|
36288
|
-
onSubmit:
|
|
36289
|
-
validate: (values2) => validateFields(schema.fields,
|
|
36283
|
+
onSubmit: handleSubmit,
|
|
36284
|
+
validate: (values2) => validateFields(schema.fields, values2),
|
|
36290
36285
|
// only validate the entire form on submit
|
|
36291
36286
|
validateOnBlur: false,
|
|
36292
36287
|
validateOnChange: false,
|
|
36293
|
-
enableReinitialize
|
|
36288
|
+
enableReinitialize: false
|
|
36294
36289
|
});
|
|
36290
|
+
useLayoutEffect(() => {
|
|
36291
|
+
if (enableReinitialize) {
|
|
36292
|
+
formik.resetForm({
|
|
36293
|
+
values: initialValues
|
|
36294
|
+
});
|
|
36295
|
+
}
|
|
36296
|
+
}, [enableReinitialize, initialValues]);
|
|
36295
36297
|
const { dirty } = formik;
|
|
36296
36298
|
const handleValuesChange = useCallback(
|
|
36297
36299
|
(identifier, value) => {
|
|
36298
36300
|
const field = getFieldsMapping(schema.fields)[identifier];
|
|
36299
36301
|
if (field.areValuesEqual(initialValues[identifier], value)) return;
|
|
36300
|
-
onValuesChange == null ? void 0 : onValuesChange({ ...
|
|
36302
|
+
onValuesChange == null ? void 0 : onValuesChange({ ...formik.values, [identifier]: value }, { [identifier]: value });
|
|
36301
36303
|
},
|
|
36302
36304
|
[formik.values, initialValues, onValuesChange, schema.fields]
|
|
36303
36305
|
);
|
package/dist/forms.umd.cjs
CHANGED
|
@@ -36243,19 +36243,10 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
36243
36243
|
}
|
|
36244
36244
|
return valuesWithoutFiles;
|
|
36245
36245
|
}
|
|
36246
|
-
const EXTRA_KEY = "__EXTRA_KEY__";
|
|
36247
|
-
const addExtraKey = (values) => {
|
|
36248
|
-
return { ...values, [EXTRA_KEY]: uuid.v4() };
|
|
36249
|
-
};
|
|
36250
|
-
const stripExtraKey = (values) => {
|
|
36251
|
-
const valuesCopy = { ...values };
|
|
36252
|
-
delete valuesCopy[EXTRA_KEY];
|
|
36253
|
-
return valuesCopy;
|
|
36254
|
-
};
|
|
36255
36246
|
const FormRenderer = React.memo(
|
|
36256
36247
|
React.forwardRef((props, ref) => {
|
|
36257
36248
|
const {
|
|
36258
|
-
schema,
|
|
36249
|
+
schema: schemaFromProps,
|
|
36259
36250
|
values = {},
|
|
36260
36251
|
onValuesChange,
|
|
36261
36252
|
onSubmit,
|
|
@@ -36265,18 +36256,22 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
36265
36256
|
onDirty,
|
|
36266
36257
|
onDirtyChange,
|
|
36267
36258
|
// if the title isn't provided, hide it by default
|
|
36268
|
-
hideTitle = !
|
|
36259
|
+
hideTitle = !schemaFromProps.title,
|
|
36269
36260
|
hideDescription,
|
|
36270
36261
|
className,
|
|
36271
36262
|
buttonProps,
|
|
36272
36263
|
enableReinitialize = false,
|
|
36273
36264
|
excludeUnchangedFields = false
|
|
36274
36265
|
} = props;
|
|
36266
|
+
const [schema, setSchema] = React.useState(schemaFromProps);
|
|
36267
|
+
React.useLayoutEffect(() => {
|
|
36268
|
+
setSchema(schemaFromProps);
|
|
36269
|
+
}, [schemaFromProps]);
|
|
36275
36270
|
const { readonly } = schema.meta;
|
|
36276
36271
|
const formId2 = React.useId();
|
|
36277
36272
|
const initialValues = React.useMemo(() => {
|
|
36278
|
-
return
|
|
36279
|
-
}, [
|
|
36273
|
+
return initializeFieldValues(flattenFields(schemaFromProps.fields), values);
|
|
36274
|
+
}, [schemaFromProps.fields, values]);
|
|
36280
36275
|
const handleSubmit = React.useCallback(
|
|
36281
36276
|
(values2) => {
|
|
36282
36277
|
onSubmit == null ? void 0 : onSubmit(
|
|
@@ -36287,19 +36282,26 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
36287
36282
|
);
|
|
36288
36283
|
const formik$1 = formik.useFormik({
|
|
36289
36284
|
initialValues,
|
|
36290
|
-
onSubmit:
|
|
36291
|
-
validate: (values2) => validateFields(schema.fields,
|
|
36285
|
+
onSubmit: handleSubmit,
|
|
36286
|
+
validate: (values2) => validateFields(schema.fields, values2),
|
|
36292
36287
|
// only validate the entire form on submit
|
|
36293
36288
|
validateOnBlur: false,
|
|
36294
36289
|
validateOnChange: false,
|
|
36295
|
-
enableReinitialize
|
|
36290
|
+
enableReinitialize: false
|
|
36296
36291
|
});
|
|
36292
|
+
React.useLayoutEffect(() => {
|
|
36293
|
+
if (enableReinitialize) {
|
|
36294
|
+
formik$1.resetForm({
|
|
36295
|
+
values: initialValues
|
|
36296
|
+
});
|
|
36297
|
+
}
|
|
36298
|
+
}, [enableReinitialize, initialValues]);
|
|
36297
36299
|
const { dirty } = formik$1;
|
|
36298
36300
|
const handleValuesChange = React.useCallback(
|
|
36299
36301
|
(identifier, value) => {
|
|
36300
36302
|
const field = getFieldsMapping(schema.fields)[identifier];
|
|
36301
36303
|
if (field.areValuesEqual(initialValues[identifier], value)) return;
|
|
36302
|
-
onValuesChange == null ? void 0 : onValuesChange({ ...
|
|
36304
|
+
onValuesChange == null ? void 0 : onValuesChange({ ...formik$1.values, [identifier]: value }, { [identifier]: value });
|
|
36303
36305
|
},
|
|
36304
36306
|
[formik$1.values, initialValues, onValuesChange, schema.fields]
|
|
36305
36307
|
);
|