import _extends from '@babel/runtime/helpers/extends';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import React__default from 'react';
import classnames from 'classnames';
import { SkeletonText } from '@carbon/react';
import { settings } from '../../constants/Settings.js';
import { ReadOnlyValuePropTypes, ReadOnlyValueDefaultProps } from './ReadOnlyValuePropTypes.js';

var iotPrefix = 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.createElement("div", {
    "data-testid": testId,
    className: classnames(className, "".concat(iotPrefix, "--read-only-value"), _defineProperty(_defineProperty(_defineProperty({}, "".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.createElement("label", {
    "data-testid": "".concat(testId, "--label"),
    htmlFor: "readonly-".concat(label)
  }, label, isLoading ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(SkeletonText, skeletonLoadingValue)) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, typeof value === 'string' ? /*#__PURE__*/React__default.createElement("textarea", _extends({}, textAreaAttributes, {
    "data-testid": "".concat(testId, "--value"),
    type: "text",
    id: "readonly-".concat(label),
    name: value,
    value: value,
    readOnly: true
  })) : /*#__PURE__*/React__default.createElement("div", {
    id: "readonly-".concat(label)
  }, value))));
};
ReadOnlyValue.propTypes = ReadOnlyValuePropTypes;
ReadOnlyValue.defaultProps = ReadOnlyValueDefaultProps;
ReadOnlyValue.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "ReadOnlyValue",
  "composes": ["./ReadOnlyValuePropTypes"]
};
var ReadOnlyValue$1 = ReadOnlyValue;

export { ReadOnlyValue$1 as default };
