import "core-js/modules/es.array.iterator.js";
import "core-js/modules/web.dom-collections.iterator.js";
/* eslint-disable @typescript-eslint/no-unused-vars */
import React from 'react';
import { runFunction } from '../../../utils';
import ProField from '../../../wau-field';
import createField from '../../create-field';
import { jsx as _jsx } from "react/jsx-runtime";
/**
 * 最普通的 Text 组件
 *
 * @param
 */
const ProFormField = ({
  fieldProps,
  children,
  labelCol,
  label,
  isDefaultDom,
  render,
  proFieldProps,
  renderFormItem,
  valueType,
  initialValue,
  onChange,
  valueEnum,
  ...restProps
}) => {
  // 防止 formItem 的值被吃掉
  if (children) {
    if ( /*#__PURE__*/React.isValidElement(children)) {
      return /*#__PURE__*/React.cloneElement(children, {
        ...restProps,
        onChange: (...restParams) => {
          var _fieldProps$onChange;
          fieldProps === null || fieldProps === void 0 ? void 0 : (_fieldProps$onChange = fieldProps.onChange) === null || _fieldProps$onChange === void 0 ? void 0 : _fieldProps$onChange.call(fieldProps, ...restParams);
          onChange === null || onChange === void 0 ? void 0 : onChange(...restParams);
        },
        ...children.props
      });
    }
    return children;
  }
  return /*#__PURE__*/_jsx(ProField, {
    text: fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.value,
    mode: "edit",
    valueType: valueType || 'text',
    fieldProps: {
      ...fieldProps,
      onChange: (...restParams) => {
        var _fieldProps$onChange2;
        fieldProps === null || fieldProps === void 0 ? void 0 : (_fieldProps$onChange2 = fieldProps.onChange) === null || _fieldProps$onChange2 === void 0 ? void 0 : _fieldProps$onChange2.call(fieldProps, ...restParams);
        onChange === null || onChange === void 0 ? void 0 : onChange(...restParams);
      }
    },
    valueEnum: runFunction(valueEnum),
    ...proFieldProps,
    ...restProps
  });
};
export default createField(ProFormField);