UNPKG

@rjsf/semantic-ui

Version:

Semantic UI theme, fields and widgets for react-jsonschema-form

26 lines 1.51 kB
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime"; import { Input } from 'semantic-ui-react'; import { ariaDescribedByIds, rangeSpec } from '@rjsf/utils'; import { getSemanticProps } from '../util.js'; /** 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 { id, value, required, readonly, disabled, onChange, onBlur, onFocus, options, schema, uiSchema, formContext, rawErrors = [], } = props; const semanticProps = getSemanticProps({ formContext, options, uiSchema, defaultSchemaProps: { fluid: true, }, }); // eslint-disable-next-line no-shadow const _onChange = ({ target: { value } }) => onChange && onChange(value === '' ? options.emptyValue : value); const _onBlur = () => onBlur && onBlur(id, value); const _onFocus = () => onFocus && onFocus(id, value); return (_jsxs(_Fragment, { children: [_jsx(Input, { id: id, name: id, type: 'range', required: required, disabled: disabled || readonly, ...rangeSpec(schema), ...semanticProps, value: value || '', error: rawErrors.length > 0, onChange: _onChange, onBlur: _onBlur, onFocus: _onFocus, "aria-describedby": ariaDescribedByIds(id) }, id), _jsx("span", { children: value })] })); } //# sourceMappingURL=RangeWidget.js.map