@overmap-ai/forms 1.0.10-conditional-arrows-2.5 → 1.0.10
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 +2 -1
- package/dist/builder/FieldSectionWithActions.d.ts +0 -1
- package/dist/fields/BooleanField/BooleanField.d.ts +1 -1
- package/dist/fields/DateField/DateField.d.ts +1 -1
- package/dist/fields/MultiStringField/MultiStringField.d.ts +1 -1
- package/dist/fields/NumberField/NumberField.d.ts +1 -1
- package/dist/fields/SelectField/MultiSelectField.d.ts +1 -1
- package/dist/fields/SelectField/SelectField.d.ts +1 -1
- package/dist/fields/StringOrTextFields/StringField/StringField.d.ts +1 -1
- package/dist/fields/StringOrTextFields/TextField/TextField.d.ts +1 -1
- package/dist/fields/UploadField/UploadField.d.ts +1 -1
- package/dist/forms.js +113 -211
- package/dist/forms.js.map +1 -1
- package/dist/forms.umd.cjs +155 -254
- package/dist/forms.umd.cjs.map +1 -1
- package/dist/style.css +1 -5
- package/package.json +7 -6
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { DraggableProvidedDragHandleProps } from "@hello-pangea/dnd";
|
|
2
3
|
import { FieldBuilderArgs } from "./FieldBuilder";
|
|
3
4
|
interface FieldActionsProps {
|
|
4
5
|
remove: () => void;
|
|
6
|
+
dragHandleProps: DraggableProvidedDragHandleProps | null | undefined;
|
|
5
7
|
editProps: FieldBuilderArgs;
|
|
6
8
|
insertAfterProps: FieldBuilderArgs;
|
|
7
9
|
duplicateProps: FieldBuilderArgs;
|
|
8
|
-
type?: string;
|
|
9
10
|
}
|
|
10
11
|
export declare const FieldActions: import("react").NamedExoticComponent<FieldActionsProps>;
|
|
11
12
|
export {};
|
|
@@ -4,7 +4,6 @@ import { DropState } from "./DropDispatch";
|
|
|
4
4
|
interface FieldSectionWithActionsProps {
|
|
5
5
|
field: SerializedFieldSection;
|
|
6
6
|
index: number;
|
|
7
|
-
conditionalFieldCounts: (number | null)[];
|
|
8
7
|
dropState: DropState;
|
|
9
8
|
}
|
|
10
9
|
export declare const FieldSectionWithActions: import("react").NamedExoticComponent<FieldSectionWithActionsProps>;
|
|
@@ -2,7 +2,7 @@ import { ISerializedField, SerializedBooleanField } from "@overmap-ai/core";
|
|
|
2
2
|
import { BaseField, ChildFieldOptions } from "../BaseField";
|
|
3
3
|
import { ChangeEvent, ReactNode } from "react";
|
|
4
4
|
import { ComponentProps } from "../typings";
|
|
5
|
-
import { CheckCircledIcon } from "@
|
|
5
|
+
import { CheckCircledIcon } from "@radix-ui/react-icons";
|
|
6
6
|
export declare class BooleanField extends BaseField<boolean, "boolean"> {
|
|
7
7
|
static readonly fieldTypeName = "Checkbox";
|
|
8
8
|
static readonly fieldTypeDescription = "Perfect for both optional and required yes/no questions.";
|
|
@@ -2,7 +2,7 @@ import { ISerializedField, SerializedDateField } from "@overmap-ai/core";
|
|
|
2
2
|
import { BaseField, ChildFieldOptions } from "../BaseField";
|
|
3
3
|
import { GetInputProps } from "../typings";
|
|
4
4
|
import React from "react";
|
|
5
|
-
import { CalendarIcon } from "@
|
|
5
|
+
import { CalendarIcon } from "@radix-ui/react-icons";
|
|
6
6
|
export declare class DateField extends BaseField<string, "date"> {
|
|
7
7
|
static readonly fieldTypeName = "Date";
|
|
8
8
|
static readonly fieldTypeDescription = "Allows specifying a date.";
|
|
@@ -2,7 +2,7 @@ import { BaseField, ChildFieldOptions } from "../BaseField";
|
|
|
2
2
|
import { ISerializedField, SelectFieldOption, SerializedMultiStringField } from "@overmap-ai/core";
|
|
3
3
|
import { GetInputProps, InputFieldLevelValidator } from "../typings.ts";
|
|
4
4
|
import { ReactNode } from "react";
|
|
5
|
-
import { ListBulletIcon } from "@
|
|
5
|
+
import { ListBulletIcon } from "@radix-ui/react-icons";
|
|
6
6
|
type MultiStringFieldOptions = ChildFieldOptions<SelectFieldOption[]> & {
|
|
7
7
|
minimum_length?: number;
|
|
8
8
|
maximum_length?: number;
|
|
@@ -3,7 +3,7 @@ import { BooleanField } from "../BooleanField";
|
|
|
3
3
|
import { BaseField, ChildFieldOptions } from "../BaseField";
|
|
4
4
|
import { GetInputProps, InputFieldLevelValidator, InputValidator } from "../typings";
|
|
5
5
|
import { ChangeEvent, ReactNode } from "react";
|
|
6
|
-
import { FontFamilyIcon } from "@
|
|
6
|
+
import { FontFamilyIcon } from "@radix-ui/react-icons";
|
|
7
7
|
export type NumberFieldValue = number | "";
|
|
8
8
|
export interface NumberFieldOptions extends ChildFieldOptions<NumberFieldValue> {
|
|
9
9
|
maximum?: number;
|
|
@@ -2,7 +2,7 @@ import { ISerializedField, SelectFieldOptionValue, SerializedMultiSelectField }
|
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
3
|
import { GetInputProps } from "../typings";
|
|
4
4
|
import { BaseSelectField, BaseSelectFieldOptions } from "./BaseSelectField";
|
|
5
|
-
import { CheckboxIcon } from "@
|
|
5
|
+
import { CheckboxIcon } from "@radix-ui/react-icons";
|
|
6
6
|
/**
|
|
7
7
|
* The options passed to the constructor of MultiSelectField.
|
|
8
8
|
*/
|
|
@@ -2,7 +2,7 @@ import { ISerializedField, SelectFieldOptionValue, SerializedSelectField } from
|
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
3
|
import { GetInputProps } from "../typings";
|
|
4
4
|
import { BaseSelectField, BaseSelectFieldOptions } from "./BaseSelectField";
|
|
5
|
-
import { DropdownMenuIcon } from "@
|
|
5
|
+
import { DropdownMenuIcon } from "@radix-ui/react-icons";
|
|
6
6
|
/**
|
|
7
7
|
* The options passed to the constructor of SelectField.
|
|
8
8
|
*/
|
|
@@ -2,7 +2,7 @@ import { ISerializedField, SerializedStringField, StringInputType } from "@overm
|
|
|
2
2
|
import { StringOrTextField, StringOrTextFieldOptions } from "../StringOrTextField";
|
|
3
3
|
import { GetInputProps } from "../../typings";
|
|
4
4
|
import React from "react";
|
|
5
|
-
import { InputIcon } from "@
|
|
5
|
+
import { InputIcon } from "@radix-ui/react-icons";
|
|
6
6
|
interface StringFieldOptions extends Omit<StringOrTextFieldOptions, "type"> {
|
|
7
7
|
inputType?: StringInputType;
|
|
8
8
|
}
|
|
@@ -2,7 +2,7 @@ import { ISerializedField, SerializedTextField } from "@overmap-ai/core";
|
|
|
2
2
|
import { StringOrTextField, StringOrTextFieldOptions } from "../StringOrTextField";
|
|
3
3
|
import { GetInputProps } from "../../typings";
|
|
4
4
|
import React from "react";
|
|
5
|
-
import { RowsIcon } from "@
|
|
5
|
+
import { RowsIcon } from "@radix-ui/react-icons";
|
|
6
6
|
export interface TextFieldOptions extends Omit<StringOrTextFieldOptions, "type"> {
|
|
7
7
|
}
|
|
8
8
|
export declare class TextField extends StringOrTextField<"text"> {
|
|
@@ -2,7 +2,7 @@ import { ISerializedField, SerializedUploadField } from "@overmap-ai/core";
|
|
|
2
2
|
import { BaseField, ChildFieldOptions } from "../BaseField";
|
|
3
3
|
import { GetInputProps, InputFieldLevelValidator } from "../typings";
|
|
4
4
|
import { ChangeEvent, ReactNode } from "react";
|
|
5
|
-
import { UploadIcon } from "@
|
|
5
|
+
import { UploadIcon } from "@radix-ui/react-icons";
|
|
6
6
|
import { NumberField } from "../NumberField";
|
|
7
7
|
import { MultiSelectField } from "../SelectField";
|
|
8
8
|
export interface UploadFieldOptions extends ChildFieldOptions<File[]> {
|
package/dist/forms.js
CHANGED
|
@@ -5,15 +5,16 @@ var __publicField = (obj, key, value) => {
|
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
7
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
8
|
-
import { Flex, Text, useSeverityColor, Checkbox,
|
|
8
|
+
import { Flex, Text, useSeverityColor, Checkbox, TextArea, Select, IconButton, Badge, MultiSelect, Button, ButtonList, divButtonProps, Tooltip, Separator, useDiscardAlertDialog, Dialog, DropdownItemMenu, useAlertDialog, useToast } from "@overmap-ai/blocks";
|
|
9
9
|
import { useField, useFormikContext, useFormik, FormikProvider } from "formik";
|
|
10
10
|
import React, { useMemo, memo, useCallback, useState, useEffect, useRef, forwardRef, useReducer } from "react";
|
|
11
|
+
import { CheckCircledIcon, FontFamilyIcon, CalendarIcon, InputIcon, RowsIcon, PlusIcon, Cross1Icon, ListBulletIcon, DropdownMenuIcon, CheckboxIcon, UploadIcon, StarFilledIcon, StarIcon, QuestionMarkCircledIcon, PersonIcon, Pencil1Icon, TrashIcon, CopyIcon, DragHandleDots2Icon, DotsVerticalIcon } from "@radix-ui/react-icons";
|
|
12
|
+
import { TextField as TextField$1, Box, Card, Heading, Avatar, Em, Strong, Tabs } from "@radix-ui/themes";
|
|
11
13
|
import { DragDropContext, Droppable, Draggable } from "@hello-pangea/dnd";
|
|
12
14
|
import { slugify, useAppSelector, selectFormRevision, useSDK, selectSubmissionAttachments, selectFilteredUserForms, selectUserFormMapping, selectOrganization, selectUser, selectNumberOfUserForms, selectCurrentUser, classNames, isToday, getLocalDateString, selectLatestFormRevision, useFileSrc, selectSubmissionsForForm } from "@overmap-ai/core";
|
|
13
15
|
import get from "lodash.get";
|
|
14
16
|
import set from "lodash.set";
|
|
15
17
|
import cloneDeep from "lodash.clonedeep";
|
|
16
|
-
import Xarrow, { useXarrow, Xwrapper } from "react-xarrows";
|
|
17
18
|
class BaseFormElement {
|
|
18
19
|
constructor(options) {
|
|
19
20
|
__publicField(this, "type");
|
|
@@ -104,11 +105,9 @@ class BaseField extends BaseFormElement {
|
|
|
104
105
|
}
|
|
105
106
|
__publicField(BaseField, "fieldTypeName");
|
|
106
107
|
__publicField(BaseField, "fieldTypeDescription");
|
|
107
|
-
const description$1 = "
|
|
108
|
-
const sectionContainer = "_sectionContainer_1se5r_5";
|
|
108
|
+
const description$1 = "_description_17zed_1";
|
|
109
109
|
const styles$3 = {
|
|
110
|
-
description: description$1
|
|
111
|
-
sectionContainer
|
|
110
|
+
description: description$1
|
|
112
111
|
};
|
|
113
112
|
const InputWithLabel = (props) => {
|
|
114
113
|
const { label, children, severity, inputId, labelId, flexProps } = props;
|
|
@@ -2070,8 +2069,12 @@ const FieldBuilder = memo(function FieldBuilder2(props) {
|
|
|
2070
2069
|
return /* @__PURE__ */ jsx(Dialog, { onCloseInterrupt: handleCloseInterrupt, title: title2, description: description2, content: dialogContent, children });
|
|
2071
2070
|
});
|
|
2072
2071
|
const DefaultWrapper = ({ children }) => /* @__PURE__ */ jsx(Fragment, { children });
|
|
2072
|
+
const forMobile = (mobile, display) => ({
|
|
2073
|
+
initial: mobile ? display : "none",
|
|
2074
|
+
sm: mobile ? "none" : display
|
|
2075
|
+
});
|
|
2073
2076
|
const FieldActions = memo(function FieldActions2(props) {
|
|
2074
|
-
const { remove: remove2, editProps, insertAfterProps, duplicateProps
|
|
2077
|
+
const { remove: remove2, dragHandleProps, editProps, insertAfterProps, duplicateProps } = props;
|
|
2075
2078
|
const actions = useMemo(
|
|
2076
2079
|
() => [
|
|
2077
2080
|
{
|
|
@@ -2097,39 +2100,53 @@ const FieldActions = memo(function FieldActions2(props) {
|
|
|
2097
2100
|
Wrapper: FieldBuilder,
|
|
2098
2101
|
wrapperProps: insertAfterProps,
|
|
2099
2102
|
Icon: PlusIcon,
|
|
2100
|
-
text:
|
|
2103
|
+
text: "Add after"
|
|
2104
|
+
},
|
|
2105
|
+
{
|
|
2106
|
+
// Wrapping icon in a div so that the asChild turns the button into a div
|
|
2107
|
+
// so that the drag handle props are not applied to the icon
|
|
2108
|
+
// Note: b/c the <button> does not handle the space-press event correctly
|
|
2109
|
+
Icon: (props2) => /* @__PURE__ */ jsx("div", { ...props2, children: /* @__PURE__ */ jsx(DragHandleDots2Icon, {}) }),
|
|
2110
|
+
text: "Reorder",
|
|
2111
|
+
disableOnMobile: true,
|
|
2112
|
+
buttonProps: { ...dragHandleProps, asChild: true }
|
|
2101
2113
|
}
|
|
2102
2114
|
],
|
|
2103
|
-
[duplicateProps, editProps, insertAfterProps, remove2
|
|
2115
|
+
[dragHandleProps, duplicateProps, editProps, insertAfterProps, remove2]
|
|
2104
2116
|
);
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
var _a;
|
|
2117
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2118
|
+
/* @__PURE__ */ jsx(Flex, { gap: "4", display: forMobile(false, "flex"), children: actions.map((Action) => {
|
|
2108
2119
|
const Wrapper = Action.Wrapper ?? DefaultWrapper;
|
|
2109
|
-
return {
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2120
|
+
return /* @__PURE__ */ jsx(Wrapper, { ...Action.wrapperProps, children: /* @__PURE__ */ jsx(IconButton, { type: "button", variant: "ghost", "aria-label": Action.text, ...Action.buttonProps, children: /* @__PURE__ */ jsx(Action.Icon, {}) }) }, Action.text);
|
|
2121
|
+
}) }),
|
|
2122
|
+
/* @__PURE__ */ jsx(Box, { display: forMobile(true, "block"), children: /* @__PURE__ */ jsx(
|
|
2123
|
+
DropdownItemMenu,
|
|
2124
|
+
{
|
|
2125
|
+
trigger: /* @__PURE__ */ jsx(IconButton, { variant: "ghost", "aria-label": "Actions menu", children: /* @__PURE__ */ jsx(DotsVerticalIcon, {}) }),
|
|
2126
|
+
closeOnSelect: false,
|
|
2127
|
+
items: actions.map((Action) => {
|
|
2128
|
+
var _a;
|
|
2129
|
+
if (Action.disableOnMobile)
|
|
2130
|
+
return null;
|
|
2131
|
+
const Wrapper = Action.Wrapper ?? DefaultWrapper;
|
|
2132
|
+
return {
|
|
2133
|
+
...Action.buttonProps,
|
|
2134
|
+
onSelect: (_a = Action.buttonProps) == null ? void 0 : _a.onClick,
|
|
2135
|
+
content: /* @__PURE__ */ jsx(Wrapper, { ...Action.wrapperProps, children: /* @__PURE__ */ jsxs(Flex, { gap: "2", align: "center", children: [
|
|
2136
|
+
/* @__PURE__ */ jsx(Action.Icon, {}),
|
|
2137
|
+
Action.text
|
|
2138
|
+
] }) })
|
|
2139
|
+
};
|
|
2140
|
+
}).filter((x) => x !== null)
|
|
2141
|
+
}
|
|
2142
|
+
) })
|
|
2143
|
+
] });
|
|
2126
2144
|
});
|
|
2127
2145
|
const formId = "form-builder";
|
|
2128
2146
|
const FieldWithActions = memo(function FieldWithActions2(props) {
|
|
2129
2147
|
const { field, index, sectionIndex, takenLabels, remove: remove2 } = props;
|
|
2130
2148
|
const deserializedField = useMemo(() => deserialize(field), [field]);
|
|
2131
2149
|
const input = useFieldInput(deserializedField, { formId, disabled: true });
|
|
2132
|
-
const updateXarrow = useXarrow();
|
|
2133
2150
|
const duplicateField = useCallback(
|
|
2134
2151
|
(field2) => {
|
|
2135
2152
|
if (field2.label === null) {
|
|
@@ -2170,9 +2187,6 @@ const FieldWithActions = memo(function FieldWithActions2(props) {
|
|
|
2170
2187
|
ref: draggableProvided.innerRef,
|
|
2171
2188
|
...draggableProvided.draggableProps,
|
|
2172
2189
|
...draggableProvided.dragHandleProps,
|
|
2173
|
-
onDrag: updateXarrow,
|
|
2174
|
-
onDragEnd: updateXarrow,
|
|
2175
|
-
id: `${field.identifier}-card`,
|
|
2176
2190
|
mb: "4",
|
|
2177
2191
|
children: /* @__PURE__ */ jsxs(Flex, { gap: "4", justify: "between", align: "center", children: [
|
|
2178
2192
|
input,
|
|
@@ -2182,91 +2196,20 @@ const FieldWithActions = memo(function FieldWithActions2(props) {
|
|
|
2182
2196
|
remove: remove2,
|
|
2183
2197
|
editProps: editFieldProps,
|
|
2184
2198
|
duplicateProps: duplicateFieldProps,
|
|
2185
|
-
insertAfterProps
|
|
2199
|
+
insertAfterProps,
|
|
2200
|
+
dragHandleProps: draggableProvided.dragHandleProps
|
|
2186
2201
|
}
|
|
2187
2202
|
)
|
|
2188
2203
|
] })
|
|
2189
2204
|
}
|
|
2190
2205
|
) });
|
|
2191
2206
|
});
|
|
2192
|
-
const ArrowSpacingDiv = memo(function ArrowSpacingDiv2(props) {
|
|
2193
|
-
const { identifier, index, conditionalFieldCounts } = props;
|
|
2194
|
-
const HORIZONTAL_SPACE = 3;
|
|
2195
|
-
const totalConditionals = conditionalFieldCounts.filter((count) => count !== null).length;
|
|
2196
|
-
const conditionalNum = conditionalFieldCounts[index] ?? 0;
|
|
2197
|
-
const marginLeft = HORIZONTAL_SPACE / totalConditionals * conditionalNum;
|
|
2198
|
-
return /* @__PURE__ */ jsx(
|
|
2199
|
-
"div",
|
|
2200
|
-
{
|
|
2201
|
-
id: `${identifier}-floating-point`,
|
|
2202
|
-
style: {
|
|
2203
|
-
width: `${HORIZONTAL_SPACE - marginLeft}%`,
|
|
2204
|
-
marginLeft: `${marginLeft}%`
|
|
2205
|
-
}
|
|
2206
|
-
}
|
|
2207
|
-
);
|
|
2208
|
-
});
|
|
2209
|
-
const ConditionalArrow = (props) => {
|
|
2210
|
-
const { identifier, condition } = props;
|
|
2211
|
-
const primaryColor = "var(--gray-a4)";
|
|
2212
|
-
const hoverColor = "var(--primary-color)";
|
|
2213
|
-
const [color, setColor] = useState(primaryColor);
|
|
2214
|
-
const [zIndex, setZIndex] = useState(0);
|
|
2215
|
-
const handleMouseEnter = useCallback(() => {
|
|
2216
|
-
setColor(hoverColor);
|
|
2217
|
-
setZIndex(1);
|
|
2218
|
-
}, [hoverColor]);
|
|
2219
|
-
const handleMouseLeave = useCallback(() => {
|
|
2220
|
-
setColor(primaryColor);
|
|
2221
|
-
setZIndex(0);
|
|
2222
|
-
}, [primaryColor]);
|
|
2223
|
-
const settings = useMemo(() => {
|
|
2224
|
-
return {
|
|
2225
|
-
strokeWidth: 1,
|
|
2226
|
-
showHead: false,
|
|
2227
|
-
color,
|
|
2228
|
-
zIndex,
|
|
2229
|
-
arrowBodyProps: {
|
|
2230
|
-
onMouseEnter: handleMouseEnter,
|
|
2231
|
-
onMouseLeave: handleMouseLeave
|
|
2232
|
-
}
|
|
2233
|
-
};
|
|
2234
|
-
}, [color, handleMouseEnter, handleMouseLeave, zIndex]);
|
|
2235
|
-
if (!condition)
|
|
2236
|
-
return null;
|
|
2237
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2238
|
-
/* @__PURE__ */ jsx(
|
|
2239
|
-
Xarrow,
|
|
2240
|
-
{
|
|
2241
|
-
start: `${identifier}-card`,
|
|
2242
|
-
end: `${identifier}-floating-point`,
|
|
2243
|
-
startAnchor: "right",
|
|
2244
|
-
endAnchor: "left",
|
|
2245
|
-
path: "straight",
|
|
2246
|
-
...settings
|
|
2247
|
-
}
|
|
2248
|
-
),
|
|
2249
|
-
/* @__PURE__ */ jsx(
|
|
2250
|
-
Xarrow,
|
|
2251
|
-
{
|
|
2252
|
-
start: `${identifier}-floating-point`,
|
|
2253
|
-
end: `${condition.identifier}-card`,
|
|
2254
|
-
startAnchor: "left",
|
|
2255
|
-
endAnchor: "right",
|
|
2256
|
-
path: "grid",
|
|
2257
|
-
gridBreak: "0",
|
|
2258
|
-
...settings
|
|
2259
|
-
}
|
|
2260
|
-
)
|
|
2261
|
-
] });
|
|
2262
|
-
};
|
|
2263
2207
|
const FieldSectionWithActions = memo(function FieldSectionWithActions2(props) {
|
|
2264
2208
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
2265
|
-
const { field, index: sectionIndex, dropState
|
|
2209
|
+
const { field, index: sectionIndex, dropState } = props;
|
|
2266
2210
|
const isDropDisabled = (_a = dropState[field.identifier]) == null ? void 0 : _a.disabled;
|
|
2267
2211
|
const { setFieldValue, values } = useFormikContext();
|
|
2268
2212
|
const alertDialog = useAlertDialog();
|
|
2269
|
-
const updateXarrow = useXarrow();
|
|
2270
2213
|
const takenFieldLabels = getTakenFieldLabels(values.fields);
|
|
2271
2214
|
const removeSectionConditions = useCallback(
|
|
2272
2215
|
(sectionsToUpdate, allSections) => {
|
|
@@ -2416,98 +2359,66 @@ const FieldSectionWithActions = memo(function FieldSectionWithActions2(props) {
|
|
|
2416
2359
|
if (valueIsFile((_d = field.condition) == null ? void 0 : _d.value))
|
|
2417
2360
|
throw new Error("File values are not supported for conditions.");
|
|
2418
2361
|
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();
|
|
2419
|
-
return /* @__PURE__ */ jsx(Draggable, { draggableId: field.identifier, index: sectionIndex, children: (draggableProvided) => /* @__PURE__ */
|
|
2420
|
-
|
|
2362
|
+
return /* @__PURE__ */ jsx(Draggable, { draggableId: field.identifier, index: sectionIndex, children: (draggableProvided) => /* @__PURE__ */ jsx(
|
|
2363
|
+
Card,
|
|
2421
2364
|
{
|
|
2422
|
-
className: styles$3.sectionContainer,
|
|
2423
2365
|
ref: draggableProvided.innerRef,
|
|
2424
2366
|
...draggableProvided.draggableProps,
|
|
2425
|
-
|
|
2426
|
-
justify: "center",
|
|
2427
|
-
align: "center",
|
|
2367
|
+
...draggableProvided.dragHandleProps,
|
|
2428
2368
|
mb: "4",
|
|
2429
|
-
children: [
|
|
2430
|
-
/* @__PURE__ */
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
Droppable,
|
|
2369
|
+
children: /* @__PURE__ */ jsxs(Flex, { gap: "3", justify: "between", align: "center", children: [
|
|
2370
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "2", grow: "1", children: [
|
|
2371
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", children: [
|
|
2372
|
+
/* @__PURE__ */ jsx(Heading, { as: "h3", size: "3", children: field.label }),
|
|
2373
|
+
/* @__PURE__ */ jsx(Text, { className: styles$3.description, children: field.description })
|
|
2374
|
+
] }),
|
|
2375
|
+
field.condition && /* @__PURE__ */ jsx(Text, { size: "1", children: /* @__PURE__ */ jsxs(Em, { children: [
|
|
2376
|
+
"Display only if ",
|
|
2377
|
+
/* @__PURE__ */ jsx(Strong, { children: conditionLabel }),
|
|
2378
|
+
" ",
|
|
2379
|
+
conditionComparison,
|
|
2380
|
+
" ",
|
|
2381
|
+
/* @__PURE__ */ jsx(Strong, { children: conditionValue })
|
|
2382
|
+
] }) }),
|
|
2383
|
+
/* @__PURE__ */ jsx(Droppable, { droppableId: field.identifier, type: "SECTION", isDropDisabled, children: (droppableProvided) => /* @__PURE__ */ jsxs(
|
|
2384
|
+
Flex,
|
|
2385
|
+
{
|
|
2386
|
+
ref: droppableProvided.innerRef,
|
|
2387
|
+
...droppableProvided.droppableProps,
|
|
2388
|
+
direction: "column",
|
|
2389
|
+
gap: "0",
|
|
2390
|
+
children: [
|
|
2391
|
+
field.fields.map((child, i) => /* @__PURE__ */ jsx(
|
|
2392
|
+
FieldWithActions,
|
|
2454
2393
|
{
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
},
|
|
2475
|
-
child.identifier
|
|
2476
|
-
)),
|
|
2477
|
-
droppableProvided.placeholder,
|
|
2478
|
-
/* @__PURE__ */ jsx(FieldBuilder, { ...insertFieldAtEndOfSection, children: /* @__PURE__ */ jsxs(Button, { type: "button", variant: "outline", children: [
|
|
2479
|
-
/* @__PURE__ */ jsx(PlusIcon, {}),
|
|
2480
|
-
" Add a field"
|
|
2481
|
-
] }) })
|
|
2482
|
-
]
|
|
2483
|
-
}
|
|
2484
|
-
)
|
|
2485
|
-
}
|
|
2486
|
-
)
|
|
2487
|
-
] }),
|
|
2488
|
-
/* @__PURE__ */ jsx(
|
|
2489
|
-
FieldActions,
|
|
2490
|
-
{
|
|
2491
|
-
remove: removeSection,
|
|
2492
|
-
insertAfterProps: insertSectionProps,
|
|
2493
|
-
editProps: editSectionProps,
|
|
2494
|
-
duplicateProps: duplicateSectionProps,
|
|
2495
|
-
type: "section"
|
|
2496
|
-
}
|
|
2497
|
-
)
|
|
2498
|
-
] })
|
|
2499
|
-
}
|
|
2500
|
-
),
|
|
2501
|
-
conditionalFieldCounts.some((count) => count !== null) && /* @__PURE__ */ jsx(
|
|
2502
|
-
ArrowSpacingDiv,
|
|
2394
|
+
field: child,
|
|
2395
|
+
index: i,
|
|
2396
|
+
sectionIndex,
|
|
2397
|
+
remove: () => removeField(i),
|
|
2398
|
+
takenLabels: takenFieldLabels
|
|
2399
|
+
},
|
|
2400
|
+
child.identifier
|
|
2401
|
+
)),
|
|
2402
|
+
droppableProvided.placeholder,
|
|
2403
|
+
/* @__PURE__ */ jsx(FieldBuilder, { ...insertFieldAtEndOfSection, children: /* @__PURE__ */ jsxs(Button, { type: "button", variant: "outline", children: [
|
|
2404
|
+
/* @__PURE__ */ jsx(PlusIcon, {}),
|
|
2405
|
+
" Add a field"
|
|
2406
|
+
] }) })
|
|
2407
|
+
]
|
|
2408
|
+
}
|
|
2409
|
+
) })
|
|
2410
|
+
] }),
|
|
2411
|
+
/* @__PURE__ */ jsx(
|
|
2412
|
+
FieldActions,
|
|
2503
2413
|
{
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2414
|
+
remove: removeSection,
|
|
2415
|
+
insertAfterProps: insertSectionProps,
|
|
2416
|
+
dragHandleProps: draggableProvided.dragHandleProps,
|
|
2417
|
+
editProps: editSectionProps,
|
|
2418
|
+
duplicateProps: duplicateSectionProps
|
|
2507
2419
|
}
|
|
2508
|
-
)
|
|
2509
|
-
|
|
2510
|
-
]
|
|
2420
|
+
)
|
|
2421
|
+
] })
|
|
2511
2422
|
}
|
|
2512
2423
|
) });
|
|
2513
2424
|
});
|
|
@@ -2644,12 +2555,6 @@ const FieldsEditor = memo(function FieldsEditor2() {
|
|
|
2644
2555
|
}),
|
|
2645
2556
|
[values.fields]
|
|
2646
2557
|
);
|
|
2647
|
-
const conditionalFieldCounts = () => {
|
|
2648
|
-
let conditionalCount = 1;
|
|
2649
|
-
return values.fields.map((field) => {
|
|
2650
|
-
return field.conditional ? conditionalCount++ : null;
|
|
2651
|
-
});
|
|
2652
|
-
};
|
|
2653
2558
|
return /* @__PURE__ */ jsx(DragDropContext, { onDragStart: handleDragStart, onDragEnd: handleDragEnd, children: /* @__PURE__ */ jsx(Droppable, { droppableId: "droppable", type: "ROOT", children: (droppableProvided) => /* @__PURE__ */ jsxs(
|
|
2654
2559
|
Flex,
|
|
2655
2560
|
{
|
|
@@ -2658,19 +2563,16 @@ const FieldsEditor = memo(function FieldsEditor2() {
|
|
|
2658
2563
|
direction: "column",
|
|
2659
2564
|
gap: "0",
|
|
2660
2565
|
children: [
|
|
2661
|
-
/* @__PURE__ */
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
)),
|
|
2672
|
-
droppableProvided.placeholder
|
|
2673
|
-
] }),
|
|
2566
|
+
values.fields.map((field, index) => /* @__PURE__ */ jsx(
|
|
2567
|
+
FieldSectionWithActions,
|
|
2568
|
+
{
|
|
2569
|
+
field,
|
|
2570
|
+
index,
|
|
2571
|
+
dropState
|
|
2572
|
+
},
|
|
2573
|
+
field.label
|
|
2574
|
+
)),
|
|
2575
|
+
droppableProvided.placeholder,
|
|
2674
2576
|
/* @__PURE__ */ jsx(FieldBuilder, { ...makeFieldSectionProps, children: /* @__PURE__ */ jsxs(Button, { type: "button", variant: "outline", children: [
|
|
2675
2577
|
/* @__PURE__ */ jsx(PlusIcon, {}),
|
|
2676
2578
|
" Add a section"
|