import * as React from "react"; import TextField from "@material-ui/core/TextField"; // import { AlloyEditor } from "alloyeditor"; import RichEditor from "@sc/modules/v2/Editor/components/RichEditor"; import { InitialValueProps } from "../types"; // import { FormFieldTypes } from "../../types"; import { FormFieldTypes } from "@sc/modules/v2/CRUD/FormBuilder/types"; import styles from "@sc/modules/v2/CRUD/FormBuilder/styles"; /** * A component for collecting the initial value to use for the specific form field */ const InitialValue: React.FC = ({ onChange = () => null, onBlur = () => null, value, fieldType = FormFieldTypes.TEXT, label, }) => { let inputRef = React.useRef(null); // React.useEffect(() => { // setTimeout(() => { // inputRef.current.focus(); // }, 50); // }, []); switch (fieldType) { case FormFieldTypes.TEXT: { return ( onChange(e.target.value)} onBlur={(e) => onBlur(e.target.value)} onClick={(e) => e.stopPropagation()} defaultValue={value} value={value} style={styles.input} variant="filled" label={label || "Initial Value"} inputRef={inputRef} /> ); } case FormFieldTypes.CONTENT: { return (

Apollo 11 was the spaceflight that landed the first humans, Americans{" "} Neil Armstrong and Buzz Aldrin , on the Moon on July 20, 1969, at 20:18 UTC. Armstrong became the first to step onto the lunar surface 6 hours later on July 21 at 02:56 UTC.

); } case FormFieldTypes.DATE: { return ( onChange(e.target.value)} onBlur={(e) => onBlur(e.target.value)} onClick={(e) => e.stopPropagation()} style={styles.input} label={label || "Initial Value"} inputRef={inputRef} /> ); } } }; export default InitialValue;