-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathFilePathInput.tsx
46 lines (42 loc) · 1.38 KB
/
FilePathInput.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// SPDX-FileCopyrightText: Meta Platforms, Inc. and its affiliates
// SPDX-FileCopyrightText: TNG Technology Consulting GmbH <https://www.tngtech.com>
//
// SPDX-License-Identifier: Apache-2.0
import { AttachFile } from '@mui/icons-material';
import { TooltipProps } from '@mui/material/Tooltip';
import MuiTypography from '@mui/material/Typography';
import { baseIcon } from '../../shared-styles';
import { TextBox, TextBoxCustomInputProps } from '../TextBox/TextBox';
const CustomInput: React.FC<TextBoxCustomInputProps> = (props) => {
return (
<MuiTypography
sx={{ ...props.sx, whiteSpace: 'nowrap', userSelect: 'none' }}
aria-label={props['aria-label']}
>
{props.value}
</MuiTypography>
);
};
interface FilePathInputProps {
label: string;
text: string;
onClick: () => void;
tooltipProps?: Partial<TooltipProps>;
}
export const FilePathInput: React.FC<FilePathInputProps> = (props) => {
return (
<TextBox
title={props.label}
text={props.text}
onClick={props.onClick}
startIcon={<AttachFile sx={baseIcon} />}
cursor={'pointer'}
showTooltip={true}
tooltipProps={props.tooltipProps}
// using a custom input component allows us to disable a lot of TextField
// behavior (e.g. horizontal text scrolling) that we don't want here
inputComponent={CustomInput}
sx={{ marginTop: '20px' }}
/>
);
};