import * as React from "react"; import styled from "styled-components"; import { get } from "lodash"; import { Grid } from "@material-ui/core"; import { FileUploadProps } from "../types"; import { EditorMode } from "../../../../Editor/types"; import { AttributeContainer } from "@sc/modules/v2/CRUD/AttributeBuilder"; import { AttributeNames } from "@sc/modules/v2/CRUD/AttributeBuilder/types"; import { LiveFormFieldProps } from "../../LiveFormField/types"; /** * A component that shows a LIVE file upload field or tools for configuring the file upload's look, feel, and behavior */ const FileUpload: React.FC = (props) => { const { mode = EditorMode.LIVE, onChange = () => null, styles = { labelStyle: {}, descriptionStyle: {}, inputStyle: {}, containerStyle: {}, validationStyle: {}, iconStyle: {}, }, name, label, description, defaultValue, disabled, icon, columns = 12, attributeContainerDataSettings = {}, } = props; /** * Deals with any changes that comes from the various attributes that are loaded * * - Converts to LiveFormFieldProps shape * - Triggers (and passes along the mutated LiveFormFieldProps payload to) the onChange event */ const handleChange = (data: LiveFormFieldProps): void => { onChange(data); }; const { iconStyle = {}, descriptionStyle = {}, containerStyle = {}, inputStyle = {}, validationStyle = {}, labelStyle = {}, } = styles; return (
{mode === EditorMode.LIVE && ( {label &&
{label}
} {description &&
{description}
}
)} {mode === EditorMode.EDITOR && (
)}
); }; export default FileUpload;