import * as React from "react";
// import ReactJson from "react-json-view";
import { EditorMode } from "@sc/modules/v2/Editor/types";
import { fieldset } from "@sc/components/ui/theme";
import { EditFormFieldProps } from "./types";
import SelectFieldType from "./SelectFieldType";
import { FormFieldTypes } from "../types";
import {
Checkboxes,
ContentField,
DateField,
DropdownField,
FileUpload,
LinearScaleField,
MultipleChoice,
TextAreaField,
TextField,
} from "../FormFields";
import LiveFormField from "../LiveFormField";
const Wrapper: React.FC<{
style?: React.CSSProperties;
children: React.ReactNode;
}> = ({ style = {}, children }) => {
return
{children}
;
};
/**
* This is the container to use as the sortable item in the SortableList Component
*
* - Used for managing the editing of individual form fields
* - It's the element that gets dragged up and down
* - Shows a dropdown for selecting the type of form field you want to edit
* - Then the appropriate form field component is displayed in "edit" mode
*/
const EditFormField: React.FC = (props) => {
const {
type,
preset,
fieldData,
showPreview,
showFieldset = false,
isExpanded = false,
caption,
globalFieldStyle = {
containerStyle: {},
},
onChange = () => {},
onBlur = () => {},
onTypeChange = () => {},
// onClick,
items,
} = props;
/**
* Performs any cleanups/combining of data (if any) before triggering the onChange event
* @params
*/
const handleChange = (data): void => {
onChange(data);
};
const { containerStyle } = globalFieldStyle;
const SFT = (
);
const LFF = ;
const FS = (
<>
{isExpanded &&
(type === FormFieldTypes.TEXT ||
type === FormFieldTypes.PASSWORD ||
type === FormFieldTypes.NUMBER ||
type === FormFieldTypes.CURRENCY) && (
)}
{isExpanded && type === FormFieldTypes.DATE && (
)}
{isExpanded &&
(type === FormFieldTypes.SELECT ||
type === FormFieldTypes.DROPDOWN) && (
)}
{isExpanded && type === FormFieldTypes.TEXTAREA && (
)}
{isExpanded && type === FormFieldTypes.CHECKBOXES && (
)}
{isExpanded && type === FormFieldTypes.MULTIPLECHOICE && (
)}
{isExpanded &&
(type === FormFieldTypes.CONTENT ||
type === FormFieldTypes.TYPOGRAPHY) && (
)}
{isExpanded && type === FormFieldTypes.FILEUPLOAD && (
)}
{isExpanded && type === FormFieldTypes.LINEARSCALE && (
)}
>
);
return (
{showFieldset ? (
<>
{isExpanded && showPreview && (
)}
>
) : (
<>
{SFT}
{isExpanded && showPreview && LFF}
{FS}
>
)}
);
};
export default EditFormField;