react-admin-component
Version:
react library
27 lines • 1.12 kB
JavaScript
import * as tslib_1 from "tslib";
import React, { useState, useEffect } from 'react';
import { Select } from 'antd';
var TdSelectRender = function (props) {
var validator = props.validator;
var _a = useState(props.value), value = _a[0], setValue = _a[1];
useEffect(function () {
setValue(props.value);
}, [props.value]);
function onSearch(inputValue) {
handleValue(inputValue);
}
function onChange(value) {
handleValue(value);
}
function handleValue(value) {
if (validator && !validator(value)) {
return;
}
setValue(value);
props.onChange && props.onChange(value);
}
return (React.createElement(Select, { className: props.className, value: value, style: tslib_1.__assign({ minWidth: 100 }, props.style), onChange: onChange, onSearch: onSearch, allowClear: true }, props.options &&
props.options.map(function (option) { return (React.createElement(Select.Option, { key: option.key }, option.value)); })));
};
export default TdSelectRender;
//# sourceMappingURL=index.js.map