import { jsx, jsxs } from 'react/jsx-runtime';
import React__default from 'react';
import { _ as _slicedToArray } from './slicedToArray-76060636.js';
import { TextField } from '../TextField/index.js';
import { RadioGroup } from '../RadioGroup/index.js';
import Select from '../Select/index.js';
import { CheckboxGroup } from '../CheckboxGroup/index.js';
import { _ as _typeof } from './typeof-498dd2b1.js';
import { Switch } from '../Switch/index.js';
import Delete from '@iam-com/icons/Delete';
import ParaLinkGroup from '@iam-com/icons/LinkGroup';
import AutoTips from '../AutoTips/index.js';
import { Button } from '../Button/index.js';
import { u as useFormatMessage } from './useFormatMessage-703f8b20.js';
import { s as styleInject } from './style-inject.es-300983ab.js';
import { InputNumber } from '../InputNumber/index.js';
import { ComboSelect } from '../ComboSelect/index.js';
import HelperText from '../HelperText/index.js';
import clsx from 'clsx';
import Label from '../Label/index.js';
import { $ as $prefixCls } from './constant-66aa48a1.js';

var FormRadioGroup = function FormRadioGroup(props) {
  var defaultValue = props.defaultValue,
    change = props.change;
  /**
   * 选中的值
   */
  var _React$useState = React__default.useState(defaultValue === undefined ? "" : defaultValue),
    _React$useState2 = _slicedToArray(_React$useState, 2),
    selectValue = _React$useState2[0],
    setSelectValue = _React$useState2[1];
  /**
   * 选中值改变
   */
  var changeValue = function changeValue(value) {
    setSelectValue(value);
    change && change(value);
  };
  return jsx(RadioGroup, Object.assign({
    value: selectValue,
    onChange: changeValue,
    hideErrorDom: null
  }, props));
};

var FormSelect = function FormSelect(props) {
  var _props$defaultValue = props.defaultValue,
    defaultValue = _props$defaultValue === void 0 ? '' : _props$defaultValue,
    change = props.change,
    value = props.value;
  /**
  * 选中的值
  */
  var _React$useState = React__default.useState(value !== undefined ? value : defaultValue),
    _React$useState2 = _slicedToArray(_React$useState, 2),
    selectValue = _React$useState2[0],
    setSelectValue = _React$useState2[1];
  /**
  * 选中值改变
  */
  var changeValue = function changeValue(value) {
    setSelectValue(value);
    change && change(value);
  };
  React__default.useEffect(function () {
    setSelectValue(value);
  }, [value]);
  return jsx(Select, Object.assign({
    labelMode: "inside",
    onChange: changeValue,
    hideErrorDom: null
  }, props, {
    value: selectValue
  }));
};

var FormCheckboxGroup = function FormCheckboxGroup(props) {
  var defaultValue = props.defaultValue,
    change = props.change;
  /**
  * 选中的值
  */
  var _React$useState = React__default.useState(defaultValue || []),
    _React$useState2 = _slicedToArray(_React$useState, 2),
    selectValue = _React$useState2[0],
    setSelectValue = _React$useState2[1];
  /**
  * 选中值改变
  */
  var changeValue = function changeValue(value) {
    setSelectValue(value);
    change && change(value);
  };
  return jsx(CheckboxGroup, Object.assign({
    value: selectValue,
    onChange: changeValue,
    hideErrorDom: null
  }, props));
};

