import React, { useContext } from 'react';
import ConfigContext from '../../../es/config-provider/ConfigContext';
import { BooleanValue, FieldType } from '../data-set/enum';
import Attachment from '../attachment/Attachment';
import { FuncType } from '../button/enum';
import { defaultRenderer } from '../field/utils';
import { ShowHelp } from '../field/enum';

var SimpleCheckBox = function SimpleCheckBox(props) {
  var checked = props.checked;

  var _useContext = useContext(ConfigContext),
      getProPrefixCls = _useContext.getProPrefixCls;

  var checkBoxPrefix = getProPrefixCls('checkbox');
  return /*#__PURE__*/React.createElement("label", {
    className: "".concat(checkBoxPrefix, "-wrapper ").concat(checkBoxPrefix, "-disabled")
  }, /*#__PURE__*/React.createElement("input", {
    disabled: true,
    className: checkBoxPrefix,
    type: "checkbox",
    checked: checked
  }), /*#__PURE__*/React.createElement("i", {
    className: "".concat(checkBoxPrefix, "-inner")
  }));
};

SimpleCheckBox.displayName = 'SimpleCheckBox';
export function defaultOutputRenderer(renderOption) {
  var value = renderOption.value,
      name = renderOption.name,
      record = renderOption.record;

  if (record) {
    var field = record.dataSet.getField(name);

    if (field) {
      if (field.get('type', record) === FieldType["boolean"]) {
        var checked = value === field.get(BooleanValue.trueValue, record);
        return /*#__PURE__*/React.createElement(SimpleCheckBox, {
          checked: checked
        });
      }

      if (field.get('type', record) === FieldType.attachment) {
        return /*#__PURE__*/React.createElement(Attachment, {
          readOnly: true,
          name: name,
          viewMode: "popup",
          record: record,
          funcType: FuncType.link,
          showHelp: ShowHelp.none
        });
      }
    }
  }

  return defaultRenderer(renderOption);
}
//# sourceMappingURL=utils.js.map
