@overmap-ai/core 1.0.35-fix-token-refresh-loop.2 → 1.0.35-fix-token-refresh-loop.4
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.
|
@@ -10225,9 +10225,9 @@ var __publicField = (obj, key, value) => {
|
|
|
10225
10225
|
PatchField.displayName = "PatchField";
|
|
10226
10226
|
const PatchFormProvider = React.memo(
|
|
10227
10227
|
React.forwardRef((props, ref) => {
|
|
10228
|
-
const { children, schema, values, onPatch, onError, requiresDiff = true, ...rest } = props;
|
|
10228
|
+
const { children, schema, values, onPatch, onError, requiresDiff = true, onDirtyChange, ...rest } = props;
|
|
10229
10229
|
const initialValues2 = React.useMemo(() => initialFormValues(schema.fields, values), [schema.fields, values]);
|
|
10230
|
-
const
|
|
10230
|
+
const getDiff = React.useCallback(
|
|
10231
10231
|
(values2) => {
|
|
10232
10232
|
const diff = {};
|
|
10233
10233
|
for (const key in values2) {
|
|
@@ -10236,21 +10236,33 @@ var __publicField = (obj, key, value) => {
|
|
|
10236
10236
|
diff[key] = value;
|
|
10237
10237
|
}
|
|
10238
10238
|
}
|
|
10239
|
+
return diff;
|
|
10240
|
+
},
|
|
10241
|
+
[initialValues2]
|
|
10242
|
+
);
|
|
10243
|
+
const handlePatch = React.useCallback(
|
|
10244
|
+
(values2) => {
|
|
10245
|
+
const diff = getDiff(values2);
|
|
10239
10246
|
if (requiresDiff && !hasKeys(diff))
|
|
10240
10247
|
return;
|
|
10241
10248
|
onPatch(diff);
|
|
10242
10249
|
},
|
|
10243
|
-
[
|
|
10250
|
+
[getDiff, onPatch, requiresDiff]
|
|
10244
10251
|
);
|
|
10245
10252
|
const validate = React.useCallback(
|
|
10246
10253
|
(form) => {
|
|
10254
|
+
console.debug("VALIDATING FORM:", form);
|
|
10247
10255
|
const error2 = validateForm(schema, form);
|
|
10248
10256
|
if (error2) {
|
|
10249
10257
|
onError(error2);
|
|
10250
10258
|
}
|
|
10259
|
+
if (onDirtyChange) {
|
|
10260
|
+
const diff = getDiff(form);
|
|
10261
|
+
onDirtyChange(hasKeys(diff));
|
|
10262
|
+
}
|
|
10251
10263
|
return error2;
|
|
10252
10264
|
},
|
|
10253
|
-
[schema, onError]
|
|
10265
|
+
[schema, onDirtyChange, onError, getDiff]
|
|
10254
10266
|
);
|
|
10255
10267
|
const formik$1 = formik.useFormik({
|
|
10256
10268
|
initialValues: initialValues2,
|
|
@@ -10260,13 +10272,21 @@ var __publicField = (obj, key, value) => {
|
|
|
10260
10272
|
validateOnBlur: false,
|
|
10261
10273
|
validateOnChange: false
|
|
10262
10274
|
});
|
|
10275
|
+
const handleBlur = React.useCallback(() => {
|
|
10276
|
+
if (onDirtyChange) {
|
|
10277
|
+
const diff = getDiff(formik$1.values);
|
|
10278
|
+
if (hasKeys(diff)) {
|
|
10279
|
+
onDirtyChange(true);
|
|
10280
|
+
}
|
|
10281
|
+
}
|
|
10282
|
+
}, [formik$1.values, getDiff, onDirtyChange]);
|
|
10263
10283
|
const { errors, resetForm } = formik$1;
|
|
10264
10284
|
React.useEffect(() => {
|
|
10265
10285
|
if (hasKeys(errors)) {
|
|
10266
10286
|
resetForm({ values: initialValues2, errors: {} });
|
|
10267
10287
|
}
|
|
10268
10288
|
}, [errors, initialValues2, resetForm]);
|
|
10269
|
-
return /* @__PURE__ */ jsxRuntime.jsx(formik.FormikProvider, { value: formik$1, children: /* @__PURE__ */ jsxRuntime.jsx("form", { ...rest, ref, onSubmit: formik$1.handleSubmit, children }) });
|
|
10289
|
+
return /* @__PURE__ */ jsxRuntime.jsx(formik.FormikProvider, { value: formik$1, children: /* @__PURE__ */ jsxRuntime.jsx("form", { ...rest, ref, onSubmit: formik$1.handleSubmit, onBlur: handleBlur, children }) });
|
|
10270
10290
|
})
|
|
10271
10291
|
);
|
|
10272
10292
|
const typeBadge$1 = "_typeBadge_an5ff_1";
|