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