import { ChangeEvent } from 'react'; import { ariaDescribedByIds, BaseInputTemplateProps, examplesId, FormContextType, getInputProps, RJSFSchema, StrictRJSFSchema, } from '@snups/rjsf-utils'; import { InputText } from 'primereact/inputtext'; /** The `BaseInputTemplate` is the template the fallback if no widget is specified. */ export default function BaseInputTemplate< T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any, >(props: BaseInputTemplateProps) { const { id, placeholder, value, required, readonly, disabled, onChange, onChangeOverride, onBlur, onFocus, autofocus, options, schema, type, registry, rawErrors = [], } = props; const { AutoCompleteWidget } = registry.widgets; if (Array.isArray(schema.examples)) { return ; } const inputProps = getInputProps(schema, type, options); const primeProps = (options.prime || {}) as object; const _onChange = ({ target: { value } }: ChangeEvent) => onChange(value === '' ? options.emptyValue : value); const _onBlur = () => onBlur && onBlur(id, value); const _onFocus = () => onFocus && onFocus(id, value); return ( (id) : undefined} value={value || value === 0 ? value : ''} invalid={rawErrors.length > 0} onChange={onChangeOverride || _onChange} onBlur={_onBlur} onFocus={_onFocus} aria-describedby={ariaDescribedByIds(id, !!schema.examples)} /> ); }