"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _antd = require("antd");
var _Uploader = _interopRequireDefault(require("../Uploader"));
var _SpecIcon = _interopRequireDefault(require("../../SpecIcon"));
var _RefactorTreeSelect = _interopRequireDefault(require("./RefactorTreeSelect"));
var _DateTimeRangePicker = _interopRequireDefault(require("../DateTimeRangePicker"));
var _setReadonlyValues = require("./setReadonlyValues");
var _TitleNode = _interopRequireDefault(require("./TitleNode"));
var _ReUpload = _interopRequireDefault(require("./ReUpload"));
var _ExtensionField = _interopRequireDefault(require("./ExtensionField"));
var _ConfigContext = require("../../ConfigContext");
var _useLanguage = require("../../hooks/use-language");
var _utils = require("../../utils");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /* eslint-disable */ // @ts-ignore
// @ts-ignore
// import UploaderViewer from './UploaderViewer'
var TextArea = _antd.Input.TextArea,
  Password = _antd.Input.Password,
  Search = _antd.Input.Search;
var Option = _antd.Select.Option;
var RangePicker = _antd.DatePicker.RangePicker;
/**
 * 判断表单控件是否禁用
 *  优先按自己配置的 protoConfig.disabled = true > 然后才是  fieldStatus === 'disabled'
 *  @params {object} protoConfig
 *  @params {boolean} defaultDisabled
 * */
var setFieldDisabled = function setFieldDisabled(defaultDisabled, protoConfig) {
  if (protoConfig && protoConfig.hasOwnProperty('disabled')) {
    return protoConfig.disabled;
  }
  return defaultDisabled;
};

