@overmap-ai/forms 1.0.9-handle-patchform-errors.0 → 1.0.10-conditional-arrows-2.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/builder/FieldActions.d.ts +1 -2
- package/dist/builder/FieldSectionWithActions.d.ts +1 -0
- package/dist/fields/index.d.ts +1 -1
- package/dist/forms.js +202 -109
- package/dist/forms.js.map +1 -1
- package/dist/forms.umd.cjs +202 -110
- package/dist/forms.umd.cjs.map +1 -1
- package/dist/style.css +5 -1
- package/package.json +4 -3
package/dist/forms.umd.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function(global, factory) {
|
|
2
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react/jsx-runtime"), require("@overmap-ai/blocks"), require("formik"), require("react"), require("@hello-pangea/dnd"), require("@overmap-ai/core"), require("lodash.get"), require("lodash.set"), require("lodash.clonedeep")) : typeof define === "function" && define.amd ? define(["exports", "react/jsx-runtime", "@overmap-ai/blocks", "formik", "react", "@hello-pangea/dnd", "@overmap-ai/core", "lodash.get", "lodash.set", "lodash.clonedeep"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.forms = {}, global.jsxRuntime, global.blocks, global.formik, global.React, global.dnd, global.core, global.get, global.set, global.cloneDeep));
|
|
3
|
-
})(this, function(exports2, jsxRuntime, blocks, formik, React, dnd, core, get, set, cloneDeep) {
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react/jsx-runtime"), require("@overmap-ai/blocks"), require("formik"), require("react"), require("@hello-pangea/dnd"), require("@overmap-ai/core"), require("lodash.get"), require("lodash.set"), require("lodash.clonedeep"), require("react-xarrows")) : typeof define === "function" && define.amd ? define(["exports", "react/jsx-runtime", "@overmap-ai/blocks", "formik", "react", "@hello-pangea/dnd", "@overmap-ai/core", "lodash.get", "lodash.set", "lodash.clonedeep", "react-xarrows"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.forms = {}, global.jsxRuntime, global.blocks, global.formik, global.React, global.dnd, global.core, global.get, global.set, global.cloneDeep, global.Xarrow));
|
|
3
|
+
})(this, function(exports2, jsxRuntime, blocks, formik, React, dnd, core, get, set, cloneDeep, Xarrow) {
|
|
4
4
|
"use strict";var __defProp = Object.defineProperty;
|
|
5
5
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
6
|
var __publicField = (obj, key, value) => {
|
|
@@ -98,9 +98,11 @@ var __publicField = (obj, key, value) => {
|
|
|
98
98
|
}
|
|
99
99
|
__publicField(BaseField, "fieldTypeName");
|
|
100
100
|
__publicField(BaseField, "fieldTypeDescription");
|
|
101
|
-
const description$1 = "
|
|
101
|
+
const description$1 = "_description_1se5r_1";
|
|
102
|
+
const sectionContainer = "_sectionContainer_1se5r_5";
|
|
102
103
|
const styles$3 = {
|
|
103
|
-
description: description$1
|
|
104
|
+
description: description$1,
|
|
105
|
+
sectionContainer
|
|
104
106
|
};
|
|
105
107
|
const InputWithLabel = (props) => {
|
|
106
108
|
const { label, children, severity, inputId, labelId, flexProps } = props;
|
|
@@ -1828,7 +1830,6 @@ var __publicField = (obj, key, value) => {
|
|
|
1828
1830
|
const PatchFormProvider = React.memo(
|
|
1829
1831
|
React.forwardRef((props, ref) => {
|
|
1830
1832
|
const { children, schema, values, onPatch, onError, ...rest } = props;
|
|
1831
|
-
const { showError } = blocks.useToast();
|
|
1832
1833
|
const initialValues2 = React.useMemo(() => initialFormValues(schema.fields, values), [schema.fields, values]);
|
|
1833
1834
|
const handlePatch = React.useCallback(
|
|
1834
1835
|
(values2) => {
|
|
@@ -1841,7 +1842,6 @@ var __publicField = (obj, key, value) => {
|
|
|
1841
1842
|
}
|
|
1842
1843
|
if (!hasKeys(diff))
|
|
1843
1844
|
return;
|
|
1844
|
-
console.log("onpatch runs", diff);
|
|
1845
1845
|
onPatch(diff);
|
|
1846
1846
|
},
|
|
1847
1847
|
[initialValues2, onPatch]
|
|
@@ -1867,13 +1867,9 @@ var __publicField = (obj, key, value) => {
|
|
|
1867
1867
|
const { errors, resetForm } = formik$1;
|
|
1868
1868
|
React.useEffect(() => {
|
|
1869
1869
|
if (hasKeys(errors)) {
|
|
1870
|
-
|
|
1871
|
-
showError({
|
|
1872
|
-
title: "test title",
|
|
1873
|
-
description: "Sections with conditions must be below the fields they reference."
|
|
1874
|
-
});
|
|
1870
|
+
resetForm({ values: initialValues2, errors: {} });
|
|
1875
1871
|
}
|
|
1876
|
-
}, [
|
|
1872
|
+
}, [errors, initialValues2, resetForm]);
|
|
1877
1873
|
return /* @__PURE__ */ jsxRuntime.jsx(formik.FormikProvider, { value: formik$1, children: /* @__PURE__ */ jsxRuntime.jsx("form", { ...rest, ref, onSubmit: formik$1.handleSubmit, children }) });
|
|
1878
1874
|
})
|
|
1879
1875
|
);
|
|
@@ -2068,12 +2064,8 @@ var __publicField = (obj, key, value) => {
|
|
|
2068
2064
|
return /* @__PURE__ */ jsxRuntime.jsx(blocks.Dialog, { onCloseInterrupt: handleCloseInterrupt, title: title2, description: description2, content: dialogContent, children });
|
|
2069
2065
|
});
|
|
2070
2066
|
const DefaultWrapper = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
2071
|
-
const forMobile = (mobile, display) => ({
|
|
2072
|
-
initial: mobile ? display : "none",
|
|
2073
|
-
sm: mobile ? "none" : display
|
|
2074
|
-
});
|
|
2075
2067
|
const FieldActions = React.memo(function FieldActions2(props) {
|
|
2076
|
-
const { remove: remove2,
|
|
2068
|
+
const { remove: remove2, editProps, insertAfterProps, duplicateProps, type } = props;
|
|
2077
2069
|
const actions = React.useMemo(
|
|
2078
2070
|
() => [
|
|
2079
2071
|
{
|
|
@@ -2099,53 +2091,37 @@ var __publicField = (obj, key, value) => {
|
|
|
2099
2091
|
Wrapper: FieldBuilder,
|
|
2100
2092
|
wrapperProps: insertAfterProps,
|
|
2101
2093
|
Icon: blocks.PlusIcon,
|
|
2102
|
-
text:
|
|
2103
|
-
},
|
|
2104
|
-
{
|
|
2105
|
-
// Wrapping icon in a div so that the asChild turns the button into a div
|
|
2106
|
-
// so that the drag handle props are not applied to the icon
|
|
2107
|
-
// Note: b/c the <button> does not handle the space-press event correctly
|
|
2108
|
-
Icon: (props2) => /* @__PURE__ */ jsxRuntime.jsx("div", { ...props2, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.DragHandleDots2Icon, {}) }),
|
|
2109
|
-
text: "Reorder",
|
|
2110
|
-
disableOnMobile: true,
|
|
2111
|
-
buttonProps: { ...dragHandleProps, asChild: true }
|
|
2094
|
+
text: `Add ${type === "section" ? "section" : "field"}`
|
|
2112
2095
|
}
|
|
2113
2096
|
],
|
|
2114
|
-
[
|
|
2097
|
+
[duplicateProps, editProps, insertAfterProps, remove2, type]
|
|
2115
2098
|
);
|
|
2116
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
/* @__PURE__ */ jsxRuntime.jsx(Action.Icon, {}),
|
|
2136
|
-
Action.text
|
|
2137
|
-
] }) })
|
|
2138
|
-
};
|
|
2139
|
-
}).filter((x) => x !== null)
|
|
2140
|
-
}
|
|
2141
|
-
) })
|
|
2142
|
-
] });
|
|
2099
|
+
return /* @__PURE__ */ jsxRuntime.jsx(blocks.Box, { display: "block", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2100
|
+
blocks.DropdownMenu,
|
|
2101
|
+
{
|
|
2102
|
+
trigger: /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { variant: "ghost", "aria-label": "Actions menu", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.DotsVerticalIcon, {}) }),
|
|
2103
|
+
closeOnSelect: false,
|
|
2104
|
+
items: actions.map((Action) => {
|
|
2105
|
+
var _a;
|
|
2106
|
+
const Wrapper = Action.Wrapper ?? DefaultWrapper;
|
|
2107
|
+
return {
|
|
2108
|
+
...Action.buttonProps,
|
|
2109
|
+
onSelect: (_a = Action.buttonProps) == null ? void 0 : _a.onClick,
|
|
2110
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(Wrapper, { ...Action.wrapperProps, children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { gap: "2", align: "center", children: [
|
|
2111
|
+
/* @__PURE__ */ jsxRuntime.jsx(Action.Icon, {}),
|
|
2112
|
+
Action.text
|
|
2113
|
+
] }) })
|
|
2114
|
+
};
|
|
2115
|
+
})
|
|
2116
|
+
}
|
|
2117
|
+
) });
|
|
2143
2118
|
});
|
|
2144
2119
|
const formId = "form-builder";
|
|
2145
2120
|
const FieldWithActions = React.memo(function FieldWithActions2(props) {
|
|
2146
2121
|
const { field, index, sectionIndex, takenLabels, remove: remove2 } = props;
|
|
2147
2122
|
const deserializedField = React.useMemo(() => deserialize(field), [field]);
|
|
2148
2123
|
const input = useFieldInput(deserializedField, { formId, disabled: true });
|
|
2124
|
+
const updateXarrow = Xarrow.useXarrow();
|
|
2149
2125
|
const duplicateField = React.useCallback(
|
|
2150
2126
|
(field2) => {
|
|
2151
2127
|
if (field2.label === null) {
|
|
@@ -2186,6 +2162,8 @@ var __publicField = (obj, key, value) => {
|
|
|
2186
2162
|
ref: draggableProvided.innerRef,
|
|
2187
2163
|
...draggableProvided.draggableProps,
|
|
2188
2164
|
...draggableProvided.dragHandleProps,
|
|
2165
|
+
onDragStart: updateXarrow,
|
|
2166
|
+
id: `${field.identifier}-card`,
|
|
2189
2167
|
mb: "4",
|
|
2190
2168
|
children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { gap: "4", justify: "between", align: "center", children: [
|
|
2191
2169
|
input,
|
|
@@ -2195,20 +2173,91 @@ var __publicField = (obj, key, value) => {
|
|
|
2195
2173
|
remove: remove2,
|
|
2196
2174
|
editProps: editFieldProps,
|
|
2197
2175
|
duplicateProps: duplicateFieldProps,
|
|
2198
|
-
insertAfterProps
|
|
2199
|
-
dragHandleProps: draggableProvided.dragHandleProps
|
|
2176
|
+
insertAfterProps
|
|
2200
2177
|
}
|
|
2201
2178
|
)
|
|
2202
2179
|
] })
|
|
2203
2180
|
}
|
|
2204
2181
|
) });
|
|
2205
2182
|
});
|
|
2183
|
+
const ArrowSpacingDiv = React.memo(function ArrowSpacingDiv2(props) {
|
|
2184
|
+
const { identifier, index, conditionalFieldCounts } = props;
|
|
2185
|
+
const HORIZONTAL_SPACE = 3;
|
|
2186
|
+
const totalConditionals = conditionalFieldCounts.filter((count) => count !== null).length;
|
|
2187
|
+
const conditionalNum = conditionalFieldCounts[index] ?? 0;
|
|
2188
|
+
const marginLeft = HORIZONTAL_SPACE / totalConditionals * conditionalNum;
|
|
2189
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2190
|
+
"div",
|
|
2191
|
+
{
|
|
2192
|
+
id: `${identifier}-floating-point`,
|
|
2193
|
+
style: {
|
|
2194
|
+
width: `${HORIZONTAL_SPACE - marginLeft}%`,
|
|
2195
|
+
marginLeft: `${marginLeft}%`
|
|
2196
|
+
}
|
|
2197
|
+
}
|
|
2198
|
+
);
|
|
2199
|
+
});
|
|
2200
|
+
const ConditionalArrow = (props) => {
|
|
2201
|
+
const { identifier, condition } = props;
|
|
2202
|
+
const primaryColor = "var(--gray-a4)";
|
|
2203
|
+
const hoverColor = "var(--primary-color)";
|
|
2204
|
+
const [color, setColor] = React.useState(primaryColor);
|
|
2205
|
+
const [zIndex, setZIndex] = React.useState(0);
|
|
2206
|
+
const handleMouseEnter = React.useCallback(() => {
|
|
2207
|
+
setColor(hoverColor);
|
|
2208
|
+
setZIndex(1);
|
|
2209
|
+
}, [hoverColor]);
|
|
2210
|
+
const handleMouseLeave = React.useCallback(() => {
|
|
2211
|
+
setColor(primaryColor);
|
|
2212
|
+
setZIndex(0);
|
|
2213
|
+
}, [primaryColor]);
|
|
2214
|
+
const settings = React.useMemo(() => {
|
|
2215
|
+
return {
|
|
2216
|
+
strokeWidth: 1,
|
|
2217
|
+
showHead: false,
|
|
2218
|
+
color,
|
|
2219
|
+
zIndex,
|
|
2220
|
+
arrowBodyProps: {
|
|
2221
|
+
onMouseEnter: handleMouseEnter,
|
|
2222
|
+
onMouseLeave: handleMouseLeave
|
|
2223
|
+
}
|
|
2224
|
+
};
|
|
2225
|
+
}, [color, handleMouseEnter, handleMouseLeave, zIndex]);
|
|
2226
|
+
if (!condition)
|
|
2227
|
+
return null;
|
|
2228
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2229
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2230
|
+
Xarrow,
|
|
2231
|
+
{
|
|
2232
|
+
start: `${identifier}-card`,
|
|
2233
|
+
end: `${identifier}-floating-point`,
|
|
2234
|
+
startAnchor: "right",
|
|
2235
|
+
endAnchor: "left",
|
|
2236
|
+
path: "straight",
|
|
2237
|
+
...settings
|
|
2238
|
+
}
|
|
2239
|
+
),
|
|
2240
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2241
|
+
Xarrow,
|
|
2242
|
+
{
|
|
2243
|
+
start: `${identifier}-floating-point`,
|
|
2244
|
+
end: `${condition.identifier}-card`,
|
|
2245
|
+
startAnchor: "left",
|
|
2246
|
+
endAnchor: "right",
|
|
2247
|
+
path: "grid",
|
|
2248
|
+
gridBreak: "0",
|
|
2249
|
+
...settings
|
|
2250
|
+
}
|
|
2251
|
+
)
|
|
2252
|
+
] });
|
|
2253
|
+
};
|
|
2206
2254
|
const FieldSectionWithActions = React.memo(function FieldSectionWithActions2(props) {
|
|
2207
2255
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
2208
|
-
const { field, index: sectionIndex, dropState } = props;
|
|
2256
|
+
const { field, index: sectionIndex, dropState, conditionalFieldCounts } = props;
|
|
2209
2257
|
const isDropDisabled = (_a = dropState[field.identifier]) == null ? void 0 : _a.disabled;
|
|
2210
2258
|
const { setFieldValue, values } = formik.useFormikContext();
|
|
2211
2259
|
const alertDialog = blocks.useAlertDialog();
|
|
2260
|
+
const updateXarrow = Xarrow.useXarrow();
|
|
2212
2261
|
const takenFieldLabels = getTakenFieldLabels(values.fields);
|
|
2213
2262
|
const removeSectionConditions = React.useCallback(
|
|
2214
2263
|
(sectionsToUpdate, allSections) => {
|
|
@@ -2359,64 +2408,95 @@ var __publicField = (obj, key, value) => {
|
|
|
2359
2408
|
throw new Error("File values are not supported for conditions.");
|
|
2360
2409
|
const conditionValue = Array.isArray((_e = field.condition) == null ? void 0 : _e.value) ? (_g = (_f = field.condition) == null ? void 0 : _f.value) == null ? void 0 : _g.map((v) => typeof v === "string" ? v : v.label).join(", ") : (_i = (_h = field.condition) == null ? void 0 : _h.value) == null ? void 0 : _i.toString();
|
|
2361
2410
|
return /* @__PURE__ */ jsxRuntime.jsx(dnd.Draggable, { draggableId: field.identifier, index: sectionIndex, children: (draggableProvided) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2362
|
-
blocks.
|
|
2411
|
+
blocks.Flex,
|
|
2363
2412
|
{
|
|
2413
|
+
className: styles$3.sectionContainer,
|
|
2364
2414
|
ref: draggableProvided.innerRef,
|
|
2365
2415
|
...draggableProvided.draggableProps,
|
|
2366
|
-
|
|
2416
|
+
direction: "row",
|
|
2417
|
+
justify: "center",
|
|
2418
|
+
align: "center",
|
|
2367
2419
|
mb: "4",
|
|
2368
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2369
|
-
/* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "2", grow: "1", children: [
|
|
2370
|
-
/* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", children: [
|
|
2371
|
-
/* @__PURE__ */ jsxRuntime.jsx(blocks.Heading, { as: "h3", size: "3", children: field.label }),
|
|
2372
|
-
/* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$3.description, children: field.description })
|
|
2373
|
-
] }),
|
|
2374
|
-
field.condition && /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "1", children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Em, { children: [
|
|
2375
|
-
"Display only if ",
|
|
2376
|
-
/* @__PURE__ */ jsxRuntime.jsx(blocks.Strong, { children: conditionLabel }),
|
|
2377
|
-
" ",
|
|
2378
|
-
conditionComparison,
|
|
2379
|
-
" ",
|
|
2380
|
-
/* @__PURE__ */ jsxRuntime.jsx(blocks.Strong, { children: conditionValue })
|
|
2381
|
-
] }) }),
|
|
2382
|
-
/* @__PURE__ */ jsxRuntime.jsx(dnd.Droppable, { droppableId: field.identifier, type: "SECTION", isDropDisabled, children: (droppableProvided) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2383
|
-
blocks.Flex,
|
|
2384
|
-
{
|
|
2385
|
-
ref: droppableProvided.innerRef,
|
|
2386
|
-
...droppableProvided.droppableProps,
|
|
2387
|
-
direction: "column",
|
|
2388
|
-
gap: "0",
|
|
2389
|
-
children: [
|
|
2390
|
-
field.fields.map((child, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2391
|
-
FieldWithActions,
|
|
2392
|
-
{
|
|
2393
|
-
field: child,
|
|
2394
|
-
index: i,
|
|
2395
|
-
sectionIndex,
|
|
2396
|
-
remove: () => removeField(i),
|
|
2397
|
-
takenLabels: takenFieldLabels
|
|
2398
|
-
},
|
|
2399
|
-
child.identifier
|
|
2400
|
-
)),
|
|
2401
|
-
droppableProvided.placeholder,
|
|
2402
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldBuilder, { ...insertFieldAtEndOfSection, children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Button, { type: "button", variant: "outline", children: [
|
|
2403
|
-
/* @__PURE__ */ jsxRuntime.jsx(blocks.PlusIcon, {}),
|
|
2404
|
-
" Add a field"
|
|
2405
|
-
] }) })
|
|
2406
|
-
]
|
|
2407
|
-
}
|
|
2408
|
-
) })
|
|
2409
|
-
] }),
|
|
2420
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(Xarrow.Xwrapper, { children: [
|
|
2410
2421
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2411
|
-
|
|
2422
|
+
blocks.Card,
|
|
2412
2423
|
{
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2424
|
+
...draggableProvided.dragHandleProps,
|
|
2425
|
+
onDragStart: updateXarrow,
|
|
2426
|
+
id: `${field.identifier}-card`,
|
|
2427
|
+
style: { flexGrow: "1" },
|
|
2428
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { gap: "3", justify: "between", align: "center", children: [
|
|
2429
|
+
/* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "2", grow: "1", children: [
|
|
2430
|
+
/* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", children: [
|
|
2431
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.Heading, { as: "h3", size: "3", children: field.label }),
|
|
2432
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$3.description, children: field.description })
|
|
2433
|
+
] }),
|
|
2434
|
+
field.condition && /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "1", children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Em, { children: [
|
|
2435
|
+
"Display only if ",
|
|
2436
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.Strong, { children: conditionLabel }),
|
|
2437
|
+
" ",
|
|
2438
|
+
conditionComparison,
|
|
2439
|
+
" ",
|
|
2440
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.Strong, { children: conditionValue })
|
|
2441
|
+
] }) }),
|
|
2442
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2443
|
+
dnd.Droppable,
|
|
2444
|
+
{
|
|
2445
|
+
droppableId: field.identifier,
|
|
2446
|
+
type: "SECTION",
|
|
2447
|
+
isDropDisabled,
|
|
2448
|
+
children: (droppableProvided) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2449
|
+
blocks.Flex,
|
|
2450
|
+
{
|
|
2451
|
+
ref: droppableProvided.innerRef,
|
|
2452
|
+
...droppableProvided.droppableProps,
|
|
2453
|
+
direction: "column",
|
|
2454
|
+
gap: "0",
|
|
2455
|
+
children: [
|
|
2456
|
+
field.fields.map((child, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2457
|
+
FieldWithActions,
|
|
2458
|
+
{
|
|
2459
|
+
field: child,
|
|
2460
|
+
index: i,
|
|
2461
|
+
sectionIndex,
|
|
2462
|
+
remove: () => removeField(i),
|
|
2463
|
+
takenLabels: takenFieldLabels
|
|
2464
|
+
},
|
|
2465
|
+
child.identifier
|
|
2466
|
+
)),
|
|
2467
|
+
droppableProvided.placeholder,
|
|
2468
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldBuilder, { ...insertFieldAtEndOfSection, children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Button, { type: "button", variant: "outline", children: [
|
|
2469
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.PlusIcon, {}),
|
|
2470
|
+
" Add a field"
|
|
2471
|
+
] }) })
|
|
2472
|
+
]
|
|
2473
|
+
}
|
|
2474
|
+
)
|
|
2475
|
+
}
|
|
2476
|
+
)
|
|
2477
|
+
] }),
|
|
2478
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2479
|
+
FieldActions,
|
|
2480
|
+
{
|
|
2481
|
+
remove: removeSection,
|
|
2482
|
+
insertAfterProps: insertSectionProps,
|
|
2483
|
+
editProps: editSectionProps,
|
|
2484
|
+
duplicateProps: duplicateSectionProps,
|
|
2485
|
+
type: "section"
|
|
2486
|
+
}
|
|
2487
|
+
)
|
|
2488
|
+
] })
|
|
2418
2489
|
}
|
|
2419
|
-
)
|
|
2490
|
+
),
|
|
2491
|
+
conditionalFieldCounts.some((count) => count !== null) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2492
|
+
ArrowSpacingDiv,
|
|
2493
|
+
{
|
|
2494
|
+
identifier: field.identifier,
|
|
2495
|
+
index: sectionIndex,
|
|
2496
|
+
conditionalFieldCounts
|
|
2497
|
+
}
|
|
2498
|
+
),
|
|
2499
|
+
field.condition && /* @__PURE__ */ jsxRuntime.jsx(ConditionalArrow, { identifier: field.identifier, condition: field.condition })
|
|
2420
2500
|
] })
|
|
2421
2501
|
}
|
|
2422
2502
|
) });
|
|
@@ -2554,6 +2634,12 @@ var __publicField = (obj, key, value) => {
|
|
|
2554
2634
|
}),
|
|
2555
2635
|
[values.fields]
|
|
2556
2636
|
);
|
|
2637
|
+
const conditionalFieldCounts = () => {
|
|
2638
|
+
let conditionalCount = 1;
|
|
2639
|
+
return values.fields.map((field) => {
|
|
2640
|
+
return field.conditional ? conditionalCount++ : null;
|
|
2641
|
+
});
|
|
2642
|
+
};
|
|
2557
2643
|
return /* @__PURE__ */ jsxRuntime.jsx(dnd.DragDropContext, { onDragStart: handleDragStart, onDragEnd: handleDragEnd, children: /* @__PURE__ */ jsxRuntime.jsx(dnd.Droppable, { droppableId: "droppable", type: "ROOT", children: (droppableProvided) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2558
2644
|
blocks.Flex,
|
|
2559
2645
|
{
|
|
@@ -2567,7 +2653,8 @@ var __publicField = (obj, key, value) => {
|
|
|
2567
2653
|
{
|
|
2568
2654
|
field,
|
|
2569
2655
|
index,
|
|
2570
|
-
dropState
|
|
2656
|
+
dropState,
|
|
2657
|
+
conditionalFieldCounts: conditionalFieldCounts()
|
|
2571
2658
|
},
|
|
2572
2659
|
field.label
|
|
2573
2660
|
)),
|
|
@@ -2668,6 +2755,8 @@ var __publicField = (obj, key, value) => {
|
|
|
2668
2755
|
] }) });
|
|
2669
2756
|
})
|
|
2670
2757
|
);
|
|
2758
|
+
exports2.BaseField = BaseField;
|
|
2759
|
+
exports2.BaseFormElement = BaseFormElement;
|
|
2671
2760
|
exports2.BooleanField = BooleanField;
|
|
2672
2761
|
exports2.BooleanInput = BooleanInput;
|
|
2673
2762
|
exports2.DateField = DateField;
|
|
@@ -2678,6 +2767,8 @@ var __publicField = (obj, key, value) => {
|
|
|
2678
2767
|
exports2.FormRenderer = FormRenderer;
|
|
2679
2768
|
exports2.FormSubmissionBrowser = FormSubmissionBrowser;
|
|
2680
2769
|
exports2.FormSubmissionViewer = FormSubmissionViewer;
|
|
2770
|
+
exports2.InputWithLabel = InputWithLabel;
|
|
2771
|
+
exports2.InputWithLabelAndHelpText = InputWithLabelAndHelpText;
|
|
2681
2772
|
exports2.MultiSelectField = MultiSelectField;
|
|
2682
2773
|
exports2.MultiSelectInput = MultiSelectInput;
|
|
2683
2774
|
exports2.MultiStringField = MultiStringField;
|
|
@@ -2698,6 +2789,7 @@ var __publicField = (obj, key, value) => {
|
|
|
2698
2789
|
exports2.isConditionMet = isConditionMet;
|
|
2699
2790
|
exports2.useFieldInput = useFieldInput;
|
|
2700
2791
|
exports2.useFieldInputs = useFieldInputs;
|
|
2792
|
+
exports2.useFormikInput = useFormikInput;
|
|
2701
2793
|
exports2.valueIsFile = valueIsFile;
|
|
2702
2794
|
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
|
2703
2795
|
});
|