/**
* 表单默认的校验方法
* @type {{[name: string]: validateFunctionType}}
*/
var fixedValidateFunction = {
  'required': function required(item, val, intl) {
    var _a, _b, _c, _d;
    var vtype = _typeof(val);
    var error = ((_b = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.required) || intl({
      id: 'unEmpty'
    }, {
      label: item.label
    });
    var jude = false;
    switch (vtype) {
      case 'string':
        var disOnlySpace = item.disOnlySpace !== undefined ? item.disOnlySpace : (_d = (_c = item.rules) === null || _c === void 0 ? void 0 : _c.validate) === null || _d === void 0 ? void 0 : _d.disOnlySpace;
        if (!disOnlySpace) {
          jude = !!val;
        } else {
          var space = /^[\s]+$/;
          jude = !!val && !space.test(val);
        }
        break;
      case 'number':
        jude = val + 1 > val;
        break;
      case 'object':
        var str = JSON.stringify(val);
        jude = str !== 'null' && str !== '[]' && str !== '{}';
        break;
      case 'boolean':
        jude = val !== undefined;
        break;
      default:
        jude = !!val;
        break;
    }
    return jude || error;
  },
  'maxlength': function maxlength(item, val, intl) {
    var _a, _b, _c, _d, _e, _f;
    var vtype = _typeof(val);
    var error = ((_b = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.maxlength) || intl({
      id: 'maxLength'
    }, {
      len: (_d = (_c = item.rules) === null || _c === void 0 ? void 0 : _c.validate) === null || _d === void 0 ? void 0 : _d.maxlength
    });
    var jude = false;
    if (vtype === 'string' || vtype === 'number' && val + 1 > val) {
      jude = !("".concat(val).length > (((_f = (_e = item.rules) === null || _e === void 0 ? void 0 : _e.validate) === null || _f === void 0 ? void 0 : _f.maxlength) || NaN));
    } else {
      jude = !val;
    }
    return jude || error;
  },
  'minLength': function minLength(item, val, intl) {
    var _a, _b, _c, _d, _e, _f;
    var vtype = _typeof(val);
    var error = ((_b = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.minLength) || intl({
      id: 'minLength'
    }, {
      len: (_d = (_c = item.rules) === null || _c === void 0 ? void 0 : _c.validate) === null || _d === void 0 ? void 0 : _d.minLength
    });
    var jude = false;
    if (vtype === 'string' || vtype === 'number' && val + 1 > val) {
      jude = "".concat(val).length >= (((_f = (_e = item.rules) === null || _e === void 0 ? void 0 : _e.validate) === null || _f === void 0 ? void 0 : _f.minLength) || -1);
    } else {
      jude = !val;
    }
    return jude || error;
  },
  'pattern': function pattern(item, val, intl) {
    var _a, _b, _c, _d;
    var testReg = (_b = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.validate) === null || _b === void 0 ? void 0 : _b.pattern;
    var error = ((_d = (_c = item.rules) === null || _c === void 0 ? void 0 : _c.message) === null || _d === void 0 ? void 0 : _d.pattern) || intl({
      id: 'unRule'
    }, {
      rule: '' + testReg
    });
    var jude = !val;
    if (testReg && val && typeof testReg !== 'function') {
      jude = testReg.test(val);
    }
    return jude || error;
  },
  'min': function min(item, val, intl) {
    var _a, _b, _c, _d, _e, _f, _g, _h;
    var vtype = _typeof(val);
    var error = ((_b = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.min) || intl({
      id: 'minValue'
    }, {
      val: (_d = (_c = item.rules) === null || _c === void 0 ? void 0 : _c.validate) === null || _d === void 0 ? void 0 : _d.min
    });
    var jude = !val;
    if (vtype === 'string' || vtype === 'number') {
      jude = val >= (((_f = (_e = item.rules) === null || _e === void 0 ? void 0 : _e.validate) === null || _f === void 0 ? void 0 : _f.min) === undefined ? -Infinity : (_h = (_g = item.rules) === null || _g === void 0 ? void 0 : _g.validate) === null || _h === void 0 ? void 0 : _h.min);
    }
    return jude || error;
  },
  'max': function max(item, val, intl) {
    var _a, _b, _c, _d, _e, _f, _g, _h;
    var vtype = _typeof(val);
    var error = ((_b = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.max) || intl({
      id: 'maxValue'
    }, {
      val: (_d = (_c = item.rules) === null || _c === void 0 ? void 0 : _c.validate) === null || _d === void 0 ? void 0 : _d.max
    });
    var jude = !val;
    if (vtype === 'string' || vtype === 'number') {
      jude = val <= (((_f = (_e = item.rules) === null || _e === void 0 ? void 0 : _e.validate) === null || _f === void 0 ? void 0 : _f.max) === undefined ? Infinity : (_h = (_g = item.rules) === null || _g === void 0 ? void 0 : _g.validate) === null || _h === void 0 ? void 0 : _h.max);
    }
    return jude || error;
  }
};
/**
* 表单rules校验方法
* @type {validateFunctionType}
*/
var validate = function validate(item, val, intl) {
  var _a, _b;
  var validateObj = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.validate;
  if (validateObj) {
    var messageObj = (_b = item.rules) === null || _b === void 0 ? void 0 : _b.message;
    for (var key in validateObj) {
      var tempFuc = validateObj[key];
      var tmsg = '';
      if (typeof tempFuc === 'function') {
        tmsg = tempFuc(item, val, intl);
        if (tmsg === false && messageObj) tmsg = messageObj[key];
      } else if (!!tempFuc && fixedValidateFunction[key]) {
        tmsg = fixedValidateFunction[key](item, val, intl);
      } else if (!tempFuc) {
        tmsg = true;
      } else {
        // console.log(`项目: ${item.label}, 自定义校验规则: ${key}, 方法未定义`);
        tmsg = true;
      }
      if (tmsg !== true) return tmsg || '';
    }
  }
  return false;
};

var en = {
  choseFile: 'Chose File',
  unEmpty: '{label} Cannot be empty',
  maxLength: 'The maximum length cannot be exceeded {len}',
  minLength: 'The minimum length cannot be exceeded {len}',
  unRule: 'The parameter does not comply with the validation rule {rule}',
  minValue: 'The minimum value is {val}',
  maxValue: 'The maximum value is {val}'
};

var zh = {
  choseFile: '选择文件',
  unEmpty: '{label}不能为空',
  maxLength: '最大长度不能超过{len}位',
  minLength: '最小长度为{len}位',
  unRule: '参数不符合校验规则{rule}',
  minValue: '最小值为{val}',
  maxValue: '最大值为{val}'
};

var localeJson = {
  zh: zh,
  en: en
};

var css_248z$1 = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/10/20 下午2:08\n* @description color\n*/\n.form-file {\n  padding: 6px;\n  font-family: -apple-system, BlinkMacSystemFont, Helvetica Neue, PingFang SC, Microsoft YaHei, Source Han Sans SC, Noto Sans CJK SC, WenQuanYi Micro Hei, sans-serif;\n  font-size: 14px;\n  font-weight: 400;\n}\n.form-file .file-tips {\n  min-height: 20px;\n  position: relative;\n  padding: 6px;\n}\n.form-file .file-tips .file-tips-item {\n  position: relative;\n  height: 20px;\n  line-height: 16px;\n  padding-right: 20px;\n}\n.form-file .file-tips .file-tips-item > [data-name=LinkGroup] {\n  vertical-align: middle;\n  margin-right: 9px;\n}\n.form-file .file-tips .file-tips-item .file-tips-context {\n  display: inline-block;\n  vertical-align: middle;\n  width: calc(100% - 45px);\n  color: rgba(46, 55, 67, 0.7);\n}\n.form-file .file-tips .file-tips-item > [data-name=Delete] {\n  display: none;\n  vertical-align: middle;\n  cursor: pointer;\n  position: absolute;\n  right: 3px;\n  top: 2px;\n}\n.form-file .file-tips .file-tips-item > [data-name=Delete]:hover {\n  opacity: 0.8;\n}\n.form-file .file-tips .file-tips-item:hover {\n  backgroundColor: #f5f5f5;\n}\n.form-file .file-tips .file-tips-item:hover > [data-name=Delete] {\n  display: inline-block;\n}";
styleInject(css_248z$1);

/**
 * 文件组件
 */
var FormFile = function FormFile(props) {
  var _props$fileType = props.fileType,
    fileType = _props$fileType === void 0 ? '' : _props$fileType,
    defaultValue = props.defaultValue,
    onChange = props.onChange,
    disabled = props.disabled,
    buttonLabel = props.buttonLabel,
    inputProps = props.inputProps,
    buttonProps = props.buttonProps;
  var intl = useFormatMessage('FormItem', localeJson);
  /**
   * 存储文件输入框真实dom
   * @type {HTMLInputElement}
   */
  var inputFileEl = React__default.useRef(null);
  /**
   * 模拟点击选择文件
   */
  var inputFileClick = function inputFileClick() {
    var _a;
    (_a = inputFileEl.current) === null || _a === void 0 ? void 0 : _a.click();
  };
  /**
   * 文件改变
   */
  var fileChange = function fileChange(value) {
    var val = value !== undefined ? value : inputFileEl.current.files;
    setSelectedFile(val);
    onChange && onChange(val);
    if (value === null) inputFileEl.current.value = null;
  };
  /**
   * @type {string}
   * 已选择的文件
   */
  var _React$useState = React__default.useState(),
    _React$useState2 = _slicedToArray(_React$useState, 2),
    selectedFile = _React$useState2[0],
    setSelectedFile = _React$useState2[1];
  /**
   * 初始化操作
   */
  React__default.useEffect(function () {
    if (defaultValue) {
      if (typeof defaultValue === 'string') {
        setSelectedFile(defaultValue);
      } else {
        setSelectedFile(defaultValue);
      }
    }
  }, [defaultValue]);
  return jsxs("div", Object.assign({
    className: 'form-file'
  }, {
    children: [!disabled && jsx(Button, Object.assign({
      variant: "outlined"
    }, buttonProps, {
      onClick: inputFileClick
    }, {
      children: buttonLabel || intl({
        id: 'choseFile'
      })
    })), jsx("input", Object.assign({}, inputProps, {
      ref: inputFileEl,
      type: "file",
      onInput: function onInput() {
        return fileChange();
      },
      hidden: true,
      accept: typeof fileType === 'string' ? fileType : fileType.join(',')
    })), selectedFile && selectedFile[0] && jsx("div", Object.assign({
      className: "file-tips ".concat(disabled && 'file-tips-disabled' || '')
    }, {
      children: jsxs("div", Object.assign({
        className: "file-tips-item"
      }, {
        children: [jsx(ParaLinkGroup, {}), jsx("span", Object.assign({
          className: "file-tips-context"
        }, {
          children: jsx(AutoTips, {
            children: typeof selectedFile === 'string' ? selectedFile : selectedFile[0].name
          })
        })), !disabled && jsx(Delete, {
          onClick: function onClick() {
            return fileChange(null);
          }
        })]
      }))
    }))]
  }));
};

/**
* @module src\FormItem\compoments\defaultCompoments\index.tsx
* @author zhanzl
* @date 2022/06/02
*/
var DefaultCompoments = function DefaultCompoments(props) {
  var error = props.error,
    placeholder = props.placeholder,
    defaultValue = props.defaultValue,
    disabled = props.disabled,
    _onChange = props.onChange,
    inputProps = props.inputProps,
    moudle = props.moudle;
  var _React$useState = React__default.useState(defaultValue),
    _React$useState2 = _slicedToArray(_React$useState, 2),
    dValue = _React$useState2[0],
    setDvalue = _React$useState2[1];
  // 监听defaultValue改变
  React__default.useEffect(function () {
    setDvalue(defaultValue);
  }, [defaultValue]);
  return moudle(Object.assign(Object.assign({
    error: error,
    placeholder: placeholder,
    value: dValue,
    disabled: disabled,
    hideErrorDom: null
  }, inputProps), {
    onChange: function onChange(e) {
      var _a;
      var tVal = ((_a = e === null || e === void 0 ? void 0 : e.target) === null || _a === void 0 ? void 0 : _a.value) || e;
      setDvalue(tVal);
      _onChange(tVal);
    }
  }));
};

/**
 * form 表单操作项 类型
 */
var ItemType = function ItemType(props) {
  var itemType = props.itemType,
    error = props.error,
    placeholder = props.placeholder,
    label = props.label,
    inputProps = props.inputProps,
    name = props.name,
    rules = props.rules,
    setValue = props.setValue,
    setError = props.setError,
    backData = props.backData,
    disabled = props.disabled,
    change = props.change,
    isComponent = props.isComponent;
  var intl = useFormatMessage('FormItem', localeJson);
  var tipsStr = placeholder || "".concat(label);
  /**
   * 报错信息
   * @type {boolean}
   */
  var _React$useState = React__default.useState(!!error),
    _React$useState2 = _slicedToArray(_React$useState, 2),
    errorStatus = _React$useState2[0],
    setErrorStatus = _React$useState2[1];
  /**
   * 校验方法
   */
  var validateFunction = function validateFunction(val) {
    setValue && setValue(name, 'value', val);
    change && change(val);
    // 没有校验规则直接退出
    if (!rules) return;
    var item = Object.assign(Object.assign({}, props), {
      setErrorMsg: setErrorMsg,
      setAndValidateValue: setAndValidateValue
    });
    var errorMessage = validate(item, val, intl) || '';
    setErrorMsg(errorMessage);
  };
  /**
   * 存储和校验数据
   */
  var setAndValidateValue = validateFunction;
  /**
   * 合并设置Error状态方法
   */
  var setErrorMsg = React__default.useCallback(function (msg) {
    setError && setError(msg);
    setErrorStatus(!!msg);
    setValue && setValue(name, 'message', msg);
  }, [name, setError, setValue]);
  /**
   * 传出最后的 item 对象
   */
  React__default.useEffect(function () {
    var item = Object.assign(Object.assign({}, props), {
      setErrorMsg: setErrorMsg,
      setAndValidateValue: setAndValidateValue
    });
    setValue && setValue(name, 'item', item);
  }, [name, props, setErrorMsg, setValue]);
  /**
   * 判断显示那个
   */
  var selectType = function selectType() {
    if (!isComponent && itemType && typeof itemType !== 'string' && (!itemType.name || itemType.name === 'InputType')) {
      var item = Object.assign(Object.assign({}, props), {
        setErrorMsg: setErrorMsg,
        setAndValidateValue: setAndValidateValue
      });
      return itemType(item);
    }
    switch (itemType) {
      case 'file':
        return jsx(FormFile, Object.assign({}, props, {
          defaultValue: backData[name],
          disabled: disabled,
          onChange: function onChange(value) {
            validateFunction(value);
          }
        }));
      case 'switch':
        if (backData[name] === undefined) setValue && setValue(name, 'initValue', !!backData[name]);
        return jsx(Switch, Object.assign({
          compact: true,
          defaultChecked: !!backData[name],
          onChange: function onChange(checked) {
            validateFunction(checked);
          }
        }, Object.assign(Object.assign({}, inputProps), {
          disabled: disabled
        })));
      case 'checkGroup':
        return jsx(FormCheckboxGroup, Object.assign({
          error: errorStatus,
          defaultValue: backData[name],
          change: function change(value) {
            validateFunction(value);
          },
          list: props.list
        }, Object.assign(Object.assign({}, inputProps), {
          disabled: disabled
        })));
      case 'select':
        return jsx(FormSelect, Object.assign({
          placeholder: tipsStr,
          defaultValue: backData[name],
          error: errorStatus,
          change: function change(value) {
            validateFunction(value);
          },
          list: props.list
        }, Object.assign({
          disabled: disabled
        }, inputProps)));
      case 'radioGroup':
        return jsx(FormRadioGroup, Object.assign({
          error: errorStatus,
          defaultValue: backData[name],
          change: function change(value) {
            validateFunction(value);
          },
          list: props.list
        }, Object.assign({
          disabled: disabled
        }, inputProps)));
      case 'textarea':
        return jsx(TextField, Object.assign({
          error: errorStatus,
          placeholder: tipsStr,
          defaultValue: backData[name] || '',
          disabled: disabled,
          multiline: true,
          rows: 3,
          name: name,
          hideErrorDom: null,
          onChange: function onChange(e) {
            validateFunction(e.target.value);
          }
        }, inputProps));
      case 'number':
        return jsx(InputNumber, Object.assign({
          error: errorStatus,
          placeholder: tipsStr,
          defaultValue: backData[name],
          disabled: disabled,
          name: name,
          hideErrorDom: null,
          onChange: function onChange(val) {
            validateFunction(val);
          }
        }, inputProps));
      case 'comboSelect':
        return jsx(ComboSelect, Object.assign({
          error: errorStatus,
          placeholder: tipsStr,
          defaultValue: backData[name],
          disabled: disabled,
          onChange: function onChange(options) {
            validateFunction(options);
          }
        }, inputProps));
      default:
        if (itemType && typeof itemType !== 'string') {
          return jsx(DefaultCompoments, {
            moudle: itemType,
            error: errorStatus,
            placeholder: tipsStr,
            defaultValue: backData[name],
            disabled: disabled,
            onChange: function onChange(val) {
              validateFunction(val);
            },
            inputProps: inputProps
          });
        }
        return jsx(TextField, Object.assign({
          defaultValue: backData[name] || '',
          error: errorStatus,
          placeholder: tipsStr,
          onChange: function onChange(e) {
            validateFunction(e.target.value);
          },
          name: name,
          hideErrorDom: null,
          disabled: disabled
        }, inputProps));
    }
  };
  return selectType();
};

/**
* 报错信息组件
* @description 为了解决，在主组件设置state，导致输入框中内容刷新，且失去焦点
*/
var ErrorTips = function ErrorTips(props) {
  var getSetError = props.getSetError,
    errorMessage = props.errorMessage,
    helperTextProps = props.helperTextProps;
  /**
  * 报错信息
  * @type {string}
  */
  var _React$useState = React__default.useState(errorMessage || ''),
    _React$useState2 = _slicedToArray(_React$useState, 2),
    errorTips = _React$useState2[0],
    setErrorTips = _React$useState2[1];
  /**
  * 初始化传出， 设置错误信息方法
  */
  React__default.useEffect(function () {
    setErrorTips(errorMessage || '');
  }, [errorMessage]);
  React__default.useEffect(function () {
    getSetError && getSetError(setErrorTips);
  }, [getSetError]);
  return jsx(HelperText, Object.assign({
    className: "error-tips",
    error: true,
    helperText: errorTips
  }, helperTextProps));
};

var css_248z = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/10/20 下午2:08\n* @description color\n*/\n.paraui-v3-form-item {\n  font-family: -apple-system, BlinkMacSystemFont, Helvetica Neue, PingFang SC, Microsoft YaHei, Source Han Sans SC, Noto Sans CJK SC, WenQuanYi Micro Hei, sans-serif;\n  font-size: 14px;\n  font-weight: 400;\n}\n.paraui-v3-form-item .paraui-v3-text-field {\n  display: block;\n}\n.paraui-v3-form-item.paraui-v3-form-item-checkGroup .form-label .form-labe-text, .paraui-v3-form-item.paraui-v3-form-item-radioGroup .form-label .form-labe-text {\n  margin-bottom: 4px;\n}\n.paraui-v3-form-item .form-label {\n  display: inline-block;\n}\n.paraui-v3-form-item .form-edit > div {\n  padding: 0;\n  width: 100%;\n}\n.paraui-v3-form-item .form-content-vertical {\n  display: inline-block;\n  width: 100%;\n}";
styleInject(css_248z);

var formInputTypeJson = {
  checkGroup: true,
  select: true,
  radioGroup: true,
  textarea: true,
  default: true,
  switch: true,
  number: true,
  file: true,
  comboSelect: true
};
/**
 * form 表单单行组件
 * @author zhanzl
 * @description 用于根据配置自动生成表单
 */
var FormItem = function FormItem(props) {
  var _a, _b;
  var _props$type = props.type,
    type = _props$type === void 0 ? 'horizontal' : _props$type,
    labelWidth = props.labelWidth,
    tips = props.tips,
    label = props.label,
    itemType = props.itemType,
    _props$InputType = props.InputType,
    InputType = _props$InputType === void 0 ? itemType : _props$InputType,
    setValue = props.setValue,
    errorMessage = props.errorMessage,
    hideLabel = props.hideLabel,
    _props$backData = props.backData,
    backData = _props$backData === void 0 ? {} : _props$backData,
    defaultValue = props.defaultValue,
    name = props.name,
    _props$hideError = props.hideError,
    hideError = _props$hideError === void 0 ? false : _props$hideError,
    _props$className = props.className,
    className = _props$className === void 0 ? '' : _props$className,
    labelProps = props.labelProps,
    helperTextProps = props.helperTextProps,
    requiredElement = props.requiredElement,
    _props$disRequiredEle = props.disRequiredElement,
    disRequiredElement = _props$disRequiredEle === void 0 ? false : _props$disRequiredEle;
  if (backData[name] === undefined) {
    backData[name] = defaultValue;
  }
  /**
   * 接受设置报错信息方法
   * @type {Function}
   */
  var setErrorTips = React__default.useRef();
  /**
   * 设置错误信息
   */
  var setError = function setError(error) {
    setErrorTips.current && setErrorTips.current(error);
  };
  /**
   * 用于判断是否是 vertical 模式如果是则添加相应的外层
   */
  var TypeLayout = function TypeLayout(props) {
    return type === 'vertical' ? jsx("div", Object.assign({
      className: "form-content-vertical form-content-vertical-".concat(name),
      style: {
        width: "calc(100% - ".concat(labelWidth, "px)")
      }
    }, {
      children: props.children
    })) : props.children;
  };
  /**
   * 展示label
   */
  var showLabel = React__default.useCallback(function () {
    if (!label) return '';
    return typeof label === 'string' ? label : label(props);
  }, [label]);
  /** 处理className */
  var handClass = function handClass() {
    var str = "".concat($prefixCls, "-form-item ").concat($prefixCls, "-form-item-").concat(name);
    if (className) str += ' ' + className;
    if (typeof InputType === 'string' && formInputTypeJson[InputType]) {
      str += " ".concat($prefixCls, "-form-item-").concat(InputType);
    }
    return str;
  };
  return jsxs("div", Object.assign({
    className: handClass()
  }, {
    children: [!hideLabel && jsx("div", Object.assign({
      className: clsx("form-label form-label-".concat(name), type === 'vertical' && 'form-label-vertical'),
      style: {
        width: type === 'vertical' ? "".concat(labelWidth, "px") : ''
      }
    }, {
      children: jsx(Label, Object.assign({
        className: clsx('form-labe-text', tips && 'form-labe-text-hastips'),
        label: showLabel(),
        required: !!((_b = (_a = props === null || props === void 0 ? void 0 : props.rules) === null || _a === void 0 ? void 0 : _a.validate) === null || _b === void 0 ? void 0 : _b.required),
        tooltip: tips,
        tooltipIcon: disRequiredElement ? '' : requiredElement
      }, labelProps))
    })), jsxs(TypeLayout, {
      children: [jsx("div", Object.assign({
        className: "form-edit form-edit-".concat(name)
      }, {
        children: !props.children ? jsx(ItemType, Object.assign({
          setError: setError,
          error: !!errorMessage,
          itemType: InputType,
          backData: backData
        }, props, {
          setValue: setValue
        })) : props.children
      })), !hideError && jsx("div", Object.assign({
        className: "form-error form-error-".concat(name)
      }, {
        children: jsx(ErrorTips, {
          getSetError: function getSetError(fuc) {
            return setErrorTips.current = fuc;
          },
          helperTextProps: helperTextProps,
          errorMessage: errorMessage
        })
      }))]
    })]
  }));
};

export { FormItem as F, localeJson as l, validate as v };
