UNPKG

@agentlab/rjsf-antd

Version:

Ant Design theme, fields and widgets for react-jsonschema-form

21 lines 1.12 kB
import React from 'react'; import { InputNumber } from 'antd'; const UpDownWidget = ({ id, required, readonly, disabled, value, onChange, onBlur, onFocus, autofocus, options, schema, }) => { const _onChange = (value) => onChange(value); const _onBlur = ({ target: { value } }) => onBlur(id, value); const _onFocus = ({ target: { value } }) => onFocus(id, value); // If multipleOf is defined, use this as the step value. This mainly improves // the experience for keyboard users (who can use the up/down KB arrows). if (schema.multipleOf) { options.step = schema.multipleOf; } if (typeof schema.minimum !== 'undefined') { options.min = schema.minimum; } if (typeof schema.maximum !== 'undefined') { options.max = schema.maximum; } return (React.createElement(InputNumber, Object.assign({ id: id }, options, { autoFocus: autofocus, required: required, type: 'number', disabled: disabled || readonly, value: value, onChange: _onChange, onBlur: _onBlur, onFocus: _onFocus }))); }; export default UpDownWidget; //# sourceMappingURL=UpDownWidget.js.map