import { FocusEvent } from 'react'; import { FormControl, FormLabel, Slider, SliderFilledTrack, SliderThumb, SliderTrack } from '@chakra-ui/react'; import { ariaDescribedByIds, FormContextType, labelValue, rangeSpec, RJSFSchema, StrictRJSFSchema, WidgetProps, } from '@rjsf/utils'; import { getChakra } from '../utils'; export default function RangeWidget({ value, readonly, disabled, onBlur, onFocus, options, schema, uiSchema, onChange, label, hideLabel, id, }: WidgetProps) { const chakraProps = getChakra({ uiSchema }); const sliderWidgetProps = { value, label, id, ...rangeSpec(schema) }; const _onChange = (value: undefined | number) => onChange(value === undefined ? options.emptyValue : value); const _onBlur = ({ target: { value } }: FocusEvent) => onBlur(id, value); const _onFocus = ({ target: { value } }: FocusEvent) => onFocus(id, value); return ( {labelValue({label}, hideLabel || !label)} (id)} > ); }