"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
require("core-js/modules/es.array.iterator.js");
require("core-js/modules/web.dom-collections.iterator.js");
var _react = _interopRequireDefault(require("react"));
var _utils = require("../../../utils");
var _wauField = _interopRequireDefault(require("../../../wau-field"));
var _createField = _interopRequireDefault(require("../../create-field"));
var _jsxRuntime = require("react/jsx-runtime");
/* eslint-disable @typescript-eslint/no-unused-vars */

/**
 * 最普通的 Text 组件
 *
 * @param
 */
const ProFormField = ({
  fieldProps,
  children,
  labelCol,
  label,
  isDefaultDom,
  render,
  proFieldProps,
  renderFormItem,
  valueType,
  initialValue,
  onChange,
  valueEnum,
  ...restProps
}) => {
  // 防止 formItem 的值被吃掉
  if (children) {
    if ( /*#__PURE__*/_react.default.isValidElement(children)) {
      return /*#__PURE__*/_react.default.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__*/(0, _jsxRuntime.jsx)(_wauField.default, {
    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: (0, _utils.runFunction)(valueEnum),
    ...proFieldProps,
    ...restProps
  });
};
var _default = (0, _createField.default)(ProFormField);
exports.default = _default;