import { useState } from 'react'
import PropTypes from 'prop-types'
import { FormControl, OutlinedInput } from '@mui/material'
import EditPromptValuesDialog from 'ui-component/dialog/EditPromptValuesDialog'
export const Input = ({ inputParam, value, onChange, disabled = false, showDialog, dialogProps, onDialogCancel, onDialogConfirm }) => {
const [myValue, setMyValue] = useState(value ?? '')
const getInputType = (type) => {
switch (type) {
case 'string':
return 'text'
case 'password':
return 'password'
case 'number':
return 'number'
default:
return 'text'
}
}
return (
<>
{
setMyValue(e.target.value)
onChange(e.target.value)
}}
inputProps={{
style: {
height: inputParam.rows ? '90px' : 'inherit'
}
}}
/>
{showDialog && (
{
setMyValue(newValue)
onDialogConfirm(newValue, inputParamName)
}}
>
)}
>
)
}
Input.propTypes = {
inputParam: PropTypes.object,
value: PropTypes.string,
onChange: PropTypes.func,
disabled: PropTypes.bool,
showDialog: PropTypes.bool,
dialogProps: PropTypes.object,
onDialogCancel: PropTypes.func,
onDialogConfirm: PropTypes.func
}