/* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { WidgetProps } from '@rjsf/utils'; import React from 'react'; import { StyledCodeTextField, StyledTextField } from '../components'; import { NumberWidget } from './NumberWidget'; export const TextWidget: React.FC = (props) => { const { id, value, required, readonly, disabled, autofocus, placeholder, onBlur, onFocus, onChange, options, schema, } = props; const inputType = schema.type; const isCode = options.widget === 'code' || schema.contentMediaType === 'application/javascript'; const handleChange = (event: React.ChangeEvent) => { const newValue = event.target.value; onChange(newValue === '' ? undefined : newValue); }; const handleBlur = (event: React.FocusEvent) => { onBlur(id, event.target.value); }; const handleFocus = (event: React.FocusEvent) => { onFocus(id, event.target.value); }; if (isCode) { return ( ); } if (inputType === 'number' || inputType === 'integer') { return ; } const getInputType = (): React.InputHTMLAttributes['type'] => { if (typeof inputType === 'string') { if (inputType === 'string') { return 'text'; } else { return 'text'; } } return 'text'; }; return ( ); };