"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _rate = _interopRequireDefault(require("../rate"));
require("./style");
var _jsxRuntime = require("react/jsx-runtime");
/**
 * 评分组件
 *
 * @param
 */const FieldRate = ({
  text,
  mode,
  render,
  renderFormItem,
  fieldProps
}, ref) => {
  if (mode === 'read') {
    const dom = /*#__PURE__*/(0, _jsxRuntime.jsx)(_rate.default, {
      allowHalf: true,
      disabled: true,
      ref: ref,
      value: text,
      ...fieldProps
    });
    if (render) {
      return render(text, {
        mode,
        ...fieldProps
      }, /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
        children: dom
      }));
    }
    return dom;
  }
  if (mode === 'edit' || mode === 'update') {
    const dom = /*#__PURE__*/(0, _jsxRuntime.jsx)(_rate.default, {
      allowHalf: true,
      ref: ref,
      ...fieldProps
    });
    if (renderFormItem) {
      return renderFormItem(text, {
        mode,
        ...fieldProps
      }, dom);
    }
    return dom;
  }
  return null;
};
var _default = /*#__PURE__*/_react.default.forwardRef(FieldRate);
exports.default = _default;