"use strict";

var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard");

var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");

var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");

require("core-js/modules/es.array.join");

_Object$defineProperty(exports, "__esModule", {
  value: true
});

exports.default = void 0;

var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));

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

var _reactIntl = require("react-intl");

var _strings = require("../utils/strings");

// @flow
var styles = {
  groupText: {
    color: 'rgba(0, 0, 0, 0.541176)'
  }
};
/*:: type Props = {
  field: Field
}*/

/** Formats a field name nicely */
var FormattedFieldname = function FormattedFieldname(_ref) {
  var field = _ref.field;

  var _useIntl = (0, _reactIntl.useIntl)(),
      locale = _useIntl.locale;

  var label = (0, _strings.getLocalizedFieldProp)(field, 'label', locale) || (0, _strings.fieldKeyToLabel)(field.key);

  if (typeof label === 'string') {
    return /*#__PURE__*/React.createElement("span", {
      title: label
    }, label);
  } else {
    var groupText = (0, _slice.default)(label).call(label, 0, label.length - 1).join(' / ') + ' / ';
    var fieldText = label[label.length - 1];
    return /*#__PURE__*/React.createElement("span", {
      title: groupText + fieldText
    }, /*#__PURE__*/React.createElement("span", {
      style: styles.groupText
    }, groupText), /*#__PURE__*/React.createElement("span", null, fieldText));
  }
};

var _default = FormattedFieldname;
exports.default = _default;
//# sourceMappingURL=FormattedFieldname.js.map