"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.defaultOutputRenderer = defaultOutputRenderer;

var _react = _interopRequireWildcard(require("react"));

var _ConfigContext = _interopRequireDefault(require("../../../lib/config-provider/ConfigContext"));

var _enum = require("../data-set/enum");

var _Attachment = _interopRequireDefault(require("../attachment/Attachment"));

var _enum2 = require("../button/enum");

var _utils = require("../field/utils");

var _enum3 = require("../field/enum");

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

  var _useContext = (0, _react.useContext)(_ConfigContext["default"]),
      getProPrefixCls = _useContext.getProPrefixCls;

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

SimpleCheckBox.displayName = 'SimpleCheckBox';

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) === _enum.FieldType["boolean"]) {
        var checked = value === field.get(_enum.BooleanValue.trueValue, record);
        return /*#__PURE__*/_react["default"].createElement(SimpleCheckBox, {
          checked: checked
        });
      }

      if (field.get('type', record) === _enum.FieldType.attachment) {
        return /*#__PURE__*/_react["default"].createElement(_Attachment["default"], {
          readOnly: true,
          name: name,
          viewMode: "popup",
          record: record,
          funcType: _enum2.FuncType.link,
          showHelp: _enum3.ShowHelp.none
        });
      }
    }
  }

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