import { useCallback } from 'react'; import { ariaDescribedByIds, rangeSpec, FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps, titleId, } from '@rjsf/utils'; import { Slider, Input } from '@mantine/core'; import { cleanupOptions } from '../utils'; /** The `RangeWidget` component uses the `BaseInputTemplate` changing the type to `range` and wrapping the result * in a div, with the value along side it. * * @param props - The `WidgetProps` for this component */ export default function RangeWidget( props: WidgetProps ) { const { id, name, value, required, disabled, readonly, autofocus, label, hideLabel, rawErrors, options, onChange, onBlur, onFocus, schema, } = props; const themeProps = cleanupOptions(options); const { min, max, step } = rangeSpec(schema); const handleChange = useCallback( (nextValue: any) => { if (!disabled && !readonly && onChange) { onChange(nextValue); } }, [onChange, disabled, readonly] ); const handleBlur = () => onBlur && onBlur(id, value); const handleFocus = () => onFocus && onFocus(id, value); return ( <> {!hideLabel && !!label && ( (id)} required={required}> {label} )} {options?.description && {options.description}} (id)} /> {rawErrors && rawErrors?.length > 0 && rawErrors.map((error: string, index: number) => ( {error} ))} ); }