2022-02-02 13:49:02 +01:00
|
|
|
// @flow
|
|
|
|
import * as ICONS from 'constants/icons';
|
|
|
|
import React from 'react';
|
|
|
|
import TextField from '@mui/material/TextField';
|
|
|
|
import Button from 'component/button';
|
|
|
|
import Zoom from '@mui/material/Zoom';
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
params: any,
|
|
|
|
messageValue: string,
|
|
|
|
inputDefaultProps: any,
|
|
|
|
inputRef: any,
|
2022-02-04 21:59:11 +01:00
|
|
|
submitButtonRef?: any,
|
|
|
|
claimIsMine?: boolean,
|
2022-02-07 20:30:42 +01:00
|
|
|
slimInput?: boolean,
|
2022-02-04 21:59:11 +01:00
|
|
|
toggleSelectors: () => any,
|
2022-02-02 13:49:02 +01:00
|
|
|
handleTip: (isLBC: boolean) => void,
|
|
|
|
handleSubmit: () => any,
|
2022-02-04 21:59:11 +01:00
|
|
|
handlePreventClick?: () => void,
|
2022-02-02 13:49:02 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
const TextareaSuggestionsInput = (props: Props) => {
|
2022-02-04 21:59:11 +01:00
|
|
|
const {
|
|
|
|
params,
|
|
|
|
messageValue,
|
|
|
|
inputRef,
|
|
|
|
inputDefaultProps,
|
|
|
|
submitButtonRef,
|
|
|
|
claimIsMine,
|
2022-02-07 20:30:42 +01:00
|
|
|
slimInput,
|
2022-02-04 21:59:11 +01:00
|
|
|
toggleSelectors,
|
|
|
|
handleTip,
|
|
|
|
handleSubmit,
|
|
|
|
handlePreventClick,
|
|
|
|
} = props;
|
2022-02-02 13:49:02 +01:00
|
|
|
|
|
|
|
const { InputProps, disabled, fullWidth, id, inputProps: autocompleteInputProps } = params;
|
|
|
|
const inputProps = { ...autocompleteInputProps, ...inputDefaultProps };
|
|
|
|
const autocompleteProps = { InputProps, disabled, fullWidth, id, inputProps };
|
|
|
|
|
2022-02-07 20:30:42 +01:00
|
|
|
if (slimInput) {
|
2022-02-04 21:59:11 +01:00
|
|
|
InputProps.startAdornment = (
|
|
|
|
<Button
|
|
|
|
icon={ICONS.STICKER}
|
|
|
|
onClick={() => {
|
|
|
|
if (handlePreventClick) handlePreventClick();
|
|
|
|
toggleSelectors();
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
2022-02-02 13:49:02 +01:00
|
|
|
InputProps.endAdornment = (
|
|
|
|
<>
|
2022-02-04 21:59:11 +01:00
|
|
|
{!claimIsMine && (
|
|
|
|
<Button
|
|
|
|
disabled={!messageValue || messageValue.length === 0}
|
|
|
|
icon={ICONS.LBC}
|
|
|
|
onClick={() => handleTip(true)}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{!claimIsMine && (
|
|
|
|
<Button
|
|
|
|
disabled={!messageValue || messageValue.length === 0}
|
|
|
|
icon={ICONS.FINANCE}
|
|
|
|
onClick={() => handleTip(false)}
|
|
|
|
/>
|
|
|
|
)}
|
2022-02-02 13:49:02 +01:00
|
|
|
|
2022-02-04 21:59:11 +01:00
|
|
|
<Zoom in={messageValue ? messageValue.length > 0 : undefined} mountOnEnter unmountOnExit>
|
2022-02-02 13:49:02 +01:00
|
|
|
<div>
|
2022-02-04 21:59:11 +01:00
|
|
|
<Button
|
|
|
|
ref={submitButtonRef}
|
|
|
|
button="primary"
|
|
|
|
icon={ICONS.SUBMIT}
|
|
|
|
iconColor="red"
|
|
|
|
onClick={() => handleSubmit()}
|
|
|
|
/>
|
2022-02-02 13:49:02 +01:00
|
|
|
</div>
|
|
|
|
</Zoom>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<TextField inputRef={inputRef} variant="outlined" multiline minRows={1} select={false} {...autocompleteProps} />
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return <TextField inputRef={inputRef} multiline select={false} {...autocompleteProps} />;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default TextareaSuggestionsInput;
|