UNPKG

rjsf-antd

Version:

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

31 lines 1.57 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var react_1 = tslib_1.__importDefault(require("react")); var antd_1 = require("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_1.default.createElement(antd_1.InputNumber, tslib_1.__assign({ id: id }, options, { autoFocus: autofocus, required: required, type: "number", disabled: disabled || readonly, value: value, onChange: _onChange, onBlur: _onBlur, onFocus: _onFocus }))); }; exports.default = UpDownWidget; //# sourceMappingURL=UpDownWidget.js.map