// 表单组件类型
// @ts-ignore
var FieldComponent = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
  var InitFanContext = (0, _react.useContext)(_ConfigContext.FanContext);
  var lang = (0, _useLanguage.useLanguageObject)(); // 当前使用的语言包
  var providerConfig = InitFanContext['Field'] || {}; // 使用上下文（全局配置）设置扩展的配置项
  var _providerConfig$props = _objectSpread(_objectSpread({}, providerConfig), props),
    type = _providerConfig$props.type,
    _onChange = _providerConfig$props.onChange,
    value = _providerConfig$props.value,
    style = _providerConfig$props.style,
    placeholder = _providerConfig$props.placeholder,
    protoConfig = _providerConfig$props.protoConfig,
    _providerConfig$props2 = _providerConfig$props.treeData,
    treeData = _providerConfig$props2 === void 0 ? [] : _providerConfig$props2,
    filedName = _providerConfig$props.filedName,
    fieldName = _providerConfig$props.fieldName,
    _providerConfig$props3 = _providerConfig$props.selectOptionName,
    selectOptionName = _providerConfig$props3 === void 0 ? {
      value: 'value',
      label: 'label',
      disabled: 'disabled',
      title: 'title'
    } : _providerConfig$props3,
    _providerConfig$props4 = _providerConfig$props.treeOptionName,
    treeOptionName = _providerConfig$props4 === void 0 ? {
      title: 'title',
      value: 'value',
      children: 'children',
      disabled: 'disabled'
    } : _providerConfig$props4,
    _providerConfig$props5 = _providerConfig$props.fieldStatus,
    fieldStatus = _providerConfig$props5 === void 0 ? 'default' : _providerConfig$props5,
    _providerConfig$props6 = _providerConfig$props.size,
    size = _providerConfig$props6 === void 0 ? 'middle' : _providerConfig$props6,
    showFullLevel = _providerConfig$props.showFullLevel,
    separator = _providerConfig$props.separator,
    disabledFields = _providerConfig$props.disabledFields,
    selectOptionRender = _providerConfig$props.selectOptionRender,
    render = _providerConfig$props.render,
    _providerConfig$props7 = _providerConfig$props.defaultStyle,
    defaultStyle = _providerConfig$props7 === void 0 ? {} : _providerConfig$props7,
    extendConfig = _providerConfig$props.extendConfig;
  var _providerConfig$props8 = _objectSpread(_objectSpread({}, providerConfig), props),
    selectOptions = _providerConfig$props8.selectOptions;
  var providerProtoConfig = (InitFanContext === null || InitFanContext === void 0 ? void 0 : InitFanContext[type || '']) || {}; // 使用上下文（全局配置）设置控件扩展的配置项
  var compContent;
  if (selectOptionName && selectOptions) {
    // 将传值的数据进行转换
    selectOptions = selectOptions.map(function (item) {
      return _objectSpread(_objectSpread({}, item), {}, {
        value: item[selectOptionName.value || 'value'],
        label: item[selectOptionName.label || 'label'],
        disabled: item[selectOptionName.disabled || 'disabled'],
        title: item[selectOptionName.title || 'title']
      });
    });
  }
  var defaultProps = _objectSpread(_objectSpread({
    style: style,
    onChange: _onChange,
    value: value,
    render: render,
    size: size,
    ref: ref
  }, providerProtoConfig), protoConfig);
  defaultProps.disabled = setFieldDisabled(fieldStatus === 'disabled', protoConfig);
  var sortLimitRule = {}; // 排序字段长度限制
  if (filedName === 'sorts' || filedName === 'sort' || filedName === 'indexSort' || filedName === 'sorta' || filedName === 'categorySort' || fieldName === 'sorts' || fieldName === 'sort' || fieldName === 'indexSort' || fieldName === 'sorta' || fieldName === 'categorySort') {
    sortLimitRule = {
      min: 0,
      max: 999999999,
      maxLength: 9
    };
  }
  // 设置纯展示模式下的“下拉树”控件返回值
  var viewOnly = fieldStatus === 'viewOnly'; // 是否纯展示
  // 输入框显示的placeholder
  var inputPlaceholder = setFieldDisabled(fieldStatus === 'disabled', protoConfig) ? '' : defaultProps.placeholder || placeholder || (lang === null || lang === void 0 ? void 0 : lang['field.input.placeholder']) || '请输入';
  switch (type) {
    case 'input':
      compContent = viewOnly ? (0, _setReadonlyValues.setInputValue)(value, _objectSpread(_objectSpread({}, defaultProps), {}, {
        type: type
      })) : /*#__PURE__*/_react.default.createElement(_antd.Input, _extends({
        placeholder: inputPlaceholder,
        autoComplete: "off",
        title: setFieldDisabled(fieldStatus === 'disabled', protoConfig) ? value : null,
        maxLength: defaultProps.maxLength || 50
        // onKeyDown={(evt) => {
        //   if (evt.key === 'Enter') {
        //     // 表单只有一个输入框时，焦点定到输入框后按下Enter会触发提交事件
        //     evt.preventDefault();  // 禁止默认行为
        //   }
        // }}
      }, (0, _utils.excludeProps)(defaultProps, 'viewOnlyHides'), {
        style: _objectSpread(_objectSpread({}, defaultStyle), defaultProps.style)
      }));
      break;
    case 'password':
      compContent = viewOnly ? value ? "\u25CF\u25CF\u25CF\u25CF\u25CF\u25CF" : '-' : /*#__PURE__*/_react.default.createElement(Password, _extends({
        autoComplete: "off",
        placeholder: inputPlaceholder,
        maxLength: defaultProps.maxLength || 50
      }, defaultProps, {
        style: _objectSpread(_objectSpread({}, defaultStyle), defaultProps.style)
      }));
      break;
    case 'textarea':
      compContent = viewOnly ? value || '-' : /*#__PURE__*/_react.default.createElement(TextArea, _extends({
        placeholder: inputPlaceholder,
        maxLength: defaultProps.maxLength || 500,
        title: setFieldDisabled(fieldStatus === 'disabled', protoConfig) ? value : null
      }, defaultProps, {
        style: _objectSpread(_objectSpread({}, defaultStyle), defaultProps.style)
      }));
      break;
    case 'inputNumber':
      compContent = viewOnly ? (0, _setReadonlyValues.setInputValue)(value, _objectSpread(_objectSpread({}, defaultProps), {}, {
        type: type
      })) : /*#__PURE__*/_react.default.createElement(_antd.InputNumber, _extends({
        placeholder: setFieldDisabled(fieldStatus === 'disabled', protoConfig) ? '' : defaultProps.placeholder || placeholder || (lang === null || lang === void 0 ? void 0 : lang['field.inputNumber.placeholder']) || '请输入数字'
      }, sortLimitRule, (0, _utils.excludeProps)(defaultProps, 'viewOnlyHides'), {
        style: _objectSpread(_objectSpread({}, defaultStyle), defaultProps.style) // 去掉width: '120px',
      }));
      break;
    case 'search':
      compContent = viewOnly ? (0, _setReadonlyValues.setInputValue)(value, _objectSpread(_objectSpread({}, defaultProps), {}, {
        type: type
      })) : /*#__PURE__*/_react.default.createElement(Search, _extends({
        placeholder: inputPlaceholder,
        title: setFieldDisabled(fieldStatus === 'disabled', protoConfig) ? value : null,
        maxLength: defaultProps.maxLength || 50
      }, (0, _utils.excludeProps)(defaultProps, 'viewOnlyHides'), {
        style: _objectSpread(_objectSpread({}, defaultStyle), defaultProps.style)
      }));
      break;
    case 'select':
      // 重置返回完整字段值
      var resetResultOption = function resetResultOption(Option) {
        if (!Option) return Option;
        if (Array.isArray(Option)) return (selectOptions || []).filter(function (childOpt) {
          return Option.filter(function (optItem) {
            return childOpt.value === optItem.value;
          }).length > 0;
        }); // 数据为数组
        var extraParam = (selectOptions || []).filter(function (childOpt) {
          return childOpt.value === Option.value;
        })[0];
        return _objectSpread(_objectSpread({}, Option), extraParam);
      };
      compContent = viewOnly ? (0, _setReadonlyValues.setSelectValue)(value, {
        selectOptions: selectOptions,
        selectOptionRender: selectOptionRender,
        defaultProps: defaultProps,
        type: type
      }) : /*#__PURE__*/_react.default.createElement(_antd.Select, _extends({
        allowClear: true,
        placeholder: setFieldDisabled(fieldStatus === 'disabled', protoConfig) ? '' : defaultProps.placeholder || placeholder || "".concat(defaultProps.showSearch ? (lang === null || lang === void 0 ? void 0 : lang['field.select.search.placeholder']) || '请输入选择' : (lang === null || lang === void 0 ? void 0 : lang['field.select.placeholder']) || '请选择'),
        filterOption: function filterOption(inputValue, option) {
          var _defaultProps$fieldNa;
          return defaultProps.showSearch ? ((option === null || option === void 0 ? void 0 : option[(defaultProps === null || defaultProps === void 0 || (_defaultProps$fieldNa = defaultProps.fieldNames) === null || _defaultProps$fieldNa === void 0 ? void 0 : _defaultProps$fieldNa.label) || (selectOptionName === null || selectOptionName === void 0 ? void 0 : selectOptionName.label) || 'label']) || '').toLowerCase().includes(inputValue.toLowerCase()) : false;
        },
        value: value,
        fieldNames: (defaultProps === null || defaultProps === void 0 ? void 0 : defaultProps.fieldNames) || selectOptionName,
        options: selectOptions,
        optionRender: function optionRender(option, info) {
          var _defaultProps$optionR;
          return (defaultProps === null || defaultProps === void 0 || (_defaultProps$optionR = defaultProps.optionRender) === null || _defaultProps$optionR === void 0 ? void 0 : _defaultProps$optionR.call(defaultProps, _objectSpread(_objectSpread({}, option.data), option), info)) || (selectOptionRender === null || selectOptionRender === void 0 ? void 0 : selectOptionRender(_objectSpread(_objectSpread({}, option.data), option), info)) || option.label;
        }
      }, defaultProps, {
        style: _objectSpread(_objectSpread({}, defaultStyle), defaultProps.style)
        // onChange返回参数：累加当前选中包括其他字段值的数据
        ,
        onChange: function onChange(value, Option) {
          return _onChange && _onChange(value, resetResultOption(Option));
        } // 数据为对象
      }));
      break;
    case 'tree-select':
      compContent = /*#__PURE__*/_react.default.createElement(_RefactorTreeSelect.default, _extends({
        treeData: treeData,
        treeOptionName: treeOptionName,
        allowClear: true,
        separator: separator,
        showFullLevel: showFullLevel,
        placeholder: setFieldDisabled(fieldStatus === 'disabled', protoConfig) ? '' : defaultProps.placeholder || placeholder || (lang === null || lang === void 0 ? void 0 : lang['field.select.placeholder']) || '请选择',
        protoTreeNode: protoConfig && protoConfig.TreeNode || {},
        fieldStatus: fieldStatus,
        disabledFields: disabledFields,
        filedName: filedName
      }, defaultProps, {
        style: _objectSpread(_objectSpread({}, defaultStyle), defaultProps.style)
      }));
      break;
    case 'checkbox':
      delete defaultProps.ref;
      compContent = viewOnly ? (0, _setReadonlyValues.setSelectValue)(value, {
        selectOptions: selectOptions,
        selectOptionRender: selectOptionRender,
        defaultProps: defaultProps,
        separator: separator
      }) : /*#__PURE__*/_react.default.createElement(_antd.Checkbox.Group, _extends({}, defaultProps, {
        style: _objectSpread(_objectSpread({}, defaultStyle), {}, {
          width: 'auto'
        }, defaultProps.style)
      }), selectOptions && selectOptions.map(function (val, index) {
        return /*#__PURE__*/_react.default.createElement(_antd.Checkbox, {
          value: val.value,
          key: val.value || index
          // @ts-ignore
          ,
          title: (0, _TitleNode.default)({
            render: selectOptionRender,
            data: val
          })
          // title={selectOptionRender ? selectOptionRender(val) : (val.title || val.label)}
          ,
          disabled: val.disabled
        }, selectOptionRender ? selectOptionRender(val) : val.label);
      }));
      break;
    case 'radio':
      delete defaultProps.ref;
      compContent = viewOnly ? (0, _setReadonlyValues.setSelectValue)(value, {
        selectOptions: selectOptions,
        selectOptionRender: selectOptionRender,
        defaultProps: defaultProps
      }) : /*#__PURE__*/_react.default.createElement(_antd.Radio.Group, _extends({
        options: (selectOptions || []).map(function (val) {
          return _objectSpread(_objectSpread({}, val), {}, {
            label: selectOptionRender ? selectOptionRender(val) : val.label
          });
        })
      }, defaultProps, {
        style: _objectSpread(_objectSpread({}, defaultStyle), {}, {
          width: 'auto'
        }, defaultProps.style)
      }));
      break;
    case 'datePicker': // 使用配置 picker设置其属于week,month,year
    case 'dateTimePicker':
      compContent = viewOnly ? (0, _setReadonlyValues.setDatePickerValue)(value, {
        type: type,
        protoConfig: protoConfig
      }) : /*#__PURE__*/_react.default.createElement(_antd.DatePicker, _extends({
        showTime: defaultProps.showTime || type === 'dateTimePicker',
        placeholder: setFieldDisabled(fieldStatus === 'disabled', protoConfig) ? '' : defaultProps.placeholder || placeholder || (lang === null || lang === void 0 ? void 0 : lang['field.calendar.placeholder']) || '请选择'
      }, defaultProps, {
        style: _objectSpread(_objectSpread({
          width: 'auto'
        }, defaultStyle), defaultProps.style)
      }));
      break;
    case 'rangePicker':
    case 'rangeTimePicker':
      if (setFieldDisabled(fieldStatus === 'disabled', protoConfig)) defaultProps.placeholder = ''; // 禁用时，placeHolder不显示
      compContent = viewOnly ? (0, _setReadonlyValues.setDatePickerValue)(value, {
        type: type,
        protoConfig: protoConfig
      }) : /*#__PURE__*/_react.default.createElement(RangePicker, _extends({
        showTime: defaultProps.showTime || type === 'rangeTimePicker',
        allowEmpty: true
      }, defaultProps, {
        // style={{  width: type === 'rangeTimePicker' ? 'auto' : '100%', ...defaultStyle,...defaultProps.style }}
        style: _objectSpread(_objectSpread({}, defaultStyle), defaultProps.style)
      }));
      break;
    case 'timePicker':
      if (setFieldDisabled(fieldStatus === 'disabled', protoConfig)) defaultProps.placeholder = ''; // 禁用时，placeHolder不显示
      compContent = viewOnly ? (0, _setReadonlyValues.setTimePickerValue)(value, {
        type: type,
        protoConfig: protoConfig
      }) : /*#__PURE__*/_react.default.createElement(_antd.TimePicker, _extends({}, defaultProps, {
        style: _objectSpread(_objectSpread({}, defaultStyle), defaultProps.style) // 去掉 width: 'auto'
      }));
      break;
    case 'timePickerRange':
      if (setFieldDisabled(fieldStatus === 'disabled', protoConfig)) defaultProps.placeholder = ''; // 禁用时，placeHolder不显示
      // @ts-ignore
      compContent = viewOnly ? (0, _setReadonlyValues.setTimePickerValue)(value, {
        type: type,
        protoConfig: protoConfig
      }) : /*#__PURE__*/_react.default.createElement(_antd.TimePicker.RangePicker, _extends({
        allowEmpty: true
      }, defaultProps, {
        style: _objectSpread(_objectSpread({}, defaultStyle), defaultProps.style)
      }));
      break;
    case 'dateTimeRangePicker':
      compContent = viewOnly ? (0, _setReadonlyValues.setDatePickerValue)(value === null || value === void 0 ? void 0 : value.dateTime, {
        type: 'rangeTimePicker',
        protoConfig: protoConfig
      }) : /*#__PURE__*/_react.default.createElement(_DateTimeRangePicker.default, _extends({}, defaultProps, {
        style: _objectSpread(_objectSpread({}, defaultStyle), {}, {
          width: 'auto'
        }, defaultProps.style)
      }));
      break;
    case 'upload':
      compContent = viewOnly && (!value || value.length === 0) ? '-' : /*#__PURE__*/_react.default.createElement(_ReUpload.default, _extends({}, defaultProps, {
        viewOnly: viewOnly,
        disabled: setFieldDisabled(viewOnly || fieldStatus === 'disabled', protoConfig)
      }), defaultProps.children ? defaultProps.children : defaultProps.fileList && defaultProps.fileList.length >= 1 || defaultProps.defaultFileList && defaultProps.defaultFileList.length >= 1 ? null : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, defaultProps.listType === 'picture-card' ? /*#__PURE__*/_react.default.createElement("div", {
        className: 'spec-uploader-control'
      }, /*#__PURE__*/_react.default.createElement(_SpecIcon.default, {
        name: "plus"
      }), /*#__PURE__*/_react.default.createElement("div", {
        className: "ant-upload-text"
      }, (lang === null || lang === void 0 ? void 0 : lang['field.upload.select']) || '点击选择')) : /*#__PURE__*/_react.default.createElement(_antd.Button, null, /*#__PURE__*/_react.default.createElement(_SpecIcon.default, {
        name: "upload"
      }), " ", (lang === null || lang === void 0 ? void 0 : lang['field.upload.import']) || '点击上传')));
      break;
    case 'uploader':
      // compContent = viewOnly ? <UploaderViewer value={value}/> : <Uploader {...defaultProps} size={protoConfig?.size}/>
      if (!(protoConfig !== null && protoConfig !== void 0 && protoConfig.hasOwnProperty('size'))) {
        delete defaultProps.size; // 需要做移除，不然可能值会为'md''sm''lg'等字符串
      }
      compContent = /*#__PURE__*/_react.default.createElement(_Uploader.default, _extends({}, defaultProps, {
        viewOnly: viewOnly
      }));
      break;
    case 'cascader':
      compContent = viewOnly ? (0, _setReadonlyValues.setCascaderValue)(value, {
        selectOptions: selectOptions,
        selectOptionRender: selectOptionRender,
        defaultProps: defaultProps
      }) : /*#__PURE__*/_react.default.createElement(_antd.Cascader, _extends({
        options: selectOptions,
        allowClear: true,
        fieldNames: (defaultProps === null || defaultProps === void 0 ? void 0 : defaultProps.fieldNames) || selectOptionName,
        placeholder: setFieldDisabled(fieldStatus === 'disabled', protoConfig) ? '' : defaultProps.placeholder || placeholder || (lang === null || lang === void 0 ? void 0 : lang['field.select.placeholder']) || '请选择'
      }, defaultProps, {
        style: _objectSpread(_objectSpread({}, defaultStyle), defaultProps.style)
      }));
      break;
    case 'switch':
      // 只读情况下禁用
      compContent = /*#__PURE__*/_react.default.createElement(_antd.Switch, _extends({}, defaultProps, {
        disabled: setFieldDisabled(viewOnly || fieldStatus === 'disabled', protoConfig),
        checked: value,
        style: _objectSpread(_objectSpread({}, defaultProps.style), {}, {
          width: 'auto'
        })
      }));
      // compContent = viewOnly ? (String(value) === 'undefined' ? '-' : String(value)) : (<Switch {...defaultProps} checked={value} style={{ ...defaultProps.style, width: 'auto' }} />)
      break;
    case 'slider':
      compContent = viewOnly ? value : /*#__PURE__*/_react.default.createElement(_antd.Slider, _extends({}, defaultProps, {
        style: _objectSpread(_objectSpread({}, defaultStyle), defaultProps.style)
      }));
      break;
    case 'mentions':
      compContent = viewOnly ? (0, _setReadonlyValues.setInputValue)(value, _objectSpread(_objectSpread({}, defaultProps), {}, {
        type: type
      })) : /*#__PURE__*/_react.default.createElement(_antd.Mentions, _extends({
        placeholder: "".concat((lang === null || lang === void 0 ? void 0 : lang['field.mentions.input.placeholder']) || '请输入', " ").concat(defaultProps.prefix || '@', " ").concat((lang === null || lang === void 0 ? void 0 : lang['field.mentions.select.placeholder']) || '选择', " "),
        options: (selectOptions || []).map(function (val) {
          return _objectSpread(_objectSpread({}, val), {}, {
            label: selectOptionRender ? selectOptionRender(val) : val.label
          });
        })
      }, (0, _utils.excludeProps)(defaultProps, 'viewOnlyHides'), {
        style: _objectSpread(_objectSpread({}, defaultStyle), defaultProps.style)
      }));
      break;
    case 'rate':
      compContent = /*#__PURE__*/_react.default.createElement(_antd.Rate, _extends({}, defaultProps, {
        disabled: setFieldDisabled(viewOnly || fieldStatus === 'disabled', protoConfig),
        style: _objectSpread(_objectSpread({}, defaultStyle), {}, {
          width: 'auto'
        }, defaultProps.style)
      }));
      break;
    case 'colorPicker':
      delete defaultProps.ref;
      compContent = /*#__PURE__*/_react.default.createElement(_antd.ColorPicker, _extends({}, defaultProps, {
        disabled: setFieldDisabled(viewOnly || fieldStatus === 'disabled', protoConfig),
        style: _objectSpread(_objectSpread({}, defaultStyle), {}, {
          width: 'auto'
        }, defaultProps.style)
      }));
      break;
    case 'custom':
      compContent = defaultProps.render && defaultProps.render(props) || defaultProps.customRender && defaultProps.customRender(props) || null;
      break;
    // case 'extends':
    //   compContent =  <ExtensionField {...props} {...defaultProps}/>
    //   break;
    default:
      // 扩展组件
      if (((providerConfig === null || providerConfig === void 0 ? void 0 : providerConfig.extendComponents) || []).some(function (tItem) {
        return tItem.extendType === props.type;
      })) {
        compContent = /*#__PURE__*/_react.default.createElement(_ExtensionField.default, _extends({}, props, defaultProps, {
          extendType: type
        }));
        // const MatchType = (extendComponents || []).find((tItem: FieldExtendsTypeType) => tItem.extendType === type)
        // const MatchTypeComponent = MatchType?.component
        // // const { type, ...fieldProps } = { ...props }
        // console.log('fieldProps',  props, defaultProps)
        // return typeof MatchTypeComponent === 'function'
        //   ? <MatchTypeComponent ref={ref} fieldProps={props} proptoConfig={protoConfig} extendConfig={Object.assign(extendConfig || {}, MatchType?.extendConfig || {})}/>
        //   : MatchTypeComponent
        //
        // const MatchType = (providerConfig?.extendComponents || []).find((tItem: FieldExtendsTypeType) => tItem.extendType === props.type)
        // const MatchTypeComponent = MatchType?.component
        // const { type, ...fieldProps } = props
        // compContent = typeof MatchTypeComponent === 'function'
        //   ? <MatchTypeComponent {...fieldProps}/>
        //   : MatchTypeComponent
      } else {
        compContent = value;
      }
      break;
  }
  return compContent;
});
var _default = exports.default = FieldComponent; //
// // 高阶组件
// const withLibraryInjection = (LibraryComponent) => (WrappedComponent) => {
//   return class InjectedComponent extends React.Component {
//     render() {
//       return (
//         <>
//           <LibraryComponent {...this.props} children={<WrappedComponent {...this.props} />}/>
//         </>
//       );
//     }
//   };
// };
//
//
// // 应用HOC
// const MyComponentWithLibrary = withLibraryInjection(FieldComponent)(ExtensionField);
//
//
// export default MyComponentWithLibrary