rjsf-antd
Version:
Ant Design theme, fields and widgets for react-jsonschema-form
29 lines • 1.44 kB
JavaScript
import { __assign } from "tslib";
import React from 'react';
import { InputNumber } from 'antd';
var UpDownWidget = function (props) {
var id = props.id, required = props.required, readonly = props.readonly, disabled = props.disabled, value = props.value, onChange = props.onChange, onBlur = props.onBlur, onFocus = props.onFocus, autofocus = props.autofocus, options = props.options, schema = props.schema;
var _onChange = function (value) { return onChange(value); };
var _onBlur = function (_a) {
var value = _a.target.value;
return onBlur(id, value);
};
var _onFocus = function (_a) {
var value = _a.target.value;
return 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, __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