import React from 'react'; import { ariaDescribedByIds, BaseInputTemplateProps, examplesId, getInputProps, labelValue, FormContextType, RJSFSchema, StrictRJSFSchema, } from '@rjsf/utils'; import { TextInput, NumberInput } from '@mantine/core'; import { cleanupOptions } from '../utils'; export default function BaseInputTemplate< T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any >(props: BaseInputTemplateProps) { const { id, type, schema, value, placeholder, required, disabled, readonly, autofocus, label, hideLabel, onChange, onChangeOverride, onBlur, onFocus, options, rawErrors, } = props; const inputProps = getInputProps(schema, type, options, false); const themeProps = cleanupOptions(options); const handleNumberChange = (value: number | string) => onChange(value); const handleChange = onChangeOverride ? onChangeOverride : (e: React.ChangeEvent) => onChange(e.target.value === '' ? options.emptyValue ?? '' : e.target.value); const handleBlur = (e: React.FocusEvent) => onBlur(id, e.target && e.target.value); const handleFocus = (e: React.FocusEvent) => onFocus(id, e.target && e.target.value); const input = inputProps.type === 'number' || inputProps.type === 'integer' ? ( 0 ? rawErrors.join('\n') : undefined} list={schema.examples ? examplesId(id) : undefined} {...inputProps} {...themeProps} step={typeof inputProps.step === 'number' ? inputProps.step : 1} type='text' value={value} aria-describedby={ariaDescribedByIds(id, !!schema.examples)} /> ) : ( 0 ? rawErrors.join('\n') : undefined} list={schema.examples ? examplesId(id) : undefined} {...inputProps} {...themeProps} value={value} aria-describedby={ariaDescribedByIds(id, !!schema.examples)} /> ); return ( <> {input} {Array.isArray(schema.examples) && ( (id)}> {(schema.examples as string[]) .concat(schema.default && !schema.examples.includes(schema.default) ? ([schema.default] as string[]) : []) .map((example) => { return )} ); }