'use strict';

var _extends = require('@babel/runtime/helpers/extends');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var React = require('react');
var classnames = require('classnames');
var react = require('@carbon/react');
var Settings = require('../../constants/Settings.js');
var ReadOnlyValuePropTypes = require('./ReadOnlyValuePropTypes.js');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var _extends__default = /*#__PURE__*/_interopDefault(_extends);
var _defineProperty__default = /*#__PURE__*/_interopDefault(_defineProperty);
var React__default = /*#__PURE__*/_interopDefault(React);
var classnames__default = /*#__PURE__*/_interopDefault(classnames);

var iotPrefix = Settings.settings.iotPrefix;
var ReadOnlyValue = function ReadOnlyValue(_ref) {
  var type = _ref.type,
    label = _ref.label,
    value = _ref.value,
    className = _ref.className,
    testId = _ref.testId,
    isLoading = _ref.isLoading,
    skeletonLoadingValue = _ref.skeletonLoadingValue,
    textAreaAttributes = _ref.textAreaAttributes;
  return /*#__PURE__*/React__default.default.createElement("div", {
    "data-testid": testId,
    className: classnames__default.default(className, "".concat(iotPrefix, "--read-only-value"), _defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default({}, "".concat(iotPrefix, "--read-only-value--loading"), isLoading), "".concat(iotPrefix, "--read-only-value__inline"), type === 'inline' || type === 'inline_small'), "".concat(iotPrefix, "--read-only-value__inline_small"), type === 'inline_small'))
  }, /*#__PURE__*/React__default.default.createElement("label", {
    "data-testid": "".concat(testId, "--label"),
    htmlFor: "readonly-".concat(label)
  }, label, isLoading ? /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, null, /*#__PURE__*/React__default.default.createElement(react.SkeletonText, skeletonLoadingValue)) : /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, null, typeof value === 'string' ? /*#__PURE__*/React__default.default.createElement("textarea", _extends__default.default({}, textAreaAttributes, {
    "data-testid": "".concat(testId, "--value"),
    type: "text",
    id: "readonly-".concat(label),
    name: value,
    value: value,
    readOnly: true
  })) : /*#__PURE__*/React__default.default.createElement("div", {
    id: "readonly-".concat(label)
  }, value))));
};
ReadOnlyValue.propTypes = ReadOnlyValuePropTypes.ReadOnlyValuePropTypes;
ReadOnlyValue.defaultProps = ReadOnlyValuePropTypes.ReadOnlyValueDefaultProps;
ReadOnlyValue.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "ReadOnlyValue",
  "composes": ["./ReadOnlyValuePropTypes"]
};
var ReadOnlyValue$1 = ReadOnlyValue;

module.exports = ReadOnlyValue$1;
