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