import React from 'react';
import InputNumber from '../input-number';
import './style';
import { jsx as _jsx } from "react/jsx-runtime";
/**
 * 数字组件
 *
 * @param FieldDigitProps {
 *     text: number;
 *     moneySymbol?: string; }
 */
const FieldDigit = ({
  text,
  mode: type,
  render,
  renderFormItem,
  fieldProps,
  ...rest
}, ref) => {
  if (type === 'read') {
    const digit = new Intl.NumberFormat().format(Number(text));
    const dom = /*#__PURE__*/_jsx("span", {
      ref: ref,
      children: digit
    });
    if (render) {
      return render(text, {
        mode: type,
        ...fieldProps
      }, dom);
    }
    return dom;
  }
  if (type === 'edit' || type === 'update') {
    const dom = /*#__PURE__*/_jsx(InputNumber, {
      ref: ref,
      min: 0,
      style: {
        width: '100%'
      },
      ...rest,
      ...fieldProps
    });
    if (renderFormItem) {
      return renderFormItem(text, {
        mode: type,
        ...fieldProps
      }, dom);
    }
    return dom;
  }
  return null;
};
export default /*#__PURE__*/React.forwardRef(FieldDigit);