@overmap-ai/forms 1.0.12-fix-dropdown-error.2 → 1.0.12-fix-form-problem.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 +54 -45
- package/dist/forms.js.map +1 -1
- package/dist/forms.umd.cjs +54 -45
- package/dist/forms.umd.cjs.map +1 -1
- package/package.json +1 -1
package/dist/forms.js
CHANGED
|
@@ -2007,25 +2007,24 @@ const FieldBuilder = memo(function FieldBuilder2(props) {
|
|
|
2007
2007
|
const handleCancel = useCallback(() => {
|
|
2008
2008
|
setFieldType(void 0);
|
|
2009
2009
|
setFormIsDirty(false);
|
|
2010
|
+
console.log("handlecancelran");
|
|
2010
2011
|
}, []);
|
|
2011
|
-
const handleCloseDialog = useCallback(
|
|
2012
|
-
(
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
[formIsDirty, openConfirmDiscardChangesDialog, setIsOpen]
|
|
2026
|
-
);
|
|
2012
|
+
const handleCloseDialog = useCallback(() => {
|
|
2013
|
+
console.log("handlecloseran");
|
|
2014
|
+
if (!formIsDirty) {
|
|
2015
|
+
setFieldType(void 0);
|
|
2016
|
+
setIsOpen(false);
|
|
2017
|
+
} else {
|
|
2018
|
+
openConfirmDiscardChangesDialog({
|
|
2019
|
+
onDiscard: () => {
|
|
2020
|
+
setFieldType(void 0);
|
|
2021
|
+
setIsOpen(false);
|
|
2022
|
+
}
|
|
2023
|
+
});
|
|
2024
|
+
}
|
|
2025
|
+
}, [formIsDirty, openConfirmDiscardChangesDialog, setIsOpen]);
|
|
2027
2026
|
const handleCreateField = useCallback(
|
|
2028
|
-
(form
|
|
2027
|
+
(form) => {
|
|
2029
2028
|
const { label } = form;
|
|
2030
2029
|
if (!type)
|
|
2031
2030
|
throw new Error("Field type must be selected before creating a field.");
|
|
@@ -2050,31 +2049,26 @@ const FieldBuilder = memo(function FieldBuilder2(props) {
|
|
|
2050
2049
|
}
|
|
2051
2050
|
setFieldValue(parentPath, newFields).then();
|
|
2052
2051
|
setIsOpen(false);
|
|
2053
|
-
console.log(closeDialog);
|
|
2054
2052
|
},
|
|
2055
2053
|
[type, values, parentPath, editing, setFieldValue, setIsOpen, index]
|
|
2056
2054
|
);
|
|
2057
2055
|
const handleDirtyChange = useCallback((dirty) => setFormIsDirty(dirty), []);
|
|
2058
|
-
const dialogContent = useCallback(
|
|
2059
|
-
(
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2056
|
+
const dialogContent = useCallback(() => {
|
|
2057
|
+
if (showChooseField) {
|
|
2058
|
+
return /* @__PURE__ */ jsx(ChooseFieldToAdd, { setFieldType });
|
|
2059
|
+
}
|
|
2060
|
+
return /* @__PURE__ */ jsx(
|
|
2061
|
+
FieldOptionsForm,
|
|
2062
|
+
{
|
|
2063
|
+
conditionalSourceFields,
|
|
2064
|
+
handleCancel,
|
|
2065
|
+
handleCreateField,
|
|
2066
|
+
fieldType: type,
|
|
2067
|
+
defaultField: initial,
|
|
2068
|
+
handleDirtyChange
|
|
2063
2069
|
}
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
{
|
|
2067
|
-
conditionalSourceFields,
|
|
2068
|
-
handleCancel,
|
|
2069
|
-
handleCreateField: (form) => handleCreateField(form, closeDialog),
|
|
2070
|
-
fieldType: type,
|
|
2071
|
-
defaultField: initial,
|
|
2072
|
-
handleDirtyChange
|
|
2073
|
-
}
|
|
2074
|
-
);
|
|
2075
|
-
},
|
|
2076
|
-
[conditionalSourceFields, handleCancel, handleCreateField, handleDirtyChange, initial, showChooseField, type]
|
|
2077
|
-
);
|
|
2070
|
+
);
|
|
2071
|
+
}, [conditionalSourceFields, handleCancel, handleCreateField, handleDirtyChange, initial, showChooseField, type]);
|
|
2078
2072
|
return /* @__PURE__ */ jsx(
|
|
2079
2073
|
Dialog,
|
|
2080
2074
|
{
|
|
@@ -2092,15 +2086,17 @@ const forMobile = (mobile, display) => ({
|
|
|
2092
2086
|
});
|
|
2093
2087
|
const FieldActions = memo(function FieldActions2(props) {
|
|
2094
2088
|
const { remove: remove2, dragHandleProps, editProps, insertAfterProps, duplicateProps } = props;
|
|
2095
|
-
const [
|
|
2089
|
+
const [isEditDialogOpen, setIsEditDialogOpen] = useState(false);
|
|
2090
|
+
const [isDuplicateDialogOpen, setIsDuplicateDialogOpen] = useState(false);
|
|
2091
|
+
const [isAddDialogOpen, setIsAddDialogOpen] = useState(false);
|
|
2096
2092
|
const actions = useMemo(
|
|
2097
2093
|
() => [
|
|
2098
2094
|
{
|
|
2099
2095
|
SelectedContent: FieldBuilder,
|
|
2100
|
-
selectedContentProps: { ...editProps, isOpen:
|
|
2096
|
+
selectedContentProps: { ...editProps, isOpen: isEditDialogOpen, setIsOpen: setIsEditDialogOpen },
|
|
2101
2097
|
Icon: Pencil1Icon,
|
|
2102
2098
|
text: "Edit",
|
|
2103
|
-
buttonProps: { onClick: () =>
|
|
2099
|
+
buttonProps: { onClick: () => setIsEditDialogOpen(true) }
|
|
2104
2100
|
},
|
|
2105
2101
|
{
|
|
2106
2102
|
Icon: TrashIcon,
|
|
@@ -2111,17 +2107,21 @@ const FieldActions = memo(function FieldActions2(props) {
|
|
|
2111
2107
|
},
|
|
2112
2108
|
{
|
|
2113
2109
|
SelectedContent: FieldBuilder,
|
|
2114
|
-
selectedContentProps: {
|
|
2110
|
+
selectedContentProps: {
|
|
2111
|
+
...duplicateProps,
|
|
2112
|
+
isOpen: isDuplicateDialogOpen,
|
|
2113
|
+
setIsOpen: setIsDuplicateDialogOpen
|
|
2114
|
+
},
|
|
2115
2115
|
Icon: CopyIcon,
|
|
2116
2116
|
text: "Duplicate",
|
|
2117
|
-
buttonProps: { onClick: () =>
|
|
2117
|
+
buttonProps: { onClick: () => setIsDuplicateDialogOpen(true) }
|
|
2118
2118
|
},
|
|
2119
2119
|
{
|
|
2120
2120
|
SelectedContent: FieldBuilder,
|
|
2121
|
-
selectedContentProps: { ...insertAfterProps, isOpen:
|
|
2121
|
+
selectedContentProps: { ...insertAfterProps, isOpen: isAddDialogOpen, setIsOpen: setIsAddDialogOpen },
|
|
2122
2122
|
Icon: PlusIcon,
|
|
2123
2123
|
text: "Add after",
|
|
2124
|
-
buttonProps: { onClick: () =>
|
|
2124
|
+
buttonProps: { onClick: () => setIsAddDialogOpen(true) }
|
|
2125
2125
|
},
|
|
2126
2126
|
{
|
|
2127
2127
|
// Wrapping icon in a div so that the asChild turns the button into a div
|
|
@@ -2133,7 +2133,16 @@ const FieldActions = memo(function FieldActions2(props) {
|
|
|
2133
2133
|
buttonProps: { ...dragHandleProps, asChild: true }
|
|
2134
2134
|
}
|
|
2135
2135
|
],
|
|
2136
|
-
[
|
|
2136
|
+
[
|
|
2137
|
+
dragHandleProps,
|
|
2138
|
+
duplicateProps,
|
|
2139
|
+
editProps,
|
|
2140
|
+
insertAfterProps,
|
|
2141
|
+
isAddDialogOpen,
|
|
2142
|
+
isDuplicateDialogOpen,
|
|
2143
|
+
isEditDialogOpen,
|
|
2144
|
+
remove2
|
|
2145
|
+
]
|
|
2137
2146
|
);
|
|
2138
2147
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2139
2148
|
/* @__PURE__ */ jsx(Flex, { gap: "4", display: forMobile(false, "flex"), children: actions.map((Action) => {
|