refactor(web): remove typescript
This commit is contained in:
@@ -1,40 +1,22 @@
|
||||
import * as React from 'react';
|
||||
import { Controller, useFormContext } from 'react-hook-form';
|
||||
import MuiTextField, {
|
||||
TextFieldProps as MuiTextFieldProps,
|
||||
} from '@mui/material/TextField';
|
||||
import MuiTextField from '@mui/material/TextField';
|
||||
import IconButton from '@mui/material/IconButton';
|
||||
import InputAdornment from '@mui/material/InputAdornment';
|
||||
import ContentCopyIcon from '@mui/icons-material/ContentCopy';
|
||||
|
||||
import copyInputValue from 'helpers/copyInputValue';
|
||||
|
||||
type TextFieldProps = {
|
||||
shouldUnregister?: boolean;
|
||||
name: string;
|
||||
clickToCopy?: boolean;
|
||||
readOnly?: boolean;
|
||||
'data-test'?: string;
|
||||
} & MuiTextFieldProps;
|
||||
|
||||
const createCopyAdornment = (
|
||||
ref: React.RefObject<HTMLInputElement | null>
|
||||
): React.ReactElement => {
|
||||
const createCopyAdornment = (ref) => {
|
||||
return (
|
||||
<InputAdornment position="end">
|
||||
<IconButton
|
||||
onClick={() => copyInputValue(ref.current as HTMLInputElement)}
|
||||
edge="end"
|
||||
>
|
||||
<IconButton onClick={() => copyInputValue(ref.current)} edge="end">
|
||||
<ContentCopyIcon color="primary" />
|
||||
</IconButton>
|
||||
</InputAdornment>
|
||||
);
|
||||
};
|
||||
|
||||
export default function TextField(props: TextFieldProps): React.ReactElement {
|
||||
export default function TextField(props) {
|
||||
const { control } = useFormContext();
|
||||
const inputRef = React.useRef<HTMLInputElement | null>(null);
|
||||
const inputRef = React.useRef(null);
|
||||
const {
|
||||
required,
|
||||
name,
|
||||
@@ -48,7 +30,6 @@ export default function TextField(props: TextFieldProps): React.ReactElement {
|
||||
'data-test': dataTest,
|
||||
...textFieldProps
|
||||
} = props;
|
||||
|
||||
return (
|
||||
<Controller
|
||||
rules={{ required }}
|
Reference in New Issue
Block a user