@overmap-ai/forms 1.0.8 → 1.0.9-handle-patchform-errors.0
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 +9 -3
- package/dist/forms.js.map +1 -1
- package/dist/forms.umd.cjs +8 -2
- package/dist/forms.umd.cjs.map +1 -1
- package/package.json +1 -1
package/dist/forms.js
CHANGED
|
@@ -5,7 +5,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
7
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
8
|
-
import { Flex, Text, useSeverityColor, Checkbox, CheckCircledIcon, TextField as TextField$1, FontFamilyIcon, CalendarIcon, InputIcon, TextArea, RowsIcon, Select, Box, IconButton, PlusIcon, Badge, Cross1Icon, ListBulletIcon, DropdownMenuIcon, MultiSelect, CheckboxIcon, Card, Heading, Button, UploadIcon, ButtonList, divButtonProps, StarFilledIcon, StarIcon, QuestionMarkCircledIcon, PersonIcon, Tooltip, Avatar, Separator, useDiscardAlertDialog, Dialog, Pencil1Icon, TrashIcon, CopyIcon, DragHandleDots2Icon, DropdownMenu, DotsVerticalIcon, useAlertDialog, Em, Strong,
|
|
8
|
+
import { Flex, Text, useSeverityColor, Checkbox, CheckCircledIcon, TextField as TextField$1, FontFamilyIcon, CalendarIcon, InputIcon, TextArea, RowsIcon, Select, Box, IconButton, PlusIcon, Badge, Cross1Icon, ListBulletIcon, DropdownMenuIcon, MultiSelect, CheckboxIcon, Card, Heading, Button, UploadIcon, ButtonList, divButtonProps, StarFilledIcon, StarIcon, QuestionMarkCircledIcon, PersonIcon, Tooltip, Avatar, useToast, Separator, useDiscardAlertDialog, Dialog, Pencil1Icon, TrashIcon, CopyIcon, DragHandleDots2Icon, DropdownMenu, DotsVerticalIcon, useAlertDialog, Em, Strong, Tabs } from "@overmap-ai/blocks";
|
|
9
9
|
import { useField, useFormikContext, useFormik, FormikProvider } from "formik";
|
|
10
10
|
import React, { useMemo, memo, useCallback, useState, useEffect, useRef, forwardRef, useReducer } from "react";
|
|
11
11
|
import { DragDropContext, Droppable, Draggable } from "@hello-pangea/dnd";
|
|
@@ -1833,6 +1833,7 @@ const PatchField = memo(function PatchField2(props) {
|
|
|
1833
1833
|
const PatchFormProvider = memo(
|
|
1834
1834
|
forwardRef((props, ref) => {
|
|
1835
1835
|
const { children, schema, values, onPatch, onError, ...rest } = props;
|
|
1836
|
+
const { showError } = useToast();
|
|
1836
1837
|
const initialValues2 = useMemo(() => initialFormValues(schema.fields, values), [schema.fields, values]);
|
|
1837
1838
|
const handlePatch = useCallback(
|
|
1838
1839
|
(values2) => {
|
|
@@ -1845,6 +1846,7 @@ const PatchFormProvider = memo(
|
|
|
1845
1846
|
}
|
|
1846
1847
|
if (!hasKeys(diff))
|
|
1847
1848
|
return;
|
|
1849
|
+
console.log("onpatch runs", diff);
|
|
1848
1850
|
onPatch(diff);
|
|
1849
1851
|
},
|
|
1850
1852
|
[initialValues2, onPatch]
|
|
@@ -1870,9 +1872,13 @@ const PatchFormProvider = memo(
|
|
|
1870
1872
|
const { errors, resetForm } = formik;
|
|
1871
1873
|
useEffect(() => {
|
|
1872
1874
|
if (hasKeys(errors)) {
|
|
1873
|
-
|
|
1875
|
+
console.log(errors);
|
|
1876
|
+
showError({
|
|
1877
|
+
title: "test title",
|
|
1878
|
+
description: "Sections with conditions must be below the fields they reference."
|
|
1879
|
+
});
|
|
1874
1880
|
}
|
|
1875
|
-
}, [errors, initialValues2, resetForm]);
|
|
1881
|
+
}, [showError, errors, initialValues2, resetForm]);
|
|
1876
1882
|
return /* @__PURE__ */ jsx(FormikProvider, { value: formik, children: /* @__PURE__ */ jsx("form", { ...rest, ref, onSubmit: formik.handleSubmit, children }) });
|
|
1877
1883
|
})
|
|
1878
1884
|
);
|