UNPKG

react-admin-component

Version:
23 lines 943 B
import * as tslib_1 from "tslib"; import React, { useState, useEffect } from 'react'; import { Input } from 'antd'; var TdInputRender = function (props) { var validator = props.validator, style = props.style, rest = tslib_1.__rest(props, ["validator", "style"]); var _a = useState(props.value), value = _a[0], setValue = _a[1]; useEffect(function () { setValue(props.value); }, [props.value]); function onChange(inputValue) { if (validator && !validator(inputValue)) { return; } setValue(inputValue); props.onChange && props.onChange(inputValue); } return (React.createElement(Input, tslib_1.__assign({ value: value, style: tslib_1.__assign({ width: 100 }, style), onChange: function (e) { e.persist(); onChange(e.target.value); } }, rest))); }; export default TdInputRender; //# sourceMappingURL=index.js.map