import React from 'react';
import Rate from '../rate';
import './style';

/**
 * 评分组件
 *
 * @param
 */
import { jsx as _jsx } from "react/jsx-runtime";
import { Fragment as _Fragment } from "react/jsx-runtime";
const FieldRate = ({
  text,
  mode,
  render,
  renderFormItem,
  fieldProps
}, ref) => {
  if (mode === 'read') {
    const dom = /*#__PURE__*/_jsx(Rate, {
      allowHalf: true,
      disabled: true,
      ref: ref,
      value: text,
      ...fieldProps
    });
    if (render) {
      return render(text, {
        mode,
        ...fieldProps
      }, /*#__PURE__*/_jsx(_Fragment, {
        children: dom
      }));
    }
    return dom;
  }
  if (mode === 'edit' || mode === 'update') {
    const dom = /*#__PURE__*/_jsx(Rate, {
      allowHalf: true,
      ref: ref,
      ...fieldProps
    });
    if (renderFormItem) {
      return renderFormItem(text, {
        mode,
        ...fieldProps
      }, dom);
    }
    return dom;
  }
  return null;
};
export default /*#__PURE__*/React.forwardRef(FieldRate);