@rjsf/material-ui
Version:
Material UI 4 theme, fields and widgets for react-jsonschema-form
20 lines • 1.38 kB
JavaScript
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import FormLabel from '@material-ui/core/FormLabel';
import Slider from '@material-ui/core/Slider';
import { ariaDescribedByIds, labelValue, rangeSpec, } from '@rjsf/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) {
const { value, readonly, disabled, onBlur, onFocus, options, schema, onChange, required, label, hideLabel, id } = props;
const sliderProps = { value, label, id, name: id, ...rangeSpec(schema) };
const _onChange = (_, value) => {
onChange(value !== null && value !== void 0 ? value : options.emptyValue);
};
const _onBlur = ({ target: { value } }) => onBlur(id, value);
const _onFocus = ({ target: { value } }) => onFocus(id, value);
return (_jsxs(_Fragment, { children: [labelValue(_jsx(FormLabel, { required: required, htmlFor: id, children: label || undefined }), hideLabel), _jsx(Slider, { disabled: disabled || readonly, onChange: _onChange, onBlur: _onBlur, onFocus: _onFocus, valueLabelDisplay: 'auto', ...sliderProps, "aria-describedby": ariaDescribedByIds(id) })] }));
}
//# sourceMappingURL=RangeWidget.js.map