import _extends from "@babel/runtime/helpers/extends";
import * as React from 'react';
import { Header, Grid, GridColumn } from '@megafon/ui-core';
import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
import "./TextWithIcon.css";
var testIdPrefix = 'TextWithIcon';
var cn = cnCreate('mfui-text-with-icon');
var TextWithIcon = function TextWithIcon(_ref) {
  var title = _ref.title,
    rootRef = _ref.rootRef,
    dataAttrs = _ref.dataAttrs,
    className = _ref.className,
    _ref$isFullWidth = _ref.isFullWidth,
    isFullWidth = _ref$isFullWidth === void 0 ? false : _ref$isFullWidth,
    children = _ref.children;
  var renderContent = function renderContent() {
    return /*#__PURE__*/React.createElement(React.Fragment, null, title && /*#__PURE__*/React.createElement(Header, {
      className: cn('header'),
      as: "h5"
    }, title), children);
  };
  var renderContentWithGrid = function renderContentWithGrid() {
    return /*#__PURE__*/React.createElement(Grid, {
      dataAttrs: {
        container: {
          'data-testid': "".concat(testIdPrefix, "-grid")
        }
      }
    }, /*#__PURE__*/React.createElement(GridColumn, {
      mobile: '12',
      tablet: '7',
      desktop: '6',
      wide: '6'
    }, renderContent()));
  };
  return /*#__PURE__*/React.createElement("div", _extends({
    className: cn([className]),
    ref: rootRef
  }, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root)), isFullWidth ? renderContent() : renderContentWithGrid());
};
export default TextWithIcon;