UNPKG

fx-form-widget

Version:
49 lines 1.9 kB
import _Rate from "antd/es/rate"; import _extends from "@babel/runtime/helpers/extends"; import * as React from 'react'; import { isNotNullValue } from './tools'; var RateWidget = function RateWidget(_ref) { var _ref$schema = _ref.schema, schema = _ref$schema === void 0 ? {} : _ref$schema, _ref$onChange = _ref.onChange, onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange, _ref$value = _ref.value, value = _ref$value === void 0 ? isNotNullValue(schema.data) ? schema.data : '' : _ref$value; var _schema$readonly = schema.readonly, readonly = _schema$readonly === void 0 ? false : _schema$readonly, _schema$required = schema.required, required = _schema$required === void 0 ? false : _schema$required, _schema$allowClear = schema.allowClear, allowClear = _schema$allowClear === void 0 ? false : _schema$allowClear, _schema$allowHalf = schema.allowHalf, allowHalf = _schema$allowHalf === void 0 ? false : _schema$allowHalf, _schema$startCount = schema.startCount, startCount = _schema$startCount === void 0 ? 5 : _schema$startCount, _schema$character = schema.character, character = _schema$character === void 0 ? undefined : _schema$character; var defaultOptions = {}; if (schema['ui_options']) { Object.keys(schema['ui_options']).forEach(function (key) { defaultOptions[key] = schema['ui_options'][key]; }); } var handleChange = function handleChange(value) { return onChange(value); }; var options = _extends({ allowClear: allowClear, disabled: readonly, allowHalf: allowHalf, count: startCount, character: character ? character : undefined }, defaultOptions); return /*#__PURE__*/React.createElement(_Rate, _extends({ style: { width: '100%' } }, options, { onChange: handleChange, value: value })); }; export default RateWidget;