import * as React from "react";
import { get } from "lodash";
import styled from "styled-components";
import { EditorMode } from "@sc/modules/v2/Editor/types";
import { LiveFormFieldProps, SProps } from "./types";
import { FormFieldTypes } from "../types";
// import Icon from "@sc/plugins/webcomponents/v2/Icon";
import {
Checkboxes,
ContentField,
DateField,
DropdownField,
FileUpload,
LinearScaleField,
MultipleChoice,
TextAreaField,
TextField,
} from "../FormFields";
import { Grid } from "@material-ui/core";
const Wrapper: React.FC<{
style?: React.CSSProperties;
children: React.ReactNode;
columns?: number;
}> = ({ style = {}, children, columns = 12 }) => {
return (
{children}
);
};
/**
* A component that loads the live version of the individual form field
*
* This is what shows in the real web page (or editor canvas with overlay turned on)
*/
const LiveFormField: React.FC = (props) => {
const {
type,
name,
placeholder,
items,
label,
description,
defaultValue,
styles = {
labelStyle: {},
inputStyle: {},
containerStyle: {},
descriptionStyle: {},
validationStyle: {},
iconStyle: {},
},
disabled,
icon,
columns,
onChange = () => null,
onBlur,
onKeyUp,
onClick,
children,
} = props;
/**
* Deal with any changes that come from the various form fields that I loads
* @params
*/
const handleChange = (): void => {
onChange();
};
// const {
// labelStyle,
// inputStyle,
// containerStyle,
// descriptionStyle,
// validationStyle,
// iconStyle,
// } = styles;
if (
type === FormFieldTypes.TEXT ||
type === FormFieldTypes.PASSWORD ||
type === FormFieldTypes.NUMBER ||
type === FormFieldTypes.CURRENCY
) {
return (
);
}
if (type === FormFieldTypes.DATE) {
return (
);
}
if (type === FormFieldTypes.SELECT || type === FormFieldTypes.DROPDOWN) {
return (
);
}
if (type === FormFieldTypes.TEXTAREA) {
return (
);
}
if (type === FormFieldTypes.CHECKBOXES) {
return (
);
}
if (type === FormFieldTypes.MULTIPLECHOICE) {
return (
);
}
if (type === FormFieldTypes.CONTENT || type === FormFieldTypes.TYPOGRAPHY) {
return (
);
}
if (type === FormFieldTypes.FILEUPLOAD) {
return (
);
}
if (type === FormFieldTypes.LINEARSCALE) {
return (
);
}
return {children};
};
export default LiveFormField;