519c411db0
* feat: sync and update with all changes from fork * refactor: extract clipboard copy logic into custom hook * fix: correct spelling of DEFAULT_REFRESH_FREQUENCY_MS in Stamps and WalletBalance providers * refactor(ui-tests): replace fixed sleeps with condition-based waits * fix: handle null values for size and granteeCount in infoGroups * fix(lint): add newline at end of file in useClipboardCopy hook * fix(ui-tests): page.goto URL * refactor: update import paths for useClipboardCopy --------- Co-authored-by: Ferenc Sárai <sarai.ferenc@gmail.com>
81 lines
1.7 KiB
TypeScript
81 lines
1.7 KiB
TypeScript
import { TextField as SimpleTextField } from '@mui/material'
|
|
import { Field } from 'formik'
|
|
import { TextField } from 'formik-mui'
|
|
import { ChangeEvent, ReactElement } from 'react'
|
|
import { makeStyles } from 'tss-react/mui'
|
|
|
|
interface Props {
|
|
name: string
|
|
label: string
|
|
password?: boolean
|
|
formik?: boolean
|
|
optional?: boolean
|
|
defaultValue?: string
|
|
placeholder?: string
|
|
onChange?: (event: ChangeEvent<HTMLTextAreaElement>) => void
|
|
}
|
|
|
|
const useStyles = makeStyles()(theme => ({
|
|
field: {
|
|
background: theme.palette.background.paper,
|
|
'& fieldset': {
|
|
border: 0,
|
|
},
|
|
'& .Mui-focused': {
|
|
background: theme.palette.background.paper,
|
|
},
|
|
'& .MuiInputBase-root': {
|
|
background: theme.palette.background.paper,
|
|
},
|
|
'& .MuiFilledInput-root': {
|
|
borderRadius: 0,
|
|
},
|
|
},
|
|
}))
|
|
|
|
export function SwarmTextInput({
|
|
name,
|
|
label,
|
|
password,
|
|
optional,
|
|
formik,
|
|
onChange,
|
|
defaultValue,
|
|
placeholder,
|
|
}: Props): ReactElement {
|
|
const { classes } = useStyles()
|
|
|
|
if (formik) {
|
|
return (
|
|
<Field
|
|
component={TextField}
|
|
type={password ? 'password' : undefined}
|
|
required={!optional}
|
|
name={name}
|
|
label={label}
|
|
fullWidth
|
|
variant="filled"
|
|
className={classes.field}
|
|
defaultValue={defaultValue || ''}
|
|
InputProps={{ disableUnderline: true }}
|
|
placeholder={placeholder}
|
|
/>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<SimpleTextField
|
|
type={password ? 'password' : undefined}
|
|
required
|
|
label={label}
|
|
fullWidth
|
|
variant="filled"
|
|
className={classes.field}
|
|
defaultValue={defaultValue || ''}
|
|
onChange={onChange}
|
|
InputProps={{ disableUnderline: true }}
|
|
placeholder={placeholder}
|
|
/>
|
|
)
|
|
}
|