|
|
|
@ -3,20 +3,24 @@ import { |
|
|
|
|
checkboxClasses, |
|
|
|
|
FormControl, |
|
|
|
|
FormControlLabel, |
|
|
|
|
inputClasses, |
|
|
|
|
FormGroup, |
|
|
|
|
InputLabel, |
|
|
|
|
inputLabelClasses, |
|
|
|
|
MenuItem, |
|
|
|
|
OutlinedInput, |
|
|
|
|
outlinedInputClasses, |
|
|
|
|
Select, |
|
|
|
|
selectClasses, |
|
|
|
|
styled, |
|
|
|
|
TextField, |
|
|
|
|
} from '@mui/material'; |
|
|
|
|
import { |
|
|
|
|
Sync as SyncIcon, |
|
|
|
|
SyncDisabled as SyncDisabledIcon, |
|
|
|
|
} from '@mui/icons-material'; |
|
|
|
|
import { v4 as uuidv4 } from 'uuid'; |
|
|
|
|
|
|
|
|
|
import { |
|
|
|
|
BLACK, |
|
|
|
|
BLUE, |
|
|
|
|
BORDER_RADIUS, |
|
|
|
|
GREY, |
|
|
|
@ -37,19 +41,18 @@ const FILE_INFO_DEFAULT_PROPS: Partial<FileInfoProps> = { |
|
|
|
|
onChange: undefined, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const StyledTextField = styled(TextField)({ |
|
|
|
|
[`& .${inputLabelClasses.root}`]: { |
|
|
|
|
const StyledInputLabel = styled(InputLabel)({ |
|
|
|
|
color: GREY, |
|
|
|
|
|
|
|
|
|
[`&.${inputClasses.focused}`]: { |
|
|
|
|
backgroundColor: BLUE, |
|
|
|
|
[`&.${inputLabelClasses.focused}`]: { |
|
|
|
|
backgroundColor: GREY, |
|
|
|
|
borderRadius: BORDER_RADIUS, |
|
|
|
|
color: TEXT, |
|
|
|
|
color: BLACK, |
|
|
|
|
padding: '.1em .6em', |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
[`& .${outlinedInputClasses.root}`]: { |
|
|
|
|
const StyledOutlinedInput = styled(OutlinedInput)({ |
|
|
|
|
color: GREY, |
|
|
|
|
|
|
|
|
|
[`& .${outlinedInputClasses.notchedOutline}`]: { |
|
|
|
@ -62,17 +65,22 @@ const StyledTextField = styled(TextField)({ |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
[`&.${inputClasses.focused}`]: { |
|
|
|
|
[`&.${outlinedInputClasses.focused}`]: { |
|
|
|
|
color: TEXT, |
|
|
|
|
|
|
|
|
|
[`& .${outlinedInputClasses.notchedOutline}`]: { |
|
|
|
|
borderColor: BLUE, |
|
|
|
|
borderColor: GREY, |
|
|
|
|
|
|
|
|
|
'& legend': { |
|
|
|
|
paddingRight: '1.2em', |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const StyledSelect = styled(Select)({ |
|
|
|
|
[`& .${selectClasses.icon}`]: { |
|
|
|
|
color: GREY, |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
@ -93,27 +101,43 @@ const FileInfo = ( |
|
|
|
|
onChange, |
|
|
|
|
}: FileInfoProps = FILE_INFO_DEFAULT_PROPS as FileInfoProps, |
|
|
|
|
): JSX.Element => { |
|
|
|
|
const idExtension = uuidv4(); |
|
|
|
|
|
|
|
|
|
const fileNameElementId = `file-name-${idExtension}`; |
|
|
|
|
const fileNameElementLabel = 'File name'; |
|
|
|
|
|
|
|
|
|
const fileTypeElementId = `file-type-${idExtension}`; |
|
|
|
|
const fileTypeElementLabel = 'File type'; |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<FormGroup sx={{ '> :not(:first-child)': { marginTop: '1em' } }}> |
|
|
|
|
<FormControl> |
|
|
|
|
<StyledTextField |
|
|
|
|
<StyledInputLabel htmlFor={fileNameElementId} variant="outlined"> |
|
|
|
|
{fileNameElementLabel} |
|
|
|
|
</StyledInputLabel> |
|
|
|
|
<StyledOutlinedInput |
|
|
|
|
defaultValue={fileName} |
|
|
|
|
disabled={isReadonly} |
|
|
|
|
id="file-name" |
|
|
|
|
label="File name" |
|
|
|
|
id={fileNameElementId} |
|
|
|
|
label={fileNameElementLabel} |
|
|
|
|
onChange={({ target: { value } }) => |
|
|
|
|
onChange?.call(null, { fileName: value }) |
|
|
|
|
} |
|
|
|
|
/> |
|
|
|
|
</FormControl> |
|
|
|
|
{fileType && ( |
|
|
|
|
<Select |
|
|
|
|
<FormControl> |
|
|
|
|
<StyledInputLabel htmlFor={fileTypeElementId} variant="outlined"> |
|
|
|
|
{fileTypeElementLabel} |
|
|
|
|
</StyledInputLabel> |
|
|
|
|
<StyledSelect |
|
|
|
|
defaultValue={fileType} |
|
|
|
|
disabled={isReadonly} |
|
|
|
|
id="file-type" |
|
|
|
|
label="File type" |
|
|
|
|
id={fileTypeElementId} |
|
|
|
|
input={<StyledOutlinedInput label={fileTypeElementLabel} />} |
|
|
|
|
onChange={({ target: { value } }) => |
|
|
|
|
onChange?.call(null, { fileType: value as FileType }) |
|
|
|
|
} |
|
|
|
|
sx={{ color: TEXT }} |
|
|
|
|
> |
|
|
|
|
{UPLOAD_FILE_TYPES_ARRAY.map( |
|
|
|
|
([fileTypeKey, [, fileTypeDisplayString]]) => { |
|
|
|
@ -124,7 +148,8 @@ const FileInfo = ( |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
)} |
|
|
|
|
</Select> |
|
|
|
|
</StyledSelect> |
|
|
|
|
</FormControl> |
|
|
|
|
)} |
|
|
|
|
{fileLocations.map( |
|
|
|
|
( |
|
|
|
@ -154,7 +179,7 @@ const FileInfo = ( |
|
|
|
|
/> |
|
|
|
|
), |
|
|
|
|
)} |
|
|
|
|
</FormControl> |
|
|
|
|
</FormGroup> |
|
|
|
|
); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|