@overmap-ai/forms 1.0.12-fix-dropdown-error.0 → 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 +55 -51
- package/dist/forms.js.map +1 -1
- package/dist/forms.umd.cjs +55 -51
- 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.");
|
|
@@ -2049,30 +2046,27 @@ const FieldBuilder = memo(function FieldBuilder2(props) {
|
|
|
2049
2046
|
newFields = insert(parent, index, field);
|
|
2050
2047
|
}
|
|
2051
2048
|
setFieldValue(parentPath, newFields).then();
|
|
2052
|
-
|
|
2049
|
+
setIsOpen(false);
|
|
2053
2050
|
},
|
|
2054
|
-
[
|
|
2051
|
+
[type, values, parentPath, editing, setFieldValue, setIsOpen, index]
|
|
2055
2052
|
);
|
|
2056
2053
|
const handleDirtyChange = useCallback((dirty) => setFormIsDirty(dirty), []);
|
|
2057
|
-
const dialogContent = useCallback(
|
|
2058
|
-
(
|
|
2059
|
-
|
|
2060
|
-
|
|
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
|
|
2061
2067
|
}
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
{
|
|
2065
|
-
conditionalSourceFields,
|
|
2066
|
-
handleCancel,
|
|
2067
|
-
handleCreateField: (form) => handleCreateField(form, closeDialog),
|
|
2068
|
-
fieldType: type,
|
|
2069
|
-
defaultField: initial,
|
|
2070
|
-
handleDirtyChange
|
|
2071
|
-
}
|
|
2072
|
-
);
|
|
2073
|
-
},
|
|
2074
|
-
[conditionalSourceFields, handleCancel, handleCreateField, handleDirtyChange, initial, showChooseField, type]
|
|
2075
|
-
);
|
|
2068
|
+
);
|
|
2069
|
+
}, [conditionalSourceFields, handleCancel, handleCreateField, handleDirtyChange, initial, showChooseField, type]);
|
|
2076
2070
|
return /* @__PURE__ */ jsx(
|
|
2077
2071
|
Dialog,
|
|
2078
2072
|
{
|
|
@@ -2090,15 +2084,17 @@ const forMobile = (mobile, display) => ({
|
|
|
2090
2084
|
});
|
|
2091
2085
|
const FieldActions = memo(function FieldActions2(props) {
|
|
2092
2086
|
const { remove: remove2, dragHandleProps, editProps, insertAfterProps, duplicateProps } = props;
|
|
2093
|
-
const [
|
|
2087
|
+
const [isEditDialogOpen, setIsEditDialogOpen] = useState(false);
|
|
2088
|
+
const [isDuplicateDialogOpen, setIsDuplicateDialogOpen] = useState(false);
|
|
2089
|
+
const [isAddDialogOpen, setIsAddDialogOpen] = useState(false);
|
|
2094
2090
|
const actions = useMemo(
|
|
2095
2091
|
() => [
|
|
2096
2092
|
{
|
|
2097
2093
|
SelectedContent: FieldBuilder,
|
|
2098
|
-
selectedContentProps: { ...editProps, isOpen:
|
|
2094
|
+
selectedContentProps: { ...editProps, isOpen: isEditDialogOpen, setIsOpen: setIsEditDialogOpen },
|
|
2099
2095
|
Icon: Pencil1Icon,
|
|
2100
2096
|
text: "Edit",
|
|
2101
|
-
buttonProps: { onClick: () =>
|
|
2097
|
+
buttonProps: { onClick: () => setIsEditDialogOpen(true) }
|
|
2102
2098
|
},
|
|
2103
2099
|
{
|
|
2104
2100
|
Icon: TrashIcon,
|
|
@@ -2109,17 +2105,21 @@ const FieldActions = memo(function FieldActions2(props) {
|
|
|
2109
2105
|
},
|
|
2110
2106
|
{
|
|
2111
2107
|
SelectedContent: FieldBuilder,
|
|
2112
|
-
selectedContentProps: {
|
|
2108
|
+
selectedContentProps: {
|
|
2109
|
+
...duplicateProps,
|
|
2110
|
+
isOpen: isDuplicateDialogOpen,
|
|
2111
|
+
setIsOpen: setIsDuplicateDialogOpen
|
|
2112
|
+
},
|
|
2113
2113
|
Icon: CopyIcon,
|
|
2114
2114
|
text: "Duplicate",
|
|
2115
|
-
buttonProps: { onClick: () =>
|
|
2115
|
+
buttonProps: { onClick: () => setIsDuplicateDialogOpen(true) }
|
|
2116
2116
|
},
|
|
2117
2117
|
{
|
|
2118
2118
|
SelectedContent: FieldBuilder,
|
|
2119
|
-
selectedContentProps: { ...insertAfterProps, isOpen:
|
|
2119
|
+
selectedContentProps: { ...insertAfterProps, isOpen: isAddDialogOpen, setIsOpen: setIsAddDialogOpen },
|
|
2120
2120
|
Icon: PlusIcon,
|
|
2121
2121
|
text: "Add after",
|
|
2122
|
-
buttonProps: { onClick: () =>
|
|
2122
|
+
buttonProps: { onClick: () => setIsAddDialogOpen(true) }
|
|
2123
2123
|
},
|
|
2124
2124
|
{
|
|
2125
2125
|
// Wrapping icon in a div so that the asChild turns the button into a div
|
|
@@ -2131,7 +2131,16 @@ const FieldActions = memo(function FieldActions2(props) {
|
|
|
2131
2131
|
buttonProps: { ...dragHandleProps, asChild: true }
|
|
2132
2132
|
}
|
|
2133
2133
|
],
|
|
2134
|
-
[
|
|
2134
|
+
[
|
|
2135
|
+
dragHandleProps,
|
|
2136
|
+
duplicateProps,
|
|
2137
|
+
editProps,
|
|
2138
|
+
insertAfterProps,
|
|
2139
|
+
isAddDialogOpen,
|
|
2140
|
+
isDuplicateDialogOpen,
|
|
2141
|
+
isEditDialogOpen,
|
|
2142
|
+
remove2
|
|
2143
|
+
]
|
|
2135
2144
|
);
|
|
2136
2145
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2137
2146
|
/* @__PURE__ */ jsx(Flex, { gap: "4", display: forMobile(false, "flex"), children: actions.map((Action) => {
|
|
@@ -2157,12 +2166,7 @@ const FieldActions = memo(function FieldActions2(props) {
|
|
|
2157
2166
|
/* @__PURE__ */ jsx(Action.Icon, {}),
|
|
2158
2167
|
Action.text
|
|
2159
2168
|
] }),
|
|
2160
|
-
Action.SelectedContent && /* @__PURE__ */ jsx(
|
|
2161
|
-
Action.SelectedContent,
|
|
2162
|
-
{
|
|
2163
|
-
...Action.selectedContentProps
|
|
2164
|
-
}
|
|
2165
|
-
)
|
|
2169
|
+
Action.SelectedContent && /* @__PURE__ */ jsx(Action.SelectedContent, { ...Action.selectedContentProps })
|
|
2166
2170
|
] }, Action.text)
|
|
2167
2171
|
};
|
|
2168
2172
|
}).filter((x) => x !== null)
|